commit dee3fe5266e9e17a4783df797333b86677e7e2c7 Author: Branimir Karadzic Date: Tue Apr 3 20:30:07 2012 -0700 Initial commit. diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..021b2a497 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.build + diff --git a/3rdparty/compiler/mingw/alloca.h b/3rdparty/compiler/mingw/alloca.h new file mode 100644 index 000000000..2da04def3 --- /dev/null +++ b/3rdparty/compiler/mingw/alloca.h @@ -0,0 +1,6 @@ +#ifndef __MINGW32__ALLOCA_H__ +#define __MINGW32__ALLOCA_H__ + +#include + +#endif // __MINGW32__ALLOCA_H__ diff --git a/3rdparty/compiler/mingw/sal.h b/3rdparty/compiler/mingw/sal.h new file mode 100644 index 000000000..ab235049b --- /dev/null +++ b/3rdparty/compiler/mingw/sal.h @@ -0,0 +1,252 @@ +#pragma once + +#if __GNUC__ >=3 +#pragma GCC system_header +#endif + +//#define __null // << Conflicts with GCC internal type __null +#define __notnull +#define __maybenull +#define __readonly +#define __notreadonly +#define __maybereadonly +#define __valid +#define __notvalid +#define __maybevalid +#define __readableTo(extent) +#define __elem_readableTo(size) +#define __byte_readableTo(size) +#define __writableTo(size) +#define __elem_writableTo(size) +#define __byte_writableTo(size) +#define __deref +#define __pre +#define __post +#define __precond(expr) +#define __postcond(expr) +#define __exceptthat +#define __execeptthat +#define __inner_success(expr) +#define __inner_checkReturn +#define __inner_typefix(ctype) +#define __inner_override +#define __inner_callback +#define __inner_blocksOn(resource) +#define __inner_fallthrough_dec +#define __inner_fallthrough +#define __refparam +#define __inner_control_entrypoint(category) +#define __inner_data_entrypoint(category) + +#define __ecount(size) +#define __bcount(size) +#define __in +#define __in_ecount(size) +#define __in_bcount(size) +#define __in_z +#define __in_ecount_z(size) +#define __in_bcount_z(size) +#define __in_nz +#define __in_ecount_nz(size) +#define __in_bcount_nz(size) +#define __out +#define __out_ecount(size) +#define __out_bcount(size) +#define __out_ecount_part(size,length) +#define __out_bcount_part(size,length) +#define __out_ecount_full(size) +#define __out_bcount_full(size) +#define __out_z +#define __out_z_opt +#define __out_ecount_z(size) +#define __out_bcount_z(size) +#define __out_ecount_part_z(size,length) +#define __out_bcount_part_z(size,length) +#define __out_ecount_full_z(size) +#define __out_bcount_full_z(size) +#define __out_nz +#define __out_nz_opt +#define __out_ecount_nz(size) +#define __out_bcount_nz(size) +#define __inout +#define __inout_ecount(size) +#define __inout_bcount(size) +#define __inout_ecount_part(size,length) +#define __inout_bcount_part(size,length) +#define __inout_ecount_full(size) +#define __inout_bcount_full(size) +#define __inout_z +#define __inout_ecount_z(size) +#define __inout_bcount_z(size) +#define __inout_nz +#define __inout_ecount_nz(size) +#define __inout_bcount_nz(size) +#define __ecount_opt(size) +#define __bcount_opt(size) +#define __in_opt +#define __in_ecount_opt(size) +#define __in_bcount_opt(size) +#define __in_z_opt +#define __in_ecount_z_opt(size) +#define __in_bcount_z_opt(size) +#define __in_nz_opt +#define __in_ecount_nz_opt(size) +#define __in_bcount_nz_opt(size) +#define __out_opt +#define __out_ecount_opt(size) +#define __out_bcount_opt(size) +#define __out_ecount_part_opt(size,length) +#define __out_bcount_part_opt(size,length) +#define __out_ecount_full_opt(size) +#define __out_bcount_full_opt(size) +#define __out_ecount_z_opt(size) +#define __out_bcount_z_opt(size) +#define __out_ecount_part_z_opt(size,length) +#define __out_bcount_part_z_opt(size,length) +#define __out_ecount_full_z_opt(size) +#define __out_bcount_full_z_opt(size) +#define __out_ecount_nz_opt(size) +#define __out_bcount_nz_opt(size) +#define __inout_opt +#define __inout_ecount_opt(size) +#define __inout_bcount_opt(size) +#define __inout_ecount_part_opt(size,length) +#define __inout_bcount_part_opt(size,length) +#define __inout_ecount_full_opt(size) +#define __inout_bcount_full_opt(size) +#define __inout_z_opt +#define __inout_ecount_z_opt(size) +#define __inout_ecount_z_opt(size) +#define __inout_bcount_z_opt(size) +#define __inout_nz_opt +#define __inout_ecount_nz_opt(size) +#define __inout_bcount_nz_opt(size) +#define __deref_ecount(size) +#define __deref_bcount(size) +#define __deref_out +#define __deref_out_ecount(size) +#define __deref_out_bcount(size) +#define __deref_out_ecount_part(size,length) +#define __deref_out_bcount_part(size,length) +#define __deref_out_ecount_full(size) +#define __deref_out_bcount_full(size) +#define __deref_out_z +#define __deref_out_ecount_z(size) +#define __deref_out_bcount_z(size) +#define __deref_out_nz +#define __deref_out_ecount_nz(size) +#define __deref_out_bcount_nz(size) +#define __deref_inout +#define __deref_inout_z +#define __deref_inout_ecount(size) +#define __deref_inout_bcount(size) +#define __deref_inout_ecount_part(size,length) +#define __deref_inout_bcount_part(size,length) +#define __deref_inout_ecount_full(size) +#define __deref_inout_bcount_full(size) +#define __deref_inout_z +#define __deref_inout_ecount_z(size) +#define __deref_inout_bcount_z(size) +#define __deref_inout_nz +#define __deref_inout_ecount_nz(size) +#define __deref_inout_bcount_nz(size) +#define __deref_ecount_opt(size) +#define __deref_bcount_opt(size) +#define __deref_out_opt +#define __deref_out_ecount_opt(size) +#define __deref_out_bcount_opt(size) +#define __deref_out_ecount_part_opt(size,length) +#define __deref_out_bcount_part_opt(size,length) +#define __deref_out_ecount_full_opt(size) +#define __deref_out_bcount_full_opt(size) +#define __deref_out_z_opt +#define __deref_out_ecount_z_opt(size) +#define __deref_out_bcount_z_opt(size) +#define __deref_out_nz_opt +#define __deref_out_ecount_nz_opt(size) +#define __deref_out_bcount_nz_opt(size) +#define __deref_inout_opt +#define __deref_inout_ecount_opt(size) +#define __deref_inout_bcount_opt(size) +#define __deref_inout_ecount_part_opt(size,length) +#define __deref_inout_bcount_part_opt(size,length) +#define __deref_inout_ecount_full_opt(size) +#define __deref_inout_bcount_full_opt(size) +#define __deref_inout_z_opt +#define __deref_inout_ecount_z_opt(size) +#define __deref_inout_bcount_z_opt(size) +#define __deref_inout_nz_opt +#define __deref_inout_ecount_nz_opt(size) +#define __deref_inout_bcount_nz_opt(size) +#define __deref_opt_ecount(size) +#define __deref_opt_bcount(size) +#define __deref_opt_out +#define __deref_opt_out_z +#define __deref_opt_out_ecount(size) +#define __deref_opt_out_bcount(size) +#define __deref_opt_out_ecount_part(size,length) +#define __deref_opt_out_bcount_part(size,length) +#define __deref_opt_out_ecount_full(size) +#define __deref_opt_out_bcount_full(size) +#define __deref_opt_inout +#define __deref_opt_inout_ecount(size) +#define __deref_opt_inout_bcount(size) +#define __deref_opt_inout_ecount_part(size,length) +#define __deref_opt_inout_bcount_part(size,length) +#define __deref_opt_inout_ecount_full(size) +#define __deref_opt_inout_bcount_full(size) +#define __deref_opt_inout_z +#define __deref_opt_inout_ecount_z(size) +#define __deref_opt_inout_bcount_z(size) +#define __deref_opt_inout_nz +#define __deref_opt_inout_ecount_nz(size) +#define __deref_opt_inout_bcount_nz(size) +#define __deref_opt_ecount_opt(size) +#define __deref_opt_bcount_opt(size) +#define __deref_opt_out_opt +#define __deref_opt_out_ecount_opt(size) +#define __deref_opt_out_bcount_opt(size) +#define __deref_opt_out_ecount_part_opt(size,length) +#define __deref_opt_out_bcount_part_opt(size,length) +#define __deref_opt_out_ecount_full_opt(size) +#define __deref_opt_out_bcount_full_opt(size) +#define __deref_opt_out_z_opt +#define __deref_opt_out_ecount_z_opt(size) +#define __deref_opt_out_bcount_z_opt(size) +#define __deref_opt_out_nz_opt +#define __deref_opt_out_ecount_nz_opt(size) +#define __deref_opt_out_bcount_nz_opt(size) +#define __deref_opt_inout_opt +#define __deref_opt_inout_ecount_opt(size) +#define __deref_opt_inout_bcount_opt(size) +#define __deref_opt_inout_ecount_part_opt(size,length) +#define __deref_opt_inout_bcount_part_opt(size,length) +#define __deref_opt_inout_ecount_full_opt(size) +#define __deref_opt_inout_bcount_full_opt(size) +#define __deref_opt_inout_z_opt +#define __deref_opt_inout_ecount_z_opt(size) +#define __deref_opt_inout_bcount_z_opt(size) +#define __deref_opt_inout_nz_opt +#define __deref_opt_inout_ecount_nz_opt(size) +#define __deref_opt_inout_bcount_nz_opt(size) + +#define __success(expr) +#define __nullterminated +#define __nullnullterminated +#define __reserved +#define __checkReturn +#define __typefix(ctype) +#define __override +#define __callback +#define __format_string +#define __blocksOn(resource) +#define __control_entrypoint(category) +#define __data_entrypoint(category) + +#ifndef __fallthrough + #define __fallthrough __inner_fallthrough +#endif + +#ifndef __analysis_assume + #define __analysis_assume(expr) +#endif diff --git a/3rdparty/compiler/mingw/specstrings_strict.h b/3rdparty/compiler/mingw/specstrings_strict.h new file mode 100644 index 000000000..982dd201c --- /dev/null +++ b/3rdparty/compiler/mingw/specstrings_strict.h @@ -0,0 +1 @@ +#define __reserved diff --git a/3rdparty/compiler/mingw/specstrings_undef.h b/3rdparty/compiler/mingw/specstrings_undef.h new file mode 100644 index 000000000..69d431556 --- /dev/null +++ b/3rdparty/compiler/mingw/specstrings_undef.h @@ -0,0 +1,2 @@ +#undef __reserved + diff --git a/3rdparty/compiler/mingw/unordered_map b/3rdparty/compiler/mingw/unordered_map new file mode 100644 index 000000000..22f82dd0d --- /dev/null +++ b/3rdparty/compiler/mingw/unordered_map @@ -0,0 +1 @@ +#include diff --git a/3rdparty/compiler/msvc/inttypes.h b/3rdparty/compiler/msvc/inttypes.h new file mode 100644 index 000000000..25542771f --- /dev/null +++ b/3rdparty/compiler/msvc/inttypes.h @@ -0,0 +1,305 @@ +// ISO C9x compliant inttypes.h for Microsoft Visual Studio +// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 +// +// Copyright (c) 2006 Alexander Chemeris +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// 1. Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// 3. The name of the author may be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED +// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +/////////////////////////////////////////////////////////////////////////////// + +#ifndef _MSC_VER // [ +#error "Use this header only with Microsoft Visual C++ compilers!" +#endif // _MSC_VER ] + +#ifndef _MSC_INTTYPES_H_ // [ +#define _MSC_INTTYPES_H_ + +#if _MSC_VER > 1000 +#pragma once +#endif + +#include "stdint.h" + +// 7.8 Format conversion of integer types + +typedef struct { + intmax_t quot; + intmax_t rem; +} imaxdiv_t; + +// 7.8.1 Macros for format specifiers + +#if !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS) // [ See footnote 185 at page 198 + +// The fprintf macros for signed integers are: +#define PRId8 "d" +#define PRIi8 "i" +#define PRIdLEAST8 "d" +#define PRIiLEAST8 "i" +#define PRIdFAST8 "d" +#define PRIiFAST8 "i" + +#define PRId16 "hd" +#define PRIi16 "hi" +#define PRIdLEAST16 "hd" +#define PRIiLEAST16 "hi" +#define PRIdFAST16 "hd" +#define PRIiFAST16 "hi" + +#define PRId32 "I32d" +#define PRIi32 "I32i" +#define PRIdLEAST32 "I32d" +#define PRIiLEAST32 "I32i" +#define PRIdFAST32 "I32d" +#define PRIiFAST32 "I32i" + +#define PRId64 "I64d" +#define PRIi64 "I64i" +#define PRIdLEAST64 "I64d" +#define PRIiLEAST64 "I64i" +#define PRIdFAST64 "I64d" +#define PRIiFAST64 "I64i" + +#define PRIdMAX "I64d" +#define PRIiMAX "I64i" + +#define PRIdPTR "Id" +#define PRIiPTR "Ii" + +// The fprintf macros for unsigned integers are: +#define PRIo8 "o" +#define PRIu8 "u" +#define PRIx8 "x" +#define PRIX8 "X" +#define PRIoLEAST8 "o" +#define PRIuLEAST8 "u" +#define PRIxLEAST8 "x" +#define PRIXLEAST8 "X" +#define PRIoFAST8 "o" +#define PRIuFAST8 "u" +#define PRIxFAST8 "x" +#define PRIXFAST8 "X" + +#define PRIo16 "ho" +#define PRIu16 "hu" +#define PRIx16 "hx" +#define PRIX16 "hX" +#define PRIoLEAST16 "ho" +#define PRIuLEAST16 "hu" +#define PRIxLEAST16 "hx" +#define PRIXLEAST16 "hX" +#define PRIoFAST16 "ho" +#define PRIuFAST16 "hu" +#define PRIxFAST16 "hx" +#define PRIXFAST16 "hX" + +#define PRIo32 "I32o" +#define PRIu32 "I32u" +#define PRIx32 "I32x" +#define PRIX32 "I32X" +#define PRIoLEAST32 "I32o" +#define PRIuLEAST32 "I32u" +#define PRIxLEAST32 "I32x" +#define PRIXLEAST32 "I32X" +#define PRIoFAST32 "I32o" +#define PRIuFAST32 "I32u" +#define PRIxFAST32 "I32x" +#define PRIXFAST32 "I32X" + +#define PRIo64 "I64o" +#define PRIu64 "I64u" +#define PRIx64 "I64x" +#define PRIX64 "I64X" +#define PRIoLEAST64 "I64o" +#define PRIuLEAST64 "I64u" +#define PRIxLEAST64 "I64x" +#define PRIXLEAST64 "I64X" +#define PRIoFAST64 "I64o" +#define PRIuFAST64 "I64u" +#define PRIxFAST64 "I64x" +#define PRIXFAST64 "I64X" + +#define PRIoMAX "I64o" +#define PRIuMAX "I64u" +#define PRIxMAX "I64x" +#define PRIXMAX "I64X" + +#define PRIoPTR "Io" +#define PRIuPTR "Iu" +#define PRIxPTR "Ix" +#define PRIXPTR "IX" + +// The fscanf macros for signed integers are: +#define SCNd8 "d" +#define SCNi8 "i" +#define SCNdLEAST8 "d" +#define SCNiLEAST8 "i" +#define SCNdFAST8 "d" +#define SCNiFAST8 "i" + +#define SCNd16 "hd" +#define SCNi16 "hi" +#define SCNdLEAST16 "hd" +#define SCNiLEAST16 "hi" +#define SCNdFAST16 "hd" +#define SCNiFAST16 "hi" + +#define SCNd32 "ld" +#define SCNi32 "li" +#define SCNdLEAST32 "ld" +#define SCNiLEAST32 "li" +#define SCNdFAST32 "ld" +#define SCNiFAST32 "li" + +#define SCNd64 "I64d" +#define SCNi64 "I64i" +#define SCNdLEAST64 "I64d" +#define SCNiLEAST64 "I64i" +#define SCNdFAST64 "I64d" +#define SCNiFAST64 "I64i" + +#define SCNdMAX "I64d" +#define SCNiMAX "I64i" + +#ifdef _WIN64 // [ +# define SCNdPTR "I64d" +# define SCNiPTR "I64i" +#else // _WIN64 ][ +# define SCNdPTR "ld" +# define SCNiPTR "li" +#endif // _WIN64 ] + +// The fscanf macros for unsigned integers are: +#define SCNo8 "o" +#define SCNu8 "u" +#define SCNx8 "x" +#define SCNX8 "X" +#define SCNoLEAST8 "o" +#define SCNuLEAST8 "u" +#define SCNxLEAST8 "x" +#define SCNXLEAST8 "X" +#define SCNoFAST8 "o" +#define SCNuFAST8 "u" +#define SCNxFAST8 "x" +#define SCNXFAST8 "X" + +#define SCNo16 "ho" +#define SCNu16 "hu" +#define SCNx16 "hx" +#define SCNX16 "hX" +#define SCNoLEAST16 "ho" +#define SCNuLEAST16 "hu" +#define SCNxLEAST16 "hx" +#define SCNXLEAST16 "hX" +#define SCNoFAST16 "ho" +#define SCNuFAST16 "hu" +#define SCNxFAST16 "hx" +#define SCNXFAST16 "hX" + +#define SCNo32 "lo" +#define SCNu32 "lu" +#define SCNx32 "lx" +#define SCNX32 "lX" +#define SCNoLEAST32 "lo" +#define SCNuLEAST32 "lu" +#define SCNxLEAST32 "lx" +#define SCNXLEAST32 "lX" +#define SCNoFAST32 "lo" +#define SCNuFAST32 "lu" +#define SCNxFAST32 "lx" +#define SCNXFAST32 "lX" + +#define SCNo64 "I64o" +#define SCNu64 "I64u" +#define SCNx64 "I64x" +#define SCNX64 "I64X" +#define SCNoLEAST64 "I64o" +#define SCNuLEAST64 "I64u" +#define SCNxLEAST64 "I64x" +#define SCNXLEAST64 "I64X" +#define SCNoFAST64 "I64o" +#define SCNuFAST64 "I64u" +#define SCNxFAST64 "I64x" +#define SCNXFAST64 "I64X" + +#define SCNoMAX "I64o" +#define SCNuMAX "I64u" +#define SCNxMAX "I64x" +#define SCNXMAX "I64X" + +#ifdef _WIN64 // [ +# define SCNoPTR "I64o" +# define SCNuPTR "I64u" +# define SCNxPTR "I64x" +# define SCNXPTR "I64X" +#else // _WIN64 ][ +# define SCNoPTR "lo" +# define SCNuPTR "lu" +# define SCNxPTR "lx" +# define SCNXPTR "lX" +#endif // _WIN64 ] + +#endif // __STDC_FORMAT_MACROS ] + +// 7.8.2 Functions for greatest-width integer types + +// 7.8.2.1 The imaxabs function +#define imaxabs _abs64 + +// 7.8.2.2 The imaxdiv function + +// This is modified version of div() function from Microsoft's div.c found +// in %MSVC.NET%\crt\src\div.c +#ifdef STATIC_IMAXDIV // [ +static +#else // STATIC_IMAXDIV ][ +_inline +#endif // STATIC_IMAXDIV ] +imaxdiv_t __cdecl imaxdiv(intmax_t numer, intmax_t denom) +{ + imaxdiv_t result; + + result.quot = numer / denom; + result.rem = numer % denom; + + if (numer < 0 && result.rem > 0) { + // did division wrong; must fix up + ++result.quot; + result.rem -= denom; + } + + return result; +} + +// 7.8.2.3 The strtoimax and strtoumax functions +#define strtoimax _strtoi64 +#define strtoumax _strtoui64 + +// 7.8.2.4 The wcstoimax and wcstoumax functions +#define wcstoimax _wcstoi64 +#define wcstoumax _wcstoui64 + + +#endif // _MSC_INTTYPES_H_ ] diff --git a/3rdparty/compiler/msvc/stdint.h b/3rdparty/compiler/msvc/stdint.h new file mode 100644 index 000000000..59d067302 --- /dev/null +++ b/3rdparty/compiler/msvc/stdint.h @@ -0,0 +1,247 @@ +// ISO C9x compliant stdint.h for Microsoft Visual Studio +// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 +// +// Copyright (c) 2006-2008 Alexander Chemeris +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// 1. Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// 3. The name of the author may be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED +// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +/////////////////////////////////////////////////////////////////////////////// + +#ifndef _MSC_VER // [ +#error "Use this header only with Microsoft Visual C++ compilers!" +#endif // _MSC_VER ] + +#ifndef _MSC_STDINT_H_ // [ +#define _MSC_STDINT_H_ + +#if _MSC_VER > 1000 +#pragma once +#endif + +#include + +// For Visual Studio 6 in C++ mode and for many Visual Studio versions when +// compiling for ARM we should wrap include with 'extern "C++" {}' +// or compiler give many errors like this: +// error C2733: second C linkage of overloaded function 'wmemchr' not allowed +#ifdef __cplusplus +extern "C" { +#endif +# include +#ifdef __cplusplus +} +#endif + +// Define _W64 macros to mark types changing their size, like intptr_t. +#ifndef _W64 +# if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300 +# define _W64 __w64 +# else +# define _W64 +# endif +#endif + + +// 7.18.1 Integer types + +// 7.18.1.1 Exact-width integer types + +// Visual Studio 6 and Embedded Visual C++ 4 doesn't +// realize that, e.g. char has the same size as __int8 +// so we give up on __intX for them. +#if (_MSC_VER < 1300) + typedef signed char int8_t; + typedef signed short int16_t; + typedef signed int int32_t; + typedef unsigned char uint8_t; + typedef unsigned short uint16_t; + typedef unsigned int uint32_t; +#else + typedef signed __int8 int8_t; + typedef signed __int16 int16_t; + typedef signed __int32 int32_t; + typedef unsigned __int8 uint8_t; + typedef unsigned __int16 uint16_t; + typedef unsigned __int32 uint32_t; +#endif +typedef signed __int64 int64_t; +typedef unsigned __int64 uint64_t; + + +// 7.18.1.2 Minimum-width integer types +typedef int8_t int_least8_t; +typedef int16_t int_least16_t; +typedef int32_t int_least32_t; +typedef int64_t int_least64_t; +typedef uint8_t uint_least8_t; +typedef uint16_t uint_least16_t; +typedef uint32_t uint_least32_t; +typedef uint64_t uint_least64_t; + +// 7.18.1.3 Fastest minimum-width integer types +typedef int8_t int_fast8_t; +typedef int16_t int_fast16_t; +typedef int32_t int_fast32_t; +typedef int64_t int_fast64_t; +typedef uint8_t uint_fast8_t; +typedef uint16_t uint_fast16_t; +typedef uint32_t uint_fast32_t; +typedef uint64_t uint_fast64_t; + +// 7.18.1.4 Integer types capable of holding object pointers +#ifdef _WIN64 // [ + typedef signed __int64 intptr_t; + typedef unsigned __int64 uintptr_t; +#else // _WIN64 ][ + typedef _W64 signed int intptr_t; + typedef _W64 unsigned int uintptr_t; +#endif // _WIN64 ] + +// 7.18.1.5 Greatest-width integer types +typedef int64_t intmax_t; +typedef uint64_t uintmax_t; + + +// 7.18.2 Limits of specified-width integer types + +#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259 + +// 7.18.2.1 Limits of exact-width integer types +#define INT8_MIN ((int8_t)_I8_MIN) +#define INT8_MAX _I8_MAX +#define INT16_MIN ((int16_t)_I16_MIN) +#define INT16_MAX _I16_MAX +#define INT32_MIN ((int32_t)_I32_MIN) +#define INT32_MAX _I32_MAX +#define INT64_MIN ((int64_t)_I64_MIN) +#define INT64_MAX _I64_MAX +#define UINT8_MAX _UI8_MAX +#define UINT16_MAX _UI16_MAX +#define UINT32_MAX _UI32_MAX +#define UINT64_MAX _UI64_MAX + +// 7.18.2.2 Limits of minimum-width integer types +#define INT_LEAST8_MIN INT8_MIN +#define INT_LEAST8_MAX INT8_MAX +#define INT_LEAST16_MIN INT16_MIN +#define INT_LEAST16_MAX INT16_MAX +#define INT_LEAST32_MIN INT32_MIN +#define INT_LEAST32_MAX INT32_MAX +#define INT_LEAST64_MIN INT64_MIN +#define INT_LEAST64_MAX INT64_MAX +#define UINT_LEAST8_MAX UINT8_MAX +#define UINT_LEAST16_MAX UINT16_MAX +#define UINT_LEAST32_MAX UINT32_MAX +#define UINT_LEAST64_MAX UINT64_MAX + +// 7.18.2.3 Limits of fastest minimum-width integer types +#define INT_FAST8_MIN INT8_MIN +#define INT_FAST8_MAX INT8_MAX +#define INT_FAST16_MIN INT16_MIN +#define INT_FAST16_MAX INT16_MAX +#define INT_FAST32_MIN INT32_MIN +#define INT_FAST32_MAX INT32_MAX +#define INT_FAST64_MIN INT64_MIN +#define INT_FAST64_MAX INT64_MAX +#define UINT_FAST8_MAX UINT8_MAX +#define UINT_FAST16_MAX UINT16_MAX +#define UINT_FAST32_MAX UINT32_MAX +#define UINT_FAST64_MAX UINT64_MAX + +// 7.18.2.4 Limits of integer types capable of holding object pointers +#ifdef _WIN64 // [ +# define INTPTR_MIN INT64_MIN +# define INTPTR_MAX INT64_MAX +# define UINTPTR_MAX UINT64_MAX +#else // _WIN64 ][ +# define INTPTR_MIN INT32_MIN +# define INTPTR_MAX INT32_MAX +# define UINTPTR_MAX UINT32_MAX +#endif // _WIN64 ] + +// 7.18.2.5 Limits of greatest-width integer types +#define INTMAX_MIN INT64_MIN +#define INTMAX_MAX INT64_MAX +#define UINTMAX_MAX UINT64_MAX + +// 7.18.3 Limits of other integer types + +#ifdef _WIN64 // [ +# define PTRDIFF_MIN _I64_MIN +# define PTRDIFF_MAX _I64_MAX +#else // _WIN64 ][ +# define PTRDIFF_MIN _I32_MIN +# define PTRDIFF_MAX _I32_MAX +#endif // _WIN64 ] + +#define SIG_ATOMIC_MIN INT_MIN +#define SIG_ATOMIC_MAX INT_MAX + +#ifndef SIZE_MAX // [ +# ifdef _WIN64 // [ +# define SIZE_MAX _UI64_MAX +# else // _WIN64 ][ +# define SIZE_MAX _UI32_MAX +# endif // _WIN64 ] +#endif // SIZE_MAX ] + +// WCHAR_MIN and WCHAR_MAX are also defined in +#ifndef WCHAR_MIN // [ +# define WCHAR_MIN 0 +#endif // WCHAR_MIN ] +#ifndef WCHAR_MAX // [ +# define WCHAR_MAX _UI16_MAX +#endif // WCHAR_MAX ] + +#define WINT_MIN 0 +#define WINT_MAX _UI16_MAX + +#endif // __STDC_LIMIT_MACROS ] + + +// 7.18.4 Limits of other integer types + +#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260 + +// 7.18.4.1 Macros for minimum-width integer constants + +#define INT8_C(val) val##i8 +#define INT16_C(val) val##i16 +#define INT32_C(val) val##i32 +#define INT64_C(val) val##i64 + +#define UINT8_C(val) val##ui8 +#define UINT16_C(val) val##ui16 +#define UINT32_C(val) val##ui32 +#define UINT64_C(val) val##ui64 + +// 7.18.4.2 Macros for greatest-width integer constants +#define INTMAX_C INT64_C +#define UINTMAX_C UINT64_C + +#endif // __STDC_CONSTANT_MACROS ] + + +#endif // _MSC_STDINT_H_ ] diff --git a/3rdparty/compiler/nacl/memory.h b/3rdparty/compiler/nacl/memory.h new file mode 100644 index 000000000..8e69c1fc0 --- /dev/null +++ b/3rdparty/compiler/nacl/memory.h @@ -0,0 +1 @@ +#include diff --git a/3rdparty/fcpp/.gitignore b/3rdparty/fcpp/.gitignore new file mode 100644 index 000000000..1279d5b47 --- /dev/null +++ b/3rdparty/fcpp/.gitignore @@ -0,0 +1,3 @@ +fcpp +*.o +*~ diff --git a/3rdparty/fcpp/COPYING b/3rdparty/fcpp/COPYING new file mode 100644 index 000000000..1eec3da88 --- /dev/null +++ b/3rdparty/fcpp/COPYING @@ -0,0 +1,38 @@ +/* + * Copyright (c) 1993-2011 Daniel Stenberg + * All rights reserved. + * + * Redistribution and use in source and binary forms, + * with or without modification, are permitted provided + * that the following conditions are met: + * + * Redistributions of source code must retain the above + * copyright notice, this list of conditions and the + * following disclaimer. + * + * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * Neither the name of the copyright holder nor the names + * of any other contributors may be used to endorse or + * promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + */ + diff --git a/3rdparty/fcpp/FPPBase.h b/3rdparty/fcpp/FPPBase.h new file mode 100644 index 000000000..4e76e1a04 --- /dev/null +++ b/3rdparty/fcpp/FPPBase.h @@ -0,0 +1,56 @@ +/****************************************************************************** + * FREXXWARE + * ---------------------------------------------------------------------------- + * + * Project: Frexx C Preprocessor + * $Source: /home/user/start/cpp/RCS/FPPBase.h,v $ + * $Revision: 1.3 $ + * $Date: 1993/12/06 13:51:20 $ + * $Author: start $ + * $State: Exp $ + * $Locker: start $ + * + * ---------------------------------------------------------------------------- + * $Log: FPPBase.h,v $ + * Revision 1.3 1993/12/06 13:51:20 start + * A lot of new stuff (too much to mention) + * + * Revision 1.2 1993/11/11 07:16:39 start + * New stuff + * + * Revision 1.2 1993/11/11 07:16:39 start + * New stuff + * + * Revision 1.1 1993/11/03 09:15:59 start + * Initial revision + * + * + *****************************************************************************/ +#ifndef FPP_BASE_H +#define FPP_BASE_H + +/* +** $Filename: libraries/FPPbase.h $ +** $Release: 1.0 $ +** $Date: 1993/12/06 13:51:20 $ +** +** (C) Copyright 1992, 1993 by FrexxWare +** All Rights Reserved +*/ + +#include +#include + +struct FPPBase { + struct Library LibNode; + UBYTE Flags; + UBYTE pad; + /* long word aligned */ + ULONG SysLib; + ULONG DosLib; + ULONG SegList; +}; + +#define FPPNAME "fpp.library" + +#endif diff --git a/3rdparty/fcpp/FPP_protos.h b/3rdparty/fcpp/FPP_protos.h new file mode 100644 index 000000000..85ffb6de3 --- /dev/null +++ b/3rdparty/fcpp/FPP_protos.h @@ -0,0 +1,35 @@ +/****************************************************************************** + * FREXXWARE + * ---------------------------------------------------------------------------- + * + * Project: Frexx C Preprocessor + * $Source: /home/user/start/cpp/RCS/FPP_protos.h,v $ + * $Revision: 1.3 $ + * $Date: 1993/12/06 13:51:20 $ + * $Author: start $ + * $State: Exp $ + * $Locker: start $ + * + * ---------------------------------------------------------------------------- + * $Log: FPP_protos.h,v $ + * Revision 1.3 1993/12/06 13:51:20 start + * A lot of new stuff (too much to mention) + * + * Revision 1.2 1993/11/11 07:16:39 start + * New stuff + * + * Revision 1.2 1993/11/11 07:16:39 start + * New stuff + * + * Revision 1.1 1993/11/03 09:15:59 start + * Initial revision + * + * + *****************************************************************************/ +/****************************************************** + * + * FPP_protos.h + * + *******/ + +int fppPreProcess(struct fppTag *); diff --git a/3rdparty/fcpp/README b/3rdparty/fcpp/README new file mode 100644 index 000000000..10c01e6a2 --- /dev/null +++ b/3rdparty/fcpp/README @@ -0,0 +1,13 @@ +Frexx CPP (C Preprocessor) + +Copyright (c) by Daniel Stenberg 1993 - 2011 + +This is a C preprocessor. It is a project based on public domain code, then +forked by Daniel in 1993 and future work has been done under a BSD license. + +The C preprocessor is now (mostly?) ANSI C compliant, and some tweaks have +been applied to also make it fairly usable to process other data files, such +as HTML for simple web sites. + +WWW: http://daniel.haxx.se/projects/fcpp/ +Code: https://github.com/bagder/fcpp diff --git a/3rdparty/fcpp/cpp.h b/3rdparty/fcpp/cpp.h new file mode 100644 index 000000000..b60c7399a --- /dev/null +++ b/3rdparty/fcpp/cpp.h @@ -0,0 +1,249 @@ +/****************************************************************************** + * FREXXWARE + * ---------------------------------------------------------------------------- + * + * Project: Frexx C Preprocessor + * $Source: /home/user/start/cpp/RCS/cpp.h,v $ + * $Revision: 1.3 $ + * $Date: 1993/12/06 13:51:20 $ + * $Author: start $ + * $State: Exp $ + * $Locker: start $ + * + * ---------------------------------------------------------------------------- + * $Log: cpp.h,v $ + * Revision 1.3 1993/12/06 13:51:20 start + * A lot of new stuff (too much to mention) + * + * Revision 1.2 1993/11/11 07:16:39 start + * New stuff + * + * Revision 1.2 1993/11/11 07:16:39 start + * New stuff + * + * Revision 1.1 1993/11/03 09:15:59 start + * Initial revision + * + * + *****************************************************************************/ + +/* + * I n t e r n a l D e f i n i t i o n s f o r C P P + * + * In general, definitions in this file should not be changed. + */ + +#include +#include +#ifndef toupper +#define toupper(c) ((c) + ('A' - 'a')) +#endif /* no toupper */ +#ifndef tolower +#define tolower(c) ((c) + ('a' - 'A')) +#endif /* no tolower */ + +#ifndef TRUE +#define TRUE 1 +#define FALSE 0 +#endif +#ifndef EOS +/* + * This is predefined in Decus C + */ +#define EOS '\0' /* End of string */ +#endif +#define EOF_CHAR 0 /* Returned by get() on eof */ +#define NULLST ((char *) NULL) /* Pointer to nowhere (linted) */ +#define DEF_NOARGS (-1) /* #define foo vs #define foo() */ + +/* + * The following may need to change if the host system doesn't use ASCII. + */ +#define QUOTE_PARM 0x1C /* Magic quoting operator */ +#define DEF_MAGIC 0x1D /* Magic for #defines */ +#define TOK_SEP 0x1E /* Token concatenation delim. */ +#define COM_SEP 0x1F /* Magic comment separator */ + +/* + * Note -- in Ascii, the following will map macro formals onto DEL + the + * C1 control character region (decimal 128 .. (128 + PAR_MAC)) which will + * be ok as long as PAR_MAC is less than 33). Note that the last PAR_MAC + * value is reserved for string substitution. + */ + +#define MAC_PARM 0x7F /* Macro formals start here */ +#ifndef OS9 +#if (PAR_MAC >= 33) +#error "assertion fails -- PAR_MAC isn't less than 33" + +#endif +#endif +#define LASTPARM (PAR_MAC - 1) + +/* + * Character type codes. + */ + +#define INV 0 /* Invalid, must be zero */ +#define OP_EOE INV /* End of expression */ +#define DIG 1 /* Digit */ +#define LET 2 /* Identifier start */ +#define FIRST_BINOP OP_ADD +#define OP_ADD 3 +#define OP_SUB 4 +#define OP_MUL 5 +#define OP_DIV 6 +#define OP_MOD 7 +#define OP_ASL 8 +#define OP_ASR 9 +#define OP_AND 10 /* &, not && */ +#define OP_OR 11 /* |, not || */ +#define OP_XOR 12 +#define OP_EQ 13 +#define OP_NE 14 +#define OP_LT 15 +#define OP_LE 16 +#define OP_GE 17 +#define OP_GT 18 +#define OP_ANA 19 /* && */ +#define OP_ORO 20 /* || */ +#define OP_QUE 21 /* ? */ +#define OP_COL 22 /* : */ +#define OP_CMA 23 /* , (relevant?) */ +#define LAST_BINOP OP_CMA /* Last binary operand */ +/* + * The following are unary. + */ +#define FIRST_UNOP OP_PLU /* First Unary operand */ +#define OP_PLU 24 /* + (draft ANSI standard) */ +#define OP_NEG 25 /* - */ +#define OP_COM 26 /* ~ */ +#define OP_NOT 27 /* ! */ +#define LAST_UNOP OP_NOT +#define OP_LPA 28 /* ( */ +#define OP_RPA 29 /* ) */ +#define OP_END 30 /* End of expression marker */ +#define OP_MAX (OP_END + 1) /* Number of operators */ +#define OP_FAIL (OP_END + 1) /* For error returns */ + +/* + * The following are for lexical scanning only. + */ + +#define QUO 65 /* Both flavors of quotation */ +#define DOT 66 /* . might start a number */ +#define SPA 67 /* Space and tab */ +#define BSH 68 /* Just a backslash */ +#define END 69 /* EOF */ + +/* + * These bits are set in ifstack[] + */ +#define WAS_COMPILING 1 /* TRUE if compile set at entry */ +#define ELSE_SEEN 2 /* TRUE when #else processed */ +#define TRUE_SEEN 4 /* TRUE when #if TRUE processed */ + +/* + * Define bits for the basic types and their adjectives + */ + +#define T_CHAR 1 +#define T_INT 2 +#define T_FLOAT 4 +#define T_DOUBLE 8 +#define T_SHORT 16 +#define T_LONG 32 +#define T_SIGNED 64 +#define T_UNSIGNED 128 +#define T_PTR 256 /* Pointer */ +#define T_FPTR 512 /* Pointer to functions */ + +/* + * The DEFBUF structure stores information about #defined + * macros. Note that the defbuf->repl information is always + * in malloc storage. + */ + +typedef struct defbuf { + struct defbuf *link; /* Next define in chain */ + char *repl; /* -> replacement */ + int hash; /* Symbol table hash */ + int nargs; /* For define(args) */ + char name[1]; /* #define name */ +} DEFBUF; + +/* + * The FILEINFO structure stores information about open files + * and macros being expanded. + */ + +typedef struct fileinfo { + char *bptr; /* Buffer pointer */ + int line; /* for include or macro */ + FILE *fp; /* File if non-null */ + struct fileinfo *parent; /* Link to includer */ + char *filename; /* File/macro name */ + char *progname; /* From #line statement */ + unsigned int unrecur; /* For macro recursion */ + char buffer[1]; /* current input line */ +} FILEINFO; + +/* + * The SIZES structure is used to store the values for #if sizeof + */ + +typedef struct sizes { + short bits; /* If this bit is set, */ + short size; /* this is the datum size value */ + short psize; /* this is the pointer size */ +} SIZES; +/* + * nomacarg is a built-in #define on Decus C. + */ + +#ifdef nomacarg +#define cput output /* cput concatenates tokens */ +#else +#if COMMENT_INVISIBLE +#define cput(c) { if (c != TOK_SEP && c != COM_SEP) putchar(c); } +#else +#define cput(c) { if (c != TOK_SEP) putchar(c); } +#endif +#endif + +#ifndef nomacarg +#define streq(s1, s2) (strcmp(s1, s2) == 0) +#endif + +/* + * Note: IO_NORMAL and IO_ERROR are defined in the Decus C stdio.h file + */ +#ifndef IO_NORMAL +#define IO_NORMAL 0 +#endif +#ifndef IO_ERROR +#define IO_ERROR 1 +#endif + +/* + * Externs + */ + +#include "fpp.h" /* structs and defines */ +#include "cppadd.h" /* Added prototypes for ANSI complience! */ + +#ifdef AMIGA +#include +extern int _OSERR; +#endif + +extern char type[]; /* Character classifier */ + +#define compiling global->ifstack[0] +#if DEBUG +extern int debug; /* Debug level */ +#endif +extern SIZES size_table[]; /* For #if sizeof sizes */ + +#define MAX_SPACE_SIZE 512 /* maximum number of whitespaces possible + to remember */ diff --git a/3rdparty/fcpp/cpp1.c b/3rdparty/fcpp/cpp1.c new file mode 100644 index 000000000..4456ea2fe --- /dev/null +++ b/3rdparty/fcpp/cpp1.c @@ -0,0 +1,592 @@ +/****************************************************************************** +Copyright (c) 1993 - 2011 Daniel Stenberg + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +******************************************************************************/ + +#include +#include +#include "cppdef.h" +#include "cpp.h" + +#if defined(AMIGA) +#include +#if defined(SHARED) +int _OSERR=0; +char *_ProgramName="junk"; +void __stdargs _XCEXIT(long a) { return; } +#endif +#endif + +FILE_LOCAL ReturnCode output(struct Global *, int); /* Output one character */ +FILE_LOCAL void sharp(struct Global *); +INLINE FILE_LOCAL ReturnCode cppmain(struct Global *); + +int fppPreProcess(struct fppTag *tags) +{ + int i=0; + ReturnCode ret; /* cpp return code */ + struct Global *global; + + global=(struct Global *)malloc(sizeof(struct Global)); + if(!global) + return(FPP_OUT_OF_MEMORY); + + memset(global, 0, sizeof(struct Global)); + + global->infile=NULL; + global->line=0; + global->wrongline=0; + global->errors=0; + global->recursion=0; + global->rec_recover=TRUE; + global->instring=FALSE; + global->inmacro=FALSE; + global->workp=NULL; + global->keepcomments = FALSE; /* Write out comments flag */ + global->cflag = FALSE; /* -C option (keep comments) */ + global->eflag = FALSE; /* -E option (never fail) */ + global->nflag = 0; /* -N option (no predefines) */ + global->wflag = FALSE; /* -W option (write #defines) */ + + global->ifstack[0]=TRUE; /* #if information */ + global->ifptr = global->ifstack; + global->incend = global->incdir; + + /* names defined at cpp start */ + global->preset[0]="frexxcpp"; /* This is the Frexx cpp program */ +#if defined( amiga ) + global->preset[1]="amiga"; + global->preset[2]="m68000"; + global->preset[3]="amigados"; + global->preset[4]= NULL; /* Must be last */ +#elif defined( unix ) + global->preset[1]="unix"; + global->preset[2]= NULL; +#endif + + /* Note: order is important */ + global->magic[0] = "__LINE__"; + global->magic[1] = "__FILE__"; + global->magic[2] = "__FUNCTION__"; + global->magic[3] = "__FUNC_LINE__"; + global->magic[4] = NULL; /* Must be last */ + + global->funcline = 0; + + global->cplusplus=1; + global->sharpfilename=NULL; + + global->parmp=NULL; + global->nargs=0; + + global->macro=NULL; + global->evalue=0; + + global->input=NULL; + global->output=NULL; + global->error=NULL; + global->first_file=NULL; + global->userdata=NULL; + + global->linelines=TRUE; + global->warnillegalcpp = FALSE; + global->outputLINE = TRUE; + global->warnnoinclude = TRUE; + global->showversion = TRUE; + global->showincluded = FALSE; + global->showspace = FALSE; + global->nestcomments = FALSE; + global->warnnestcomments = FALSE; + global->outputfile = TRUE; + global->included = 0; + + global->comment = FALSE; + global->rightconcat = FALSE; + global->work[0] = '\0'; + global->initialfunc = NULL; + + memset(global->symtab, 0, SBSIZE * sizeof(DEFBUF *)); + + ret=initdefines(global); /* O.S. specific def's */ + if(ret) + return(ret); + dooptions(global, tags); /* Command line -flags */ + ret=addfile(global, stdin, global->work); /* "open" main input file */ + + global->out = global->outputfile; + + if(!ret) + ret=cppmain(global); /* Process main file */ + if ((i = (global->ifptr - global->ifstack)) != 0) { +#if OLD_PREPROCESSOR + cwarn(global, ERROR_IFDEF_DEPTH, i); +#else + cerror(global, ERROR_IFDEF_DEPTH, i); +#endif + } + fflush(stdout); + fclose(stdout); + + if (global->errors > 0 && !global->eflag) + return(IO_ERROR); + return(IO_NORMAL); /* No errors or -E option set */ +} + +INLINE FILE_LOCAL +ReturnCode cppmain(struct Global *global) +{ + /* + * Main process for cpp -- copies tokens from the current input + * stream (main file, include file, or a macro) to the output + * file. + */ + + int c; /* Current character */ + int counter; /* newlines and spaces */ + ReturnCode ret; /* return code variable type */ + + long bracelevel = 0; + long parenlevel = 0; + long bracketlevel = 0; + int fake = 0; + +#define MAX_FUNC_LENGTH 50 + + char tempfunc[MAX_FUNC_LENGTH + 1]; + char tempfunc2[MAX_FUNC_LENGTH + 1]; + char define = 0; /* probability of a function define phase in the program */ + char prev = 0; /* previous type */ + char go = 0; + char include = 0; + char initfunc = 0; + + /* Initialize for reading tokens */ + global->tokenbsize = 50; + global->tokenbuf = malloc(global->tokenbsize + 1); + if(!global->tokenbuf) + return(FPP_OUT_OF_MEMORY); + + global->functionname = malloc(global->tokenbsize + 1); + if(!global->functionname) + return(FPP_OUT_OF_MEMORY); + global->functionname[0] = '\0'; + + if(global->showspace) { + global->spacebuf = (char *)malloc(MAX_SPACE_SIZE); + if(!global->spacebuf) + return(FPP_OUT_OF_MEMORY); + } + + if(global->showversion) + Error(global, VERSION_TEXT); + + /* + * Explicitly output a #line at the start of cpp output so + * that lint (etc.) knows the name of the original source + * file. If we don't do this explicitly, we may get + * the name of the first #include file instead. + */ + if(global->linelines) /* if #line lines are wanted! */ + sharp(global); + /* + * This loop is started "from the top" at the beginning of each line + * wrongline is set TRUE in many places if it is necessary to write + * a #line record. (But we don't write them when expanding macros.) + * + * The counter variable has two different uses: at + * the start of a line, it counts the number of blank lines that + * have been skipped over. These are then either output via + * #line records or by outputting explicit blank lines. + * When expanding tokens within a line, the counter remembers + * whether a blank/tab has been output. These are dropped + * at the end of the line, and replaced by a single blank + * within lines. + */ + + include = global->included; + + while(include--) { + openinclude(global, global->include[include], TRUE); + } + + for (;;) { + counter = 0; /* Count empty lines */ + for (;;) { /* For each line, ... */ + global->comment = FALSE; /* No comment yet! */ + global->chpos = 0; /* Count whitespaces */ + while (type[(c = get(global))] == SPA) /* Skip leading blanks */ + if(global->showspace) { + if(global->chposspacebuf[global->chpos++]=(char)c; + } + if (c == '\n') { /* If line's all blank, */ + if(global->comment) { + /* A comment was output! */ + Putchar(global, '\n'); + } + else + ++counter; /* Do nothing now */ + } + else if (c == '#') { /* Is 1st non-space '#' */ + global->keepcomments = FALSE; /* Don't pass comments */ + ret = control(global, &counter); /* Yes, do a #command */ + if(ret) + return(ret); + global->keepcomments = (global->cflag && compiling); + } + else if (c == EOF_CHAR) /* At end of file? */ + break; + else if (!compiling) { /* #ifdef false? */ + skipnl(global); /* Skip to newline */ + counter++; /* Count it, too. */ + } else { + break; /* Actual token */ + } + } + if (c == EOF_CHAR) /* Exit process at */ + break; /* End of file */ + /* + * If the loop didn't terminate because of end of file, we + * know there is a token to compile. First, clean up after + * absorbing newlines. counter has the number we skipped. + */ + if(global->linelines) { /* if #line lines are wanted! */ + if ((global->wrongline && global->infile->fp != NULL) || counter > 4) + sharp(global); /* Output # line number */ + else { /* If just a few, stuff */ + while (--counter >= 0) /* them out ourselves */ + Putchar(global, (int)'\n'); + } + } + if(global->showspace) { + /* Show all whitespaces! */ + global->spacebuf[global->chpos] = '\0'; + Putstring(global, global->spacebuf); + } + + /* + * Process each token on this line. + */ + unget(global); /* Reread the char. */ + for (;;) { /* For the whole line, */ + do { /* Token concat. loop */ + for (global->chpos = counter = 0; (type[(c = get(global))] == SPA);) { +#if COMMENT_INVISIBLE + if (c != COM_SEP) + counter++; +#else + if(global->showspace && global->chpos < MAX_SPACE_SIZE-1) { + global->spacebuf[global->chpos++]=(char)c; + } + counter++; /* Skip over blanks */ +#endif + } + if (c == EOF_CHAR || c == '\n') + break; /* Exit line loop */ + else if (counter > 0) { /* If we got any spaces */ + if(!global->showspace) /* We don't output all spaces */ + Putchar(global, (int)' ');/* Output one space */ + else { + global->spacebuf[global->chpos] = '\0'; + Putstring(global, global->spacebuf); /* Output all whitespaces */ + } + } + if(ret=macroid(global, &c)) /* Grab the token */ + return(ret); + } while (type[c] == LET && catenate(global, &ret) && !ret); + if(ret) + /* If the loop was broken because of a fatal error! */ + return(ret); + if (c == EOF_CHAR || c == '\n') /* From macro exp error */ + break; /* Exit line loop */ + go++; + switch (type[c]) { + case LET: + go =0; + /* Quite ordinary token */ + Putstring(global, global->tokenbuf); + + if(!define) { + /* Copy the name */ + strncpy(tempfunc, global->tokenbuf, MAX_FUNC_LENGTH); + tempfunc[MAX_FUNC_LENGTH]=0; + } + /* fputs(global->tokenbuf, stdout); */ + break; + case DIG: /* Output a number */ + case DOT: /* Dot may begin floats */ + go = 0; + ret=scannumber(global, c, (ReturnCode(*)(struct Global *, int))output); + if(ret) + return(ret); + break; + case QUO: /* char or string const */ + go = 0; + /* Copy it to output */ + if(!global->webmode) { + ret=scanstring(global, c, + (ReturnCode(*)(struct Global *, int))output); + if(ret) + return(ret); + break; + } + /* FALLTHROUGH */ + default: /* Some other character */ + + define++; + switch(c) { + case '{': + if(! bracelevel++ && define > 2) { + /* + * This is a starting brace. If there is a probability of a + * function defining, we copy the `tempfunc' function name to + * `global->functionname'. + */ + strcpy(global->functionname, tempfunc2); + global->funcline = global->line; + + if(global->outputfunctions) { + /* + * Output the discovered function name to stderr! + */ + Error(global, "#> Function defined at line %d: %s <#\n", + global->line, + global->functionname); + } + + if(global->initialfunc) { + int a; + for(a=0; aexcluded; a++) { + /* check for excluded functions */ + if(!strcmp(global->functionname, + global->excludedinit[a])) + break; + } + if(a==global->excluded) { + expstuff(global, "__brace__", "{"); + expstuff(global, "__init_func__", global->initialfunc); + initfunc = TRUE; + } + } + + } + break; + case '}': + go = 0; + if( (--bracelevel == initfunc) && + strcmp(global->infile->filename, "__init_func__") ) { + /* we just stepped out of the function! */ + global->functionname[0] = '\0'; + global->funcline = 0; + define = 1; + + if(initfunc) { + Putchar(global, '}'); + bracelevel--; + initfunc=0; + } + } + fake = 0; + break; + + case ';': + case ',': + if(go == 2) { + define = 1; + fake = 0; + go--; + break; + } + break; + case '(': + if(! parenlevel++ && !bracelevel) { + if(go == 2) { + /* foobar(text) -> "(" is found. This can't be a + function */ + go--; + define = 1; + break; + } + if( define < 2 && prev == LET) { + /* This is the first parenthesis on the ground brace + level, and we did previously not have a probable + function name */ + strncpy(tempfunc2, global->tokenbuf, MAX_FUNC_LENGTH); + tempfunc2[MAX_FUNC_LENGTH]=0; + define++; + } + else { + /* we have a fake start */ + fake++; + } + } + break; + case ')': + if(! --parenlevel && !bracelevel && define>1 && !fake) { + /* + * The starting parentheses level and + * the starting brace level. + * This might be the start of a function defining coming + * up! + */ + define++; /* increase probability */ + fake = 0; + go = 1; + } + break; + case '[': + bracketlevel++; + break; + case ']': + bracketlevel--; + break; + } + define--; /* decrease function probability */ + + Putchar(global, c); /* Just output it */ + break; + } /* Switch ends */ + prev = type[c]; + } /* Line for loop */ + + if (c == '\n') { /* Compiling at EOL? */ + Putchar(global, '\n'); /* Output newline, if */ + if (global->infile->fp == NULL) /* Expanding a macro, */ + global->wrongline = TRUE; /* Output # line later */ + } + } /* Continue until EOF */ + + if(global->showbalance) { + if(bracketlevel) { + cwarn(global, WARN_BRACKET_DEPTH, bracketlevel); + } + if(parenlevel) { + cwarn(global, WARN_PAREN_DEPTH, parenlevel); + } + if(bracelevel) { + cwarn(global, WARN_BRACE_DEPTH, bracelevel); + } + } + if (global->wflag) { + global->out = TRUE; /* enable output */ + outdefines(global); /* Write out #defines */ + } + return(FPP_OK); +} + +FILE_LOCAL +ReturnCode output(struct Global *global, int c) +{ + /* + * Output one character to stdout -- output() is passed as an + * argument to scanstring() + */ +#if COMMENT_INVISIBLE + if (c != TOK_SEP && c != COM_SEP) +#else + if (c != TOK_SEP) +#endif + Putchar(global, c); + return(FPP_OK); +} + +void Putchar(struct Global *global, int c) +{ + /* + * Output one character to stdout or to output function! + */ + if(!global->out) + return; +#if defined(UNIX) + if(global->output) + global->output(c, global->userdata); + else + putchar(c); +#else /* amiga */ + global->output(c, global->userdata); +#endif +} + +void Putstring(struct Global *global, char *string) +{ + /* + * Output a string! One letter at a time to the Putchar routine! + */ + + if(!string) + return; + + while(*string) + Putchar(global, *string++); +} + +void Putint(struct Global *global, int number) +{ + /* + * Output the number as a string. + */ + + char buffer[16]; /* an integer can't be that big! */ + char *point=buffer; + + sprintf(buffer, "%d", number); + + while(*point) + Putchar(global, *point++); +} + + +FILE_LOCAL +void sharp(struct Global *global) +{ + /* + * Output a line number line. + */ + + char *name; + if (global->keepcomments) /* Make sure # comes on */ + Putchar(global, '\n'); /* a fresh, new line. */ + /* printf("#%s %d", LINE_PREFIX, global->line); */ + + Putchar(global, '#'); + if(global->outputLINE) + Putstring(global, LINE_PREFIX); + Putchar(global, ' '); + Putint(global, global->line); + + if (global->infile->fp != NULL) { + name = (global->infile->progname != NULL) + ? global->infile->progname : global->infile->filename; + if (global->sharpfilename == NULL + || (global->sharpfilename != NULL && !streq(name, global->sharpfilename))) { + if (global->sharpfilename != NULL) + free(global->sharpfilename); + global->sharpfilename = savestring(global, name); + /* printf(" \"%s\"", name); */ + Putstring(global, " \""); + Putstring(global, name); + Putchar(global, '\"'); + } + } + Putchar(global, '\n'); + global->wrongline = FALSE; + return; +} diff --git a/3rdparty/fcpp/cpp2.c b/3rdparty/fcpp/cpp2.c new file mode 100644 index 000000000..1d4fa1548 --- /dev/null +++ b/3rdparty/fcpp/cpp2.c @@ -0,0 +1,814 @@ +/****************************************************************************** +Copyright (c) 1999 Daniel Stenberg + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +******************************************************************************/ +#include +#include +#include "cppdef.h" +#include "cpp.h" + +#ifdef _AMIGA +#include +#endif + +FILE_LOCAL void dump_line(struct Global *, int *); +FILE_LOCAL ReturnCode doif(struct Global *, int); +INLINE FILE_LOCAL ReturnCode doinclude(struct Global *); +INLINE FILE_LOCAL int hasdirectory(char *, char *); + + +/* + * Generate (by hand-inspection) a set of unique values for each control + * operator. Note that this is not guaranteed to work for non-Ascii + * machines. CPP won't compile if there are hash conflicts. + */ + +#define L_assert ('a' + ('s' << 1)) +#define L_define ('d' + ('f' << 1)) +#define L_elif ('e' + ('i' << 1)) +#define L_else ('e' + ('s' << 1)) +#define L_endif ('e' + ('d' << 1)) +#define L_error ('e' + ('r' << 1)) +#define L_if ('i' + (EOS << 1)) +#define L_ifdef ('i' + ('d' << 1)) +#define L_ifndef ('i' + ('n' << 1)) +#define L_include ('i' + ('c' << 1)) +#define L_line ('l' + ('n' << 1)) +#define L_nogood (EOS + (EOS << 1)) /* To catch #i */ +#define L_pragma ('p' + ('a' << 1)) +#define L_undef ('u' + ('d' << 1)) + +ReturnCode control( struct Global *global, + int *counter ) /* Pending newline counter */ +{ + /* + * Process #control lines. Simple commands are processed inline, + * while complex commands have their own subroutines. + * + * The counter is used to force out a newline before #line, and + * #pragma commands. This prevents these commands from ending up at + * the end of the previous line if cpp is invoked with the -C option. + */ + + int c; + char *tp; + int hash; + char *ep; + ReturnCode ret; + + c = skipws( global ); + + if( c == '\n' || c == EOF_CHAR ) + { + (*counter)++; + + return(FPP_OK); + } + + if( !isdigit(c) ) + scanid( global, c ); /* Get #word to tokenbuf */ + else + { + unget( global ); /* Hack -- allow #123 as a */ + + strcpy( global->tokenbuf, "line" ); /* synonym for #line 123 */ + } + + hash = (global->tokenbuf[1] == EOS) ? L_nogood : (global->tokenbuf[0] + (global->tokenbuf[2] << 1)); + + switch( hash ) + { + case L_assert: + tp = "assert"; + break; + case L_define: + tp = "define"; + break; + case L_elif: + tp = "elif"; + break; + case L_else: + tp = "else"; + break; + case L_endif: + tp = "endif"; + break; + case L_error: + tp = "error"; + break; + case L_if: + tp = "if"; + break; + case L_ifdef: + tp = "ifdef"; + break; + case L_ifndef: + tp = "ifndef"; + break; + case L_include: + tp = "include"; + break; + case L_line: + tp = "line"; + break; + case L_pragma: + tp = "pragma"; + break; + case L_undef: + tp = "undef"; + break; + default: + hash = L_nogood; + case L_nogood: + tp = ""; + break; + } + + if( !streq( tp, global->tokenbuf ) ) + hash = L_nogood; + + /* + * hash is set to a unique value corresponding to the + * control keyword (or L_nogood if we think it's nonsense). + */ + if( global->infile->fp == NULL ) + cwarn( global, WARN_CONTROL_LINE_IN_MACRO, global->tokenbuf ); + + if( !compiling ) + { /* Not compiling now */ + switch( hash ) + { + case L_if: /* These can't turn */ + case L_ifdef: /* compilation on, but */ + case L_ifndef: /* we must nest #if's */ + if( ++global->ifptr >= &global->ifstack[BLK_NEST] ) + { + cfatal( global, FATAL_TOO_MANY_NESTINGS, global->tokenbuf ); + + return( FPP_TOO_MANY_NESTED_STATEMENTS ); + } + + *global->ifptr = 0; /* !WAS_COMPILING */ + + case L_line: /* Many */ + /* + * Are pragma's always processed? + */ + case L_pragma: /* options */ + case L_include: /* are uninteresting */ + case L_define: /* if we */ + case L_undef: /* aren't */ + case L_assert: /* compiling. */ + case L_error: + dump_line( global, counter ); /* Ignore rest of line */ + return(FPP_OK); + } + } + /* + * Make sure that #line and #pragma are output on a fresh line. + */ + if( *counter > 0 && (hash == L_line || hash == L_pragma) ) + { + Putchar( global, '\n' ); + + (*counter)--; + } + + switch( hash ) + { + case L_line: + /* + * Parse the line to update the line number and "progname" + * field and line number for the next input line. + * Set wrongline to force it out later. + */ + c = skipws( global ); + + global->workp = global->work; /* Save name in work */ + + while( c != '\n' && c != EOF_CHAR ) + { + if( ret = save( global, c ) ) + return(ret); + + c = get( global ); + } + + unget( global ); + + if( ret = save( global, EOS ) ) + return(ret); + + /* + * Split #line argument into and + * We subtract 1 as we want the number of the next line. + */ + global->line = atoi(global->work) - 1; /* Reset line number */ + + for( tp = global->work; isdigit(*tp) || type[*tp] == SPA; tp++) + ; /* Skip over digits */ + + if( *tp != EOS ) + { + /* Got a filename, so: */ + + if( *tp == '"' && (ep = strrchr(tp + 1, '"')) != NULL ) + { + tp++; /* Skip over left quote */ + + *ep = EOS; /* And ignore right one */ + } + + if( global->infile->progname != NULL ) + /* Give up the old name if it's allocated. */ + free( global->infile->progname ); + + global->infile->progname = savestring( global, tp ); + } + + global->wrongline = TRUE; /* Force output later */ + break; + + case L_include: + ret = doinclude( global ); + if( ret ) + return(ret); + break; + + case L_define: + ret = dodefine( global ); + if( ret ) + return(ret); + break; + + case L_undef: + doundef( global ); + break; + + case L_else: + if( global->ifptr == &global->ifstack[0] ) + { + cerror( global, ERROR_STRING_MUST_BE_IF, global->tokenbuf ); + + dump_line( global, counter ); + + return( FPP_OK ); + } + else if( (*global->ifptr & ELSE_SEEN) != 0 ) + { + cerror( global, ERROR_STRING_MAY_NOT_FOLLOW_ELSE, global->tokenbuf ); + + dump_line( global, counter ); + + return( FPP_OK ); + } + + *global->ifptr |= ELSE_SEEN; + + if( (*global->ifptr & WAS_COMPILING) != 0 ) + { + if( compiling || (*global->ifptr & TRUE_SEEN) != 0 ) + compiling = FALSE; + else + { + compiling = TRUE; + } + } + break; + + case L_elif: + if( global->ifptr == &global->ifstack[0] ) + { + cerror( global, ERROR_STRING_MUST_BE_IF, global->tokenbuf ); + + dump_line( global, counter ); + + return( FPP_OK ); + } + else if( (*global->ifptr & ELSE_SEEN) != 0 ) + { + cerror( global, ERROR_STRING_MAY_NOT_FOLLOW_ELSE, global->tokenbuf ); + + dump_line( global, counter ); + + return( FPP_OK ); + } + + if( (*global->ifptr & (WAS_COMPILING | TRUE_SEEN)) != WAS_COMPILING ) + { + compiling = FALSE; /* Done compiling stuff */ + + dump_line( global, counter ); /* Skip this clause */ + + return( FPP_OK ); + } + + ret = doif( global, L_if ); + + if( ret ) + return(ret); + + break; + + case L_error: + cerror(global, ERROR_ERROR); + break; + + case L_if: + case L_ifdef: + case L_ifndef: + if( ++global->ifptr < &global->ifstack[BLK_NEST] ) + { + *global->ifptr = WAS_COMPILING; + + ret = doif( global, hash ); + + if( ret ) + return(ret); + + break; + } + + cfatal( global, FATAL_TOO_MANY_NESTINGS, global->tokenbuf ); + + return( FPP_TOO_MANY_NESTED_STATEMENTS ); + + case L_endif: + if( global->ifptr == &global->ifstack[0] ) + { + cerror( global, ERROR_STRING_MUST_BE_IF, global->tokenbuf ); + + dump_line( global, counter ); + + return(FPP_OK); + } + + if( !compiling && (*global->ifptr & WAS_COMPILING) != 0 ) + global->wrongline = TRUE; + + compiling = ((*global->ifptr & WAS_COMPILING) != 0); + + --global->ifptr; + + break; + + case L_assert: + { + int result; + + ret = eval( global, &result ); + + if(ret) + return(ret); + + if( result == 0 ) + cerror( global, ERROR_PREPROC_FAILURE ); + } + break; + + case L_pragma: + /* + * #pragma is provided to pass "options" to later + * passes of the compiler. cpp doesn't have any yet. + */ + Putstring( global, "#pragma " ); + + while( (c = get( global ) ) != '\n' && c != EOF_CHAR ) + Putchar( global, c ); + + unget( global ); + + Putchar( global, '\n' ); + + break; + + default: + /* + * Undefined #control keyword. + * Note: the correct behavior may be to warn and + * pass the line to a subsequent compiler pass. + * This would allow #asm or similar extensions. + */ + if( global->warnillegalcpp ) + cwarn( global, WARN_ILLEGAL_COMMAND, global->tokenbuf ); + + Putchar( global, '#' ); + Putstring( global, global->tokenbuf ); + Putchar( global, ' ' ); + + while( (c = get( global ) ) != '\n' && c != EOF_CHAR ) + Putchar( global, c ); + + unget( global ); + + Putchar( global, '\n' ); + + break; + } + + if( hash != L_include ) + { + #if OLD_PREPROCESSOR + /* + * Ignore the rest of the #control line so you can write + * #if foo + * #endif foo + */ + dump_line( global, counter ); /* Take common exit */ + + return( FPP_OK ); + #else + if( skipws( global ) != '\n' ) + { + cwarn( global, WARN_UNEXPECTED_TEXT_IGNORED ); + + skipnl( global ); + } + #endif + } + + (*counter)++; + + return( FPP_OK ); +} + +FILE_LOCAL +void dump_line(struct Global *global, int *counter) +{ + skipnl( global ); /* Ignore rest of line */ + + (*counter)++; +} + +FILE_LOCAL +ReturnCode doif(struct Global *global, int hash) +{ + /* + * Process an #if, #ifdef, or #ifndef. The latter two are straightforward, + * while #if needs a subroutine of its own to evaluate the expression. + * + * doif() is called only if compiling is TRUE. If false, compilation + * is always supressed, so we don't need to evaluate anything. This + * supresses unnecessary warnings. + */ + + int c; + int found; + ReturnCode ret; + + if( (c = skipws( global ) ) == '\n' || c == EOF_CHAR ) + { + unget( global ); + + cerror( global, ERROR_MISSING_ARGUMENT ); + + #if !OLD_PREPROCESSOR + skipnl( global ); /* Prevent an extra */ + + unget( global ); /* Error message */ + #endif + + return(FPP_OK); + } + + if( hash == L_if ) + { + unget( global ); + + ret = eval( global, &found ); + + if( ret ) + return( ret ); + + found = (found != 0); /* Evaluate expr, != 0 is TRUE */ + + hash = L_ifdef; /* #if is now like #ifdef */ + } + else + { + if( type[c] != LET ) + { /* Next non-blank isn't letter */ + /* ... is an error */ + cerror( global, ERROR_MISSING_ARGUMENT ); + + #if !OLD_PREPROCESSOR + skipnl( global ); /* Prevent an extra */ + + unget( global ); /* Error message */ + #endif + + return(FPP_OK); + } + + found = ( lookid( global, c ) != NULL ); /* Look for it in symbol table */ + } + + if( found == (hash == L_ifdef) ) + { + compiling = TRUE; + + *global->ifptr |= TRUE_SEEN; + } + else + compiling = FALSE; + + return(FPP_OK); +} + +INLINE FILE_LOCAL +ReturnCode doinclude( struct Global *global ) +{ + /* + * Process the #include control line. + * There are three variations: + * + * #include "file" search somewhere relative to the + * current source file, if not found, + * treat as #include . + * + * #include Search in an implementation-dependent + * list of places. + * + * #include token Expand the token, it must be one of + * "file" or , process as such. + * + * Note: the November 12 draft forbids '>' in the #include format. + * This restriction is unnecessary and not implemented. + */ + + int c; + int delim; + ReturnCode ret; + + delim = skipws( global ); + + if( ret = macroid( global, &delim ) ) + return(ret); + + if( delim != '<' && delim != '"' ) + { + cerror( global, ERROR_INCLUDE_SYNTAX ); + + return( FPP_OK ); + } + + if( delim == '<' ) + delim = '>'; + + global->workp = global->work; + + while( (c = get(global)) != '\n' && c != EOF_CHAR ) + if( ret = save( global, c ) ) /* Put it away. */ + return( ret ); + + unget( global ); /* Force nl after include */ + + /* + * The draft is unclear if the following should be done. + */ + while( --global->workp >= global->work && + (*global->workp == ' ' || *global->workp == '\t') ) + ; /* Trim blanks from filename */ + + if( *global->workp != delim ) + { + cerror( global, ERROR_INCLUDE_SYNTAX ); + + return(FPP_OK); + } + + *global->workp = EOS; /* Terminate filename */ + + ret = openinclude( global, global->work, (delim == '"') ); + + if( ret && global->warnnoinclude ) + { + /* + * Warn if #include file isn't there. + */ + cwarn( global, WARN_CANNOT_OPEN_INCLUDE, global->work ); + } + + return( FPP_OK ); +} + +#ifdef _AMIGA +ReturnCode MultiAssignLoad( struct Global *global, char *incptr, char *filename, char *tmpname ); +#endif + +ReturnCode openinclude( struct Global *global, + char *filename, /* Input file name */ + int searchlocal ) /* TRUE if #include "file" */ +{ + /* + * Actually open an include file. This routine is only called from + * doinclude() above, but was written as a separate subroutine for + * programmer convenience. It searches the list of directories + * and actually opens the file, linking it into the list of + * active files. Returns ReturnCode. No error message is printed. + */ + + char **incptr; + char tmpname[NWORK]; /* Filename work area */ + int len; + + #if HOST == SYS_AMIGADOS + if( strchr (filename, ':') != NULL ) + { + if( ! openfile( global, filename ) ) + return(FPP_OK); + } + #else + if( filename[0] == '/' ) + { + if( ! openfile( global, filename ) ) + return(FPP_OK); + } + #endif + + if( searchlocal ) + { + /* + * Look in local directory first. + * Try to open filename relative to the directory of the current + * source file (as opposed to the current directory). (ARF, SCK). + * Note that the fully qualified pathname is always built by + * discarding the last pathname component of the source file + * name then tacking on the #include argument. + */ + if( hasdirectory( global->infile->filename, tmpname ) ) + strcat( tmpname, filename ); + else + strcpy( tmpname, filename ); + + if( ! openfile( global, tmpname ) ) + return(FPP_OK); + } + + /* + * Look in any directories specified by -I command line + * arguments, then in the builtin search list. + */ + for( incptr = global->incdir; incptr < global->incend; incptr++ ) + { + len = strlen(*incptr); + + if( len + strlen(filename) >= sizeof(tmpname) ) + { + cfatal( global, FATAL_FILENAME_BUFFER_OVERFLOW ); + + return( FPP_FILENAME_BUFFER_OVERFLOW ); + } + else + { + #if HOST == SYS_AMIGADOS + if( (*incptr)[len-1] != '/' && (*incptr)[len-1] != ':' ) + sprintf( tmpname, "%s/%s", *incptr, filename ); + #else + if( (*incptr)[len-1] != '/' ) + sprintf( tmpname, "%s/%s", *incptr, filename ); + #endif + else + sprintf( tmpname, "%s%s", *incptr, filename ); + + #if HOST == SYS_AMIGADOS + // + // amp July 9, 1997 + // + // OK, hack in multiassign support for the buitin + // search directories... + // + if( (*incptr)[len-1] == ':' ) + { + if( ! MultiAssignLoad( global, *incptr, filename, tmpname ) ) + return(FPP_OK); + } + else + #endif + if( !openfile( global, tmpname ) ) + return(FPP_OK); + } + } + + return( FPP_NO_INCLUDE ); +} + +INLINE FILE_LOCAL +int hasdirectory( char *source, /* Directory to examine */ + char *result ) /* Put directory stuff here */ +{ + /* + * If a device or directory is found in the source filename string, the + * node/device/directory part of the string is copied to result and + * hasdirectory returns TRUE. Else, nothing is copied and it returns FALSE. + */ + + char *tp2; + + #if HOST == SYS_AMIGADOS + char *tp1; + + if( (tp1 = strrchr( source, ':' ) ) == NULL ) + tp1 = source; + + if( (tp2 = strrchr( tp1, '/' ) ) == NULL ) + tp2 = tp1; + + if( tp2 == source ) + return (FALSE); + + #else + if( (tp2 = strrchr( source, '/' ) ) == NULL ) + return(FALSE); + #endif + + strncpy( result, source, tp2 - source + 1 ); + + result[tp2 - source + 1] = EOS; + + return( TRUE ); +} + +#ifdef _AMIGA +// +// amp July 9, 1997 +// +// Use the OS Luke... +// +// We do the sneaky version and let the OS do all +// the hard work so we don't have to mess around +// a lot ;) +// +ReturnCode MultiAssignLoad( struct Global *global, char *incptr, char *filename, char *tmpname ) + +{ /* MultiAssignLoad */ + + struct MsgPort *FSTask; + struct DevProc *DevProc = NULL; + LONG RtnCode = FPP_NO_INCLUDE; + + FSTask = GetFileSysTask(); + + do + { + // + // This should not bring up a requester. + // check to see if cpp does in fact tweek + // the process WindowPtr. + // + DevProc = GetDeviceProc( incptr, DevProc ); + + if( DevProc ) + { + SetFileSysTask( DevProc->dvp_Port ); + + // + // Normally we would pass the lock and filename + // to the Load() routine, which would CD to the + // directory and Open(filename), but in order to + // satisfy the exisiting openfile() function, we + // bite the bullet and build the complete pathspec + // rather than add the standard Load() routine. + // + if( NameFromLock( DevProc->dvp_Lock, tmpname, NWORK ) ) + { + AddPart( tmpname, filename, NWORK ); + + RtnCode = openfile( global, tmpname ); + + if( ! RtnCode ) + break; + } + } + + } while ( RtnCode && + DevProc && + (DevProc->dvp_Flags & DVPF_ASSIGN) && + IoErr() == ERROR_OBJECT_NOT_FOUND); /* repeat if multi-assign */ + + SetFileSysTask( FSTask ); + + if( DevProc ) + FreeDeviceProc( DevProc ); + + return RtnCode; + +} /* MultiAssignLoad */ +#endif //_AMIGA diff --git a/3rdparty/fcpp/cpp3.c b/3rdparty/fcpp/cpp3.c new file mode 100644 index 000000000..2f77fbc59 --- /dev/null +++ b/3rdparty/fcpp/cpp3.c @@ -0,0 +1,395 @@ +/****************************************************************************** +Copyright (c) 1999 Daniel Stenberg + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +******************************************************************************/ +#include +#include +#include /*OIS*0.92*/ +#include "cppdef.h" +#include "cpp.h" + +ReturnCode openfile(struct Global *global, char *filename) +{ + /* + * Open a file, add it to the linked list of open files. + * This is called only from openfile() in cpp2.c. + */ + + FILE *fp; + ReturnCode ret; + + if ((fp = fopen(filename, "r")) == NULL) + ret=FPP_OPEN_ERROR; + else + ret=addfile(global, fp, filename); + + if(!ret && global->showincluded) { + /* no error occured! */ + Error(global, "cpp: included \""); + Error(global, filename); + Error(global, "\"\n"); + } + return(ret); +} + +ReturnCode addfile(struct Global *global, + FILE *fp, /* Open file pointer */ + char *filename) /* Name of the file */ +{ + /* + * Initialize tables for this open file. This is called from openfile() + * above (for #include files), and from the entry to cpp to open the main + * input file. It calls a common routine, getfile() to build the FILEINFO + * structure which is used to read characters. (getfile() is also called + * to setup a macro replacement.) + */ + + FILEINFO *file; + ReturnCode ret; + + ret = getfile(global, NBUFF, filename, &file); + if(ret) + return(ret); + file->fp = fp; /* Better remember FILE * */ + file->buffer[0] = EOS; /* Initialize for first read */ + global->line = 1; /* Working on line 1 now */ + global->wrongline = TRUE; /* Force out initial #line */ + return(FPP_OK); +} + +int dooptions(struct Global *global, struct fppTag *tags) +{ + /* + * dooptions is called to process command line arguments (-Detc). + * It is called only at cpp startup. + */ + DEFBUF *dp; + char end=FALSE; /* end of taglist */ + + while(tags && !end) { + switch(tags->tag) { + case FPPTAG_END: + end=TRUE; + break; + case FPPTAG_INITFUNC: + global->initialfunc = (char *) tags->data; + break; + case FPPTAG_DISPLAYFUNCTIONS: + global->outputfunctions = tags->data?1:0; + break; + case FPPTAG_RIGHTCONCAT: + global->rightconcat = tags->data?1:0; + break; + case FPPTAG_OUTPUTMAIN: + global->outputfile = tags->data?1:0; + break; + case FPPTAG_NESTED_COMMENTS: + global->nestcomments = tags->data?1:0; + break; + case FPPTAG_WARNMISSINCLUDE: + global->warnnoinclude = tags->data?1:0; + break; + case FPPTAG_WARN_NESTED_COMMENTS: + global->warnnestcomments = tags->data?1:0; + break; + case FPPTAG_OUTPUTSPACE: + global->showspace = tags->data?1:0; + break; + case FPPTAG_OUTPUTBALANCE: + global->showbalance = tags->data?1:0; + break; + case FPPTAG_OUTPUTINCLUDES: + global->showincluded = tags->data?1:0; + break; + case FPPTAG_IGNOREVERSION: + global->showversion = tags->data?1:0; + break; + case FPPTAG_WARNILLEGALCPP: + global->warnillegalcpp = tags->data?1:0; + break; + case FPPTAG_OUTPUTLINE: + global->outputLINE = tags->data?1:0; + break; + case FPPTAG_KEEPCOMMENTS: + if(tags->data) { + global->cflag = TRUE; + global->keepcomments = TRUE; + } + break; + case FPPTAG_DEFINE: + /* + * If the option is just "-Dfoo", make it -Dfoo=1 + */ + { + char *symbol=(char *)tags->data; + char *text=symbol; + while (*text != EOS && *text != '=') + text++; + if (*text == EOS) + text = "1"; + else + *text++ = EOS; + /* + * Now, save the word and its definition. + */ + dp = defendel(global, symbol, FALSE); + if(!dp) + return(FPP_OUT_OF_MEMORY); + dp->repl = savestring(global, text); + dp->nargs = DEF_NOARGS; + } + break; + case FPPTAG_IGNORE_NONFATAL: + global->eflag = TRUE; + break; + case FPPTAG_INCLUDE_DIR: + if (global->incend >= &global->incdir[NINCLUDE]) { + cfatal(global, FATAL_TOO_MANY_INCLUDE_DIRS); + return(FPP_TOO_MANY_INCLUDE_DIRS); + } + *global->incend++ = (char *)tags->data; + break; + case FPPTAG_INCLUDE_FILE: + case FPPTAG_INCLUDE_MACRO_FILE: + if (global->included >= NINCLUDE) { + cfatal(global, FATAL_TOO_MANY_INCLUDE_FILES); + return(FPP_TOO_MANY_INCLUDE_FILES); + } + global->include[global->included] = (char *)tags->data; + + global->includeshow[global->included] = + (tags->tag == FPPTAG_INCLUDE_FILE); + + global->included++; + break; + case FPPTAG_BUILTINS: + global->nflag|=(tags->data?NFLAG_BUILTIN:0); + break; + case FPPTAG_PREDEFINES: + global->nflag|=(tags->data?NFLAG_PREDEFINE:0); + break; + case FPPTAG_IGNORE_CPLUSPLUS: + global->cplusplus=!tags->data; + break; + case FPPTAG_SIZEOF_TABLE: + { + SIZES *sizp; /* For -S */ + int size; /* For -S */ + int isdatum; /* FALSE for -S* */ + int endtest; /* For -S */ + + char *text=(char *)tags->data; + + sizp = size_table; + if (isdatum = (*text != '*')) /* If it's just -S, */ + endtest = T_FPTR; /* Stop here */ + else { /* But if it's -S* */ + text++; /* Step over '*' */ + endtest = 0; /* Stop at end marker */ + } + while (sizp->bits != endtest && *text != EOS) { + if (!isdigit(*text)) { /* Skip to next digit */ + text++; + continue; + } + size = 0; /* Compile the value */ + while (isdigit(*text)) { + size *= 10; + size += (*text++ - '0'); + } + if (isdatum) + sizp->size = size; /* Datum size */ + else + sizp->psize = size; /* Pointer size */ + sizp++; + } + if (sizp->bits != endtest) + cwarn(global, WARN_TOO_FEW_VALUES_TO_SIZEOF, NULL); + else if (*text != EOS) + cwarn(global, WARN_TOO_MANY_VALUES_TO_SIZEOF, NULL); + } + break; + case FPPTAG_UNDEFINE: + if (defendel(global, (char *)tags->data, TRUE) == NULL) + cwarn(global, WARN_NOT_DEFINED, tags->data); + break; + case FPPTAG_OUTPUT_DEFINES: + global->wflag++; + break; + case FPPTAG_INPUT_NAME: + strcpy(global->work, tags->data); /* Remember input filename */ + global->first_file=tags->data; + break; + case FPPTAG_INPUT: + global->input=(char *(*)(char *, int, void *))tags->data; + break; + case FPPTAG_OUTPUT: + global->output=(void (*)(int, void *))tags->data; + break; + case FPPTAG_ERROR: + global->error=(void (*)(void *, char *, va_list))tags->data; + break; + case FPPTAG_USERDATA: + global->userdata=tags->data; + break; + case FPPTAG_LINE: + global->linelines= tags->data?1:0; + break; + case FPPTAG_EXCLFUNC: + global->excludedinit[ global->excluded++ ] = (char *)tags->data; + break; + case FPPTAG_WEBMODE: + global->webmode=(tags->data?1:0); + break; + default: + cwarn(global, WARN_INTERNAL_ERROR, NULL); + break; + } + tags++; + } + return(0); +} + +ReturnCode initdefines(struct Global *global) +{ + /* + * Initialize the built-in #define's. There are two flavors: + * #define decus 1 (static definitions) + * #define __FILE__ ?? (dynamic, evaluated by magic) + * Called only on cpp startup. + * + * Note: the built-in static definitions are supressed by the -N option. + * __LINE__, __FILE__, __TIME__ and __DATE__ are always present. + */ + + char **pp; + char *tp; + DEFBUF *dp; + struct tm *tm; + + int i; + time_t tvec; + + static char months[12][4] = { + "Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" + }; + + /* + * Predefine the built-in symbols. Allow the + * implementor to pre-define a symbol as "" to + * eliminate it. + */ + if (!(global->nflag & NFLAG_BUILTIN)) { + for (pp = global->preset; *pp != NULL; pp++) { + if (*pp[0] != EOS) { + dp = defendel(global, *pp, FALSE); + if(!dp) + return(FPP_OUT_OF_MEMORY); + dp->repl = savestring(global, "1"); + dp->nargs = DEF_NOARGS; + } + } + } + /* + * The magic pre-defines (__FILE__ and __LINE__ are + * initialized with negative argument counts. expand() + * notices this and calls the appropriate routine. + * DEF_NOARGS is one greater than the first "magic" definition. + */ + if (!(global->nflag & NFLAG_PREDEFINE)) { + for (pp = global->magic, i = DEF_NOARGS; *pp != NULL; pp++) { + dp = defendel(global, *pp, FALSE); + if(!dp) + return(FPP_OUT_OF_MEMORY); + dp->nargs = --i; + } +#if OK_DATE + /* + * Define __DATE__ as today's date. + */ + dp = defendel(global, "__DATE__", FALSE); + tp = malloc(14); + if(!tp || !dp) + return(FPP_OUT_OF_MEMORY); + dp->repl = tp; + dp->nargs = DEF_NOARGS; + time(&tvec); + tm = localtime(&tvec); + sprintf(tp, "\"%3s %2d %4d\"", /* "Aug 20 1988" */ + months[tm->tm_mon], + tm->tm_mday, + tm->tm_year + 1900); + + /* + * Define __TIME__ as this moment's time. + */ + dp = defendel(global, "__TIME__", FALSE); + tp = malloc(11); + if(!tp || !dp) + return(FPP_OUT_OF_MEMORY); + dp->repl = tp; + dp->nargs = DEF_NOARGS; + sprintf(tp, "\"%2d:%02d:%02d\"", /* "20:42:31" */ + tm->tm_hour, + tm->tm_min, + tm->tm_sec); +#endif + } + return(FPP_OK); +} + +void deldefines(struct Global *global) +{ + /* + * Delete the built-in #define's. + */ + char **pp; + int i; + + + /* + * Delete the built-in symbols, unless -WW. + */ + if (global->wflag < 2) { + for (pp = global->preset; *pp != NULL; pp++) { + defendel(global, *pp, TRUE); + } + } + /* + * The magic pre-defines __FILE__ and __LINE__ + */ + for (pp = global->magic, i = DEF_NOARGS; *pp != NULL; pp++) { + defendel(global, *pp, TRUE); + } +#if OK_DATE + /* + * Undefine __DATE__. + */ + defendel(global, "__DATE__", TRUE); + + /* + * Undefine __TIME__. + */ + defendel(global, "__TIME__", TRUE); +#endif + return; +} + diff --git a/3rdparty/fcpp/cpp4.c b/3rdparty/fcpp/cpp4.c new file mode 100644 index 000000000..2c64af211 --- /dev/null +++ b/3rdparty/fcpp/cpp4.c @@ -0,0 +1,633 @@ +/****************************************************************************** +Copyright (c) 1999 Daniel Stenberg + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +******************************************************************************/ +#include +#include +#include "cppdef.h" +#include "cpp.h" + +INLINE FILE_LOCAL ReturnCode checkparm(struct Global *, int, DEFBUF *, int); +INLINE FILE_LOCAL ReturnCode stparmscan(struct Global *, int); +INLINE FILE_LOCAL ReturnCode textput(struct Global *, char *); +FILE_LOCAL ReturnCode charput(struct Global *, int); +INLINE FILE_LOCAL ReturnCode expcollect(struct Global *); +INLINE FILE_LOCAL char *doquoting(char *, char *); + + +ReturnCode dodefine(struct Global *global) +{ + /* + * Called from control when a #define is scanned. This module + * parses formal parameters and the replacement string. When + * the formal parameter name is encountered in the replacement + * string, it is replaced by a character in the range 128 to + * 128+NPARAM (this allows up to 32 parameters within the + * Dec Multinational range). If cpp is ported to an EBCDIC + * machine, you will have to make other arrangements. + * + * There is some special case code to distinguish + * #define foo bar + * from #define foo() bar + * + * Also, we make sure that + * #define foo foo + * expands to "foo" but doesn't put cpp into an infinite loop. + * + * A warning message is printed if you redefine a symbol to a + * different text. I.e, + * #define foo 123 + * #define foo 123 + * is ok, but + * #define foo 123 + * #define foo +123 + * is not. + * + * The following subroutines are called from define(): + * checkparm called when a token is scanned. It checks through the + * array of formal parameters. If a match is found, the + * token is replaced by a control byte which will be used + * to locate the parameter when the macro is expanded. + * textput puts a string in the macro work area (parm[]), updating + * parmp to point to the first free byte in parm[]. + * textput() tests for work buffer overflow. + * charput puts a single character in the macro work area (parm[]) + * in a manner analogous to textput(). + */ + int c; + DEFBUF *dp; /* -> new definition */ + int isredefine; /* TRUE if redefined */ + char *old; /* Remember redefined */ + ReturnCode ret; +#if OK_CONCAT + int quoting; /* Remember we saw a # */ +#endif + + if (type[(c = skipws(global))] != LET) { + cerror(global, ERROR_DEFINE_SYNTAX); + global->inmacro = FALSE; /* Stop hack */ + return(FPP_OK); + } + isredefine = FALSE; /* Set if redefining */ + if ((dp = lookid(global, c)) == NULL) { /* If not known now */ + dp = defendel(global, global->tokenbuf, FALSE); /* Save the name */ + if(!dp) + return(FPP_OUT_OF_MEMORY); + } else { /* It's known: */ + isredefine = TRUE; /* Remember this fact */ + old = dp->repl; /* Remember replacement */ + dp->repl = NULL; /* No replacement now */ + } + global->parlist[0] = global->parmp = global->parm; /* Setup parm buffer */ + if ((c = get(global)) == '(') { /* With arguments? */ + global->nargs = 0; /* Init formals counter */ + do { /* Collect formal parms */ + if (global->nargs >= LASTPARM) { + cfatal(global, FATAL_TOO_MANY_ARGUMENTS_MACRO); + return(FPP_TOO_MANY_ARGUMENTS); + } else if ((c = skipws(global)) == ')') + break; /* Got them all */ + else if (type[c] != LET) { /* Bad formal syntax */ + cerror(global, ERROR_DEFINE_SYNTAX); + global->inmacro = FALSE; /* Stop hack */ + return(FPP_OK); + } + scanid(global, c); /* Get the formal param */ + global->parlist[global->nargs++] = global->parmp; /* Save its start */ + ret=textput(global, global->tokenbuf); /* Save text in parm[] */ + if(ret) + return(ret); + } while ((c = skipws(global)) == ','); /* Get another argument */ + if (c != ')') { /* Must end at ) */ + cerror(global, ERROR_DEFINE_SYNTAX); + global->inmacro = FALSE; /* Stop hack */ + return(FPP_OK); + } + c = ' '; /* Will skip to body */ + } + else { + /* + * DEF_NOARGS is needed to distinguish between + * "#define foo" and "#define foo()". + */ + global->nargs = DEF_NOARGS; /* No () parameters */ + } + if (type[c] == SPA) /* At whitespace? */ + c = skipws(global); /* Not any more. */ + global->workp = global->work; /* Replacement put here */ + global->inmacro = TRUE; /* Keep \ now */ + quoting = 0; /* No # seen yet. */ + while (c != EOF_CHAR && c != '\n') { /* Compile macro body */ +#if OK_CONCAT + if (c == '#') { /* Token concatenation? */ + if ((c = get(global)) != '#') { /* No, not really */ + quoting = 1; /* Maybe quoting op. */ + continue; + } + while (global->workp > global->work && type[global->workp[-1]] == SPA) + --global->workp; /* Erase leading spaces */ + if(ret=save(global, TOK_SEP)) /* Stuff a delimiter */ + return(ret); + c = skipws(global); /* Eat whitespace */ + continue; + } +#endif + switch (type[c]) { + case LET: +#if OK_CONCAT + ret=checkparm(global, c, dp, quoting); /* Might be a formal */ +#else + ret=checkparm(c, dp); /* Might be a formal */ +#endif + if(ret) + return(ret); + break; + + case DIG: /* Number in mac. body */ + case DOT: /* Maybe a float number */ + ret=scannumber(global, c, save); /* Scan it off */ + if(ret) + return(ret); + break; + + case QUO: /* String in mac. body */ + ret=stparmscan(global, c); + if(ret) + return(ret); + break; + + case BSH: /* Backslash */ + ret=save(global, '\\'); + if(ret) + return(ret); + if ((c = get(global)) == '\n') + global->wrongline = TRUE; + ret=save(global, c); + if(ret) + return(ret); + break; + + case SPA: /* Absorb whitespace */ + /* + * Note: the "end of comment" marker is passed on + * to allow comments to separate tokens. + */ + if (global->workp[-1] == ' ') /* Absorb multiple */ + break; /* spaces */ + else if (c == '\t') + c = ' '; /* Normalize tabs */ + /* Fall through to store character */ + default: /* Other character */ + ret=save(global, c); + if(ret) + return(ret); + break; + } + c = get(global); + quoting = 0; /* Only when immediately*/ + /* preceding a formal */ + } + global->inmacro = FALSE; /* Stop newline hack */ + unget(global); /* For control check */ + if (global->workp > global->work && global->workp[-1] == ' ') /* Drop trailing blank */ + global->workp--; + *global->workp = EOS; /* Terminate work */ + dp->repl = savestring(global, global->work); /* Save the string */ + dp->nargs = global->nargs; /* Save arg count */ + if (isredefine) { /* Error if redefined */ + if ((old != NULL && dp->repl != NULL && !streq(old, dp->repl)) + || (old == NULL && dp->repl != NULL) + || (old != NULL && dp->repl == NULL)) { + cerror(global, ERROR_REDEFINE, dp->name); + } + if (old != NULL) /* We don't need the */ + free(old); /* old definition now. */ + } + return(FPP_OK); +} + +INLINE FILE_LOCAL +ReturnCode checkparm(struct Global *global, + int c, + DEFBUF *dp, + int quoting) /* Preceded by a # ? */ +{ + /* + * Replace this param if it's defined. Note that the macro name is a + * possible replacement token. We stuff DEF_MAGIC in front of the token + * which is treated as a LETTER by the token scanner and eaten by + * the output routine. This prevents the macro expander from + * looping if someone writes "#define foo foo". + */ + + int i; + char *cp; + ReturnCode ret=FPP_OK; + + scanid(global, c); /* Get parm to tokenbuf */ + for (i = 0; i < global->nargs; i++) { /* For each argument */ + if (streq(global->parlist[i], global->tokenbuf)) { /* If it's known */ +#if OK_CONCAT + if (quoting) { /* Special handling of */ + ret=save(global, QUOTE_PARM); /* #formal inside defn */ + if(ret) + return(ret); + } +#endif + ret=save(global, i + MAC_PARM); /* Save a magic cookie */ + return(ret); /* And exit the search */ + } + } + if (streq(dp->name, global->tokenbuf)) /* Macro name in body? */ + ret=save(global, DEF_MAGIC); /* Save magic marker */ + for (cp = global->tokenbuf; *cp != EOS;) /* And save */ + ret=save(global, *cp++); /* The token itself */ + return(ret); +} + +INLINE FILE_LOCAL +ReturnCode stparmscan(struct Global *global, int delim) +{ + /* + * Normal string parameter scan. + */ + + unsigned char *wp; + int i; + ReturnCode ret; + + wp = (unsigned char *)global->workp; /* Here's where it starts */ + ret=scanstring(global, delim, save); + if(ret) + return(ret); /* Exit on scanstring error */ + global->workp[-1] = EOS; /* Erase trailing quote */ + wp++; /* -> first string content byte */ + for (i = 0; i < global->nargs; i++) { + if (streq(global->parlist[i], (char *)wp)) { + *wp++ = MAC_PARM + PAR_MAC; /* Stuff a magic marker */ + *wp++ = (i + MAC_PARM); /* Make a formal marker */ + *wp = wp[-3]; /* Add on closing quote */ + global->workp = (char *)wp + 1; /* Reset string end */ + return(FPP_OK); + } + } + global->workp[-1] = wp[-1]; /* Nope, reset end quote. */ + return(FPP_OK); +} + +void doundef(struct Global *global) + /* + * Remove the symbol from the defined list. + * Called from the #control processor. + */ +{ + int c; + if (type[(c = skipws(global))] != LET) + cerror(global, ERROR_ILLEGAL_UNDEF); + else { + scanid(global, c); /* Get name to tokenbuf */ + (void) defendel(global, global->tokenbuf, TRUE); + } +} + +INLINE FILE_LOCAL +ReturnCode textput(struct Global *global, char *text) +{ + /* + * Put the string in the parm[] buffer. + */ + + int size; + + size = strlen(text) + 1; + if ((global->parmp + size) >= &global->parm[NPARMWORK]) { + cfatal(global, FATAL_MACRO_AREA_OVERFLOW); + return(FPP_WORK_AREA_OVERFLOW); + } else { + strcpy(global->parmp, text); + global->parmp += size; + } + return(FPP_OK); +} + +FILE_LOCAL +ReturnCode charput(struct Global *global, int c) +{ + /* + * Put the byte in the parm[] buffer. + */ + + if (global->parmp >= &global->parm[NPARMWORK]) { + cfatal(global, FATAL_MACRO_AREA_OVERFLOW); + return(FPP_WORK_AREA_OVERFLOW); + } + *global->parmp++ = c; + return(FPP_OK); +} + +/* + * M a c r o E x p a n s i o n + */ + +ReturnCode expand(struct Global *global, DEFBUF *tokenp) +{ + /* + * Expand a macro. Called from the cpp mainline routine (via subroutine + * macroid()) when a token is found in the symbol table. It calls + * expcollect() to parse actual parameters, checking for the correct number. + * It then creates a "file" containing a single line containing the + * macro with actual parameters inserted appropriately. This is + * "pushed back" onto the input stream. (When the get() routine runs + * off the end of the macro line, it will dismiss the macro itself.) + */ + int c; + FILEINFO *file; + ReturnCode ret=FPP_OK; + + /* + * If no macro is pending, save the name of this macro + * for an eventual error message. + */ + if (global->recursion++ == 0) + global->macro = tokenp; + else if (global->recursion == RECURSION_LIMIT) { + cerror(global, ERROR_RECURSIVE_MACRO, tokenp->name, global->macro->name); + if (global->rec_recover) { + do { + c = get(global); + } while (global->infile != NULL && global->infile->fp == NULL); + unget(global); + global->recursion = 0; + return(FPP_OK); + } + } + /* + * Here's a macro to expand. + */ + global->nargs = 0; /* Formals counter */ + global->parmp = global->parm; /* Setup parm buffer */ + switch (tokenp->nargs) { + case (-2): /* __LINE__ */ + if(global->infile->fp) + /* This is a file */ + sprintf(global->work, "%d", global->line); + else + /* This is a macro! Find out the file line number! */ + for (file = global->infile; file != NULL; file = file->parent) { + if (file->fp != NULL) { + sprintf(global->work, "%d", file->line); + break; + } + } + ret=ungetstring(global, global->work); + if(ret) + return(ret); + break; + + case (-3): /* __FILE__ */ + for (file = global->infile; file != NULL; file = file->parent) { + if (file->fp != NULL) { + sprintf(global->work, "\"%s\"", (file->progname != NULL) + ? file->progname : file->filename); + ret=ungetstring(global, global->work); + if(ret) + return(ret); + break; + } + } + break; + + case (-4): /* __FUNC__ */ + sprintf(global->work, "\"%s\"", global->functionname[0]? + global->functionname : ""); + ret=ungetstring(global, global->work); + if(ret) + return(ret); + break; + + case (-5): /* __FUNC_LINE__ */ + sprintf(global->work, "%d", global->funcline); + ret=ungetstring(global, global->work); + if(ret) + return(ret); + break; + + default: + /* + * Nothing funny about this macro. + */ + if (tokenp->nargs < 0) { + cfatal(global, FATAL_ILLEGAL_MACRO, tokenp->name); + return(FPP_ILLEGAL_MACRO); + } + while ((c = skipws(global)) == '\n') /* Look for (, skipping */ + global->wrongline = TRUE; /* spaces and newlines */ + if (c != '(') { + /* + * If the programmer writes + * #define foo() ... + * ... + * foo [no ()] + * just write foo to the output stream. + */ + unget(global); + cwarn(global, WARN_MACRO_NEEDS_ARGUMENTS, tokenp->name); + + /* fputs(tokenp->name, stdout); */ + Putstring(global, tokenp->name); + return(FPP_OK); + } else if (!(ret=expcollect(global))) { /* Collect arguments */ + if (tokenp->nargs != global->nargs) { /* Should be an error? */ + cwarn(global, WARN_WRONG_NUMBER_ARGUMENTS, tokenp->name); + } + } else { /* Collect arguments */ + return(ret); /* We failed in argument colleting! */ + } + case DEF_NOARGS: /* No parameters just stuffs */ + ret=expstuff(global, tokenp->name, tokenp->repl); /* expand macro */ + } /* nargs switch */ + return(ret); +} + +INLINE FILE_LOCAL +ReturnCode expcollect(struct Global *global) +{ + /* + * Collect the actual parameters for this macro. + */ + + int c; + int paren; /* For embedded ()'s */ + ReturnCode ret; + + for (;;) { + paren = 0; /* Collect next arg. */ + while ((c = skipws(global)) == '\n')/* Skip over whitespace */ + global->wrongline = TRUE; /* and newlines. */ + if (c == ')') { /* At end of all args? */ + /* + * Note that there is a guard byte in parm[] + * so we don't have to check for overflow here. + */ + *global->parmp = EOS; /* Make sure terminated */ + break; /* Exit collection loop */ + } + else if (global->nargs >= LASTPARM) { + cfatal(global, FATAL_TOO_MANY_ARGUMENTS_EXPANSION); + return(FPP_TOO_MANY_ARGUMENTS); + } + global->parlist[global->nargs++] = global->parmp; /* At start of new arg */ + for (;; c = cget(global)) { /* Collect arg's bytes */ + if (c == EOF_CHAR) { + cerror(global, ERROR_EOF_IN_ARGUMENT); + return(FPP_EOF_IN_MACRO); /* Sorry. */ + } + else if (c == '\\') { /* Quote next character */ + charput(global, c); /* Save the \ for later */ + charput(global, cget(global)); /* Save the next char. */ + continue; /* And go get another */ + } + else if (type[c] == QUO) { /* Start of string? */ + ret=scanstring(global, c, (ReturnCode (*)(struct Global *, int))charput); /* Scan it off */ + if(ret) + return(ret); + continue; /* Go get next char */ + } + else if (c == '(') /* Worry about balance */ + paren++; /* To know about commas */ + else if (c == ')') { /* Other side too */ + if (paren == 0) { /* At the end? */ + unget(global); /* Look at it later */ + break; /* Exit arg getter. */ + } + paren--; /* More to come. */ + } + else if (c == ',' && paren == 0) /* Comma delimits args */ + break; + else if (c == '\n') /* Newline inside arg? */ + global->wrongline = TRUE; /* We'll need a #line */ + charput(global, c); /* Store this one */ + } /* Collect an argument */ + charput(global, EOS); /* Terminate argument */ + } /* Collect all args. */ + return(FPP_OK); /* Normal return */ +} + + +#if OK_CONCAT + +INLINE FILE_LOCAL +char *doquoting(char *to, char *from) +{ + *to++ = '"'; + while (*from) { + if (*from == '\\' || *from == '"') + *to++ = '\\'; + *to++ = *from++; + } + *to++ = '"'; + + return to; +} + +#endif + +ReturnCode expstuff(struct Global *global, + char *MacroName, + char *MacroReplace) +{ + /* + * Stuff the macro body, replacing formal parameters by actual parameters. + */ + int c; /* Current character */ + char *inp; /* -> repl string */ + char *defp; /* -> macro output buff */ + int size; /* Actual parm. size */ + char *defend; /* -> output buff end */ + int string_magic; /* String formal hack */ + FILEINFO *file; /* Funny #include */ + ReturnCode ret; +#if OK_CONCAT + char quoting; /* Quote macro argument */ +#endif + + ret = getfile(global, NBUFF, MacroName, &file); + if(ret) + return(ret); + inp = MacroReplace; /* -> macro replacement */ + defp = file->buffer; /* -> output buffer */ + defend = defp + (NBUFF - 1); /* Note its end */ + if (inp != NULL) { + quoting = 0; + while ((c = (*inp++ & 0xFF)) != EOS) { +#if OK_CONCAT + if (c == QUOTE_PARM) { /* Special token for # */ + quoting = 1; /* set flag, for later */ + continue; /* Get next character */ + } +#endif + if (c >= MAC_PARM && c <= (MAC_PARM + PAR_MAC)) { + string_magic = (c == (MAC_PARM + PAR_MAC)); + if (string_magic) + c = (*inp++ & 0xFF); + /* + * Replace formal parameter by actual parameter string. + */ + if ((c -= MAC_PARM) < global->nargs) { + size = strlen(global->parlist[c]); +#if OK_CONCAT + if (quoting) { + size++; + size *= 2; /* worst case condition */ + } +#endif + if ((defp + size) >= defend) { + cfatal(global, FATAL_OUT_OF_SPACE_IN_ARGUMENT, MacroName); + return(FPP_OUT_OF_SPACE_IN_MACRO_EXPANSION); + } + /* + * Erase the extra set of quotes. + */ + if (string_magic && defp[-1] == global->parlist[c][0]) { + strcpy(defp-1, global->parlist[c]); + defp += (size - 2); + } +#if OK_CONCAT +else if (quoting) + defp = doquoting(defp, global->parlist[c]); +#endif +else { + strcpy(defp, global->parlist[c]); + defp += size; +} + } + } + else if (defp >= defend) { + cfatal(global, FATAL_OUT_OF_SPACE_IN_ARGUMENT, MacroName); + return(FPP_OUT_OF_SPACE_IN_MACRO_EXPANSION); + } else + *defp++ = c; + quoting = 0; + } + } + *defp = EOS; + return(FPP_OK); +} + diff --git a/3rdparty/fcpp/cpp5.c b/3rdparty/fcpp/cpp5.c new file mode 100644 index 000000000..c1aa8f489 --- /dev/null +++ b/3rdparty/fcpp/cpp5.c @@ -0,0 +1,903 @@ +/****************************************************************************** +Copyright (c) 1999 Daniel Stenberg + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +******************************************************************************/ +#include +#include +#include "cppdef.h" +#include "cpp.h" + +INLINE FILE_LOCAL ReturnCode evallex(struct Global *, int, int *); +INLINE FILE_LOCAL ReturnCode dosizeof(struct Global *, int *); +INLINE FILE_LOCAL int bittest(int); +INLINE FILE_LOCAL int evalnum(struct Global *, int); +INLINE FILE_LOCAL int evalchar(struct Global *, int); +INLINE FILE_LOCAL int *evaleval(struct Global *, int *, int, int); + +/* + * Evaluate an #if expression. + */ + +static char *opname[] = { /* For debug and error messages */ + "end of expression", "val", "id", + "+", "-", "*", "/", "%", + "<<", ">>", "&", "|", "^", + "==", "!=", "<", "<=", ">=", ">", + "&&", "||", "?", ":", ",", + "unary +", "unary -", "~", "!", "(", ")", "(none)", +}; + +/* + * opdope[] has the operator precedence: + * Bits + * 7 Unused (so the value is always positive) + * 6-2 Precedence (000x .. 017x) + * 1-0 Binary op. flags: + * 01 The binop flag should be set/cleared when this op is seen. + * 10 The new value of the binop flag. + * Note: Expected, New binop + * constant 0 1 Binop, end, or ) should follow constants + * End of line 1 0 End may not be preceeded by an operator + * binary 1 0 Binary op follows a value, value follows. + * unary 0 0 Unary op doesn't follow a value, value follows + * ( 0 0 Doesn't follow value, value or unop follows + * ) 1 1 Follows value. Op follows. + */ + +static char opdope[OP_MAX] = { + 0001, /* End of expression */ + 0002, /* Digit */ + 0000, /* Letter (identifier) */ + 0141, 0141, 0151, 0151, 0151, /* ADD, SUB, MUL, DIV, MOD */ + 0131, 0131, 0101, 0071, 0071, /* ASL, ASR, AND, OR, XOR */ + 0111, 0111, 0121, 0121, 0121, 0121, /* EQ, NE, LT, LE, GE, GT */ + 0061, 0051, 0041, 0041, 0031, /* ANA, ORO, QUE, COL, CMA */ + /* + * Unary op's follow + */ + 0160, 0160, 0160, 0160, /* NEG, PLU, COM, NOT */ + 0170, 0013, 0023, /* LPA, RPA, END */ +}; +/* + * OP_QUE and OP_RPA have alternate precedences: + */ +#define OP_RPA_PREC 0013 +#define OP_QUE_PREC 0034 + +/* + * S_ANDOR and S_QUEST signal "short-circuit" boolean evaluation, so that + * #if FOO != 0 && 10 / FOO ... + * doesn't generate an error message. They are stored in optab.skip. + */ +#define S_ANDOR 2 +#define S_QUEST 1 + +typedef struct optab { + char op; /* Operator */ + char prec; /* Its precedence */ + char skip; /* Short-circuit: TRUE to skip */ +} OPTAB; + +#ifdef nomacargs + FILE_LOCAL int + isbinary(op) + int op; +{ + return (op >= FIRST_BINOP && op <= LAST_BINOP); +} + +FILE_LOCAL int + isunary(op) +int op; +{ + return (op >= FIRST_UNOP && op <= LAST_UNOP); +} +#else +#define isbinary(op) (op >= FIRST_BINOP && op <= LAST_BINOP) +#define isunary(op) (op >= FIRST_UNOP && op <= LAST_UNOP) +#endif + +/* + * The following definitions are used to specify basic variable sizes. + */ + +#if OK_SIZEOF + +#ifndef S_CHAR +#define S_CHAR (sizeof (char)) +#endif +#ifndef S_SINT +#ifdef manx /* Aztec/Manx C does not like "short int" */ +#define S_SINT (sizeof (short)) +#else +#define S_SINT (sizeof (short int)) +#endif +#endif +#ifndef S_INT +#define S_INT (sizeof (int)) +#endif +#ifndef S_LINT +#define S_LINT (sizeof (long int)) +#endif +#ifndef S_FLOAT +#define S_FLOAT (sizeof (float)) +#endif +#ifndef S_DOUBLE +#define S_DOUBLE (sizeof (double)) +#endif +#ifndef S_PCHAR +#define S_PCHAR (sizeof (char *)) +#endif +#ifndef S_PSINT +#ifdef manx /* Aztec/Manx C does not like "short int" */ +#define S_PSINT (sizeof (short *)) +#else +#define S_PSINT (sizeof (short int *)) +#endif +#endif +#ifndef S_PINT +#define S_PINT (sizeof (int *)) +#endif +#ifndef S_PLINT +#define S_PLINT (sizeof (long int *)) +#endif +#ifndef S_PFLOAT +#define S_PFLOAT (sizeof (float *)) +#endif +#ifndef S_PDOUBLE +#define S_PDOUBLE (sizeof (double *)) +#endif +#ifndef S_PFPTR +#define S_PFPTR (sizeof (int (*)())) +#endif + + +typedef struct types { + short type; /* This is the bit if */ + char *name; /* this is the token word */ +} TYPES; + +static TYPES basic_types[] = { + { T_CHAR, "char", }, + { T_INT, "int", }, + { T_FLOAT, "float", }, + { T_DOUBLE, "double", }, + { T_SHORT, "short", }, + { T_LONG, "long", }, + { T_SIGNED, "signed", }, + { T_UNSIGNED, "unsigned", }, + { 0, NULL, }, /* Signal end */ +}; + +/* + * Test_table[] is used to test for illegal combinations. + */ +static short test_table[] = { + T_FLOAT | T_DOUBLE | T_LONG | T_SHORT, + T_FLOAT | T_DOUBLE | T_CHAR | T_INT, + T_FLOAT | T_DOUBLE | T_SIGNED | T_UNSIGNED, + T_LONG | T_SHORT | T_CHAR, + 0 /* end marker */ + }; + +/* + * The order of this table is important -- it is also referenced by + * the command line processor to allow run-time overriding of the + * built-in size values. The order must not be changed: + * char, short, int, long, float, double (func pointer) + */ +SIZES size_table[] = { + { T_CHAR, S_CHAR, S_PCHAR }, /* char */ + { T_SHORT, S_SINT, S_PSINT }, /* short int */ + { T_INT, S_INT, S_PINT }, /* int */ + { T_LONG, S_LINT, S_PLINT }, /* long */ + { T_FLOAT, S_FLOAT, S_PFLOAT }, /* float */ + { T_DOUBLE, S_DOUBLE, S_PDOUBLE }, /* double */ + { T_FPTR, 0, S_PFPTR }, /* int (*()) */ + { 0, 0, 0 }, /* End of table */ +}; + +#endif /* OK_SIZEOF */ + +ReturnCode eval(struct Global *global, int *eval) +{ + /* + * Evaluate an expression. Straight-forward operator precedence. + * This is called from control() on encountering an #if statement. + * It calls the following routines: + * evallex Lexical analyser -- returns the type and value of + * the next input token. + * evaleval Evaluate the current operator, given the values on + * the value stack. Returns a pointer to the (new) + * value stack. + * For compatiblity with older cpp's, this return returns 1 (TRUE) + * if a syntax error is detected. + */ + int op; /* Current operator */ + int *valp; /* -> value vector */ + OPTAB *opp; /* Operator stack */ + int prec; /* Op precedence */ + int binop; /* Set if binary op. needed */ + int op1; /* Operand from stack */ + int skip; /* For short-circuit testing */ + int value[NEXP]; /* Value stack */ + OPTAB opstack[NEXP]; /* Operand stack */ + ReturnCode ret; + char again=TRUE; + + valp = value; + opp = opstack; + opp->op = OP_END; /* Mark bottom of stack */ + opp->prec = opdope[OP_END]; /* And its precedence */ + opp->skip = 0; /* Not skipping now */ + binop = 0; + + while(again) { + ret=evallex(global, opp->skip, &op); + if(ret) + return(ret); + if (op == OP_SUB && binop == 0) + op = OP_NEG; /* Unary minus */ + else if (op == OP_ADD && binop == 0) + op = OP_PLU; /* Unary plus */ + else if (op == OP_FAIL) { + *eval=1; /* Error in evallex */ + return(FPP_OK); + } + if (op == DIG) { /* Value? */ + if (binop != 0) { + cerror(global, ERROR_MISPLACED_CONSTANT); + *eval=1; + return(FPP_OK); + } else if (valp >= &value[NEXP-1]) { + cerror(global, ERROR_IF_OVERFLOW); + *eval=1; + return(FPP_OK); + } else { + *valp++ = global->evalue; + binop = 1; + } + again=TRUE; + continue; + } else if (op > OP_END) { + cerror(global, ERROR_ILLEGAL_IF_LINE); + *eval=1; + return(FPP_OK); + } + prec = opdope[op]; + if (binop != (prec & 1)) { + cerror(global, ERROR_OPERATOR, opname[op]); + *eval=1; + return(FPP_OK); + } + binop = (prec & 2) >> 1; + do { + if (prec > opp->prec) { + if (op == OP_LPA) + prec = OP_RPA_PREC; + else if (op == OP_QUE) + prec = OP_QUE_PREC; + op1 = opp->skip; /* Save skip for test */ + /* + * Push operator onto op. stack. + */ + opp++; + if (opp >= &opstack[NEXP]) { + cerror(global, ERROR_EXPR_OVERFLOW, opname[op]); + *eval=1; + return(FPP_OK); + } + opp->op = op; + opp->prec = prec; + skip = (valp[-1] != 0); /* Short-circuit tester */ + /* + * Do the short-circuit stuff here. Short-circuiting + * stops automagically when operators are evaluated. + */ + if ((op == OP_ANA && !skip) + || (op == OP_ORO && skip)) + opp->skip = S_ANDOR; /* And/or skip starts */ + else if (op == OP_QUE) /* Start of ?: operator */ + opp->skip = (op1 & S_ANDOR) | ((!skip) ? S_QUEST : 0); + else if (op == OP_COL) { /* : inverts S_QUEST */ + opp->skip = (op1 & S_ANDOR) + | (((op1 & S_QUEST) != 0) ? 0 : S_QUEST); + } + else { /* Other ops leave */ + opp->skip = op1; /* skipping unchanged. */ + } + again=TRUE; + continue; + } + /* + * Pop operator from op. stack and evaluate it. + * End of stack and '(' are specials. + */ + skip = opp->skip; /* Remember skip value */ + switch ((op1 = opp->op)) { /* Look at stacked op */ + case OP_END: /* Stack end marker */ + if (op == OP_EOE) { + *eval=valp[-1]; /* Finished ok. */ + return(FPP_OK); + } + /* Read another op. */ + again=TRUE; + continue; + case OP_LPA: /* ( on stack */ + if (op != OP_RPA) { /* Matches ) on input */ + cerror(global, ERROR_UNBALANCED_PARENS, opname[op]); + *eval=1; + return(FPP_OK); + } + opp--; /* Unstack it */ + /* -- Fall through */ + case OP_QUE: + /* Evaluate true expr. */ + again=TRUE; + continue; + case OP_COL: /* : on stack. */ + opp--; /* Unstack : */ + if (opp->op != OP_QUE) { /* Matches ? on stack? */ + cerror(global, ERROR_MISPLACED, opname[opp->op]); + *eval=1; + return(FPP_OK); + } + /* + * Evaluate op1. + */ + default: /* Others: */ + opp--; /* Unstack the operator */ + valp = evaleval(global, valp, op1, skip); + again=FALSE; + } /* op1 switch end */ + } while (!again); /* Stack unwind loop */ + } + return(FPP_OK); +} + +INLINE FILE_LOCAL +ReturnCode evallex(struct Global *global, + int skip, /* TRUE if short-circuit evaluation */ + int *op) +{ + /* + * Set *op to next eval operator or value. Called from eval(). It + * calls a special-purpose routines for 'char' strings and + * numeric values: + * evalchar called to evaluate 'x' + * evalnum called to evaluate numbers. + */ + + int c, c1, t; + ReturnCode ret; + char loop; + + do { /* while(loop); */ + /* again: */ + loop=FALSE; + do { /* Collect the token */ + c = skipws(global); + if(ret=macroid(global, &c)) + return(ret); + if (c == EOF_CHAR || c == '\n') { + unget(global); + *op=OP_EOE; /* End of expression */ + return(FPP_OK); + } + } while ((t = type[c]) == LET && catenate(global, &ret) && !ret); + if(ret) + /* If the loop was broken because of a fatal error! */ + return(ret); + if (t == INV) { /* Total nonsense */ + if (!skip) { + if (isascii(c) && isprint(c)) + cerror(global, ERROR_ILLEGAL_CHARACTER, c); + else + cerror(global, ERROR_ILLEGAL_CHARACTER2, c); + } + return(FPP_ILLEGAL_CHARACTER); + } else if (t == QUO) { /* ' or " */ + if (c == '\'') { /* Character constant */ + global->evalue = evalchar(global, skip); /* Somewhat messy */ + *op=DIG; /* Return a value */ + return(FPP_OK); + } + cerror(global, ERROR_STRING_IN_IF); + return(FPP_CANT_USE_STRING_IN_IF); + } else if (t == LET) { /* ID must be a macro */ + if (streq(global->tokenbuf, "defined")) { /* Or defined name */ + c1 = c = skipws(global); + if (c == '(') /* Allow defined(name) */ + c = skipws(global); + if (type[c] == LET) { + global->evalue = (lookid(global, c) != NULL); + if (c1 != '(' /* Need to balance */ + || skipws(global) == ')') { /* Did we balance? */ + *op=DIG; + return(FPP_OK); /* Parsed ok */ + } + } + cerror(global, ERROR_DEFINED_SYNTAX); + return(FPP_BAD_IF_DEFINED_SYNTAX); + } +#if OK_SIZEOF +else if (streq(global->tokenbuf, "sizeof")) { /* New sizeof hackery */ + ret=dosizeof(global, op); /* Gets own routine */ + return(ret); +} +#endif + global->evalue = 0; + *op=DIG; + return(FPP_OK); + } + else if (t == DIG) { /* Numbers are harder */ + global->evalue = evalnum(global, c); + } + else if (strchr("!=<>&|\\", c) != NULL) { + /* + * Process a possible multi-byte lexeme. + */ + c1 = cget(global); /* Peek at next char */ + switch (c) { + case '!': + if (c1 == '=') { + *op=OP_NE; + return(FPP_OK); + } + break; + + case '=': + if (c1 != '=') { /* Can't say a=b in #if */ + unget(global); + cerror(global, ERROR_ILLEGAL_ASSIGN); + return (FPP_IF_ERROR); + } + *op=OP_EQ; + return(FPP_OK); + + case '>': + case '<': + if (c1 == c) { + *op= ((c == '<') ? OP_ASL : OP_ASR); + return(FPP_OK); + } else if (c1 == '=') { + *op= ((c == '<') ? OP_LE : OP_GE); + return(FPP_OK); + } + break; + + case '|': + case '&': + if (c1 == c) { + *op= ((c == '|') ? OP_ORO : OP_ANA); + return(FPP_OK); + } + break; + + case '\\': + if (c1 == '\n') { /* Multi-line if */ + loop=TRUE; + break; + } + cerror(global, ERROR_ILLEGAL_BACKSLASH); + return(FPP_IF_ERROR); + } + if(!loop) + unget(global); + } + } while(loop); + *op=t; + return(FPP_OK); +} + +#if OK_SIZEOF + +INLINE FILE_LOCAL +ReturnCode dosizeof(struct Global *global, int *result) +{ + /* + * Process the sizeof (basic type) operation in an #if string. + * Sets evalue to the size and returns + * DIG success + * OP_FAIL bad parse or something. + */ + int c; + TYPES *tp; + SIZES *sizp; + short *testp; + short typecode; + ReturnCode ret; + + if ((c = skipws(global)) != '(') { + unget(global); + cerror(global, ERROR_SIZEOF_SYNTAX); + return(FPP_SIZEOF_ERROR); + } + /* + * Scan off the tokens. + */ + typecode = 0; + while ((c = skipws(global))) { + if(ret=macroid(global, &c)) + return(ret); + /* (I) return on fail! */ + if (c == EOF_CHAR || c == '\n') { + /* End of line is a bug */ + unget(global); + cerror(global, ERROR_SIZEOF_SYNTAX); + return(FPP_SIZEOF_ERROR); + } else if (c == '(') { /* thing (*)() func ptr */ + if (skipws(global) == '*' + && skipws(global) == ')') { /* We found (*) */ + if (skipws(global) != '(') /* Let () be optional */ + unget(global); + else if (skipws(global) != ')') { + unget(global); + cerror(global, ERROR_SIZEOF_SYNTAX); + return(FPP_SIZEOF_ERROR); + } + typecode |= T_FPTR; /* Function pointer */ + } else { /* Junk is a bug */ + unget(global); + cerror(global, ERROR_SIZEOF_SYNTAX); + return(FPP_SIZEOF_ERROR); + } + } + else if (type[c] != LET) /* Exit if not a type */ + break; + else if (!catenate(global, &ret) && !ret) { /* Maybe combine tokens */ + /* + * Look for this unexpandable token in basic_types. + * The code accepts "int long" as well as "long int" + * which is a minor bug as bugs go (and one shared with + * a lot of C compilers). + */ + for (tp = basic_types; tp->name != NULLST; tp++) { + if (streq(global->tokenbuf, tp->name)) + break; + } + if (tp->name == NULLST) { + cerror(global, ERROR_SIZEOF_UNKNOWN, global->tokenbuf); + return(FPP_SIZEOF_ERROR); + } + typecode |= tp->type; /* Or in the type bit */ + } else if(ret) + return(ret); + } + /* + * We are at the end of the type scan. Chew off '*' if necessary. + */ + if (c == '*') { + typecode |= T_PTR; + c = skipws(global); + } + if (c == ')') { /* Last syntax check */ + for (testp = test_table; *testp != 0; testp++) { + if (!bittest(typecode & *testp)) { + cerror(global, ERROR_SIZEOF_ILLEGAL_TYPE); + return(FPP_SIZEOF_ERROR); + } + } + /* + * We assume that all function pointers are the same size: + * sizeof (int (*)()) == sizeof (float (*)()) + * We assume that signed and unsigned don't change the size: + * sizeof (signed int) == (sizeof unsigned int) + */ + if ((typecode & T_FPTR) != 0) /* Function pointer */ + typecode = T_FPTR | T_PTR; + else { /* Var or var * datum */ + typecode &= ~(T_SIGNED | T_UNSIGNED); + if ((typecode & (T_SHORT | T_LONG)) != 0) + typecode &= ~T_INT; + } + if ((typecode & ~T_PTR) == 0) { + cerror(global, ERROR_SIZEOF_NO_TYPE); + return(FPP_SIZEOF_ERROR); + } + /* + * Exactly one bit (and possibly T_PTR) may be set. + */ + for (sizp = size_table; sizp->bits != 0; sizp++) { + if ((typecode & ~T_PTR) == sizp->bits) { + global->evalue = ((typecode & T_PTR) != 0) + ? sizp->psize : sizp->size; + *result=DIG; + return(FPP_OK); + } + } /* We shouldn't fail */ + cerror(global, ERROR_SIZEOF_BUG, typecode); + return(FPP_SIZEOF_ERROR); + } + unget(global); + cerror(global, ERROR_SIZEOF_SYNTAX); + return(FPP_SIZEOF_ERROR); +} + +INLINE FILE_LOCAL +int bittest(int value) +{ + /* + * TRUE if value is zero or exactly one bit is set in value. + */ + +#if (4096 & ~(-4096)) == 0 + return ((value & ~(-value)) == 0); +#else + /* + * Do it the hard way (for non 2's complement machines) + */ + return (value == 0 || value ^ (value - 1) == (value * 2 - 1)); +#endif +} + +#endif /* OK_SIZEOF */ + +INLINE FILE_LOCAL +int evalnum(struct Global *global, int c) +{ + /* + * Expand number for #if lexical analysis. Note: evalnum recognizes + * the unsigned suffix, but only returns a signed int value. + */ + + int value; + int base; + int c1; + + if (c != '0') + base = 10; + else if ((c = cget(global)) == 'x' || c == 'X') { + base = 16; + c = cget(global); + } + else base = 8; + value = 0; + for (;;) { + c1 = c; + if (isascii(c) && isupper(c1)) + c1 = tolower(c1); + if (c1 >= 'a') + c1 -= ('a' - 10); + else c1 -= '0'; + if (c1 < 0 || c1 >= base) + break; + value *= base; + value += c1; + c = cget(global); + } + if (c == 'u' || c == 'U') /* Unsigned nonsense */ + c = cget(global); + unget(global); + return (value); +} + +INLINE FILE_LOCAL +int evalchar(struct Global *global, + int skip) /* TRUE if short-circuit evaluation */ + /* + * Get a character constant + */ +{ + int c; + int value; + int count; + + global->instring = TRUE; + if ((c = cget(global)) == '\\') { + switch ((c = cget(global))) { + case 'a': /* New in Standard */ +#if ('a' == '\a' || '\a' == ALERT) + value = ALERT; /* Use predefined value */ +#else + value = '\a'; /* Use compiler's value */ +#endif + break; + + case 'b': + value = '\b'; + break; + + case 'f': + value = '\f'; + break; + + case 'n': + value = '\n'; + break; + + case 'r': + value = '\r'; + break; + + case 't': + value = '\t'; + break; + + case 'v': /* New in Standard */ +#if ('v' == '\v' || '\v' == VT) + value = VT; /* Use predefined value */ +#else + value = '\v'; /* Use compiler's value */ +#endif + break; + + case 'x': /* '\xFF' */ + count = 3; + value = 0; + while ((((c = get(global)) >= '0' && c <= '9') + || (c >= 'a' && c <= 'f') + || (c >= 'A' && c <= 'F')) + && (--count >= 0)) { + value *= 16; + value += (c <= '9') ? (c - '0') : ((c & 0xF) + 9); + } + unget(global); + break; + + default: + if (c >= '0' && c <= '7') { + count = 3; + value = 0; + while (c >= '0' && c <= '7' && --count >= 0) { + value *= 8; + value += (c - '0'); + c = get(global); + } + unget(global); + } else + value = c; + break; + } + } else if (c == '\'') + value = 0; + else value = c; + /* + * We warn on multi-byte constants and try to hack + * (big|little)endian machines. + */ +#if BIG_ENDIAN + count = 0; +#endif + while ((c = get(global)) != '\'' && c != EOF_CHAR && c != '\n') { + if (!skip) + cwarn(global, WARN_MULTIBYTE_NOT_PORTABLE, c); +#if BIG_ENDIAN + count += BITS_CHAR; + value += (c << count); +#else + value <<= BITS_CHAR; + value += c; +#endif + } + global->instring = FALSE; + return (value); +} + +INLINE FILE_LOCAL +int *evaleval(struct Global *global, + int *valp, + int op, + int skip) /* TRUE if short-circuit evaluation */ +{ + /* + * Apply the argument operator to the data on the value stack. + * One or two values are popped from the value stack and the result + * is pushed onto the value stack. + * + * OP_COL is a special case. + * + * evaleval() returns the new pointer to the top of the value stack. + */ + int v1, v2; + + if (isbinary(op)) + v2 = *--valp; + v1 = *--valp; + switch (op) { + case OP_EOE: + break; + case OP_ADD: + v1 += v2; + break; + case OP_SUB: + v1 -= v2; + break; + case OP_MUL: + v1 *= v2; + break; + case OP_DIV: + case OP_MOD: + if (v2 == 0) { + if (!skip) { + cwarn(global, WARN_DIVISION_BY_ZERO, + (op == OP_DIV) ? "divide" : "mod"); + } + v1 = 0; + } + else if (op == OP_DIV) + v1 /= v2; + else + v1 %= v2; + break; + case OP_ASL: + v1 <<= v2; + break; + case OP_ASR: + v1 >>= v2; + break; + case OP_AND: + v1 &= v2; + break; + case OP_OR: + v1 |= v2; + break; + case OP_XOR: + v1 ^= v2; + break; + case OP_EQ: + v1 = (v1 == v2); + break; + case OP_NE: + v1 = (v1 != v2); + break; + case OP_LT: + v1 = (v1 < v2); + break; + case OP_LE: + v1 = (v1 <= v2); + break; + case OP_GE: + v1 = (v1 >= v2); + break; + case OP_GT: + v1 = (v1 > v2); + break; + case OP_ANA: + v1 = (v1 && v2); + break; + case OP_ORO: + v1 = (v1 || v2); + break; + case OP_COL: + /* + * v1 has the "true" value, v2 the "false" value. + * The top of the value stack has the test. + */ + v1 = (*--valp) ? v1 : v2; + break; + case OP_NEG: + v1 = (-v1); + break; + case OP_PLU: + break; + case OP_COM: + v1 = ~v1; + break; + case OP_NOT: + v1 = !v1; + break; + default: + cerror(global, ERROR_IF_OPERAND, op); + v1 = 0; + } + *valp++ = v1; + return (valp); +} diff --git a/3rdparty/fcpp/cpp6.c b/3rdparty/fcpp/cpp6.c new file mode 100644 index 000000000..b6f59abc4 --- /dev/null +++ b/3rdparty/fcpp/cpp6.c @@ -0,0 +1,1141 @@ +/****************************************************************************** +Copyright (c) 1999 Daniel Stenberg + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +******************************************************************************/ +#include +#include +#include "cppdef.h" +#include "cpp.h" + +INLINE FILE_LOCAL void outadefine(struct Global *, DEFBUF *); +INLINE FILE_LOCAL void domsg(struct Global *, ErrorCode, va_list); +FILE_LOCAL char *incmem(struct Global *, char *, int); + +/* + * skipnl() skips over input text to the end of the line. + * skipws() skips over "whitespace" (spaces or tabs), but + * not skip over the end of the line. It skips over + * TOK_SEP, however (though that shouldn't happen). + * scanid() reads the next token (C identifier) into tokenbuf. + * The caller has already read the first character of + * the identifier. Unlike macroid(), the token is + * never expanded. + * macroid() reads the next token (C identifier) into tokenbuf. + * If it is a #defined macro, it is expanded, and + * macroid() returns TRUE, otherwise, FALSE. + * catenate() Does the dirty work of token concatenation, TRUE if it did. + * scanstring() Reads a string from the input stream, calling + * a user-supplied function for each character. + * This function may be output() to write the + * string to the output file, or save() to save + * the string in the work buffer. + * scannumber() Reads a C numeric constant from the input stream, + * calling the user-supplied function for each + * character. (output() or save() as noted above.) + * save() Save one character in the work[] buffer. + * savestring() Saves a string in malloc() memory. + * getfile() Initialize a new FILEINFO structure, called when + * #include opens a new file, or a macro is to be + * expanded. + * Getmem() Get a specified number of bytes from malloc memory. + * output() Write one character to stdout (calling Putchar) -- + * implemented as a function so its address may be + * passed to scanstring() and scannumber(). + * lookid() Scans the next token (identifier) from the input + * stream. Looks for it in the #defined symbol table. + * Returns a pointer to the definition, if found, or NULL + * if not present. The identifier is stored in tokenbuf. + * defnedel() Define enter/delete subroutine. Updates the + * symbol table. + * get() Read the next byte from the current input stream, + * handling end of (macro/file) input and embedded + * comments appropriately. Note that the global + * instring is -- essentially -- a parameter to get(). + * cget() Like get(), but skip over TOK_SEP. + * unget() Push last gotten character back on the input stream. + * cerror() This routine format an print messages to the user. + */ + +/* + * This table must be rewritten for a non-Ascii machine. + * + * Note that several "non-visible" characters have special meaning: + * Hex 1C QUOTE_PARM --a flag for # stringifying + * Hex 1D DEF_MAGIC -- a flag to prevent #define recursion. + * Hex 1E TOK_SEP -- a delimiter for ## token concatenation + * Hex 1F COM_SEP -- a zero-width whitespace for comment concatenation + */ + +#ifndef OS9 +#if (TOK_SEP != 0x1E || COM_SEP != 0x1F || DEF_MAGIC != 0x1D) +#error "<< error type table isn't correct >>" +#endif +#endif + +#if OK_DOLLAR +#define DOL LET +#else +#define DOL 000 +#endif + +char type[256] = { /* Character type codes Hex */ + END, 000, 000, 000, 000, 000, 000, 000, /* 00 */ + 000, SPA, 000, 000, 000, 000, 000, 000, /* 08 */ + 000, 000, 000, 000, 000, 000, 000, 000, /* 10 */ + 000, 000, 000, 000, 000, LET, 000, SPA, /* 18 */ + SPA, OP_NOT, QUO, 000, DOL, OP_MOD,OP_AND,QUO, /* 20 !"#$%&' */ + OP_LPA,OP_RPA,OP_MUL,OP_ADD, 000,OP_SUB, DOT,OP_DIV, /* 28 ()*+,-./ */ + DIG, DIG, DIG, DIG, DIG, DIG, DIG, DIG, /* 30 01234567 */ + DIG, DIG,OP_COL, 000, OP_LT, OP_EQ, OP_GT,OP_QUE, /* 38 89:;<=>? */ + 000, LET, LET, LET, LET, LET, LET, LET, /* 40 @ABCDEFG */ + LET, LET, LET, LET, LET, LET, LET, LET, /* 48 HIJKLMNO */ + LET, LET, LET, LET, LET, LET, LET, LET, /* 50 PQRSTUVW */ + LET, LET, LET, 000, BSH, 000,OP_XOR, LET, /* 58 XYZ[\]^_ */ + 000, LET, LET, LET, LET, LET, LET, LET, /* 60 `abcdefg */ + LET, LET, LET, LET, LET, LET, LET, LET, /* 68 hijklmno */ + LET, LET, LET, LET, LET, LET, LET, LET, /* 70 pqrstuvw */ + LET, LET, LET, 000, OP_OR, 000,OP_NOT, 000, /* 78 xyz{|}~ */ + 000, 000, 000, 000, 000, 000, 000, 000, /* 80 .. FF */ + 000, 000, 000, 000, 000, 000, 000, 000, /* 80 .. FF */ + 000, 000, 000, 000, 000, 000, 000, 000, /* 80 .. FF */ + 000, 000, 000, 000, 000, 000, 000, 000, /* 80 .. FF */ + 000, 000, 000, 000, 000, 000, 000, 000, /* 80 .. FF */ + 000, 000, 000, 000, 000, 000, 000, 000, /* 80 .. FF */ + 000, 000, 000, 000, 000, 000, 000, 000, /* 80 .. FF */ + 000, 000, 000, 000, 000, 000, 000, 000, /* 80 .. FF */ +}; + +void skipnl(struct Global *global) +{ + /* + * Skip to the end of the current input line. + */ + int c; + + do { /* Skip to newline */ + c = get(global); + } while (c != '\n' && c != EOF_CHAR); + return; +} + +int skipws(struct Global *global) +{ + /* + * Skip over whitespace + */ + int c; + + do { /* Skip whitespace */ + c = get(global); +#if COMMENT_INVISIBLE + } while (type[c] == SPA || c == COM_SEP); +#else +} while (type[c] == SPA); +#endif + return(c); +} + +void scanid(struct Global *global, + int c) /* First char of id */ +{ + /* + * Get the next token (an id) into the token buffer. + * Note: this code is duplicated in lookid(). + * Change one, change both. + */ + + int ct; + + if (c == DEF_MAGIC) /* Eat the magic token */ + c = get(global); /* undefiner. */ + ct = 0; + do + { + if (ct == global->tokenbsize) + global->tokenbuf = realloc(global->tokenbuf, 1 + + (global->tokenbsize *= 2)); + global->tokenbuf[ct++] = c; + c = get(global); + } + while (type[c] == LET || type[c] == DIG); + unget(global); + global->tokenbuf[ct] = EOS; +} + +ReturnCode macroid(struct Global *global, int *c) +{ + /* + * If c is a letter, scan the id. if it's #defined, expand it and scan + * the next character and try again. + * + * Else, return the character. If type[c] is a LET, the token is in tokenbuf. + */ + DEFBUF *dp; + ReturnCode ret=FPP_OK; + + if (global->infile != NULL && global->infile->fp != NULL) + global->recursion = 0; + while (type[*c] == LET && (dp = lookid(global, *c)) != NULL) { + if(ret=expand(global, dp)) + return(ret); + *c = get(global); + } + return(FPP_OK); +} + +int catenate(struct Global *global, ReturnCode *ret) +{ + /* + * A token was just read (via macroid). + * If the next character is TOK_SEP, concatenate the next token + * return TRUE -- which should recall macroid after refreshing + * macroid's argument. If it is not TOK_SEP, unget() the character + * and return FALSE. + */ + +#if OK_CONCAT + int c; + char *token1; +#endif + +#if OK_CONCAT + if (get(global) != TOK_SEP) { /* Token concatenation */ + unget(global); + return (FALSE); + } + else { + token1 = savestring(global, global->tokenbuf); /* Save first token */ + c=get(global); + if(global->rightconcat) { + *ret=macroid(global, &c); /* Scan next token */ + if(*ret) + return(FALSE); + } else + lookid(global, c); + switch(type[c]) { /* What was it? */ + case LET: /* An identifier, ... */ + if ((int)strlen(token1) + (int)strlen(global->tokenbuf) >= NWORK) { + cfatal(global, FATAL_WORK_AREA_OVERFLOW, token1); + *ret=FPP_WORK_AREA_OVERFLOW; + return(FALSE); + } + sprintf(global->work, "%s%s", token1, global->tokenbuf); + break; + case DIG: /* A number */ + case DOT: /* Or maybe a float */ + strcpy(global->work, token1); + global->workp = global->work + strlen(global->work); + *ret=scannumber(global, c, save); + if(*ret) + return(FALSE); + *ret=save(global, EOS); + if(*ret) + return(FALSE); + break; + default: /* An error, ... */ + if (isprint(c)) + cerror(global, ERROR_STRANG_CHARACTER, c); + else + cerror(global, ERROR_STRANG_CHARACTER2, c); + strcpy(global->work, token1); + unget(global); + break; + } + /* + * work has the concatenated token and token1 has + * the first token (no longer needed). Unget the + * new (concatenated) token after freeing token1. + * Finally, setup to read the new token. + */ + free(token1); /* Free up memory */ + *ret=ungetstring(global, global->work); /* Unget the new thing, */ + if(*ret) + return(FALSE); + return(TRUE); + } +#else + return(FALSE); /* Not supported */ +#endif +} + +ReturnCode scanstring(struct Global *global, + int delim, /* ' or " */ + /* Output function: */ + ReturnCode (*outfun)(struct Global *, int)) +{ + /* + * Scan off a string. Warning if terminated by newline or EOF. + * outfun() outputs the character -- to a buffer if in a macro. + * TRUE if ok, FALSE if error. + */ + + int c; + ReturnCode ret; + + global->instring = TRUE; /* Don't strip comments */ + ret=(*outfun)(global, delim); + if(ret) + return(ret); + while ((c = get(global)) != delim + && c != '\n' + && c != EOF_CHAR) { + ret=(*outfun)(global, c); + if(ret) + return(ret); + if (c == '\\') { + ret=(*outfun)(global, get(global)); + if(ret) + return(ret); + } + } + global->instring = FALSE; + if (c == delim) { + ret=(*outfun)(global, c); + return(ret); + } else { + cerror(global, ERROR_UNTERMINATED_STRING); + unget(global); + return(FPP_UNTERMINATED_STRING); + } +} + +ReturnCode scannumber(struct Global *global, + int c, /* First char of number */ + /* Output/store func: */ + ReturnCode (*outfun)(struct Global *, int)) +{ + /* + * Process a number. We know that c is from 0 to 9 or dot. + * Algorithm from Dave Conroy's Decus C. + */ + + int radix; /* 8, 10, or 16 */ + int expseen; /* 'e' seen in floater */ + int signseen; /* '+' or '-' seen */ + int octal89; /* For bad octal test */ + int dotflag; /* TRUE if '.' was seen */ + ReturnCode ret; + char done=FALSE; + + expseen = FALSE; /* No exponent seen yet */ + signseen = TRUE; /* No +/- allowed yet */ + octal89 = FALSE; /* No bad octal yet */ + radix = 10; /* Assume decimal */ + if ((dotflag = (c == '.')) != FALSE) {/* . something? */ + ret=(*outfun)(global, '.'); /* Always out the dot */ + if(ret) + return(ret); + if (type[(c = get(global))] != DIG) { /* If not a float numb, */ + unget(global); /* Rescan strange char */ + return(FPP_OK); /* All done for now */ + } + } /* End of float test */ + else if (c == '0') { /* Octal or hex? */ + ret=(*outfun)(global, c); /* Stuff initial zero */ + if(ret) + return(ret); + radix = 8; /* Assume it's octal */ + c = get(global); /* Look for an 'x' */ + if (c == 'x' || c == 'X') { /* Did we get one? */ + radix = 16; /* Remember new radix */ + ret=(*outfun)(global, c); /* Stuff the 'x' */ + if(ret) + return(ret); + c = get(global); /* Get next character */ + } + } + while (!done) { /* Process curr. char. */ + /* + * Note that this algorithm accepts "012e4" and "03.4" + * as legitimate floating-point numbers. + */ + if (radix != 16 && (c == 'e' || c == 'E')) { + if (expseen) /* Already saw 'E'? */ + break; /* Exit loop, bad nbr. */ + expseen = TRUE; /* Set exponent seen */ + signseen = FALSE; /* We can read '+' now */ + radix = 10; /* Decimal exponent */ + } + else if (radix != 16 && c == '.') { + if (dotflag) /* Saw dot already? */ + break; /* Exit loop, two dots */ + dotflag = TRUE; /* Remember the dot */ + radix = 10; /* Decimal fraction */ + } + else if (c == '+' || c == '-') { /* 1.0e+10 */ + if (signseen) /* Sign in wrong place? */ + break; /* Exit loop, not nbr. */ + /* signseen = TRUE; */ /* Remember we saw it */ + } else { /* Check the digit */ + switch (c) { + case '8': case '9': /* Sometimes wrong */ + octal89 = TRUE; /* Do check later */ + case '0': case '1': case '2': case '3': + case '4': case '5': case '6': case '7': + break; /* Always ok */ + + case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': + case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': + if (radix == 16) /* Alpha's are ok only */ + break; /* if reading hex. */ + default: /* At number end */ + done=TRUE; /* Break from for loop */ + continue; + } /* End of switch */ + } /* End general case */ + ret=(*outfun)(global, c); /* Accept the character */ + if(ret) + return(ret); + signseen = TRUE; /* Don't read sign now */ + c = get(global); /* Read another char */ + } /* End of scan loop */ + /* + * When we break out of the scan loop, c contains the first + * character (maybe) not in the number. If the number is an + * integer, allow a trailing 'L' for long and/or a trailing 'U' + * for unsigned. If not those, push the trailing character back + * on the input stream. Floating point numbers accept a trailing + * 'L' for "long double". + */ + + if (dotflag || expseen) { /* Floating point? */ + if (c == 'l' || c == 'L') { + ret=(*outfun)(global, c); + if(ret) + return(ret); + c = get(global); /* Ungotten later */ + } + } else { /* Else it's an integer */ + /* + * We know that dotflag and expseen are both zero, now: + * dotflag signals "saw 'L'", and + * expseen signals "saw 'U'". + */ + char done=TRUE; + while(done) { + switch (c) { + case 'l': + case 'L': + if (dotflag) { + done=FALSE; + continue; + } + dotflag = TRUE; + break; + case 'u': + case 'U': + if (expseen) { + done=FALSE; + continue; + } + expseen = TRUE; + break; + default: + done=FALSE; + continue; + } + ret=(*outfun)(global, c); /* Got 'L' or 'U'. */ + if(ret) + return(ret); + c = get(global); /* Look at next, too. */ + } + } + unget(global); /* Not part of a number */ + if(!(global->webmode)) { + if (octal89 && radix == 8) + cwarn(global, WARN_ILLEGAL_OCTAL); + } + return(FPP_OK); +} + +ReturnCode save(struct Global *global, int c) +{ + if (global->workp >= &global->work[NWORK]) { + cfatal(global, FATAL_WORK_BUFFER_OVERFLOW); + return(FPP_WORK_AREA_OVERFLOW); + } else + *global->workp++ = c; + return(FPP_OK); +} + +char *savestring(struct Global *global, char *text) +{ + /* + * Store a string into free memory. + */ + + char *result; + result = malloc(strlen(text) + 1); + strcpy(result, text); + return (result); +} + +ReturnCode getfile(struct Global *global, + int bufsize, /* Line or define buffer size */ + char *name, + FILEINFO **file) /* File or macro name string */ +{ + /* + * Common FILEINFO buffer initialization for a new file or macro. + */ + + int size; + + size = strlen(name); /* File/macro name */ + + if(!size) { + name = "[stdin]"; + size = strlen(name); + } + + *file = (FILEINFO *) malloc((int)(sizeof (FILEINFO) + bufsize + size)); + if(!*file) + return(FPP_OUT_OF_MEMORY); + (*file)->parent = global->infile; /* Chain files together */ + (*file)->fp = NULL; /* No file yet */ + (*file)->filename = savestring(global, name); /* Save file/macro name */ + (*file)->progname = NULL; /* No #line seen yet */ + (*file)->unrecur = 0; /* No macro fixup */ + (*file)->bptr = (*file)->buffer; /* Initialize line ptr */ + (*file)->buffer[0] = EOS; /* Force first read */ + (*file)->line = 0; /* (Not used just yet) */ + if (global->infile != NULL) /* If #include file */ + global->infile->line = global->line; /* Save current line */ + global->infile = (*file); /* New current file */ + global->line = 1; /* Note first line */ + return(FPP_OK); /* All done. */ +} + +/* + * C P P S y m b o l T a b l e s + */ + +DEFBUF *lookid(struct Global *global, + int c) /* First character of token */ +{ + /* + * Look for the next token in the symbol table. Returns token in tokenbuf. + * If found, returns the table pointer; Else returns NULL. + */ + + int nhash; + DEFBUF *dp; + int ct; + int temp = 0; + int isrecurse; /* For #define foo foo */ + + nhash = 0; + if ((isrecurse = (c == DEF_MAGIC))) /* If recursive macro */ + c = get(global); /* hack, skip DEF_MAGIC */ + ct = 0; + do { + if (ct == global->tokenbsize) + global->tokenbuf = realloc(global->tokenbuf, 1 + (global->tokenbsize *= 2)); + global->tokenbuf[ct++] = c; /* Store token byte */ + nhash += c; /* Update hash value */ + c = get(global); + } while (type[c] == LET || type[c] == DIG); + unget(global); /* Rescan terminator */ + global->tokenbuf[ct] = EOS; /* Terminate token */ + if (isrecurse) /* Recursive definition */ + return(NULL); /* undefined just now */ + nhash += ct; /* Fix hash value */ + dp = global->symtab[nhash % SBSIZE]; /* Starting bucket */ + while (dp != (DEFBUF *) NULL) { /* Search symbol table */ + if (dp->hash == nhash /* Fast precheck */ + && (temp = strcmp(dp->name, global->tokenbuf)) >= 0) + break; + dp = dp->link; /* Nope, try next one */ + } + return((temp == 0) ? dp : NULL); +} + +DEFBUF *defendel(struct Global *global, + char *name, + int delete) /* TRUE to delete a symbol */ +{ + /* + * Enter this name in the lookup table (delete = FALSE) + * or delete this name (delete = TRUE). + * Returns a pointer to the define block (delete = FALSE) + * Returns NULL if the symbol wasn't defined (delete = TRUE). + */ + + DEFBUF *dp; + DEFBUF **prevp; + char *np; + int nhash; + int temp; + int size; + + for (nhash = 0, np = name; *np != EOS;) + nhash += *np++; + size = (np - name); + nhash += size; + prevp = &global->symtab[nhash % SBSIZE]; + while ((dp = *prevp) != (DEFBUF *) NULL) { + if (dp->hash == nhash + && (temp = strcmp(dp->name, name)) >= 0) { + if (temp > 0) + dp = NULL; /* Not found */ + else { + *prevp = dp->link; /* Found, unlink and */ + if (dp->repl != NULL) /* Free the replacement */ + free(dp->repl); /* if any, and then */ + free((char *) dp); /* Free the symbol */ + } + break; + } + prevp = &dp->link; + } + if (!delete) { + dp = (DEFBUF *) malloc((int) (sizeof (DEFBUF) + size)); + dp->link = *prevp; + *prevp = dp; + dp->hash = nhash; + dp->repl = NULL; + dp->nargs = 0; + strcpy(dp->name, name); + } + return(dp); +} + + +void outdefines(struct Global *global) +{ + DEFBUF *dp; + DEFBUF **syp; + + deldefines(global); /* Delete built-in #defines */ + for (syp = global->symtab; syp < &global->symtab[SBSIZE]; syp++) { + if ((dp = *syp) != (DEFBUF *) NULL) { + do { + outadefine(global, dp); + } while ((dp = dp->link) != (DEFBUF *) NULL); + } + } +} + +INLINE FILE_LOCAL +void outadefine(struct Global *global, DEFBUF *dp) +{ + char *cp; + int c; + + /* printf("#define %s", dp->name); */ + Putstring(global, "#define "); + Putstring(global, dp->name); + + if (dp->nargs > 0) { + int i; + Putchar(global, '('); + for (i = 1; i < dp->nargs; i++) { + /* printf("__%d,", i); */ + Putstring(global, "__"); + Putint(global, i); + Putchar(global, ','); + } + /* printf("__%d)", i); */ + Putstring(global, "__"); + Putint(global, i); + Putchar(global, ')'); + + } else if (dp->nargs == 0) { + Putstring(global, "()"); + } + if (dp->repl != NULL) { + Putchar(global, '\t'); + for (cp = dp->repl; (c = *cp++ & 0xFF) != EOS;) { + if (c >= MAC_PARM && c < (MAC_PARM + PAR_MAC)) { + /* printf("__%d", c - MAC_PARM + 1); */ + Putstring(global, "__"); + Putint(global, c - MAC_PARM + 1); + } else if (isprint(c) || c == '\t' || c == '\n') + Putchar(global, c); + else switch (c) { + case QUOTE_PARM: + Putchar(global, '#'); + break; + case DEF_MAGIC: /* Special anti-recursion */ + case MAC_PARM + PAR_MAC: /* Special "arg" marker */ + break; + case COM_SEP: +#if COMMENT_INVISIBLE + Putstring(global, "/**/"); +#else + Putchar(global, ' '); +#endif + break; + case TOK_SEP: + Putstring(global, "##"); + break; + default: + { + /* Octal output! */ + char buffer[32]; + sprintf(buffer, "\\0%o", c); + Putstring(global, buffer); + } + } + } + } + Putchar(global, '\n'); +} + +/* + * G E T + */ + +int get(struct Global *global) +{ + /* + * Return the next character from a macro or the current file. + * Handle end of file from #include files. + */ + + int c; + FILEINFO *file; + int popped; /* Recursion fixup */ + long comments=0; + + popped = 0; + get_from_file: + if ((file = global->infile) == NULL) + return (EOF_CHAR); + newline: + /* + * Read a character from the current input line or macro. + * At EOS, either finish the current macro (freeing temp. + * storage) or read another line from the current input file. + * At EOF, exit the current file (#include) or, at EOF from + * the cpp input file, return EOF_CHAR to finish processing. + */ + if ((c = *file->bptr++ & 0xFF) == EOS) { + /* + * Nothing in current line or macro. Get next line (if + * input from a file), or do end of file/macro processing. + * In the latter case, jump back to restart from the top. + */ + if (file->fp == NULL) { /* NULL if macro */ + popped++; + global->recursion -= file->unrecur; + if (global->recursion < 0) + global->recursion = 0; + global->infile = file->parent; /* Unwind file chain */ + } else { /* Else get from a file */ + /* + * If a input routine has been specified in the initial taglist, + * we should get the next line from that function IF we're reading + * from that certain file! + */ + + if(global->input && global->first_file && !strcmp(global->first_file, file->filename)) + file->bptr = global->input(file->buffer, NBUFF, global->userdata); + else + file->bptr = fgets(file->buffer, NBUFF, file->fp); + if(file->bptr != NULL) { + goto newline; /* process the line */ + } else { + if(!(global->input && global->first_file && !strcmp(global->first_file, file->filename))) + /* If the input function isn't user supplied, close the file! */ + fclose(file->fp); /* Close finished file */ + if ((global->infile = file->parent) != NULL) { + /* + * There is an "ungotten" newline in the current + * infile buffer (set there by doinclude() in + * cpp1.c). Thus, we know that the mainline code + * is skipping over blank lines and will do a + * #line at its convenience. + */ + global->wrongline = TRUE; /* Need a #line now */ + } + } + } + /* + * Free up space used by the (finished) file or macro and + * restart input from the parent file/macro, if any. + */ + free(file->filename); /* Free name and */ + if (file->progname != NULL) /* if a #line was seen, */ + free(file->progname); /* free it, too. */ + free(file); /* Free file space */ + if (global->infile == NULL) /* If at end of file */ + return (EOF_CHAR); /* Return end of file */ + global->line = global->infile->line; /* Reset line number */ + goto get_from_file; /* Get from the top. */ + } + /* + * Common processing for the new character. + */ + if (c == DEF_MAGIC && file->fp != NULL) /* Don't allow delete */ + goto newline; /* from a file */ + if (file->parent != NULL) { /* Macro or #include */ + if (popped != 0) + file->parent->unrecur += popped; + else { + global->recursion -= file->parent->unrecur; + if (global->recursion < 0) + global->recursion = 0; + file->parent->unrecur = 0; + } + } + if (c == '\n') /* Maintain current */ + ++global->line; /* line counter */ + if (global->instring) /* Strings just return */ + return (c); /* the character. */ + else if (c == '/') { /* Comment? */ + global->instring = TRUE; /* So get() won't loop */ + + /* Check next byte for '*' and if(cplusplus) also '/' */ + if ( (c = get(global)) != '*' ) + if(!global->cplusplus || (global->cplusplus && c!='/')) { + global->instring = FALSE; /* Nope, no comment */ + unget(global); /* Push the char. back */ + return ('/'); /* Return the slash */ + } + + comments = 1; + + if (global->keepcomments) { /* If writing comments */ + + global->comment = TRUE; /* information that a comment has been output */ + if(global->showspace) { + /* Show all whitespaces! */ + global->spacebuf[global->chpos] = '\0'; + Putstring(global, global->spacebuf); + } + + if(c=='*') { + Putchar(global, '/'); /* Write out the */ + Putchar(global, '*'); /* initializer */ + } else { + /* C++ style comment */ + Putchar(global, '/'); /* Write out the */ + Putchar(global, '/'); /* initializer */ + } + } + + if(global->cplusplus && c=='/') { /* Eat C++ comment! */ + do { + c=get(global); + if(global->keepcomments) + Putchar(global, c); + } while(c!='\n' && c!=EOF_CHAR); /* eat all to EOL or EOF */ + global->instring = FALSE; /* End of comment */ + return(c); /* Return the end char */ + } + + for (;;) { /* Eat a comment */ + c = get(global); + test: + if (global->keepcomments && c != EOF_CHAR) + Putchar(global, c); + switch (c) { + case EOF_CHAR: + cerror(global, ERROR_EOF_IN_COMMENT); + return (EOF_CHAR); + + case '/': + if(global->nestcomments || global->warnnestcomments) { + if((c = get(global)) != '*') + goto test; + if(global->warnnestcomments) { + cwarn(global, WARN_NESTED_COMMENT); + } + if(global->nestcomments) + comments++; + } + break; + + case '*': + if ((c = get(global)) != '/') /* If comment doesn't */ + goto test; /* end, look at next */ + if (global->keepcomments) { /* Put out the comment */ + Putchar(global, c); /* terminator, too */ + } + if(--comments) + /* nested comment, continue! */ + break; + + global->instring = FALSE; /* End of comment, */ + /* + * A comment is syntactically "whitespace" -- + * however, there are certain strange sequences + * such as + * #define foo(x) (something) + * foo|* comment *|(123) + * these are '/' ^ ^ + * where just returning space (or COM_SEP) will cause + * problems. This can be "fixed" by overwriting the + * '/' in the input line buffer with ' ' (or COM_SEP) + * but that may mess up an error message. + * So, we peek ahead -- if the next character is + * "whitespace" we just get another character, if not, + * we modify the buffer. All in the name of purity. + */ + if (*file->bptr == '\n' + || type[*file->bptr & 0xFF] == SPA) + goto newline; +#if COMMENT_INVISIBLE + /* + * Return magic (old-fashioned) syntactic space. + */ + return ((file->bptr[-1] = COM_SEP)); +#else + return ((file->bptr[-1] = ' ')); +#endif + + case '\n': /* we'll need a #line */ + if (!global->keepcomments) + global->wrongline = TRUE; /* later... */ + default: /* Anything else is */ + break; /* Just a character */ + } /* End switch */ + } /* End comment loop */ + } /* End if in comment */ + else if (!global->inmacro && c == '\\') { /* If backslash, peek */ + if ((c = get(global)) == '\n') { /* for a . If so, */ + global->wrongline = TRUE; + goto newline; + } else { /* Backslash anything */ + unget(global); /* Get it later */ + return ('\\'); /* Return the backslash */ + } + } else if (c == '\f' || c == VT) /* Form Feed, Vertical */ + c = ' '; /* Tab are whitespace */ + return (c); /* Just return the char */ +} + +void unget(struct Global *global) +{ + /* + * Backup the pointer to reread the last character. Fatal error + * (code bug) if we backup too far. unget() may be called, + * without problems, at end of file. Only one character may + * be ungotten. If you need to unget more, call ungetstring(). + */ + + FILEINFO *file; + if ((file = global->infile) == NULL) + return; /* Unget after EOF */ + if (--file->bptr < file->buffer) { + cfatal(global, FATAL_TOO_MUCH_PUSHBACK); + /* This happens only if used the wrong way! */ + return; + } + if (*file->bptr == '\n') /* Ungetting a newline? */ + --global->line; /* Unget the line number, too */ +} + +ReturnCode ungetstring(struct Global *global, char *text) +{ + /* + * Push a string back on the input stream. This is done by treating + * the text as if it were a macro. + */ + + FILEINFO *file; + ReturnCode ret; + + ret = getfile(global, strlen(text) + 1, "", &file); + if(!ret) + strcpy(file->buffer, text); + return(ret); +} + +int cget(struct Global *global) +{ + /* + * Get one character, absorb "funny space" after comments or + * token concatenation + */ + + int c; + do { + c = get(global); +#if COMMENT_INVISIBLE + } while (c == TOK_SEP || c == COM_SEP); +#else + } while (c == TOK_SEP); +#endif + return (c); +} + +/* + * Error messages and other hacks. + */ + +INLINE FILE_LOCAL +void domsg(struct Global *global, + ErrorCode error, /* error message number */ + va_list arg) /* Something for the message */ +{ + /* + * Print filenames, macro names, and line numbers for error messages. + */ + + static char *ErrorMessage[]={ + /* + * ERRORS: + */ + "#%s must be in an #if", + "#%s may not follow #else", + "#error directive encountered", + "Preprocessor assertion failure", + "#if, #ifdef, or #ifndef without an argument", + "#include syntax error", + "#define syntax error", + "Redefining defined variable \"%s\"", + "Illegal #undef argument", + "Recursive macro definition of \"%s\"(Defined by \"%s\")", + "end of file within macro argument", + "misplaced constant in #if", + "#if value stack overflow", + "Illegal #if line", + "Operator %s in incorrect context", + "expression stack overflow at op \"%s\"", + "unbalanced paren's, op is \"%s\"", + "Misplaced '?' or ':', previous operator is %s", + "Can't use a string in an #if", + "Bad #if ... defined() syntax", + "= not allowed in #if", + "Unexpected \\ in #if", + "#if ... sizeof() syntax error", + "#if sizeof, unknown type \"%s\"", + "#if ... sizeof: illegal type combination", + "#if sizeof() error, no type specified", + "Unterminated string", + "EOF in comment", + "Inside #ifdef block at end of input, depth = %d", + "illegal character '%c' in #if", + "illegal character (%d decimal) in #if", + "#if ... sizeof: bug, unknown type code 0x%x", + "#if bug, operand = %d.", + "Strange character '%c' after ##", + "Strange character (%d.) after ##", + + "", /* Dummy, to visualize the border between errors and warnings */ + /* + * WARNINGS: + */ + "Control line \"%s\" within macro expansion", + "Illegal # command \"%s\"", + "Unexpected text in #control line ignored", + "too few values specified to sizeof", + "too many values specified to sizeof! Not used.", + "\"%s\" wasn't defined", + "Internal error!", + "Macro \"%s\" needs arguments", + "Wrong number of macro arguments for \"%s\"", + "%s by zero in #if, zero result assumed", + "Illegal digit in octal number", + "multi-byte constant '%c' isn't portable", + "Cannot open include file \"%s\"", + "Illegal bracket '[]' balance, depth = %d", + "Illegal parentheses '()' balance, depth = %d", + "Illegal brace '{}' balance, depth = %d", + "Nested comment", + + "", /* Dummy, to visualize the border between warnings and fatals */ + + /* + * FATALS: + */ + "Too many nested #%s statements", + "Filename work buffer overflow", + "Too many include directories", + "Too many include files", + "Too many arguments for macro", + "Macro work area overflow", + "Bug: Illegal __ macro \"%s\"", + "Too many arguments in macro expansion", + "Out of space in macro \"%s\" arg expansion", + "work buffer overflow doing %s ##", + "Work buffer overflow", + "Out of memory", + "Too much pushback", /* internal */ + }; + + char *tp; + FILEINFO *file; + char *severity=errorinfile; file && !file->fp; file = file->parent) + ; + tp = file ? file->filename : 0; + Error(global, "%s\"%s\", line %d: %s: ", + MSG_PREFIX, tp, global->infile->fp?global->line:file->line, severity); + if(global->error) + global->error(global->userdata, ErrorMessage[error], arg); +#if defined(UNIX) + else + vfprintf(stderr, ErrorMessage[error], arg); +#elif defined(AMIGA) + else + return; +#endif + Error(global, "\n"); + + if (file) /*OIS*0.92*/ + while ((file = file->parent) != NULL) { /* Print #includes, too */ + tp = file->parent ? "," : "."; + if (file->fp == NULL) + Error(global, " from macro %s%s\n", file->filename, tp); + else + Error(global, " from file %s, line %d%s\n", + (file->progname != NULL) ? file->progname : file->filename, + file->line, tp); + } + + if(errorerrors++; +} + +void cerror(struct Global *global, + ErrorCode message, + ...) /* arguments */ +{ + /* + * Print a normal error message, string argument. + */ + va_list arg; + va_start(arg, message); + domsg(global, message, arg); +} + +void Error(struct Global *global, char *format, ...) +{ + /* + * Just get the arguments and send a decent string to the user error + * string handler or to stderr. + */ + + va_list arg; + va_start(arg, format); + if(global->error) + global->error(global->userdata, format, arg); +#if defined(UNIX) + else + vfprintf(stderr, format, arg); +#endif +} diff --git a/3rdparty/fcpp/cppadd.h b/3rdparty/fcpp/cppadd.h new file mode 100644 index 000000000..a088af3d6 --- /dev/null +++ b/3rdparty/fcpp/cppadd.h @@ -0,0 +1,411 @@ +/****************************************************************************** + * FREXXWARE + * ---------------------------------------------------------------------------- + * + * Project: Frexx C Preprocessor + * $Source: /home/user/start/cpp/RCS/cppadd.h,v $ + * $Revision: 1.5 $ + * $Date: 1994/01/24 09:38:12 $ + * $Author: start $ + * $State: Exp $ + * $Locker: start $ + * + * ---------------------------------------------------------------------------- + * $Log: cppadd.h,v $ + * Revision 1.5 1994/01/24 09:38:12 start + * Added the 'rightconcat' in the global structure. + * + * Revision 1.4 1993/12/06 13:51:20 start + * A lot of new stuff (too much to mention) + * + * Revision 1.3 1993/11/29 14:01:13 start + * New features added + * + * Revision 1.2 1993/11/11 07:16:39 start + * New stuff + * + * Revision 1.1 1993/11/03 09:15:59 start + * Initial revision + * + * + *****************************************************************************/ +/********************************************************************** + * + * cppadd.h + * + * Prototypes and structures added by Daniel Stenberg. + * + *******/ + +#include +#include "memory.h" + +struct Global { + + /* + * Commonly used global variables: + * line is the current input line number. + * wrongline is set in many places when the actual output + * line is out of sync with the numbering, e.g, + * when expanding a macro with an embedded newline. + * + * tokenbuf holds the last identifier scanned (which might + * be a candidate for macro expansion). + * errors is the running cpp error counter. + * infile is the head of a linked list of input files (extended by + * #include and macros being expanded). infile always points + * to the current file/macro. infile->parent to the includer, + * etc. infile->fd is NULL if this input stream is a macro. + */ + int line; /* Current line number */ + int wrongline; /* Force #line to compiler */ + char *tokenbuf; /* Buffer for current input token */ + char *functionname; /* Buffer for current function */ + int funcline; /* Line number of current function */ + int tokenbsize; /* Allocated size of tokenbuf, */ + /* not counting zero at end. */ + int errors; /* cpp error counter */ + FILEINFO *infile; /* Current input file */ +#if DEBUG + int debug; /* TRUE if debugging now */ +#endif + /* + * This counter is incremented when a macro expansion is initiated. + * If it exceeds a built-in value, the expansion stops -- this tests + * for a runaway condition: + * #define X Y + * #define Y X + * X + * This can be disabled by falsifying rec_recover. (Nothing does this + * currently: it is a hook for an eventual invocation flag.) + */ + int recursion; /* Infinite recursion counter */ + int rec_recover; /* Unwind recursive macros */ + + /* + * instring is set TRUE when a string is scanned. It modifies the + * behavior of the "get next character" routine, causing all characters + * to be passed to the caller (except ). Note especially that + * comments and \ are not removed from the source. (This + * prevents cpp output lines from being arbitrarily long). + * + * inmacro is set by #define -- it absorbs comments and converts + * form-feed and vertical-tab to space, but returns \ + * to the caller. Strictly speaking, this is a bug as \ + * shouldn't delimit tokens, but we'll worry about that some other + * time -- it is more important to prevent infinitly long output lines. + * + * instring and inmarcor are parameters to the get() routine which + * were made global for speed. + */ + int instring; /* TRUE if scanning string */ + int inmacro; /* TRUE if #defining a macro */ + + /* + * work[] and workp are used to store one piece of text in a temporay + * buffer. To initialize storage, set workp = work. To store one + * character, call save(c); (This will fatally exit if there isn't + * room.) To terminate the string, call save(EOS). Note that + * the work buffer is used by several subroutines -- be sure your + * data won't be overwritten. The extra byte in the allocation is + * needed for string formal replacement. + */ + char work[NWORK + 1]; /* Work buffer */ + char *workp; /* Work buffer pointer */ + + /* + * keepcomments is set TRUE by the -C option. If TRUE, comments + * are written directly to the output stream. This is needed if + * the output from cpp is to be passed to lint (which uses commands + * embedded in comments). cflag contains the permanent state of the + * -C flag. keepcomments is always falsified when processing #control + * commands and when compilation is supressed by a false #if + * + * If eflag is set, CPP returns "success" even if non-fatal errors + * were detected. + * + * If nflag is non-zero, no symbols are predefined except __LINE__. + * __FILE__, and __DATE__. If nflag > 1, absolutely no symbols + * are predefined. + */ + char keepcomments; /* Write out comments flag */ + char cflag; /* -C option (keep comments) */ + char eflag; /* -E option (never fail) */ + char nflag; /* -N option (no predefines) */ + char wflag; /* -W option (write #defines) */ + + /* + * ifstack[] holds information about nested #if's. It is always + * accessed via *ifptr. The information is as follows: + * WAS_COMPILING state of compiling flag at outer level. + * ELSE_SEEN set TRUE when #else seen to prevent 2nd #else. + * TRUE_SEEN set TRUE when #if or #elif succeeds + * ifstack[0] holds the compiling flag. It is TRUE if compilation + * is currently enabled. Note that this must be initialized TRUE. + */ + char ifstack[BLK_NEST]; /* #if information */ + char *ifptr; /* -> current ifstack[] */ + + /* + * incdir[] stores the -i directories (and the system-specific + * #include <...> directories. + */ + char *incdir[NINCLUDE]; /* -i directories */ + char **incend; /* -> free space in incdir[] */ + + /* + * include[] stores the -X and -x files. + */ + char *include[NINCLUDE]; + char includeshow[NINCLUDE]; /* show it or not! */ + char included; + + /* + * This is the table used to predefine target machine and operating + * system designators. It may need hacking for specific circumstances. + * Note: it is not clear that this is part of the Ansi Standard. + * The -B option supresses preset definitions. + */ + char *preset[5]; /* names defined at cpp start */ + + /* + * The value of these predefined symbols must be recomputed whenever + * they are evaluated. The order must not be changed. + */ + char *magic[5]; /* Note: order is important */ + + /* + * This is the variable saying if Cpp should remove C++ style comments from + * the output. Default is... TRUE, yes, pronto, do it!!! + */ + + char cplusplus; + + char *sharpfilename; + + + /* + * parm[], parmp, and parlist[] are used to store #define() argument + * lists. nargs contains the actual number of parameters stored. + */ + char parm[NPARMWORK + 1]; /* define param work buffer */ + char *parmp; /* Free space in parm */ + char *parlist[LASTPARM]; /* -> start of each parameter */ + int nargs; /* Parameters for this macro */ + + DEFBUF *macro; /* Catches start of infinite macro */ + + DEFBUF *symtab[SBSIZE]; /* Symbol table queue headers */ + + int evalue; /* Current value from evallex() */ + + char *(*input)(char *, int, void *); /* Input function */ + + char *first_file; /* Preprocessed file. */ + + void *userdata; /* Data sent to input function */ + + void (*output)(int, void *); /* output function */ + + void (*error)(void *, char *, va_list); /* error function */ + + char linelines; + + char warnillegalcpp; /* warn for illegal preprocessor instructions? */ + + char outputLINE; /* output 'line' in #line instructions */ + + char showversion; /* display version */ + + char showincluded; /* display included files */ + + char showbalance; /* display paren balance */ + + char showspace; /* display all whitespaces as they are */ + + char comment; /* TRUE if a comment just has been written to output */ + + char *spacebuf; /* Buffer to store whitespaces in if -H */ + + long chpos; /* Number of whitespaces in buffer */ + + char nestcomments; /* Allow nested comments */ + + char warnnestcomments; /* Warn at nested comments */ + + char warnnoinclude; /* Warn at missing include file */ + + char outputfile; /* output the main file */ + + char out; /* should we output anything now? */ + + char rightconcat; /* should the right part of a concatenation be avaluated + before the concat (TRUE) or after (FALSE) */ + char *initialfunc; /* file to include first in all functions */ + + char *excludedinit[20]; /* functions (names) excluded from the initfunc */ + int excluded; + + char outputfunctions; /* output all discovered functions to stderr! */ + + char webmode; /* WWW process mode */ +}; + +typedef enum { + ERROR_STRING_MUST_BE_IF, + ERROR_STRING_MAY_NOT_FOLLOW_ELSE, + ERROR_ERROR, + ERROR_PREPROC_FAILURE, + ERROR_MISSING_ARGUMENT, + ERROR_INCLUDE_SYNTAX, + ERROR_DEFINE_SYNTAX, + ERROR_REDEFINE, + ERROR_ILLEGAL_UNDEF, + ERROR_RECURSIVE_MACRO, + ERROR_EOF_IN_ARGUMENT, + ERROR_MISPLACED_CONSTANT, + ERROR_IF_OVERFLOW, + ERROR_ILLEGAL_IF_LINE, + ERROR_OPERATOR, + ERROR_EXPR_OVERFLOW, + ERROR_UNBALANCED_PARENS, + ERROR_MISPLACED, + ERROR_STRING_IN_IF, + ERROR_DEFINED_SYNTAX, + ERROR_ILLEGAL_ASSIGN, + ERROR_ILLEGAL_BACKSLASH, + ERROR_SIZEOF_SYNTAX, + ERROR_SIZEOF_UNKNOWN, + ERROR_SIZEOF_ILLEGAL_TYPE, + ERROR_SIZEOF_NO_TYPE, + ERROR_UNTERMINATED_STRING, + ERROR_EOF_IN_COMMENT, + ERROR_IFDEF_DEPTH, + ERROR_ILLEGAL_CHARACTER, + ERROR_ILLEGAL_CHARACTER2, + ERROR_SIZEOF_BUG, + ERROR_IF_OPERAND, + ERROR_STRANG_CHARACTER, + ERROR_STRANG_CHARACTER2, + + BORDER_ERROR_WARN, /* below this number: errors, above: warnings */ + + WARN_CONTROL_LINE_IN_MACRO, + WARN_ILLEGAL_COMMAND, + WARN_UNEXPECTED_TEXT_IGNORED, + WARN_TOO_FEW_VALUES_TO_SIZEOF, + WARN_TOO_MANY_VALUES_TO_SIZEOF, + WARN_NOT_DEFINED, + WARN_INTERNAL_ERROR, + WARN_MACRO_NEEDS_ARGUMENTS, + WARN_WRONG_NUMBER_ARGUMENTS, + WARN_DIVISION_BY_ZERO, + WARN_ILLEGAL_OCTAL, + WARN_MULTIBYTE_NOT_PORTABLE, + WARN_CANNOT_OPEN_INCLUDE, + WARN_BRACKET_DEPTH, + WARN_PAREN_DEPTH, + WARN_BRACE_DEPTH, + WARN_NESTED_COMMENT, + + BORDER_WARN_FATAL, /* below this number: warnings, above: fatals */ + + FATAL_TOO_MANY_NESTINGS, + FATAL_FILENAME_BUFFER_OVERFLOW, + FATAL_TOO_MANY_INCLUDE_DIRS, + FATAL_TOO_MANY_INCLUDE_FILES, + FATAL_TOO_MANY_ARGUMENTS_MACRO, + FATAL_MACRO_AREA_OVERFLOW, + FATAL_ILLEGAL_MACRO, + FATAL_TOO_MANY_ARGUMENTS_EXPANSION, + FATAL_OUT_OF_SPACE_IN_ARGUMENT, + FATAL_WORK_AREA_OVERFLOW, + FATAL_WORK_BUFFER_OVERFLOW, + FATAL_OUT_OF_MEMORY, + FATAL_TOO_MUCH_PUSHBACK + + + } ErrorCode; + +/********************************************************************** + * RETURN CODES: + *********************************************************************/ + +typedef enum { + FPP_OK, + FPP_OUT_OF_MEMORY, + FPP_TOO_MANY_NESTED_STATEMENTS, + FPP_FILENAME_BUFFER_OVERFLOW, + FPP_NO_INCLUDE, + FPP_OPEN_ERROR, + FPP_TOO_MANY_ARGUMENTS, + FPP_WORK_AREA_OVERFLOW, + FPP_ILLEGAL_MACRO, + FPP_EOF_IN_MACRO, + FPP_OUT_OF_SPACE_IN_MACRO_EXPANSION, + FPP_ILLEGAL_CHARACTER, + FPP_CANT_USE_STRING_IN_IF, + FPP_BAD_IF_DEFINED_SYNTAX, + FPP_IF_ERROR, + FPP_SIZEOF_ERROR, + FPP_UNTERMINATED_STRING, + FPP_TOO_MANY_INCLUDE_DIRS, + FPP_TOO_MANY_INCLUDE_FILES, + FPP_INTERNAL_ERROR, + + FPP_LAST_ERROR +} ReturnCode; + +/* Nasty defines to make them appear as three different functions! */ +#define cwarn cerror +#define cfatal cerror + + +/********************************************************************** + * PROTOTYPES: + *********************************************************************/ +int PREFIX fppPreProcess(REG(a0) struct fppTag *); +void Freemem(void *); +void Error(struct Global *, char *, ...); +void Putchar(struct Global *, int); +void Putstring(struct Global *, char *); +void Putint(struct Global *, int); +char *savestring(struct Global *, char *); +ReturnCode addfile(struct Global *, FILE *, char *); +int catenate(struct Global *, ReturnCode *); +void cerror(struct Global *, ErrorCode, ...); +ReturnCode control(struct Global *, int *); +ReturnCode dodefine(struct Global *); +int dooptions(struct Global *, struct fppTag *); +void doundef(struct Global *); +void dumpparm(char *); +ReturnCode expand(struct Global *, DEFBUF *); +int get(struct Global *); +ReturnCode initdefines(struct Global *); +void outdefines(struct Global *); +ReturnCode save(struct Global *, int); +void scanid(struct Global *, int); +ReturnCode scannumber(struct Global *, int, ReturnCode(*)(struct Global *, int)); +ReturnCode scanstring(struct Global *, int, ReturnCode(*)(struct Global *, int)); +void unget(struct Global *); +ReturnCode ungetstring(struct Global *, char *); +ReturnCode eval(struct Global *, int *); +#ifdef DEBUG_EVAL +void dumpstack(OPTAB[NEXP], register OPTAB *, int [NEXP], register int *); +#endif +void skipnl(struct Global *); +int skipws(struct Global *); +ReturnCode macroid(struct Global *, int *); +ReturnCode getfile(struct Global *, int, char *, FILEINFO **); +DEFBUF *lookid(struct Global *, int ); +DEFBUF *defendel(struct Global *, char *, int); +#if DEBUG +void dumpdef(char *); +void dumpadef(char *, register DEFBUF *); +#endif +ReturnCode openfile(struct Global *,char *); +int cget(struct Global *); +void deldefines(struct Global *); +char *Getmem(struct Global *, int); +ReturnCode openinclude(struct Global *, char *, int); +ReturnCode expstuff(struct Global *, char *, char *); diff --git a/3rdparty/fcpp/cppdef.h b/3rdparty/fcpp/cppdef.h new file mode 100644 index 000000000..c188a2240 --- /dev/null +++ b/3rdparty/fcpp/cppdef.h @@ -0,0 +1,383 @@ +/****************************************************************************** + * FREXXWARE + * ---------------------------------------------------------------------------- + * + * Project: Frexx C Preprocessor + * $Source: /home/user/start/cpp/RCS/cppdef.h,v $ + * $Revision: 1.4 $ + * $Date: 1993/12/06 13:51:20 $ + * $Author: start $ + * $State: Exp $ + * $Locker: start $ + * + * ---------------------------------------------------------------------------- + * $Log: cppdef.h,v $ + * Revision 1.4 1993/12/06 13:51:20 start + * A lot of new stuff (too much to mention) + * + * Revision 1.3 1993/11/29 14:01:13 start + * New features added + * + * Revision 1.2 1993/11/11 07:16:39 start + * New stuff + * + * Revision 1.1 1993/11/03 09:15:59 start + * Initial revision + * + * + *****************************************************************************/ +#ifdef EMACS + +/* Use the Emacs config file to find out what type of machine */ + +#define NO_SHORTNAMES + +/* Convert Emacs's conventions for BIG_ENDIAN to cpp's convention. */ +#ifdef BIG_ENDIAN +#undef BIG_ENDIAN +#define BIG_ENDIAN TRUE +#else /* not BIG_ENDIAN */ +#define BIG_ENDIAN FALSE +#endif /* BIG_ENDIAN */ + +/* Emacs uses the names index and rindex and defines them as str(r)chr if nec; + cpp uses the opposite convention. Here we flush the macro definitions for + Emacs and add the ones cpp wants. */ + +#ifdef index +#undef index +#undef rindex +#else /* index is not defined as a macro */ +#define strchr index +#define strrchr rindex +#endif /* index is not defined as a macro */ + +#define NBUFF 2048 +#define NWORK 2048 + +#endif /* EMACS */ + +/* + * S y s t e m D e p e n d e n t + * D e f i n i t i o n s f o r C P P + * + * Definitions in this file may be edited to configure CPP for particular + * host operating systems and target configurations. + * + * NOTE: cpp assumes it is compiled by a compiler that supports macros + * with arguments. If this is not the case (as for Decus C), #define + * nomacarg -- and provide function equivalents for all macros. + * + * cpp also assumes the host and target implement the Ascii character set. + * If this is not the case, you will have to do some editing here and there. + */ + +/* + * This redundant definition of TRUE and FALSE works around + * a limitation of Decus C. + */ +#ifndef TRUE +#define TRUE 1 +#define FALSE 0 +#endif + +/* + * Define the HOST operating system. This is needed so that + * cpp can use appropriate filename conventions. + */ +#define SYS_UNKNOWN 0 +#define SYS_UNIX 1 +#define SYS_VMS 2 +#define SYS_RSX 3 +#define SYS_RT11 4 +#define SYS_LATTICE 5 +#define SYS_ONYX 6 +#define SYS_68000 7 +#define SYS_AMIGADOS 8 + +#ifndef HOST +#ifdef unix +#define HOST SYS_UNIX +#else +#ifdef amiga +#define HOST SYS_AMIGADOS +#endif +#endif +#endif + +/* + * We assume that the target is the same as the host system + */ +#ifndef TARGET +#define TARGET HOST +#endif + +/* + * In order to predefine machine-dependent constants, + * several strings are defined here: + * + * MACHINE defines the target cpu (by name) + * SYSTEM defines the target operating system + * COMPILER defines the target compiler + * + * The above may be #defined as "" if they are not wanted. + * They should not be #defined as NULL. + * + * LINE_PREFIX defines the # output line prefix, if not "line" + * This should be defined as "" if cpp is to replace + * the "standard" C pre-processor. + */ +#define LINE_PREFIX "line" +/* + * FILE_LOCAL marks functions which are referenced only in the + * file they reside. Some C compilers allow these + * to be marked "static" even though they are referenced + * by "extern" statements elsewhere. + * + * OK_DOLLAR Should be set TRUE if $ is a valid alphabetic character + * in identifiers (default), or zero if $ is invalid. + * Default is TRUE. + * + * OK_CONCAT Should be set TRUE if # may be used to concatenate + * tokens in macros (per the Ansi Draft Standard) or + * FALSE for old-style # processing (needed if cpp is + * to process assembler source code). + */ +#define OK_CONCAT TRUE +/* + * OK_DATE Predefines the compilation date if set TRUE. + * Not permitted by the Nov. 12, 1984 Draft Standard. + */ +#define OK_DATE TRUE +/* + * + * OK_SIZEOF Permits sizeof in #if preprocessor expressions. + * According to K&R V2 (page 232), this is not allowed. + */ +#define OK_SIZEOF TRUE +/* + * S_CHAR etc. Define the sizeof the basic TARGET machine word types. + * By default, sizes are set to the values for the HOST + * computer. If this is inappropriate, see the code in + * cpp3.c for details on what to change. Also, if you + * have a machine where sizeof (signed int) differs from + * sizeof (unsigned int), you will have to edit code and + * tables in cpp3.c (and extend the -S option definition.) + * + * CPP_LIBRARY May be defined if you have a site-specific include directory + * which is to be searched *before* the operating-system + * specific directories. + */ + +#define MACHINE "amiga", "m68000" +#define SYSTEM "amigados" + + +/* + * defaults + */ + +#ifndef MSG_PREFIX +#define MSG_PREFIX "cpp: " +#endif + +/* + * OLD_PREPROCESSOR forces the definition of OK_DOLLAR, OK_CONCAT, + * COMMENT_INVISIBLE to values appropriate for + * an old-style preprocessor. + */ + +#if OLD_PREPROCESSOR +#define OK_DOLLAR FALSE +#define OK_CONCAT FALSE +#define COMMENT_INVISIBLE TRUE +#endif + +/* + * RECURSION_LIMIT may be set to -1 to disable the macro recursion test. + */ +#ifndef RECURSION_LIMIT +#define RECURSION_LIMIT 1000 +#endif + +/* + * BITS_CHAR may be defined to set the number of bits per character. + * it is needed only for multi-byte character constants. + */ +#ifndef BITS_CHAR +#define BITS_CHAR 8 +#endif + +/* + * BIG_ENDIAN is set TRUE on machines (such as the IBM 360 series) + * where 'ab' stores 'a' in the high-bits and 'b' in the low-bits. + * It is set FALSE on machines (such as the PDP-11 and Vax-11) + * where 'ab' stores 'a' in the low-bits and 'b' in the high-bits. + * (Or is it the other way around?) -- Warning: BIG_ENDIAN code is untested. + * [I *seems* to be the other way around, according to the code /OIS] + */ +#ifndef BIG_ENDIAN +#define BIG_ENDIAN FALSE +#endif + +/* + * COMMENT_INVISIBLE may be defined to allow "old-style" comment + * processing, whereby the comment becomes a zero-length token + * delimiter. This permitted tokens to be concatenated in macro + * expansions. This was removed from the Draft Ansi Standard. + */ +#ifndef COMMENT_INVISIBLE +#define COMMENT_INVISIBLE FALSE +#endif + +/* + * OK_DOLLAR enables use of $ as a valid "letter" in identifiers. + * This is a permitted extension to the Ansi Standard and is required + * for e.g., VMS, RSX-11M, etc. It should be set FALSE if cpp is + * used to preprocess assembler source on Unix systems. OLD_PREPROCESSOR + * sets OK_DOLLAR FALSE for that reason. + */ +#ifndef OK_DOLLAR +#define OK_DOLLAR TRUE +#endif + +/* + * OK_CONCAT enables (one possible implementation of) token concatenation. + * If cpp is used to preprocess Unix assembler source, this should be + * set FALSE as the concatenation character, #, is used by the assembler. + */ +#ifndef OK_CONCAT +#define OK_CONCAT TRUE +#endif + +/* + * OK_DATE may be enabled to predefine today's date as a string + * at the start of each compilation. This is apparently not permitted + * by the Draft Ansi Standard. + */ +#ifndef OK_DATE +#define OK_DATE TRUE +#endif + +/* + * OK_SIZEOF may be defined to allow sizeof(type) in #if expressions. + * Actually, it is none of the preprocessors business how large these + * things are, as they might be different with different compiler + * options. Also, according to K&R V2, page 232, it is nonstandard. + * This option was added in the PDC process, under no. *OIS*0.92*. + */ +#ifndef OK_SIZEOF +#define OK_SIZEOF FALSE +#endif + +/* + * Some common definitions. + */ + +#ifndef DEBUG +#define DEBUG FALSE +#endif + +/* + * The following definitions are used to allocate memory for + * work buffers. In general, they should not be modified + * by implementors. + * + * PAR_MAC The maximum number of #define parameters (31 per Standard) + * Note: we need another one for strings. + * NBUFF Input buffer size + * NWORK Work buffer size -- the longest macro + * must fit here after expansion. + * NEXP The nesting depth of #if expressions + * NINCLUDE The number of directories that may be specified + * on a per-system basis, or by the -I option. + * BLK_NEST The number of nested #if's permitted. + */ + +#ifndef PAR_MAC +#define PAR_MAC (31 + 1) +#endif + +#ifndef NBUFF +#define NBUFF 512 +#endif + +#ifndef NWORK +#define NWORK 512 +#endif + +#ifndef NEXP +#define NEXP 128 +#endif + +#ifndef NINCLUDE +#define NINCLUDE 20 +#endif + +#ifndef NPARMWORK +#define NPARMWORK (NWORK * 2) +#endif + +#ifndef BLK_NEST +#define BLK_NEST 32 +#endif + + +/* + * Some special constants. These may need to be changed if cpp + * is ported to a wierd machine. + * + * NOTE: if cpp is run on a non-ascii machine, ALERT and VT may + * need to be changed. They are used to implement the proposed + * ANSI standard C control characters '\a' and '\v' only. + * DEL is used to tag macro tokens to prevent #define foo foo + * from looping. Note that we don't try to prevent more elaborate + * #define loops from occurring. + */ + +#ifndef ALERT +#define ALERT '\007' /* '\a' is "Bell" */ +#endif + +#ifndef VT +#define VT '\013' /* Vertical Tab CTRL/K */ +#endif + +/* + * Functions can be declared/defined static to only become in the + * scope for functions of the same source file. + */ + +#ifndef FILE_LOCAL +#define FILE_LOCAL static /* file-unique globals */ +#endif + +/* + * For compilers supporting inlining, the INLINE macro has been added to + * functions called from only one place. There might still be some + * functions that should have this macro. + */ +#ifdef AMIGA +#define INLINE __inline /* Amiga compiler SAS/C 6.x supports this! */ +#else +#define INLINE /* don't support that kind of stuff */ +#endif + +#if defined(AMIGA) && defined(SHARED) +#define PREFIX __asm __saveds +#define REG(x) register __ ## x +#else +#define PREFIX +#define REG(x) +#endif + +/* + * SBSIZE defines the number of hash-table slots for the symbol table. + */ +#ifndef SBSIZE +#define SBSIZE 64 +#endif + +#define VERSION_TEXT "Frexx C Preprocessor v1.5.1 " \ +"Copyright (C) by FrexxWare 1993 - 2002.\n" \ +"Compiled " __DATE__ "\n" diff --git a/3rdparty/fcpp/fpp.exp b/3rdparty/fcpp/fpp.exp new file mode 100644 index 000000000..c004e42bc --- /dev/null +++ b/3rdparty/fcpp/fpp.exp @@ -0,0 +1,2 @@ +#! +fppPreProcess diff --git a/3rdparty/fcpp/fpp.fd b/3rdparty/fcpp/fpp.fd new file mode 100644 index 000000000..db0ac52fa --- /dev/null +++ b/3rdparty/fcpp/fpp.fd @@ -0,0 +1,4 @@ +##base _FPPBase +##bias 30 +fppPreProcess(a)(A0) +##end diff --git a/3rdparty/fcpp/fpp.h b/3rdparty/fcpp/fpp.h new file mode 100644 index 000000000..bf774dca6 --- /dev/null +++ b/3rdparty/fcpp/fpp.h @@ -0,0 +1,159 @@ +/****************************************************************************** + * FREXXWARE + * ---------------------------------------------------------------------------- + * + * Project: Frexx C Preprocessor + * $Source: /home/user/start/cpp/RCS/fpp.h,v $ + * $Revision: 1.5 $ + * $Date: 1994/01/24 09:38:45 $ + * $Author: start $ + * $State: Exp $ + * $Locker: start $ + * + * ---------------------------------------------------------------------------- + * $Log: fpp.h,v $ + * Revision 1.5 1994/01/24 09:38:45 start + * Added FPPTAG_RIGHTCONCAT. + * + * Revision 1.4 1993/12/06 13:51:20 start + * A lot of new stuff (too much to mention) + * + * Revision 1.3 1993/11/29 14:01:13 start + * New features added + * + * Revision 1.2 1993/11/11 07:16:39 start + * New stuff + * + * Revision 1.1 1993/11/03 09:15:59 start + * Initial revision + * + * + *****************************************************************************/ +/********************************************************************** + * + * fpp.h + * + */ + + +struct fppTag { + int tag; + void *data; +}; + +#ifndef TRUE +#define TRUE 1 +#endif + +#ifndef FALSE +#define FALSE 0 +#endif + +#define NFLAG_BUILTIN 1 +#define NFLAG_PREDEFINE 2 + +/* end of taglist: */ +#define FPPTAG_END 0 + +/* To make the preprocessed output keep the comments: */ +#define FPPTAG_KEEPCOMMENTS 1 /* data is TRUE or FALSE */ + +/* To define symbols to the preprocessor: */ +#define FPPTAG_DEFINE 2 /* data is the string "symbol" or "symbol=" */ + +/* To make the preprocessor ignore all non-fatal errors: */ +#define FPPTAG_IGNORE_NONFATAL 3 /* data is TRUE or FALSE */ + +/* To add an include directory to the include directory list: */ +#define FPPTAG_INCLUDE_DIR 4 /* data is directory name ending with a '/' (on + amiga a ':' is also valid) */ + +/* To define all machine specific built-in #defines, default is TRUE: */ +#define FPPTAG_BUILTINS 5 /* data is TRUE or FALSE */ + +/* To define predefines like __LINE__, __DATE__, etc. default is TRUE: */ +#define FPPTAG_PREDEFINES 6 /* data is TRUE or FALSE */ + +/* To make fpp leave C++ comments in the output: */ +#define FPPTAG_IGNORE_CPLUSPLUS 7 /* data is TRUE or FALSE */ + +/* To define new sizes to #if sizeof: */ +#define FPPTAG_SIZEOF_TABLE 8 /* data is sizeof table string */ + +/* To undefine symbols: */ +#define FPPTAG_UNDEFINE 9 /* data is symbol name */ + +/* Output all #defines: */ +#define FPPTAG_OUTPUT_DEFINES 10 /* data is TRUE or FALSE */ + +/* Initial input file name: */ +#define FPPTAG_INPUT_NAME 11 /* data is string */ + +/* Input function: */ +#define FPPTAG_INPUT 12 /* data is an input funtion */ + +/* Output function: */ +#define FPPTAG_OUTPUT 13 /* data is an output function */ + +/* User data, sent in the last argument to the input function: */ +#define FPPTAG_USERDATA 14 /* data is user data */ + +/* Whether to exclude #line instructions in the output, default is FALSE */ +#define FPPTAG_LINE 15 /* data is TRUE or FALSE */ + +/* Error function. This is called when FPP finds any warning/error/fatal: */ +#define FPPTAG_ERROR 16 /* data is function pointer to a + "void (*)(void *, char *, va_list)" */ + +/* Whether to warn for illegal cpp instructions */ +#define FPPTAG_WARNILLEGALCPP 17 /* data is boolean, default is FALSE */ + +/* Output the 'line' keyword on #line-lines? */ +#define FPPTAG_OUTPUTLINE 18 /* data is boolean, default is TRUE */ + +/* Do not output the version information string */ +#define FPPTAG_IGNOREVERSION 19 /* data is boolean, default is FALSE */ + +/* Output all included file names to stderr */ +#define FPPTAG_OUTPUTINCLUDES 20 /* data is boolean, default is FALSE */ + +/* Display warning if there is any brace, bracket or parentheses unbalance */ +#define FPPTAG_OUTPUTBALANCE 21 /* data is boolean, default is FALSE */ + +/* Display all whitespaces in the source */ +#define FPPTAG_OUTPUTSPACE 22 /* data is boolean, default is FALSE */ + +/* Allow nested comments */ +#define FPPTAG_NESTED_COMMENTS 23 /* data is boolean, default is FALSE */ + +/* Enable warnings at nested comments */ +#define FPPTAG_WARN_NESTED_COMMENTS 24 /* data is boolean, default is FALSE */ + +/* Enable warnings at missing includes */ +#define FPPTAG_WARNMISSINCLUDE 25 /* data is boolean, default is TRUE */ + +/* Output the main file */ +#define FPPTAG_OUTPUTMAIN 26 /* data is boolean, default is TRUE */ + +/* Include file */ +#define FPPTAG_INCLUDE_FILE 27 /* data is char pointer */ + +/* Include macro file */ +#define FPPTAG_INCLUDE_MACRO_FILE 28 /* data is char pointer */ + +/* Evaluate the right part of a concatenate before the concat */ +#define FPPTAG_RIGHTCONCAT 29 /* data is boolean, default is FALSE */ + +/* Include the specified file at the beginning of each function */ +#define FPPTAG_INITFUNC 30 /* data is char pointer or NULL */ + +/* Define function to be excluded from the "beginning-function-addings" */ +#define FPPTAG_EXCLFUNC 31 /* data is char pointer */ + +/* Enable output of all function names defined in the source */ +#define FPPTAG_DISPLAYFUNCTIONS 32 + +/* Switch on WWW-mode */ +#define FPPTAG_WEBMODE 33 + +int fppPreProcess(struct fppTag *); diff --git a/3rdparty/fcpp/fpp_pragmas.h b/3rdparty/fcpp/fpp_pragmas.h new file mode 100644 index 000000000..15f2f0fbd --- /dev/null +++ b/3rdparty/fcpp/fpp_pragmas.h @@ -0,0 +1,20 @@ +#ifdef RCS +static char rcsid[]="$Id$"; +#endif +/****************************************************************************** + * FREXXWARE + * ---------------------------------------------------------------------------- + * + * Project: Frexx C Preprocessor + * $Source$ + * $Revision$ + * $Date$ + * $Author$ + * $State$ + * $Locker$ + * + * ---------------------------------------------------------------------------- + * $Log$ + * + *****************************************************************************/ +#pragma libcall FPPBase fppPreProcess 1E 801 diff --git a/3rdparty/fcpp/makefile b/3rdparty/fcpp/makefile new file mode 100644 index 000000000..ec75d60c5 --- /dev/null +++ b/3rdparty/fcpp/makefile @@ -0,0 +1,86 @@ +############################################################################## +## FREXXWARE +############################################################################## +## +## Project: Frexx C Preprocessor +## $Source: /home/user/start/cpp/RCS/makefile,v $ +## $Revision: 1.3 $ +## $Date: 1994/06/02 09:11:24 $ +## $Author: start $ +## $State: Exp $ +## $Locker: $ +## +############################################################################## +## $Log: makefile,v $ +# Revision 1.3 1994/06/02 09:11:24 start +# Now uses 'gcc' and -O! +# +# Revision 1.2 1993/11/11 07:16:39 start +# New stuff +# +# Revision 1.1 1993/11/03 09:19:28 start +# Initial revision +# +## +############################################################################## + +# Frexx PreProcessor Makefile + +#HOST =-tp -B/home/danne/code/cpp/ -Wp\,-Q\,-Dunix\,-Ddpc\,-DAIX +#DEFINES = -Dunix -Dpdc -DAIX -DUNIX -DDEBUG +DEFINES = -Dunix -Dpdc -DUNIX -DDEBUG +DEBUGFLAG = -g +LD = ld +LDFLAGS = +LIB = libfpp.a +CPP = fpp +FILECPP = fcpp +TEMP = templib.o +EXPORT = fpp.exp +CC = gcc +CFLAGS = $(DEBUGFLAG) $(DEFINES) +AR = ar +ARFLAGS = rv +.SUFFIXES: .o .c .c~ .h .h~ .a .i +OBJS = cpp1.o cpp2.o cpp3.o cpp4.o cpp5.o cpp6.o +FILEOBJS = cpp1.o cpp2.o cpp3.o cpp4.o cpp5.o cpp6.o usecpp.o + +# ** compile cpp +# + +#all: $(LIB) $(CPP) +all: $(FILECPP) + +$(LIB) : $(OBJS) $(EXPORT) + $(LD) $(OBJS) -o $(TEMP) -bE:$(EXPORT) -bM:SRE -T512 -H512 -lc + rm -f $(LIB) + $(AR) $(ARFLAGS) $(LIB) $(TEMP) + rm $(TEMP) + +$(CPP) : usecpp.c + $(CC) $(CFLAGS) -o $(CPP) usecpp.c -L. -lfpp + +$(FILECPP) : $(FILEOBJS) + $(CC) $(FILEOBJS) -o $(FILECPP) + +.c.o: + $(CC) $(CFLAGS) -c $< + +cpp1.o:cpp1.c +cpp2.o:cpp2.c +cpp3.o:cpp3.c +cpp4.o:cpp4.c +cpp5.o:cpp5.c +cpp6.o:cpp6.c +memory.o:memory.c + +usecpp.o:usecpp.c + +clean : + rm -f *.o $(FILECPP) + +tgz: + rm -f makefile*~ + (dir=`pwd`;name=`basename $$dir`;echo Creates $$name.tar.gz; cd .. ; \ + tar -cf $$name.tar `ls $$name/*.[ch] $$name/*.exp $$name/*.fd $$name/makefile*` ; \ + gzip $$name.tar ; chmod a+r $$name.tar.gz ; mv $$name.tar.gz $$name/) diff --git a/3rdparty/fcpp/usecpp.c b/3rdparty/fcpp/usecpp.c new file mode 100644 index 000000000..3611ed247 --- /dev/null +++ b/3rdparty/fcpp/usecpp.c @@ -0,0 +1,602 @@ +/****************************************************************************** +Copyright (c) 1999 Daniel Stenberg + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +******************************************************************************/ +/****************************************************************************** + * FREXXWARE + * ---------------------------------------------------------------------------- + * + * Project: Frexx C Preprocessor + * $Source: /home/user/start/cpp/RCS/usecpp.c,v $ + * $Revision: 1.6 $ + * $Date: 1994/06/02 09:11:01 $ + * $Author: start $ + * $State: Exp $ + * $Locker: start $ + * + * ---------------------------------------------------------------------------- + * $Log: usecpp.c,v $ + * Revision 1.6 1994/06/02 09:11:01 start + * Added the '-n' option! + * + * Revision 1.5 1994/06/02 08:51:49 start + * Added three more command line parameters + * Made -h invokes exit nice + * + * Revision 1.4 1994/01/24 09:37:17 start + * Major difference. + * + * Revision 1.3 1993/12/06 13:51:20 start + * A lot of new stuff (too much to mention) + * + * Revision 1.2 1993/11/11 07:16:39 start + * New stuff + * + * Revision 1.1 1993/11/03 09:13:08 start + * Initial revision + * + * + *****************************************************************************/ +/********************************************************************** + * + * usecpp.c + * + * This is a routine that is should be used to call functions in the + * fpp.library. We supply the own_input() and own_output() functions to + * the preprocessor to remain flexible. + */ + +#include + +#ifdef AMIGA +#include +#include + +#if defined(SHARED) +#include +#include + +#include "fpp_pragmas.h" +#include "fpp_protos.h" +#include "FPPBase.h" +struct Library *FPPBase=NULL; +#define PREFIX __saveds +#define REG(x) register __ ## x +#else +#define PREFIX +#define REG(x) +#endif + +#elif defined(UNIX) +#if defined(OS9) +#include +#else +#include +#ifdef BSD +#include /* for BSD systems (SUN OS at least) */ +#endif +#endif +#define PREFIX +#define REG(x) +#endif +#include +#include +#include +#include +#ifndef OS9 +#include +#else +#define va_list void * +#endif + +#include "fpp.h" +#define MAX_TAGS 40 /* maximum number of tags allowed! */ +#define FILE_LOCAL static + +#define CPP_PREFS_FILE "cpp.prefs" +#ifdef AMIGA +#define DEFAULT_CPP_PREFS_FILE "s:cpp.prefs" +#else +#define DEFAULT_CPP_PREFS_FILE "$HOME/cpp.prefs" +#endif + +FILE_LOCAL char PREFIX *own_input(char *, int, void *); +FILE_LOCAL void PREFIX own_output(int, void *); +FILE_LOCAL void PREFIX own_error(void *, char *, va_list); +FILE_LOCAL int SetOptions(int, char **, struct fppTag **); +FILE_LOCAL char GetPrefs(struct fppTag **, char **); +FILE_LOCAL char DoString(struct fppTag **, char *); + +#ifdef AMIGA +extern long __stack=8000; +#endif + +FILE_LOCAL char ignore=FALSE; /* if we should ignore strange flags! */ +FILE_LOCAL char display=FALSE; /* display all options in use! */ + +FILE_LOCAL char dontreadprefs; /* set if only the command line is valid */ + +int main(int argc, char **argv) +{ + struct fppTag tags[MAX_TAGS]; + int i; + struct fppTag *tagptr = tags; + char *dealloc; + + /* + * Append system-specific directories to the include directory list. + * The include directories will be searched through in the same order + * as you add them in the taglist! + * The directory _must_ end with a proper directory speparator! + */ + + tagptr->tag=FPPTAG_INCLUDE_DIR; +#if defined (AMIGA) + tagptr->data = "INCLUDE:"; +#elif defined (OS9) + tagptr->data = "/dd/defs/"; +#else + tagptr->data = "/usr/include/"; +#endif + tagptr++; + + if(GetPrefs(&tagptr, &dealloc)) + return(0); + + if( !(i = SetOptions(argc, argv, &tagptr))) + return(0); + + if (argc - i >2) { + printf("Too many file arguments. Usage: cpp [options] [input [output]]\n"); + return(-1); + } + + tagptr->tag=FPPTAG_INPUT; + tagptr->data=(void *)own_input; + tagptr++; + + if(itag=FPPTAG_INPUT_NAME; + tagptr->data=argv[i]; + tagptr++; + if(display) + fprintf(stderr, "cpp: input: %s\n", argv[i]); + } else /* Else, just get stdin */ + if(display) + fprintf(stderr, "cpp: input: [stdin]\n"); + i++; + } else + if(display) + fprintf(stderr, "cpp: input: [stdin]\n"); + + if(itag=FPPTAG_OUTPUT; + tagptr->data=(void *)own_output; + tagptr++; + + tagptr->tag=FPPTAG_ERROR; + tagptr->data=(void *)own_error; + tagptr++; + + /* The LAST tag: */ + + tagptr->tag=FPPTAG_END; + tagptr->data=0; + tagptr++; + +#if defined(SHARED) && defined(AMIGA) + if(!(FPPBase=OpenLibrary(FPPNAME, 1))) { + printf("Error opening %s!\n", FPPNAME); + return(-1); + } +#endif + fppPreProcess(tags); + +#if defined(SHARED) && defined(AMIGA) + CloseLibrary((struct Library *)FPPBase); +#endif + /* + * Preprocess ready! + */ + + if( dealloc ) + free( dealloc ); + + return(0); +} + + +FILE_LOCAL +char PREFIX *own_input(char *buffer, int size, void *userdata) +{ + return(fgets(buffer, size, stdin)); +} + +FILE_LOCAL +void PREFIX own_output(int c, void *userdata) +{ + putchar(c); +} + +FILE_LOCAL +void PREFIX own_error(void *userdata, char *format, va_list arg) +{ + vfprintf(stderr, format, arg); +} + +FILE_LOCAL +char GetPrefs(struct fppTag **tagptr, char **string) +{ + + FILE *PrefsFile_PF; + unsigned Length_U; + char *PrefsBuffer_PC; + char ret= 0; + char *environ; + + *string = NULL; + + /* Open prefs file for read */ + if ( (PrefsFile_PF = fopen(CPP_PREFS_FILE, "r")) || + (PrefsFile_PF = fopen(DEFAULT_CPP_PREFS_FILE, "r"))) { + + fseek(PrefsFile_PF, 0 , SEEK_END); + Length_U = ftell(PrefsFile_PF); + fseek(PrefsFile_PF, 0, SEEK_SET); + + if (*string = (char *)malloc(Length_U+1)) { + fread(*string, 1, Length_U, PrefsFile_PF); + (*string)[Length_U] = '\0'; + + ret = !DoString(tagptr, *string); + } + fclose(PrefsFile_PF); + if(ret) { + free( *string ); + return ret; + } + } + + if(environ = getenv("CPP_PREFS")) { + ret= !DoString(tagptr, environ); + if(ret && *string) + free( *string ); + } + return ret; +} + +FILE_LOCAL +char DoString(struct fppTag **tagptr, char *string) +{ + char *argv[MAX_TAGS]; + int argc=1; + do { + while(*string && *string != '-') + string++; + + if(!*string) + break; + + argv[argc]=string; + + do { + string++; + if(*string=='\"') { + do + string++; + while(*string != '\"'); + string++; + } + } while(*string && *string!=' ' && *string != '\n' && *string != '\t'); + argc++; + if(*string) { + *string='\0'; + string++; + } else + break; + } while(1); + + return (SetOptions(argc, argv, tagptr)); +} + +FILE_LOCAL +int SetOptions(int argc, char **argv, struct fppTag **tagptr) +{ + int i; + char *ap; + for (i = 1; i < argc; i++) { + ap = argv[i]; + if (*ap++ != '-' || *ap == '\0') + break; + else { + char c = *ap++; + + if(display) + fprintf(stderr, "cpp: option: %s\n", ap-2); + + switch (c) { /* Command character */ + case 'Q': /* ignore unknown flags but */ + ignore=1; /* output them on stderr */ + break; + + case 'q': /* ignore unknown flags */ + ignore=2; + break; + + case 'H': /* display all whitespaces */ + (*tagptr)->tag = FPPTAG_OUTPUTSPACE; + (*tagptr)->data= (void *)TRUE; + (*tagptr)++; + break; + + case 'b': /* display unbalance */ + (*tagptr)->tag = FPPTAG_OUTPUTBALANCE; + (*tagptr)->data= (void *)TRUE; + (*tagptr)++; + break; + + case 'f': /* output all defined functions! */ + (*tagptr)->tag = FPPTAG_DISPLAYFUNCTIONS; + (*tagptr)->data= (void *)TRUE; + (*tagptr)++; + break; + + case 'F': /* output all included files! */ + (*tagptr)->tag = FPPTAG_OUTPUTINCLUDES; + (*tagptr)->data= (void *)TRUE; + (*tagptr)++; + break; + + case 'V': /* do not output version */ + (*tagptr)->tag = FPPTAG_IGNOREVERSION; + (*tagptr)->data= (void *)FALSE; + (*tagptr)++; + break; + + case 'C': /* Keep comments */ + (*tagptr)->tag = FPPTAG_KEEPCOMMENTS; + (*tagptr)->data= (void *)TRUE; + (*tagptr)++; + break; + + case 'D': /* Define symbol */ + (*tagptr)->tag=FPPTAG_DEFINE; + (*tagptr)->data=argv[i]+2; + (*tagptr)++; + break; + + case 'd': /* Display all options */ + fprintf(stderr, "FOUND -d flag!\n"); + display = TRUE; + break; + + case 'E': /* Ignore non-fatal errors */ + (*tagptr)->tag=FPPTAG_IGNORE_NONFATAL; + (*tagptr)->data=(void *)TRUE; + (*tagptr)++; + break; + + case 'I': /* Include directory */ + (*tagptr)->tag=FPPTAG_INCLUDE_DIR; + (*tagptr)->data=ap; + (*tagptr)++; + break; + + case 'J': /* Allow nested comments */ + (*tagptr)->tag=FPPTAG_NESTED_COMMENTS; + (*tagptr)->data=ap; + (*tagptr)++; + break; + + case 'j': /* Warn at nested comments */ + (*tagptr)->tag=FPPTAG_WARN_NESTED_COMMENTS; + (*tagptr)->data=ap; + (*tagptr)++; + break; + + case 'L': + if(*ap == 'L') { /* Do not output #line */ + (*tagptr)->tag=FPPTAG_LINE; + } else { + /* Do not output the 'line' keyword */ + (*tagptr)->tag=FPPTAG_OUTPUTLINE; + } + (*tagptr)->data=(void *)FALSE; + (*tagptr)++; + break; + + case 'M': /* Do not warn at missing includes */ + (*tagptr)->tag=FPPTAG_WARNMISSINCLUDE; + (*tagptr)->data=(void *)FALSE; + (*tagptr)++; + break; + + case 'n': + dontreadprefs^=1; /* toggle prefsreading, default is read prefs */ + + /* + * This flag should reset all previously added tags! + */ + + break; + + case 'N': /* No machine specific built-ins */ + (*tagptr)->tag=FPPTAG_BUILTINS; + (*tagptr)->data=(void *)FALSE; + (*tagptr)++; + break; + + case 'B': /* No predefines like __LINE__, etc. */ + (*tagptr)->tag=FPPTAG_PREDEFINES; + (*tagptr)->data=(void *)FALSE; + (*tagptr)++; + break; + + case 'P': /* No C++ comments */ + (*tagptr)->tag=FPPTAG_IGNORE_CPLUSPLUS; + (*tagptr)->data=(void *)TRUE; + (*tagptr)++; + break; + + case 'p': /* warn about illegal # - instructions */ + (*tagptr)->tag = FPPTAG_WARNILLEGALCPP; + (*tagptr)->data= (void *)TRUE; + (*tagptr)++; + break; + + case 'R': + (*tagptr)->tag = FPPTAG_RIGHTCONCAT; + (*tagptr)->data= (void *)TRUE; + (*tagptr)++; + break; + + case 's': /* sizeof table */ + (*tagptr)->tag=FPPTAG_INITFUNC; + (*tagptr)->data=ap; + (*tagptr)++; + break; + + case 't': /* excluded functions */ + (*tagptr)->tag=FPPTAG_EXCLFUNC; + (*tagptr)->data=ap; + (*tagptr)++; + break; + + case 'S': /* sizeof table */ + (*tagptr)->tag=FPPTAG_SIZEOF_TABLE; + (*tagptr)->data=ap; + (*tagptr)++; + break; + + case 'U': /* Undefine symbol */ + (*tagptr)->tag=FPPTAG_UNDEFINE; + (*tagptr)->data=ap; + (*tagptr)++; + break; + + case 'w': /* Output all #defines but not the + main file */ + (*tagptr)->tag=FPPTAG_OUTPUTMAIN; + (*tagptr)->data=(void *)FALSE; + (*tagptr)++; + + case 'W': /* Output all #defines */ + if(!strncmp(ap, "WW", 2)) { + (*tagptr)->tag=FPPTAG_WEBMODE; + (*tagptr)->data=(void *)TRUE; + (*tagptr)++; + } + else { + (*tagptr)->tag=FPPTAG_OUTPUT_DEFINES; + (*tagptr)->data=(void *)TRUE; + (*tagptr)++; + } + break; + + case 'X': + (*tagptr)->tag=FPPTAG_INCLUDE_FILE; + (*tagptr)->data=ap; + (*tagptr)++; + break; + +/* + case 'x': + tags[tag]->tag=FPPTAG_INCLUDE_MACRO_FILE; + tags[tag++]->data=ap; + break; +*/ + case 'h': + case '?': /* if a question mark is possible to specify! */ + default: /* What is this one? */ + if( ignore < 2 && c != 'h') { + fprintf(stderr, "cpp: unknown option: -%s\n", ap-1); + } + if(!ignore || c == 'h') { + fprintf(stderr, + "Usage: cpp [options] [infile [outfile] ]\n\n" + "The following options are valid:\n" + " -B\tNo mahcine specific built-in symbols\n" + " -b\tOutput any parentheses, brace or bracket unbalance\n" + " -C\tWrite source file comments to output\n" + " -D\tDefine a symbol with the given (optional) value \"symbol[=value]\"\n" + " -d\tDisplay all specified options\n" + " -E\tIgnore non-fatal errors\n" + " -F\tOutput all included file names on stderr\n" + " -f\tOutput all defined functions' names on stderr\n" + " -H\tOutput all whitespaces from the source file\n" + " -h\tOutput this help text\n" + " -I\tAdd directory to the #include search list\n" + " -J\tAllow nested comments\n" + " -j\tEnable warnings for nested comments\n" + " -LL\tDon't output #line instructions\n" + " -L\tDon't output the 'line' keyword in \"#line\" instructions\n" + " -M\tDon't warn for missing include files\n" + " -N\tDon't predefine target-specific names\n" + " -n\tToggle prefs usage\n" + " -P\tDon't recognize C++ comment style\n" + " -p\tEnable warnings on non ANSI preprocessor instructions\n" + " -Q\tIgnore but visualize undefined flags\n" + " -q\tIgnore all undefined flags\n" + " -R\tEvaluate the right part first in symbol concatenations\n" + " -s\tInclude the following string at the top of each function\n" + " -S\tSpecify sizes for #if sizeof\n" + " -t\tThis function should not get an initial function\n" + " -U\tUndefine symbol\n" + " -V\tDon't output version information\n" + " -W\tOutput all #defines\n" + " -WWW\tWeb mode preprocessing\n" + " -w\tOnly output #defines\n" + " -X\tInclude file\n"); + return(0); + } /* if (!ignore) */ + } /* Switch on all options */ + } /* If it's a -option */ + } /* For all arguments */ + + return i; + +} /* end of function */ diff --git a/3rdparty/glsl-optimizer/.emacs-dirvars b/3rdparty/glsl-optimizer/.emacs-dirvars new file mode 100644 index 000000000..33945f91e --- /dev/null +++ b/3rdparty/glsl-optimizer/.emacs-dirvars @@ -0,0 +1,10 @@ +;; -*- emacs-lisp -*- +;; +;; This file is processed by the dirvars emacs package. Each variable +;; setting below is performed when this dirvars file is loaded. +;; +indent-tabs-mode: nil +tab-width: 8 +c-basic-offset: 3 +kde-emacs-after-parent-string: "" +evaluate: (c-set-offset 'inline-open '0) diff --git a/3rdparty/glsl-optimizer/.gitattributes b/3rdparty/glsl-optimizer/.gitattributes new file mode 100644 index 000000000..23c6280f6 --- /dev/null +++ b/3rdparty/glsl-optimizer/.gitattributes @@ -0,0 +1,4 @@ +*.dsp -crlf +*.dsw -crlf +*.sln -crlf +*.vcproj -crlf diff --git a/3rdparty/glsl-optimizer/.gitignore b/3rdparty/glsl-optimizer/.gitignore new file mode 100644 index 000000000..0f9c9ff1f --- /dev/null +++ b/3rdparty/glsl-optimizer/.gitignore @@ -0,0 +1,57 @@ +*.a +*.dll +*.exe +*.ilk +*.o +*.obj +*.os +*.pc +*.pdb +*.pyc +*.pyo +*.so +*.sw[a-z] +*.tar +*.tar.bz2 +*.tar.gz +*.zip +*~ +depend +depend.bak +lib +lib64 +configure +autom4te.cache +aclocal.m4 +config.log +config.status +cscope* +.scon* +config.py +build +manifest.txt +.dir-locals.el +*.pbxuser +*.perspectivev3 +*.mode1v3 +.svn +*.ncb +*.user +*.suo +*.dSYM +xcuserdata +*.xcworkspace + +cmake_install.cmake +Makefile +CMakeFiles/ +CMakeCache.txt +.project +.cproject +glsl_main +glsl_test +glcpp +glslopt +glsl_compiler +.settings/ +.pydevproject diff --git a/3rdparty/glsl-optimizer/CMakeLists.txt b/3rdparty/glsl-optimizer/CMakeLists.txt new file mode 100644 index 000000000..9f400b82e --- /dev/null +++ b/3rdparty/glsl-optimizer/CMakeLists.txt @@ -0,0 +1,45 @@ +cmake_minimum_required(VERSION 2.8) + +include_directories(include) +include_directories(src/mesa) +include_directories(src/mapi) +include_directories(src/glsl) + +option (DEBUG "Enable debugging" FALSE) + +if(${DEBUG} MATCHES "on") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0") +else() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Os -DNDEBUG") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Os -DNDEBUG") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -s") +endif() + +file(GLOB glcpp-library_sources src/glsl/glcpp/*.c) +file(GLOB glcpp-library_sources_remove src/glsl/glcpp/glcpp.c) +list(REMOVE_ITEM glcpp-library_sources ${glcpp-library_sources_remove}) +add_library(glcpp-library ${glcpp-library_sources}) + +file(GLOB mesa_sources src/mesa/program/*.c) +add_library(mesa ${mesa_sources}) + +file(GLOB glsl_sources src/glsl/*.cpp src/glsl/*.c) +file(GLOB glsl_sources_remove src/glsl/main.cpp src/glsl/builtin_stubs.cpp) +list(REMOVE_ITEM glsl_sources ${glsl_sources_remove}) +add_library(glsl_optimizer ${glsl_sources}) +target_link_libraries(glsl_optimizer glcpp-library mesa) + +add_executable(glsl_compiler src/glsl/main.cpp) +target_link_libraries(glsl_compiler glsl_optimizer) + +file(GLOB glsl_test_sources tests/*.cpp) +add_executable(glsl_test ${glsl_test_sources}) +target_link_libraries(glsl_test glsl_optimizer) + +file(GLOB glslopt_sources contrib/glslopt/*.cpp) +add_executable(glslopt ${glslopt_sources}) +target_link_libraries(glslopt glsl_optimizer) + +add_executable(glcpp src/glsl/glcpp/glcpp.c) +target_link_libraries(glcpp glsl_optimizer) \ No newline at end of file diff --git a/3rdparty/glsl-optimizer/README.md b/3rdparty/glsl-optimizer/README.md new file mode 100644 index 000000000..8c3531f17 --- /dev/null +++ b/3rdparty/glsl-optimizer/README.md @@ -0,0 +1,50 @@ +GLSL optimizer +============== + +A C++ library that takes GLSL shaders, does some GPU-independent optimizations on them +and outputs GLSL back. Optimizations are function inlining, dead code removal, copy propagation, +constant folding, constant propagation, arithmetic optimizations and so on. + +Apparently quite a few mobile platforms are pretty bad at optimizing GLSL shaders; and +unfortunately they *also* lack offline shader compilers. So using a GLSL optimizer offline +before can make the shader run much faster on a platform like that. See performance numbers +in [this blog post](http://aras-p.info/blog/2010/09/29/glsl-optimizer/). + +Almost all actual code is [Mesa 3D's GLSL2](http://cgit.freedesktop.org/mesa/mesa/log/?h=glsl2) +compiler; all this library does is spits out optimized GLSL back. + +This GLSL optimizer is made for [Unity's](http://unity3d.com/) purposes and is built-in +in [Unity 3.0](http://unity3d.com/unity/whats-new/unity-3). + +GLSL Optimizer is licensed according to the terms of the MIT license. + + +Usage +----- + +Visual Studio 2008 (Windows, x86) and Xcode 3.2 (Mac, i386) project files for a static +library are provided in `src/glsl/msvc/mesaglsl2.vcproj` and `src/glsl/xcode/mesaglsl2` +respectively. + +For Linux you can use cmake. Just type "cmake . && make" in the root directory. +This will build the optimizer library and some executable binaries. + +Interface for the library is `src/glsl/glsl_optimizer.h`. General usage is: + + ctx = glslopt_initialize(); + for (lots of shaders) { + shader = glslopt_optimize (ctx, shaderType, shaderSource, options); + if (glslopt_get_status (shader)) { + newSource = glslopt_get_output (shader); + } else { + errorLog = glslopt_get_log (shader); + } + glslopt_shader_delete (shader); + } + glslopt_cleanup (ctx); + +Notes +----- + +* I haven't checked if/how it works with higher GLSL versions than the + default (1.10?). diff --git a/3rdparty/glsl-optimizer/autogen.sh b/3rdparty/glsl-optimizer/autogen.sh new file mode 100644 index 000000000..c76bf8b07 --- /dev/null +++ b/3rdparty/glsl-optimizer/autogen.sh @@ -0,0 +1,18 @@ +#! /bin/sh + +srcdir=`dirname "$0"` +test -z "$srcdir" && srcdir=. + +SRCDIR=`(cd "$srcdir" && pwd)` +ORIGDIR=`pwd` + +if test "x$SRCDIR" != "x$ORIGDIR"; then + echo "Mesa cannot be built when srcdir != builddir" 1>&2 + exit 1 +fi + +MAKEFLAGS="" + +autoreconf -v --install || exit 1 + +"$srcdir"/configure "$@" diff --git a/3rdparty/glsl-optimizer/contrib/staticlib/Build/Tool/SourceFiles b/3rdparty/glsl-optimizer/contrib/staticlib/Build/Tool/SourceFiles new file mode 100644 index 000000000..61be13694 --- /dev/null +++ b/3rdparty/glsl-optimizer/contrib/staticlib/Build/Tool/SourceFiles @@ -0,0 +1,90 @@ + ../../../../src/mesa/program/hash_table.c + ../../../../src/mesa/program/hash_table.h + ../../../../src/mesa/program/symbol_table.c + ../../../../src/mesa/program/symbol_table.h + ../../../../src/talloc/talloc.c + ../../../../src/talloc/talloc.h + ../../../../src/glsl/ast.h + ../../../../src/glsl/ast_expr.cpp + ../../../../src/glsl/ast_function.cpp + ../../../../src/glsl/ast_to_hir.cpp + ../../../../src/glsl/ast_type.cpp + ../../../../src/glsl/builtin_function.cpp + ../../../../src/glsl/builtin_types.h + ../../../../src/glsl/builtin_variables.h + ../../../../src/glsl/glsl_lexer.cpp + ../../../../src/glsl/glsl_lexer.lpp + ../../../../src/glsl/glsl_optimizer.cpp + ../../../../src/glsl/glsl_optimizer.h +# ../../../../src/glsl/glsl_optimizer_main.cpp + ../../../../src/glsl/glsl_parser.cpp + ../../../../src/glsl/glsl_parser.h + ../../../../src/glsl/glsl_parser.ypp + ../../../../src/glsl/glsl_parser_extras.cpp + ../../../../src/glsl/glsl_parser_extras.h + ../../../../src/glsl/glsl_symbol_table.h + ../../../../src/glsl/glsl_types.cpp + ../../../../src/glsl/glsl_types.h + ../../../../src/glsl/hir_field_selection.cpp + ../../../../src/glsl/ir.cpp + ../../../../src/glsl/ir.h + ../../../../src/glsl/ir_algebraic.cpp + ../../../../src/glsl/ir_basic_block.cpp + ../../../../src/glsl/ir_basic_block.h + ../../../../src/glsl/ir_clone.cpp + ../../../../src/glsl/ir_constant_expression.cpp + ../../../../src/glsl/ir_constant_folding.cpp + ../../../../src/glsl/ir_constant_propagation.cpp + ../../../../src/glsl/ir_constant_variable.cpp + ../../../../src/glsl/ir_copy_propagation.cpp + ../../../../src/glsl/ir_dead_code.cpp + ../../../../src/glsl/ir_dead_code_local.cpp + ../../../../src/glsl/ir_dead_functions.cpp + ../../../../src/glsl/ir_div_to_mul_rcp.cpp + ../../../../src/glsl/ir_expression_flattening.cpp + ../../../../src/glsl/ir_expression_flattening.h + ../../../../src/glsl/ir_function.cpp + ../../../../src/glsl/ir_function_can_inline.cpp + ../../../../src/glsl/ir_function_inlining.cpp + ../../../../src/glsl/ir_function_inlining.h + ../../../../src/glsl/ir_hierarchical_visitor.cpp + ../../../../src/glsl/ir_hierarchical_visitor.h + ../../../../src/glsl/ir_hv_accept.cpp + ../../../../src/glsl/ir_if_return.cpp + ../../../../src/glsl/ir_if_simplification.cpp + ../../../../src/glsl/ir_if_to_cond_assign.cpp + ../../../../src/glsl/ir_import_prototypes.cpp + ../../../../src/glsl/ir_mat_op_to_vec.cpp + ../../../../src/glsl/ir_mod_to_fract.cpp + ../../../../src/glsl/ir_noop_swizzle.cpp + ../../../../src/glsl/ir_optimization.h + ../../../../src/glsl/ir_print_glsl_visitor.cpp + ../../../../src/glsl/ir_print_glsl_visitor.h + ../../../../src/glsl/ir_print_visitor.cpp + ../../../../src/glsl/ir_print_visitor.h + ../../../../src/glsl/ir_reader.cpp + ../../../../src/glsl/ir_reader.h + ../../../../src/glsl/ir_rvalue_visitor.cpp + ../../../../src/glsl/ir_rvalue_visitor.h + ../../../../src/glsl/ir_structure_splitting.cpp + ../../../../src/glsl/ir_sub_to_add_neg.cpp + ../../../../src/glsl/ir_swizzle_swizzle.cpp + ../../../../src/glsl/ir_tree_grafting.cpp + ../../../../src/glsl/ir_unused_structs.cpp + ../../../../src/glsl/ir_unused_structs.h + ../../../../src/glsl/ir_validate.cpp + ../../../../src/glsl/ir_variable.cpp + ../../../../src/glsl/ir_variable_refcount.cpp + ../../../../src/glsl/ir_variable_refcount.h + ../../../../src/glsl/ir_vec_index_to_cond_assign.cpp + ../../../../src/glsl/ir_vec_index_to_swizzle.cpp + ../../../../src/glsl/ir_visitor.h + ../../../../src/glsl/link_functions.cpp + ../../../../src/glsl/linker.cpp + ../../../../src/glsl/linker.h + ../../../../src/glsl/list.h +# ../../../../src/glsl/main.cpp + ../../../../src/glsl/program.h + ../../../../src/glsl/s_expression.cpp + ../../../../src/glsl/s_expression.h + ../../../../src/glsl/msvc/msvccompat.h diff --git a/3rdparty/glsl-optimizer/contrib/staticlib/Build/Tool/glsloptlib.bdgcfg b/3rdparty/glsl-optimizer/contrib/staticlib/Build/Tool/glsloptlib.bdgcfg new file mode 100644 index 000000000..34d312f52 --- /dev/null +++ b/3rdparty/glsl-optimizer/contrib/staticlib/Build/Tool/glsloptlib.bdgcfg @@ -0,0 +1,9 @@ +[General] +Type = StaticLibrary +SourceFiles = SourceFiles +Platform = Tool + +[Project] +IncludePaths=../../../../src/talloc;../../../../include;../../../../src/mesa;../../../../src/mapi;../../../../src/glsl/msvc;../../../../src/glsl +Defines=snprintf=_snprintf;NOMINMAX;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE +DisabledVcWarnings=4291;4996;4800;4099;4244;4018;4245 diff --git a/3rdparty/glsl-optimizer/contrib/staticlib/Build/Tool/glsloptlib.vcproj b/3rdparty/glsl-optimizer/contrib/staticlib/Build/Tool/glsloptlib.vcproj new file mode 100644 index 000000000..53b434097 --- /dev/null +++ b/3rdparty/glsl-optimizer/contrib/staticlib/Build/Tool/glsloptlib.vcproj @@ -0,0 +1,829 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/3rdparty/glsl-optimizer/generateParsers.sh b/3rdparty/glsl-optimizer/generateParsers.sh new file mode 100644 index 000000000..dc1c0c75b --- /dev/null +++ b/3rdparty/glsl-optimizer/generateParsers.sh @@ -0,0 +1,5 @@ +#! /bin/sh +flex --nounistd -osrc/glsl/glcpp/glcpp-lex.c src/glsl/glcpp/glcpp-lex.l +flex --nounistd -osrc/glsl/glsl_lexer.cpp src/glsl/glsl_lexer.ll +bison -v -o "src/glsl/glcpp/glcpp-parse.c" --defines=src/glsl/glcpp/glcpp-parse.h src/glsl/glcpp/glcpp-parse.y +bison -v -o "src/glsl/glsl_parser.cpp" -p "_mesa_glsl_" --defines=src/glsl/glsl_parser.h src/glsl/glsl_parser.yy diff --git a/3rdparty/glsl-optimizer/include/GL/gl.h b/3rdparty/glsl-optimizer/include/GL/gl.h new file mode 100644 index 000000000..bca550fa2 --- /dev/null +++ b/3rdparty/glsl-optimizer/include/GL/gl.h @@ -0,0 +1,2241 @@ +/* + * Mesa 3-D graphics library + * Version: 7.6 + * + * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * Copyright (C) 2009 VMware, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#ifndef __gl_h_ +#define __gl_h_ + +#if defined(USE_MGL_NAMESPACE) +#include "gl_mangle.h" +#endif + + +/********************************************************************** + * Begin system-specific stuff. Do not do any of this when building + * for SciTech SNAP, as this is all done before this header file is + * included. + */ +#if !defined(__SCITECH_SNAP__) + +#if defined(__BEOS__) +#include /* to get some BeOS-isms */ +#endif + +#if !defined(OPENSTEP) && (defined(NeXT) || defined(NeXT_PDO)) +#define OPENSTEP +#endif + +#if defined(_WIN32) && !defined(__WIN32__) && !defined(__CYGWIN__) +#define __WIN32__ +#endif + +#if !defined(OPENSTEP) && (defined(__WIN32__) && !defined(__CYGWIN__)) +# if (defined(_MSC_VER) || defined(__MINGW32__)) && defined(BUILD_GL32) /* tag specify we're building mesa as a DLL */ +# define GLAPI __declspec(dllexport) +# elif (defined(_MSC_VER) || defined(__MINGW32__)) && defined(_DLL) /* tag specifying we're building for DLL runtime support */ +# define GLAPI __declspec(dllimport) +# else /* for use with static link lib build of Win32 edition only */ +# define GLAPI extern +# endif /* _STATIC_MESA support */ +# if defined(__MINGW32__) && defined(GL_NO_STDCALL) || defined(UNDER_CE) /* The generated DLLs by MingW with STDCALL are not compatible with the ones done by Microsoft's compilers */ +# define GLAPIENTRY +# else +# define GLAPIENTRY __stdcall +# endif +#elif defined(__CYGWIN__) && defined(USE_OPENGL32) /* use native windows opengl32 */ +# define GLAPI extern +# define GLAPIENTRY __stdcall +#elif defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) +# define GLAPI __attribute__((visibility("default"))) +# define GLAPIENTRY +#endif /* WIN32 && !CYGWIN */ + +#if (defined(__BEOS__) && defined(__POWERPC__)) || defined(__QUICKDRAW__) +# define PRAGMA_EXPORT_SUPPORTED 1 +#endif + +/* + * WINDOWS: Include windows.h here to define APIENTRY. + * It is also useful when applications include this file by + * including only glut.h, since glut.h depends on windows.h. + * Applications needing to include windows.h with parms other + * than "WIN32_LEAN_AND_MEAN" may include windows.h before + * glut.h or gl.h. + */ +#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN 1 +#endif +#include +#endif + +#if defined(_WIN32) && !defined(_WINGDI_) && !defined(_WIN32_WCE) \ + && !defined(_GNU_H_WINDOWS32_DEFINES) && !defined(OPENSTEP) \ + && !defined(__CYGWIN__) || defined(__MINGW32__) +#include +#endif + +#if defined(macintosh) && PRAGMA_IMPORT_SUPPORTED +#pragma import on +#endif + +#ifndef GLAPI +#define GLAPI extern +#endif + +#ifndef GLAPIENTRY +#define GLAPIENTRY +#endif + +#ifndef APIENTRY +#define APIENTRY GLAPIENTRY +#endif + +/* "P" suffix to be used for a pointer to a function */ +#ifndef APIENTRYP +#define APIENTRYP APIENTRY * +#endif + +#ifndef GLAPIENTRYP +#define GLAPIENTRYP GLAPIENTRY * +#endif + +#ifdef CENTERLINE_CLPP +#define signed +#endif + +#if defined(PRAGMA_EXPORT_SUPPORTED) +#pragma export on +#endif + +#endif /* !__SCITECH_SNAP__ */ +/* + * End system-specific stuff. + **********************************************************************/ + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +#define GL_VERSION_1_1 1 +#define GL_VERSION_1_2 1 +#define GL_VERSION_1_3 1 +#define GL_ARB_imaging 1 + + +/* + * Datatypes + */ +typedef unsigned int GLenum; +typedef unsigned char GLboolean; +typedef unsigned int GLbitfield; +typedef void GLvoid; +typedef signed char GLbyte; /* 1-byte signed */ +typedef short GLshort; /* 2-byte signed */ +typedef int GLint; /* 4-byte signed */ +typedef unsigned char GLubyte; /* 1-byte unsigned */ +typedef unsigned short GLushort; /* 2-byte unsigned */ +typedef unsigned int GLuint; /* 4-byte unsigned */ +typedef int GLsizei; /* 4-byte signed */ +typedef float GLfloat; /* single precision float */ +typedef float GLclampf; /* single precision float in [0,1] */ +typedef double GLdouble; /* double precision float */ +typedef double GLclampd; /* double precision float in [0,1] */ + + + +/* + * Constants + */ + +/* Boolean values */ +#define GL_FALSE 0x0 +#define GL_TRUE 0x1 + +/* Data types */ +#define GL_BYTE 0x1400 +#define GL_UNSIGNED_BYTE 0x1401 +#define GL_SHORT 0x1402 +#define GL_UNSIGNED_SHORT 0x1403 +#define GL_INT 0x1404 +#define GL_UNSIGNED_INT 0x1405 +#define GL_FLOAT 0x1406 +#define GL_2_BYTES 0x1407 +#define GL_3_BYTES 0x1408 +#define GL_4_BYTES 0x1409 +#define GL_DOUBLE 0x140A + +/* Primitives */ +#define GL_POINTS 0x0000 +#define GL_LINES 0x0001 +#define GL_LINE_LOOP 0x0002 +#define GL_LINE_STRIP 0x0003 +#define GL_TRIANGLES 0x0004 +#define GL_TRIANGLE_STRIP 0x0005 +#define GL_TRIANGLE_FAN 0x0006 +#define GL_QUADS 0x0007 +#define GL_QUAD_STRIP 0x0008 +#define GL_POLYGON 0x0009 + +/* Vertex Arrays */ +#define GL_VERTEX_ARRAY 0x8074 +#define GL_NORMAL_ARRAY 0x8075 +#define GL_COLOR_ARRAY 0x8076 +#define GL_INDEX_ARRAY 0x8077 +#define GL_TEXTURE_COORD_ARRAY 0x8078 +#define GL_EDGE_FLAG_ARRAY 0x8079 +#define GL_VERTEX_ARRAY_SIZE 0x807A +#define GL_VERTEX_ARRAY_TYPE 0x807B +#define GL_VERTEX_ARRAY_STRIDE 0x807C +#define GL_NORMAL_ARRAY_TYPE 0x807E +#define GL_NORMAL_ARRAY_STRIDE 0x807F +#define GL_COLOR_ARRAY_SIZE 0x8081 +#define GL_COLOR_ARRAY_TYPE 0x8082 +#define GL_COLOR_ARRAY_STRIDE 0x8083 +#define GL_INDEX_ARRAY_TYPE 0x8085 +#define GL_INDEX_ARRAY_STRIDE 0x8086 +#define GL_TEXTURE_COORD_ARRAY_SIZE 0x8088 +#define GL_TEXTURE_COORD_ARRAY_TYPE 0x8089 +#define GL_TEXTURE_COORD_ARRAY_STRIDE 0x808A +#define GL_EDGE_FLAG_ARRAY_STRIDE 0x808C +#define GL_VERTEX_ARRAY_POINTER 0x808E +#define GL_NORMAL_ARRAY_POINTER 0x808F +#define GL_COLOR_ARRAY_POINTER 0x8090 +#define GL_INDEX_ARRAY_POINTER 0x8091 +#define GL_TEXTURE_COORD_ARRAY_POINTER 0x8092 +#define GL_EDGE_FLAG_ARRAY_POINTER 0x8093 +#define GL_V2F 0x2A20 +#define GL_V3F 0x2A21 +#define GL_C4UB_V2F 0x2A22 +#define GL_C4UB_V3F 0x2A23 +#define GL_C3F_V3F 0x2A24 +#define GL_N3F_V3F 0x2A25 +#define GL_C4F_N3F_V3F 0x2A26 +#define GL_T2F_V3F 0x2A27 +#define GL_T4F_V4F 0x2A28 +#define GL_T2F_C4UB_V3F 0x2A29 +#define GL_T2F_C3F_V3F 0x2A2A +#define GL_T2F_N3F_V3F 0x2A2B +#define GL_T2F_C4F_N3F_V3F 0x2A2C +#define GL_T4F_C4F_N3F_V4F 0x2A2D + +/* Matrix Mode */ +#define GL_MATRIX_MODE 0x0BA0 +#define GL_MODELVIEW 0x1700 +#define GL_PROJECTION 0x1701 +#define GL_TEXTURE 0x1702 + +/* Points */ +#define GL_POINT_SMOOTH 0x0B10 +#define GL_POINT_SIZE 0x0B11 +#define GL_POINT_SIZE_GRANULARITY 0x0B13 +#define GL_POINT_SIZE_RANGE 0x0B12 + +/* Lines */ +#define GL_LINE_SMOOTH 0x0B20 +#define GL_LINE_STIPPLE 0x0B24 +#define GL_LINE_STIPPLE_PATTERN 0x0B25 +#define GL_LINE_STIPPLE_REPEAT 0x0B26 +#define GL_LINE_WIDTH 0x0B21 +#define GL_LINE_WIDTH_GRANULARITY 0x0B23 +#define GL_LINE_WIDTH_RANGE 0x0B22 + +/* Polygons */ +#define GL_POINT 0x1B00 +#define GL_LINE 0x1B01 +#define GL_FILL 0x1B02 +#define GL_CW 0x0900 +#define GL_CCW 0x0901 +#define GL_FRONT 0x0404 +#define GL_BACK 0x0405 +#define GL_POLYGON_MODE 0x0B40 +#define GL_POLYGON_SMOOTH 0x0B41 +#define GL_POLYGON_STIPPLE 0x0B42 +#define GL_EDGE_FLAG 0x0B43 +#define GL_CULL_FACE 0x0B44 +#define GL_CULL_FACE_MODE 0x0B45 +#define GL_FRONT_FACE 0x0B46 +#define GL_POLYGON_OFFSET_FACTOR 0x8038 +#define GL_POLYGON_OFFSET_UNITS 0x2A00 +#define GL_POLYGON_OFFSET_POINT 0x2A01 +#define GL_POLYGON_OFFSET_LINE 0x2A02 +#define GL_POLYGON_OFFSET_FILL 0x8037 + +/* Display Lists */ +#define GL_COMPILE 0x1300 +#define GL_COMPILE_AND_EXECUTE 0x1301 +#define GL_LIST_BASE 0x0B32 +#define GL_LIST_INDEX 0x0B33 +#define GL_LIST_MODE 0x0B30 + +/* Depth buffer */ +#define GL_NEVER 0x0200 +#define GL_LESS 0x0201 +#define GL_EQUAL 0x0202 +#define GL_LEQUAL 0x0203 +#define GL_GREATER 0x0204 +#define GL_NOTEQUAL 0x0205 +#define GL_GEQUAL 0x0206 +#define GL_ALWAYS 0x0207 +#define GL_DEPTH_TEST 0x0B71 +#define GL_DEPTH_BITS 0x0D56 +#define GL_DEPTH_CLEAR_VALUE 0x0B73 +#define GL_DEPTH_FUNC 0x0B74 +#define GL_DEPTH_RANGE 0x0B70 +#define GL_DEPTH_WRITEMASK 0x0B72 +#define GL_DEPTH_COMPONENT 0x1902 + +/* Lighting */ +#define GL_LIGHTING 0x0B50 +#define GL_LIGHT0 0x4000 +#define GL_LIGHT1 0x4001 +#define GL_LIGHT2 0x4002 +#define GL_LIGHT3 0x4003 +#define GL_LIGHT4 0x4004 +#define GL_LIGHT5 0x4005 +#define GL_LIGHT6 0x4006 +#define GL_LIGHT7 0x4007 +#define GL_SPOT_EXPONENT 0x1205 +#define GL_SPOT_CUTOFF 0x1206 +#define GL_CONSTANT_ATTENUATION 0x1207 +#define GL_LINEAR_ATTENUATION 0x1208 +#define GL_QUADRATIC_ATTENUATION 0x1209 +#define GL_AMBIENT 0x1200 +#define GL_DIFFUSE 0x1201 +#define GL_SPECULAR 0x1202 +#define GL_SHININESS 0x1601 +#define GL_EMISSION 0x1600 +#define GL_POSITION 0x1203 +#define GL_SPOT_DIRECTION 0x1204 +#define GL_AMBIENT_AND_DIFFUSE 0x1602 +#define GL_COLOR_INDEXES 0x1603 +#define GL_LIGHT_MODEL_TWO_SIDE 0x0B52 +#define GL_LIGHT_MODEL_LOCAL_VIEWER 0x0B51 +#define GL_LIGHT_MODEL_AMBIENT 0x0B53 +#define GL_FRONT_AND_BACK 0x0408 +#define GL_SHADE_MODEL 0x0B54 +#define GL_FLAT 0x1D00 +#define GL_SMOOTH 0x1D01 +#define GL_COLOR_MATERIAL 0x0B57 +#define GL_COLOR_MATERIAL_FACE 0x0B55 +#define GL_COLOR_MATERIAL_PARAMETER 0x0B56 +#define GL_NORMALIZE 0x0BA1 + +/* User clipping planes */ +#define GL_CLIP_PLANE0 0x3000 +#define GL_CLIP_PLANE1 0x3001 +#define GL_CLIP_PLANE2 0x3002 +#define GL_CLIP_PLANE3 0x3003 +#define GL_CLIP_PLANE4 0x3004 +#define GL_CLIP_PLANE5 0x3005 + +/* Accumulation buffer */ +#define GL_ACCUM_RED_BITS 0x0D58 +#define GL_ACCUM_GREEN_BITS 0x0D59 +#define GL_ACCUM_BLUE_BITS 0x0D5A +#define GL_ACCUM_ALPHA_BITS 0x0D5B +#define GL_ACCUM_CLEAR_VALUE 0x0B80 +#define GL_ACCUM 0x0100 +#define GL_ADD 0x0104 +#define GL_LOAD 0x0101 +#define GL_MULT 0x0103 +#define GL_RETURN 0x0102 + +/* Alpha testing */ +#define GL_ALPHA_TEST 0x0BC0 +#define GL_ALPHA_TEST_REF 0x0BC2 +#define GL_ALPHA_TEST_FUNC 0x0BC1 + +/* Blending */ +#define GL_BLEND 0x0BE2 +#define GL_BLEND_SRC 0x0BE1 +#define GL_BLEND_DST 0x0BE0 +#define GL_ZERO 0x0 +#define GL_ONE 0x1 +#define GL_SRC_COLOR 0x0300 +#define GL_ONE_MINUS_SRC_COLOR 0x0301 +#define GL_SRC_ALPHA 0x0302 +#define GL_ONE_MINUS_SRC_ALPHA 0x0303 +#define GL_DST_ALPHA 0x0304 +#define GL_ONE_MINUS_DST_ALPHA 0x0305 +#define GL_DST_COLOR 0x0306 +#define GL_ONE_MINUS_DST_COLOR 0x0307 +#define GL_SRC_ALPHA_SATURATE 0x0308 + +/* Render Mode */ +#define GL_FEEDBACK 0x1C01 +#define GL_RENDER 0x1C00 +#define GL_SELECT 0x1C02 + +/* Feedback */ +#define GL_2D 0x0600 +#define GL_3D 0x0601 +#define GL_3D_COLOR 0x0602 +#define GL_3D_COLOR_TEXTURE 0x0603 +#define GL_4D_COLOR_TEXTURE 0x0604 +#define GL_POINT_TOKEN 0x0701 +#define GL_LINE_TOKEN 0x0702 +#define GL_LINE_RESET_TOKEN 0x0707 +#define GL_POLYGON_TOKEN 0x0703 +#define GL_BITMAP_TOKEN 0x0704 +#define GL_DRAW_PIXEL_TOKEN 0x0705 +#define GL_COPY_PIXEL_TOKEN 0x0706 +#define GL_PASS_THROUGH_TOKEN 0x0700 +#define GL_FEEDBACK_BUFFER_POINTER 0x0DF0 +#define GL_FEEDBACK_BUFFER_SIZE 0x0DF1 +#define GL_FEEDBACK_BUFFER_TYPE 0x0DF2 + +/* Selection */ +#define GL_SELECTION_BUFFER_POINTER 0x0DF3 +#define GL_SELECTION_BUFFER_SIZE 0x0DF4 + +/* Fog */ +#define GL_FOG 0x0B60 +#define GL_FOG_MODE 0x0B65 +#define GL_FOG_DENSITY 0x0B62 +#define GL_FOG_COLOR 0x0B66 +#define GL_FOG_INDEX 0x0B61 +#define GL_FOG_START 0x0B63 +#define GL_FOG_END 0x0B64 +#define GL_LINEAR 0x2601 +#define GL_EXP 0x0800 +#define GL_EXP2 0x0801 + +/* Logic Ops */ +#define GL_LOGIC_OP 0x0BF1 +#define GL_INDEX_LOGIC_OP 0x0BF1 +#define GL_COLOR_LOGIC_OP 0x0BF2 +#define GL_LOGIC_OP_MODE 0x0BF0 +#define GL_CLEAR 0x1500 +#define GL_SET 0x150F +#define GL_COPY 0x1503 +#define GL_COPY_INVERTED 0x150C +#define GL_NOOP 0x1505 +#define GL_INVERT 0x150A +#define GL_AND 0x1501 +#define GL_NAND 0x150E +#define GL_OR 0x1507 +#define GL_NOR 0x1508 +#define GL_XOR 0x1506 +#define GL_EQUIV 0x1509 +#define GL_AND_REVERSE 0x1502 +#define GL_AND_INVERTED 0x1504 +#define GL_OR_REVERSE 0x150B +#define GL_OR_INVERTED 0x150D + +/* Stencil */ +#define GL_STENCIL_BITS 0x0D57 +#define GL_STENCIL_TEST 0x0B90 +#define GL_STENCIL_CLEAR_VALUE 0x0B91 +#define GL_STENCIL_FUNC 0x0B92 +#define GL_STENCIL_VALUE_MASK 0x0B93 +#define GL_STENCIL_FAIL 0x0B94 +#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95 +#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96 +#define GL_STENCIL_REF 0x0B97 +#define GL_STENCIL_WRITEMASK 0x0B98 +#define GL_STENCIL_INDEX 0x1901 +#define GL_KEEP 0x1E00 +#define GL_REPLACE 0x1E01 +#define GL_INCR 0x1E02 +#define GL_DECR 0x1E03 + +/* Buffers, Pixel Drawing/Reading */ +#define GL_NONE 0x0 +#define GL_LEFT 0x0406 +#define GL_RIGHT 0x0407 +/*GL_FRONT 0x0404 */ +/*GL_BACK 0x0405 */ +/*GL_FRONT_AND_BACK 0x0408 */ +#define GL_FRONT_LEFT 0x0400 +#define GL_FRONT_RIGHT 0x0401 +#define GL_BACK_LEFT 0x0402 +#define GL_BACK_RIGHT 0x0403 +#define GL_AUX0 0x0409 +#define GL_AUX1 0x040A +#define GL_AUX2 0x040B +#define GL_AUX3 0x040C +#define GL_COLOR_INDEX 0x1900 +#define GL_RED 0x1903 +#define GL_GREEN 0x1904 +#define GL_BLUE 0x1905 +#define GL_ALPHA 0x1906 +#define GL_LUMINANCE 0x1909 +#define GL_LUMINANCE_ALPHA 0x190A +#define GL_ALPHA_BITS 0x0D55 +#define GL_RED_BITS 0x0D52 +#define GL_GREEN_BITS 0x0D53 +#define GL_BLUE_BITS 0x0D54 +#define GL_INDEX_BITS 0x0D51 +#define GL_SUBPIXEL_BITS 0x0D50 +#define GL_AUX_BUFFERS 0x0C00 +#define GL_READ_BUFFER 0x0C02 +#define GL_DRAW_BUFFER 0x0C01 +#define GL_DOUBLEBUFFER 0x0C32 +#define GL_STEREO 0x0C33 +#define GL_BITMAP 0x1A00 +#define GL_COLOR 0x1800 +#define GL_DEPTH 0x1801 +#define GL_STENCIL 0x1802 +#define GL_DITHER 0x0BD0 +#define GL_RGB 0x1907 +#define GL_RGBA 0x1908 + +/* Implementation limits */ +#define GL_MAX_LIST_NESTING 0x0B31 +#define GL_MAX_EVAL_ORDER 0x0D30 +#define GL_MAX_LIGHTS 0x0D31 +#define GL_MAX_CLIP_PLANES 0x0D32 +#define GL_MAX_TEXTURE_SIZE 0x0D33 +#define GL_MAX_PIXEL_MAP_TABLE 0x0D34 +#define GL_MAX_ATTRIB_STACK_DEPTH 0x0D35 +#define GL_MAX_MODELVIEW_STACK_DEPTH 0x0D36 +#define GL_MAX_NAME_STACK_DEPTH 0x0D37 +#define GL_MAX_PROJECTION_STACK_DEPTH 0x0D38 +#define GL_MAX_TEXTURE_STACK_DEPTH 0x0D39 +#define GL_MAX_VIEWPORT_DIMS 0x0D3A +#define GL_MAX_CLIENT_ATTRIB_STACK_DEPTH 0x0D3B + +/* Gets */ +#define GL_ATTRIB_STACK_DEPTH 0x0BB0 +#define GL_CLIENT_ATTRIB_STACK_DEPTH 0x0BB1 +#define GL_COLOR_CLEAR_VALUE 0x0C22 +#define GL_COLOR_WRITEMASK 0x0C23 +#define GL_CURRENT_INDEX 0x0B01 +#define GL_CURRENT_COLOR 0x0B00 +#define GL_CURRENT_NORMAL 0x0B02 +#define GL_CURRENT_RASTER_COLOR 0x0B04 +#define GL_CURRENT_RASTER_DISTANCE 0x0B09 +#define GL_CURRENT_RASTER_INDEX 0x0B05 +#define GL_CURRENT_RASTER_POSITION 0x0B07 +#define GL_CURRENT_RASTER_TEXTURE_COORDS 0x0B06 +#define GL_CURRENT_RASTER_POSITION_VALID 0x0B08 +#define GL_CURRENT_TEXTURE_COORDS 0x0B03 +#define GL_INDEX_CLEAR_VALUE 0x0C20 +#define GL_INDEX_MODE 0x0C30 +#define GL_INDEX_WRITEMASK 0x0C21 +#define GL_MODELVIEW_MATRIX 0x0BA6 +#define GL_MODELVIEW_STACK_DEPTH 0x0BA3 +#define GL_NAME_STACK_DEPTH 0x0D70 +#define GL_PROJECTION_MATRIX 0x0BA7 +#define GL_PROJECTION_STACK_DEPTH 0x0BA4 +#define GL_RENDER_MODE 0x0C40 +#define GL_RGBA_MODE 0x0C31 +#define GL_TEXTURE_MATRIX 0x0BA8 +#define GL_TEXTURE_STACK_DEPTH 0x0BA5 +#define GL_VIEWPORT 0x0BA2 + +/* Evaluators */ +#define GL_AUTO_NORMAL 0x0D80 +#define GL_MAP1_COLOR_4 0x0D90 +#define GL_MAP1_INDEX 0x0D91 +#define GL_MAP1_NORMAL 0x0D92 +#define GL_MAP1_TEXTURE_COORD_1 0x0D93 +#define GL_MAP1_TEXTURE_COORD_2 0x0D94 +#define GL_MAP1_TEXTURE_COORD_3 0x0D95 +#define GL_MAP1_TEXTURE_COORD_4 0x0D96 +#define GL_MAP1_VERTEX_3 0x0D97 +#define GL_MAP1_VERTEX_4 0x0D98 +#define GL_MAP2_COLOR_4 0x0DB0 +#define GL_MAP2_INDEX 0x0DB1 +#define GL_MAP2_NORMAL 0x0DB2 +#define GL_MAP2_TEXTURE_COORD_1 0x0DB3 +#define GL_MAP2_TEXTURE_COORD_2 0x0DB4 +#define GL_MAP2_TEXTURE_COORD_3 0x0DB5 +#define GL_MAP2_TEXTURE_COORD_4 0x0DB6 +#define GL_MAP2_VERTEX_3 0x0DB7 +#define GL_MAP2_VERTEX_4 0x0DB8 +#define GL_MAP1_GRID_DOMAIN 0x0DD0 +#define GL_MAP1_GRID_SEGMENTS 0x0DD1 +#define GL_MAP2_GRID_DOMAIN 0x0DD2 +#define GL_MAP2_GRID_SEGMENTS 0x0DD3 +#define GL_COEFF 0x0A00 +#define GL_ORDER 0x0A01 +#define GL_DOMAIN 0x0A02 + +/* Hints */ +#define GL_PERSPECTIVE_CORRECTION_HINT 0x0C50 +#define GL_POINT_SMOOTH_HINT 0x0C51 +#define GL_LINE_SMOOTH_HINT 0x0C52 +#define GL_POLYGON_SMOOTH_HINT 0x0C53 +#define GL_FOG_HINT 0x0C54 +#define GL_DONT_CARE 0x1100 +#define GL_FASTEST 0x1101 +#define GL_NICEST 0x1102 + +/* Scissor box */ +#define GL_SCISSOR_BOX 0x0C10 +#define GL_SCISSOR_TEST 0x0C11 + +/* Pixel Mode / Transfer */ +#define GL_MAP_COLOR 0x0D10 +#define GL_MAP_STENCIL 0x0D11 +#define GL_INDEX_SHIFT 0x0D12 +#define GL_INDEX_OFFSET 0x0D13 +#define GL_RED_SCALE 0x0D14 +#define GL_RED_BIAS 0x0D15 +#define GL_GREEN_SCALE 0x0D18 +#define GL_GREEN_BIAS 0x0D19 +#define GL_BLUE_SCALE 0x0D1A +#define GL_BLUE_BIAS 0x0D1B +#define GL_ALPHA_SCALE 0x0D1C +#define GL_ALPHA_BIAS 0x0D1D +#define GL_DEPTH_SCALE 0x0D1E +#define GL_DEPTH_BIAS 0x0D1F +#define GL_PIXEL_MAP_S_TO_S_SIZE 0x0CB1 +#define GL_PIXEL_MAP_I_TO_I_SIZE 0x0CB0 +#define GL_PIXEL_MAP_I_TO_R_SIZE 0x0CB2 +#define GL_PIXEL_MAP_I_TO_G_SIZE 0x0CB3 +#define GL_PIXEL_MAP_I_TO_B_SIZE 0x0CB4 +#define GL_PIXEL_MAP_I_TO_A_SIZE 0x0CB5 +#define GL_PIXEL_MAP_R_TO_R_SIZE 0x0CB6 +#define GL_PIXEL_MAP_G_TO_G_SIZE 0x0CB7 +#define GL_PIXEL_MAP_B_TO_B_SIZE 0x0CB8 +#define GL_PIXEL_MAP_A_TO_A_SIZE 0x0CB9 +#define GL_PIXEL_MAP_S_TO_S 0x0C71 +#define GL_PIXEL_MAP_I_TO_I 0x0C70 +#define GL_PIXEL_MAP_I_TO_R 0x0C72 +#define GL_PIXEL_MAP_I_TO_G 0x0C73 +#define GL_PIXEL_MAP_I_TO_B 0x0C74 +#define GL_PIXEL_MAP_I_TO_A 0x0C75 +#define GL_PIXEL_MAP_R_TO_R 0x0C76 +#define GL_PIXEL_MAP_G_TO_G 0x0C77 +#define GL_PIXEL_MAP_B_TO_B 0x0C78 +#define GL_PIXEL_MAP_A_TO_A 0x0C79 +#define GL_PACK_ALIGNMENT 0x0D05 +#define GL_PACK_LSB_FIRST 0x0D01 +#define GL_PACK_ROW_LENGTH 0x0D02 +#define GL_PACK_SKIP_PIXELS 0x0D04 +#define GL_PACK_SKIP_ROWS 0x0D03 +#define GL_PACK_SWAP_BYTES 0x0D00 +#define GL_UNPACK_ALIGNMENT 0x0CF5 +#define GL_UNPACK_LSB_FIRST 0x0CF1 +#define GL_UNPACK_ROW_LENGTH 0x0CF2 +#define GL_UNPACK_SKIP_PIXELS 0x0CF4 +#define GL_UNPACK_SKIP_ROWS 0x0CF3 +#define GL_UNPACK_SWAP_BYTES 0x0CF0 +#define GL_ZOOM_X 0x0D16 +#define GL_ZOOM_Y 0x0D17 + +/* Texture mapping */ +#define GL_TEXTURE_ENV 0x2300 +#define GL_TEXTURE_ENV_MODE 0x2200 +#define GL_TEXTURE_1D 0x0DE0 +#define GL_TEXTURE_2D 0x0DE1 +#define GL_TEXTURE_WRAP_S 0x2802 +#define GL_TEXTURE_WRAP_T 0x2803 +#define GL_TEXTURE_MAG_FILTER 0x2800 +#define GL_TEXTURE_MIN_FILTER 0x2801 +#define GL_TEXTURE_ENV_COLOR 0x2201 +#define GL_TEXTURE_GEN_S 0x0C60 +#define GL_TEXTURE_GEN_T 0x0C61 +#define GL_TEXTURE_GEN_R 0x0C62 +#define GL_TEXTURE_GEN_Q 0x0C63 +#define GL_TEXTURE_GEN_MODE 0x2500 +#define GL_TEXTURE_BORDER_COLOR 0x1004 +#define GL_TEXTURE_WIDTH 0x1000 +#define GL_TEXTURE_HEIGHT 0x1001 +#define GL_TEXTURE_BORDER 0x1005 +#define GL_TEXTURE_COMPONENTS 0x1003 +#define GL_TEXTURE_RED_SIZE 0x805C +#define GL_TEXTURE_GREEN_SIZE 0x805D +#define GL_TEXTURE_BLUE_SIZE 0x805E +#define GL_TEXTURE_ALPHA_SIZE 0x805F +#define GL_TEXTURE_LUMINANCE_SIZE 0x8060 +#define GL_TEXTURE_INTENSITY_SIZE 0x8061 +#define GL_NEAREST_MIPMAP_NEAREST 0x2700 +#define GL_NEAREST_MIPMAP_LINEAR 0x2702 +#define GL_LINEAR_MIPMAP_NEAREST 0x2701 +#define GL_LINEAR_MIPMAP_LINEAR 0x2703 +#define GL_OBJECT_LINEAR 0x2401 +#define GL_OBJECT_PLANE 0x2501 +#define GL_EYE_LINEAR 0x2400 +#define GL_EYE_PLANE 0x2502 +#define GL_SPHERE_MAP 0x2402 +#define GL_DECAL 0x2101 +#define GL_MODULATE 0x2100 +#define GL_NEAREST 0x2600 +#define GL_REPEAT 0x2901 +#define GL_CLAMP 0x2900 +#define GL_S 0x2000 +#define GL_T 0x2001 +#define GL_R 0x2002 +#define GL_Q 0x2003 + +/* Utility */ +#define GL_VENDOR 0x1F00 +#define GL_RENDERER 0x1F01 +#define GL_VERSION 0x1F02 +#define GL_EXTENSIONS 0x1F03 + +/* Errors */ +#define GL_NO_ERROR 0x0 +#define GL_INVALID_ENUM 0x0500 +#define GL_INVALID_VALUE 0x0501 +#define GL_INVALID_OPERATION 0x0502 +#define GL_STACK_OVERFLOW 0x0503 +#define GL_STACK_UNDERFLOW 0x0504 +#define GL_OUT_OF_MEMORY 0x0505 + +/* glPush/PopAttrib bits */ +#define GL_CURRENT_BIT 0x00000001 +#define GL_POINT_BIT 0x00000002 +#define GL_LINE_BIT 0x00000004 +#define GL_POLYGON_BIT 0x00000008 +#define GL_POLYGON_STIPPLE_BIT 0x00000010 +#define GL_PIXEL_MODE_BIT 0x00000020 +#define GL_LIGHTING_BIT 0x00000040 +#define GL_FOG_BIT 0x00000080 +#define GL_DEPTH_BUFFER_BIT 0x00000100 +#define GL_ACCUM_BUFFER_BIT 0x00000200 +#define GL_STENCIL_BUFFER_BIT 0x00000400 +#define GL_VIEWPORT_BIT 0x00000800 +#define GL_TRANSFORM_BIT 0x00001000 +#define GL_ENABLE_BIT 0x00002000 +#define GL_COLOR_BUFFER_BIT 0x00004000 +#define GL_HINT_BIT 0x00008000 +#define GL_EVAL_BIT 0x00010000 +#define GL_LIST_BIT 0x00020000 +#define GL_TEXTURE_BIT 0x00040000 +#define GL_SCISSOR_BIT 0x00080000 +#define GL_ALL_ATTRIB_BITS 0x000FFFFF + + +/* OpenGL 1.1 */ +#define GL_PROXY_TEXTURE_1D 0x8063 +#define GL_PROXY_TEXTURE_2D 0x8064 +#define GL_TEXTURE_PRIORITY 0x8066 +#define GL_TEXTURE_RESIDENT 0x8067 +#define GL_TEXTURE_BINDING_1D 0x8068 +#define GL_TEXTURE_BINDING_2D 0x8069 +#define GL_TEXTURE_INTERNAL_FORMAT 0x1003 +#define GL_ALPHA4 0x803B +#define GL_ALPHA8 0x803C +#define GL_ALPHA12 0x803D +#define GL_ALPHA16 0x803E +#define GL_LUMINANCE4 0x803F +#define GL_LUMINANCE8 0x8040 +#define GL_LUMINANCE12 0x8041 +#define GL_LUMINANCE16 0x8042 +#define GL_LUMINANCE4_ALPHA4 0x8043 +#define GL_LUMINANCE6_ALPHA2 0x8044 +#define GL_LUMINANCE8_ALPHA8 0x8045 +#define GL_LUMINANCE12_ALPHA4 0x8046 +#define GL_LUMINANCE12_ALPHA12 0x8047 +#define GL_LUMINANCE16_ALPHA16 0x8048 +#define GL_INTENSITY 0x8049 +#define GL_INTENSITY4 0x804A +#define GL_INTENSITY8 0x804B +#define GL_INTENSITY12 0x804C +#define GL_INTENSITY16 0x804D +#define GL_R3_G3_B2 0x2A10 +#define GL_RGB4 0x804F +#define GL_RGB5 0x8050 +#define GL_RGB8 0x8051 +#define GL_RGB10 0x8052 +#define GL_RGB12 0x8053 +#define GL_RGB16 0x8054 +#define GL_RGBA2 0x8055 +#define GL_RGBA4 0x8056 +#define GL_RGB5_A1 0x8057 +#define GL_RGBA8 0x8058 +#define GL_RGB10_A2 0x8059 +#define GL_RGBA12 0x805A +#define GL_RGBA16 0x805B +#define GL_CLIENT_PIXEL_STORE_BIT 0x00000001 +#define GL_CLIENT_VERTEX_ARRAY_BIT 0x00000002 +#define GL_ALL_CLIENT_ATTRIB_BITS 0xFFFFFFFF +#define GL_CLIENT_ALL_ATTRIB_BITS 0xFFFFFFFF + + + +/* + * Miscellaneous + */ + +GLAPI void GLAPIENTRY glClearIndex( GLfloat c ); + +GLAPI void GLAPIENTRY glClearColor( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha ); + +GLAPI void GLAPIENTRY glClear( GLbitfield mask ); + +GLAPI void GLAPIENTRY glIndexMask( GLuint mask ); + +GLAPI void GLAPIENTRY glColorMask( GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha ); + +GLAPI void GLAPIENTRY glAlphaFunc( GLenum func, GLclampf ref ); + +GLAPI void GLAPIENTRY glBlendFunc( GLenum sfactor, GLenum dfactor ); + +GLAPI void GLAPIENTRY glLogicOp( GLenum opcode ); + +GLAPI void GLAPIENTRY glCullFace( GLenum mode ); + +GLAPI void GLAPIENTRY glFrontFace( GLenum mode ); + +GLAPI void GLAPIENTRY glPointSize( GLfloat size ); + +GLAPI void GLAPIENTRY glLineWidth( GLfloat width ); + +GLAPI void GLAPIENTRY glLineStipple( GLint factor, GLushort pattern ); + +GLAPI void GLAPIENTRY glPolygonMode( GLenum face, GLenum mode ); + +GLAPI void GLAPIENTRY glPolygonOffset( GLfloat factor, GLfloat units ); + +GLAPI void GLAPIENTRY glPolygonStipple( const GLubyte *mask ); + +GLAPI void GLAPIENTRY glGetPolygonStipple( GLubyte *mask ); + +GLAPI void GLAPIENTRY glEdgeFlag( GLboolean flag ); + +GLAPI void GLAPIENTRY glEdgeFlagv( const GLboolean *flag ); + +GLAPI void GLAPIENTRY glScissor( GLint x, GLint y, GLsizei width, GLsizei height); + +GLAPI void GLAPIENTRY glClipPlane( GLenum plane, const GLdouble *equation ); + +GLAPI void GLAPIENTRY glGetClipPlane( GLenum plane, GLdouble *equation ); + +GLAPI void GLAPIENTRY glDrawBuffer( GLenum mode ); + +GLAPI void GLAPIENTRY glReadBuffer( GLenum mode ); + +GLAPI void GLAPIENTRY glEnable( GLenum cap ); + +GLAPI void GLAPIENTRY glDisable( GLenum cap ); + +GLAPI GLboolean GLAPIENTRY glIsEnabled( GLenum cap ); + + +GLAPI void GLAPIENTRY glEnableClientState( GLenum cap ); /* 1.1 */ + +GLAPI void GLAPIENTRY glDisableClientState( GLenum cap ); /* 1.1 */ + + +GLAPI void GLAPIENTRY glGetBooleanv( GLenum pname, GLboolean *params ); + +GLAPI void GLAPIENTRY glGetDoublev( GLenum pname, GLdouble *params ); + +GLAPI void GLAPIENTRY glGetFloatv( GLenum pname, GLfloat *params ); + +GLAPI void GLAPIENTRY glGetIntegerv( GLenum pname, GLint *params ); + + +GLAPI void GLAPIENTRY glPushAttrib( GLbitfield mask ); + +GLAPI void GLAPIENTRY glPopAttrib( void ); + + +GLAPI void GLAPIENTRY glPushClientAttrib( GLbitfield mask ); /* 1.1 */ + +GLAPI void GLAPIENTRY glPopClientAttrib( void ); /* 1.1 */ + + +GLAPI GLint GLAPIENTRY glRenderMode( GLenum mode ); + +GLAPI GLenum GLAPIENTRY glGetError( void ); + +GLAPI const GLubyte * GLAPIENTRY glGetString( GLenum name ); + +GLAPI void GLAPIENTRY glFinish( void ); + +GLAPI void GLAPIENTRY glFlush( void ); + +GLAPI void GLAPIENTRY glHint( GLenum target, GLenum mode ); + + +/* + * Depth Buffer + */ + +GLAPI void GLAPIENTRY glClearDepth( GLclampd depth ); + +GLAPI void GLAPIENTRY glDepthFunc( GLenum func ); + +GLAPI void GLAPIENTRY glDepthMask( GLboolean flag ); + +GLAPI void GLAPIENTRY glDepthRange( GLclampd near_val, GLclampd far_val ); + + +/* + * Accumulation Buffer + */ + +GLAPI void GLAPIENTRY glClearAccum( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha ); + +GLAPI void GLAPIENTRY glAccum( GLenum op, GLfloat value ); + + +/* + * Transformation + */ + +GLAPI void GLAPIENTRY glMatrixMode( GLenum mode ); + +GLAPI void GLAPIENTRY glOrtho( GLdouble left, GLdouble right, + GLdouble bottom, GLdouble top, + GLdouble near_val, GLdouble far_val ); + +GLAPI void GLAPIENTRY glFrustum( GLdouble left, GLdouble right, + GLdouble bottom, GLdouble top, + GLdouble near_val, GLdouble far_val ); + +GLAPI void GLAPIENTRY glViewport( GLint x, GLint y, + GLsizei width, GLsizei height ); + +GLAPI void GLAPIENTRY glPushMatrix( void ); + +GLAPI void GLAPIENTRY glPopMatrix( void ); + +GLAPI void GLAPIENTRY glLoadIdentity( void ); + +GLAPI void GLAPIENTRY glLoadMatrixd( const GLdouble *m ); +GLAPI void GLAPIENTRY glLoadMatrixf( const GLfloat *m ); + +GLAPI void GLAPIENTRY glMultMatrixd( const GLdouble *m ); +GLAPI void GLAPIENTRY glMultMatrixf( const GLfloat *m ); + +GLAPI void GLAPIENTRY glRotated( GLdouble angle, + GLdouble x, GLdouble y, GLdouble z ); +GLAPI void GLAPIENTRY glRotatef( GLfloat angle, + GLfloat x, GLfloat y, GLfloat z ); + +GLAPI void GLAPIENTRY glScaled( GLdouble x, GLdouble y, GLdouble z ); +GLAPI void GLAPIENTRY glScalef( GLfloat x, GLfloat y, GLfloat z ); + +GLAPI void GLAPIENTRY glTranslated( GLdouble x, GLdouble y, GLdouble z ); +GLAPI void GLAPIENTRY glTranslatef( GLfloat x, GLfloat y, GLfloat z ); + + +/* + * Display Lists + */ + +GLAPI GLboolean GLAPIENTRY glIsList( GLuint list ); + +GLAPI void GLAPIENTRY glDeleteLists( GLuint list, GLsizei range ); + +GLAPI GLuint GLAPIENTRY glGenLists( GLsizei range ); + +GLAPI void GLAPIENTRY glNewList( GLuint list, GLenum mode ); + +GLAPI void GLAPIENTRY glEndList( void ); + +GLAPI void GLAPIENTRY glCallList( GLuint list ); + +GLAPI void GLAPIENTRY glCallLists( GLsizei n, GLenum type, + const GLvoid *lists ); + +GLAPI void GLAPIENTRY glListBase( GLuint base ); + + +/* + * Drawing Functions + */ + +GLAPI void GLAPIENTRY glBegin( GLenum mode ); + +GLAPI void GLAPIENTRY glEnd( void ); + + +GLAPI void GLAPIENTRY glVertex2d( GLdouble x, GLdouble y ); +GLAPI void GLAPIENTRY glVertex2f( GLfloat x, GLfloat y ); +GLAPI void GLAPIENTRY glVertex2i( GLint x, GLint y ); +GLAPI void GLAPIENTRY glVertex2s( GLshort x, GLshort y ); + +GLAPI void GLAPIENTRY glVertex3d( GLdouble x, GLdouble y, GLdouble z ); +GLAPI void GLAPIENTRY glVertex3f( GLfloat x, GLfloat y, GLfloat z ); +GLAPI void GLAPIENTRY glVertex3i( GLint x, GLint y, GLint z ); +GLAPI void GLAPIENTRY glVertex3s( GLshort x, GLshort y, GLshort z ); + +GLAPI void GLAPIENTRY glVertex4d( GLdouble x, GLdouble y, GLdouble z, GLdouble w ); +GLAPI void GLAPIENTRY glVertex4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w ); +GLAPI void GLAPIENTRY glVertex4i( GLint x, GLint y, GLint z, GLint w ); +GLAPI void GLAPIENTRY glVertex4s( GLshort x, GLshort y, GLshort z, GLshort w ); + +GLAPI void GLAPIENTRY glVertex2dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glVertex2fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glVertex2iv( const GLint *v ); +GLAPI void GLAPIENTRY glVertex2sv( const GLshort *v ); + +GLAPI void GLAPIENTRY glVertex3dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glVertex3fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glVertex3iv( const GLint *v ); +GLAPI void GLAPIENTRY glVertex3sv( const GLshort *v ); + +GLAPI void GLAPIENTRY glVertex4dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glVertex4fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glVertex4iv( const GLint *v ); +GLAPI void GLAPIENTRY glVertex4sv( const GLshort *v ); + + +GLAPI void GLAPIENTRY glNormal3b( GLbyte nx, GLbyte ny, GLbyte nz ); +GLAPI void GLAPIENTRY glNormal3d( GLdouble nx, GLdouble ny, GLdouble nz ); +GLAPI void GLAPIENTRY glNormal3f( GLfloat nx, GLfloat ny, GLfloat nz ); +GLAPI void GLAPIENTRY glNormal3i( GLint nx, GLint ny, GLint nz ); +GLAPI void GLAPIENTRY glNormal3s( GLshort nx, GLshort ny, GLshort nz ); + +GLAPI void GLAPIENTRY glNormal3bv( const GLbyte *v ); +GLAPI void GLAPIENTRY glNormal3dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glNormal3fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glNormal3iv( const GLint *v ); +GLAPI void GLAPIENTRY glNormal3sv( const GLshort *v ); + + +GLAPI void GLAPIENTRY glIndexd( GLdouble c ); +GLAPI void GLAPIENTRY glIndexf( GLfloat c ); +GLAPI void GLAPIENTRY glIndexi( GLint c ); +GLAPI void GLAPIENTRY glIndexs( GLshort c ); +GLAPI void GLAPIENTRY glIndexub( GLubyte c ); /* 1.1 */ + +GLAPI void GLAPIENTRY glIndexdv( const GLdouble *c ); +GLAPI void GLAPIENTRY glIndexfv( const GLfloat *c ); +GLAPI void GLAPIENTRY glIndexiv( const GLint *c ); +GLAPI void GLAPIENTRY glIndexsv( const GLshort *c ); +GLAPI void GLAPIENTRY glIndexubv( const GLubyte *c ); /* 1.1 */ + +GLAPI void GLAPIENTRY glColor3b( GLbyte red, GLbyte green, GLbyte blue ); +GLAPI void GLAPIENTRY glColor3d( GLdouble red, GLdouble green, GLdouble blue ); +GLAPI void GLAPIENTRY glColor3f( GLfloat red, GLfloat green, GLfloat blue ); +GLAPI void GLAPIENTRY glColor3i( GLint red, GLint green, GLint blue ); +GLAPI void GLAPIENTRY glColor3s( GLshort red, GLshort green, GLshort blue ); +GLAPI void GLAPIENTRY glColor3ub( GLubyte red, GLubyte green, GLubyte blue ); +GLAPI void GLAPIENTRY glColor3ui( GLuint red, GLuint green, GLuint blue ); +GLAPI void GLAPIENTRY glColor3us( GLushort red, GLushort green, GLushort blue ); + +GLAPI void GLAPIENTRY glColor4b( GLbyte red, GLbyte green, + GLbyte blue, GLbyte alpha ); +GLAPI void GLAPIENTRY glColor4d( GLdouble red, GLdouble green, + GLdouble blue, GLdouble alpha ); +GLAPI void GLAPIENTRY glColor4f( GLfloat red, GLfloat green, + GLfloat blue, GLfloat alpha ); +GLAPI void GLAPIENTRY glColor4i( GLint red, GLint green, + GLint blue, GLint alpha ); +GLAPI void GLAPIENTRY glColor4s( GLshort red, GLshort green, + GLshort blue, GLshort alpha ); +GLAPI void GLAPIENTRY glColor4ub( GLubyte red, GLubyte green, + GLubyte blue, GLubyte alpha ); +GLAPI void GLAPIENTRY glColor4ui( GLuint red, GLuint green, + GLuint blue, GLuint alpha ); +GLAPI void GLAPIENTRY glColor4us( GLushort red, GLushort green, + GLushort blue, GLushort alpha ); + + +GLAPI void GLAPIENTRY glColor3bv( const GLbyte *v ); +GLAPI void GLAPIENTRY glColor3dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glColor3fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glColor3iv( const GLint *v ); +GLAPI void GLAPIENTRY glColor3sv( const GLshort *v ); +GLAPI void GLAPIENTRY glColor3ubv( const GLubyte *v ); +GLAPI void GLAPIENTRY glColor3uiv( const GLuint *v ); +GLAPI void GLAPIENTRY glColor3usv( const GLushort *v ); + +GLAPI void GLAPIENTRY glColor4bv( const GLbyte *v ); +GLAPI void GLAPIENTRY glColor4dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glColor4fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glColor4iv( const GLint *v ); +GLAPI void GLAPIENTRY glColor4sv( const GLshort *v ); +GLAPI void GLAPIENTRY glColor4ubv( const GLubyte *v ); +GLAPI void GLAPIENTRY glColor4uiv( const GLuint *v ); +GLAPI void GLAPIENTRY glColor4usv( const GLushort *v ); + + +GLAPI void GLAPIENTRY glTexCoord1d( GLdouble s ); +GLAPI void GLAPIENTRY glTexCoord1f( GLfloat s ); +GLAPI void GLAPIENTRY glTexCoord1i( GLint s ); +GLAPI void GLAPIENTRY glTexCoord1s( GLshort s ); + +GLAPI void GLAPIENTRY glTexCoord2d( GLdouble s, GLdouble t ); +GLAPI void GLAPIENTRY glTexCoord2f( GLfloat s, GLfloat t ); +GLAPI void GLAPIENTRY glTexCoord2i( GLint s, GLint t ); +GLAPI void GLAPIENTRY glTexCoord2s( GLshort s, GLshort t ); + +GLAPI void GLAPIENTRY glTexCoord3d( GLdouble s, GLdouble t, GLdouble r ); +GLAPI void GLAPIENTRY glTexCoord3f( GLfloat s, GLfloat t, GLfloat r ); +GLAPI void GLAPIENTRY glTexCoord3i( GLint s, GLint t, GLint r ); +GLAPI void GLAPIENTRY glTexCoord3s( GLshort s, GLshort t, GLshort r ); + +GLAPI void GLAPIENTRY glTexCoord4d( GLdouble s, GLdouble t, GLdouble r, GLdouble q ); +GLAPI void GLAPIENTRY glTexCoord4f( GLfloat s, GLfloat t, GLfloat r, GLfloat q ); +GLAPI void GLAPIENTRY glTexCoord4i( GLint s, GLint t, GLint r, GLint q ); +GLAPI void GLAPIENTRY glTexCoord4s( GLshort s, GLshort t, GLshort r, GLshort q ); + +GLAPI void GLAPIENTRY glTexCoord1dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glTexCoord1fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glTexCoord1iv( const GLint *v ); +GLAPI void GLAPIENTRY glTexCoord1sv( const GLshort *v ); + +GLAPI void GLAPIENTRY glTexCoord2dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glTexCoord2fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glTexCoord2iv( const GLint *v ); +GLAPI void GLAPIENTRY glTexCoord2sv( const GLshort *v ); + +GLAPI void GLAPIENTRY glTexCoord3dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glTexCoord3fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glTexCoord3iv( const GLint *v ); +GLAPI void GLAPIENTRY glTexCoord3sv( const GLshort *v ); + +GLAPI void GLAPIENTRY glTexCoord4dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glTexCoord4fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glTexCoord4iv( const GLint *v ); +GLAPI void GLAPIENTRY glTexCoord4sv( const GLshort *v ); + + +GLAPI void GLAPIENTRY glRasterPos2d( GLdouble x, GLdouble y ); +GLAPI void GLAPIENTRY glRasterPos2f( GLfloat x, GLfloat y ); +GLAPI void GLAPIENTRY glRasterPos2i( GLint x, GLint y ); +GLAPI void GLAPIENTRY glRasterPos2s( GLshort x, GLshort y ); + +GLAPI void GLAPIENTRY glRasterPos3d( GLdouble x, GLdouble y, GLdouble z ); +GLAPI void GLAPIENTRY glRasterPos3f( GLfloat x, GLfloat y, GLfloat z ); +GLAPI void GLAPIENTRY glRasterPos3i( GLint x, GLint y, GLint z ); +GLAPI void GLAPIENTRY glRasterPos3s( GLshort x, GLshort y, GLshort z ); + +GLAPI void GLAPIENTRY glRasterPos4d( GLdouble x, GLdouble y, GLdouble z, GLdouble w ); +GLAPI void GLAPIENTRY glRasterPos4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w ); +GLAPI void GLAPIENTRY glRasterPos4i( GLint x, GLint y, GLint z, GLint w ); +GLAPI void GLAPIENTRY glRasterPos4s( GLshort x, GLshort y, GLshort z, GLshort w ); + +GLAPI void GLAPIENTRY glRasterPos2dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glRasterPos2fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glRasterPos2iv( const GLint *v ); +GLAPI void GLAPIENTRY glRasterPos2sv( const GLshort *v ); + +GLAPI void GLAPIENTRY glRasterPos3dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glRasterPos3fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glRasterPos3iv( const GLint *v ); +GLAPI void GLAPIENTRY glRasterPos3sv( const GLshort *v ); + +GLAPI void GLAPIENTRY glRasterPos4dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glRasterPos4fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glRasterPos4iv( const GLint *v ); +GLAPI void GLAPIENTRY glRasterPos4sv( const GLshort *v ); + + +GLAPI void GLAPIENTRY glRectd( GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2 ); +GLAPI void GLAPIENTRY glRectf( GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 ); +GLAPI void GLAPIENTRY glRecti( GLint x1, GLint y1, GLint x2, GLint y2 ); +GLAPI void GLAPIENTRY glRects( GLshort x1, GLshort y1, GLshort x2, GLshort y2 ); + + +GLAPI void GLAPIENTRY glRectdv( const GLdouble *v1, const GLdouble *v2 ); +GLAPI void GLAPIENTRY glRectfv( const GLfloat *v1, const GLfloat *v2 ); +GLAPI void GLAPIENTRY glRectiv( const GLint *v1, const GLint *v2 ); +GLAPI void GLAPIENTRY glRectsv( const GLshort *v1, const GLshort *v2 ); + + +/* + * Vertex Arrays (1.1) + */ + +GLAPI void GLAPIENTRY glVertexPointer( GLint size, GLenum type, + GLsizei stride, const GLvoid *ptr ); + +GLAPI void GLAPIENTRY glNormalPointer( GLenum type, GLsizei stride, + const GLvoid *ptr ); + +GLAPI void GLAPIENTRY glColorPointer( GLint size, GLenum type, + GLsizei stride, const GLvoid *ptr ); + +GLAPI void GLAPIENTRY glIndexPointer( GLenum type, GLsizei stride, + const GLvoid *ptr ); + +GLAPI void GLAPIENTRY glTexCoordPointer( GLint size, GLenum type, + GLsizei stride, const GLvoid *ptr ); + +GLAPI void GLAPIENTRY glEdgeFlagPointer( GLsizei stride, const GLvoid *ptr ); + +GLAPI void GLAPIENTRY glGetPointerv( GLenum pname, GLvoid **params ); + +GLAPI void GLAPIENTRY glArrayElement( GLint i ); + +GLAPI void GLAPIENTRY glDrawArrays( GLenum mode, GLint first, GLsizei count ); + +GLAPI void GLAPIENTRY glDrawElements( GLenum mode, GLsizei count, + GLenum type, const GLvoid *indices ); + +GLAPI void GLAPIENTRY glInterleavedArrays( GLenum format, GLsizei stride, + const GLvoid *pointer ); + +/* + * Lighting + */ + +GLAPI void GLAPIENTRY glShadeModel( GLenum mode ); + +GLAPI void GLAPIENTRY glLightf( GLenum light, GLenum pname, GLfloat param ); +GLAPI void GLAPIENTRY glLighti( GLenum light, GLenum pname, GLint param ); +GLAPI void GLAPIENTRY glLightfv( GLenum light, GLenum pname, + const GLfloat *params ); +GLAPI void GLAPIENTRY glLightiv( GLenum light, GLenum pname, + const GLint *params ); + +GLAPI void GLAPIENTRY glGetLightfv( GLenum light, GLenum pname, + GLfloat *params ); +GLAPI void GLAPIENTRY glGetLightiv( GLenum light, GLenum pname, + GLint *params ); + +GLAPI void GLAPIENTRY glLightModelf( GLenum pname, GLfloat param ); +GLAPI void GLAPIENTRY glLightModeli( GLenum pname, GLint param ); +GLAPI void GLAPIENTRY glLightModelfv( GLenum pname, const GLfloat *params ); +GLAPI void GLAPIENTRY glLightModeliv( GLenum pname, const GLint *params ); + +GLAPI void GLAPIENTRY glMaterialf( GLenum face, GLenum pname, GLfloat param ); +GLAPI void GLAPIENTRY glMateriali( GLenum face, GLenum pname, GLint param ); +GLAPI void GLAPIENTRY glMaterialfv( GLenum face, GLenum pname, const GLfloat *params ); +GLAPI void GLAPIENTRY glMaterialiv( GLenum face, GLenum pname, const GLint *params ); + +GLAPI void GLAPIENTRY glGetMaterialfv( GLenum face, GLenum pname, GLfloat *params ); +GLAPI void GLAPIENTRY glGetMaterialiv( GLenum face, GLenum pname, GLint *params ); + +GLAPI void GLAPIENTRY glColorMaterial( GLenum face, GLenum mode ); + + +/* + * Raster functions + */ + +GLAPI void GLAPIENTRY glPixelZoom( GLfloat xfactor, GLfloat yfactor ); + +GLAPI void GLAPIENTRY glPixelStoref( GLenum pname, GLfloat param ); +GLAPI void GLAPIENTRY glPixelStorei( GLenum pname, GLint param ); + +GLAPI void GLAPIENTRY glPixelTransferf( GLenum pname, GLfloat param ); +GLAPI void GLAPIENTRY glPixelTransferi( GLenum pname, GLint param ); + +GLAPI void GLAPIENTRY glPixelMapfv( GLenum map, GLsizei mapsize, + const GLfloat *values ); +GLAPI void GLAPIENTRY glPixelMapuiv( GLenum map, GLsizei mapsize, + const GLuint *values ); +GLAPI void GLAPIENTRY glPixelMapusv( GLenum map, GLsizei mapsize, + const GLushort *values ); + +GLAPI void GLAPIENTRY glGetPixelMapfv( GLenum map, GLfloat *values ); +GLAPI void GLAPIENTRY glGetPixelMapuiv( GLenum map, GLuint *values ); +GLAPI void GLAPIENTRY glGetPixelMapusv( GLenum map, GLushort *values ); + +GLAPI void GLAPIENTRY glBitmap( GLsizei width, GLsizei height, + GLfloat xorig, GLfloat yorig, + GLfloat xmove, GLfloat ymove, + const GLubyte *bitmap ); + +GLAPI void GLAPIENTRY glReadPixels( GLint x, GLint y, + GLsizei width, GLsizei height, + GLenum format, GLenum type, + GLvoid *pixels ); + +GLAPI void GLAPIENTRY glDrawPixels( GLsizei width, GLsizei height, + GLenum format, GLenum type, + const GLvoid *pixels ); + +GLAPI void GLAPIENTRY glCopyPixels( GLint x, GLint y, + GLsizei width, GLsizei height, + GLenum type ); + +/* + * Stenciling + */ + +GLAPI void GLAPIENTRY glStencilFunc( GLenum func, GLint ref, GLuint mask ); + +GLAPI void GLAPIENTRY glStencilMask( GLuint mask ); + +GLAPI void GLAPIENTRY glStencilOp( GLenum fail, GLenum zfail, GLenum zpass ); + +GLAPI void GLAPIENTRY glClearStencil( GLint s ); + + + +/* + * Texture mapping + */ + +GLAPI void GLAPIENTRY glTexGend( GLenum coord, GLenum pname, GLdouble param ); +GLAPI void GLAPIENTRY glTexGenf( GLenum coord, GLenum pname, GLfloat param ); +GLAPI void GLAPIENTRY glTexGeni( GLenum coord, GLenum pname, GLint param ); + +GLAPI void GLAPIENTRY glTexGendv( GLenum coord, GLenum pname, const GLdouble *params ); +GLAPI void GLAPIENTRY glTexGenfv( GLenum coord, GLenum pname, const GLfloat *params ); +GLAPI void GLAPIENTRY glTexGeniv( GLenum coord, GLenum pname, const GLint *params ); + +GLAPI void GLAPIENTRY glGetTexGendv( GLenum coord, GLenum pname, GLdouble *params ); +GLAPI void GLAPIENTRY glGetTexGenfv( GLenum coord, GLenum pname, GLfloat *params ); +GLAPI void GLAPIENTRY glGetTexGeniv( GLenum coord, GLenum pname, GLint *params ); + + +GLAPI void GLAPIENTRY glTexEnvf( GLenum target, GLenum pname, GLfloat param ); +GLAPI void GLAPIENTRY glTexEnvi( GLenum target, GLenum pname, GLint param ); + +GLAPI void GLAPIENTRY glTexEnvfv( GLenum target, GLenum pname, const GLfloat *params ); +GLAPI void GLAPIENTRY glTexEnviv( GLenum target, GLenum pname, const GLint *params ); + +GLAPI void GLAPIENTRY glGetTexEnvfv( GLenum target, GLenum pname, GLfloat *params ); +GLAPI void GLAPIENTRY glGetTexEnviv( GLenum target, GLenum pname, GLint *params ); + + +GLAPI void GLAPIENTRY glTexParameterf( GLenum target, GLenum pname, GLfloat param ); +GLAPI void GLAPIENTRY glTexParameteri( GLenum target, GLenum pname, GLint param ); + +GLAPI void GLAPIENTRY glTexParameterfv( GLenum target, GLenum pname, + const GLfloat *params ); +GLAPI void GLAPIENTRY glTexParameteriv( GLenum target, GLenum pname, + const GLint *params ); + +GLAPI void GLAPIENTRY glGetTexParameterfv( GLenum target, + GLenum pname, GLfloat *params); +GLAPI void GLAPIENTRY glGetTexParameteriv( GLenum target, + GLenum pname, GLint *params ); + +GLAPI void GLAPIENTRY glGetTexLevelParameterfv( GLenum target, GLint level, + GLenum pname, GLfloat *params ); +GLAPI void GLAPIENTRY glGetTexLevelParameteriv( GLenum target, GLint level, + GLenum pname, GLint *params ); + + +GLAPI void GLAPIENTRY glTexImage1D( GLenum target, GLint level, + GLint internalFormat, + GLsizei width, GLint border, + GLenum format, GLenum type, + const GLvoid *pixels ); + +GLAPI void GLAPIENTRY glTexImage2D( GLenum target, GLint level, + GLint internalFormat, + GLsizei width, GLsizei height, + GLint border, GLenum format, GLenum type, + const GLvoid *pixels ); + +GLAPI void GLAPIENTRY glGetTexImage( GLenum target, GLint level, + GLenum format, GLenum type, + GLvoid *pixels ); + + +/* 1.1 functions */ + +GLAPI void GLAPIENTRY glGenTextures( GLsizei n, GLuint *textures ); + +GLAPI void GLAPIENTRY glDeleteTextures( GLsizei n, const GLuint *textures); + +GLAPI void GLAPIENTRY glBindTexture( GLenum target, GLuint texture ); + +GLAPI void GLAPIENTRY glPrioritizeTextures( GLsizei n, + const GLuint *textures, + const GLclampf *priorities ); + +GLAPI GLboolean GLAPIENTRY glAreTexturesResident( GLsizei n, + const GLuint *textures, + GLboolean *residences ); + +GLAPI GLboolean GLAPIENTRY glIsTexture( GLuint texture ); + + +GLAPI void GLAPIENTRY glTexSubImage1D( GLenum target, GLint level, + GLint xoffset, + GLsizei width, GLenum format, + GLenum type, const GLvoid *pixels ); + + +GLAPI void GLAPIENTRY glTexSubImage2D( GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, + GLenum format, GLenum type, + const GLvoid *pixels ); + + +GLAPI void GLAPIENTRY glCopyTexImage1D( GLenum target, GLint level, + GLenum internalformat, + GLint x, GLint y, + GLsizei width, GLint border ); + + +GLAPI void GLAPIENTRY glCopyTexImage2D( GLenum target, GLint level, + GLenum internalformat, + GLint x, GLint y, + GLsizei width, GLsizei height, + GLint border ); + + +GLAPI void GLAPIENTRY glCopyTexSubImage1D( GLenum target, GLint level, + GLint xoffset, GLint x, GLint y, + GLsizei width ); + + +GLAPI void GLAPIENTRY glCopyTexSubImage2D( GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLint x, GLint y, + GLsizei width, GLsizei height ); + + +/* + * Evaluators + */ + +GLAPI void GLAPIENTRY glMap1d( GLenum target, GLdouble u1, GLdouble u2, + GLint stride, + GLint order, const GLdouble *points ); +GLAPI void GLAPIENTRY glMap1f( GLenum target, GLfloat u1, GLfloat u2, + GLint stride, + GLint order, const GLfloat *points ); + +GLAPI void GLAPIENTRY glMap2d( GLenum target, + GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, + GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, + const GLdouble *points ); +GLAPI void GLAPIENTRY glMap2f( GLenum target, + GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, + GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, + const GLfloat *points ); + +GLAPI void GLAPIENTRY glGetMapdv( GLenum target, GLenum query, GLdouble *v ); +GLAPI void GLAPIENTRY glGetMapfv( GLenum target, GLenum query, GLfloat *v ); +GLAPI void GLAPIENTRY glGetMapiv( GLenum target, GLenum query, GLint *v ); + +GLAPI void GLAPIENTRY glEvalCoord1d( GLdouble u ); +GLAPI void GLAPIENTRY glEvalCoord1f( GLfloat u ); + +GLAPI void GLAPIENTRY glEvalCoord1dv( const GLdouble *u ); +GLAPI void GLAPIENTRY glEvalCoord1fv( const GLfloat *u ); + +GLAPI void GLAPIENTRY glEvalCoord2d( GLdouble u, GLdouble v ); +GLAPI void GLAPIENTRY glEvalCoord2f( GLfloat u, GLfloat v ); + +GLAPI void GLAPIENTRY glEvalCoord2dv( const GLdouble *u ); +GLAPI void GLAPIENTRY glEvalCoord2fv( const GLfloat *u ); + +GLAPI void GLAPIENTRY glMapGrid1d( GLint un, GLdouble u1, GLdouble u2 ); +GLAPI void GLAPIENTRY glMapGrid1f( GLint un, GLfloat u1, GLfloat u2 ); + +GLAPI void GLAPIENTRY glMapGrid2d( GLint un, GLdouble u1, GLdouble u2, + GLint vn, GLdouble v1, GLdouble v2 ); +GLAPI void GLAPIENTRY glMapGrid2f( GLint un, GLfloat u1, GLfloat u2, + GLint vn, GLfloat v1, GLfloat v2 ); + +GLAPI void GLAPIENTRY glEvalPoint1( GLint i ); + +GLAPI void GLAPIENTRY glEvalPoint2( GLint i, GLint j ); + +GLAPI void GLAPIENTRY glEvalMesh1( GLenum mode, GLint i1, GLint i2 ); + +GLAPI void GLAPIENTRY glEvalMesh2( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 ); + + +/* + * Fog + */ + +GLAPI void GLAPIENTRY glFogf( GLenum pname, GLfloat param ); + +GLAPI void GLAPIENTRY glFogi( GLenum pname, GLint param ); + +GLAPI void GLAPIENTRY glFogfv( GLenum pname, const GLfloat *params ); + +GLAPI void GLAPIENTRY glFogiv( GLenum pname, const GLint *params ); + + +/* + * Selection and Feedback + */ + +GLAPI void GLAPIENTRY glFeedbackBuffer( GLsizei size, GLenum type, GLfloat *buffer ); + +GLAPI void GLAPIENTRY glPassThrough( GLfloat token ); + +GLAPI void GLAPIENTRY glSelectBuffer( GLsizei size, GLuint *buffer ); + +GLAPI void GLAPIENTRY glInitNames( void ); + +GLAPI void GLAPIENTRY glLoadName( GLuint name ); + +GLAPI void GLAPIENTRY glPushName( GLuint name ); + +GLAPI void GLAPIENTRY glPopName( void ); + + + +/* + * OpenGL 1.2 + */ + +#define GL_RESCALE_NORMAL 0x803A +#define GL_CLAMP_TO_EDGE 0x812F +#define GL_MAX_ELEMENTS_VERTICES 0x80E8 +#define GL_MAX_ELEMENTS_INDICES 0x80E9 +#define GL_BGR 0x80E0 +#define GL_BGRA 0x80E1 +#define GL_UNSIGNED_BYTE_3_3_2 0x8032 +#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362 +#define GL_UNSIGNED_SHORT_5_6_5 0x8363 +#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 +#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 +#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 +#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 +#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 +#define GL_UNSIGNED_INT_8_8_8_8 0x8035 +#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 +#define GL_UNSIGNED_INT_10_10_10_2 0x8036 +#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 +#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8 +#define GL_SINGLE_COLOR 0x81F9 +#define GL_SEPARATE_SPECULAR_COLOR 0x81FA +#define GL_TEXTURE_MIN_LOD 0x813A +#define GL_TEXTURE_MAX_LOD 0x813B +#define GL_TEXTURE_BASE_LEVEL 0x813C +#define GL_TEXTURE_MAX_LEVEL 0x813D +#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12 +#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13 +#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 +#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23 +#define GL_ALIASED_POINT_SIZE_RANGE 0x846D +#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E +#define GL_PACK_SKIP_IMAGES 0x806B +#define GL_PACK_IMAGE_HEIGHT 0x806C +#define GL_UNPACK_SKIP_IMAGES 0x806D +#define GL_UNPACK_IMAGE_HEIGHT 0x806E +#define GL_TEXTURE_3D 0x806F +#define GL_PROXY_TEXTURE_3D 0x8070 +#define GL_TEXTURE_DEPTH 0x8071 +#define GL_TEXTURE_WRAP_R 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE 0x8073 +#define GL_TEXTURE_BINDING_3D 0x806A + +GLAPI void GLAPIENTRY glDrawRangeElements( GLenum mode, GLuint start, + GLuint end, GLsizei count, GLenum type, const GLvoid *indices ); + +GLAPI void GLAPIENTRY glTexImage3D( GLenum target, GLint level, + GLint internalFormat, + GLsizei width, GLsizei height, + GLsizei depth, GLint border, + GLenum format, GLenum type, + const GLvoid *pixels ); + +GLAPI void GLAPIENTRY glTexSubImage3D( GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLint zoffset, GLsizei width, + GLsizei height, GLsizei depth, + GLenum format, + GLenum type, const GLvoid *pixels); + +GLAPI void GLAPIENTRY glCopyTexSubImage3D( GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLint zoffset, GLint x, + GLint y, GLsizei width, + GLsizei height ); + +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); +typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); + + +/* + * GL_ARB_imaging + */ + +#define GL_CONSTANT_COLOR 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 +#define GL_CONSTANT_ALPHA 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 +#define GL_COLOR_TABLE 0x80D0 +#define GL_POST_CONVOLUTION_COLOR_TABLE 0x80D1 +#define GL_POST_COLOR_MATRIX_COLOR_TABLE 0x80D2 +#define GL_PROXY_COLOR_TABLE 0x80D3 +#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80D4 +#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80D5 +#define GL_COLOR_TABLE_SCALE 0x80D6 +#define GL_COLOR_TABLE_BIAS 0x80D7 +#define GL_COLOR_TABLE_FORMAT 0x80D8 +#define GL_COLOR_TABLE_WIDTH 0x80D9 +#define GL_COLOR_TABLE_RED_SIZE 0x80DA +#define GL_COLOR_TABLE_GREEN_SIZE 0x80DB +#define GL_COLOR_TABLE_BLUE_SIZE 0x80DC +#define GL_COLOR_TABLE_ALPHA_SIZE 0x80DD +#define GL_COLOR_TABLE_LUMINANCE_SIZE 0x80DE +#define GL_COLOR_TABLE_INTENSITY_SIZE 0x80DF +#define GL_CONVOLUTION_1D 0x8010 +#define GL_CONVOLUTION_2D 0x8011 +#define GL_SEPARABLE_2D 0x8012 +#define GL_CONVOLUTION_BORDER_MODE 0x8013 +#define GL_CONVOLUTION_FILTER_SCALE 0x8014 +#define GL_CONVOLUTION_FILTER_BIAS 0x8015 +#define GL_REDUCE 0x8016 +#define GL_CONVOLUTION_FORMAT 0x8017 +#define GL_CONVOLUTION_WIDTH 0x8018 +#define GL_CONVOLUTION_HEIGHT 0x8019 +#define GL_MAX_CONVOLUTION_WIDTH 0x801A +#define GL_MAX_CONVOLUTION_HEIGHT 0x801B +#define GL_POST_CONVOLUTION_RED_SCALE 0x801C +#define GL_POST_CONVOLUTION_GREEN_SCALE 0x801D +#define GL_POST_CONVOLUTION_BLUE_SCALE 0x801E +#define GL_POST_CONVOLUTION_ALPHA_SCALE 0x801F +#define GL_POST_CONVOLUTION_RED_BIAS 0x8020 +#define GL_POST_CONVOLUTION_GREEN_BIAS 0x8021 +#define GL_POST_CONVOLUTION_BLUE_BIAS 0x8022 +#define GL_POST_CONVOLUTION_ALPHA_BIAS 0x8023 +#define GL_CONSTANT_BORDER 0x8151 +#define GL_REPLICATE_BORDER 0x8153 +#define GL_CONVOLUTION_BORDER_COLOR 0x8154 +#define GL_COLOR_MATRIX 0x80B1 +#define GL_COLOR_MATRIX_STACK_DEPTH 0x80B2 +#define GL_MAX_COLOR_MATRIX_STACK_DEPTH 0x80B3 +#define GL_POST_COLOR_MATRIX_RED_SCALE 0x80B4 +#define GL_POST_COLOR_MATRIX_GREEN_SCALE 0x80B5 +#define GL_POST_COLOR_MATRIX_BLUE_SCALE 0x80B6 +#define GL_POST_COLOR_MATRIX_ALPHA_SCALE 0x80B7 +#define GL_POST_COLOR_MATRIX_RED_BIAS 0x80B8 +#define GL_POST_COLOR_MATRIX_GREEN_BIAS 0x80B9 +#define GL_POST_COLOR_MATRIX_BLUE_BIAS 0x80BA +#define GL_POST_COLOR_MATRIX_ALPHA_BIAS 0x80BB +#define GL_HISTOGRAM 0x8024 +#define GL_PROXY_HISTOGRAM 0x8025 +#define GL_HISTOGRAM_WIDTH 0x8026 +#define GL_HISTOGRAM_FORMAT 0x8027 +#define GL_HISTOGRAM_RED_SIZE 0x8028 +#define GL_HISTOGRAM_GREEN_SIZE 0x8029 +#define GL_HISTOGRAM_BLUE_SIZE 0x802A +#define GL_HISTOGRAM_ALPHA_SIZE 0x802B +#define GL_HISTOGRAM_LUMINANCE_SIZE 0x802C +#define GL_HISTOGRAM_SINK 0x802D +#define GL_MINMAX 0x802E +#define GL_MINMAX_FORMAT 0x802F +#define GL_MINMAX_SINK 0x8030 +#define GL_TABLE_TOO_LARGE 0x8031 +#define GL_BLEND_EQUATION 0x8009 +#define GL_MIN 0x8007 +#define GL_MAX 0x8008 +#define GL_FUNC_ADD 0x8006 +#define GL_FUNC_SUBTRACT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT 0x800B +#define GL_BLEND_COLOR 0x8005 + + +GLAPI void GLAPIENTRY glColorTable( GLenum target, GLenum internalformat, + GLsizei width, GLenum format, + GLenum type, const GLvoid *table ); + +GLAPI void GLAPIENTRY glColorSubTable( GLenum target, + GLsizei start, GLsizei count, + GLenum format, GLenum type, + const GLvoid *data ); + +GLAPI void GLAPIENTRY glColorTableParameteriv(GLenum target, GLenum pname, + const GLint *params); + +GLAPI void GLAPIENTRY glColorTableParameterfv(GLenum target, GLenum pname, + const GLfloat *params); + +GLAPI void GLAPIENTRY glCopyColorSubTable( GLenum target, GLsizei start, + GLint x, GLint y, GLsizei width ); + +GLAPI void GLAPIENTRY glCopyColorTable( GLenum target, GLenum internalformat, + GLint x, GLint y, GLsizei width ); + +GLAPI void GLAPIENTRY glGetColorTable( GLenum target, GLenum format, + GLenum type, GLvoid *table ); + +GLAPI void GLAPIENTRY glGetColorTableParameterfv( GLenum target, GLenum pname, + GLfloat *params ); + +GLAPI void GLAPIENTRY glGetColorTableParameteriv( GLenum target, GLenum pname, + GLint *params ); + +GLAPI void GLAPIENTRY glBlendEquation( GLenum mode ); + +GLAPI void GLAPIENTRY glBlendColor( GLclampf red, GLclampf green, + GLclampf blue, GLclampf alpha ); + +GLAPI void GLAPIENTRY glHistogram( GLenum target, GLsizei width, + GLenum internalformat, GLboolean sink ); + +GLAPI void GLAPIENTRY glResetHistogram( GLenum target ); + +GLAPI void GLAPIENTRY glGetHistogram( GLenum target, GLboolean reset, + GLenum format, GLenum type, + GLvoid *values ); + +GLAPI void GLAPIENTRY glGetHistogramParameterfv( GLenum target, GLenum pname, + GLfloat *params ); + +GLAPI void GLAPIENTRY glGetHistogramParameteriv( GLenum target, GLenum pname, + GLint *params ); + +GLAPI void GLAPIENTRY glMinmax( GLenum target, GLenum internalformat, + GLboolean sink ); + +GLAPI void GLAPIENTRY glResetMinmax( GLenum target ); + +GLAPI void GLAPIENTRY glGetMinmax( GLenum target, GLboolean reset, + GLenum format, GLenum types, + GLvoid *values ); + +GLAPI void GLAPIENTRY glGetMinmaxParameterfv( GLenum target, GLenum pname, + GLfloat *params ); + +GLAPI void GLAPIENTRY glGetMinmaxParameteriv( GLenum target, GLenum pname, + GLint *params ); + +GLAPI void GLAPIENTRY glConvolutionFilter1D( GLenum target, + GLenum internalformat, GLsizei width, GLenum format, GLenum type, + const GLvoid *image ); + +GLAPI void GLAPIENTRY glConvolutionFilter2D( GLenum target, + GLenum internalformat, GLsizei width, GLsizei height, GLenum format, + GLenum type, const GLvoid *image ); + +GLAPI void GLAPIENTRY glConvolutionParameterf( GLenum target, GLenum pname, + GLfloat params ); + +GLAPI void GLAPIENTRY glConvolutionParameterfv( GLenum target, GLenum pname, + const GLfloat *params ); + +GLAPI void GLAPIENTRY glConvolutionParameteri( GLenum target, GLenum pname, + GLint params ); + +GLAPI void GLAPIENTRY glConvolutionParameteriv( GLenum target, GLenum pname, + const GLint *params ); + +GLAPI void GLAPIENTRY glCopyConvolutionFilter1D( GLenum target, + GLenum internalformat, GLint x, GLint y, GLsizei width ); + +GLAPI void GLAPIENTRY glCopyConvolutionFilter2D( GLenum target, + GLenum internalformat, GLint x, GLint y, GLsizei width, + GLsizei height); + +GLAPI void GLAPIENTRY glGetConvolutionFilter( GLenum target, GLenum format, + GLenum type, GLvoid *image ); + +GLAPI void GLAPIENTRY glGetConvolutionParameterfv( GLenum target, GLenum pname, + GLfloat *params ); + +GLAPI void GLAPIENTRY glGetConvolutionParameteriv( GLenum target, GLenum pname, + GLint *params ); + +GLAPI void GLAPIENTRY glSeparableFilter2D( GLenum target, + GLenum internalformat, GLsizei width, GLsizei height, GLenum format, + GLenum type, const GLvoid *row, const GLvoid *column ); + +GLAPI void GLAPIENTRY glGetSeparableFilter( GLenum target, GLenum format, + GLenum type, GLvoid *row, GLvoid *column, GLvoid *span ); + +typedef void (APIENTRYP PFNGLBLENDCOLORPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); +typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode); + + + +/* + * OpenGL 1.3 + */ + +/* multitexture */ +#define GL_TEXTURE0 0x84C0 +#define GL_TEXTURE1 0x84C1 +#define GL_TEXTURE2 0x84C2 +#define GL_TEXTURE3 0x84C3 +#define GL_TEXTURE4 0x84C4 +#define GL_TEXTURE5 0x84C5 +#define GL_TEXTURE6 0x84C6 +#define GL_TEXTURE7 0x84C7 +#define GL_TEXTURE8 0x84C8 +#define GL_TEXTURE9 0x84C9 +#define GL_TEXTURE10 0x84CA +#define GL_TEXTURE11 0x84CB +#define GL_TEXTURE12 0x84CC +#define GL_TEXTURE13 0x84CD +#define GL_TEXTURE14 0x84CE +#define GL_TEXTURE15 0x84CF +#define GL_TEXTURE16 0x84D0 +#define GL_TEXTURE17 0x84D1 +#define GL_TEXTURE18 0x84D2 +#define GL_TEXTURE19 0x84D3 +#define GL_TEXTURE20 0x84D4 +#define GL_TEXTURE21 0x84D5 +#define GL_TEXTURE22 0x84D6 +#define GL_TEXTURE23 0x84D7 +#define GL_TEXTURE24 0x84D8 +#define GL_TEXTURE25 0x84D9 +#define GL_TEXTURE26 0x84DA +#define GL_TEXTURE27 0x84DB +#define GL_TEXTURE28 0x84DC +#define GL_TEXTURE29 0x84DD +#define GL_TEXTURE30 0x84DE +#define GL_TEXTURE31 0x84DF +#define GL_ACTIVE_TEXTURE 0x84E0 +#define GL_CLIENT_ACTIVE_TEXTURE 0x84E1 +#define GL_MAX_TEXTURE_UNITS 0x84E2 +/* texture_cube_map */ +#define GL_NORMAL_MAP 0x8511 +#define GL_REFLECTION_MAP 0x8512 +#define GL_TEXTURE_CUBE_MAP 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C +/* texture_compression */ +#define GL_COMPRESSED_ALPHA 0x84E9 +#define GL_COMPRESSED_LUMINANCE 0x84EA +#define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB +#define GL_COMPRESSED_INTENSITY 0x84EC +#define GL_COMPRESSED_RGB 0x84ED +#define GL_COMPRESSED_RGBA 0x84EE +#define GL_TEXTURE_COMPRESSION_HINT 0x84EF +#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0 +#define GL_TEXTURE_COMPRESSED 0x86A1 +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 +/* multisample */ +#define GL_MULTISAMPLE 0x809D +#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE 0x809F +#define GL_SAMPLE_COVERAGE 0x80A0 +#define GL_SAMPLE_BUFFERS 0x80A8 +#define GL_SAMPLES 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT 0x80AB +#define GL_MULTISAMPLE_BIT 0x20000000 +/* transpose_matrix */ +#define GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3 +#define GL_TRANSPOSE_PROJECTION_MATRIX 0x84E4 +#define GL_TRANSPOSE_TEXTURE_MATRIX 0x84E5 +#define GL_TRANSPOSE_COLOR_MATRIX 0x84E6 +/* texture_env_combine */ +#define GL_COMBINE 0x8570 +#define GL_COMBINE_RGB 0x8571 +#define GL_COMBINE_ALPHA 0x8572 +#define GL_SOURCE0_RGB 0x8580 +#define GL_SOURCE1_RGB 0x8581 +#define GL_SOURCE2_RGB 0x8582 +#define GL_SOURCE0_ALPHA 0x8588 +#define GL_SOURCE1_ALPHA 0x8589 +#define GL_SOURCE2_ALPHA 0x858A +#define GL_OPERAND0_RGB 0x8590 +#define GL_OPERAND1_RGB 0x8591 +#define GL_OPERAND2_RGB 0x8592 +#define GL_OPERAND0_ALPHA 0x8598 +#define GL_OPERAND1_ALPHA 0x8599 +#define GL_OPERAND2_ALPHA 0x859A +#define GL_RGB_SCALE 0x8573 +#define GL_ADD_SIGNED 0x8574 +#define GL_INTERPOLATE 0x8575 +#define GL_SUBTRACT 0x84E7 +#define GL_CONSTANT 0x8576 +#define GL_PRIMARY_COLOR 0x8577 +#define GL_PREVIOUS 0x8578 +/* texture_env_dot3 */ +#define GL_DOT3_RGB 0x86AE +#define GL_DOT3_RGBA 0x86AF +/* texture_border_clamp */ +#define GL_CLAMP_TO_BORDER 0x812D + +GLAPI void GLAPIENTRY glActiveTexture( GLenum texture ); + +GLAPI void GLAPIENTRY glClientActiveTexture( GLenum texture ); + +GLAPI void GLAPIENTRY glCompressedTexImage1D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data ); + +GLAPI void GLAPIENTRY glCompressedTexImage2D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data ); + +GLAPI void GLAPIENTRY glCompressedTexImage3D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data ); + +GLAPI void GLAPIENTRY glCompressedTexSubImage1D( GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data ); + +GLAPI void GLAPIENTRY glCompressedTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data ); + +GLAPI void GLAPIENTRY glCompressedTexSubImage3D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data ); + +GLAPI void GLAPIENTRY glGetCompressedTexImage( GLenum target, GLint lod, GLvoid *img ); + +GLAPI void GLAPIENTRY glMultiTexCoord1d( GLenum target, GLdouble s ); + +GLAPI void GLAPIENTRY glMultiTexCoord1dv( GLenum target, const GLdouble *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord1f( GLenum target, GLfloat s ); + +GLAPI void GLAPIENTRY glMultiTexCoord1fv( GLenum target, const GLfloat *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord1i( GLenum target, GLint s ); + +GLAPI void GLAPIENTRY glMultiTexCoord1iv( GLenum target, const GLint *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord1s( GLenum target, GLshort s ); + +GLAPI void GLAPIENTRY glMultiTexCoord1sv( GLenum target, const GLshort *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord2d( GLenum target, GLdouble s, GLdouble t ); + +GLAPI void GLAPIENTRY glMultiTexCoord2dv( GLenum target, const GLdouble *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord2f( GLenum target, GLfloat s, GLfloat t ); + +GLAPI void GLAPIENTRY glMultiTexCoord2fv( GLenum target, const GLfloat *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord2i( GLenum target, GLint s, GLint t ); + +GLAPI void GLAPIENTRY glMultiTexCoord2iv( GLenum target, const GLint *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord2s( GLenum target, GLshort s, GLshort t ); + +GLAPI void GLAPIENTRY glMultiTexCoord2sv( GLenum target, const GLshort *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord3d( GLenum target, GLdouble s, GLdouble t, GLdouble r ); + +GLAPI void GLAPIENTRY glMultiTexCoord3dv( GLenum target, const GLdouble *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord3f( GLenum target, GLfloat s, GLfloat t, GLfloat r ); + +GLAPI void GLAPIENTRY glMultiTexCoord3fv( GLenum target, const GLfloat *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord3i( GLenum target, GLint s, GLint t, GLint r ); + +GLAPI void GLAPIENTRY glMultiTexCoord3iv( GLenum target, const GLint *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord3s( GLenum target, GLshort s, GLshort t, GLshort r ); + +GLAPI void GLAPIENTRY glMultiTexCoord3sv( GLenum target, const GLshort *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord4d( GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q ); + +GLAPI void GLAPIENTRY glMultiTexCoord4dv( GLenum target, const GLdouble *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord4f( GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q ); + +GLAPI void GLAPIENTRY glMultiTexCoord4fv( GLenum target, const GLfloat *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord4i( GLenum target, GLint s, GLint t, GLint r, GLint q ); + +GLAPI void GLAPIENTRY glMultiTexCoord4iv( GLenum target, const GLint *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord4s( GLenum target, GLshort s, GLshort t, GLshort r, GLshort q ); + +GLAPI void GLAPIENTRY glMultiTexCoord4sv( GLenum target, const GLshort *v ); + + +GLAPI void GLAPIENTRY glLoadTransposeMatrixd( const GLdouble m[16] ); + +GLAPI void GLAPIENTRY glLoadTransposeMatrixf( const GLfloat m[16] ); + +GLAPI void GLAPIENTRY glMultTransposeMatrixd( const GLdouble m[16] ); + +GLAPI void GLAPIENTRY glMultTransposeMatrixf( const GLfloat m[16] ); + +GLAPI void GLAPIENTRY glSampleCoverage( GLclampf value, GLboolean invert ); + + +typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLclampf value, GLboolean invert); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, GLvoid *img); + + + +/* + * GL_ARB_multitexture (ARB extension 1 and OpenGL 1.2.1) + */ +#ifndef GL_ARB_multitexture +#define GL_ARB_multitexture 1 + +#define GL_TEXTURE0_ARB 0x84C0 +#define GL_TEXTURE1_ARB 0x84C1 +#define GL_TEXTURE2_ARB 0x84C2 +#define GL_TEXTURE3_ARB 0x84C3 +#define GL_TEXTURE4_ARB 0x84C4 +#define GL_TEXTURE5_ARB 0x84C5 +#define GL_TEXTURE6_ARB 0x84C6 +#define GL_TEXTURE7_ARB 0x84C7 +#define GL_TEXTURE8_ARB 0x84C8 +#define GL_TEXTURE9_ARB 0x84C9 +#define GL_TEXTURE10_ARB 0x84CA +#define GL_TEXTURE11_ARB 0x84CB +#define GL_TEXTURE12_ARB 0x84CC +#define GL_TEXTURE13_ARB 0x84CD +#define GL_TEXTURE14_ARB 0x84CE +#define GL_TEXTURE15_ARB 0x84CF +#define GL_TEXTURE16_ARB 0x84D0 +#define GL_TEXTURE17_ARB 0x84D1 +#define GL_TEXTURE18_ARB 0x84D2 +#define GL_TEXTURE19_ARB 0x84D3 +#define GL_TEXTURE20_ARB 0x84D4 +#define GL_TEXTURE21_ARB 0x84D5 +#define GL_TEXTURE22_ARB 0x84D6 +#define GL_TEXTURE23_ARB 0x84D7 +#define GL_TEXTURE24_ARB 0x84D8 +#define GL_TEXTURE25_ARB 0x84D9 +#define GL_TEXTURE26_ARB 0x84DA +#define GL_TEXTURE27_ARB 0x84DB +#define GL_TEXTURE28_ARB 0x84DC +#define GL_TEXTURE29_ARB 0x84DD +#define GL_TEXTURE30_ARB 0x84DE +#define GL_TEXTURE31_ARB 0x84DF +#define GL_ACTIVE_TEXTURE_ARB 0x84E0 +#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1 +#define GL_MAX_TEXTURE_UNITS_ARB 0x84E2 + +GLAPI void GLAPIENTRY glActiveTextureARB(GLenum texture); +GLAPI void GLAPIENTRY glClientActiveTextureARB(GLenum texture); +GLAPI void GLAPIENTRY glMultiTexCoord1dARB(GLenum target, GLdouble s); +GLAPI void GLAPIENTRY glMultiTexCoord1dvARB(GLenum target, const GLdouble *v); +GLAPI void GLAPIENTRY glMultiTexCoord1fARB(GLenum target, GLfloat s); +GLAPI void GLAPIENTRY glMultiTexCoord1fvARB(GLenum target, const GLfloat *v); +GLAPI void GLAPIENTRY glMultiTexCoord1iARB(GLenum target, GLint s); +GLAPI void GLAPIENTRY glMultiTexCoord1ivARB(GLenum target, const GLint *v); +GLAPI void GLAPIENTRY glMultiTexCoord1sARB(GLenum target, GLshort s); +GLAPI void GLAPIENTRY glMultiTexCoord1svARB(GLenum target, const GLshort *v); +GLAPI void GLAPIENTRY glMultiTexCoord2dARB(GLenum target, GLdouble s, GLdouble t); +GLAPI void GLAPIENTRY glMultiTexCoord2dvARB(GLenum target, const GLdouble *v); +GLAPI void GLAPIENTRY glMultiTexCoord2fARB(GLenum target, GLfloat s, GLfloat t); +GLAPI void GLAPIENTRY glMultiTexCoord2fvARB(GLenum target, const GLfloat *v); +GLAPI void GLAPIENTRY glMultiTexCoord2iARB(GLenum target, GLint s, GLint t); +GLAPI void GLAPIENTRY glMultiTexCoord2ivARB(GLenum target, const GLint *v); +GLAPI void GLAPIENTRY glMultiTexCoord2sARB(GLenum target, GLshort s, GLshort t); +GLAPI void GLAPIENTRY glMultiTexCoord2svARB(GLenum target, const GLshort *v); +GLAPI void GLAPIENTRY glMultiTexCoord3dARB(GLenum target, GLdouble s, GLdouble t, GLdouble r); +GLAPI void GLAPIENTRY glMultiTexCoord3dvARB(GLenum target, const GLdouble *v); +GLAPI void GLAPIENTRY glMultiTexCoord3fARB(GLenum target, GLfloat s, GLfloat t, GLfloat r); +GLAPI void GLAPIENTRY glMultiTexCoord3fvARB(GLenum target, const GLfloat *v); +GLAPI void GLAPIENTRY glMultiTexCoord3iARB(GLenum target, GLint s, GLint t, GLint r); +GLAPI void GLAPIENTRY glMultiTexCoord3ivARB(GLenum target, const GLint *v); +GLAPI void GLAPIENTRY glMultiTexCoord3sARB(GLenum target, GLshort s, GLshort t, GLshort r); +GLAPI void GLAPIENTRY glMultiTexCoord3svARB(GLenum target, const GLshort *v); +GLAPI void GLAPIENTRY glMultiTexCoord4dARB(GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +GLAPI void GLAPIENTRY glMultiTexCoord4dvARB(GLenum target, const GLdouble *v); +GLAPI void GLAPIENTRY glMultiTexCoord4fARB(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +GLAPI void GLAPIENTRY glMultiTexCoord4fvARB(GLenum target, const GLfloat *v); +GLAPI void GLAPIENTRY glMultiTexCoord4iARB(GLenum target, GLint s, GLint t, GLint r, GLint q); +GLAPI void GLAPIENTRY glMultiTexCoord4ivARB(GLenum target, const GLint *v); +GLAPI void GLAPIENTRY glMultiTexCoord4sARB(GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +GLAPI void GLAPIENTRY glMultiTexCoord4svARB(GLenum target, const GLshort *v); + +typedef void (APIENTRYP PFNGLACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v); + +#endif /* GL_ARB_multitexture */ + + + +/* + * Define this token if you want "old-style" header file behaviour (extensions + * defined in gl.h). Otherwise, extensions will be included from glext.h. + */ +#if defined(GL_GLEXT_LEGACY) + +/* All extensions that used to be here are now found in glext.h */ + +#else /* GL_GLEXT_LEGACY */ + +#include + +#endif /* GL_GLEXT_LEGACY */ + + + +#if GL_ARB_shader_objects + +#ifndef GL_MESA_shader_debug +#define GL_MESA_shader_debug 1 + +#define GL_DEBUG_OBJECT_MESA 0x8759 +#define GL_DEBUG_PRINT_MESA 0x875A +#define GL_DEBUG_ASSERT_MESA 0x875B + +GLAPI GLhandleARB GLAPIENTRY glCreateDebugObjectMESA (void); +GLAPI void GLAPIENTRY glClearDebugLogMESA (GLhandleARB obj, GLenum logType, GLenum shaderType); +GLAPI void GLAPIENTRY glGetDebugLogMESA (GLhandleARB obj, GLenum logType, GLenum shaderType, GLsizei maxLength, + GLsizei *length, GLcharARB *debugLog); +GLAPI GLsizei GLAPIENTRY glGetDebugLogLengthMESA (GLhandleARB obj, GLenum logType, GLenum shaderType); + +#endif /* GL_MESA_shader_debug */ + +#endif /* GL_ARB_shader_objects */ + + +/* + * ???. GL_MESA_packed_depth_stencil + * XXX obsolete + */ +#ifndef GL_MESA_packed_depth_stencil +#define GL_MESA_packed_depth_stencil 1 + +#define GL_DEPTH_STENCIL_MESA 0x8750 +#define GL_UNSIGNED_INT_24_8_MESA 0x8751 +#define GL_UNSIGNED_INT_8_24_REV_MESA 0x8752 +#define GL_UNSIGNED_SHORT_15_1_MESA 0x8753 +#define GL_UNSIGNED_SHORT_1_15_REV_MESA 0x8754 + +#endif /* GL_MESA_packed_depth_stencil */ + + +#ifndef GL_MESA_program_debug +#define GL_MESA_program_debug 1 + +#define GL_FRAGMENT_PROGRAM_POSITION_MESA 0x8bb0 +#define GL_FRAGMENT_PROGRAM_CALLBACK_MESA 0x8bb1 +#define GL_FRAGMENT_PROGRAM_CALLBACK_FUNC_MESA 0x8bb2 +#define GL_FRAGMENT_PROGRAM_CALLBACK_DATA_MESA 0x8bb3 +#define GL_VERTEX_PROGRAM_POSITION_MESA 0x8bb4 +#define GL_VERTEX_PROGRAM_CALLBACK_MESA 0x8bb5 +#define GL_VERTEX_PROGRAM_CALLBACK_FUNC_MESA 0x8bb6 +#define GL_VERTEX_PROGRAM_CALLBACK_DATA_MESA 0x8bb7 + +typedef void (*GLprogramcallbackMESA)(GLenum target, GLvoid *data); + +GLAPI void GLAPIENTRY glProgramCallbackMESA(GLenum target, GLprogramcallbackMESA callback, GLvoid *data); + +GLAPI void GLAPIENTRY glGetProgramRegisterfvMESA(GLenum target, GLsizei len, const GLubyte *name, GLfloat *v); + +#endif /* GL_MESA_program_debug */ + + +#ifndef GL_MESA_texture_array +#define GL_MESA_texture_array 1 + +/* GL_MESA_texture_array uses the same enum values as GL_EXT_texture_array. + */ +#ifndef GL_EXT_texture_array + +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFramebufferTextureLayerEXT(GLenum target, + GLenum attachment, GLuint texture, GLint level, GLint layer); +#endif /* GL_GLEXT_PROTOTYPES */ + +#if 0 +/* (temporarily) disabled because of collision with typedef in glext.h + * that happens if apps include both gl.h and glext.h + */ +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC) (GLenum target, + GLenum attachment, GLuint texture, GLint level, GLint layer); +#endif + +#define GL_TEXTURE_1D_ARRAY_EXT 0x8C18 +#define GL_PROXY_TEXTURE_1D_ARRAY_EXT 0x8C19 +#define GL_TEXTURE_2D_ARRAY_EXT 0x8C1A +#define GL_PROXY_TEXTURE_2D_ARRAY_EXT 0x8C1B +#define GL_TEXTURE_BINDING_1D_ARRAY_EXT 0x8C1C +#define GL_TEXTURE_BINDING_2D_ARRAY_EXT 0x8C1D +#define GL_MAX_ARRAY_TEXTURE_LAYERS_EXT 0x88FF +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT 0x8CD4 +#endif + +#endif + + +#ifndef GL_ATI_blend_equation_separate +#define GL_ATI_blend_equation_separate 1 + +#define GL_ALPHA_BLEND_EQUATION_ATI 0x883D + +GLAPI void GLAPIENTRY glBlendEquationSeparateATI( GLenum modeRGB, GLenum modeA ); +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEATIPROC) (GLenum modeRGB, GLenum modeA); + +#endif /* GL_ATI_blend_equation_separate */ + + +/* GL_OES_EGL_image */ +#ifndef GL_OES_EGL_image +typedef void* GLeglImageOES; +#endif + +#ifndef GL_OES_EGL_image +#define GL_OES_EGL_image 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glEGLImageTargetTexture2DOES (GLenum target, GLeglImageOES image); +GLAPI void APIENTRY glEGLImageTargetRenderbufferStorageOES (GLenum target, GLeglImageOES image); +#endif +typedef void (APIENTRYP PFNGLEGLIMAGETARGETTEXTURE2DOESPROC) (GLenum target, GLeglImageOES image); +typedef void (APIENTRYP PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC) (GLenum target, GLeglImageOES image); +#endif + + +/** + ** NOTE!!!!! If you add new functions to this file, or update + ** glext.h be sure to regenerate the gl_mangle.h file. See comments + ** in that file for details. + **/ + + + +/********************************************************************** + * Begin system-specific stuff + */ +#if defined(PRAGMA_EXPORT_SUPPORTED) +#pragma export off +#endif + +#if defined(macintosh) && PRAGMA_IMPORT_SUPPORTED +#pragma import off +#endif +/* + * End system-specific stuff + **********************************************************************/ + + +#ifdef __cplusplus +} +#endif + +#endif /* __gl_h_ */ diff --git a/3rdparty/glsl-optimizer/include/GL/glext.h b/3rdparty/glsl-optimizer/include/GL/glext.h new file mode 100644 index 000000000..09400215b --- /dev/null +++ b/3rdparty/glsl-optimizer/include/GL/glext.h @@ -0,0 +1,11488 @@ +#ifndef __glext_h_ +#define __glext_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +/* +** Copyright (c) 2007-2011 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +/* Header file version number, required by OpenGL ABI for Linux */ +/* glext.h last updated $Date: 2011-08-08 00:34:29 -0700 (Mon, 08 Aug 2011) $ */ +/* Current version at http://www.opengl.org/registry/ */ +#define GL_GLEXT_VERSION 72 +/* Function declaration macros - to move into glplatform.h */ + +#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) +#define WIN32_LEAN_AND_MEAN 1 +#include +#endif + +#ifndef APIENTRY +#define APIENTRY +#endif +#ifndef APIENTRYP +#define APIENTRYP APIENTRY * +#endif +#ifndef GLAPI +#define GLAPI extern +#endif + +/*************************************************************/ + +#ifndef GL_VERSION_1_2 +#define GL_UNSIGNED_BYTE_3_3_2 0x8032 +#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 +#define GL_UNSIGNED_INT_8_8_8_8 0x8035 +#define GL_UNSIGNED_INT_10_10_10_2 0x8036 +#define GL_TEXTURE_BINDING_3D 0x806A +#define GL_PACK_SKIP_IMAGES 0x806B +#define GL_PACK_IMAGE_HEIGHT 0x806C +#define GL_UNPACK_SKIP_IMAGES 0x806D +#define GL_UNPACK_IMAGE_HEIGHT 0x806E +#define GL_TEXTURE_3D 0x806F +#define GL_PROXY_TEXTURE_3D 0x8070 +#define GL_TEXTURE_DEPTH 0x8071 +#define GL_TEXTURE_WRAP_R 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE 0x8073 +#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362 +#define GL_UNSIGNED_SHORT_5_6_5 0x8363 +#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 +#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 +#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 +#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 +#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 +#define GL_BGR 0x80E0 +#define GL_BGRA 0x80E1 +#define GL_MAX_ELEMENTS_VERTICES 0x80E8 +#define GL_MAX_ELEMENTS_INDICES 0x80E9 +#define GL_CLAMP_TO_EDGE 0x812F +#define GL_TEXTURE_MIN_LOD 0x813A +#define GL_TEXTURE_MAX_LOD 0x813B +#define GL_TEXTURE_BASE_LEVEL 0x813C +#define GL_TEXTURE_MAX_LEVEL 0x813D +#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12 +#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13 +#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 +#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23 +#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E +#endif + +#ifndef GL_VERSION_1_2_DEPRECATED +#define GL_RESCALE_NORMAL 0x803A +#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8 +#define GL_SINGLE_COLOR 0x81F9 +#define GL_SEPARATE_SPECULAR_COLOR 0x81FA +#define GL_ALIASED_POINT_SIZE_RANGE 0x846D +#endif + +#ifndef GL_ARB_imaging +#define GL_CONSTANT_COLOR 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 +#define GL_CONSTANT_ALPHA 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 +#define GL_BLEND_COLOR 0x8005 +#define GL_FUNC_ADD 0x8006 +#define GL_MIN 0x8007 +#define GL_MAX 0x8008 +#define GL_BLEND_EQUATION 0x8009 +#define GL_FUNC_SUBTRACT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT 0x800B +#endif + +#ifndef GL_ARB_imaging_DEPRECATED +#define GL_CONVOLUTION_1D 0x8010 +#define GL_CONVOLUTION_2D 0x8011 +#define GL_SEPARABLE_2D 0x8012 +#define GL_CONVOLUTION_BORDER_MODE 0x8013 +#define GL_CONVOLUTION_FILTER_SCALE 0x8014 +#define GL_CONVOLUTION_FILTER_BIAS 0x8015 +#define GL_REDUCE 0x8016 +#define GL_CONVOLUTION_FORMAT 0x8017 +#define GL_CONVOLUTION_WIDTH 0x8018 +#define GL_CONVOLUTION_HEIGHT 0x8019 +#define GL_MAX_CONVOLUTION_WIDTH 0x801A +#define GL_MAX_CONVOLUTION_HEIGHT 0x801B +#define GL_POST_CONVOLUTION_RED_SCALE 0x801C +#define GL_POST_CONVOLUTION_GREEN_SCALE 0x801D +#define GL_POST_CONVOLUTION_BLUE_SCALE 0x801E +#define GL_POST_CONVOLUTION_ALPHA_SCALE 0x801F +#define GL_POST_CONVOLUTION_RED_BIAS 0x8020 +#define GL_POST_CONVOLUTION_GREEN_BIAS 0x8021 +#define GL_POST_CONVOLUTION_BLUE_BIAS 0x8022 +#define GL_POST_CONVOLUTION_ALPHA_BIAS 0x8023 +#define GL_HISTOGRAM 0x8024 +#define GL_PROXY_HISTOGRAM 0x8025 +#define GL_HISTOGRAM_WIDTH 0x8026 +#define GL_HISTOGRAM_FORMAT 0x8027 +#define GL_HISTOGRAM_RED_SIZE 0x8028 +#define GL_HISTOGRAM_GREEN_SIZE 0x8029 +#define GL_HISTOGRAM_BLUE_SIZE 0x802A +#define GL_HISTOGRAM_ALPHA_SIZE 0x802B +#define GL_HISTOGRAM_LUMINANCE_SIZE 0x802C +#define GL_HISTOGRAM_SINK 0x802D +#define GL_MINMAX 0x802E +#define GL_MINMAX_FORMAT 0x802F +#define GL_MINMAX_SINK 0x8030 +#define GL_TABLE_TOO_LARGE 0x8031 +#define GL_COLOR_MATRIX 0x80B1 +#define GL_COLOR_MATRIX_STACK_DEPTH 0x80B2 +#define GL_MAX_COLOR_MATRIX_STACK_DEPTH 0x80B3 +#define GL_POST_COLOR_MATRIX_RED_SCALE 0x80B4 +#define GL_POST_COLOR_MATRIX_GREEN_SCALE 0x80B5 +#define GL_POST_COLOR_MATRIX_BLUE_SCALE 0x80B6 +#define GL_POST_COLOR_MATRIX_ALPHA_SCALE 0x80B7 +#define GL_POST_COLOR_MATRIX_RED_BIAS 0x80B8 +#define GL_POST_COLOR_MATRIX_GREEN_BIAS 0x80B9 +#define GL_POST_COLOR_MATRIX_BLUE_BIAS 0x80BA +#define GL_POST_COLOR_MATRIX_ALPHA_BIAS 0x80BB +#define GL_COLOR_TABLE 0x80D0 +#define GL_POST_CONVOLUTION_COLOR_TABLE 0x80D1 +#define GL_POST_COLOR_MATRIX_COLOR_TABLE 0x80D2 +#define GL_PROXY_COLOR_TABLE 0x80D3 +#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80D4 +#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80D5 +#define GL_COLOR_TABLE_SCALE 0x80D6 +#define GL_COLOR_TABLE_BIAS 0x80D7 +#define GL_COLOR_TABLE_FORMAT 0x80D8 +#define GL_COLOR_TABLE_WIDTH 0x80D9 +#define GL_COLOR_TABLE_RED_SIZE 0x80DA +#define GL_COLOR_TABLE_GREEN_SIZE 0x80DB +#define GL_COLOR_TABLE_BLUE_SIZE 0x80DC +#define GL_COLOR_TABLE_ALPHA_SIZE 0x80DD +#define GL_COLOR_TABLE_LUMINANCE_SIZE 0x80DE +#define GL_COLOR_TABLE_INTENSITY_SIZE 0x80DF +#define GL_CONSTANT_BORDER 0x8151 +#define GL_REPLICATE_BORDER 0x8153 +#define GL_CONVOLUTION_BORDER_COLOR 0x8154 +#endif + +#ifndef GL_VERSION_1_3 +#define GL_TEXTURE0 0x84C0 +#define GL_TEXTURE1 0x84C1 +#define GL_TEXTURE2 0x84C2 +#define GL_TEXTURE3 0x84C3 +#define GL_TEXTURE4 0x84C4 +#define GL_TEXTURE5 0x84C5 +#define GL_TEXTURE6 0x84C6 +#define GL_TEXTURE7 0x84C7 +#define GL_TEXTURE8 0x84C8 +#define GL_TEXTURE9 0x84C9 +#define GL_TEXTURE10 0x84CA +#define GL_TEXTURE11 0x84CB +#define GL_TEXTURE12 0x84CC +#define GL_TEXTURE13 0x84CD +#define GL_TEXTURE14 0x84CE +#define GL_TEXTURE15 0x84CF +#define GL_TEXTURE16 0x84D0 +#define GL_TEXTURE17 0x84D1 +#define GL_TEXTURE18 0x84D2 +#define GL_TEXTURE19 0x84D3 +#define GL_TEXTURE20 0x84D4 +#define GL_TEXTURE21 0x84D5 +#define GL_TEXTURE22 0x84D6 +#define GL_TEXTURE23 0x84D7 +#define GL_TEXTURE24 0x84D8 +#define GL_TEXTURE25 0x84D9 +#define GL_TEXTURE26 0x84DA +#define GL_TEXTURE27 0x84DB +#define GL_TEXTURE28 0x84DC +#define GL_TEXTURE29 0x84DD +#define GL_TEXTURE30 0x84DE +#define GL_TEXTURE31 0x84DF +#define GL_ACTIVE_TEXTURE 0x84E0 +#define GL_MULTISAMPLE 0x809D +#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE 0x809F +#define GL_SAMPLE_COVERAGE 0x80A0 +#define GL_SAMPLE_BUFFERS 0x80A8 +#define GL_SAMPLES 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT 0x80AB +#define GL_TEXTURE_CUBE_MAP 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C +#define GL_COMPRESSED_RGB 0x84ED +#define GL_COMPRESSED_RGBA 0x84EE +#define GL_TEXTURE_COMPRESSION_HINT 0x84EF +#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0 +#define GL_TEXTURE_COMPRESSED 0x86A1 +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 +#define GL_CLAMP_TO_BORDER 0x812D +#endif + +#ifndef GL_VERSION_1_3_DEPRECATED +#define GL_CLIENT_ACTIVE_TEXTURE 0x84E1 +#define GL_MAX_TEXTURE_UNITS 0x84E2 +#define GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3 +#define GL_TRANSPOSE_PROJECTION_MATRIX 0x84E4 +#define GL_TRANSPOSE_TEXTURE_MATRIX 0x84E5 +#define GL_TRANSPOSE_COLOR_MATRIX 0x84E6 +#define GL_MULTISAMPLE_BIT 0x20000000 +#define GL_NORMAL_MAP 0x8511 +#define GL_REFLECTION_MAP 0x8512 +#define GL_COMPRESSED_ALPHA 0x84E9 +#define GL_COMPRESSED_LUMINANCE 0x84EA +#define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB +#define GL_COMPRESSED_INTENSITY 0x84EC +#define GL_COMBINE 0x8570 +#define GL_COMBINE_RGB 0x8571 +#define GL_COMBINE_ALPHA 0x8572 +#define GL_SOURCE0_RGB 0x8580 +#define GL_SOURCE1_RGB 0x8581 +#define GL_SOURCE2_RGB 0x8582 +#define GL_SOURCE0_ALPHA 0x8588 +#define GL_SOURCE1_ALPHA 0x8589 +#define GL_SOURCE2_ALPHA 0x858A +#define GL_OPERAND0_RGB 0x8590 +#define GL_OPERAND1_RGB 0x8591 +#define GL_OPERAND2_RGB 0x8592 +#define GL_OPERAND0_ALPHA 0x8598 +#define GL_OPERAND1_ALPHA 0x8599 +#define GL_OPERAND2_ALPHA 0x859A +#define GL_RGB_SCALE 0x8573 +#define GL_ADD_SIGNED 0x8574 +#define GL_INTERPOLATE 0x8575 +#define GL_SUBTRACT 0x84E7 +#define GL_CONSTANT 0x8576 +#define GL_PRIMARY_COLOR 0x8577 +#define GL_PREVIOUS 0x8578 +#define GL_DOT3_RGB 0x86AE +#define GL_DOT3_RGBA 0x86AF +#endif + +#ifndef GL_VERSION_1_4 +#define GL_BLEND_DST_RGB 0x80C8 +#define GL_BLEND_SRC_RGB 0x80C9 +#define GL_BLEND_DST_ALPHA 0x80CA +#define GL_BLEND_SRC_ALPHA 0x80CB +#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128 +#define GL_DEPTH_COMPONENT16 0x81A5 +#define GL_DEPTH_COMPONENT24 0x81A6 +#define GL_DEPTH_COMPONENT32 0x81A7 +#define GL_MIRRORED_REPEAT 0x8370 +#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD +#define GL_TEXTURE_LOD_BIAS 0x8501 +#define GL_INCR_WRAP 0x8507 +#define GL_DECR_WRAP 0x8508 +#define GL_TEXTURE_DEPTH_SIZE 0x884A +#define GL_TEXTURE_COMPARE_MODE 0x884C +#define GL_TEXTURE_COMPARE_FUNC 0x884D +#endif + +#ifndef GL_VERSION_1_4_DEPRECATED +#define GL_POINT_SIZE_MIN 0x8126 +#define GL_POINT_SIZE_MAX 0x8127 +#define GL_POINT_DISTANCE_ATTENUATION 0x8129 +#define GL_GENERATE_MIPMAP 0x8191 +#define GL_GENERATE_MIPMAP_HINT 0x8192 +#define GL_FOG_COORDINATE_SOURCE 0x8450 +#define GL_FOG_COORDINATE 0x8451 +#define GL_FRAGMENT_DEPTH 0x8452 +#define GL_CURRENT_FOG_COORDINATE 0x8453 +#define GL_FOG_COORDINATE_ARRAY_TYPE 0x8454 +#define GL_FOG_COORDINATE_ARRAY_STRIDE 0x8455 +#define GL_FOG_COORDINATE_ARRAY_POINTER 0x8456 +#define GL_FOG_COORDINATE_ARRAY 0x8457 +#define GL_COLOR_SUM 0x8458 +#define GL_CURRENT_SECONDARY_COLOR 0x8459 +#define GL_SECONDARY_COLOR_ARRAY_SIZE 0x845A +#define GL_SECONDARY_COLOR_ARRAY_TYPE 0x845B +#define GL_SECONDARY_COLOR_ARRAY_STRIDE 0x845C +#define GL_SECONDARY_COLOR_ARRAY_POINTER 0x845D +#define GL_SECONDARY_COLOR_ARRAY 0x845E +#define GL_TEXTURE_FILTER_CONTROL 0x8500 +#define GL_DEPTH_TEXTURE_MODE 0x884B +#define GL_COMPARE_R_TO_TEXTURE 0x884E +#endif + +#ifndef GL_VERSION_1_5 +#define GL_BUFFER_SIZE 0x8764 +#define GL_BUFFER_USAGE 0x8765 +#define GL_QUERY_COUNTER_BITS 0x8864 +#define GL_CURRENT_QUERY 0x8865 +#define GL_QUERY_RESULT 0x8866 +#define GL_QUERY_RESULT_AVAILABLE 0x8867 +#define GL_ARRAY_BUFFER 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER 0x8893 +#define GL_ARRAY_BUFFER_BINDING 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F +#define GL_READ_ONLY 0x88B8 +#define GL_WRITE_ONLY 0x88B9 +#define GL_READ_WRITE 0x88BA +#define GL_BUFFER_ACCESS 0x88BB +#define GL_BUFFER_MAPPED 0x88BC +#define GL_BUFFER_MAP_POINTER 0x88BD +#define GL_STREAM_DRAW 0x88E0 +#define GL_STREAM_READ 0x88E1 +#define GL_STREAM_COPY 0x88E2 +#define GL_STATIC_DRAW 0x88E4 +#define GL_STATIC_READ 0x88E5 +#define GL_STATIC_COPY 0x88E6 +#define GL_DYNAMIC_DRAW 0x88E8 +#define GL_DYNAMIC_READ 0x88E9 +#define GL_DYNAMIC_COPY 0x88EA +#define GL_SAMPLES_PASSED 0x8914 +#endif + +#ifndef GL_VERSION_1_5_DEPRECATED +#define GL_VERTEX_ARRAY_BUFFER_BINDING 0x8896 +#define GL_NORMAL_ARRAY_BUFFER_BINDING 0x8897 +#define GL_COLOR_ARRAY_BUFFER_BINDING 0x8898 +#define GL_INDEX_ARRAY_BUFFER_BINDING 0x8899 +#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A +#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING 0x889B +#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING 0x889C +#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING 0x889D +#define GL_WEIGHT_ARRAY_BUFFER_BINDING 0x889E +#define GL_FOG_COORD_SRC 0x8450 +#define GL_FOG_COORD 0x8451 +#define GL_CURRENT_FOG_COORD 0x8453 +#define GL_FOG_COORD_ARRAY_TYPE 0x8454 +#define GL_FOG_COORD_ARRAY_STRIDE 0x8455 +#define GL_FOG_COORD_ARRAY_POINTER 0x8456 +#define GL_FOG_COORD_ARRAY 0x8457 +#define GL_FOG_COORD_ARRAY_BUFFER_BINDING 0x889D +#define GL_SRC0_RGB 0x8580 +#define GL_SRC1_RGB 0x8581 +#define GL_SRC2_RGB 0x8582 +#define GL_SRC0_ALPHA 0x8588 +#define GL_SRC1_ALPHA 0x8589 +#define GL_SRC2_ALPHA 0x858A +#endif + +#ifndef GL_VERSION_2_0 +#define GL_BLEND_EQUATION_RGB 0x8009 +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 +#define GL_CURRENT_VERTEX_ATTRIB 0x8626 +#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642 +#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 +#define GL_STENCIL_BACK_FUNC 0x8800 +#define GL_STENCIL_BACK_FAIL 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 +#define GL_MAX_DRAW_BUFFERS 0x8824 +#define GL_DRAW_BUFFER0 0x8825 +#define GL_DRAW_BUFFER1 0x8826 +#define GL_DRAW_BUFFER2 0x8827 +#define GL_DRAW_BUFFER3 0x8828 +#define GL_DRAW_BUFFER4 0x8829 +#define GL_DRAW_BUFFER5 0x882A +#define GL_DRAW_BUFFER6 0x882B +#define GL_DRAW_BUFFER7 0x882C +#define GL_DRAW_BUFFER8 0x882D +#define GL_DRAW_BUFFER9 0x882E +#define GL_DRAW_BUFFER10 0x882F +#define GL_DRAW_BUFFER11 0x8830 +#define GL_DRAW_BUFFER12 0x8831 +#define GL_DRAW_BUFFER13 0x8832 +#define GL_DRAW_BUFFER14 0x8833 +#define GL_DRAW_BUFFER15 0x8834 +#define GL_BLEND_EQUATION_ALPHA 0x883D +#define GL_MAX_VERTEX_ATTRIBS 0x8869 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A +#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 +#define GL_FRAGMENT_SHADER 0x8B30 +#define GL_VERTEX_SHADER 0x8B31 +#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49 +#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A +#define GL_MAX_VARYING_FLOATS 0x8B4B +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D +#define GL_SHADER_TYPE 0x8B4F +#define GL_FLOAT_VEC2 0x8B50 +#define GL_FLOAT_VEC3 0x8B51 +#define GL_FLOAT_VEC4 0x8B52 +#define GL_INT_VEC2 0x8B53 +#define GL_INT_VEC3 0x8B54 +#define GL_INT_VEC4 0x8B55 +#define GL_BOOL 0x8B56 +#define GL_BOOL_VEC2 0x8B57 +#define GL_BOOL_VEC3 0x8B58 +#define GL_BOOL_VEC4 0x8B59 +#define GL_FLOAT_MAT2 0x8B5A +#define GL_FLOAT_MAT3 0x8B5B +#define GL_FLOAT_MAT4 0x8B5C +#define GL_SAMPLER_1D 0x8B5D +#define GL_SAMPLER_2D 0x8B5E +#define GL_SAMPLER_3D 0x8B5F +#define GL_SAMPLER_CUBE 0x8B60 +#define GL_SAMPLER_1D_SHADOW 0x8B61 +#define GL_SAMPLER_2D_SHADOW 0x8B62 +#define GL_DELETE_STATUS 0x8B80 +#define GL_COMPILE_STATUS 0x8B81 +#define GL_LINK_STATUS 0x8B82 +#define GL_VALIDATE_STATUS 0x8B83 +#define GL_INFO_LOG_LENGTH 0x8B84 +#define GL_ATTACHED_SHADERS 0x8B85 +#define GL_ACTIVE_UNIFORMS 0x8B86 +#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 +#define GL_SHADER_SOURCE_LENGTH 0x8B88 +#define GL_ACTIVE_ATTRIBUTES 0x8B89 +#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B +#define GL_SHADING_LANGUAGE_VERSION 0x8B8C +#define GL_CURRENT_PROGRAM 0x8B8D +#define GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0 +#define GL_LOWER_LEFT 0x8CA1 +#define GL_UPPER_LEFT 0x8CA2 +#define GL_STENCIL_BACK_REF 0x8CA3 +#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 +#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 +#endif + +#ifndef GL_VERSION_2_0_DEPRECATED +#define GL_VERTEX_PROGRAM_TWO_SIDE 0x8643 +#define GL_POINT_SPRITE 0x8861 +#define GL_COORD_REPLACE 0x8862 +#define GL_MAX_TEXTURE_COORDS 0x8871 +#endif + +#ifndef GL_VERSION_2_1 +#define GL_PIXEL_PACK_BUFFER 0x88EB +#define GL_PIXEL_UNPACK_BUFFER 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF +#define GL_FLOAT_MAT2x3 0x8B65 +#define GL_FLOAT_MAT2x4 0x8B66 +#define GL_FLOAT_MAT3x2 0x8B67 +#define GL_FLOAT_MAT3x4 0x8B68 +#define GL_FLOAT_MAT4x2 0x8B69 +#define GL_FLOAT_MAT4x3 0x8B6A +#define GL_SRGB 0x8C40 +#define GL_SRGB8 0x8C41 +#define GL_SRGB_ALPHA 0x8C42 +#define GL_SRGB8_ALPHA8 0x8C43 +#define GL_COMPRESSED_SRGB 0x8C48 +#define GL_COMPRESSED_SRGB_ALPHA 0x8C49 +#endif + +#ifndef GL_VERSION_2_1_DEPRECATED +#define GL_CURRENT_RASTER_SECONDARY_COLOR 0x845F +#define GL_SLUMINANCE_ALPHA 0x8C44 +#define GL_SLUMINANCE8_ALPHA8 0x8C45 +#define GL_SLUMINANCE 0x8C46 +#define GL_SLUMINANCE8 0x8C47 +#define GL_COMPRESSED_SLUMINANCE 0x8C4A +#define GL_COMPRESSED_SLUMINANCE_ALPHA 0x8C4B +#endif + +#ifndef GL_VERSION_3_0 +#define GL_COMPARE_REF_TO_TEXTURE 0x884E +#define GL_CLIP_DISTANCE0 0x3000 +#define GL_CLIP_DISTANCE1 0x3001 +#define GL_CLIP_DISTANCE2 0x3002 +#define GL_CLIP_DISTANCE3 0x3003 +#define GL_CLIP_DISTANCE4 0x3004 +#define GL_CLIP_DISTANCE5 0x3005 +#define GL_CLIP_DISTANCE6 0x3006 +#define GL_CLIP_DISTANCE7 0x3007 +#define GL_MAX_CLIP_DISTANCES 0x0D32 +#define GL_MAJOR_VERSION 0x821B +#define GL_MINOR_VERSION 0x821C +#define GL_NUM_EXTENSIONS 0x821D +#define GL_CONTEXT_FLAGS 0x821E +#define GL_DEPTH_BUFFER 0x8223 +#define GL_STENCIL_BUFFER 0x8224 +#define GL_COMPRESSED_RED 0x8225 +#define GL_COMPRESSED_RG 0x8226 +#define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x0001 +#define GL_RGBA32F 0x8814 +#define GL_RGB32F 0x8815 +#define GL_RGBA16F 0x881A +#define GL_RGB16F 0x881B +#define GL_VERTEX_ATTRIB_ARRAY_INTEGER 0x88FD +#define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF +#define GL_MIN_PROGRAM_TEXEL_OFFSET 0x8904 +#define GL_MAX_PROGRAM_TEXEL_OFFSET 0x8905 +#define GL_CLAMP_READ_COLOR 0x891C +#define GL_FIXED_ONLY 0x891D +#define GL_MAX_VARYING_COMPONENTS 0x8B4B +#define GL_TEXTURE_1D_ARRAY 0x8C18 +#define GL_PROXY_TEXTURE_1D_ARRAY 0x8C19 +#define GL_TEXTURE_2D_ARRAY 0x8C1A +#define GL_PROXY_TEXTURE_2D_ARRAY 0x8C1B +#define GL_TEXTURE_BINDING_1D_ARRAY 0x8C1C +#define GL_TEXTURE_BINDING_2D_ARRAY 0x8C1D +#define GL_R11F_G11F_B10F 0x8C3A +#define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B +#define GL_RGB9_E5 0x8C3D +#define GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E +#define GL_TEXTURE_SHARED_SIZE 0x8C3F +#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 0x8C76 +#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE 0x8C7F +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS 0x8C80 +#define GL_TRANSFORM_FEEDBACK_VARYINGS 0x8C83 +#define GL_TRANSFORM_FEEDBACK_BUFFER_START 0x8C84 +#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE 0x8C85 +#define GL_PRIMITIVES_GENERATED 0x8C87 +#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 0x8C88 +#define GL_RASTERIZER_DISCARD 0x8C89 +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS 0x8C8B +#define GL_INTERLEAVED_ATTRIBS 0x8C8C +#define GL_SEPARATE_ATTRIBS 0x8C8D +#define GL_TRANSFORM_FEEDBACK_BUFFER 0x8C8E +#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING 0x8C8F +#define GL_RGBA32UI 0x8D70 +#define GL_RGB32UI 0x8D71 +#define GL_RGBA16UI 0x8D76 +#define GL_RGB16UI 0x8D77 +#define GL_RGBA8UI 0x8D7C +#define GL_RGB8UI 0x8D7D +#define GL_RGBA32I 0x8D82 +#define GL_RGB32I 0x8D83 +#define GL_RGBA16I 0x8D88 +#define GL_RGB16I 0x8D89 +#define GL_RGBA8I 0x8D8E +#define GL_RGB8I 0x8D8F +#define GL_RED_INTEGER 0x8D94 +#define GL_GREEN_INTEGER 0x8D95 +#define GL_BLUE_INTEGER 0x8D96 +#define GL_RGB_INTEGER 0x8D98 +#define GL_RGBA_INTEGER 0x8D99 +#define GL_BGR_INTEGER 0x8D9A +#define GL_BGRA_INTEGER 0x8D9B +#define GL_SAMPLER_1D_ARRAY 0x8DC0 +#define GL_SAMPLER_2D_ARRAY 0x8DC1 +#define GL_SAMPLER_1D_ARRAY_SHADOW 0x8DC3 +#define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4 +#define GL_SAMPLER_CUBE_SHADOW 0x8DC5 +#define GL_UNSIGNED_INT_VEC2 0x8DC6 +#define GL_UNSIGNED_INT_VEC3 0x8DC7 +#define GL_UNSIGNED_INT_VEC4 0x8DC8 +#define GL_INT_SAMPLER_1D 0x8DC9 +#define GL_INT_SAMPLER_2D 0x8DCA +#define GL_INT_SAMPLER_3D 0x8DCB +#define GL_INT_SAMPLER_CUBE 0x8DCC +#define GL_INT_SAMPLER_1D_ARRAY 0x8DCE +#define GL_INT_SAMPLER_2D_ARRAY 0x8DCF +#define GL_UNSIGNED_INT_SAMPLER_1D 0x8DD1 +#define GL_UNSIGNED_INT_SAMPLER_2D 0x8DD2 +#define GL_UNSIGNED_INT_SAMPLER_3D 0x8DD3 +#define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4 +#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY 0x8DD6 +#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY 0x8DD7 +#define GL_QUERY_WAIT 0x8E13 +#define GL_QUERY_NO_WAIT 0x8E14 +#define GL_QUERY_BY_REGION_WAIT 0x8E15 +#define GL_QUERY_BY_REGION_NO_WAIT 0x8E16 +#define GL_BUFFER_ACCESS_FLAGS 0x911F +#define GL_BUFFER_MAP_LENGTH 0x9120 +#define GL_BUFFER_MAP_OFFSET 0x9121 +/* Reuse tokens from ARB_depth_buffer_float */ +/* reuse GL_DEPTH_COMPONENT32F */ +/* reuse GL_DEPTH32F_STENCIL8 */ +/* reuse GL_FLOAT_32_UNSIGNED_INT_24_8_REV */ +/* Reuse tokens from ARB_framebuffer_object */ +/* reuse GL_INVALID_FRAMEBUFFER_OPERATION */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE */ +/* reuse GL_FRAMEBUFFER_DEFAULT */ +/* reuse GL_FRAMEBUFFER_UNDEFINED */ +/* reuse GL_DEPTH_STENCIL_ATTACHMENT */ +/* reuse GL_INDEX */ +/* reuse GL_MAX_RENDERBUFFER_SIZE */ +/* reuse GL_DEPTH_STENCIL */ +/* reuse GL_UNSIGNED_INT_24_8 */ +/* reuse GL_DEPTH24_STENCIL8 */ +/* reuse GL_TEXTURE_STENCIL_SIZE */ +/* reuse GL_TEXTURE_RED_TYPE */ +/* reuse GL_TEXTURE_GREEN_TYPE */ +/* reuse GL_TEXTURE_BLUE_TYPE */ +/* reuse GL_TEXTURE_ALPHA_TYPE */ +/* reuse GL_TEXTURE_DEPTH_TYPE */ +/* reuse GL_UNSIGNED_NORMALIZED */ +/* reuse GL_FRAMEBUFFER_BINDING */ +/* reuse GL_DRAW_FRAMEBUFFER_BINDING */ +/* reuse GL_RENDERBUFFER_BINDING */ +/* reuse GL_READ_FRAMEBUFFER */ +/* reuse GL_DRAW_FRAMEBUFFER */ +/* reuse GL_READ_FRAMEBUFFER_BINDING */ +/* reuse GL_RENDERBUFFER_SAMPLES */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER */ +/* reuse GL_FRAMEBUFFER_COMPLETE */ +/* reuse GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT */ +/* reuse GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT */ +/* reuse GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER */ +/* reuse GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER */ +/* reuse GL_FRAMEBUFFER_UNSUPPORTED */ +/* reuse GL_MAX_COLOR_ATTACHMENTS */ +/* reuse GL_COLOR_ATTACHMENT0 */ +/* reuse GL_COLOR_ATTACHMENT1 */ +/* reuse GL_COLOR_ATTACHMENT2 */ +/* reuse GL_COLOR_ATTACHMENT3 */ +/* reuse GL_COLOR_ATTACHMENT4 */ +/* reuse GL_COLOR_ATTACHMENT5 */ +/* reuse GL_COLOR_ATTACHMENT6 */ +/* reuse GL_COLOR_ATTACHMENT7 */ +/* reuse GL_COLOR_ATTACHMENT8 */ +/* reuse GL_COLOR_ATTACHMENT9 */ +/* reuse GL_COLOR_ATTACHMENT10 */ +/* reuse GL_COLOR_ATTACHMENT11 */ +/* reuse GL_COLOR_ATTACHMENT12 */ +/* reuse GL_COLOR_ATTACHMENT13 */ +/* reuse GL_COLOR_ATTACHMENT14 */ +/* reuse GL_COLOR_ATTACHMENT15 */ +/* reuse GL_DEPTH_ATTACHMENT */ +/* reuse GL_STENCIL_ATTACHMENT */ +/* reuse GL_FRAMEBUFFER */ +/* reuse GL_RENDERBUFFER */ +/* reuse GL_RENDERBUFFER_WIDTH */ +/* reuse GL_RENDERBUFFER_HEIGHT */ +/* reuse GL_RENDERBUFFER_INTERNAL_FORMAT */ +/* reuse GL_STENCIL_INDEX1 */ +/* reuse GL_STENCIL_INDEX4 */ +/* reuse GL_STENCIL_INDEX8 */ +/* reuse GL_STENCIL_INDEX16 */ +/* reuse GL_RENDERBUFFER_RED_SIZE */ +/* reuse GL_RENDERBUFFER_GREEN_SIZE */ +/* reuse GL_RENDERBUFFER_BLUE_SIZE */ +/* reuse GL_RENDERBUFFER_ALPHA_SIZE */ +/* reuse GL_RENDERBUFFER_DEPTH_SIZE */ +/* reuse GL_RENDERBUFFER_STENCIL_SIZE */ +/* reuse GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE */ +/* reuse GL_MAX_SAMPLES */ +/* Reuse tokens from ARB_framebuffer_sRGB */ +/* reuse GL_FRAMEBUFFER_SRGB */ +/* Reuse tokens from ARB_half_float_vertex */ +/* reuse GL_HALF_FLOAT */ +/* Reuse tokens from ARB_map_buffer_range */ +/* reuse GL_MAP_READ_BIT */ +/* reuse GL_MAP_WRITE_BIT */ +/* reuse GL_MAP_INVALIDATE_RANGE_BIT */ +/* reuse GL_MAP_INVALIDATE_BUFFER_BIT */ +/* reuse GL_MAP_FLUSH_EXPLICIT_BIT */ +/* reuse GL_MAP_UNSYNCHRONIZED_BIT */ +/* Reuse tokens from ARB_texture_compression_rgtc */ +/* reuse GL_COMPRESSED_RED_RGTC1 */ +/* reuse GL_COMPRESSED_SIGNED_RED_RGTC1 */ +/* reuse GL_COMPRESSED_RG_RGTC2 */ +/* reuse GL_COMPRESSED_SIGNED_RG_RGTC2 */ +/* Reuse tokens from ARB_texture_rg */ +/* reuse GL_RG */ +/* reuse GL_RG_INTEGER */ +/* reuse GL_R8 */ +/* reuse GL_R16 */ +/* reuse GL_RG8 */ +/* reuse GL_RG16 */ +/* reuse GL_R16F */ +/* reuse GL_R32F */ +/* reuse GL_RG16F */ +/* reuse GL_RG32F */ +/* reuse GL_R8I */ +/* reuse GL_R8UI */ +/* reuse GL_R16I */ +/* reuse GL_R16UI */ +/* reuse GL_R32I */ +/* reuse GL_R32UI */ +/* reuse GL_RG8I */ +/* reuse GL_RG8UI */ +/* reuse GL_RG16I */ +/* reuse GL_RG16UI */ +/* reuse GL_RG32I */ +/* reuse GL_RG32UI */ +/* Reuse tokens from ARB_vertex_array_object */ +/* reuse GL_VERTEX_ARRAY_BINDING */ +#endif + +#ifndef GL_VERSION_3_0_DEPRECATED +#define GL_CLAMP_VERTEX_COLOR 0x891A +#define GL_CLAMP_FRAGMENT_COLOR 0x891B +#define GL_ALPHA_INTEGER 0x8D97 +/* Reuse tokens from ARB_framebuffer_object */ +/* reuse GL_TEXTURE_LUMINANCE_TYPE */ +/* reuse GL_TEXTURE_INTENSITY_TYPE */ +#endif + +#ifndef GL_VERSION_3_1 +#define GL_SAMPLER_2D_RECT 0x8B63 +#define GL_SAMPLER_2D_RECT_SHADOW 0x8B64 +#define GL_SAMPLER_BUFFER 0x8DC2 +#define GL_INT_SAMPLER_2D_RECT 0x8DCD +#define GL_INT_SAMPLER_BUFFER 0x8DD0 +#define GL_UNSIGNED_INT_SAMPLER_2D_RECT 0x8DD5 +#define GL_UNSIGNED_INT_SAMPLER_BUFFER 0x8DD8 +#define GL_TEXTURE_BUFFER 0x8C2A +#define GL_MAX_TEXTURE_BUFFER_SIZE 0x8C2B +#define GL_TEXTURE_BINDING_BUFFER 0x8C2C +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING 0x8C2D +#define GL_TEXTURE_BUFFER_FORMAT 0x8C2E +#define GL_TEXTURE_RECTANGLE 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE 0x84F8 +#define GL_RED_SNORM 0x8F90 +#define GL_RG_SNORM 0x8F91 +#define GL_RGB_SNORM 0x8F92 +#define GL_RGBA_SNORM 0x8F93 +#define GL_R8_SNORM 0x8F94 +#define GL_RG8_SNORM 0x8F95 +#define GL_RGB8_SNORM 0x8F96 +#define GL_RGBA8_SNORM 0x8F97 +#define GL_R16_SNORM 0x8F98 +#define GL_RG16_SNORM 0x8F99 +#define GL_RGB16_SNORM 0x8F9A +#define GL_RGBA16_SNORM 0x8F9B +#define GL_SIGNED_NORMALIZED 0x8F9C +#define GL_PRIMITIVE_RESTART 0x8F9D +#define GL_PRIMITIVE_RESTART_INDEX 0x8F9E +/* Reuse tokens from ARB_copy_buffer */ +/* reuse GL_COPY_READ_BUFFER */ +/* reuse GL_COPY_WRITE_BUFFER */ +/* Reuse tokens from ARB_draw_instanced (none) */ +/* Reuse tokens from ARB_uniform_buffer_object */ +/* reuse GL_UNIFORM_BUFFER */ +/* reuse GL_UNIFORM_BUFFER_BINDING */ +/* reuse GL_UNIFORM_BUFFER_START */ +/* reuse GL_UNIFORM_BUFFER_SIZE */ +/* reuse GL_MAX_VERTEX_UNIFORM_BLOCKS */ +/* reuse GL_MAX_FRAGMENT_UNIFORM_BLOCKS */ +/* reuse GL_MAX_COMBINED_UNIFORM_BLOCKS */ +/* reuse GL_MAX_UNIFORM_BUFFER_BINDINGS */ +/* reuse GL_MAX_UNIFORM_BLOCK_SIZE */ +/* reuse GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS */ +/* reuse GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS */ +/* reuse GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT */ +/* reuse GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH */ +/* reuse GL_ACTIVE_UNIFORM_BLOCKS */ +/* reuse GL_UNIFORM_TYPE */ +/* reuse GL_UNIFORM_SIZE */ +/* reuse GL_UNIFORM_NAME_LENGTH */ +/* reuse GL_UNIFORM_BLOCK_INDEX */ +/* reuse GL_UNIFORM_OFFSET */ +/* reuse GL_UNIFORM_ARRAY_STRIDE */ +/* reuse GL_UNIFORM_MATRIX_STRIDE */ +/* reuse GL_UNIFORM_IS_ROW_MAJOR */ +/* reuse GL_UNIFORM_BLOCK_BINDING */ +/* reuse GL_UNIFORM_BLOCK_DATA_SIZE */ +/* reuse GL_UNIFORM_BLOCK_NAME_LENGTH */ +/* reuse GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS */ +/* reuse GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES */ +/* reuse GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER */ +/* reuse GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER */ +/* reuse GL_INVALID_INDEX */ +#endif + +#ifndef GL_VERSION_3_2 +#define GL_CONTEXT_CORE_PROFILE_BIT 0x00000001 +#define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002 +#define GL_LINES_ADJACENCY 0x000A +#define GL_LINE_STRIP_ADJACENCY 0x000B +#define GL_TRIANGLES_ADJACENCY 0x000C +#define GL_TRIANGLE_STRIP_ADJACENCY 0x000D +#define GL_PROGRAM_POINT_SIZE 0x8642 +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS 0x8C29 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED 0x8DA7 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS 0x8DA8 +#define GL_GEOMETRY_SHADER 0x8DD9 +#define GL_GEOMETRY_VERTICES_OUT 0x8916 +#define GL_GEOMETRY_INPUT_TYPE 0x8917 +#define GL_GEOMETRY_OUTPUT_TYPE 0x8918 +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS 0x8DDF +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS 0x8DE1 +#define GL_MAX_VERTEX_OUTPUT_COMPONENTS 0x9122 +#define GL_MAX_GEOMETRY_INPUT_COMPONENTS 0x9123 +#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS 0x9124 +#define GL_MAX_FRAGMENT_INPUT_COMPONENTS 0x9125 +#define GL_CONTEXT_PROFILE_MASK 0x9126 +/* reuse GL_MAX_VARYING_COMPONENTS */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER */ +/* Reuse tokens from ARB_depth_clamp */ +/* reuse GL_DEPTH_CLAMP */ +/* Reuse tokens from ARB_draw_elements_base_vertex (none) */ +/* Reuse tokens from ARB_fragment_coord_conventions (none) */ +/* Reuse tokens from ARB_provoking_vertex */ +/* reuse GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION */ +/* reuse GL_FIRST_VERTEX_CONVENTION */ +/* reuse GL_LAST_VERTEX_CONVENTION */ +/* reuse GL_PROVOKING_VERTEX */ +/* Reuse tokens from ARB_seamless_cube_map */ +/* reuse GL_TEXTURE_CUBE_MAP_SEAMLESS */ +/* Reuse tokens from ARB_sync */ +/* reuse GL_MAX_SERVER_WAIT_TIMEOUT */ +/* reuse GL_OBJECT_TYPE */ +/* reuse GL_SYNC_CONDITION */ +/* reuse GL_SYNC_STATUS */ +/* reuse GL_SYNC_FLAGS */ +/* reuse GL_SYNC_FENCE */ +/* reuse GL_SYNC_GPU_COMMANDS_COMPLETE */ +/* reuse GL_UNSIGNALED */ +/* reuse GL_SIGNALED */ +/* reuse GL_ALREADY_SIGNALED */ +/* reuse GL_TIMEOUT_EXPIRED */ +/* reuse GL_CONDITION_SATISFIED */ +/* reuse GL_WAIT_FAILED */ +/* reuse GL_TIMEOUT_IGNORED */ +/* reuse GL_SYNC_FLUSH_COMMANDS_BIT */ +/* reuse GL_TIMEOUT_IGNORED */ +/* Reuse tokens from ARB_texture_multisample */ +/* reuse GL_SAMPLE_POSITION */ +/* reuse GL_SAMPLE_MASK */ +/* reuse GL_SAMPLE_MASK_VALUE */ +/* reuse GL_MAX_SAMPLE_MASK_WORDS */ +/* reuse GL_TEXTURE_2D_MULTISAMPLE */ +/* reuse GL_PROXY_TEXTURE_2D_MULTISAMPLE */ +/* reuse GL_TEXTURE_2D_MULTISAMPLE_ARRAY */ +/* reuse GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY */ +/* reuse GL_TEXTURE_BINDING_2D_MULTISAMPLE */ +/* reuse GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY */ +/* reuse GL_TEXTURE_SAMPLES */ +/* reuse GL_TEXTURE_FIXED_SAMPLE_LOCATIONS */ +/* reuse GL_SAMPLER_2D_MULTISAMPLE */ +/* reuse GL_INT_SAMPLER_2D_MULTISAMPLE */ +/* reuse GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE */ +/* reuse GL_SAMPLER_2D_MULTISAMPLE_ARRAY */ +/* reuse GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY */ +/* reuse GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY */ +/* reuse GL_MAX_COLOR_TEXTURE_SAMPLES */ +/* reuse GL_MAX_DEPTH_TEXTURE_SAMPLES */ +/* reuse GL_MAX_INTEGER_SAMPLES */ +/* Don't need to reuse tokens from ARB_vertex_array_bgra since they're already in 1.2 core */ +#endif + +#ifndef GL_VERSION_3_3 +#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR 0x88FE +/* Reuse tokens from ARB_blend_func_extended */ +/* reuse GL_SRC1_COLOR */ +/* reuse GL_ONE_MINUS_SRC1_COLOR */ +/* reuse GL_ONE_MINUS_SRC1_ALPHA */ +/* reuse GL_MAX_DUAL_SOURCE_DRAW_BUFFERS */ +/* Reuse tokens from ARB_explicit_attrib_location (none) */ +/* Reuse tokens from ARB_occlusion_query2 */ +/* reuse GL_ANY_SAMPLES_PASSED */ +/* Reuse tokens from ARB_sampler_objects */ +/* reuse GL_SAMPLER_BINDING */ +/* Reuse tokens from ARB_shader_bit_encoding (none) */ +/* Reuse tokens from ARB_texture_rgb10_a2ui */ +/* reuse GL_RGB10_A2UI */ +/* Reuse tokens from ARB_texture_swizzle */ +/* reuse GL_TEXTURE_SWIZZLE_R */ +/* reuse GL_TEXTURE_SWIZZLE_G */ +/* reuse GL_TEXTURE_SWIZZLE_B */ +/* reuse GL_TEXTURE_SWIZZLE_A */ +/* reuse GL_TEXTURE_SWIZZLE_RGBA */ +/* Reuse tokens from ARB_timer_query */ +/* reuse GL_TIME_ELAPSED */ +/* reuse GL_TIMESTAMP */ +/* Reuse tokens from ARB_vertex_type_2_10_10_10_rev */ +/* reuse GL_INT_2_10_10_10_REV */ +#endif + +#ifndef GL_VERSION_4_0 +#define GL_SAMPLE_SHADING 0x8C36 +#define GL_MIN_SAMPLE_SHADING_VALUE 0x8C37 +#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5E +#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5F +#define GL_TEXTURE_CUBE_MAP_ARRAY 0x9009 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY 0x900A +#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY 0x900B +#define GL_SAMPLER_CUBE_MAP_ARRAY 0x900C +#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW 0x900D +#define GL_INT_SAMPLER_CUBE_MAP_ARRAY 0x900E +#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY 0x900F +/* Reuse tokens from ARB_texture_query_lod (none) */ +/* Reuse tokens from ARB_draw_buffers_blend (none) */ +/* Reuse tokens from ARB_draw_indirect */ +/* reuse GL_DRAW_INDIRECT_BUFFER */ +/* reuse GL_DRAW_INDIRECT_BUFFER_BINDING */ +/* Reuse tokens from ARB_gpu_shader5 */ +/* reuse GL_GEOMETRY_SHADER_INVOCATIONS */ +/* reuse GL_MAX_GEOMETRY_SHADER_INVOCATIONS */ +/* reuse GL_MIN_FRAGMENT_INTERPOLATION_OFFSET */ +/* reuse GL_MAX_FRAGMENT_INTERPOLATION_OFFSET */ +/* reuse GL_FRAGMENT_INTERPOLATION_OFFSET_BITS */ +/* reuse GL_MAX_VERTEX_STREAMS */ +/* Reuse tokens from ARB_gpu_shader_fp64 */ +/* reuse GL_DOUBLE_VEC2 */ +/* reuse GL_DOUBLE_VEC3 */ +/* reuse GL_DOUBLE_VEC4 */ +/* reuse GL_DOUBLE_MAT2 */ +/* reuse GL_DOUBLE_MAT3 */ +/* reuse GL_DOUBLE_MAT4 */ +/* reuse GL_DOUBLE_MAT2x3 */ +/* reuse GL_DOUBLE_MAT2x4 */ +/* reuse GL_DOUBLE_MAT3x2 */ +/* reuse GL_DOUBLE_MAT3x4 */ +/* reuse GL_DOUBLE_MAT4x2 */ +/* reuse GL_DOUBLE_MAT4x3 */ +/* Reuse tokens from ARB_shader_subroutine */ +/* reuse GL_ACTIVE_SUBROUTINES */ +/* reuse GL_ACTIVE_SUBROUTINE_UNIFORMS */ +/* reuse GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS */ +/* reuse GL_ACTIVE_SUBROUTINE_MAX_LENGTH */ +/* reuse GL_ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH */ +/* reuse GL_MAX_SUBROUTINES */ +/* reuse GL_MAX_SUBROUTINE_UNIFORM_LOCATIONS */ +/* reuse GL_NUM_COMPATIBLE_SUBROUTINES */ +/* reuse GL_COMPATIBLE_SUBROUTINES */ +/* Reuse tokens from ARB_tessellation_shader */ +/* reuse GL_PATCHES */ +/* reuse GL_PATCH_VERTICES */ +/* reuse GL_PATCH_DEFAULT_INNER_LEVEL */ +/* reuse GL_PATCH_DEFAULT_OUTER_LEVEL */ +/* reuse GL_TESS_CONTROL_OUTPUT_VERTICES */ +/* reuse GL_TESS_GEN_MODE */ +/* reuse GL_TESS_GEN_SPACING */ +/* reuse GL_TESS_GEN_VERTEX_ORDER */ +/* reuse GL_TESS_GEN_POINT_MODE */ +/* reuse GL_ISOLINES */ +/* reuse GL_FRACTIONAL_ODD */ +/* reuse GL_FRACTIONAL_EVEN */ +/* reuse GL_MAX_PATCH_VERTICES */ +/* reuse GL_MAX_TESS_GEN_LEVEL */ +/* reuse GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS */ +/* reuse GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS */ +/* reuse GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS */ +/* reuse GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS */ +/* reuse GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS */ +/* reuse GL_MAX_TESS_PATCH_COMPONENTS */ +/* reuse GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS */ +/* reuse GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS */ +/* reuse GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS */ +/* reuse GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS */ +/* reuse GL_MAX_TESS_CONTROL_INPUT_COMPONENTS */ +/* reuse GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS */ +/* reuse GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS */ +/* reuse GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS */ +/* reuse GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER */ +/* reuse GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER */ +/* reuse GL_TESS_EVALUATION_SHADER */ +/* reuse GL_TESS_CONTROL_SHADER */ +/* Reuse tokens from ARB_texture_buffer_object_rgb32 (none) */ +/* Reuse tokens from ARB_transform_feedback2 */ +/* reuse GL_TRANSFORM_FEEDBACK */ +/* reuse GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED */ +/* reuse GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE */ +/* reuse GL_TRANSFORM_FEEDBACK_BINDING */ +/* Reuse tokens from ARB_transform_feedback3 */ +/* reuse GL_MAX_TRANSFORM_FEEDBACK_BUFFERS */ +/* reuse GL_MAX_VERTEX_STREAMS */ +#endif + +#ifndef GL_VERSION_4_1 +/* Reuse tokens from ARB_ES2_compatibility */ +/* reuse GL_FIXED */ +/* reuse GL_IMPLEMENTATION_COLOR_READ_TYPE */ +/* reuse GL_IMPLEMENTATION_COLOR_READ_FORMAT */ +/* reuse GL_LOW_FLOAT */ +/* reuse GL_MEDIUM_FLOAT */ +/* reuse GL_HIGH_FLOAT */ +/* reuse GL_LOW_INT */ +/* reuse GL_MEDIUM_INT */ +/* reuse GL_HIGH_INT */ +/* reuse GL_SHADER_COMPILER */ +/* reuse GL_NUM_SHADER_BINARY_FORMATS */ +/* reuse GL_MAX_VERTEX_UNIFORM_VECTORS */ +/* reuse GL_MAX_VARYING_VECTORS */ +/* reuse GL_MAX_FRAGMENT_UNIFORM_VECTORS */ +/* Reuse tokens from ARB_get_program_binary */ +/* reuse GL_PROGRAM_BINARY_RETRIEVABLE_HINT */ +/* reuse GL_PROGRAM_BINARY_LENGTH */ +/* reuse GL_NUM_PROGRAM_BINARY_FORMATS */ +/* reuse GL_PROGRAM_BINARY_FORMATS */ +/* Reuse tokens from ARB_separate_shader_objects */ +/* reuse GL_VERTEX_SHADER_BIT */ +/* reuse GL_FRAGMENT_SHADER_BIT */ +/* reuse GL_GEOMETRY_SHADER_BIT */ +/* reuse GL_TESS_CONTROL_SHADER_BIT */ +/* reuse GL_TESS_EVALUATION_SHADER_BIT */ +/* reuse GL_ALL_SHADER_BITS */ +/* reuse GL_PROGRAM_SEPARABLE */ +/* reuse GL_ACTIVE_PROGRAM */ +/* reuse GL_PROGRAM_PIPELINE_BINDING */ +/* Reuse tokens from ARB_shader_precision (none) */ +/* Reuse tokens from ARB_vertex_attrib_64bit - all are in GL 3.0 and 4.0 already */ +/* Reuse tokens from ARB_viewport_array - some are in GL 1.1 and ARB_provoking_vertex already */ +/* reuse GL_MAX_VIEWPORTS */ +/* reuse GL_VIEWPORT_SUBPIXEL_BITS */ +/* reuse GL_VIEWPORT_BOUNDS_RANGE */ +/* reuse GL_LAYER_PROVOKING_VERTEX */ +/* reuse GL_VIEWPORT_INDEX_PROVOKING_VERTEX */ +/* reuse GL_UNDEFINED_VERTEX */ +#endif + +#ifndef GL_VERSION_4_2 +/* Reuse tokens from ARB_base_instance (none) */ +/* Reuse tokens from ARB_shading_language_420pack (none) */ +/* Reuse tokens from ARB_transform_feedback_instanced (none) */ +/* Reuse tokens from ARB_compressed_texture_pixel_storage */ +/* reuse GL_UNPACK_COMPRESSED_BLOCK_WIDTH */ +/* reuse GL_UNPACK_COMPRESSED_BLOCK_HEIGHT */ +/* reuse GL_UNPACK_COMPRESSED_BLOCK_DEPTH */ +/* reuse GL_UNPACK_COMPRESSED_BLOCK_SIZE */ +/* reuse GL_PACK_COMPRESSED_BLOCK_WIDTH */ +/* reuse GL_PACK_COMPRESSED_BLOCK_HEIGHT */ +/* reuse GL_PACK_COMPRESSED_BLOCK_DEPTH */ +/* reuse GL_PACK_COMPRESSED_BLOCK_SIZE */ +/* Reuse tokens from ARB_conservative_depth (none) */ +/* Reuse tokens from ARB_internalformat_query */ +/* reuse GL_NUM_SAMPLE_COUNTS */ +/* Reuse tokens from ARB_map_buffer_alignment */ +/* reuse GL_MIN_MAP_BUFFER_ALIGNMENT */ +/* Reuse tokens from ARB_shader_atomic_counters */ +/* reuse GL_ATOMIC_COUNTER_BUFFER */ +/* reuse GL_ATOMIC_COUNTER_BUFFER_BINDING */ +/* reuse GL_ATOMIC_COUNTER_BUFFER_START */ +/* reuse GL_ATOMIC_COUNTER_BUFFER_SIZE */ +/* reuse GL_ATOMIC_COUNTER_BUFFER_DATA_SIZE */ +/* reuse GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTERS */ +/* reuse GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTER_INDICES */ +/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_VERTEX_SHADER */ +/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_CONTROL_SHADER */ +/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_EVALUATION_SHADER */ +/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_GEOMETRY_SHADER */ +/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_FRAGMENT_SHADER */ +/* reuse GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS */ +/* reuse GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS */ +/* reuse GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS */ +/* reuse GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS */ +/* reuse GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS */ +/* reuse GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS */ +/* reuse GL_MAX_VERTEX_ATOMIC_COUNTERS */ +/* reuse GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS */ +/* reuse GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS */ +/* reuse GL_MAX_GEOMETRY_ATOMIC_COUNTERS */ +/* reuse GL_MAX_FRAGMENT_ATOMIC_COUNTERS */ +/* reuse GL_MAX_COMBINED_ATOMIC_COUNTERS */ +/* reuse GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE */ +/* reuse GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS */ +/* reuse GL_ACTIVE_ATOMIC_COUNTER_BUFFERS */ +/* reuse GL_UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX */ +/* reuse GL_UNSIGNED_INT_ATOMIC_COUNTER */ +/* Reuse tokens from ARB_shader_image_load_store */ +/* reuse GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT */ +/* reuse GL_ELEMENT_ARRAY_BARRIER_BIT */ +/* reuse GL_UNIFORM_BARRIER_BIT */ +/* reuse GL_TEXTURE_FETCH_BARRIER_BIT */ +/* reuse GL_SHADER_IMAGE_ACCESS_BARRIER_BIT */ +/* reuse GL_COMMAND_BARRIER_BIT */ +/* reuse GL_PIXEL_BUFFER_BARRIER_BIT */ +/* reuse GL_TEXTURE_UPDATE_BARRIER_BIT */ +/* reuse GL_BUFFER_UPDATE_BARRIER_BIT */ +/* reuse GL_FRAMEBUFFER_BARRIER_BIT */ +/* reuse GL_TRANSFORM_FEEDBACK_BARRIER_BIT */ +/* reuse GL_ATOMIC_COUNTER_BARRIER_BIT */ +/* reuse GL_ALL_BARRIER_BITS */ +/* reuse GL_MAX_IMAGE_UNITS */ +/* reuse GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS */ +/* reuse GL_IMAGE_BINDING_NAME */ +/* reuse GL_IMAGE_BINDING_LEVEL */ +/* reuse GL_IMAGE_BINDING_LAYERED */ +/* reuse GL_IMAGE_BINDING_LAYER */ +/* reuse GL_IMAGE_BINDING_ACCESS */ +/* reuse GL_IMAGE_1D */ +/* reuse GL_IMAGE_2D */ +/* reuse GL_IMAGE_3D */ +/* reuse GL_IMAGE_2D_RECT */ +/* reuse GL_IMAGE_CUBE */ +/* reuse GL_IMAGE_BUFFER */ +/* reuse GL_IMAGE_1D_ARRAY */ +/* reuse GL_IMAGE_2D_ARRAY */ +/* reuse GL_IMAGE_CUBE_MAP_ARRAY */ +/* reuse GL_IMAGE_2D_MULTISAMPLE */ +/* reuse GL_IMAGE_2D_MULTISAMPLE_ARRAY */ +/* reuse GL_INT_IMAGE_1D */ +/* reuse GL_INT_IMAGE_2D */ +/* reuse GL_INT_IMAGE_3D */ +/* reuse GL_INT_IMAGE_2D_RECT */ +/* reuse GL_INT_IMAGE_CUBE */ +/* reuse GL_INT_IMAGE_BUFFER */ +/* reuse GL_INT_IMAGE_1D_ARRAY */ +/* reuse GL_INT_IMAGE_2D_ARRAY */ +/* reuse GL_INT_IMAGE_CUBE_MAP_ARRAY */ +/* reuse GL_INT_IMAGE_2D_MULTISAMPLE */ +/* reuse GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY */ +/* reuse GL_UNSIGNED_INT_IMAGE_1D */ +/* reuse GL_UNSIGNED_INT_IMAGE_2D */ +/* reuse GL_UNSIGNED_INT_IMAGE_3D */ +/* reuse GL_UNSIGNED_INT_IMAGE_2D_RECT */ +/* reuse GL_UNSIGNED_INT_IMAGE_CUBE */ +/* reuse GL_UNSIGNED_INT_IMAGE_BUFFER */ +/* reuse GL_UNSIGNED_INT_IMAGE_1D_ARRAY */ +/* reuse GL_UNSIGNED_INT_IMAGE_2D_ARRAY */ +/* reuse GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY */ +/* reuse GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE */ +/* reuse GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY */ +/* reuse GL_MAX_IMAGE_SAMPLES */ +/* reuse GL_IMAGE_BINDING_FORMAT */ +/* reuse GL_IMAGE_FORMAT_COMPATIBILITY_TYPE */ +/* reuse GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE */ +/* reuse GL_IMAGE_FORMAT_COMPATIBILITY_BY_CLASS */ +/* reuse GL_MAX_VERTEX_IMAGE_UNIFORMS */ +/* reuse GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS */ +/* reuse GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS */ +/* reuse GL_MAX_GEOMETRY_IMAGE_UNIFORMS */ +/* reuse GL_MAX_FRAGMENT_IMAGE_UNIFORMS */ +/* reuse GL_MAX_COMBINED_IMAGE_UNIFORMS */ +/* Reuse tokens from ARB_shading_language_packing (none) */ +/* Reuse tokens from ARB_texture_storage */ +/* reuse GL_TEXTURE_IMMUTABLE_FORMAT */ +#endif + +#ifndef GL_ARB_multitexture +#define GL_TEXTURE0_ARB 0x84C0 +#define GL_TEXTURE1_ARB 0x84C1 +#define GL_TEXTURE2_ARB 0x84C2 +#define GL_TEXTURE3_ARB 0x84C3 +#define GL_TEXTURE4_ARB 0x84C4 +#define GL_TEXTURE5_ARB 0x84C5 +#define GL_TEXTURE6_ARB 0x84C6 +#define GL_TEXTURE7_ARB 0x84C7 +#define GL_TEXTURE8_ARB 0x84C8 +#define GL_TEXTURE9_ARB 0x84C9 +#define GL_TEXTURE10_ARB 0x84CA +#define GL_TEXTURE11_ARB 0x84CB +#define GL_TEXTURE12_ARB 0x84CC +#define GL_TEXTURE13_ARB 0x84CD +#define GL_TEXTURE14_ARB 0x84CE +#define GL_TEXTURE15_ARB 0x84CF +#define GL_TEXTURE16_ARB 0x84D0 +#define GL_TEXTURE17_ARB 0x84D1 +#define GL_TEXTURE18_ARB 0x84D2 +#define GL_TEXTURE19_ARB 0x84D3 +#define GL_TEXTURE20_ARB 0x84D4 +#define GL_TEXTURE21_ARB 0x84D5 +#define GL_TEXTURE22_ARB 0x84D6 +#define GL_TEXTURE23_ARB 0x84D7 +#define GL_TEXTURE24_ARB 0x84D8 +#define GL_TEXTURE25_ARB 0x84D9 +#define GL_TEXTURE26_ARB 0x84DA +#define GL_TEXTURE27_ARB 0x84DB +#define GL_TEXTURE28_ARB 0x84DC +#define GL_TEXTURE29_ARB 0x84DD +#define GL_TEXTURE30_ARB 0x84DE +#define GL_TEXTURE31_ARB 0x84DF +#define GL_ACTIVE_TEXTURE_ARB 0x84E0 +#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1 +#define GL_MAX_TEXTURE_UNITS_ARB 0x84E2 +#endif + +#ifndef GL_ARB_transpose_matrix +#define GL_TRANSPOSE_MODELVIEW_MATRIX_ARB 0x84E3 +#define GL_TRANSPOSE_PROJECTION_MATRIX_ARB 0x84E4 +#define GL_TRANSPOSE_TEXTURE_MATRIX_ARB 0x84E5 +#define GL_TRANSPOSE_COLOR_MATRIX_ARB 0x84E6 +#endif + +#ifndef GL_ARB_multisample +#define GL_MULTISAMPLE_ARB 0x809D +#define GL_SAMPLE_ALPHA_TO_COVERAGE_ARB 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_ARB 0x809F +#define GL_SAMPLE_COVERAGE_ARB 0x80A0 +#define GL_SAMPLE_BUFFERS_ARB 0x80A8 +#define GL_SAMPLES_ARB 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE_ARB 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT_ARB 0x80AB +#define GL_MULTISAMPLE_BIT_ARB 0x20000000 +#endif + +#ifndef GL_ARB_texture_env_add +#endif + +#ifndef GL_ARB_texture_cube_map +#define GL_NORMAL_MAP_ARB 0x8511 +#define GL_REFLECTION_MAP_ARB 0x8512 +#define GL_TEXTURE_CUBE_MAP_ARB 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARB 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB 0x851C +#endif + +#ifndef GL_ARB_texture_compression +#define GL_COMPRESSED_ALPHA_ARB 0x84E9 +#define GL_COMPRESSED_LUMINANCE_ARB 0x84EA +#define GL_COMPRESSED_LUMINANCE_ALPHA_ARB 0x84EB +#define GL_COMPRESSED_INTENSITY_ARB 0x84EC +#define GL_COMPRESSED_RGB_ARB 0x84ED +#define GL_COMPRESSED_RGBA_ARB 0x84EE +#define GL_TEXTURE_COMPRESSION_HINT_ARB 0x84EF +#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB 0x86A0 +#define GL_TEXTURE_COMPRESSED_ARB 0x86A1 +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A3 +#endif + +#ifndef GL_ARB_texture_border_clamp +#define GL_CLAMP_TO_BORDER_ARB 0x812D +#endif + +#ifndef GL_ARB_point_parameters +#define GL_POINT_SIZE_MIN_ARB 0x8126 +#define GL_POINT_SIZE_MAX_ARB 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_ARB 0x8128 +#define GL_POINT_DISTANCE_ATTENUATION_ARB 0x8129 +#endif + +#ifndef GL_ARB_vertex_blend +#define GL_MAX_VERTEX_UNITS_ARB 0x86A4 +#define GL_ACTIVE_VERTEX_UNITS_ARB 0x86A5 +#define GL_WEIGHT_SUM_UNITY_ARB 0x86A6 +#define GL_VERTEX_BLEND_ARB 0x86A7 +#define GL_CURRENT_WEIGHT_ARB 0x86A8 +#define GL_WEIGHT_ARRAY_TYPE_ARB 0x86A9 +#define GL_WEIGHT_ARRAY_STRIDE_ARB 0x86AA +#define GL_WEIGHT_ARRAY_SIZE_ARB 0x86AB +#define GL_WEIGHT_ARRAY_POINTER_ARB 0x86AC +#define GL_WEIGHT_ARRAY_ARB 0x86AD +#define GL_MODELVIEW0_ARB 0x1700 +#define GL_MODELVIEW1_ARB 0x850A +#define GL_MODELVIEW2_ARB 0x8722 +#define GL_MODELVIEW3_ARB 0x8723 +#define GL_MODELVIEW4_ARB 0x8724 +#define GL_MODELVIEW5_ARB 0x8725 +#define GL_MODELVIEW6_ARB 0x8726 +#define GL_MODELVIEW7_ARB 0x8727 +#define GL_MODELVIEW8_ARB 0x8728 +#define GL_MODELVIEW9_ARB 0x8729 +#define GL_MODELVIEW10_ARB 0x872A +#define GL_MODELVIEW11_ARB 0x872B +#define GL_MODELVIEW12_ARB 0x872C +#define GL_MODELVIEW13_ARB 0x872D +#define GL_MODELVIEW14_ARB 0x872E +#define GL_MODELVIEW15_ARB 0x872F +#define GL_MODELVIEW16_ARB 0x8730 +#define GL_MODELVIEW17_ARB 0x8731 +#define GL_MODELVIEW18_ARB 0x8732 +#define GL_MODELVIEW19_ARB 0x8733 +#define GL_MODELVIEW20_ARB 0x8734 +#define GL_MODELVIEW21_ARB 0x8735 +#define GL_MODELVIEW22_ARB 0x8736 +#define GL_MODELVIEW23_ARB 0x8737 +#define GL_MODELVIEW24_ARB 0x8738 +#define GL_MODELVIEW25_ARB 0x8739 +#define GL_MODELVIEW26_ARB 0x873A +#define GL_MODELVIEW27_ARB 0x873B +#define GL_MODELVIEW28_ARB 0x873C +#define GL_MODELVIEW29_ARB 0x873D +#define GL_MODELVIEW30_ARB 0x873E +#define GL_MODELVIEW31_ARB 0x873F +#endif + +#ifndef GL_ARB_matrix_palette +#define GL_MATRIX_PALETTE_ARB 0x8840 +#define GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB 0x8841 +#define GL_MAX_PALETTE_MATRICES_ARB 0x8842 +#define GL_CURRENT_PALETTE_MATRIX_ARB 0x8843 +#define GL_MATRIX_INDEX_ARRAY_ARB 0x8844 +#define GL_CURRENT_MATRIX_INDEX_ARB 0x8845 +#define GL_MATRIX_INDEX_ARRAY_SIZE_ARB 0x8846 +#define GL_MATRIX_INDEX_ARRAY_TYPE_ARB 0x8847 +#define GL_MATRIX_INDEX_ARRAY_STRIDE_ARB 0x8848 +#define GL_MATRIX_INDEX_ARRAY_POINTER_ARB 0x8849 +#endif + +#ifndef GL_ARB_texture_env_combine +#define GL_COMBINE_ARB 0x8570 +#define GL_COMBINE_RGB_ARB 0x8571 +#define GL_COMBINE_ALPHA_ARB 0x8572 +#define GL_SOURCE0_RGB_ARB 0x8580 +#define GL_SOURCE1_RGB_ARB 0x8581 +#define GL_SOURCE2_RGB_ARB 0x8582 +#define GL_SOURCE0_ALPHA_ARB 0x8588 +#define GL_SOURCE1_ALPHA_ARB 0x8589 +#define GL_SOURCE2_ALPHA_ARB 0x858A +#define GL_OPERAND0_RGB_ARB 0x8590 +#define GL_OPERAND1_RGB_ARB 0x8591 +#define GL_OPERAND2_RGB_ARB 0x8592 +#define GL_OPERAND0_ALPHA_ARB 0x8598 +#define GL_OPERAND1_ALPHA_ARB 0x8599 +#define GL_OPERAND2_ALPHA_ARB 0x859A +#define GL_RGB_SCALE_ARB 0x8573 +#define GL_ADD_SIGNED_ARB 0x8574 +#define GL_INTERPOLATE_ARB 0x8575 +#define GL_SUBTRACT_ARB 0x84E7 +#define GL_CONSTANT_ARB 0x8576 +#define GL_PRIMARY_COLOR_ARB 0x8577 +#define GL_PREVIOUS_ARB 0x8578 +#endif + +#ifndef GL_ARB_texture_env_crossbar +#endif + +#ifndef GL_ARB_texture_env_dot3 +#define GL_DOT3_RGB_ARB 0x86AE +#define GL_DOT3_RGBA_ARB 0x86AF +#endif + +#ifndef GL_ARB_texture_mirrored_repeat +#define GL_MIRRORED_REPEAT_ARB 0x8370 +#endif + +#ifndef GL_ARB_depth_texture +#define GL_DEPTH_COMPONENT16_ARB 0x81A5 +#define GL_DEPTH_COMPONENT24_ARB 0x81A6 +#define GL_DEPTH_COMPONENT32_ARB 0x81A7 +#define GL_TEXTURE_DEPTH_SIZE_ARB 0x884A +#define GL_DEPTH_TEXTURE_MODE_ARB 0x884B +#endif + +#ifndef GL_ARB_shadow +#define GL_TEXTURE_COMPARE_MODE_ARB 0x884C +#define GL_TEXTURE_COMPARE_FUNC_ARB 0x884D +#define GL_COMPARE_R_TO_TEXTURE_ARB 0x884E +#endif + +#ifndef GL_ARB_shadow_ambient +#define GL_TEXTURE_COMPARE_FAIL_VALUE_ARB 0x80BF +#endif + +#ifndef GL_ARB_window_pos +#endif + +#ifndef GL_ARB_vertex_program +#define GL_COLOR_SUM_ARB 0x8458 +#define GL_VERTEX_PROGRAM_ARB 0x8620 +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB 0x8625 +#define GL_CURRENT_VERTEX_ATTRIB_ARB 0x8626 +#define GL_PROGRAM_LENGTH_ARB 0x8627 +#define GL_PROGRAM_STRING_ARB 0x8628 +#define GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB 0x862E +#define GL_MAX_PROGRAM_MATRICES_ARB 0x862F +#define GL_CURRENT_MATRIX_STACK_DEPTH_ARB 0x8640 +#define GL_CURRENT_MATRIX_ARB 0x8641 +#define GL_VERTEX_PROGRAM_POINT_SIZE_ARB 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE_ARB 0x8643 +#define GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB 0x8645 +#define GL_PROGRAM_ERROR_POSITION_ARB 0x864B +#define GL_PROGRAM_BINDING_ARB 0x8677 +#define GL_MAX_VERTEX_ATTRIBS_ARB 0x8869 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB 0x886A +#define GL_PROGRAM_ERROR_STRING_ARB 0x8874 +#define GL_PROGRAM_FORMAT_ASCII_ARB 0x8875 +#define GL_PROGRAM_FORMAT_ARB 0x8876 +#define GL_PROGRAM_INSTRUCTIONS_ARB 0x88A0 +#define GL_MAX_PROGRAM_INSTRUCTIONS_ARB 0x88A1 +#define GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A2 +#define GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A3 +#define GL_PROGRAM_TEMPORARIES_ARB 0x88A4 +#define GL_MAX_PROGRAM_TEMPORARIES_ARB 0x88A5 +#define GL_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A6 +#define GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A7 +#define GL_PROGRAM_PARAMETERS_ARB 0x88A8 +#define GL_MAX_PROGRAM_PARAMETERS_ARB 0x88A9 +#define GL_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AA +#define GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AB +#define GL_PROGRAM_ATTRIBS_ARB 0x88AC +#define GL_MAX_PROGRAM_ATTRIBS_ARB 0x88AD +#define GL_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AE +#define GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AF +#define GL_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B0 +#define GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B1 +#define GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B2 +#define GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B3 +#define GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB 0x88B4 +#define GL_MAX_PROGRAM_ENV_PARAMETERS_ARB 0x88B5 +#define GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB 0x88B6 +#define GL_TRANSPOSE_CURRENT_MATRIX_ARB 0x88B7 +#define GL_MATRIX0_ARB 0x88C0 +#define GL_MATRIX1_ARB 0x88C1 +#define GL_MATRIX2_ARB 0x88C2 +#define GL_MATRIX3_ARB 0x88C3 +#define GL_MATRIX4_ARB 0x88C4 +#define GL_MATRIX5_ARB 0x88C5 +#define GL_MATRIX6_ARB 0x88C6 +#define GL_MATRIX7_ARB 0x88C7 +#define GL_MATRIX8_ARB 0x88C8 +#define GL_MATRIX9_ARB 0x88C9 +#define GL_MATRIX10_ARB 0x88CA +#define GL_MATRIX11_ARB 0x88CB +#define GL_MATRIX12_ARB 0x88CC +#define GL_MATRIX13_ARB 0x88CD +#define GL_MATRIX14_ARB 0x88CE +#define GL_MATRIX15_ARB 0x88CF +#define GL_MATRIX16_ARB 0x88D0 +#define GL_MATRIX17_ARB 0x88D1 +#define GL_MATRIX18_ARB 0x88D2 +#define GL_MATRIX19_ARB 0x88D3 +#define GL_MATRIX20_ARB 0x88D4 +#define GL_MATRIX21_ARB 0x88D5 +#define GL_MATRIX22_ARB 0x88D6 +#define GL_MATRIX23_ARB 0x88D7 +#define GL_MATRIX24_ARB 0x88D8 +#define GL_MATRIX25_ARB 0x88D9 +#define GL_MATRIX26_ARB 0x88DA +#define GL_MATRIX27_ARB 0x88DB +#define GL_MATRIX28_ARB 0x88DC +#define GL_MATRIX29_ARB 0x88DD +#define GL_MATRIX30_ARB 0x88DE +#define GL_MATRIX31_ARB 0x88DF +#endif + +#ifndef GL_ARB_fragment_program +#define GL_FRAGMENT_PROGRAM_ARB 0x8804 +#define GL_PROGRAM_ALU_INSTRUCTIONS_ARB 0x8805 +#define GL_PROGRAM_TEX_INSTRUCTIONS_ARB 0x8806 +#define GL_PROGRAM_TEX_INDIRECTIONS_ARB 0x8807 +#define GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x8808 +#define GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x8809 +#define GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x880A +#define GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB 0x880B +#define GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB 0x880C +#define GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB 0x880D +#define GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x880E +#define GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x880F +#define GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x8810 +#define GL_MAX_TEXTURE_COORDS_ARB 0x8871 +#define GL_MAX_TEXTURE_IMAGE_UNITS_ARB 0x8872 +#endif + +#ifndef GL_ARB_vertex_buffer_object +#define GL_BUFFER_SIZE_ARB 0x8764 +#define GL_BUFFER_USAGE_ARB 0x8765 +#define GL_ARRAY_BUFFER_ARB 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER_ARB 0x8893 +#define GL_ARRAY_BUFFER_BINDING_ARB 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895 +#define GL_VERTEX_ARRAY_BUFFER_BINDING_ARB 0x8896 +#define GL_NORMAL_ARRAY_BUFFER_BINDING_ARB 0x8897 +#define GL_COLOR_ARRAY_BUFFER_BINDING_ARB 0x8898 +#define GL_INDEX_ARRAY_BUFFER_BINDING_ARB 0x8899 +#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB 0x889A +#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB 0x889B +#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889C +#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB 0x889D +#define GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB 0x889E +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB 0x889F +#define GL_READ_ONLY_ARB 0x88B8 +#define GL_WRITE_ONLY_ARB 0x88B9 +#define GL_READ_WRITE_ARB 0x88BA +#define GL_BUFFER_ACCESS_ARB 0x88BB +#define GL_BUFFER_MAPPED_ARB 0x88BC +#define GL_BUFFER_MAP_POINTER_ARB 0x88BD +#define GL_STREAM_DRAW_ARB 0x88E0 +#define GL_STREAM_READ_ARB 0x88E1 +#define GL_STREAM_COPY_ARB 0x88E2 +#define GL_STATIC_DRAW_ARB 0x88E4 +#define GL_STATIC_READ_ARB 0x88E5 +#define GL_STATIC_COPY_ARB 0x88E6 +#define GL_DYNAMIC_DRAW_ARB 0x88E8 +#define GL_DYNAMIC_READ_ARB 0x88E9 +#define GL_DYNAMIC_COPY_ARB 0x88EA +#endif + +#ifndef GL_ARB_occlusion_query +#define GL_QUERY_COUNTER_BITS_ARB 0x8864 +#define GL_CURRENT_QUERY_ARB 0x8865 +#define GL_QUERY_RESULT_ARB 0x8866 +#define GL_QUERY_RESULT_AVAILABLE_ARB 0x8867 +#define GL_SAMPLES_PASSED_ARB 0x8914 +#endif + +#ifndef GL_ARB_shader_objects +#define GL_PROGRAM_OBJECT_ARB 0x8B40 +#define GL_SHADER_OBJECT_ARB 0x8B48 +#define GL_OBJECT_TYPE_ARB 0x8B4E +#define GL_OBJECT_SUBTYPE_ARB 0x8B4F +#define GL_FLOAT_VEC2_ARB 0x8B50 +#define GL_FLOAT_VEC3_ARB 0x8B51 +#define GL_FLOAT_VEC4_ARB 0x8B52 +#define GL_INT_VEC2_ARB 0x8B53 +#define GL_INT_VEC3_ARB 0x8B54 +#define GL_INT_VEC4_ARB 0x8B55 +#define GL_BOOL_ARB 0x8B56 +#define GL_BOOL_VEC2_ARB 0x8B57 +#define GL_BOOL_VEC3_ARB 0x8B58 +#define GL_BOOL_VEC4_ARB 0x8B59 +#define GL_FLOAT_MAT2_ARB 0x8B5A +#define GL_FLOAT_MAT3_ARB 0x8B5B +#define GL_FLOAT_MAT4_ARB 0x8B5C +#define GL_SAMPLER_1D_ARB 0x8B5D +#define GL_SAMPLER_2D_ARB 0x8B5E +#define GL_SAMPLER_3D_ARB 0x8B5F +#define GL_SAMPLER_CUBE_ARB 0x8B60 +#define GL_SAMPLER_1D_SHADOW_ARB 0x8B61 +#define GL_SAMPLER_2D_SHADOW_ARB 0x8B62 +#define GL_SAMPLER_2D_RECT_ARB 0x8B63 +#define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64 +#define GL_OBJECT_DELETE_STATUS_ARB 0x8B80 +#define GL_OBJECT_COMPILE_STATUS_ARB 0x8B81 +#define GL_OBJECT_LINK_STATUS_ARB 0x8B82 +#define GL_OBJECT_VALIDATE_STATUS_ARB 0x8B83 +#define GL_OBJECT_INFO_LOG_LENGTH_ARB 0x8B84 +#define GL_OBJECT_ATTACHED_OBJECTS_ARB 0x8B85 +#define GL_OBJECT_ACTIVE_UNIFORMS_ARB 0x8B86 +#define GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB 0x8B87 +#define GL_OBJECT_SHADER_SOURCE_LENGTH_ARB 0x8B88 +#endif + +#ifndef GL_ARB_vertex_shader +#define GL_VERTEX_SHADER_ARB 0x8B31 +#define GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB 0x8B4A +#define GL_MAX_VARYING_FLOATS_ARB 0x8B4B +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB 0x8B4D +#define GL_OBJECT_ACTIVE_ATTRIBUTES_ARB 0x8B89 +#define GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB 0x8B8A +#endif + +#ifndef GL_ARB_fragment_shader +#define GL_FRAGMENT_SHADER_ARB 0x8B30 +#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB 0x8B49 +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8B8B +#endif + +#ifndef GL_ARB_shading_language_100 +#define GL_SHADING_LANGUAGE_VERSION_ARB 0x8B8C +#endif + +#ifndef GL_ARB_texture_non_power_of_two +#endif + +#ifndef GL_ARB_point_sprite +#define GL_POINT_SPRITE_ARB 0x8861 +#define GL_COORD_REPLACE_ARB 0x8862 +#endif + +#ifndef GL_ARB_fragment_program_shadow +#endif + +#ifndef GL_ARB_draw_buffers +#define GL_MAX_DRAW_BUFFERS_ARB 0x8824 +#define GL_DRAW_BUFFER0_ARB 0x8825 +#define GL_DRAW_BUFFER1_ARB 0x8826 +#define GL_DRAW_BUFFER2_ARB 0x8827 +#define GL_DRAW_BUFFER3_ARB 0x8828 +#define GL_DRAW_BUFFER4_ARB 0x8829 +#define GL_DRAW_BUFFER5_ARB 0x882A +#define GL_DRAW_BUFFER6_ARB 0x882B +#define GL_DRAW_BUFFER7_ARB 0x882C +#define GL_DRAW_BUFFER8_ARB 0x882D +#define GL_DRAW_BUFFER9_ARB 0x882E +#define GL_DRAW_BUFFER10_ARB 0x882F +#define GL_DRAW_BUFFER11_ARB 0x8830 +#define GL_DRAW_BUFFER12_ARB 0x8831 +#define GL_DRAW_BUFFER13_ARB 0x8832 +#define GL_DRAW_BUFFER14_ARB 0x8833 +#define GL_DRAW_BUFFER15_ARB 0x8834 +#endif + +#ifndef GL_ARB_texture_rectangle +#define GL_TEXTURE_RECTANGLE_ARB 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE_ARB 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE_ARB 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8 +#endif + +#ifndef GL_ARB_color_buffer_float +#define GL_RGBA_FLOAT_MODE_ARB 0x8820 +#define GL_CLAMP_VERTEX_COLOR_ARB 0x891A +#define GL_CLAMP_FRAGMENT_COLOR_ARB 0x891B +#define GL_CLAMP_READ_COLOR_ARB 0x891C +#define GL_FIXED_ONLY_ARB 0x891D +#endif + +#ifndef GL_ARB_half_float_pixel +#define GL_HALF_FLOAT_ARB 0x140B +#endif + +#ifndef GL_ARB_texture_float +#define GL_TEXTURE_RED_TYPE_ARB 0x8C10 +#define GL_TEXTURE_GREEN_TYPE_ARB 0x8C11 +#define GL_TEXTURE_BLUE_TYPE_ARB 0x8C12 +#define GL_TEXTURE_ALPHA_TYPE_ARB 0x8C13 +#define GL_TEXTURE_LUMINANCE_TYPE_ARB 0x8C14 +#define GL_TEXTURE_INTENSITY_TYPE_ARB 0x8C15 +#define GL_TEXTURE_DEPTH_TYPE_ARB 0x8C16 +#define GL_UNSIGNED_NORMALIZED_ARB 0x8C17 +#define GL_RGBA32F_ARB 0x8814 +#define GL_RGB32F_ARB 0x8815 +#define GL_ALPHA32F_ARB 0x8816 +#define GL_INTENSITY32F_ARB 0x8817 +#define GL_LUMINANCE32F_ARB 0x8818 +#define GL_LUMINANCE_ALPHA32F_ARB 0x8819 +#define GL_RGBA16F_ARB 0x881A +#define GL_RGB16F_ARB 0x881B +#define GL_ALPHA16F_ARB 0x881C +#define GL_INTENSITY16F_ARB 0x881D +#define GL_LUMINANCE16F_ARB 0x881E +#define GL_LUMINANCE_ALPHA16F_ARB 0x881F +#endif + +#ifndef GL_ARB_pixel_buffer_object +#define GL_PIXEL_PACK_BUFFER_ARB 0x88EB +#define GL_PIXEL_UNPACK_BUFFER_ARB 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING_ARB 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB 0x88EF +#endif + +#ifndef GL_ARB_depth_buffer_float +#define GL_DEPTH_COMPONENT32F 0x8CAC +#define GL_DEPTH32F_STENCIL8 0x8CAD +#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD +#endif + +#ifndef GL_ARB_draw_instanced +#endif + +#ifndef GL_ARB_framebuffer_object +#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 +#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210 +#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211 +#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212 +#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213 +#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214 +#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215 +#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216 +#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217 +#define GL_FRAMEBUFFER_DEFAULT 0x8218 +#define GL_FRAMEBUFFER_UNDEFINED 0x8219 +#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A +#define GL_MAX_RENDERBUFFER_SIZE 0x84E8 +#define GL_DEPTH_STENCIL 0x84F9 +#define GL_UNSIGNED_INT_24_8 0x84FA +#define GL_DEPTH24_STENCIL8 0x88F0 +#define GL_TEXTURE_STENCIL_SIZE 0x88F1 +#define GL_TEXTURE_RED_TYPE 0x8C10 +#define GL_TEXTURE_GREEN_TYPE 0x8C11 +#define GL_TEXTURE_BLUE_TYPE 0x8C12 +#define GL_TEXTURE_ALPHA_TYPE 0x8C13 +#define GL_TEXTURE_DEPTH_TYPE 0x8C16 +#define GL_UNSIGNED_NORMALIZED 0x8C17 +#define GL_FRAMEBUFFER_BINDING 0x8CA6 +#define GL_DRAW_FRAMEBUFFER_BINDING GL_FRAMEBUFFER_BINDING +#define GL_RENDERBUFFER_BINDING 0x8CA7 +#define GL_READ_FRAMEBUFFER 0x8CA8 +#define GL_DRAW_FRAMEBUFFER 0x8CA9 +#define GL_READ_FRAMEBUFFER_BINDING 0x8CAA +#define GL_RENDERBUFFER_SAMPLES 0x8CAB +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4 +#define GL_FRAMEBUFFER_COMPLETE 0x8CD5 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 +#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 0x8CDB +#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC +#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD +#define GL_MAX_COLOR_ATTACHMENTS 0x8CDF +#define GL_COLOR_ATTACHMENT0 0x8CE0 +#define GL_COLOR_ATTACHMENT1 0x8CE1 +#define GL_COLOR_ATTACHMENT2 0x8CE2 +#define GL_COLOR_ATTACHMENT3 0x8CE3 +#define GL_COLOR_ATTACHMENT4 0x8CE4 +#define GL_COLOR_ATTACHMENT5 0x8CE5 +#define GL_COLOR_ATTACHMENT6 0x8CE6 +#define GL_COLOR_ATTACHMENT7 0x8CE7 +#define GL_COLOR_ATTACHMENT8 0x8CE8 +#define GL_COLOR_ATTACHMENT9 0x8CE9 +#define GL_COLOR_ATTACHMENT10 0x8CEA +#define GL_COLOR_ATTACHMENT11 0x8CEB +#define GL_COLOR_ATTACHMENT12 0x8CEC +#define GL_COLOR_ATTACHMENT13 0x8CED +#define GL_COLOR_ATTACHMENT14 0x8CEE +#define GL_COLOR_ATTACHMENT15 0x8CEF +#define GL_DEPTH_ATTACHMENT 0x8D00 +#define GL_STENCIL_ATTACHMENT 0x8D20 +#define GL_FRAMEBUFFER 0x8D40 +#define GL_RENDERBUFFER 0x8D41 +#define GL_RENDERBUFFER_WIDTH 0x8D42 +#define GL_RENDERBUFFER_HEIGHT 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 +#define GL_STENCIL_INDEX1 0x8D46 +#define GL_STENCIL_INDEX4 0x8D47 +#define GL_STENCIL_INDEX8 0x8D48 +#define GL_STENCIL_INDEX16 0x8D49 +#define GL_RENDERBUFFER_RED_SIZE 0x8D50 +#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51 +#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52 +#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53 +#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54 +#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55 +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56 +#define GL_MAX_SAMPLES 0x8D57 +#endif + +#ifndef GL_ARB_framebuffer_object_DEPRECATED +#define GL_INDEX 0x8222 +#define GL_TEXTURE_LUMINANCE_TYPE 0x8C14 +#define GL_TEXTURE_INTENSITY_TYPE 0x8C15 +#endif + +#ifndef GL_ARB_framebuffer_sRGB +#define GL_FRAMEBUFFER_SRGB 0x8DB9 +#endif + +#ifndef GL_ARB_geometry_shader4 +#define GL_LINES_ADJACENCY_ARB 0x000A +#define GL_LINE_STRIP_ADJACENCY_ARB 0x000B +#define GL_TRIANGLES_ADJACENCY_ARB 0x000C +#define GL_TRIANGLE_STRIP_ADJACENCY_ARB 0x000D +#define GL_PROGRAM_POINT_SIZE_ARB 0x8642 +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB 0x8C29 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_ARB 0x8DA7 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_ARB 0x8DA8 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB 0x8DA9 +#define GL_GEOMETRY_SHADER_ARB 0x8DD9 +#define GL_GEOMETRY_VERTICES_OUT_ARB 0x8DDA +#define GL_GEOMETRY_INPUT_TYPE_ARB 0x8DDB +#define GL_GEOMETRY_OUTPUT_TYPE_ARB 0x8DDC +#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB 0x8DDD +#define GL_MAX_VERTEX_VARYING_COMPONENTS_ARB 0x8DDE +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB 0x8DDF +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB 0x8DE1 +/* reuse GL_MAX_VARYING_COMPONENTS */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER */ +#endif + +#ifndef GL_ARB_half_float_vertex +#define GL_HALF_FLOAT 0x140B +#endif + +#ifndef GL_ARB_instanced_arrays +#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB 0x88FE +#endif + +#ifndef GL_ARB_map_buffer_range +#define GL_MAP_READ_BIT 0x0001 +#define GL_MAP_WRITE_BIT 0x0002 +#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004 +#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008 +#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010 +#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020 +#endif + +#ifndef GL_ARB_texture_buffer_object +#define GL_TEXTURE_BUFFER_ARB 0x8C2A +#define GL_MAX_TEXTURE_BUFFER_SIZE_ARB 0x8C2B +#define GL_TEXTURE_BINDING_BUFFER_ARB 0x8C2C +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB 0x8C2D +#define GL_TEXTURE_BUFFER_FORMAT_ARB 0x8C2E +#endif + +#ifndef GL_ARB_texture_compression_rgtc +#define GL_COMPRESSED_RED_RGTC1 0x8DBB +#define GL_COMPRESSED_SIGNED_RED_RGTC1 0x8DBC +#define GL_COMPRESSED_RG_RGTC2 0x8DBD +#define GL_COMPRESSED_SIGNED_RG_RGTC2 0x8DBE +#endif + +#ifndef GL_ARB_texture_rg +#define GL_RG 0x8227 +#define GL_RG_INTEGER 0x8228 +#define GL_R8 0x8229 +#define GL_R16 0x822A +#define GL_RG8 0x822B +#define GL_RG16 0x822C +#define GL_R16F 0x822D +#define GL_R32F 0x822E +#define GL_RG16F 0x822F +#define GL_RG32F 0x8230 +#define GL_R8I 0x8231 +#define GL_R8UI 0x8232 +#define GL_R16I 0x8233 +#define GL_R16UI 0x8234 +#define GL_R32I 0x8235 +#define GL_R32UI 0x8236 +#define GL_RG8I 0x8237 +#define GL_RG8UI 0x8238 +#define GL_RG16I 0x8239 +#define GL_RG16UI 0x823A +#define GL_RG32I 0x823B +#define GL_RG32UI 0x823C +#endif + +#ifndef GL_ARB_vertex_array_object +#define GL_VERTEX_ARRAY_BINDING 0x85B5 +#endif + +#ifndef GL_ARB_uniform_buffer_object +#define GL_UNIFORM_BUFFER 0x8A11 +#define GL_UNIFORM_BUFFER_BINDING 0x8A28 +#define GL_UNIFORM_BUFFER_START 0x8A29 +#define GL_UNIFORM_BUFFER_SIZE 0x8A2A +#define GL_MAX_VERTEX_UNIFORM_BLOCKS 0x8A2B +#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS 0x8A2C +#define GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D +#define GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E +#define GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F +#define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30 +#define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31 +#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS 0x8A32 +#define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33 +#define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34 +#define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35 +#define GL_ACTIVE_UNIFORM_BLOCKS 0x8A36 +#define GL_UNIFORM_TYPE 0x8A37 +#define GL_UNIFORM_SIZE 0x8A38 +#define GL_UNIFORM_NAME_LENGTH 0x8A39 +#define GL_UNIFORM_BLOCK_INDEX 0x8A3A +#define GL_UNIFORM_OFFSET 0x8A3B +#define GL_UNIFORM_ARRAY_STRIDE 0x8A3C +#define GL_UNIFORM_MATRIX_STRIDE 0x8A3D +#define GL_UNIFORM_IS_ROW_MAJOR 0x8A3E +#define GL_UNIFORM_BLOCK_BINDING 0x8A3F +#define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40 +#define GL_UNIFORM_BLOCK_NAME_LENGTH 0x8A41 +#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42 +#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER 0x8A45 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46 +#define GL_INVALID_INDEX 0xFFFFFFFFu +#endif + +#ifndef GL_ARB_compatibility +/* ARB_compatibility just defines tokens from core 3.0 */ +#endif + +#ifndef GL_ARB_copy_buffer +#define GL_COPY_READ_BUFFER 0x8F36 +#define GL_COPY_WRITE_BUFFER 0x8F37 +#endif + +#ifndef GL_ARB_shader_texture_lod +#endif + +#ifndef GL_ARB_depth_clamp +#define GL_DEPTH_CLAMP 0x864F +#endif + +#ifndef GL_ARB_draw_elements_base_vertex +#endif + +#ifndef GL_ARB_fragment_coord_conventions +#endif + +#ifndef GL_ARB_provoking_vertex +#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION 0x8E4C +#define GL_FIRST_VERTEX_CONVENTION 0x8E4D +#define GL_LAST_VERTEX_CONVENTION 0x8E4E +#define GL_PROVOKING_VERTEX 0x8E4F +#endif + +#ifndef GL_ARB_seamless_cube_map +#define GL_TEXTURE_CUBE_MAP_SEAMLESS 0x884F +#endif + +#ifndef GL_ARB_sync +#define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111 +#define GL_OBJECT_TYPE 0x9112 +#define GL_SYNC_CONDITION 0x9113 +#define GL_SYNC_STATUS 0x9114 +#define GL_SYNC_FLAGS 0x9115 +#define GL_SYNC_FENCE 0x9116 +#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117 +#define GL_UNSIGNALED 0x9118 +#define GL_SIGNALED 0x9119 +#define GL_ALREADY_SIGNALED 0x911A +#define GL_TIMEOUT_EXPIRED 0x911B +#define GL_CONDITION_SATISFIED 0x911C +#define GL_WAIT_FAILED 0x911D +#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001 +#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFFull +#endif + +#ifndef GL_ARB_texture_multisample +#define GL_SAMPLE_POSITION 0x8E50 +#define GL_SAMPLE_MASK 0x8E51 +#define GL_SAMPLE_MASK_VALUE 0x8E52 +#define GL_MAX_SAMPLE_MASK_WORDS 0x8E59 +#define GL_TEXTURE_2D_MULTISAMPLE 0x9100 +#define GL_PROXY_TEXTURE_2D_MULTISAMPLE 0x9101 +#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9102 +#define GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9103 +#define GL_TEXTURE_BINDING_2D_MULTISAMPLE 0x9104 +#define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY 0x9105 +#define GL_TEXTURE_SAMPLES 0x9106 +#define GL_TEXTURE_FIXED_SAMPLE_LOCATIONS 0x9107 +#define GL_SAMPLER_2D_MULTISAMPLE 0x9108 +#define GL_INT_SAMPLER_2D_MULTISAMPLE 0x9109 +#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A +#define GL_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910B +#define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910C +#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910D +#define GL_MAX_COLOR_TEXTURE_SAMPLES 0x910E +#define GL_MAX_DEPTH_TEXTURE_SAMPLES 0x910F +#define GL_MAX_INTEGER_SAMPLES 0x9110 +#endif + +#ifndef GL_ARB_vertex_array_bgra +/* reuse GL_BGRA */ +#endif + +#ifndef GL_ARB_draw_buffers_blend +#endif + +#ifndef GL_ARB_sample_shading +#define GL_SAMPLE_SHADING_ARB 0x8C36 +#define GL_MIN_SAMPLE_SHADING_VALUE_ARB 0x8C37 +#endif + +#ifndef GL_ARB_texture_cube_map_array +#define GL_TEXTURE_CUBE_MAP_ARRAY_ARB 0x9009 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_ARB 0x900A +#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY_ARB 0x900B +#define GL_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900C +#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_ARB 0x900D +#define GL_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900E +#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900F +#endif + +#ifndef GL_ARB_texture_gather +#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5E +#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5F +#endif + +#ifndef GL_ARB_texture_query_lod +#endif + +#ifndef GL_ARB_shading_language_include +#define GL_SHADER_INCLUDE_ARB 0x8DAE +#define GL_NAMED_STRING_LENGTH_ARB 0x8DE9 +#define GL_NAMED_STRING_TYPE_ARB 0x8DEA +#endif + +#ifndef GL_ARB_texture_compression_bptc +#define GL_COMPRESSED_RGBA_BPTC_UNORM_ARB 0x8E8C +#define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB 0x8E8D +#define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB 0x8E8E +#define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB 0x8E8F +#endif + +#ifndef GL_ARB_blend_func_extended +#define GL_SRC1_COLOR 0x88F9 +/* reuse GL_SRC1_ALPHA */ +#define GL_ONE_MINUS_SRC1_COLOR 0x88FA +#define GL_ONE_MINUS_SRC1_ALPHA 0x88FB +#define GL_MAX_DUAL_SOURCE_DRAW_BUFFERS 0x88FC +#endif + +#ifndef GL_ARB_explicit_attrib_location +#endif + +#ifndef GL_ARB_occlusion_query2 +#define GL_ANY_SAMPLES_PASSED 0x8C2F +#endif + +#ifndef GL_ARB_sampler_objects +#define GL_SAMPLER_BINDING 0x8919 +#endif + +#ifndef GL_ARB_shader_bit_encoding +#endif + +#ifndef GL_ARB_texture_rgb10_a2ui +#define GL_RGB10_A2UI 0x906F +#endif + +#ifndef GL_ARB_texture_swizzle +#define GL_TEXTURE_SWIZZLE_R 0x8E42 +#define GL_TEXTURE_SWIZZLE_G 0x8E43 +#define GL_TEXTURE_SWIZZLE_B 0x8E44 +#define GL_TEXTURE_SWIZZLE_A 0x8E45 +#define GL_TEXTURE_SWIZZLE_RGBA 0x8E46 +#endif + +#ifndef GL_ARB_timer_query +#define GL_TIME_ELAPSED 0x88BF +#define GL_TIMESTAMP 0x8E28 +#endif + +#ifndef GL_ARB_vertex_type_2_10_10_10_rev +/* reuse GL_UNSIGNED_INT_2_10_10_10_REV */ +#define GL_INT_2_10_10_10_REV 0x8D9F +#endif + +#ifndef GL_ARB_draw_indirect +#define GL_DRAW_INDIRECT_BUFFER 0x8F3F +#define GL_DRAW_INDIRECT_BUFFER_BINDING 0x8F43 +#endif + +#ifndef GL_ARB_gpu_shader5 +#define GL_GEOMETRY_SHADER_INVOCATIONS 0x887F +#define GL_MAX_GEOMETRY_SHADER_INVOCATIONS 0x8E5A +#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET 0x8E5B +#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET 0x8E5C +#define GL_FRAGMENT_INTERPOLATION_OFFSET_BITS 0x8E5D +/* reuse GL_MAX_VERTEX_STREAMS */ +#endif + +#ifndef GL_ARB_gpu_shader_fp64 +/* reuse GL_DOUBLE */ +#define GL_DOUBLE_VEC2 0x8FFC +#define GL_DOUBLE_VEC3 0x8FFD +#define GL_DOUBLE_VEC4 0x8FFE +#define GL_DOUBLE_MAT2 0x8F46 +#define GL_DOUBLE_MAT3 0x8F47 +#define GL_DOUBLE_MAT4 0x8F48 +#define GL_DOUBLE_MAT2x3 0x8F49 +#define GL_DOUBLE_MAT2x4 0x8F4A +#define GL_DOUBLE_MAT3x2 0x8F4B +#define GL_DOUBLE_MAT3x4 0x8F4C +#define GL_DOUBLE_MAT4x2 0x8F4D +#define GL_DOUBLE_MAT4x3 0x8F4E +#endif + +#ifndef GL_ARB_shader_subroutine +#define GL_ACTIVE_SUBROUTINES 0x8DE5 +#define GL_ACTIVE_SUBROUTINE_UNIFORMS 0x8DE6 +#define GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS 0x8E47 +#define GL_ACTIVE_SUBROUTINE_MAX_LENGTH 0x8E48 +#define GL_ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH 0x8E49 +#define GL_MAX_SUBROUTINES 0x8DE7 +#define GL_MAX_SUBROUTINE_UNIFORM_LOCATIONS 0x8DE8 +#define GL_NUM_COMPATIBLE_SUBROUTINES 0x8E4A +#define GL_COMPATIBLE_SUBROUTINES 0x8E4B +/* reuse GL_UNIFORM_SIZE */ +/* reuse GL_UNIFORM_NAME_LENGTH */ +#endif + +#ifndef GL_ARB_tessellation_shader +#define GL_PATCHES 0x000E +#define GL_PATCH_VERTICES 0x8E72 +#define GL_PATCH_DEFAULT_INNER_LEVEL 0x8E73 +#define GL_PATCH_DEFAULT_OUTER_LEVEL 0x8E74 +#define GL_TESS_CONTROL_OUTPUT_VERTICES 0x8E75 +#define GL_TESS_GEN_MODE 0x8E76 +#define GL_TESS_GEN_SPACING 0x8E77 +#define GL_TESS_GEN_VERTEX_ORDER 0x8E78 +#define GL_TESS_GEN_POINT_MODE 0x8E79 +/* reuse GL_TRIANGLES */ +/* reuse GL_QUADS */ +#define GL_ISOLINES 0x8E7A +/* reuse GL_EQUAL */ +#define GL_FRACTIONAL_ODD 0x8E7B +#define GL_FRACTIONAL_EVEN 0x8E7C +/* reuse GL_CCW */ +/* reuse GL_CW */ +#define GL_MAX_PATCH_VERTICES 0x8E7D +#define GL_MAX_TESS_GEN_LEVEL 0x8E7E +#define GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E7F +#define GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E80 +#define GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS 0x8E81 +#define GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS 0x8E82 +#define GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS 0x8E83 +#define GL_MAX_TESS_PATCH_COMPONENTS 0x8E84 +#define GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS 0x8E85 +#define GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS 0x8E86 +#define GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS 0x8E89 +#define GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS 0x8E8A +#define GL_MAX_TESS_CONTROL_INPUT_COMPONENTS 0x886C +#define GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS 0x886D +#define GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E1E +#define GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E1F +#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER 0x84F0 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER 0x84F1 +#define GL_TESS_EVALUATION_SHADER 0x8E87 +#define GL_TESS_CONTROL_SHADER 0x8E88 +#endif + +#ifndef GL_ARB_texture_buffer_object_rgb32 +/* reuse GL_RGB32F */ +/* reuse GL_RGB32UI */ +/* reuse GL_RGB32I */ +#endif + +#ifndef GL_ARB_transform_feedback2 +#define GL_TRANSFORM_FEEDBACK 0x8E22 +#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED 0x8E23 +#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE 0x8E24 +#define GL_TRANSFORM_FEEDBACK_BINDING 0x8E25 +#endif + +#ifndef GL_ARB_transform_feedback3 +#define GL_MAX_TRANSFORM_FEEDBACK_BUFFERS 0x8E70 +#define GL_MAX_VERTEX_STREAMS 0x8E71 +#endif + +#ifndef GL_ARB_ES2_compatibility +#define GL_FIXED 0x140C +#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A +#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B +#define GL_LOW_FLOAT 0x8DF0 +#define GL_MEDIUM_FLOAT 0x8DF1 +#define GL_HIGH_FLOAT 0x8DF2 +#define GL_LOW_INT 0x8DF3 +#define GL_MEDIUM_INT 0x8DF4 +#define GL_HIGH_INT 0x8DF5 +#define GL_SHADER_COMPILER 0x8DFA +#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 +#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB +#define GL_MAX_VARYING_VECTORS 0x8DFC +#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD +#endif + +#ifndef GL_ARB_get_program_binary +#define GL_PROGRAM_BINARY_RETRIEVABLE_HINT 0x8257 +#define GL_PROGRAM_BINARY_LENGTH 0x8741 +#define GL_NUM_PROGRAM_BINARY_FORMATS 0x87FE +#define GL_PROGRAM_BINARY_FORMATS 0x87FF +#endif + +#ifndef GL_ARB_separate_shader_objects +#define GL_VERTEX_SHADER_BIT 0x00000001 +#define GL_FRAGMENT_SHADER_BIT 0x00000002 +#define GL_GEOMETRY_SHADER_BIT 0x00000004 +#define GL_TESS_CONTROL_SHADER_BIT 0x00000008 +#define GL_TESS_EVALUATION_SHADER_BIT 0x00000010 +#define GL_ALL_SHADER_BITS 0xFFFFFFFF +#define GL_PROGRAM_SEPARABLE 0x8258 +#define GL_ACTIVE_PROGRAM 0x8259 +#define GL_PROGRAM_PIPELINE_BINDING 0x825A +#endif + +#ifndef GL_ARB_shader_precision +#endif + +#ifndef GL_ARB_vertex_attrib_64bit +/* reuse GL_RGB32I */ +/* reuse GL_DOUBLE_VEC2 */ +/* reuse GL_DOUBLE_VEC3 */ +/* reuse GL_DOUBLE_VEC4 */ +/* reuse GL_DOUBLE_MAT2 */ +/* reuse GL_DOUBLE_MAT3 */ +/* reuse GL_DOUBLE_MAT4 */ +/* reuse GL_DOUBLE_MAT2x3 */ +/* reuse GL_DOUBLE_MAT2x4 */ +/* reuse GL_DOUBLE_MAT3x2 */ +/* reuse GL_DOUBLE_MAT3x4 */ +/* reuse GL_DOUBLE_MAT4x2 */ +/* reuse GL_DOUBLE_MAT4x3 */ +#endif + +#ifndef GL_ARB_viewport_array +/* reuse GL_SCISSOR_BOX */ +/* reuse GL_VIEWPORT */ +/* reuse GL_DEPTH_RANGE */ +/* reuse GL_SCISSOR_TEST */ +#define GL_MAX_VIEWPORTS 0x825B +#define GL_VIEWPORT_SUBPIXEL_BITS 0x825C +#define GL_VIEWPORT_BOUNDS_RANGE 0x825D +#define GL_LAYER_PROVOKING_VERTEX 0x825E +#define GL_VIEWPORT_INDEX_PROVOKING_VERTEX 0x825F +#define GL_UNDEFINED_VERTEX 0x8260 +/* reuse GL_FIRST_VERTEX_CONVENTION */ +/* reuse GL_LAST_VERTEX_CONVENTION */ +/* reuse GL_PROVOKING_VERTEX */ +#endif + +#ifndef GL_ARB_cl_event +#define GL_SYNC_CL_EVENT_ARB 0x8240 +#define GL_SYNC_CL_EVENT_COMPLETE_ARB 0x8241 +#endif + +#ifndef GL_ARB_debug_output +#define GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB 0x8242 +#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_ARB 0x8243 +#define GL_DEBUG_CALLBACK_FUNCTION_ARB 0x8244 +#define GL_DEBUG_CALLBACK_USER_PARAM_ARB 0x8245 +#define GL_DEBUG_SOURCE_API_ARB 0x8246 +#define GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB 0x8247 +#define GL_DEBUG_SOURCE_SHADER_COMPILER_ARB 0x8248 +#define GL_DEBUG_SOURCE_THIRD_PARTY_ARB 0x8249 +#define GL_DEBUG_SOURCE_APPLICATION_ARB 0x824A +#define GL_DEBUG_SOURCE_OTHER_ARB 0x824B +#define GL_DEBUG_TYPE_ERROR_ARB 0x824C +#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB 0x824D +#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB 0x824E +#define GL_DEBUG_TYPE_PORTABILITY_ARB 0x824F +#define GL_DEBUG_TYPE_PERFORMANCE_ARB 0x8250 +#define GL_DEBUG_TYPE_OTHER_ARB 0x8251 +#define GL_MAX_DEBUG_MESSAGE_LENGTH_ARB 0x9143 +#define GL_MAX_DEBUG_LOGGED_MESSAGES_ARB 0x9144 +#define GL_DEBUG_LOGGED_MESSAGES_ARB 0x9145 +#define GL_DEBUG_SEVERITY_HIGH_ARB 0x9146 +#define GL_DEBUG_SEVERITY_MEDIUM_ARB 0x9147 +#define GL_DEBUG_SEVERITY_LOW_ARB 0x9148 +#endif + +#ifndef GL_ARB_robustness +/* reuse GL_NO_ERROR */ +#define GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB 0x00000004 +#define GL_LOSE_CONTEXT_ON_RESET_ARB 0x8252 +#define GL_GUILTY_CONTEXT_RESET_ARB 0x8253 +#define GL_INNOCENT_CONTEXT_RESET_ARB 0x8254 +#define GL_UNKNOWN_CONTEXT_RESET_ARB 0x8255 +#define GL_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 +#define GL_NO_RESET_NOTIFICATION_ARB 0x8261 +#endif + +#ifndef GL_ARB_shader_stencil_export +#endif + +#ifndef GL_ARB_base_instance +#endif + +#ifndef GL_ARB_shading_language_420pack +#endif + +#ifndef GL_ARB_transform_feedback_instanced +#endif + +#ifndef GL_ARB_compressed_texture_pixel_storage +#define GL_UNPACK_COMPRESSED_BLOCK_WIDTH 0x9127 +#define GL_UNPACK_COMPRESSED_BLOCK_HEIGHT 0x9128 +#define GL_UNPACK_COMPRESSED_BLOCK_DEPTH 0x9129 +#define GL_UNPACK_COMPRESSED_BLOCK_SIZE 0x912A +#define GL_PACK_COMPRESSED_BLOCK_WIDTH 0x912B +#define GL_PACK_COMPRESSED_BLOCK_HEIGHT 0x912C +#define GL_PACK_COMPRESSED_BLOCK_DEPTH 0x912D +#define GL_PACK_COMPRESSED_BLOCK_SIZE 0x912E +#endif + +#ifndef GL_ARB_conservative_depth +#endif + +#ifndef GL_ARB_internalformat_query +#define GL_NUM_SAMPLE_COUNTS 0x9380 +#endif + +#ifndef GL_ARB_map_buffer_alignment +#define GL_MIN_MAP_BUFFER_ALIGNMENT 0x90BC +#endif + +#ifndef GL_ARB_shader_atomic_counters +#define GL_ATOMIC_COUNTER_BUFFER 0x92C0 +#define GL_ATOMIC_COUNTER_BUFFER_BINDING 0x92C1 +#define GL_ATOMIC_COUNTER_BUFFER_START 0x92C2 +#define GL_ATOMIC_COUNTER_BUFFER_SIZE 0x92C3 +#define GL_ATOMIC_COUNTER_BUFFER_DATA_SIZE 0x92C4 +#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTERS 0x92C5 +#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTER_INDICES 0x92C6 +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_VERTEX_SHADER 0x92C7 +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_CONTROL_SHADER 0x92C8 +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_EVALUATION_SHADER 0x92C9 +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_GEOMETRY_SHADER 0x92CA +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_FRAGMENT_SHADER 0x92CB +#define GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS 0x92CC +#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS 0x92CD +#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS 0x92CE +#define GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS 0x92CF +#define GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS 0x92D0 +#define GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS 0x92D1 +#define GL_MAX_VERTEX_ATOMIC_COUNTERS 0x92D2 +#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS 0x92D3 +#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS 0x92D4 +#define GL_MAX_GEOMETRY_ATOMIC_COUNTERS 0x92D5 +#define GL_MAX_FRAGMENT_ATOMIC_COUNTERS 0x92D6 +#define GL_MAX_COMBINED_ATOMIC_COUNTERS 0x92D7 +#define GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE 0x92D8 +#define GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS 0x92DC +#define GL_ACTIVE_ATOMIC_COUNTER_BUFFERS 0x92D9 +#define GL_UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX 0x92DA +#define GL_UNSIGNED_INT_ATOMIC_COUNTER 0x92DB +#endif + +#ifndef GL_ARB_shader_image_load_store +#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT 0x00000001 +#define GL_ELEMENT_ARRAY_BARRIER_BIT 0x00000002 +#define GL_UNIFORM_BARRIER_BIT 0x00000004 +#define GL_TEXTURE_FETCH_BARRIER_BIT 0x00000008 +#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT 0x00000020 +#define GL_COMMAND_BARRIER_BIT 0x00000040 +#define GL_PIXEL_BUFFER_BARRIER_BIT 0x00000080 +#define GL_TEXTURE_UPDATE_BARRIER_BIT 0x00000100 +#define GL_BUFFER_UPDATE_BARRIER_BIT 0x00000200 +#define GL_FRAMEBUFFER_BARRIER_BIT 0x00000400 +#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT 0x00000800 +#define GL_ATOMIC_COUNTER_BARRIER_BIT 0x00001000 +#define GL_ALL_BARRIER_BITS 0xFFFFFFFF +#define GL_MAX_IMAGE_UNITS 0x8F38 +#define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS 0x8F39 +#define GL_IMAGE_BINDING_NAME 0x8F3A +#define GL_IMAGE_BINDING_LEVEL 0x8F3B +#define GL_IMAGE_BINDING_LAYERED 0x8F3C +#define GL_IMAGE_BINDING_LAYER 0x8F3D +#define GL_IMAGE_BINDING_ACCESS 0x8F3E +#define GL_IMAGE_1D 0x904C +#define GL_IMAGE_2D 0x904D +#define GL_IMAGE_3D 0x904E +#define GL_IMAGE_2D_RECT 0x904F +#define GL_IMAGE_CUBE 0x9050 +#define GL_IMAGE_BUFFER 0x9051 +#define GL_IMAGE_1D_ARRAY 0x9052 +#define GL_IMAGE_2D_ARRAY 0x9053 +#define GL_IMAGE_CUBE_MAP_ARRAY 0x9054 +#define GL_IMAGE_2D_MULTISAMPLE 0x9055 +#define GL_IMAGE_2D_MULTISAMPLE_ARRAY 0x9056 +#define GL_INT_IMAGE_1D 0x9057 +#define GL_INT_IMAGE_2D 0x9058 +#define GL_INT_IMAGE_3D 0x9059 +#define GL_INT_IMAGE_2D_RECT 0x905A +#define GL_INT_IMAGE_CUBE 0x905B +#define GL_INT_IMAGE_BUFFER 0x905C +#define GL_INT_IMAGE_1D_ARRAY 0x905D +#define GL_INT_IMAGE_2D_ARRAY 0x905E +#define GL_INT_IMAGE_CUBE_MAP_ARRAY 0x905F +#define GL_INT_IMAGE_2D_MULTISAMPLE 0x9060 +#define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x9061 +#define GL_UNSIGNED_INT_IMAGE_1D 0x9062 +#define GL_UNSIGNED_INT_IMAGE_2D 0x9063 +#define GL_UNSIGNED_INT_IMAGE_3D 0x9064 +#define GL_UNSIGNED_INT_IMAGE_2D_RECT 0x9065 +#define GL_UNSIGNED_INT_IMAGE_CUBE 0x9066 +#define GL_UNSIGNED_INT_IMAGE_BUFFER 0x9067 +#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY 0x9068 +#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY 0x9069 +#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY 0x906A +#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE 0x906B +#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x906C +#define GL_MAX_IMAGE_SAMPLES 0x906D +#define GL_IMAGE_BINDING_FORMAT 0x906E +#define GL_IMAGE_FORMAT_COMPATIBILITY_TYPE 0x90C7 +#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE 0x90C8 +#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_CLASS 0x90C9 +#define GL_MAX_VERTEX_IMAGE_UNIFORMS 0x90CA +#define GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS 0x90CB +#define GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS 0x90CC +#define GL_MAX_GEOMETRY_IMAGE_UNIFORMS 0x90CD +#define GL_MAX_FRAGMENT_IMAGE_UNIFORMS 0x90CE +#define GL_MAX_COMBINED_IMAGE_UNIFORMS 0x90CF +#endif + +#ifndef GL_ARB_shading_language_packing +#endif + +#ifndef GL_ARB_texture_storage +#define GL_TEXTURE_IMMUTABLE_FORMAT 0x912F +#endif + +#ifndef GL_EXT_abgr +#define GL_ABGR_EXT 0x8000 +#endif + +#ifndef GL_EXT_blend_color +#define GL_CONSTANT_COLOR_EXT 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR_EXT 0x8002 +#define GL_CONSTANT_ALPHA_EXT 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA_EXT 0x8004 +#define GL_BLEND_COLOR_EXT 0x8005 +#endif + +#ifndef GL_EXT_polygon_offset +#define GL_POLYGON_OFFSET_EXT 0x8037 +#define GL_POLYGON_OFFSET_FACTOR_EXT 0x8038 +#define GL_POLYGON_OFFSET_BIAS_EXT 0x8039 +#endif + +#ifndef GL_EXT_texture +#define GL_ALPHA4_EXT 0x803B +#define GL_ALPHA8_EXT 0x803C +#define GL_ALPHA12_EXT 0x803D +#define GL_ALPHA16_EXT 0x803E +#define GL_LUMINANCE4_EXT 0x803F +#define GL_LUMINANCE8_EXT 0x8040 +#define GL_LUMINANCE12_EXT 0x8041 +#define GL_LUMINANCE16_EXT 0x8042 +#define GL_LUMINANCE4_ALPHA4_EXT 0x8043 +#define GL_LUMINANCE6_ALPHA2_EXT 0x8044 +#define GL_LUMINANCE8_ALPHA8_EXT 0x8045 +#define GL_LUMINANCE12_ALPHA4_EXT 0x8046 +#define GL_LUMINANCE12_ALPHA12_EXT 0x8047 +#define GL_LUMINANCE16_ALPHA16_EXT 0x8048 +#define GL_INTENSITY_EXT 0x8049 +#define GL_INTENSITY4_EXT 0x804A +#define GL_INTENSITY8_EXT 0x804B +#define GL_INTENSITY12_EXT 0x804C +#define GL_INTENSITY16_EXT 0x804D +#define GL_RGB2_EXT 0x804E +#define GL_RGB4_EXT 0x804F +#define GL_RGB5_EXT 0x8050 +#define GL_RGB8_EXT 0x8051 +#define GL_RGB10_EXT 0x8052 +#define GL_RGB12_EXT 0x8053 +#define GL_RGB16_EXT 0x8054 +#define GL_RGBA2_EXT 0x8055 +#define GL_RGBA4_EXT 0x8056 +#define GL_RGB5_A1_EXT 0x8057 +#define GL_RGBA8_EXT 0x8058 +#define GL_RGB10_A2_EXT 0x8059 +#define GL_RGBA12_EXT 0x805A +#define GL_RGBA16_EXT 0x805B +#define GL_TEXTURE_RED_SIZE_EXT 0x805C +#define GL_TEXTURE_GREEN_SIZE_EXT 0x805D +#define GL_TEXTURE_BLUE_SIZE_EXT 0x805E +#define GL_TEXTURE_ALPHA_SIZE_EXT 0x805F +#define GL_TEXTURE_LUMINANCE_SIZE_EXT 0x8060 +#define GL_TEXTURE_INTENSITY_SIZE_EXT 0x8061 +#define GL_REPLACE_EXT 0x8062 +#define GL_PROXY_TEXTURE_1D_EXT 0x8063 +#define GL_PROXY_TEXTURE_2D_EXT 0x8064 +#define GL_TEXTURE_TOO_LARGE_EXT 0x8065 +#endif + +#ifndef GL_EXT_texture3D +#define GL_PACK_SKIP_IMAGES_EXT 0x806B +#define GL_PACK_IMAGE_HEIGHT_EXT 0x806C +#define GL_UNPACK_SKIP_IMAGES_EXT 0x806D +#define GL_UNPACK_IMAGE_HEIGHT_EXT 0x806E +#define GL_TEXTURE_3D_EXT 0x806F +#define GL_PROXY_TEXTURE_3D_EXT 0x8070 +#define GL_TEXTURE_DEPTH_EXT 0x8071 +#define GL_TEXTURE_WRAP_R_EXT 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE_EXT 0x8073 +#endif + +#ifndef GL_SGIS_texture_filter4 +#define GL_FILTER4_SGIS 0x8146 +#define GL_TEXTURE_FILTER4_SIZE_SGIS 0x8147 +#endif + +#ifndef GL_EXT_subtexture +#endif + +#ifndef GL_EXT_copy_texture +#endif + +#ifndef GL_EXT_histogram +#define GL_HISTOGRAM_EXT 0x8024 +#define GL_PROXY_HISTOGRAM_EXT 0x8025 +#define GL_HISTOGRAM_WIDTH_EXT 0x8026 +#define GL_HISTOGRAM_FORMAT_EXT 0x8027 +#define GL_HISTOGRAM_RED_SIZE_EXT 0x8028 +#define GL_HISTOGRAM_GREEN_SIZE_EXT 0x8029 +#define GL_HISTOGRAM_BLUE_SIZE_EXT 0x802A +#define GL_HISTOGRAM_ALPHA_SIZE_EXT 0x802B +#define GL_HISTOGRAM_LUMINANCE_SIZE_EXT 0x802C +#define GL_HISTOGRAM_SINK_EXT 0x802D +#define GL_MINMAX_EXT 0x802E +#define GL_MINMAX_FORMAT_EXT 0x802F +#define GL_MINMAX_SINK_EXT 0x8030 +#define GL_TABLE_TOO_LARGE_EXT 0x8031 +#endif + +#ifndef GL_EXT_convolution +#define GL_CONVOLUTION_1D_EXT 0x8010 +#define GL_CONVOLUTION_2D_EXT 0x8011 +#define GL_SEPARABLE_2D_EXT 0x8012 +#define GL_CONVOLUTION_BORDER_MODE_EXT 0x8013 +#define GL_CONVOLUTION_FILTER_SCALE_EXT 0x8014 +#define GL_CONVOLUTION_FILTER_BIAS_EXT 0x8015 +#define GL_REDUCE_EXT 0x8016 +#define GL_CONVOLUTION_FORMAT_EXT 0x8017 +#define GL_CONVOLUTION_WIDTH_EXT 0x8018 +#define GL_CONVOLUTION_HEIGHT_EXT 0x8019 +#define GL_MAX_CONVOLUTION_WIDTH_EXT 0x801A +#define GL_MAX_CONVOLUTION_HEIGHT_EXT 0x801B +#define GL_POST_CONVOLUTION_RED_SCALE_EXT 0x801C +#define GL_POST_CONVOLUTION_GREEN_SCALE_EXT 0x801D +#define GL_POST_CONVOLUTION_BLUE_SCALE_EXT 0x801E +#define GL_POST_CONVOLUTION_ALPHA_SCALE_EXT 0x801F +#define GL_POST_CONVOLUTION_RED_BIAS_EXT 0x8020 +#define GL_POST_CONVOLUTION_GREEN_BIAS_EXT 0x8021 +#define GL_POST_CONVOLUTION_BLUE_BIAS_EXT 0x8022 +#define GL_POST_CONVOLUTION_ALPHA_BIAS_EXT 0x8023 +#endif + +#ifndef GL_SGI_color_matrix +#define GL_COLOR_MATRIX_SGI 0x80B1 +#define GL_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B2 +#define GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B3 +#define GL_POST_COLOR_MATRIX_RED_SCALE_SGI 0x80B4 +#define GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI 0x80B5 +#define GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI 0x80B6 +#define GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI 0x80B7 +#define GL_POST_COLOR_MATRIX_RED_BIAS_SGI 0x80B8 +#define GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI 0x80B9 +#define GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI 0x80BA +#define GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI 0x80BB +#endif + +#ifndef GL_SGI_color_table +#define GL_COLOR_TABLE_SGI 0x80D0 +#define GL_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D1 +#define GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D2 +#define GL_PROXY_COLOR_TABLE_SGI 0x80D3 +#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D4 +#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D5 +#define GL_COLOR_TABLE_SCALE_SGI 0x80D6 +#define GL_COLOR_TABLE_BIAS_SGI 0x80D7 +#define GL_COLOR_TABLE_FORMAT_SGI 0x80D8 +#define GL_COLOR_TABLE_WIDTH_SGI 0x80D9 +#define GL_COLOR_TABLE_RED_SIZE_SGI 0x80DA +#define GL_COLOR_TABLE_GREEN_SIZE_SGI 0x80DB +#define GL_COLOR_TABLE_BLUE_SIZE_SGI 0x80DC +#define GL_COLOR_TABLE_ALPHA_SIZE_SGI 0x80DD +#define GL_COLOR_TABLE_LUMINANCE_SIZE_SGI 0x80DE +#define GL_COLOR_TABLE_INTENSITY_SIZE_SGI 0x80DF +#endif + +#ifndef GL_SGIS_pixel_texture +#define GL_PIXEL_TEXTURE_SGIS 0x8353 +#define GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS 0x8354 +#define GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS 0x8355 +#define GL_PIXEL_GROUP_COLOR_SGIS 0x8356 +#endif + +#ifndef GL_SGIX_pixel_texture +#define GL_PIXEL_TEX_GEN_SGIX 0x8139 +#define GL_PIXEL_TEX_GEN_MODE_SGIX 0x832B +#endif + +#ifndef GL_SGIS_texture4D +#define GL_PACK_SKIP_VOLUMES_SGIS 0x8130 +#define GL_PACK_IMAGE_DEPTH_SGIS 0x8131 +#define GL_UNPACK_SKIP_VOLUMES_SGIS 0x8132 +#define GL_UNPACK_IMAGE_DEPTH_SGIS 0x8133 +#define GL_TEXTURE_4D_SGIS 0x8134 +#define GL_PROXY_TEXTURE_4D_SGIS 0x8135 +#define GL_TEXTURE_4DSIZE_SGIS 0x8136 +#define GL_TEXTURE_WRAP_Q_SGIS 0x8137 +#define GL_MAX_4D_TEXTURE_SIZE_SGIS 0x8138 +#define GL_TEXTURE_4D_BINDING_SGIS 0x814F +#endif + +#ifndef GL_SGI_texture_color_table +#define GL_TEXTURE_COLOR_TABLE_SGI 0x80BC +#define GL_PROXY_TEXTURE_COLOR_TABLE_SGI 0x80BD +#endif + +#ifndef GL_EXT_cmyka +#define GL_CMYK_EXT 0x800C +#define GL_CMYKA_EXT 0x800D +#define GL_PACK_CMYK_HINT_EXT 0x800E +#define GL_UNPACK_CMYK_HINT_EXT 0x800F +#endif + +#ifndef GL_EXT_texture_object +#define GL_TEXTURE_PRIORITY_EXT 0x8066 +#define GL_TEXTURE_RESIDENT_EXT 0x8067 +#define GL_TEXTURE_1D_BINDING_EXT 0x8068 +#define GL_TEXTURE_2D_BINDING_EXT 0x8069 +#define GL_TEXTURE_3D_BINDING_EXT 0x806A +#endif + +#ifndef GL_SGIS_detail_texture +#define GL_DETAIL_TEXTURE_2D_SGIS 0x8095 +#define GL_DETAIL_TEXTURE_2D_BINDING_SGIS 0x8096 +#define GL_LINEAR_DETAIL_SGIS 0x8097 +#define GL_LINEAR_DETAIL_ALPHA_SGIS 0x8098 +#define GL_LINEAR_DETAIL_COLOR_SGIS 0x8099 +#define GL_DETAIL_TEXTURE_LEVEL_SGIS 0x809A +#define GL_DETAIL_TEXTURE_MODE_SGIS 0x809B +#define GL_DETAIL_TEXTURE_FUNC_POINTS_SGIS 0x809C +#endif + +#ifndef GL_SGIS_sharpen_texture +#define GL_LINEAR_SHARPEN_SGIS 0x80AD +#define GL_LINEAR_SHARPEN_ALPHA_SGIS 0x80AE +#define GL_LINEAR_SHARPEN_COLOR_SGIS 0x80AF +#define GL_SHARPEN_TEXTURE_FUNC_POINTS_SGIS 0x80B0 +#endif + +#ifndef GL_EXT_packed_pixels +#define GL_UNSIGNED_BYTE_3_3_2_EXT 0x8032 +#define GL_UNSIGNED_SHORT_4_4_4_4_EXT 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1_EXT 0x8034 +#define GL_UNSIGNED_INT_8_8_8_8_EXT 0x8035 +#define GL_UNSIGNED_INT_10_10_10_2_EXT 0x8036 +#endif + +#ifndef GL_SGIS_texture_lod +#define GL_TEXTURE_MIN_LOD_SGIS 0x813A +#define GL_TEXTURE_MAX_LOD_SGIS 0x813B +#define GL_TEXTURE_BASE_LEVEL_SGIS 0x813C +#define GL_TEXTURE_MAX_LEVEL_SGIS 0x813D +#endif + +#ifndef GL_SGIS_multisample +#define GL_MULTISAMPLE_SGIS 0x809D +#define GL_SAMPLE_ALPHA_TO_MASK_SGIS 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_SGIS 0x809F +#define GL_SAMPLE_MASK_SGIS 0x80A0 +#define GL_1PASS_SGIS 0x80A1 +#define GL_2PASS_0_SGIS 0x80A2 +#define GL_2PASS_1_SGIS 0x80A3 +#define GL_4PASS_0_SGIS 0x80A4 +#define GL_4PASS_1_SGIS 0x80A5 +#define GL_4PASS_2_SGIS 0x80A6 +#define GL_4PASS_3_SGIS 0x80A7 +#define GL_SAMPLE_BUFFERS_SGIS 0x80A8 +#define GL_SAMPLES_SGIS 0x80A9 +#define GL_SAMPLE_MASK_VALUE_SGIS 0x80AA +#define GL_SAMPLE_MASK_INVERT_SGIS 0x80AB +#define GL_SAMPLE_PATTERN_SGIS 0x80AC +#endif + +#ifndef GL_EXT_rescale_normal +#define GL_RESCALE_NORMAL_EXT 0x803A +#endif + +#ifndef GL_EXT_vertex_array +#define GL_VERTEX_ARRAY_EXT 0x8074 +#define GL_NORMAL_ARRAY_EXT 0x8075 +#define GL_COLOR_ARRAY_EXT 0x8076 +#define GL_INDEX_ARRAY_EXT 0x8077 +#define GL_TEXTURE_COORD_ARRAY_EXT 0x8078 +#define GL_EDGE_FLAG_ARRAY_EXT 0x8079 +#define GL_VERTEX_ARRAY_SIZE_EXT 0x807A +#define GL_VERTEX_ARRAY_TYPE_EXT 0x807B +#define GL_VERTEX_ARRAY_STRIDE_EXT 0x807C +#define GL_VERTEX_ARRAY_COUNT_EXT 0x807D +#define GL_NORMAL_ARRAY_TYPE_EXT 0x807E +#define GL_NORMAL_ARRAY_STRIDE_EXT 0x807F +#define GL_NORMAL_ARRAY_COUNT_EXT 0x8080 +#define GL_COLOR_ARRAY_SIZE_EXT 0x8081 +#define GL_COLOR_ARRAY_TYPE_EXT 0x8082 +#define GL_COLOR_ARRAY_STRIDE_EXT 0x8083 +#define GL_COLOR_ARRAY_COUNT_EXT 0x8084 +#define GL_INDEX_ARRAY_TYPE_EXT 0x8085 +#define GL_INDEX_ARRAY_STRIDE_EXT 0x8086 +#define GL_INDEX_ARRAY_COUNT_EXT 0x8087 +#define GL_TEXTURE_COORD_ARRAY_SIZE_EXT 0x8088 +#define GL_TEXTURE_COORD_ARRAY_TYPE_EXT 0x8089 +#define GL_TEXTURE_COORD_ARRAY_STRIDE_EXT 0x808A +#define GL_TEXTURE_COORD_ARRAY_COUNT_EXT 0x808B +#define GL_EDGE_FLAG_ARRAY_STRIDE_EXT 0x808C +#define GL_EDGE_FLAG_ARRAY_COUNT_EXT 0x808D +#define GL_VERTEX_ARRAY_POINTER_EXT 0x808E +#define GL_NORMAL_ARRAY_POINTER_EXT 0x808F +#define GL_COLOR_ARRAY_POINTER_EXT 0x8090 +#define GL_INDEX_ARRAY_POINTER_EXT 0x8091 +#define GL_TEXTURE_COORD_ARRAY_POINTER_EXT 0x8092 +#define GL_EDGE_FLAG_ARRAY_POINTER_EXT 0x8093 +#endif + +#ifndef GL_EXT_misc_attribute +#endif + +#ifndef GL_SGIS_generate_mipmap +#define GL_GENERATE_MIPMAP_SGIS 0x8191 +#define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192 +#endif + +#ifndef GL_SGIX_clipmap +#define GL_LINEAR_CLIPMAP_LINEAR_SGIX 0x8170 +#define GL_TEXTURE_CLIPMAP_CENTER_SGIX 0x8171 +#define GL_TEXTURE_CLIPMAP_FRAME_SGIX 0x8172 +#define GL_TEXTURE_CLIPMAP_OFFSET_SGIX 0x8173 +#define GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8174 +#define GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX 0x8175 +#define GL_TEXTURE_CLIPMAP_DEPTH_SGIX 0x8176 +#define GL_MAX_CLIPMAP_DEPTH_SGIX 0x8177 +#define GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8178 +#define GL_NEAREST_CLIPMAP_NEAREST_SGIX 0x844D +#define GL_NEAREST_CLIPMAP_LINEAR_SGIX 0x844E +#define GL_LINEAR_CLIPMAP_NEAREST_SGIX 0x844F +#endif + +#ifndef GL_SGIX_shadow +#define GL_TEXTURE_COMPARE_SGIX 0x819A +#define GL_TEXTURE_COMPARE_OPERATOR_SGIX 0x819B +#define GL_TEXTURE_LEQUAL_R_SGIX 0x819C +#define GL_TEXTURE_GEQUAL_R_SGIX 0x819D +#endif + +#ifndef GL_SGIS_texture_edge_clamp +#define GL_CLAMP_TO_EDGE_SGIS 0x812F +#endif + +#ifndef GL_SGIS_texture_border_clamp +#define GL_CLAMP_TO_BORDER_SGIS 0x812D +#endif + +#ifndef GL_EXT_blend_minmax +#define GL_FUNC_ADD_EXT 0x8006 +#define GL_MIN_EXT 0x8007 +#define GL_MAX_EXT 0x8008 +#define GL_BLEND_EQUATION_EXT 0x8009 +#endif + +#ifndef GL_EXT_blend_subtract +#define GL_FUNC_SUBTRACT_EXT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT_EXT 0x800B +#endif + +#ifndef GL_EXT_blend_logic_op +#endif + +#ifndef GL_SGIX_interlace +#define GL_INTERLACE_SGIX 0x8094 +#endif + +#ifndef GL_SGIX_pixel_tiles +#define GL_PIXEL_TILE_BEST_ALIGNMENT_SGIX 0x813E +#define GL_PIXEL_TILE_CACHE_INCREMENT_SGIX 0x813F +#define GL_PIXEL_TILE_WIDTH_SGIX 0x8140 +#define GL_PIXEL_TILE_HEIGHT_SGIX 0x8141 +#define GL_PIXEL_TILE_GRID_WIDTH_SGIX 0x8142 +#define GL_PIXEL_TILE_GRID_HEIGHT_SGIX 0x8143 +#define GL_PIXEL_TILE_GRID_DEPTH_SGIX 0x8144 +#define GL_PIXEL_TILE_CACHE_SIZE_SGIX 0x8145 +#endif + +#ifndef GL_SGIS_texture_select +#define GL_DUAL_ALPHA4_SGIS 0x8110 +#define GL_DUAL_ALPHA8_SGIS 0x8111 +#define GL_DUAL_ALPHA12_SGIS 0x8112 +#define GL_DUAL_ALPHA16_SGIS 0x8113 +#define GL_DUAL_LUMINANCE4_SGIS 0x8114 +#define GL_DUAL_LUMINANCE8_SGIS 0x8115 +#define GL_DUAL_LUMINANCE12_SGIS 0x8116 +#define GL_DUAL_LUMINANCE16_SGIS 0x8117 +#define GL_DUAL_INTENSITY4_SGIS 0x8118 +#define GL_DUAL_INTENSITY8_SGIS 0x8119 +#define GL_DUAL_INTENSITY12_SGIS 0x811A +#define GL_DUAL_INTENSITY16_SGIS 0x811B +#define GL_DUAL_LUMINANCE_ALPHA4_SGIS 0x811C +#define GL_DUAL_LUMINANCE_ALPHA8_SGIS 0x811D +#define GL_QUAD_ALPHA4_SGIS 0x811E +#define GL_QUAD_ALPHA8_SGIS 0x811F +#define GL_QUAD_LUMINANCE4_SGIS 0x8120 +#define GL_QUAD_LUMINANCE8_SGIS 0x8121 +#define GL_QUAD_INTENSITY4_SGIS 0x8122 +#define GL_QUAD_INTENSITY8_SGIS 0x8123 +#define GL_DUAL_TEXTURE_SELECT_SGIS 0x8124 +#define GL_QUAD_TEXTURE_SELECT_SGIS 0x8125 +#endif + +#ifndef GL_SGIX_sprite +#define GL_SPRITE_SGIX 0x8148 +#define GL_SPRITE_MODE_SGIX 0x8149 +#define GL_SPRITE_AXIS_SGIX 0x814A +#define GL_SPRITE_TRANSLATION_SGIX 0x814B +#define GL_SPRITE_AXIAL_SGIX 0x814C +#define GL_SPRITE_OBJECT_ALIGNED_SGIX 0x814D +#define GL_SPRITE_EYE_ALIGNED_SGIX 0x814E +#endif + +#ifndef GL_SGIX_texture_multi_buffer +#define GL_TEXTURE_MULTI_BUFFER_HINT_SGIX 0x812E +#endif + +#ifndef GL_EXT_point_parameters +#define GL_POINT_SIZE_MIN_EXT 0x8126 +#define GL_POINT_SIZE_MAX_EXT 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_EXT 0x8128 +#define GL_DISTANCE_ATTENUATION_EXT 0x8129 +#endif + +#ifndef GL_SGIS_point_parameters +#define GL_POINT_SIZE_MIN_SGIS 0x8126 +#define GL_POINT_SIZE_MAX_SGIS 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_SGIS 0x8128 +#define GL_DISTANCE_ATTENUATION_SGIS 0x8129 +#endif + +#ifndef GL_SGIX_instruments +#define GL_INSTRUMENT_BUFFER_POINTER_SGIX 0x8180 +#define GL_INSTRUMENT_MEASUREMENTS_SGIX 0x8181 +#endif + +#ifndef GL_SGIX_texture_scale_bias +#define GL_POST_TEXTURE_FILTER_BIAS_SGIX 0x8179 +#define GL_POST_TEXTURE_FILTER_SCALE_SGIX 0x817A +#define GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX 0x817B +#define GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX 0x817C +#endif + +#ifndef GL_SGIX_framezoom +#define GL_FRAMEZOOM_SGIX 0x818B +#define GL_FRAMEZOOM_FACTOR_SGIX 0x818C +#define GL_MAX_FRAMEZOOM_FACTOR_SGIX 0x818D +#endif + +#ifndef GL_SGIX_tag_sample_buffer +#endif + +#ifndef GL_FfdMaskSGIX +#define GL_TEXTURE_DEFORMATION_BIT_SGIX 0x00000001 +#define GL_GEOMETRY_DEFORMATION_BIT_SGIX 0x00000002 +#endif + +#ifndef GL_SGIX_polynomial_ffd +#define GL_GEOMETRY_DEFORMATION_SGIX 0x8194 +#define GL_TEXTURE_DEFORMATION_SGIX 0x8195 +#define GL_DEFORMATIONS_MASK_SGIX 0x8196 +#define GL_MAX_DEFORMATION_ORDER_SGIX 0x8197 +#endif + +#ifndef GL_SGIX_reference_plane +#define GL_REFERENCE_PLANE_SGIX 0x817D +#define GL_REFERENCE_PLANE_EQUATION_SGIX 0x817E +#endif + +#ifndef GL_SGIX_flush_raster +#endif + +#ifndef GL_SGIX_depth_texture +#define GL_DEPTH_COMPONENT16_SGIX 0x81A5 +#define GL_DEPTH_COMPONENT24_SGIX 0x81A6 +#define GL_DEPTH_COMPONENT32_SGIX 0x81A7 +#endif + +#ifndef GL_SGIS_fog_function +#define GL_FOG_FUNC_SGIS 0x812A +#define GL_FOG_FUNC_POINTS_SGIS 0x812B +#define GL_MAX_FOG_FUNC_POINTS_SGIS 0x812C +#endif + +#ifndef GL_SGIX_fog_offset +#define GL_FOG_OFFSET_SGIX 0x8198 +#define GL_FOG_OFFSET_VALUE_SGIX 0x8199 +#endif + +#ifndef GL_HP_image_transform +#define GL_IMAGE_SCALE_X_HP 0x8155 +#define GL_IMAGE_SCALE_Y_HP 0x8156 +#define GL_IMAGE_TRANSLATE_X_HP 0x8157 +#define GL_IMAGE_TRANSLATE_Y_HP 0x8158 +#define GL_IMAGE_ROTATE_ANGLE_HP 0x8159 +#define GL_IMAGE_ROTATE_ORIGIN_X_HP 0x815A +#define GL_IMAGE_ROTATE_ORIGIN_Y_HP 0x815B +#define GL_IMAGE_MAG_FILTER_HP 0x815C +#define GL_IMAGE_MIN_FILTER_HP 0x815D +#define GL_IMAGE_CUBIC_WEIGHT_HP 0x815E +#define GL_CUBIC_HP 0x815F +#define GL_AVERAGE_HP 0x8160 +#define GL_IMAGE_TRANSFORM_2D_HP 0x8161 +#define GL_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8162 +#define GL_PROXY_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8163 +#endif + +#ifndef GL_HP_convolution_border_modes +#define GL_IGNORE_BORDER_HP 0x8150 +#define GL_CONSTANT_BORDER_HP 0x8151 +#define GL_REPLICATE_BORDER_HP 0x8153 +#define GL_CONVOLUTION_BORDER_COLOR_HP 0x8154 +#endif + +#ifndef GL_INGR_palette_buffer +#endif + +#ifndef GL_SGIX_texture_add_env +#define GL_TEXTURE_ENV_BIAS_SGIX 0x80BE +#endif + +#ifndef GL_EXT_color_subtable +#endif + +#ifndef GL_PGI_vertex_hints +#define GL_VERTEX_DATA_HINT_PGI 0x1A22A +#define GL_VERTEX_CONSISTENT_HINT_PGI 0x1A22B +#define GL_MATERIAL_SIDE_HINT_PGI 0x1A22C +#define GL_MAX_VERTEX_HINT_PGI 0x1A22D +#define GL_COLOR3_BIT_PGI 0x00010000 +#define GL_COLOR4_BIT_PGI 0x00020000 +#define GL_EDGEFLAG_BIT_PGI 0x00040000 +#define GL_INDEX_BIT_PGI 0x00080000 +#define GL_MAT_AMBIENT_BIT_PGI 0x00100000 +#define GL_MAT_AMBIENT_AND_DIFFUSE_BIT_PGI 0x00200000 +#define GL_MAT_DIFFUSE_BIT_PGI 0x00400000 +#define GL_MAT_EMISSION_BIT_PGI 0x00800000 +#define GL_MAT_COLOR_INDEXES_BIT_PGI 0x01000000 +#define GL_MAT_SHININESS_BIT_PGI 0x02000000 +#define GL_MAT_SPECULAR_BIT_PGI 0x04000000 +#define GL_NORMAL_BIT_PGI 0x08000000 +#define GL_TEXCOORD1_BIT_PGI 0x10000000 +#define GL_TEXCOORD2_BIT_PGI 0x20000000 +#define GL_TEXCOORD3_BIT_PGI 0x40000000 +#define GL_TEXCOORD4_BIT_PGI 0x80000000 +#define GL_VERTEX23_BIT_PGI 0x00000004 +#define GL_VERTEX4_BIT_PGI 0x00000008 +#endif + +#ifndef GL_PGI_misc_hints +#define GL_PREFER_DOUBLEBUFFER_HINT_PGI 0x1A1F8 +#define GL_CONSERVE_MEMORY_HINT_PGI 0x1A1FD +#define GL_RECLAIM_MEMORY_HINT_PGI 0x1A1FE +#define GL_NATIVE_GRAPHICS_HANDLE_PGI 0x1A202 +#define GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI 0x1A203 +#define GL_NATIVE_GRAPHICS_END_HINT_PGI 0x1A204 +#define GL_ALWAYS_FAST_HINT_PGI 0x1A20C +#define GL_ALWAYS_SOFT_HINT_PGI 0x1A20D +#define GL_ALLOW_DRAW_OBJ_HINT_PGI 0x1A20E +#define GL_ALLOW_DRAW_WIN_HINT_PGI 0x1A20F +#define GL_ALLOW_DRAW_FRG_HINT_PGI 0x1A210 +#define GL_ALLOW_DRAW_MEM_HINT_PGI 0x1A211 +#define GL_STRICT_DEPTHFUNC_HINT_PGI 0x1A216 +#define GL_STRICT_LIGHTING_HINT_PGI 0x1A217 +#define GL_STRICT_SCISSOR_HINT_PGI 0x1A218 +#define GL_FULL_STIPPLE_HINT_PGI 0x1A219 +#define GL_CLIP_NEAR_HINT_PGI 0x1A220 +#define GL_CLIP_FAR_HINT_PGI 0x1A221 +#define GL_WIDE_LINE_HINT_PGI 0x1A222 +#define GL_BACK_NORMALS_HINT_PGI 0x1A223 +#endif + +#ifndef GL_EXT_paletted_texture +#define GL_COLOR_INDEX1_EXT 0x80E2 +#define GL_COLOR_INDEX2_EXT 0x80E3 +#define GL_COLOR_INDEX4_EXT 0x80E4 +#define GL_COLOR_INDEX8_EXT 0x80E5 +#define GL_COLOR_INDEX12_EXT 0x80E6 +#define GL_COLOR_INDEX16_EXT 0x80E7 +#define GL_TEXTURE_INDEX_SIZE_EXT 0x80ED +#endif + +#ifndef GL_EXT_clip_volume_hint +#define GL_CLIP_VOLUME_CLIPPING_HINT_EXT 0x80F0 +#endif + +#ifndef GL_SGIX_list_priority +#define GL_LIST_PRIORITY_SGIX 0x8182 +#endif + +#ifndef GL_SGIX_ir_instrument1 +#define GL_IR_INSTRUMENT1_SGIX 0x817F +#endif + +#ifndef GL_SGIX_calligraphic_fragment +#define GL_CALLIGRAPHIC_FRAGMENT_SGIX 0x8183 +#endif + +#ifndef GL_SGIX_texture_lod_bias +#define GL_TEXTURE_LOD_BIAS_S_SGIX 0x818E +#define GL_TEXTURE_LOD_BIAS_T_SGIX 0x818F +#define GL_TEXTURE_LOD_BIAS_R_SGIX 0x8190 +#endif + +#ifndef GL_SGIX_shadow_ambient +#define GL_SHADOW_AMBIENT_SGIX 0x80BF +#endif + +#ifndef GL_EXT_index_texture +#endif + +#ifndef GL_EXT_index_material +#define GL_INDEX_MATERIAL_EXT 0x81B8 +#define GL_INDEX_MATERIAL_PARAMETER_EXT 0x81B9 +#define GL_INDEX_MATERIAL_FACE_EXT 0x81BA +#endif + +#ifndef GL_EXT_index_func +#define GL_INDEX_TEST_EXT 0x81B5 +#define GL_INDEX_TEST_FUNC_EXT 0x81B6 +#define GL_INDEX_TEST_REF_EXT 0x81B7 +#endif + +#ifndef GL_EXT_index_array_formats +#define GL_IUI_V2F_EXT 0x81AD +#define GL_IUI_V3F_EXT 0x81AE +#define GL_IUI_N3F_V2F_EXT 0x81AF +#define GL_IUI_N3F_V3F_EXT 0x81B0 +#define GL_T2F_IUI_V2F_EXT 0x81B1 +#define GL_T2F_IUI_V3F_EXT 0x81B2 +#define GL_T2F_IUI_N3F_V2F_EXT 0x81B3 +#define GL_T2F_IUI_N3F_V3F_EXT 0x81B4 +#endif + +#ifndef GL_EXT_compiled_vertex_array +#define GL_ARRAY_ELEMENT_LOCK_FIRST_EXT 0x81A8 +#define GL_ARRAY_ELEMENT_LOCK_COUNT_EXT 0x81A9 +#endif + +#ifndef GL_EXT_cull_vertex +#define GL_CULL_VERTEX_EXT 0x81AA +#define GL_CULL_VERTEX_EYE_POSITION_EXT 0x81AB +#define GL_CULL_VERTEX_OBJECT_POSITION_EXT 0x81AC +#endif + +#ifndef GL_SGIX_ycrcb +#define GL_YCRCB_422_SGIX 0x81BB +#define GL_YCRCB_444_SGIX 0x81BC +#endif + +#ifndef GL_SGIX_fragment_lighting +#define GL_FRAGMENT_LIGHTING_SGIX 0x8400 +#define GL_FRAGMENT_COLOR_MATERIAL_SGIX 0x8401 +#define GL_FRAGMENT_COLOR_MATERIAL_FACE_SGIX 0x8402 +#define GL_FRAGMENT_COLOR_MATERIAL_PARAMETER_SGIX 0x8403 +#define GL_MAX_FRAGMENT_LIGHTS_SGIX 0x8404 +#define GL_MAX_ACTIVE_LIGHTS_SGIX 0x8405 +#define GL_CURRENT_RASTER_NORMAL_SGIX 0x8406 +#define GL_LIGHT_ENV_MODE_SGIX 0x8407 +#define GL_FRAGMENT_LIGHT_MODEL_LOCAL_VIEWER_SGIX 0x8408 +#define GL_FRAGMENT_LIGHT_MODEL_TWO_SIDE_SGIX 0x8409 +#define GL_FRAGMENT_LIGHT_MODEL_AMBIENT_SGIX 0x840A +#define GL_FRAGMENT_LIGHT_MODEL_NORMAL_INTERPOLATION_SGIX 0x840B +#define GL_FRAGMENT_LIGHT0_SGIX 0x840C +#define GL_FRAGMENT_LIGHT1_SGIX 0x840D +#define GL_FRAGMENT_LIGHT2_SGIX 0x840E +#define GL_FRAGMENT_LIGHT3_SGIX 0x840F +#define GL_FRAGMENT_LIGHT4_SGIX 0x8410 +#define GL_FRAGMENT_LIGHT5_SGIX 0x8411 +#define GL_FRAGMENT_LIGHT6_SGIX 0x8412 +#define GL_FRAGMENT_LIGHT7_SGIX 0x8413 +#endif + +#ifndef GL_IBM_rasterpos_clip +#define GL_RASTER_POSITION_UNCLIPPED_IBM 0x19262 +#endif + +#ifndef GL_HP_texture_lighting +#define GL_TEXTURE_LIGHTING_MODE_HP 0x8167 +#define GL_TEXTURE_POST_SPECULAR_HP 0x8168 +#define GL_TEXTURE_PRE_SPECULAR_HP 0x8169 +#endif + +#ifndef GL_EXT_draw_range_elements +#define GL_MAX_ELEMENTS_VERTICES_EXT 0x80E8 +#define GL_MAX_ELEMENTS_INDICES_EXT 0x80E9 +#endif + +#ifndef GL_WIN_phong_shading +#define GL_PHONG_WIN 0x80EA +#define GL_PHONG_HINT_WIN 0x80EB +#endif + +#ifndef GL_WIN_specular_fog +#define GL_FOG_SPECULAR_TEXTURE_WIN 0x80EC +#endif + +#ifndef GL_EXT_light_texture +#define GL_FRAGMENT_MATERIAL_EXT 0x8349 +#define GL_FRAGMENT_NORMAL_EXT 0x834A +#define GL_FRAGMENT_COLOR_EXT 0x834C +#define GL_ATTENUATION_EXT 0x834D +#define GL_SHADOW_ATTENUATION_EXT 0x834E +#define GL_TEXTURE_APPLICATION_MODE_EXT 0x834F +#define GL_TEXTURE_LIGHT_EXT 0x8350 +#define GL_TEXTURE_MATERIAL_FACE_EXT 0x8351 +#define GL_TEXTURE_MATERIAL_PARAMETER_EXT 0x8352 +/* reuse GL_FRAGMENT_DEPTH_EXT */ +#endif + +#ifndef GL_SGIX_blend_alpha_minmax +#define GL_ALPHA_MIN_SGIX 0x8320 +#define GL_ALPHA_MAX_SGIX 0x8321 +#endif + +#ifndef GL_SGIX_impact_pixel_texture +#define GL_PIXEL_TEX_GEN_Q_CEILING_SGIX 0x8184 +#define GL_PIXEL_TEX_GEN_Q_ROUND_SGIX 0x8185 +#define GL_PIXEL_TEX_GEN_Q_FLOOR_SGIX 0x8186 +#define GL_PIXEL_TEX_GEN_ALPHA_REPLACE_SGIX 0x8187 +#define GL_PIXEL_TEX_GEN_ALPHA_NO_REPLACE_SGIX 0x8188 +#define GL_PIXEL_TEX_GEN_ALPHA_LS_SGIX 0x8189 +#define GL_PIXEL_TEX_GEN_ALPHA_MS_SGIX 0x818A +#endif + +#ifndef GL_EXT_bgra +#define GL_BGR_EXT 0x80E0 +#define GL_BGRA_EXT 0x80E1 +#endif + +#ifndef GL_SGIX_async +#define GL_ASYNC_MARKER_SGIX 0x8329 +#endif + +#ifndef GL_SGIX_async_pixel +#define GL_ASYNC_TEX_IMAGE_SGIX 0x835C +#define GL_ASYNC_DRAW_PIXELS_SGIX 0x835D +#define GL_ASYNC_READ_PIXELS_SGIX 0x835E +#define GL_MAX_ASYNC_TEX_IMAGE_SGIX 0x835F +#define GL_MAX_ASYNC_DRAW_PIXELS_SGIX 0x8360 +#define GL_MAX_ASYNC_READ_PIXELS_SGIX 0x8361 +#endif + +#ifndef GL_SGIX_async_histogram +#define GL_ASYNC_HISTOGRAM_SGIX 0x832C +#define GL_MAX_ASYNC_HISTOGRAM_SGIX 0x832D +#endif + +#ifndef GL_INTEL_texture_scissor +#endif + +#ifndef GL_INTEL_parallel_arrays +#define GL_PARALLEL_ARRAYS_INTEL 0x83F4 +#define GL_VERTEX_ARRAY_PARALLEL_POINTERS_INTEL 0x83F5 +#define GL_NORMAL_ARRAY_PARALLEL_POINTERS_INTEL 0x83F6 +#define GL_COLOR_ARRAY_PARALLEL_POINTERS_INTEL 0x83F7 +#define GL_TEXTURE_COORD_ARRAY_PARALLEL_POINTERS_INTEL 0x83F8 +#endif + +#ifndef GL_HP_occlusion_test +#define GL_OCCLUSION_TEST_HP 0x8165 +#define GL_OCCLUSION_TEST_RESULT_HP 0x8166 +#endif + +#ifndef GL_EXT_pixel_transform +#define GL_PIXEL_TRANSFORM_2D_EXT 0x8330 +#define GL_PIXEL_MAG_FILTER_EXT 0x8331 +#define GL_PIXEL_MIN_FILTER_EXT 0x8332 +#define GL_PIXEL_CUBIC_WEIGHT_EXT 0x8333 +#define GL_CUBIC_EXT 0x8334 +#define GL_AVERAGE_EXT 0x8335 +#define GL_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8336 +#define GL_MAX_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8337 +#define GL_PIXEL_TRANSFORM_2D_MATRIX_EXT 0x8338 +#endif + +#ifndef GL_EXT_pixel_transform_color_table +#endif + +#ifndef GL_EXT_shared_texture_palette +#define GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB +#endif + +#ifndef GL_EXT_separate_specular_color +#define GL_LIGHT_MODEL_COLOR_CONTROL_EXT 0x81F8 +#define GL_SINGLE_COLOR_EXT 0x81F9 +#define GL_SEPARATE_SPECULAR_COLOR_EXT 0x81FA +#endif + +#ifndef GL_EXT_secondary_color +#define GL_COLOR_SUM_EXT 0x8458 +#define GL_CURRENT_SECONDARY_COLOR_EXT 0x8459 +#define GL_SECONDARY_COLOR_ARRAY_SIZE_EXT 0x845A +#define GL_SECONDARY_COLOR_ARRAY_TYPE_EXT 0x845B +#define GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT 0x845C +#define GL_SECONDARY_COLOR_ARRAY_POINTER_EXT 0x845D +#define GL_SECONDARY_COLOR_ARRAY_EXT 0x845E +#endif + +#ifndef GL_EXT_texture_perturb_normal +#define GL_PERTURB_EXT 0x85AE +#define GL_TEXTURE_NORMAL_EXT 0x85AF +#endif + +#ifndef GL_EXT_multi_draw_arrays +#endif + +#ifndef GL_EXT_fog_coord +#define GL_FOG_COORDINATE_SOURCE_EXT 0x8450 +#define GL_FOG_COORDINATE_EXT 0x8451 +#define GL_FRAGMENT_DEPTH_EXT 0x8452 +#define GL_CURRENT_FOG_COORDINATE_EXT 0x8453 +#define GL_FOG_COORDINATE_ARRAY_TYPE_EXT 0x8454 +#define GL_FOG_COORDINATE_ARRAY_STRIDE_EXT 0x8455 +#define GL_FOG_COORDINATE_ARRAY_POINTER_EXT 0x8456 +#define GL_FOG_COORDINATE_ARRAY_EXT 0x8457 +#endif + +#ifndef GL_REND_screen_coordinates +#define GL_SCREEN_COORDINATES_REND 0x8490 +#define GL_INVERTED_SCREEN_W_REND 0x8491 +#endif + +#ifndef GL_EXT_coordinate_frame +#define GL_TANGENT_ARRAY_EXT 0x8439 +#define GL_BINORMAL_ARRAY_EXT 0x843A +#define GL_CURRENT_TANGENT_EXT 0x843B +#define GL_CURRENT_BINORMAL_EXT 0x843C +#define GL_TANGENT_ARRAY_TYPE_EXT 0x843E +#define GL_TANGENT_ARRAY_STRIDE_EXT 0x843F +#define GL_BINORMAL_ARRAY_TYPE_EXT 0x8440 +#define GL_BINORMAL_ARRAY_STRIDE_EXT 0x8441 +#define GL_TANGENT_ARRAY_POINTER_EXT 0x8442 +#define GL_BINORMAL_ARRAY_POINTER_EXT 0x8443 +#define GL_MAP1_TANGENT_EXT 0x8444 +#define GL_MAP2_TANGENT_EXT 0x8445 +#define GL_MAP1_BINORMAL_EXT 0x8446 +#define GL_MAP2_BINORMAL_EXT 0x8447 +#endif + +#ifndef GL_EXT_texture_env_combine +#define GL_COMBINE_EXT 0x8570 +#define GL_COMBINE_RGB_EXT 0x8571 +#define GL_COMBINE_ALPHA_EXT 0x8572 +#define GL_RGB_SCALE_EXT 0x8573 +#define GL_ADD_SIGNED_EXT 0x8574 +#define GL_INTERPOLATE_EXT 0x8575 +#define GL_CONSTANT_EXT 0x8576 +#define GL_PRIMARY_COLOR_EXT 0x8577 +#define GL_PREVIOUS_EXT 0x8578 +#define GL_SOURCE0_RGB_EXT 0x8580 +#define GL_SOURCE1_RGB_EXT 0x8581 +#define GL_SOURCE2_RGB_EXT 0x8582 +#define GL_SOURCE0_ALPHA_EXT 0x8588 +#define GL_SOURCE1_ALPHA_EXT 0x8589 +#define GL_SOURCE2_ALPHA_EXT 0x858A +#define GL_OPERAND0_RGB_EXT 0x8590 +#define GL_OPERAND1_RGB_EXT 0x8591 +#define GL_OPERAND2_RGB_EXT 0x8592 +#define GL_OPERAND0_ALPHA_EXT 0x8598 +#define GL_OPERAND1_ALPHA_EXT 0x8599 +#define GL_OPERAND2_ALPHA_EXT 0x859A +#endif + +#ifndef GL_APPLE_specular_vector +#define GL_LIGHT_MODEL_SPECULAR_VECTOR_APPLE 0x85B0 +#endif + +#ifndef GL_APPLE_transform_hint +#define GL_TRANSFORM_HINT_APPLE 0x85B1 +#endif + +#ifndef GL_SGIX_fog_scale +#define GL_FOG_SCALE_SGIX 0x81FC +#define GL_FOG_SCALE_VALUE_SGIX 0x81FD +#endif + +#ifndef GL_SUNX_constant_data +#define GL_UNPACK_CONSTANT_DATA_SUNX 0x81D5 +#define GL_TEXTURE_CONSTANT_DATA_SUNX 0x81D6 +#endif + +#ifndef GL_SUN_global_alpha +#define GL_GLOBAL_ALPHA_SUN 0x81D9 +#define GL_GLOBAL_ALPHA_FACTOR_SUN 0x81DA +#endif + +#ifndef GL_SUN_triangle_list +#define GL_RESTART_SUN 0x0001 +#define GL_REPLACE_MIDDLE_SUN 0x0002 +#define GL_REPLACE_OLDEST_SUN 0x0003 +#define GL_TRIANGLE_LIST_SUN 0x81D7 +#define GL_REPLACEMENT_CODE_SUN 0x81D8 +#define GL_REPLACEMENT_CODE_ARRAY_SUN 0x85C0 +#define GL_REPLACEMENT_CODE_ARRAY_TYPE_SUN 0x85C1 +#define GL_REPLACEMENT_CODE_ARRAY_STRIDE_SUN 0x85C2 +#define GL_REPLACEMENT_CODE_ARRAY_POINTER_SUN 0x85C3 +#define GL_R1UI_V3F_SUN 0x85C4 +#define GL_R1UI_C4UB_V3F_SUN 0x85C5 +#define GL_R1UI_C3F_V3F_SUN 0x85C6 +#define GL_R1UI_N3F_V3F_SUN 0x85C7 +#define GL_R1UI_C4F_N3F_V3F_SUN 0x85C8 +#define GL_R1UI_T2F_V3F_SUN 0x85C9 +#define GL_R1UI_T2F_N3F_V3F_SUN 0x85CA +#define GL_R1UI_T2F_C4F_N3F_V3F_SUN 0x85CB +#endif + +#ifndef GL_SUN_vertex +#endif + +#ifndef GL_EXT_blend_func_separate +#define GL_BLEND_DST_RGB_EXT 0x80C8 +#define GL_BLEND_SRC_RGB_EXT 0x80C9 +#define GL_BLEND_DST_ALPHA_EXT 0x80CA +#define GL_BLEND_SRC_ALPHA_EXT 0x80CB +#endif + +#ifndef GL_INGR_color_clamp +#define GL_RED_MIN_CLAMP_INGR 0x8560 +#define GL_GREEN_MIN_CLAMP_INGR 0x8561 +#define GL_BLUE_MIN_CLAMP_INGR 0x8562 +#define GL_ALPHA_MIN_CLAMP_INGR 0x8563 +#define GL_RED_MAX_CLAMP_INGR 0x8564 +#define GL_GREEN_MAX_CLAMP_INGR 0x8565 +#define GL_BLUE_MAX_CLAMP_INGR 0x8566 +#define GL_ALPHA_MAX_CLAMP_INGR 0x8567 +#endif + +#ifndef GL_INGR_interlace_read +#define GL_INTERLACE_READ_INGR 0x8568 +#endif + +#ifndef GL_EXT_stencil_wrap +#define GL_INCR_WRAP_EXT 0x8507 +#define GL_DECR_WRAP_EXT 0x8508 +#endif + +#ifndef GL_EXT_422_pixels +#define GL_422_EXT 0x80CC +#define GL_422_REV_EXT 0x80CD +#define GL_422_AVERAGE_EXT 0x80CE +#define GL_422_REV_AVERAGE_EXT 0x80CF +#endif + +#ifndef GL_NV_texgen_reflection +#define GL_NORMAL_MAP_NV 0x8511 +#define GL_REFLECTION_MAP_NV 0x8512 +#endif + +#ifndef GL_EXT_texture_cube_map +#define GL_NORMAL_MAP_EXT 0x8511 +#define GL_REFLECTION_MAP_EXT 0x8512 +#define GL_TEXTURE_CUBE_MAP_EXT 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP_EXT 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP_EXT 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_EXT 0x851C +#endif + +#ifndef GL_SUN_convolution_border_modes +#define GL_WRAP_BORDER_SUN 0x81D4 +#endif + +#ifndef GL_EXT_texture_env_add +#endif + +#ifndef GL_EXT_texture_lod_bias +#define GL_MAX_TEXTURE_LOD_BIAS_EXT 0x84FD +#define GL_TEXTURE_FILTER_CONTROL_EXT 0x8500 +#define GL_TEXTURE_LOD_BIAS_EXT 0x8501 +#endif + +#ifndef GL_EXT_texture_filter_anisotropic +#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE +#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF +#endif + +#ifndef GL_EXT_vertex_weighting +#define GL_MODELVIEW0_STACK_DEPTH_EXT GL_MODELVIEW_STACK_DEPTH +#define GL_MODELVIEW1_STACK_DEPTH_EXT 0x8502 +#define GL_MODELVIEW0_MATRIX_EXT GL_MODELVIEW_MATRIX +#define GL_MODELVIEW1_MATRIX_EXT 0x8506 +#define GL_VERTEX_WEIGHTING_EXT 0x8509 +#define GL_MODELVIEW0_EXT GL_MODELVIEW +#define GL_MODELVIEW1_EXT 0x850A +#define GL_CURRENT_VERTEX_WEIGHT_EXT 0x850B +#define GL_VERTEX_WEIGHT_ARRAY_EXT 0x850C +#define GL_VERTEX_WEIGHT_ARRAY_SIZE_EXT 0x850D +#define GL_VERTEX_WEIGHT_ARRAY_TYPE_EXT 0x850E +#define GL_VERTEX_WEIGHT_ARRAY_STRIDE_EXT 0x850F +#define GL_VERTEX_WEIGHT_ARRAY_POINTER_EXT 0x8510 +#endif + +#ifndef GL_NV_light_max_exponent +#define GL_MAX_SHININESS_NV 0x8504 +#define GL_MAX_SPOT_EXPONENT_NV 0x8505 +#endif + +#ifndef GL_NV_vertex_array_range +#define GL_VERTEX_ARRAY_RANGE_NV 0x851D +#define GL_VERTEX_ARRAY_RANGE_LENGTH_NV 0x851E +#define GL_VERTEX_ARRAY_RANGE_VALID_NV 0x851F +#define GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_NV 0x8520 +#define GL_VERTEX_ARRAY_RANGE_POINTER_NV 0x8521 +#endif + +#ifndef GL_NV_register_combiners +#define GL_REGISTER_COMBINERS_NV 0x8522 +#define GL_VARIABLE_A_NV 0x8523 +#define GL_VARIABLE_B_NV 0x8524 +#define GL_VARIABLE_C_NV 0x8525 +#define GL_VARIABLE_D_NV 0x8526 +#define GL_VARIABLE_E_NV 0x8527 +#define GL_VARIABLE_F_NV 0x8528 +#define GL_VARIABLE_G_NV 0x8529 +#define GL_CONSTANT_COLOR0_NV 0x852A +#define GL_CONSTANT_COLOR1_NV 0x852B +#define GL_PRIMARY_COLOR_NV 0x852C +#define GL_SECONDARY_COLOR_NV 0x852D +#define GL_SPARE0_NV 0x852E +#define GL_SPARE1_NV 0x852F +#define GL_DISCARD_NV 0x8530 +#define GL_E_TIMES_F_NV 0x8531 +#define GL_SPARE0_PLUS_SECONDARY_COLOR_NV 0x8532 +#define GL_UNSIGNED_IDENTITY_NV 0x8536 +#define GL_UNSIGNED_INVERT_NV 0x8537 +#define GL_EXPAND_NORMAL_NV 0x8538 +#define GL_EXPAND_NEGATE_NV 0x8539 +#define GL_HALF_BIAS_NORMAL_NV 0x853A +#define GL_HALF_BIAS_NEGATE_NV 0x853B +#define GL_SIGNED_IDENTITY_NV 0x853C +#define GL_SIGNED_NEGATE_NV 0x853D +#define GL_SCALE_BY_TWO_NV 0x853E +#define GL_SCALE_BY_FOUR_NV 0x853F +#define GL_SCALE_BY_ONE_HALF_NV 0x8540 +#define GL_BIAS_BY_NEGATIVE_ONE_HALF_NV 0x8541 +#define GL_COMBINER_INPUT_NV 0x8542 +#define GL_COMBINER_MAPPING_NV 0x8543 +#define GL_COMBINER_COMPONENT_USAGE_NV 0x8544 +#define GL_COMBINER_AB_DOT_PRODUCT_NV 0x8545 +#define GL_COMBINER_CD_DOT_PRODUCT_NV 0x8546 +#define GL_COMBINER_MUX_SUM_NV 0x8547 +#define GL_COMBINER_SCALE_NV 0x8548 +#define GL_COMBINER_BIAS_NV 0x8549 +#define GL_COMBINER_AB_OUTPUT_NV 0x854A +#define GL_COMBINER_CD_OUTPUT_NV 0x854B +#define GL_COMBINER_SUM_OUTPUT_NV 0x854C +#define GL_MAX_GENERAL_COMBINERS_NV 0x854D +#define GL_NUM_GENERAL_COMBINERS_NV 0x854E +#define GL_COLOR_SUM_CLAMP_NV 0x854F +#define GL_COMBINER0_NV 0x8550 +#define GL_COMBINER1_NV 0x8551 +#define GL_COMBINER2_NV 0x8552 +#define GL_COMBINER3_NV 0x8553 +#define GL_COMBINER4_NV 0x8554 +#define GL_COMBINER5_NV 0x8555 +#define GL_COMBINER6_NV 0x8556 +#define GL_COMBINER7_NV 0x8557 +/* reuse GL_TEXTURE0_ARB */ +/* reuse GL_TEXTURE1_ARB */ +/* reuse GL_ZERO */ +/* reuse GL_NONE */ +/* reuse GL_FOG */ +#endif + +#ifndef GL_NV_fog_distance +#define GL_FOG_DISTANCE_MODE_NV 0x855A +#define GL_EYE_RADIAL_NV 0x855B +#define GL_EYE_PLANE_ABSOLUTE_NV 0x855C +/* reuse GL_EYE_PLANE */ +#endif + +#ifndef GL_NV_texgen_emboss +#define GL_EMBOSS_LIGHT_NV 0x855D +#define GL_EMBOSS_CONSTANT_NV 0x855E +#define GL_EMBOSS_MAP_NV 0x855F +#endif + +#ifndef GL_NV_blend_square +#endif + +#ifndef GL_NV_texture_env_combine4 +#define GL_COMBINE4_NV 0x8503 +#define GL_SOURCE3_RGB_NV 0x8583 +#define GL_SOURCE3_ALPHA_NV 0x858B +#define GL_OPERAND3_RGB_NV 0x8593 +#define GL_OPERAND3_ALPHA_NV 0x859B +#endif + +#ifndef GL_MESA_resize_buffers +#endif + +#ifndef GL_MESA_window_pos +#endif + +#ifndef GL_EXT_texture_compression_s3tc +#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 +#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 +#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 +#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 +#endif + +#ifndef GL_IBM_cull_vertex +#define GL_CULL_VERTEX_IBM 103050 +#endif + +#ifndef GL_IBM_multimode_draw_arrays +#endif + +#ifndef GL_IBM_vertex_array_lists +#define GL_VERTEX_ARRAY_LIST_IBM 103070 +#define GL_NORMAL_ARRAY_LIST_IBM 103071 +#define GL_COLOR_ARRAY_LIST_IBM 103072 +#define GL_INDEX_ARRAY_LIST_IBM 103073 +#define GL_TEXTURE_COORD_ARRAY_LIST_IBM 103074 +#define GL_EDGE_FLAG_ARRAY_LIST_IBM 103075 +#define GL_FOG_COORDINATE_ARRAY_LIST_IBM 103076 +#define GL_SECONDARY_COLOR_ARRAY_LIST_IBM 103077 +#define GL_VERTEX_ARRAY_LIST_STRIDE_IBM 103080 +#define GL_NORMAL_ARRAY_LIST_STRIDE_IBM 103081 +#define GL_COLOR_ARRAY_LIST_STRIDE_IBM 103082 +#define GL_INDEX_ARRAY_LIST_STRIDE_IBM 103083 +#define GL_TEXTURE_COORD_ARRAY_LIST_STRIDE_IBM 103084 +#define GL_EDGE_FLAG_ARRAY_LIST_STRIDE_IBM 103085 +#define GL_FOG_COORDINATE_ARRAY_LIST_STRIDE_IBM 103086 +#define GL_SECONDARY_COLOR_ARRAY_LIST_STRIDE_IBM 103087 +#endif + +#ifndef GL_SGIX_subsample +#define GL_PACK_SUBSAMPLE_RATE_SGIX 0x85A0 +#define GL_UNPACK_SUBSAMPLE_RATE_SGIX 0x85A1 +#define GL_PIXEL_SUBSAMPLE_4444_SGIX 0x85A2 +#define GL_PIXEL_SUBSAMPLE_2424_SGIX 0x85A3 +#define GL_PIXEL_SUBSAMPLE_4242_SGIX 0x85A4 +#endif + +#ifndef GL_SGIX_ycrcb_subsample +#endif + +#ifndef GL_SGIX_ycrcba +#define GL_YCRCB_SGIX 0x8318 +#define GL_YCRCBA_SGIX 0x8319 +#endif + +#ifndef GL_SGI_depth_pass_instrument +#define GL_DEPTH_PASS_INSTRUMENT_SGIX 0x8310 +#define GL_DEPTH_PASS_INSTRUMENT_COUNTERS_SGIX 0x8311 +#define GL_DEPTH_PASS_INSTRUMENT_MAX_SGIX 0x8312 +#endif + +#ifndef GL_3DFX_texture_compression_FXT1 +#define GL_COMPRESSED_RGB_FXT1_3DFX 0x86B0 +#define GL_COMPRESSED_RGBA_FXT1_3DFX 0x86B1 +#endif + +#ifndef GL_3DFX_multisample +#define GL_MULTISAMPLE_3DFX 0x86B2 +#define GL_SAMPLE_BUFFERS_3DFX 0x86B3 +#define GL_SAMPLES_3DFX 0x86B4 +#define GL_MULTISAMPLE_BIT_3DFX 0x20000000 +#endif + +#ifndef GL_3DFX_tbuffer +#endif + +#ifndef GL_EXT_multisample +#define GL_MULTISAMPLE_EXT 0x809D +#define GL_SAMPLE_ALPHA_TO_MASK_EXT 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_EXT 0x809F +#define GL_SAMPLE_MASK_EXT 0x80A0 +#define GL_1PASS_EXT 0x80A1 +#define GL_2PASS_0_EXT 0x80A2 +#define GL_2PASS_1_EXT 0x80A3 +#define GL_4PASS_0_EXT 0x80A4 +#define GL_4PASS_1_EXT 0x80A5 +#define GL_4PASS_2_EXT 0x80A6 +#define GL_4PASS_3_EXT 0x80A7 +#define GL_SAMPLE_BUFFERS_EXT 0x80A8 +#define GL_SAMPLES_EXT 0x80A9 +#define GL_SAMPLE_MASK_VALUE_EXT 0x80AA +#define GL_SAMPLE_MASK_INVERT_EXT 0x80AB +#define GL_SAMPLE_PATTERN_EXT 0x80AC +#define GL_MULTISAMPLE_BIT_EXT 0x20000000 +#endif + +#ifndef GL_SGIX_vertex_preclip +#define GL_VERTEX_PRECLIP_SGIX 0x83EE +#define GL_VERTEX_PRECLIP_HINT_SGIX 0x83EF +#endif + +#ifndef GL_SGIX_convolution_accuracy +#define GL_CONVOLUTION_HINT_SGIX 0x8316 +#endif + +#ifndef GL_SGIX_resample +#define GL_PACK_RESAMPLE_SGIX 0x842C +#define GL_UNPACK_RESAMPLE_SGIX 0x842D +#define GL_RESAMPLE_REPLICATE_SGIX 0x842E +#define GL_RESAMPLE_ZERO_FILL_SGIX 0x842F +#define GL_RESAMPLE_DECIMATE_SGIX 0x8430 +#endif + +#ifndef GL_SGIS_point_line_texgen +#define GL_EYE_DISTANCE_TO_POINT_SGIS 0x81F0 +#define GL_OBJECT_DISTANCE_TO_POINT_SGIS 0x81F1 +#define GL_EYE_DISTANCE_TO_LINE_SGIS 0x81F2 +#define GL_OBJECT_DISTANCE_TO_LINE_SGIS 0x81F3 +#define GL_EYE_POINT_SGIS 0x81F4 +#define GL_OBJECT_POINT_SGIS 0x81F5 +#define GL_EYE_LINE_SGIS 0x81F6 +#define GL_OBJECT_LINE_SGIS 0x81F7 +#endif + +#ifndef GL_SGIS_texture_color_mask +#define GL_TEXTURE_COLOR_WRITEMASK_SGIS 0x81EF +#endif + +#ifndef GL_EXT_texture_env_dot3 +#define GL_DOT3_RGB_EXT 0x8740 +#define GL_DOT3_RGBA_EXT 0x8741 +#endif + +#ifndef GL_ATI_texture_mirror_once +#define GL_MIRROR_CLAMP_ATI 0x8742 +#define GL_MIRROR_CLAMP_TO_EDGE_ATI 0x8743 +#endif + +#ifndef GL_NV_fence +#define GL_ALL_COMPLETED_NV 0x84F2 +#define GL_FENCE_STATUS_NV 0x84F3 +#define GL_FENCE_CONDITION_NV 0x84F4 +#endif + +#ifndef GL_IBM_texture_mirrored_repeat +#define GL_MIRRORED_REPEAT_IBM 0x8370 +#endif + +#ifndef GL_NV_evaluators +#define GL_EVAL_2D_NV 0x86C0 +#define GL_EVAL_TRIANGULAR_2D_NV 0x86C1 +#define GL_MAP_TESSELLATION_NV 0x86C2 +#define GL_MAP_ATTRIB_U_ORDER_NV 0x86C3 +#define GL_MAP_ATTRIB_V_ORDER_NV 0x86C4 +#define GL_EVAL_FRACTIONAL_TESSELLATION_NV 0x86C5 +#define GL_EVAL_VERTEX_ATTRIB0_NV 0x86C6 +#define GL_EVAL_VERTEX_ATTRIB1_NV 0x86C7 +#define GL_EVAL_VERTEX_ATTRIB2_NV 0x86C8 +#define GL_EVAL_VERTEX_ATTRIB3_NV 0x86C9 +#define GL_EVAL_VERTEX_ATTRIB4_NV 0x86CA +#define GL_EVAL_VERTEX_ATTRIB5_NV 0x86CB +#define GL_EVAL_VERTEX_ATTRIB6_NV 0x86CC +#define GL_EVAL_VERTEX_ATTRIB7_NV 0x86CD +#define GL_EVAL_VERTEX_ATTRIB8_NV 0x86CE +#define GL_EVAL_VERTEX_ATTRIB9_NV 0x86CF +#define GL_EVAL_VERTEX_ATTRIB10_NV 0x86D0 +#define GL_EVAL_VERTEX_ATTRIB11_NV 0x86D1 +#define GL_EVAL_VERTEX_ATTRIB12_NV 0x86D2 +#define GL_EVAL_VERTEX_ATTRIB13_NV 0x86D3 +#define GL_EVAL_VERTEX_ATTRIB14_NV 0x86D4 +#define GL_EVAL_VERTEX_ATTRIB15_NV 0x86D5 +#define GL_MAX_MAP_TESSELLATION_NV 0x86D6 +#define GL_MAX_RATIONAL_EVAL_ORDER_NV 0x86D7 +#endif + +#ifndef GL_NV_packed_depth_stencil +#define GL_DEPTH_STENCIL_NV 0x84F9 +#define GL_UNSIGNED_INT_24_8_NV 0x84FA +#endif + +#ifndef GL_NV_register_combiners2 +#define GL_PER_STAGE_CONSTANTS_NV 0x8535 +#endif + +#ifndef GL_NV_texture_compression_vtc +#endif + +#ifndef GL_NV_texture_rectangle +#define GL_TEXTURE_RECTANGLE_NV 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE_NV 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE_NV 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE_NV 0x84F8 +#endif + +#ifndef GL_NV_texture_shader +#define GL_OFFSET_TEXTURE_RECTANGLE_NV 0x864C +#define GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV 0x864D +#define GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV 0x864E +#define GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV 0x86D9 +#define GL_UNSIGNED_INT_S8_S8_8_8_NV 0x86DA +#define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV 0x86DB +#define GL_DSDT_MAG_INTENSITY_NV 0x86DC +#define GL_SHADER_CONSISTENT_NV 0x86DD +#define GL_TEXTURE_SHADER_NV 0x86DE +#define GL_SHADER_OPERATION_NV 0x86DF +#define GL_CULL_MODES_NV 0x86E0 +#define GL_OFFSET_TEXTURE_MATRIX_NV 0x86E1 +#define GL_OFFSET_TEXTURE_SCALE_NV 0x86E2 +#define GL_OFFSET_TEXTURE_BIAS_NV 0x86E3 +#define GL_OFFSET_TEXTURE_2D_MATRIX_NV GL_OFFSET_TEXTURE_MATRIX_NV +#define GL_OFFSET_TEXTURE_2D_SCALE_NV GL_OFFSET_TEXTURE_SCALE_NV +#define GL_OFFSET_TEXTURE_2D_BIAS_NV GL_OFFSET_TEXTURE_BIAS_NV +#define GL_PREVIOUS_TEXTURE_INPUT_NV 0x86E4 +#define GL_CONST_EYE_NV 0x86E5 +#define GL_PASS_THROUGH_NV 0x86E6 +#define GL_CULL_FRAGMENT_NV 0x86E7 +#define GL_OFFSET_TEXTURE_2D_NV 0x86E8 +#define GL_DEPENDENT_AR_TEXTURE_2D_NV 0x86E9 +#define GL_DEPENDENT_GB_TEXTURE_2D_NV 0x86EA +#define GL_DOT_PRODUCT_NV 0x86EC +#define GL_DOT_PRODUCT_DEPTH_REPLACE_NV 0x86ED +#define GL_DOT_PRODUCT_TEXTURE_2D_NV 0x86EE +#define GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV 0x86F0 +#define GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV 0x86F1 +#define GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV 0x86F2 +#define GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV 0x86F3 +#define GL_HILO_NV 0x86F4 +#define GL_DSDT_NV 0x86F5 +#define GL_DSDT_MAG_NV 0x86F6 +#define GL_DSDT_MAG_VIB_NV 0x86F7 +#define GL_HILO16_NV 0x86F8 +#define GL_SIGNED_HILO_NV 0x86F9 +#define GL_SIGNED_HILO16_NV 0x86FA +#define GL_SIGNED_RGBA_NV 0x86FB +#define GL_SIGNED_RGBA8_NV 0x86FC +#define GL_SIGNED_RGB_NV 0x86FE +#define GL_SIGNED_RGB8_NV 0x86FF +#define GL_SIGNED_LUMINANCE_NV 0x8701 +#define GL_SIGNED_LUMINANCE8_NV 0x8702 +#define GL_SIGNED_LUMINANCE_ALPHA_NV 0x8703 +#define GL_SIGNED_LUMINANCE8_ALPHA8_NV 0x8704 +#define GL_SIGNED_ALPHA_NV 0x8705 +#define GL_SIGNED_ALPHA8_NV 0x8706 +#define GL_SIGNED_INTENSITY_NV 0x8707 +#define GL_SIGNED_INTENSITY8_NV 0x8708 +#define GL_DSDT8_NV 0x8709 +#define GL_DSDT8_MAG8_NV 0x870A +#define GL_DSDT8_MAG8_INTENSITY8_NV 0x870B +#define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV 0x870C +#define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D +#define GL_HI_SCALE_NV 0x870E +#define GL_LO_SCALE_NV 0x870F +#define GL_DS_SCALE_NV 0x8710 +#define GL_DT_SCALE_NV 0x8711 +#define GL_MAGNITUDE_SCALE_NV 0x8712 +#define GL_VIBRANCE_SCALE_NV 0x8713 +#define GL_HI_BIAS_NV 0x8714 +#define GL_LO_BIAS_NV 0x8715 +#define GL_DS_BIAS_NV 0x8716 +#define GL_DT_BIAS_NV 0x8717 +#define GL_MAGNITUDE_BIAS_NV 0x8718 +#define GL_VIBRANCE_BIAS_NV 0x8719 +#define GL_TEXTURE_BORDER_VALUES_NV 0x871A +#define GL_TEXTURE_HI_SIZE_NV 0x871B +#define GL_TEXTURE_LO_SIZE_NV 0x871C +#define GL_TEXTURE_DS_SIZE_NV 0x871D +#define GL_TEXTURE_DT_SIZE_NV 0x871E +#define GL_TEXTURE_MAG_SIZE_NV 0x871F +#endif + +#ifndef GL_NV_texture_shader2 +#define GL_DOT_PRODUCT_TEXTURE_3D_NV 0x86EF +#endif + +#ifndef GL_NV_vertex_array_range2 +#define GL_VERTEX_ARRAY_RANGE_WITHOUT_FLUSH_NV 0x8533 +#endif + +#ifndef GL_NV_vertex_program +#define GL_VERTEX_PROGRAM_NV 0x8620 +#define GL_VERTEX_STATE_PROGRAM_NV 0x8621 +#define GL_ATTRIB_ARRAY_SIZE_NV 0x8623 +#define GL_ATTRIB_ARRAY_STRIDE_NV 0x8624 +#define GL_ATTRIB_ARRAY_TYPE_NV 0x8625 +#define GL_CURRENT_ATTRIB_NV 0x8626 +#define GL_PROGRAM_LENGTH_NV 0x8627 +#define GL_PROGRAM_STRING_NV 0x8628 +#define GL_MODELVIEW_PROJECTION_NV 0x8629 +#define GL_IDENTITY_NV 0x862A +#define GL_INVERSE_NV 0x862B +#define GL_TRANSPOSE_NV 0x862C +#define GL_INVERSE_TRANSPOSE_NV 0x862D +#define GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV 0x862E +#define GL_MAX_TRACK_MATRICES_NV 0x862F +#define GL_MATRIX0_NV 0x8630 +#define GL_MATRIX1_NV 0x8631 +#define GL_MATRIX2_NV 0x8632 +#define GL_MATRIX3_NV 0x8633 +#define GL_MATRIX4_NV 0x8634 +#define GL_MATRIX5_NV 0x8635 +#define GL_MATRIX6_NV 0x8636 +#define GL_MATRIX7_NV 0x8637 +#define GL_CURRENT_MATRIX_STACK_DEPTH_NV 0x8640 +#define GL_CURRENT_MATRIX_NV 0x8641 +#define GL_VERTEX_PROGRAM_POINT_SIZE_NV 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE_NV 0x8643 +#define GL_PROGRAM_PARAMETER_NV 0x8644 +#define GL_ATTRIB_ARRAY_POINTER_NV 0x8645 +#define GL_PROGRAM_TARGET_NV 0x8646 +#define GL_PROGRAM_RESIDENT_NV 0x8647 +#define GL_TRACK_MATRIX_NV 0x8648 +#define GL_TRACK_MATRIX_TRANSFORM_NV 0x8649 +#define GL_VERTEX_PROGRAM_BINDING_NV 0x864A +#define GL_PROGRAM_ERROR_POSITION_NV 0x864B +#define GL_VERTEX_ATTRIB_ARRAY0_NV 0x8650 +#define GL_VERTEX_ATTRIB_ARRAY1_NV 0x8651 +#define GL_VERTEX_ATTRIB_ARRAY2_NV 0x8652 +#define GL_VERTEX_ATTRIB_ARRAY3_NV 0x8653 +#define GL_VERTEX_ATTRIB_ARRAY4_NV 0x8654 +#define GL_VERTEX_ATTRIB_ARRAY5_NV 0x8655 +#define GL_VERTEX_ATTRIB_ARRAY6_NV 0x8656 +#define GL_VERTEX_ATTRIB_ARRAY7_NV 0x8657 +#define GL_VERTEX_ATTRIB_ARRAY8_NV 0x8658 +#define GL_VERTEX_ATTRIB_ARRAY9_NV 0x8659 +#define GL_VERTEX_ATTRIB_ARRAY10_NV 0x865A +#define GL_VERTEX_ATTRIB_ARRAY11_NV 0x865B +#define GL_VERTEX_ATTRIB_ARRAY12_NV 0x865C +#define GL_VERTEX_ATTRIB_ARRAY13_NV 0x865D +#define GL_VERTEX_ATTRIB_ARRAY14_NV 0x865E +#define GL_VERTEX_ATTRIB_ARRAY15_NV 0x865F +#define GL_MAP1_VERTEX_ATTRIB0_4_NV 0x8660 +#define GL_MAP1_VERTEX_ATTRIB1_4_NV 0x8661 +#define GL_MAP1_VERTEX_ATTRIB2_4_NV 0x8662 +#define GL_MAP1_VERTEX_ATTRIB3_4_NV 0x8663 +#define GL_MAP1_VERTEX_ATTRIB4_4_NV 0x8664 +#define GL_MAP1_VERTEX_ATTRIB5_4_NV 0x8665 +#define GL_MAP1_VERTEX_ATTRIB6_4_NV 0x8666 +#define GL_MAP1_VERTEX_ATTRIB7_4_NV 0x8667 +#define GL_MAP1_VERTEX_ATTRIB8_4_NV 0x8668 +#define GL_MAP1_VERTEX_ATTRIB9_4_NV 0x8669 +#define GL_MAP1_VERTEX_ATTRIB10_4_NV 0x866A +#define GL_MAP1_VERTEX_ATTRIB11_4_NV 0x866B +#define GL_MAP1_VERTEX_ATTRIB12_4_NV 0x866C +#define GL_MAP1_VERTEX_ATTRIB13_4_NV 0x866D +#define GL_MAP1_VERTEX_ATTRIB14_4_NV 0x866E +#define GL_MAP1_VERTEX_ATTRIB15_4_NV 0x866F +#define GL_MAP2_VERTEX_ATTRIB0_4_NV 0x8670 +#define GL_MAP2_VERTEX_ATTRIB1_4_NV 0x8671 +#define GL_MAP2_VERTEX_ATTRIB2_4_NV 0x8672 +#define GL_MAP2_VERTEX_ATTRIB3_4_NV 0x8673 +#define GL_MAP2_VERTEX_ATTRIB4_4_NV 0x8674 +#define GL_MAP2_VERTEX_ATTRIB5_4_NV 0x8675 +#define GL_MAP2_VERTEX_ATTRIB6_4_NV 0x8676 +#define GL_MAP2_VERTEX_ATTRIB7_4_NV 0x8677 +#define GL_MAP2_VERTEX_ATTRIB8_4_NV 0x8678 +#define GL_MAP2_VERTEX_ATTRIB9_4_NV 0x8679 +#define GL_MAP2_VERTEX_ATTRIB10_4_NV 0x867A +#define GL_MAP2_VERTEX_ATTRIB11_4_NV 0x867B +#define GL_MAP2_VERTEX_ATTRIB12_4_NV 0x867C +#define GL_MAP2_VERTEX_ATTRIB13_4_NV 0x867D +#define GL_MAP2_VERTEX_ATTRIB14_4_NV 0x867E +#define GL_MAP2_VERTEX_ATTRIB15_4_NV 0x867F +#endif + +#ifndef GL_SGIX_texture_coordinate_clamp +#define GL_TEXTURE_MAX_CLAMP_S_SGIX 0x8369 +#define GL_TEXTURE_MAX_CLAMP_T_SGIX 0x836A +#define GL_TEXTURE_MAX_CLAMP_R_SGIX 0x836B +#endif + +#ifndef GL_SGIX_scalebias_hint +#define GL_SCALEBIAS_HINT_SGIX 0x8322 +#endif + +#ifndef GL_OML_interlace +#define GL_INTERLACE_OML 0x8980 +#define GL_INTERLACE_READ_OML 0x8981 +#endif + +#ifndef GL_OML_subsample +#define GL_FORMAT_SUBSAMPLE_24_24_OML 0x8982 +#define GL_FORMAT_SUBSAMPLE_244_244_OML 0x8983 +#endif + +#ifndef GL_OML_resample +#define GL_PACK_RESAMPLE_OML 0x8984 +#define GL_UNPACK_RESAMPLE_OML 0x8985 +#define GL_RESAMPLE_REPLICATE_OML 0x8986 +#define GL_RESAMPLE_ZERO_FILL_OML 0x8987 +#define GL_RESAMPLE_AVERAGE_OML 0x8988 +#define GL_RESAMPLE_DECIMATE_OML 0x8989 +#endif + +#ifndef GL_NV_copy_depth_to_color +#define GL_DEPTH_STENCIL_TO_RGBA_NV 0x886E +#define GL_DEPTH_STENCIL_TO_BGRA_NV 0x886F +#endif + +#ifndef GL_ATI_envmap_bumpmap +#define GL_BUMP_ROT_MATRIX_ATI 0x8775 +#define GL_BUMP_ROT_MATRIX_SIZE_ATI 0x8776 +#define GL_BUMP_NUM_TEX_UNITS_ATI 0x8777 +#define GL_BUMP_TEX_UNITS_ATI 0x8778 +#define GL_DUDV_ATI 0x8779 +#define GL_DU8DV8_ATI 0x877A +#define GL_BUMP_ENVMAP_ATI 0x877B +#define GL_BUMP_TARGET_ATI 0x877C +#endif + +#ifndef GL_ATI_fragment_shader +#define GL_FRAGMENT_SHADER_ATI 0x8920 +#define GL_REG_0_ATI 0x8921 +#define GL_REG_1_ATI 0x8922 +#define GL_REG_2_ATI 0x8923 +#define GL_REG_3_ATI 0x8924 +#define GL_REG_4_ATI 0x8925 +#define GL_REG_5_ATI 0x8926 +#define GL_REG_6_ATI 0x8927 +#define GL_REG_7_ATI 0x8928 +#define GL_REG_8_ATI 0x8929 +#define GL_REG_9_ATI 0x892A +#define GL_REG_10_ATI 0x892B +#define GL_REG_11_ATI 0x892C +#define GL_REG_12_ATI 0x892D +#define GL_REG_13_ATI 0x892E +#define GL_REG_14_ATI 0x892F +#define GL_REG_15_ATI 0x8930 +#define GL_REG_16_ATI 0x8931 +#define GL_REG_17_ATI 0x8932 +#define GL_REG_18_ATI 0x8933 +#define GL_REG_19_ATI 0x8934 +#define GL_REG_20_ATI 0x8935 +#define GL_REG_21_ATI 0x8936 +#define GL_REG_22_ATI 0x8937 +#define GL_REG_23_ATI 0x8938 +#define GL_REG_24_ATI 0x8939 +#define GL_REG_25_ATI 0x893A +#define GL_REG_26_ATI 0x893B +#define GL_REG_27_ATI 0x893C +#define GL_REG_28_ATI 0x893D +#define GL_REG_29_ATI 0x893E +#define GL_REG_30_ATI 0x893F +#define GL_REG_31_ATI 0x8940 +#define GL_CON_0_ATI 0x8941 +#define GL_CON_1_ATI 0x8942 +#define GL_CON_2_ATI 0x8943 +#define GL_CON_3_ATI 0x8944 +#define GL_CON_4_ATI 0x8945 +#define GL_CON_5_ATI 0x8946 +#define GL_CON_6_ATI 0x8947 +#define GL_CON_7_ATI 0x8948 +#define GL_CON_8_ATI 0x8949 +#define GL_CON_9_ATI 0x894A +#define GL_CON_10_ATI 0x894B +#define GL_CON_11_ATI 0x894C +#define GL_CON_12_ATI 0x894D +#define GL_CON_13_ATI 0x894E +#define GL_CON_14_ATI 0x894F +#define GL_CON_15_ATI 0x8950 +#define GL_CON_16_ATI 0x8951 +#define GL_CON_17_ATI 0x8952 +#define GL_CON_18_ATI 0x8953 +#define GL_CON_19_ATI 0x8954 +#define GL_CON_20_ATI 0x8955 +#define GL_CON_21_ATI 0x8956 +#define GL_CON_22_ATI 0x8957 +#define GL_CON_23_ATI 0x8958 +#define GL_CON_24_ATI 0x8959 +#define GL_CON_25_ATI 0x895A +#define GL_CON_26_ATI 0x895B +#define GL_CON_27_ATI 0x895C +#define GL_CON_28_ATI 0x895D +#define GL_CON_29_ATI 0x895E +#define GL_CON_30_ATI 0x895F +#define GL_CON_31_ATI 0x8960 +#define GL_MOV_ATI 0x8961 +#define GL_ADD_ATI 0x8963 +#define GL_MUL_ATI 0x8964 +#define GL_SUB_ATI 0x8965 +#define GL_DOT3_ATI 0x8966 +#define GL_DOT4_ATI 0x8967 +#define GL_MAD_ATI 0x8968 +#define GL_LERP_ATI 0x8969 +#define GL_CND_ATI 0x896A +#define GL_CND0_ATI 0x896B +#define GL_DOT2_ADD_ATI 0x896C +#define GL_SECONDARY_INTERPOLATOR_ATI 0x896D +#define GL_NUM_FRAGMENT_REGISTERS_ATI 0x896E +#define GL_NUM_FRAGMENT_CONSTANTS_ATI 0x896F +#define GL_NUM_PASSES_ATI 0x8970 +#define GL_NUM_INSTRUCTIONS_PER_PASS_ATI 0x8971 +#define GL_NUM_INSTRUCTIONS_TOTAL_ATI 0x8972 +#define GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI 0x8973 +#define GL_NUM_LOOPBACK_COMPONENTS_ATI 0x8974 +#define GL_COLOR_ALPHA_PAIRING_ATI 0x8975 +#define GL_SWIZZLE_STR_ATI 0x8976 +#define GL_SWIZZLE_STQ_ATI 0x8977 +#define GL_SWIZZLE_STR_DR_ATI 0x8978 +#define GL_SWIZZLE_STQ_DQ_ATI 0x8979 +#define GL_SWIZZLE_STRQ_ATI 0x897A +#define GL_SWIZZLE_STRQ_DQ_ATI 0x897B +#define GL_RED_BIT_ATI 0x00000001 +#define GL_GREEN_BIT_ATI 0x00000002 +#define GL_BLUE_BIT_ATI 0x00000004 +#define GL_2X_BIT_ATI 0x00000001 +#define GL_4X_BIT_ATI 0x00000002 +#define GL_8X_BIT_ATI 0x00000004 +#define GL_HALF_BIT_ATI 0x00000008 +#define GL_QUARTER_BIT_ATI 0x00000010 +#define GL_EIGHTH_BIT_ATI 0x00000020 +#define GL_SATURATE_BIT_ATI 0x00000040 +#define GL_COMP_BIT_ATI 0x00000002 +#define GL_NEGATE_BIT_ATI 0x00000004 +#define GL_BIAS_BIT_ATI 0x00000008 +#endif + +#ifndef GL_ATI_pn_triangles +#define GL_PN_TRIANGLES_ATI 0x87F0 +#define GL_MAX_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F1 +#define GL_PN_TRIANGLES_POINT_MODE_ATI 0x87F2 +#define GL_PN_TRIANGLES_NORMAL_MODE_ATI 0x87F3 +#define GL_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F4 +#define GL_PN_TRIANGLES_POINT_MODE_LINEAR_ATI 0x87F5 +#define GL_PN_TRIANGLES_POINT_MODE_CUBIC_ATI 0x87F6 +#define GL_PN_TRIANGLES_NORMAL_MODE_LINEAR_ATI 0x87F7 +#define GL_PN_TRIANGLES_NORMAL_MODE_QUADRATIC_ATI 0x87F8 +#endif + +#ifndef GL_ATI_vertex_array_object +#define GL_STATIC_ATI 0x8760 +#define GL_DYNAMIC_ATI 0x8761 +#define GL_PRESERVE_ATI 0x8762 +#define GL_DISCARD_ATI 0x8763 +#define GL_OBJECT_BUFFER_SIZE_ATI 0x8764 +#define GL_OBJECT_BUFFER_USAGE_ATI 0x8765 +#define GL_ARRAY_OBJECT_BUFFER_ATI 0x8766 +#define GL_ARRAY_OBJECT_OFFSET_ATI 0x8767 +#endif + +#ifndef GL_EXT_vertex_shader +#define GL_VERTEX_SHADER_EXT 0x8780 +#define GL_VERTEX_SHADER_BINDING_EXT 0x8781 +#define GL_OP_INDEX_EXT 0x8782 +#define GL_OP_NEGATE_EXT 0x8783 +#define GL_OP_DOT3_EXT 0x8784 +#define GL_OP_DOT4_EXT 0x8785 +#define GL_OP_MUL_EXT 0x8786 +#define GL_OP_ADD_EXT 0x8787 +#define GL_OP_MADD_EXT 0x8788 +#define GL_OP_FRAC_EXT 0x8789 +#define GL_OP_MAX_EXT 0x878A +#define GL_OP_MIN_EXT 0x878B +#define GL_OP_SET_GE_EXT 0x878C +#define GL_OP_SET_LT_EXT 0x878D +#define GL_OP_CLAMP_EXT 0x878E +#define GL_OP_FLOOR_EXT 0x878F +#define GL_OP_ROUND_EXT 0x8790 +#define GL_OP_EXP_BASE_2_EXT 0x8791 +#define GL_OP_LOG_BASE_2_EXT 0x8792 +#define GL_OP_POWER_EXT 0x8793 +#define GL_OP_RECIP_EXT 0x8794 +#define GL_OP_RECIP_SQRT_EXT 0x8795 +#define GL_OP_SUB_EXT 0x8796 +#define GL_OP_CROSS_PRODUCT_EXT 0x8797 +#define GL_OP_MULTIPLY_MATRIX_EXT 0x8798 +#define GL_OP_MOV_EXT 0x8799 +#define GL_OUTPUT_VERTEX_EXT 0x879A +#define GL_OUTPUT_COLOR0_EXT 0x879B +#define GL_OUTPUT_COLOR1_EXT 0x879C +#define GL_OUTPUT_TEXTURE_COORD0_EXT 0x879D +#define GL_OUTPUT_TEXTURE_COORD1_EXT 0x879E +#define GL_OUTPUT_TEXTURE_COORD2_EXT 0x879F +#define GL_OUTPUT_TEXTURE_COORD3_EXT 0x87A0 +#define GL_OUTPUT_TEXTURE_COORD4_EXT 0x87A1 +#define GL_OUTPUT_TEXTURE_COORD5_EXT 0x87A2 +#define GL_OUTPUT_TEXTURE_COORD6_EXT 0x87A3 +#define GL_OUTPUT_TEXTURE_COORD7_EXT 0x87A4 +#define GL_OUTPUT_TEXTURE_COORD8_EXT 0x87A5 +#define GL_OUTPUT_TEXTURE_COORD9_EXT 0x87A6 +#define GL_OUTPUT_TEXTURE_COORD10_EXT 0x87A7 +#define GL_OUTPUT_TEXTURE_COORD11_EXT 0x87A8 +#define GL_OUTPUT_TEXTURE_COORD12_EXT 0x87A9 +#define GL_OUTPUT_TEXTURE_COORD13_EXT 0x87AA +#define GL_OUTPUT_TEXTURE_COORD14_EXT 0x87AB +#define GL_OUTPUT_TEXTURE_COORD15_EXT 0x87AC +#define GL_OUTPUT_TEXTURE_COORD16_EXT 0x87AD +#define GL_OUTPUT_TEXTURE_COORD17_EXT 0x87AE +#define GL_OUTPUT_TEXTURE_COORD18_EXT 0x87AF +#define GL_OUTPUT_TEXTURE_COORD19_EXT 0x87B0 +#define GL_OUTPUT_TEXTURE_COORD20_EXT 0x87B1 +#define GL_OUTPUT_TEXTURE_COORD21_EXT 0x87B2 +#define GL_OUTPUT_TEXTURE_COORD22_EXT 0x87B3 +#define GL_OUTPUT_TEXTURE_COORD23_EXT 0x87B4 +#define GL_OUTPUT_TEXTURE_COORD24_EXT 0x87B5 +#define GL_OUTPUT_TEXTURE_COORD25_EXT 0x87B6 +#define GL_OUTPUT_TEXTURE_COORD26_EXT 0x87B7 +#define GL_OUTPUT_TEXTURE_COORD27_EXT 0x87B8 +#define GL_OUTPUT_TEXTURE_COORD28_EXT 0x87B9 +#define GL_OUTPUT_TEXTURE_COORD29_EXT 0x87BA +#define GL_OUTPUT_TEXTURE_COORD30_EXT 0x87BB +#define GL_OUTPUT_TEXTURE_COORD31_EXT 0x87BC +#define GL_OUTPUT_FOG_EXT 0x87BD +#define GL_SCALAR_EXT 0x87BE +#define GL_VECTOR_EXT 0x87BF +#define GL_MATRIX_EXT 0x87C0 +#define GL_VARIANT_EXT 0x87C1 +#define GL_INVARIANT_EXT 0x87C2 +#define GL_LOCAL_CONSTANT_EXT 0x87C3 +#define GL_LOCAL_EXT 0x87C4 +#define GL_MAX_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87C5 +#define GL_MAX_VERTEX_SHADER_VARIANTS_EXT 0x87C6 +#define GL_MAX_VERTEX_SHADER_INVARIANTS_EXT 0x87C7 +#define GL_MAX_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87C8 +#define GL_MAX_VERTEX_SHADER_LOCALS_EXT 0x87C9 +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CA +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_VARIANTS_EXT 0x87CB +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87CC +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_EXT 0x87CD +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCALS_EXT 0x87CE +#define GL_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CF +#define GL_VERTEX_SHADER_VARIANTS_EXT 0x87D0 +#define GL_VERTEX_SHADER_INVARIANTS_EXT 0x87D1 +#define GL_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87D2 +#define GL_VERTEX_SHADER_LOCALS_EXT 0x87D3 +#define GL_VERTEX_SHADER_OPTIMIZED_EXT 0x87D4 +#define GL_X_EXT 0x87D5 +#define GL_Y_EXT 0x87D6 +#define GL_Z_EXT 0x87D7 +#define GL_W_EXT 0x87D8 +#define GL_NEGATIVE_X_EXT 0x87D9 +#define GL_NEGATIVE_Y_EXT 0x87DA +#define GL_NEGATIVE_Z_EXT 0x87DB +#define GL_NEGATIVE_W_EXT 0x87DC +#define GL_ZERO_EXT 0x87DD +#define GL_ONE_EXT 0x87DE +#define GL_NEGATIVE_ONE_EXT 0x87DF +#define GL_NORMALIZED_RANGE_EXT 0x87E0 +#define GL_FULL_RANGE_EXT 0x87E1 +#define GL_CURRENT_VERTEX_EXT 0x87E2 +#define GL_MVP_MATRIX_EXT 0x87E3 +#define GL_VARIANT_VALUE_EXT 0x87E4 +#define GL_VARIANT_DATATYPE_EXT 0x87E5 +#define GL_VARIANT_ARRAY_STRIDE_EXT 0x87E6 +#define GL_VARIANT_ARRAY_TYPE_EXT 0x87E7 +#define GL_VARIANT_ARRAY_EXT 0x87E8 +#define GL_VARIANT_ARRAY_POINTER_EXT 0x87E9 +#define GL_INVARIANT_VALUE_EXT 0x87EA +#define GL_INVARIANT_DATATYPE_EXT 0x87EB +#define GL_LOCAL_CONSTANT_VALUE_EXT 0x87EC +#define GL_LOCAL_CONSTANT_DATATYPE_EXT 0x87ED +#endif + +#ifndef GL_ATI_vertex_streams +#define GL_MAX_VERTEX_STREAMS_ATI 0x876B +#define GL_VERTEX_STREAM0_ATI 0x876C +#define GL_VERTEX_STREAM1_ATI 0x876D +#define GL_VERTEX_STREAM2_ATI 0x876E +#define GL_VERTEX_STREAM3_ATI 0x876F +#define GL_VERTEX_STREAM4_ATI 0x8770 +#define GL_VERTEX_STREAM5_ATI 0x8771 +#define GL_VERTEX_STREAM6_ATI 0x8772 +#define GL_VERTEX_STREAM7_ATI 0x8773 +#define GL_VERTEX_SOURCE_ATI 0x8774 +#endif + +#ifndef GL_ATI_element_array +#define GL_ELEMENT_ARRAY_ATI 0x8768 +#define GL_ELEMENT_ARRAY_TYPE_ATI 0x8769 +#define GL_ELEMENT_ARRAY_POINTER_ATI 0x876A +#endif + +#ifndef GL_SUN_mesh_array +#define GL_QUAD_MESH_SUN 0x8614 +#define GL_TRIANGLE_MESH_SUN 0x8615 +#endif + +#ifndef GL_SUN_slice_accum +#define GL_SLICE_ACCUM_SUN 0x85CC +#endif + +#ifndef GL_NV_multisample_filter_hint +#define GL_MULTISAMPLE_FILTER_HINT_NV 0x8534 +#endif + +#ifndef GL_NV_depth_clamp +#define GL_DEPTH_CLAMP_NV 0x864F +#endif + +#ifndef GL_NV_occlusion_query +#define GL_PIXEL_COUNTER_BITS_NV 0x8864 +#define GL_CURRENT_OCCLUSION_QUERY_ID_NV 0x8865 +#define GL_PIXEL_COUNT_NV 0x8866 +#define GL_PIXEL_COUNT_AVAILABLE_NV 0x8867 +#endif + +#ifndef GL_NV_point_sprite +#define GL_POINT_SPRITE_NV 0x8861 +#define GL_COORD_REPLACE_NV 0x8862 +#define GL_POINT_SPRITE_R_MODE_NV 0x8863 +#endif + +#ifndef GL_NV_texture_shader3 +#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_NV 0x8850 +#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_SCALE_NV 0x8851 +#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8852 +#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_SCALE_NV 0x8853 +#define GL_OFFSET_HILO_TEXTURE_2D_NV 0x8854 +#define GL_OFFSET_HILO_TEXTURE_RECTANGLE_NV 0x8855 +#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_2D_NV 0x8856 +#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8857 +#define GL_DEPENDENT_HILO_TEXTURE_2D_NV 0x8858 +#define GL_DEPENDENT_RGB_TEXTURE_3D_NV 0x8859 +#define GL_DEPENDENT_RGB_TEXTURE_CUBE_MAP_NV 0x885A +#define GL_DOT_PRODUCT_PASS_THROUGH_NV 0x885B +#define GL_DOT_PRODUCT_TEXTURE_1D_NV 0x885C +#define GL_DOT_PRODUCT_AFFINE_DEPTH_REPLACE_NV 0x885D +#define GL_HILO8_NV 0x885E +#define GL_SIGNED_HILO8_NV 0x885F +#define GL_FORCE_BLUE_TO_ONE_NV 0x8860 +#endif + +#ifndef GL_NV_vertex_program1_1 +#endif + +#ifndef GL_EXT_shadow_funcs +#endif + +#ifndef GL_EXT_stencil_two_side +#define GL_STENCIL_TEST_TWO_SIDE_EXT 0x8910 +#define GL_ACTIVE_STENCIL_FACE_EXT 0x8911 +#endif + +#ifndef GL_ATI_text_fragment_shader +#define GL_TEXT_FRAGMENT_SHADER_ATI 0x8200 +#endif + +#ifndef GL_APPLE_client_storage +#define GL_UNPACK_CLIENT_STORAGE_APPLE 0x85B2 +#endif + +#ifndef GL_APPLE_element_array +#define GL_ELEMENT_ARRAY_APPLE 0x8A0C +#define GL_ELEMENT_ARRAY_TYPE_APPLE 0x8A0D +#define GL_ELEMENT_ARRAY_POINTER_APPLE 0x8A0E +#endif + +#ifndef GL_APPLE_fence +#define GL_DRAW_PIXELS_APPLE 0x8A0A +#define GL_FENCE_APPLE 0x8A0B +#endif + +#ifndef GL_APPLE_vertex_array_object +#define GL_VERTEX_ARRAY_BINDING_APPLE 0x85B5 +#endif + +#ifndef GL_APPLE_vertex_array_range +#define GL_VERTEX_ARRAY_RANGE_APPLE 0x851D +#define GL_VERTEX_ARRAY_RANGE_LENGTH_APPLE 0x851E +#define GL_VERTEX_ARRAY_STORAGE_HINT_APPLE 0x851F +#define GL_VERTEX_ARRAY_RANGE_POINTER_APPLE 0x8521 +#define GL_STORAGE_CLIENT_APPLE 0x85B4 +#define GL_STORAGE_CACHED_APPLE 0x85BE +#define GL_STORAGE_SHARED_APPLE 0x85BF +#endif + +#ifndef GL_APPLE_ycbcr_422 +#define GL_YCBCR_422_APPLE 0x85B9 +#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA +#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB +#endif + +#ifndef GL_S3_s3tc +#define GL_RGB_S3TC 0x83A0 +#define GL_RGB4_S3TC 0x83A1 +#define GL_RGBA_S3TC 0x83A2 +#define GL_RGBA4_S3TC 0x83A3 +#endif + +#ifndef GL_ATI_draw_buffers +#define GL_MAX_DRAW_BUFFERS_ATI 0x8824 +#define GL_DRAW_BUFFER0_ATI 0x8825 +#define GL_DRAW_BUFFER1_ATI 0x8826 +#define GL_DRAW_BUFFER2_ATI 0x8827 +#define GL_DRAW_BUFFER3_ATI 0x8828 +#define GL_DRAW_BUFFER4_ATI 0x8829 +#define GL_DRAW_BUFFER5_ATI 0x882A +#define GL_DRAW_BUFFER6_ATI 0x882B +#define GL_DRAW_BUFFER7_ATI 0x882C +#define GL_DRAW_BUFFER8_ATI 0x882D +#define GL_DRAW_BUFFER9_ATI 0x882E +#define GL_DRAW_BUFFER10_ATI 0x882F +#define GL_DRAW_BUFFER11_ATI 0x8830 +#define GL_DRAW_BUFFER12_ATI 0x8831 +#define GL_DRAW_BUFFER13_ATI 0x8832 +#define GL_DRAW_BUFFER14_ATI 0x8833 +#define GL_DRAW_BUFFER15_ATI 0x8834 +#endif + +#ifndef GL_ATI_pixel_format_float +#define GL_TYPE_RGBA_FLOAT_ATI 0x8820 +#define GL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI 0x8835 +#endif + +#ifndef GL_ATI_texture_env_combine3 +#define GL_MODULATE_ADD_ATI 0x8744 +#define GL_MODULATE_SIGNED_ADD_ATI 0x8745 +#define GL_MODULATE_SUBTRACT_ATI 0x8746 +#endif + +#ifndef GL_ATI_texture_float +#define GL_RGBA_FLOAT32_ATI 0x8814 +#define GL_RGB_FLOAT32_ATI 0x8815 +#define GL_ALPHA_FLOAT32_ATI 0x8816 +#define GL_INTENSITY_FLOAT32_ATI 0x8817 +#define GL_LUMINANCE_FLOAT32_ATI 0x8818 +#define GL_LUMINANCE_ALPHA_FLOAT32_ATI 0x8819 +#define GL_RGBA_FLOAT16_ATI 0x881A +#define GL_RGB_FLOAT16_ATI 0x881B +#define GL_ALPHA_FLOAT16_ATI 0x881C +#define GL_INTENSITY_FLOAT16_ATI 0x881D +#define GL_LUMINANCE_FLOAT16_ATI 0x881E +#define GL_LUMINANCE_ALPHA_FLOAT16_ATI 0x881F +#endif + +#ifndef GL_NV_float_buffer +#define GL_FLOAT_R_NV 0x8880 +#define GL_FLOAT_RG_NV 0x8881 +#define GL_FLOAT_RGB_NV 0x8882 +#define GL_FLOAT_RGBA_NV 0x8883 +#define GL_FLOAT_R16_NV 0x8884 +#define GL_FLOAT_R32_NV 0x8885 +#define GL_FLOAT_RG16_NV 0x8886 +#define GL_FLOAT_RG32_NV 0x8887 +#define GL_FLOAT_RGB16_NV 0x8888 +#define GL_FLOAT_RGB32_NV 0x8889 +#define GL_FLOAT_RGBA16_NV 0x888A +#define GL_FLOAT_RGBA32_NV 0x888B +#define GL_TEXTURE_FLOAT_COMPONENTS_NV 0x888C +#define GL_FLOAT_CLEAR_COLOR_VALUE_NV 0x888D +#define GL_FLOAT_RGBA_MODE_NV 0x888E +#endif + +#ifndef GL_NV_fragment_program +#define GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV 0x8868 +#define GL_FRAGMENT_PROGRAM_NV 0x8870 +#define GL_MAX_TEXTURE_COORDS_NV 0x8871 +#define GL_MAX_TEXTURE_IMAGE_UNITS_NV 0x8872 +#define GL_FRAGMENT_PROGRAM_BINDING_NV 0x8873 +#define GL_PROGRAM_ERROR_STRING_NV 0x8874 +#endif + +#ifndef GL_NV_half_float +#define GL_HALF_FLOAT_NV 0x140B +#endif + +#ifndef GL_NV_pixel_data_range +#define GL_WRITE_PIXEL_DATA_RANGE_NV 0x8878 +#define GL_READ_PIXEL_DATA_RANGE_NV 0x8879 +#define GL_WRITE_PIXEL_DATA_RANGE_LENGTH_NV 0x887A +#define GL_READ_PIXEL_DATA_RANGE_LENGTH_NV 0x887B +#define GL_WRITE_PIXEL_DATA_RANGE_POINTER_NV 0x887C +#define GL_READ_PIXEL_DATA_RANGE_POINTER_NV 0x887D +#endif + +#ifndef GL_NV_primitive_restart +#define GL_PRIMITIVE_RESTART_NV 0x8558 +#define GL_PRIMITIVE_RESTART_INDEX_NV 0x8559 +#endif + +#ifndef GL_NV_texture_expand_normal +#define GL_TEXTURE_UNSIGNED_REMAP_MODE_NV 0x888F +#endif + +#ifndef GL_NV_vertex_program2 +#endif + +#ifndef GL_ATI_map_object_buffer +#endif + +#ifndef GL_ATI_separate_stencil +#define GL_STENCIL_BACK_FUNC_ATI 0x8800 +#define GL_STENCIL_BACK_FAIL_ATI 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI 0x8803 +#endif + +#ifndef GL_ATI_vertex_attrib_array_object +#endif + +#ifndef GL_OES_read_format +#define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES 0x8B9A +#define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES 0x8B9B +#endif + +#ifndef GL_EXT_depth_bounds_test +#define GL_DEPTH_BOUNDS_TEST_EXT 0x8890 +#define GL_DEPTH_BOUNDS_EXT 0x8891 +#endif + +#ifndef GL_EXT_texture_mirror_clamp +#define GL_MIRROR_CLAMP_EXT 0x8742 +#define GL_MIRROR_CLAMP_TO_EDGE_EXT 0x8743 +#define GL_MIRROR_CLAMP_TO_BORDER_EXT 0x8912 +#endif + +#ifndef GL_EXT_blend_equation_separate +#define GL_BLEND_EQUATION_RGB_EXT 0x8009 +#define GL_BLEND_EQUATION_ALPHA_EXT 0x883D +#endif + +#ifndef GL_MESA_pack_invert +#define GL_PACK_INVERT_MESA 0x8758 +#endif + +#ifndef GL_MESA_ycbcr_texture +#define GL_UNSIGNED_SHORT_8_8_MESA 0x85BA +#define GL_UNSIGNED_SHORT_8_8_REV_MESA 0x85BB +#define GL_YCBCR_MESA 0x8757 +#endif + +#ifndef GL_EXT_pixel_buffer_object +#define GL_PIXEL_PACK_BUFFER_EXT 0x88EB +#define GL_PIXEL_UNPACK_BUFFER_EXT 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING_EXT 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING_EXT 0x88EF +#endif + +#ifndef GL_NV_fragment_program_option +#endif + +#ifndef GL_NV_fragment_program2 +#define GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88F4 +#define GL_MAX_PROGRAM_CALL_DEPTH_NV 0x88F5 +#define GL_MAX_PROGRAM_IF_DEPTH_NV 0x88F6 +#define GL_MAX_PROGRAM_LOOP_DEPTH_NV 0x88F7 +#define GL_MAX_PROGRAM_LOOP_COUNT_NV 0x88F8 +#endif + +#ifndef GL_NV_vertex_program2_option +/* reuse GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV */ +/* reuse GL_MAX_PROGRAM_CALL_DEPTH_NV */ +#endif + +#ifndef GL_NV_vertex_program3 +/* reuse GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB */ +#endif + +#ifndef GL_EXT_framebuffer_object +#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506 +#define GL_MAX_RENDERBUFFER_SIZE_EXT 0x84E8 +#define GL_FRAMEBUFFER_BINDING_EXT 0x8CA6 +#define GL_RENDERBUFFER_BINDING_EXT 0x8CA7 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT 0x8CD0 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT 0x8CD1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8CD2 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8CD3 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8CD4 +#define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7 +#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT 0x8CD9 +#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 0x8CDA +#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8CDB +#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC +#define GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8CDD +#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF +#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0 +#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1 +#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2 +#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3 +#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4 +#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5 +#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6 +#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7 +#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8 +#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9 +#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA +#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB +#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC +#define GL_COLOR_ATTACHMENT13_EXT 0x8CED +#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE +#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF +#define GL_DEPTH_ATTACHMENT_EXT 0x8D00 +#define GL_STENCIL_ATTACHMENT_EXT 0x8D20 +#define GL_FRAMEBUFFER_EXT 0x8D40 +#define GL_RENDERBUFFER_EXT 0x8D41 +#define GL_RENDERBUFFER_WIDTH_EXT 0x8D42 +#define GL_RENDERBUFFER_HEIGHT_EXT 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8D44 +#define GL_STENCIL_INDEX1_EXT 0x8D46 +#define GL_STENCIL_INDEX4_EXT 0x8D47 +#define GL_STENCIL_INDEX8_EXT 0x8D48 +#define GL_STENCIL_INDEX16_EXT 0x8D49 +#define GL_RENDERBUFFER_RED_SIZE_EXT 0x8D50 +#define GL_RENDERBUFFER_GREEN_SIZE_EXT 0x8D51 +#define GL_RENDERBUFFER_BLUE_SIZE_EXT 0x8D52 +#define GL_RENDERBUFFER_ALPHA_SIZE_EXT 0x8D53 +#define GL_RENDERBUFFER_DEPTH_SIZE_EXT 0x8D54 +#define GL_RENDERBUFFER_STENCIL_SIZE_EXT 0x8D55 +#endif + +#ifndef GL_GREMEDY_string_marker +#endif + +#ifndef GL_EXT_packed_depth_stencil +#define GL_DEPTH_STENCIL_EXT 0x84F9 +#define GL_UNSIGNED_INT_24_8_EXT 0x84FA +#define GL_DEPTH24_STENCIL8_EXT 0x88F0 +#define GL_TEXTURE_STENCIL_SIZE_EXT 0x88F1 +#endif + +#ifndef GL_EXT_stencil_clear_tag +#define GL_STENCIL_TAG_BITS_EXT 0x88F2 +#define GL_STENCIL_CLEAR_TAG_VALUE_EXT 0x88F3 +#endif + +#ifndef GL_EXT_texture_sRGB +#define GL_SRGB_EXT 0x8C40 +#define GL_SRGB8_EXT 0x8C41 +#define GL_SRGB_ALPHA_EXT 0x8C42 +#define GL_SRGB8_ALPHA8_EXT 0x8C43 +#define GL_SLUMINANCE_ALPHA_EXT 0x8C44 +#define GL_SLUMINANCE8_ALPHA8_EXT 0x8C45 +#define GL_SLUMINANCE_EXT 0x8C46 +#define GL_SLUMINANCE8_EXT 0x8C47 +#define GL_COMPRESSED_SRGB_EXT 0x8C48 +#define GL_COMPRESSED_SRGB_ALPHA_EXT 0x8C49 +#define GL_COMPRESSED_SLUMINANCE_EXT 0x8C4A +#define GL_COMPRESSED_SLUMINANCE_ALPHA_EXT 0x8C4B +#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F +#endif + +#ifndef GL_EXT_framebuffer_blit +#define GL_READ_FRAMEBUFFER_EXT 0x8CA8 +#define GL_DRAW_FRAMEBUFFER_EXT 0x8CA9 +#define GL_DRAW_FRAMEBUFFER_BINDING_EXT GL_FRAMEBUFFER_BINDING_EXT +#define GL_READ_FRAMEBUFFER_BINDING_EXT 0x8CAA +#endif + +#ifndef GL_EXT_framebuffer_multisample +#define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56 +#define GL_MAX_SAMPLES_EXT 0x8D57 +#endif + +#ifndef GL_MESAX_texture_stack +#define GL_TEXTURE_1D_STACK_MESAX 0x8759 +#define GL_TEXTURE_2D_STACK_MESAX 0x875A +#define GL_PROXY_TEXTURE_1D_STACK_MESAX 0x875B +#define GL_PROXY_TEXTURE_2D_STACK_MESAX 0x875C +#define GL_TEXTURE_1D_STACK_BINDING_MESAX 0x875D +#define GL_TEXTURE_2D_STACK_BINDING_MESAX 0x875E +#endif + +#ifndef GL_EXT_timer_query +#define GL_TIME_ELAPSED_EXT 0x88BF +#endif + +#ifndef GL_EXT_gpu_program_parameters +#endif + +#ifndef GL_APPLE_flush_buffer_range +#define GL_BUFFER_SERIALIZED_MODIFY_APPLE 0x8A12 +#define GL_BUFFER_FLUSHING_UNMAP_APPLE 0x8A13 +#endif + +#ifndef GL_NV_gpu_program4 +#define GL_MIN_PROGRAM_TEXEL_OFFSET_NV 0x8904 +#define GL_MAX_PROGRAM_TEXEL_OFFSET_NV 0x8905 +#define GL_PROGRAM_ATTRIB_COMPONENTS_NV 0x8906 +#define GL_PROGRAM_RESULT_COMPONENTS_NV 0x8907 +#define GL_MAX_PROGRAM_ATTRIB_COMPONENTS_NV 0x8908 +#define GL_MAX_PROGRAM_RESULT_COMPONENTS_NV 0x8909 +#define GL_MAX_PROGRAM_GENERIC_ATTRIBS_NV 0x8DA5 +#define GL_MAX_PROGRAM_GENERIC_RESULTS_NV 0x8DA6 +#endif + +#ifndef GL_NV_geometry_program4 +#define GL_LINES_ADJACENCY_EXT 0x000A +#define GL_LINE_STRIP_ADJACENCY_EXT 0x000B +#define GL_TRIANGLES_ADJACENCY_EXT 0x000C +#define GL_TRIANGLE_STRIP_ADJACENCY_EXT 0x000D +#define GL_GEOMETRY_PROGRAM_NV 0x8C26 +#define GL_MAX_PROGRAM_OUTPUT_VERTICES_NV 0x8C27 +#define GL_MAX_PROGRAM_TOTAL_OUTPUT_COMPONENTS_NV 0x8C28 +#define GL_GEOMETRY_VERTICES_OUT_EXT 0x8DDA +#define GL_GEOMETRY_INPUT_TYPE_EXT 0x8DDB +#define GL_GEOMETRY_OUTPUT_TYPE_EXT 0x8DDC +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT 0x8C29 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT 0x8DA7 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT 0x8DA8 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_EXT 0x8DA9 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT 0x8CD4 +#define GL_PROGRAM_POINT_SIZE_EXT 0x8642 +#endif + +#ifndef GL_EXT_geometry_shader4 +#define GL_GEOMETRY_SHADER_EXT 0x8DD9 +/* reuse GL_GEOMETRY_VERTICES_OUT_EXT */ +/* reuse GL_GEOMETRY_INPUT_TYPE_EXT */ +/* reuse GL_GEOMETRY_OUTPUT_TYPE_EXT */ +/* reuse GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT */ +#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_EXT 0x8DDD +#define GL_MAX_VERTEX_VARYING_COMPONENTS_EXT 0x8DDE +#define GL_MAX_VARYING_COMPONENTS_EXT 0x8B4B +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT 0x8DDF +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT 0x8DE1 +/* reuse GL_LINES_ADJACENCY_EXT */ +/* reuse GL_LINE_STRIP_ADJACENCY_EXT */ +/* reuse GL_TRIANGLES_ADJACENCY_EXT */ +/* reuse GL_TRIANGLE_STRIP_ADJACENCY_EXT */ +/* reuse GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT */ +/* reuse GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_EXT */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT */ +/* reuse GL_PROGRAM_POINT_SIZE_EXT */ +#endif + +#ifndef GL_NV_vertex_program4 +#define GL_VERTEX_ATTRIB_ARRAY_INTEGER_NV 0x88FD +#endif + +#ifndef GL_EXT_gpu_shader4 +#define GL_SAMPLER_1D_ARRAY_EXT 0x8DC0 +#define GL_SAMPLER_2D_ARRAY_EXT 0x8DC1 +#define GL_SAMPLER_BUFFER_EXT 0x8DC2 +#define GL_SAMPLER_1D_ARRAY_SHADOW_EXT 0x8DC3 +#define GL_SAMPLER_2D_ARRAY_SHADOW_EXT 0x8DC4 +#define GL_SAMPLER_CUBE_SHADOW_EXT 0x8DC5 +#define GL_UNSIGNED_INT_VEC2_EXT 0x8DC6 +#define GL_UNSIGNED_INT_VEC3_EXT 0x8DC7 +#define GL_UNSIGNED_INT_VEC4_EXT 0x8DC8 +#define GL_INT_SAMPLER_1D_EXT 0x8DC9 +#define GL_INT_SAMPLER_2D_EXT 0x8DCA +#define GL_INT_SAMPLER_3D_EXT 0x8DCB +#define GL_INT_SAMPLER_CUBE_EXT 0x8DCC +#define GL_INT_SAMPLER_2D_RECT_EXT 0x8DCD +#define GL_INT_SAMPLER_1D_ARRAY_EXT 0x8DCE +#define GL_INT_SAMPLER_2D_ARRAY_EXT 0x8DCF +#define GL_INT_SAMPLER_BUFFER_EXT 0x8DD0 +#define GL_UNSIGNED_INT_SAMPLER_1D_EXT 0x8DD1 +#define GL_UNSIGNED_INT_SAMPLER_2D_EXT 0x8DD2 +#define GL_UNSIGNED_INT_SAMPLER_3D_EXT 0x8DD3 +#define GL_UNSIGNED_INT_SAMPLER_CUBE_EXT 0x8DD4 +#define GL_UNSIGNED_INT_SAMPLER_2D_RECT_EXT 0x8DD5 +#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY_EXT 0x8DD6 +#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY_EXT 0x8DD7 +#define GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT 0x8DD8 +#endif + +#ifndef GL_EXT_draw_instanced +#endif + +#ifndef GL_EXT_packed_float +#define GL_R11F_G11F_B10F_EXT 0x8C3A +#define GL_UNSIGNED_INT_10F_11F_11F_REV_EXT 0x8C3B +#define GL_RGBA_SIGNED_COMPONENTS_EXT 0x8C3C +#endif + +#ifndef GL_EXT_texture_array +#define GL_TEXTURE_1D_ARRAY_EXT 0x8C18 +#define GL_PROXY_TEXTURE_1D_ARRAY_EXT 0x8C19 +#define GL_TEXTURE_2D_ARRAY_EXT 0x8C1A +#define GL_PROXY_TEXTURE_2D_ARRAY_EXT 0x8C1B +#define GL_TEXTURE_BINDING_1D_ARRAY_EXT 0x8C1C +#define GL_TEXTURE_BINDING_2D_ARRAY_EXT 0x8C1D +#define GL_MAX_ARRAY_TEXTURE_LAYERS_EXT 0x88FF +#define GL_COMPARE_REF_DEPTH_TO_TEXTURE_EXT 0x884E +/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT */ +#endif + +#ifndef GL_EXT_texture_buffer_object +#define GL_TEXTURE_BUFFER_EXT 0x8C2A +#define GL_MAX_TEXTURE_BUFFER_SIZE_EXT 0x8C2B +#define GL_TEXTURE_BINDING_BUFFER_EXT 0x8C2C +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_EXT 0x8C2D +#define GL_TEXTURE_BUFFER_FORMAT_EXT 0x8C2E +#endif + +#ifndef GL_EXT_texture_compression_latc +#define GL_COMPRESSED_LUMINANCE_LATC1_EXT 0x8C70 +#define GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT 0x8C71 +#define GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT 0x8C72 +#define GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT 0x8C73 +#endif + +#ifndef GL_EXT_texture_compression_rgtc +#define GL_COMPRESSED_RED_RGTC1_EXT 0x8DBB +#define GL_COMPRESSED_SIGNED_RED_RGTC1_EXT 0x8DBC +#define GL_COMPRESSED_RED_GREEN_RGTC2_EXT 0x8DBD +#define GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT 0x8DBE +#endif + +#ifndef GL_EXT_texture_shared_exponent +#define GL_RGB9_E5_EXT 0x8C3D +#define GL_UNSIGNED_INT_5_9_9_9_REV_EXT 0x8C3E +#define GL_TEXTURE_SHARED_SIZE_EXT 0x8C3F +#endif + +#ifndef GL_NV_depth_buffer_float +#define GL_DEPTH_COMPONENT32F_NV 0x8DAB +#define GL_DEPTH32F_STENCIL8_NV 0x8DAC +#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV_NV 0x8DAD +#define GL_DEPTH_BUFFER_FLOAT_MODE_NV 0x8DAF +#endif + +#ifndef GL_NV_fragment_program4 +#endif + +#ifndef GL_NV_framebuffer_multisample_coverage +#define GL_RENDERBUFFER_COVERAGE_SAMPLES_NV 0x8CAB +#define GL_RENDERBUFFER_COLOR_SAMPLES_NV 0x8E10 +#define GL_MAX_MULTISAMPLE_COVERAGE_MODES_NV 0x8E11 +#define GL_MULTISAMPLE_COVERAGE_MODES_NV 0x8E12 +#endif + +#ifndef GL_EXT_framebuffer_sRGB +#define GL_FRAMEBUFFER_SRGB_EXT 0x8DB9 +#define GL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x8DBA +#endif + +#ifndef GL_NV_geometry_shader4 +#endif + +#ifndef GL_NV_parameter_buffer_object +#define GL_MAX_PROGRAM_PARAMETER_BUFFER_BINDINGS_NV 0x8DA0 +#define GL_MAX_PROGRAM_PARAMETER_BUFFER_SIZE_NV 0x8DA1 +#define GL_VERTEX_PROGRAM_PARAMETER_BUFFER_NV 0x8DA2 +#define GL_GEOMETRY_PROGRAM_PARAMETER_BUFFER_NV 0x8DA3 +#define GL_FRAGMENT_PROGRAM_PARAMETER_BUFFER_NV 0x8DA4 +#endif + +#ifndef GL_EXT_draw_buffers2 +#endif + +#ifndef GL_NV_transform_feedback +#define GL_BACK_PRIMARY_COLOR_NV 0x8C77 +#define GL_BACK_SECONDARY_COLOR_NV 0x8C78 +#define GL_TEXTURE_COORD_NV 0x8C79 +#define GL_CLIP_DISTANCE_NV 0x8C7A +#define GL_VERTEX_ID_NV 0x8C7B +#define GL_PRIMITIVE_ID_NV 0x8C7C +#define GL_GENERIC_ATTRIB_NV 0x8C7D +#define GL_TRANSFORM_FEEDBACK_ATTRIBS_NV 0x8C7E +#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_NV 0x8C7F +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_NV 0x8C80 +#define GL_ACTIVE_VARYINGS_NV 0x8C81 +#define GL_ACTIVE_VARYING_MAX_LENGTH_NV 0x8C82 +#define GL_TRANSFORM_FEEDBACK_VARYINGS_NV 0x8C83 +#define GL_TRANSFORM_FEEDBACK_BUFFER_START_NV 0x8C84 +#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_NV 0x8C85 +#define GL_TRANSFORM_FEEDBACK_RECORD_NV 0x8C86 +#define GL_PRIMITIVES_GENERATED_NV 0x8C87 +#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_NV 0x8C88 +#define GL_RASTERIZER_DISCARD_NV 0x8C89 +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_ATTRIBS_NV 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_NV 0x8C8B +#define GL_INTERLEAVED_ATTRIBS_NV 0x8C8C +#define GL_SEPARATE_ATTRIBS_NV 0x8C8D +#define GL_TRANSFORM_FEEDBACK_BUFFER_NV 0x8C8E +#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_NV 0x8C8F +#define GL_LAYER_NV 0x8DAA +#define GL_NEXT_BUFFER_NV -2 +#define GL_SKIP_COMPONENTS4_NV -3 +#define GL_SKIP_COMPONENTS3_NV -4 +#define GL_SKIP_COMPONENTS2_NV -5 +#define GL_SKIP_COMPONENTS1_NV -6 +#endif + +#ifndef GL_EXT_bindable_uniform +#define GL_MAX_VERTEX_BINDABLE_UNIFORMS_EXT 0x8DE2 +#define GL_MAX_FRAGMENT_BINDABLE_UNIFORMS_EXT 0x8DE3 +#define GL_MAX_GEOMETRY_BINDABLE_UNIFORMS_EXT 0x8DE4 +#define GL_MAX_BINDABLE_UNIFORM_SIZE_EXT 0x8DED +#define GL_UNIFORM_BUFFER_EXT 0x8DEE +#define GL_UNIFORM_BUFFER_BINDING_EXT 0x8DEF +#endif + +#ifndef GL_EXT_texture_integer +#define GL_RGBA32UI_EXT 0x8D70 +#define GL_RGB32UI_EXT 0x8D71 +#define GL_ALPHA32UI_EXT 0x8D72 +#define GL_INTENSITY32UI_EXT 0x8D73 +#define GL_LUMINANCE32UI_EXT 0x8D74 +#define GL_LUMINANCE_ALPHA32UI_EXT 0x8D75 +#define GL_RGBA16UI_EXT 0x8D76 +#define GL_RGB16UI_EXT 0x8D77 +#define GL_ALPHA16UI_EXT 0x8D78 +#define GL_INTENSITY16UI_EXT 0x8D79 +#define GL_LUMINANCE16UI_EXT 0x8D7A +#define GL_LUMINANCE_ALPHA16UI_EXT 0x8D7B +#define GL_RGBA8UI_EXT 0x8D7C +#define GL_RGB8UI_EXT 0x8D7D +#define GL_ALPHA8UI_EXT 0x8D7E +#define GL_INTENSITY8UI_EXT 0x8D7F +#define GL_LUMINANCE8UI_EXT 0x8D80 +#define GL_LUMINANCE_ALPHA8UI_EXT 0x8D81 +#define GL_RGBA32I_EXT 0x8D82 +#define GL_RGB32I_EXT 0x8D83 +#define GL_ALPHA32I_EXT 0x8D84 +#define GL_INTENSITY32I_EXT 0x8D85 +#define GL_LUMINANCE32I_EXT 0x8D86 +#define GL_LUMINANCE_ALPHA32I_EXT 0x8D87 +#define GL_RGBA16I_EXT 0x8D88 +#define GL_RGB16I_EXT 0x8D89 +#define GL_ALPHA16I_EXT 0x8D8A +#define GL_INTENSITY16I_EXT 0x8D8B +#define GL_LUMINANCE16I_EXT 0x8D8C +#define GL_LUMINANCE_ALPHA16I_EXT 0x8D8D +#define GL_RGBA8I_EXT 0x8D8E +#define GL_RGB8I_EXT 0x8D8F +#define GL_ALPHA8I_EXT 0x8D90 +#define GL_INTENSITY8I_EXT 0x8D91 +#define GL_LUMINANCE8I_EXT 0x8D92 +#define GL_LUMINANCE_ALPHA8I_EXT 0x8D93 +#define GL_RED_INTEGER_EXT 0x8D94 +#define GL_GREEN_INTEGER_EXT 0x8D95 +#define GL_BLUE_INTEGER_EXT 0x8D96 +#define GL_ALPHA_INTEGER_EXT 0x8D97 +#define GL_RGB_INTEGER_EXT 0x8D98 +#define GL_RGBA_INTEGER_EXT 0x8D99 +#define GL_BGR_INTEGER_EXT 0x8D9A +#define GL_BGRA_INTEGER_EXT 0x8D9B +#define GL_LUMINANCE_INTEGER_EXT 0x8D9C +#define GL_LUMINANCE_ALPHA_INTEGER_EXT 0x8D9D +#define GL_RGBA_INTEGER_MODE_EXT 0x8D9E +#endif + +#ifndef GL_GREMEDY_frame_terminator +#endif + +#ifndef GL_NV_conditional_render +#define GL_QUERY_WAIT_NV 0x8E13 +#define GL_QUERY_NO_WAIT_NV 0x8E14 +#define GL_QUERY_BY_REGION_WAIT_NV 0x8E15 +#define GL_QUERY_BY_REGION_NO_WAIT_NV 0x8E16 +#endif + +#ifndef GL_NV_present_video +#define GL_FRAME_NV 0x8E26 +#define GL_FIELDS_NV 0x8E27 +#define GL_CURRENT_TIME_NV 0x8E28 +#define GL_NUM_FILL_STREAMS_NV 0x8E29 +#define GL_PRESENT_TIME_NV 0x8E2A +#define GL_PRESENT_DURATION_NV 0x8E2B +#endif + +#ifndef GL_EXT_transform_feedback +#define GL_TRANSFORM_FEEDBACK_BUFFER_EXT 0x8C8E +#define GL_TRANSFORM_FEEDBACK_BUFFER_START_EXT 0x8C84 +#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_EXT 0x8C85 +#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_EXT 0x8C8F +#define GL_INTERLEAVED_ATTRIBS_EXT 0x8C8C +#define GL_SEPARATE_ATTRIBS_EXT 0x8C8D +#define GL_PRIMITIVES_GENERATED_EXT 0x8C87 +#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_EXT 0x8C88 +#define GL_RASTERIZER_DISCARD_EXT 0x8C89 +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_EXT 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_EXT 0x8C8B +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_EXT 0x8C80 +#define GL_TRANSFORM_FEEDBACK_VARYINGS_EXT 0x8C83 +#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_EXT 0x8C7F +#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH_EXT 0x8C76 +#endif + +#ifndef GL_EXT_direct_state_access +#define GL_PROGRAM_MATRIX_EXT 0x8E2D +#define GL_TRANSPOSE_PROGRAM_MATRIX_EXT 0x8E2E +#define GL_PROGRAM_MATRIX_STACK_DEPTH_EXT 0x8E2F +#endif + +#ifndef GL_EXT_vertex_array_bgra +/* reuse GL_BGRA */ +#endif + +#ifndef GL_EXT_texture_swizzle +#define GL_TEXTURE_SWIZZLE_R_EXT 0x8E42 +#define GL_TEXTURE_SWIZZLE_G_EXT 0x8E43 +#define GL_TEXTURE_SWIZZLE_B_EXT 0x8E44 +#define GL_TEXTURE_SWIZZLE_A_EXT 0x8E45 +#define GL_TEXTURE_SWIZZLE_RGBA_EXT 0x8E46 +#endif + +#ifndef GL_NV_explicit_multisample +#define GL_SAMPLE_POSITION_NV 0x8E50 +#define GL_SAMPLE_MASK_NV 0x8E51 +#define GL_SAMPLE_MASK_VALUE_NV 0x8E52 +#define GL_TEXTURE_BINDING_RENDERBUFFER_NV 0x8E53 +#define GL_TEXTURE_RENDERBUFFER_DATA_STORE_BINDING_NV 0x8E54 +#define GL_TEXTURE_RENDERBUFFER_NV 0x8E55 +#define GL_SAMPLER_RENDERBUFFER_NV 0x8E56 +#define GL_INT_SAMPLER_RENDERBUFFER_NV 0x8E57 +#define GL_UNSIGNED_INT_SAMPLER_RENDERBUFFER_NV 0x8E58 +#define GL_MAX_SAMPLE_MASK_WORDS_NV 0x8E59 +#endif + +#ifndef GL_NV_transform_feedback2 +#define GL_TRANSFORM_FEEDBACK_NV 0x8E22 +#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED_NV 0x8E23 +#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE_NV 0x8E24 +#define GL_TRANSFORM_FEEDBACK_BINDING_NV 0x8E25 +#endif + +#ifndef GL_ATI_meminfo +#define GL_VBO_FREE_MEMORY_ATI 0x87FB +#define GL_TEXTURE_FREE_MEMORY_ATI 0x87FC +#define GL_RENDERBUFFER_FREE_MEMORY_ATI 0x87FD +#endif + +#ifndef GL_AMD_performance_monitor +#define GL_COUNTER_TYPE_AMD 0x8BC0 +#define GL_COUNTER_RANGE_AMD 0x8BC1 +#define GL_UNSIGNED_INT64_AMD 0x8BC2 +#define GL_PERCENTAGE_AMD 0x8BC3 +#define GL_PERFMON_RESULT_AVAILABLE_AMD 0x8BC4 +#define GL_PERFMON_RESULT_SIZE_AMD 0x8BC5 +#define GL_PERFMON_RESULT_AMD 0x8BC6 +#endif + +#ifndef GL_AMD_texture_texture4 +#endif + +#ifndef GL_AMD_vertex_shader_tesselator +#define GL_SAMPLER_BUFFER_AMD 0x9001 +#define GL_INT_SAMPLER_BUFFER_AMD 0x9002 +#define GL_UNSIGNED_INT_SAMPLER_BUFFER_AMD 0x9003 +#define GL_TESSELLATION_MODE_AMD 0x9004 +#define GL_TESSELLATION_FACTOR_AMD 0x9005 +#define GL_DISCRETE_AMD 0x9006 +#define GL_CONTINUOUS_AMD 0x9007 +#endif + +#ifndef GL_EXT_provoking_vertex +#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT 0x8E4C +#define GL_FIRST_VERTEX_CONVENTION_EXT 0x8E4D +#define GL_LAST_VERTEX_CONVENTION_EXT 0x8E4E +#define GL_PROVOKING_VERTEX_EXT 0x8E4F +#endif + +#ifndef GL_EXT_texture_snorm +#define GL_ALPHA_SNORM 0x9010 +#define GL_LUMINANCE_SNORM 0x9011 +#define GL_LUMINANCE_ALPHA_SNORM 0x9012 +#define GL_INTENSITY_SNORM 0x9013 +#define GL_ALPHA8_SNORM 0x9014 +#define GL_LUMINANCE8_SNORM 0x9015 +#define GL_LUMINANCE8_ALPHA8_SNORM 0x9016 +#define GL_INTENSITY8_SNORM 0x9017 +#define GL_ALPHA16_SNORM 0x9018 +#define GL_LUMINANCE16_SNORM 0x9019 +#define GL_LUMINANCE16_ALPHA16_SNORM 0x901A +#define GL_INTENSITY16_SNORM 0x901B +/* reuse GL_RED_SNORM */ +/* reuse GL_RG_SNORM */ +/* reuse GL_RGB_SNORM */ +/* reuse GL_RGBA_SNORM */ +/* reuse GL_R8_SNORM */ +/* reuse GL_RG8_SNORM */ +/* reuse GL_RGB8_SNORM */ +/* reuse GL_RGBA8_SNORM */ +/* reuse GL_R16_SNORM */ +/* reuse GL_RG16_SNORM */ +/* reuse GL_RGB16_SNORM */ +/* reuse GL_RGBA16_SNORM */ +/* reuse GL_SIGNED_NORMALIZED */ +#endif + +#ifndef GL_AMD_draw_buffers_blend +#endif + +#ifndef GL_APPLE_texture_range +#define GL_TEXTURE_RANGE_LENGTH_APPLE 0x85B7 +#define GL_TEXTURE_RANGE_POINTER_APPLE 0x85B8 +#define GL_TEXTURE_STORAGE_HINT_APPLE 0x85BC +#define GL_STORAGE_PRIVATE_APPLE 0x85BD +/* reuse GL_STORAGE_CACHED_APPLE */ +/* reuse GL_STORAGE_SHARED_APPLE */ +#endif + +#ifndef GL_APPLE_float_pixels +#define GL_HALF_APPLE 0x140B +#define GL_RGBA_FLOAT32_APPLE 0x8814 +#define GL_RGB_FLOAT32_APPLE 0x8815 +#define GL_ALPHA_FLOAT32_APPLE 0x8816 +#define GL_INTENSITY_FLOAT32_APPLE 0x8817 +#define GL_LUMINANCE_FLOAT32_APPLE 0x8818 +#define GL_LUMINANCE_ALPHA_FLOAT32_APPLE 0x8819 +#define GL_RGBA_FLOAT16_APPLE 0x881A +#define GL_RGB_FLOAT16_APPLE 0x881B +#define GL_ALPHA_FLOAT16_APPLE 0x881C +#define GL_INTENSITY_FLOAT16_APPLE 0x881D +#define GL_LUMINANCE_FLOAT16_APPLE 0x881E +#define GL_LUMINANCE_ALPHA_FLOAT16_APPLE 0x881F +#define GL_COLOR_FLOAT_APPLE 0x8A0F +#endif + +#ifndef GL_APPLE_vertex_program_evaluators +#define GL_VERTEX_ATTRIB_MAP1_APPLE 0x8A00 +#define GL_VERTEX_ATTRIB_MAP2_APPLE 0x8A01 +#define GL_VERTEX_ATTRIB_MAP1_SIZE_APPLE 0x8A02 +#define GL_VERTEX_ATTRIB_MAP1_COEFF_APPLE 0x8A03 +#define GL_VERTEX_ATTRIB_MAP1_ORDER_APPLE 0x8A04 +#define GL_VERTEX_ATTRIB_MAP1_DOMAIN_APPLE 0x8A05 +#define GL_VERTEX_ATTRIB_MAP2_SIZE_APPLE 0x8A06 +#define GL_VERTEX_ATTRIB_MAP2_COEFF_APPLE 0x8A07 +#define GL_VERTEX_ATTRIB_MAP2_ORDER_APPLE 0x8A08 +#define GL_VERTEX_ATTRIB_MAP2_DOMAIN_APPLE 0x8A09 +#endif + +#ifndef GL_APPLE_aux_depth_stencil +#define GL_AUX_DEPTH_STENCIL_APPLE 0x8A14 +#endif + +#ifndef GL_APPLE_object_purgeable +#define GL_BUFFER_OBJECT_APPLE 0x85B3 +#define GL_RELEASED_APPLE 0x8A19 +#define GL_VOLATILE_APPLE 0x8A1A +#define GL_RETAINED_APPLE 0x8A1B +#define GL_UNDEFINED_APPLE 0x8A1C +#define GL_PURGEABLE_APPLE 0x8A1D +#endif + +#ifndef GL_APPLE_row_bytes +#define GL_PACK_ROW_BYTES_APPLE 0x8A15 +#define GL_UNPACK_ROW_BYTES_APPLE 0x8A16 +#endif + +#ifndef GL_APPLE_rgb_422 +#define GL_RGB_422_APPLE 0x8A1F +/* reuse GL_UNSIGNED_SHORT_8_8_APPLE */ +/* reuse GL_UNSIGNED_SHORT_8_8_REV_APPLE */ +#endif + +#ifndef GL_NV_video_capture +#define GL_VIDEO_BUFFER_NV 0x9020 +#define GL_VIDEO_BUFFER_BINDING_NV 0x9021 +#define GL_FIELD_UPPER_NV 0x9022 +#define GL_FIELD_LOWER_NV 0x9023 +#define GL_NUM_VIDEO_CAPTURE_STREAMS_NV 0x9024 +#define GL_NEXT_VIDEO_CAPTURE_BUFFER_STATUS_NV 0x9025 +#define GL_VIDEO_CAPTURE_TO_422_SUPPORTED_NV 0x9026 +#define GL_LAST_VIDEO_CAPTURE_STATUS_NV 0x9027 +#define GL_VIDEO_BUFFER_PITCH_NV 0x9028 +#define GL_VIDEO_COLOR_CONVERSION_MATRIX_NV 0x9029 +#define GL_VIDEO_COLOR_CONVERSION_MAX_NV 0x902A +#define GL_VIDEO_COLOR_CONVERSION_MIN_NV 0x902B +#define GL_VIDEO_COLOR_CONVERSION_OFFSET_NV 0x902C +#define GL_VIDEO_BUFFER_INTERNAL_FORMAT_NV 0x902D +#define GL_PARTIAL_SUCCESS_NV 0x902E +#define GL_SUCCESS_NV 0x902F +#define GL_FAILURE_NV 0x9030 +#define GL_YCBYCR8_422_NV 0x9031 +#define GL_YCBAYCR8A_4224_NV 0x9032 +#define GL_Z6Y10Z6CB10Z6Y10Z6CR10_422_NV 0x9033 +#define GL_Z6Y10Z6CB10Z6A10Z6Y10Z6CR10Z6A10_4224_NV 0x9034 +#define GL_Z4Y12Z4CB12Z4Y12Z4CR12_422_NV 0x9035 +#define GL_Z4Y12Z4CB12Z4A12Z4Y12Z4CR12Z4A12_4224_NV 0x9036 +#define GL_Z4Y12Z4CB12Z4CR12_444_NV 0x9037 +#define GL_VIDEO_CAPTURE_FRAME_WIDTH_NV 0x9038 +#define GL_VIDEO_CAPTURE_FRAME_HEIGHT_NV 0x9039 +#define GL_VIDEO_CAPTURE_FIELD_UPPER_HEIGHT_NV 0x903A +#define GL_VIDEO_CAPTURE_FIELD_LOWER_HEIGHT_NV 0x903B +#define GL_VIDEO_CAPTURE_SURFACE_ORIGIN_NV 0x903C +#endif + +#ifndef GL_NV_copy_image +#endif + +#ifndef GL_EXT_separate_shader_objects +#define GL_ACTIVE_PROGRAM_EXT 0x8B8D +#endif + +#ifndef GL_NV_parameter_buffer_object2 +#endif + +#ifndef GL_NV_shader_buffer_load +#define GL_BUFFER_GPU_ADDRESS_NV 0x8F1D +#define GL_GPU_ADDRESS_NV 0x8F34 +#define GL_MAX_SHADER_BUFFER_ADDRESS_NV 0x8F35 +#endif + +#ifndef GL_NV_vertex_buffer_unified_memory +#define GL_VERTEX_ATTRIB_ARRAY_UNIFIED_NV 0x8F1E +#define GL_ELEMENT_ARRAY_UNIFIED_NV 0x8F1F +#define GL_VERTEX_ATTRIB_ARRAY_ADDRESS_NV 0x8F20 +#define GL_VERTEX_ARRAY_ADDRESS_NV 0x8F21 +#define GL_NORMAL_ARRAY_ADDRESS_NV 0x8F22 +#define GL_COLOR_ARRAY_ADDRESS_NV 0x8F23 +#define GL_INDEX_ARRAY_ADDRESS_NV 0x8F24 +#define GL_TEXTURE_COORD_ARRAY_ADDRESS_NV 0x8F25 +#define GL_EDGE_FLAG_ARRAY_ADDRESS_NV 0x8F26 +#define GL_SECONDARY_COLOR_ARRAY_ADDRESS_NV 0x8F27 +#define GL_FOG_COORD_ARRAY_ADDRESS_NV 0x8F28 +#define GL_ELEMENT_ARRAY_ADDRESS_NV 0x8F29 +#define GL_VERTEX_ATTRIB_ARRAY_LENGTH_NV 0x8F2A +#define GL_VERTEX_ARRAY_LENGTH_NV 0x8F2B +#define GL_NORMAL_ARRAY_LENGTH_NV 0x8F2C +#define GL_COLOR_ARRAY_LENGTH_NV 0x8F2D +#define GL_INDEX_ARRAY_LENGTH_NV 0x8F2E +#define GL_TEXTURE_COORD_ARRAY_LENGTH_NV 0x8F2F +#define GL_EDGE_FLAG_ARRAY_LENGTH_NV 0x8F30 +#define GL_SECONDARY_COLOR_ARRAY_LENGTH_NV 0x8F31 +#define GL_FOG_COORD_ARRAY_LENGTH_NV 0x8F32 +#define GL_ELEMENT_ARRAY_LENGTH_NV 0x8F33 +#define GL_DRAW_INDIRECT_UNIFIED_NV 0x8F40 +#define GL_DRAW_INDIRECT_ADDRESS_NV 0x8F41 +#define GL_DRAW_INDIRECT_LENGTH_NV 0x8F42 +#endif + +#ifndef GL_NV_texture_barrier +#endif + +#ifndef GL_AMD_shader_stencil_export +#endif + +#ifndef GL_AMD_seamless_cubemap_per_texture +/* reuse GL_TEXTURE_CUBE_MAP_SEAMLESS */ +#endif + +#ifndef GL_AMD_conservative_depth +#endif + +#ifndef GL_EXT_shader_image_load_store +#define GL_MAX_IMAGE_UNITS_EXT 0x8F38 +#define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS_EXT 0x8F39 +#define GL_IMAGE_BINDING_NAME_EXT 0x8F3A +#define GL_IMAGE_BINDING_LEVEL_EXT 0x8F3B +#define GL_IMAGE_BINDING_LAYERED_EXT 0x8F3C +#define GL_IMAGE_BINDING_LAYER_EXT 0x8F3D +#define GL_IMAGE_BINDING_ACCESS_EXT 0x8F3E +#define GL_IMAGE_1D_EXT 0x904C +#define GL_IMAGE_2D_EXT 0x904D +#define GL_IMAGE_3D_EXT 0x904E +#define GL_IMAGE_2D_RECT_EXT 0x904F +#define GL_IMAGE_CUBE_EXT 0x9050 +#define GL_IMAGE_BUFFER_EXT 0x9051 +#define GL_IMAGE_1D_ARRAY_EXT 0x9052 +#define GL_IMAGE_2D_ARRAY_EXT 0x9053 +#define GL_IMAGE_CUBE_MAP_ARRAY_EXT 0x9054 +#define GL_IMAGE_2D_MULTISAMPLE_EXT 0x9055 +#define GL_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x9056 +#define GL_INT_IMAGE_1D_EXT 0x9057 +#define GL_INT_IMAGE_2D_EXT 0x9058 +#define GL_INT_IMAGE_3D_EXT 0x9059 +#define GL_INT_IMAGE_2D_RECT_EXT 0x905A +#define GL_INT_IMAGE_CUBE_EXT 0x905B +#define GL_INT_IMAGE_BUFFER_EXT 0x905C +#define GL_INT_IMAGE_1D_ARRAY_EXT 0x905D +#define GL_INT_IMAGE_2D_ARRAY_EXT 0x905E +#define GL_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x905F +#define GL_INT_IMAGE_2D_MULTISAMPLE_EXT 0x9060 +#define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x9061 +#define GL_UNSIGNED_INT_IMAGE_1D_EXT 0x9062 +#define GL_UNSIGNED_INT_IMAGE_2D_EXT 0x9063 +#define GL_UNSIGNED_INT_IMAGE_3D_EXT 0x9064 +#define GL_UNSIGNED_INT_IMAGE_2D_RECT_EXT 0x9065 +#define GL_UNSIGNED_INT_IMAGE_CUBE_EXT 0x9066 +#define GL_UNSIGNED_INT_IMAGE_BUFFER_EXT 0x9067 +#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY_EXT 0x9068 +#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY_EXT 0x9069 +#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x906A +#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_EXT 0x906B +#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x906C +#define GL_MAX_IMAGE_SAMPLES_EXT 0x906D +#define GL_IMAGE_BINDING_FORMAT_EXT 0x906E +#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT_EXT 0x00000001 +#define GL_ELEMENT_ARRAY_BARRIER_BIT_EXT 0x00000002 +#define GL_UNIFORM_BARRIER_BIT_EXT 0x00000004 +#define GL_TEXTURE_FETCH_BARRIER_BIT_EXT 0x00000008 +#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT_EXT 0x00000020 +#define GL_COMMAND_BARRIER_BIT_EXT 0x00000040 +#define GL_PIXEL_BUFFER_BARRIER_BIT_EXT 0x00000080 +#define GL_TEXTURE_UPDATE_BARRIER_BIT_EXT 0x00000100 +#define GL_BUFFER_UPDATE_BARRIER_BIT_EXT 0x00000200 +#define GL_FRAMEBUFFER_BARRIER_BIT_EXT 0x00000400 +#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT_EXT 0x00000800 +#define GL_ATOMIC_COUNTER_BARRIER_BIT_EXT 0x00001000 +#define GL_ALL_BARRIER_BITS_EXT 0xFFFFFFFF +#endif + +#ifndef GL_EXT_vertex_attrib_64bit +/* reuse GL_DOUBLE */ +#define GL_DOUBLE_VEC2_EXT 0x8FFC +#define GL_DOUBLE_VEC3_EXT 0x8FFD +#define GL_DOUBLE_VEC4_EXT 0x8FFE +#define GL_DOUBLE_MAT2_EXT 0x8F46 +#define GL_DOUBLE_MAT3_EXT 0x8F47 +#define GL_DOUBLE_MAT4_EXT 0x8F48 +#define GL_DOUBLE_MAT2x3_EXT 0x8F49 +#define GL_DOUBLE_MAT2x4_EXT 0x8F4A +#define GL_DOUBLE_MAT3x2_EXT 0x8F4B +#define GL_DOUBLE_MAT3x4_EXT 0x8F4C +#define GL_DOUBLE_MAT4x2_EXT 0x8F4D +#define GL_DOUBLE_MAT4x3_EXT 0x8F4E +#endif + +#ifndef GL_NV_gpu_program5 +#define GL_MAX_GEOMETRY_PROGRAM_INVOCATIONS_NV 0x8E5A +#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET_NV 0x8E5B +#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET_NV 0x8E5C +#define GL_FRAGMENT_PROGRAM_INTERPOLATION_OFFSET_BITS_NV 0x8E5D +#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_NV 0x8E5E +#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_NV 0x8E5F +#define GL_MAX_PROGRAM_SUBROUTINE_PARAMETERS_NV 0x8F44 +#define GL_MAX_PROGRAM_SUBROUTINE_NUM_NV 0x8F45 +#endif + +#ifndef GL_NV_gpu_shader5 +#define GL_INT64_NV 0x140E +#define GL_UNSIGNED_INT64_NV 0x140F +#define GL_INT8_NV 0x8FE0 +#define GL_INT8_VEC2_NV 0x8FE1 +#define GL_INT8_VEC3_NV 0x8FE2 +#define GL_INT8_VEC4_NV 0x8FE3 +#define GL_INT16_NV 0x8FE4 +#define GL_INT16_VEC2_NV 0x8FE5 +#define GL_INT16_VEC3_NV 0x8FE6 +#define GL_INT16_VEC4_NV 0x8FE7 +#define GL_INT64_VEC2_NV 0x8FE9 +#define GL_INT64_VEC3_NV 0x8FEA +#define GL_INT64_VEC4_NV 0x8FEB +#define GL_UNSIGNED_INT8_NV 0x8FEC +#define GL_UNSIGNED_INT8_VEC2_NV 0x8FED +#define GL_UNSIGNED_INT8_VEC3_NV 0x8FEE +#define GL_UNSIGNED_INT8_VEC4_NV 0x8FEF +#define GL_UNSIGNED_INT16_NV 0x8FF0 +#define GL_UNSIGNED_INT16_VEC2_NV 0x8FF1 +#define GL_UNSIGNED_INT16_VEC3_NV 0x8FF2 +#define GL_UNSIGNED_INT16_VEC4_NV 0x8FF3 +#define GL_UNSIGNED_INT64_VEC2_NV 0x8FF5 +#define GL_UNSIGNED_INT64_VEC3_NV 0x8FF6 +#define GL_UNSIGNED_INT64_VEC4_NV 0x8FF7 +#define GL_FLOAT16_NV 0x8FF8 +#define GL_FLOAT16_VEC2_NV 0x8FF9 +#define GL_FLOAT16_VEC3_NV 0x8FFA +#define GL_FLOAT16_VEC4_NV 0x8FFB +/* reuse GL_PATCHES */ +#endif + +#ifndef GL_NV_shader_buffer_store +#define GL_SHADER_GLOBAL_ACCESS_BARRIER_BIT_NV 0x00000010 +/* reuse GL_READ_WRITE */ +/* reuse GL_WRITE_ONLY */ +#endif + +#ifndef GL_NV_tessellation_program5 +#define GL_MAX_PROGRAM_PATCH_ATTRIBS_NV 0x86D8 +#define GL_TESS_CONTROL_PROGRAM_NV 0x891E +#define GL_TESS_EVALUATION_PROGRAM_NV 0x891F +#define GL_TESS_CONTROL_PROGRAM_PARAMETER_BUFFER_NV 0x8C74 +#define GL_TESS_EVALUATION_PROGRAM_PARAMETER_BUFFER_NV 0x8C75 +#endif + +#ifndef GL_NV_vertex_attrib_integer_64bit +/* reuse GL_INT64_NV */ +/* reuse GL_UNSIGNED_INT64_NV */ +#endif + +#ifndef GL_NV_multisample_coverage +#define GL_COVERAGE_SAMPLES_NV 0x80A9 +#define GL_COLOR_SAMPLES_NV 0x8E20 +#endif + +#ifndef GL_AMD_name_gen_delete +#define GL_DATA_BUFFER_AMD 0x9151 +#define GL_PERFORMANCE_MONITOR_AMD 0x9152 +#define GL_QUERY_OBJECT_AMD 0x9153 +#define GL_VERTEX_ARRAY_OBJECT_AMD 0x9154 +#define GL_SAMPLER_OBJECT_AMD 0x9155 +#endif + +#ifndef GL_AMD_debug_output +#define GL_MAX_DEBUG_LOGGED_MESSAGES_AMD 0x9144 +#define GL_DEBUG_LOGGED_MESSAGES_AMD 0x9145 +#define GL_DEBUG_SEVERITY_HIGH_AMD 0x9146 +#define GL_DEBUG_SEVERITY_MEDIUM_AMD 0x9147 +#define GL_DEBUG_SEVERITY_LOW_AMD 0x9148 +#define GL_DEBUG_CATEGORY_API_ERROR_AMD 0x9149 +#define GL_DEBUG_CATEGORY_WINDOW_SYSTEM_AMD 0x914A +#define GL_DEBUG_CATEGORY_DEPRECATION_AMD 0x914B +#define GL_DEBUG_CATEGORY_UNDEFINED_BEHAVIOR_AMD 0x914C +#define GL_DEBUG_CATEGORY_PERFORMANCE_AMD 0x914D +#define GL_DEBUG_CATEGORY_SHADER_COMPILER_AMD 0x914E +#define GL_DEBUG_CATEGORY_APPLICATION_AMD 0x914F +#define GL_DEBUG_CATEGORY_OTHER_AMD 0x9150 +#endif + +#ifndef GL_NV_vdpau_interop +#define GL_SURFACE_STATE_NV 0x86EB +#define GL_SURFACE_REGISTERED_NV 0x86FD +#define GL_SURFACE_MAPPED_NV 0x8700 +#define GL_WRITE_DISCARD_NV 0x88BE +#endif + +#ifndef GL_AMD_transform_feedback3_lines_triangles +#endif + +#ifndef GL_AMD_depth_clamp_separate +#define GL_DEPTH_CLAMP_NEAR_AMD 0x901E +#define GL_DEPTH_CLAMP_FAR_AMD 0x901F +#endif + +#ifndef GL_EXT_texture_sRGB_decode +#define GL_TEXTURE_SRGB_DECODE_EXT 0x8A48 +#define GL_DECODE_EXT 0x8A49 +#define GL_SKIP_DECODE_EXT 0x8A4A +#endif + +#ifndef GL_NV_texture_multisample +#define GL_TEXTURE_COVERAGE_SAMPLES_NV 0x9045 +#define GL_TEXTURE_COLOR_SAMPLES_NV 0x9046 +#endif + +#ifndef GL_AMD_blend_minmax_factor +#define GL_FACTOR_MIN_AMD 0x901C +#define GL_FACTOR_MAX_AMD 0x901D +#endif + +#ifndef GL_AMD_sample_positions +#define GL_SUBSAMPLE_DISTANCE_AMD 0x883F +#endif + +#ifndef GL_EXT_x11_sync_object +#define GL_SYNC_X11_FENCE_EXT 0x90E1 +#endif + +#ifndef GL_AMD_multi_draw_indirect +#endif + +#ifndef GL_EXT_framebuffer_multisample_blit_scaled +#define GL_SCALED_RESOLVE_FASTEST_EXT 0x90BA +#define GL_SCALED_RESOLVE_NICEST_EXT 0x90BB +#endif + + +/*************************************************************/ + +#include +#ifndef GL_VERSION_2_0 +/* GL type for program/shader text */ +typedef char GLchar; +#endif + +#ifndef GL_VERSION_1_5 +/* GL types for handling large vertex buffer objects */ +typedef ptrdiff_t GLintptr; +typedef ptrdiff_t GLsizeiptr; +#endif + +#ifndef GL_ARB_vertex_buffer_object +/* GL types for handling large vertex buffer objects */ +typedef ptrdiff_t GLintptrARB; +typedef ptrdiff_t GLsizeiptrARB; +#endif + +#ifndef GL_ARB_shader_objects +/* GL types for program/shader text and shader object handles */ +typedef char GLcharARB; +typedef unsigned int GLhandleARB; +#endif + +/* GL type for "half" precision (s10e5) float data in host memory */ +#ifndef GL_ARB_half_float_pixel +typedef unsigned short GLhalfARB; +#endif + +#ifndef GL_NV_half_float +typedef unsigned short GLhalfNV; +#endif + +#ifndef GLEXT_64_TYPES_DEFINED +/* This code block is duplicated in glxext.h, so must be protected */ +#define GLEXT_64_TYPES_DEFINED +/* Define int32_t, int64_t, and uint64_t types for UST/MSC */ +/* (as used in the GL_EXT_timer_query extension). */ +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L +#include +#elif defined(__sun__) || defined(__digital__) +#include +#if defined(__STDC__) +#if defined(__arch64__) || defined(_LP64) +typedef long int int64_t; +typedef unsigned long int uint64_t; +#else +typedef long long int int64_t; +typedef unsigned long long int uint64_t; +#endif /* __arch64__ */ +#endif /* __STDC__ */ +#elif defined( __VMS ) || defined(__sgi) +#include +#elif defined(__SCO__) || defined(__USLC__) +#include +#elif defined(__UNIXOS2__) || defined(__SOL64__) +typedef long int int32_t; +typedef long long int int64_t; +typedef unsigned long long int uint64_t; +#elif defined(_WIN32) && defined(__GNUC__) +#include +#elif defined(_WIN32) +typedef __int32 int32_t; +typedef __int64 int64_t; +typedef unsigned __int64 uint64_t; +#else +/* Fallback if nothing above works */ +#include +#endif +#endif + +#ifndef GL_EXT_timer_query +typedef int64_t GLint64EXT; +typedef uint64_t GLuint64EXT; +#endif + +#ifndef GL_ARB_sync +typedef int64_t GLint64; +typedef uint64_t GLuint64; +typedef struct __GLsync *GLsync; +#endif + +#ifndef GL_ARB_cl_event +/* These incomplete types let us declare types compatible with OpenCL's cl_context and cl_event */ +struct _cl_context; +struct _cl_event; +#endif + +#ifndef GL_ARB_debug_output +typedef void (APIENTRY *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam); +#endif + +#ifndef GL_AMD_debug_output +typedef void (APIENTRY *GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam); +#endif + +#ifndef GL_NV_vdpau_interop +typedef GLintptr GLvdpauSurfaceNV; +#endif + +#ifndef GL_VERSION_1_2 +#define GL_VERSION_1_2 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); +GLAPI void APIENTRY glBlendEquation (GLenum mode); +GLAPI void APIENTRY glDrawRangeElements (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); +GLAPI void APIENTRY glTexImage3D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glCopyTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDCOLORPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); +typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); +typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#endif + +#ifndef GL_VERSION_1_2_DEPRECATED +#define GL_VERSION_1_2_DEPRECATED 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorTable (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +GLAPI void APIENTRY glColorTableParameterfv (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glColorTableParameteriv (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glCopyColorTable (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glGetColorTable (GLenum target, GLenum format, GLenum type, GLvoid *table); +GLAPI void APIENTRY glGetColorTableParameterfv (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetColorTableParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glColorSubTable (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); +GLAPI void APIENTRY glCopyColorSubTable (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glConvolutionFilter1D (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); +GLAPI void APIENTRY glConvolutionFilter2D (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); +GLAPI void APIENTRY glConvolutionParameterf (GLenum target, GLenum pname, GLfloat params); +GLAPI void APIENTRY glConvolutionParameterfv (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glConvolutionParameteri (GLenum target, GLenum pname, GLint params); +GLAPI void APIENTRY glConvolutionParameteriv (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glCopyConvolutionFilter1D (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyConvolutionFilter2D (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetConvolutionFilter (GLenum target, GLenum format, GLenum type, GLvoid *image); +GLAPI void APIENTRY glGetConvolutionParameterfv (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetConvolutionParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetSeparableFilter (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); +GLAPI void APIENTRY glSeparableFilter2D (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); +GLAPI void APIENTRY glGetHistogram (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +GLAPI void APIENTRY glGetHistogramParameterfv (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetHistogramParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMinmax (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +GLAPI void APIENTRY glGetMinmaxParameterfv (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMinmaxParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glHistogram (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +GLAPI void APIENTRY glMinmax (GLenum target, GLenum internalformat, GLboolean sink); +GLAPI void APIENTRY glResetHistogram (GLenum target); +GLAPI void APIENTRY glResetMinmax (GLenum target); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIPROC) (GLenum target, GLenum pname, GLint params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); +typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLHISTOGRAMPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLMINMAXPROC) (GLenum target, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLRESETHISTOGRAMPROC) (GLenum target); +typedef void (APIENTRYP PFNGLRESETMINMAXPROC) (GLenum target); +#endif + +#ifndef GL_VERSION_1_3 +#define GL_VERSION_1_3 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveTexture (GLenum texture); +GLAPI void APIENTRY glSampleCoverage (GLclampf value, GLboolean invert); +GLAPI void APIENTRY glCompressedTexImage3D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexImage1D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glGetCompressedTexImage (GLenum target, GLint level, GLvoid *img); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLclampf value, GLboolean invert); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, GLvoid *img); +#endif + +#ifndef GL_VERSION_1_3_DEPRECATED +#define GL_VERSION_1_3_DEPRECATED 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glClientActiveTexture (GLenum texture); +GLAPI void APIENTRY glMultiTexCoord1d (GLenum target, GLdouble s); +GLAPI void APIENTRY glMultiTexCoord1dv (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord1f (GLenum target, GLfloat s); +GLAPI void APIENTRY glMultiTexCoord1fv (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord1i (GLenum target, GLint s); +GLAPI void APIENTRY glMultiTexCoord1iv (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord1s (GLenum target, GLshort s); +GLAPI void APIENTRY glMultiTexCoord1sv (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord2d (GLenum target, GLdouble s, GLdouble t); +GLAPI void APIENTRY glMultiTexCoord2dv (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord2f (GLenum target, GLfloat s, GLfloat t); +GLAPI void APIENTRY glMultiTexCoord2fv (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord2i (GLenum target, GLint s, GLint t); +GLAPI void APIENTRY glMultiTexCoord2iv (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord2s (GLenum target, GLshort s, GLshort t); +GLAPI void APIENTRY glMultiTexCoord2sv (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord3d (GLenum target, GLdouble s, GLdouble t, GLdouble r); +GLAPI void APIENTRY glMultiTexCoord3dv (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord3f (GLenum target, GLfloat s, GLfloat t, GLfloat r); +GLAPI void APIENTRY glMultiTexCoord3fv (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord3i (GLenum target, GLint s, GLint t, GLint r); +GLAPI void APIENTRY glMultiTexCoord3iv (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord3s (GLenum target, GLshort s, GLshort t, GLshort r); +GLAPI void APIENTRY glMultiTexCoord3sv (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord4d (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +GLAPI void APIENTRY glMultiTexCoord4dv (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord4f (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +GLAPI void APIENTRY glMultiTexCoord4fv (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord4i (GLenum target, GLint s, GLint t, GLint r, GLint q); +GLAPI void APIENTRY glMultiTexCoord4iv (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord4s (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +GLAPI void APIENTRY glMultiTexCoord4sv (GLenum target, const GLshort *v); +GLAPI void APIENTRY glLoadTransposeMatrixf (const GLfloat *m); +GLAPI void APIENTRY glLoadTransposeMatrixd (const GLdouble *m); +GLAPI void APIENTRY glMultTransposeMatrixf (const GLfloat *m); +GLAPI void APIENTRY glMultTransposeMatrixd (const GLdouble *m); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DPROC) (GLenum target, GLdouble s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FPROC) (GLenum target, GLfloat s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IPROC) (GLenum target, GLint s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SPROC) (GLenum target, GLshort s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DPROC) (GLenum target, GLdouble s, GLdouble t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IPROC) (GLenum target, GLint s, GLint t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SPROC) (GLenum target, GLshort s, GLshort t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IPROC) (GLenum target, GLint s, GLint t, GLint r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SPROC) (GLenum target, GLshort s, GLshort t, GLshort r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDPROC) (const GLdouble *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDPROC) (const GLdouble *m); +#endif + +#ifndef GL_VERSION_1_4 +#define GL_VERSION_1_4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparate (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +GLAPI void APIENTRY glMultiDrawArrays (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +GLAPI void APIENTRY glMultiDrawElements (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); +GLAPI void APIENTRY glPointParameterf (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPointParameterfv (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glPointParameteri (GLenum pname, GLint param); +GLAPI void APIENTRY glPointParameteriv (GLenum pname, const GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIVPROC) (GLenum pname, const GLint *params); +#endif + +#ifndef GL_VERSION_1_4_DEPRECATED +#define GL_VERSION_1_4_DEPRECATED 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFogCoordf (GLfloat coord); +GLAPI void APIENTRY glFogCoordfv (const GLfloat *coord); +GLAPI void APIENTRY glFogCoordd (GLdouble coord); +GLAPI void APIENTRY glFogCoorddv (const GLdouble *coord); +GLAPI void APIENTRY glFogCoordPointer (GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glSecondaryColor3b (GLbyte red, GLbyte green, GLbyte blue); +GLAPI void APIENTRY glSecondaryColor3bv (const GLbyte *v); +GLAPI void APIENTRY glSecondaryColor3d (GLdouble red, GLdouble green, GLdouble blue); +GLAPI void APIENTRY glSecondaryColor3dv (const GLdouble *v); +GLAPI void APIENTRY glSecondaryColor3f (GLfloat red, GLfloat green, GLfloat blue); +GLAPI void APIENTRY glSecondaryColor3fv (const GLfloat *v); +GLAPI void APIENTRY glSecondaryColor3i (GLint red, GLint green, GLint blue); +GLAPI void APIENTRY glSecondaryColor3iv (const GLint *v); +GLAPI void APIENTRY glSecondaryColor3s (GLshort red, GLshort green, GLshort blue); +GLAPI void APIENTRY glSecondaryColor3sv (const GLshort *v); +GLAPI void APIENTRY glSecondaryColor3ub (GLubyte red, GLubyte green, GLubyte blue); +GLAPI void APIENTRY glSecondaryColor3ubv (const GLubyte *v); +GLAPI void APIENTRY glSecondaryColor3ui (GLuint red, GLuint green, GLuint blue); +GLAPI void APIENTRY glSecondaryColor3uiv (const GLuint *v); +GLAPI void APIENTRY glSecondaryColor3us (GLushort red, GLushort green, GLushort blue); +GLAPI void APIENTRY glSecondaryColor3usv (const GLushort *v); +GLAPI void APIENTRY glSecondaryColorPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glWindowPos2d (GLdouble x, GLdouble y); +GLAPI void APIENTRY glWindowPos2dv (const GLdouble *v); +GLAPI void APIENTRY glWindowPos2f (GLfloat x, GLfloat y); +GLAPI void APIENTRY glWindowPos2fv (const GLfloat *v); +GLAPI void APIENTRY glWindowPos2i (GLint x, GLint y); +GLAPI void APIENTRY glWindowPos2iv (const GLint *v); +GLAPI void APIENTRY glWindowPos2s (GLshort x, GLshort y); +GLAPI void APIENTRY glWindowPos2sv (const GLshort *v); +GLAPI void APIENTRY glWindowPos3d (GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glWindowPos3dv (const GLdouble *v); +GLAPI void APIENTRY glWindowPos3f (GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glWindowPos3fv (const GLfloat *v); +GLAPI void APIENTRY glWindowPos3i (GLint x, GLint y, GLint z); +GLAPI void APIENTRY glWindowPos3iv (const GLint *v); +GLAPI void APIENTRY glWindowPos3s (GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glWindowPos3sv (const GLshort *v); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFOGCOORDFPROC) (GLfloat coord); +typedef void (APIENTRYP PFNGLFOGCOORDFVPROC) (const GLfloat *coord); +typedef void (APIENTRYP PFNGLFOGCOORDDPROC) (GLdouble coord); +typedef void (APIENTRYP PFNGLFOGCOORDDVPROC) (const GLdouble *coord); +typedef void (APIENTRYP PFNGLFOGCOORDPOINTERPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BPROC) (GLbyte red, GLbyte green, GLbyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DPROC) (GLdouble red, GLdouble green, GLdouble blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FPROC) (GLfloat red, GLfloat green, GLfloat blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IPROC) (GLint red, GLint green, GLint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SPROC) (GLshort red, GLshort green, GLshort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBPROC) (GLubyte red, GLubyte green, GLubyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVPROC) (const GLubyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIPROC) (GLuint red, GLuint green, GLuint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVPROC) (const GLuint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USPROC) (GLushort red, GLushort green, GLushort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVPROC) (const GLushort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLWINDOWPOS2DPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLWINDOWPOS2DVPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2FPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLWINDOWPOS2FVPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2IPROC) (GLint x, GLint y); +typedef void (APIENTRYP PFNGLWINDOWPOS2IVPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2SPROC) (GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLWINDOWPOS2SVPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3DPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLWINDOWPOS3DVPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3FPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLWINDOWPOS3FVPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3IPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLWINDOWPOS3IVPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3SPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLWINDOWPOS3SVPROC) (const GLshort *v); +#endif + +#ifndef GL_VERSION_1_5 +#define GL_VERSION_1_5 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenQueries (GLsizei n, GLuint *ids); +GLAPI void APIENTRY glDeleteQueries (GLsizei n, const GLuint *ids); +GLAPI GLboolean APIENTRY glIsQuery (GLuint id); +GLAPI void APIENTRY glBeginQuery (GLenum target, GLuint id); +GLAPI void APIENTRY glEndQuery (GLenum target); +GLAPI void APIENTRY glGetQueryiv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetQueryObjectiv (GLuint id, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetQueryObjectuiv (GLuint id, GLenum pname, GLuint *params); +GLAPI void APIENTRY glBindBuffer (GLenum target, GLuint buffer); +GLAPI void APIENTRY glDeleteBuffers (GLsizei n, const GLuint *buffers); +GLAPI void APIENTRY glGenBuffers (GLsizei n, GLuint *buffers); +GLAPI GLboolean APIENTRY glIsBuffer (GLuint buffer); +GLAPI void APIENTRY glBufferData (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage); +GLAPI void APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data); +GLAPI void APIENTRY glGetBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data); +GLAPI GLvoid* APIENTRY glMapBuffer (GLenum target, GLenum access); +GLAPI GLboolean APIENTRY glUnmapBuffer (GLenum target); +GLAPI void APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetBufferPointerv (GLenum target, GLenum pname, GLvoid* *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGENQUERIESPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEQUERIESPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISQUERYPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINQUERYPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLENDQUERYPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETQUERYIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVPROC) (GLuint id, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer); +typedef void (APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers); +typedef void (APIENTRYP PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers); +typedef GLboolean (APIENTRYP PFNGLISBUFFERPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage); +typedef void (APIENTRYP PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data); +typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERPROC) (GLenum target, GLenum access); +typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVPROC) (GLenum target, GLenum pname, GLvoid* *params); +#endif + +#ifndef GL_VERSION_2_0 +#define GL_VERSION_2_0 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha); +GLAPI void APIENTRY glDrawBuffers (GLsizei n, const GLenum *bufs); +GLAPI void APIENTRY glStencilOpSeparate (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +GLAPI void APIENTRY glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask); +GLAPI void APIENTRY glStencilMaskSeparate (GLenum face, GLuint mask); +GLAPI void APIENTRY glAttachShader (GLuint program, GLuint shader); +GLAPI void APIENTRY glBindAttribLocation (GLuint program, GLuint index, const GLchar *name); +GLAPI void APIENTRY glCompileShader (GLuint shader); +GLAPI GLuint APIENTRY glCreateProgram (void); +GLAPI GLuint APIENTRY glCreateShader (GLenum type); +GLAPI void APIENTRY glDeleteProgram (GLuint program); +GLAPI void APIENTRY glDeleteShader (GLuint shader); +GLAPI void APIENTRY glDetachShader (GLuint program, GLuint shader); +GLAPI void APIENTRY glDisableVertexAttribArray (GLuint index); +GLAPI void APIENTRY glEnableVertexAttribArray (GLuint index); +GLAPI void APIENTRY glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +GLAPI void APIENTRY glGetActiveUniform (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +GLAPI void APIENTRY glGetAttachedShaders (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *obj); +GLAPI GLint APIENTRY glGetAttribLocation (GLuint program, const GLchar *name); +GLAPI void APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +GLAPI void APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +GLAPI void APIENTRY glGetShaderSource (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); +GLAPI GLint APIENTRY glGetUniformLocation (GLuint program, const GLchar *name); +GLAPI void APIENTRY glGetUniformfv (GLuint program, GLint location, GLfloat *params); +GLAPI void APIENTRY glGetUniformiv (GLuint program, GLint location, GLint *params); +GLAPI void APIENTRY glGetVertexAttribdv (GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, GLvoid* *pointer); +GLAPI GLboolean APIENTRY glIsProgram (GLuint program); +GLAPI GLboolean APIENTRY glIsShader (GLuint shader); +GLAPI void APIENTRY glLinkProgram (GLuint program); +GLAPI void APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar* *string, const GLint *length); +GLAPI void APIENTRY glUseProgram (GLuint program); +GLAPI void APIENTRY glUniform1f (GLint location, GLfloat v0); +GLAPI void APIENTRY glUniform2f (GLint location, GLfloat v0, GLfloat v1); +GLAPI void APIENTRY glUniform3f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GLAPI void APIENTRY glUniform4f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GLAPI void APIENTRY glUniform1i (GLint location, GLint v0); +GLAPI void APIENTRY glUniform2i (GLint location, GLint v0, GLint v1); +GLAPI void APIENTRY glUniform3i (GLint location, GLint v0, GLint v1, GLint v2); +GLAPI void APIENTRY glUniform4i (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GLAPI void APIENTRY glUniform1fv (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform2fv (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform3fv (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform4fv (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform1iv (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform2iv (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform3iv (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform4iv (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glValidateProgram (GLuint program); +GLAPI void APIENTRY glVertexAttrib1d (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttrib1dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib1f (GLuint index, GLfloat x); +GLAPI void APIENTRY glVertexAttrib1fv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib1s (GLuint index, GLshort x); +GLAPI void APIENTRY glVertexAttrib1sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib2d (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttrib2dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib2f (GLuint index, GLfloat x, GLfloat y); +GLAPI void APIENTRY glVertexAttrib2fv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib2s (GLuint index, GLshort x, GLshort y); +GLAPI void APIENTRY glVertexAttrib2sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib3d (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttrib3dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib3f (GLuint index, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glVertexAttrib3fv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib3s (GLuint index, GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glVertexAttrib3sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4Nbv (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttrib4Niv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttrib4Nsv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4Nub (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +GLAPI void APIENTRY glVertexAttrib4Nubv (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttrib4Nuiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttrib4Nusv (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttrib4bv (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttrib4d (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttrib4dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib4f (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glVertexAttrib4fv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib4iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttrib4s (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glVertexAttrib4sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4ubv (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttrib4uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttrib4usv (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttribPointer (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha); +typedef void (APIENTRYP PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum *bufs); +typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC) (GLenum face, GLenum func, GLint ref, GLuint mask); +typedef void (APIENTRYP PFNGLSTENCILMASKSEPARATEPROC) (GLenum face, GLuint mask); +typedef void (APIENTRYP PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader); +typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar *name); +typedef void (APIENTRYP PFNGLCOMPILESHADERPROC) (GLuint shader); +typedef GLuint (APIENTRYP PFNGLCREATEPROGRAMPROC) (void); +typedef GLuint (APIENTRYP PFNGLCREATESHADERPROC) (GLenum type); +typedef void (APIENTRYP PFNGLDELETEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLDELETESHADERPROC) (GLuint shader); +typedef void (APIENTRYP PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader); +typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index); +typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index); +typedef void (APIENTRYP PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *obj); +typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (APIENTRYP PFNGLGETSHADERSOURCEPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); +typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat *params); +typedef void (APIENTRYP PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, GLvoid* *pointer); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMPROC) (GLuint program); +typedef GLboolean (APIENTRYP PFNGLISSHADERPROC) (GLuint shader); +typedef void (APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar* *string, const GLint *length); +typedef void (APIENTRYP PFNGLUSEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLUNIFORM1IPROC) (GLint location, GLint v0); +typedef void (APIENTRYP PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SPROC) (GLuint index, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_VERSION_2_1 +#define GL_VERSION_2_1 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUniformMatrix2x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix3x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix2x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix4x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix3x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix4x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +#endif + +#ifndef GL_VERSION_3_0 +#define GL_VERSION_3_0 1 +/* OpenGL 3.0 also reuses entry points from these extensions: */ +/* ARB_framebuffer_object */ +/* ARB_map_buffer_range */ +/* ARB_vertex_array_object */ +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorMaski (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +GLAPI void APIENTRY glGetBooleani_v (GLenum target, GLuint index, GLboolean *data); +GLAPI void APIENTRY glGetIntegeri_v (GLenum target, GLuint index, GLint *data); +GLAPI void APIENTRY glEnablei (GLenum target, GLuint index); +GLAPI void APIENTRY glDisablei (GLenum target, GLuint index); +GLAPI GLboolean APIENTRY glIsEnabledi (GLenum target, GLuint index); +GLAPI void APIENTRY glBeginTransformFeedback (GLenum primitiveMode); +GLAPI void APIENTRY glEndTransformFeedback (void); +GLAPI void APIENTRY glBindBufferRange (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glBindBufferBase (GLenum target, GLuint index, GLuint buffer); +GLAPI void APIENTRY glTransformFeedbackVaryings (GLuint program, GLsizei count, const GLchar* *varyings, GLenum bufferMode); +GLAPI void APIENTRY glGetTransformFeedbackVarying (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +GLAPI void APIENTRY glClampColor (GLenum target, GLenum clamp); +GLAPI void APIENTRY glBeginConditionalRender (GLuint id, GLenum mode); +GLAPI void APIENTRY glEndConditionalRender (void); +GLAPI void APIENTRY glVertexAttribIPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glGetVertexAttribIiv (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribIuiv (GLuint index, GLenum pname, GLuint *params); +GLAPI void APIENTRY glVertexAttribI1i (GLuint index, GLint x); +GLAPI void APIENTRY glVertexAttribI2i (GLuint index, GLint x, GLint y); +GLAPI void APIENTRY glVertexAttribI3i (GLuint index, GLint x, GLint y, GLint z); +GLAPI void APIENTRY glVertexAttribI4i (GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glVertexAttribI1ui (GLuint index, GLuint x); +GLAPI void APIENTRY glVertexAttribI2ui (GLuint index, GLuint x, GLuint y); +GLAPI void APIENTRY glVertexAttribI3ui (GLuint index, GLuint x, GLuint y, GLuint z); +GLAPI void APIENTRY glVertexAttribI4ui (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glVertexAttribI1iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI2iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI3iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI4iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI1uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI2uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI3uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI4uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI4bv (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttribI4sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttribI4ubv (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttribI4usv (GLuint index, const GLushort *v); +GLAPI void APIENTRY glGetUniformuiv (GLuint program, GLint location, GLuint *params); +GLAPI void APIENTRY glBindFragDataLocation (GLuint program, GLuint color, const GLchar *name); +GLAPI GLint APIENTRY glGetFragDataLocation (GLuint program, const GLchar *name); +GLAPI void APIENTRY glUniform1ui (GLint location, GLuint v0); +GLAPI void APIENTRY glUniform2ui (GLint location, GLuint v0, GLuint v1); +GLAPI void APIENTRY glUniform3ui (GLint location, GLuint v0, GLuint v1, GLuint v2); +GLAPI void APIENTRY glUniform4ui (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GLAPI void APIENTRY glUniform1uiv (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform2uiv (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform3uiv (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform4uiv (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glTexParameterIiv (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTexParameterIuiv (GLenum target, GLenum pname, const GLuint *params); +GLAPI void APIENTRY glGetTexParameterIiv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTexParameterIuiv (GLenum target, GLenum pname, GLuint *params); +GLAPI void APIENTRY glClearBufferiv (GLenum buffer, GLint drawbuffer, const GLint *value); +GLAPI void APIENTRY glClearBufferuiv (GLenum buffer, GLint drawbuffer, const GLuint *value); +GLAPI void APIENTRY glClearBufferfv (GLenum buffer, GLint drawbuffer, const GLfloat *value); +GLAPI void APIENTRY glClearBufferfi (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); +GLAPI const GLubyte * APIENTRY glGetStringi (GLenum name, GLuint index); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORMASKIPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +typedef void (APIENTRYP PFNGLGETBOOLEANI_VPROC) (GLenum target, GLuint index, GLboolean *data); +typedef void (APIENTRYP PFNGLGETINTEGERI_VPROC) (GLenum target, GLuint index, GLint *data); +typedef void (APIENTRYP PFNGLENABLEIPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLDISABLEIPROC) (GLenum target, GLuint index); +typedef GLboolean (APIENTRYP PFNGLISENABLEDIPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKPROC) (GLenum primitiveMode); +typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKPROC) (void); +typedef void (APIENTRYP PFNGLBINDBUFFERRANGEPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLBINDBUFFERBASEPROC) (GLenum target, GLuint index, GLuint buffer); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSPROC) (GLuint program, GLsizei count, const GLchar* *varyings, GLenum bufferMode); +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLCLAMPCOLORPROC) (GLenum target, GLenum clamp); +typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERPROC) (GLuint id, GLenum mode); +typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERPROC) (void); +typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVPROC) (GLuint index, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IPROC) (GLuint index, GLint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IPROC) (GLuint index, GLint x, GLint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IPROC) (GLuint index, GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIPROC) (GLuint index, GLuint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIPROC) (GLuint index, GLuint x, GLuint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLGETUNIFORMUIVPROC) (GLuint program, GLint location, GLuint *params); +typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONPROC) (GLuint program, GLuint color, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLUNIFORM1UIPROC) (GLint location, GLuint v0); +typedef void (APIENTRYP PFNGLUNIFORM2UIPROC) (GLint location, GLuint v0, GLuint v1); +typedef void (APIENTRYP PFNGLUNIFORM3UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (APIENTRYP PFNGLUNIFORM4UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (APIENTRYP PFNGLUNIFORM1UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM2UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM3UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM4UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLCLEARBUFFERIVPROC) (GLenum buffer, GLint drawbuffer, const GLint *value); +typedef void (APIENTRYP PFNGLCLEARBUFFERUIVPROC) (GLenum buffer, GLint drawbuffer, const GLuint *value); +typedef void (APIENTRYP PFNGLCLEARBUFFERFVPROC) (GLenum buffer, GLint drawbuffer, const GLfloat *value); +typedef void (APIENTRYP PFNGLCLEARBUFFERFIPROC) (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); +typedef const GLubyte * (APIENTRYP PFNGLGETSTRINGIPROC) (GLenum name, GLuint index); +#endif + +#ifndef GL_VERSION_3_1 +#define GL_VERSION_3_1 1 +/* OpenGL 3.1 also reuses entry points from these extensions: */ +/* ARB_copy_buffer */ +/* ARB_uniform_buffer_object */ +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawArraysInstanced (GLenum mode, GLint first, GLsizei count, GLsizei primcount); +GLAPI void APIENTRY glDrawElementsInstanced (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); +GLAPI void APIENTRY glTexBuffer (GLenum target, GLenum internalformat, GLuint buffer); +GLAPI void APIENTRY glPrimitiveRestartIndex (GLuint index); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); +typedef void (APIENTRYP PFNGLTEXBUFFERPROC) (GLenum target, GLenum internalformat, GLuint buffer); +typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXPROC) (GLuint index); +#endif + +#ifndef GL_VERSION_3_2 +#define GL_VERSION_3_2 1 +/* OpenGL 3.2 also reuses entry points from these extensions: */ +/* ARB_draw_elements_base_vertex */ +/* ARB_provoking_vertex */ +/* ARB_sync */ +/* ARB_texture_multisample */ +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetInteger64i_v (GLenum target, GLuint index, GLint64 *data); +GLAPI void APIENTRY glGetBufferParameteri64v (GLenum target, GLenum pname, GLint64 *params); +GLAPI void APIENTRY glFramebufferTexture (GLenum target, GLenum attachment, GLuint texture, GLint level); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETINTEGER64I_VPROC) (GLenum target, GLuint index, GLint64 *data); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERI64VPROC) (GLenum target, GLenum pname, GLint64 *params); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); +#endif + +#ifndef GL_VERSION_3_3 +#define GL_VERSION_3_3 1 +/* OpenGL 3.3 also reuses entry points from these extensions: */ +/* ARB_blend_func_extended */ +/* ARB_sampler_objects */ +/* ARB_explicit_attrib_location, but it has none */ +/* ARB_occlusion_query2 (no entry points) */ +/* ARB_shader_bit_encoding (no entry points) */ +/* ARB_texture_rgb10_a2ui (no entry points) */ +/* ARB_texture_swizzle (no entry points) */ +/* ARB_timer_query */ +/* ARB_vertex_type_2_10_10_10_rev */ +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribDivisor (GLuint index, GLuint divisor); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORPROC) (GLuint index, GLuint divisor); +#endif + +#ifndef GL_VERSION_4_0 +#define GL_VERSION_4_0 1 +/* OpenGL 4.0 also reuses entry points from these extensions: */ +/* ARB_texture_query_lod (no entry points) */ +/* ARB_draw_indirect */ +/* ARB_gpu_shader5 (no entry points) */ +/* ARB_gpu_shader_fp64 */ +/* ARB_shader_subroutine */ +/* ARB_tessellation_shader */ +/* ARB_texture_buffer_object_rgb32 (no entry points) */ +/* ARB_texture_cube_map_array (no entry points) */ +/* ARB_texture_gather (no entry points) */ +/* ARB_transform_feedback2 */ +/* ARB_transform_feedback3 */ +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMinSampleShading (GLclampf value); +GLAPI void APIENTRY glBlendEquationi (GLuint buf, GLenum mode); +GLAPI void APIENTRY glBlendEquationSeparatei (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +GLAPI void APIENTRY glBlendFunci (GLuint buf, GLenum src, GLenum dst); +GLAPI void APIENTRY glBlendFuncSeparatei (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLMINSAMPLESHADINGPROC) (GLclampf value); +typedef void (APIENTRYP PFNGLBLENDEQUATIONIPROC) (GLuint buf, GLenum mode); +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEIPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +typedef void (APIENTRYP PFNGLBLENDFUNCIPROC) (GLuint buf, GLenum src, GLenum dst); +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +#endif + +#ifndef GL_VERSION_4_1 +#define GL_VERSION_4_1 1 +/* OpenGL 4.1 reuses entry points from these extensions: */ +/* ARB_ES2_compatibility */ +/* ARB_get_program_binary */ +/* ARB_separate_shader_objects */ +/* ARB_shader_precision (no entry points) */ +/* ARB_vertex_attrib_64bit */ +/* ARB_viewport_array */ +#endif + +#ifndef GL_VERSION_4_2 +#define GL_VERSION_4_2 1 +/* OpenGL 4.2 reuses entry points from these extensions: */ +/* ARB_base_instance */ +/* ARB_shading_language_420pack (no entry points) */ +/* ARB_transform_feedback_instanced */ +/* ARB_compressed_texture_pixel_storage (no entry points) */ +/* ARB_conservative_depth (no entry points) */ +/* ARB_internalformat_query */ +/* ARB_map_buffer_alignment (no entry points) */ +/* ARB_shader_atomic_counters */ +/* ARB_shader_image_load_store */ +/* ARB_shading_language_packing (no entry points) */ +/* ARB_texture_storage */ +#endif + +#ifndef GL_ARB_multitexture +#define GL_ARB_multitexture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveTextureARB (GLenum texture); +GLAPI void APIENTRY glClientActiveTextureARB (GLenum texture); +GLAPI void APIENTRY glMultiTexCoord1dARB (GLenum target, GLdouble s); +GLAPI void APIENTRY glMultiTexCoord1dvARB (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord1fARB (GLenum target, GLfloat s); +GLAPI void APIENTRY glMultiTexCoord1fvARB (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord1iARB (GLenum target, GLint s); +GLAPI void APIENTRY glMultiTexCoord1ivARB (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord1sARB (GLenum target, GLshort s); +GLAPI void APIENTRY glMultiTexCoord1svARB (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord2dARB (GLenum target, GLdouble s, GLdouble t); +GLAPI void APIENTRY glMultiTexCoord2dvARB (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord2fARB (GLenum target, GLfloat s, GLfloat t); +GLAPI void APIENTRY glMultiTexCoord2fvARB (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord2iARB (GLenum target, GLint s, GLint t); +GLAPI void APIENTRY glMultiTexCoord2ivARB (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord2sARB (GLenum target, GLshort s, GLshort t); +GLAPI void APIENTRY glMultiTexCoord2svARB (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord3dARB (GLenum target, GLdouble s, GLdouble t, GLdouble r); +GLAPI void APIENTRY glMultiTexCoord3dvARB (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord3fARB (GLenum target, GLfloat s, GLfloat t, GLfloat r); +GLAPI void APIENTRY glMultiTexCoord3fvARB (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord3iARB (GLenum target, GLint s, GLint t, GLint r); +GLAPI void APIENTRY glMultiTexCoord3ivARB (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord3sARB (GLenum target, GLshort s, GLshort t, GLshort r); +GLAPI void APIENTRY glMultiTexCoord3svARB (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord4dARB (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +GLAPI void APIENTRY glMultiTexCoord4dvARB (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord4fARB (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +GLAPI void APIENTRY glMultiTexCoord4fvARB (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord4iARB (GLenum target, GLint s, GLint t, GLint r, GLint q); +GLAPI void APIENTRY glMultiTexCoord4ivARB (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord4sARB (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +GLAPI void APIENTRY glMultiTexCoord4svARB (GLenum target, const GLshort *v); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v); +#endif + +#ifndef GL_ARB_transpose_matrix +#define GL_ARB_transpose_matrix 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glLoadTransposeMatrixfARB (const GLfloat *m); +GLAPI void APIENTRY glLoadTransposeMatrixdARB (const GLdouble *m); +GLAPI void APIENTRY glMultTransposeMatrixfARB (const GLfloat *m); +GLAPI void APIENTRY glMultTransposeMatrixdARB (const GLdouble *m); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); +#endif + +#ifndef GL_ARB_multisample +#define GL_ARB_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSampleCoverageARB (GLclampf value, GLboolean invert); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSAMPLECOVERAGEARBPROC) (GLclampf value, GLboolean invert); +#endif + +#ifndef GL_ARB_texture_env_add +#define GL_ARB_texture_env_add 1 +#endif + +#ifndef GL_ARB_texture_cube_map +#define GL_ARB_texture_cube_map 1 +#endif + +#ifndef GL_ARB_texture_compression +#define GL_ARB_texture_compression 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCompressedTexImage3DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexImage2DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexImage1DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexSubImage3DARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexSubImage2DARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexSubImage1DARB (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glGetCompressedTexImageARB (GLenum target, GLint level, GLvoid *img); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint level, GLvoid *img); +#endif + +#ifndef GL_ARB_texture_border_clamp +#define GL_ARB_texture_border_clamp 1 +#endif + +#ifndef GL_ARB_point_parameters +#define GL_ARB_point_parameters 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameterfARB (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPointParameterfvARB (GLenum pname, const GLfloat *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPOINTPARAMETERFARBPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVARBPROC) (GLenum pname, const GLfloat *params); +#endif + +#ifndef GL_ARB_vertex_blend +#define GL_ARB_vertex_blend 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWeightbvARB (GLint size, const GLbyte *weights); +GLAPI void APIENTRY glWeightsvARB (GLint size, const GLshort *weights); +GLAPI void APIENTRY glWeightivARB (GLint size, const GLint *weights); +GLAPI void APIENTRY glWeightfvARB (GLint size, const GLfloat *weights); +GLAPI void APIENTRY glWeightdvARB (GLint size, const GLdouble *weights); +GLAPI void APIENTRY glWeightubvARB (GLint size, const GLubyte *weights); +GLAPI void APIENTRY glWeightusvARB (GLint size, const GLushort *weights); +GLAPI void APIENTRY glWeightuivARB (GLint size, const GLuint *weights); +GLAPI void APIENTRY glWeightPointerARB (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glVertexBlendARB (GLint count); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLWEIGHTBVARBPROC) (GLint size, const GLbyte *weights); +typedef void (APIENTRYP PFNGLWEIGHTSVARBPROC) (GLint size, const GLshort *weights); +typedef void (APIENTRYP PFNGLWEIGHTIVARBPROC) (GLint size, const GLint *weights); +typedef void (APIENTRYP PFNGLWEIGHTFVARBPROC) (GLint size, const GLfloat *weights); +typedef void (APIENTRYP PFNGLWEIGHTDVARBPROC) (GLint size, const GLdouble *weights); +typedef void (APIENTRYP PFNGLWEIGHTUBVARBPROC) (GLint size, const GLubyte *weights); +typedef void (APIENTRYP PFNGLWEIGHTUSVARBPROC) (GLint size, const GLushort *weights); +typedef void (APIENTRYP PFNGLWEIGHTUIVARBPROC) (GLint size, const GLuint *weights); +typedef void (APIENTRYP PFNGLWEIGHTPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLVERTEXBLENDARBPROC) (GLint count); +#endif + +#ifndef GL_ARB_matrix_palette +#define GL_ARB_matrix_palette 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCurrentPaletteMatrixARB (GLint index); +GLAPI void APIENTRY glMatrixIndexubvARB (GLint size, const GLubyte *indices); +GLAPI void APIENTRY glMatrixIndexusvARB (GLint size, const GLushort *indices); +GLAPI void APIENTRY glMatrixIndexuivARB (GLint size, const GLuint *indices); +GLAPI void APIENTRY glMatrixIndexPointerARB (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCURRENTPALETTEMATRIXARBPROC) (GLint index); +typedef void (APIENTRYP PFNGLMATRIXINDEXUBVARBPROC) (GLint size, const GLubyte *indices); +typedef void (APIENTRYP PFNGLMATRIXINDEXUSVARBPROC) (GLint size, const GLushort *indices); +typedef void (APIENTRYP PFNGLMATRIXINDEXUIVARBPROC) (GLint size, const GLuint *indices); +typedef void (APIENTRYP PFNGLMATRIXINDEXPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_ARB_texture_env_combine +#define GL_ARB_texture_env_combine 1 +#endif + +#ifndef GL_ARB_texture_env_crossbar +#define GL_ARB_texture_env_crossbar 1 +#endif + +#ifndef GL_ARB_texture_env_dot3 +#define GL_ARB_texture_env_dot3 1 +#endif + +#ifndef GL_ARB_texture_mirrored_repeat +#define GL_ARB_texture_mirrored_repeat 1 +#endif + +#ifndef GL_ARB_depth_texture +#define GL_ARB_depth_texture 1 +#endif + +#ifndef GL_ARB_shadow +#define GL_ARB_shadow 1 +#endif + +#ifndef GL_ARB_shadow_ambient +#define GL_ARB_shadow_ambient 1 +#endif + +#ifndef GL_ARB_window_pos +#define GL_ARB_window_pos 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWindowPos2dARB (GLdouble x, GLdouble y); +GLAPI void APIENTRY glWindowPos2dvARB (const GLdouble *v); +GLAPI void APIENTRY glWindowPos2fARB (GLfloat x, GLfloat y); +GLAPI void APIENTRY glWindowPos2fvARB (const GLfloat *v); +GLAPI void APIENTRY glWindowPos2iARB (GLint x, GLint y); +GLAPI void APIENTRY glWindowPos2ivARB (const GLint *v); +GLAPI void APIENTRY glWindowPos2sARB (GLshort x, GLshort y); +GLAPI void APIENTRY glWindowPos2svARB (const GLshort *v); +GLAPI void APIENTRY glWindowPos3dARB (GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glWindowPos3dvARB (const GLdouble *v); +GLAPI void APIENTRY glWindowPos3fARB (GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glWindowPos3fvARB (const GLfloat *v); +GLAPI void APIENTRY glWindowPos3iARB (GLint x, GLint y, GLint z); +GLAPI void APIENTRY glWindowPos3ivARB (const GLint *v); +GLAPI void APIENTRY glWindowPos3sARB (GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glWindowPos3svARB (const GLshort *v); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLWINDOWPOS2DARBPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLWINDOWPOS2DVARBPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2FARBPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLWINDOWPOS2FVARBPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2IARBPROC) (GLint x, GLint y); +typedef void (APIENTRYP PFNGLWINDOWPOS2IVARBPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2SARBPROC) (GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLWINDOWPOS2SVARBPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3DARBPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLWINDOWPOS3DVARBPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3FARBPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLWINDOWPOS3FVARBPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3IARBPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLWINDOWPOS3IVARBPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3SARBPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLWINDOWPOS3SVARBPROC) (const GLshort *v); +#endif + +#ifndef GL_ARB_vertex_program +#define GL_ARB_vertex_program 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttrib1dARB (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttrib1dvARB (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib1fARB (GLuint index, GLfloat x); +GLAPI void APIENTRY glVertexAttrib1fvARB (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib1sARB (GLuint index, GLshort x); +GLAPI void APIENTRY glVertexAttrib1svARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib2dARB (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttrib2dvARB (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib2fARB (GLuint index, GLfloat x, GLfloat y); +GLAPI void APIENTRY glVertexAttrib2fvARB (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib2sARB (GLuint index, GLshort x, GLshort y); +GLAPI void APIENTRY glVertexAttrib2svARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib3dARB (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttrib3dvARB (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib3fARB (GLuint index, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glVertexAttrib3fvARB (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib3sARB (GLuint index, GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glVertexAttrib3svARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4NbvARB (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttrib4NivARB (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttrib4NsvARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4NubARB (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +GLAPI void APIENTRY glVertexAttrib4NubvARB (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttrib4NuivARB (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttrib4NusvARB (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttrib4bvARB (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttrib4dARB (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttrib4dvARB (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib4fARB (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glVertexAttrib4fvARB (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib4ivARB (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttrib4sARB (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glVertexAttrib4svARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4ubvARB (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttrib4uivARB (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttrib4usvARB (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttribPointerARB (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glEnableVertexAttribArrayARB (GLuint index); +GLAPI void APIENTRY glDisableVertexAttribArrayARB (GLuint index); +GLAPI void APIENTRY glProgramStringARB (GLenum target, GLenum format, GLsizei len, const GLvoid *string); +GLAPI void APIENTRY glBindProgramARB (GLenum target, GLuint program); +GLAPI void APIENTRY glDeleteProgramsARB (GLsizei n, const GLuint *programs); +GLAPI void APIENTRY glGenProgramsARB (GLsizei n, GLuint *programs); +GLAPI void APIENTRY glProgramEnvParameter4dARB (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramEnvParameter4dvARB (GLenum target, GLuint index, const GLdouble *params); +GLAPI void APIENTRY glProgramEnvParameter4fARB (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glProgramEnvParameter4fvARB (GLenum target, GLuint index, const GLfloat *params); +GLAPI void APIENTRY glProgramLocalParameter4dARB (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramLocalParameter4dvARB (GLenum target, GLuint index, const GLdouble *params); +GLAPI void APIENTRY glProgramLocalParameter4fARB (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glProgramLocalParameter4fvARB (GLenum target, GLuint index, const GLfloat *params); +GLAPI void APIENTRY glGetProgramEnvParameterdvARB (GLenum target, GLuint index, GLdouble *params); +GLAPI void APIENTRY glGetProgramEnvParameterfvARB (GLenum target, GLuint index, GLfloat *params); +GLAPI void APIENTRY glGetProgramLocalParameterdvARB (GLenum target, GLuint index, GLdouble *params); +GLAPI void APIENTRY glGetProgramLocalParameterfvARB (GLenum target, GLuint index, GLfloat *params); +GLAPI void APIENTRY glGetProgramivARB (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetProgramStringARB (GLenum target, GLenum pname, GLvoid *string); +GLAPI void APIENTRY glGetVertexAttribdvARB (GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetVertexAttribfvARB (GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVertexAttribivARB (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribPointervARB (GLuint index, GLenum pname, GLvoid* *pointer); +GLAPI GLboolean APIENTRY glIsProgramARB (GLuint program); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DARBPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FARBPROC) (GLuint index, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SARBPROC) (GLuint index, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DARBPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FARBPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SARBPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVARBPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVARBPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBARBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVARBPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVARBPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVARBPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVARBPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVARBPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVARBPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVARBPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVARBPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERARBPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); +typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); +typedef void (APIENTRYP PFNGLPROGRAMSTRINGARBPROC) (GLenum target, GLenum format, GLsizei len, const GLvoid *string); +typedef void (APIENTRYP PFNGLBINDPROGRAMARBPROC) (GLenum target, GLuint program); +typedef void (APIENTRYP PFNGLDELETEPROGRAMSARBPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRYP PFNGLGENPROGRAMSARBPROC) (GLsizei n, GLuint *programs); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGARBPROC) (GLenum target, GLenum pname, GLvoid *string); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVARBPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVARBPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVARBPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVARBPROC) (GLuint index, GLenum pname, GLvoid* *pointer); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMARBPROC) (GLuint program); +#endif + +#ifndef GL_ARB_fragment_program +#define GL_ARB_fragment_program 1 +/* All ARB_fragment_program entry points are shared with ARB_vertex_program. */ +#endif + +#ifndef GL_ARB_vertex_buffer_object +#define GL_ARB_vertex_buffer_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindBufferARB (GLenum target, GLuint buffer); +GLAPI void APIENTRY glDeleteBuffersARB (GLsizei n, const GLuint *buffers); +GLAPI void APIENTRY glGenBuffersARB (GLsizei n, GLuint *buffers); +GLAPI GLboolean APIENTRY glIsBufferARB (GLuint buffer); +GLAPI void APIENTRY glBufferDataARB (GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage); +GLAPI void APIENTRY glBufferSubDataARB (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid *data); +GLAPI void APIENTRY glGetBufferSubDataARB (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid *data); +GLAPI GLvoid* APIENTRY glMapBufferARB (GLenum target, GLenum access); +GLAPI GLboolean APIENTRY glUnmapBufferARB (GLenum target); +GLAPI void APIENTRY glGetBufferParameterivARB (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetBufferPointervARB (GLenum target, GLenum pname, GLvoid* *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDBUFFERARBPROC) (GLenum target, GLuint buffer); +typedef void (APIENTRYP PFNGLDELETEBUFFERSARBPROC) (GLsizei n, const GLuint *buffers); +typedef void (APIENTRYP PFNGLGENBUFFERSARBPROC) (GLsizei n, GLuint *buffers); +typedef GLboolean (APIENTRYP PFNGLISBUFFERARBPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLBUFFERDATAARBPROC) (GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage); +typedef void (APIENTRYP PFNGLBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid *data); +typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERARBPROC) (GLenum target, GLenum access); +typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERARBPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVARBPROC) (GLenum target, GLenum pname, GLvoid* *params); +#endif + +#ifndef GL_ARB_occlusion_query +#define GL_ARB_occlusion_query 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenQueriesARB (GLsizei n, GLuint *ids); +GLAPI void APIENTRY glDeleteQueriesARB (GLsizei n, const GLuint *ids); +GLAPI GLboolean APIENTRY glIsQueryARB (GLuint id); +GLAPI void APIENTRY glBeginQueryARB (GLenum target, GLuint id); +GLAPI void APIENTRY glEndQueryARB (GLenum target); +GLAPI void APIENTRY glGetQueryivARB (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetQueryObjectivARB (GLuint id, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetQueryObjectuivARB (GLuint id, GLenum pname, GLuint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGENQUERIESARBPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEQUERIESARBPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISQUERYARBPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINQUERYARBPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLENDQUERYARBPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETQUERYIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVARBPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVARBPROC) (GLuint id, GLenum pname, GLuint *params); +#endif + +#ifndef GL_ARB_shader_objects +#define GL_ARB_shader_objects 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDeleteObjectARB (GLhandleARB obj); +GLAPI GLhandleARB APIENTRY glGetHandleARB (GLenum pname); +GLAPI void APIENTRY glDetachObjectARB (GLhandleARB containerObj, GLhandleARB attachedObj); +GLAPI GLhandleARB APIENTRY glCreateShaderObjectARB (GLenum shaderType); +GLAPI void APIENTRY glShaderSourceARB (GLhandleARB shaderObj, GLsizei count, const GLcharARB* *string, const GLint *length); +GLAPI void APIENTRY glCompileShaderARB (GLhandleARB shaderObj); +GLAPI GLhandleARB APIENTRY glCreateProgramObjectARB (void); +GLAPI void APIENTRY glAttachObjectARB (GLhandleARB containerObj, GLhandleARB obj); +GLAPI void APIENTRY glLinkProgramARB (GLhandleARB programObj); +GLAPI void APIENTRY glUseProgramObjectARB (GLhandleARB programObj); +GLAPI void APIENTRY glValidateProgramARB (GLhandleARB programObj); +GLAPI void APIENTRY glUniform1fARB (GLint location, GLfloat v0); +GLAPI void APIENTRY glUniform2fARB (GLint location, GLfloat v0, GLfloat v1); +GLAPI void APIENTRY glUniform3fARB (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GLAPI void APIENTRY glUniform4fARB (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GLAPI void APIENTRY glUniform1iARB (GLint location, GLint v0); +GLAPI void APIENTRY glUniform2iARB (GLint location, GLint v0, GLint v1); +GLAPI void APIENTRY glUniform3iARB (GLint location, GLint v0, GLint v1, GLint v2); +GLAPI void APIENTRY glUniform4iARB (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GLAPI void APIENTRY glUniform1fvARB (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform2fvARB (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform3fvARB (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform4fvARB (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform1ivARB (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform2ivARB (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform3ivARB (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform4ivARB (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniformMatrix2fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix3fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix4fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glGetObjectParameterfvARB (GLhandleARB obj, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetObjectParameterivARB (GLhandleARB obj, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetInfoLogARB (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); +GLAPI void APIENTRY glGetAttachedObjectsARB (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj); +GLAPI GLint APIENTRY glGetUniformLocationARB (GLhandleARB programObj, const GLcharARB *name); +GLAPI void APIENTRY glGetActiveUniformARB (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +GLAPI void APIENTRY glGetUniformfvARB (GLhandleARB programObj, GLint location, GLfloat *params); +GLAPI void APIENTRY glGetUniformivARB (GLhandleARB programObj, GLint location, GLint *params); +GLAPI void APIENTRY glGetShaderSourceARB (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDELETEOBJECTARBPROC) (GLhandleARB obj); +typedef GLhandleARB (APIENTRYP PFNGLGETHANDLEARBPROC) (GLenum pname); +typedef void (APIENTRYP PFNGLDETACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB attachedObj); +typedef GLhandleARB (APIENTRYP PFNGLCREATESHADEROBJECTARBPROC) (GLenum shaderType); +typedef void (APIENTRYP PFNGLSHADERSOURCEARBPROC) (GLhandleARB shaderObj, GLsizei count, const GLcharARB* *string, const GLint *length); +typedef void (APIENTRYP PFNGLCOMPILESHADERARBPROC) (GLhandleARB shaderObj); +typedef GLhandleARB (APIENTRYP PFNGLCREATEPROGRAMOBJECTARBPROC) (void); +typedef void (APIENTRYP PFNGLATTACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB obj); +typedef void (APIENTRYP PFNGLLINKPROGRAMARBPROC) (GLhandleARB programObj); +typedef void (APIENTRYP PFNGLUSEPROGRAMOBJECTARBPROC) (GLhandleARB programObj); +typedef void (APIENTRYP PFNGLVALIDATEPROGRAMARBPROC) (GLhandleARB programObj); +typedef void (APIENTRYP PFNGLUNIFORM1FARBPROC) (GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLUNIFORM2FARBPROC) (GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLUNIFORM3FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLUNIFORM4FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLUNIFORM1IARBPROC) (GLint location, GLint v0); +typedef void (APIENTRYP PFNGLUNIFORM2IARBPROC) (GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLUNIFORM3IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLUNIFORM4IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLUNIFORM1FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM2FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM3FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM4FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM1IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM2IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM3IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM4IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERFVARBPROC) (GLhandleARB obj, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVARBPROC) (GLhandleARB obj, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETINFOLOGARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); +typedef void (APIENTRYP PFNGLGETATTACHEDOBJECTSARBPROC) (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj); +typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +typedef void (APIENTRYP PFNGLGETUNIFORMFVARBPROC) (GLhandleARB programObj, GLint location, GLfloat *params); +typedef void (APIENTRYP PFNGLGETUNIFORMIVARBPROC) (GLhandleARB programObj, GLint location, GLint *params); +typedef void (APIENTRYP PFNGLGETSHADERSOURCEARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source); +#endif + +#ifndef GL_ARB_vertex_shader +#define GL_ARB_vertex_shader 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindAttribLocationARB (GLhandleARB programObj, GLuint index, const GLcharARB *name); +GLAPI void APIENTRY glGetActiveAttribARB (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +GLAPI GLint APIENTRY glGetAttribLocationARB (GLhandleARB programObj, const GLcharARB *name); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONARBPROC) (GLhandleARB programObj, GLuint index, const GLcharARB *name); +typedef void (APIENTRYP PFNGLGETACTIVEATTRIBARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); +#endif + +#ifndef GL_ARB_fragment_shader +#define GL_ARB_fragment_shader 1 +#endif + +#ifndef GL_ARB_shading_language_100 +#define GL_ARB_shading_language_100 1 +#endif + +#ifndef GL_ARB_texture_non_power_of_two +#define GL_ARB_texture_non_power_of_two 1 +#endif + +#ifndef GL_ARB_point_sprite +#define GL_ARB_point_sprite 1 +#endif + +#ifndef GL_ARB_fragment_program_shadow +#define GL_ARB_fragment_program_shadow 1 +#endif + +#ifndef GL_ARB_draw_buffers +#define GL_ARB_draw_buffers 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawBuffersARB (GLsizei n, const GLenum *bufs); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWBUFFERSARBPROC) (GLsizei n, const GLenum *bufs); +#endif + +#ifndef GL_ARB_texture_rectangle +#define GL_ARB_texture_rectangle 1 +#endif + +#ifndef GL_ARB_color_buffer_float +#define GL_ARB_color_buffer_float 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glClampColorARB (GLenum target, GLenum clamp); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCLAMPCOLORARBPROC) (GLenum target, GLenum clamp); +#endif + +#ifndef GL_ARB_half_float_pixel +#define GL_ARB_half_float_pixel 1 +#endif + +#ifndef GL_ARB_texture_float +#define GL_ARB_texture_float 1 +#endif + +#ifndef GL_ARB_pixel_buffer_object +#define GL_ARB_pixel_buffer_object 1 +#endif + +#ifndef GL_ARB_depth_buffer_float +#define GL_ARB_depth_buffer_float 1 +#endif + +#ifndef GL_ARB_draw_instanced +#define GL_ARB_draw_instanced 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawArraysInstancedARB (GLenum mode, GLint first, GLsizei count, GLsizei primcount); +GLAPI void APIENTRY glDrawElementsInstancedARB (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDARBPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDARBPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); +#endif + +#ifndef GL_ARB_framebuffer_object +#define GL_ARB_framebuffer_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glIsRenderbuffer (GLuint renderbuffer); +GLAPI void APIENTRY glBindRenderbuffer (GLenum target, GLuint renderbuffer); +GLAPI void APIENTRY glDeleteRenderbuffers (GLsizei n, const GLuint *renderbuffers); +GLAPI void APIENTRY glGenRenderbuffers (GLsizei n, GLuint *renderbuffers); +GLAPI void APIENTRY glRenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetRenderbufferParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI GLboolean APIENTRY glIsFramebuffer (GLuint framebuffer); +GLAPI void APIENTRY glBindFramebuffer (GLenum target, GLuint framebuffer); +GLAPI void APIENTRY glDeleteFramebuffers (GLsizei n, const GLuint *framebuffers); +GLAPI void APIENTRY glGenFramebuffers (GLsizei n, GLuint *framebuffers); +GLAPI GLenum APIENTRY glCheckFramebufferStatus (GLenum target); +GLAPI void APIENTRY glFramebufferTexture1D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTexture3D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +GLAPI void APIENTRY glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +GLAPI void APIENTRY glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint *params); +GLAPI void APIENTRY glGenerateMipmap (GLenum target); +GLAPI void APIENTRY glBlitFramebuffer (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +GLAPI void APIENTRY glRenderbufferStorageMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glFramebufferTextureLayer (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFERPROC) (GLuint renderbuffer); +typedef void (APIENTRYP PFNGLBINDRENDERBUFFERPROC) (GLenum target, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSPROC) (GLsizei n, const GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLGENRENDERBUFFERSPROC) (GLsizei n, GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFERPROC) (GLuint framebuffer); +typedef void (APIENTRYP PFNGLBINDFRAMEBUFFERPROC) (GLenum target, GLuint framebuffer); +typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSPROC) (GLsizei n, const GLuint *framebuffers); +typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSPROC) (GLsizei n, GLuint *framebuffers); +typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSPROC) (GLenum target); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFERPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGENERATEMIPMAPPROC) (GLenum target); +typedef void (APIENTRYP PFNGLBLITFRAMEBUFFERPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +#endif + +#ifndef GL_ARB_framebuffer_sRGB +#define GL_ARB_framebuffer_sRGB 1 +#endif + +#ifndef GL_ARB_geometry_shader4 +#define GL_ARB_geometry_shader4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramParameteriARB (GLuint program, GLenum pname, GLint value); +GLAPI void APIENTRY glFramebufferTextureARB (GLenum target, GLenum attachment, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTextureLayerARB (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +GLAPI void APIENTRY glFramebufferTextureFaceARB (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIARBPROC) (GLuint program, GLenum pname, GLint value); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREFACEARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +#endif + +#ifndef GL_ARB_half_float_vertex +#define GL_ARB_half_float_vertex 1 +#endif + +#ifndef GL_ARB_instanced_arrays +#define GL_ARB_instanced_arrays 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribDivisorARB (GLuint index, GLuint divisor); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORARBPROC) (GLuint index, GLuint divisor); +#endif + +#ifndef GL_ARB_map_buffer_range +#define GL_ARB_map_buffer_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLvoid* APIENTRY glMapBufferRange (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +GLAPI void APIENTRY glFlushMappedBufferRange (GLenum target, GLintptr offset, GLsizeiptr length); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length); +#endif + +#ifndef GL_ARB_texture_buffer_object +#define GL_ARB_texture_buffer_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexBufferARB (GLenum target, GLenum internalformat, GLuint buffer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXBUFFERARBPROC) (GLenum target, GLenum internalformat, GLuint buffer); +#endif + +#ifndef GL_ARB_texture_compression_rgtc +#define GL_ARB_texture_compression_rgtc 1 +#endif + +#ifndef GL_ARB_texture_rg +#define GL_ARB_texture_rg 1 +#endif + +#ifndef GL_ARB_vertex_array_object +#define GL_ARB_vertex_array_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindVertexArray (GLuint array); +GLAPI void APIENTRY glDeleteVertexArrays (GLsizei n, const GLuint *arrays); +GLAPI void APIENTRY glGenVertexArrays (GLsizei n, GLuint *arrays); +GLAPI GLboolean APIENTRY glIsVertexArray (GLuint array); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDVERTEXARRAYPROC) (GLuint array); +typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSPROC) (GLsizei n, const GLuint *arrays); +typedef void (APIENTRYP PFNGLGENVERTEXARRAYSPROC) (GLsizei n, GLuint *arrays); +typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYPROC) (GLuint array); +#endif + +#ifndef GL_ARB_uniform_buffer_object +#define GL_ARB_uniform_buffer_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetUniformIndices (GLuint program, GLsizei uniformCount, const GLchar* *uniformNames, GLuint *uniformIndices); +GLAPI void APIENTRY glGetActiveUniformsiv (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetActiveUniformName (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName); +GLAPI GLuint APIENTRY glGetUniformBlockIndex (GLuint program, const GLchar *uniformBlockName); +GLAPI void APIENTRY glGetActiveUniformBlockiv (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetActiveUniformBlockName (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); +GLAPI void APIENTRY glUniformBlockBinding (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETUNIFORMINDICESPROC) (GLuint program, GLsizei uniformCount, const GLchar* *uniformNames, GLuint *uniformIndices); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMSIVPROC) (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMNAMEPROC) (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName); +typedef GLuint (APIENTRYP PFNGLGETUNIFORMBLOCKINDEXPROC) (GLuint program, const GLchar *uniformBlockName); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKIVPROC) (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC) (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); +typedef void (APIENTRYP PFNGLUNIFORMBLOCKBINDINGPROC) (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); +#endif + +#ifndef GL_ARB_compatibility +#define GL_ARB_compatibility 1 +#endif + +#ifndef GL_ARB_copy_buffer +#define GL_ARB_copy_buffer 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCopyBufferSubData (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOPYBUFFERSUBDATAPROC) (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +#endif + +#ifndef GL_ARB_shader_texture_lod +#define GL_ARB_shader_texture_lod 1 +#endif + +#ifndef GL_ARB_depth_clamp +#define GL_ARB_depth_clamp 1 +#endif + +#ifndef GL_ARB_draw_elements_base_vertex +#define GL_ARB_draw_elements_base_vertex 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawElementsBaseVertex (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); +GLAPI void APIENTRY glDrawRangeElementsBaseVertex (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); +GLAPI void APIENTRY glDrawElementsInstancedBaseVertex (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount, GLint basevertex); +GLAPI void APIENTRY glMultiDrawElementsBaseVertex (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount, const GLint *basevertex); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount, GLint basevertex); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount, const GLint *basevertex); +#endif + +#ifndef GL_ARB_fragment_coord_conventions +#define GL_ARB_fragment_coord_conventions 1 +#endif + +#ifndef GL_ARB_provoking_vertex +#define GL_ARB_provoking_vertex 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProvokingVertex (GLenum mode); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROVOKINGVERTEXPROC) (GLenum mode); +#endif + +#ifndef GL_ARB_seamless_cube_map +#define GL_ARB_seamless_cube_map 1 +#endif + +#ifndef GL_ARB_sync +#define GL_ARB_sync 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLsync APIENTRY glFenceSync (GLenum condition, GLbitfield flags); +GLAPI GLboolean APIENTRY glIsSync (GLsync sync); +GLAPI void APIENTRY glDeleteSync (GLsync sync); +GLAPI GLenum APIENTRY glClientWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); +GLAPI void APIENTRY glWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); +GLAPI void APIENTRY glGetInteger64v (GLenum pname, GLint64 *params); +GLAPI void APIENTRY glGetSynciv (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLsync (APIENTRYP PFNGLFENCESYNCPROC) (GLenum condition, GLbitfield flags); +typedef GLboolean (APIENTRYP PFNGLISSYNCPROC) (GLsync sync); +typedef void (APIENTRYP PFNGLDELETESYNCPROC) (GLsync sync); +typedef GLenum (APIENTRYP PFNGLCLIENTWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef void (APIENTRYP PFNGLWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef void (APIENTRYP PFNGLGETINTEGER64VPROC) (GLenum pname, GLint64 *params); +typedef void (APIENTRYP PFNGLGETSYNCIVPROC) (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +#endif + +#ifndef GL_ARB_texture_multisample +#define GL_ARB_texture_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexImage2DMultisample (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTexImage3DMultisample (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glGetMultisamplefv (GLenum pname, GLuint index, GLfloat *val); +GLAPI void APIENTRY glSampleMaski (GLuint index, GLbitfield mask); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLGETMULTISAMPLEFVPROC) (GLenum pname, GLuint index, GLfloat *val); +typedef void (APIENTRYP PFNGLSAMPLEMASKIPROC) (GLuint index, GLbitfield mask); +#endif + +#ifndef GL_ARB_vertex_array_bgra +#define GL_ARB_vertex_array_bgra 1 +#endif + +#ifndef GL_ARB_draw_buffers_blend +#define GL_ARB_draw_buffers_blend 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationiARB (GLuint buf, GLenum mode); +GLAPI void APIENTRY glBlendEquationSeparateiARB (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +GLAPI void APIENTRY glBlendFunciARB (GLuint buf, GLenum src, GLenum dst); +GLAPI void APIENTRY glBlendFuncSeparateiARB (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDEQUATIONIARBPROC) (GLuint buf, GLenum mode); +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEIARBPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +typedef void (APIENTRYP PFNGLBLENDFUNCIARBPROC) (GLuint buf, GLenum src, GLenum dst); +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIARBPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +#endif + +#ifndef GL_ARB_sample_shading +#define GL_ARB_sample_shading 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMinSampleShadingARB (GLclampf value); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLMINSAMPLESHADINGARBPROC) (GLclampf value); +#endif + +#ifndef GL_ARB_texture_cube_map_array +#define GL_ARB_texture_cube_map_array 1 +#endif + +#ifndef GL_ARB_texture_gather +#define GL_ARB_texture_gather 1 +#endif + +#ifndef GL_ARB_texture_query_lod +#define GL_ARB_texture_query_lod 1 +#endif + +#ifndef GL_ARB_shading_language_include +#define GL_ARB_shading_language_include 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glNamedStringARB (GLenum type, GLint namelen, const GLchar *name, GLint stringlen, const GLchar *string); +GLAPI void APIENTRY glDeleteNamedStringARB (GLint namelen, const GLchar *name); +GLAPI void APIENTRY glCompileShaderIncludeARB (GLuint shader, GLsizei count, const GLchar* *path, const GLint *length); +GLAPI GLboolean APIENTRY glIsNamedStringARB (GLint namelen, const GLchar *name); +GLAPI void APIENTRY glGetNamedStringARB (GLint namelen, const GLchar *name, GLsizei bufSize, GLint *stringlen, GLchar *string); +GLAPI void APIENTRY glGetNamedStringivARB (GLint namelen, const GLchar *name, GLenum pname, GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLNAMEDSTRINGARBPROC) (GLenum type, GLint namelen, const GLchar *name, GLint stringlen, const GLchar *string); +typedef void (APIENTRYP PFNGLDELETENAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name); +typedef void (APIENTRYP PFNGLCOMPILESHADERINCLUDEARBPROC) (GLuint shader, GLsizei count, const GLchar* *path, const GLint *length); +typedef GLboolean (APIENTRYP PFNGLISNAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name); +typedef void (APIENTRYP PFNGLGETNAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name, GLsizei bufSize, GLint *stringlen, GLchar *string); +typedef void (APIENTRYP PFNGLGETNAMEDSTRINGIVARBPROC) (GLint namelen, const GLchar *name, GLenum pname, GLint *params); +#endif + +#ifndef GL_ARB_texture_compression_bptc +#define GL_ARB_texture_compression_bptc 1 +#endif + +#ifndef GL_ARB_blend_func_extended +#define GL_ARB_blend_func_extended 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindFragDataLocationIndexed (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name); +GLAPI GLint APIENTRY glGetFragDataIndex (GLuint program, const GLchar *name); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONINDEXEDPROC) (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETFRAGDATAINDEXPROC) (GLuint program, const GLchar *name); +#endif + +#ifndef GL_ARB_explicit_attrib_location +#define GL_ARB_explicit_attrib_location 1 +#endif + +#ifndef GL_ARB_occlusion_query2 +#define GL_ARB_occlusion_query2 1 +#endif + +#ifndef GL_ARB_sampler_objects +#define GL_ARB_sampler_objects 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenSamplers (GLsizei count, GLuint *samplers); +GLAPI void APIENTRY glDeleteSamplers (GLsizei count, const GLuint *samplers); +GLAPI GLboolean APIENTRY glIsSampler (GLuint sampler); +GLAPI void APIENTRY glBindSampler (GLuint unit, GLuint sampler); +GLAPI void APIENTRY glSamplerParameteri (GLuint sampler, GLenum pname, GLint param); +GLAPI void APIENTRY glSamplerParameteriv (GLuint sampler, GLenum pname, const GLint *param); +GLAPI void APIENTRY glSamplerParameterf (GLuint sampler, GLenum pname, GLfloat param); +GLAPI void APIENTRY glSamplerParameterfv (GLuint sampler, GLenum pname, const GLfloat *param); +GLAPI void APIENTRY glSamplerParameterIiv (GLuint sampler, GLenum pname, const GLint *param); +GLAPI void APIENTRY glSamplerParameterIuiv (GLuint sampler, GLenum pname, const GLuint *param); +GLAPI void APIENTRY glGetSamplerParameteriv (GLuint sampler, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetSamplerParameterIiv (GLuint sampler, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetSamplerParameterfv (GLuint sampler, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetSamplerParameterIuiv (GLuint sampler, GLenum pname, GLuint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGENSAMPLERSPROC) (GLsizei count, GLuint *samplers); +typedef void (APIENTRYP PFNGLDELETESAMPLERSPROC) (GLsizei count, const GLuint *samplers); +typedef GLboolean (APIENTRYP PFNGLISSAMPLERPROC) (GLuint sampler); +typedef void (APIENTRYP PFNGLBINDSAMPLERPROC) (GLuint unit, GLuint sampler); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIPROC) (GLuint sampler, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, const GLint *param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFPROC) (GLuint sampler, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, const GLfloat *param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, const GLint *param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, const GLuint *param); +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, GLuint *params); +#endif + +#ifndef GL_ARB_shader_bit_encoding +#define GL_ARB_shader_bit_encoding 1 +#endif + +#ifndef GL_ARB_texture_rgb10_a2ui +#define GL_ARB_texture_rgb10_a2ui 1 +#endif + +#ifndef GL_ARB_texture_swizzle +#define GL_ARB_texture_swizzle 1 +#endif + +#ifndef GL_ARB_timer_query +#define GL_ARB_timer_query 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glQueryCounter (GLuint id, GLenum target); +GLAPI void APIENTRY glGetQueryObjecti64v (GLuint id, GLenum pname, GLint64 *params); +GLAPI void APIENTRY glGetQueryObjectui64v (GLuint id, GLenum pname, GLuint64 *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLQUERYCOUNTERPROC) (GLuint id, GLenum target); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VPROC) (GLuint id, GLenum pname, GLint64 *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VPROC) (GLuint id, GLenum pname, GLuint64 *params); +#endif + +#ifndef GL_ARB_vertex_type_2_10_10_10_rev +#define GL_ARB_vertex_type_2_10_10_10_rev 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexP2ui (GLenum type, GLuint value); +GLAPI void APIENTRY glVertexP2uiv (GLenum type, const GLuint *value); +GLAPI void APIENTRY glVertexP3ui (GLenum type, GLuint value); +GLAPI void APIENTRY glVertexP3uiv (GLenum type, const GLuint *value); +GLAPI void APIENTRY glVertexP4ui (GLenum type, GLuint value); +GLAPI void APIENTRY glVertexP4uiv (GLenum type, const GLuint *value); +GLAPI void APIENTRY glTexCoordP1ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glTexCoordP1uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glTexCoordP2ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glTexCoordP2uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glTexCoordP3ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glTexCoordP3uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glTexCoordP4ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glTexCoordP4uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glMultiTexCoordP1ui (GLenum texture, GLenum type, GLuint coords); +GLAPI void APIENTRY glMultiTexCoordP1uiv (GLenum texture, GLenum type, const GLuint *coords); +GLAPI void APIENTRY glMultiTexCoordP2ui (GLenum texture, GLenum type, GLuint coords); +GLAPI void APIENTRY glMultiTexCoordP2uiv (GLenum texture, GLenum type, const GLuint *coords); +GLAPI void APIENTRY glMultiTexCoordP3ui (GLenum texture, GLenum type, GLuint coords); +GLAPI void APIENTRY glMultiTexCoordP3uiv (GLenum texture, GLenum type, const GLuint *coords); +GLAPI void APIENTRY glMultiTexCoordP4ui (GLenum texture, GLenum type, GLuint coords); +GLAPI void APIENTRY glMultiTexCoordP4uiv (GLenum texture, GLenum type, const GLuint *coords); +GLAPI void APIENTRY glNormalP3ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glNormalP3uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glColorP3ui (GLenum type, GLuint color); +GLAPI void APIENTRY glColorP3uiv (GLenum type, const GLuint *color); +GLAPI void APIENTRY glColorP4ui (GLenum type, GLuint color); +GLAPI void APIENTRY glColorP4uiv (GLenum type, const GLuint *color); +GLAPI void APIENTRY glSecondaryColorP3ui (GLenum type, GLuint color); +GLAPI void APIENTRY glSecondaryColorP3uiv (GLenum type, const GLuint *color); +GLAPI void APIENTRY glVertexAttribP1ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI void APIENTRY glVertexAttribP1uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +GLAPI void APIENTRY glVertexAttribP2ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI void APIENTRY glVertexAttribP2uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +GLAPI void APIENTRY glVertexAttribP3ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI void APIENTRY glVertexAttribP3uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +GLAPI void APIENTRY glVertexAttribP4ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI void APIENTRY glVertexAttribP4uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXP2UIPROC) (GLenum type, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXP2UIVPROC) (GLenum type, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXP3UIPROC) (GLenum type, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXP3UIVPROC) (GLenum type, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXP4UIPROC) (GLenum type, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXP4UIVPROC) (GLenum type, const GLuint *value); +typedef void (APIENTRYP PFNGLTEXCOORDP1UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLTEXCOORDP1UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLTEXCOORDP2UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLTEXCOORDP2UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLTEXCOORDP3UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLTEXCOORDP3UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLTEXCOORDP4UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLTEXCOORDP4UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLNORMALP3UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLNORMALP3UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLCOLORP3UIPROC) (GLenum type, GLuint color); +typedef void (APIENTRYP PFNGLCOLORP3UIVPROC) (GLenum type, const GLuint *color); +typedef void (APIENTRYP PFNGLCOLORP4UIPROC) (GLenum type, GLuint color); +typedef void (APIENTRYP PFNGLCOLORP4UIVPROC) (GLenum type, const GLuint *color); +typedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIPROC) (GLenum type, GLuint color); +typedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIVPROC) (GLenum type, const GLuint *color); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +#endif + +#ifndef GL_ARB_draw_indirect +#define GL_ARB_draw_indirect 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawArraysIndirect (GLenum mode, const GLvoid *indirect); +GLAPI void APIENTRY glDrawElementsIndirect (GLenum mode, GLenum type, const GLvoid *indirect); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWARRAYSINDIRECTPROC) (GLenum mode, const GLvoid *indirect); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const GLvoid *indirect); +#endif + +#ifndef GL_ARB_gpu_shader5 +#define GL_ARB_gpu_shader5 1 +#endif + +#ifndef GL_ARB_gpu_shader_fp64 +#define GL_ARB_gpu_shader_fp64 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUniform1d (GLint location, GLdouble x); +GLAPI void APIENTRY glUniform2d (GLint location, GLdouble x, GLdouble y); +GLAPI void APIENTRY glUniform3d (GLint location, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glUniform4d (GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glUniform1dv (GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glUniform2dv (GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glUniform3dv (GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glUniform4dv (GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix2x3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix2x4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix3x2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix3x4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix4x2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix4x3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glGetUniformdv (GLuint program, GLint location, GLdouble *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLUNIFORM1DPROC) (GLint location, GLdouble x); +typedef void (APIENTRYP PFNGLUNIFORM2DPROC) (GLint location, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLUNIFORM3DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLUNIFORM4DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLUNIFORM1DVPROC) (GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORM2DVPROC) (GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORM3DVPROC) (GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORM4DVPROC) (GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLGETUNIFORMDVPROC) (GLuint program, GLint location, GLdouble *params); +#endif + +#ifndef GL_ARB_shader_subroutine +#define GL_ARB_shader_subroutine 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLint APIENTRY glGetSubroutineUniformLocation (GLuint program, GLenum shadertype, const GLchar *name); +GLAPI GLuint APIENTRY glGetSubroutineIndex (GLuint program, GLenum shadertype, const GLchar *name); +GLAPI void APIENTRY glGetActiveSubroutineUniformiv (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values); +GLAPI void APIENTRY glGetActiveSubroutineUniformName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); +GLAPI void APIENTRY glGetActiveSubroutineName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); +GLAPI void APIENTRY glUniformSubroutinesuiv (GLenum shadertype, GLsizei count, const GLuint *indices); +GLAPI void APIENTRY glGetUniformSubroutineuiv (GLenum shadertype, GLint location, GLuint *params); +GLAPI void APIENTRY glGetProgramStageiv (GLuint program, GLenum shadertype, GLenum pname, GLint *values); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLint (APIENTRYP PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC) (GLuint program, GLenum shadertype, const GLchar *name); +typedef GLuint (APIENTRYP PFNGLGETSUBROUTINEINDEXPROC) (GLuint program, GLenum shadertype, const GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC) (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values); +typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINENAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); +typedef void (APIENTRYP PFNGLUNIFORMSUBROUTINESUIVPROC) (GLenum shadertype, GLsizei count, const GLuint *indices); +typedef void (APIENTRYP PFNGLGETUNIFORMSUBROUTINEUIVPROC) (GLenum shadertype, GLint location, GLuint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSTAGEIVPROC) (GLuint program, GLenum shadertype, GLenum pname, GLint *values); +#endif + +#ifndef GL_ARB_tessellation_shader +#define GL_ARB_tessellation_shader 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPatchParameteri (GLenum pname, GLint value); +GLAPI void APIENTRY glPatchParameterfv (GLenum pname, const GLfloat *values); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPATCHPARAMETERIPROC) (GLenum pname, GLint value); +typedef void (APIENTRYP PFNGLPATCHPARAMETERFVPROC) (GLenum pname, const GLfloat *values); +#endif + +#ifndef GL_ARB_texture_buffer_object_rgb32 +#define GL_ARB_texture_buffer_object_rgb32 1 +#endif + +#ifndef GL_ARB_transform_feedback2 +#define GL_ARB_transform_feedback2 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindTransformFeedback (GLenum target, GLuint id); +GLAPI void APIENTRY glDeleteTransformFeedbacks (GLsizei n, const GLuint *ids); +GLAPI void APIENTRY glGenTransformFeedbacks (GLsizei n, GLuint *ids); +GLAPI GLboolean APIENTRY glIsTransformFeedback (GLuint id); +GLAPI void APIENTRY glPauseTransformFeedback (void); +GLAPI void APIENTRY glResumeTransformFeedback (void); +GLAPI void APIENTRY glDrawTransformFeedback (GLenum mode, GLuint id); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDTRANSFORMFEEDBACKPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSPROC) (GLsizei n, const GLuint *ids); +typedef void (APIENTRYP PFNGLGENTRANSFORMFEEDBACKSPROC) (GLsizei n, GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISTRANSFORMFEEDBACKPROC) (GLuint id); +typedef void (APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKPROC) (void); +typedef void (APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKPROC) (void); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKPROC) (GLenum mode, GLuint id); +#endif + +#ifndef GL_ARB_transform_feedback3 +#define GL_ARB_transform_feedback3 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawTransformFeedbackStream (GLenum mode, GLuint id, GLuint stream); +GLAPI void APIENTRY glBeginQueryIndexed (GLenum target, GLuint index, GLuint id); +GLAPI void APIENTRY glEndQueryIndexed (GLenum target, GLuint index); +GLAPI void APIENTRY glGetQueryIndexediv (GLenum target, GLuint index, GLenum pname, GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC) (GLenum mode, GLuint id, GLuint stream); +typedef void (APIENTRYP PFNGLBEGINQUERYINDEXEDPROC) (GLenum target, GLuint index, GLuint id); +typedef void (APIENTRYP PFNGLENDQUERYINDEXEDPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLGETQUERYINDEXEDIVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params); +#endif + +#ifndef GL_ARB_ES2_compatibility +#define GL_ARB_ES2_compatibility 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glReleaseShaderCompiler (void); +GLAPI void APIENTRY glShaderBinary (GLsizei count, const GLuint *shaders, GLenum binaryformat, const GLvoid *binary, GLsizei length); +GLAPI void APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); +GLAPI void APIENTRY glDepthRangef (GLclampf n, GLclampf f); +GLAPI void APIENTRY glClearDepthf (GLclampf d); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLRELEASESHADERCOMPILERPROC) (void); +typedef void (APIENTRYP PFNGLSHADERBINARYPROC) (GLsizei count, const GLuint *shaders, GLenum binaryformat, const GLvoid *binary, GLsizei length); +typedef void (APIENTRYP PFNGLGETSHADERPRECISIONFORMATPROC) (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); +typedef void (APIENTRYP PFNGLDEPTHRANGEFPROC) (GLclampf n, GLclampf f); +typedef void (APIENTRYP PFNGLCLEARDEPTHFPROC) (GLclampf d); +#endif + +#ifndef GL_ARB_get_program_binary +#define GL_ARB_get_program_binary 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetProgramBinary (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary); +GLAPI void APIENTRY glProgramBinary (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLsizei length); +GLAPI void APIENTRY glProgramParameteri (GLuint program, GLenum pname, GLint value); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETPROGRAMBINARYPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary); +typedef void (APIENTRYP PFNGLPROGRAMBINARYPROC) (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLsizei length); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIPROC) (GLuint program, GLenum pname, GLint value); +#endif + +#ifndef GL_ARB_separate_shader_objects +#define GL_ARB_separate_shader_objects 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUseProgramStages (GLuint pipeline, GLbitfield stages, GLuint program); +GLAPI void APIENTRY glActiveShaderProgram (GLuint pipeline, GLuint program); +GLAPI GLuint APIENTRY glCreateShaderProgramv (GLenum type, GLsizei count, const GLchar* *strings); +GLAPI void APIENTRY glBindProgramPipeline (GLuint pipeline); +GLAPI void APIENTRY glDeleteProgramPipelines (GLsizei n, const GLuint *pipelines); +GLAPI void APIENTRY glGenProgramPipelines (GLsizei n, GLuint *pipelines); +GLAPI GLboolean APIENTRY glIsProgramPipeline (GLuint pipeline); +GLAPI void APIENTRY glGetProgramPipelineiv (GLuint pipeline, GLenum pname, GLint *params); +GLAPI void APIENTRY glProgramUniform1i (GLuint program, GLint location, GLint v0); +GLAPI void APIENTRY glProgramUniform1iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform1f (GLuint program, GLint location, GLfloat v0); +GLAPI void APIENTRY glProgramUniform1fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform1d (GLuint program, GLint location, GLdouble v0); +GLAPI void APIENTRY glProgramUniform1dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform1ui (GLuint program, GLint location, GLuint v0); +GLAPI void APIENTRY glProgramUniform1uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform2i (GLuint program, GLint location, GLint v0, GLint v1); +GLAPI void APIENTRY glProgramUniform2iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform2f (GLuint program, GLint location, GLfloat v0, GLfloat v1); +GLAPI void APIENTRY glProgramUniform2fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform2d (GLuint program, GLint location, GLdouble v0, GLdouble v1); +GLAPI void APIENTRY glProgramUniform2dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform2ui (GLuint program, GLint location, GLuint v0, GLuint v1); +GLAPI void APIENTRY glProgramUniform2uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform3i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +GLAPI void APIENTRY glProgramUniform3iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform3f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GLAPI void APIENTRY glProgramUniform3fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform3d (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2); +GLAPI void APIENTRY glProgramUniform3dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform3ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +GLAPI void APIENTRY glProgramUniform3uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform4i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GLAPI void APIENTRY glProgramUniform4iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform4f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GLAPI void APIENTRY glProgramUniform4fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform4d (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3); +GLAPI void APIENTRY glProgramUniform4dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform4ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GLAPI void APIENTRY glProgramUniform4uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniformMatrix2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2x3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3x2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2x4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4x2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3x4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4x3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glValidateProgramPipeline (GLuint pipeline); +GLAPI void APIENTRY glGetProgramPipelineInfoLog (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLUSEPROGRAMSTAGESPROC) (GLuint pipeline, GLbitfield stages, GLuint program); +typedef void (APIENTRYP PFNGLACTIVESHADERPROGRAMPROC) (GLuint pipeline, GLuint program); +typedef GLuint (APIENTRYP PFNGLCREATESHADERPROGRAMVPROC) (GLenum type, GLsizei count, const GLchar* *strings); +typedef void (APIENTRYP PFNGLBINDPROGRAMPIPELINEPROC) (GLuint pipeline); +typedef void (APIENTRYP PFNGLDELETEPROGRAMPIPELINESPROC) (GLsizei n, const GLuint *pipelines); +typedef void (APIENTRYP PFNGLGENPROGRAMPIPELINESPROC) (GLsizei n, GLuint *pipelines); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMPIPELINEPROC) (GLuint pipeline); +typedef void (APIENTRYP PFNGLGETPROGRAMPIPELINEIVPROC) (GLuint pipeline, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IPROC) (GLuint program, GLint location, GLint v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FPROC) (GLuint program, GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DPROC) (GLuint program, GLint location, GLdouble v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIPROC) (GLuint program, GLint location, GLuint v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IPROC) (GLuint program, GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPIPELINEPROC) (GLuint pipeline); +typedef void (APIENTRYP PFNGLGETPROGRAMPIPELINEINFOLOGPROC) (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +#endif + +#ifndef GL_ARB_vertex_attrib_64bit +#define GL_ARB_vertex_attrib_64bit 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribL1d (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttribL2d (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttribL3d (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttribL4d (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttribL1dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL2dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL3dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL4dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribLPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glGetVertexAttribLdv (GLuint index, GLenum pname, GLdouble *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBLPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLDVPROC) (GLuint index, GLenum pname, GLdouble *params); +#endif + +#ifndef GL_ARB_viewport_array +#define GL_ARB_viewport_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glViewportArrayv (GLuint first, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glViewportIndexedf (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); +GLAPI void APIENTRY glViewportIndexedfv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glScissorArrayv (GLuint first, GLsizei count, const GLint *v); +GLAPI void APIENTRY glScissorIndexed (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); +GLAPI void APIENTRY glScissorIndexedv (GLuint index, const GLint *v); +GLAPI void APIENTRY glDepthRangeArrayv (GLuint first, GLsizei count, const GLclampd *v); +GLAPI void APIENTRY glDepthRangeIndexed (GLuint index, GLclampd n, GLclampd f); +GLAPI void APIENTRY glGetFloati_v (GLenum target, GLuint index, GLfloat *data); +GLAPI void APIENTRY glGetDoublei_v (GLenum target, GLuint index, GLdouble *data); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVIEWPORTARRAYVPROC) (GLuint first, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); +typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLSCISSORARRAYVPROC) (GLuint first, GLsizei count, const GLint *v); +typedef void (APIENTRYP PFNGLSCISSORINDEXEDPROC) (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLSCISSORINDEXEDVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLDEPTHRANGEARRAYVPROC) (GLuint first, GLsizei count, const GLclampd *v); +typedef void (APIENTRYP PFNGLDEPTHRANGEINDEXEDPROC) (GLuint index, GLclampd n, GLclampd f); +typedef void (APIENTRYP PFNGLGETFLOATI_VPROC) (GLenum target, GLuint index, GLfloat *data); +typedef void (APIENTRYP PFNGLGETDOUBLEI_VPROC) (GLenum target, GLuint index, GLdouble *data); +#endif + +#ifndef GL_ARB_cl_event +#define GL_ARB_cl_event 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLsync APIENTRY glCreateSyncFromCLeventARB (struct _cl_context * context, struct _cl_event * event, GLbitfield flags); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLsync (APIENTRYP PFNGLCREATESYNCFROMCLEVENTARBPROC) (struct _cl_context * context, struct _cl_event * event, GLbitfield flags); +#endif + +#ifndef GL_ARB_debug_output +#define GL_ARB_debug_output 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDebugMessageControlARB (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +GLAPI void APIENTRY glDebugMessageInsertARB (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +GLAPI void APIENTRY glDebugMessageCallbackARB (GLDEBUGPROCARB callback, const GLvoid *userParam); +GLAPI GLuint APIENTRY glGetDebugMessageLogARB (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDEBUGMESSAGECONTROLARBPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTARBPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKARBPROC) (GLDEBUGPROCARB callback, const GLvoid *userParam); +typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGARBPROC) (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +#endif + +#ifndef GL_ARB_robustness +#define GL_ARB_robustness 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLenum APIENTRY glGetGraphicsResetStatusARB (void); +GLAPI void APIENTRY glGetnMapdvARB (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v); +GLAPI void APIENTRY glGetnMapfvARB (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v); +GLAPI void APIENTRY glGetnMapivARB (GLenum target, GLenum query, GLsizei bufSize, GLint *v); +GLAPI void APIENTRY glGetnPixelMapfvARB (GLenum map, GLsizei bufSize, GLfloat *values); +GLAPI void APIENTRY glGetnPixelMapuivARB (GLenum map, GLsizei bufSize, GLuint *values); +GLAPI void APIENTRY glGetnPixelMapusvARB (GLenum map, GLsizei bufSize, GLushort *values); +GLAPI void APIENTRY glGetnPolygonStippleARB (GLsizei bufSize, GLubyte *pattern); +GLAPI void APIENTRY glGetnColorTableARB (GLenum target, GLenum format, GLenum type, GLsizei bufSize, GLvoid *table); +GLAPI void APIENTRY glGetnConvolutionFilterARB (GLenum target, GLenum format, GLenum type, GLsizei bufSize, GLvoid *image); +GLAPI void APIENTRY glGetnSeparableFilterARB (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, GLvoid *row, GLsizei columnBufSize, GLvoid *column, GLvoid *span); +GLAPI void APIENTRY glGetnHistogramARB (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, GLvoid *values); +GLAPI void APIENTRY glGetnMinmaxARB (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, GLvoid *values); +GLAPI void APIENTRY glGetnTexImageARB (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, GLvoid *img); +GLAPI void APIENTRY glReadnPixelsARB (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, GLvoid *data); +GLAPI void APIENTRY glGetnCompressedTexImageARB (GLenum target, GLint lod, GLsizei bufSize, GLvoid *img); +GLAPI void APIENTRY glGetnUniformfvARB (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); +GLAPI void APIENTRY glGetnUniformivARB (GLuint program, GLint location, GLsizei bufSize, GLint *params); +GLAPI void APIENTRY glGetnUniformuivARB (GLuint program, GLint location, GLsizei bufSize, GLuint *params); +GLAPI void APIENTRY glGetnUniformdvARB (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLenum (APIENTRYP PFNGLGETGRAPHICSRESETSTATUSARBPROC) (void); +typedef void (APIENTRYP PFNGLGETNMAPDVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v); +typedef void (APIENTRYP PFNGLGETNMAPFVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v); +typedef void (APIENTRYP PFNGLGETNMAPIVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLint *v); +typedef void (APIENTRYP PFNGLGETNPIXELMAPFVARBPROC) (GLenum map, GLsizei bufSize, GLfloat *values); +typedef void (APIENTRYP PFNGLGETNPIXELMAPUIVARBPROC) (GLenum map, GLsizei bufSize, GLuint *values); +typedef void (APIENTRYP PFNGLGETNPIXELMAPUSVARBPROC) (GLenum map, GLsizei bufSize, GLushort *values); +typedef void (APIENTRYP PFNGLGETNPOLYGONSTIPPLEARBPROC) (GLsizei bufSize, GLubyte *pattern); +typedef void (APIENTRYP PFNGLGETNCOLORTABLEARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, GLvoid *table); +typedef void (APIENTRYP PFNGLGETNCONVOLUTIONFILTERARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, GLvoid *image); +typedef void (APIENTRYP PFNGLGETNSEPARABLEFILTERARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, GLvoid *row, GLsizei columnBufSize, GLvoid *column, GLvoid *span); +typedef void (APIENTRYP PFNGLGETNHISTOGRAMARBPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, GLvoid *values); +typedef void (APIENTRYP PFNGLGETNMINMAXARBPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, GLvoid *values); +typedef void (APIENTRYP PFNGLGETNTEXIMAGEARBPROC) (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, GLvoid *img); +typedef void (APIENTRYP PFNGLREADNPIXELSARBPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, GLvoid *data); +typedef void (APIENTRYP PFNGLGETNCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint lod, GLsizei bufSize, GLvoid *img); +typedef void (APIENTRYP PFNGLGETNUNIFORMFVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLint *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMUIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMDVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); +#endif + +#ifndef GL_ARB_shader_stencil_export +#define GL_ARB_shader_stencil_export 1 +#endif + +#ifndef GL_ARB_base_instance +#define GL_ARB_base_instance 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawArraysInstancedBaseInstance (GLenum mode, GLint first, GLsizei count, GLsizei primcount, GLuint baseinstance); +GLAPI void APIENTRY glDrawElementsInstancedBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount, GLuint baseinstance); +GLAPI void APIENTRY glDrawElementsInstancedBaseVertexBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount, GLint basevertex, GLuint baseinstance); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount, GLuint baseinstance); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount, GLuint baseinstance); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount, GLint basevertex, GLuint baseinstance); +#endif + +#ifndef GL_ARB_shading_language_420pack +#define GL_ARB_shading_language_420pack 1 +#endif + +#ifndef GL_ARB_transform_feedback_instanced +#define GL_ARB_transform_feedback_instanced 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawTransformFeedbackInstanced (GLenum mode, GLuint id, GLsizei primcount); +GLAPI void APIENTRY glDrawTransformFeedbackStreamInstanced (GLenum mode, GLuint id, GLuint stream, GLsizei primcount); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC) (GLenum mode, GLuint id, GLsizei primcount); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC) (GLenum mode, GLuint id, GLuint stream, GLsizei primcount); +#endif + +#ifndef GL_ARB_compressed_texture_pixel_storage +#define GL_ARB_compressed_texture_pixel_storage 1 +#endif + +#ifndef GL_ARB_conservative_depth +#define GL_ARB_conservative_depth 1 +#endif + +#ifndef GL_ARB_internalformat_query +#define GL_ARB_internalformat_query 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetInternalformativ (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETINTERNALFORMATIVPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params); +#endif + +#ifndef GL_ARB_map_buffer_alignment +#define GL_ARB_map_buffer_alignment 1 +#endif + +#ifndef GL_ARB_shader_atomic_counters +#define GL_ARB_shader_atomic_counters 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetActiveAtomicCounterBufferiv (GLuint program, GLuint bufferIndex, GLenum pname, GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC) (GLuint program, GLuint bufferIndex, GLenum pname, GLint *params); +#endif + +#ifndef GL_ARB_shader_image_load_store +#define GL_ARB_shader_image_load_store 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindImageTexture (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); +GLAPI void APIENTRY glMemoryBarrier (GLbitfield barriers); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDIMAGETEXTUREPROC) (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); +typedef void (APIENTRYP PFNGLMEMORYBARRIERPROC) (GLbitfield barriers); +#endif + +#ifndef GL_ARB_shading_language_packing +#define GL_ARB_shading_language_packing 1 +#endif + +#ifndef GL_ARB_texture_storage +#define GL_ARB_texture_storage 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexStorage1D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +GLAPI void APIENTRY glTexStorage2D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glTexStorage3D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +GLAPI void APIENTRY glTextureStorage1DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +GLAPI void APIENTRY glTextureStorage2DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glTextureStorage3DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXSTORAGE1DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +typedef void (APIENTRYP PFNGLTEXSTORAGE2DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLTEXSTORAGE3DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE1DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +#endif + +#ifndef GL_EXT_abgr +#define GL_EXT_abgr 1 +#endif + +#ifndef GL_EXT_blend_color +#define GL_EXT_blend_color 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendColorEXT (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDCOLOREXTPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); +#endif + +#ifndef GL_EXT_polygon_offset +#define GL_EXT_polygon_offset 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPolygonOffsetEXT (GLfloat factor, GLfloat bias); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPOLYGONOFFSETEXTPROC) (GLfloat factor, GLfloat bias); +#endif + +#ifndef GL_EXT_texture +#define GL_EXT_texture 1 +#endif + +#ifndef GL_EXT_texture3D +#define GL_EXT_texture3D 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexImage3DEXT (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glTexSubImage3DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXIMAGE3DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +#endif + +#ifndef GL_SGIS_texture_filter4 +#define GL_SGIS_texture_filter4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetTexFilterFuncSGIS (GLenum target, GLenum filter, GLfloat *weights); +GLAPI void APIENTRY glTexFilterFuncSGIS (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLfloat *weights); +typedef void (APIENTRYP PFNGLTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights); +#endif + +#ifndef GL_EXT_subtexture +#define GL_EXT_subtexture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexSubImage1DEXT (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glTexSubImage2DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +#endif + +#ifndef GL_EXT_copy_texture +#define GL_EXT_copy_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCopyTexImage1DEXT (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +GLAPI void APIENTRY glCopyTexImage2DEXT (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +GLAPI void APIENTRY glCopyTexSubImage1DEXT (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyTexSubImage2DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glCopyTexSubImage3DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOPYTEXIMAGE1DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXIMAGE2DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#endif + +#ifndef GL_EXT_histogram +#define GL_EXT_histogram 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetHistogramEXT (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +GLAPI void APIENTRY glGetHistogramParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetHistogramParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMinmaxEXT (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +GLAPI void APIENTRY glGetMinmaxParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMinmaxParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glHistogramEXT (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +GLAPI void APIENTRY glMinmaxEXT (GLenum target, GLenum internalformat, GLboolean sink); +GLAPI void APIENTRY glResetHistogramEXT (GLenum target); +GLAPI void APIENTRY glResetMinmaxEXT (GLenum target); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETHISTOGRAMEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMINMAXEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLHISTOGRAMEXTPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLMINMAXEXTPROC) (GLenum target, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLRESETHISTOGRAMEXTPROC) (GLenum target); +typedef void (APIENTRYP PFNGLRESETMINMAXEXTPROC) (GLenum target); +#endif + +#ifndef GL_EXT_convolution +#define GL_EXT_convolution 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glConvolutionFilter1DEXT (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); +GLAPI void APIENTRY glConvolutionFilter2DEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); +GLAPI void APIENTRY glConvolutionParameterfEXT (GLenum target, GLenum pname, GLfloat params); +GLAPI void APIENTRY glConvolutionParameterfvEXT (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glConvolutionParameteriEXT (GLenum target, GLenum pname, GLint params); +GLAPI void APIENTRY glConvolutionParameterivEXT (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glCopyConvolutionFilter1DEXT (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyConvolutionFilter2DEXT (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetConvolutionFilterEXT (GLenum target, GLenum format, GLenum type, GLvoid *image); +GLAPI void APIENTRY glGetConvolutionParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetConvolutionParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetSeparableFilterEXT (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); +GLAPI void APIENTRY glSeparableFilter2DEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSEPARABLEFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); +typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); +#endif + +#ifndef GL_SGI_color_matrix +#define GL_SGI_color_matrix 1 +#endif + +#ifndef GL_SGI_color_table +#define GL_SGI_color_table 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorTableSGI (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +GLAPI void APIENTRY glColorTableParameterfvSGI (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glColorTableParameterivSGI (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glCopyColorTableSGI (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glGetColorTableSGI (GLenum target, GLenum format, GLenum type, GLvoid *table); +GLAPI void APIENTRY glGetColorTableParameterfvSGI (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetColorTableParameterivSGI (GLenum target, GLenum pname, GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLGETCOLORTABLESGIPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, GLint *params); +#endif + +#ifndef GL_SGIX_pixel_texture +#define GL_SGIX_pixel_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelTexGenSGIX (GLenum mode); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPIXELTEXGENSGIXPROC) (GLenum mode); +#endif + +#ifndef GL_SGIS_pixel_texture +#define GL_SGIS_pixel_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelTexGenParameteriSGIS (GLenum pname, GLint param); +GLAPI void APIENTRY glPixelTexGenParameterivSGIS (GLenum pname, const GLint *params); +GLAPI void APIENTRY glPixelTexGenParameterfSGIS (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPixelTexGenParameterfvSGIS (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetPixelTexGenParameterivSGIS (GLenum pname, GLint *params); +GLAPI void APIENTRY glGetPixelTexGenParameterfvSGIS (GLenum pname, GLfloat *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERISGISPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFSGISPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, GLfloat *params); +#endif + +#ifndef GL_SGIS_texture4D +#define GL_SGIS_texture4D 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexImage4DSGIS (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glTexSubImage4DSGIS (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const GLvoid *pixels); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXIMAGE4DSGISPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE4DSGISPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const GLvoid *pixels); +#endif + +#ifndef GL_SGI_texture_color_table +#define GL_SGI_texture_color_table 1 +#endif + +#ifndef GL_EXT_cmyka +#define GL_EXT_cmyka 1 +#endif + +#ifndef GL_EXT_texture_object +#define GL_EXT_texture_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glAreTexturesResidentEXT (GLsizei n, const GLuint *textures, GLboolean *residences); +GLAPI void APIENTRY glBindTextureEXT (GLenum target, GLuint texture); +GLAPI void APIENTRY glDeleteTexturesEXT (GLsizei n, const GLuint *textures); +GLAPI void APIENTRY glGenTexturesEXT (GLsizei n, GLuint *textures); +GLAPI GLboolean APIENTRY glIsTextureEXT (GLuint texture); +GLAPI void APIENTRY glPrioritizeTexturesEXT (GLsizei n, const GLuint *textures, const GLclampf *priorities); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLboolean (APIENTRYP PFNGLARETEXTURESRESIDENTEXTPROC) (GLsizei n, const GLuint *textures, GLboolean *residences); +typedef void (APIENTRYP PFNGLBINDTEXTUREEXTPROC) (GLenum target, GLuint texture); +typedef void (APIENTRYP PFNGLDELETETEXTURESEXTPROC) (GLsizei n, const GLuint *textures); +typedef void (APIENTRYP PFNGLGENTEXTURESEXTPROC) (GLsizei n, GLuint *textures); +typedef GLboolean (APIENTRYP PFNGLISTEXTUREEXTPROC) (GLuint texture); +typedef void (APIENTRYP PFNGLPRIORITIZETEXTURESEXTPROC) (GLsizei n, const GLuint *textures, const GLclampf *priorities); +#endif + +#ifndef GL_SGIS_detail_texture +#define GL_SGIS_detail_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDetailTexFuncSGIS (GLenum target, GLsizei n, const GLfloat *points); +GLAPI void APIENTRY glGetDetailTexFuncSGIS (GLenum target, GLfloat *points); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDETAILTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); +typedef void (APIENTRYP PFNGLGETDETAILTEXFUNCSGISPROC) (GLenum target, GLfloat *points); +#endif + +#ifndef GL_SGIS_sharpen_texture +#define GL_SGIS_sharpen_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSharpenTexFuncSGIS (GLenum target, GLsizei n, const GLfloat *points); +GLAPI void APIENTRY glGetSharpenTexFuncSGIS (GLenum target, GLfloat *points); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSHARPENTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); +typedef void (APIENTRYP PFNGLGETSHARPENTEXFUNCSGISPROC) (GLenum target, GLfloat *points); +#endif + +#ifndef GL_EXT_packed_pixels +#define GL_EXT_packed_pixels 1 +#endif + +#ifndef GL_SGIS_texture_lod +#define GL_SGIS_texture_lod 1 +#endif + +#ifndef GL_SGIS_multisample +#define GL_SGIS_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSampleMaskSGIS (GLclampf value, GLboolean invert); +GLAPI void APIENTRY glSamplePatternSGIS (GLenum pattern); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSAMPLEMASKSGISPROC) (GLclampf value, GLboolean invert); +typedef void (APIENTRYP PFNGLSAMPLEPATTERNSGISPROC) (GLenum pattern); +#endif + +#ifndef GL_EXT_rescale_normal +#define GL_EXT_rescale_normal 1 +#endif + +#ifndef GL_EXT_vertex_array +#define GL_EXT_vertex_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glArrayElementEXT (GLint i); +GLAPI void APIENTRY glColorPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +GLAPI void APIENTRY glDrawArraysEXT (GLenum mode, GLint first, GLsizei count); +GLAPI void APIENTRY glEdgeFlagPointerEXT (GLsizei stride, GLsizei count, const GLboolean *pointer); +GLAPI void APIENTRY glGetPointervEXT (GLenum pname, GLvoid* *params); +GLAPI void APIENTRY glIndexPointerEXT (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +GLAPI void APIENTRY glNormalPointerEXT (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +GLAPI void APIENTRY glTexCoordPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +GLAPI void APIENTRY glVertexPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLARRAYELEMENTEXTPROC) (GLint i); +typedef void (APIENTRYP PFNGLCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLDRAWARRAYSEXTPROC) (GLenum mode, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLEDGEFLAGPOINTEREXTPROC) (GLsizei stride, GLsizei count, const GLboolean *pointer); +typedef void (APIENTRYP PFNGLGETPOINTERVEXTPROC) (GLenum pname, GLvoid* *params); +typedef void (APIENTRYP PFNGLINDEXPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLNORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLTEXCOORDPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLVERTEXPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +#endif + +#ifndef GL_EXT_misc_attribute +#define GL_EXT_misc_attribute 1 +#endif + +#ifndef GL_SGIS_generate_mipmap +#define GL_SGIS_generate_mipmap 1 +#endif + +#ifndef GL_SGIX_clipmap +#define GL_SGIX_clipmap 1 +#endif + +#ifndef GL_SGIX_shadow +#define GL_SGIX_shadow 1 +#endif + +#ifndef GL_SGIS_texture_edge_clamp +#define GL_SGIS_texture_edge_clamp 1 +#endif + +#ifndef GL_SGIS_texture_border_clamp +#define GL_SGIS_texture_border_clamp 1 +#endif + +#ifndef GL_EXT_blend_minmax +#define GL_EXT_blend_minmax 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationEXT (GLenum mode); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDEQUATIONEXTPROC) (GLenum mode); +#endif + +#ifndef GL_EXT_blend_subtract +#define GL_EXT_blend_subtract 1 +#endif + +#ifndef GL_EXT_blend_logic_op +#define GL_EXT_blend_logic_op 1 +#endif + +#ifndef GL_SGIX_interlace +#define GL_SGIX_interlace 1 +#endif + +#ifndef GL_SGIX_pixel_tiles +#define GL_SGIX_pixel_tiles 1 +#endif + +#ifndef GL_SGIX_texture_select +#define GL_SGIX_texture_select 1 +#endif + +#ifndef GL_SGIX_sprite +#define GL_SGIX_sprite 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSpriteParameterfSGIX (GLenum pname, GLfloat param); +GLAPI void APIENTRY glSpriteParameterfvSGIX (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glSpriteParameteriSGIX (GLenum pname, GLint param); +GLAPI void APIENTRY glSpriteParameterivSGIX (GLenum pname, const GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSPRITEPARAMETERFSGIXPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERFVSGIXPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERISGIXPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERIVSGIXPROC) (GLenum pname, const GLint *params); +#endif + +#ifndef GL_SGIX_texture_multi_buffer +#define GL_SGIX_texture_multi_buffer 1 +#endif + +#ifndef GL_EXT_point_parameters +#define GL_EXT_point_parameters 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameterfEXT (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPointParameterfvEXT (GLenum pname, const GLfloat *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPOINTPARAMETERFEXTPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVEXTPROC) (GLenum pname, const GLfloat *params); +#endif + +#ifndef GL_SGIS_point_parameters +#define GL_SGIS_point_parameters 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameterfSGIS (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPointParameterfvSGIS (GLenum pname, const GLfloat *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPOINTPARAMETERFSGISPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); +#endif + +#ifndef GL_SGIX_instruments +#define GL_SGIX_instruments 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLint APIENTRY glGetInstrumentsSGIX (void); +GLAPI void APIENTRY glInstrumentsBufferSGIX (GLsizei size, GLint *buffer); +GLAPI GLint APIENTRY glPollInstrumentsSGIX (GLint *marker_p); +GLAPI void APIENTRY glReadInstrumentsSGIX (GLint marker); +GLAPI void APIENTRY glStartInstrumentsSGIX (void); +GLAPI void APIENTRY glStopInstrumentsSGIX (GLint marker); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLint (APIENTRYP PFNGLGETINSTRUMENTSSGIXPROC) (void); +typedef void (APIENTRYP PFNGLINSTRUMENTSBUFFERSGIXPROC) (GLsizei size, GLint *buffer); +typedef GLint (APIENTRYP PFNGLPOLLINSTRUMENTSSGIXPROC) (GLint *marker_p); +typedef void (APIENTRYP PFNGLREADINSTRUMENTSSGIXPROC) (GLint marker); +typedef void (APIENTRYP PFNGLSTARTINSTRUMENTSSGIXPROC) (void); +typedef void (APIENTRYP PFNGLSTOPINSTRUMENTSSGIXPROC) (GLint marker); +#endif + +#ifndef GL_SGIX_texture_scale_bias +#define GL_SGIX_texture_scale_bias 1 +#endif + +#ifndef GL_SGIX_framezoom +#define GL_SGIX_framezoom 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFrameZoomSGIX (GLint factor); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFRAMEZOOMSGIXPROC) (GLint factor); +#endif + +#ifndef GL_SGIX_tag_sample_buffer +#define GL_SGIX_tag_sample_buffer 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTagSampleBufferSGIX (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTAGSAMPLEBUFFERSGIXPROC) (void); +#endif + +#ifndef GL_SGIX_polynomial_ffd +#define GL_SGIX_polynomial_ffd 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDeformationMap3dSGIX (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points); +GLAPI void APIENTRY glDeformationMap3fSGIX (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points); +GLAPI void APIENTRY glDeformSGIX (GLbitfield mask); +GLAPI void APIENTRY glLoadIdentityDeformationMapSGIX (GLbitfield mask); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDEFORMATIONMAP3DSGIXPROC) (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points); +typedef void (APIENTRYP PFNGLDEFORMATIONMAP3FSGIXPROC) (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points); +typedef void (APIENTRYP PFNGLDEFORMSGIXPROC) (GLbitfield mask); +typedef void (APIENTRYP PFNGLLOADIDENTITYDEFORMATIONMAPSGIXPROC) (GLbitfield mask); +#endif + +#ifndef GL_SGIX_reference_plane +#define GL_SGIX_reference_plane 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glReferencePlaneSGIX (const GLdouble *equation); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLREFERENCEPLANESGIXPROC) (const GLdouble *equation); +#endif + +#ifndef GL_SGIX_flush_raster +#define GL_SGIX_flush_raster 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFlushRasterSGIX (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFLUSHRASTERSGIXPROC) (void); +#endif + +#ifndef GL_SGIX_depth_texture +#define GL_SGIX_depth_texture 1 +#endif + +#ifndef GL_SGIS_fog_function +#define GL_SGIS_fog_function 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFogFuncSGIS (GLsizei n, const GLfloat *points); +GLAPI void APIENTRY glGetFogFuncSGIS (GLfloat *points); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFOGFUNCSGISPROC) (GLsizei n, const GLfloat *points); +typedef void (APIENTRYP PFNGLGETFOGFUNCSGISPROC) (GLfloat *points); +#endif + +#ifndef GL_SGIX_fog_offset +#define GL_SGIX_fog_offset 1 +#endif + +#ifndef GL_HP_image_transform +#define GL_HP_image_transform 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glImageTransformParameteriHP (GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glImageTransformParameterfHP (GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glImageTransformParameterivHP (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glImageTransformParameterfvHP (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetImageTransformParameterivHP (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetImageTransformParameterfvHP (GLenum target, GLenum pname, GLfloat *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIHPPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFHPPROC) (GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, GLfloat *params); +#endif + +#ifndef GL_HP_convolution_border_modes +#define GL_HP_convolution_border_modes 1 +#endif + +#ifndef GL_SGIX_texture_add_env +#define GL_SGIX_texture_add_env 1 +#endif + +#ifndef GL_EXT_color_subtable +#define GL_EXT_color_subtable 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorSubTableEXT (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); +GLAPI void APIENTRY glCopyColorSubTableEXT (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +#endif + +#ifndef GL_PGI_vertex_hints +#define GL_PGI_vertex_hints 1 +#endif + +#ifndef GL_PGI_misc_hints +#define GL_PGI_misc_hints 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glHintPGI (GLenum target, GLint mode); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLHINTPGIPROC) (GLenum target, GLint mode); +#endif + +#ifndef GL_EXT_paletted_texture +#define GL_EXT_paletted_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorTableEXT (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +GLAPI void APIENTRY glGetColorTableEXT (GLenum target, GLenum format, GLenum type, GLvoid *data); +GLAPI void APIENTRY glGetColorTableParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetColorTableParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +typedef void (APIENTRYP PFNGLGETCOLORTABLEEXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *data); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +#endif + +#ifndef GL_EXT_clip_volume_hint +#define GL_EXT_clip_volume_hint 1 +#endif + +#ifndef GL_SGIX_list_priority +#define GL_SGIX_list_priority 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetListParameterfvSGIX (GLuint list, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetListParameterivSGIX (GLuint list, GLenum pname, GLint *params); +GLAPI void APIENTRY glListParameterfSGIX (GLuint list, GLenum pname, GLfloat param); +GLAPI void APIENTRY glListParameterfvSGIX (GLuint list, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glListParameteriSGIX (GLuint list, GLenum pname, GLint param); +GLAPI void APIENTRY glListParameterivSGIX (GLuint list, GLenum pname, const GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLLISTPARAMETERFSGIXPROC) (GLuint list, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLLISTPARAMETERISGIXPROC) (GLuint list, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, const GLint *params); +#endif + +#ifndef GL_SGIX_ir_instrument1 +#define GL_SGIX_ir_instrument1 1 +#endif + +#ifndef GL_SGIX_calligraphic_fragment +#define GL_SGIX_calligraphic_fragment 1 +#endif + +#ifndef GL_SGIX_texture_lod_bias +#define GL_SGIX_texture_lod_bias 1 +#endif + +#ifndef GL_SGIX_shadow_ambient +#define GL_SGIX_shadow_ambient 1 +#endif + +#ifndef GL_EXT_index_texture +#define GL_EXT_index_texture 1 +#endif + +#ifndef GL_EXT_index_material +#define GL_EXT_index_material 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glIndexMaterialEXT (GLenum face, GLenum mode); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLINDEXMATERIALEXTPROC) (GLenum face, GLenum mode); +#endif + +#ifndef GL_EXT_index_func +#define GL_EXT_index_func 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glIndexFuncEXT (GLenum func, GLclampf ref); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLINDEXFUNCEXTPROC) (GLenum func, GLclampf ref); +#endif + +#ifndef GL_EXT_index_array_formats +#define GL_EXT_index_array_formats 1 +#endif + +#ifndef GL_EXT_compiled_vertex_array +#define GL_EXT_compiled_vertex_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glLockArraysEXT (GLint first, GLsizei count); +GLAPI void APIENTRY glUnlockArraysEXT (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLLOCKARRAYSEXTPROC) (GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLUNLOCKARRAYSEXTPROC) (void); +#endif + +#ifndef GL_EXT_cull_vertex +#define GL_EXT_cull_vertex 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCullParameterdvEXT (GLenum pname, GLdouble *params); +GLAPI void APIENTRY glCullParameterfvEXT (GLenum pname, GLfloat *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCULLPARAMETERDVEXTPROC) (GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLCULLPARAMETERFVEXTPROC) (GLenum pname, GLfloat *params); +#endif + +#ifndef GL_SGIX_ycrcb +#define GL_SGIX_ycrcb 1 +#endif + +#ifndef GL_SGIX_fragment_lighting +#define GL_SGIX_fragment_lighting 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFragmentColorMaterialSGIX (GLenum face, GLenum mode); +GLAPI void APIENTRY glFragmentLightfSGIX (GLenum light, GLenum pname, GLfloat param); +GLAPI void APIENTRY glFragmentLightfvSGIX (GLenum light, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glFragmentLightiSGIX (GLenum light, GLenum pname, GLint param); +GLAPI void APIENTRY glFragmentLightivSGIX (GLenum light, GLenum pname, const GLint *params); +GLAPI void APIENTRY glFragmentLightModelfSGIX (GLenum pname, GLfloat param); +GLAPI void APIENTRY glFragmentLightModelfvSGIX (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glFragmentLightModeliSGIX (GLenum pname, GLint param); +GLAPI void APIENTRY glFragmentLightModelivSGIX (GLenum pname, const GLint *params); +GLAPI void APIENTRY glFragmentMaterialfSGIX (GLenum face, GLenum pname, GLfloat param); +GLAPI void APIENTRY glFragmentMaterialfvSGIX (GLenum face, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glFragmentMaterialiSGIX (GLenum face, GLenum pname, GLint param); +GLAPI void APIENTRY glFragmentMaterialivSGIX (GLenum face, GLenum pname, const GLint *params); +GLAPI void APIENTRY glGetFragmentLightfvSGIX (GLenum light, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetFragmentLightivSGIX (GLenum light, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetFragmentMaterialfvSGIX (GLenum face, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetFragmentMaterialivSGIX (GLenum face, GLenum pname, GLint *params); +GLAPI void APIENTRY glLightEnviSGIX (GLenum pname, GLint param); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFRAGMENTCOLORMATERIALSGIXPROC) (GLenum face, GLenum mode); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFSGIXPROC) (GLenum light, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTISGIXPROC) (GLenum light, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFSGIXPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFVSGIXPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELISGIXPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELIVSGIXPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFSGIXPROC) (GLenum face, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALISGIXPROC) (GLenum face, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLLIGHTENVISGIXPROC) (GLenum pname, GLint param); +#endif + +#ifndef GL_IBM_rasterpos_clip +#define GL_IBM_rasterpos_clip 1 +#endif + +#ifndef GL_HP_texture_lighting +#define GL_HP_texture_lighting 1 +#endif + +#ifndef GL_EXT_draw_range_elements +#define GL_EXT_draw_range_elements 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawRangeElementsEXT (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSEXTPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); +#endif + +#ifndef GL_WIN_phong_shading +#define GL_WIN_phong_shading 1 +#endif + +#ifndef GL_WIN_specular_fog +#define GL_WIN_specular_fog 1 +#endif + +#ifndef GL_EXT_light_texture +#define GL_EXT_light_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glApplyTextureEXT (GLenum mode); +GLAPI void APIENTRY glTextureLightEXT (GLenum pname); +GLAPI void APIENTRY glTextureMaterialEXT (GLenum face, GLenum mode); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLAPPLYTEXTUREEXTPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLTEXTURELIGHTEXTPROC) (GLenum pname); +typedef void (APIENTRYP PFNGLTEXTUREMATERIALEXTPROC) (GLenum face, GLenum mode); +#endif + +#ifndef GL_SGIX_blend_alpha_minmax +#define GL_SGIX_blend_alpha_minmax 1 +#endif + +#ifndef GL_EXT_bgra +#define GL_EXT_bgra 1 +#endif + +#ifndef GL_SGIX_async +#define GL_SGIX_async 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glAsyncMarkerSGIX (GLuint marker); +GLAPI GLint APIENTRY glFinishAsyncSGIX (GLuint *markerp); +GLAPI GLint APIENTRY glPollAsyncSGIX (GLuint *markerp); +GLAPI GLuint APIENTRY glGenAsyncMarkersSGIX (GLsizei range); +GLAPI void APIENTRY glDeleteAsyncMarkersSGIX (GLuint marker, GLsizei range); +GLAPI GLboolean APIENTRY glIsAsyncMarkerSGIX (GLuint marker); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLASYNCMARKERSGIXPROC) (GLuint marker); +typedef GLint (APIENTRYP PFNGLFINISHASYNCSGIXPROC) (GLuint *markerp); +typedef GLint (APIENTRYP PFNGLPOLLASYNCSGIXPROC) (GLuint *markerp); +typedef GLuint (APIENTRYP PFNGLGENASYNCMARKERSSGIXPROC) (GLsizei range); +typedef void (APIENTRYP PFNGLDELETEASYNCMARKERSSGIXPROC) (GLuint marker, GLsizei range); +typedef GLboolean (APIENTRYP PFNGLISASYNCMARKERSGIXPROC) (GLuint marker); +#endif + +#ifndef GL_SGIX_async_pixel +#define GL_SGIX_async_pixel 1 +#endif + +#ifndef GL_SGIX_async_histogram +#define GL_SGIX_async_histogram 1 +#endif + +#ifndef GL_INTEL_parallel_arrays +#define GL_INTEL_parallel_arrays 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexPointervINTEL (GLint size, GLenum type, const GLvoid* *pointer); +GLAPI void APIENTRY glNormalPointervINTEL (GLenum type, const GLvoid* *pointer); +GLAPI void APIENTRY glColorPointervINTEL (GLint size, GLenum type, const GLvoid* *pointer); +GLAPI void APIENTRY glTexCoordPointervINTEL (GLint size, GLenum type, const GLvoid* *pointer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); +typedef void (APIENTRYP PFNGLNORMALPOINTERVINTELPROC) (GLenum type, const GLvoid* *pointer); +typedef void (APIENTRYP PFNGLCOLORPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); +typedef void (APIENTRYP PFNGLTEXCOORDPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); +#endif + +#ifndef GL_HP_occlusion_test +#define GL_HP_occlusion_test 1 +#endif + +#ifndef GL_EXT_pixel_transform +#define GL_EXT_pixel_transform 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelTransformParameteriEXT (GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glPixelTransformParameterfEXT (GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glPixelTransformParameterivEXT (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glPixelTransformParameterfvEXT (GLenum target, GLenum pname, const GLfloat *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); +#endif + +#ifndef GL_EXT_pixel_transform_color_table +#define GL_EXT_pixel_transform_color_table 1 +#endif + +#ifndef GL_EXT_shared_texture_palette +#define GL_EXT_shared_texture_palette 1 +#endif + +#ifndef GL_EXT_separate_specular_color +#define GL_EXT_separate_specular_color 1 +#endif + +#ifndef GL_EXT_secondary_color +#define GL_EXT_secondary_color 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSecondaryColor3bEXT (GLbyte red, GLbyte green, GLbyte blue); +GLAPI void APIENTRY glSecondaryColor3bvEXT (const GLbyte *v); +GLAPI void APIENTRY glSecondaryColor3dEXT (GLdouble red, GLdouble green, GLdouble blue); +GLAPI void APIENTRY glSecondaryColor3dvEXT (const GLdouble *v); +GLAPI void APIENTRY glSecondaryColor3fEXT (GLfloat red, GLfloat green, GLfloat blue); +GLAPI void APIENTRY glSecondaryColor3fvEXT (const GLfloat *v); +GLAPI void APIENTRY glSecondaryColor3iEXT (GLint red, GLint green, GLint blue); +GLAPI void APIENTRY glSecondaryColor3ivEXT (const GLint *v); +GLAPI void APIENTRY glSecondaryColor3sEXT (GLshort red, GLshort green, GLshort blue); +GLAPI void APIENTRY glSecondaryColor3svEXT (const GLshort *v); +GLAPI void APIENTRY glSecondaryColor3ubEXT (GLubyte red, GLubyte green, GLubyte blue); +GLAPI void APIENTRY glSecondaryColor3ubvEXT (const GLubyte *v); +GLAPI void APIENTRY glSecondaryColor3uiEXT (GLuint red, GLuint green, GLuint blue); +GLAPI void APIENTRY glSecondaryColor3uivEXT (const GLuint *v); +GLAPI void APIENTRY glSecondaryColor3usEXT (GLushort red, GLushort green, GLushort blue); +GLAPI void APIENTRY glSecondaryColor3usvEXT (const GLushort *v); +GLAPI void APIENTRY glSecondaryColorPointerEXT (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BEXTPROC) (GLbyte red, GLbyte green, GLbyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DEXTPROC) (GLdouble red, GLdouble green, GLdouble blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FEXTPROC) (GLfloat red, GLfloat green, GLfloat blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IEXTPROC) (GLint red, GLint green, GLint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVEXTPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SEXTPROC) (GLshort red, GLshort green, GLshort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBEXTPROC) (GLubyte red, GLubyte green, GLubyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVEXTPROC) (const GLubyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIEXTPROC) (GLuint red, GLuint green, GLuint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVEXTPROC) (const GLuint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USEXTPROC) (GLushort red, GLushort green, GLushort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVEXTPROC) (const GLushort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_EXT_texture_perturb_normal +#define GL_EXT_texture_perturb_normal 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureNormalEXT (GLenum mode); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXTURENORMALEXTPROC) (GLenum mode); +#endif + +#ifndef GL_EXT_multi_draw_arrays +#define GL_EXT_multi_draw_arrays 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiDrawArraysEXT (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +GLAPI void APIENTRY glMultiDrawElementsEXT (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); +#endif + +#ifndef GL_EXT_fog_coord +#define GL_EXT_fog_coord 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFogCoordfEXT (GLfloat coord); +GLAPI void APIENTRY glFogCoordfvEXT (const GLfloat *coord); +GLAPI void APIENTRY glFogCoorddEXT (GLdouble coord); +GLAPI void APIENTRY glFogCoorddvEXT (const GLdouble *coord); +GLAPI void APIENTRY glFogCoordPointerEXT (GLenum type, GLsizei stride, const GLvoid *pointer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFOGCOORDFEXTPROC) (GLfloat coord); +typedef void (APIENTRYP PFNGLFOGCOORDFVEXTPROC) (const GLfloat *coord); +typedef void (APIENTRYP PFNGLFOGCOORDDEXTPROC) (GLdouble coord); +typedef void (APIENTRYP PFNGLFOGCOORDDVEXTPROC) (const GLdouble *coord); +typedef void (APIENTRYP PFNGLFOGCOORDPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_REND_screen_coordinates +#define GL_REND_screen_coordinates 1 +#endif + +#ifndef GL_EXT_coordinate_frame +#define GL_EXT_coordinate_frame 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTangent3bEXT (GLbyte tx, GLbyte ty, GLbyte tz); +GLAPI void APIENTRY glTangent3bvEXT (const GLbyte *v); +GLAPI void APIENTRY glTangent3dEXT (GLdouble tx, GLdouble ty, GLdouble tz); +GLAPI void APIENTRY glTangent3dvEXT (const GLdouble *v); +GLAPI void APIENTRY glTangent3fEXT (GLfloat tx, GLfloat ty, GLfloat tz); +GLAPI void APIENTRY glTangent3fvEXT (const GLfloat *v); +GLAPI void APIENTRY glTangent3iEXT (GLint tx, GLint ty, GLint tz); +GLAPI void APIENTRY glTangent3ivEXT (const GLint *v); +GLAPI void APIENTRY glTangent3sEXT (GLshort tx, GLshort ty, GLshort tz); +GLAPI void APIENTRY glTangent3svEXT (const GLshort *v); +GLAPI void APIENTRY glBinormal3bEXT (GLbyte bx, GLbyte by, GLbyte bz); +GLAPI void APIENTRY glBinormal3bvEXT (const GLbyte *v); +GLAPI void APIENTRY glBinormal3dEXT (GLdouble bx, GLdouble by, GLdouble bz); +GLAPI void APIENTRY glBinormal3dvEXT (const GLdouble *v); +GLAPI void APIENTRY glBinormal3fEXT (GLfloat bx, GLfloat by, GLfloat bz); +GLAPI void APIENTRY glBinormal3fvEXT (const GLfloat *v); +GLAPI void APIENTRY glBinormal3iEXT (GLint bx, GLint by, GLint bz); +GLAPI void APIENTRY glBinormal3ivEXT (const GLint *v); +GLAPI void APIENTRY glBinormal3sEXT (GLshort bx, GLshort by, GLshort bz); +GLAPI void APIENTRY glBinormal3svEXT (const GLshort *v); +GLAPI void APIENTRY glTangentPointerEXT (GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glBinormalPointerEXT (GLenum type, GLsizei stride, const GLvoid *pointer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTANGENT3BEXTPROC) (GLbyte tx, GLbyte ty, GLbyte tz); +typedef void (APIENTRYP PFNGLTANGENT3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLTANGENT3DEXTPROC) (GLdouble tx, GLdouble ty, GLdouble tz); +typedef void (APIENTRYP PFNGLTANGENT3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLTANGENT3FEXTPROC) (GLfloat tx, GLfloat ty, GLfloat tz); +typedef void (APIENTRYP PFNGLTANGENT3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLTANGENT3IEXTPROC) (GLint tx, GLint ty, GLint tz); +typedef void (APIENTRYP PFNGLTANGENT3IVEXTPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLTANGENT3SEXTPROC) (GLshort tx, GLshort ty, GLshort tz); +typedef void (APIENTRYP PFNGLTANGENT3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLBINORMAL3BEXTPROC) (GLbyte bx, GLbyte by, GLbyte bz); +typedef void (APIENTRYP PFNGLBINORMAL3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLBINORMAL3DEXTPROC) (GLdouble bx, GLdouble by, GLdouble bz); +typedef void (APIENTRYP PFNGLBINORMAL3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLBINORMAL3FEXTPROC) (GLfloat bx, GLfloat by, GLfloat bz); +typedef void (APIENTRYP PFNGLBINORMAL3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLBINORMAL3IEXTPROC) (GLint bx, GLint by, GLint bz); +typedef void (APIENTRYP PFNGLBINORMAL3IVEXTPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLBINORMAL3SEXTPROC) (GLshort bx, GLshort by, GLshort bz); +typedef void (APIENTRYP PFNGLBINORMAL3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLTANGENTPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLBINORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_EXT_texture_env_combine +#define GL_EXT_texture_env_combine 1 +#endif + +#ifndef GL_APPLE_specular_vector +#define GL_APPLE_specular_vector 1 +#endif + +#ifndef GL_APPLE_transform_hint +#define GL_APPLE_transform_hint 1 +#endif + +#ifndef GL_SGIX_fog_scale +#define GL_SGIX_fog_scale 1 +#endif + +#ifndef GL_SUNX_constant_data +#define GL_SUNX_constant_data 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFinishTextureSUNX (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFINISHTEXTURESUNXPROC) (void); +#endif + +#ifndef GL_SUN_global_alpha +#define GL_SUN_global_alpha 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGlobalAlphaFactorbSUN (GLbyte factor); +GLAPI void APIENTRY glGlobalAlphaFactorsSUN (GLshort factor); +GLAPI void APIENTRY glGlobalAlphaFactoriSUN (GLint factor); +GLAPI void APIENTRY glGlobalAlphaFactorfSUN (GLfloat factor); +GLAPI void APIENTRY glGlobalAlphaFactordSUN (GLdouble factor); +GLAPI void APIENTRY glGlobalAlphaFactorubSUN (GLubyte factor); +GLAPI void APIENTRY glGlobalAlphaFactorusSUN (GLushort factor); +GLAPI void APIENTRY glGlobalAlphaFactoruiSUN (GLuint factor); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORBSUNPROC) (GLbyte factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORSSUNPROC) (GLshort factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORISUNPROC) (GLint factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORFSUNPROC) (GLfloat factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORDSUNPROC) (GLdouble factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUBSUNPROC) (GLubyte factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUSSUNPROC) (GLushort factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUISUNPROC) (GLuint factor); +#endif + +#ifndef GL_SUN_triangle_list +#define GL_SUN_triangle_list 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glReplacementCodeuiSUN (GLuint code); +GLAPI void APIENTRY glReplacementCodeusSUN (GLushort code); +GLAPI void APIENTRY glReplacementCodeubSUN (GLubyte code); +GLAPI void APIENTRY glReplacementCodeuivSUN (const GLuint *code); +GLAPI void APIENTRY glReplacementCodeusvSUN (const GLushort *code); +GLAPI void APIENTRY glReplacementCodeubvSUN (const GLubyte *code); +GLAPI void APIENTRY glReplacementCodePointerSUN (GLenum type, GLsizei stride, const GLvoid* *pointer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUISUNPROC) (GLuint code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSSUNPROC) (GLushort code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBSUNPROC) (GLubyte code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVSUNPROC) (const GLuint *code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSVSUNPROC) (const GLushort *code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBVSUNPROC) (const GLubyte *code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEPOINTERSUNPROC) (GLenum type, GLsizei stride, const GLvoid* *pointer); +#endif + +#ifndef GL_SUN_vertex +#define GL_SUN_vertex 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColor4ubVertex2fSUN (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); +GLAPI void APIENTRY glColor4ubVertex2fvSUN (const GLubyte *c, const GLfloat *v); +GLAPI void APIENTRY glColor4ubVertex3fSUN (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glColor4ubVertex3fvSUN (const GLubyte *c, const GLfloat *v); +GLAPI void APIENTRY glColor3fVertex3fSUN (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glColor3fVertex3fvSUN (const GLfloat *c, const GLfloat *v); +GLAPI void APIENTRY glNormal3fVertex3fSUN (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glNormal3fVertex3fvSUN (const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glColor4fNormal3fVertex3fSUN (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glColor4fNormal3fVertex3fvSUN (const GLfloat *c, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fVertex3fSUN (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fVertex3fvSUN (const GLfloat *tc, const GLfloat *v); +GLAPI void APIENTRY glTexCoord4fVertex4fSUN (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glTexCoord4fVertex4fvSUN (const GLfloat *tc, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fSUN (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fvSUN (const GLfloat *tc, const GLubyte *c, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fColor3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fColor3fVertex3fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fvSUN (const GLfloat *tc, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fSUN (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiVertex3fSUN (GLuint rc, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiVertex3fvSUN (const GLuint *rc, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fSUN (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fvSUN (const GLuint *rc, const GLubyte *c, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fSUN (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fvSUN (const GLuint *rc, const GLfloat *c, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fSUN (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fSUN (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FVSUNPROC) (const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FVSUNPROC) (const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FSUNPROC) (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC) (const GLfloat *tc, const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC) (GLuint rc, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC) (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC) (const GLuint *rc, const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +#endif + +#ifndef GL_EXT_blend_func_separate +#define GL_EXT_blend_func_separate 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparateEXT (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEEXTPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#endif + +#ifndef GL_INGR_blend_func_separate +#define GL_INGR_blend_func_separate 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparateINGR (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINGRPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#endif + +#ifndef GL_INGR_color_clamp +#define GL_INGR_color_clamp 1 +#endif + +#ifndef GL_INGR_interlace_read +#define GL_INGR_interlace_read 1 +#endif + +#ifndef GL_EXT_stencil_wrap +#define GL_EXT_stencil_wrap 1 +#endif + +#ifndef GL_EXT_422_pixels +#define GL_EXT_422_pixels 1 +#endif + +#ifndef GL_NV_texgen_reflection +#define GL_NV_texgen_reflection 1 +#endif + +#ifndef GL_SUN_convolution_border_modes +#define GL_SUN_convolution_border_modes 1 +#endif + +#ifndef GL_EXT_texture_env_add +#define GL_EXT_texture_env_add 1 +#endif + +#ifndef GL_EXT_texture_lod_bias +#define GL_EXT_texture_lod_bias 1 +#endif + +#ifndef GL_EXT_texture_filter_anisotropic +#define GL_EXT_texture_filter_anisotropic 1 +#endif + +#ifndef GL_EXT_vertex_weighting +#define GL_EXT_vertex_weighting 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexWeightfEXT (GLfloat weight); +GLAPI void APIENTRY glVertexWeightfvEXT (const GLfloat *weight); +GLAPI void APIENTRY glVertexWeightPointerEXT (GLsizei size, GLenum type, GLsizei stride, const GLvoid *pointer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXWEIGHTFEXTPROC) (GLfloat weight); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTFVEXTPROC) (const GLfloat *weight); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTPOINTEREXTPROC) (GLsizei size, GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_NV_light_max_exponent +#define GL_NV_light_max_exponent 1 +#endif + +#ifndef GL_NV_vertex_array_range +#define GL_NV_vertex_array_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFlushVertexArrayRangeNV (void); +GLAPI void APIENTRY glVertexArrayRangeNV (GLsizei length, const GLvoid *pointer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGENVPROC) (void); +typedef void (APIENTRYP PFNGLVERTEXARRAYRANGENVPROC) (GLsizei length, const GLvoid *pointer); +#endif + +#ifndef GL_NV_register_combiners +#define GL_NV_register_combiners 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCombinerParameterfvNV (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glCombinerParameterfNV (GLenum pname, GLfloat param); +GLAPI void APIENTRY glCombinerParameterivNV (GLenum pname, const GLint *params); +GLAPI void APIENTRY glCombinerParameteriNV (GLenum pname, GLint param); +GLAPI void APIENTRY glCombinerInputNV (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +GLAPI void APIENTRY glCombinerOutputNV (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); +GLAPI void APIENTRY glFinalCombinerInputNV (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +GLAPI void APIENTRY glGetCombinerInputParameterfvNV (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetCombinerInputParameterivNV (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetCombinerOutputParameterfvNV (GLenum stage, GLenum portion, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetCombinerOutputParameterivNV (GLenum stage, GLenum portion, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetFinalCombinerInputParameterfvNV (GLenum variable, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetFinalCombinerInputParameterivNV (GLenum variable, GLenum pname, GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFVNVPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFNVPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERIVNVPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERINVPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLCOMBINERINPUTNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +typedef void (APIENTRYP PFNGLCOMBINEROUTPUTNVPROC) (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); +typedef void (APIENTRYP PFNGLFINALCOMBINERINPUTNVPROC) (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC) (GLenum variable, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC) (GLenum variable, GLenum pname, GLint *params); +#endif + +#ifndef GL_NV_fog_distance +#define GL_NV_fog_distance 1 +#endif + +#ifndef GL_NV_texgen_emboss +#define GL_NV_texgen_emboss 1 +#endif + +#ifndef GL_NV_blend_square +#define GL_NV_blend_square 1 +#endif + +#ifndef GL_NV_texture_env_combine4 +#define GL_NV_texture_env_combine4 1 +#endif + +#ifndef GL_MESA_resize_buffers +#define GL_MESA_resize_buffers 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glResizeBuffersMESA (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLRESIZEBUFFERSMESAPROC) (void); +#endif + +#ifndef GL_MESA_window_pos +#define GL_MESA_window_pos 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWindowPos2dMESA (GLdouble x, GLdouble y); +GLAPI void APIENTRY glWindowPos2dvMESA (const GLdouble *v); +GLAPI void APIENTRY glWindowPos2fMESA (GLfloat x, GLfloat y); +GLAPI void APIENTRY glWindowPos2fvMESA (const GLfloat *v); +GLAPI void APIENTRY glWindowPos2iMESA (GLint x, GLint y); +GLAPI void APIENTRY glWindowPos2ivMESA (const GLint *v); +GLAPI void APIENTRY glWindowPos2sMESA (GLshort x, GLshort y); +GLAPI void APIENTRY glWindowPos2svMESA (const GLshort *v); +GLAPI void APIENTRY glWindowPos3dMESA (GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glWindowPos3dvMESA (const GLdouble *v); +GLAPI void APIENTRY glWindowPos3fMESA (GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glWindowPos3fvMESA (const GLfloat *v); +GLAPI void APIENTRY glWindowPos3iMESA (GLint x, GLint y, GLint z); +GLAPI void APIENTRY glWindowPos3ivMESA (const GLint *v); +GLAPI void APIENTRY glWindowPos3sMESA (GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glWindowPos3svMESA (const GLshort *v); +GLAPI void APIENTRY glWindowPos4dMESA (GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glWindowPos4dvMESA (const GLdouble *v); +GLAPI void APIENTRY glWindowPos4fMESA (GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glWindowPos4fvMESA (const GLfloat *v); +GLAPI void APIENTRY glWindowPos4iMESA (GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glWindowPos4ivMESA (const GLint *v); +GLAPI void APIENTRY glWindowPos4sMESA (GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glWindowPos4svMESA (const GLshort *v); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLWINDOWPOS2DMESAPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLWINDOWPOS2DVMESAPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2FMESAPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLWINDOWPOS2FVMESAPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2IMESAPROC) (GLint x, GLint y); +typedef void (APIENTRYP PFNGLWINDOWPOS2IVMESAPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2SMESAPROC) (GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLWINDOWPOS2SVMESAPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3DMESAPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLWINDOWPOS3DVMESAPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3FMESAPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLWINDOWPOS3FVMESAPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3IMESAPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLWINDOWPOS3IVMESAPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3SMESAPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLWINDOWPOS3SVMESAPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4DMESAPROC) (GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLWINDOWPOS4DVMESAPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4FMESAPROC) (GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLWINDOWPOS4FVMESAPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4IMESAPROC) (GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLWINDOWPOS4IVMESAPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4SMESAPROC) (GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLWINDOWPOS4SVMESAPROC) (const GLshort *v); +#endif + +#ifndef GL_IBM_cull_vertex +#define GL_IBM_cull_vertex 1 +#endif + +#ifndef GL_IBM_multimode_draw_arrays +#define GL_IBM_multimode_draw_arrays 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiModeDrawArraysIBM (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); +GLAPI void APIENTRY glMultiModeDrawElementsIBM (const GLenum *mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei primcount, GLint modestride); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLMULTIMODEDRAWARRAYSIBMPROC) (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); +typedef void (APIENTRYP PFNGLMULTIMODEDRAWELEMENTSIBMPROC) (const GLenum *mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei primcount, GLint modestride); +#endif + +#ifndef GL_IBM_vertex_array_lists +#define GL_IBM_vertex_array_lists 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorPointerListIBM (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +GLAPI void APIENTRY glSecondaryColorPointerListIBM (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +GLAPI void APIENTRY glEdgeFlagPointerListIBM (GLint stride, const GLboolean* *pointer, GLint ptrstride); +GLAPI void APIENTRY glFogCoordPointerListIBM (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +GLAPI void APIENTRY glIndexPointerListIBM (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +GLAPI void APIENTRY glNormalPointerListIBM (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +GLAPI void APIENTRY glTexCoordPointerListIBM (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +GLAPI void APIENTRY glVertexPointerListIBM (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLEDGEFLAGPOINTERLISTIBMPROC) (GLint stride, const GLboolean* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLFOGCOORDPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLINDEXPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLNORMALPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLTEXCOORDPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLVERTEXPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +#endif + +#ifndef GL_SGIX_subsample +#define GL_SGIX_subsample 1 +#endif + +#ifndef GL_SGIX_ycrcba +#define GL_SGIX_ycrcba 1 +#endif + +#ifndef GL_SGIX_ycrcb_subsample +#define GL_SGIX_ycrcb_subsample 1 +#endif + +#ifndef GL_SGIX_depth_pass_instrument +#define GL_SGIX_depth_pass_instrument 1 +#endif + +#ifndef GL_3DFX_texture_compression_FXT1 +#define GL_3DFX_texture_compression_FXT1 1 +#endif + +#ifndef GL_3DFX_multisample +#define GL_3DFX_multisample 1 +#endif + +#ifndef GL_3DFX_tbuffer +#define GL_3DFX_tbuffer 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTbufferMask3DFX (GLuint mask); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTBUFFERMASK3DFXPROC) (GLuint mask); +#endif + +#ifndef GL_EXT_multisample +#define GL_EXT_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSampleMaskEXT (GLclampf value, GLboolean invert); +GLAPI void APIENTRY glSamplePatternEXT (GLenum pattern); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSAMPLEMASKEXTPROC) (GLclampf value, GLboolean invert); +typedef void (APIENTRYP PFNGLSAMPLEPATTERNEXTPROC) (GLenum pattern); +#endif + +#ifndef GL_SGIX_vertex_preclip +#define GL_SGIX_vertex_preclip 1 +#endif + +#ifndef GL_SGIX_convolution_accuracy +#define GL_SGIX_convolution_accuracy 1 +#endif + +#ifndef GL_SGIX_resample +#define GL_SGIX_resample 1 +#endif + +#ifndef GL_SGIS_point_line_texgen +#define GL_SGIS_point_line_texgen 1 +#endif + +#ifndef GL_SGIS_texture_color_mask +#define GL_SGIS_texture_color_mask 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureColorMaskSGIS (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXTURECOLORMASKSGISPROC) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +#endif + +#ifndef GL_SGIX_igloo_interface +#define GL_SGIX_igloo_interface 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glIglooInterfaceSGIX (GLenum pname, const GLvoid *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLIGLOOINTERFACESGIXPROC) (GLenum pname, const GLvoid *params); +#endif + +#ifndef GL_EXT_texture_env_dot3 +#define GL_EXT_texture_env_dot3 1 +#endif + +#ifndef GL_ATI_texture_mirror_once +#define GL_ATI_texture_mirror_once 1 +#endif + +#ifndef GL_NV_fence +#define GL_NV_fence 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDeleteFencesNV (GLsizei n, const GLuint *fences); +GLAPI void APIENTRY glGenFencesNV (GLsizei n, GLuint *fences); +GLAPI GLboolean APIENTRY glIsFenceNV (GLuint fence); +GLAPI GLboolean APIENTRY glTestFenceNV (GLuint fence); +GLAPI void APIENTRY glGetFenceivNV (GLuint fence, GLenum pname, GLint *params); +GLAPI void APIENTRY glFinishFenceNV (GLuint fence); +GLAPI void APIENTRY glSetFenceNV (GLuint fence, GLenum condition); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint *fences); +typedef void (APIENTRYP PFNGLGENFENCESNVPROC) (GLsizei n, GLuint *fences); +typedef GLboolean (APIENTRYP PFNGLISFENCENVPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLTESTFENCENVPROC) (GLuint fence); +typedef void (APIENTRYP PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence); +typedef void (APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition); +#endif + +#ifndef GL_NV_evaluators +#define GL_NV_evaluators 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMapControlPointsNV (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const GLvoid *points); +GLAPI void APIENTRY glMapParameterivNV (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glMapParameterfvNV (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetMapControlPointsNV (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, GLvoid *points); +GLAPI void APIENTRY glGetMapParameterivNV (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMapParameterfvNV (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMapAttribParameterivNV (GLenum target, GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMapAttribParameterfvNV (GLenum target, GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glEvalMapsNV (GLenum target, GLenum mode); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const GLvoid *points); +typedef void (APIENTRYP PFNGLMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, GLvoid *points); +typedef void (APIENTRYP PFNGLGETMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERIVNVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLEVALMAPSNVPROC) (GLenum target, GLenum mode); +#endif + +#ifndef GL_NV_packed_depth_stencil +#define GL_NV_packed_depth_stencil 1 +#endif + +#ifndef GL_NV_register_combiners2 +#define GL_NV_register_combiners2 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCombinerStageParameterfvNV (GLenum stage, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetCombinerStageParameterfvNV (GLenum stage, GLenum pname, GLfloat *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, GLfloat *params); +#endif + +#ifndef GL_NV_texture_compression_vtc +#define GL_NV_texture_compression_vtc 1 +#endif + +#ifndef GL_NV_texture_rectangle +#define GL_NV_texture_rectangle 1 +#endif + +#ifndef GL_NV_texture_shader +#define GL_NV_texture_shader 1 +#endif + +#ifndef GL_NV_texture_shader2 +#define GL_NV_texture_shader2 1 +#endif + +#ifndef GL_NV_vertex_array_range2 +#define GL_NV_vertex_array_range2 1 +#endif + +#ifndef GL_NV_vertex_program +#define GL_NV_vertex_program 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glAreProgramsResidentNV (GLsizei n, const GLuint *programs, GLboolean *residences); +GLAPI void APIENTRY glBindProgramNV (GLenum target, GLuint id); +GLAPI void APIENTRY glDeleteProgramsNV (GLsizei n, const GLuint *programs); +GLAPI void APIENTRY glExecuteProgramNV (GLenum target, GLuint id, const GLfloat *params); +GLAPI void APIENTRY glGenProgramsNV (GLsizei n, GLuint *programs); +GLAPI void APIENTRY glGetProgramParameterdvNV (GLenum target, GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetProgramParameterfvNV (GLenum target, GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetProgramivNV (GLuint id, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetProgramStringNV (GLuint id, GLenum pname, GLubyte *program); +GLAPI void APIENTRY glGetTrackMatrixivNV (GLenum target, GLuint address, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribdvNV (GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetVertexAttribfvNV (GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVertexAttribivNV (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribPointervNV (GLuint index, GLenum pname, GLvoid* *pointer); +GLAPI GLboolean APIENTRY glIsProgramNV (GLuint id); +GLAPI void APIENTRY glLoadProgramNV (GLenum target, GLuint id, GLsizei len, const GLubyte *program); +GLAPI void APIENTRY glProgramParameter4dNV (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramParameter4dvNV (GLenum target, GLuint index, const GLdouble *v); +GLAPI void APIENTRY glProgramParameter4fNV (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glProgramParameter4fvNV (GLenum target, GLuint index, const GLfloat *v); +GLAPI void APIENTRY glProgramParameters4dvNV (GLenum target, GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glProgramParameters4fvNV (GLenum target, GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glRequestResidentProgramsNV (GLsizei n, const GLuint *programs); +GLAPI void APIENTRY glTrackMatrixNV (GLenum target, GLuint address, GLenum matrix, GLenum transform); +GLAPI void APIENTRY glVertexAttribPointerNV (GLuint index, GLint fsize, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glVertexAttrib1dNV (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttrib1dvNV (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib1fNV (GLuint index, GLfloat x); +GLAPI void APIENTRY glVertexAttrib1fvNV (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib1sNV (GLuint index, GLshort x); +GLAPI void APIENTRY glVertexAttrib1svNV (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib2dNV (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttrib2dvNV (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib2fNV (GLuint index, GLfloat x, GLfloat y); +GLAPI void APIENTRY glVertexAttrib2fvNV (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib2sNV (GLuint index, GLshort x, GLshort y); +GLAPI void APIENTRY glVertexAttrib2svNV (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib3dNV (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttrib3dvNV (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib3fNV (GLuint index, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glVertexAttrib3fvNV (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib3sNV (GLuint index, GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glVertexAttrib3svNV (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4dNV (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttrib4dvNV (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib4fNV (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glVertexAttrib4fvNV (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib4sNV (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glVertexAttrib4svNV (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4ubNV (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +GLAPI void APIENTRY glVertexAttrib4ubvNV (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttribs1dvNV (GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribs1fvNV (GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glVertexAttribs1svNV (GLuint index, GLsizei count, const GLshort *v); +GLAPI void APIENTRY glVertexAttribs2dvNV (GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribs2fvNV (GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glVertexAttribs2svNV (GLuint index, GLsizei count, const GLshort *v); +GLAPI void APIENTRY glVertexAttribs3dvNV (GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribs3fvNV (GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glVertexAttribs3svNV (GLuint index, GLsizei count, const GLshort *v); +GLAPI void APIENTRY glVertexAttribs4dvNV (GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribs4fvNV (GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glVertexAttribs4svNV (GLuint index, GLsizei count, const GLshort *v); +GLAPI void APIENTRY glVertexAttribs4ubvNV (GLuint index, GLsizei count, const GLubyte *v); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLboolean (APIENTRYP PFNGLAREPROGRAMSRESIDENTNVPROC) (GLsizei n, const GLuint *programs, GLboolean *residences); +typedef void (APIENTRYP PFNGLBINDPROGRAMNVPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLDELETEPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRYP PFNGLEXECUTEPROGRAMNVPROC) (GLenum target, GLuint id, const GLfloat *params); +typedef void (APIENTRYP PFNGLGENPROGRAMSNVPROC) (GLsizei n, GLuint *programs); +typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERDVNVPROC) (GLenum target, GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMIVNVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGNVPROC) (GLuint id, GLenum pname, GLubyte *program); +typedef void (APIENTRYP PFNGLGETTRACKMATRIXIVNVPROC) (GLenum target, GLuint address, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVNVPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVNVPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVNVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVNVPROC) (GLuint index, GLenum pname, GLvoid* *pointer); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLLOADPROGRAMNVPROC) (GLenum target, GLuint id, GLsizei len, const GLubyte *program); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DNVPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DVNVPROC) (GLenum target, GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FNVPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FVNVPROC) (GLenum target, GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4DVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4FVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLREQUESTRESIDENTPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRYP PFNGLTRACKMATRIXNVPROC) (GLenum target, GLuint address, GLenum matrix, GLenum transform); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERNVPROC) (GLuint index, GLint fsize, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DNVPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FNVPROC) (GLuint index, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SNVPROC) (GLuint index, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DNVPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FNVPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SNVPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBNVPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVNVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4UBVNVPROC) (GLuint index, GLsizei count, const GLubyte *v); +#endif + +#ifndef GL_SGIX_texture_coordinate_clamp +#define GL_SGIX_texture_coordinate_clamp 1 +#endif + +#ifndef GL_SGIX_scalebias_hint +#define GL_SGIX_scalebias_hint 1 +#endif + +#ifndef GL_OML_interlace +#define GL_OML_interlace 1 +#endif + +#ifndef GL_OML_subsample +#define GL_OML_subsample 1 +#endif + +#ifndef GL_OML_resample +#define GL_OML_resample 1 +#endif + +#ifndef GL_NV_copy_depth_to_color +#define GL_NV_copy_depth_to_color 1 +#endif + +#ifndef GL_ATI_envmap_bumpmap +#define GL_ATI_envmap_bumpmap 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexBumpParameterivATI (GLenum pname, const GLint *param); +GLAPI void APIENTRY glTexBumpParameterfvATI (GLenum pname, const GLfloat *param); +GLAPI void APIENTRY glGetTexBumpParameterivATI (GLenum pname, GLint *param); +GLAPI void APIENTRY glGetTexBumpParameterfvATI (GLenum pname, GLfloat *param); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERIVATIPROC) (GLenum pname, const GLint *param); +typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERFVATIPROC) (GLenum pname, const GLfloat *param); +typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERIVATIPROC) (GLenum pname, GLint *param); +typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERFVATIPROC) (GLenum pname, GLfloat *param); +#endif + +#ifndef GL_ATI_fragment_shader +#define GL_ATI_fragment_shader 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint APIENTRY glGenFragmentShadersATI (GLuint range); +GLAPI void APIENTRY glBindFragmentShaderATI (GLuint id); +GLAPI void APIENTRY glDeleteFragmentShaderATI (GLuint id); +GLAPI void APIENTRY glBeginFragmentShaderATI (void); +GLAPI void APIENTRY glEndFragmentShaderATI (void); +GLAPI void APIENTRY glPassTexCoordATI (GLuint dst, GLuint coord, GLenum swizzle); +GLAPI void APIENTRY glSampleMapATI (GLuint dst, GLuint interp, GLenum swizzle); +GLAPI void APIENTRY glColorFragmentOp1ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +GLAPI void APIENTRY glColorFragmentOp2ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +GLAPI void APIENTRY glColorFragmentOp3ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +GLAPI void APIENTRY glAlphaFragmentOp1ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +GLAPI void APIENTRY glAlphaFragmentOp2ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +GLAPI void APIENTRY glAlphaFragmentOp3ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +GLAPI void APIENTRY glSetFragmentShaderConstantATI (GLuint dst, const GLfloat *value); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLuint (APIENTRYP PFNGLGENFRAGMENTSHADERSATIPROC) (GLuint range); +typedef void (APIENTRYP PFNGLBINDFRAGMENTSHADERATIPROC) (GLuint id); +typedef void (APIENTRYP PFNGLDELETEFRAGMENTSHADERATIPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINFRAGMENTSHADERATIPROC) (void); +typedef void (APIENTRYP PFNGLENDFRAGMENTSHADERATIPROC) (void); +typedef void (APIENTRYP PFNGLPASSTEXCOORDATIPROC) (GLuint dst, GLuint coord, GLenum swizzle); +typedef void (APIENTRYP PFNGLSAMPLEMAPATIPROC) (GLuint dst, GLuint interp, GLenum swizzle); +typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +typedef void (APIENTRYP PFNGLSETFRAGMENTSHADERCONSTANTATIPROC) (GLuint dst, const GLfloat *value); +#endif + +#ifndef GL_ATI_pn_triangles +#define GL_ATI_pn_triangles 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPNTrianglesiATI (GLenum pname, GLint param); +GLAPI void APIENTRY glPNTrianglesfATI (GLenum pname, GLfloat param); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPNTRIANGLESIATIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPNTRIANGLESFATIPROC) (GLenum pname, GLfloat param); +#endif + +#ifndef GL_ATI_vertex_array_object +#define GL_ATI_vertex_array_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint APIENTRY glNewObjectBufferATI (GLsizei size, const GLvoid *pointer, GLenum usage); +GLAPI GLboolean APIENTRY glIsObjectBufferATI (GLuint buffer); +GLAPI void APIENTRY glUpdateObjectBufferATI (GLuint buffer, GLuint offset, GLsizei size, const GLvoid *pointer, GLenum preserve); +GLAPI void APIENTRY glGetObjectBufferfvATI (GLuint buffer, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetObjectBufferivATI (GLuint buffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glFreeObjectBufferATI (GLuint buffer); +GLAPI void APIENTRY glArrayObjectATI (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +GLAPI void APIENTRY glGetArrayObjectfvATI (GLenum array, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetArrayObjectivATI (GLenum array, GLenum pname, GLint *params); +GLAPI void APIENTRY glVariantArrayObjectATI (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +GLAPI void APIENTRY glGetVariantArrayObjectfvATI (GLuint id, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVariantArrayObjectivATI (GLuint id, GLenum pname, GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLuint (APIENTRYP PFNGLNEWOBJECTBUFFERATIPROC) (GLsizei size, const GLvoid *pointer, GLenum usage); +typedef GLboolean (APIENTRYP PFNGLISOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLUPDATEOBJECTBUFFERATIPROC) (GLuint buffer, GLuint offset, GLsizei size, const GLvoid *pointer, GLenum preserve); +typedef void (APIENTRYP PFNGLGETOBJECTBUFFERFVATIPROC) (GLuint buffer, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETOBJECTBUFFERIVATIPROC) (GLuint buffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLFREEOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLARRAYOBJECTATIPROC) (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRYP PFNGLGETARRAYOBJECTFVATIPROC) (GLenum array, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETARRAYOBJECTIVATIPROC) (GLenum array, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLVARIANTARRAYOBJECTATIPROC) (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTFVATIPROC) (GLuint id, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTIVATIPROC) (GLuint id, GLenum pname, GLint *params); +#endif + +#ifndef GL_EXT_vertex_shader +#define GL_EXT_vertex_shader 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginVertexShaderEXT (void); +GLAPI void APIENTRY glEndVertexShaderEXT (void); +GLAPI void APIENTRY glBindVertexShaderEXT (GLuint id); +GLAPI GLuint APIENTRY glGenVertexShadersEXT (GLuint range); +GLAPI void APIENTRY glDeleteVertexShaderEXT (GLuint id); +GLAPI void APIENTRY glShaderOp1EXT (GLenum op, GLuint res, GLuint arg1); +GLAPI void APIENTRY glShaderOp2EXT (GLenum op, GLuint res, GLuint arg1, GLuint arg2); +GLAPI void APIENTRY glShaderOp3EXT (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); +GLAPI void APIENTRY glSwizzleEXT (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +GLAPI void APIENTRY glWriteMaskEXT (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +GLAPI void APIENTRY glInsertComponentEXT (GLuint res, GLuint src, GLuint num); +GLAPI void APIENTRY glExtractComponentEXT (GLuint res, GLuint src, GLuint num); +GLAPI GLuint APIENTRY glGenSymbolsEXT (GLenum datatype, GLenum storagetype, GLenum range, GLuint components); +GLAPI void APIENTRY glSetInvariantEXT (GLuint id, GLenum type, const GLvoid *addr); +GLAPI void APIENTRY glSetLocalConstantEXT (GLuint id, GLenum type, const GLvoid *addr); +GLAPI void APIENTRY glVariantbvEXT (GLuint id, const GLbyte *addr); +GLAPI void APIENTRY glVariantsvEXT (GLuint id, const GLshort *addr); +GLAPI void APIENTRY glVariantivEXT (GLuint id, const GLint *addr); +GLAPI void APIENTRY glVariantfvEXT (GLuint id, const GLfloat *addr); +GLAPI void APIENTRY glVariantdvEXT (GLuint id, const GLdouble *addr); +GLAPI void APIENTRY glVariantubvEXT (GLuint id, const GLubyte *addr); +GLAPI void APIENTRY glVariantusvEXT (GLuint id, const GLushort *addr); +GLAPI void APIENTRY glVariantuivEXT (GLuint id, const GLuint *addr); +GLAPI void APIENTRY glVariantPointerEXT (GLuint id, GLenum type, GLuint stride, const GLvoid *addr); +GLAPI void APIENTRY glEnableVariantClientStateEXT (GLuint id); +GLAPI void APIENTRY glDisableVariantClientStateEXT (GLuint id); +GLAPI GLuint APIENTRY glBindLightParameterEXT (GLenum light, GLenum value); +GLAPI GLuint APIENTRY glBindMaterialParameterEXT (GLenum face, GLenum value); +GLAPI GLuint APIENTRY glBindTexGenParameterEXT (GLenum unit, GLenum coord, GLenum value); +GLAPI GLuint APIENTRY glBindTextureUnitParameterEXT (GLenum unit, GLenum value); +GLAPI GLuint APIENTRY glBindParameterEXT (GLenum value); +GLAPI GLboolean APIENTRY glIsVariantEnabledEXT (GLuint id, GLenum cap); +GLAPI void APIENTRY glGetVariantBooleanvEXT (GLuint id, GLenum value, GLboolean *data); +GLAPI void APIENTRY glGetVariantIntegervEXT (GLuint id, GLenum value, GLint *data); +GLAPI void APIENTRY glGetVariantFloatvEXT (GLuint id, GLenum value, GLfloat *data); +GLAPI void APIENTRY glGetVariantPointervEXT (GLuint id, GLenum value, GLvoid* *data); +GLAPI void APIENTRY glGetInvariantBooleanvEXT (GLuint id, GLenum value, GLboolean *data); +GLAPI void APIENTRY glGetInvariantIntegervEXT (GLuint id, GLenum value, GLint *data); +GLAPI void APIENTRY glGetInvariantFloatvEXT (GLuint id, GLenum value, GLfloat *data); +GLAPI void APIENTRY glGetLocalConstantBooleanvEXT (GLuint id, GLenum value, GLboolean *data); +GLAPI void APIENTRY glGetLocalConstantIntegervEXT (GLuint id, GLenum value, GLint *data); +GLAPI void APIENTRY glGetLocalConstantFloatvEXT (GLuint id, GLenum value, GLfloat *data); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBEGINVERTEXSHADEREXTPROC) (void); +typedef void (APIENTRYP PFNGLENDVERTEXSHADEREXTPROC) (void); +typedef void (APIENTRYP PFNGLBINDVERTEXSHADEREXTPROC) (GLuint id); +typedef GLuint (APIENTRYP PFNGLGENVERTEXSHADERSEXTPROC) (GLuint range); +typedef void (APIENTRYP PFNGLDELETEVERTEXSHADEREXTPROC) (GLuint id); +typedef void (APIENTRYP PFNGLSHADEROP1EXTPROC) (GLenum op, GLuint res, GLuint arg1); +typedef void (APIENTRYP PFNGLSHADEROP2EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2); +typedef void (APIENTRYP PFNGLSHADEROP3EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); +typedef void (APIENTRYP PFNGLSWIZZLEEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +typedef void (APIENTRYP PFNGLWRITEMASKEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +typedef void (APIENTRYP PFNGLINSERTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); +typedef void (APIENTRYP PFNGLEXTRACTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); +typedef GLuint (APIENTRYP PFNGLGENSYMBOLSEXTPROC) (GLenum datatype, GLenum storagetype, GLenum range, GLuint components); +typedef void (APIENTRYP PFNGLSETINVARIANTEXTPROC) (GLuint id, GLenum type, const GLvoid *addr); +typedef void (APIENTRYP PFNGLSETLOCALCONSTANTEXTPROC) (GLuint id, GLenum type, const GLvoid *addr); +typedef void (APIENTRYP PFNGLVARIANTBVEXTPROC) (GLuint id, const GLbyte *addr); +typedef void (APIENTRYP PFNGLVARIANTSVEXTPROC) (GLuint id, const GLshort *addr); +typedef void (APIENTRYP PFNGLVARIANTIVEXTPROC) (GLuint id, const GLint *addr); +typedef void (APIENTRYP PFNGLVARIANTFVEXTPROC) (GLuint id, const GLfloat *addr); +typedef void (APIENTRYP PFNGLVARIANTDVEXTPROC) (GLuint id, const GLdouble *addr); +typedef void (APIENTRYP PFNGLVARIANTUBVEXTPROC) (GLuint id, const GLubyte *addr); +typedef void (APIENTRYP PFNGLVARIANTUSVEXTPROC) (GLuint id, const GLushort *addr); +typedef void (APIENTRYP PFNGLVARIANTUIVEXTPROC) (GLuint id, const GLuint *addr); +typedef void (APIENTRYP PFNGLVARIANTPOINTEREXTPROC) (GLuint id, GLenum type, GLuint stride, const GLvoid *addr); +typedef void (APIENTRYP PFNGLENABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); +typedef void (APIENTRYP PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); +typedef GLuint (APIENTRYP PFNGLBINDLIGHTPARAMETEREXTPROC) (GLenum light, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDMATERIALPARAMETEREXTPROC) (GLenum face, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDTEXGENPARAMETEREXTPROC) (GLenum unit, GLenum coord, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDTEXTUREUNITPARAMETEREXTPROC) (GLenum unit, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDPARAMETEREXTPROC) (GLenum value); +typedef GLboolean (APIENTRYP PFNGLISVARIANTENABLEDEXTPROC) (GLuint id, GLenum cap); +typedef void (APIENTRYP PFNGLGETVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRYP PFNGLGETVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRYP PFNGLGETVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +typedef void (APIENTRYP PFNGLGETVARIANTPOINTERVEXTPROC) (GLuint id, GLenum value, GLvoid* *data); +typedef void (APIENTRYP PFNGLGETINVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRYP PFNGLGETINVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRYP PFNGLGETINVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +typedef void (APIENTRYP PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRYP PFNGLGETLOCALCONSTANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRYP PFNGLGETLOCALCONSTANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +#endif + +#ifndef GL_ATI_vertex_streams +#define GL_ATI_vertex_streams 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexStream1sATI (GLenum stream, GLshort x); +GLAPI void APIENTRY glVertexStream1svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glVertexStream1iATI (GLenum stream, GLint x); +GLAPI void APIENTRY glVertexStream1ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glVertexStream1fATI (GLenum stream, GLfloat x); +GLAPI void APIENTRY glVertexStream1fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glVertexStream1dATI (GLenum stream, GLdouble x); +GLAPI void APIENTRY glVertexStream1dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glVertexStream2sATI (GLenum stream, GLshort x, GLshort y); +GLAPI void APIENTRY glVertexStream2svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glVertexStream2iATI (GLenum stream, GLint x, GLint y); +GLAPI void APIENTRY glVertexStream2ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glVertexStream2fATI (GLenum stream, GLfloat x, GLfloat y); +GLAPI void APIENTRY glVertexStream2fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glVertexStream2dATI (GLenum stream, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexStream2dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glVertexStream3sATI (GLenum stream, GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glVertexStream3svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glVertexStream3iATI (GLenum stream, GLint x, GLint y, GLint z); +GLAPI void APIENTRY glVertexStream3ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glVertexStream3fATI (GLenum stream, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glVertexStream3fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glVertexStream3dATI (GLenum stream, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexStream3dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glVertexStream4sATI (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glVertexStream4svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glVertexStream4iATI (GLenum stream, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glVertexStream4ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glVertexStream4fATI (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glVertexStream4fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glVertexStream4dATI (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexStream4dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glNormalStream3bATI (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz); +GLAPI void APIENTRY glNormalStream3bvATI (GLenum stream, const GLbyte *coords); +GLAPI void APIENTRY glNormalStream3sATI (GLenum stream, GLshort nx, GLshort ny, GLshort nz); +GLAPI void APIENTRY glNormalStream3svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glNormalStream3iATI (GLenum stream, GLint nx, GLint ny, GLint nz); +GLAPI void APIENTRY glNormalStream3ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glNormalStream3fATI (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz); +GLAPI void APIENTRY glNormalStream3fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glNormalStream3dATI (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz); +GLAPI void APIENTRY glNormalStream3dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glClientActiveVertexStreamATI (GLenum stream); +GLAPI void APIENTRY glVertexBlendEnviATI (GLenum pname, GLint param); +GLAPI void APIENTRY glVertexBlendEnvfATI (GLenum pname, GLfloat param); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXSTREAM1SATIPROC) (GLenum stream, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1IATIPROC) (GLenum stream, GLint x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1FATIPROC) (GLenum stream, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1DATIPROC) (GLenum stream, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2SATIPROC) (GLenum stream, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2IATIPROC) (GLenum stream, GLint x, GLint y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2FATIPROC) (GLenum stream, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2DATIPROC) (GLenum stream, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3IATIPROC) (GLenum stream, GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4IATIPROC) (GLenum stream, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3BATIPROC) (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3BVATIPROC) (GLenum stream, const GLbyte *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3SATIPROC) (GLenum stream, GLshort nx, GLshort ny, GLshort nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3IATIPROC) (GLenum stream, GLint nx, GLint ny, GLint nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3FATIPROC) (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3DATIPROC) (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC) (GLenum stream); +typedef void (APIENTRYP PFNGLVERTEXBLENDENVIATIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLVERTEXBLENDENVFATIPROC) (GLenum pname, GLfloat param); +#endif + +#ifndef GL_ATI_element_array +#define GL_ATI_element_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glElementPointerATI (GLenum type, const GLvoid *pointer); +GLAPI void APIENTRY glDrawElementArrayATI (GLenum mode, GLsizei count); +GLAPI void APIENTRY glDrawRangeElementArrayATI (GLenum mode, GLuint start, GLuint end, GLsizei count); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLELEMENTPOINTERATIPROC) (GLenum type, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYATIPROC) (GLenum mode, GLsizei count); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYATIPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count); +#endif + +#ifndef GL_SUN_mesh_array +#define GL_SUN_mesh_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawMeshArraysSUN (GLenum mode, GLint first, GLsizei count, GLsizei width); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWMESHARRAYSSUNPROC) (GLenum mode, GLint first, GLsizei count, GLsizei width); +#endif + +#ifndef GL_SUN_slice_accum +#define GL_SUN_slice_accum 1 +#endif + +#ifndef GL_NV_multisample_filter_hint +#define GL_NV_multisample_filter_hint 1 +#endif + +#ifndef GL_NV_depth_clamp +#define GL_NV_depth_clamp 1 +#endif + +#ifndef GL_NV_occlusion_query +#define GL_NV_occlusion_query 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenOcclusionQueriesNV (GLsizei n, GLuint *ids); +GLAPI void APIENTRY glDeleteOcclusionQueriesNV (GLsizei n, const GLuint *ids); +GLAPI GLboolean APIENTRY glIsOcclusionQueryNV (GLuint id); +GLAPI void APIENTRY glBeginOcclusionQueryNV (GLuint id); +GLAPI void APIENTRY glEndOcclusionQueryNV (void); +GLAPI void APIENTRY glGetOcclusionQueryivNV (GLuint id, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetOcclusionQueryuivNV (GLuint id, GLenum pname, GLuint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGENOCCLUSIONQUERIESNVPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEOCCLUSIONQUERIESNVPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISOCCLUSIONQUERYNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINOCCLUSIONQUERYNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLENDOCCLUSIONQUERYNVPROC) (void); +typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYIVNVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYUIVNVPROC) (GLuint id, GLenum pname, GLuint *params); +#endif + +#ifndef GL_NV_point_sprite +#define GL_NV_point_sprite 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameteriNV (GLenum pname, GLint param); +GLAPI void APIENTRY glPointParameterivNV (GLenum pname, const GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPOINTPARAMETERINVPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIVNVPROC) (GLenum pname, const GLint *params); +#endif + +#ifndef GL_NV_texture_shader3 +#define GL_NV_texture_shader3 1 +#endif + +#ifndef GL_NV_vertex_program1_1 +#define GL_NV_vertex_program1_1 1 +#endif + +#ifndef GL_EXT_shadow_funcs +#define GL_EXT_shadow_funcs 1 +#endif + +#ifndef GL_EXT_stencil_two_side +#define GL_EXT_stencil_two_side 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveStencilFaceEXT (GLenum face); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLACTIVESTENCILFACEEXTPROC) (GLenum face); +#endif + +#ifndef GL_ATI_text_fragment_shader +#define GL_ATI_text_fragment_shader 1 +#endif + +#ifndef GL_APPLE_client_storage +#define GL_APPLE_client_storage 1 +#endif + +#ifndef GL_APPLE_element_array +#define GL_APPLE_element_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glElementPointerAPPLE (GLenum type, const GLvoid *pointer); +GLAPI void APIENTRY glDrawElementArrayAPPLE (GLenum mode, GLint first, GLsizei count); +GLAPI void APIENTRY glDrawRangeElementArrayAPPLE (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); +GLAPI void APIENTRY glMultiDrawElementArrayAPPLE (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +GLAPI void APIENTRY glMultiDrawRangeElementArrayAPPLE (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLELEMENTPOINTERAPPLEPROC) (GLenum type, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +typedef void (APIENTRYP PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount); +#endif + +#ifndef GL_APPLE_fence +#define GL_APPLE_fence 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenFencesAPPLE (GLsizei n, GLuint *fences); +GLAPI void APIENTRY glDeleteFencesAPPLE (GLsizei n, const GLuint *fences); +GLAPI void APIENTRY glSetFenceAPPLE (GLuint fence); +GLAPI GLboolean APIENTRY glIsFenceAPPLE (GLuint fence); +GLAPI GLboolean APIENTRY glTestFenceAPPLE (GLuint fence); +GLAPI void APIENTRY glFinishFenceAPPLE (GLuint fence); +GLAPI GLboolean APIENTRY glTestObjectAPPLE (GLenum object, GLuint name); +GLAPI void APIENTRY glFinishObjectAPPLE (GLenum object, GLint name); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGENFENCESAPPLEPROC) (GLsizei n, GLuint *fences); +typedef void (APIENTRYP PFNGLDELETEFENCESAPPLEPROC) (GLsizei n, const GLuint *fences); +typedef void (APIENTRYP PFNGLSETFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLISFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLTESTFENCEAPPLEPROC) (GLuint fence); +typedef void (APIENTRYP PFNGLFINISHFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLTESTOBJECTAPPLEPROC) (GLenum object, GLuint name); +typedef void (APIENTRYP PFNGLFINISHOBJECTAPPLEPROC) (GLenum object, GLint name); +#endif + +#ifndef GL_APPLE_vertex_array_object +#define GL_APPLE_vertex_array_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindVertexArrayAPPLE (GLuint array); +GLAPI void APIENTRY glDeleteVertexArraysAPPLE (GLsizei n, const GLuint *arrays); +GLAPI void APIENTRY glGenVertexArraysAPPLE (GLsizei n, GLuint *arrays); +GLAPI GLboolean APIENTRY glIsVertexArrayAPPLE (GLuint array); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDVERTEXARRAYAPPLEPROC) (GLuint array); +typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint *arrays); +typedef void (APIENTRYP PFNGLGENVERTEXARRAYSAPPLEPROC) (GLsizei n, GLuint *arrays); +typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYAPPLEPROC) (GLuint array); +#endif + +#ifndef GL_APPLE_vertex_array_range +#define GL_APPLE_vertex_array_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexArrayRangeAPPLE (GLsizei length, GLvoid *pointer); +GLAPI void APIENTRY glFlushVertexArrayRangeAPPLE (GLsizei length, GLvoid *pointer); +GLAPI void APIENTRY glVertexArrayParameteriAPPLE (GLenum pname, GLint param); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, GLvoid *pointer); +typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, GLvoid *pointer); +typedef void (APIENTRYP PFNGLVERTEXARRAYPARAMETERIAPPLEPROC) (GLenum pname, GLint param); +#endif + +#ifndef GL_APPLE_ycbcr_422 +#define GL_APPLE_ycbcr_422 1 +#endif + +#ifndef GL_S3_s3tc +#define GL_S3_s3tc 1 +#endif + +#ifndef GL_ATI_draw_buffers +#define GL_ATI_draw_buffers 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawBuffersATI (GLsizei n, const GLenum *bufs); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWBUFFERSATIPROC) (GLsizei n, const GLenum *bufs); +#endif + +#ifndef GL_ATI_pixel_format_float +#define GL_ATI_pixel_format_float 1 +/* This is really a WGL extension, but defines some associated GL enums. + * ATI does not export "GL_ATI_pixel_format_float" in the GL_EXTENSIONS string. + */ +#endif + +#ifndef GL_ATI_texture_env_combine3 +#define GL_ATI_texture_env_combine3 1 +#endif + +#ifndef GL_ATI_texture_float +#define GL_ATI_texture_float 1 +#endif + +#ifndef GL_NV_float_buffer +#define GL_NV_float_buffer 1 +#endif + +#ifndef GL_NV_fragment_program +#define GL_NV_fragment_program 1 +/* Some NV_fragment_program entry points are shared with ARB_vertex_program. */ +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramNamedParameter4fNV (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glProgramNamedParameter4dNV (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramNamedParameter4fvNV (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v); +GLAPI void APIENTRY glProgramNamedParameter4dvNV (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v); +GLAPI void APIENTRY glGetProgramNamedParameterfvNV (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params); +GLAPI void APIENTRY glGetProgramNamedParameterdvNV (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v); +typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params); +#endif + +#ifndef GL_NV_half_float +#define GL_NV_half_float 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertex2hNV (GLhalfNV x, GLhalfNV y); +GLAPI void APIENTRY glVertex2hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glVertex3hNV (GLhalfNV x, GLhalfNV y, GLhalfNV z); +GLAPI void APIENTRY glVertex3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glVertex4hNV (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +GLAPI void APIENTRY glVertex4hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glNormal3hNV (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz); +GLAPI void APIENTRY glNormal3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glColor3hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +GLAPI void APIENTRY glColor3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glColor4hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha); +GLAPI void APIENTRY glColor4hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glTexCoord1hNV (GLhalfNV s); +GLAPI void APIENTRY glTexCoord1hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glTexCoord2hNV (GLhalfNV s, GLhalfNV t); +GLAPI void APIENTRY glTexCoord2hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glTexCoord3hNV (GLhalfNV s, GLhalfNV t, GLhalfNV r); +GLAPI void APIENTRY glTexCoord3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glTexCoord4hNV (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +GLAPI void APIENTRY glTexCoord4hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glMultiTexCoord1hNV (GLenum target, GLhalfNV s); +GLAPI void APIENTRY glMultiTexCoord1hvNV (GLenum target, const GLhalfNV *v); +GLAPI void APIENTRY glMultiTexCoord2hNV (GLenum target, GLhalfNV s, GLhalfNV t); +GLAPI void APIENTRY glMultiTexCoord2hvNV (GLenum target, const GLhalfNV *v); +GLAPI void APIENTRY glMultiTexCoord3hNV (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r); +GLAPI void APIENTRY glMultiTexCoord3hvNV (GLenum target, const GLhalfNV *v); +GLAPI void APIENTRY glMultiTexCoord4hNV (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +GLAPI void APIENTRY glMultiTexCoord4hvNV (GLenum target, const GLhalfNV *v); +GLAPI void APIENTRY glFogCoordhNV (GLhalfNV fog); +GLAPI void APIENTRY glFogCoordhvNV (const GLhalfNV *fog); +GLAPI void APIENTRY glSecondaryColor3hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +GLAPI void APIENTRY glSecondaryColor3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glVertexWeighthNV (GLhalfNV weight); +GLAPI void APIENTRY glVertexWeighthvNV (const GLhalfNV *weight); +GLAPI void APIENTRY glVertexAttrib1hNV (GLuint index, GLhalfNV x); +GLAPI void APIENTRY glVertexAttrib1hvNV (GLuint index, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttrib2hNV (GLuint index, GLhalfNV x, GLhalfNV y); +GLAPI void APIENTRY glVertexAttrib2hvNV (GLuint index, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttrib3hNV (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z); +GLAPI void APIENTRY glVertexAttrib3hvNV (GLuint index, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttrib4hNV (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +GLAPI void APIENTRY glVertexAttrib4hvNV (GLuint index, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttribs1hvNV (GLuint index, GLsizei n, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttribs2hvNV (GLuint index, GLsizei n, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttribs3hvNV (GLuint index, GLsizei n, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttribs4hvNV (GLuint index, GLsizei n, const GLhalfNV *v); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEX2HNVPROC) (GLhalfNV x, GLhalfNV y); +typedef void (APIENTRYP PFNGLVERTEX2HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEX3HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z); +typedef void (APIENTRYP PFNGLVERTEX3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEX4HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +typedef void (APIENTRYP PFNGLVERTEX4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLNORMAL3HNVPROC) (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz); +typedef void (APIENTRYP PFNGLNORMAL3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +typedef void (APIENTRYP PFNGLCOLOR3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLCOLOR4HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha); +typedef void (APIENTRYP PFNGLCOLOR4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD1HNVPROC) (GLhalfNV s); +typedef void (APIENTRYP PFNGLTEXCOORD1HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD2HNVPROC) (GLhalfNV s, GLhalfNV t); +typedef void (APIENTRYP PFNGLTEXCOORD2HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD3HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r); +typedef void (APIENTRYP PFNGLTEXCOORD3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD4HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +typedef void (APIENTRYP PFNGLTEXCOORD4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1HNVPROC) (GLenum target, GLhalfNV s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLFOGCOORDHNVPROC) (GLhalfNV fog); +typedef void (APIENTRYP PFNGLFOGCOORDHVNVPROC) (const GLhalfNV *fog); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTHNVPROC) (GLhalfNV weight); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTHVNVPROC) (const GLhalfNV *weight); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1HNVPROC) (GLuint index, GLhalfNV x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +#endif + +#ifndef GL_NV_pixel_data_range +#define GL_NV_pixel_data_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelDataRangeNV (GLenum target, GLsizei length, GLvoid *pointer); +GLAPI void APIENTRY glFlushPixelDataRangeNV (GLenum target); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPIXELDATARANGENVPROC) (GLenum target, GLsizei length, GLvoid *pointer); +typedef void (APIENTRYP PFNGLFLUSHPIXELDATARANGENVPROC) (GLenum target); +#endif + +#ifndef GL_NV_primitive_restart +#define GL_NV_primitive_restart 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPrimitiveRestartNV (void); +GLAPI void APIENTRY glPrimitiveRestartIndexNV (GLuint index); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPRIMITIVERESTARTNVPROC) (void); +typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXNVPROC) (GLuint index); +#endif + +#ifndef GL_NV_texture_expand_normal +#define GL_NV_texture_expand_normal 1 +#endif + +#ifndef GL_NV_vertex_program2 +#define GL_NV_vertex_program2 1 +#endif + +#ifndef GL_ATI_map_object_buffer +#define GL_ATI_map_object_buffer 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLvoid* APIENTRY glMapObjectBufferATI (GLuint buffer); +GLAPI void APIENTRY glUnmapObjectBufferATI (GLuint buffer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLvoid* (APIENTRYP PFNGLMAPOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLUNMAPOBJECTBUFFERATIPROC) (GLuint buffer); +#endif + +#ifndef GL_ATI_separate_stencil +#define GL_ATI_separate_stencil 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStencilOpSeparateATI (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +GLAPI void APIENTRY glStencilFuncSeparateATI (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEATIPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEATIPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); +#endif + +#ifndef GL_ATI_vertex_attrib_array_object +#define GL_ATI_vertex_attrib_array_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribArrayObjectATI (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); +GLAPI void APIENTRY glGetVertexAttribArrayObjectfvATI (GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVertexAttribArrayObjectivATI (GLuint index, GLenum pname, GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXATTRIBARRAYOBJECTATIPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC) (GLuint index, GLenum pname, GLint *params); +#endif + +#ifndef GL_OES_read_format +#define GL_OES_read_format 1 +#endif + +#ifndef GL_EXT_depth_bounds_test +#define GL_EXT_depth_bounds_test 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDepthBoundsEXT (GLclampd zmin, GLclampd zmax); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDEPTHBOUNDSEXTPROC) (GLclampd zmin, GLclampd zmax); +#endif + +#ifndef GL_EXT_texture_mirror_clamp +#define GL_EXT_texture_mirror_clamp 1 +#endif + +#ifndef GL_EXT_blend_equation_separate +#define GL_EXT_blend_equation_separate 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationSeparateEXT (GLenum modeRGB, GLenum modeAlpha); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEEXTPROC) (GLenum modeRGB, GLenum modeAlpha); +#endif + +#ifndef GL_MESA_pack_invert +#define GL_MESA_pack_invert 1 +#endif + +#ifndef GL_MESA_ycbcr_texture +#define GL_MESA_ycbcr_texture 1 +#endif + +#ifndef GL_EXT_pixel_buffer_object +#define GL_EXT_pixel_buffer_object 1 +#endif + +#ifndef GL_NV_fragment_program_option +#define GL_NV_fragment_program_option 1 +#endif + +#ifndef GL_NV_fragment_program2 +#define GL_NV_fragment_program2 1 +#endif + +#ifndef GL_NV_vertex_program2_option +#define GL_NV_vertex_program2_option 1 +#endif + +#ifndef GL_NV_vertex_program3 +#define GL_NV_vertex_program3 1 +#endif + +#ifndef GL_EXT_framebuffer_object +#define GL_EXT_framebuffer_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glIsRenderbufferEXT (GLuint renderbuffer); +GLAPI void APIENTRY glBindRenderbufferEXT (GLenum target, GLuint renderbuffer); +GLAPI void APIENTRY glDeleteRenderbuffersEXT (GLsizei n, const GLuint *renderbuffers); +GLAPI void APIENTRY glGenRenderbuffersEXT (GLsizei n, GLuint *renderbuffers); +GLAPI void APIENTRY glRenderbufferStorageEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetRenderbufferParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI GLboolean APIENTRY glIsFramebufferEXT (GLuint framebuffer); +GLAPI void APIENTRY glBindFramebufferEXT (GLenum target, GLuint framebuffer); +GLAPI void APIENTRY glDeleteFramebuffersEXT (GLsizei n, const GLuint *framebuffers); +GLAPI void APIENTRY glGenFramebuffersEXT (GLsizei n, GLuint *framebuffers); +GLAPI GLenum APIENTRY glCheckFramebufferStatusEXT (GLenum target); +GLAPI void APIENTRY glFramebufferTexture1DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTexture2DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTexture3DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +GLAPI void APIENTRY glFramebufferRenderbufferEXT (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +GLAPI void APIENTRY glGetFramebufferAttachmentParameterivEXT (GLenum target, GLenum attachment, GLenum pname, GLint *params); +GLAPI void APIENTRY glGenerateMipmapEXT (GLenum target); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFEREXTPROC) (GLuint renderbuffer); +typedef void (APIENTRYP PFNGLBINDRENDERBUFFEREXTPROC) (GLenum target, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSEXTPROC) (GLsizei n, const GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLGENRENDERBUFFERSEXTPROC) (GLsizei n, GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFEREXTPROC) (GLuint framebuffer); +typedef void (APIENTRYP PFNGLBINDFRAMEBUFFEREXTPROC) (GLenum target, GLuint framebuffer); +typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSEXTPROC) (GLsizei n, const GLuint *framebuffers); +typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSEXTPROC) (GLsizei n, GLuint *framebuffers); +typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) (GLenum target); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGENERATEMIPMAPEXTPROC) (GLenum target); +#endif + +#ifndef GL_GREMEDY_string_marker +#define GL_GREMEDY_string_marker 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStringMarkerGREMEDY (GLsizei len, const GLvoid *string); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSTRINGMARKERGREMEDYPROC) (GLsizei len, const GLvoid *string); +#endif + +#ifndef GL_EXT_packed_depth_stencil +#define GL_EXT_packed_depth_stencil 1 +#endif + +#ifndef GL_EXT_stencil_clear_tag +#define GL_EXT_stencil_clear_tag 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStencilClearTagEXT (GLsizei stencilTagBits, GLuint stencilClearTag); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSTENCILCLEARTAGEXTPROC) (GLsizei stencilTagBits, GLuint stencilClearTag); +#endif + +#ifndef GL_EXT_texture_sRGB +#define GL_EXT_texture_sRGB 1 +#endif + +#ifndef GL_EXT_framebuffer_blit +#define GL_EXT_framebuffer_blit 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlitFramebufferEXT (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLITFRAMEBUFFEREXTPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#endif + +#ifndef GL_EXT_framebuffer_multisample +#define GL_EXT_framebuffer_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glRenderbufferStorageMultisampleEXT (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +#endif + +#ifndef GL_MESAX_texture_stack +#define GL_MESAX_texture_stack 1 +#endif + +#ifndef GL_EXT_timer_query +#define GL_EXT_timer_query 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetQueryObjecti64vEXT (GLuint id, GLenum pname, GLint64EXT *params); +GLAPI void APIENTRY glGetQueryObjectui64vEXT (GLuint id, GLenum pname, GLuint64EXT *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VEXTPROC) (GLuint id, GLenum pname, GLint64EXT *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VEXTPROC) (GLuint id, GLenum pname, GLuint64EXT *params); +#endif + +#ifndef GL_EXT_gpu_program_parameters +#define GL_EXT_gpu_program_parameters 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramEnvParameters4fvEXT (GLenum target, GLuint index, GLsizei count, const GLfloat *params); +GLAPI void APIENTRY glProgramLocalParameters4fvEXT (GLenum target, GLuint index, GLsizei count, const GLfloat *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *params); +#endif + +#ifndef GL_APPLE_flush_buffer_range +#define GL_APPLE_flush_buffer_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBufferParameteriAPPLE (GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glFlushMappedBufferRangeAPPLE (GLenum target, GLintptr offset, GLsizeiptr size); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBUFFERPARAMETERIAPPLEPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEAPPLEPROC) (GLenum target, GLintptr offset, GLsizeiptr size); +#endif + +#ifndef GL_NV_gpu_program4 +#define GL_NV_gpu_program4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramLocalParameterI4iNV (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glProgramLocalParameterI4ivNV (GLenum target, GLuint index, const GLint *params); +GLAPI void APIENTRY glProgramLocalParametersI4ivNV (GLenum target, GLuint index, GLsizei count, const GLint *params); +GLAPI void APIENTRY glProgramLocalParameterI4uiNV (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glProgramLocalParameterI4uivNV (GLenum target, GLuint index, const GLuint *params); +GLAPI void APIENTRY glProgramLocalParametersI4uivNV (GLenum target, GLuint index, GLsizei count, const GLuint *params); +GLAPI void APIENTRY glProgramEnvParameterI4iNV (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glProgramEnvParameterI4ivNV (GLenum target, GLuint index, const GLint *params); +GLAPI void APIENTRY glProgramEnvParametersI4ivNV (GLenum target, GLuint index, GLsizei count, const GLint *params); +GLAPI void APIENTRY glProgramEnvParameterI4uiNV (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glProgramEnvParameterI4uivNV (GLenum target, GLuint index, const GLuint *params); +GLAPI void APIENTRY glProgramEnvParametersI4uivNV (GLenum target, GLuint index, GLsizei count, const GLuint *params); +GLAPI void APIENTRY glGetProgramLocalParameterIivNV (GLenum target, GLuint index, GLint *params); +GLAPI void APIENTRY glGetProgramLocalParameterIuivNV (GLenum target, GLuint index, GLuint *params); +GLAPI void APIENTRY glGetProgramEnvParameterIivNV (GLenum target, GLuint index, GLint *params); +GLAPI void APIENTRY glGetProgramEnvParameterIuivNV (GLenum target, GLuint index, GLuint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERIIVNVPROC) (GLenum target, GLuint index, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERIUIVNVPROC) (GLenum target, GLuint index, GLuint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERIIVNVPROC) (GLenum target, GLuint index, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERIUIVNVPROC) (GLenum target, GLuint index, GLuint *params); +#endif + +#ifndef GL_NV_geometry_program4 +#define GL_NV_geometry_program4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramVertexLimitNV (GLenum target, GLint limit); +GLAPI void APIENTRY glFramebufferTextureEXT (GLenum target, GLenum attachment, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTextureLayerEXT (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +GLAPI void APIENTRY glFramebufferTextureFaceEXT (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROGRAMVERTEXLIMITNVPROC) (GLenum target, GLint limit); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREFACEEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +#endif + +#ifndef GL_EXT_geometry_shader4 +#define GL_EXT_geometry_shader4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramParameteriEXT (GLuint program, GLenum pname, GLint value); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIEXTPROC) (GLuint program, GLenum pname, GLint value); +#endif + +#ifndef GL_NV_vertex_program4 +#define GL_NV_vertex_program4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribI1iEXT (GLuint index, GLint x); +GLAPI void APIENTRY glVertexAttribI2iEXT (GLuint index, GLint x, GLint y); +GLAPI void APIENTRY glVertexAttribI3iEXT (GLuint index, GLint x, GLint y, GLint z); +GLAPI void APIENTRY glVertexAttribI4iEXT (GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glVertexAttribI1uiEXT (GLuint index, GLuint x); +GLAPI void APIENTRY glVertexAttribI2uiEXT (GLuint index, GLuint x, GLuint y); +GLAPI void APIENTRY glVertexAttribI3uiEXT (GLuint index, GLuint x, GLuint y, GLuint z); +GLAPI void APIENTRY glVertexAttribI4uiEXT (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glVertexAttribI1ivEXT (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI2ivEXT (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI3ivEXT (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI4ivEXT (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI1uivEXT (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI2uivEXT (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI3uivEXT (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI4uivEXT (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI4bvEXT (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttribI4svEXT (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttribI4ubvEXT (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttribI4usvEXT (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttribIPointerEXT (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glGetVertexAttribIivEXT (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribIuivEXT (GLuint index, GLenum pname, GLuint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IEXTPROC) (GLuint index, GLint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IEXTPROC) (GLuint index, GLint x, GLint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IEXTPROC) (GLuint index, GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IEXTPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIEXTPROC) (GLuint index, GLuint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIEXTPROC) (GLuint index, GLuint x, GLuint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVEXTPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVEXTPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVEXTPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVEXTPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVEXTPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVEXTPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVEXTPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVEXTPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVEXTPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVEXTPROC) (GLuint index, GLenum pname, GLuint *params); +#endif + +#ifndef GL_EXT_gpu_shader4 +#define GL_EXT_gpu_shader4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetUniformuivEXT (GLuint program, GLint location, GLuint *params); +GLAPI void APIENTRY glBindFragDataLocationEXT (GLuint program, GLuint color, const GLchar *name); +GLAPI GLint APIENTRY glGetFragDataLocationEXT (GLuint program, const GLchar *name); +GLAPI void APIENTRY glUniform1uiEXT (GLint location, GLuint v0); +GLAPI void APIENTRY glUniform2uiEXT (GLint location, GLuint v0, GLuint v1); +GLAPI void APIENTRY glUniform3uiEXT (GLint location, GLuint v0, GLuint v1, GLuint v2); +GLAPI void APIENTRY glUniform4uiEXT (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GLAPI void APIENTRY glUniform1uivEXT (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform2uivEXT (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform3uivEXT (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform4uivEXT (GLint location, GLsizei count, const GLuint *value); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETUNIFORMUIVEXTPROC) (GLuint program, GLint location, GLuint *params); +typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONEXTPROC) (GLuint program, GLuint color, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONEXTPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLUNIFORM1UIEXTPROC) (GLint location, GLuint v0); +typedef void (APIENTRYP PFNGLUNIFORM2UIEXTPROC) (GLint location, GLuint v0, GLuint v1); +typedef void (APIENTRYP PFNGLUNIFORM3UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (APIENTRYP PFNGLUNIFORM4UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (APIENTRYP PFNGLUNIFORM1UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM2UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM3UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM4UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +#endif + +#ifndef GL_EXT_draw_instanced +#define GL_EXT_draw_instanced 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawArraysInstancedEXT (GLenum mode, GLint start, GLsizei count, GLsizei primcount); +GLAPI void APIENTRY glDrawElementsInstancedEXT (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDEXTPROC) (GLenum mode, GLint start, GLsizei count, GLsizei primcount); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDEXTPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); +#endif + +#ifndef GL_EXT_packed_float +#define GL_EXT_packed_float 1 +#endif + +#ifndef GL_EXT_texture_array +#define GL_EXT_texture_array 1 +#endif + +#ifndef GL_EXT_texture_buffer_object +#define GL_EXT_texture_buffer_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexBufferEXT (GLenum target, GLenum internalformat, GLuint buffer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXBUFFEREXTPROC) (GLenum target, GLenum internalformat, GLuint buffer); +#endif + +#ifndef GL_EXT_texture_compression_latc +#define GL_EXT_texture_compression_latc 1 +#endif + +#ifndef GL_EXT_texture_compression_rgtc +#define GL_EXT_texture_compression_rgtc 1 +#endif + +#ifndef GL_EXT_texture_shared_exponent +#define GL_EXT_texture_shared_exponent 1 +#endif + +#ifndef GL_NV_depth_buffer_float +#define GL_NV_depth_buffer_float 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDepthRangedNV (GLdouble zNear, GLdouble zFar); +GLAPI void APIENTRY glClearDepthdNV (GLdouble depth); +GLAPI void APIENTRY glDepthBoundsdNV (GLdouble zmin, GLdouble zmax); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDEPTHRANGEDNVPROC) (GLdouble zNear, GLdouble zFar); +typedef void (APIENTRYP PFNGLCLEARDEPTHDNVPROC) (GLdouble depth); +typedef void (APIENTRYP PFNGLDEPTHBOUNDSDNVPROC) (GLdouble zmin, GLdouble zmax); +#endif + +#ifndef GL_NV_fragment_program4 +#define GL_NV_fragment_program4 1 +#endif + +#ifndef GL_NV_framebuffer_multisample_coverage +#define GL_NV_framebuffer_multisample_coverage 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glRenderbufferStorageMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); +#endif + +#ifndef GL_EXT_framebuffer_sRGB +#define GL_EXT_framebuffer_sRGB 1 +#endif + +#ifndef GL_NV_geometry_shader4 +#define GL_NV_geometry_shader4 1 +#endif + +#ifndef GL_NV_parameter_buffer_object +#define GL_NV_parameter_buffer_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramBufferParametersfvNV (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLfloat *params); +GLAPI void APIENTRY glProgramBufferParametersIivNV (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLint *params); +GLAPI void APIENTRY glProgramBufferParametersIuivNV (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLuint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSFVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLfloat *params); +typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSIIVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSIUIVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLuint *params); +#endif + +#ifndef GL_EXT_draw_buffers2 +#define GL_EXT_draw_buffers2 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorMaskIndexedEXT (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +GLAPI void APIENTRY glGetBooleanIndexedvEXT (GLenum target, GLuint index, GLboolean *data); +GLAPI void APIENTRY glGetIntegerIndexedvEXT (GLenum target, GLuint index, GLint *data); +GLAPI void APIENTRY glEnableIndexedEXT (GLenum target, GLuint index); +GLAPI void APIENTRY glDisableIndexedEXT (GLenum target, GLuint index); +GLAPI GLboolean APIENTRY glIsEnabledIndexedEXT (GLenum target, GLuint index); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORMASKINDEXEDEXTPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +typedef void (APIENTRYP PFNGLGETBOOLEANINDEXEDVEXTPROC) (GLenum target, GLuint index, GLboolean *data); +typedef void (APIENTRYP PFNGLGETINTEGERINDEXEDVEXTPROC) (GLenum target, GLuint index, GLint *data); +typedef void (APIENTRYP PFNGLENABLEINDEXEDEXTPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLDISABLEINDEXEDEXTPROC) (GLenum target, GLuint index); +typedef GLboolean (APIENTRYP PFNGLISENABLEDINDEXEDEXTPROC) (GLenum target, GLuint index); +#endif + +#ifndef GL_NV_transform_feedback +#define GL_NV_transform_feedback 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginTransformFeedbackNV (GLenum primitiveMode); +GLAPI void APIENTRY glEndTransformFeedbackNV (void); +GLAPI void APIENTRY glTransformFeedbackAttribsNV (GLuint count, const GLint *attribs, GLenum bufferMode); +GLAPI void APIENTRY glBindBufferRangeNV (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glBindBufferOffsetNV (GLenum target, GLuint index, GLuint buffer, GLintptr offset); +GLAPI void APIENTRY glBindBufferBaseNV (GLenum target, GLuint index, GLuint buffer); +GLAPI void APIENTRY glTransformFeedbackVaryingsNV (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode); +GLAPI void APIENTRY glActiveVaryingNV (GLuint program, const GLchar *name); +GLAPI GLint APIENTRY glGetVaryingLocationNV (GLuint program, const GLchar *name); +GLAPI void APIENTRY glGetActiveVaryingNV (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +GLAPI void APIENTRY glGetTransformFeedbackVaryingNV (GLuint program, GLuint index, GLint *location); +GLAPI void APIENTRY glTransformFeedbackStreamAttribsNV (GLsizei count, const GLint *attribs, GLsizei nbuffers, const GLint *bufstreams, GLenum bufferMode); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKNVPROC) (GLenum primitiveMode); +typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKNVPROC) (void); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKATTRIBSNVPROC) (GLuint count, const GLint *attribs, GLenum bufferMode); +typedef void (APIENTRYP PFNGLBINDBUFFERRANGENVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLBINDBUFFEROFFSETNVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset); +typedef void (APIENTRYP PFNGLBINDBUFFERBASENVPROC) (GLenum target, GLuint index, GLuint buffer); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSNVPROC) (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode); +typedef void (APIENTRYP PFNGLACTIVEVARYINGNVPROC) (GLuint program, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETVARYINGLOCATIONNVPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVEVARYINGNVPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGNVPROC) (GLuint program, GLuint index, GLint *location); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKSTREAMATTRIBSNVPROC) (GLsizei count, const GLint *attribs, GLsizei nbuffers, const GLint *bufstreams, GLenum bufferMode); +#endif + +#ifndef GL_EXT_bindable_uniform +#define GL_EXT_bindable_uniform 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUniformBufferEXT (GLuint program, GLint location, GLuint buffer); +GLAPI GLint APIENTRY glGetUniformBufferSizeEXT (GLuint program, GLint location); +GLAPI GLintptr APIENTRY glGetUniformOffsetEXT (GLuint program, GLint location); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLUNIFORMBUFFEREXTPROC) (GLuint program, GLint location, GLuint buffer); +typedef GLint (APIENTRYP PFNGLGETUNIFORMBUFFERSIZEEXTPROC) (GLuint program, GLint location); +typedef GLintptr (APIENTRYP PFNGLGETUNIFORMOFFSETEXTPROC) (GLuint program, GLint location); +#endif + +#ifndef GL_EXT_texture_integer +#define GL_EXT_texture_integer 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexParameterIivEXT (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTexParameterIuivEXT (GLenum target, GLenum pname, const GLuint *params); +GLAPI void APIENTRY glGetTexParameterIivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTexParameterIuivEXT (GLenum target, GLenum pname, GLuint *params); +GLAPI void APIENTRY glClearColorIiEXT (GLint red, GLint green, GLint blue, GLint alpha); +GLAPI void APIENTRY glClearColorIuiEXT (GLuint red, GLuint green, GLuint blue, GLuint alpha); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLCLEARCOLORIIEXTPROC) (GLint red, GLint green, GLint blue, GLint alpha); +typedef void (APIENTRYP PFNGLCLEARCOLORIUIEXTPROC) (GLuint red, GLuint green, GLuint blue, GLuint alpha); +#endif + +#ifndef GL_GREMEDY_frame_terminator +#define GL_GREMEDY_frame_terminator 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFrameTerminatorGREMEDY (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFRAMETERMINATORGREMEDYPROC) (void); +#endif + +#ifndef GL_NV_conditional_render +#define GL_NV_conditional_render 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginConditionalRenderNV (GLuint id, GLenum mode); +GLAPI void APIENTRY glEndConditionalRenderNV (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERNVPROC) (GLuint id, GLenum mode); +typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERNVPROC) (void); +#endif + +#ifndef GL_NV_present_video +#define GL_NV_present_video 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPresentFrameKeyedNV (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLuint key0, GLenum target1, GLuint fill1, GLuint key1); +GLAPI void APIENTRY glPresentFrameDualFillNV (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLenum target1, GLuint fill1, GLenum target2, GLuint fill2, GLenum target3, GLuint fill3); +GLAPI void APIENTRY glGetVideoivNV (GLuint video_slot, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVideouivNV (GLuint video_slot, GLenum pname, GLuint *params); +GLAPI void APIENTRY glGetVideoi64vNV (GLuint video_slot, GLenum pname, GLint64EXT *params); +GLAPI void APIENTRY glGetVideoui64vNV (GLuint video_slot, GLenum pname, GLuint64EXT *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPRESENTFRAMEKEYEDNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLuint key0, GLenum target1, GLuint fill1, GLuint key1); +typedef void (APIENTRYP PFNGLPRESENTFRAMEDUALFILLNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLenum target1, GLuint fill1, GLenum target2, GLuint fill2, GLenum target3, GLuint fill3); +typedef void (APIENTRYP PFNGLGETVIDEOIVNVPROC) (GLuint video_slot, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVIDEOUIVNVPROC) (GLuint video_slot, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLGETVIDEOI64VNVPROC) (GLuint video_slot, GLenum pname, GLint64EXT *params); +typedef void (APIENTRYP PFNGLGETVIDEOUI64VNVPROC) (GLuint video_slot, GLenum pname, GLuint64EXT *params); +#endif + +#ifndef GL_EXT_transform_feedback +#define GL_EXT_transform_feedback 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginTransformFeedbackEXT (GLenum primitiveMode); +GLAPI void APIENTRY glEndTransformFeedbackEXT (void); +GLAPI void APIENTRY glBindBufferRangeEXT (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glBindBufferOffsetEXT (GLenum target, GLuint index, GLuint buffer, GLintptr offset); +GLAPI void APIENTRY glBindBufferBaseEXT (GLenum target, GLuint index, GLuint buffer); +GLAPI void APIENTRY glTransformFeedbackVaryingsEXT (GLuint program, GLsizei count, const GLchar* *varyings, GLenum bufferMode); +GLAPI void APIENTRY glGetTransformFeedbackVaryingEXT (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKEXTPROC) (GLenum primitiveMode); +typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKEXTPROC) (void); +typedef void (APIENTRYP PFNGLBINDBUFFERRANGEEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLBINDBUFFEROFFSETEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset); +typedef void (APIENTRYP PFNGLBINDBUFFERBASEEXTPROC) (GLenum target, GLuint index, GLuint buffer); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSEXTPROC) (GLuint program, GLsizei count, const GLchar* *varyings, GLenum bufferMode); +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGEXTPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +#endif + +#ifndef GL_EXT_direct_state_access +#define GL_EXT_direct_state_access 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glClientAttribDefaultEXT (GLbitfield mask); +GLAPI void APIENTRY glPushClientAttribDefaultEXT (GLbitfield mask); +GLAPI void APIENTRY glMatrixLoadfEXT (GLenum mode, const GLfloat *m); +GLAPI void APIENTRY glMatrixLoaddEXT (GLenum mode, const GLdouble *m); +GLAPI void APIENTRY glMatrixMultfEXT (GLenum mode, const GLfloat *m); +GLAPI void APIENTRY glMatrixMultdEXT (GLenum mode, const GLdouble *m); +GLAPI void APIENTRY glMatrixLoadIdentityEXT (GLenum mode); +GLAPI void APIENTRY glMatrixRotatefEXT (GLenum mode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glMatrixRotatedEXT (GLenum mode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glMatrixScalefEXT (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glMatrixScaledEXT (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glMatrixTranslatefEXT (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glMatrixTranslatedEXT (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glMatrixFrustumEXT (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +GLAPI void APIENTRY glMatrixOrthoEXT (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +GLAPI void APIENTRY glMatrixPopEXT (GLenum mode); +GLAPI void APIENTRY glMatrixPushEXT (GLenum mode); +GLAPI void APIENTRY glMatrixLoadTransposefEXT (GLenum mode, const GLfloat *m); +GLAPI void APIENTRY glMatrixLoadTransposedEXT (GLenum mode, const GLdouble *m); +GLAPI void APIENTRY glMatrixMultTransposefEXT (GLenum mode, const GLfloat *m); +GLAPI void APIENTRY glMatrixMultTransposedEXT (GLenum mode, const GLdouble *m); +GLAPI void APIENTRY glTextureParameterfEXT (GLuint texture, GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glTextureParameterfvEXT (GLuint texture, GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glTextureParameteriEXT (GLuint texture, GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glTextureParameterivEXT (GLuint texture, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glCopyTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +GLAPI void APIENTRY glCopyTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +GLAPI void APIENTRY glCopyTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetTextureImageEXT (GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels); +GLAPI void APIENTRY glGetTextureParameterfvEXT (GLuint texture, GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetTextureParameterivEXT (GLuint texture, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTextureLevelParameterfvEXT (GLuint texture, GLenum target, GLint level, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetTextureLevelParameterivEXT (GLuint texture, GLenum target, GLint level, GLenum pname, GLint *params); +GLAPI void APIENTRY glTextureImage3DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glCopyTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glMultiTexParameterfEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glMultiTexParameterfvEXT (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glMultiTexParameteriEXT (GLenum texunit, GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glMultiTexParameterivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glCopyMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +GLAPI void APIENTRY glCopyMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +GLAPI void APIENTRY glCopyMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetMultiTexImageEXT (GLenum texunit, GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels); +GLAPI void APIENTRY glGetMultiTexParameterfvEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMultiTexParameterivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMultiTexLevelParameterfvEXT (GLenum texunit, GLenum target, GLint level, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMultiTexLevelParameterivEXT (GLenum texunit, GLenum target, GLint level, GLenum pname, GLint *params); +GLAPI void APIENTRY glMultiTexImage3DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glCopyMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glBindMultiTextureEXT (GLenum texunit, GLenum target, GLuint texture); +GLAPI void APIENTRY glEnableClientStateIndexedEXT (GLenum array, GLuint index); +GLAPI void APIENTRY glDisableClientStateIndexedEXT (GLenum array, GLuint index); +GLAPI void APIENTRY glMultiTexCoordPointerEXT (GLenum texunit, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glMultiTexEnvfEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glMultiTexEnvfvEXT (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glMultiTexEnviEXT (GLenum texunit, GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glMultiTexEnvivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glMultiTexGendEXT (GLenum texunit, GLenum coord, GLenum pname, GLdouble param); +GLAPI void APIENTRY glMultiTexGendvEXT (GLenum texunit, GLenum coord, GLenum pname, const GLdouble *params); +GLAPI void APIENTRY glMultiTexGenfEXT (GLenum texunit, GLenum coord, GLenum pname, GLfloat param); +GLAPI void APIENTRY glMultiTexGenfvEXT (GLenum texunit, GLenum coord, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glMultiTexGeniEXT (GLenum texunit, GLenum coord, GLenum pname, GLint param); +GLAPI void APIENTRY glMultiTexGenivEXT (GLenum texunit, GLenum coord, GLenum pname, const GLint *params); +GLAPI void APIENTRY glGetMultiTexEnvfvEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMultiTexEnvivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMultiTexGendvEXT (GLenum texunit, GLenum coord, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetMultiTexGenfvEXT (GLenum texunit, GLenum coord, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMultiTexGenivEXT (GLenum texunit, GLenum coord, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetFloatIndexedvEXT (GLenum target, GLuint index, GLfloat *data); +GLAPI void APIENTRY glGetDoubleIndexedvEXT (GLenum target, GLuint index, GLdouble *data); +GLAPI void APIENTRY glGetPointerIndexedvEXT (GLenum target, GLuint index, GLvoid* *data); +GLAPI void APIENTRY glCompressedTextureImage3DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glGetCompressedTextureImageEXT (GLuint texture, GLenum target, GLint lod, GLvoid *img); +GLAPI void APIENTRY glCompressedMultiTexImage3DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glGetCompressedMultiTexImageEXT (GLenum texunit, GLenum target, GLint lod, GLvoid *img); +GLAPI void APIENTRY glNamedProgramStringEXT (GLuint program, GLenum target, GLenum format, GLsizei len, const GLvoid *string); +GLAPI void APIENTRY glNamedProgramLocalParameter4dEXT (GLuint program, GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glNamedProgramLocalParameter4dvEXT (GLuint program, GLenum target, GLuint index, const GLdouble *params); +GLAPI void APIENTRY glNamedProgramLocalParameter4fEXT (GLuint program, GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glNamedProgramLocalParameter4fvEXT (GLuint program, GLenum target, GLuint index, const GLfloat *params); +GLAPI void APIENTRY glGetNamedProgramLocalParameterdvEXT (GLuint program, GLenum target, GLuint index, GLdouble *params); +GLAPI void APIENTRY glGetNamedProgramLocalParameterfvEXT (GLuint program, GLenum target, GLuint index, GLfloat *params); +GLAPI void APIENTRY glGetNamedProgramivEXT (GLuint program, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetNamedProgramStringEXT (GLuint program, GLenum target, GLenum pname, GLvoid *string); +GLAPI void APIENTRY glNamedProgramLocalParameters4fvEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLfloat *params); +GLAPI void APIENTRY glNamedProgramLocalParameterI4iEXT (GLuint program, GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glNamedProgramLocalParameterI4ivEXT (GLuint program, GLenum target, GLuint index, const GLint *params); +GLAPI void APIENTRY glNamedProgramLocalParametersI4ivEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLint *params); +GLAPI void APIENTRY glNamedProgramLocalParameterI4uiEXT (GLuint program, GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glNamedProgramLocalParameterI4uivEXT (GLuint program, GLenum target, GLuint index, const GLuint *params); +GLAPI void APIENTRY glNamedProgramLocalParametersI4uivEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLuint *params); +GLAPI void APIENTRY glGetNamedProgramLocalParameterIivEXT (GLuint program, GLenum target, GLuint index, GLint *params); +GLAPI void APIENTRY glGetNamedProgramLocalParameterIuivEXT (GLuint program, GLenum target, GLuint index, GLuint *params); +GLAPI void APIENTRY glTextureParameterIivEXT (GLuint texture, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTextureParameterIuivEXT (GLuint texture, GLenum target, GLenum pname, const GLuint *params); +GLAPI void APIENTRY glGetTextureParameterIivEXT (GLuint texture, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTextureParameterIuivEXT (GLuint texture, GLenum target, GLenum pname, GLuint *params); +GLAPI void APIENTRY glMultiTexParameterIivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glMultiTexParameterIuivEXT (GLenum texunit, GLenum target, GLenum pname, const GLuint *params); +GLAPI void APIENTRY glGetMultiTexParameterIivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMultiTexParameterIuivEXT (GLenum texunit, GLenum target, GLenum pname, GLuint *params); +GLAPI void APIENTRY glProgramUniform1fEXT (GLuint program, GLint location, GLfloat v0); +GLAPI void APIENTRY glProgramUniform2fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1); +GLAPI void APIENTRY glProgramUniform3fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GLAPI void APIENTRY glProgramUniform4fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GLAPI void APIENTRY glProgramUniform1iEXT (GLuint program, GLint location, GLint v0); +GLAPI void APIENTRY glProgramUniform2iEXT (GLuint program, GLint location, GLint v0, GLint v1); +GLAPI void APIENTRY glProgramUniform3iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +GLAPI void APIENTRY glProgramUniform4iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GLAPI void APIENTRY glProgramUniform1fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform2fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform3fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform4fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform1ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform2ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform3ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform4ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniformMatrix2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform1uiEXT (GLuint program, GLint location, GLuint v0); +GLAPI void APIENTRY glProgramUniform2uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1); +GLAPI void APIENTRY glProgramUniform3uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +GLAPI void APIENTRY glProgramUniform4uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GLAPI void APIENTRY glProgramUniform1uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform2uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform3uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform4uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glNamedBufferDataEXT (GLuint buffer, GLsizeiptr size, const GLvoid *data, GLenum usage); +GLAPI void APIENTRY glNamedBufferSubDataEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, const GLvoid *data); +GLAPI GLvoid* APIENTRY glMapNamedBufferEXT (GLuint buffer, GLenum access); +GLAPI GLboolean APIENTRY glUnmapNamedBufferEXT (GLuint buffer); +GLAPI GLvoid* APIENTRY glMapNamedBufferRangeEXT (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); +GLAPI void APIENTRY glFlushMappedNamedBufferRangeEXT (GLuint buffer, GLintptr offset, GLsizeiptr length); +GLAPI void APIENTRY glNamedCopyBufferSubDataEXT (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +GLAPI void APIENTRY glGetNamedBufferParameterivEXT (GLuint buffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetNamedBufferPointervEXT (GLuint buffer, GLenum pname, GLvoid* *params); +GLAPI void APIENTRY glGetNamedBufferSubDataEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, GLvoid *data); +GLAPI void APIENTRY glTextureBufferEXT (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer); +GLAPI void APIENTRY glMultiTexBufferEXT (GLenum texunit, GLenum target, GLenum internalformat, GLuint buffer); +GLAPI void APIENTRY glNamedRenderbufferStorageEXT (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetNamedRenderbufferParameterivEXT (GLuint renderbuffer, GLenum pname, GLint *params); +GLAPI GLenum APIENTRY glCheckNamedFramebufferStatusEXT (GLuint framebuffer, GLenum target); +GLAPI void APIENTRY glNamedFramebufferTexture1DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glNamedFramebufferTexture2DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glNamedFramebufferTexture3DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +GLAPI void APIENTRY glNamedFramebufferRenderbufferEXT (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +GLAPI void APIENTRY glGetNamedFramebufferAttachmentParameterivEXT (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params); +GLAPI void APIENTRY glGenerateTextureMipmapEXT (GLuint texture, GLenum target); +GLAPI void APIENTRY glGenerateMultiTexMipmapEXT (GLenum texunit, GLenum target); +GLAPI void APIENTRY glFramebufferDrawBufferEXT (GLuint framebuffer, GLenum mode); +GLAPI void APIENTRY glFramebufferDrawBuffersEXT (GLuint framebuffer, GLsizei n, const GLenum *bufs); +GLAPI void APIENTRY glFramebufferReadBufferEXT (GLuint framebuffer, GLenum mode); +GLAPI void APIENTRY glGetFramebufferParameterivEXT (GLuint framebuffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleEXT (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleCoverageEXT (GLuint renderbuffer, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glNamedFramebufferTextureEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); +GLAPI void APIENTRY glNamedFramebufferTextureLayerEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); +GLAPI void APIENTRY glNamedFramebufferTextureFaceEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLenum face); +GLAPI void APIENTRY glTextureRenderbufferEXT (GLuint texture, GLenum target, GLuint renderbuffer); +GLAPI void APIENTRY glMultiTexRenderbufferEXT (GLenum texunit, GLenum target, GLuint renderbuffer); +GLAPI void APIENTRY glProgramUniform1dEXT (GLuint program, GLint location, GLdouble x); +GLAPI void APIENTRY glProgramUniform2dEXT (GLuint program, GLint location, GLdouble x, GLdouble y); +GLAPI void APIENTRY glProgramUniform3dEXT (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glProgramUniform4dEXT (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramUniform1dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform2dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform3dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform4dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2x3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2x4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3x2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3x4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4x2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4x3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask); +typedef void (APIENTRYP PFNGLPUSHCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask); +typedef void (APIENTRYP PFNGLMATRIXLOADFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXLOADDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (APIENTRYP PFNGLMATRIXMULTFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXMULTDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (APIENTRYP PFNGLMATRIXLOADIDENTITYEXTPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLMATRIXROTATEFEXTPROC) (GLenum mode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLMATRIXROTATEDEXTPROC) (GLenum mode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLMATRIXSCALEFEXTPROC) (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLMATRIXSCALEDEXTPROC) (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLMATRIXTRANSLATEFEXTPROC) (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLMATRIXTRANSLATEDEXTPROC) (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLMATRIXFRUSTUMEXTPROC) (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +typedef void (APIENTRYP PFNGLMATRIXORTHOEXTPROC) (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +typedef void (APIENTRYP PFNGLMATRIXPOPEXTPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLMATRIXPUSHEXTPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLCOPYTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLCOPYMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +typedef void (APIENTRYP PFNGLCOPYMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels); +typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXLEVELPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMULTITEXLEVELPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLBINDMULTITEXTUREEXTPROC) (GLenum texunit, GLenum target, GLuint texture); +typedef void (APIENTRYP PFNGLENABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index); +typedef void (APIENTRYP PFNGLDISABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index); +typedef void (APIENTRYP PFNGLMULTITEXCOORDPOINTEREXTPROC) (GLenum texunit, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLMULTITEXENVFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLMULTITEXENVIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXGENDEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLdouble param); +typedef void (APIENTRYP PFNGLMULTITEXGENDVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLdouble *params); +typedef void (APIENTRYP PFNGLMULTITEXGENFEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLMULTITEXGENFVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLMULTITEXGENIEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLMULTITEXGENIVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXGENDVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETMULTITEXGENFVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMULTITEXGENIVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETFLOATINDEXEDVEXTPROC) (GLenum target, GLuint index, GLfloat *data); +typedef void (APIENTRYP PFNGLGETDOUBLEINDEXEDVEXTPROC) (GLenum target, GLuint index, GLdouble *data); +typedef void (APIENTRYP PFNGLGETPOINTERINDEXEDVEXTPROC) (GLenum target, GLuint index, GLvoid* *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint lod, GLvoid *img); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint lod, GLvoid *img); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum format, GLsizei len, const GLvoid *string); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4DEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4DVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLdouble *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4FEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4FVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERDVEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERFVEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMIVEXTPROC) (GLuint program, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum pname, GLvoid *string); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLfloat *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4IEXTPROC) (GLuint program, GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLint *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERSI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLint *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLuint *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERSI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLuint *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERIIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLint *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERIUIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint *params); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FEXTPROC) (GLuint program, GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IEXTPROC) (GLuint program, GLint location, GLint v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIEXTPROC) (GLuint program, GLint location, GLuint v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLNAMEDBUFFERDATAEXTPROC) (GLuint buffer, GLsizeiptr size, const GLvoid *data, GLenum usage); +typedef void (APIENTRYP PFNGLNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, const GLvoid *data); +typedef GLvoid* (APIENTRYP PFNGLMAPNAMEDBUFFEREXTPROC) (GLuint buffer, GLenum access); +typedef GLboolean (APIENTRYP PFNGLUNMAPNAMEDBUFFEREXTPROC) (GLuint buffer); +typedef GLvoid* (APIENTRYP PFNGLMAPNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); +typedef void (APIENTRYP PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length); +typedef void (APIENTRYP PFNGLNAMEDCOPYBUFFERSUBDATAEXTPROC) (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERIVEXTPROC) (GLuint buffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPOINTERVEXTPROC) (GLuint buffer, GLenum pname, GLvoid* *params); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, GLvoid *data); +typedef void (APIENTRYP PFNGLTEXTUREBUFFEREXTPROC) (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer); +typedef void (APIENTRYP PFNGLMULTITEXBUFFEREXTPROC) (GLenum texunit, GLenum target, GLenum internalformat, GLuint buffer); +typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEEXTPROC) (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETNAMEDRENDERBUFFERPARAMETERIVEXTPROC) (GLuint renderbuffer, GLenum pname, GLint *params); +typedef GLenum (APIENTRYP PFNGLCHECKNAMEDFRAMEBUFFERSTATUSEXTPROC) (GLuint framebuffer, GLenum target); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE1DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE2DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE3DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERRENDERBUFFEREXTPROC) (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGENERATETEXTUREMIPMAPEXTPROC) (GLuint texture, GLenum target); +typedef void (APIENTRYP PFNGLGENERATEMULTITEXMIPMAPEXTPROC) (GLenum texunit, GLenum target); +typedef void (APIENTRYP PFNGLFRAMEBUFFERDRAWBUFFEREXTPROC) (GLuint framebuffer, GLenum mode); +typedef void (APIENTRYP PFNGLFRAMEBUFFERDRAWBUFFERSEXTPROC) (GLuint framebuffer, GLsizei n, const GLenum *bufs); +typedef void (APIENTRYP PFNGLFRAMEBUFFERREADBUFFEREXTPROC) (GLuint framebuffer, GLenum mode); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLECOVERAGEEXTPROC) (GLuint renderbuffer, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURELAYEREXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREFACEEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLenum face); +typedef void (APIENTRYP PFNGLTEXTURERENDERBUFFEREXTPROC) (GLuint texture, GLenum target, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLMULTITEXRENDERBUFFEREXTPROC) (GLenum texunit, GLenum target, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DEXTPROC) (GLuint program, GLint location, GLdouble x); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +#endif + +#ifndef GL_EXT_vertex_array_bgra +#define GL_EXT_vertex_array_bgra 1 +#endif + +#ifndef GL_EXT_texture_swizzle +#define GL_EXT_texture_swizzle 1 +#endif + +#ifndef GL_NV_explicit_multisample +#define GL_NV_explicit_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetMultisamplefvNV (GLenum pname, GLuint index, GLfloat *val); +GLAPI void APIENTRY glSampleMaskIndexedNV (GLuint index, GLbitfield mask); +GLAPI void APIENTRY glTexRenderbufferNV (GLenum target, GLuint renderbuffer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETMULTISAMPLEFVNVPROC) (GLenum pname, GLuint index, GLfloat *val); +typedef void (APIENTRYP PFNGLSAMPLEMASKINDEXEDNVPROC) (GLuint index, GLbitfield mask); +typedef void (APIENTRYP PFNGLTEXRENDERBUFFERNVPROC) (GLenum target, GLuint renderbuffer); +#endif + +#ifndef GL_NV_transform_feedback2 +#define GL_NV_transform_feedback2 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindTransformFeedbackNV (GLenum target, GLuint id); +GLAPI void APIENTRY glDeleteTransformFeedbacksNV (GLsizei n, const GLuint *ids); +GLAPI void APIENTRY glGenTransformFeedbacksNV (GLsizei n, GLuint *ids); +GLAPI GLboolean APIENTRY glIsTransformFeedbackNV (GLuint id); +GLAPI void APIENTRY glPauseTransformFeedbackNV (void); +GLAPI void APIENTRY glResumeTransformFeedbackNV (void); +GLAPI void APIENTRY glDrawTransformFeedbackNV (GLenum mode, GLuint id); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDTRANSFORMFEEDBACKNVPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSNVPROC) (GLsizei n, const GLuint *ids); +typedef void (APIENTRYP PFNGLGENTRANSFORMFEEDBACKSNVPROC) (GLsizei n, GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISTRANSFORMFEEDBACKNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKNVPROC) (void); +typedef void (APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKNVPROC) (void); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKNVPROC) (GLenum mode, GLuint id); +#endif + +#ifndef GL_ATI_meminfo +#define GL_ATI_meminfo 1 +#endif + +#ifndef GL_AMD_performance_monitor +#define GL_AMD_performance_monitor 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetPerfMonitorGroupsAMD (GLint *numGroups, GLsizei groupsSize, GLuint *groups); +GLAPI void APIENTRY glGetPerfMonitorCountersAMD (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); +GLAPI void APIENTRY glGetPerfMonitorGroupStringAMD (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString); +GLAPI void APIENTRY glGetPerfMonitorCounterStringAMD (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString); +GLAPI void APIENTRY glGetPerfMonitorCounterInfoAMD (GLuint group, GLuint counter, GLenum pname, GLvoid *data); +GLAPI void APIENTRY glGenPerfMonitorsAMD (GLsizei n, GLuint *monitors); +GLAPI void APIENTRY glDeletePerfMonitorsAMD (GLsizei n, GLuint *monitors); +GLAPI void APIENTRY glSelectPerfMonitorCountersAMD (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList); +GLAPI void APIENTRY glBeginPerfMonitorAMD (GLuint monitor); +GLAPI void APIENTRY glEndPerfMonitorAMD (GLuint monitor); +GLAPI void APIENTRY glGetPerfMonitorCounterDataAMD (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETPERFMONITORGROUPSAMDPROC) (GLint *numGroups, GLsizei groupsSize, GLuint *groups); +typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERSAMDPROC) (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); +typedef void (APIENTRYP PFNGLGETPERFMONITORGROUPSTRINGAMDPROC) (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString); +typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC) (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString); +typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERINFOAMDPROC) (GLuint group, GLuint counter, GLenum pname, GLvoid *data); +typedef void (APIENTRYP PFNGLGENPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); +typedef void (APIENTRYP PFNGLDELETEPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); +typedef void (APIENTRYP PFNGLSELECTPERFMONITORCOUNTERSAMDPROC) (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList); +typedef void (APIENTRYP PFNGLBEGINPERFMONITORAMDPROC) (GLuint monitor); +typedef void (APIENTRYP PFNGLENDPERFMONITORAMDPROC) (GLuint monitor); +typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERDATAAMDPROC) (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); +#endif + +#ifndef GL_AMD_texture_texture4 +#define GL_AMD_texture_texture4 1 +#endif + +#ifndef GL_AMD_vertex_shader_tesselator +#define GL_AMD_vertex_shader_tesselator 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTessellationFactorAMD (GLfloat factor); +GLAPI void APIENTRY glTessellationModeAMD (GLenum mode); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTESSELLATIONFACTORAMDPROC) (GLfloat factor); +typedef void (APIENTRYP PFNGLTESSELLATIONMODEAMDPROC) (GLenum mode); +#endif + +#ifndef GL_EXT_provoking_vertex +#define GL_EXT_provoking_vertex 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProvokingVertexEXT (GLenum mode); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROVOKINGVERTEXEXTPROC) (GLenum mode); +#endif + +#ifndef GL_EXT_texture_snorm +#define GL_EXT_texture_snorm 1 +#endif + +#ifndef GL_AMD_draw_buffers_blend +#define GL_AMD_draw_buffers_blend 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncIndexedAMD (GLuint buf, GLenum src, GLenum dst); +GLAPI void APIENTRY glBlendFuncSeparateIndexedAMD (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +GLAPI void APIENTRY glBlendEquationIndexedAMD (GLuint buf, GLenum mode); +GLAPI void APIENTRY glBlendEquationSeparateIndexedAMD (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDFUNCINDEXEDAMDPROC) (GLuint buf, GLenum src, GLenum dst); +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +typedef void (APIENTRYP PFNGLBLENDEQUATIONINDEXEDAMDPROC) (GLuint buf, GLenum mode); +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +#endif + +#ifndef GL_APPLE_texture_range +#define GL_APPLE_texture_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureRangeAPPLE (GLenum target, GLsizei length, const GLvoid *pointer); +GLAPI void APIENTRY glGetTexParameterPointervAPPLE (GLenum target, GLenum pname, GLvoid* *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXTURERANGEAPPLEPROC) (GLenum target, GLsizei length, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERPOINTERVAPPLEPROC) (GLenum target, GLenum pname, GLvoid* *params); +#endif + +#ifndef GL_APPLE_float_pixels +#define GL_APPLE_float_pixels 1 +#endif + +#ifndef GL_APPLE_vertex_program_evaluators +#define GL_APPLE_vertex_program_evaluators 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glEnableVertexAttribAPPLE (GLuint index, GLenum pname); +GLAPI void APIENTRY glDisableVertexAttribAPPLE (GLuint index, GLenum pname); +GLAPI GLboolean APIENTRY glIsVertexAttribEnabledAPPLE (GLuint index, GLenum pname); +GLAPI void APIENTRY glMapVertexAttrib1dAPPLE (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points); +GLAPI void APIENTRY glMapVertexAttrib1fAPPLE (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points); +GLAPI void APIENTRY glMapVertexAttrib2dAPPLE (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points); +GLAPI void APIENTRY glMapVertexAttrib2fAPPLE (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname); +typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname); +typedef GLboolean (APIENTRYP PFNGLISVERTEXATTRIBENABLEDAPPLEPROC) (GLuint index, GLenum pname); +typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB1DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points); +typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB1FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points); +typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB2DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points); +typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB2FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points); +#endif + +#ifndef GL_APPLE_aux_depth_stencil +#define GL_APPLE_aux_depth_stencil 1 +#endif + +#ifndef GL_APPLE_object_purgeable +#define GL_APPLE_object_purgeable 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLenum APIENTRY glObjectPurgeableAPPLE (GLenum objectType, GLuint name, GLenum option); +GLAPI GLenum APIENTRY glObjectUnpurgeableAPPLE (GLenum objectType, GLuint name, GLenum option); +GLAPI void APIENTRY glGetObjectParameterivAPPLE (GLenum objectType, GLuint name, GLenum pname, GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLenum (APIENTRYP PFNGLOBJECTPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option); +typedef GLenum (APIENTRYP PFNGLOBJECTUNPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option); +typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVAPPLEPROC) (GLenum objectType, GLuint name, GLenum pname, GLint *params); +#endif + +#ifndef GL_APPLE_row_bytes +#define GL_APPLE_row_bytes 1 +#endif + +#ifndef GL_APPLE_rgb_422 +#define GL_APPLE_rgb_422 1 +#endif + +#ifndef GL_NV_video_capture +#define GL_NV_video_capture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginVideoCaptureNV (GLuint video_capture_slot); +GLAPI void APIENTRY glBindVideoCaptureStreamBufferNV (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLintptrARB offset); +GLAPI void APIENTRY glBindVideoCaptureStreamTextureNV (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLenum target, GLuint texture); +GLAPI void APIENTRY glEndVideoCaptureNV (GLuint video_capture_slot); +GLAPI void APIENTRY glGetVideoCaptureivNV (GLuint video_capture_slot, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVideoCaptureStreamivNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVideoCaptureStreamfvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVideoCaptureStreamdvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLdouble *params); +GLAPI GLenum APIENTRY glVideoCaptureNV (GLuint video_capture_slot, GLuint *sequence_num, GLuint64EXT *capture_time); +GLAPI void APIENTRY glVideoCaptureStreamParameterivNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLint *params); +GLAPI void APIENTRY glVideoCaptureStreamParameterfvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glVideoCaptureStreamParameterdvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLdouble *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBEGINVIDEOCAPTURENVPROC) (GLuint video_capture_slot); +typedef void (APIENTRYP PFNGLBINDVIDEOCAPTURESTREAMBUFFERNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLintptrARB offset); +typedef void (APIENTRYP PFNGLBINDVIDEOCAPTURESTREAMTEXTURENVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLenum target, GLuint texture); +typedef void (APIENTRYP PFNGLENDVIDEOCAPTURENVPROC) (GLuint video_capture_slot); +typedef void (APIENTRYP PFNGLGETVIDEOCAPTUREIVNVPROC) (GLuint video_capture_slot, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMIVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMFVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLdouble *params); +typedef GLenum (APIENTRYP PFNGLVIDEOCAPTURENVPROC) (GLuint video_capture_slot, GLuint *sequence_num, GLuint64EXT *capture_time); +typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERIVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERFVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLdouble *params); +#endif + +#ifndef GL_NV_copy_image +#define GL_NV_copy_image 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCopyImageSubDataNV (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOPYIMAGESUBDATANVPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); +#endif + +#ifndef GL_EXT_separate_shader_objects +#define GL_EXT_separate_shader_objects 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUseShaderProgramEXT (GLenum type, GLuint program); +GLAPI void APIENTRY glActiveProgramEXT (GLuint program); +GLAPI GLuint APIENTRY glCreateShaderProgramEXT (GLenum type, const GLchar *string); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLUSESHADERPROGRAMEXTPROC) (GLenum type, GLuint program); +typedef void (APIENTRYP PFNGLACTIVEPROGRAMEXTPROC) (GLuint program); +typedef GLuint (APIENTRYP PFNGLCREATESHADERPROGRAMEXTPROC) (GLenum type, const GLchar *string); +#endif + +#ifndef GL_NV_parameter_buffer_object2 +#define GL_NV_parameter_buffer_object2 1 +#endif + +#ifndef GL_NV_shader_buffer_load +#define GL_NV_shader_buffer_load 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMakeBufferResidentNV (GLenum target, GLenum access); +GLAPI void APIENTRY glMakeBufferNonResidentNV (GLenum target); +GLAPI GLboolean APIENTRY glIsBufferResidentNV (GLenum target); +GLAPI void APIENTRY glMakeNamedBufferResidentNV (GLuint buffer, GLenum access); +GLAPI void APIENTRY glMakeNamedBufferNonResidentNV (GLuint buffer); +GLAPI GLboolean APIENTRY glIsNamedBufferResidentNV (GLuint buffer); +GLAPI void APIENTRY glGetBufferParameterui64vNV (GLenum target, GLenum pname, GLuint64EXT *params); +GLAPI void APIENTRY glGetNamedBufferParameterui64vNV (GLuint buffer, GLenum pname, GLuint64EXT *params); +GLAPI void APIENTRY glGetIntegerui64vNV (GLenum value, GLuint64EXT *result); +GLAPI void APIENTRY glUniformui64NV (GLint location, GLuint64EXT value); +GLAPI void APIENTRY glUniformui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glGetUniformui64vNV (GLuint program, GLint location, GLuint64EXT *params); +GLAPI void APIENTRY glProgramUniformui64NV (GLuint program, GLint location, GLuint64EXT value); +GLAPI void APIENTRY glProgramUniformui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLMAKEBUFFERRESIDENTNVPROC) (GLenum target, GLenum access); +typedef void (APIENTRYP PFNGLMAKEBUFFERNONRESIDENTNVPROC) (GLenum target); +typedef GLboolean (APIENTRYP PFNGLISBUFFERRESIDENTNVPROC) (GLenum target); +typedef void (APIENTRYP PFNGLMAKENAMEDBUFFERRESIDENTNVPROC) (GLuint buffer, GLenum access); +typedef void (APIENTRYP PFNGLMAKENAMEDBUFFERNONRESIDENTNVPROC) (GLuint buffer); +typedef GLboolean (APIENTRYP PFNGLISNAMEDBUFFERRESIDENTNVPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERUI64VNVPROC) (GLenum target, GLenum pname, GLuint64EXT *params); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERUI64VNVPROC) (GLuint buffer, GLenum pname, GLuint64EXT *params); +typedef void (APIENTRYP PFNGLGETINTEGERUI64VNVPROC) (GLenum value, GLuint64EXT *result); +typedef void (APIENTRYP PFNGLUNIFORMUI64NVPROC) (GLint location, GLuint64EXT value); +typedef void (APIENTRYP PFNGLUNIFORMUI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLGETUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLuint64EXT *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMUI64NVPROC) (GLuint program, GLint location, GLuint64EXT value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#endif + +#ifndef GL_NV_vertex_buffer_unified_memory +#define GL_NV_vertex_buffer_unified_memory 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBufferAddressRangeNV (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length); +GLAPI void APIENTRY glVertexFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glNormalFormatNV (GLenum type, GLsizei stride); +GLAPI void APIENTRY glColorFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glIndexFormatNV (GLenum type, GLsizei stride); +GLAPI void APIENTRY glTexCoordFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glEdgeFlagFormatNV (GLsizei stride); +GLAPI void APIENTRY glSecondaryColorFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glFogCoordFormatNV (GLenum type, GLsizei stride); +GLAPI void APIENTRY glVertexAttribFormatNV (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride); +GLAPI void APIENTRY glVertexAttribIFormatNV (GLuint index, GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glGetIntegerui64i_vNV (GLenum value, GLuint index, GLuint64EXT *result); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBUFFERADDRESSRANGENVPROC) (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length); +typedef void (APIENTRYP PFNGLVERTEXFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLNORMALFORMATNVPROC) (GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLINDEXFORMATNVPROC) (GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLTEXCOORDFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLEDGEFLAGFORMATNVPROC) (GLsizei stride); +typedef void (APIENTRYP PFNGLSECONDARYCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLFOGCOORDFORMATNVPROC) (GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXATTRIBFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXATTRIBIFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLGETINTEGERUI64I_VNVPROC) (GLenum value, GLuint index, GLuint64EXT *result); +#endif + +#ifndef GL_NV_texture_barrier +#define GL_NV_texture_barrier 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureBarrierNV (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXTUREBARRIERNVPROC) (void); +#endif + +#ifndef GL_AMD_shader_stencil_export +#define GL_AMD_shader_stencil_export 1 +#endif + +#ifndef GL_AMD_seamless_cubemap_per_texture +#define GL_AMD_seamless_cubemap_per_texture 1 +#endif + +#ifndef GL_AMD_conservative_depth +#define GL_AMD_conservative_depth 1 +#endif + +#ifndef GL_EXT_shader_image_load_store +#define GL_EXT_shader_image_load_store 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindImageTextureEXT (GLuint index, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLint format); +GLAPI void APIENTRY glMemoryBarrierEXT (GLbitfield barriers); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDIMAGETEXTUREEXTPROC) (GLuint index, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLint format); +typedef void (APIENTRYP PFNGLMEMORYBARRIEREXTPROC) (GLbitfield barriers); +#endif + +#ifndef GL_EXT_vertex_attrib_64bit +#define GL_EXT_vertex_attrib_64bit 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribL1dEXT (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttribL2dEXT (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttribL3dEXT (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttribL4dEXT (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttribL1dvEXT (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL2dvEXT (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL3dvEXT (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL4dvEXT (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribLPointerEXT (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glGetVertexAttribLdvEXT (GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glVertexArrayVertexAttribLOffsetEXT (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DEXTPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DEXTPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DEXTPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DEXTPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DVEXTPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DVEXTPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DVEXTPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DVEXTPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBLPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLDVEXTPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBLOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); +#endif + +#ifndef GL_NV_gpu_program5 +#define GL_NV_gpu_program5 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramSubroutineParametersuivNV (GLenum target, GLsizei count, const GLuint *params); +GLAPI void APIENTRY glGetProgramSubroutineParameteruivNV (GLenum target, GLuint index, GLuint *param); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROGRAMSUBROUTINEPARAMETERSUIVNVPROC) (GLenum target, GLsizei count, const GLuint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSUBROUTINEPARAMETERUIVNVPROC) (GLenum target, GLuint index, GLuint *param); +#endif + +#ifndef GL_NV_gpu_shader5 +#define GL_NV_gpu_shader5 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUniform1i64NV (GLint location, GLint64EXT x); +GLAPI void APIENTRY glUniform2i64NV (GLint location, GLint64EXT x, GLint64EXT y); +GLAPI void APIENTRY glUniform3i64NV (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +GLAPI void APIENTRY glUniform4i64NV (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +GLAPI void APIENTRY glUniform1i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glUniform2i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glUniform3i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glUniform4i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glUniform1ui64NV (GLint location, GLuint64EXT x); +GLAPI void APIENTRY glUniform2ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y); +GLAPI void APIENTRY glUniform3ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +GLAPI void APIENTRY glUniform4ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +GLAPI void APIENTRY glUniform1ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glUniform2ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glUniform3ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glUniform4ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glGetUniformi64vNV (GLuint program, GLint location, GLint64EXT *params); +GLAPI void APIENTRY glProgramUniform1i64NV (GLuint program, GLint location, GLint64EXT x); +GLAPI void APIENTRY glProgramUniform2i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y); +GLAPI void APIENTRY glProgramUniform3i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +GLAPI void APIENTRY glProgramUniform4i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +GLAPI void APIENTRY glProgramUniform1i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glProgramUniform2i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glProgramUniform3i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glProgramUniform4i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glProgramUniform1ui64NV (GLuint program, GLint location, GLuint64EXT x); +GLAPI void APIENTRY glProgramUniform2ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y); +GLAPI void APIENTRY glProgramUniform3ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +GLAPI void APIENTRY glProgramUniform4ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +GLAPI void APIENTRY glProgramUniform1ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glProgramUniform2ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glProgramUniform3ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glProgramUniform4ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLUNIFORM1I64NVPROC) (GLint location, GLint64EXT x); +typedef void (APIENTRYP PFNGLUNIFORM2I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y); +typedef void (APIENTRYP PFNGLUNIFORM3I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +typedef void (APIENTRYP PFNGLUNIFORM4I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +typedef void (APIENTRYP PFNGLUNIFORM1I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM2I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM3I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM4I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM1UI64NVPROC) (GLint location, GLuint64EXT x); +typedef void (APIENTRYP PFNGLUNIFORM2UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y); +typedef void (APIENTRYP PFNGLUNIFORM3UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +typedef void (APIENTRYP PFNGLUNIFORM4UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +typedef void (APIENTRYP PFNGLUNIFORM1UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM2UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM3UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM4UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLGETUNIFORMI64VNVPROC) (GLuint program, GLint location, GLint64EXT *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64NVPROC) (GLuint program, GLint location, GLint64EXT x); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#endif + +#ifndef GL_NV_shader_buffer_store +#define GL_NV_shader_buffer_store 1 +#endif + +#ifndef GL_NV_tessellation_program5 +#define GL_NV_tessellation_program5 1 +#endif + +#ifndef GL_NV_vertex_attrib_integer_64bit +#define GL_NV_vertex_attrib_integer_64bit 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribL1i64NV (GLuint index, GLint64EXT x); +GLAPI void APIENTRY glVertexAttribL2i64NV (GLuint index, GLint64EXT x, GLint64EXT y); +GLAPI void APIENTRY glVertexAttribL3i64NV (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z); +GLAPI void APIENTRY glVertexAttribL4i64NV (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +GLAPI void APIENTRY glVertexAttribL1i64vNV (GLuint index, const GLint64EXT *v); +GLAPI void APIENTRY glVertexAttribL2i64vNV (GLuint index, const GLint64EXT *v); +GLAPI void APIENTRY glVertexAttribL3i64vNV (GLuint index, const GLint64EXT *v); +GLAPI void APIENTRY glVertexAttribL4i64vNV (GLuint index, const GLint64EXT *v); +GLAPI void APIENTRY glVertexAttribL1ui64NV (GLuint index, GLuint64EXT x); +GLAPI void APIENTRY glVertexAttribL2ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y); +GLAPI void APIENTRY glVertexAttribL3ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +GLAPI void APIENTRY glVertexAttribL4ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +GLAPI void APIENTRY glVertexAttribL1ui64vNV (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glVertexAttribL2ui64vNV (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glVertexAttribL3ui64vNV (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glVertexAttribL4ui64vNV (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glGetVertexAttribLi64vNV (GLuint index, GLenum pname, GLint64EXT *params); +GLAPI void APIENTRY glGetVertexAttribLui64vNV (GLuint index, GLenum pname, GLuint64EXT *params); +GLAPI void APIENTRY glVertexAttribLFormatNV (GLuint index, GLint size, GLenum type, GLsizei stride); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1I64NVPROC) (GLuint index, GLint64EXT x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1I64VNVPROC) (GLuint index, const GLint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2I64VNVPROC) (GLuint index, const GLint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3I64VNVPROC) (GLuint index, const GLint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4I64VNVPROC) (GLuint index, const GLint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64NVPROC) (GLuint index, GLuint64EXT x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64VNVPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2UI64VNVPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3UI64VNVPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4UI64VNVPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLI64VNVPROC) (GLuint index, GLenum pname, GLint64EXT *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLUI64VNVPROC) (GLuint index, GLenum pname, GLuint64EXT *params); +typedef void (APIENTRYP PFNGLVERTEXATTRIBLFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride); +#endif + +#ifndef GL_NV_multisample_coverage +#define GL_NV_multisample_coverage 1 +#endif + +#ifndef GL_AMD_name_gen_delete +#define GL_AMD_name_gen_delete 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenNamesAMD (GLenum identifier, GLuint num, GLuint *names); +GLAPI void APIENTRY glDeleteNamesAMD (GLenum identifier, GLuint num, const GLuint *names); +GLAPI GLboolean APIENTRY glIsNameAMD (GLenum identifier, GLuint name); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGENNAMESAMDPROC) (GLenum identifier, GLuint num, GLuint *names); +typedef void (APIENTRYP PFNGLDELETENAMESAMDPROC) (GLenum identifier, GLuint num, const GLuint *names); +typedef GLboolean (APIENTRYP PFNGLISNAMEAMDPROC) (GLenum identifier, GLuint name); +#endif + +#ifndef GL_AMD_debug_output +#define GL_AMD_debug_output 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDebugMessageEnableAMD (GLenum category, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +GLAPI void APIENTRY glDebugMessageInsertAMD (GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar *buf); +GLAPI void APIENTRY glDebugMessageCallbackAMD (GLDEBUGPROCAMD callback, GLvoid *userParam); +GLAPI GLuint APIENTRY glGetDebugMessageLogAMD (GLuint count, GLsizei bufsize, GLenum *categories, GLuint *severities, GLuint *ids, GLsizei *lengths, GLchar *message); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDEBUGMESSAGEENABLEAMDPROC) (GLenum category, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTAMDPROC) (GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar *buf); +typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKAMDPROC) (GLDEBUGPROCAMD callback, GLvoid *userParam); +typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGAMDPROC) (GLuint count, GLsizei bufsize, GLenum *categories, GLuint *severities, GLuint *ids, GLsizei *lengths, GLchar *message); +#endif + +#ifndef GL_NV_vdpau_interop +#define GL_NV_vdpau_interop 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVDPAUInitNV (const GLvoid *vdpDevice, const GLvoid *getProcAddress); +GLAPI void APIENTRY glVDPAUFiniNV (void); +GLAPI GLvdpauSurfaceNV APIENTRY glVDPAURegisterVideoSurfaceNV (GLvoid *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); +GLAPI GLvdpauSurfaceNV APIENTRY glVDPAURegisterOutputSurfaceNV (GLvoid *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); +GLAPI void APIENTRY glVDPAUIsSurfaceNV (GLvdpauSurfaceNV surface); +GLAPI void APIENTRY glVDPAUUnregisterSurfaceNV (GLvdpauSurfaceNV surface); +GLAPI void APIENTRY glVDPAUGetSurfaceivNV (GLvdpauSurfaceNV surface, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +GLAPI void APIENTRY glVDPAUSurfaceAccessNV (GLvdpauSurfaceNV surface, GLenum access); +GLAPI void APIENTRY glVDPAUMapSurfacesNV (GLsizei numSurfaces, const GLvdpauSurfaceNV *surfaces); +GLAPI void APIENTRY glVDPAUUnmapSurfacesNV (GLsizei numSurface, const GLvdpauSurfaceNV *surfaces); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVDPAUINITNVPROC) (const GLvoid *vdpDevice, const GLvoid *getProcAddress); +typedef void (APIENTRYP PFNGLVDPAUFININVPROC) (void); +typedef GLvdpauSurfaceNV (APIENTRYP PFNGLVDPAUREGISTERVIDEOSURFACENVPROC) (GLvoid *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); +typedef GLvdpauSurfaceNV (APIENTRYP PFNGLVDPAUREGISTEROUTPUTSURFACENVPROC) (GLvoid *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); +typedef void (APIENTRYP PFNGLVDPAUISSURFACENVPROC) (GLvdpauSurfaceNV surface); +typedef void (APIENTRYP PFNGLVDPAUUNREGISTERSURFACENVPROC) (GLvdpauSurfaceNV surface); +typedef void (APIENTRYP PFNGLVDPAUGETSURFACEIVNVPROC) (GLvdpauSurfaceNV surface, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +typedef void (APIENTRYP PFNGLVDPAUSURFACEACCESSNVPROC) (GLvdpauSurfaceNV surface, GLenum access); +typedef void (APIENTRYP PFNGLVDPAUMAPSURFACESNVPROC) (GLsizei numSurfaces, const GLvdpauSurfaceNV *surfaces); +typedef void (APIENTRYP PFNGLVDPAUUNMAPSURFACESNVPROC) (GLsizei numSurface, const GLvdpauSurfaceNV *surfaces); +#endif + +#ifndef GL_AMD_transform_feedback3_lines_triangles +#define GL_AMD_transform_feedback3_lines_triangles 1 +#endif + +#ifndef GL_AMD_depth_clamp_separate +#define GL_AMD_depth_clamp_separate 1 +#endif + +#ifndef GL_EXT_texture_sRGB_decode +#define GL_EXT_texture_sRGB_decode 1 +#endif + +#ifndef GL_NV_texture_multisample +#define GL_NV_texture_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexImage2DMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTexImage3DMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTextureImage2DMultisampleNV (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTextureImage3DMultisampleNV (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTextureImage2DMultisampleCoverageNV (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTextureImage3DMultisampleCoverageNV (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +typedef void (APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DMULTISAMPLENVPROC) (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DMULTISAMPLENVPROC) (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DMULTISAMPLECOVERAGENVPROC) (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DMULTISAMPLECOVERAGENVPROC) (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +#endif + +#ifndef GL_AMD_blend_minmax_factor +#define GL_AMD_blend_minmax_factor 1 +#endif + +#ifndef GL_AMD_sample_positions +#define GL_AMD_sample_positions 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSetMultisamplefvAMD (GLenum pname, GLuint index, const GLfloat *val); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSETMULTISAMPLEFVAMDPROC) (GLenum pname, GLuint index, const GLfloat *val); +#endif + +#ifndef GL_EXT_x11_sync_object +#define GL_EXT_x11_sync_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLsync APIENTRY glImportSyncEXT (GLenum external_sync_type, GLintptr external_sync, GLbitfield flags); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLsync (APIENTRYP PFNGLIMPORTSYNCEXTPROC) (GLenum external_sync_type, GLintptr external_sync, GLbitfield flags); +#endif + +#ifndef GL_AMD_multi_draw_indirect +#define GL_AMD_multi_draw_indirect 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiDrawArraysIndirectAMD (GLenum mode, const GLvoid *indirect, GLsizei primcount, GLsizei stride); +GLAPI void APIENTRY glMultiDrawElementsIndirectAMD (GLenum mode, GLenum type, const GLvoid *indirect, GLsizei primcount, GLsizei stride); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTAMDPROC) (GLenum mode, const GLvoid *indirect, GLsizei primcount, GLsizei stride); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTAMDPROC) (GLenum mode, GLenum type, const GLvoid *indirect, GLsizei primcount, GLsizei stride); +#endif + +#ifndef GL_EXT_framebuffer_multisample_blit_scaled +#define GL_EXT_framebuffer_multisample_blit_scaled 1 +#endif + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/3rdparty/glsl-optimizer/include/c99/inttypes.h b/3rdparty/glsl-optimizer/include/c99/inttypes.h new file mode 100644 index 000000000..4b3828a21 --- /dev/null +++ b/3rdparty/glsl-optimizer/include/c99/inttypes.h @@ -0,0 +1,305 @@ +// ISO C9x compliant inttypes.h for Microsoft Visual Studio +// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 +// +// Copyright (c) 2006 Alexander Chemeris +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// 1. Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// 3. The name of the author may be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED +// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +/////////////////////////////////////////////////////////////////////////////// + +#ifndef _MSC_VER // [ +#error "Use this header only with Microsoft Visual C++ compilers!" +#endif // _MSC_VER ] + +#ifndef _MSC_INTTYPES_H_ // [ +#define _MSC_INTTYPES_H_ + +#if _MSC_VER > 1000 +#pragma once +#endif + +#include "stdint.h" + +// 7.8 Format conversion of integer types + +typedef struct { + intmax_t quot; + intmax_t rem; +} imaxdiv_t; + +// 7.8.1 Macros for format specifiers + +#if !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS) // [ See footnote 185 at page 198 + +// The fprintf macros for signed integers are: +#define PRId8 "d" +#define PRIi8 "i" +#define PRIdLEAST8 "d" +#define PRIiLEAST8 "i" +#define PRIdFAST8 "d" +#define PRIiFAST8 "i" + +#define PRId16 "hd" +#define PRIi16 "hi" +#define PRIdLEAST16 "hd" +#define PRIiLEAST16 "hi" +#define PRIdFAST16 "hd" +#define PRIiFAST16 "hi" + +#define PRId32 "I32d" +#define PRIi32 "I32i" +#define PRIdLEAST32 "I32d" +#define PRIiLEAST32 "I32i" +#define PRIdFAST32 "I32d" +#define PRIiFAST32 "I32i" + +#define PRId64 "I64d" +#define PRIi64 "I64i" +#define PRIdLEAST64 "I64d" +#define PRIiLEAST64 "I64i" +#define PRIdFAST64 "I64d" +#define PRIiFAST64 "I64i" + +#define PRIdMAX "I64d" +#define PRIiMAX "I64i" + +#define PRIdPTR "Id" +#define PRIiPTR "Ii" + +// The fprintf macros for unsigned integers are: +#define PRIo8 "o" +#define PRIu8 "u" +#define PRIx8 "x" +#define PRIX8 "X" +#define PRIoLEAST8 "o" +#define PRIuLEAST8 "u" +#define PRIxLEAST8 "x" +#define PRIXLEAST8 "X" +#define PRIoFAST8 "o" +#define PRIuFAST8 "u" +#define PRIxFAST8 "x" +#define PRIXFAST8 "X" + +#define PRIo16 "ho" +#define PRIu16 "hu" +#define PRIx16 "hx" +#define PRIX16 "hX" +#define PRIoLEAST16 "ho" +#define PRIuLEAST16 "hu" +#define PRIxLEAST16 "hx" +#define PRIXLEAST16 "hX" +#define PRIoFAST16 "ho" +#define PRIuFAST16 "hu" +#define PRIxFAST16 "hx" +#define PRIXFAST16 "hX" + +#define PRIo32 "I32o" +#define PRIu32 "I32u" +#define PRIx32 "I32x" +#define PRIX32 "I32X" +#define PRIoLEAST32 "I32o" +#define PRIuLEAST32 "I32u" +#define PRIxLEAST32 "I32x" +#define PRIXLEAST32 "I32X" +#define PRIoFAST32 "I32o" +#define PRIuFAST32 "I32u" +#define PRIxFAST32 "I32x" +#define PRIXFAST32 "I32X" + +#define PRIo64 "I64o" +#define PRIu64 "I64u" +#define PRIx64 "I64x" +#define PRIX64 "I64X" +#define PRIoLEAST64 "I64o" +#define PRIuLEAST64 "I64u" +#define PRIxLEAST64 "I64x" +#define PRIXLEAST64 "I64X" +#define PRIoFAST64 "I64o" +#define PRIuFAST64 "I64u" +#define PRIxFAST64 "I64x" +#define PRIXFAST64 "I64X" + +#define PRIoMAX "I64o" +#define PRIuMAX "I64u" +#define PRIxMAX "I64x" +#define PRIXMAX "I64X" + +#define PRIoPTR "Io" +#define PRIuPTR "Iu" +#define PRIxPTR "Ix" +#define PRIXPTR "IX" + +// The fscanf macros for signed integers are: +#define SCNd8 "d" +#define SCNi8 "i" +#define SCNdLEAST8 "d" +#define SCNiLEAST8 "i" +#define SCNdFAST8 "d" +#define SCNiFAST8 "i" + +#define SCNd16 "hd" +#define SCNi16 "hi" +#define SCNdLEAST16 "hd" +#define SCNiLEAST16 "hi" +#define SCNdFAST16 "hd" +#define SCNiFAST16 "hi" + +#define SCNd32 "ld" +#define SCNi32 "li" +#define SCNdLEAST32 "ld" +#define SCNiLEAST32 "li" +#define SCNdFAST32 "ld" +#define SCNiFAST32 "li" + +#define SCNd64 "I64d" +#define SCNi64 "I64i" +#define SCNdLEAST64 "I64d" +#define SCNiLEAST64 "I64i" +#define SCNdFAST64 "I64d" +#define SCNiFAST64 "I64i" + +#define SCNdMAX "I64d" +#define SCNiMAX "I64i" + +#ifdef _WIN64 // [ +# define SCNdPTR "I64d" +# define SCNiPTR "I64i" +#else // _WIN64 ][ +# define SCNdPTR "ld" +# define SCNiPTR "li" +#endif // _WIN64 ] + +// The fscanf macros for unsigned integers are: +#define SCNo8 "o" +#define SCNu8 "u" +#define SCNx8 "x" +#define SCNX8 "X" +#define SCNoLEAST8 "o" +#define SCNuLEAST8 "u" +#define SCNxLEAST8 "x" +#define SCNXLEAST8 "X" +#define SCNoFAST8 "o" +#define SCNuFAST8 "u" +#define SCNxFAST8 "x" +#define SCNXFAST8 "X" + +#define SCNo16 "ho" +#define SCNu16 "hu" +#define SCNx16 "hx" +#define SCNX16 "hX" +#define SCNoLEAST16 "ho" +#define SCNuLEAST16 "hu" +#define SCNxLEAST16 "hx" +#define SCNXLEAST16 "hX" +#define SCNoFAST16 "ho" +#define SCNuFAST16 "hu" +#define SCNxFAST16 "hx" +#define SCNXFAST16 "hX" + +#define SCNo32 "lo" +#define SCNu32 "lu" +#define SCNx32 "lx" +#define SCNX32 "lX" +#define SCNoLEAST32 "lo" +#define SCNuLEAST32 "lu" +#define SCNxLEAST32 "lx" +#define SCNXLEAST32 "lX" +#define SCNoFAST32 "lo" +#define SCNuFAST32 "lu" +#define SCNxFAST32 "lx" +#define SCNXFAST32 "lX" + +#define SCNo64 "I64o" +#define SCNu64 "I64u" +#define SCNx64 "I64x" +#define SCNX64 "I64X" +#define SCNoLEAST64 "I64o" +#define SCNuLEAST64 "I64u" +#define SCNxLEAST64 "I64x" +#define SCNXLEAST64 "I64X" +#define SCNoFAST64 "I64o" +#define SCNuFAST64 "I64u" +#define SCNxFAST64 "I64x" +#define SCNXFAST64 "I64X" + +#define SCNoMAX "I64o" +#define SCNuMAX "I64u" +#define SCNxMAX "I64x" +#define SCNXMAX "I64X" + +#ifdef _WIN64 // [ +# define SCNoPTR "I64o" +# define SCNuPTR "I64u" +# define SCNxPTR "I64x" +# define SCNXPTR "I64X" +#else // _WIN64 ][ +# define SCNoPTR "lo" +# define SCNuPTR "lu" +# define SCNxPTR "lx" +# define SCNXPTR "lX" +#endif // _WIN64 ] + +#endif // __STDC_FORMAT_MACROS ] + +// 7.8.2 Functions for greatest-width integer types + +// 7.8.2.1 The imaxabs function +#define imaxabs _abs64 + +// 7.8.2.2 The imaxdiv function + +// This is modified version of div() function from Microsoft's div.c found +// in %MSVC.NET%\crt\src\div.c +#ifdef STATIC_IMAXDIV // [ +static +#else // STATIC_IMAXDIV ][ +_inline +#endif // STATIC_IMAXDIV ] +imaxdiv_t __cdecl imaxdiv(intmax_t numer, intmax_t denom) +{ + imaxdiv_t result; + + result.quot = numer / denom; + result.rem = numer % denom; + + if (numer < 0 && result.rem > 0) { + // did division wrong; must fix up + ++result.quot; + result.rem -= denom; + } + + return result; +} + +// 7.8.2.3 The strtoimax and strtoumax functions +#define strtoimax _strtoi64 +#define strtoumax _strtoui64 + +// 7.8.2.4 The wcstoimax and wcstoumax functions +#define wcstoimax _wcstoi64 +#define wcstoumax _wcstoui64 + + +#endif // _MSC_INTTYPES_H_ ] diff --git a/3rdparty/glsl-optimizer/include/c99/stdbool.h b/3rdparty/glsl-optimizer/include/c99/stdbool.h new file mode 100644 index 000000000..304108217 --- /dev/null +++ b/3rdparty/glsl-optimizer/include/c99/stdbool.h @@ -0,0 +1,46 @@ +/************************************************************************** + * + * Copyright 2007-2010 VMware, Inc. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + * USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + **************************************************************************/ + +#ifndef _STDBOOL_H_ +#define _STDBOOL_H_ + +#ifndef __cplusplus + +#define false 0 +#define true 1 +#define bool _Bool + +/* For compilers that don't have the builtin _Bool type. */ +#if (defined(_MSC_VER) || (__STDC_VERSION__ < 199901L && __GNUC__ < 3)) && !defined(_lint) +typedef unsigned char _Bool; +#endif + +#endif /* !__cplusplus */ + +#define __bool_true_false_are_defined 1 + +#endif /* !_STDBOOL_H_ */ diff --git a/3rdparty/glsl-optimizer/include/c99/stdint.h b/3rdparty/glsl-optimizer/include/c99/stdint.h new file mode 100644 index 000000000..d02608a59 --- /dev/null +++ b/3rdparty/glsl-optimizer/include/c99/stdint.h @@ -0,0 +1,247 @@ +// ISO C9x compliant stdint.h for Microsoft Visual Studio +// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 +// +// Copyright (c) 2006-2008 Alexander Chemeris +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// 1. Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// 3. The name of the author may be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED +// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +/////////////////////////////////////////////////////////////////////////////// + +#ifndef _MSC_VER // [ +#error "Use this header only with Microsoft Visual C++ compilers!" +#endif // _MSC_VER ] + +#ifndef _MSC_STDINT_H_ // [ +#define _MSC_STDINT_H_ + +#if _MSC_VER > 1000 +#pragma once +#endif + +#include + +// For Visual Studio 6 in C++ mode and for many Visual Studio versions when +// compiling for ARM we should wrap include with 'extern "C++" {}' +// or compiler give many errors like this: +// error C2733: second C linkage of overloaded function 'wmemchr' not allowed +#ifdef __cplusplus +extern "C" { +#endif +# include +#ifdef __cplusplus +} +#endif + +// Define _W64 macros to mark types changing their size, like intptr_t. +#ifndef _W64 +# if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300 +# define _W64 __w64 +# else +# define _W64 +# endif +#endif + + +// 7.18.1 Integer types + +// 7.18.1.1 Exact-width integer types + +// Visual Studio 6 and Embedded Visual C++ 4 doesn't +// realize that, e.g. char has the same size as __int8 +// so we give up on __intX for them. +#if (_MSC_VER < 1300) + typedef signed char int8_t; + typedef signed short int16_t; + typedef signed int int32_t; + typedef unsigned char uint8_t; + typedef unsigned short uint16_t; + typedef unsigned int uint32_t; +#else + typedef signed __int8 int8_t; + typedef signed __int16 int16_t; + typedef signed __int32 int32_t; + typedef unsigned __int8 uint8_t; + typedef unsigned __int16 uint16_t; + typedef unsigned __int32 uint32_t; +#endif +typedef signed __int64 int64_t; +typedef unsigned __int64 uint64_t; + + +// 7.18.1.2 Minimum-width integer types +typedef int8_t int_least8_t; +typedef int16_t int_least16_t; +typedef int32_t int_least32_t; +typedef int64_t int_least64_t; +typedef uint8_t uint_least8_t; +typedef uint16_t uint_least16_t; +typedef uint32_t uint_least32_t; +typedef uint64_t uint_least64_t; + +// 7.18.1.3 Fastest minimum-width integer types +typedef int8_t int_fast8_t; +typedef int16_t int_fast16_t; +typedef int32_t int_fast32_t; +typedef int64_t int_fast64_t; +typedef uint8_t uint_fast8_t; +typedef uint16_t uint_fast16_t; +typedef uint32_t uint_fast32_t; +typedef uint64_t uint_fast64_t; + +// 7.18.1.4 Integer types capable of holding object pointers +#ifdef _WIN64 // [ + typedef signed __int64 intptr_t; + typedef unsigned __int64 uintptr_t; +#else // _WIN64 ][ + typedef _W64 signed int intptr_t; + typedef _W64 unsigned int uintptr_t; +#endif // _WIN64 ] + +// 7.18.1.5 Greatest-width integer types +typedef int64_t intmax_t; +typedef uint64_t uintmax_t; + + +// 7.18.2 Limits of specified-width integer types + +#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259 + +// 7.18.2.1 Limits of exact-width integer types +#define INT8_MIN ((int8_t)_I8_MIN) +#define INT8_MAX _I8_MAX +#define INT16_MIN ((int16_t)_I16_MIN) +#define INT16_MAX _I16_MAX +#define INT32_MIN ((int32_t)_I32_MIN) +#define INT32_MAX _I32_MAX +#define INT64_MIN ((int64_t)_I64_MIN) +#define INT64_MAX _I64_MAX +#define UINT8_MAX _UI8_MAX +#define UINT16_MAX _UI16_MAX +#define UINT32_MAX _UI32_MAX +#define UINT64_MAX _UI64_MAX + +// 7.18.2.2 Limits of minimum-width integer types +#define INT_LEAST8_MIN INT8_MIN +#define INT_LEAST8_MAX INT8_MAX +#define INT_LEAST16_MIN INT16_MIN +#define INT_LEAST16_MAX INT16_MAX +#define INT_LEAST32_MIN INT32_MIN +#define INT_LEAST32_MAX INT32_MAX +#define INT_LEAST64_MIN INT64_MIN +#define INT_LEAST64_MAX INT64_MAX +#define UINT_LEAST8_MAX UINT8_MAX +#define UINT_LEAST16_MAX UINT16_MAX +#define UINT_LEAST32_MAX UINT32_MAX +#define UINT_LEAST64_MAX UINT64_MAX + +// 7.18.2.3 Limits of fastest minimum-width integer types +#define INT_FAST8_MIN INT8_MIN +#define INT_FAST8_MAX INT8_MAX +#define INT_FAST16_MIN INT16_MIN +#define INT_FAST16_MAX INT16_MAX +#define INT_FAST32_MIN INT32_MIN +#define INT_FAST32_MAX INT32_MAX +#define INT_FAST64_MIN INT64_MIN +#define INT_FAST64_MAX INT64_MAX +#define UINT_FAST8_MAX UINT8_MAX +#define UINT_FAST16_MAX UINT16_MAX +#define UINT_FAST32_MAX UINT32_MAX +#define UINT_FAST64_MAX UINT64_MAX + +// 7.18.2.4 Limits of integer types capable of holding object pointers +#ifdef _WIN64 // [ +# define INTPTR_MIN INT64_MIN +# define INTPTR_MAX INT64_MAX +# define UINTPTR_MAX UINT64_MAX +#else // _WIN64 ][ +# define INTPTR_MIN INT32_MIN +# define INTPTR_MAX INT32_MAX +# define UINTPTR_MAX UINT32_MAX +#endif // _WIN64 ] + +// 7.18.2.5 Limits of greatest-width integer types +#define INTMAX_MIN INT64_MIN +#define INTMAX_MAX INT64_MAX +#define UINTMAX_MAX UINT64_MAX + +// 7.18.3 Limits of other integer types + +#ifdef _WIN64 // [ +# define PTRDIFF_MIN _I64_MIN +# define PTRDIFF_MAX _I64_MAX +#else // _WIN64 ][ +# define PTRDIFF_MIN _I32_MIN +# define PTRDIFF_MAX _I32_MAX +#endif // _WIN64 ] + +#define SIG_ATOMIC_MIN INT_MIN +#define SIG_ATOMIC_MAX INT_MAX + +#ifndef SIZE_MAX // [ +# ifdef _WIN64 // [ +# define SIZE_MAX _UI64_MAX +# else // _WIN64 ][ +# define SIZE_MAX _UI32_MAX +# endif // _WIN64 ] +#endif // SIZE_MAX ] + +// WCHAR_MIN and WCHAR_MAX are also defined in +#ifndef WCHAR_MIN // [ +# define WCHAR_MIN 0 +#endif // WCHAR_MIN ] +#ifndef WCHAR_MAX // [ +# define WCHAR_MAX _UI16_MAX +#endif // WCHAR_MAX ] + +#define WINT_MIN 0 +#define WINT_MAX _UI16_MAX + +#endif // __STDC_LIMIT_MACROS ] + + +// 7.18.4 Limits of other integer types + +#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260 + +// 7.18.4.1 Macros for minimum-width integer constants + +#define INT8_C(val) val##i8 +#define INT16_C(val) val##i16 +#define INT32_C(val) val##i32 +#define INT64_C(val) val##i64 + +#define UINT8_C(val) val##ui8 +#define UINT16_C(val) val##ui16 +#define UINT32_C(val) val##ui32 +#define UINT64_C(val) val##ui64 + +// 7.18.4.2 Macros for greatest-width integer constants +#define INTMAX_C INT64_C +#define UINTMAX_C UINT64_C + +#endif // __STDC_CONSTANT_MACROS ] + + +#endif // _MSC_STDINT_H_ ] diff --git a/3rdparty/glsl-optimizer/license.txt b/3rdparty/glsl-optimizer/license.txt new file mode 100644 index 000000000..6ef971544 --- /dev/null +++ b/3rdparty/glsl-optimizer/license.txt @@ -0,0 +1,21 @@ +GLSL Optimizer is licensed according to the terms of the MIT license: + +Copyright (C) 1999-2007 Brian Paul All Rights Reserved. +Copyright (C) 2010-2011 Unity Technologies All Rights Reserved. + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the "Software"), +to deal in the Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/3rdparty/glsl-optimizer/removeDeletedByUs.sh b/3rdparty/glsl-optimizer/removeDeletedByUs.sh new file mode 100644 index 000000000..0e42d490b --- /dev/null +++ b/3rdparty/glsl-optimizer/removeDeletedByUs.sh @@ -0,0 +1,5 @@ +#! /bin/sh +git rm -rf docs +git rm -rf src/mesa/drivers +git rm -rf src/gallium +git rm -rf $(git status --porcelain | awk '/^DU/ {print $NF}') diff --git a/3rdparty/glsl-optimizer/src/getopt/SConscript b/3rdparty/glsl-optimizer/src/getopt/SConscript new file mode 100644 index 000000000..14cabed4e --- /dev/null +++ b/3rdparty/glsl-optimizer/src/getopt/SConscript @@ -0,0 +1,15 @@ +Import('*') + +if not env['msvc']: + Return() + +env = env.Clone() + +env.Prepend(CPPPATH = ['.']) + +getopt = env.ConvenienceLibrary( + target = 'getopt', + source = ['getopt_long.c'], +) + +Export('getopt') diff --git a/3rdparty/glsl-optimizer/src/getopt/getopt.h b/3rdparty/glsl-optimizer/src/getopt/getopt.h new file mode 100644 index 000000000..117608f48 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/getopt/getopt.h @@ -0,0 +1,82 @@ +/* $OpenBSD: getopt.h,v 1.2 2008/06/26 05:42:04 ray Exp $ */ +/* $NetBSD: getopt.h,v 1.4 2000/07/07 10:43:54 ad Exp $ */ + +/*- + * Copyright (c) 2000 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Dieter Baron and Thomas Klausner. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _GETOPT_H_ +#define _GETOPT_H_ + +/* + * GNU-like getopt_long() and 4.4BSD getsubopt()/optreset extensions + */ +#define no_argument 0 +#define required_argument 1 +#define optional_argument 2 + +#ifdef __cplusplus +extern "C" { +#endif + +struct option { + /* name of long option */ + const char *name; + /* + * one of no_argument, required_argument, and optional_argument: + * whether option takes an argument + */ + int has_arg; + /* if not NULL, set *flag to val when option found */ + int *flag; + /* if flag not NULL, value to set *flag to; else return value */ + int val; +}; + +int getopt_long(int, char * const *, const char *, + const struct option *, int *); +int getopt_long_only(int, char * const *, const char *, + const struct option *, int *); +#ifndef _GETOPT_DEFINED_ +#define _GETOPT_DEFINED_ +int getopt(int, char * const *, const char *); +int getsubopt(char **, char * const *, char **); + +extern char *optarg; /* getopt(3) external variables */ +extern int opterr; +extern int optind; +extern int optopt; +extern int optreset; +extern char *suboptarg; /* getsubopt(3) external variable */ +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* !_GETOPT_H_ */ diff --git a/3rdparty/glsl-optimizer/src/getopt/getopt_long.c b/3rdparty/glsl-optimizer/src/getopt/getopt_long.c new file mode 100644 index 000000000..81268b839 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/getopt/getopt_long.c @@ -0,0 +1,511 @@ +/* $OpenBSD: getopt_long.c,v 1.24 2010/07/22 19:31:53 blambert Exp $ */ +/* $NetBSD: getopt_long.c,v 1.15 2002/01/31 22:43:40 tv Exp $ */ + +/* + * Copyright (c) 2002 Todd C. Miller + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Sponsored in part by the Defense Advanced Research Projects + * Agency (DARPA) and Air Force Research Laboratory, Air Force + * Materiel Command, USAF, under agreement number F39502-99-1-0512. + */ +/*- + * Copyright (c) 2000 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Dieter Baron and Thomas Klausner. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include +#include +#include +#include + +int opterr = 1; /* if error message should be printed */ +int optind = 1; /* index into parent argv vector */ +int optopt = '?'; /* character checked for validity */ +int optreset; /* reset getopt */ +char *optarg; /* argument associated with option */ + +#define PRINT_ERROR ((opterr) && (*options != ':')) + +#define FLAG_PERMUTE 0x01 /* permute non-options to the end of argv */ +#define FLAG_ALLARGS 0x02 /* treat non-options as args to option "-1" */ +#define FLAG_LONGONLY 0x04 /* operate as getopt_long_only */ + +/* return values */ +#define BADCH (int)'?' +#define BADARG ((*options == ':') ? (int)':' : (int)'?') +#define INORDER (int)1 + +#define EMSG "" + +static int getopt_internal(int, char * const *, const char *, + const struct option *, int *, int); +static int parse_long_options(char * const *, const char *, + const struct option *, int *, int); +static int gcd(int, int); +static void permute_args(int, int, int, char * const *); + +static char *place = EMSG; /* option letter processing */ + +/* XXX: set optreset to 1 rather than these two */ +static int nonopt_start = -1; /* first non option argument (for permute) */ +static int nonopt_end = -1; /* first option after non options (for permute) */ + +/* Error messages */ +static const char recargchar[] = "option requires an argument -- %c"; +static const char recargstring[] = "option requires an argument -- %s"; +static const char ambig[] = "ambiguous option -- %.*s"; +static const char noarg[] = "option doesn't take an argument -- %.*s"; +static const char illoptchar[] = "unknown option -- %c"; +static const char illoptstring[] = "unknown option -- %s"; + +/* + * Compute the greatest common divisor of a and b. + */ +static int +gcd(int a, int b) +{ + int c; + + c = a % b; + while (c != 0) { + a = b; + b = c; + c = a % b; + } + + return (b); +} + +/* + * Exchange the block from nonopt_start to nonopt_end with the block + * from nonopt_end to opt_end (keeping the same order of arguments + * in each block). + */ +static void +permute_args(int panonopt_start, int panonopt_end, int opt_end, + char * const *nargv) +{ + int cstart, cyclelen, i, j, ncycle, nnonopts, nopts, pos; + char *swap; + + /* + * compute lengths of blocks and number and size of cycles + */ + nnonopts = panonopt_end - panonopt_start; + nopts = opt_end - panonopt_end; + ncycle = gcd(nnonopts, nopts); + cyclelen = (opt_end - panonopt_start) / ncycle; + + for (i = 0; i < ncycle; i++) { + cstart = panonopt_end+i; + pos = cstart; + for (j = 0; j < cyclelen; j++) { + if (pos >= panonopt_end) + pos -= nnonopts; + else + pos += nopts; + swap = nargv[pos]; + /* LINTED const cast */ + ((char **) nargv)[pos] = nargv[cstart]; + /* LINTED const cast */ + ((char **)nargv)[cstart] = swap; + } + } +} + +/* + * parse_long_options -- + * Parse long options in argc/argv argument vector. + * Returns -1 if short_too is set and the option does not match long_options. + */ +static int +parse_long_options(char * const *nargv, const char *options, + const struct option *long_options, int *idx, int short_too) +{ + char *current_argv, *has_equal; + size_t current_argv_len; + int i, match; + + current_argv = place; + match = -1; + + optind++; + + if ((has_equal = strchr(current_argv, '=')) != NULL) { + /* argument found (--option=arg) */ + current_argv_len = has_equal - current_argv; + has_equal++; + } else + current_argv_len = strlen(current_argv); + + for (i = 0; long_options[i].name; i++) { + /* find matching long option */ + if (strncmp(current_argv, long_options[i].name, + current_argv_len)) + continue; + + if (strlen(long_options[i].name) == current_argv_len) { + /* exact match */ + match = i; + break; + } + /* + * If this is a known short option, don't allow + * a partial match of a single character. + */ + if (short_too && current_argv_len == 1) + continue; + + if (match == -1) /* partial match */ + match = i; + else { + /* ambiguous abbreviation */ + if (PRINT_ERROR) + fprintf(stderr, ambig, (int)current_argv_len, + current_argv); + optopt = 0; + return (BADCH); + } + } + if (match != -1) { /* option found */ + if (long_options[match].has_arg == no_argument + && has_equal) { + if (PRINT_ERROR) + fprintf(stderr, noarg, (int)current_argv_len, + current_argv); + /* + * XXX: GNU sets optopt to val regardless of flag + */ + if (long_options[match].flag == NULL) + optopt = long_options[match].val; + else + optopt = 0; + return (BADARG); + } + if (long_options[match].has_arg == required_argument || + long_options[match].has_arg == optional_argument) { + if (has_equal) + optarg = has_equal; + else if (long_options[match].has_arg == + required_argument) { + /* + * optional argument doesn't use next nargv + */ + optarg = nargv[optind++]; + } + } + if ((long_options[match].has_arg == required_argument) + && (optarg == NULL)) { + /* + * Missing argument; leading ':' indicates no error + * should be generated. + */ + if (PRINT_ERROR) + fprintf(stderr, recargstring, + current_argv); + /* + * XXX: GNU sets optopt to val regardless of flag + */ + if (long_options[match].flag == NULL) + optopt = long_options[match].val; + else + optopt = 0; + --optind; + return (BADARG); + } + } else { /* unknown option */ + if (short_too) { + --optind; + return (-1); + } + if (PRINT_ERROR) + fprintf(stderr, illoptstring, current_argv); + optopt = 0; + return (BADCH); + } + if (idx) + *idx = match; + if (long_options[match].flag) { + *long_options[match].flag = long_options[match].val; + return (0); + } else + return (long_options[match].val); +} + +/* + * getopt_internal -- + * Parse argc/argv argument vector. Called by user level routines. + */ +static int +getopt_internal(int nargc, char * const *nargv, const char *options, + const struct option *long_options, int *idx, int flags) +{ + char *oli; /* option letter list index */ + int optchar, short_too; + static int posixly_correct = -1; + + if (options == NULL) + return (-1); + + /* + * Disable GNU extensions if POSIXLY_CORRECT is set or options + * string begins with a '+'. + */ + if (posixly_correct == -1) + posixly_correct = (getenv("POSIXLY_CORRECT") != NULL); + if (posixly_correct || *options == '+') + flags &= ~FLAG_PERMUTE; + else if (*options == '-') + flags |= FLAG_ALLARGS; + if (*options == '+' || *options == '-') + options++; + + /* + * XXX Some GNU programs (like cvs) set optind to 0 instead of + * XXX using optreset. Work around this braindamage. + */ + if (optind == 0) + optind = optreset = 1; + + optarg = NULL; + if (optreset) + nonopt_start = nonopt_end = -1; +start: + if (optreset || !*place) { /* update scanning pointer */ + optreset = 0; + if (optind >= nargc) { /* end of argument vector */ + place = EMSG; + if (nonopt_end != -1) { + /* do permutation, if we have to */ + permute_args(nonopt_start, nonopt_end, + optind, nargv); + optind -= nonopt_end - nonopt_start; + } + else if (nonopt_start != -1) { + /* + * If we skipped non-options, set optind + * to the first of them. + */ + optind = nonopt_start; + } + nonopt_start = nonopt_end = -1; + return (-1); + } + if (*(place = nargv[optind]) != '-' || + (place[1] == '\0' && strchr(options, '-') == NULL)) { + place = EMSG; /* found non-option */ + if (flags & FLAG_ALLARGS) { + /* + * GNU extension: + * return non-option as argument to option 1 + */ + optarg = nargv[optind++]; + return (INORDER); + } + if (!(flags & FLAG_PERMUTE)) { + /* + * If no permutation wanted, stop parsing + * at first non-option. + */ + return (-1); + } + /* do permutation */ + if (nonopt_start == -1) + nonopt_start = optind; + else if (nonopt_end != -1) { + permute_args(nonopt_start, nonopt_end, + optind, nargv); + nonopt_start = optind - + (nonopt_end - nonopt_start); + nonopt_end = -1; + } + optind++; + /* process next argument */ + goto start; + } + if (nonopt_start != -1 && nonopt_end == -1) + nonopt_end = optind; + + /* + * If we have "-" do nothing, if "--" we are done. + */ + if (place[1] != '\0' && *++place == '-' && place[1] == '\0') { + optind++; + place = EMSG; + /* + * We found an option (--), so if we skipped + * non-options, we have to permute. + */ + if (nonopt_end != -1) { + permute_args(nonopt_start, nonopt_end, + optind, nargv); + optind -= nonopt_end - nonopt_start; + } + nonopt_start = nonopt_end = -1; + return (-1); + } + } + + /* + * Check long options if: + * 1) we were passed some + * 2) the arg is not just "-" + * 3) either the arg starts with -- we are getopt_long_only() + */ + if (long_options != NULL && place != nargv[optind] && + (*place == '-' || (flags & FLAG_LONGONLY))) { + short_too = 0; + if (*place == '-') + place++; /* --foo long option */ + else if (*place != ':' && strchr(options, *place) != NULL) + short_too = 1; /* could be short option too */ + + optchar = parse_long_options(nargv, options, long_options, + idx, short_too); + if (optchar != -1) { + place = EMSG; + return (optchar); + } + } + + if ((optchar = (int)*place++) == (int)':' || + (optchar == (int)'-' && *place != '\0') || + (oli = strchr(options, optchar)) == NULL) { + /* + * If the user specified "-" and '-' isn't listed in + * options, return -1 (non-option) as per POSIX. + * Otherwise, it is an unknown option character (or ':'). + */ + if (optchar == (int)'-' && *place == '\0') + return (-1); + if (!*place) + ++optind; + if (PRINT_ERROR) + fprintf(stderr, illoptchar, optchar); + optopt = optchar; + return (BADCH); + } + if (long_options != NULL && optchar == 'W' && oli[1] == ';') { + /* -W long-option */ + if (*place) /* no space */ + /* NOTHING */; + else if (++optind >= nargc) { /* no arg */ + place = EMSG; + if (PRINT_ERROR) + fprintf(stderr, recargchar, optchar); + optopt = optchar; + return (BADARG); + } else /* white space */ + place = nargv[optind]; + optchar = parse_long_options(nargv, options, long_options, + idx, 0); + place = EMSG; + return (optchar); + } + if (*++oli != ':') { /* doesn't take argument */ + if (!*place) + ++optind; + } else { /* takes (optional) argument */ + optarg = NULL; + if (*place) /* no white space */ + optarg = place; + else if (oli[1] != ':') { /* arg not optional */ + if (++optind >= nargc) { /* no arg */ + place = EMSG; + if (PRINT_ERROR) + fprintf(stderr, recargchar, optchar); + optopt = optchar; + return (BADARG); + } else + optarg = nargv[optind]; + } + place = EMSG; + ++optind; + } + /* dump back option letter */ + return (optchar); +} + +/* + * getopt -- + * Parse argc/argv argument vector. + * + * [eventually this will replace the BSD getopt] + */ +int +getopt(int nargc, char * const *nargv, const char *options) +{ + + /* + * We don't pass FLAG_PERMUTE to getopt_internal() since + * the BSD getopt(3) (unlike GNU) has never done this. + * + * Furthermore, since many privileged programs call getopt() + * before dropping privileges it makes sense to keep things + * as simple (and bug-free) as possible. + */ + return (getopt_internal(nargc, nargv, options, NULL, NULL, 0)); +} + +/* + * getopt_long -- + * Parse argc/argv argument vector. + */ +int +getopt_long(int nargc, char * const *nargv, const char *options, + const struct option *long_options, int *idx) +{ + + return (getopt_internal(nargc, nargv, options, long_options, idx, + FLAG_PERMUTE)); +} + +/* + * getopt_long_only -- + * Parse argc/argv argument vector. + */ +int +getopt_long_only(int nargc, char * const *nargv, const char *options, + const struct option *long_options, int *idx) +{ + + return (getopt_internal(nargc, nargv, options, long_options, idx, + FLAG_PERMUTE|FLAG_LONGONLY)); +} diff --git a/3rdparty/glsl-optimizer/src/glsl/.gitignore b/3rdparty/glsl-optimizer/src/glsl/.gitignore new file mode 100644 index 000000000..2013db6f5 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/.gitignore @@ -0,0 +1,4 @@ +glsl_compiler +glsl_parser.output +builtin_compiler +glsl_test diff --git a/3rdparty/glsl-optimizer/src/glsl/Makefile.template b/3rdparty/glsl-optimizer/src/glsl/Makefile.template new file mode 100644 index 000000000..974987a0a --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/Makefile.template @@ -0,0 +1,50 @@ +# src/glsl/Makefile.template + +# Template makefile for glsl libraries. +# +# Usage: +# The minimum that the including makefile needs to define +# is TOP, LIBNAME and one of of the *_SOURCES. +# +# Optional defines: +# LIBRARY_INCLUDES are appended to the list of includes directories. +# LIBRARY_DEFINES is not used for makedepend, but for compilation. + + +### Basic defines ### + +OBJECTS = $(C_SOURCES:.c=.o) + +INCLUDES = \ + -I. \ + $(LIBRARY_INCLUDES) + + +##### TARGETS ##### + +default: depend lib$(LIBNAME).a + +lib$(LIBNAME).a: $(OBJECTS) Makefile $(TOP)/src/glsl/Makefile.template + $(MKLIB) -o $(LIBNAME) -static $(OBJECTS) + +depend: $(C_SOURCES) + rm -f depend + touch depend + $(MKDEP) $(MKDEP_OPTIONS) $(INCLUDES) $(C_SOURCES) 2> /dev/null + +# Remove .o and backup files +clean: + rm -f $(OBJECTS) lib$(LIBNAME).a depend depend.bak + +# Dummy target +install: + @echo -n "" + + +##### RULES ##### + +.c.o: + $(CC) -c $(INCLUDES) $(CFLAGS) $(LIBRARY_DEFINES) $< -o $@ + +-include depend + diff --git a/3rdparty/glsl-optimizer/src/glsl/README b/3rdparty/glsl-optimizer/src/glsl/README new file mode 100644 index 000000000..dd80a53d4 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/README @@ -0,0 +1,229 @@ +Welcome to Mesa's GLSL compiler. A brief overview of how things flow: + +1) lex and yacc-based preprocessor takes the incoming shader string +and produces a new string containing the preprocessed shader. This +takes care of things like #if, #ifdef, #define, and preprocessor macro +invocations. Note that #version, #extension, and some others are +passed straight through. See glcpp/* + +2) lex and yacc-based parser takes the preprocessed string and +generates the AST (abstract syntax tree). Almost no checking is +performed in this stage. See glsl_lexer.lpp and glsl_parser.ypp. + +3) The AST is converted to "HIR". This is the intermediate +representation of the compiler. Constructors are generated, function +calls are resolved to particular function signatures, and all the +semantic checking is performed. See ast_*.cpp for the conversion, and +ir.h for the IR structures. + +4) The driver (Mesa, or main.cpp for the standalone binary) performs +optimizations. These include copy propagation, dead code elimination, +constant folding, and others. Generally the driver will call +optimizations in a loop, as each may open up opportunities for other +optimizations to do additional work. See most files called ir_*.cpp + +5) linking is performed. This does checking to ensure that the +outputs of the vertex shader match the inputs of the fragment shader, +and assigns locations to uniforms, attributes, and varyings. See +linker.cpp. + +6) The driver may perform additional optimization at this point, as +for example dead code elimination previously couldn't remove functions +or global variable usage when we didn't know what other code would be +linked in. + +7) The driver performs code generation out of the IR, taking a linked +shader program and producing a compiled program for each stage. See +ir_to_mesa.cpp for Mesa IR code generation. + +FAQ: + +Q: What is HIR versus IR versus LIR? + +A: The idea behind the naming was that ast_to_hir would produce a +high-level IR ("HIR"), with things like matrix operations, structure +assignments, etc., present. A series of lowering passes would occur +that do things like break matrix multiplication into a series of dot +products/MADs, make structure assignment be a series of assignment of +components, flatten if statements into conditional moves, and such, +producing a low level IR ("LIR"). + +However, it now appears that each driver will have different +requirements from a LIR. A 915-generation chipset wants all functions +inlined, all loops unrolled, all ifs flattened, no variable array +accesses, and matrix multiplication broken down. The Mesa IR backend +for swrast would like matrices and structure assignment broken down, +but it can support function calls and dynamic branching. A 965 vertex +shader IR backend could potentially even handle some matrix operations +without breaking them down, but the 965 fragment shader IR backend +would want to break to have (almost) all operations down channel-wise +and perform optimization on that. As a result, there's no single +low-level IR that will make everyone happy. So that usage has fallen +out of favor, and each driver will perform a series of lowering passes +to take the HIR down to whatever restrictions it wants to impose +before doing codegen. + +Q: How is the IR structured? + +A: The best way to get started seeing it would be to run the +standalone compiler against a shader: + +./glsl_compiler --dump-lir \ + ~/src/piglit/tests/shaders/glsl-orangebook-ch06-bump.frag + +So for example one of the ir_instructions in main() contains: + +(assign (constant bool (1)) (var_ref litColor) (expression vec3 * (var_ref Surf +aceColor) (var_ref __retval) ) ) + +Or more visually: + (assign) + / | \ + (var_ref) (expression *) (constant bool 1) + / / \ +(litColor) (var_ref) (var_ref) + / \ + (SurfaceColor) (__retval) + +which came from: + +litColor = SurfaceColor * max(dot(normDelta, LightDir), 0.0); + +(the max call is not represented in this expression tree, as it was a +function call that got inlined but not brought into this expression +tree) + +Each of those nodes is a subclass of ir_instruction. A particular +ir_instruction instance may only appear once in the whole IR tree with +the exception of ir_variables, which appear once as variable +declarations: + +(declare () vec3 normDelta) + +and multiple times as the targets of variable dereferences: +... +(assign (constant bool (1)) (var_ref __retval) (expression float dot + (var_ref normDelta) (var_ref LightDir) ) ) +... +(assign (constant bool (1)) (var_ref __retval) (expression vec3 - + (var_ref LightDir) (expression vec3 * (constant float (2.000000)) + (expression vec3 * (expression float dot (var_ref normDelta) (var_ref + LightDir) ) (var_ref normDelta) ) ) ) ) +... + +Each node has a type. Expressions may involve several different types: +(declare (uniform ) mat4 gl_ModelViewMatrix) +((assign (constant bool (1)) (var_ref constructor_tmp) (expression + vec4 * (var_ref gl_ModelViewMatrix) (var_ref gl_Vertex) ) ) + +An expression tree can be arbitrarily deep, and the compiler tries to +keep them structured like that so that things like algebraic +optimizations ((color * 1.0 == color) and ((mat1 * mat2) * vec == mat1 +* (mat2 * vec))) or recognizing operation patterns for code generation +(vec1 * vec2 + vec3 == mad(vec1, vec2, vec3)) are easier. This comes +at the expense of additional trickery in implementing some +optimizations like CSE where one must navigate an expression tree. + +Q: Why no SSA representation? + +A: Converting an IR tree to SSA form makes dead code elmimination, +common subexpression elimination, and many other optimizations much +easier. However, in our primarily vector-based language, there's some +major questions as to how it would work. Do we do SSA on the scalar +or vector level? If we do it at the vector level, we're going to end +up with many different versions of the variable when encountering code +like: + +(assign (constant bool (1)) (swiz x (var_ref __retval) ) (var_ref a) ) +(assign (constant bool (1)) (swiz y (var_ref __retval) ) (var_ref b) ) +(assign (constant bool (1)) (swiz z (var_ref __retval) ) (var_ref c) ) + +If every masked update of a component relies on the previous value of +the variable, then we're probably going to be quite limited in our +dead code elimination wins, and recognizing common expressions may +just not happen. On the other hand, if we operate channel-wise, then +we'll be prone to optimizing the operation on one of the channels at +the expense of making its instruction flow different from the other +channels, and a vector-based GPU would end up with worse code than if +we didn't optimize operations on that channel! + +Once again, it appears that our optimization requirements are driven +significantly by the target architecture. For now, targeting the Mesa +IR backend, SSA does not appear to be that important to producing +excellent code, but we do expect to do some SSA-based optimizations +for the 965 fragment shader backend when that is developed. + +Q: How should I expand instructions that take multiple backend instructions? + +Sometimes you'll have to do the expansion in your code generation -- +see, for example, ir_to_mesa.cpp's handling of ir_unop_sqrt. However, +in many cases you'll want to do a pass over the IR to convert +non-native instructions to a series of native instructions. For +example, for the Mesa backend we have ir_div_to_mul_rcp.cpp because +Mesa IR (and many hardware backends) only have a reciprocal +instruction, not a divide. Implementing non-native instructions this +way gives the chance for constant folding to occur, so (a / 2.0) +becomes (a * 0.5) after codegen instead of (a * (1.0 / 2.0)) + +Q: How shoud I handle my special hardware instructions with respect to IR? + +Our current theory is that if multiple targets have an instruction for +some operation, then we should probably be able to represent that in +the IR. Generally this is in the form of an ir_{bin,un}op expression +type. For example, we initially implemented fract() using (a - +floor(a)), but both 945 and 965 have instructions to give that result, +and it would also simplify the implementation of mod(), so +ir_unop_fract was added. The following areas need updating to add a +new expression type: + +ir.h (new enum) +ir.cpp:get_num_operands() (used for ir_reader) +ir.cpp:operator_strs (used for ir_reader) +ir_constant_expression.cpp (you probably want to be able to constant fold) +ir_validate.cpp (check users have the right types) + +You may also need to update the backends if they will see the new expr type: + +../mesa/shaders/ir_to_mesa.cpp + +You can then use the new expression from builtins (if all backends +would rather see it), or scan the IR and convert to use your new +expression type (see ir_mod_to_fract, for example). + +Q: How is memory management handled in the compiler? + +The hierarchical memory allocator "talloc" developed for the Samba +project is used, so that things like optimization passes don't have to +worry about their garbage collection so much. It has a few nice +features, including low performance overhead and good debugging +support that's trivially available. + +Generally, each stage of the compile creates a talloc context and +allocates its memory out of that or children of it. At the end of the +stage, the pieces still live are stolen to a new context and the old +one freed, or the whole context is kept for use by the next stage. + +For IR transformations, a temporary context is used, then at the end +of all transformations, reparent_ir reparents all live nodes under the +shader's IR list, and the old context full of dead nodes is freed. +When developing a single IR transformation pass, this means that you +want to allocate instruction nodes out of the temporary context, so if +it becomes dead it doesn't live on as the child of a live node. At +the moment, optimization passes aren't passed that temporary context, +so they find it by calling talloc_parent() on a nearby IR node. The +talloc_parent() call is expensive, so many passes will cache the +result of the first talloc_parent(). Cleaning up all the optimization +passes to take a context argument and not call talloc_parent() is left +as an exercise. + +Q: What is the file naming convention in this directory? + +Initially, there really wasn't one. We have since adopted one: + + - Files that implement code lowering passes should be named lower_* + (e.g., lower_noise.cpp). + - Files that implement optimization passes should be named opt_*. + - Files that implement a class that is used throught the code should + take the name of that class (e.g., ir_hierarchical_visitor.cpp). + - Files that contain code not fitting in one of the previous + categories should have a sensible name (e.g., glsl_parser.ypp). diff --git a/3rdparty/glsl-optimizer/src/glsl/SConscript b/3rdparty/glsl-optimizer/src/glsl/SConscript new file mode 100644 index 000000000..1da58a91f --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/SConscript @@ -0,0 +1,183 @@ +import common + +Import('*') + +from sys import executable as python_cmd + +env = env.Clone() + +env.Prepend(CPPPATH = [ + '#include', + '#src/mapi', + '#src/mesa', + '#src/glsl', + '#src/glsl/glcpp', +]) + +# Make glcpp/glcpp-parse.h and glsl_parser.h reacheable from the include path +env.Append(CPPPATH = [Dir('.').abspath]) + +env.Append(YACCFLAGS = '-d') + +parser_env = env.Clone() +parser_env.Append(YACCFLAGS = [ + '--defines=%s' % File('glsl_parser.h').abspath, + '-p', '_mesa_glsl_', +]) + +glcpp_lexer = env.CFile('glcpp/glcpp-lex.c', 'glcpp/glcpp-lex.l') +glcpp_parser = env.CFile('glcpp/glcpp-parse.c', 'glcpp/glcpp-parse.y') +glsl_lexer = parser_env.CXXFile('glsl_lexer.cpp', 'glsl_lexer.ll') +glsl_parser = parser_env.CXXFile('glsl_parser.cpp', 'glsl_parser.yy') + +glsl_sources = [ + glcpp_lexer, + glcpp_parser[0], + 'glcpp/pp.c', + 'ast_expr.cpp', + 'ast_function.cpp', + 'ast_to_hir.cpp', + 'ast_type.cpp', + glsl_lexer, + glsl_parser[0], + 'glsl_parser_extras.cpp', + 'glsl_types.cpp', + 'glsl_symbol_table.cpp', + 'hir_field_selection.cpp', + 'ir_basic_block.cpp', + 'ir_clone.cpp', + 'ir_constant_expression.cpp', + 'ir.cpp', + 'ir_expression_flattening.cpp', + 'ir_function_can_inline.cpp', + 'ir_function_detect_recursion.cpp', + 'ir_function.cpp', + 'ir_hierarchical_visitor.cpp', + 'ir_hv_accept.cpp', + 'ir_import_prototypes.cpp', + 'ir_print_visitor.cpp', + 'ir_reader.cpp', + 'ir_rvalue_visitor.cpp', + 'ir_set_program_inouts.cpp', + 'ir_validate.cpp', + 'ir_variable.cpp', + 'ir_variable_refcount.cpp', + 'linker.cpp', + 'link_functions.cpp', + 'loop_analysis.cpp', + 'loop_controls.cpp', + 'loop_unroll.cpp', + 'lower_discard.cpp', + 'lower_if_to_cond_assign.cpp', + 'lower_instructions.cpp', + 'lower_jumps.cpp', + 'lower_mat_op_to_vec.cpp', + 'lower_noise.cpp', + 'lower_variable_index_to_cond_assign.cpp', + 'lower_vec_index_to_cond_assign.cpp', + 'lower_vec_index_to_swizzle.cpp', + 'lower_vector.cpp', + 'opt_algebraic.cpp', + 'opt_constant_folding.cpp', + 'opt_constant_propagation.cpp', + 'opt_constant_variable.cpp', + 'opt_copy_propagation.cpp', + 'opt_copy_propagation_elements.cpp', + 'opt_dead_code.cpp', + 'opt_dead_code_local.cpp', + 'opt_dead_functions.cpp', + 'opt_discard_simplification.cpp', + 'opt_function_inlining.cpp', + 'opt_if_simplification.cpp', + 'opt_noop_swizzle.cpp', + 'opt_redundant_jumps.cpp', + 'opt_structure_splitting.cpp', + 'opt_swizzle_swizzle.cpp', + 'opt_tree_grafting.cpp', + 'ralloc.c', + 's_expression.cpp', + 'standalone_scaffolding.cpp', + 'strtod.c', +] + +if env['msvc']: + env.Prepend(CPPPATH = ['#/src/getopt']) + env.PrependUnique(LIBS = [getopt]) + +if env['crosscompile'] and not env['embedded']: + Import('builtin_glsl_function') +else: + # Copy these files to avoid generation object files into src/mesa/program + env.Prepend(CPPPATH = ['#src/mesa/program']) + env.Command('hash_table.c', '#src/mesa/program/hash_table.c', Copy('$TARGET', '$SOURCE')) + env.Command('symbol_table.c', '#src/mesa/program/symbol_table.c', Copy('$TARGET', '$SOURCE')) + + main_obj = env.StaticObject('main.cpp') + + mesa_objs = env.StaticObject([ + 'hash_table.c', + 'symbol_table.c', + ]) + + builtin_compiler = env.Program( + target = 'builtin_compiler', + source = main_obj + glsl_sources + ['builtin_stubs.cpp'] + mesa_objs, + ) + + # SCons builtin dependency scanner doesn't detect that glsl_lexer.ll + # depends on glsl_parser.h + env.Depends(builtin_compiler, glsl_parser) + + builtin_glsl_function = env.CodeGenerate( + target = 'builtin_function.cpp', + script = 'builtins/tools/generate_builtins.py', + source = builtin_compiler, + command = python_cmd + ' $SCRIPT $SOURCE > $TARGET' + ) + + env.Depends(builtin_glsl_function, ['builtins/tools/generate_builtins.py', 'builtins/tools/texture_builtins.py'] + Glob('builtins/ir/*')) + + Export('builtin_glsl_function') + + if env['hostonly']: + Return() + + +glsl_sources += builtin_glsl_function + +glsl = env.ConvenienceLibrary( + target = 'glsl', + source = glsl_sources, +) + +# SCons builtin dependency scanner doesn't detect that glsl_lexer.ll depends on +# glsl_parser.h +env.Depends(glsl, glsl_parser) + +Export('glsl') + +# Skip building these programs as they will cause SCons error "Two environments +# with different actions were specified for the same target" +if env['crosscompile'] or env['embedded']: + Return() + +env = env.Clone() + +if env['platform'] == 'windows': + env.PrependUnique(LIBS = [ + 'user32', + ]) + +env.Prepend(LIBS = [glsl]) + +glsl2 = env.Program( + target = 'glsl2', + source = main_obj + mesa_objs, +) +env.Alias('glsl2', glsl2) + +glcpp = env.Program( + target = 'glcpp/glcpp', + source = ['glcpp/glcpp.c'] + mesa_objs, +) +env.Alias('glcpp', glcpp) diff --git a/3rdparty/glsl-optimizer/src/glsl/TODO b/3rdparty/glsl-optimizer/src/glsl/TODO new file mode 100644 index 000000000..c99d7e152 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/TODO @@ -0,0 +1,27 @@ +- Detect code paths in non-void functions that don't reach a return statement + +- Improve handling of constants and their initializers. Constant initializers + should never generate any code. This is trival for scalar constants. It is + also trivial for arrays, matrices, and vectors that are accessed with + constant index values. For others it is more complicated. Perhaps these + cases should be silently converted to uniforms? + +- Implement support for ir_binop_dot in ir_algebraic.cpp. Perform + transformations such as "dot(v, vec3(0.0, 1.0, 0.0))" -> v.y. + +- Track source locations throughout the IR. There are currently several + places where we cannot emit line numbers for errors (and currently emit 0:0) + because we've "lost" the line number information. This is particularly + noticeable at link time. + +1.30 features: + +- Implement AST-to-HIR conversion of switch-statements + - switch + - case + - Update break to correcly handle mixed nexting of switch-statements + and loops. + +- Implement support for gl_ClipDistance. This is non-trivial because + gl_ClipDistance is exposed as a float[8], but all hardware actually + implements it as vec4[2]. \ No newline at end of file diff --git a/3rdparty/glsl-optimizer/src/glsl/ast.h b/3rdparty/glsl-optimizer/src/glsl/ast.h new file mode 100644 index 000000000..52226d6f4 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/ast.h @@ -0,0 +1,744 @@ +/* -*- c++ -*- */ +/* + * Copyright © 2009 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#pragma once +#ifndef AST_H +#define AST_H + +#include "list.h" +#include "glsl_parser_extras.h" + +struct _mesa_glsl_parse_state; + +struct YYLTYPE; + +/** + * \defgroup AST Abstract syntax tree node definitions + * + * An abstract syntax tree is generated by the parser. This is a fairly + * direct representation of the gramma derivation for the source program. + * No symantic checking is done during the generation of the AST. Only + * syntactic checking is done. Symantic checking is performed by a later + * stage that converts the AST to a more generic intermediate representation. + * + *@{ + */ +/** + * Base class of all abstract syntax tree nodes + */ +class ast_node { +public: + /* Callers of this ralloc-based new need not call delete. It's + * easier to just ralloc_free 'ctx' (or any of its ancestors). */ + static void* operator new(size_t size, void *ctx) + { + void *node; + + node = rzalloc_size(ctx, size); + assert(node != NULL); + + return node; + } + + /* If the user *does* call delete, that's OK, we will just + * ralloc_free in that case. */ + static void operator delete(void *table) + { + ralloc_free(table); + } + + /** + * Print an AST node in something approximating the original GLSL code + */ + virtual void print(void) const; + + /** + * Convert the AST node to the high-level intermediate representation + */ + virtual ir_rvalue *hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state); + + /** + * Retrieve the source location of an AST node + * + * This function is primarily used to get the source position of an AST node + * into a form that can be passed to \c _mesa_glsl_error. + * + * \sa _mesa_glsl_error, ast_node::set_location + */ + struct YYLTYPE get_location(void) const + { + struct YYLTYPE locp; + + locp.source = this->location.source; + locp.first_line = this->location.line; + locp.first_column = this->location.column; + locp.last_line = locp.first_line; + locp.last_column = locp.first_column; + + return locp; + } + + /** + * Set the source location of an AST node from a parser location + * + * \sa ast_node::get_location + */ + void set_location(const struct YYLTYPE &locp) + { + this->location.source = locp.source; + this->location.line = locp.first_line; + this->location.column = locp.first_column; + } + + /** + * Source location of the AST node. + */ + struct { + unsigned source; /**< GLSL source number. */ + unsigned line; /**< Line number within the source string. */ + unsigned column; /**< Column in the line. */ + } location; + + exec_node link; + +protected: + /** + * The only constructor is protected so that only derived class objects can + * be created. + */ + ast_node(void); +}; + + +/** + * Operators for AST expression nodes. + */ +enum ast_operators { + ast_assign, + ast_plus, /**< Unary + operator. */ + ast_neg, + ast_add, + ast_sub, + ast_mul, + ast_div, + ast_mod, + ast_lshift, + ast_rshift, + ast_less, + ast_greater, + ast_lequal, + ast_gequal, + ast_equal, + ast_nequal, + ast_bit_and, + ast_bit_xor, + ast_bit_or, + ast_bit_not, + ast_logic_and, + ast_logic_xor, + ast_logic_or, + ast_logic_not, + + ast_mul_assign, + ast_div_assign, + ast_mod_assign, + ast_add_assign, + ast_sub_assign, + ast_ls_assign, + ast_rs_assign, + ast_and_assign, + ast_xor_assign, + ast_or_assign, + + ast_conditional, + + ast_pre_inc, + ast_pre_dec, + ast_post_inc, + ast_post_dec, + ast_field_selection, + ast_array_index, + + ast_function_call, + + ast_identifier, + ast_int_constant, + ast_uint_constant, + ast_float_constant, + ast_bool_constant, + + ast_sequence +}; + +/** + * Representation of any sort of expression. + */ +class ast_expression : public ast_node { +public: + ast_expression(int oper, ast_expression *, + ast_expression *, ast_expression *); + + ast_expression(const char *identifier) : + oper(ast_identifier) + { + subexpressions[0] = NULL; + subexpressions[1] = NULL; + subexpressions[2] = NULL; + primary_expression.identifier = (char *) identifier; + } + + static const char *operator_string(enum ast_operators op); + + virtual ir_rvalue *hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state); + + virtual void print(void) const; + + enum ast_operators oper; + + ast_expression *subexpressions[3]; + + union { + char *identifier; + int int_constant; + float float_constant; + unsigned uint_constant; + int bool_constant; + } primary_expression; + + + /** + * List of expressions for an \c ast_sequence or parameters for an + * \c ast_function_call + */ + exec_list expressions; +}; + +class ast_expression_bin : public ast_expression { +public: + ast_expression_bin(int oper, ast_expression *, ast_expression *); + + virtual void print(void) const; +}; + +/** + * Subclass of expressions for function calls + */ +class ast_function_expression : public ast_expression { +public: + ast_function_expression(ast_expression *callee) + : ast_expression(ast_function_call, callee, + NULL, NULL), + cons(false) + { + /* empty */ + } + + ast_function_expression(class ast_type_specifier *type) + : ast_expression(ast_function_call, (ast_expression *) type, + NULL, NULL), + cons(true) + { + /* empty */ + } + + bool is_constructor() const + { + return cons; + } + + virtual ir_rvalue *hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state); + +private: + /** + * Is this function call actually a constructor? + */ + bool cons; +}; + + +/** + * Number of possible operators for an ast_expression + * + * This is done as a define instead of as an additional value in the enum so + * that the compiler won't generate spurious messages like "warning: + * enumeration value ‘ast_num_operators’ not handled in switch" + */ +#define AST_NUM_OPERATORS (ast_sequence + 1) + + +class ast_compound_statement : public ast_node { +public: + ast_compound_statement(int new_scope, ast_node *statements); + virtual void print(void) const; + + virtual ir_rvalue *hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state); + + int new_scope; + exec_list statements; +}; + +class ast_declaration : public ast_node { +public: + ast_declaration(char *identifier, int is_array, ast_expression *array_size, + ast_expression *initializer); + virtual void print(void) const; + + char *identifier; + + int is_array; + ast_expression *array_size; + + ast_expression *initializer; +}; + + +enum { + ast_precision_high = 0, + ast_precision_medium, + ast_precision_low, + ast_precision_none, /**< Absence of precision qualifier. */ +}; + +struct ast_type_qualifier { + union { + struct { + unsigned invariant:1; + unsigned constant:1; + unsigned attribute:1; + unsigned varying:1; + unsigned in:1; + unsigned out:1; + unsigned centroid:1; + unsigned uniform:1; + unsigned smooth:1; + unsigned flat:1; + unsigned noperspective:1; + + /** \name Layout qualifiers for GL_ARB_fragment_coord_conventions */ + /*@{*/ + unsigned origin_upper_left:1; + unsigned pixel_center_integer:1; + /*@}*/ + + /** + * Flag set if GL_ARB_explicit_attrib_location "location" layout + * qualifier is used. + */ + unsigned explicit_location:1; + + /** \name Layout qualifiers for GL_AMD_conservative_depth */ + /** \{ */ + unsigned depth_any:1; + unsigned depth_greater:1; + unsigned depth_less:1; + unsigned depth_unchanged:1; + /** \} */ + } + /** \brief Set of flags, accessed by name. */ + q; + + /** \brief Set of flags, accessed as a bitmask. */ + unsigned i; + } flags; + + /** + * Location specified via GL_ARB_explicit_attrib_location layout + * + * \note + * This field is only valid if \c explicit_location is set. + */ + unsigned location; + + /** + * Return true if and only if an interpolation qualifier is present. + */ + bool has_interpolation() const; + + /** + * \brief Return string representation of interpolation qualifier. + * + * If an interpolation qualifier is present, then return that qualifier's + * string representation. Otherwise, return null. For example, if the + * noperspective bit is set, then this returns "noperspective". + * + * If multiple interpolation qualifiers are somehow present, then the + * returned string is undefined but not null. + */ + const char *interpolation_string() const; +}; + +class ast_struct_specifier : public ast_node { +public: + ast_struct_specifier(char *identifier, ast_node *declarator_list); + virtual void print(void) const; + + virtual ir_rvalue *hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state); + + char *name; + exec_list declarations; +}; + + +enum ast_types { + ast_void, + ast_float, + ast_int, + ast_uint, + ast_bool, + ast_vec2, + ast_vec3, + ast_vec4, + ast_bvec2, + ast_bvec3, + ast_bvec4, + ast_ivec2, + ast_ivec3, + ast_ivec4, + ast_uvec2, + ast_uvec3, + ast_uvec4, + ast_mat2, + ast_mat2x3, + ast_mat2x4, + ast_mat3x2, + ast_mat3, + ast_mat3x4, + ast_mat4x2, + ast_mat4x3, + ast_mat4, + ast_sampler1d, + ast_sampler2d, + ast_sampler2drect, + ast_sampler3d, + ast_samplercube, + ast_sampler1dshadow, + ast_sampler2dshadow, + ast_sampler2drectshadow, + ast_samplercubeshadow, + ast_sampler1darray, + ast_sampler2darray, + ast_sampler1darrayshadow, + ast_sampler2darrayshadow, + ast_isampler1d, + ast_isampler2d, + ast_isampler3d, + ast_isamplercube, + ast_isampler1darray, + ast_isampler2darray, + ast_usampler1d, + ast_usampler2d, + ast_usampler3d, + ast_usamplercube, + ast_usampler1darray, + ast_usampler2darray, + + ast_struct, + ast_type_name +}; + + +class ast_type_specifier : public ast_node { +public: + ast_type_specifier(int specifier); + + /** Construct a type specifier from a type name */ + ast_type_specifier(const char *name) + : type_specifier(ast_type_name), type_name(name), structure(NULL), + is_array(false), array_size(NULL), precision(ast_precision_none), + is_precision_statement(false) + { + /* empty */ + } + + /** Construct a type specifier from a structure definition */ + ast_type_specifier(ast_struct_specifier *s) + : type_specifier(ast_struct), type_name(s->name), structure(s), + is_array(false), array_size(NULL), precision(ast_precision_none), + is_precision_statement(false) + { + /* empty */ + } + + const struct glsl_type *glsl_type(const char **name, + struct _mesa_glsl_parse_state *state) + const; + + virtual void print(void) const; + + ir_rvalue *hir(exec_list *, struct _mesa_glsl_parse_state *); + + enum ast_types type_specifier; + + const char *type_name; + ast_struct_specifier *structure; + + int is_array; + ast_expression *array_size; + + unsigned precision:2; + + bool is_precision_statement; +}; + + +class ast_fully_specified_type : public ast_node { +public: + ast_fully_specified_type () + { + union { + ast_type_qualifier q; + unsigned i; + } q; + q.i = 0; + qualifier = q.q; + } + virtual void print(void) const; + bool has_qualifiers() const; + + ast_type_qualifier qualifier; + ast_type_specifier *specifier; +}; + + +class ast_declarator_list : public ast_node { +public: + ast_declarator_list(ast_fully_specified_type *); + virtual void print(void) const; + + virtual ir_rvalue *hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state); + + ast_fully_specified_type *type; + exec_list declarations; + + /** + * Special flag for vertex shader "invariant" declarations. + * + * Vertex shaders can contain "invariant" variable redeclarations that do + * not include a type. For example, "invariant gl_Position;". This flag + * is used to note these cases when no type is specified. + */ + int invariant; +}; + + +class ast_parameter_declarator : public ast_node { +public: + ast_parameter_declarator() + { + this->identifier = NULL; + this->is_array = false; + this->array_size = 0; + } + + virtual void print(void) const; + + virtual ir_rvalue *hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state); + + ast_fully_specified_type *type; + char *identifier; + int is_array; + ast_expression *array_size; + + static void parameters_to_hir(exec_list *ast_parameters, + bool formal, exec_list *ir_parameters, + struct _mesa_glsl_parse_state *state); + +private: + /** Is this parameter declaration part of a formal parameter list? */ + bool formal_parameter; + + /** + * Is this parameter 'void' type? + * + * This field is set by \c ::hir. + */ + bool is_void; +}; + + +class ast_function : public ast_node { +public: + ast_function(void); + + virtual void print(void) const; + + virtual ir_rvalue *hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state); + + ast_fully_specified_type *return_type; + char *identifier; + + exec_list parameters; + +private: + /** + * Is this prototype part of the function definition? + * + * Used by ast_function_definition::hir to process the parameters, etc. + * of the function. + * + * \sa ::hir + */ + bool is_definition; + + /** + * Function signature corresponding to this function prototype instance + * + * Used by ast_function_definition::hir to process the parameters, etc. + * of the function. + * + * \sa ::hir + */ + class ir_function_signature *signature; + + friend class ast_function_definition; +}; + + +class ast_expression_statement : public ast_node { +public: + ast_expression_statement(ast_expression *); + virtual void print(void) const; + + virtual ir_rvalue *hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state); + + ast_expression *expression; +}; + + +class ast_case_label : public ast_node { +public: + + /** + * An expression of NULL means 'default'. + */ + ast_expression *expression; +}; + +class ast_selection_statement : public ast_node { +public: + ast_selection_statement(ast_expression *condition, + ast_node *then_statement, + ast_node *else_statement); + virtual void print(void) const; + + virtual ir_rvalue *hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state); + + ast_expression *condition; + ast_node *then_statement; + ast_node *else_statement; +}; + + +class ast_switch_statement : public ast_node { +public: + ast_expression *expression; + exec_list statements; +}; + +class ast_iteration_statement : public ast_node { +public: + ast_iteration_statement(int mode, ast_node *init, ast_node *condition, + ast_expression *rest_expression, ast_node *body); + + virtual void print(void) const; + + virtual ir_rvalue *hir(exec_list *, struct _mesa_glsl_parse_state *); + + enum ast_iteration_modes { + ast_for, + ast_while, + ast_do_while + } mode; + + + ast_node *init_statement; + ast_node *condition; + ast_expression *rest_expression; + + ast_node *body; + +private: + /** + * Generate IR from the condition of a loop + * + * This is factored out of ::hir because some loops have the condition + * test at the top (for and while), and others have it at the end (do-while). + */ + void condition_to_hir(class ir_loop *, struct _mesa_glsl_parse_state *); +}; + + +class ast_jump_statement : public ast_node { +public: + ast_jump_statement(int mode, ast_expression *return_value); + virtual void print(void) const; + + virtual ir_rvalue *hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state); + + enum ast_jump_modes { + ast_continue, + ast_break, + ast_return, + ast_discard + } mode; + + ast_expression *opt_return_value; +}; + + +class ast_function_definition : public ast_node { +public: + virtual void print(void) const; + + virtual ir_rvalue *hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state); + + ast_function *prototype; + ast_compound_statement *body; +}; +/*@}*/ + +extern void +_mesa_ast_to_hir(exec_list *instructions, struct _mesa_glsl_parse_state *state); + +extern ir_rvalue * +_mesa_ast_field_selection_to_hir(const ast_expression *expr, + exec_list *instructions, + struct _mesa_glsl_parse_state *state); + +void +emit_function(_mesa_glsl_parse_state *state, ir_function *f); + +#endif /* AST_H */ diff --git a/3rdparty/glsl-optimizer/src/glsl/ast_expr.cpp b/3rdparty/glsl-optimizer/src/glsl/ast_expr.cpp new file mode 100644 index 000000000..e624d11cf --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/ast_expr.cpp @@ -0,0 +1,95 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +#include +#include "ast.h" + +const char * +ast_expression::operator_string(enum ast_operators op) +{ + static const char *const operators[] = { + "=", + "+", + "-", + "+", + "-", + "*", + "/", + "%", + "<<", + ">>", + "<", + ">", + "<=", + ">=", + "==", + "!=", + "&", + "^", + "|", + "~", + "&&", + "^^", + "||", + "!", + + "*=", + "/=", + "%=", + "+=", + "-=", + "<<=", + ">>=", + "&=", + "^=", + "|=", + + "?:", + + "++", + "--", + "++", + "--", + ".", + }; + + assert((unsigned int)op < sizeof(operators) / sizeof(operators[0])); + + return operators[op]; +} + + +ast_expression_bin::ast_expression_bin(int oper, ast_expression *ex0, + ast_expression *ex1) : + ast_expression(oper, ex0, ex1, NULL) +{ + assert((oper >= ast_plus) && (oper <= ast_logic_not)); +} + + +void +ast_expression_bin::print(void) const +{ + subexpressions[0]->print(); + printf("%s ", operator_string(oper)); + subexpressions[1]->print(); +} diff --git a/3rdparty/glsl-optimizer/src/glsl/ast_function.cpp b/3rdparty/glsl-optimizer/src/glsl/ast_function.cpp new file mode 100644 index 000000000..3647e7cc9 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/ast_function.cpp @@ -0,0 +1,1447 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include "glsl_symbol_table.h" +#include "ast.h" +#include "glsl_types.h" +#include "ir.h" +#include "main/core.h" /* for MIN2 */ + +static ir_rvalue * +convert_component(ir_rvalue *src, const glsl_type *desired_type); + +bool +apply_implicit_conversion(const glsl_type *to, ir_rvalue * &from, + struct _mesa_glsl_parse_state *state); + +static unsigned +process_parameters(exec_list *instructions, exec_list *actual_parameters, + exec_list *parameters, + struct _mesa_glsl_parse_state *state) +{ + unsigned count = 0; + + foreach_list (n, parameters) { + ast_node *const ast = exec_node_data(ast_node, n, link); + ir_rvalue *result = ast->hir(instructions, state); + + ir_constant *const constant = result->constant_expression_value(); + if (constant != NULL) + result = constant; + + actual_parameters->push_tail(result); + count++; + } + + return count; +} + + +/** + * Generate a source prototype for a function signature + * + * \param return_type Return type of the function. May be \c NULL. + * \param name Name of the function. + * \param parameters List of \c ir_instruction nodes representing the + * parameter list for the function. This may be either a + * formal (\c ir_variable) or actual (\c ir_rvalue) + * parameter list. Only the type is used. + * + * \return + * A ralloced string representing the prototype of the function. + */ +char * +prototype_string(const glsl_type *return_type, const char *name, + exec_list *parameters) +{ + char *str = NULL; + + if (return_type != NULL) + str = ralloc_asprintf(NULL, "%s ", return_type->name); + + ralloc_asprintf_append(&str, "%s(", name); + + const char *comma = ""; + foreach_list(node, parameters) { + const ir_instruction *const param = (ir_instruction *) node; + + ralloc_asprintf_append(&str, "%s%s", comma, param->type->name); + comma = ", "; + } + + ralloc_strcat(&str, ")"); + return str; +} + +static glsl_precision precision_from_call (const ir_function_signature* sig, glsl_precision max_prec, glsl_precision first_prec) +{ + if (sig->precision != glsl_precision_undefined) + return sig->precision; + + // if return type is boolean, treat as lowp + if (sig->return_type->base_type == GLSL_TYPE_BOOL) + return glsl_precision_low; + + // if it's a built-in texture function, precision comes from sampler (1st param) precision + if (sig->is_builtin) + { + if (strncmp (sig->function_name(), "texture", 7) == 0) + return first_prec; + + } + + // other built-in: max precision of parameters + if (sig->is_builtin) + return max_prec; + + // otherwise: undefined + return glsl_precision_undefined; +} + + +static ir_rvalue * +match_function_by_name(exec_list *instructions, const char *name, + YYLTYPE *loc, exec_list *actual_parameters, + struct _mesa_glsl_parse_state *state) +{ + void *ctx = state; + ir_function *f = state->symbols->get_function(name); + ir_function_signature *sig; + + sig = f ? f->matching_signature(actual_parameters) : NULL; + + /* FINISHME: This doesn't handle the case where shader X contains a + * FINISHME: matching signature but shader X + N contains an _exact_ + * FINISHME: matching signature. + */ + if (sig == NULL + && (f == NULL || state->es_shader || !f->has_user_signature()) + && state->symbols->get_type(name) == NULL + && (state->language_version == 110 + || state->symbols->get_variable(name) == NULL)) { + /* The current shader doesn't contain a matching function or signature. + * Before giving up, look for the prototype in the built-in functions. + */ + for (unsigned i = 0; i < state->num_builtins_to_link; i++) { + ir_function *builtin; + builtin = state->builtins_to_link[i]->symbols->get_function(name); + sig = builtin ? builtin->matching_signature(actual_parameters) : NULL; + if (sig != NULL) { + if (f == NULL) { + f = new(ctx) ir_function(name); + state->symbols->add_global_function(f); + emit_function(state, f); + } + + f->add_signature(sig->clone_prototype(f, NULL)); + break; + } + } + } + + glsl_precision prec_params_max = glsl_precision_undefined; + glsl_precision prec_params_first = glsl_precision_undefined; + int params_counter = 0; + exec_list post_call_conversions; + + if (sig != NULL) { + /* Verify that 'out' and 'inout' actual parameters are lvalues. This + * isn't done in ir_function::matching_signature because that function + * cannot generate the necessary diagnostics. + * + * Also, validate that 'const_in' formal parameters (an extension of our + * IR) correspond to ir_constant actual parameters. + * + * Also, perform implicit conversion of arguments. Note: to implicitly + * convert out parameters, we need to place them in a temporary + * variable, and do the conversion after the call takes place. Since we + * haven't emitted the call yet, we'll place the post-call conversions + * in a temporary exec_list, and emit them later. + */ + exec_list_iterator actual_iter = actual_parameters->iterator(); + exec_list_iterator formal_iter = sig->parameters.iterator(); + + while (actual_iter.has_next()) { + ir_rvalue *actual = (ir_rvalue *) actual_iter.get(); + ir_variable *formal = (ir_variable *) formal_iter.get(); + + assert(actual != NULL); + assert(formal != NULL); + + glsl_precision param_prec = (glsl_precision)formal->precision; + if (param_prec == glsl_precision_undefined) + param_prec = actual->get_precision(); + prec_params_max = higher_precision (prec_params_max, param_prec); + if (params_counter == 0) + prec_params_first = param_prec; + + if (formal->mode == ir_var_const_in && !actual->as_constant()) { + _mesa_glsl_error(loc, state, + "parameter `%s' must be a constant expression", + formal->name); + } + + if ((formal->mode == ir_var_out) + || (formal->mode == ir_var_inout)) { + const char *mode = NULL; + switch (formal->mode) { + case ir_var_out: mode = "out"; break; + case ir_var_inout: mode = "inout"; break; + default: assert(false); break; + } + /* FIXME: 'loc' is incorrect (as of 2011-01-21). It is always + * FIXME: 0:0(0). + */ + if (actual->variable_referenced() + && actual->variable_referenced()->read_only) { + _mesa_glsl_error(loc, state, + "function parameter '%s %s' references the " + "read-only variable '%s'", + mode, formal->name, + actual->variable_referenced()->name); + + } else if (!actual->is_lvalue()) { + _mesa_glsl_error(loc, state, + "function parameter '%s %s' is not an lvalue", + mode, formal->name); + } + } + + if (formal->type->is_numeric() || formal->type->is_boolean()) { + switch (formal->mode) { + case ir_var_in: { + ir_rvalue *converted + = convert_component(actual, formal->type); + actual->replace_with(converted); + break; + } + case ir_var_out: + if (actual->type != formal->type) { + /* To convert an out parameter, we need to create a + * temporary variable to hold the value before conversion, + * and then perform the conversion after the function call + * returns. + * + * This has the effect of transforming code like this: + * + * void f(out int x); + * float value; + * f(value); + * + * Into IR that's equivalent to this: + * + * void f(out int x); + * float value; + * int out_parameter_conversion; + * f(out_parameter_conversion); + * value = float(out_parameter_conversion); + */ + ir_variable *tmp = + new(ctx) ir_variable(formal->type, + "out_parameter_conversion", + ir_var_temporary, (glsl_precision)formal->precision); + instructions->push_tail(tmp); + ir_dereference_variable *deref_tmp_1 + = new(ctx) ir_dereference_variable(tmp); + ir_dereference_variable *deref_tmp_2 + = new(ctx) ir_dereference_variable(tmp); + ir_rvalue *converted_tmp + = convert_component(deref_tmp_1, actual->type); + ir_assignment *assignment + = new(ctx) ir_assignment(actual, converted_tmp); + post_call_conversions.push_tail(assignment); + actual->replace_with(deref_tmp_2); + } + break; + case ir_var_inout: + /* Inout parameters should never require conversion, since that + * would require an implicit conversion to exist both to and + * from the formal parameter type, and there are no + * bidirectional implicit conversions. + */ + assert (actual->type == formal->type); + break; + default: + assert (!"Illegal formal parameter mode"); + break; + } + } + + actual_iter.next(); + formal_iter.next(); + ++params_counter; + } + + glsl_precision call_prec = precision_from_call(sig, prec_params_max, prec_params_first); + + /* Always insert the call in the instruction stream, and return a deref + * of its return val if it returns a value, since we don't know if + * the rvalue is going to be assigned to anything or not. + * + * Also insert any out parameter conversions after the call. + */ + ir_call *call = new(ctx) ir_call(sig, actual_parameters); + ir_dereference_variable *deref; + if (!sig->return_type->is_void()) { + /* If the function call is a constant expression, don't + * generate the instructions to call it; just generate an + * ir_constant representing the constant value. + * + * Function calls can only be constant expressions starting + * in GLSL 1.20. + */ + if (state->language_version >= 120) { + ir_constant *const_val = call->constant_expression_value(); + if (const_val) { + return const_val; + } + } + + ir_variable *var; + + var = new(ctx) ir_variable(sig->return_type, + ralloc_asprintf(ctx, "%s_retval", + sig->function_name()), + ir_var_temporary, call_prec); + instructions->push_tail(var); + call->set_precision (call_prec); + + deref = new(ctx) ir_dereference_variable(var); + ir_assignment *assign = new(ctx) ir_assignment(deref, call, NULL); + instructions->push_tail(assign); + + deref = new(ctx) ir_dereference_variable(var); + } else { + instructions->push_tail(call); + deref = NULL; + } + instructions->append_list(&post_call_conversions); + return deref; + } else { + char *str = prototype_string(NULL, name, actual_parameters); + + _mesa_glsl_error(loc, state, "no matching function for call to `%s'", + str); + ralloc_free(str); + + const char *prefix = "candidates are: "; + + for (int i = -1; i < (int) state->num_builtins_to_link; i++) { + glsl_symbol_table *syms = i >= 0 ? state->builtins_to_link[i]->symbols + : state->symbols; + f = syms->get_function(name); + if (f == NULL) + continue; + + foreach_list (node, &f->signatures) { + ir_function_signature *sig = (ir_function_signature *) node; + + str = prototype_string(sig->return_type, f->name, &sig->parameters); + _mesa_glsl_error(loc, state, "%s%s", prefix, str); + ralloc_free(str); + + prefix = " "; + } + + } + + return ir_call::get_error_instruction(ctx); + } +} + + +/** + * Perform automatic type conversion of constructor parameters + * + * This implements the rules in the "Conversion and Scalar Constructors" + * section (GLSL 1.10 section 5.4.1), not the "Implicit Conversions" rules. + */ +static ir_rvalue * +convert_component(ir_rvalue *src, const glsl_type *desired_type) +{ + void *ctx = ralloc_parent(src); + const unsigned a = desired_type->base_type; + const unsigned b = src->type->base_type; + ir_expression *result = NULL; + + if (src->type->is_error()) + return src; + + assert(a <= GLSL_TYPE_BOOL); + assert(b <= GLSL_TYPE_BOOL); + + if (a == b) + return src; + + switch (a) { + case GLSL_TYPE_UINT: + switch (b) { + case GLSL_TYPE_INT: + result = new(ctx) ir_expression(ir_unop_i2u, src); + break; + case GLSL_TYPE_FLOAT: + result = new(ctx) ir_expression(ir_unop_i2u, + new(ctx) ir_expression(ir_unop_f2i, src)); + break; + case GLSL_TYPE_BOOL: + result = new(ctx) ir_expression(ir_unop_i2u, + new(ctx) ir_expression(ir_unop_b2i, src)); + break; + } + break; + case GLSL_TYPE_INT: + switch (b) { + case GLSL_TYPE_UINT: + result = new(ctx) ir_expression(ir_unop_u2i, src); + break; + case GLSL_TYPE_FLOAT: + result = new(ctx) ir_expression(ir_unop_f2i, src); + break; + case GLSL_TYPE_BOOL: + result = new(ctx) ir_expression(ir_unop_b2i, src); + break; + } + break; + case GLSL_TYPE_FLOAT: + switch (b) { + case GLSL_TYPE_UINT: + result = new(ctx) ir_expression(ir_unop_u2f, desired_type, src, NULL); + break; + case GLSL_TYPE_INT: + result = new(ctx) ir_expression(ir_unop_i2f, desired_type, src, NULL); + break; + case GLSL_TYPE_BOOL: + result = new(ctx) ir_expression(ir_unop_b2f, desired_type, src, NULL); + break; + } + break; + case GLSL_TYPE_BOOL: + switch (b) { + case GLSL_TYPE_UINT: + result = new(ctx) ir_expression(ir_unop_i2b, + new(ctx) ir_expression(ir_unop_u2i, src)); + break; + case GLSL_TYPE_INT: + result = new(ctx) ir_expression(ir_unop_i2b, desired_type, src, NULL); + break; + case GLSL_TYPE_FLOAT: + result = new(ctx) ir_expression(ir_unop_f2b, desired_type, src, NULL); + break; + } + break; + } + + assert(result != NULL); + assert(result->type == desired_type); + + /* Try constant folding; it may fold in the conversion we just added. */ + ir_constant *const constant = result->constant_expression_value(); + return (constant != NULL) ? (ir_rvalue *) constant : (ir_rvalue *) result; +} + +/** + * Dereference a specific component from a scalar, vector, or matrix + */ +static ir_rvalue * +dereference_component(ir_rvalue *src, unsigned component) +{ + void *ctx = ralloc_parent(src); + assert(component < src->type->components()); + + /* If the source is a constant, just create a new constant instead of a + * dereference of the existing constant. + */ + ir_constant *constant = src->as_constant(); + if (constant) + return new(ctx) ir_constant(constant, component); + + if (src->type->is_scalar()) { + return src; + } else if (src->type->is_vector()) { + return new(ctx) ir_swizzle(src, component, 0, 0, 0, 1); + } else { + assert(src->type->is_matrix()); + + /* Dereference a row of the matrix, then call this function again to get + * a specific element from that row. + */ + const int c = component / src->type->column_type()->vector_elements; + const int r = component % src->type->column_type()->vector_elements; + ir_constant *const col_index = new(ctx) ir_constant(c); + ir_dereference *const col = new(ctx) ir_dereference_array(src, col_index); + + col->type = src->type->column_type(); + + return dereference_component(col, r); + } + + assert(!"Should not get here."); + return NULL; +} + + +static ir_rvalue * +process_array_constructor(exec_list *instructions, + const glsl_type *constructor_type, + YYLTYPE *loc, exec_list *parameters, + struct _mesa_glsl_parse_state *state) +{ + void *ctx = state; + /* Array constructors come in two forms: sized and unsized. Sized array + * constructors look like 'vec4[2](a, b)', where 'a' and 'b' are vec4 + * variables. In this case the number of parameters must exactly match the + * specified size of the array. + * + * Unsized array constructors look like 'vec4[](a, b)', where 'a' and 'b' + * are vec4 variables. In this case the size of the array being constructed + * is determined by the number of parameters. + * + * From page 52 (page 58 of the PDF) of the GLSL 1.50 spec: + * + * "There must be exactly the same number of arguments as the size of + * the array being constructed. If no size is present in the + * constructor, then the array is explicitly sized to the number of + * arguments provided. The arguments are assigned in order, starting at + * element 0, to the elements of the constructed array. Each argument + * must be the same type as the element type of the array, or be a type + * that can be converted to the element type of the array according to + * Section 4.1.10 "Implicit Conversions."" + */ + exec_list actual_parameters; + const unsigned parameter_count = + process_parameters(instructions, &actual_parameters, parameters, state); + + if ((parameter_count == 0) + || ((constructor_type->length != 0) + && (constructor_type->length != parameter_count))) { + const unsigned min_param = (constructor_type->length == 0) + ? 1 : constructor_type->length; + + _mesa_glsl_error(loc, state, "array constructor must have %s %u " + "parameter%s", + (constructor_type->length != 0) ? "at least" : "exactly", + min_param, (min_param <= 1) ? "" : "s"); + return ir_call::get_error_instruction(ctx); + } + + if (constructor_type->length == 0) { + constructor_type = + glsl_type::get_array_instance(constructor_type->element_type(), + parameter_count); + assert(constructor_type != NULL); + assert(constructor_type->length == parameter_count); + } + + bool all_parameters_are_constant = true; + + /* Type cast each parameter and, if possible, fold constants. */ + foreach_list_safe(n, &actual_parameters) { + ir_rvalue *ir = (ir_rvalue *) n; + ir_rvalue *result = ir; + + /* Apply implicit conversions (not the scalar constructor rules!). See + * the spec quote above. */ + if (constructor_type->element_type()->is_float()) { + const glsl_type *desired_type = + glsl_type::get_instance(GLSL_TYPE_FLOAT, + ir->type->vector_elements, + ir->type->matrix_columns); + if (result->type->can_implicitly_convert_to(desired_type)) { + /* Even though convert_component() implements the constructor + * conversion rules (not the implicit conversion rules), its safe + * to use it here because we already checked that the implicit + * conversion is legal. + */ + result = convert_component(ir, desired_type); + } + } + + if (result->type != constructor_type->element_type()) { + _mesa_glsl_error(loc, state, "type error in array constructor: " + "expected: %s, found %s", + constructor_type->element_type()->name, + result->type->name); + } + + /* Attempt to convert the parameter to a constant valued expression. + * After doing so, track whether or not all the parameters to the + * constructor are trivially constant valued expressions. + */ + ir_rvalue *const constant = result->constant_expression_value(); + + if (constant != NULL) + result = constant; + else + all_parameters_are_constant = false; + + ir->replace_with(result); + } + + if (all_parameters_are_constant) + return new(ctx) ir_constant(constructor_type, &actual_parameters); + + ir_variable *var = new(ctx) ir_variable(constructor_type, "array_ctor", + ir_var_temporary, glsl_precision_undefined); ///@TODO + instructions->push_tail(var); + + int i = 0; + foreach_list(node, &actual_parameters) { + ir_rvalue *rhs = (ir_rvalue *) node; + ir_rvalue *lhs = new(ctx) ir_dereference_array(var, + new(ctx) ir_constant(i)); + + ir_instruction *assignment = new(ctx) ir_assignment(lhs, rhs, NULL); + instructions->push_tail(assignment); + + i++; + } + + return new(ctx) ir_dereference_variable(var); +} + + +/** + * Try to convert a record constructor to a constant expression + */ +static ir_constant * +constant_record_constructor(const glsl_type *constructor_type, + exec_list *parameters, void *mem_ctx) +{ + foreach_list(node, parameters) { + ir_constant *constant = ((ir_instruction *) node)->as_constant(); + if (constant == NULL) + return NULL; + node->replace_with(constant); + } + + return new(mem_ctx) ir_constant(constructor_type, parameters); +} + + +/** + * Determine if a list consists of a single scalar r-value + */ +bool +single_scalar_parameter(exec_list *parameters) +{ + const ir_rvalue *const p = (ir_rvalue *) parameters->head; + assert(((ir_rvalue *)p)->as_rvalue() != NULL); + + return (p->type->is_scalar() && p->next->is_tail_sentinel()); +} + + +/** + * Generate inline code for a vector constructor + * + * The generated constructor code will consist of a temporary variable + * declaration of the same type as the constructor. A sequence of assignments + * from constructor parameters to the temporary will follow. + * + * \return + * An \c ir_dereference_variable of the temprorary generated in the constructor + * body. + */ +ir_rvalue * +emit_inline_vector_constructor(const glsl_type *type, unsigned ast_precision, + exec_list *instructions, + exec_list *parameters, + void *ctx) +{ + assert(!parameters->is_empty()); + + ir_variable *var = new(ctx) ir_variable(type, "vec_ctor", ir_var_temporary, (glsl_precision)ast_precision); + instructions->push_tail(var); + + /* There are two kinds of vector constructors. + * + * - Construct a vector from a single scalar by replicating that scalar to + * all components of the vector. + * + * - Construct a vector from an arbirary combination of vectors and + * scalars. The components of the constructor parameters are assigned + * to the vector in order until the vector is full. + */ + const unsigned lhs_components = type->components(); + if (single_scalar_parameter(parameters)) { + ir_rvalue *first_param = (ir_rvalue *)parameters->head; + ir_rvalue *rhs = new(ctx) ir_swizzle(first_param, 0, 0, 0, 0, + lhs_components); + var->precision = higher_precision ((glsl_precision)var->precision, rhs->get_precision()); + ir_dereference_variable *lhs = new(ctx) ir_dereference_variable(var); + const unsigned mask = (1U << lhs_components) - 1; + + assert(rhs->type == lhs->type); + + ir_instruction *inst = new(ctx) ir_assignment(lhs, rhs, NULL, mask); + instructions->push_tail(inst); + } else { + unsigned base_component = 0; + unsigned base_lhs_component = 0; + ir_constant_data data; + unsigned constant_mask = 0, constant_components = 0; + + memset(&data, 0, sizeof(data)); + + foreach_list(node, parameters) { + ir_rvalue *param = (ir_rvalue *) node; + var->precision = higher_precision ((glsl_precision)var->precision, param->get_precision()); + unsigned rhs_components = param->type->components(); + + /* Do not try to assign more components to the vector than it has! + */ + if ((rhs_components + base_lhs_component) > lhs_components) { + rhs_components = lhs_components - base_lhs_component; + } + + const ir_constant *const c = param->as_constant(); + if (c != NULL) { + for (unsigned i = 0; i < rhs_components; i++) { + switch (c->type->base_type) { + case GLSL_TYPE_UINT: + data.u[i + base_component] = c->get_uint_component(i); + break; + case GLSL_TYPE_INT: + data.i[i + base_component] = c->get_int_component(i); + break; + case GLSL_TYPE_FLOAT: + data.f[i + base_component] = c->get_float_component(i); + break; + case GLSL_TYPE_BOOL: + data.b[i + base_component] = c->get_bool_component(i); + break; + default: + assert(!"Should not get here."); + break; + } + } + + /* Mask of fields to be written in the assignment. + */ + constant_mask |= ((1U << rhs_components) - 1) << base_lhs_component; + constant_components += rhs_components; + + base_component += rhs_components; + } + /* Advance the component index by the number of components + * that were just assigned. + */ + base_lhs_component += rhs_components; + } + + if (constant_mask != 0) { + ir_dereference *lhs = new(ctx) ir_dereference_variable(var); + const glsl_type *rhs_type = glsl_type::get_instance(var->type->base_type, + constant_components, + 1); + ir_rvalue *rhs = new(ctx) ir_constant(rhs_type, &data); + + ir_instruction *inst = + new(ctx) ir_assignment(lhs, rhs, NULL, constant_mask); + instructions->push_tail(inst); + } + + base_component = 0; + foreach_list(node, parameters) { + ir_rvalue *param = (ir_rvalue *) node; + unsigned rhs_components = param->type->components(); + + /* Do not try to assign more components to the vector than it has! + */ + if ((rhs_components + base_component) > lhs_components) { + rhs_components = lhs_components - base_component; + } + + const ir_constant *const c = param->as_constant(); + if (c == NULL) { + /* Mask of fields to be written in the assignment. + */ + const unsigned write_mask = ((1U << rhs_components) - 1) + << base_component; + + ir_dereference *lhs = new(ctx) ir_dereference_variable(var); + + /* Generate a swizzle so that LHS and RHS sizes match. + */ + ir_rvalue *rhs = + new(ctx) ir_swizzle(param, 0, 1, 2, 3, rhs_components); + + ir_instruction *inst = + new(ctx) ir_assignment(lhs, rhs, NULL, write_mask); + instructions->push_tail(inst); + } + + /* Advance the component index by the number of components that were + * just assigned. + */ + base_component += rhs_components; + } + } + return new(ctx) ir_dereference_variable(var); +} + + +/** + * Generate assignment of a portion of a vector to a portion of a matrix column + * + * \param src_base First component of the source to be used in assignment + * \param column Column of destination to be assiged + * \param row_base First component of the destination column to be assigned + * \param count Number of components to be assigned + * + * \note + * \c src_base + \c count must be less than or equal to the number of components + * in the source vector. + */ +ir_instruction * +assign_to_matrix_column(ir_variable *var, unsigned column, unsigned row_base, + ir_rvalue *src, unsigned src_base, unsigned count, + void *mem_ctx) +{ + ir_constant *col_idx = new(mem_ctx) ir_constant(column); + ir_dereference *column_ref = new(mem_ctx) ir_dereference_array(var, col_idx); + + assert(column_ref->type->components() >= (row_base + count)); + assert(src->type->components() >= (src_base + count)); + + /* Generate a swizzle that extracts the number of components from the source + * that are to be assigned to the column of the matrix. + */ + if (count < src->type->vector_elements) { + src = new(mem_ctx) ir_swizzle(src, + src_base + 0, src_base + 1, + src_base + 2, src_base + 3, + count); + } + + /* Mask of fields to be written in the assignment. + */ + const unsigned write_mask = ((1U << count) - 1) << row_base; + + return new(mem_ctx) ir_assignment(column_ref, src, NULL, write_mask); +} + + +/** + * Generate inline code for a matrix constructor + * + * The generated constructor code will consist of a temporary variable + * declaration of the same type as the constructor. A sequence of assignments + * from constructor parameters to the temporary will follow. + * + * \return + * An \c ir_dereference_variable of the temprorary generated in the constructor + * body. + */ +ir_rvalue * +emit_inline_matrix_constructor(const glsl_type *type, unsigned ast_precision, + exec_list *instructions, + exec_list *parameters, + void *ctx) +{ + assert(!parameters->is_empty()); + + ir_variable *var = new(ctx) ir_variable(type, "mat_ctor", ir_var_temporary, (glsl_precision)ast_precision); + instructions->push_tail(var); + + /* There are three kinds of matrix constructors. + * + * - Construct a matrix from a single scalar by replicating that scalar to + * along the diagonal of the matrix and setting all other components to + * zero. + * + * - Construct a matrix from an arbirary combination of vectors and + * scalars. The components of the constructor parameters are assigned + * to the matrix in colum-major order until the matrix is full. + * + * - Construct a matrix from a single matrix. The source matrix is copied + * to the upper left portion of the constructed matrix, and the remaining + * elements take values from the identity matrix. + */ + ir_rvalue *const first_param = (ir_rvalue *) parameters->head; + if (single_scalar_parameter(parameters)) { + /* Assign the scalar to the X component of a vec4, and fill the remaining + * components with zero. + */ + ir_variable *rhs_var = + new(ctx) ir_variable(glsl_type::vec4_type, "mat_ctor_vec", + ir_var_temporary, (glsl_precision)ast_precision); + instructions->push_tail(rhs_var); + + ir_constant_data zero; + zero.f[0] = 0.0; + zero.f[1] = 0.0; + zero.f[2] = 0.0; + zero.f[3] = 0.0; + + ir_instruction *inst = + new(ctx) ir_assignment(new(ctx) ir_dereference_variable(rhs_var), + new(ctx) ir_constant(rhs_var->type, &zero), + NULL); + instructions->push_tail(inst); + + ir_dereference *const rhs_ref = new(ctx) ir_dereference_variable(rhs_var); + + inst = new(ctx) ir_assignment(rhs_ref, first_param, NULL, 0x01); + instructions->push_tail(inst); + + /* Assign the temporary vector to each column of the destination matrix + * with a swizzle that puts the X component on the diagonal of the + * matrix. In some cases this may mean that the X component does not + * get assigned into the column at all (i.e., when the matrix has more + * columns than rows). + */ + static const unsigned rhs_swiz[4][4] = { + { 0, 1, 1, 1 }, + { 1, 0, 1, 1 }, + { 1, 1, 0, 1 }, + { 1, 1, 1, 0 } + }; + + const unsigned cols_to_init = MIN2(type->matrix_columns, + type->vector_elements); + for (unsigned i = 0; i < cols_to_init; i++) { + ir_constant *const col_idx = new(ctx) ir_constant(i); + ir_rvalue *const col_ref = new(ctx) ir_dereference_array(var, col_idx); + + ir_rvalue *const rhs_ref = new(ctx) ir_dereference_variable(rhs_var); + ir_rvalue *const rhs = new(ctx) ir_swizzle(rhs_ref, rhs_swiz[i], + type->vector_elements); + + inst = new(ctx) ir_assignment(col_ref, rhs, NULL); + instructions->push_tail(inst); + } + + for (unsigned i = cols_to_init; i < type->matrix_columns; i++) { + ir_constant *const col_idx = new(ctx) ir_constant(i); + ir_rvalue *const col_ref = new(ctx) ir_dereference_array(var, col_idx); + + ir_rvalue *const rhs_ref = new(ctx) ir_dereference_variable(rhs_var); + ir_rvalue *const rhs = new(ctx) ir_swizzle(rhs_ref, 1, 1, 1, 1, + type->vector_elements); + + inst = new(ctx) ir_assignment(col_ref, rhs, NULL); + instructions->push_tail(inst); + } + } else if (first_param->type->is_matrix()) { + /* From page 50 (56 of the PDF) of the GLSL 1.50 spec: + * + * "If a matrix is constructed from a matrix, then each component + * (column i, row j) in the result that has a corresponding + * component (column i, row j) in the argument will be initialized + * from there. All other components will be initialized to the + * identity matrix. If a matrix argument is given to a matrix + * constructor, it is an error to have any other arguments." + */ + assert(first_param->next->is_tail_sentinel()); + ir_rvalue *const src_matrix = first_param; + + /* If the source matrix is smaller, pre-initialize the relavent parts of + * the destination matrix to the identity matrix. + */ + if ((src_matrix->type->matrix_columns < var->type->matrix_columns) + || (src_matrix->type->vector_elements < var->type->vector_elements)) { + + /* If the source matrix has fewer rows, every column of the destination + * must be initialized. Otherwise only the columns in the destination + * that do not exist in the source must be initialized. + */ + unsigned col = + (src_matrix->type->vector_elements < var->type->vector_elements) + ? 0 : src_matrix->type->matrix_columns; + + const glsl_type *const col_type = var->type->column_type(); + for (/* empty */; col < var->type->matrix_columns; col++) { + ir_constant_data ident; + + ident.f[0] = 0.0; + ident.f[1] = 0.0; + ident.f[2] = 0.0; + ident.f[3] = 0.0; + + ident.f[col] = 1.0; + + ir_rvalue *const rhs = new(ctx) ir_constant(col_type, &ident); + + ir_rvalue *const lhs = + new(ctx) ir_dereference_array(var, new(ctx) ir_constant(col)); + + ir_instruction *inst = new(ctx) ir_assignment(lhs, rhs, NULL); + instructions->push_tail(inst); + } + } + + /* Assign columns from the source matrix to the destination matrix. + * + * Since the parameter will be used in the RHS of multiple assignments, + * generate a temporary and copy the paramter there. + */ + ir_variable *const rhs_var = + new(ctx) ir_variable(first_param->type, "mat_ctor_mat", + ir_var_temporary, (glsl_precision)ast_precision); + instructions->push_tail(rhs_var); + + ir_dereference *const rhs_var_ref = + new(ctx) ir_dereference_variable(rhs_var); + ir_instruction *const inst = + new(ctx) ir_assignment(rhs_var_ref, first_param, NULL); + instructions->push_tail(inst); + + const unsigned last_row = MIN2(src_matrix->type->vector_elements, + var->type->vector_elements); + const unsigned last_col = MIN2(src_matrix->type->matrix_columns, + var->type->matrix_columns); + + unsigned swiz[4] = { 0, 0, 0, 0 }; + for (unsigned i = 1; i < last_row; i++) + swiz[i] = i; + + const unsigned write_mask = (1U << last_row) - 1; + + for (unsigned i = 0; i < last_col; i++) { + ir_dereference *const lhs = + new(ctx) ir_dereference_array(var, new(ctx) ir_constant(i)); + ir_rvalue *const rhs_col = + new(ctx) ir_dereference_array(rhs_var, new(ctx) ir_constant(i)); + + /* If one matrix has columns that are smaller than the columns of the + * other matrix, wrap the column access of the larger with a swizzle + * so that the LHS and RHS of the assignment have the same size (and + * therefore have the same type). + * + * It would be perfectly valid to unconditionally generate the + * swizzles, this this will typically result in a more compact IR tree. + */ + ir_rvalue *rhs; + if (lhs->type->vector_elements != rhs_col->type->vector_elements) { + rhs = new(ctx) ir_swizzle(rhs_col, swiz, last_row); + } else { + rhs = rhs_col; + } + + ir_instruction *inst = + new(ctx) ir_assignment(lhs, rhs, NULL, write_mask); + instructions->push_tail(inst); + } + } else { + const unsigned cols = type->matrix_columns; + const unsigned rows = type->vector_elements; + unsigned col_idx = 0; + unsigned row_idx = 0; + + foreach_list (node, parameters) { + ir_rvalue *const rhs = (ir_rvalue *) node; + const unsigned components_remaining_this_column = rows - row_idx; + unsigned rhs_components = rhs->type->components(); + unsigned rhs_base = 0; + + /* Since the parameter might be used in the RHS of two assignments, + * generate a temporary and copy the paramter there. + */ + ir_variable *rhs_var = + new(ctx) ir_variable(rhs->type, "mat_ctor_vec", ir_var_temporary, (glsl_precision)ast_precision); + instructions->push_tail(rhs_var); + + ir_dereference *rhs_var_ref = + new(ctx) ir_dereference_variable(rhs_var); + ir_instruction *inst = new(ctx) ir_assignment(rhs_var_ref, rhs, NULL); + instructions->push_tail(inst); + + /* Assign the current parameter to as many components of the matrix + * as it will fill. + * + * NOTE: A single vector parameter can span two matrix columns. A + * single vec4, for example, can completely fill a mat2. + */ + if (rhs_components >= components_remaining_this_column) { + const unsigned count = MIN2(rhs_components, + components_remaining_this_column); + + rhs_var_ref = new(ctx) ir_dereference_variable(rhs_var); + + ir_instruction *inst = assign_to_matrix_column(var, col_idx, + row_idx, + rhs_var_ref, 0, + count, ctx); + instructions->push_tail(inst); + + rhs_base = count; + + col_idx++; + row_idx = 0; + } + + /* If there is data left in the parameter and components left to be + * set in the destination, emit another assignment. It is possible + * that the assignment could be of a vec4 to the last element of the + * matrix. In this case col_idx==cols, but there is still data + * left in the source parameter. Obviously, don't emit an assignment + * to data outside the destination matrix. + */ + if ((col_idx < cols) && (rhs_base < rhs_components)) { + const unsigned count = rhs_components - rhs_base; + + rhs_var_ref = new(ctx) ir_dereference_variable(rhs_var); + + ir_instruction *inst = assign_to_matrix_column(var, col_idx, + row_idx, + rhs_var_ref, + rhs_base, + count, ctx); + instructions->push_tail(inst); + + row_idx += count; + } + } + } + + return new(ctx) ir_dereference_variable(var); +} + + +ir_rvalue * +emit_inline_record_constructor(const glsl_type *type, + exec_list *instructions, + exec_list *parameters, + void *mem_ctx) +{ + ir_variable *const var = + new(mem_ctx) ir_variable(type, "record_ctor", ir_var_temporary, glsl_precision_undefined); + ir_dereference_variable *const d = new(mem_ctx) ir_dereference_variable(var); + + instructions->push_tail(var); + + exec_node *node = parameters->head; + for (unsigned i = 0; i < type->length; i++) { + assert(!node->is_tail_sentinel()); + + ir_dereference *const lhs = + new(mem_ctx) ir_dereference_record(d->clone(mem_ctx, NULL), + type->fields.structure[i].name); + + ir_rvalue *const rhs = ((ir_instruction *) node)->as_rvalue(); + assert(rhs != NULL); + + ir_instruction *const assign = new(mem_ctx) ir_assignment(lhs, rhs, NULL); + + instructions->push_tail(assign); + node = node->next; + } + + return d; +} + + +ir_rvalue * +ast_function_expression::hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state) +{ + void *ctx = state; + /* There are three sorts of function calls. + * + * 1. constructors - The first subexpression is an ast_type_specifier. + * 2. methods - Only the .length() method of array types. + * 3. functions - Calls to regular old functions. + * + * Method calls are actually detected when the ast_field_selection + * expression is handled. + */ + if (is_constructor()) { + const ast_type_specifier *type = (ast_type_specifier *) subexpressions[0]; + YYLTYPE loc = type->get_location(); + const char *name; + + const glsl_type *const constructor_type = type->glsl_type(& name, state); + + /* constructor_type can be NULL if a variable with the same name as the + * structure has come into scope. + */ + if (constructor_type == NULL) { + _mesa_glsl_error(& loc, state, "unknown type `%s' (structure name " + "may be shadowed by a variable with the same name)", + type->type_name); + return ir_call::get_error_instruction(ctx); + } + + + /* Constructors for samplers are illegal. + */ + if (constructor_type->is_sampler()) { + _mesa_glsl_error(& loc, state, "cannot construct sampler type `%s'", + constructor_type->name); + return ir_call::get_error_instruction(ctx); + } + + if (constructor_type->is_array()) { + if (state->language_version <= 110) { + _mesa_glsl_error(& loc, state, + "array constructors forbidden in GLSL 1.10"); + return ir_call::get_error_instruction(ctx); + } + + return process_array_constructor(instructions, constructor_type, + & loc, &this->expressions, state); + } + + + /* There are two kinds of constructor call. Constructors for built-in + * language types, such as mat4 and vec2, are free form. The only + * requirement is that the parameters must provide enough values of the + * correct scalar type. Constructors for arrays and structures must + * have the exact number of parameters with matching types in the + * correct order. These constructors follow essentially the same type + * matching rules as functions. + */ + if (constructor_type->is_record()) { + exec_list actual_parameters; + + process_parameters(instructions, &actual_parameters, + &this->expressions, state); + + exec_node *node = actual_parameters.head; + for (unsigned i = 0; i < constructor_type->length; i++) { + ir_rvalue *ir = (ir_rvalue *) node; + + if (node->is_tail_sentinel()) { + _mesa_glsl_error(&loc, state, + "insufficient parameters to constructor " + "for `%s'", + constructor_type->name); + return ir_call::get_error_instruction(ctx); + } + + if (apply_implicit_conversion(constructor_type->fields.structure[i].type, + ir, state)) { + node->replace_with(ir); + } else { + _mesa_glsl_error(&loc, state, + "parameter type mismatch in constructor " + "for `%s.%s' (%s vs %s)", + constructor_type->name, + constructor_type->fields.structure[i].name, + ir->type->name, + constructor_type->fields.structure[i].type->name); + return ir_call::get_error_instruction(ctx);; + } + + node = node->next; + } + + if (!node->is_tail_sentinel()) { + _mesa_glsl_error(&loc, state, "too many parameters in constructor " + "for `%s'", constructor_type->name); + return ir_call::get_error_instruction(ctx); + } + + ir_rvalue *const constant = + constant_record_constructor(constructor_type, &actual_parameters, + state); + + return (constant != NULL) + ? constant + : emit_inline_record_constructor(constructor_type, instructions, + &actual_parameters, state); + } + + if (!constructor_type->is_numeric() && !constructor_type->is_boolean()) + return ir_call::get_error_instruction(ctx); + + /* Total number of components of the type being constructed. */ + const unsigned type_components = constructor_type->components(); + + /* Number of components from parameters that have actually been + * consumed. This is used to perform several kinds of error checking. + */ + unsigned components_used = 0; + + unsigned matrix_parameters = 0; + unsigned nonmatrix_parameters = 0; + exec_list actual_parameters; + + foreach_list (n, &this->expressions) { + ast_node *ast = exec_node_data(ast_node, n, link); + ir_rvalue *result = ast->hir(instructions, state)->as_rvalue(); + + /* From page 50 (page 56 of the PDF) of the GLSL 1.50 spec: + * + * "It is an error to provide extra arguments beyond this + * last used argument." + */ + if (components_used >= type_components) { + _mesa_glsl_error(& loc, state, "too many parameters to `%s' " + "constructor", + constructor_type->name); + return ir_call::get_error_instruction(ctx); + } + + if (!result->type->is_numeric() && !result->type->is_boolean()) { + _mesa_glsl_error(& loc, state, "cannot construct `%s' from a " + "non-numeric data type", + constructor_type->name); + return ir_call::get_error_instruction(ctx); + } + + /* Count the number of matrix and nonmatrix parameters. This + * is used below to enforce some of the constructor rules. + */ + if (result->type->is_matrix()) + matrix_parameters++; + else + nonmatrix_parameters++; + + actual_parameters.push_tail(result); + components_used += result->type->components(); + } + + /* From page 28 (page 34 of the PDF) of the GLSL 1.10 spec: + * + * "It is an error to construct matrices from other matrices. This + * is reserved for future use." + */ + if (state->language_version == 110 && matrix_parameters > 0 + && constructor_type->is_matrix()) { + _mesa_glsl_error(& loc, state, "cannot construct `%s' from a " + "matrix in GLSL 1.10", + constructor_type->name); + return ir_call::get_error_instruction(ctx); + } + + /* From page 50 (page 56 of the PDF) of the GLSL 1.50 spec: + * + * "If a matrix argument is given to a matrix constructor, it is + * an error to have any other arguments." + */ + if ((matrix_parameters > 0) + && ((matrix_parameters + nonmatrix_parameters) > 1) + && constructor_type->is_matrix()) { + _mesa_glsl_error(& loc, state, "for matrix `%s' constructor, " + "matrix must be only parameter", + constructor_type->name); + return ir_call::get_error_instruction(ctx); + } + + /* From page 28 (page 34 of the PDF) of the GLSL 1.10 spec: + * + * "In these cases, there must be enough components provided in the + * arguments to provide an initializer for every component in the + * constructed value." + */ + if (components_used < type_components && components_used != 1 + && matrix_parameters == 0) { + _mesa_glsl_error(& loc, state, "too few components to construct " + "`%s'", + constructor_type->name); + return ir_call::get_error_instruction(ctx); + } + + /* Later, we cast each parameter to the same base type as the + * constructor. Since there are no non-floating point matrices, we + * need to break them up into a series of column vectors. + */ + if (constructor_type->base_type != GLSL_TYPE_FLOAT) { + foreach_list_safe(n, &actual_parameters) { + ir_rvalue *matrix = (ir_rvalue *) n; + + if (!matrix->type->is_matrix()) + continue; + + /* Create a temporary containing the matrix. */ + ir_variable *var = new(ctx) ir_variable(matrix->type, "matrix_tmp", + ir_var_temporary, matrix->get_precision()); + instructions->push_tail(var); + instructions->push_tail(new(ctx) ir_assignment(new(ctx) + ir_dereference_variable(var), matrix, NULL)); + var->constant_value = matrix->constant_expression_value(); + + /* Replace the matrix with dereferences of its columns. */ + for (unsigned int i = 0; i < matrix->type->matrix_columns; i++) { + matrix->insert_before(new (ctx) ir_dereference_array(var, + new(ctx) ir_constant(i))); + } + matrix->remove(); + } + } + + bool all_parameters_are_constant = true; + + /* Type cast each parameter and, if possible, fold constants.*/ + foreach_list_safe(n, &actual_parameters) { + ir_rvalue *ir = (ir_rvalue *) n; + + const glsl_type *desired_type = + glsl_type::get_instance(constructor_type->base_type, + ir->type->vector_elements, + ir->type->matrix_columns); + ir_rvalue *result = convert_component(ir, desired_type); + + /* Attempt to convert the parameter to a constant valued expression. + * After doing so, track whether or not all the parameters to the + * constructor are trivially constant valued expressions. + */ + ir_rvalue *const constant = result->constant_expression_value(); + + if (constant != NULL) + result = constant; + else + all_parameters_are_constant = false; + + if (result != ir) { + ir->replace_with(result); + } + } + + /* If all of the parameters are trivially constant, create a + * constant representing the complete collection of parameters. + */ + if (all_parameters_are_constant) { + return new(ctx) ir_constant(constructor_type, &actual_parameters); + } else if (constructor_type->is_scalar()) { + return dereference_component((ir_rvalue *) actual_parameters.head, + 0); + } else if (constructor_type->is_vector()) { + return emit_inline_vector_constructor(constructor_type, type->precision, + instructions, + &actual_parameters, + ctx); + } else { + assert(constructor_type->is_matrix()); + return emit_inline_matrix_constructor(constructor_type, type->precision, + instructions, + &actual_parameters, + ctx); + } + } else { + const ast_expression *id = subexpressions[0]; + YYLTYPE loc = id->get_location(); + exec_list actual_parameters; + + process_parameters(instructions, &actual_parameters, &this->expressions, + state); + + return match_function_by_name(instructions, + id->primary_expression.identifier, & loc, + &actual_parameters, state); + } + + return ir_call::get_error_instruction(ctx); +} diff --git a/3rdparty/glsl-optimizer/src/glsl/ast_to_hir.cpp b/3rdparty/glsl-optimizer/src/glsl/ast_to_hir.cpp new file mode 100644 index 000000000..50efa8c1a --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/ast_to_hir.cpp @@ -0,0 +1,3585 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file ast_to_hir.c + * Convert abstract syntax to to high-level intermediate reprensentation (HIR). + * + * During the conversion to HIR, the majority of the symantic checking is + * preformed on the program. This includes: + * + * * Symbol table management + * * Type checking + * * Function binding + * + * The majority of this work could be done during parsing, and the parser could + * probably generate HIR directly. However, this results in frequent changes + * to the parser code. Since we do not assume that every system this complier + * is built on will have Flex and Bison installed, we have to store the code + * generated by these tools in our version control system. In other parts of + * the system we've seen problems where a parser was changed but the generated + * code was not committed, merge conflicts where created because two developers + * had slightly different versions of Bison installed, etc. + * + * I have also noticed that running Bison generated parsers in GDB is very + * irritating. When you get a segfault on '$$ = $1->foo', you can't very + * well 'print $1' in GDB. + * + * As a result, my preference is to put as little C code as possible in the + * parser (and lexer) sources. + */ + +#include "main/core.h" /* for struct gl_extensions */ +#include "glsl_symbol_table.h" +#include "glsl_parser_extras.h" +#include "ast.h" +#include "glsl_types.h" +#include "ir.h" + +void +_mesa_ast_to_hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) +{ + _mesa_glsl_initialize_variables(instructions, state); + _mesa_glsl_initialize_functions(state); + + state->symbols->language_version = state->language_version; + + state->current_function = NULL; + + state->toplevel_ir = instructions; + + /* Section 4.2 of the GLSL 1.20 specification states: + * "The built-in functions are scoped in a scope outside the global scope + * users declare global variables in. That is, a shader's global scope, + * available for user-defined functions and global variables, is nested + * inside the scope containing the built-in functions." + * + * Since built-in functions like ftransform() access built-in variables, + * it follows that those must be in the outer scope as well. + * + * We push scope here to create this nesting effect...but don't pop. + * This way, a shader's globals are still in the symbol table for use + * by the linker. + */ + state->symbols->push_scope(); + + foreach_list_typed (ast_node, ast, link, & state->translation_unit) + ast->hir(instructions, state); + + detect_recursion_unlinked(state, instructions); + + state->toplevel_ir = NULL; +} + + +/** + * If a conversion is available, convert one operand to a different type + * + * The \c from \c ir_rvalue is converted "in place". + * + * \param to Type that the operand it to be converted to + * \param from Operand that is being converted + * \param state GLSL compiler state + * + * \return + * If a conversion is possible (or unnecessary), \c true is returned. + * Otherwise \c false is returned. + */ +bool +apply_implicit_conversion(const glsl_type *to, ir_rvalue * &from, + struct _mesa_glsl_parse_state *state) +{ + void *ctx = state; + if (to->base_type == from->type->base_type) + return true; + + /* This conversion was added in GLSL 1.20. If the compilation mode is + * GLSL 1.10, the conversion is skipped. + */ + if (state->language_version < 120) + return false; + + /* From page 27 (page 33 of the PDF) of the GLSL 1.50 spec: + * + * "There are no implicit array or structure conversions. For + * example, an array of int cannot be implicitly converted to an + * array of float. There are no implicit conversions between + * signed and unsigned integers." + */ + /* FINISHME: The above comment is partially a lie. There is int/uint + * FINISHME: conversion for immediate constants. + */ + if (!to->is_float() || !from->type->is_numeric()) + return false; + + /* Convert to a floating point type with the same number of components + * as the original type - i.e. int to float, not int to vec4. + */ + to = glsl_type::get_instance(GLSL_TYPE_FLOAT, from->type->vector_elements, + from->type->matrix_columns); + + switch (from->type->base_type) { + case GLSL_TYPE_INT: + from = new(ctx) ir_expression(ir_unop_i2f, to, from, NULL); + break; + case GLSL_TYPE_UINT: + from = new(ctx) ir_expression(ir_unop_u2f, to, from, NULL); + break; + case GLSL_TYPE_BOOL: + from = new(ctx) ir_expression(ir_unop_b2f, to, from, NULL); + break; + default: + assert(0); + } + + return true; +} + + +static const struct glsl_type * +arithmetic_result_type(ir_rvalue * &value_a, ir_rvalue * &value_b, + bool multiply, + struct _mesa_glsl_parse_state *state, YYLTYPE *loc) +{ + const glsl_type *type_a = value_a->type; + const glsl_type *type_b = value_b->type; + + /* From GLSL 1.50 spec, page 56: + * + * "The arithmetic binary operators add (+), subtract (-), + * multiply (*), and divide (/) operate on integer and + * floating-point scalars, vectors, and matrices." + */ + if (!type_a->is_numeric() || !type_b->is_numeric()) { + _mesa_glsl_error(loc, state, + "Operands to arithmetic operators must be numeric"); + return glsl_type::error_type; + } + + + /* "If one operand is floating-point based and the other is + * not, then the conversions from Section 4.1.10 "Implicit + * Conversions" are applied to the non-floating-point-based operand." + */ + if (!apply_implicit_conversion(type_a, value_b, state) + && !apply_implicit_conversion(type_b, value_a, state)) { + _mesa_glsl_error(loc, state, + "Could not implicitly convert operands to " + "arithmetic operator"); + return glsl_type::error_type; + } + type_a = value_a->type; + type_b = value_b->type; + + /* "If the operands are integer types, they must both be signed or + * both be unsigned." + * + * From this rule and the preceeding conversion it can be inferred that + * both types must be GLSL_TYPE_FLOAT, or GLSL_TYPE_UINT, or GLSL_TYPE_INT. + * The is_numeric check above already filtered out the case where either + * type is not one of these, so now the base types need only be tested for + * equality. + */ + if (type_a->base_type != type_b->base_type) { + _mesa_glsl_error(loc, state, + "base type mismatch for arithmetic operator"); + return glsl_type::error_type; + } + + /* "All arithmetic binary operators result in the same fundamental type + * (signed integer, unsigned integer, or floating-point) as the + * operands they operate on, after operand type conversion. After + * conversion, the following cases are valid + * + * * The two operands are scalars. In this case the operation is + * applied, resulting in a scalar." + */ + if (type_a->is_scalar() && type_b->is_scalar()) + return type_a; + + /* "* One operand is a scalar, and the other is a vector or matrix. + * In this case, the scalar operation is applied independently to each + * component of the vector or matrix, resulting in the same size + * vector or matrix." + */ + if (type_a->is_scalar()) { + if (!type_b->is_scalar()) + return type_b; + } else if (type_b->is_scalar()) { + return type_a; + } + + /* All of the combinations of , , + * , , and have been + * handled. + */ + assert(!type_a->is_scalar()); + assert(!type_b->is_scalar()); + + /* "* The two operands are vectors of the same size. In this case, the + * operation is done component-wise resulting in the same size + * vector." + */ + if (type_a->is_vector() && type_b->is_vector()) { + if (type_a == type_b) { + return type_a; + } else { + _mesa_glsl_error(loc, state, + "vector size mismatch for arithmetic operator"); + return glsl_type::error_type; + } + } + + /* All of the combinations of , , + * , , , and + * have been handled. At least one of the operands must + * be matrix. Further, since there are no integer matrix types, the base + * type of both operands must be float. + */ + assert(type_a->is_matrix() || type_b->is_matrix()); + assert(type_a->base_type == GLSL_TYPE_FLOAT); + assert(type_b->base_type == GLSL_TYPE_FLOAT); + + /* "* The operator is add (+), subtract (-), or divide (/), and the + * operands are matrices with the same number of rows and the same + * number of columns. In this case, the operation is done component- + * wise resulting in the same size matrix." + * * The operator is multiply (*), where both operands are matrices or + * one operand is a vector and the other a matrix. A right vector + * operand is treated as a column vector and a left vector operand as a + * row vector. In all these cases, it is required that the number of + * columns of the left operand is equal to the number of rows of the + * right operand. Then, the multiply (*) operation does a linear + * algebraic multiply, yielding an object that has the same number of + * rows as the left operand and the same number of columns as the right + * operand. Section 5.10 "Vector and Matrix Operations" explains in + * more detail how vectors and matrices are operated on." + */ + if (! multiply) { + if (type_a == type_b) + return type_a; + } else { + if (type_a->is_matrix() && type_b->is_matrix()) { + /* Matrix multiply. The columns of A must match the rows of B. Given + * the other previously tested constraints, this means the vector type + * of a row from A must be the same as the vector type of a column from + * B. + */ + if (type_a->row_type() == type_b->column_type()) { + /* The resulting matrix has the number of columns of matrix B and + * the number of rows of matrix A. We get the row count of A by + * looking at the size of a vector that makes up a column. The + * transpose (size of a row) is done for B. + */ + const glsl_type *const type = + glsl_type::get_instance(type_a->base_type, + type_a->column_type()->vector_elements, + type_b->row_type()->vector_elements); + assert(type != glsl_type::error_type); + + return type; + } + } else if (type_a->is_matrix()) { + /* A is a matrix and B is a column vector. Columns of A must match + * rows of B. Given the other previously tested constraints, this + * means the vector type of a row from A must be the same as the + * vector the type of B. + */ + if (type_a->row_type() == type_b) { + /* The resulting vector has a number of elements equal to + * the number of rows of matrix A. */ + const glsl_type *const type = + glsl_type::get_instance(type_a->base_type, + type_a->column_type()->vector_elements, + 1); + assert(type != glsl_type::error_type); + + return type; + } + } else { + assert(type_b->is_matrix()); + + /* A is a row vector and B is a matrix. Columns of A must match rows + * of B. Given the other previously tested constraints, this means + * the type of A must be the same as the vector type of a column from + * B. + */ + if (type_a == type_b->column_type()) { + /* The resulting vector has a number of elements equal to + * the number of columns of matrix B. */ + const glsl_type *const type = + glsl_type::get_instance(type_a->base_type, + type_b->row_type()->vector_elements, + 1); + assert(type != glsl_type::error_type); + + return type; + } + } + + _mesa_glsl_error(loc, state, "size mismatch for matrix multiplication"); + return glsl_type::error_type; + } + + + /* "All other cases are illegal." + */ + _mesa_glsl_error(loc, state, "type mismatch"); + return glsl_type::error_type; +} + + +static const struct glsl_type * +unary_arithmetic_result_type(const struct glsl_type *type, + struct _mesa_glsl_parse_state *state, YYLTYPE *loc) +{ + /* From GLSL 1.50 spec, page 57: + * + * "The arithmetic unary operators negate (-), post- and pre-increment + * and decrement (-- and ++) operate on integer or floating-point + * values (including vectors and matrices). All unary operators work + * component-wise on their operands. These result with the same type + * they operated on." + */ + if (!type->is_numeric()) { + _mesa_glsl_error(loc, state, + "Operands to arithmetic operators must be numeric"); + return glsl_type::error_type; + } + + return type; +} + +/** + * \brief Return the result type of a bit-logic operation. + * + * If the given types to the bit-logic operator are invalid, return + * glsl_type::error_type. + * + * \param type_a Type of LHS of bit-logic op + * \param type_b Type of RHS of bit-logic op + */ +static const struct glsl_type * +bit_logic_result_type(const struct glsl_type *type_a, + const struct glsl_type *type_b, + ast_operators op, + struct _mesa_glsl_parse_state *state, YYLTYPE *loc) +{ + if (state->language_version < 130) { + _mesa_glsl_error(loc, state, "bit operations require GLSL 1.30"); + return glsl_type::error_type; + } + + /* From page 50 (page 56 of PDF) of GLSL 1.30 spec: + * + * "The bitwise operators and (&), exclusive-or (^), and inclusive-or + * (|). The operands must be of type signed or unsigned integers or + * integer vectors." + */ + if (!type_a->is_integer()) { + _mesa_glsl_error(loc, state, "LHS of `%s' must be an integer", + ast_expression::operator_string(op)); + return glsl_type::error_type; + } + if (!type_b->is_integer()) { + _mesa_glsl_error(loc, state, "RHS of `%s' must be an integer", + ast_expression::operator_string(op)); + return glsl_type::error_type; + } + + /* "The fundamental types of the operands (signed or unsigned) must + * match," + */ + if (type_a->base_type != type_b->base_type) { + _mesa_glsl_error(loc, state, "operands of `%s' must have the same " + "base type", ast_expression::operator_string(op)); + return glsl_type::error_type; + } + + /* "The operands cannot be vectors of differing size." */ + if (type_a->is_vector() && + type_b->is_vector() && + type_a->vector_elements != type_b->vector_elements) { + _mesa_glsl_error(loc, state, "operands of `%s' cannot be vectors of " + "different sizes", ast_expression::operator_string(op)); + return glsl_type::error_type; + } + + /* "If one operand is a scalar and the other a vector, the scalar is + * applied component-wise to the vector, resulting in the same type as + * the vector. The fundamental types of the operands [...] will be the + * resulting fundamental type." + */ + if (type_a->is_scalar()) + return type_b; + else + return type_a; +} + +static const struct glsl_type * +modulus_result_type(const struct glsl_type *type_a, + const struct glsl_type *type_b, + struct _mesa_glsl_parse_state *state, YYLTYPE *loc) +{ + if (state->language_version < 130) { + _mesa_glsl_error(loc, state, + "operator '%%' is reserved in %s", + state->version_string); + return glsl_type::error_type; + } + + /* From GLSL 1.50 spec, page 56: + * "The operator modulus (%) operates on signed or unsigned integers or + * integer vectors. The operand types must both be signed or both be + * unsigned." + */ + if (!type_a->is_integer()) { + _mesa_glsl_error(loc, state, "LHS of operator %% must be an integer."); + return glsl_type::error_type; + } + if (!type_b->is_integer()) { + _mesa_glsl_error(loc, state, "RHS of operator %% must be an integer."); + return glsl_type::error_type; + } + if (type_a->base_type != type_b->base_type) { + _mesa_glsl_error(loc, state, + "operands of %% must have the same base type"); + return glsl_type::error_type; + } + + /* "The operands cannot be vectors of differing size. If one operand is + * a scalar and the other vector, then the scalar is applied component- + * wise to the vector, resulting in the same type as the vector. If both + * are vectors of the same size, the result is computed component-wise." + */ + if (type_a->is_vector()) { + if (!type_b->is_vector() + || (type_a->vector_elements == type_b->vector_elements)) + return type_a; + } else + return type_b; + + /* "The operator modulus (%) is not defined for any other data types + * (non-integer types)." + */ + _mesa_glsl_error(loc, state, "type mismatch"); + return glsl_type::error_type; +} + + +static const struct glsl_type * +relational_result_type(ir_rvalue * &value_a, ir_rvalue * &value_b, + struct _mesa_glsl_parse_state *state, YYLTYPE *loc) +{ + const glsl_type *type_a = value_a->type; + const glsl_type *type_b = value_b->type; + + /* From GLSL 1.50 spec, page 56: + * "The relational operators greater than (>), less than (<), greater + * than or equal (>=), and less than or equal (<=) operate only on + * scalar integer and scalar floating-point expressions." + */ + if (!type_a->is_numeric() + || !type_b->is_numeric() + || !type_a->is_scalar() + || !type_b->is_scalar()) { + _mesa_glsl_error(loc, state, + "Operands to relational operators must be scalar and " + "numeric"); + return glsl_type::error_type; + } + + /* "Either the operands' types must match, or the conversions from + * Section 4.1.10 "Implicit Conversions" will be applied to the integer + * operand, after which the types must match." + */ + if (!apply_implicit_conversion(type_a, value_b, state) + && !apply_implicit_conversion(type_b, value_a, state)) { + _mesa_glsl_error(loc, state, + "Could not implicitly convert operands to " + "relational operator"); + return glsl_type::error_type; + } + type_a = value_a->type; + type_b = value_b->type; + + if (type_a->base_type != type_b->base_type) { + _mesa_glsl_error(loc, state, "base type mismatch"); + return glsl_type::error_type; + } + + /* "The result is scalar Boolean." + */ + return glsl_type::bool_type; +} + +/** + * \brief Return the result type of a bit-shift operation. + * + * If the given types to the bit-shift operator are invalid, return + * glsl_type::error_type. + * + * \param type_a Type of LHS of bit-shift op + * \param type_b Type of RHS of bit-shift op + */ +static const struct glsl_type * +shift_result_type(const struct glsl_type *type_a, + const struct glsl_type *type_b, + ast_operators op, + struct _mesa_glsl_parse_state *state, YYLTYPE *loc) +{ + if (state->language_version < 130) { + _mesa_glsl_error(loc, state, "bit operations require GLSL 1.30"); + return glsl_type::error_type; + } + + /* From page 50 (page 56 of the PDF) of the GLSL 1.30 spec: + * + * "The shift operators (<<) and (>>). For both operators, the operands + * must be signed or unsigned integers or integer vectors. One operand + * can be signed while the other is unsigned." + */ + if (!type_a->is_integer()) { + _mesa_glsl_error(loc, state, "LHS of operator %s must be an integer or " + "integer vector", ast_expression::operator_string(op)); + return glsl_type::error_type; + + } + if (!type_b->is_integer()) { + _mesa_glsl_error(loc, state, "RHS of operator %s must be an integer or " + "integer vector", ast_expression::operator_string(op)); + return glsl_type::error_type; + } + + /* "If the first operand is a scalar, the second operand has to be + * a scalar as well." + */ + if (type_a->is_scalar() && !type_b->is_scalar()) { + _mesa_glsl_error(loc, state, "If the first operand of %s is scalar, the " + "second must be scalar as well", + ast_expression::operator_string(op)); + return glsl_type::error_type; + } + + /* If both operands are vectors, check that they have same number of + * elements. + */ + if (type_a->is_vector() && + type_b->is_vector() && + type_a->vector_elements != type_b->vector_elements) { + _mesa_glsl_error(loc, state, "Vector operands to operator %s must " + "have same number of elements", + ast_expression::operator_string(op)); + return glsl_type::error_type; + } + + /* "In all cases, the resulting type will be the same type as the left + * operand." + */ + return type_a; +} + +/** + * Validates that a value can be assigned to a location with a specified type + * + * Validates that \c rhs can be assigned to some location. If the types are + * not an exact match but an automatic conversion is possible, \c rhs will be + * converted. + * + * \return + * \c NULL if \c rhs cannot be assigned to a location with type \c lhs_type. + * Otherwise the actual RHS to be assigned will be returned. This may be + * \c rhs, or it may be \c rhs after some type conversion. + * + * \note + * In addition to being used for assignments, this function is used to + * type-check return values. + */ +ir_rvalue * +validate_assignment(struct _mesa_glsl_parse_state *state, + const glsl_type *lhs_type, ir_rvalue *rhs, + bool is_initializer) +{ + /* If there is already some error in the RHS, just return it. Anything + * else will lead to an avalanche of error message back to the user. + */ + if (rhs->type->is_error()) + return rhs; + + /* If the types are identical, the assignment can trivially proceed. + */ + if (rhs->type == lhs_type) + return rhs; + + /* If the array element types are the same and the size of the LHS is zero, + * the assignment is okay for initializers embedded in variable + * declarations. + * + * Note: Whole-array assignments are not permitted in GLSL 1.10, but this + * is handled by ir_dereference::is_lvalue. + */ + if (is_initializer && lhs_type->is_array() && rhs->type->is_array() + && (lhs_type->element_type() == rhs->type->element_type()) + && (lhs_type->array_size() == 0)) { + return rhs; + } + + /* Check for implicit conversion in GLSL 1.20 */ + if (apply_implicit_conversion(lhs_type, rhs, state)) { + if (rhs->type == lhs_type) + return rhs; + } + + return NULL; +} + +static void +mark_whole_array_access(ir_rvalue *access) +{ + ir_dereference_variable *deref = access->as_dereference_variable(); + + if (deref && deref->var) { + deref->var->max_array_access = deref->type->length - 1; + } +} + +ir_rvalue * +do_assignment(exec_list *instructions, struct _mesa_glsl_parse_state *state, + ir_rvalue *lhs, ir_rvalue *rhs, bool is_initializer, + YYLTYPE lhs_loc) +{ + void *ctx = state; + bool error_emitted = (lhs->type->is_error() || rhs->type->is_error()); + + if (!error_emitted) { + if (lhs->variable_referenced() != NULL + && lhs->variable_referenced()->read_only) { + _mesa_glsl_error(&lhs_loc, state, + "assignment to read-only variable '%s'", + lhs->variable_referenced()->name); + error_emitted = true; + + } else if (!lhs->is_lvalue()) { + _mesa_glsl_error(& lhs_loc, state, "non-lvalue in assignment"); + error_emitted = true; + } + + if (state->es_shader && lhs->type->is_array()) { + _mesa_glsl_error(&lhs_loc, state, "whole array assignment is not " + "allowed in GLSL ES 1.00."); + error_emitted = true; + } + } + + ir_rvalue *new_rhs = + validate_assignment(state, lhs->type, rhs, is_initializer); + if (new_rhs == NULL) { + _mesa_glsl_error(& lhs_loc, state, "type mismatch"); + } else { + rhs = new_rhs; + + /* If the LHS array was not declared with a size, it takes it size from + * the RHS. If the LHS is an l-value and a whole array, it must be a + * dereference of a variable. Any other case would require that the LHS + * is either not an l-value or not a whole array. + */ + if (lhs->type->array_size() == 0) { + ir_dereference *const d = lhs->as_dereference(); + + assert(d != NULL); + + ir_variable *const var = d->variable_referenced(); + + assert(var != NULL); + + if (var->max_array_access >= unsigned(rhs->type->array_size())) { + /* FINISHME: This should actually log the location of the RHS. */ + _mesa_glsl_error(& lhs_loc, state, "array size must be > %u due to " + "previous access", + var->max_array_access); + } + + var->type = glsl_type::get_array_instance(lhs->type->element_type(), + rhs->type->array_size()); + d->type = var->type; + } + mark_whole_array_access(lhs); + } + + if (lhs->get_precision() == glsl_precision_undefined) + { + glsl_precision prec = precision_from_ir (rhs); + ir_dereference *const d = lhs->as_dereference(); + if (d) + { + ir_variable *const var = d->variable_referenced(); + if (var) + var->precision = prec; + } + } + + /* Most callers of do_assignment (assign, add_assign, pre_inc/dec, + * but not post_inc) need the converted assigned value as an rvalue + * to handle things like: + * + * i = j += 1; + * + * So we always just store the computed value being assigned to a + * temporary and return a deref of that temporary. If the rvalue + * ends up not being used, the temp will get copy-propagated out. + */ + ir_variable *var = new(ctx) ir_variable(rhs->type, "assignment_tmp", + ir_var_temporary, precision_from_ir(rhs)); + ir_dereference_variable *deref_var = new(ctx) ir_dereference_variable(var); + instructions->push_tail(var); + instructions->push_tail(new(ctx) ir_assignment(deref_var, + rhs, + NULL)); + deref_var = new(ctx) ir_dereference_variable(var); + + if (!error_emitted) + instructions->push_tail(new(ctx) ir_assignment(lhs, deref_var, NULL)); + + return new(ctx) ir_dereference_variable(var); +} + +static ir_rvalue * +get_lvalue_copy(exec_list *instructions, ir_rvalue *lvalue) +{ + void *ctx = ralloc_parent(lvalue); + ir_variable *var; + + var = new(ctx) ir_variable(lvalue->type, "_post_incdec_tmp", + ir_var_temporary, precision_from_ir(lvalue)); + instructions->push_tail(var); + var->mode = ir_var_auto; + + instructions->push_tail(new(ctx) ir_assignment(new(ctx) ir_dereference_variable(var), + lvalue, NULL)); + + /* Once we've created this temporary, mark it read only so it's no + * longer considered an lvalue. + */ + var->read_only = true; + + return new(ctx) ir_dereference_variable(var); +} + + +ir_rvalue * +ast_node::hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state) +{ + (void) instructions; + (void) state; + + return NULL; +} + +static ir_rvalue * +do_comparison(void *mem_ctx, int operation, ir_rvalue *op0, ir_rvalue *op1) +{ + int join_op; + ir_rvalue *cmp = NULL; + + if (operation == ir_binop_all_equal) + join_op = ir_binop_logic_and; + else + join_op = ir_binop_logic_or; + + switch (op0->type->base_type) { + case GLSL_TYPE_FLOAT: + case GLSL_TYPE_UINT: + case GLSL_TYPE_INT: + case GLSL_TYPE_BOOL: + return new(mem_ctx) ir_expression(operation, op0, op1); + + case GLSL_TYPE_ARRAY: { + for (unsigned int i = 0; i < op0->type->length; i++) { + ir_rvalue *e0, *e1, *result; + + e0 = new(mem_ctx) ir_dereference_array(op0->clone(mem_ctx, NULL), + new(mem_ctx) ir_constant(i)); + e1 = new(mem_ctx) ir_dereference_array(op1->clone(mem_ctx, NULL), + new(mem_ctx) ir_constant(i)); + result = do_comparison(mem_ctx, operation, e0, e1); + + if (cmp) { + cmp = new(mem_ctx) ir_expression(join_op, cmp, result); + } else { + cmp = result; + } + } + + mark_whole_array_access(op0); + mark_whole_array_access(op1); + break; + } + + case GLSL_TYPE_STRUCT: { + for (unsigned int i = 0; i < op0->type->length; i++) { + ir_rvalue *e0, *e1, *result; + const char *field_name = op0->type->fields.structure[i].name; + + e0 = new(mem_ctx) ir_dereference_record(op0->clone(mem_ctx, NULL), + field_name); + e1 = new(mem_ctx) ir_dereference_record(op1->clone(mem_ctx, NULL), + field_name); + result = do_comparison(mem_ctx, operation, e0, e1); + + if (cmp) { + cmp = new(mem_ctx) ir_expression(join_op, cmp, result); + } else { + cmp = result; + } + } + break; + } + + case GLSL_TYPE_ERROR: + case GLSL_TYPE_VOID: + case GLSL_TYPE_SAMPLER: + /* I assume a comparison of a struct containing a sampler just + * ignores the sampler present in the type. + */ + break; + + default: + assert(!"Should not get here."); + break; + } + + if (cmp == NULL) + cmp = new(mem_ctx) ir_constant(true); + + return cmp; +} + +/* For logical operations, we want to ensure that the operands are + * scalar booleans. If it isn't, emit an error and return a constant + * boolean to avoid triggering cascading error messages. + */ +ir_rvalue * +get_scalar_boolean_operand(exec_list *instructions, + struct _mesa_glsl_parse_state *state, + ast_expression *parent_expr, + int operand, + const char *operand_name, + bool *error_emitted) +{ + ast_expression *expr = parent_expr->subexpressions[operand]; + void *ctx = state; + ir_rvalue *val = expr->hir(instructions, state); + + if (val->type->is_boolean() && val->type->is_scalar()) + return val; + + if (!*error_emitted) { + YYLTYPE loc = expr->get_location(); + _mesa_glsl_error(&loc, state, "%s of `%s' must be scalar boolean", + operand_name, + parent_expr->operator_string(parent_expr->oper)); + *error_emitted = true; + } + + return new(ctx) ir_constant(true); +} + +ir_rvalue * +ast_expression::hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state) +{ + void *ctx = state; + static const int operations[AST_NUM_OPERATORS] = { + -1, /* ast_assign doesn't convert to ir_expression. */ + -1, /* ast_plus doesn't convert to ir_expression. */ + ir_unop_neg, + ir_binop_add, + ir_binop_sub, + ir_binop_mul, + ir_binop_div, + ir_binop_mod, + ir_binop_lshift, + ir_binop_rshift, + ir_binop_less, + ir_binop_greater, + ir_binop_lequal, + ir_binop_gequal, + ir_binop_all_equal, + ir_binop_any_nequal, + ir_binop_bit_and, + ir_binop_bit_xor, + ir_binop_bit_or, + ir_unop_bit_not, + ir_binop_logic_and, + ir_binop_logic_xor, + ir_binop_logic_or, + ir_unop_logic_not, + + /* Note: The following block of expression types actually convert + * to multiple IR instructions. + */ + ir_binop_mul, /* ast_mul_assign */ + ir_binop_div, /* ast_div_assign */ + ir_binop_mod, /* ast_mod_assign */ + ir_binop_add, /* ast_add_assign */ + ir_binop_sub, /* ast_sub_assign */ + ir_binop_lshift, /* ast_ls_assign */ + ir_binop_rshift, /* ast_rs_assign */ + ir_binop_bit_and, /* ast_and_assign */ + ir_binop_bit_xor, /* ast_xor_assign */ + ir_binop_bit_or, /* ast_or_assign */ + + -1, /* ast_conditional doesn't convert to ir_expression. */ + ir_binop_add, /* ast_pre_inc. */ + ir_binop_sub, /* ast_pre_dec. */ + ir_binop_add, /* ast_post_inc. */ + ir_binop_sub, /* ast_post_dec. */ + -1, /* ast_field_selection doesn't conv to ir_expression. */ + -1, /* ast_array_index doesn't convert to ir_expression. */ + -1, /* ast_function_call doesn't conv to ir_expression. */ + -1, /* ast_identifier doesn't convert to ir_expression. */ + -1, /* ast_int_constant doesn't convert to ir_expression. */ + -1, /* ast_uint_constant doesn't conv to ir_expression. */ + -1, /* ast_float_constant doesn't conv to ir_expression. */ + -1, /* ast_bool_constant doesn't conv to ir_expression. */ + -1, /* ast_sequence doesn't convert to ir_expression. */ + }; + ir_rvalue *result = NULL; + ir_rvalue *op[3]; + const struct glsl_type *type; /* a temporary variable for switch cases */ + bool error_emitted = false; + YYLTYPE loc; + + loc = this->get_location(); + + switch (this->oper) { + case ast_assign: { + op[0] = this->subexpressions[0]->hir(instructions, state); + op[1] = this->subexpressions[1]->hir(instructions, state); + + result = do_assignment(instructions, state, op[0], op[1], false, + this->subexpressions[0]->get_location()); + error_emitted = result->type->is_error(); + break; + } + + case ast_plus: + op[0] = this->subexpressions[0]->hir(instructions, state); + + type = unary_arithmetic_result_type(op[0]->type, state, & loc); + + error_emitted = type->is_error(); + + result = op[0]; + break; + + case ast_neg: + op[0] = this->subexpressions[0]->hir(instructions, state); + + type = unary_arithmetic_result_type(op[0]->type, state, & loc); + + error_emitted = type->is_error(); + + result = new(ctx) ir_expression(operations[this->oper], type, + op[0], NULL); + break; + + case ast_add: + case ast_sub: + case ast_mul: + case ast_div: + op[0] = this->subexpressions[0]->hir(instructions, state); + op[1] = this->subexpressions[1]->hir(instructions, state); + + type = arithmetic_result_type(op[0], op[1], + (this->oper == ast_mul), + state, & loc); + error_emitted = type->is_error(); + + result = new(ctx) ir_expression(operations[this->oper], type, + op[0], op[1]); + break; + + case ast_mod: + op[0] = this->subexpressions[0]->hir(instructions, state); + op[1] = this->subexpressions[1]->hir(instructions, state); + + type = modulus_result_type(op[0]->type, op[1]->type, state, & loc); + + assert(operations[this->oper] == ir_binop_mod); + + result = new(ctx) ir_expression(operations[this->oper], type, + op[0], op[1]); + error_emitted = type->is_error(); + break; + + case ast_lshift: + case ast_rshift: + if (state->language_version < 130) { + _mesa_glsl_error(&loc, state, "operator %s requires GLSL 1.30", + operator_string(this->oper)); + error_emitted = true; + } + + op[0] = this->subexpressions[0]->hir(instructions, state); + op[1] = this->subexpressions[1]->hir(instructions, state); + type = shift_result_type(op[0]->type, op[1]->type, this->oper, state, + &loc); + result = new(ctx) ir_expression(operations[this->oper], type, + op[0], op[1]); + error_emitted = op[0]->type->is_error() || op[1]->type->is_error(); + break; + + case ast_less: + case ast_greater: + case ast_lequal: + case ast_gequal: + op[0] = this->subexpressions[0]->hir(instructions, state); + op[1] = this->subexpressions[1]->hir(instructions, state); + + type = relational_result_type(op[0], op[1], state, & loc); + + /* The relational operators must either generate an error or result + * in a scalar boolean. See page 57 of the GLSL 1.50 spec. + */ + assert(type->is_error() + || ((type->base_type == GLSL_TYPE_BOOL) + && type->is_scalar())); + + result = new(ctx) ir_expression(operations[this->oper], type, + op[0], op[1]); + error_emitted = type->is_error(); + break; + + case ast_nequal: + case ast_equal: + op[0] = this->subexpressions[0]->hir(instructions, state); + op[1] = this->subexpressions[1]->hir(instructions, state); + + /* From page 58 (page 64 of the PDF) of the GLSL 1.50 spec: + * + * "The equality operators equal (==), and not equal (!=) + * operate on all types. They result in a scalar Boolean. If + * the operand types do not match, then there must be a + * conversion from Section 4.1.10 "Implicit Conversions" + * applied to one operand that can make them match, in which + * case this conversion is done." + */ + if ((!apply_implicit_conversion(op[0]->type, op[1], state) + && !apply_implicit_conversion(op[1]->type, op[0], state)) + || (op[0]->type != op[1]->type)) { + _mesa_glsl_error(& loc, state, "operands of `%s' must have the same " + "type", (this->oper == ast_equal) ? "==" : "!="); + error_emitted = true; + } else if ((state->language_version <= 110) + && (op[0]->type->is_array() || op[1]->type->is_array())) { + _mesa_glsl_error(& loc, state, "array comparisons forbidden in " + "GLSL 1.10"); + error_emitted = true; + } + + if (error_emitted) { + result = new(ctx) ir_constant(false); + } else { + result = do_comparison(ctx, operations[this->oper], op[0], op[1]); + assert(result->type == glsl_type::bool_type); + } + break; + + case ast_bit_and: + case ast_bit_xor: + case ast_bit_or: + op[0] = this->subexpressions[0]->hir(instructions, state); + op[1] = this->subexpressions[1]->hir(instructions, state); + + type = bit_logic_result_type(op[0]->type, op[1]->type, this->oper, + state, &loc); + result = new(ctx) ir_expression(operations[this->oper], type, + op[0], op[1]); + error_emitted = op[0]->type->is_error() || op[1]->type->is_error(); + break; + + case ast_bit_not: + op[0] = this->subexpressions[0]->hir(instructions, state); + + if (state->language_version < 130) { + _mesa_glsl_error(&loc, state, "bit-wise operations require GLSL 1.30"); + error_emitted = true; + } + + if (!op[0]->type->is_integer()) { + _mesa_glsl_error(&loc, state, "operand of `~' must be an integer"); + error_emitted = true; + } + + type = op[0]->type; + result = new(ctx) ir_expression(ir_unop_bit_not, type, op[0], NULL); + break; + + case ast_logic_and: { + exec_list rhs_instructions; + op[0] = get_scalar_boolean_operand(instructions, state, this, 0, + "LHS", &error_emitted); + op[1] = get_scalar_boolean_operand(&rhs_instructions, state, this, 1, + "RHS", &error_emitted); + + ir_constant *op0_const = op[0]->constant_expression_value(); + if (op0_const) { + if (op0_const->value.b[0]) { + instructions->append_list(&rhs_instructions); + result = op[1]; + } else { + result = op0_const; + } + type = glsl_type::bool_type; + } else { + ir_variable *const tmp = new(ctx) ir_variable(glsl_type::bool_type, + "and_tmp", + ir_var_temporary, glsl_precision_low); + instructions->push_tail(tmp); + + ir_if *const stmt = new(ctx) ir_if(op[0]); + instructions->push_tail(stmt); + + stmt->then_instructions.append_list(&rhs_instructions); + ir_dereference *const then_deref = new(ctx) ir_dereference_variable(tmp); + ir_assignment *const then_assign = + new(ctx) ir_assignment(then_deref, op[1], NULL); + stmt->then_instructions.push_tail(then_assign); + + ir_dereference *const else_deref = new(ctx) ir_dereference_variable(tmp); + ir_assignment *const else_assign = + new(ctx) ir_assignment(else_deref, new(ctx) ir_constant(false), NULL); + stmt->else_instructions.push_tail(else_assign); + + result = new(ctx) ir_dereference_variable(tmp); + type = tmp->type; + } + break; + } + + case ast_logic_or: { + exec_list rhs_instructions; + op[0] = get_scalar_boolean_operand(instructions, state, this, 0, + "LHS", &error_emitted); + op[1] = get_scalar_boolean_operand(&rhs_instructions, state, this, 1, + "RHS", &error_emitted); + + ir_constant *op0_const = op[0]->constant_expression_value(); + if (op0_const) { + if (op0_const->value.b[0]) { + result = op0_const; + } else { + result = op[1]; + } + type = glsl_type::bool_type; + } else { + ir_variable *const tmp = new(ctx) ir_variable(glsl_type::bool_type, + "or_tmp", + ir_var_temporary, glsl_precision_low); + instructions->push_tail(tmp); + + ir_if *const stmt = new(ctx) ir_if(op[0]); + instructions->push_tail(stmt); + + ir_dereference *const then_deref = new(ctx) ir_dereference_variable(tmp); + ir_assignment *const then_assign = + new(ctx) ir_assignment(then_deref, new(ctx) ir_constant(true), NULL); + stmt->then_instructions.push_tail(then_assign); + + stmt->else_instructions.append_list(&rhs_instructions); + ir_dereference *const else_deref = new(ctx) ir_dereference_variable(tmp); + ir_assignment *const else_assign = + new(ctx) ir_assignment(else_deref, op[1], NULL); + stmt->else_instructions.push_tail(else_assign); + + result = new(ctx) ir_dereference_variable(tmp); + type = tmp->type; + } + break; + } + + case ast_logic_xor: + /* From page 33 (page 39 of the PDF) of the GLSL 1.10 spec: + * + * "The logical binary operators and (&&), or ( | | ), and + * exclusive or (^^). They operate only on two Boolean + * expressions and result in a Boolean expression." + */ + op[0] = get_scalar_boolean_operand(instructions, state, this, 0, "LHS", + &error_emitted); + op[1] = get_scalar_boolean_operand(instructions, state, this, 1, "RHS", + &error_emitted); + + result = new(ctx) ir_expression(operations[this->oper], glsl_type::bool_type, + op[0], op[1]); + break; + + case ast_logic_not: + op[0] = get_scalar_boolean_operand(instructions, state, this, 0, + "operand", &error_emitted); + + result = new(ctx) ir_expression(operations[this->oper], glsl_type::bool_type, + op[0], NULL); + break; + + case ast_mul_assign: + case ast_div_assign: + case ast_add_assign: + case ast_sub_assign: { + op[0] = this->subexpressions[0]->hir(instructions, state); + op[1] = this->subexpressions[1]->hir(instructions, state); + + type = arithmetic_result_type(op[0], op[1], + (this->oper == ast_mul_assign), + state, & loc); + + ir_rvalue *temp_rhs = new(ctx) ir_expression(operations[this->oper], type, + op[0], op[1]); + + result = do_assignment(instructions, state, + op[0]->clone(ctx, NULL), temp_rhs, false, + this->subexpressions[0]->get_location()); + error_emitted = (op[0]->type->is_error()); + + /* GLSL 1.10 does not allow array assignment. However, we don't have to + * explicitly test for this because none of the binary expression + * operators allow array operands either. + */ + + break; + } + + case ast_mod_assign: { + op[0] = this->subexpressions[0]->hir(instructions, state); + op[1] = this->subexpressions[1]->hir(instructions, state); + + type = modulus_result_type(op[0]->type, op[1]->type, state, & loc); + + assert(operations[this->oper] == ir_binop_mod); + + ir_rvalue *temp_rhs; + temp_rhs = new(ctx) ir_expression(operations[this->oper], type, + op[0], op[1]); + + result = do_assignment(instructions, state, + op[0]->clone(ctx, NULL), temp_rhs, false, + this->subexpressions[0]->get_location()); + error_emitted = type->is_error(); + break; + } + + case ast_ls_assign: + case ast_rs_assign: { + op[0] = this->subexpressions[0]->hir(instructions, state); + op[1] = this->subexpressions[1]->hir(instructions, state); + type = shift_result_type(op[0]->type, op[1]->type, this->oper, state, + &loc); + ir_rvalue *temp_rhs = new(ctx) ir_expression(operations[this->oper], + type, op[0], op[1]); + result = do_assignment(instructions, state, op[0]->clone(ctx, NULL), + temp_rhs, false, + this->subexpressions[0]->get_location()); + error_emitted = op[0]->type->is_error() || op[1]->type->is_error(); + break; + } + + case ast_and_assign: + case ast_xor_assign: + case ast_or_assign: { + op[0] = this->subexpressions[0]->hir(instructions, state); + op[1] = this->subexpressions[1]->hir(instructions, state); + type = bit_logic_result_type(op[0]->type, op[1]->type, this->oper, + state, &loc); + ir_rvalue *temp_rhs = new(ctx) ir_expression(operations[this->oper], + type, op[0], op[1]); + result = do_assignment(instructions, state, op[0]->clone(ctx, NULL), + temp_rhs, false, + this->subexpressions[0]->get_location()); + error_emitted = op[0]->type->is_error() || op[1]->type->is_error(); + break; + } + + case ast_conditional: { + /* From page 59 (page 65 of the PDF) of the GLSL 1.50 spec: + * + * "The ternary selection operator (?:). It operates on three + * expressions (exp1 ? exp2 : exp3). This operator evaluates the + * first expression, which must result in a scalar Boolean." + */ + op[0] = get_scalar_boolean_operand(instructions, state, this, 0, + "condition", &error_emitted); + + /* The :? operator is implemented by generating an anonymous temporary + * followed by an if-statement. The last instruction in each branch of + * the if-statement assigns a value to the anonymous temporary. This + * temporary is the r-value of the expression. + */ + exec_list then_instructions; + exec_list else_instructions; + + op[1] = this->subexpressions[1]->hir(&then_instructions, state); + op[2] = this->subexpressions[2]->hir(&else_instructions, state); + + /* From page 59 (page 65 of the PDF) of the GLSL 1.50 spec: + * + * "The second and third expressions can be any type, as + * long their types match, or there is a conversion in + * Section 4.1.10 "Implicit Conversions" that can be applied + * to one of the expressions to make their types match. This + * resulting matching type is the type of the entire + * expression." + */ + if ((!apply_implicit_conversion(op[1]->type, op[2], state) + && !apply_implicit_conversion(op[2]->type, op[1], state)) + || (op[1]->type != op[2]->type)) { + YYLTYPE loc = this->subexpressions[1]->get_location(); + + _mesa_glsl_error(& loc, state, "Second and third operands of ?: " + "operator must have matching types."); + error_emitted = true; + type = glsl_type::error_type; + } else { + type = op[1]->type; + } + + /* From page 33 (page 39 of the PDF) of the GLSL 1.10 spec: + * + * "The second and third expressions must be the same type, but can + * be of any type other than an array." + */ + if ((state->language_version <= 110) && type->is_array()) { + _mesa_glsl_error(& loc, state, "Second and third operands of ?: " + "operator must not be arrays."); + error_emitted = true; + } + + ir_constant *cond_val = op[0]->constant_expression_value(); + ir_constant *then_val = op[1]->constant_expression_value(); + ir_constant *else_val = op[2]->constant_expression_value(); + + if (then_instructions.is_empty() + && else_instructions.is_empty() + && (cond_val != NULL) && (then_val != NULL) && (else_val != NULL)) { + result = (cond_val->value.b[0]) ? then_val : else_val; + } else { + ir_variable *const tmp = + new(ctx) ir_variable(type, "conditional_tmp", ir_var_temporary, higher_precision(op[1], op[2])); + instructions->push_tail(tmp); + + ir_if *const stmt = new(ctx) ir_if(op[0]); + instructions->push_tail(stmt); + + then_instructions.move_nodes_to(& stmt->then_instructions); + ir_dereference *const then_deref = + new(ctx) ir_dereference_variable(tmp); + ir_assignment *const then_assign = + new(ctx) ir_assignment(then_deref, op[1], NULL); + stmt->then_instructions.push_tail(then_assign); + + else_instructions.move_nodes_to(& stmt->else_instructions); + ir_dereference *const else_deref = + new(ctx) ir_dereference_variable(tmp); + ir_assignment *const else_assign = + new(ctx) ir_assignment(else_deref, op[2], NULL); + stmt->else_instructions.push_tail(else_assign); + + result = new(ctx) ir_dereference_variable(tmp); + } + break; + } + + case ast_pre_inc: + case ast_pre_dec: { + op[0] = this->subexpressions[0]->hir(instructions, state); + if (op[0]->type->base_type == GLSL_TYPE_FLOAT) + op[1] = new(ctx) ir_constant(1.0f); + else + op[1] = new(ctx) ir_constant(1); + + type = arithmetic_result_type(op[0], op[1], false, state, & loc); + + ir_rvalue *temp_rhs; + temp_rhs = new(ctx) ir_expression(operations[this->oper], type, + op[0], op[1]); + + result = do_assignment(instructions, state, + op[0]->clone(ctx, NULL), temp_rhs, false, + this->subexpressions[0]->get_location()); + error_emitted = op[0]->type->is_error(); + break; + } + + case ast_post_inc: + case ast_post_dec: { + op[0] = this->subexpressions[0]->hir(instructions, state); + if (op[0]->type->base_type == GLSL_TYPE_FLOAT) + op[1] = new(ctx) ir_constant(1.0f); + else + op[1] = new(ctx) ir_constant(1); + + error_emitted = op[0]->type->is_error() || op[1]->type->is_error(); + + type = arithmetic_result_type(op[0], op[1], false, state, & loc); + + ir_rvalue *temp_rhs; + temp_rhs = new(ctx) ir_expression(operations[this->oper], type, + op[0], op[1]); + + /* Get a temporary of a copy of the lvalue before it's modified. + * This may get thrown away later. + */ + result = get_lvalue_copy(instructions, op[0]->clone(ctx, NULL)); + + (void)do_assignment(instructions, state, + op[0]->clone(ctx, NULL), temp_rhs, false, + this->subexpressions[0]->get_location()); + + error_emitted = op[0]->type->is_error(); + break; + } + + case ast_field_selection: + result = _mesa_ast_field_selection_to_hir(this, instructions, state); + break; + + case ast_array_index: { + YYLTYPE index_loc = subexpressions[1]->get_location(); + + op[0] = subexpressions[0]->hir(instructions, state); + op[1] = subexpressions[1]->hir(instructions, state); + + error_emitted = op[0]->type->is_error() || op[1]->type->is_error(); + + ir_rvalue *const array = op[0]; + + result = new(ctx) ir_dereference_array(op[0], op[1]); + + /* Do not use op[0] after this point. Use array. + */ + op[0] = NULL; + + + if (error_emitted) + break; + + if (!array->type->is_array() + && !array->type->is_matrix() + && !array->type->is_vector()) { + _mesa_glsl_error(& index_loc, state, + "cannot dereference non-array / non-matrix / " + "non-vector"); + error_emitted = true; + } + + if (!op[1]->type->is_integer()) { + _mesa_glsl_error(& index_loc, state, + "array index must be integer type"); + error_emitted = true; + } else if (!op[1]->type->is_scalar()) { + _mesa_glsl_error(& index_loc, state, + "array index must be scalar"); + error_emitted = true; + } + + /* If the array index is a constant expression and the array has a + * declared size, ensure that the access is in-bounds. If the array + * index is not a constant expression, ensure that the array has a + * declared size. + */ + ir_constant *const const_index = op[1]->constant_expression_value(); + if (const_index != NULL) { + const int idx = const_index->value.i[0]; + const char *type_name; + unsigned bound = 0; + + if (array->type->is_matrix()) { + type_name = "matrix"; + } else if (array->type->is_vector()) { + type_name = "vector"; + } else { + type_name = "array"; + } + + /* From page 24 (page 30 of the PDF) of the GLSL 1.50 spec: + * + * "It is illegal to declare an array with a size, and then + * later (in the same shader) index the same array with an + * integral constant expression greater than or equal to the + * declared size. It is also illegal to index an array with a + * negative constant expression." + */ + if (array->type->is_matrix()) { + if (array->type->row_type()->vector_elements <= idx) { + bound = array->type->row_type()->vector_elements; + } + } else if (array->type->is_vector()) { + if (array->type->vector_elements <= idx) { + bound = array->type->vector_elements; + } + } else { + if ((array->type->array_size() > 0) + && (array->type->array_size() <= idx)) { + bound = array->type->array_size(); + } + } + + if (bound > 0) { + _mesa_glsl_error(& loc, state, "%s index must be < %u", + type_name, bound); + error_emitted = true; + } else if (idx < 0) { + _mesa_glsl_error(& loc, state, "%s index must be >= 0", + type_name); + error_emitted = true; + } + + if (array->type->is_array()) { + /* If the array is a variable dereference, it dereferences the + * whole array, by definition. Use this to get the variable. + * + * FINISHME: Should some methods for getting / setting / testing + * FINISHME: array access limits be added to ir_dereference? + */ + ir_variable *const v = array->whole_variable_referenced(); + if ((v != NULL) && (unsigned(idx) > v->max_array_access)) + v->max_array_access = idx; + } + } else if (array->type->array_size() == 0) { + _mesa_glsl_error(&loc, state, "unsized array index must be constant"); + } else { + if (array->type->is_array()) { + /* whole_variable_referenced can return NULL if the array is a + * member of a structure. In this case it is safe to not update + * the max_array_access field because it is never used for fields + * of structures. + */ + ir_variable *v = array->whole_variable_referenced(); + if (v != NULL) + v->max_array_access = array->type->array_size() - 1; + } + } + + /* From page 23 (29 of the PDF) of the GLSL 1.30 spec: + * + * "Samplers aggregated into arrays within a shader (using square + * brackets [ ]) can only be indexed with integral constant + * expressions [...]." + * + * This restriction was added in GLSL 1.30. Shaders using earlier version + * of the language should not be rejected by the compiler front-end for + * using this construct. This allows useful things such as using a loop + * counter as the index to an array of samplers. If the loop in unrolled, + * the code should compile correctly. Instead, emit a warning. + */ + if (array->type->is_array() && + array->type->element_type()->is_sampler() && + const_index == NULL) { + + if (state->language_version == 100) { + _mesa_glsl_warning(&loc, state, + "sampler arrays indexed with non-constant " + "expressions is optional in GLSL ES 1.00"); + } else if (state->language_version < 130) { + _mesa_glsl_warning(&loc, state, + "sampler arrays indexed with non-constant " + "expressions is forbidden in GLSL 1.30 and " + "later"); + } else { + _mesa_glsl_error(&loc, state, + "sampler arrays indexed with non-constant " + "expressions is forbidden in GLSL 1.30 and " + "later"); + error_emitted = true; + } + } + + if (error_emitted) + result->type = glsl_type::error_type; + + break; + } + + case ast_function_call: + /* Should *NEVER* get here. ast_function_call should always be handled + * by ast_function_expression::hir. + */ + assert(0); + break; + + case ast_identifier: { + /* ast_identifier can appear several places in a full abstract syntax + * tree. This particular use must be at location specified in the grammar + * as 'variable_identifier'. + */ + ir_variable *var = + state->symbols->get_variable(this->primary_expression.identifier); + + result = new(ctx) ir_dereference_variable(var); + + if (var != NULL) { + var->used = true; + } else { + _mesa_glsl_error(& loc, state, "`%s' undeclared", + this->primary_expression.identifier); + + error_emitted = true; + } + break; + } + + case ast_int_constant: + result = new(ctx) ir_constant(this->primary_expression.int_constant); + break; + + case ast_uint_constant: + result = new(ctx) ir_constant(this->primary_expression.uint_constant); + break; + + case ast_float_constant: + result = new(ctx) ir_constant(this->primary_expression.float_constant); + break; + + case ast_bool_constant: + result = new(ctx) ir_constant(bool(this->primary_expression.bool_constant)); + break; + + case ast_sequence: { + /* It should not be possible to generate a sequence in the AST without + * any expressions in it. + */ + assert(!this->expressions.is_empty()); + + /* The r-value of a sequence is the last expression in the sequence. If + * the other expressions in the sequence do not have side-effects (and + * therefore add instructions to the instruction list), they get dropped + * on the floor. + */ + exec_node *previous_tail_pred = NULL; + YYLTYPE previous_operand_loc = loc; + + foreach_list_typed (ast_node, ast, link, &this->expressions) { + /* If one of the operands of comma operator does not generate any + * code, we want to emit a warning. At each pass through the loop + * previous_tail_pred will point to the last instruction in the + * stream *before* processing the previous operand. Naturally, + * instructions->tail_pred will point to the last instruction in the + * stream *after* processing the previous operand. If the two + * pointers match, then the previous operand had no effect. + * + * The warning behavior here differs slightly from GCC. GCC will + * only emit a warning if none of the left-hand operands have an + * effect. However, it will emit a warning for each. I believe that + * there are some cases in C (especially with GCC extensions) where + * it is useful to have an intermediate step in a sequence have no + * effect, but I don't think these cases exist in GLSL. Either way, + * it would be a giant hassle to replicate that behavior. + */ + if (previous_tail_pred == instructions->tail_pred) { + _mesa_glsl_warning(&previous_operand_loc, state, + "left-hand operand of comma expression has " + "no effect"); + } + + /* tail_pred is directly accessed instead of using the get_tail() + * method for performance reasons. get_tail() has extra code to + * return NULL when the list is empty. We don't care about that + * here, so using tail_pred directly is fine. + */ + previous_tail_pred = instructions->tail_pred; + previous_operand_loc = ast->get_location(); + + result = ast->hir(instructions, state); + } + + /* Any errors should have already been emitted in the loop above. + */ + error_emitted = true; + break; + } + } + type = NULL; /* use result->type, not type. */ + assert(result != NULL); + + if (result->type->is_error() && !error_emitted) + _mesa_glsl_error(& loc, state, "type mismatch"); + + return result; +} + + +ir_rvalue * +ast_expression_statement::hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state) +{ + /* It is possible to have expression statements that don't have an + * expression. This is the solitary semicolon: + * + * for (i = 0; i < 5; i++) + * ; + * + * In this case the expression will be NULL. Test for NULL and don't do + * anything in that case. + */ + if (expression != NULL) + expression->hir(instructions, state); + + /* Statements do not have r-values. + */ + return NULL; +} + + +ir_rvalue * +ast_compound_statement::hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state) +{ + if (new_scope) + state->symbols->push_scope(); + + foreach_list_typed (ast_node, ast, link, &this->statements) + ast->hir(instructions, state); + + if (new_scope) + state->symbols->pop_scope(); + + /* Compound statements do not have r-values. + */ + return NULL; +} + + +static const glsl_type * +process_array_type(YYLTYPE *loc, const glsl_type *base, ast_node *array_size, + struct _mesa_glsl_parse_state *state) +{ + unsigned length = 0; + + /* FINISHME: Reject delcarations of multidimensional arrays. */ + + if (array_size != NULL) { + exec_list dummy_instructions; + ir_rvalue *const ir = array_size->hir(& dummy_instructions, state); + YYLTYPE loc = array_size->get_location(); + + if (ir != NULL) { + if (!ir->type->is_integer()) { + _mesa_glsl_error(& loc, state, "array size must be integer type"); + } else if (!ir->type->is_scalar()) { + _mesa_glsl_error(& loc, state, "array size must be scalar type"); + } else { + ir_constant *const size = ir->constant_expression_value(); + + if (size == NULL) { + _mesa_glsl_error(& loc, state, "array size must be a " + "constant valued expression"); + } else if (size->value.i[0] <= 0) { + _mesa_glsl_error(& loc, state, "array size must be > 0"); + } else { + assert(size->type == ir->type); + length = size->value.u[0]; + + /* If the array size is const (and we've verified that + * it is) then no instructions should have been emitted + * when we converted it to HIR. If they were emitted, + * then either the array size isn't const after all, or + * we are emitting unnecessary instructions. + */ + assert(dummy_instructions.is_empty()); + } + } + } + } else if (state->es_shader) { + /* Section 10.17 of the GLSL ES 1.00 specification states that unsized + * array declarations have been removed from the language. + */ + _mesa_glsl_error(loc, state, "unsized array declarations are not " + "allowed in GLSL ES 1.00."); + } + + return glsl_type::get_array_instance(base, length); +} + + +const glsl_type * +ast_type_specifier::glsl_type(const char **name, + struct _mesa_glsl_parse_state *state) const +{ + const struct glsl_type *type; + + type = state->symbols->get_type(this->type_name); + *name = this->type_name; + + if (this->is_array) { + YYLTYPE loc = this->get_location(); + type = process_array_type(&loc, type, this->array_size, state); + } + + return type; +} + + +static void +apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual, + ir_variable *var, + struct _mesa_glsl_parse_state *state, + YYLTYPE *loc) +{ + if (qual->flags.q.invariant) { + if (var->used) { + _mesa_glsl_error(loc, state, + "variable `%s' may not be redeclared " + "`invariant' after being used", + var->name); + } else { + var->invariant = 1; + } + } + + if (qual->flags.q.constant || qual->flags.q.attribute + || qual->flags.q.uniform + || (qual->flags.q.varying && (state->target == fragment_shader))) + var->read_only = 1; + + if (qual->flags.q.centroid) + var->centroid = 1; + + if (qual->flags.q.attribute && state->target != vertex_shader) { + var->type = glsl_type::error_type; + _mesa_glsl_error(loc, state, + "`attribute' variables may not be declared in the " + "%s shader", + _mesa_glsl_shader_target_name(state->target)); + } + + /* From page 25 (page 31 of the PDF) of the GLSL 1.10 spec: + * + * "The varying qualifier can be used only with the data types + * float, vec2, vec3, vec4, mat2, mat3, and mat4, or arrays of + * these." + */ + if (qual->flags.q.varying) { + const glsl_type *non_array_type; + + if (var->type && var->type->is_array()) + non_array_type = var->type->fields.array; + else + non_array_type = var->type; + + if (non_array_type && non_array_type->base_type != GLSL_TYPE_FLOAT) { + var->type = glsl_type::error_type; + _mesa_glsl_error(loc, state, + "varying variables must be of base type float"); + } + } + + /* If there is no qualifier that changes the mode of the variable, leave + * the setting alone. + */ + if (qual->flags.q.in && qual->flags.q.out) + var->mode = ir_var_inout; + else if (qual->flags.q.attribute || qual->flags.q.in + || (qual->flags.q.varying && (state->target == fragment_shader))) + var->mode = ir_var_in; + else if (qual->flags.q.out + || (qual->flags.q.varying && (state->target == vertex_shader))) + var->mode = ir_var_out; + else if (qual->flags.q.uniform) + var->mode = ir_var_uniform; + + if (state->all_invariant && (state->current_function == NULL)) { + switch (state->target) { + case vertex_shader: + if (var->mode == ir_var_out) + var->invariant = true; + break; + case geometry_shader: + if ((var->mode == ir_var_in) || (var->mode == ir_var_out)) + var->invariant = true; + break; + case fragment_shader: + if (var->mode == ir_var_in) + var->invariant = true; + break; + } + } + + if (qual->flags.q.flat) + var->interpolation = ir_var_flat; + else if (qual->flags.q.noperspective) + var->interpolation = ir_var_noperspective; + else + var->interpolation = ir_var_smooth; + + var->pixel_center_integer = qual->flags.q.pixel_center_integer; + var->origin_upper_left = qual->flags.q.origin_upper_left; + if ((qual->flags.q.origin_upper_left || qual->flags.q.pixel_center_integer) + && (strcmp(var->name, "gl_FragCoord") != 0)) { + const char *const qual_string = (qual->flags.q.origin_upper_left) + ? "origin_upper_left" : "pixel_center_integer"; + + _mesa_glsl_error(loc, state, + "layout qualifier `%s' can only be applied to " + "fragment shader input `gl_FragCoord'", + qual_string); + } + + if (qual->flags.q.explicit_location) { + const bool global_scope = (state->current_function == NULL); + bool fail = false; + const char *string = ""; + + /* In the vertex shader only shader inputs can be given explicit + * locations. + * + * In the fragment shader only shader outputs can be given explicit + * locations. + */ + switch (state->target) { + case vertex_shader: + if (!global_scope || (var->mode != ir_var_in)) { + fail = true; + string = "input"; + } + break; + + case geometry_shader: + _mesa_glsl_error(loc, state, + "geometry shader variables cannot be given " + "explicit locations\n"); + break; + + case fragment_shader: + if (!global_scope || (var->mode != ir_var_out)) { + fail = true; + string = "output"; + } + break; + }; + + if (fail) { + _mesa_glsl_error(loc, state, + "only %s shader %s variables can be given an " + "explicit location\n", + _mesa_glsl_shader_target_name(state->target), + string); + } else { + var->explicit_location = true; + + /* This bit of silliness is needed because invalid explicit locations + * are supposed to be flagged during linking. Small negative values + * biased by VERT_ATTRIB_GENERIC0 or FRAG_RESULT_DATA0 could alias + * built-in values (e.g., -16+VERT_ATTRIB_GENERIC0 = VERT_ATTRIB_POS). + * The linker needs to be able to differentiate these cases. This + * ensures that negative values stay negative. + */ + if (qual->location >= 0) { + var->location = (state->target == vertex_shader) + ? (qual->location + VERT_ATTRIB_GENERIC0) + : (qual->location + FRAG_RESULT_DATA0); + } else { + var->location = qual->location; + } + } + } + + /* Does the declaration use the 'layout' keyword? + */ + const bool uses_layout = qual->flags.q.pixel_center_integer + || qual->flags.q.origin_upper_left + || qual->flags.q.explicit_location; + + /* Does the declaration use the deprecated 'attribute' or 'varying' + * keywords? + */ + const bool uses_deprecated_qualifier = qual->flags.q.attribute + || qual->flags.q.varying; + + /* Is the 'layout' keyword used with parameters that allow relaxed checking. + * Many implementations of GL_ARB_fragment_coord_conventions_enable and some + * implementations (only Mesa?) GL_ARB_explicit_attrib_location_enable + * allowed the layout qualifier to be used with 'varying' and 'attribute'. + * These extensions and all following extensions that add the 'layout' + * keyword have been modified to require the use of 'in' or 'out'. + * + * The following extension do not allow the deprecated keywords: + * + * GL_AMD_conservative_depth + * GL_ARB_gpu_shader5 + * GL_ARB_separate_shader_objects + * GL_ARB_tesselation_shader + * GL_ARB_transform_feedback3 + * GL_ARB_uniform_buffer_object + * + * It is unknown whether GL_EXT_shader_image_load_store or GL_NV_gpu_shader5 + * allow layout with the deprecated keywords. + */ + const bool relaxed_layout_qualifier_checking = + state->ARB_fragment_coord_conventions_enable; + + if (uses_layout && uses_deprecated_qualifier) { + if (relaxed_layout_qualifier_checking) { + _mesa_glsl_warning(loc, state, + "`layout' qualifier may not be used with " + "`attribute' or `varying'"); + } else { + _mesa_glsl_error(loc, state, + "`layout' qualifier may not be used with " + "`attribute' or `varying'"); + } + } + + /* Layout qualifiers for gl_FragDepth, which are enabled by extension + * AMD_conservative_depth. + */ + int depth_layout_count = qual->flags.q.depth_any + + qual->flags.q.depth_greater + + qual->flags.q.depth_less + + qual->flags.q.depth_unchanged; + if (depth_layout_count > 0 + && !state->AMD_conservative_depth_enable) { + _mesa_glsl_error(loc, state, + "extension GL_AMD_conservative_depth must be enabled " + "to use depth layout qualifiers"); + } else if (depth_layout_count > 0 + && strcmp(var->name, "gl_FragDepth") != 0) { + _mesa_glsl_error(loc, state, + "depth layout qualifiers can be applied only to " + "gl_FragDepth"); + } else if (depth_layout_count > 1 + && strcmp(var->name, "gl_FragDepth") == 0) { + _mesa_glsl_error(loc, state, + "at most one depth layout qualifier can be applied to " + "gl_FragDepth"); + } + if (qual->flags.q.depth_any) + var->depth_layout = ir_depth_layout_any; + else if (qual->flags.q.depth_greater) + var->depth_layout = ir_depth_layout_greater; + else if (qual->flags.q.depth_less) + var->depth_layout = ir_depth_layout_less; + else if (qual->flags.q.depth_unchanged) + var->depth_layout = ir_depth_layout_unchanged; + else + var->depth_layout = ir_depth_layout_none; + + if (var->type->is_array() && state->language_version != 110) { + var->array_lvalue = true; + } +} + +/** + * Get the variable that is being redeclared by this declaration + * + * Semantic checks to verify the validity of the redeclaration are also + * performed. If semantic checks fail, compilation error will be emitted via + * \c _mesa_glsl_error, but a non-\c NULL pointer will still be returned. + * + * \returns + * A pointer to an existing variable in the current scope if the declaration + * is a redeclaration, \c NULL otherwise. + */ +ir_variable * +get_variable_being_redeclared(ir_variable *var, ast_declaration *decl, + struct _mesa_glsl_parse_state *state) +{ + /* Check if this declaration is actually a re-declaration, either to + * resize an array or add qualifiers to an existing variable. + * + * This is allowed for variables in the current scope, or when at + * global scope (for built-ins in the implicit outer scope). + */ + ir_variable *earlier = state->symbols->get_variable(decl->identifier); + if (earlier == NULL || + (state->current_function != NULL && + !state->symbols->name_declared_this_scope(decl->identifier))) { + return NULL; + } + + + YYLTYPE loc = decl->get_location(); + + /* From page 24 (page 30 of the PDF) of the GLSL 1.50 spec, + * + * "It is legal to declare an array without a size and then + * later re-declare the same name as an array of the same + * type and specify a size." + */ + if ((earlier->type->array_size() == 0) + && var->type->is_array() + && (var->type->element_type() == earlier->type->element_type())) { + /* FINISHME: This doesn't match the qualifiers on the two + * FINISHME: declarations. It's not 100% clear whether this is + * FINISHME: required or not. + */ + + /* From page 54 (page 60 of the PDF) of the GLSL 1.20 spec: + * + * "The size [of gl_TexCoord] can be at most + * gl_MaxTextureCoords." + */ + const unsigned size = unsigned(var->type->array_size()); + if ((strcmp("gl_TexCoord", var->name) == 0) + && (size > state->Const.MaxTextureCoords)) { + _mesa_glsl_error(& loc, state, "`gl_TexCoord' array size cannot " + "be larger than gl_MaxTextureCoords (%u)\n", + state->Const.MaxTextureCoords); + } else if ((size > 0) && (size <= earlier->max_array_access)) { + _mesa_glsl_error(& loc, state, "array size must be > %u due to " + "previous access", + earlier->max_array_access); + } + + earlier->type = var->type; + delete var; + var = NULL; + } else if (state->ARB_fragment_coord_conventions_enable + && strcmp(var->name, "gl_FragCoord") == 0 + && earlier->type == var->type + && earlier->mode == var->mode) { + /* Allow redeclaration of gl_FragCoord for ARB_fcc layout + * qualifiers. + */ + earlier->origin_upper_left = var->origin_upper_left; + earlier->pixel_center_integer = var->pixel_center_integer; + + /* According to section 4.3.7 of the GLSL 1.30 spec, + * the following built-in varaibles can be redeclared with an + * interpolation qualifier: + * * gl_FrontColor + * * gl_BackColor + * * gl_FrontSecondaryColor + * * gl_BackSecondaryColor + * * gl_Color + * * gl_SecondaryColor + */ + } else if (state->language_version >= 130 + && (strcmp(var->name, "gl_FrontColor") == 0 + || strcmp(var->name, "gl_BackColor") == 0 + || strcmp(var->name, "gl_FrontSecondaryColor") == 0 + || strcmp(var->name, "gl_BackSecondaryColor") == 0 + || strcmp(var->name, "gl_Color") == 0 + || strcmp(var->name, "gl_SecondaryColor") == 0) + && earlier->type == var->type + && earlier->mode == var->mode) { + earlier->interpolation = var->interpolation; + + /* Layout qualifiers for gl_FragDepth. */ + } else if (state->AMD_conservative_depth_enable + && strcmp(var->name, "gl_FragDepth") == 0 + && earlier->type == var->type + && earlier->mode == var->mode) { + + /** From the AMD_conservative_depth spec: + * Within any shader, the first redeclarations of gl_FragDepth + * must appear before any use of gl_FragDepth. + */ + if (earlier->used) { + _mesa_glsl_error(&loc, state, + "the first redeclaration of gl_FragDepth " + "must appear before any use of gl_FragDepth"); + } + + /* Prevent inconsistent redeclaration of depth layout qualifier. */ + if (earlier->depth_layout != ir_depth_layout_none + && earlier->depth_layout != var->depth_layout) { + _mesa_glsl_error(&loc, state, + "gl_FragDepth: depth layout is declared here " + "as '%s, but it was previously declared as " + "'%s'", + depth_layout_string(var->depth_layout), + depth_layout_string(earlier->depth_layout)); + } + + earlier->depth_layout = var->depth_layout; + + } else { + _mesa_glsl_error(&loc, state, "`%s' redeclared", decl->identifier); + } + + return earlier; +} + +/** + * Generate the IR for an initializer in a variable declaration + */ +ir_rvalue * +process_initializer(ir_variable *var, ast_declaration *decl, + ast_fully_specified_type *type, + exec_list *initializer_instructions, + struct _mesa_glsl_parse_state *state) +{ + ir_rvalue *result = NULL; + + YYLTYPE initializer_loc = decl->initializer->get_location(); + + /* From page 24 (page 30 of the PDF) of the GLSL 1.10 spec: + * + * "All uniform variables are read-only and are initialized either + * directly by an application via API commands, or indirectly by + * OpenGL." + */ + if ((state->language_version <= 110) + && (var->mode == ir_var_uniform)) { + _mesa_glsl_error(& initializer_loc, state, + "cannot initialize uniforms in GLSL 1.10"); + } + + if (var->type->is_sampler()) { + _mesa_glsl_error(& initializer_loc, state, + "cannot initialize samplers"); + } + + if ((var->mode == ir_var_in) && (state->current_function == NULL)) { + _mesa_glsl_error(& initializer_loc, state, + "cannot initialize %s shader input / %s", + _mesa_glsl_shader_target_name(state->target), + (state->target == vertex_shader) + ? "attribute" : "varying"); + } + + ir_dereference *const lhs = new(state) ir_dereference_variable(var); + ir_rvalue *rhs = decl->initializer->hir(initializer_instructions, + state); + + /* Calculate the constant value if this is a const or uniform + * declaration. + */ + if (type->qualifier.flags.q.constant + || type->qualifier.flags.q.uniform) { + ir_rvalue *new_rhs = validate_assignment(state, var->type, rhs, true); + if (new_rhs != NULL) { + rhs = new_rhs; + + ir_constant *constant_value = rhs->constant_expression_value(); + if (!constant_value) { + _mesa_glsl_error(& initializer_loc, state, + "initializer of %s variable `%s' must be a " + "constant expression", + (type->qualifier.flags.q.constant) + ? "const" : "uniform", + decl->identifier); + if (var->type->is_numeric()) { + /* Reduce cascading errors. */ + var->constant_value = ir_constant::zero(state, var->type); + } + } else { + rhs = constant_value; + var->constant_value = constant_value; + } + } else { + _mesa_glsl_error(&initializer_loc, state, + "initializer of type %s cannot be assigned to " + "variable of type %s", + rhs->type->name, var->type->name); + if (var->type->is_numeric()) { + /* Reduce cascading errors. */ + var->constant_value = ir_constant::zero(state, var->type); + } + } + } + + if (rhs && !rhs->type->is_error()) { + bool temp = var->read_only; + if (type->qualifier.flags.q.constant) + var->read_only = false; + + /* Never emit code to initialize a uniform. + */ + const glsl_type *initializer_type; + if (!type->qualifier.flags.q.uniform) { + result = do_assignment(initializer_instructions, state, + lhs, rhs, true, + type->get_location()); + initializer_type = result->type; + } else + initializer_type = rhs->type; + + /* If the declared variable is an unsized array, it must inherrit + * its full type from the initializer. A declaration such as + * + * uniform float a[] = float[](1.0, 2.0, 3.0, 3.0); + * + * becomes + * + * uniform float a[4] = float[](1.0, 2.0, 3.0, 3.0); + * + * The assignment generated in the if-statement (below) will also + * automatically handle this case for non-uniforms. + * + * If the declared variable is not an array, the types must + * already match exactly. As a result, the type assignment + * here can be done unconditionally. For non-uniforms the call + * to do_assignment can change the type of the initializer (via + * the implicit conversion rules). For uniforms the initializer + * must be a constant expression, and the type of that expression + * was validated above. + */ + var->type = initializer_type; + + var->read_only = temp; + } + + return result; +} + +static void +apply_precision_to_variable(const struct ast_type_specifier *spec, + ir_variable *var, + struct _mesa_glsl_parse_state *state) +{ + if (!state->es_shader) + return; + if (var->type->is_sampler() && spec->precision == ast_precision_none) + var->precision = ast_precision_low; // samplers default to low precision + else + var->precision = spec->precision; +} + + +ir_rvalue * +ast_declarator_list::hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state) +{ + void *ctx = state; + const struct glsl_type *decl_type; + const char *type_name = NULL; + ir_rvalue *result = NULL; + YYLTYPE loc = this->get_location(); + + /* From page 46 (page 52 of the PDF) of the GLSL 1.50 spec: + * + * "To ensure that a particular output variable is invariant, it is + * necessary to use the invariant qualifier. It can either be used to + * qualify a previously declared variable as being invariant + * + * invariant gl_Position; // make existing gl_Position be invariant" + * + * In these cases the parser will set the 'invariant' flag in the declarator + * list, and the type will be NULL. + */ + if (this->invariant) { + assert(this->type == NULL); + + if (state->current_function != NULL) { + _mesa_glsl_error(& loc, state, + "All uses of `invariant' keyword must be at global " + "scope\n"); + } + + foreach_list_typed (ast_declaration, decl, link, &this->declarations) { + assert(!decl->is_array); + assert(decl->array_size == NULL); + assert(decl->initializer == NULL); + + ir_variable *const earlier = + state->symbols->get_variable(decl->identifier); + if (earlier == NULL) { + _mesa_glsl_error(& loc, state, + "Undeclared variable `%s' cannot be marked " + "invariant\n", decl->identifier); + } else if ((state->target == vertex_shader) + && (earlier->mode != ir_var_out)) { + _mesa_glsl_error(& loc, state, + "`%s' cannot be marked invariant, vertex shader " + "outputs only\n", decl->identifier); + } else if ((state->target == fragment_shader) + && (earlier->mode != ir_var_in)) { + _mesa_glsl_error(& loc, state, + "`%s' cannot be marked invariant, fragment shader " + "inputs only\n", decl->identifier); + } else if (earlier->used) { + _mesa_glsl_error(& loc, state, + "variable `%s' may not be redeclared " + "`invariant' after being used", + earlier->name); + } else { + earlier->invariant = true; + } + } + + /* Invariant redeclarations do not have r-values. + */ + return NULL; + } + + assert(this->type != NULL); + assert(!this->invariant); + + /* The type specifier may contain a structure definition. Process that + * before any of the variable declarations. + */ + (void) this->type->specifier->hir(instructions, state); + + decl_type = this->type->specifier->glsl_type(& type_name, state); + if (this->declarations.is_empty()) { + if (decl_type != NULL) { + /* Warn if this empty declaration is not for declaring a structure. + */ + if (this->type->specifier->structure == NULL) { + _mesa_glsl_warning(&loc, state, "empty declaration"); + } + } else { + _mesa_glsl_error(& loc, state, "incomplete declaration"); + } + } + + foreach_list_typed (ast_declaration, decl, link, &this->declarations) { + const struct glsl_type *var_type; + ir_variable *var; + + /* FINISHME: Emit a warning if a variable declaration shadows a + * FINISHME: declaration at a higher scope. + */ + + if ((decl_type == NULL) || decl_type->is_void()) { + if (type_name != NULL) { + _mesa_glsl_error(& loc, state, + "invalid type `%s' in declaration of `%s'", + type_name, decl->identifier); + } else { + _mesa_glsl_error(& loc, state, + "invalid type in declaration of `%s'", + decl->identifier); + } + continue; + } + + if (decl->is_array) { + var_type = process_array_type(&loc, decl_type, decl->array_size, + state); + } else { + var_type = decl_type; + } + + var = new(ctx) ir_variable(var_type, decl->identifier, ir_var_auto, (glsl_precision)this->type->specifier->precision); + + /* From page 22 (page 28 of the PDF) of the GLSL 1.10 specification; + * + * "Global variables can only use the qualifiers const, + * attribute, uni form, or varying. Only one may be + * specified. + * + * Local variables can only use the qualifier const." + * + * This is relaxed in GLSL 1.30. It is also relaxed by any extension + * that adds the 'layout' keyword. + */ + if ((state->language_version < 130) + && !state->ARB_explicit_attrib_location_enable + && !state->ARB_fragment_coord_conventions_enable) { + if (this->type->qualifier.flags.q.out) { + _mesa_glsl_error(& loc, state, + "`out' qualifier in declaration of `%s' " + "only valid for function parameters in %s.", + decl->identifier, state->version_string); + } + if (this->type->qualifier.flags.q.in) { + _mesa_glsl_error(& loc, state, + "`in' qualifier in declaration of `%s' " + "only valid for function parameters in %s.", + decl->identifier, state->version_string); + } + /* FINISHME: Test for other invalid qualifiers. */ + } + + apply_type_qualifier_to_variable(& this->type->qualifier, var, state, + & loc); + apply_precision_to_variable(this->type->specifier, var, state); + + if (this->type->qualifier.flags.q.invariant) { + if ((state->target == vertex_shader) && !(var->mode == ir_var_out || + var->mode == ir_var_inout)) { + /* FINISHME: Note that this doesn't work for invariant on + * a function signature outval + */ + _mesa_glsl_error(& loc, state, + "`%s' cannot be marked invariant, vertex shader " + "outputs only\n", var->name); + } else if ((state->target == fragment_shader) && + !(var->mode == ir_var_in || var->mode == ir_var_inout)) { + /* FINISHME: Note that this doesn't work for invariant on + * a function signature inval + */ + _mesa_glsl_error(& loc, state, + "`%s' cannot be marked invariant, fragment shader " + "inputs only\n", var->name); + } + } + + if (state->current_function != NULL) { + const char *mode = NULL; + const char *extra = ""; + + /* There is no need to check for 'inout' here because the parser will + * only allow that in function parameter lists. + */ + if (this->type->qualifier.flags.q.attribute) { + mode = "attribute"; + } else if (this->type->qualifier.flags.q.uniform) { + mode = "uniform"; + } else if (this->type->qualifier.flags.q.varying) { + mode = "varying"; + } else if (this->type->qualifier.flags.q.in) { + mode = "in"; + extra = " or in function parameter list"; + } else if (this->type->qualifier.flags.q.out) { + mode = "out"; + extra = " or in function parameter list"; + } + + if (mode) { + _mesa_glsl_error(& loc, state, + "%s variable `%s' must be declared at " + "global scope%s", + mode, var->name, extra); + } + } else if (var->mode == ir_var_in) { + var->read_only = true; + + if (state->target == vertex_shader) { + bool error_emitted = false; + + /* From page 31 (page 37 of the PDF) of the GLSL 1.50 spec: + * + * "Vertex shader inputs can only be float, floating-point + * vectors, matrices, signed and unsigned integers and integer + * vectors. Vertex shader inputs can also form arrays of these + * types, but not structures." + * + * From page 31 (page 27 of the PDF) of the GLSL 1.30 spec: + * + * "Vertex shader inputs can only be float, floating-point + * vectors, matrices, signed and unsigned integers and integer + * vectors. They cannot be arrays or structures." + * + * From page 23 (page 29 of the PDF) of the GLSL 1.20 spec: + * + * "The attribute qualifier can be used only with float, + * floating-point vectors, and matrices. Attribute variables + * cannot be declared as arrays or structures." + */ + const glsl_type *check_type = var->type->is_array() + ? var->type->fields.array : var->type; + + switch (check_type->base_type) { + case GLSL_TYPE_FLOAT: + break; + case GLSL_TYPE_UINT: + case GLSL_TYPE_INT: + if (state->language_version > 120) + break; + /* FALLTHROUGH */ + default: + _mesa_glsl_error(& loc, state, + "vertex shader input / attribute cannot have " + "type %s`%s'", + var->type->is_array() ? "array of " : "", + check_type->name); + error_emitted = true; + } + + if (!error_emitted && (state->language_version <= 130) + && var->type->is_array()) { + _mesa_glsl_error(& loc, state, + "vertex shader input / attribute cannot have " + "array type"); + error_emitted = true; + } + } + } + + /* Integer vertex outputs must be qualified with 'flat'. + * + * From section 4.3.6 of the GLSL 1.30 spec: + * "If a vertex output is a signed or unsigned integer or integer + * vector, then it must be qualified with the interpolation qualifier + * flat." + */ + if (state->language_version >= 130 + && state->target == vertex_shader + && state->current_function == NULL + && var->type->is_integer() + && var->mode == ir_var_out + && var->interpolation != ir_var_flat) { + + _mesa_glsl_error(&loc, state, "If a vertex output is an integer, " + "then it must be qualified with 'flat'"); + } + + + /* Interpolation qualifiers cannot be applied to 'centroid' and + * 'centroid varying'. + * + * From page 29 (page 35 of the PDF) of the GLSL 1.30 spec: + * "interpolation qualifiers may only precede the qualifiers in, + * centroid in, out, or centroid out in a declaration. They do not apply + * to the deprecated storage qualifiers varying or centroid varying." + */ + if (state->language_version >= 130 + && this->type->qualifier.has_interpolation() + && this->type->qualifier.flags.q.varying) { + + const char *i = this->type->qualifier.interpolation_string(); + assert(i != NULL); + const char *s; + if (this->type->qualifier.flags.q.centroid) + s = "centroid varying"; + else + s = "varying"; + + _mesa_glsl_error(&loc, state, + "qualifier '%s' cannot be applied to the " + "deprecated storage qualifier '%s'", i, s); + } + + + /* Interpolation qualifiers can only apply to vertex shader outputs and + * fragment shader inputs. + * + * From page 29 (page 35 of the PDF) of the GLSL 1.30 spec: + * "Outputs from a vertex shader (out) and inputs to a fragment + * shader (in) can be further qualified with one or more of these + * interpolation qualifiers" + */ + if (state->language_version >= 130 + && this->type->qualifier.has_interpolation()) { + + const char *i = this->type->qualifier.interpolation_string(); + assert(i != NULL); + + switch (state->target) { + case vertex_shader: + if (this->type->qualifier.flags.q.in) { + _mesa_glsl_error(&loc, state, + "qualifier '%s' cannot be applied to vertex " + "shader inputs", i); + } + break; + case fragment_shader: + if (this->type->qualifier.flags.q.out) { + _mesa_glsl_error(&loc, state, + "qualifier '%s' cannot be applied to fragment " + "shader outputs", i); + } + break; + default: + assert(0); + } + } + + + /* From section 4.3.4 of the GLSL 1.30 spec: + * "It is an error to use centroid in in a vertex shader." + */ + if (state->language_version >= 130 + && this->type->qualifier.flags.q.centroid + && this->type->qualifier.flags.q.in + && state->target == vertex_shader) { + + _mesa_glsl_error(&loc, state, + "'centroid in' cannot be used in a vertex shader"); + } + + + /* Precision qualifiers exists only in GLSL versions 1.00 and >= 1.30. + */ + if (this->type->specifier->precision != ast_precision_none + && state->language_version != 100 + && state->language_version < 130) { + + _mesa_glsl_error(&loc, state, + "precision qualifiers are supported only in GLSL ES " + "1.00, and GLSL 1.30 and later"); + } + + + /* Precision qualifiers only apply to floating point and integer types. + * + * From section 4.5.2 of the GLSL 1.30 spec: + * "Any floating point or any integer declaration can have the type + * preceded by one of these precision qualifiers [...] Literal + * constants do not have precision qualifiers. Neither do Boolean + * variables. + * + * In GLSL ES, sampler types are also allowed. + * + * From page 87 of the GLSL ES spec: + * "RESOLUTION: Allow sampler types to take a precision qualifier." + */ + if (this->type->specifier->precision != ast_precision_none + && !var->type->is_float() + && !var->type->is_integer() + && !(var->type->is_sampler() && state->es_shader) + && !(var->type->is_array() + && (var->type->fields.array->is_float() + || var->type->fields.array->is_integer()))) { + + _mesa_glsl_error(&loc, state, + "precision qualifiers apply only to floating point" + "%s types", state->es_shader ? ", integer, and sampler" + : "and integer"); + } + + /* From page 17 (page 23 of the PDF) of the GLSL 1.20 spec: + * + * "[Sampler types] can only be declared as function + * parameters or uniform variables (see Section 4.3.5 + * "Uniform")". + */ + if (var_type->contains_sampler() && + !this->type->qualifier.flags.q.uniform) { + _mesa_glsl_error(&loc, state, "samplers must be declared uniform"); + } + + /* Process the initializer and add its instructions to a temporary + * list. This list will be added to the instruction stream (below) after + * the declaration is added. This is done because in some cases (such as + * redeclarations) the declaration may not actually be added to the + * instruction stream. + */ + exec_list initializer_instructions; + ir_variable *earlier = get_variable_being_redeclared(var, decl, state); + + if (decl->initializer != NULL) { + result = process_initializer((earlier == NULL) ? var : earlier, + decl, this->type, + &initializer_instructions, state); + } + + /* From page 23 (page 29 of the PDF) of the GLSL 1.10 spec: + * + * "It is an error to write to a const variable outside of + * its declaration, so they must be initialized when + * declared." + */ + if (this->type->qualifier.flags.q.constant && decl->initializer == NULL) { + _mesa_glsl_error(& loc, state, + "const declaration of `%s' must be initialized", + decl->identifier); + } + + /* If the declaration is not a redeclaration, there are a few additional + * semantic checks that must be applied. In addition, variable that was + * created for the declaration should be added to the IR stream. + */ + if (earlier == NULL) { + /* From page 15 (page 21 of the PDF) of the GLSL 1.10 spec, + * + * "Identifiers starting with "gl_" are reserved for use by + * OpenGL, and may not be declared in a shader as either a + * variable or a function." + */ + if (strncmp(decl->identifier, "gl_", 3) == 0) + _mesa_glsl_error(& loc, state, + "identifier `%s' uses reserved `gl_' prefix", + decl->identifier); + + /* Add the variable to the symbol table. Note that the initializer's + * IR was already processed earlier (though it hasn't been emitted + * yet), without the variable in scope. + * + * This differs from most C-like languages, but it follows the GLSL + * specification. From page 28 (page 34 of the PDF) of the GLSL 1.50 + * spec: + * + * "Within a declaration, the scope of a name starts immediately + * after the initializer if present or immediately after the name + * being declared if not." + */ + if (!state->symbols->add_variable(var)) { + YYLTYPE loc = this->get_location(); + _mesa_glsl_error(&loc, state, "name `%s' already taken in the " + "current scope", decl->identifier); + continue; + } + + /* Push the variable declaration to the top. It means that all the + * variable declarations will appear in a funny last-to-first order, + * but otherwise we run into trouble if a function is prototyped, a + * global var is decled, then the function is defined with usage of + * the global var. See glslparsertest's CorrectModule.frag. + */ + instructions->push_head(var); + } + + instructions->append_list(&initializer_instructions); + } + + + /* Generally, variable declarations do not have r-values. However, + * one is used for the declaration in + * + * while (bool b = some_condition()) { + * ... + * } + * + * so we return the rvalue from the last seen declaration here. + */ + return result; +} + + +ir_rvalue * +ast_parameter_declarator::hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state) +{ + void *ctx = state; + const struct glsl_type *type; + const char *name = NULL; + YYLTYPE loc = this->get_location(); + + type = this->type->specifier->glsl_type(& name, state); + + if (type == NULL) { + if (name != NULL) { + _mesa_glsl_error(& loc, state, + "invalid type `%s' in declaration of `%s'", + name, this->identifier); + } else { + _mesa_glsl_error(& loc, state, + "invalid type in declaration of `%s'", + this->identifier); + } + + type = glsl_type::error_type; + } + + /* From page 62 (page 68 of the PDF) of the GLSL 1.50 spec: + * + * "Functions that accept no input arguments need not use void in the + * argument list because prototypes (or definitions) are required and + * therefore there is no ambiguity when an empty argument list "( )" is + * declared. The idiom "(void)" as a parameter list is provided for + * convenience." + * + * Placing this check here prevents a void parameter being set up + * for a function, which avoids tripping up checks for main taking + * parameters and lookups of an unnamed symbol. + */ + if (type->is_void()) { + if (this->identifier != NULL) + _mesa_glsl_error(& loc, state, + "named parameter cannot have type `void'"); + + is_void = true; + return NULL; + } + + if (formal_parameter && (this->identifier == NULL)) { + _mesa_glsl_error(& loc, state, "formal parameter lacks a name"); + return NULL; + } + + /* This only handles "vec4 foo[..]". The earlier specifier->glsl_type(...) + * call already handled the "vec4[..] foo" case. + */ + if (this->is_array) { + type = process_array_type(&loc, type, this->array_size, state); + } + + if (type->array_size() == 0) { + _mesa_glsl_error(&loc, state, "arrays passed as parameters must have " + "a declared size."); + type = glsl_type::error_type; + } + + is_void = false; + ir_variable *var = new(ctx) ir_variable(type, this->identifier, ir_var_in, (glsl_precision)this->type->specifier->precision); + + /* Apply any specified qualifiers to the parameter declaration. Note that + * for function parameters the default mode is 'in'. + */ + apply_type_qualifier_to_variable(& this->type->qualifier, var, state, & loc); + apply_precision_to_variable(this->type->specifier, var, state); + + /* From page 17 (page 23 of the PDF) of the GLSL 1.20 spec: + * + * "Samplers cannot be treated as l-values; hence cannot be used + * as out or inout function parameters, nor can they be assigned + * into." + */ + if ((var->mode == ir_var_inout || var->mode == ir_var_out) + && type->contains_sampler()) { + _mesa_glsl_error(&loc, state, "out and inout parameters cannot contain samplers"); + type = glsl_type::error_type; + } + + instructions->push_tail(var); + + /* Parameter declarations do not have r-values. + */ + return NULL; +} + + +void +ast_parameter_declarator::parameters_to_hir(exec_list *ast_parameters, + bool formal, + exec_list *ir_parameters, + _mesa_glsl_parse_state *state) +{ + ast_parameter_declarator *void_param = NULL; + unsigned count = 0; + + foreach_list_typed (ast_parameter_declarator, param, link, ast_parameters) { + param->formal_parameter = formal; + param->hir(ir_parameters, state); + + if (param->is_void) + void_param = param; + + count++; + } + + if ((void_param != NULL) && (count > 1)) { + YYLTYPE loc = void_param->get_location(); + + _mesa_glsl_error(& loc, state, + "`void' parameter must be only parameter"); + } +} + + +void +emit_function(_mesa_glsl_parse_state *state, ir_function *f) +{ + /* IR invariants disallow function declarations or definitions + * nested within other function definitions. But there is no + * requirement about the relative order of function declarations + * and definitions with respect to one another. So simply insert + * the new ir_function block at the end of the toplevel instruction + * list. + */ + state->toplevel_ir->push_tail(f); +} + + +ir_rvalue * +ast_function::hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state) +{ + void *ctx = state; + ir_function *f = NULL; + ir_function_signature *sig = NULL; + exec_list hir_parameters; + + const char *const name = identifier; + + /* From page 21 (page 27 of the PDF) of the GLSL 1.20 spec, + * + * "Function declarations (prototypes) cannot occur inside of functions; + * they must be at global scope, or for the built-in functions, outside + * the global scope." + * + * From page 27 (page 33 of the PDF) of the GLSL ES 1.00.16 spec, + * + * "User defined functions may only be defined within the global scope." + * + * Note that this language does not appear in GLSL 1.10. + */ + if ((state->current_function != NULL) && (state->language_version != 110)) { + YYLTYPE loc = this->get_location(); + _mesa_glsl_error(&loc, state, + "declaration of function `%s' not allowed within " + "function body", name); + } + + /* From page 15 (page 21 of the PDF) of the GLSL 1.10 spec, + * + * "Identifiers starting with "gl_" are reserved for use by + * OpenGL, and may not be declared in a shader as either a + * variable or a function." + */ + if (strncmp(name, "gl_", 3) == 0) { + YYLTYPE loc = this->get_location(); + _mesa_glsl_error(&loc, state, + "identifier `%s' uses reserved `gl_' prefix", name); + } + + /* Convert the list of function parameters to HIR now so that they can be + * used below to compare this function's signature with previously seen + * signatures for functions with the same name. + */ + ast_parameter_declarator::parameters_to_hir(& this->parameters, + is_definition, + & hir_parameters, state); + + const char *return_type_name; + const glsl_type *return_type = + this->return_type->specifier->glsl_type(& return_type_name, state); + + if (!return_type) { + YYLTYPE loc = this->get_location(); + _mesa_glsl_error(&loc, state, + "function `%s' has undeclared return type `%s'", + name, return_type_name); + return_type = glsl_type::error_type; + } + + /* From page 56 (page 62 of the PDF) of the GLSL 1.30 spec: + * "No qualifier is allowed on the return type of a function." + */ + if (this->return_type->has_qualifiers()) { + YYLTYPE loc = this->get_location(); + _mesa_glsl_error(& loc, state, + "function `%s' return type has qualifiers", name); + } + + /* From page 17 (page 23 of the PDF) of the GLSL 1.20 spec: + * + * "[Sampler types] can only be declared as function parameters + * or uniform variables (see Section 4.3.5 "Uniform")". + */ + if (return_type->contains_sampler()) { + YYLTYPE loc = this->get_location(); + _mesa_glsl_error(&loc, state, + "function `%s' return type can't contain a sampler", + name); + } + + /* Verify that this function's signature either doesn't match a previously + * seen signature for a function with the same name, or, if a match is found, + * that the previously seen signature does not have an associated definition. + */ + f = state->symbols->get_function(name); + if (f != NULL && (state->es_shader || f->has_user_signature())) { + sig = f->exact_matching_signature(&hir_parameters); + if (sig != NULL) { + const char *badvar = sig->qualifiers_match(&hir_parameters); + if (badvar != NULL) { + YYLTYPE loc = this->get_location(); + + _mesa_glsl_error(&loc, state, "function `%s' parameter `%s' " + "qualifiers don't match prototype", name, badvar); + } + + if (sig->return_type != return_type) { + YYLTYPE loc = this->get_location(); + + _mesa_glsl_error(&loc, state, "function `%s' return type doesn't " + "match prototype", name); + } + + if (is_definition && sig->is_defined) { + YYLTYPE loc = this->get_location(); + + _mesa_glsl_error(& loc, state, "function `%s' redefined", name); + } + } + } else { + f = new(ctx) ir_function(name); + if (!state->symbols->add_function(f)) { + /* This function name shadows a non-function use of the same name. */ + YYLTYPE loc = this->get_location(); + + _mesa_glsl_error(&loc, state, "function name `%s' conflicts with " + "non-function", name); + return NULL; + } + + emit_function(state, f); + } + + /* Verify the return type of main() */ + if (strcmp(name, "main") == 0) { + if (! return_type->is_void()) { + YYLTYPE loc = this->get_location(); + + _mesa_glsl_error(& loc, state, "main() must return void"); + } + + if (!hir_parameters.is_empty()) { + YYLTYPE loc = this->get_location(); + + _mesa_glsl_error(& loc, state, "main() must not take any parameters"); + } + } + + /* Finish storing the information about this new function in its signature. + */ + if (sig == NULL) { + sig = new(ctx) ir_function_signature(return_type, (glsl_precision)this->return_type->specifier->precision); + f->add_signature(sig); + } + + sig->replace_parameters(&hir_parameters); + signature = sig; + + /* Function declarations (prototypes) do not have r-values. + */ + return NULL; +} + + +ir_rvalue * +ast_function_definition::hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state) +{ + prototype->is_definition = true; + prototype->hir(instructions, state); + + ir_function_signature *signature = prototype->signature; + if (signature == NULL) + return NULL; + + assert(state->current_function == NULL); + state->current_function = signature; + state->found_return = false; + + /* Duplicate parameters declared in the prototype as concrete variables. + * Add these to the symbol table. + */ + state->symbols->push_scope(); + foreach_iter(exec_list_iterator, iter, signature->parameters) { + ir_variable *const var = ((ir_instruction *) iter.get())->as_variable(); + + assert(var != NULL); + + /* The only way a parameter would "exist" is if two parameters have + * the same name. + */ + if (state->symbols->name_declared_this_scope(var->name)) { + YYLTYPE loc = this->get_location(); + + _mesa_glsl_error(& loc, state, "parameter `%s' redeclared", var->name); + } else { + state->symbols->add_variable(var); + } + } + + /* Convert the body of the function to HIR. */ + this->body->hir(&signature->body, state); + signature->is_defined = true; + + state->symbols->pop_scope(); + + assert(state->current_function == signature); + state->current_function = NULL; + + if (!signature->return_type->is_void() && !state->found_return) { + YYLTYPE loc = this->get_location(); + _mesa_glsl_error(& loc, state, "function `%s' has non-void return type " + "%s, but no return statement", + signature->function_name(), + signature->return_type->name); + } + + /* Function definitions do not have r-values. + */ + return NULL; +} + + +ir_rvalue * +ast_jump_statement::hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state) +{ + void *ctx = state; + + switch (mode) { + case ast_return: { + ir_return *inst; + assert(state->current_function); + + if (opt_return_value) { + ir_rvalue *const ret = opt_return_value->hir(instructions, state); + + /* The value of the return type can be NULL if the shader says + * 'return foo();' and foo() is a function that returns void. + * + * NOTE: The GLSL spec doesn't say that this is an error. The type + * of the return value is void. If the return type of the function is + * also void, then this should compile without error. Seriously. + */ + const glsl_type *const ret_type = + (ret == NULL) ? glsl_type::void_type : ret->type; + + /* Implicit conversions are not allowed for return values. */ + if (state->current_function->return_type != ret_type) { + YYLTYPE loc = this->get_location(); + + _mesa_glsl_error(& loc, state, + "`return' with wrong type %s, in function `%s' " + "returning %s", + ret_type->name, + state->current_function->function_name(), + state->current_function->return_type->name); + } + + inst = new(ctx) ir_return(ret); + } else { + if (state->current_function->return_type->base_type != + GLSL_TYPE_VOID) { + YYLTYPE loc = this->get_location(); + + _mesa_glsl_error(& loc, state, + "`return' with no value, in function %s returning " + "non-void", + state->current_function->function_name()); + } + inst = new(ctx) ir_return; + } + + state->found_return = true; + instructions->push_tail(inst); + break; + } + + case ast_discard: + if (state->target != fragment_shader) { + YYLTYPE loc = this->get_location(); + + _mesa_glsl_error(& loc, state, + "`discard' may only appear in a fragment shader"); + } + instructions->push_tail(new(ctx) ir_discard); + break; + + case ast_break: + case ast_continue: + /* FINISHME: Handle switch-statements. They cannot contain 'continue', + * FINISHME: and they use a different IR instruction for 'break'. + */ + /* FINISHME: Correctly handle the nesting. If a switch-statement is + * FINISHME: inside a loop, a 'continue' is valid and will bind to the + * FINISHME: loop. + */ + if (state->loop_or_switch_nesting == NULL) { + YYLTYPE loc = this->get_location(); + + _mesa_glsl_error(& loc, state, + "`%s' may only appear in a loop", + (mode == ast_break) ? "break" : "continue"); + } else { + ir_loop *const loop = state->loop_or_switch_nesting->as_loop(); + + /* Inline the for loop expression again, since we don't know + * where near the end of the loop body the normal copy of it + * is going to be placed. + */ + if (mode == ast_continue && + state->loop_or_switch_nesting_ast->rest_expression) { + state->loop_or_switch_nesting_ast->rest_expression->hir(instructions, + state); + } + + if (loop != NULL) { + ir_loop_jump *const jump = + new(ctx) ir_loop_jump((mode == ast_break) + ? ir_loop_jump::jump_break + : ir_loop_jump::jump_continue); + instructions->push_tail(jump); + } + } + + break; + } + + /* Jump instructions do not have r-values. + */ + return NULL; +} + + +ir_rvalue * +ast_selection_statement::hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state) +{ + void *ctx = state; + + ir_rvalue *const condition = this->condition->hir(instructions, state); + + /* From page 66 (page 72 of the PDF) of the GLSL 1.50 spec: + * + * "Any expression whose type evaluates to a Boolean can be used as the + * conditional expression bool-expression. Vector types are not accepted + * as the expression to if." + * + * The checks are separated so that higher quality diagnostics can be + * generated for cases where both rules are violated. + */ + if (!condition->type->is_boolean() || !condition->type->is_scalar()) { + YYLTYPE loc = this->condition->get_location(); + + _mesa_glsl_error(& loc, state, "if-statement condition must be scalar " + "boolean"); + } + + ir_if *const stmt = new(ctx) ir_if(condition); + + if (then_statement != NULL) { + state->symbols->push_scope(); + then_statement->hir(& stmt->then_instructions, state); + state->symbols->pop_scope(); + } + + if (else_statement != NULL) { + state->symbols->push_scope(); + else_statement->hir(& stmt->else_instructions, state); + state->symbols->pop_scope(); + } + + instructions->push_tail(stmt); + + /* if-statements do not have r-values. + */ + return NULL; +} + + +void +ast_iteration_statement::condition_to_hir(ir_loop *stmt, + struct _mesa_glsl_parse_state *state) +{ + void *ctx = state; + + if (condition != NULL) { + ir_rvalue *const cond = + condition->hir(& stmt->body_instructions, state); + + if ((cond == NULL) + || !cond->type->is_boolean() || !cond->type->is_scalar()) { + YYLTYPE loc = condition->get_location(); + + _mesa_glsl_error(& loc, state, + "loop condition must be scalar boolean"); + } else { + /* As the first code in the loop body, generate a block that looks + * like 'if (!condition) break;' as the loop termination condition. + */ + ir_rvalue *const not_cond = + new(ctx) ir_expression(ir_unop_logic_not, glsl_type::bool_type, cond, + NULL); + + ir_if *const if_stmt = new(ctx) ir_if(not_cond); + + ir_jump *const break_stmt = + new(ctx) ir_loop_jump(ir_loop_jump::jump_break); + + if_stmt->then_instructions.push_tail(break_stmt); + stmt->body_instructions.push_tail(if_stmt); + } + } +} + + +ir_rvalue * +ast_iteration_statement::hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state) +{ + void *ctx = state; + + /* For-loops and while-loops start a new scope, but do-while loops do not. + */ + if (mode != ast_do_while) + state->symbols->push_scope(); + + if (init_statement != NULL) + init_statement->hir(instructions, state); + + ir_loop *const stmt = new(ctx) ir_loop(); + instructions->push_tail(stmt); + + /* Track the current loop and / or switch-statement nesting. + */ + ir_instruction *const nesting = state->loop_or_switch_nesting; + ast_iteration_statement *nesting_ast = state->loop_or_switch_nesting_ast; + + state->loop_or_switch_nesting = stmt; + state->loop_or_switch_nesting_ast = this; + + if (mode != ast_do_while) + condition_to_hir(stmt, state); + + if (body != NULL) + body->hir(& stmt->body_instructions, state); + + if (rest_expression != NULL) + rest_expression->hir(& stmt->body_instructions, state); + + if (mode == ast_do_while) + condition_to_hir(stmt, state); + + if (mode != ast_do_while) + state->symbols->pop_scope(); + + /* Restore previous nesting before returning. + */ + state->loop_or_switch_nesting = nesting; + state->loop_or_switch_nesting_ast = nesting_ast; + + /* Loops do not have r-values. + */ + return NULL; +} + + +ir_rvalue * +ast_type_specifier::hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state) +{ + if (!this->is_precision_statement && this->structure == NULL) + return NULL; + + YYLTYPE loc = this->get_location(); + + if (this->precision != ast_precision_none + && state->language_version != 100 + && state->language_version < 130) { + _mesa_glsl_error(&loc, state, + "precision qualifiers exist only in " + "GLSL ES 1.00, and GLSL 1.30 and later"); + return NULL; + } + if (this->precision != ast_precision_none + && this->structure != NULL) { + _mesa_glsl_error(&loc, state, + "precision qualifiers do not apply to structures"); + return NULL; + } + + /* If this is a precision statement, check that the type to which it is + * applied is either float or int. + * + * From section 4.5.3 of the GLSL 1.30 spec: + * "The precision statement + * precision precision-qualifier type; + * can be used to establish a default precision qualifier. The type + * field can be either int or float [...]. Any other types or + * qualifiers will result in an error. + */ + if (this->is_precision_statement) { + assert(this->precision != ast_precision_none); + assert(this->structure == NULL); /* The check for structures was + * performed above. */ + if (this->is_array) { + _mesa_glsl_error(&loc, state, + "default precision statements do not apply to " + "arrays"); + return NULL; + } + if (this->type_specifier != ast_float + && this->type_specifier != ast_int) { + _mesa_glsl_error(&loc, state, + "default precision statements apply only to types " + "float and int"); + return NULL; + } + + /* FINISHME: Translate precision statements into IR. */ + return NULL; + } + + if (this->structure != NULL) + return this->structure->hir(instructions, state); + + return NULL; +} + + +ir_rvalue * +ast_struct_specifier::hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state) +{ + unsigned decl_count = 0; + + /* Make an initial pass over the list of structure fields to determine how + * many there are. Each element in this list is an ast_declarator_list. + * This means that we actually need to count the number of elements in the + * 'declarations' list in each of the elements. + */ + foreach_list_typed (ast_declarator_list, decl_list, link, + &this->declarations) { + foreach_list_const (decl_ptr, & decl_list->declarations) { + decl_count++; + } + } + + /* Allocate storage for the structure fields and process the field + * declarations. As the declarations are processed, try to also convert + * the types to HIR. This ensures that structure definitions embedded in + * other structure definitions are processed. + */ + glsl_struct_field *const fields = ralloc_array(state, glsl_struct_field, + decl_count); + + unsigned i = 0; + foreach_list_typed (ast_declarator_list, decl_list, link, + &this->declarations) { + const char *type_name; + + decl_list->type->specifier->hir(instructions, state); + + /* Section 10.9 of the GLSL ES 1.00 specification states that + * embedded structure definitions have been removed from the language. + */ + if (state->es_shader && decl_list->type->specifier->structure != NULL) { + YYLTYPE loc = this->get_location(); + _mesa_glsl_error(&loc, state, "Embedded structure definitions are " + "not allowed in GLSL ES 1.00."); + } + + const glsl_type *decl_type = + decl_list->type->specifier->glsl_type(& type_name, state); + + foreach_list_typed (ast_declaration, decl, link, + &decl_list->declarations) { + const struct glsl_type *field_type = decl_type; + if (decl->is_array) { + YYLTYPE loc = decl->get_location(); + field_type = process_array_type(&loc, decl_type, decl->array_size, + state); + } + fields[i].type = (field_type != NULL) + ? field_type : glsl_type::error_type; + fields[i].name = decl->identifier; + fields[i].precision = (glsl_precision)decl_list->type->specifier->precision; + i++; + } + } + + assert(i == decl_count); + + const glsl_type *t = + glsl_type::get_record_instance(fields, decl_count, this->name); + + YYLTYPE loc = this->get_location(); + if (!state->symbols->add_type(name, t)) { + _mesa_glsl_error(& loc, state, "struct `%s' previously defined", name); + } else { + const glsl_type **s = reralloc(state, state->user_structures, + const glsl_type *, + state->num_user_structures + 1); + if (s != NULL) { + s[state->num_user_structures] = t; + state->user_structures = s; + state->num_user_structures++; + } + } + + /* Structure type definitions do not have r-values. + */ + return NULL; +} diff --git a/3rdparty/glsl-optimizer/src/glsl/ast_type.cpp b/3rdparty/glsl-optimizer/src/glsl/ast_type.cpp new file mode 100644 index 000000000..c680ae5f6 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/ast_type.cpp @@ -0,0 +1,138 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include "ast.h" +extern "C" { +#include "program/symbol_table.h" +} + +void +ast_type_specifier::print(void) const +{ + if (type_specifier == ast_struct) { + structure->print(); + } else { + printf("%s ", type_name); + } + + if (is_array) { + printf("[ "); + + if (array_size) { + array_size->print(); + } + + printf("] "); + } +} + +ast_type_specifier::ast_type_specifier(int specifier) + : type_specifier(ast_types(specifier)), type_name(NULL), structure(NULL), + is_array(false), array_size(NULL), precision(ast_precision_none), + is_precision_statement(false) +{ + static const char *const names[] = { + "void", + "float", + "int", + "uint", + "bool", + "vec2", + "vec3", + "vec4", + "bvec2", + "bvec3", + "bvec4", + "ivec2", + "ivec3", + "ivec4", + "uvec2", + "uvec3", + "uvec4", + "mat2", + "mat2x3", + "mat2x4", + "mat3x2", + "mat3", + "mat3x4", + "mat4x2", + "mat4x3", + "mat4", + "sampler1D", + "sampler2D", + "sampler2DRect", + "sampler3D", + "samplerCube", + "sampler1DShadow", + "sampler2DShadow", + "sampler2DRectShadow", + "samplerCubeShadow", + "sampler1DArray", + "sampler2DArray", + "sampler1DArrayShadow", + "sampler2DArrayShadow", + "isampler1D", + "isampler2D", + "isampler3D", + "isamplerCube", + "isampler1DArray", + "isampler2DArray", + "usampler1D", + "usampler2D", + "usampler3D", + "usamplerCube", + "usampler1DArray", + "usampler2DArray", + + NULL, /* ast_struct */ + NULL /* ast_type_name */ + }; + + type_name = names[specifier]; +} + +bool +ast_fully_specified_type::has_qualifiers() const +{ + return this->qualifier.flags.i != 0; +} + +bool ast_type_qualifier::has_interpolation() const +{ + return this->flags.q.smooth + || this->flags.q.flat + || this->flags.q.noperspective; +} + +const char* +ast_type_qualifier::interpolation_string() const +{ + if (this->flags.q.smooth) + return "smooth"; + else if (this->flags.q.flat) + return "flat"; + else if (this->flags.q.noperspective) + return "noperspective"; + else + return NULL; +} diff --git a/3rdparty/glsl-optimizer/src/glsl/autogen.sh b/3rdparty/glsl-optimizer/src/glsl/autogen.sh new file mode 100644 index 000000000..904cd6746 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/autogen.sh @@ -0,0 +1,12 @@ +#! /bin/sh + +srcdir=`dirname $0` +test -z "$srcdir" && srcdir=. + +ORIGDIR=`pwd` +cd $srcdir + +autoreconf -v --install || exit 1 +cd $ORIGDIR || exit $? + +$srcdir/configure --enable-maintainer-mode "$@" diff --git a/3rdparty/glsl-optimizer/src/glsl/builtin_function.cpp b/3rdparty/glsl-optimizer/src/glsl/builtin_function.cpp new file mode 100644 index 000000000..d5f6e093b --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtin_function.cpp @@ -0,0 +1,18943 @@ +/* DO NOT MODIFY - automatically generated by generate_builtins.py */ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include +#include "main/core.h" /* for struct gl_shader */ +#include "glsl_parser_extras.h" +#include "ir_reader.h" +#include "program.h" +#include "ast.h" + +extern "C" struct gl_shader * +_mesa_new_shader(struct gl_context *ctx, GLuint name, GLenum type); + +gl_shader * +read_builtins(GLenum target, const char *protos, const char **functions, unsigned count) +{ + struct gl_context fakeCtx; + fakeCtx.API = API_OPENGL; + fakeCtx.Const.GLSLVersion = 130; + fakeCtx.Extensions.ARB_ES2_compatibility = true; + gl_shader *sh = _mesa_new_shader(NULL, 0, target); + struct _mesa_glsl_parse_state *st = + new(sh) _mesa_glsl_parse_state(&fakeCtx, target, sh); + + st->language_version = 130; + st->symbols->language_version = 130; + st->ARB_texture_rectangle_enable = true; + st->EXT_texture_array_enable = true; + _mesa_glsl_initialize_types(st); + + sh->ir = new(sh) exec_list; + sh->symbols = st->symbols; + + /* Read the IR containing the prototypes */ + _mesa_glsl_read_ir(st, sh->ir, protos, true); + + /* Read ALL the function bodies, telling the IR reader not to scan for + * prototypes (we've already created them). The IR reader will skip any + * signature that does not already exist as a prototype. + */ + for (unsigned i = 0; i < count; i++) { + _mesa_glsl_read_ir(st, sh->ir, functions[i], false); + + if (st->error) { + printf("error reading builtin: %.35s ...\n", functions[i]); + printf("Info log:\n%s\n", st->info_log); + ralloc_free(sh); + return NULL; + } + } + + reparent_ir(sh->ir, sh); + delete st; + + return sh; +} + +static const char builtin_abs[] = + "((function abs\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float arg0))\n" + " ((return (expression float abs (var_ref arg0)))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 arg0))\n" + " ((return (expression vec2 abs (var_ref arg0)))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0))\n" + " ((return (expression vec3 abs (var_ref arg0)))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 arg0))\n" + " ((return (expression vec4 abs (var_ref arg0)))))\n" + "\n" + " (signature int\n" + " (parameters\n" + " (declare (in) int arg0))\n" + " ((return (expression int abs (var_ref arg0)))))\n" + "\n" + " (signature ivec2\n" + " (parameters\n" + " (declare (in) ivec2 arg0))\n" + " ((return (expression ivec2 abs (var_ref arg0)))))\n" + "\n" + " (signature ivec3\n" + " (parameters\n" + " (declare (in) ivec3 arg0))\n" + " ((return (expression ivec3 abs (var_ref arg0)))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) ivec4 arg0))\n" + " ((return (expression ivec4 abs (var_ref arg0)))))\n" + "))\n" + "" +; +static const char builtin_acos[] = + "((function acos\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ((return (expression float - (constant float (1.5707963))\n" + " (call asin ((var_ref x)))))))\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ((return (expression vec2 - (constant float (1.5707963))\n" + " (call asin ((var_ref x)))))))\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ((return (expression vec3 - (constant float (1.5707963))\n" + " (call asin ((var_ref x)))))))\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ((return (expression vec4 - (constant float (1.5707963))\n" + " (call asin ((var_ref x)))))))\n" + "))\n" + "" +; +static const char builtin_acosh[] = + "((function acosh\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ((return (expression float log (expression float + (var_ref x) (expression float sqrt (expression float - (expression float * (var_ref x) (var_ref x)) (constant float (1)))))))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ((return (expression vec2 log (expression vec2 + (var_ref x) (expression vec2 sqrt (expression vec2 - (expression vec2 * (var_ref x) (var_ref x)) (constant vec2 (1)))))))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ((return (expression vec3 log (expression vec3 + (var_ref x) (expression vec3 sqrt (expression vec3 - (expression vec3 * (var_ref x) (var_ref x)) (constant vec3 (1)))))))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ((return (expression vec4 log (expression vec4 + (var_ref x) (expression vec4 sqrt (expression vec4 - (expression vec4 * (var_ref x) (var_ref x)) (constant vec4 (1)))))))))\n" + "))\n" + "" +; +static const char builtin_all[] = + "((function all\n" + " (signature bool\n" + " (parameters\n" + " (declare (in) bvec2 arg0))\n" + " ((return (expression bool && (swiz x (var_ref arg0))(swiz y (var_ref arg0))))))\n" + "\n" + " (signature bool\n" + " (parameters\n" + " (declare (in) bvec3 arg0))\n" + " ((return (expression bool && (expression bool && (swiz x (var_ref arg0))(swiz y (var_ref arg0))) (swiz z (var_ref arg0))))))\n" + "\n" + " (signature bool\n" + " (parameters\n" + " (declare (in) bvec4 arg0))\n" + " ((return (expression bool && (expression bool && (expression bool && (swiz x (var_ref arg0))(swiz y (var_ref arg0))) (swiz z (var_ref arg0))) (swiz w (var_ref arg0))))))\n" + "))\n" + "" +; +static const char builtin_any[] = + "((function any\n" + " (signature bool\n" + " (parameters\n" + " (declare (in) bvec2 arg0))\n" + " ((return (expression bool any (var_ref arg0)))))\n" + "\n" + " (signature bool\n" + " (parameters\n" + " (declare (in) bvec3 arg0))\n" + " ((return (expression bool any (var_ref arg0)))))\n" + "\n" + " (signature bool\n" + " (parameters\n" + " (declare (in) bvec4 arg0))\n" + " ((return (expression bool any (var_ref arg0)))))\n" + "))\n" + "" +; +static const char builtin_asin[] = + "((function asin\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ((return (expression float *\n" + " (expression float sign (var_ref x))\n" + " (expression float -\n" + " (constant float (1.5707964))\n" + " (expression float *\n" + " (expression float sqrt\n" + " (expression float -\n" + " (constant float (1.0))\n" + " (expression float abs (var_ref x))))\n" + " (expression float +\n" + " (constant float (1.5707964))\n" + " (expression float *\n" + " (expression float abs (var_ref x))\n" + " (expression float +\n" + " (constant float (-0.21460183))\n" + " (expression float *\n" + " (expression float abs (var_ref x))\n" + " (expression float +\n" + " (constant float (0.086566724))\n" + " (expression float *\n" + " (expression float abs (var_ref x))\n" + " (constant float (-0.03102955))\n" + " ))))))))))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ((return (expression vec2 *\n" + " (expression vec2 sign (var_ref x))\n" + " (expression vec2 -\n" + " (constant float (1.5707964))\n" + " (expression vec2 *\n" + " (expression vec2 sqrt\n" + " (expression vec2 -\n" + " (constant float (1.0))\n" + " (expression vec2 abs (var_ref x))))\n" + " (expression vec2 +\n" + " (constant float (1.5707964))\n" + " (expression vec2 *\n" + " (expression vec2 abs (var_ref x))\n" + " (expression vec2 +\n" + " (constant float (-0.21460183))\n" + " (expression vec2 *\n" + " (expression vec2 abs (var_ref x))\n" + " (expression vec2 +\n" + " (constant float (0.086566724))\n" + " (expression vec2 *\n" + " (expression vec2 abs (var_ref x))\n" + " (constant float (-0.03102955))\n" + " ))))))))))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ((return (expression vec3 *\n" + " (expression vec3 sign (var_ref x))\n" + " (expression vec3 -\n" + " (constant float (1.5707964))\n" + " (expression vec3 *\n" + " (expression vec3 sqrt\n" + " (expression vec3 -\n" + " (constant float (1.0))\n" + " (expression vec3 abs (var_ref x))))\n" + " (expression vec3 +\n" + " (constant float (1.5707964))\n" + " (expression vec3 *\n" + " (expression vec3 abs (var_ref x))\n" + " (expression vec3 +\n" + " (constant float (-0.21460183))\n" + " (expression vec3 *\n" + " (expression vec3 abs (var_ref x))\n" + " (expression vec3 +\n" + " (constant float (0.086566724))\n" + " (expression vec3 *\n" + " (expression vec3 abs (var_ref x))\n" + " (constant float (-0.03102955))\n" + " ))))))))))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ((return (expression vec4 *\n" + " (expression vec4 sign (var_ref x))\n" + " (expression vec4 -\n" + " (constant float (1.5707964))\n" + " (expression vec4 *\n" + " (expression vec4 sqrt\n" + " (expression vec4 -\n" + " (constant float (1.0))\n" + " (expression vec4 abs (var_ref x))))\n" + " (expression vec4 +\n" + " (constant float (1.5707964))\n" + " (expression vec4 *\n" + " (expression vec4 abs (var_ref x))\n" + " (expression vec4 +\n" + " (constant float (-0.21460183))\n" + " (expression vec4 *\n" + " (expression vec4 abs (var_ref x))\n" + " (expression vec4 +\n" + " (constant float (0.086566724))\n" + " (expression vec4 *\n" + " (expression vec4 abs (var_ref x))\n" + " (constant float (-0.03102955))\n" + " ))))))))))))\n" + "))\n" + "" +; +static const char builtin_asinh[] = + "((function asinh\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ((return (expression float log (expression float + (var_ref x) (expression float sqrt (expression float + (expression float * (var_ref x) (var_ref x)) (constant float (1)))))))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ((return (expression vec2 log (expression vec2 + (var_ref x) (expression vec2 sqrt (expression vec2 + (expression vec2 * (var_ref x) (var_ref x)) (constant vec2 (1)))))))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ((return (expression vec3 log (expression vec3 + (var_ref x) (expression vec3 sqrt (expression vec3 + (expression vec3 * (var_ref x) (var_ref x)) (constant vec3 (1)))))))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ((return (expression vec4 log (expression vec4 + (var_ref x) (expression vec4 sqrt (expression vec4 + (expression vec4 * (var_ref x) (var_ref x)) (constant vec4 (1)))))))))\n" + "))\n" + "" +; +static const char builtin_atan[] = + "((function atan\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float y_over_x))\n" + " ((return (call asin ((expression float *\n" + " (var_ref y_over_x)\n" + " (expression float rsq\n" + " (expression float +\n" + " (expression float *\n" + " (var_ref y_over_x)\n" + " (var_ref y_over_x))\n" + " (constant float (1.0))))))))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 y_over_x))\n" + " ((return (call asin ((expression vec2 *\n" + " (var_ref y_over_x)\n" + " (expression vec2 rsq\n" + " (expression vec2 +\n" + " (expression vec2 *\n" + " (var_ref y_over_x)\n" + " (var_ref y_over_x))\n" + " (constant float (1.0))))))))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 y_over_x))\n" + " ((return (call asin ((expression vec3 *\n" + " (var_ref y_over_x)\n" + " (expression vec3 rsq\n" + " (expression vec3 +\n" + " (expression vec3 *\n" + " (var_ref y_over_x)\n" + " (var_ref y_over_x))\n" + " (constant float (1.0))))))))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 y_over_x))\n" + " ((return (call asin ((expression vec4 *\n" + " (var_ref y_over_x)\n" + " (expression vec4 rsq\n" + " (expression vec4 +\n" + " (expression vec4 *\n" + " (var_ref y_over_x)\n" + " (var_ref y_over_x))\n" + " (constant float (1.0))))))))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in ) float y)\n" + " (declare (in ) float x)\n" + " )\n" + " (\n" + " (declare () float r)\n" + " (if (expression bool >\n" + " (expression float abs (var_ref x))\n" + " (expression float * (constant float (1.0e-8)) (expression float abs (var_ref y)))) (\n" + " (assign (x) (var_ref r) (call atan ((expression float / (var_ref y) (var_ref x)))))\n" + " (if (expression bool < (var_ref x) (constant float (0.000000)) ) (\n" + " (if (expression bool >= (var_ref y) (constant float (0.000000)) )\n" + " ((assign (x) (var_ref r) (expression float + (var_ref r) (constant float (3.141593)))))\n" + " ((assign (x) (var_ref r) (expression float - (var_ref r) (constant float (3.141593))))))\n" + " )\n" + " (\n" + " ))\n" + " )\n" + " (\n" + " (declare () float sgn)\n" + " (assign (x) (var_ref sgn) (expression float sign (var_ref y)))\n" + " (assign (x) (var_ref r) (expression float * (var_ref sgn) (constant float (1.5707965))))\n" + " ))\n" + "\n" + " (return (var_ref r) )\n" + " ))\n" + "\n" + "\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 y)\n" + " (declare (in) vec2 x))\n" + " ((declare () vec2 r)\n" + " (assign (x) (var_ref r)\n" + " (call atan ((swiz x (var_ref y))\n" + " (swiz x (var_ref x)))))\n" + " (assign (y) (var_ref r)\n" + " (call atan ((swiz y (var_ref y))\n" + " (swiz y (var_ref x)))))\n" + " (return (var_ref r))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 y)\n" + " (declare (in) vec3 x))\n" + " ((declare () vec3 r)\n" + " (assign (x) (var_ref r)\n" + " (call atan ((swiz x (var_ref y))\n" + " (swiz x (var_ref x)))))\n" + " (assign (y) (var_ref r)\n" + " (call atan ((swiz y (var_ref y))\n" + " (swiz y (var_ref x)))))\n" + " (assign (z) (var_ref r)\n" + " (call atan ((swiz z (var_ref y))\n" + " (swiz z (var_ref x)))))\n" + " (return (var_ref r))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 y)\n" + " (declare (in) vec4 x))\n" + " ((declare () vec4 r)\n" + " (assign (x) (var_ref r)\n" + " (call atan ((swiz x (var_ref y))\n" + " (swiz x (var_ref x)))))\n" + " (assign (y) (var_ref r)\n" + " (call atan ((swiz y (var_ref y))\n" + " (swiz y (var_ref x)))))\n" + " (assign (z) (var_ref r)\n" + " (call atan ((swiz z (var_ref y))\n" + " (swiz z (var_ref x)))))\n" + " (assign (w) (var_ref r)\n" + " (call atan ((swiz w (var_ref y))\n" + " (swiz w (var_ref x)))))\n" + " (return (var_ref r)))))\n" + "\n" + "))\n" + "" +; +static const char builtin_atanh[] = + "((function atanh\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ((return (expression float * (constant float (0.5))\n" + " (expression float log\n" + " (expression float /\n" + " (expression float + (constant float (1)) (var_ref x))\n" + " (expression float - (constant float (1)) (var_ref x))))))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ((return (expression vec2 * (constant vec2 (0.5))\n" + " (expression vec2 log\n" + " (expression vec2 /\n" + " (expression vec2 + (constant vec2 (1)) (var_ref x))\n" + " (expression vec2 - (constant vec2 (1)) (var_ref x))))))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ((return (expression vec3 * (constant vec3 (0.5))\n" + " (expression vec3 log\n" + " (expression vec3 /\n" + " (expression vec3 + (constant vec3 (1)) (var_ref x))\n" + " (expression vec3 - (constant vec3 (1)) (var_ref x))))))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ((return (expression vec4 * (constant vec4 (0.5))\n" + " (expression vec4 log\n" + " (expression vec4 /\n" + " (expression vec4 + (constant vec4 (1)) (var_ref x))\n" + " (expression vec4 - (constant vec4 (1)) (var_ref x))))))))\n" + "))\n" + "" +; +static const char builtin_ceil[] = + "((function ceil\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float arg0))\n" + " ((return (expression float ceil (var_ref arg0)))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 arg0))\n" + " ((return (expression vec2 ceil (var_ref arg0)))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0))\n" + " ((return (expression vec3 ceil (var_ref arg0)))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 arg0))\n" + " ((return (expression vec4 ceil (var_ref arg0)))))\n" + "))\n" + "" +; +static const char builtin_clamp[] = + "((function clamp\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float arg0)\n" + " (declare (in) float arg1)\n" + " (declare (in) float arg2))\n" + " ((return (expression float max (expression float min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 arg0)\n" + " (declare (in) vec2 arg1)\n" + " (declare (in) vec2 arg2))\n" + " ((return (expression vec2 max (expression vec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0)\n" + " (declare (in) vec3 arg1)\n" + " (declare (in) vec3 arg2))\n" + " ((return (expression vec3 max (expression vec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 arg0)\n" + " (declare (in) vec4 arg1)\n" + " (declare (in) vec4 arg2))\n" + " ((return (expression vec4 max (expression vec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 arg0)\n" + " (declare (in) float arg1)\n" + " (declare (in) float arg2))\n" + " ((return (expression vec2 max (expression vec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0)\n" + " (declare (in) float arg1)\n" + " (declare (in) float arg2))\n" + " ((return (expression vec3 max (expression vec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 arg0)\n" + " (declare (in) float arg1)\n" + " (declare (in) float arg2))\n" + " ((return (expression vec4 max (expression vec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" + "\n" + " (signature int\n" + " (parameters\n" + " (declare (in) int arg0)\n" + " (declare (in) int arg1)\n" + " (declare (in) int arg2))\n" + " ((return (expression int max (expression int min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" + "\n" + " (signature ivec2\n" + " (parameters\n" + " (declare (in) ivec2 arg0)\n" + " (declare (in) ivec2 arg1)\n" + " (declare (in) ivec2 arg2))\n" + " ((return (expression ivec2 max (expression ivec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" + "\n" + " (signature ivec3\n" + " (parameters\n" + " (declare (in) ivec3 arg0)\n" + " (declare (in) ivec3 arg1)\n" + " (declare (in) ivec3 arg2))\n" + " ((return (expression ivec3 max (expression ivec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) ivec4 arg0)\n" + " (declare (in) ivec4 arg1)\n" + " (declare (in) ivec4 arg2))\n" + " ((return (expression ivec4 max (expression ivec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" + "\n" + " (signature ivec2\n" + " (parameters\n" + " (declare (in) ivec2 arg0)\n" + " (declare (in) int arg1)\n" + " (declare (in) int arg2))\n" + " ((return (expression ivec2 max (expression ivec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" + "\n" + " (signature ivec3\n" + " (parameters\n" + " (declare (in) ivec3 arg0)\n" + " (declare (in) int arg1)\n" + " (declare (in) int arg2))\n" + " ((return (expression ivec3 max (expression ivec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) ivec4 arg0)\n" + " (declare (in) int arg1)\n" + " (declare (in) int arg2))\n" + " ((return (expression ivec4 max (expression ivec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" + "\n" + " (signature uint\n" + " (parameters\n" + " (declare (in) uint arg0)\n" + " (declare (in) uint arg1)\n" + " (declare (in) uint arg2))\n" + " ((return (expression uint max (expression uint min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" + "\n" + " (signature uvec2\n" + " (parameters\n" + " (declare (in) uvec2 arg0)\n" + " (declare (in) uvec2 arg1)\n" + " (declare (in) uvec2 arg2))\n" + " ((return (expression uvec2 max (expression uvec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" + "\n" + " (signature uvec3\n" + " (parameters\n" + " (declare (in) uvec3 arg0)\n" + " (declare (in) uvec3 arg1)\n" + " (declare (in) uvec3 arg2))\n" + " ((return (expression uvec3 max (expression uvec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) uvec4 arg0)\n" + " (declare (in) uvec4 arg1)\n" + " (declare (in) uvec4 arg2))\n" + " ((return (expression uvec4 max (expression uvec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" + "\n" + " (signature uvec2\n" + " (parameters\n" + " (declare (in) uvec2 arg0)\n" + " (declare (in) uint arg1)\n" + " (declare (in) uint arg2))\n" + " ((return (expression uvec2 max (expression uvec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" + "\n" + " (signature uvec3\n" + " (parameters\n" + " (declare (in) uvec3 arg0)\n" + " (declare (in) uint arg1)\n" + " (declare (in) uint arg2))\n" + " ((return (expression uvec3 max (expression uvec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) uvec4 arg0)\n" + " (declare (in) uint arg1)\n" + " (declare (in) uint arg2))\n" + " ((return (expression uvec4 max (expression uvec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n" + "))\n" + "" +; +static const char builtin_cos[] = + "((function cos\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float angle))\n" + " ((return (expression float cos (var_ref angle)))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 angle))\n" + " ((return (expression vec2 cos (var_ref angle)))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 angle))\n" + " ((return (expression vec3 cos (var_ref angle)))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 angle))\n" + " ((return (expression vec4 cos (var_ref angle)))))\n" + "))\n" + "" +; +static const char builtin_cosh[] = + "((function cosh\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ((return (expression float * (constant float (0.5))\n" + " (expression float +\n" + " (expression float exp (var_ref x))\n" + " (expression float exp (expression float neg (var_ref x))))))))\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ((return (expression vec2 * (constant vec2 (0.5))\n" + " (expression vec2 +\n" + " (expression vec2 exp (var_ref x))\n" + " (expression vec2 exp (expression vec2 neg (var_ref x))))))))\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ((return (expression vec3 * (constant vec3 (0.5))\n" + " (expression vec3 +\n" + " (expression vec3 exp (var_ref x))\n" + " (expression vec3 exp (expression vec3 neg (var_ref x))))))))\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ((return (expression vec4 * (constant vec4 (0.5))\n" + " (expression vec4 +\n" + " (expression vec4 exp (var_ref x))\n" + " (expression vec4 exp (expression vec4 neg (var_ref x))))))))\n" + "))\n" + "" +; +static const char builtin_cross[] = + "((function cross\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 a)\n" + " (declare (in) vec3 b))\n" + " ((return (expression vec3 -\n" + " (expression vec3 * (swiz yzx (var_ref a)) (swiz zxy (var_ref b)))\n" + " (expression vec3 * (swiz zxy (var_ref a)) (swiz yzx (var_ref b)))))))\n" + "))\n" + "" +; +static const char builtin_dFdx[] = + "((function dFdx\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float p))\n" + " ((return (expression float dFdx (var_ref p)))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 p))\n" + " ((return (expression vec2 dFdx (var_ref p)))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 p))\n" + " ((return (expression vec3 dFdx (var_ref p)))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 p))\n" + " ((return (expression vec4 dFdx (var_ref p)))))\n" + "))\n" + "" +; +static const char builtin_dFdy[] = + "((function dFdy\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float p))\n" + " ((return (expression float dFdy (var_ref p)))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 p))\n" + " ((return (expression vec2 dFdy (var_ref p)))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 p))\n" + " ((return (expression vec3 dFdy (var_ref p)))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 p))\n" + " ((return (expression vec4 dFdy (var_ref p)))))\n" + "))\n" + "" +; +static const char builtin_degrees[] = + "((function degrees\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float arg0))\n" + " ((return (expression float * (var_ref arg0) (constant float (57.295780))))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 arg0))\n" + " ((return (expression vec2 * (var_ref arg0) (constant float (57.295780))))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0))\n" + " ((return (expression vec3 * (var_ref arg0) (constant float (57.295780))))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 arg0))\n" + " ((return (expression vec4 * (var_ref arg0) (constant float (57.295780))))))\n" + "))\n" + "" +; +static const char builtin_distance[] = + "((function distance\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float p0)\n" + " (declare (in) float p1))\n" + " ((return (expression float abs (expression float - (var_ref p0) (var_ref p1))))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec2 p0)\n" + " (declare (in) vec2 p1))\n" + " ((declare () vec2 p)\n" + " (assign (xy) (var_ref p) (expression vec2 - (var_ref p0) (var_ref p1)))\n" + " (return (expression float sqrt (expression float dot (var_ref p) (var_ref p))))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec3 p0)\n" + " (declare (in) vec3 p1))\n" + " ((declare () vec3 p)\n" + " (assign (xyz) (var_ref p) (expression vec3 - (var_ref p0) (var_ref p1)))\n" + " (return (expression float sqrt (expression float dot (var_ref p) (var_ref p))))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec4 p0)\n" + " (declare (in) vec4 p1))\n" + " ((declare () vec4 p)\n" + " (assign (xyzw) (var_ref p) (expression vec4 - (var_ref p0) (var_ref p1)))\n" + " (return (expression float sqrt (expression float dot (var_ref p) (var_ref p))))))\n" + "))\n" + "" +; +static const char builtin_dot[] = + "((function dot\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float arg0)\n" + " (declare (in) float arg1))\n" + " ((return (expression float * (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec2 arg0)\n" + " (declare (in) vec2 arg1))\n" + " ((return (expression float dot (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec3 arg0)\n" + " (declare (in) vec3 arg1))\n" + " ((return (expression float dot (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec4 arg0)\n" + " (declare (in) vec4 arg1))\n" + " ((return (expression float dot (var_ref arg0) (var_ref arg1)))))\n" + "))\n" + "" +; +static const char builtin_equal[] = + "((function equal\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) vec2 arg0)\n" + " (declare (in) vec2 arg1))\n" + " ((return (expression bvec2 == (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) vec3 arg0)\n" + " (declare (in) vec3 arg1))\n" + " ((return (expression bvec3 == (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) vec4 arg0)\n" + " (declare (in) vec4 arg1))\n" + " ((return (expression bvec4 == (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) bvec2 arg0)\n" + " (declare (in) bvec2 arg1))\n" + " ((return (expression bvec2 == (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) bvec3 arg0)\n" + " (declare (in) bvec3 arg1))\n" + " ((return (expression bvec3 == (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) bvec4 arg0)\n" + " (declare (in) bvec4 arg1))\n" + " ((return (expression bvec4 == (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) ivec2 arg0)\n" + " (declare (in) ivec2 arg1))\n" + " ((return (expression bvec2 == (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) ivec3 arg0)\n" + " (declare (in) ivec3 arg1))\n" + " ((return (expression bvec3 == (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) ivec4 arg0)\n" + " (declare (in) ivec4 arg1))\n" + " ((return (expression bvec4 == (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) uvec2 arg0)\n" + " (declare (in) uvec2 arg1))\n" + " ((return (expression bvec2 == (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) uvec3 arg0)\n" + " (declare (in) uvec3 arg1))\n" + " ((return (expression bvec3 == (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) uvec4 arg0)\n" + " (declare (in) uvec4 arg1))\n" + " ((return (expression bvec4 == (var_ref arg0) (var_ref arg1)))))\n" + "))\n" + "" +; +static const char builtin_exp[] = + "((function exp\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float arg0))\n" + " ((return (expression float exp (var_ref arg0)))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 arg0))\n" + " ((return (expression vec2 exp (var_ref arg0)))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0))\n" + " ((return (expression vec3 exp (var_ref arg0)))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 arg0))\n" + " ((return (expression vec4 exp (var_ref arg0)))))\n" + "))\n" + "" +; +static const char builtin_exp2[] = + "((function exp2\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float arg0))\n" + " ((return (expression float exp2 (var_ref arg0)))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 arg0))\n" + " ((return (expression vec2 exp2 (var_ref arg0)))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0))\n" + " ((return (expression vec3 exp2 (var_ref arg0)))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 arg0))\n" + " ((return (expression vec4 exp2 (var_ref arg0)))))\n" + "))\n" + "" +; +static const char builtin_faceforward[] = + "((function faceforward\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float N)\n" + " (declare (in) float I)\n" + " (declare (in) float Nref))\n" + " ((if (expression bool < (expression float * (var_ref Nref) (var_ref I)) (constant float (0)))\n" + " ((return (var_ref N)))\n" + " ((return (expression float neg (var_ref N)))))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 N)\n" + " (declare (in) vec2 I)\n" + " (declare (in) vec2 Nref))\n" + " ((if (expression bool < (expression float dot (var_ref Nref) (var_ref I)) (constant float (0)))\n" + " ((return (var_ref N)))\n" + " ((return (expression vec2 neg (var_ref N)))))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 N)\n" + " (declare (in) vec3 I)\n" + " (declare (in) vec3 Nref))\n" + " ((if (expression bool < (expression float dot (var_ref Nref) (var_ref I)) (constant float (0)))\n" + " ((return (var_ref N)))\n" + " ((return (expression vec3 neg (var_ref N)))))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 N)\n" + " (declare (in) vec4 I)\n" + " (declare (in) vec4 Nref))\n" + " ((if (expression bool < (expression float dot (var_ref Nref) (var_ref I)) (constant float (0)))\n" + " ((return (var_ref N)))\n" + " ((return (expression vec4 neg (var_ref N)))))))\n" + "))\n" + "" +; +static const char builtin_floor[] = + "((function floor\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float arg0))\n" + " ((return (expression float floor (var_ref arg0)))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 arg0))\n" + " ((return (expression vec2 floor (var_ref arg0)))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0))\n" + " ((return (expression vec3 floor (var_ref arg0)))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 arg0))\n" + " ((return (expression vec4 floor (var_ref arg0)))))\n" + "))\n" + "" +; +static const char builtin_fract[] = + "((function fract\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ((return (expression float fract (var_ref x)))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ((return (expression vec2 fract (var_ref x)))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ((return (expression vec3 fract (var_ref x)))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ((return (expression vec4 fract (var_ref x)))))\n" + "))\n" + "\n" + "" +; +static const char builtin_ftransform[] = + "((declare (uniform) mat4 gl_ModelViewProjectionMatrix)\n" + " (declare (in) vec4 gl_Vertex)\n" + " (function ftransform\n" + " (signature vec4\n" + " (parameters)\n" + " ((return (expression vec4 *\n" + " (var_ref gl_ModelViewProjectionMatrix)\n" + " (var_ref gl_Vertex)))))\n" + "))\n" + "" +; +static const char builtin_fwidth[] = + "((function fwidth\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float p))\n" + " ((return (expression float +\n" + " (expression float abs (expression float dFdx (var_ref p)))\n" + " (expression float abs (expression float dFdy (var_ref p)))))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 p))\n" + " ((return (expression vec2 +\n" + " (expression vec2 abs (expression vec2 dFdx (var_ref p)))\n" + " (expression vec2 abs (expression vec2 dFdy (var_ref p)))))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 p))\n" + " ((return (expression vec3 +\n" + " (expression vec3 abs (expression vec3 dFdx (var_ref p)))\n" + " (expression vec3 abs (expression vec3 dFdy (var_ref p)))))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 p))\n" + " ((return (expression vec4 +\n" + " (expression vec4 abs (expression vec4 dFdx (var_ref p)))\n" + " (expression vec4 abs (expression vec4 dFdy (var_ref p)))))))\n" + "))\n" + "" +; +static const char builtin_greaterThan[] = + "((function greaterThan\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) vec2 arg0)\n" + " (declare (in) vec2 arg1))\n" + " ((return (expression bvec2 > (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) vec3 arg0)\n" + " (declare (in) vec3 arg1))\n" + " ((return (expression bvec3 > (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) vec4 arg0)\n" + " (declare (in) vec4 arg1))\n" + " ((return (expression bvec4 > (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) ivec2 arg0)\n" + " (declare (in) ivec2 arg1))\n" + " ((return (expression bvec2 > (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) ivec3 arg0)\n" + " (declare (in) ivec3 arg1))\n" + " ((return (expression bvec3 > (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) ivec4 arg0)\n" + " (declare (in) ivec4 arg1))\n" + " ((return (expression bvec4 > (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) uvec2 arg0)\n" + " (declare (in) uvec2 arg1))\n" + " ((return (expression bvec2 > (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) uvec3 arg0)\n" + " (declare (in) uvec3 arg1))\n" + " ((return (expression bvec3 > (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) uvec4 arg0)\n" + " (declare (in) uvec4 arg1))\n" + " ((return (expression bvec4 > (var_ref arg0) (var_ref arg1)))))\n" + "))\n" + "" +; +static const char builtin_greaterThanEqual[] = + "((function greaterThanEqual\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) vec2 arg0)\n" + " (declare (in) vec2 arg1))\n" + " ((return (expression bvec2 >= (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) vec3 arg0)\n" + " (declare (in) vec3 arg1))\n" + " ((return (expression bvec3 >= (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) vec4 arg0)\n" + " (declare (in) vec4 arg1))\n" + " ((return (expression bvec4 >= (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) ivec2 arg0)\n" + " (declare (in) ivec2 arg1))\n" + " ((return (expression bvec2 >= (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) ivec3 arg0)\n" + " (declare (in) ivec3 arg1))\n" + " ((return (expression bvec3 >= (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) ivec4 arg0)\n" + " (declare (in) ivec4 arg1))\n" + " ((return (expression bvec4 >= (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) uvec2 arg0)\n" + " (declare (in) uvec2 arg1))\n" + " ((return (expression bvec2 >= (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) uvec3 arg0)\n" + " (declare (in) uvec3 arg1))\n" + " ((return (expression bvec3 >= (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) uvec4 arg0)\n" + " (declare (in) uvec4 arg1))\n" + " ((return (expression bvec4 >= (var_ref arg0) (var_ref arg1)))))\n" + "))\n" + "" +; +static const char builtin_inversesqrt[] = + "((function inversesqrt\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float arg0))\n" + " ((return (expression float rsq (var_ref arg0)))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 arg0))\n" + " ((return (expression vec2 rsq (var_ref arg0)))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0))\n" + " ((return (expression vec3 rsq (var_ref arg0)))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 arg0))\n" + " ((return (expression vec4 rsq (var_ref arg0)))))\n" + "))\n" + "" +; +static const char builtin_length[] = + "((function length\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float arg0))\n" + " ((return (expression float abs (var_ref arg0)))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec2 arg0))\n" + " ((return (expression float sqrt (expression float dot (var_ref arg0) (var_ref arg0))))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec3 arg0))\n" + " ((return (expression float sqrt (expression float dot (var_ref arg0) (var_ref arg0))))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec4 arg0))\n" + " ((return (expression float sqrt (expression float dot (var_ref arg0) (var_ref arg0))))))\n" + "))\n" + "" +; +static const char builtin_lessThan[] = + "((function lessThan\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) vec2 arg0)\n" + " (declare (in) vec2 arg1))\n" + " ((return (expression bvec2 < (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) vec3 arg0)\n" + " (declare (in) vec3 arg1))\n" + " ((return (expression bvec3 < (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) vec4 arg0)\n" + " (declare (in) vec4 arg1))\n" + " ((return (expression bvec4 < (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) ivec2 arg0)\n" + " (declare (in) ivec2 arg1))\n" + " ((return (expression bvec2 < (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) ivec3 arg0)\n" + " (declare (in) ivec3 arg1))\n" + " ((return (expression bvec3 < (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) ivec4 arg0)\n" + " (declare (in) ivec4 arg1))\n" + " ((return (expression bvec4 < (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) uvec2 arg0)\n" + " (declare (in) uvec2 arg1))\n" + " ((return (expression bvec2 < (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) uvec3 arg0)\n" + " (declare (in) uvec3 arg1))\n" + " ((return (expression bvec3 < (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) uvec4 arg0)\n" + " (declare (in) uvec4 arg1))\n" + " ((return (expression bvec4 < (var_ref arg0) (var_ref arg1)))))\n" + "))\n" + "" +; +static const char builtin_lessThanEqual[] = + "((function lessThanEqual\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) vec2 arg0)\n" + " (declare (in) vec2 arg1))\n" + " ((return (expression bvec2 <= (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) vec3 arg0)\n" + " (declare (in) vec3 arg1))\n" + " ((return (expression bvec3 <= (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) vec4 arg0)\n" + " (declare (in) vec4 arg1))\n" + " ((return (expression bvec4 <= (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) ivec2 arg0)\n" + " (declare (in) ivec2 arg1))\n" + " ((return (expression bvec2 <= (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) ivec3 arg0)\n" + " (declare (in) ivec3 arg1))\n" + " ((return (expression bvec3 <= (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) ivec4 arg0)\n" + " (declare (in) ivec4 arg1))\n" + " ((return (expression bvec4 <= (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) uvec2 arg0)\n" + " (declare (in) uvec2 arg1))\n" + " ((return (expression bvec2 <= (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) uvec3 arg0)\n" + " (declare (in) uvec3 arg1))\n" + " ((return (expression bvec3 <= (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) uvec4 arg0)\n" + " (declare (in) uvec4 arg1))\n" + " ((return (expression bvec4 <= (var_ref arg0) (var_ref arg1)))))\n" + "))\n" + "" +; +static const char builtin_log[] = + "((function log\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float arg0))\n" + " ((return (expression float log (var_ref arg0)))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 arg0))\n" + " ((return (expression vec2 log (var_ref arg0)))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0))\n" + " ((return (expression vec3 log (var_ref arg0)))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 arg0))\n" + " ((return (expression vec4 log (var_ref arg0)))))\n" + "))\n" + "" +; +static const char builtin_log2[] = + "((function log2\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float arg0))\n" + " ((return (expression float log2 (var_ref arg0)))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 arg0))\n" + " ((return (expression vec2 log2 (var_ref arg0)))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0))\n" + " ((return (expression vec3 log2 (var_ref arg0)))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 arg0))\n" + " ((return (expression vec4 log2 (var_ref arg0)))))\n" + "))\n" + "" +; +static const char builtin_matrixCompMult[] = + "((function matrixCompMult\n" + " (signature mat2\n" + " (parameters\n" + " (declare (in) mat2 x)\n" + " (declare (in) mat2 y))\n" + " ((declare () mat2 z)\n" + " (assign (xy) (array_ref (var_ref z) (constant int (0))) (expression vec2 * (array_ref (var_ref x) (constant int (0))) (array_ref (var_ref y) (constant int (0)))))\n" + " (assign (xy) (array_ref (var_ref z) (constant int (1))) (expression vec2 * (array_ref (var_ref x) (constant int (1))) (array_ref (var_ref y) (constant int (1)))))\n" + "(return (var_ref z))))\n" + "\n" + " (signature mat3\n" + " (parameters\n" + " (declare (in) mat3 x)\n" + " (declare (in) mat3 y))\n" + " ((declare () mat3 z)\n" + " (assign (xyz) (array_ref (var_ref z) (constant int (0))) (expression vec3 * (array_ref (var_ref x) (constant int (0))) (array_ref (var_ref y) (constant int (0)))))\n" + " (assign (xyz) (array_ref (var_ref z) (constant int (1))) (expression vec3 * (array_ref (var_ref x) (constant int (1))) (array_ref (var_ref y) (constant int (1)))))\n" + " (assign (xyz) (array_ref (var_ref z) (constant int (2))) (expression vec3 * (array_ref (var_ref x) (constant int (2))) (array_ref (var_ref y) (constant int (2)))))\n" + "(return (var_ref z))))\n" + "\n" + " (signature mat4\n" + " (parameters\n" + " (declare (in) mat4 x)\n" + " (declare (in) mat4 y))\n" + " ((declare () mat4 z)\n" + " (assign (xyzw) (array_ref (var_ref z) (constant int (0))) (expression vec4 * (array_ref (var_ref x) (constant int (0))) (array_ref (var_ref y) (constant int (0)))))\n" + " (assign (xyzw) (array_ref (var_ref z) (constant int (1))) (expression vec4 * (array_ref (var_ref x) (constant int (1))) (array_ref (var_ref y) (constant int (1)))))\n" + " (assign (xyzw) (array_ref (var_ref z) (constant int (2))) (expression vec4 * (array_ref (var_ref x) (constant int (2))) (array_ref (var_ref y) (constant int (2)))))\n" + " (assign (xyzw) (array_ref (var_ref z) (constant int (3))) (expression vec4 * (array_ref (var_ref x) (constant int (3))) (array_ref (var_ref y) (constant int (3)))))\n" + "(return (var_ref z))))\n" + "\n" + " (signature mat2x3\n" + " (parameters\n" + " (declare (in) mat2x3 x)\n" + " (declare (in) mat2x3 y))\n" + " ((declare () mat2x3 z)\n" + " (assign (xyz) (array_ref (var_ref z) (constant int (0))) (expression vec3 * (array_ref (var_ref x) (constant int (0))) (array_ref (var_ref y) (constant int (0)))))\n" + " (assign (xyz) (array_ref (var_ref z) (constant int (1))) (expression vec3 * (array_ref (var_ref x) (constant int (1))) (array_ref (var_ref y) (constant int (1)))))\n" + "(return (var_ref z))))\n" + "\n" + " (signature mat3x2\n" + " (parameters\n" + " (declare (in) mat3x2 x)\n" + " (declare (in) mat3x2 y))\n" + " ((declare () mat3x2 z)\n" + " (assign (xy) (array_ref (var_ref z) (constant int (0))) (expression vec2 * (array_ref (var_ref x) (constant int (0))) (array_ref (var_ref y) (constant int (0)))))\n" + " (assign (xy) (array_ref (var_ref z) (constant int (1))) (expression vec2 * (array_ref (var_ref x) (constant int (1))) (array_ref (var_ref y) (constant int (1)))))\n" + " (assign (xy) (array_ref (var_ref z) (constant int (2))) (expression vec2 * (array_ref (var_ref x) (constant int (2))) (array_ref (var_ref y) (constant int (2)))))\n" + "(return (var_ref z))))\n" + "\n" + " (signature mat2x4\n" + " (parameters\n" + " (declare (in) mat2x4 x)\n" + " (declare (in) mat2x4 y))\n" + " ((declare () mat2x4 z)\n" + " (assign (xyzw) (array_ref (var_ref z) (constant int (0))) (expression vec4 * (array_ref (var_ref x) (constant int (0))) (array_ref (var_ref y) (constant int (0)))))\n" + " (assign (xyzw) (array_ref (var_ref z) (constant int (1))) (expression vec4 * (array_ref (var_ref x) (constant int (1))) (array_ref (var_ref y) (constant int (1)))))\n" + "(return (var_ref z))))\n" + "\n" + " (signature mat4x2\n" + " (parameters\n" + " (declare (in) mat4x2 x)\n" + " (declare (in) mat4x2 y))\n" + " ((declare () mat4x2 z)\n" + " (assign (xy) (array_ref (var_ref z) (constant int (0))) (expression vec2 * (array_ref (var_ref x) (constant int (0))) (array_ref (var_ref y) (constant int (0)))))\n" + " (assign (xy) (array_ref (var_ref z) (constant int (1))) (expression vec2 * (array_ref (var_ref x) (constant int (1))) (array_ref (var_ref y) (constant int (1)))))\n" + " (assign (xy) (array_ref (var_ref z) (constant int (2))) (expression vec2 * (array_ref (var_ref x) (constant int (2))) (array_ref (var_ref y) (constant int (2)))))\n" + " (assign (xy) (array_ref (var_ref z) (constant int (3))) (expression vec2 * (array_ref (var_ref x) (constant int (3))) (array_ref (var_ref y) (constant int (3)))))\n" + "(return (var_ref z))))\n" + "\n" + " (signature mat3x4\n" + " (parameters\n" + " (declare (in) mat3x4 x)\n" + " (declare (in) mat3x4 y))\n" + " ((declare () mat3x4 z)\n" + " (assign (xyzw) (array_ref (var_ref z) (constant int (0))) (expression vec4 * (array_ref (var_ref x) (constant int (0))) (array_ref (var_ref y) (constant int (0)))))\n" + " (assign (xyzw) (array_ref (var_ref z) (constant int (1))) (expression vec4 * (array_ref (var_ref x) (constant int (1))) (array_ref (var_ref y) (constant int (1)))))\n" + " (assign (xyzw) (array_ref (var_ref z) (constant int (2))) (expression vec4 * (array_ref (var_ref x) (constant int (2))) (array_ref (var_ref y) (constant int (2)))))\n" + "(return (var_ref z))))\n" + "\n" + " (signature mat4x3\n" + " (parameters\n" + " (declare (in) mat4x3 x)\n" + " (declare (in) mat4x3 y))\n" + " ((declare () mat4x3 z)\n" + " (assign (xyz) (array_ref (var_ref z) (constant int (0))) (expression vec3 * (array_ref (var_ref x) (constant int (0))) (array_ref (var_ref y) (constant int (0)))))\n" + " (assign (xyz) (array_ref (var_ref z) (constant int (1))) (expression vec3 * (array_ref (var_ref x) (constant int (1))) (array_ref (var_ref y) (constant int (1)))))\n" + " (assign (xyz) (array_ref (var_ref z) (constant int (2))) (expression vec3 * (array_ref (var_ref x) (constant int (2))) (array_ref (var_ref y) (constant int (2)))))\n" + " (assign (xyz) (array_ref (var_ref z) (constant int (3))) (expression vec3 * (array_ref (var_ref x) (constant int (3))) (array_ref (var_ref y) (constant int (3)))))\n" + "(return (var_ref z))))\n" + "))\n" + "" +; +static const char builtin_max[] = + "((function max\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float arg0)\n" + " (declare (in) float arg1))\n" + " ((return (expression float max (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 arg0)\n" + " (declare (in) vec2 arg1))\n" + " ((return (expression vec2 max (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0)\n" + " (declare (in) vec3 arg1))\n" + " ((return (expression vec3 max (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 arg0)\n" + " (declare (in) vec4 arg1))\n" + " ((return (expression vec4 max (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 arg0)\n" + " (declare (in) float arg1))\n" + " ((return (expression vec2 max (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0)\n" + " (declare (in) float arg1))\n" + " ((return (expression vec3 max (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 arg0)\n" + " (declare (in) float arg1))\n" + " ((return (expression vec4 max (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature int\n" + " (parameters\n" + " (declare (in) int arg0)\n" + " (declare (in) int arg1))\n" + " ((return (expression int max (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature ivec2\n" + " (parameters\n" + " (declare (in) ivec2 arg0)\n" + " (declare (in) ivec2 arg1))\n" + " ((return (expression ivec2 max (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature ivec3\n" + " (parameters\n" + " (declare (in) ivec3 arg0)\n" + " (declare (in) ivec3 arg1))\n" + " ((return (expression ivec3 max (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) ivec4 arg0)\n" + " (declare (in) ivec4 arg1))\n" + " ((return (expression ivec4 max (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature ivec2\n" + " (parameters\n" + " (declare (in) ivec2 arg0)\n" + " (declare (in) int arg1))\n" + " ((return (expression ivec2 max (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature ivec3\n" + " (parameters\n" + " (declare (in) ivec3 arg0)\n" + " (declare (in) int arg1))\n" + " ((return (expression ivec3 max (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) ivec4 arg0)\n" + " (declare (in) int arg1))\n" + " ((return (expression ivec4 max (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature uint\n" + " (parameters\n" + " (declare (in) uint arg0)\n" + " (declare (in) uint arg1))\n" + " ((return (expression uint max (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature uvec2\n" + " (parameters\n" + " (declare (in) uvec2 arg0)\n" + " (declare (in) uvec2 arg1))\n" + " ((return (expression uvec2 max (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature uvec3\n" + " (parameters\n" + " (declare (in) uvec3 arg0)\n" + " (declare (in) uvec3 arg1))\n" + " ((return (expression uvec3 max (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) uvec4 arg0)\n" + " (declare (in) uvec4 arg1))\n" + " ((return (expression uvec4 max (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature uvec2\n" + " (parameters\n" + " (declare (in) uvec2 arg0)\n" + " (declare (in) uint arg1))\n" + " ((return (expression uvec2 max (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature uvec3\n" + " (parameters\n" + " (declare (in) uvec3 arg0)\n" + " (declare (in) uint arg1))\n" + " ((return (expression uvec3 max (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) uvec4 arg0)\n" + " (declare (in) uint arg1))\n" + " ((return (expression uvec4 max (var_ref arg0) (var_ref arg1)))))\n" + "))\n" + "" +; +static const char builtin_min[] = + "((function min\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float arg0)\n" + " (declare (in) float arg1))\n" + " ((return (expression float min (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 arg0)\n" + " (declare (in) vec2 arg1))\n" + " ((return (expression vec2 min (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0)\n" + " (declare (in) vec3 arg1))\n" + " ((return (expression vec3 min (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 arg0)\n" + " (declare (in) vec4 arg1))\n" + " ((return (expression vec4 min (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 arg0)\n" + " (declare (in) float arg1))\n" + " ((return (expression vec2 min (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0)\n" + " (declare (in) float arg1))\n" + " ((return (expression vec3 min (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 arg0)\n" + " (declare (in) float arg1))\n" + " ((return (expression vec4 min (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature int\n" + " (parameters\n" + " (declare (in) int arg0)\n" + " (declare (in) int arg1))\n" + " ((return (expression int min (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature ivec2\n" + " (parameters\n" + " (declare (in) ivec2 arg0)\n" + " (declare (in) ivec2 arg1))\n" + " ((return (expression ivec2 min (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature ivec3\n" + " (parameters\n" + " (declare (in) ivec3 arg0)\n" + " (declare (in) ivec3 arg1))\n" + " ((return (expression ivec3 min (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) ivec4 arg0)\n" + " (declare (in) ivec4 arg1))\n" + " ((return (expression ivec4 min (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature ivec2\n" + " (parameters\n" + " (declare (in) ivec2 arg0)\n" + " (declare (in) int arg1))\n" + " ((return (expression ivec2 min (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature ivec3\n" + " (parameters\n" + " (declare (in) ivec3 arg0)\n" + " (declare (in) int arg1))\n" + " ((return (expression ivec3 min (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) ivec4 arg0)\n" + " (declare (in) int arg1))\n" + " ((return (expression ivec4 min (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature uint\n" + " (parameters\n" + " (declare (in) uint arg0)\n" + " (declare (in) uint arg1))\n" + " ((return (expression uint min (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature uvec2\n" + " (parameters\n" + " (declare (in) uvec2 arg0)\n" + " (declare (in) uvec2 arg1))\n" + " ((return (expression uvec2 min (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature uvec3\n" + " (parameters\n" + " (declare (in) uvec3 arg0)\n" + " (declare (in) uvec3 arg1))\n" + " ((return (expression uvec3 min (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) uvec4 arg0)\n" + " (declare (in) uvec4 arg1))\n" + " ((return (expression uvec4 min (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature uvec2\n" + " (parameters\n" + " (declare (in) uvec2 arg0)\n" + " (declare (in) uint arg1))\n" + " ((return (expression uvec2 min (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature uvec3\n" + " (parameters\n" + " (declare (in) uvec3 arg0)\n" + " (declare (in) uint arg1))\n" + " ((return (expression uvec3 min (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) uvec4 arg0)\n" + " (declare (in) uint arg1))\n" + " ((return (expression uvec4 min (var_ref arg0) (var_ref arg1)))))\n" + "))\n" + "" +; +static const char builtin_mix[] = + "((function mix\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float arg0)\n" + " (declare (in) float arg1)\n" + " (declare (in) float arg2))\n" + " ((return (expression float + (expression float * (var_ref arg0) (expression float - (constant float (1.000000)) (var_ref arg2))) (expression float * (var_ref arg1) (var_ref arg2))))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 arg0)\n" + " (declare (in) vec2 arg1)\n" + " (declare (in) vec2 arg2))\n" + " ((return (expression vec2 + (expression vec2 * (var_ref arg0) (expression vec2 - (constant float (1.000000)) (var_ref arg2))) (expression vec2 * (var_ref arg1) (var_ref arg2))))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0)\n" + " (declare (in) vec3 arg1)\n" + " (declare (in) vec3 arg2))\n" + " ((return (expression vec3 + (expression vec3 * (var_ref arg0) (expression vec3 - (constant float (1.000000)) (var_ref arg2))) (expression vec3 * (var_ref arg1) (var_ref arg2))))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 arg0)\n" + " (declare (in) vec4 arg1)\n" + " (declare (in) vec4 arg2))\n" + " ((return (expression vec4 + (expression vec4 * (var_ref arg0) (expression vec4 - (constant float (1.000000)) (var_ref arg2))) (expression vec4 * (var_ref arg1) (var_ref arg2))))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 arg0)\n" + " (declare (in) vec2 arg1)\n" + " (declare (in) float arg2))\n" + " ((return (expression vec2 + (expression vec2 * (var_ref arg0) (expression float - (constant float (1.000000)) (var_ref arg2))) (expression vec2 * (var_ref arg1) (var_ref arg2))))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0)\n" + " (declare (in) vec3 arg1)\n" + " (declare (in) float arg2))\n" + " ((return (expression vec3 + (expression vec3 * (var_ref arg0) (expression float - (constant float (1.000000)) (var_ref arg2))) (expression vec3 * (var_ref arg1) (var_ref arg2))))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 arg0)\n" + " (declare (in) vec4 arg1)\n" + " (declare (in) float arg2))\n" + " ((return (expression vec4 + (expression vec4 * (var_ref arg0) (expression float - (constant float (1.000000)) (var_ref arg2))) (expression vec4 * (var_ref arg1) (var_ref arg2))))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float v1)\n" + " (declare (in) float v2)\n" + " (declare (in) bool a))\n" + " ((assign (var_ref a) (var_ref v1) (var_ref v2))\n" + " (return (var_ref v1))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 v1)\n" + " (declare (in) vec2 v2)\n" + " (declare (in) bvec2 a))\n" + " ((assign (swiz x (var_ref a)) (x) (var_ref v1) (swiz x (var_ref v2)))\n" + " (assign (swiz y (var_ref a)) (y) (var_ref v1) (swiz y (var_ref v2)))\n" + " (return (var_ref v1))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 v1)\n" + " (declare (in) vec3 v2)\n" + " (declare (in) bvec3 a))\n" + " ((assign (swiz x (var_ref a)) (x) (var_ref v1) (swiz x (var_ref v2)))\n" + " (assign (swiz y (var_ref a)) (y) (var_ref v1) (swiz y (var_ref v2)))\n" + " (assign (swiz z (var_ref a)) (z) (var_ref v1) (swiz z (var_ref v2)))\n" + " (return (var_ref v1))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 v1)\n" + " (declare (in) vec4 v2)\n" + " (declare (in) bvec4 a))\n" + " ((assign (swiz x (var_ref a)) (x) (var_ref v1) (swiz x (var_ref v2)))\n" + " (assign (swiz y (var_ref a)) (y) (var_ref v1) (swiz y (var_ref v2)))\n" + " (assign (swiz z (var_ref a)) (z) (var_ref v1) (swiz z (var_ref v2)))\n" + " (assign (swiz w (var_ref a)) (w) (var_ref v1) (swiz w (var_ref v2)))\n" + " (return (var_ref v1))))\n" + "))\n" + "" +; +static const char builtin_mod[] = + "((function mod\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float arg0)\n" + " (declare (in) float arg1))\n" + " ((return (expression float % (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 arg0)\n" + " (declare (in) vec2 arg1))\n" + " ((return (expression vec2 % (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0)\n" + " (declare (in) vec3 arg1))\n" + " ((return (expression vec3 % (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 arg0)\n" + " (declare (in) vec4 arg1))\n" + " ((return (expression vec4 % (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 arg0)\n" + " (declare (in) float arg1))\n" + " ((return (expression vec2 % (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0)\n" + " (declare (in) float arg1))\n" + " ((return (expression vec3 % (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 arg0)\n" + " (declare (in) float arg1))\n" + " ((return (expression vec4 % (var_ref arg0) (var_ref arg1)))))\n" + "))\n" + "" +; +static const char builtin_modf[] = + "((function modf\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x)\n" + " (declare (out) float i))\n" + " ((declare () float t)\n" + " (assign (x) (var_ref t) (expression float trunc (var_ref x)))\n" + " (assign (x) (var_ref i) (var_ref t))\n" + " (return (expression float - (var_ref x) (var_ref t)))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (out) vec2 i))\n" + " ((declare () vec2 t)\n" + " (assign (xy) (var_ref t) (expression vec2 trunc (var_ref x)))\n" + " (assign (xy) (var_ref i) (var_ref t))\n" + " (return (expression vec2 - (var_ref x) (var_ref t)))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (out) vec3 i))\n" + " ((declare () vec3 t)\n" + " (assign (xyz) (var_ref t) (expression vec3 trunc (var_ref x)))\n" + " (assign (xyz) (var_ref i) (var_ref t))\n" + " (return (expression vec3 - (var_ref x) (var_ref t)))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (out) vec4 i))\n" + " ((declare () vec4 t)\n" + " (assign (xyzw) (var_ref t) (expression vec4 trunc (var_ref x)))\n" + " (assign (xyzw) (var_ref i) (var_ref t))\n" + " (return (expression vec4 - (var_ref x) (var_ref t)))))\n" + "))\n" + "" +; +static const char builtin_noise1[] = + "((function noise1\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ((return (expression float noise (var_ref x)))))\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ((return (expression float noise (var_ref x)))))\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ((return (expression float noise (var_ref x)))))\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ((return (expression float noise (var_ref x)))))\n" + "))\n" + "" +; +static const char builtin_noise2[] = + "((function noise2\n" + " (signature vec2\n" + " (parameters (declare (in) vec4 p))\n" + " (\n" + " (declare () float a)\n" + " (declare () float b)\n" + " (declare () vec2 t)\n" + "\n" + " (assign (x) (var_ref a) (expression float noise (var_ref p)))\n" + " (assign (x) (var_ref b) (expression float noise (expression vec4 + (var_ref p) (constant vec4 (601.0 313.0 29.0 277.0)))))\n" + " (assign (x) (var_ref t) (var_ref a))\n" + " (assign (y) (var_ref t) (var_ref b))\n" + " (return (var_ref t))\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters (declare (in) vec3 p))\n" + " (\n" + " (declare () float a)\n" + " (declare () float b)\n" + " (declare () vec2 t)\n" + "\n" + " (assign (x) (var_ref a) (expression float noise (var_ref p)))\n" + " (assign (x) (var_ref b) (expression float noise (expression vec3 + (var_ref p) (constant vec3 (601.0 313.0 29.0)))))\n" + " (assign (x) (var_ref t) (var_ref a))\n" + " (assign (y) (var_ref t) (var_ref b))\n" + " (return (var_ref t))\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) vec2 p)\n" + " )\n" + " (\n" + " (declare () float a)\n" + " (declare () float b)\n" + " (declare () vec2 t)\n" + "\n" + " (assign (x) (var_ref a) (expression float noise (var_ref p)))\n" + " (assign (x) (var_ref b) (expression float noise (expression vec2 + (var_ref p) (constant vec2 (601.0 313.0)))))\n" + " (assign (x) (var_ref t) (var_ref a))\n" + " (assign (y) (var_ref t) (var_ref b))\n" + " (return (var_ref t))\n" + " ))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in ) float p)\n" + " )\n" + " (\n" + " (declare () float a)\n" + " (declare () float b)\n" + " (declare () vec2 t)\n" + "\n" + " (assign (x) (var_ref a) (expression float noise (var_ref p)))\n" + " (assign (x) (var_ref b) (expression float noise (expression float + (var_ref p) (constant float (601.0)))))\n" + " (assign (x) (var_ref t) (var_ref a))\n" + " (assign (y) (var_ref t) (var_ref b))\n" + " (return (var_ref t))\n" + " ))\n" + "))\n" + "" +; +static const char builtin_noise3[] = + "((function noise3\n" + " (signature vec3\n" + " (parameters (declare (in) vec4 p))\n" + " (\n" + " (declare () float a)\n" + " (declare () float b)\n" + " (declare () float c)\n" + " (declare () vec3 t)\n" + "\n" + " (assign (x) (var_ref a) (expression float noise (var_ref p)))\n" + " (assign (x) (var_ref b) (expression float noise (expression vec4 + (var_ref p) (constant vec4 (601.0 313.0 29.0 277.0)))))\n" + " (assign (x) (var_ref c) (expression float noise (expression vec4 + (var_ref p) (constant vec4 (1559.0 113.0 1861.0 797.0)))))\n" + "\n" + " (assign (x) (var_ref t) (var_ref a))\n" + " (assign (y) (var_ref t) (var_ref b))\n" + " (assign (z) (var_ref t) (var_ref c))\n" + " (return (var_ref t))\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters (declare (in) vec3 p))\n" + " (\n" + " (declare () float a)\n" + " (declare () float b)\n" + " (declare () float c)\n" + " (declare () vec3 t)\n" + "\n" + " (assign (x) (var_ref a) (expression float noise (var_ref p)))\n" + " (assign (x) (var_ref b) (expression float noise (expression vec3 + (var_ref p) (constant vec3 (601.0 313.0 29.0)))))\n" + " (assign (x) (var_ref c) (expression float noise (expression vec3 + (var_ref p) (constant vec3 (1559.0 113.0 1861.0)))))\n" + "\n" + " (assign (x) (var_ref t) (var_ref a))\n" + " (assign (y) (var_ref t) (var_ref b))\n" + " (assign (z) (var_ref t) (var_ref c))\n" + " (return (var_ref t))\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters (declare (in) vec2 p))\n" + " (\n" + " (declare () float a)\n" + " (declare () float b)\n" + " (declare () float c)\n" + " (declare () vec3 t)\n" + "\n" + " (assign (x) (var_ref a) (expression float noise (var_ref p)))\n" + " (assign (x) (var_ref b) (expression float noise (expression vec2 + (var_ref p) (constant vec2 (601.0 313.0)))))\n" + " (assign (x) (var_ref c) (expression float noise (expression vec2 + (var_ref p) (constant vec2 (1559.0 113.0)))))\n" + "\n" + " (assign (x) (var_ref t) (var_ref a))\n" + " (assign (y) (var_ref t) (var_ref b))\n" + " (assign (z) (var_ref t) (var_ref c))\n" + " (return (var_ref t))\n" + " ))\n" + "\n" + " (signature vec3\n" + " (parameters (declare (in) float p))\n" + " (\n" + " (declare () float a)\n" + " (declare () float b)\n" + " (declare () float c)\n" + " (declare () vec3 t)\n" + "\n" + " (assign (x) (var_ref a) (expression float noise (var_ref p)))\n" + " (assign (x) (var_ref b) (expression float noise (expression float + (var_ref p) (constant float (601.0)))))\n" + " (assign (x) (var_ref c) (expression float noise (expression float + (var_ref p) (constant float (1559.0)))))\n" + "\n" + " (assign (x) (var_ref t) (var_ref a))\n" + " (assign (y) (var_ref t) (var_ref b))\n" + " (assign (z) (var_ref t) (var_ref c))\n" + " (return (var_ref t))\n" + " ))\n" + "))\n" + "" +; +static const char builtin_noise4[] = + "((function noise4\n" + " (signature vec4\n" + " (parameters (declare (in) vec4 p))\n" + " (\n" + " (declare () float _x)\n" + " (declare () float _y)\n" + " (declare () float _z)\n" + " (declare () float _w)\n" + " (declare () vec4 _r)\n" + "\n" + " (declare () vec4 _p)\n" + " (assign (xyzw) (var_ref _p) (expression vec4 + (var_ref p) (constant vec4 (1559.0 113.0 1861.0 797.0))) )\n" + "\n" + " (assign (x) (var_ref _x) (expression float noise(var_ref p)))\n" + " (assign (x) (var_ref _y) (expression float noise(expression vec4 + (var_ref p) (constant vec4 (601.0 313.0 29.0 277.0)))))\n" + " (assign (x) (var_ref _z) (expression float noise(var_ref _p)))\n" + " (assign (x) (var_ref _w) (expression float noise(expression vec4 + (var_ref _p) (constant vec4 (601.0 313.0 29.0 277.0)))))\n" + "\n" + " (assign (x) (var_ref _r) (var_ref _x))\n" + " (assign (y) (var_ref _r) (var_ref _y))\n" + " (assign (z) (var_ref _r) (var_ref _z))\n" + " (assign (w) (var_ref _r) (var_ref _w))\n" + " (return (var_ref _r))\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters (declare (in) vec3 p))\n" + " (\n" + " (declare () float _x)\n" + " (declare () float _y)\n" + " (declare () float _z)\n" + " (declare () float _w)\n" + " (declare () vec4 _r)\n" + "\n" + " (declare () vec3 _p)\n" + " (assign (xyz) (var_ref _p) (expression vec3 + (var_ref p) (constant vec3 (1559.0 113.0 1861.0))) )\n" + "\n" + " (assign (x) (var_ref _x) (expression float noise(var_ref p)))\n" + " (assign (x) (var_ref _y) (expression float noise(expression vec3 + (var_ref p) (constant vec3 (601.0 313.0 29.0)))))\n" + " (assign (x) (var_ref _z) (expression float noise(var_ref _p)))\n" + " (assign (x) (var_ref _w) (expression float noise(expression vec3 + (var_ref _p) (constant vec3 (601.0 313.0 29.0)))))\n" + "\n" + " (assign (x) (var_ref _r) (var_ref _x))\n" + " (assign (y) (var_ref _r) (var_ref _y))\n" + " (assign (z) (var_ref _r) (var_ref _z))\n" + " (assign (w) (var_ref _r) (var_ref _w))\n" + " (return (var_ref _r))\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters (declare (in) vec2 p))\n" + " (\n" + " (declare () float _x)\n" + " (declare () float _y)\n" + " (declare () float _z)\n" + " (declare () float _w)\n" + " (declare () vec4 _r)\n" + "\n" + " (declare () vec2 _p)\n" + " (assign (xy) (var_ref _p) (expression vec2 + (var_ref p) (constant vec2 (1559.0 113.0))) )\n" + "\n" + " (assign (x) (var_ref _x) (expression float noise(var_ref p)))\n" + " (assign (x) (var_ref _y) (expression float noise(expression vec2 + (var_ref p) (constant vec2 (601.0 313.0)))))\n" + " (assign (x) (var_ref _z) (expression float noise(var_ref _p)))\n" + " (assign (x) (var_ref _w) (expression float noise(expression vec2 + (var_ref _p) (constant vec2 (601.0 313.0)))))\n" + "\n" + " (assign (x) (var_ref _r) (var_ref _x))\n" + " (assign (y) (var_ref _r) (var_ref _y))\n" + " (assign (z) (var_ref _r) (var_ref _z))\n" + " (assign (w) (var_ref _r) (var_ref _w))\n" + " (return (var_ref _r))\n" + " ))\n" + "\n" + " (signature vec4\n" + " (parameters (declare (in) float p))\n" + " (\n" + " (declare () float _x)\n" + " (declare () float _y)\n" + " (declare () float _z)\n" + " (declare () float _w)\n" + " (declare () vec4 _r)\n" + "\n" + " (declare () float _p)\n" + " (assign (x) (var_ref _p) (expression float + (var_ref p) (constant float (1559.0))) )\n" + "\n" + " (assign (x) (var_ref _x) (expression float noise(var_ref p)))\n" + " (assign (x) (var_ref _y) (expression float noise(expression float + (var_ref p) (constant float (601.0 313.0 29.0 277.0)))))\n" + " (assign (x) (var_ref _z) (expression float noise(var_ref _p)))\n" + " (assign (x) (var_ref _w) (expression float noise(expression float + (var_ref _p) (constant float (601.0 313.0 29.0 277.0)))))\n" + "\n" + " (assign (x) (var_ref _r) (var_ref _x))\n" + " (assign (y) (var_ref _r) (var_ref _y))\n" + " (assign (z) (var_ref _r) (var_ref _z))\n" + " (assign (w) (var_ref _r) (var_ref _w))\n" + " (return (var_ref _r))\n" + " ))\n" + "))\n" + "" +; +static const char builtin_normalize[] = + "((function normalize\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float arg0))\n" + " ((return (expression float sign (var_ref arg0)))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 arg0))\n" + " ((return (expression vec2 * (var_ref arg0) (expression float rsq (expression float dot (var_ref arg0) (var_ref arg0)))))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0))\n" + " ((return (expression vec3 * (var_ref arg0) (expression float rsq (expression float dot (var_ref arg0) (var_ref arg0)))))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 arg0))\n" + " ((return (expression vec4 * (var_ref arg0) (expression float rsq (expression float dot (var_ref arg0) (var_ref arg0)))))))\n" + "))\n" + "" +; +static const char builtin_not[] = + "((function not\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) bvec2 arg0))\n" + " ((return (expression bvec2 ! (var_ref arg0)))))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) bvec3 arg0))\n" + " ((return (expression bvec3 ! (var_ref arg0)))))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) bvec4 arg0))\n" + " ((return (expression bvec4 ! (var_ref arg0)))))\n" + "))\n" + "" +; +static const char builtin_notEqual[] = + "((function notEqual\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) vec2 arg0)\n" + " (declare (in) vec2 arg1))\n" + " ((return (expression bvec2 != (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) vec3 arg0)\n" + " (declare (in) vec3 arg1))\n" + " ((return (expression bvec3 != (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) vec4 arg0)\n" + " (declare (in) vec4 arg1))\n" + " ((return (expression bvec4 != (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) bvec2 arg0)\n" + " (declare (in) bvec2 arg1))\n" + " ((return (expression bvec2 != (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) bvec3 arg0)\n" + " (declare (in) bvec3 arg1))\n" + " ((return (expression bvec3 != (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) bvec4 arg0)\n" + " (declare (in) bvec4 arg1))\n" + " ((return (expression bvec4 != (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) ivec2 arg0)\n" + " (declare (in) ivec2 arg1))\n" + " ((return (expression bvec2 != (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) ivec3 arg0)\n" + " (declare (in) ivec3 arg1))\n" + " ((return (expression bvec3 != (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) ivec4 arg0)\n" + " (declare (in) ivec4 arg1))\n" + " ((return (expression bvec4 != (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) uvec2 arg0)\n" + " (declare (in) uvec2 arg1))\n" + " ((return (expression bvec2 != (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) uvec3 arg0)\n" + " (declare (in) uvec3 arg1))\n" + " ((return (expression bvec3 != (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) uvec4 arg0)\n" + " (declare (in) uvec4 arg1))\n" + " ((return (expression bvec4 != (var_ref arg0) (var_ref arg1)))))\n" + "))\n" + "" +; +static const char builtin_outerProduct[] = + "((function outerProduct\n" + " (signature mat2\n" + " (parameters\n" + " (declare (in) vec2 u)\n" + " (declare (in) vec2 v))\n" + " ((declare () mat2 m)\n" + " (assign (xy) (array_ref (var_ref m) (constant int (0))) (expression vec2 * (var_ref u) (swiz x (var_ref v))))\n" + " (assign (xy) (array_ref (var_ref m) (constant int (1))) (expression vec2 * (var_ref u) (swiz y (var_ref v))))\n" + " (return (var_ref m))))\n" + "\n" + " (signature mat2x3\n" + " (parameters\n" + " (declare (in) vec3 u)\n" + " (declare (in) vec2 v))\n" + " ((declare () mat2x3 m)\n" + " (assign (xyz) (array_ref (var_ref m) (constant int (0))) (expression vec3 * (var_ref u) (swiz x (var_ref v))))\n" + " (assign (xyz) (array_ref (var_ref m) (constant int (1))) (expression vec3 * (var_ref u) (swiz y (var_ref v))))\n" + " (return (var_ref m))))\n" + "\n" + " (signature mat2x4\n" + " (parameters\n" + " (declare (in) vec4 u)\n" + " (declare (in) vec2 v))\n" + " ((declare () mat2x4 m)\n" + " (assign (xyzw) (array_ref (var_ref m) (constant int (0))) (expression vec4 * (var_ref u) (swiz x (var_ref v))))\n" + " (assign (xyzw) (array_ref (var_ref m) (constant int (1))) (expression vec4 * (var_ref u) (swiz y (var_ref v))))\n" + " (return (var_ref m))))\n" + "\n" + " (signature mat3x2\n" + " (parameters\n" + " (declare (in) vec2 u)\n" + " (declare (in) vec3 v))\n" + " ((declare () mat3x2 m)\n" + " (assign (xy) (array_ref (var_ref m) (constant int (0))) (expression vec2 * (var_ref u) (swiz x (var_ref v))))\n" + " (assign (xy) (array_ref (var_ref m) (constant int (1))) (expression vec2 * (var_ref u) (swiz y (var_ref v))))\n" + " (assign (xy) (array_ref (var_ref m) (constant int (2))) (expression vec2 * (var_ref u) (swiz z (var_ref v))))\n" + " (return (var_ref m))\n" + " ))\n" + "\n" + " (signature mat3\n" + " (parameters\n" + " (declare (in) vec3 u)\n" + " (declare (in) vec3 v))\n" + " ((declare () mat3 m)\n" + " (assign (xyz) (array_ref (var_ref m) (constant int (0))) (expression vec3 * (var_ref u) (swiz x (var_ref v))))\n" + " (assign (xyz) (array_ref (var_ref m) (constant int (1))) (expression vec3 * (var_ref u) (swiz y (var_ref v))))\n" + " (assign (xyz) (array_ref (var_ref m) (constant int (2))) (expression vec3 * (var_ref u) (swiz z (var_ref v))))\n" + " (return (var_ref m))))\n" + "\n" + " (signature mat3x4\n" + " (parameters\n" + " (declare (in) vec4 u)\n" + " (declare (in) vec3 v))\n" + " ((declare () mat3x4 m)\n" + " (assign (xyzw) (array_ref (var_ref m) (constant int (0))) (expression vec4 * (var_ref u) (swiz x (var_ref v))))\n" + " (assign (xyzw) (array_ref (var_ref m) (constant int (1))) (expression vec4 * (var_ref u) (swiz y (var_ref v))))\n" + " (assign (xyzw) (array_ref (var_ref m) (constant int (2))) (expression vec4 * (var_ref u) (swiz z (var_ref v))))\n" + " (return (var_ref m))))\n" + "\n" + " (signature mat4x2\n" + " (parameters\n" + " (declare (in) vec2 u)\n" + " (declare (in) vec4 v))\n" + " ((declare () mat4x2 m)\n" + " (assign (xy) (array_ref (var_ref m) (constant int (0))) (expression vec2 * (var_ref u) (swiz x (var_ref v))))\n" + " (assign (xy) (array_ref (var_ref m) (constant int (1))) (expression vec2 * (var_ref u) (swiz y (var_ref v))))\n" + " (assign (xy) (array_ref (var_ref m) (constant int (2))) (expression vec2 * (var_ref u) (swiz z (var_ref v))))\n" + " (assign (xy) (array_ref (var_ref m) (constant int (3))) (expression vec2 * (var_ref u) (swiz w (var_ref v))))\n" + " (return (var_ref m))))\n" + "\n" + " (signature mat4x3\n" + " (parameters\n" + " (declare (in) vec3 u)\n" + " (declare (in) vec4 v))\n" + " ((declare () mat4x3 m)\n" + " (assign (xyz) (array_ref (var_ref m) (constant int (0))) (expression vec3 * (var_ref u) (swiz x (var_ref v))))\n" + " (assign (xyz) (array_ref (var_ref m) (constant int (1))) (expression vec3 * (var_ref u) (swiz y (var_ref v))))\n" + " (assign (xyz) (array_ref (var_ref m) (constant int (2))) (expression vec3 * (var_ref u) (swiz z (var_ref v))))\n" + " (assign (xyz) (array_ref (var_ref m) (constant int (3))) (expression vec3 * (var_ref u) (swiz w (var_ref v))))\n" + " (return (var_ref m))))\n" + "\n" + " (signature mat4\n" + " (parameters\n" + " (declare (in) vec4 u)\n" + " (declare (in) vec4 v))\n" + " ((declare () mat4 m)\n" + " (assign (xyzw) (array_ref (var_ref m) (constant int (0))) (expression vec4 * (var_ref u) (swiz x (var_ref v))))\n" + " (assign (xyzw) (array_ref (var_ref m) (constant int (1))) (expression vec4 * (var_ref u) (swiz y (var_ref v))))\n" + " (assign (xyzw) (array_ref (var_ref m) (constant int (2))) (expression vec4 * (var_ref u) (swiz z (var_ref v))))\n" + " (assign (xyzw) (array_ref (var_ref m) (constant int (3))) (expression vec4 * (var_ref u) (swiz w (var_ref v))))\n" + " (return (var_ref m))))\n" + "))\n" + "" +; +static const char builtin_pow[] = + "((function pow\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float arg0)\n" + " (declare (in) float arg1))\n" + " ((return (expression float pow (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 arg0)\n" + " (declare (in) vec2 arg1))\n" + " ((return (expression vec2 pow (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0)\n" + " (declare (in) vec3 arg1))\n" + " ((return (expression vec3 pow (var_ref arg0) (var_ref arg1)))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 arg0)\n" + " (declare (in) vec4 arg1))\n" + " ((return (expression vec4 pow (var_ref arg0) (var_ref arg1)))))\n" + "))\n" + "" +; +static const char builtin_radians[] = + "((function radians\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float arg0))\n" + " ((return (expression float * (var_ref arg0) (constant float (0.0174532925))))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 arg0))\n" + " ((return (expression vec2 * (var_ref arg0) (constant float (0.0174532925))))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0))\n" + " ((return (expression vec3 * (var_ref arg0) (constant float (0.0174532925))))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 arg0))\n" + " ((return (expression vec4 * (var_ref arg0) (constant float (0.0174532925))))))\n" + "))\n" + "" +; +static const char builtin_reflect[] = + "((function reflect\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float i)\n" + " (declare (in) float n))\n" + " ((return (expression float -\n" + " (var_ref i)\n" + " (expression float *\n" + " (constant float (2.0))\n" + " (expression float *\n" + " (expression float *\n" + " (var_ref n)\n" + " (var_ref i))\n" + " (var_ref n)))))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 i)\n" + " (declare (in) vec2 n))\n" + " ((return (expression vec2 -\n" + " (var_ref i)\n" + " (expression vec2 *\n" + " (constant float (2.0))\n" + " (expression vec2 *\n" + " (expression float dot\n" + " (var_ref n)\n" + " (var_ref i))\n" + " (var_ref n)))))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 i)\n" + " (declare (in) vec3 n))\n" + " ((return (expression vec3 -\n" + " (var_ref i)\n" + " (expression vec3 *\n" + " (constant float (2.0))\n" + " (expression vec3 *\n" + " (expression float dot\n" + " (var_ref n)\n" + " (var_ref i))\n" + " (var_ref n)))))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 i)\n" + " (declare (in) vec4 n))\n" + " ((return (expression vec4 -\n" + " (var_ref i)\n" + " (expression vec4 *\n" + " (constant float (2.0))\n" + " (expression vec4 *\n" + " (expression float dot\n" + " (var_ref n)\n" + " (var_ref i))\n" + " (var_ref n)))))))\n" + "\n" + "))\n" + "" +; +static const char builtin_refract[] = + "((function refract\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float i)\n" + " (declare (in) float n)\n" + " (declare (in) float eta))\n" + " ((declare () float k)\n" + " (assign (x) (var_ref k)\n" + " (expression float - (constant float (1.0))\n" + " (expression float * (var_ref eta)\n" + " (expression float * (var_ref eta)\n" + " (expression float - (constant float (1.0))\n" + " (expression float * \n" + " (expression float * (var_ref n) (var_ref i))\n" + " (expression float * (var_ref n) (var_ref i))))))))\n" + " (if (expression bool < (var_ref k) (constant float (0.0)))\n" + " ((return (constant float (0.0))))\n" + " ((return (expression float -\n" + " (expression float * (var_ref eta) (var_ref i))\n" + " (expression float *\n" + " (expression float +\n" + " (expression float * (var_ref eta)\n" + " (expression float * (var_ref n) (var_ref i)))\n" + " (expression float sqrt (var_ref k)))\n" + " (var_ref n))))))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 i)\n" + " (declare (in) vec2 n)\n" + " (declare (in) float eta))\n" + " ((declare () float k)\n" + " (assign (x) (var_ref k)\n" + " (expression float - (constant float (1.0))\n" + " (expression float * (var_ref eta)\n" + " (expression float * (var_ref eta)\n" + " (expression float - (constant float (1.0))\n" + " (expression float * \n" + " (expression float dot (var_ref n) (var_ref i))\n" + " (expression float dot (var_ref n) (var_ref i))))))))\n" + " (if (expression bool < (var_ref k) (constant float (0.0)))\n" + " ((return (constant vec2 (0.0 0.0))))\n" + " ((return (expression vec2 -\n" + " (expression vec2 * (var_ref eta) (var_ref i))\n" + " (expression vec2 *\n" + " (expression float +\n" + " (expression float * (var_ref eta)\n" + " (expression float dot (var_ref n) (var_ref i)))\n" + " (expression float sqrt (var_ref k)))\n" + " (var_ref n))))))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 i)\n" + " (declare (in) vec3 n)\n" + " (declare (in) float eta))\n" + " ((declare () float k)\n" + " (assign (x) (var_ref k)\n" + " (expression float - (constant float (1.0))\n" + " (expression float * (var_ref eta)\n" + " (expression float * (var_ref eta)\n" + " (expression float - (constant float (1.0))\n" + " (expression float * \n" + " (expression float dot (var_ref n) (var_ref i))\n" + " (expression float dot (var_ref n) (var_ref i))))))))\n" + " (if (expression bool < (var_ref k) (constant float (0.0)))\n" + " ((return (constant vec3 (0.0 0.0 0.0))))\n" + " ((return (expression vec3 -\n" + " (expression vec3 * (var_ref eta) (var_ref i))\n" + " (expression vec3 *\n" + " (expression float +\n" + " (expression float * (var_ref eta)\n" + " (expression float dot (var_ref n) (var_ref i)))\n" + " (expression float sqrt (var_ref k)))\n" + " (var_ref n))))))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 i)\n" + " (declare (in) vec4 n)\n" + " (declare (in) float eta))\n" + " ((declare () float k)\n" + " (assign (x) (var_ref k)\n" + " (expression float - (constant float (1.0))\n" + " (expression float * (var_ref eta)\n" + " (expression float * (var_ref eta)\n" + " (expression float - (constant float (1.0))\n" + " (expression float * \n" + " (expression float dot (var_ref n) (var_ref i))\n" + " (expression float dot (var_ref n) (var_ref i))))))))\n" + " (if (expression bool < (var_ref k) (constant float (0.0)))\n" + " ((return (constant vec4 (0.0 0.0 0.0 0.0))))\n" + " ((return (expression vec4 -\n" + " (expression vec4 * (var_ref eta) (var_ref i))\n" + " (expression vec4 *\n" + " (expression float +\n" + " (expression float * (var_ref eta)\n" + " (expression float dot (var_ref n) (var_ref i)))\n" + " (expression float sqrt (var_ref k)))\n" + " (var_ref n))))))))\n" + "\n" + "))\n" + "" +; +static const char builtin_round[] = + "((function round\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float arg0))\n" + " ((return (expression float round_even (var_ref arg0)))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 arg0))\n" + " ((return (expression vec2 round_even (var_ref arg0)))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0))\n" + " ((return (expression vec3 round_even (var_ref arg0)))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 arg0))\n" + " ((return (expression vec4 round_even (var_ref arg0)))))\n" + "))\n" + "" +; +static const char builtin_roundEven[] = + "((function roundEven\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float arg0))\n" + " ((return (expression float round_even (var_ref arg0)))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 arg0))\n" + " ((return (expression vec2 round_even (var_ref arg0)))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0))\n" + " ((return (expression vec3 round_even (var_ref arg0)))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 arg0))\n" + " ((return (expression vec4 round_even (var_ref arg0)))))\n" + "))\n" + "" +; +static const char builtin_shadow1D[] = + "((function shadow1D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DShadow sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex vec4 (var_ref sampler) (swiz x (var_ref P)) 0 1 (swiz z (var_ref P)) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DShadow sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb vec4 (var_ref sampler) (swiz x (var_ref P)) 0 1 (swiz z (var_ref P)) (var_ref bias) ))))\n" + "\n" + "))\n" + "" +; +static const char builtin_shadow1DArray[] = + "((function shadow1DArray\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DArrayShadow sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex vec4 (var_ref sampler) (swiz xy (var_ref P)) 0 1 (swiz z (var_ref P)) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DArrayShadow sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb vec4 (var_ref sampler) (swiz xy (var_ref P)) 0 1 (swiz z (var_ref P)) (var_ref bias) ))))\n" + "\n" + "))\n" + "" +; +static const char builtin_shadow1DArrayLod[] = + "((function shadow1DArrayLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DArrayShadow sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl vec4 (var_ref sampler) (swiz xy (var_ref P)) 0 1 (swiz z (var_ref P)) (var_ref lod) ))))\n" + "\n" + "))\n" + "" +; +static const char builtin_shadow1DGradARB[] = + "((function shadow1DGradARB\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DShadow sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float dPdx) \n" + " (declare (in) float dPdy) )\n" + " ((return (txd vec4 (var_ref sampler) (swiz x (var_ref P)) 0 1 (swiz z (var_ref P)) ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + "))\n" + "" +; +static const char builtin_shadow1DLod[] = + "((function shadow1DLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DShadow sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl vec4 (var_ref sampler) (swiz x (var_ref P)) 0 1 (swiz z (var_ref P)) (var_ref lod) ))))\n" + "\n" + "))\n" + "" +; +static const char builtin_shadow1DProj[] = + "((function shadow1DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DShadow sampler)\n" + " (declare (in) vec4 P) )\n" + " ((return (tex vec4 (var_ref sampler) (swiz x (var_ref P)) 0 (swiz w (var_ref P)) (swiz z (var_ref P)) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DShadow sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb vec4 (var_ref sampler) (swiz x (var_ref P)) 0 (swiz w (var_ref P)) (swiz z (var_ref P)) (var_ref bias) ))))\n" + "\n" + "))\n" + "" +; +static const char builtin_shadow1DProjGradARB[] = + "((function shadow1DProjGradARB\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DShadow sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float dPdx) \n" + " (declare (in) float dPdy) )\n" + " ((return (txd vec4 (var_ref sampler) (swiz x (var_ref P)) 0 (swiz w (var_ref P)) (swiz z (var_ref P)) ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + "))\n" + "" +; +static const char builtin_shadow1DProjLod[] = + "((function shadow1DProjLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DShadow sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl vec4 (var_ref sampler) (swiz x (var_ref P)) 0 (swiz w (var_ref P)) (swiz z (var_ref P)) (var_ref lod) ))))\n" + "\n" + "))\n" + "" +; +static const char builtin_shadow2D[] = + "((function shadow2D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DShadow sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex vec4 (var_ref sampler) (swiz xy (var_ref P)) 0 1 (swiz z (var_ref P)) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DShadow sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb vec4 (var_ref sampler) (swiz xy (var_ref P)) 0 1 (swiz z (var_ref P)) (var_ref bias) ))))\n" + "\n" + "))\n" + "" +; +static const char builtin_shadow2DArray[] = + "((function shadow2DArray\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DArrayShadow sampler)\n" + " (declare (in) vec4 P) )\n" + " ((return (tex vec4 (var_ref sampler) (swiz xyz (var_ref P)) 0 1 (swiz w (var_ref P)) ))))\n" + "\n" + "))\n" + "" +; +static const char builtin_shadow2DGradARB[] = + "((function shadow2DGradARB\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DShadow sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd vec4 (var_ref sampler) (swiz xy (var_ref P)) 0 1 (swiz z (var_ref P)) ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + "))\n" + "" +; +static const char builtin_shadow2DLod[] = + "((function shadow2DLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DShadow sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl vec4 (var_ref sampler) (swiz xy (var_ref P)) 0 1 (swiz z (var_ref P)) (var_ref lod) ))))\n" + "\n" + "))\n" + "" +; +static const char builtin_shadow2DProj[] = + "((function shadow2DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DShadow sampler)\n" + " (declare (in) vec4 P) )\n" + " ((return (tex vec4 (var_ref sampler) (swiz xy (var_ref P)) 0 (swiz w (var_ref P)) (swiz z (var_ref P)) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DShadow sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb vec4 (var_ref sampler) (swiz xy (var_ref P)) 0 (swiz w (var_ref P)) (swiz z (var_ref P)) (var_ref bias) ))))\n" + "\n" + "))\n" + "" +; +static const char builtin_shadow2DProjGradARB[] = + "((function shadow2DProjGradARB\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DShadow sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd vec4 (var_ref sampler) (swiz xy (var_ref P)) 0 (swiz w (var_ref P)) (swiz z (var_ref P)) ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + "))\n" + "" +; +static const char builtin_shadow2DProjLod[] = + "((function shadow2DProjLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DShadow sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl vec4 (var_ref sampler) (swiz xy (var_ref P)) 0 (swiz w (var_ref P)) (swiz z (var_ref P)) (var_ref lod) ))))\n" + "\n" + "))\n" + "" +; +static const char builtin_shadow2DRect[] = + "((function shadow2DRect\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DRectShadow sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex vec4 (var_ref sampler) (swiz xy (var_ref P)) 0 1 (swiz z (var_ref P)) ))))\n" + "\n" + "))\n" + "" +; +static const char builtin_shadow2DRectGradARB[] = + "((function shadow2DRectGradARB\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DRectShadow sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd vec4 (var_ref sampler) (swiz xy (var_ref P)) 0 1 (swiz z (var_ref P)) ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + "))\n" + "" +; +static const char builtin_shadow2DRectProj[] = + "((function shadow2DRectProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DRectShadow sampler)\n" + " (declare (in) vec4 P) )\n" + " ((return (tex vec4 (var_ref sampler) (swiz xy (var_ref P)) 0 (swiz w (var_ref P)) (swiz z (var_ref P)) ))))\n" + "\n" + "))\n" + "" +; +static const char builtin_shadow2DRectProjGradARB[] = + "((function shadow2DRectProjGradARB\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DRectShadow sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd vec4 (var_ref sampler) (swiz xy (var_ref P)) 0 (swiz w (var_ref P)) (swiz z (var_ref P)) ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + "))\n" + "" +; +static const char builtin_sign[] = + "((function sign\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ((return (expression float sign (var_ref x)))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ((return (expression vec2 sign (var_ref x)))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ((return (expression vec3 sign (var_ref x)))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ((return (expression vec4 sign (var_ref x)))))\n" + "\n" + " (signature int\n" + " (parameters\n" + " (declare (in) int x))\n" + " ((return (expression int sign (var_ref x)))))\n" + "\n" + " (signature ivec2\n" + " (parameters\n" + " (declare (in) ivec2 x))\n" + " ((return (expression ivec2 sign (var_ref x)))))\n" + "\n" + " (signature ivec3\n" + " (parameters\n" + " (declare (in) ivec3 x))\n" + " ((return (expression ivec3 sign (var_ref x)))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) ivec4 x))\n" + " ((return (expression ivec4 sign (var_ref x)))))\n" + "))\n" + "\n" + "" +; +static const char builtin_sin[] = + "((function sin\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float angle))\n" + " ((return (expression float sin (var_ref angle)))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 angle))\n" + " ((return (expression vec2 sin (var_ref angle)))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 angle))\n" + " ((return (expression vec3 sin (var_ref angle)))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 angle))\n" + " ((return (expression vec4 sin (var_ref angle)))))\n" + "))\n" + "" +; +static const char builtin_sinh[] = + "((function sinh\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ((return (expression float * (constant float (0.5))\n" + " (expression float -\n" + " (expression float exp (var_ref x))\n" + " (expression float exp (expression float neg (var_ref x))))))))\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ((return (expression vec2 * (constant vec2 (0.5))\n" + " (expression vec2 -\n" + " (expression vec2 exp (var_ref x))\n" + " (expression vec2 exp (expression vec2 neg (var_ref x))))))))\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ((return (expression vec3 * (constant vec3 (0.5))\n" + " (expression vec3 -\n" + " (expression vec3 exp (var_ref x))\n" + " (expression vec3 exp (expression vec3 neg (var_ref x))))))))\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ((return (expression vec4 * (constant vec4 (0.5))\n" + " (expression vec4 -\n" + " (expression vec4 exp (var_ref x))\n" + " (expression vec4 exp (expression vec4 neg (var_ref x))))))))\n" + "))\n" + "" +; +static const char builtin_smoothstep[] = + "((function smoothstep\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float edge0)\n" + " (declare (in) float edge1)\n" + " (declare (in) float x))\n" + " ((declare () float t)\n" + " (assign (x) (var_ref t)\n" + " (expression float max\n" + " (expression float min\n" + " (expression float / (expression float - (var_ref x) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n" + " (constant float (1.0)))\n" + " (constant float (0.0))))\n" + " (return (expression float * (var_ref t) (expression float * (var_ref t) (expression float - (constant float (3.0)) (expression float * (constant float (2.0)) (var_ref t))))))))\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) float edge0)\n" + " (declare (in) float edge1)\n" + " (declare (in) vec2 x))\n" + " ((declare () vec2 t)\n" + " (assign (xy) (var_ref t)\n" + " (expression vec2 max\n" + " (expression vec2 min\n" + " (expression vec2 / (expression vec2 - (var_ref x) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n" + " (constant float (1.0)))\n" + " (constant float (0.0))))\n" + " (return (expression vec2 * (var_ref t) (expression vec2 * (var_ref t) (expression vec2 - (constant float (3.0)) (expression vec2 * (constant float (2.0)) (var_ref t))))))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) float edge0)\n" + " (declare (in) float edge1)\n" + " (declare (in) vec3 x))\n" + " ((declare () vec3 t)\n" + " (assign (xyz) (var_ref t)\n" + " (expression vec3 max\n" + " (expression vec3 min\n" + " (expression vec3 / (expression vec3 - (var_ref x) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n" + " (constant float (1.0)))\n" + " (constant float (0.0))))\n" + " (return (expression vec3 * (var_ref t) (expression vec3 * (var_ref t) (expression vec3 - (constant float (3.0)) (expression vec3 * (constant float (2.0)) (var_ref t))))))))\n" + "\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) float edge0)\n" + " (declare (in) float edge1)\n" + " (declare (in) vec4 x))\n" + " ((declare () vec4 t)\n" + " (assign (xyzw) (var_ref t)\n" + " (expression vec4 max\n" + " (expression vec4 min\n" + " (expression vec4 / (expression vec4 - (var_ref x) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n" + " (constant float (1.0)))\n" + " (constant float (0.0))))\n" + " (return (expression vec4 * (var_ref t) (expression vec4 * (var_ref t) (expression vec4 - (constant float (3.0)) (expression vec4 * (constant float (2.0)) (var_ref t))))))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 edge0)\n" + " (declare (in) vec2 edge1)\n" + " (declare (in) vec2 x))\n" + " ((declare () vec2 t)\n" + " (assign (xy) (var_ref t)\n" + " (expression vec2 max\n" + " (expression vec2 min\n" + " (expression vec2 / (expression vec2 - (var_ref x) (var_ref edge0)) (expression vec2 - (var_ref edge1) (var_ref edge0)))\n" + " (constant float (1.0)))\n" + " (constant float (0.0))))\n" + " (return (expression vec2 * (var_ref t) (expression vec2 * (var_ref t) (expression vec2 - (constant float (3.0)) (expression vec2 * (constant float (2.0)) (var_ref t))))))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 edge0)\n" + " (declare (in) vec3 edge1)\n" + " (declare (in) vec3 x))\n" + " ((declare () vec3 t)\n" + " (assign (xyz) (var_ref t)\n" + " (expression vec3 max\n" + " (expression vec3 min\n" + " (expression vec3 / (expression vec3 - (var_ref x) (var_ref edge0)) (expression vec3 - (var_ref edge1) (var_ref edge0)))\n" + " (constant float (1.0)))\n" + " (constant float (0.0))))\n" + " (return (expression vec3 * (var_ref t) (expression vec3 * (var_ref t) (expression vec3 - (constant float (3.0)) (expression vec3 * (constant float (2.0)) (var_ref t))))))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 edge0)\n" + " (declare (in) vec4 edge1)\n" + " (declare (in) vec4 x))\n" + " ((declare () vec4 t)\n" + " (assign (xyzw) (var_ref t)\n" + " (expression vec4 max\n" + " (expression vec4 min\n" + " (expression vec4 / (expression vec4 - (var_ref x) (var_ref edge0)) (expression vec4 - (var_ref edge1) (var_ref edge0)))\n" + " (constant float (1.0)))\n" + " (constant float (0.0))))\n" + " (return (expression vec4 * (var_ref t) (expression vec4 * (var_ref t) (expression vec4 - (constant float (3.0)) (expression vec4 * (constant float (2.0)) (var_ref t))))))))\n" + "))\n" + "\n" + "" +; +static const char builtin_sqrt[] = + "((function sqrt\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float arg0))\n" + " ((return (expression float sqrt (var_ref arg0)))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 arg0))\n" + " ((return (expression vec2 sqrt (var_ref arg0)))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0))\n" + " ((return (expression vec3 sqrt (var_ref arg0)))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 arg0))\n" + " ((return (expression vec4 sqrt (var_ref arg0)))))\n" + "))\n" + "" +; +static const char builtin_step[] = + "((function step\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float edge)\n" + " (declare (in) float x))\n" + " ((return (expression float b2f (expression bool >= (var_ref x) (var_ref edge))))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) float edge)\n" + " (declare (in) vec2 x))\n" + " ((declare () vec2 t)\n" + " (assign (x) (var_ref t) (expression float b2f (expression bool >= (swiz x (var_ref x))(var_ref edge))))\n" + " (assign (y) (var_ref t) (expression float b2f (expression bool >= (swiz y (var_ref x))(var_ref edge))))\n" + " (return (var_ref t))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) float edge)\n" + " (declare (in) vec3 x))\n" + " ((declare () vec3 t)\n" + " (assign (x) (var_ref t) (expression float b2f (expression bool >= (swiz x (var_ref x))(var_ref edge))))\n" + " (assign (y) (var_ref t) (expression float b2f (expression bool >= (swiz y (var_ref x))(var_ref edge))))\n" + " (assign (z) (var_ref t) (expression float b2f (expression bool >= (swiz z (var_ref x))(var_ref edge))))\n" + " (return (var_ref t))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) float edge)\n" + " (declare (in) vec4 x))\n" + " ((declare () vec4 t)\n" + " (assign (x) (var_ref t) (expression float b2f (expression bool >= (swiz x (var_ref x))(var_ref edge))))\n" + " (assign (y) (var_ref t) (expression float b2f (expression bool >= (swiz y (var_ref x))(var_ref edge))))\n" + " (assign (z) (var_ref t) (expression float b2f (expression bool >= (swiz z (var_ref x))(var_ref edge))))\n" + " (assign (w) (var_ref t) (expression float b2f (expression bool >= (swiz w (var_ref x))(var_ref edge))))\n" + " (return (var_ref t))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 edge)\n" + " (declare (in) vec2 x))\n" + " ((declare () vec2 t)\n" + " (assign (x) (var_ref t) (expression float b2f (expression bool >= (swiz x (var_ref x))(swiz x (var_ref edge)))))\n" + " (assign (y) (var_ref t) (expression float b2f (expression bool >= (swiz y (var_ref x))(swiz y (var_ref edge)))))\n" + " (return (var_ref t))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 edge)\n" + " (declare (in) vec3 x))\n" + " ((declare () vec3 t)\n" + " (assign (x) (var_ref t) (expression float b2f (expression bool >= (swiz x (var_ref x))(swiz x (var_ref edge)))))\n" + " (assign (y) (var_ref t) (expression float b2f (expression bool >= (swiz y (var_ref x))(swiz y (var_ref edge)))))\n" + " (assign (z) (var_ref t) (expression float b2f (expression bool >= (swiz z (var_ref x))(swiz z (var_ref edge)))))\n" + " (return (var_ref t))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 edge)\n" + " (declare (in) vec4 x))\n" + " ((declare () vec4 t)\n" + " (assign (x) (var_ref t) (expression float b2f (expression bool >= (swiz x (var_ref x))(swiz x (var_ref edge)))))\n" + " (assign (y) (var_ref t) (expression float b2f (expression bool >= (swiz y (var_ref x))(swiz y (var_ref edge)))))\n" + " (assign (z) (var_ref t) (expression float b2f (expression bool >= (swiz z (var_ref x))(swiz z (var_ref edge)))))\n" + " (assign (w) (var_ref t) (expression float b2f (expression bool >= (swiz w (var_ref x))(swiz w (var_ref edge)))))\n" + " (return (var_ref t))))\n" + "))\n" + "\n" + "" +; +static const char builtin_tan[] = + "((function tan\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float angle))\n" + " ((return (expression float / (expression float sin (var_ref angle)) (expression float cos (var_ref angle))))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 angle))\n" + " ((return (expression vec2 / (expression vec2 sin (var_ref angle)) (expression vec2 cos (var_ref angle))))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 angle))\n" + " ((return (expression vec3 / (expression vec3 sin (var_ref angle)) (expression vec3 cos (var_ref angle))))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 angle))\n" + " ((return (expression vec4 / (expression vec4 sin (var_ref angle)) (expression vec4 cos (var_ref angle))))))\n" + "))\n" + "" +; +static const char builtin_tanh[] = + "((function tanh\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ((return (expression float /\n" + " (expression float -\n" + " (expression float exp (var_ref x))\n" + " (expression float exp (expression float neg (var_ref x))))\n" + " (expression float +\n" + " (expression float exp (var_ref x))\n" + " (expression float exp (expression float neg (var_ref x))))))))\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ((return (expression vec2 /\n" + " (expression vec2 -\n" + " (expression vec2 exp (var_ref x))\n" + " (expression vec2 exp (expression vec2 neg (var_ref x))))\n" + " (expression vec2 +\n" + " (expression vec2 exp (var_ref x))\n" + " (expression vec2 exp (expression vec2 neg (var_ref x))))))))\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ((return (expression vec3 /\n" + " (expression vec3 -\n" + " (expression vec3 exp (var_ref x))\n" + " (expression vec3 exp (expression vec3 neg (var_ref x))))\n" + " (expression vec3 +\n" + " (expression vec3 exp (var_ref x))\n" + " (expression vec3 exp (expression vec3 neg (var_ref x))))))))\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ((return (expression vec4 /\n" + " (expression vec4 -\n" + " (expression vec4 exp (var_ref x))\n" + " (expression vec4 exp (expression vec4 neg (var_ref x))))\n" + " (expression vec4 +\n" + " (expression vec4 exp (var_ref x))\n" + " (expression vec4 exp (expression vec4 neg (var_ref x))))))))\n" + "))\n" + "" +; +static const char builtin_texelFetch[] = + "((function texelFetch\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) int P) \n" + " (declare (in) int lod) )\n" + " ((return (txf vec4 (var_ref sampler) (var_ref P) 0 (var_ref lod) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1D sampler)\n" + " (declare (in) int P) \n" + " (declare (in) int lod) )\n" + " ((return (txf ivec4 (var_ref sampler) (var_ref P) 0 (var_ref lod) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1D sampler)\n" + " (declare (in) int P) \n" + " (declare (in) int lod) )\n" + " ((return (txf uvec4 (var_ref sampler) (var_ref P) 0 (var_ref lod) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) ivec2 P) \n" + " (declare (in) int lod) )\n" + " ((return (txf vec4 (var_ref sampler) (var_ref P) 0 (var_ref lod) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2D sampler)\n" + " (declare (in) ivec2 P) \n" + " (declare (in) int lod) )\n" + " ((return (txf ivec4 (var_ref sampler) (var_ref P) 0 (var_ref lod) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2D sampler)\n" + " (declare (in) ivec2 P) \n" + " (declare (in) int lod) )\n" + " ((return (txf uvec4 (var_ref sampler) (var_ref P) 0 (var_ref lod) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) ivec3 P) \n" + " (declare (in) int lod) )\n" + " ((return (txf vec4 (var_ref sampler) (var_ref P) 0 (var_ref lod) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler3D sampler)\n" + " (declare (in) ivec3 P) \n" + " (declare (in) int lod) )\n" + " ((return (txf ivec4 (var_ref sampler) (var_ref P) 0 (var_ref lod) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler3D sampler)\n" + " (declare (in) ivec3 P) \n" + " (declare (in) int lod) )\n" + " ((return (txf uvec4 (var_ref sampler) (var_ref P) 0 (var_ref lod) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DArray sampler)\n" + " (declare (in) ivec2 P) \n" + " (declare (in) int lod) )\n" + " ((return (txf vec4 (var_ref sampler) (var_ref P) 0 (var_ref lod) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1DArray sampler)\n" + " (declare (in) ivec2 P) \n" + " (declare (in) int lod) )\n" + " ((return (txf ivec4 (var_ref sampler) (var_ref P) 0 (var_ref lod) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1DArray sampler)\n" + " (declare (in) ivec2 P) \n" + " (declare (in) int lod) )\n" + " ((return (txf uvec4 (var_ref sampler) (var_ref P) 0 (var_ref lod) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DArray sampler)\n" + " (declare (in) ivec3 P) \n" + " (declare (in) int lod) )\n" + " ((return (txf vec4 (var_ref sampler) (var_ref P) 0 (var_ref lod) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2DArray sampler)\n" + " (declare (in) ivec3 P) \n" + " (declare (in) int lod) )\n" + " ((return (txf ivec4 (var_ref sampler) (var_ref P) 0 (var_ref lod) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2DArray sampler)\n" + " (declare (in) ivec3 P) \n" + " (declare (in) int lod) )\n" + " ((return (txf uvec4 (var_ref sampler) (var_ref P) 0 (var_ref lod) ))))\n" + "\n" + "))\n" + "" +; +static const char builtin_texelFetchOffset[] = + "((function texelFetchOffset\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) int P) \n" + " (declare (in) int lod) \n" + " (declare (const_in) int offset) )\n" + " ((return (txf vec4 (var_ref sampler) (var_ref P) (var_ref offset) (var_ref lod) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1D sampler)\n" + " (declare (in) int P) \n" + " (declare (in) int lod) \n" + " (declare (const_in) int offset) )\n" + " ((return (txf ivec4 (var_ref sampler) (var_ref P) (var_ref offset) (var_ref lod) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1D sampler)\n" + " (declare (in) int P) \n" + " (declare (in) int lod) \n" + " (declare (const_in) int offset) )\n" + " ((return (txf uvec4 (var_ref sampler) (var_ref P) (var_ref offset) (var_ref lod) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) ivec2 P) \n" + " (declare (in) int lod) \n" + " (declare (const_in) ivec2 offset) )\n" + " ((return (txf vec4 (var_ref sampler) (var_ref P) (var_ref offset) (var_ref lod) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2D sampler)\n" + " (declare (in) ivec2 P) \n" + " (declare (in) int lod) \n" + " (declare (const_in) ivec2 offset) )\n" + " ((return (txf ivec4 (var_ref sampler) (var_ref P) (var_ref offset) (var_ref lod) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2D sampler)\n" + " (declare (in) ivec2 P) \n" + " (declare (in) int lod) \n" + " (declare (const_in) ivec2 offset) )\n" + " ((return (txf uvec4 (var_ref sampler) (var_ref P) (var_ref offset) (var_ref lod) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) ivec3 P) \n" + " (declare (in) int lod) \n" + " (declare (const_in) ivec3 offset) )\n" + " ((return (txf vec4 (var_ref sampler) (var_ref P) (var_ref offset) (var_ref lod) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler3D sampler)\n" + " (declare (in) ivec3 P) \n" + " (declare (in) int lod) \n" + " (declare (const_in) ivec3 offset) )\n" + " ((return (txf ivec4 (var_ref sampler) (var_ref P) (var_ref offset) (var_ref lod) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler3D sampler)\n" + " (declare (in) ivec3 P) \n" + " (declare (in) int lod) \n" + " (declare (const_in) ivec3 offset) )\n" + " ((return (txf uvec4 (var_ref sampler) (var_ref P) (var_ref offset) (var_ref lod) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DArray sampler)\n" + " (declare (in) ivec2 P) \n" + " (declare (in) int lod) \n" + " (declare (const_in) int offset) )\n" + " ((return (txf vec4 (var_ref sampler) (var_ref P) (var_ref offset) (var_ref lod) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1DArray sampler)\n" + " (declare (in) ivec2 P) \n" + " (declare (in) int lod) \n" + " (declare (const_in) int offset) )\n" + " ((return (txf ivec4 (var_ref sampler) (var_ref P) (var_ref offset) (var_ref lod) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1DArray sampler)\n" + " (declare (in) ivec2 P) \n" + " (declare (in) int lod) \n" + " (declare (const_in) int offset) )\n" + " ((return (txf uvec4 (var_ref sampler) (var_ref P) (var_ref offset) (var_ref lod) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DArray sampler)\n" + " (declare (in) ivec3 P) \n" + " (declare (in) int lod) \n" + " (declare (const_in) ivec2 offset) )\n" + " ((return (txf vec4 (var_ref sampler) (var_ref P) (var_ref offset) (var_ref lod) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2DArray sampler)\n" + " (declare (in) ivec3 P) \n" + " (declare (in) int lod) \n" + " (declare (const_in) ivec2 offset) )\n" + " ((return (txf ivec4 (var_ref sampler) (var_ref P) (var_ref offset) (var_ref lod) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2DArray sampler)\n" + " (declare (in) ivec3 P) \n" + " (declare (in) int lod) \n" + " (declare (const_in) ivec2 offset) )\n" + " ((return (txf uvec4 (var_ref sampler) (var_ref P) (var_ref offset) (var_ref lod) ))))\n" + "\n" + "))\n" + "" +; +static const char builtin_texture[] = + "((function texture\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) float P) )\n" + " ((return (tex vec4 (var_ref sampler) (var_ref P) 0 1 () ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1D sampler)\n" + " (declare (in) float P) )\n" + " ((return (tex ivec4 (var_ref sampler) (var_ref P) 0 1 () ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1D sampler)\n" + " (declare (in) float P) )\n" + " ((return (tex uvec4 (var_ref sampler) (var_ref P) 0 1 () ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec2 P) )\n" + " ((return (tex vec4 (var_ref sampler) (var_ref P) 0 1 () ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2D sampler)\n" + " (declare (in) vec2 P) )\n" + " ((return (tex ivec4 (var_ref sampler) (var_ref P) 0 1 () ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2D sampler)\n" + " (declare (in) vec2 P) )\n" + " ((return (tex uvec4 (var_ref sampler) (var_ref P) 0 1 () ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex vec4 (var_ref sampler) (var_ref P) 0 1 () ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler3D sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex ivec4 (var_ref sampler) (var_ref P) 0 1 () ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler3D sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex uvec4 (var_ref sampler) (var_ref P) 0 1 () ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) samplerCube sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex vec4 (var_ref sampler) (var_ref P) 0 1 () ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isamplerCube sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex ivec4 (var_ref sampler) (var_ref P) 0 1 () ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usamplerCube sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex uvec4 (var_ref sampler) (var_ref P) 0 1 () ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DArray sampler)\n" + " (declare (in) vec2 P) )\n" + " ((return (tex vec4 (var_ref sampler) (var_ref P) 0 1 () ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1DArray sampler)\n" + " (declare (in) vec2 P) )\n" + " ((return (tex ivec4 (var_ref sampler) (var_ref P) 0 1 () ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1DArray sampler)\n" + " (declare (in) vec2 P) )\n" + " ((return (tex uvec4 (var_ref sampler) (var_ref P) 0 1 () ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DArray sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex vec4 (var_ref sampler) (var_ref P) 0 1 () ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2DArray sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex ivec4 (var_ref sampler) (var_ref P) 0 1 () ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2DArray sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex uvec4 (var_ref sampler) (var_ref P) 0 1 () ))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) sampler1DShadow sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex float (var_ref sampler) (swiz x (var_ref P)) 0 1 (swiz z (var_ref P)) ))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) sampler2DShadow sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex float (var_ref sampler) (swiz xy (var_ref P)) 0 1 (swiz z (var_ref P)) ))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) samplerCubeShadow sampler)\n" + " (declare (in) vec4 P) )\n" + " ((return (tex float (var_ref sampler) (swiz xyz (var_ref P)) 0 1 (swiz z (var_ref P)) ))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) sampler1DArrayShadow sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex float (var_ref sampler) (swiz xy (var_ref P)) 0 1 (swiz z (var_ref P)) ))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) sampler2DArrayShadow sampler)\n" + " (declare (in) vec4 P) )\n" + " ((return (tex float (var_ref sampler) (swiz xyz (var_ref P)) 0 1 (swiz w (var_ref P)) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) float P) \n" + " (declare (in) float bias) )\n" + " ((return (txb vec4 (var_ref sampler) (var_ref P) 0 1 () (var_ref bias) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1D sampler)\n" + " (declare (in) float P) \n" + " (declare (in) float bias) )\n" + " ((return (txb ivec4 (var_ref sampler) (var_ref P) 0 1 () (var_ref bias) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1D sampler)\n" + " (declare (in) float P) \n" + " (declare (in) float bias) )\n" + " ((return (txb uvec4 (var_ref sampler) (var_ref P) 0 1 () (var_ref bias) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb vec4 (var_ref sampler) (var_ref P) 0 1 () (var_ref bias) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb ivec4 (var_ref sampler) (var_ref P) 0 1 () (var_ref bias) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb uvec4 (var_ref sampler) (var_ref P) 0 1 () (var_ref bias) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb vec4 (var_ref sampler) (var_ref P) 0 1 () (var_ref bias) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler3D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb ivec4 (var_ref sampler) (var_ref P) 0 1 () (var_ref bias) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler3D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb uvec4 (var_ref sampler) (var_ref P) 0 1 () (var_ref bias) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) samplerCube sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb vec4 (var_ref sampler) (var_ref P) 0 1 () (var_ref bias) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isamplerCube sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb ivec4 (var_ref sampler) (var_ref P) 0 1 () (var_ref bias) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usamplerCube sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb uvec4 (var_ref sampler) (var_ref P) 0 1 () (var_ref bias) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DArray sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb vec4 (var_ref sampler) (var_ref P) 0 1 () (var_ref bias) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1DArray sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb ivec4 (var_ref sampler) (var_ref P) 0 1 () (var_ref bias) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1DArray sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb uvec4 (var_ref sampler) (var_ref P) 0 1 () (var_ref bias) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DArray sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb vec4 (var_ref sampler) (var_ref P) 0 1 () (var_ref bias) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2DArray sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb ivec4 (var_ref sampler) (var_ref P) 0 1 () (var_ref bias) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2DArray sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb uvec4 (var_ref sampler) (var_ref P) 0 1 () (var_ref bias) ))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) sampler1DShadow sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb float (var_ref sampler) (swiz x (var_ref P)) 0 1 (swiz z (var_ref P)) (var_ref bias) ))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) sampler2DShadow sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb float (var_ref sampler) (swiz xy (var_ref P)) 0 1 (swiz z (var_ref P)) (var_ref bias) ))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) samplerCubeShadow sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb float (var_ref sampler) (swiz xyz (var_ref P)) 0 1 (swiz z (var_ref P)) (var_ref bias) ))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) sampler1DArrayShadow sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb float (var_ref sampler) (swiz xy (var_ref P)) 0 1 (swiz z (var_ref P)) (var_ref bias) ))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) sampler2DArrayShadow sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb float (var_ref sampler) (swiz xyz (var_ref P)) 0 1 (swiz w (var_ref P)) (var_ref bias) ))))\n" + "\n" + "))\n" + "" +; +static const char builtin_texture1D[] = + "((function texture1D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) float P) )\n" + " ((return (tex vec4 (var_ref sampler) (var_ref P) 0 1 () ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) float P) \n" + " (declare (in) float bias) )\n" + " ((return (txb vec4 (var_ref sampler) (var_ref P) 0 1 () (var_ref bias) ))))\n" + "\n" + "))\n" + "" +; +static const char builtin_texture1DArray[] = + "((function texture1DArray\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DArray sampler)\n" + " (declare (in) vec2 P) )\n" + " ((return (tex vec4 (var_ref sampler) (var_ref P) 0 1 () ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DArray sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb vec4 (var_ref sampler) (var_ref P) 0 1 () (var_ref bias) ))))\n" + "\n" + "))\n" + "" +; +static const char builtin_texture1DArrayLod[] = + "((function texture1DArrayLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DArray sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl vec4 (var_ref sampler) (var_ref P) 0 1 () (var_ref lod) ))))\n" + "\n" + "))\n" + "" +; +static const char builtin_texture1DGradARB[] = + "((function texture1DGradARB\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) float P) \n" + " (declare (in) float dPdx) \n" + " (declare (in) float dPdy) )\n" + " ((return (txd vec4 (var_ref sampler) (var_ref P) 0 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1D sampler)\n" + " (declare (in) float P) \n" + " (declare (in) float dPdx) \n" + " (declare (in) float dPdy) )\n" + " ((return (txd ivec4 (var_ref sampler) (var_ref P) 0 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1D sampler)\n" + " (declare (in) float P) \n" + " (declare (in) float dPdx) \n" + " (declare (in) float dPdy) )\n" + " ((return (txd uvec4 (var_ref sampler) (var_ref P) 0 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + "))\n" + "" +; +static const char builtin_texture1DLod[] = + "((function texture1DLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) float P) \n" + " (declare (in) float lod) )\n" + " ((return (txl vec4 (var_ref sampler) (var_ref P) 0 1 () (var_ref lod) ))))\n" + "\n" + "))\n" + "" +; +static const char builtin_texture1DProj[] = + "((function texture1DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec2 P) )\n" + " ((return (tex vec4 (var_ref sampler) (swiz x (var_ref P)) 0 (swiz y (var_ref P)) () ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec4 P) )\n" + " ((return (tex vec4 (var_ref sampler) (swiz x (var_ref P)) 0 (swiz w (var_ref P)) () ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb vec4 (var_ref sampler) (swiz x (var_ref P)) 0 (swiz y (var_ref P)) () (var_ref bias) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb vec4 (var_ref sampler) (swiz x (var_ref P)) 0 (swiz w (var_ref P)) () (var_ref bias) ))))\n" + "\n" + "))\n" + "" +; +static const char builtin_texture1DProjGradARB[] = + "((function texture1DProjGradARB\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float dPdx) \n" + " (declare (in) float dPdy) )\n" + " ((return (txd vec4 (var_ref sampler) (swiz x (var_ref P)) 0 (swiz y (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float dPdx) \n" + " (declare (in) float dPdy) )\n" + " ((return (txd ivec4 (var_ref sampler) (swiz x (var_ref P)) 0 (swiz y (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float dPdx) \n" + " (declare (in) float dPdy) )\n" + " ((return (txd uvec4 (var_ref sampler) (swiz x (var_ref P)) 0 (swiz y (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float dPdx) \n" + " (declare (in) float dPdy) )\n" + " ((return (txd vec4 (var_ref sampler) (swiz x (var_ref P)) 0 (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float dPdx) \n" + " (declare (in) float dPdy) )\n" + " ((return (txd ivec4 (var_ref sampler) (swiz x (var_ref P)) 0 (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float dPdx) \n" + " (declare (in) float dPdy) )\n" + " ((return (txd uvec4 (var_ref sampler) (swiz x (var_ref P)) 0 (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + "))\n" + "" +; +static const char builtin_texture1DProjLod[] = + "((function texture1DProjLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl vec4 (var_ref sampler) (swiz x (var_ref P)) 0 (swiz y (var_ref P)) () (var_ref lod) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl vec4 (var_ref sampler) (swiz x (var_ref P)) 0 (swiz w (var_ref P)) () (var_ref lod) ))))\n" + "\n" + "))\n" + "" +; +static const char builtin_texture2D[] = + "((function texture2D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec2 P) )\n" + " ((return (tex vec4 (var_ref sampler) (var_ref P) 0 1 () ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb vec4 (var_ref sampler) (var_ref P) 0 1 () (var_ref bias) ))))\n" + "\n" + "))\n" + "" +; +static const char builtin_texture2DArray[] = + "((function texture2DArray\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DArray sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex vec4 (var_ref sampler) (var_ref P) 0 1 () ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DArray sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb vec4 (var_ref sampler) (var_ref P) 0 1 () (var_ref bias) ))))\n" + "\n" + "))\n" + "" +; +static const char builtin_texture2DArrayLod[] = + "((function texture2DArrayLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DArray sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl vec4 (var_ref sampler) (var_ref P) 0 1 () (var_ref lod) ))))\n" + "\n" + "))\n" + "" +; +static const char builtin_texture2DGradARB[] = + "((function texture2DGradARB\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd vec4 (var_ref sampler) (var_ref P) 0 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd ivec4 (var_ref sampler) (var_ref P) 0 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd uvec4 (var_ref sampler) (var_ref P) 0 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + "))\n" + "" +; +static const char builtin_texture2DGradEXT[] = + "((function texture2DGradEXT\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd vec4 (var_ref sampler) (var_ref P) 0 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd ivec4 (var_ref sampler) (var_ref P) 0 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd uvec4 (var_ref sampler) (var_ref P) 0 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + "))\n" + "" +; +static const char builtin_texture2DLod[] = + "((function texture2DLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl vec4 (var_ref sampler) (var_ref P) 0 1 () (var_ref lod) ))))\n" + "\n" + "))\n" + "" +; +static const char builtin_texture2DLodEXT[] = + "((function texture2DLodEXT\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl vec4 (var_ref sampler) (var_ref P) 0 1 () (var_ref lod) ))))\n" + "\n" + "))\n" + "" +; +static const char builtin_texture2DProj[] = + "((function texture2DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex vec4 (var_ref sampler) (swiz xy (var_ref P)) 0 (swiz z (var_ref P)) () ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec4 P) )\n" + " ((return (tex vec4 (var_ref sampler) (swiz xy (var_ref P)) 0 (swiz w (var_ref P)) () ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb vec4 (var_ref sampler) (swiz xy (var_ref P)) 0 (swiz z (var_ref P)) () (var_ref bias) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb vec4 (var_ref sampler) (swiz xy (var_ref P)) 0 (swiz w (var_ref P)) () (var_ref bias) ))))\n" + "\n" + "))\n" + "" +; +static const char builtin_texture2DProjGradARB[] = + "((function texture2DProjGradARB\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd vec4 (var_ref sampler) (swiz xy (var_ref P)) 0 (swiz z (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd ivec4 (var_ref sampler) (swiz xy (var_ref P)) 0 (swiz z (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd uvec4 (var_ref sampler) (swiz xy (var_ref P)) 0 (swiz z (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd vec4 (var_ref sampler) (swiz xy (var_ref P)) 0 (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd ivec4 (var_ref sampler) (swiz xy (var_ref P)) 0 (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd uvec4 (var_ref sampler) (swiz xy (var_ref P)) 0 (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + "))\n" + "" +; +static const char builtin_texture2DProjGradEXT[] = + "((function texture2DProjGradEXT\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd vec4 (var_ref sampler) (swiz xy (var_ref P)) 0 (swiz z (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd ivec4 (var_ref sampler) (swiz xy (var_ref P)) 0 (swiz z (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd uvec4 (var_ref sampler) (swiz xy (var_ref P)) 0 (swiz z (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd vec4 (var_ref sampler) (swiz xy (var_ref P)) 0 (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd ivec4 (var_ref sampler) (swiz xy (var_ref P)) 0 (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd uvec4 (var_ref sampler) (swiz xy (var_ref P)) 0 (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + "))\n" + "" +; +static const char builtin_texture2DProjLod[] = + "((function texture2DProjLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl vec4 (var_ref sampler) (swiz xy (var_ref P)) 0 (swiz z (var_ref P)) () (var_ref lod) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl vec4 (var_ref sampler) (swiz xy (var_ref P)) 0 (swiz w (var_ref P)) () (var_ref lod) ))))\n" + "\n" + "))\n" + "" +; +static const char builtin_texture2DProjLodEXT[] = + "((function texture2DProjLodEXT\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl vec4 (var_ref sampler) (swiz xy (var_ref P)) 0 (swiz z (var_ref P)) () (var_ref lod) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl vec4 (var_ref sampler) (swiz xy (var_ref P)) 0 (swiz w (var_ref P)) () (var_ref lod) ))))\n" + "\n" + "))\n" + "" +; +static const char builtin_texture2DRect[] = + "((function texture2DRect\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DRect sampler)\n" + " (declare (in) vec2 P) )\n" + " ((return (tex vec4 (var_ref sampler) (var_ref P) 0 1 () ))))\n" + "\n" + "))\n" + "" +; +static const char builtin_texture2DRectGradARB[] = + "((function texture2DRectGradARB\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DRect sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd vec4 (var_ref sampler) (var_ref P) 0 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + "))\n" + "" +; +static const char builtin_texture2DRectProj[] = + "((function texture2DRectProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DRect sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex vec4 (var_ref sampler) (swiz xy (var_ref P)) 0 (swiz z (var_ref P)) () ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DRect sampler)\n" + " (declare (in) vec4 P) )\n" + " ((return (tex vec4 (var_ref sampler) (swiz xy (var_ref P)) 0 (swiz w (var_ref P)) () ))))\n" + "\n" + "))\n" + "" +; +static const char builtin_texture2DRectProjGradARB[] = + "((function texture2DRectProjGradARB\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DRect sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd vec4 (var_ref sampler) (swiz xy (var_ref P)) 0 (swiz z (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DRect sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd vec4 (var_ref sampler) (swiz xy (var_ref P)) 0 (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + "))\n" + "" +; +static const char builtin_texture3D[] = + "((function texture3D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex vec4 (var_ref sampler) (var_ref P) 0 1 () ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb vec4 (var_ref sampler) (var_ref P) 0 1 () (var_ref bias) ))))\n" + "\n" + "))\n" + "" +; +static const char builtin_texture3DGradARB[] = + "((function texture3DGradARB\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec3 dPdx) \n" + " (declare (in) vec3 dPdy) )\n" + " ((return (txd vec4 (var_ref sampler) (var_ref P) 0 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler3D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec3 dPdx) \n" + " (declare (in) vec3 dPdy) )\n" + " ((return (txd ivec4 (var_ref sampler) (var_ref P) 0 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler3D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec3 dPdx) \n" + " (declare (in) vec3 dPdy) )\n" + " ((return (txd uvec4 (var_ref sampler) (var_ref P) 0 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + "))\n" + "" +; +static const char builtin_texture3DLod[] = + "((function texture3DLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl vec4 (var_ref sampler) (var_ref P) 0 1 () (var_ref lod) ))))\n" + "\n" + "))\n" + "" +; +static const char builtin_texture3DProj[] = + "((function texture3DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec4 P) )\n" + " ((return (tex vec4 (var_ref sampler) (swiz xyz (var_ref P)) 0 (swiz w (var_ref P)) () ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb vec4 (var_ref sampler) (swiz xyz (var_ref P)) 0 (swiz w (var_ref P)) () (var_ref bias) ))))\n" + "\n" + "))\n" + "" +; +static const char builtin_texture3DProjGradARB[] = + "((function texture3DProjGradARB\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) vec3 dPdx) \n" + " (declare (in) vec3 dPdy) )\n" + " ((return (txd vec4 (var_ref sampler) (swiz xyz (var_ref P)) 0 (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler3D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) vec3 dPdx) \n" + " (declare (in) vec3 dPdy) )\n" + " ((return (txd ivec4 (var_ref sampler) (swiz xyz (var_ref P)) 0 (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler3D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) vec3 dPdx) \n" + " (declare (in) vec3 dPdy) )\n" + " ((return (txd uvec4 (var_ref sampler) (swiz xyz (var_ref P)) 0 (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + "))\n" + "" +; +static const char builtin_texture3DProjLod[] = + "((function texture3DProjLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl vec4 (var_ref sampler) (swiz xyz (var_ref P)) 0 (swiz w (var_ref P)) () (var_ref lod) ))))\n" + "\n" + "))\n" + "" +; +static const char builtin_textureCube[] = + "((function textureCube\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) samplerCube sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex vec4 (var_ref sampler) (var_ref P) 0 1 () ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) samplerCube sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb vec4 (var_ref sampler) (var_ref P) 0 1 () (var_ref bias) ))))\n" + "\n" + "))\n" + "" +; +static const char builtin_textureCubeGradARB[] = + "((function textureCubeGradARB\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) samplerCube sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec3 dPdx) \n" + " (declare (in) vec3 dPdy) )\n" + " ((return (txd vec4 (var_ref sampler) (var_ref P) 0 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isamplerCube sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec3 dPdx) \n" + " (declare (in) vec3 dPdy) )\n" + " ((return (txd ivec4 (var_ref sampler) (var_ref P) 0 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usamplerCube sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec3 dPdx) \n" + " (declare (in) vec3 dPdy) )\n" + " ((return (txd uvec4 (var_ref sampler) (var_ref P) 0 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + "))\n" + "" +; +static const char builtin_textureCubeGradEXT[] = + "((function textureCubeGradEXT\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) samplerCube sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec3 dPdx) \n" + " (declare (in) vec3 dPdy) )\n" + " ((return (txd vec4 (var_ref sampler) (var_ref P) 0 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isamplerCube sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec3 dPdx) \n" + " (declare (in) vec3 dPdy) )\n" + " ((return (txd ivec4 (var_ref sampler) (var_ref P) 0 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usamplerCube sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec3 dPdx) \n" + " (declare (in) vec3 dPdy) )\n" + " ((return (txd uvec4 (var_ref sampler) (var_ref P) 0 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + "))\n" + "" +; +static const char builtin_textureCubeLod[] = + "((function textureCubeLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) samplerCube sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl vec4 (var_ref sampler) (var_ref P) 0 1 () (var_ref lod) ))))\n" + "\n" + "))\n" + "" +; +static const char builtin_textureCubeLodEXT[] = + "((function textureCubeLodEXT\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) samplerCube sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl vec4 (var_ref sampler) (var_ref P) 0 1 () (var_ref lod) ))))\n" + "\n" + "))\n" + "" +; +static const char builtin_textureGrad[] = + "((function textureGrad\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) float P) \n" + " (declare (in) float dPdx) \n" + " (declare (in) float dPdy) )\n" + " ((return (txd vec4 (var_ref sampler) (var_ref P) 0 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1D sampler)\n" + " (declare (in) float P) \n" + " (declare (in) float dPdx) \n" + " (declare (in) float dPdy) )\n" + " ((return (txd ivec4 (var_ref sampler) (var_ref P) 0 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1D sampler)\n" + " (declare (in) float P) \n" + " (declare (in) float dPdx) \n" + " (declare (in) float dPdy) )\n" + " ((return (txd uvec4 (var_ref sampler) (var_ref P) 0 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd vec4 (var_ref sampler) (var_ref P) 0 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd ivec4 (var_ref sampler) (var_ref P) 0 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd uvec4 (var_ref sampler) (var_ref P) 0 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec3 dPdx) \n" + " (declare (in) vec3 dPdy) )\n" + " ((return (txd vec4 (var_ref sampler) (var_ref P) 0 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler3D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec3 dPdx) \n" + " (declare (in) vec3 dPdy) )\n" + " ((return (txd ivec4 (var_ref sampler) (var_ref P) 0 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler3D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec3 dPdx) \n" + " (declare (in) vec3 dPdy) )\n" + " ((return (txd uvec4 (var_ref sampler) (var_ref P) 0 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) samplerCube sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec3 dPdx) \n" + " (declare (in) vec3 dPdy) )\n" + " ((return (txd vec4 (var_ref sampler) (var_ref P) 0 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isamplerCube sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec3 dPdx) \n" + " (declare (in) vec3 dPdy) )\n" + " ((return (txd ivec4 (var_ref sampler) (var_ref P) 0 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usamplerCube sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec3 dPdx) \n" + " (declare (in) vec3 dPdy) )\n" + " ((return (txd uvec4 (var_ref sampler) (var_ref P) 0 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DArray sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd vec4 (var_ref sampler) (var_ref P) 0 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1DArray sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd ivec4 (var_ref sampler) (var_ref P) 0 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1DArray sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd uvec4 (var_ref sampler) (var_ref P) 0 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DArray sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec3 dPdx) \n" + " (declare (in) vec3 dPdy) )\n" + " ((return (txd vec4 (var_ref sampler) (var_ref P) 0 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2DArray sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec3 dPdx) \n" + " (declare (in) vec3 dPdy) )\n" + " ((return (txd ivec4 (var_ref sampler) (var_ref P) 0 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2DArray sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec3 dPdx) \n" + " (declare (in) vec3 dPdy) )\n" + " ((return (txd uvec4 (var_ref sampler) (var_ref P) 0 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) sampler1DShadow sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float dPdx) \n" + " (declare (in) float dPdy) )\n" + " ((return (txd float (var_ref sampler) (swiz x (var_ref P)) 0 1 (swiz z (var_ref P)) ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) sampler2DShadow sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd float (var_ref sampler) (swiz xy (var_ref P)) 0 1 (swiz z (var_ref P)) ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) samplerCubeShadow sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) vec3 dPdx) \n" + " (declare (in) vec3 dPdy) )\n" + " ((return (txd float (var_ref sampler) (swiz xyz (var_ref P)) 0 1 (swiz z (var_ref P)) ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) sampler1DArrayShadow sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd float (var_ref sampler) (swiz xy (var_ref P)) 0 1 (swiz z (var_ref P)) ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) sampler2DArrayShadow sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) vec3 dPdx) \n" + " (declare (in) vec3 dPdy) )\n" + " ((return (txd float (var_ref sampler) (swiz xyz (var_ref P)) 0 1 (swiz w (var_ref P)) ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + "))\n" + "" +; +static const char builtin_textureGradOffset[] = + "((function textureGradOffset\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) float P) \n" + " (declare (in) float dPdx) \n" + " (declare (in) float dPdy) \n" + " (declare (const_in) int offset) )\n" + " ((return (txd vec4 (var_ref sampler) (var_ref P) (var_ref offset) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1D sampler)\n" + " (declare (in) float P) \n" + " (declare (in) float dPdx) \n" + " (declare (in) float dPdy) \n" + " (declare (const_in) int offset) )\n" + " ((return (txd ivec4 (var_ref sampler) (var_ref P) (var_ref offset) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1D sampler)\n" + " (declare (in) float P) \n" + " (declare (in) float dPdx) \n" + " (declare (in) float dPdy) \n" + " (declare (const_in) int offset) )\n" + " ((return (txd uvec4 (var_ref sampler) (var_ref P) (var_ref offset) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) \n" + " (declare (const_in) ivec2 offset) )\n" + " ((return (txd vec4 (var_ref sampler) (var_ref P) (var_ref offset) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) \n" + " (declare (const_in) ivec2 offset) )\n" + " ((return (txd ivec4 (var_ref sampler) (var_ref P) (var_ref offset) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) \n" + " (declare (const_in) ivec2 offset) )\n" + " ((return (txd uvec4 (var_ref sampler) (var_ref P) (var_ref offset) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec3 dPdx) \n" + " (declare (in) vec3 dPdy) \n" + " (declare (const_in) ivec3 offset) )\n" + " ((return (txd vec4 (var_ref sampler) (var_ref P) (var_ref offset) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler3D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec3 dPdx) \n" + " (declare (in) vec3 dPdy) \n" + " (declare (const_in) ivec3 offset) )\n" + " ((return (txd ivec4 (var_ref sampler) (var_ref P) (var_ref offset) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler3D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec3 dPdx) \n" + " (declare (in) vec3 dPdy) \n" + " (declare (const_in) ivec3 offset) )\n" + " ((return (txd uvec4 (var_ref sampler) (var_ref P) (var_ref offset) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) samplerCube sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec3 dPdx) \n" + " (declare (in) vec3 dPdy) \n" + " (declare (const_in) ivec3 offset) )\n" + " ((return (txd vec4 (var_ref sampler) (var_ref P) (var_ref offset) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isamplerCube sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec3 dPdx) \n" + " (declare (in) vec3 dPdy) \n" + " (declare (const_in) ivec3 offset) )\n" + " ((return (txd ivec4 (var_ref sampler) (var_ref P) (var_ref offset) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usamplerCube sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec3 dPdx) \n" + " (declare (in) vec3 dPdy) \n" + " (declare (const_in) ivec3 offset) )\n" + " ((return (txd uvec4 (var_ref sampler) (var_ref P) (var_ref offset) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DArray sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) \n" + " (declare (const_in) int offset) )\n" + " ((return (txd vec4 (var_ref sampler) (var_ref P) (var_ref offset) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1DArray sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) \n" + " (declare (const_in) int offset) )\n" + " ((return (txd ivec4 (var_ref sampler) (var_ref P) (var_ref offset) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1DArray sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) \n" + " (declare (const_in) int offset) )\n" + " ((return (txd uvec4 (var_ref sampler) (var_ref P) (var_ref offset) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DArray sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec3 dPdx) \n" + " (declare (in) vec3 dPdy) \n" + " (declare (const_in) ivec2 offset) )\n" + " ((return (txd vec4 (var_ref sampler) (var_ref P) (var_ref offset) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2DArray sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec3 dPdx) \n" + " (declare (in) vec3 dPdy) \n" + " (declare (const_in) ivec2 offset) )\n" + " ((return (txd ivec4 (var_ref sampler) (var_ref P) (var_ref offset) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2DArray sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec3 dPdx) \n" + " (declare (in) vec3 dPdy) \n" + " (declare (const_in) ivec2 offset) )\n" + " ((return (txd uvec4 (var_ref sampler) (var_ref P) (var_ref offset) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) sampler1DShadow sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float dPdx) \n" + " (declare (in) float dPdy) \n" + " (declare (const_in) int offset) )\n" + " ((return (txd float (var_ref sampler) (swiz x (var_ref P)) (var_ref offset) 1 (swiz z (var_ref P)) ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) sampler2DShadow sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) \n" + " (declare (const_in) ivec2 offset) )\n" + " ((return (txd float (var_ref sampler) (swiz xy (var_ref P)) (var_ref offset) 1 (swiz z (var_ref P)) ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) sampler1DArrayShadow sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) \n" + " (declare (const_in) int offset) )\n" + " ((return (txd float (var_ref sampler) (swiz xy (var_ref P)) (var_ref offset) 1 (swiz z (var_ref P)) ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) sampler2DArrayShadow sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) vec3 dPdx) \n" + " (declare (in) vec3 dPdy) \n" + " (declare (const_in) ivec2 offset) )\n" + " ((return (txd float (var_ref sampler) (swiz xyz (var_ref P)) (var_ref offset) 1 (swiz w (var_ref P)) ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + "))\n" + "" +; +static const char builtin_textureLod[] = + "((function textureLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) float P) \n" + " (declare (in) float lod) )\n" + " ((return (txl vec4 (var_ref sampler) (var_ref P) 0 1 () (var_ref lod) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1D sampler)\n" + " (declare (in) float P) \n" + " (declare (in) float lod) )\n" + " ((return (txl ivec4 (var_ref sampler) (var_ref P) 0 1 () (var_ref lod) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1D sampler)\n" + " (declare (in) float P) \n" + " (declare (in) float lod) )\n" + " ((return (txl uvec4 (var_ref sampler) (var_ref P) 0 1 () (var_ref lod) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl vec4 (var_ref sampler) (var_ref P) 0 1 () (var_ref lod) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl ivec4 (var_ref sampler) (var_ref P) 0 1 () (var_ref lod) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl uvec4 (var_ref sampler) (var_ref P) 0 1 () (var_ref lod) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl vec4 (var_ref sampler) (var_ref P) 0 1 () (var_ref lod) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler3D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl ivec4 (var_ref sampler) (var_ref P) 0 1 () (var_ref lod) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler3D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl uvec4 (var_ref sampler) (var_ref P) 0 1 () (var_ref lod) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) samplerCube sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl vec4 (var_ref sampler) (var_ref P) 0 1 () (var_ref lod) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isamplerCube sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl ivec4 (var_ref sampler) (var_ref P) 0 1 () (var_ref lod) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usamplerCube sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl uvec4 (var_ref sampler) (var_ref P) 0 1 () (var_ref lod) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DArray sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl vec4 (var_ref sampler) (var_ref P) 0 1 () (var_ref lod) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1DArray sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl ivec4 (var_ref sampler) (var_ref P) 0 1 () (var_ref lod) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1DArray sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl uvec4 (var_ref sampler) (var_ref P) 0 1 () (var_ref lod) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DArray sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl vec4 (var_ref sampler) (var_ref P) 0 1 () (var_ref lod) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2DArray sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl ivec4 (var_ref sampler) (var_ref P) 0 1 () (var_ref lod) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2DArray sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl uvec4 (var_ref sampler) (var_ref P) 0 1 () (var_ref lod) ))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) sampler1DShadow sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl float (var_ref sampler) (swiz x (var_ref P)) 0 1 (swiz z (var_ref P)) (var_ref lod) ))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) sampler2DShadow sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl float (var_ref sampler) (swiz xy (var_ref P)) 0 1 (swiz z (var_ref P)) (var_ref lod) ))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) sampler1DArrayShadow sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl float (var_ref sampler) (swiz xy (var_ref P)) 0 1 (swiz z (var_ref P)) (var_ref lod) ))))\n" + "\n" + "))\n" + "" +; +static const char builtin_textureLodOffset[] = + "((function textureLodOffset\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) float P) \n" + " (declare (in) float lod) \n" + " (declare (const_in) int offset) )\n" + " ((return (txl vec4 (var_ref sampler) (var_ref P) (var_ref offset) 1 () (var_ref lod) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1D sampler)\n" + " (declare (in) float P) \n" + " (declare (in) float lod) \n" + " (declare (const_in) int offset) )\n" + " ((return (txl ivec4 (var_ref sampler) (var_ref P) (var_ref offset) 1 () (var_ref lod) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1D sampler)\n" + " (declare (in) float P) \n" + " (declare (in) float lod) \n" + " (declare (const_in) int offset) )\n" + " ((return (txl uvec4 (var_ref sampler) (var_ref P) (var_ref offset) 1 () (var_ref lod) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float lod) \n" + " (declare (const_in) ivec2 offset) )\n" + " ((return (txl vec4 (var_ref sampler) (var_ref P) (var_ref offset) 1 () (var_ref lod) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float lod) \n" + " (declare (const_in) ivec2 offset) )\n" + " ((return (txl ivec4 (var_ref sampler) (var_ref P) (var_ref offset) 1 () (var_ref lod) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float lod) \n" + " (declare (const_in) ivec2 offset) )\n" + " ((return (txl uvec4 (var_ref sampler) (var_ref P) (var_ref offset) 1 () (var_ref lod) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) \n" + " (declare (const_in) ivec3 offset) )\n" + " ((return (txl vec4 (var_ref sampler) (var_ref P) (var_ref offset) 1 () (var_ref lod) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler3D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) \n" + " (declare (const_in) ivec3 offset) )\n" + " ((return (txl ivec4 (var_ref sampler) (var_ref P) (var_ref offset) 1 () (var_ref lod) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler3D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) \n" + " (declare (const_in) ivec3 offset) )\n" + " ((return (txl uvec4 (var_ref sampler) (var_ref P) (var_ref offset) 1 () (var_ref lod) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DArray sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float lod) \n" + " (declare (const_in) int offset) )\n" + " ((return (txl vec4 (var_ref sampler) (var_ref P) (var_ref offset) 1 () (var_ref lod) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1DArray sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float lod) \n" + " (declare (const_in) int offset) )\n" + " ((return (txl ivec4 (var_ref sampler) (var_ref P) (var_ref offset) 1 () (var_ref lod) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1DArray sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float lod) \n" + " (declare (const_in) int offset) )\n" + " ((return (txl uvec4 (var_ref sampler) (var_ref P) (var_ref offset) 1 () (var_ref lod) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DArray sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) \n" + " (declare (const_in) ivec2 offset) )\n" + " ((return (txl vec4 (var_ref sampler) (var_ref P) (var_ref offset) 1 () (var_ref lod) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2DArray sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) \n" + " (declare (const_in) ivec2 offset) )\n" + " ((return (txl ivec4 (var_ref sampler) (var_ref P) (var_ref offset) 1 () (var_ref lod) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2DArray sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) \n" + " (declare (const_in) ivec2 offset) )\n" + " ((return (txl uvec4 (var_ref sampler) (var_ref P) (var_ref offset) 1 () (var_ref lod) ))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) sampler1DShadow sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) \n" + " (declare (const_in) int offset) )\n" + " ((return (txl float (var_ref sampler) (swiz x (var_ref P)) (var_ref offset) 1 (swiz z (var_ref P)) (var_ref lod) ))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) sampler2DShadow sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) \n" + " (declare (const_in) ivec2 offset) )\n" + " ((return (txl float (var_ref sampler) (swiz xy (var_ref P)) (var_ref offset) 1 (swiz z (var_ref P)) (var_ref lod) ))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) sampler1DArrayShadow sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) \n" + " (declare (const_in) int offset) )\n" + " ((return (txl float (var_ref sampler) (swiz xy (var_ref P)) (var_ref offset) 1 (swiz z (var_ref P)) (var_ref lod) ))))\n" + "\n" + "))\n" + "" +; +static const char builtin_textureOffset[] = + "((function textureOffset\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) float P) \n" + " (declare (const_in) int offset) )\n" + " ((return (tex vec4 (var_ref sampler) (var_ref P) (var_ref offset) 1 () ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1D sampler)\n" + " (declare (in) float P) \n" + " (declare (const_in) int offset) )\n" + " ((return (tex ivec4 (var_ref sampler) (var_ref P) (var_ref offset) 1 () ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1D sampler)\n" + " (declare (in) float P) \n" + " (declare (const_in) int offset) )\n" + " ((return (tex uvec4 (var_ref sampler) (var_ref P) (var_ref offset) 1 () ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (const_in) ivec2 offset) )\n" + " ((return (tex vec4 (var_ref sampler) (var_ref P) (var_ref offset) 1 () ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (const_in) ivec2 offset) )\n" + " ((return (tex ivec4 (var_ref sampler) (var_ref P) (var_ref offset) 1 () ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (const_in) ivec2 offset) )\n" + " ((return (tex uvec4 (var_ref sampler) (var_ref P) (var_ref offset) 1 () ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (const_in) ivec3 offset) )\n" + " ((return (tex vec4 (var_ref sampler) (var_ref P) (var_ref offset) 1 () ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler3D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (const_in) ivec3 offset) )\n" + " ((return (tex ivec4 (var_ref sampler) (var_ref P) (var_ref offset) 1 () ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler3D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (const_in) ivec3 offset) )\n" + " ((return (tex uvec4 (var_ref sampler) (var_ref P) (var_ref offset) 1 () ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DArray sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (const_in) int offset) )\n" + " ((return (tex vec4 (var_ref sampler) (var_ref P) (var_ref offset) 1 () ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1DArray sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (const_in) int offset) )\n" + " ((return (tex ivec4 (var_ref sampler) (var_ref P) (var_ref offset) 1 () ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1DArray sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (const_in) int offset) )\n" + " ((return (tex uvec4 (var_ref sampler) (var_ref P) (var_ref offset) 1 () ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DArray sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (const_in) ivec2 offset) )\n" + " ((return (tex vec4 (var_ref sampler) (var_ref P) (var_ref offset) 1 () ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2DArray sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (const_in) ivec2 offset) )\n" + " ((return (tex ivec4 (var_ref sampler) (var_ref P) (var_ref offset) 1 () ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2DArray sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (const_in) ivec2 offset) )\n" + " ((return (tex uvec4 (var_ref sampler) (var_ref P) (var_ref offset) 1 () ))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) sampler1DShadow sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (const_in) int offset) )\n" + " ((return (tex float (var_ref sampler) (swiz x (var_ref P)) (var_ref offset) 1 (swiz z (var_ref P)) ))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) sampler2DShadow sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (const_in) ivec2 offset) )\n" + " ((return (tex float (var_ref sampler) (swiz xy (var_ref P)) (var_ref offset) 1 (swiz z (var_ref P)) ))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) sampler1DArrayShadow sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (const_in) int offset) )\n" + " ((return (tex float (var_ref sampler) (swiz xy (var_ref P)) (var_ref offset) 1 (swiz z (var_ref P)) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) float P) \n" + " (declare (const_in) int offset) \n" + " (declare (in) float bias) )\n" + " ((return (txb vec4 (var_ref sampler) (var_ref P) (var_ref offset) 1 () (var_ref bias) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1D sampler)\n" + " (declare (in) float P) \n" + " (declare (const_in) int offset) \n" + " (declare (in) float bias) )\n" + " ((return (txb ivec4 (var_ref sampler) (var_ref P) (var_ref offset) 1 () (var_ref bias) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1D sampler)\n" + " (declare (in) float P) \n" + " (declare (const_in) int offset) \n" + " (declare (in) float bias) )\n" + " ((return (txb uvec4 (var_ref sampler) (var_ref P) (var_ref offset) 1 () (var_ref bias) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (const_in) ivec2 offset) \n" + " (declare (in) float bias) )\n" + " ((return (txb vec4 (var_ref sampler) (var_ref P) (var_ref offset) 1 () (var_ref bias) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (const_in) ivec2 offset) \n" + " (declare (in) float bias) )\n" + " ((return (txb ivec4 (var_ref sampler) (var_ref P) (var_ref offset) 1 () (var_ref bias) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (const_in) ivec2 offset) \n" + " (declare (in) float bias) )\n" + " ((return (txb uvec4 (var_ref sampler) (var_ref P) (var_ref offset) 1 () (var_ref bias) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (const_in) ivec3 offset) \n" + " (declare (in) float bias) )\n" + " ((return (txb vec4 (var_ref sampler) (var_ref P) (var_ref offset) 1 () (var_ref bias) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler3D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (const_in) ivec3 offset) \n" + " (declare (in) float bias) )\n" + " ((return (txb ivec4 (var_ref sampler) (var_ref P) (var_ref offset) 1 () (var_ref bias) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler3D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (const_in) ivec3 offset) \n" + " (declare (in) float bias) )\n" + " ((return (txb uvec4 (var_ref sampler) (var_ref P) (var_ref offset) 1 () (var_ref bias) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DArray sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (const_in) int offset) \n" + " (declare (in) float bias) )\n" + " ((return (txb vec4 (var_ref sampler) (var_ref P) (var_ref offset) 1 () (var_ref bias) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1DArray sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (const_in) int offset) \n" + " (declare (in) float bias) )\n" + " ((return (txb ivec4 (var_ref sampler) (var_ref P) (var_ref offset) 1 () (var_ref bias) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1DArray sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (const_in) int offset) \n" + " (declare (in) float bias) )\n" + " ((return (txb uvec4 (var_ref sampler) (var_ref P) (var_ref offset) 1 () (var_ref bias) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DArray sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (const_in) ivec2 offset) \n" + " (declare (in) float bias) )\n" + " ((return (txb vec4 (var_ref sampler) (var_ref P) (var_ref offset) 1 () (var_ref bias) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2DArray sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (const_in) ivec2 offset) \n" + " (declare (in) float bias) )\n" + " ((return (txb ivec4 (var_ref sampler) (var_ref P) (var_ref offset) 1 () (var_ref bias) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2DArray sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (const_in) ivec2 offset) \n" + " (declare (in) float bias) )\n" + " ((return (txb uvec4 (var_ref sampler) (var_ref P) (var_ref offset) 1 () (var_ref bias) ))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) sampler1DShadow sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (const_in) int offset) \n" + " (declare (in) float bias) )\n" + " ((return (txb float (var_ref sampler) (swiz x (var_ref P)) (var_ref offset) 1 (swiz z (var_ref P)) (var_ref bias) ))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) sampler2DShadow sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (const_in) ivec2 offset) \n" + " (declare (in) float bias) )\n" + " ((return (txb float (var_ref sampler) (swiz xy (var_ref P)) (var_ref offset) 1 (swiz z (var_ref P)) (var_ref bias) ))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) sampler1DArrayShadow sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (const_in) int offset) \n" + " (declare (in) float bias) )\n" + " ((return (txb float (var_ref sampler) (swiz xy (var_ref P)) (var_ref offset) 1 (swiz z (var_ref P)) (var_ref bias) ))))\n" + "\n" + "))\n" + "" +; +static const char builtin_textureProj[] = + "((function textureProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec2 P) )\n" + " ((return (tex vec4 (var_ref sampler) (swiz x (var_ref P)) 0 (swiz y (var_ref P)) () ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1D sampler)\n" + " (declare (in) vec2 P) )\n" + " ((return (tex ivec4 (var_ref sampler) (swiz x (var_ref P)) 0 (swiz y (var_ref P)) () ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1D sampler)\n" + " (declare (in) vec2 P) )\n" + " ((return (tex uvec4 (var_ref sampler) (swiz x (var_ref P)) 0 (swiz y (var_ref P)) () ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec4 P) )\n" + " ((return (tex vec4 (var_ref sampler) (swiz x (var_ref P)) 0 (swiz w (var_ref P)) () ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1D sampler)\n" + " (declare (in) vec4 P) )\n" + " ((return (tex ivec4 (var_ref sampler) (swiz x (var_ref P)) 0 (swiz w (var_ref P)) () ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1D sampler)\n" + " (declare (in) vec4 P) )\n" + " ((return (tex uvec4 (var_ref sampler) (swiz x (var_ref P)) 0 (swiz w (var_ref P)) () ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex vec4 (var_ref sampler) (swiz xy (var_ref P)) 0 (swiz z (var_ref P)) () ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2D sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex ivec4 (var_ref sampler) (swiz xy (var_ref P)) 0 (swiz z (var_ref P)) () ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2D sampler)\n" + " (declare (in) vec3 P) )\n" + " ((return (tex uvec4 (var_ref sampler) (swiz xy (var_ref P)) 0 (swiz z (var_ref P)) () ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec4 P) )\n" + " ((return (tex vec4 (var_ref sampler) (swiz xy (var_ref P)) 0 (swiz w (var_ref P)) () ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2D sampler)\n" + " (declare (in) vec4 P) )\n" + " ((return (tex ivec4 (var_ref sampler) (swiz xy (var_ref P)) 0 (swiz w (var_ref P)) () ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2D sampler)\n" + " (declare (in) vec4 P) )\n" + " ((return (tex uvec4 (var_ref sampler) (swiz xy (var_ref P)) 0 (swiz w (var_ref P)) () ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec4 P) )\n" + " ((return (tex vec4 (var_ref sampler) (swiz xyz (var_ref P)) 0 (swiz w (var_ref P)) () ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler3D sampler)\n" + " (declare (in) vec4 P) )\n" + " ((return (tex ivec4 (var_ref sampler) (swiz xyz (var_ref P)) 0 (swiz w (var_ref P)) () ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler3D sampler)\n" + " (declare (in) vec4 P) )\n" + " ((return (tex uvec4 (var_ref sampler) (swiz xyz (var_ref P)) 0 (swiz w (var_ref P)) () ))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) sampler1DShadow sampler)\n" + " (declare (in) vec4 P) )\n" + " ((return (tex float (var_ref sampler) (swiz x (var_ref P)) 0 (swiz w (var_ref P)) (swiz z (var_ref P)) ))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) sampler2DShadow sampler)\n" + " (declare (in) vec4 P) )\n" + " ((return (tex float (var_ref sampler) (swiz xy (var_ref P)) 0 (swiz w (var_ref P)) (swiz z (var_ref P)) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb vec4 (var_ref sampler) (swiz x (var_ref P)) 0 (swiz y (var_ref P)) () (var_ref bias) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb ivec4 (var_ref sampler) (swiz x (var_ref P)) 0 (swiz y (var_ref P)) () (var_ref bias) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb uvec4 (var_ref sampler) (swiz x (var_ref P)) 0 (swiz y (var_ref P)) () (var_ref bias) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb vec4 (var_ref sampler) (swiz x (var_ref P)) 0 (swiz w (var_ref P)) () (var_ref bias) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb ivec4 (var_ref sampler) (swiz x (var_ref P)) 0 (swiz w (var_ref P)) () (var_ref bias) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb uvec4 (var_ref sampler) (swiz x (var_ref P)) 0 (swiz w (var_ref P)) () (var_ref bias) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb vec4 (var_ref sampler) (swiz xy (var_ref P)) 0 (swiz z (var_ref P)) () (var_ref bias) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb ivec4 (var_ref sampler) (swiz xy (var_ref P)) 0 (swiz z (var_ref P)) () (var_ref bias) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb uvec4 (var_ref sampler) (swiz xy (var_ref P)) 0 (swiz z (var_ref P)) () (var_ref bias) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb vec4 (var_ref sampler) (swiz xy (var_ref P)) 0 (swiz w (var_ref P)) () (var_ref bias) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb ivec4 (var_ref sampler) (swiz xy (var_ref P)) 0 (swiz w (var_ref P)) () (var_ref bias) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb uvec4 (var_ref sampler) (swiz xy (var_ref P)) 0 (swiz w (var_ref P)) () (var_ref bias) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb vec4 (var_ref sampler) (swiz xyz (var_ref P)) 0 (swiz w (var_ref P)) () (var_ref bias) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler3D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb ivec4 (var_ref sampler) (swiz xyz (var_ref P)) 0 (swiz w (var_ref P)) () (var_ref bias) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler3D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb uvec4 (var_ref sampler) (swiz xyz (var_ref P)) 0 (swiz w (var_ref P)) () (var_ref bias) ))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) sampler1DShadow sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb float (var_ref sampler) (swiz x (var_ref P)) 0 (swiz w (var_ref P)) (swiz z (var_ref P)) (var_ref bias) ))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) sampler2DShadow sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float bias) )\n" + " ((return (txb float (var_ref sampler) (swiz xy (var_ref P)) 0 (swiz w (var_ref P)) (swiz z (var_ref P)) (var_ref bias) ))))\n" + "\n" + "))\n" + "" +; +static const char builtin_textureProjGrad[] = + "((function textureProjGrad\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float dPdx) \n" + " (declare (in) float dPdy) )\n" + " ((return (txd vec4 (var_ref sampler) (swiz x (var_ref P)) 0 (swiz y (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float dPdx) \n" + " (declare (in) float dPdy) )\n" + " ((return (txd ivec4 (var_ref sampler) (swiz x (var_ref P)) 0 (swiz y (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float dPdx) \n" + " (declare (in) float dPdy) )\n" + " ((return (txd uvec4 (var_ref sampler) (swiz x (var_ref P)) 0 (swiz y (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float dPdx) \n" + " (declare (in) float dPdy) )\n" + " ((return (txd vec4 (var_ref sampler) (swiz x (var_ref P)) 0 (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float dPdx) \n" + " (declare (in) float dPdy) )\n" + " ((return (txd ivec4 (var_ref sampler) (swiz x (var_ref P)) 0 (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float dPdx) \n" + " (declare (in) float dPdy) )\n" + " ((return (txd uvec4 (var_ref sampler) (swiz x (var_ref P)) 0 (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd vec4 (var_ref sampler) (swiz xy (var_ref P)) 0 (swiz z (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd ivec4 (var_ref sampler) (swiz xy (var_ref P)) 0 (swiz z (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd uvec4 (var_ref sampler) (swiz xy (var_ref P)) 0 (swiz z (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd vec4 (var_ref sampler) (swiz xy (var_ref P)) 0 (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd ivec4 (var_ref sampler) (swiz xy (var_ref P)) 0 (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd uvec4 (var_ref sampler) (swiz xy (var_ref P)) 0 (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) vec3 dPdx) \n" + " (declare (in) vec3 dPdy) )\n" + " ((return (txd vec4 (var_ref sampler) (swiz xyz (var_ref P)) 0 (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler3D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) vec3 dPdx) \n" + " (declare (in) vec3 dPdy) )\n" + " ((return (txd ivec4 (var_ref sampler) (swiz xyz (var_ref P)) 0 (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler3D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) vec3 dPdx) \n" + " (declare (in) vec3 dPdy) )\n" + " ((return (txd uvec4 (var_ref sampler) (swiz xyz (var_ref P)) 0 (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) sampler1DShadow sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float dPdx) \n" + " (declare (in) float dPdy) )\n" + " ((return (txd float (var_ref sampler) (swiz x (var_ref P)) 0 (swiz w (var_ref P)) (swiz z (var_ref P)) ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) sampler2DShadow sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) )\n" + " ((return (txd float (var_ref sampler) (swiz xy (var_ref P)) 0 (swiz w (var_ref P)) (swiz z (var_ref P)) ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + "))\n" + "" +; +static const char builtin_textureProjGradOffset[] = + "((function textureProjGradOffset\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float dPdx) \n" + " (declare (in) float dPdy) \n" + " (declare (const_in) int offset) )\n" + " ((return (txd vec4 (var_ref sampler) (swiz x (var_ref P)) (var_ref offset) (swiz y (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float dPdx) \n" + " (declare (in) float dPdy) \n" + " (declare (const_in) int offset) )\n" + " ((return (txd ivec4 (var_ref sampler) (swiz x (var_ref P)) (var_ref offset) (swiz y (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float dPdx) \n" + " (declare (in) float dPdy) \n" + " (declare (const_in) int offset) )\n" + " ((return (txd uvec4 (var_ref sampler) (swiz x (var_ref P)) (var_ref offset) (swiz y (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float dPdx) \n" + " (declare (in) float dPdy) \n" + " (declare (const_in) int offset) )\n" + " ((return (txd vec4 (var_ref sampler) (swiz x (var_ref P)) (var_ref offset) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float dPdx) \n" + " (declare (in) float dPdy) \n" + " (declare (const_in) int offset) )\n" + " ((return (txd ivec4 (var_ref sampler) (swiz x (var_ref P)) (var_ref offset) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float dPdx) \n" + " (declare (in) float dPdy) \n" + " (declare (const_in) int offset) )\n" + " ((return (txd uvec4 (var_ref sampler) (swiz x (var_ref P)) (var_ref offset) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) \n" + " (declare (const_in) ivec2 offset) )\n" + " ((return (txd vec4 (var_ref sampler) (swiz xy (var_ref P)) (var_ref offset) (swiz z (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) \n" + " (declare (const_in) ivec2 offset) )\n" + " ((return (txd ivec4 (var_ref sampler) (swiz xy (var_ref P)) (var_ref offset) (swiz z (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) \n" + " (declare (const_in) ivec2 offset) )\n" + " ((return (txd uvec4 (var_ref sampler) (swiz xy (var_ref P)) (var_ref offset) (swiz z (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) \n" + " (declare (const_in) ivec2 offset) )\n" + " ((return (txd vec4 (var_ref sampler) (swiz xy (var_ref P)) (var_ref offset) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) \n" + " (declare (const_in) ivec2 offset) )\n" + " ((return (txd ivec4 (var_ref sampler) (swiz xy (var_ref P)) (var_ref offset) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) \n" + " (declare (const_in) ivec2 offset) )\n" + " ((return (txd uvec4 (var_ref sampler) (swiz xy (var_ref P)) (var_ref offset) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) vec3 dPdx) \n" + " (declare (in) vec3 dPdy) \n" + " (declare (const_in) ivec3 offset) )\n" + " ((return (txd vec4 (var_ref sampler) (swiz xyz (var_ref P)) (var_ref offset) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler3D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) vec3 dPdx) \n" + " (declare (in) vec3 dPdy) \n" + " (declare (const_in) ivec3 offset) )\n" + " ((return (txd ivec4 (var_ref sampler) (swiz xyz (var_ref P)) (var_ref offset) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler3D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) vec3 dPdx) \n" + " (declare (in) vec3 dPdy) \n" + " (declare (const_in) ivec3 offset) )\n" + " ((return (txd uvec4 (var_ref sampler) (swiz xyz (var_ref P)) (var_ref offset) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) sampler1DShadow sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float dPdx) \n" + " (declare (in) float dPdy) \n" + " (declare (const_in) int offset) )\n" + " ((return (txd float (var_ref sampler) (swiz x (var_ref P)) (var_ref offset) (swiz w (var_ref P)) (swiz z (var_ref P)) ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) sampler2DShadow sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) vec2 dPdx) \n" + " (declare (in) vec2 dPdy) \n" + " (declare (const_in) ivec2 offset) )\n" + " ((return (txd float (var_ref sampler) (swiz xy (var_ref P)) (var_ref offset) (swiz w (var_ref P)) (swiz z (var_ref P)) ((var_ref dPdx) (var_ref dPdy)) ))))\n" + "\n" + "))\n" + "" +; +static const char builtin_textureProjLod[] = + "((function textureProjLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl vec4 (var_ref sampler) (swiz x (var_ref P)) 0 (swiz y (var_ref P)) () (var_ref lod) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl ivec4 (var_ref sampler) (swiz x (var_ref P)) 0 (swiz y (var_ref P)) () (var_ref lod) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl uvec4 (var_ref sampler) (swiz x (var_ref P)) 0 (swiz y (var_ref P)) () (var_ref lod) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl vec4 (var_ref sampler) (swiz x (var_ref P)) 0 (swiz w (var_ref P)) () (var_ref lod) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl ivec4 (var_ref sampler) (swiz x (var_ref P)) 0 (swiz w (var_ref P)) () (var_ref lod) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl uvec4 (var_ref sampler) (swiz x (var_ref P)) 0 (swiz w (var_ref P)) () (var_ref lod) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl vec4 (var_ref sampler) (swiz xy (var_ref P)) 0 (swiz z (var_ref P)) () (var_ref lod) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl ivec4 (var_ref sampler) (swiz xy (var_ref P)) 0 (swiz z (var_ref P)) () (var_ref lod) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl uvec4 (var_ref sampler) (swiz xy (var_ref P)) 0 (swiz z (var_ref P)) () (var_ref lod) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl vec4 (var_ref sampler) (swiz xy (var_ref P)) 0 (swiz w (var_ref P)) () (var_ref lod) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl ivec4 (var_ref sampler) (swiz xy (var_ref P)) 0 (swiz w (var_ref P)) () (var_ref lod) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl uvec4 (var_ref sampler) (swiz xy (var_ref P)) 0 (swiz w (var_ref P)) () (var_ref lod) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl vec4 (var_ref sampler) (swiz xyz (var_ref P)) 0 (swiz w (var_ref P)) () (var_ref lod) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler3D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl ivec4 (var_ref sampler) (swiz xyz (var_ref P)) 0 (swiz w (var_ref P)) () (var_ref lod) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler3D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl uvec4 (var_ref sampler) (swiz xyz (var_ref P)) 0 (swiz w (var_ref P)) () (var_ref lod) ))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) sampler1DShadow sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl float (var_ref sampler) (swiz x (var_ref P)) 0 (swiz w (var_ref P)) (swiz z (var_ref P)) (var_ref lod) ))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) sampler2DShadow sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float lod) )\n" + " ((return (txl float (var_ref sampler) (swiz xy (var_ref P)) 0 (swiz w (var_ref P)) (swiz z (var_ref P)) (var_ref lod) ))))\n" + "\n" + "))\n" + "" +; +static const char builtin_textureProjLodOffset[] = + "((function textureProjLodOffset\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float lod) \n" + " (declare (const_in) int offset) )\n" + " ((return (txl vec4 (var_ref sampler) (swiz x (var_ref P)) (var_ref offset) (swiz y (var_ref P)) () (var_ref lod) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float lod) \n" + " (declare (const_in) int offset) )\n" + " ((return (txl ivec4 (var_ref sampler) (swiz x (var_ref P)) (var_ref offset) (swiz y (var_ref P)) () (var_ref lod) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (in) float lod) \n" + " (declare (const_in) int offset) )\n" + " ((return (txl uvec4 (var_ref sampler) (swiz x (var_ref P)) (var_ref offset) (swiz y (var_ref P)) () (var_ref lod) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float lod) \n" + " (declare (const_in) int offset) )\n" + " ((return (txl vec4 (var_ref sampler) (swiz x (var_ref P)) (var_ref offset) (swiz w (var_ref P)) () (var_ref lod) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float lod) \n" + " (declare (const_in) int offset) )\n" + " ((return (txl ivec4 (var_ref sampler) (swiz x (var_ref P)) (var_ref offset) (swiz w (var_ref P)) () (var_ref lod) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float lod) \n" + " (declare (const_in) int offset) )\n" + " ((return (txl uvec4 (var_ref sampler) (swiz x (var_ref P)) (var_ref offset) (swiz w (var_ref P)) () (var_ref lod) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) \n" + " (declare (const_in) ivec2 offset) )\n" + " ((return (txl vec4 (var_ref sampler) (swiz xy (var_ref P)) (var_ref offset) (swiz z (var_ref P)) () (var_ref lod) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) \n" + " (declare (const_in) ivec2 offset) )\n" + " ((return (txl ivec4 (var_ref sampler) (swiz xy (var_ref P)) (var_ref offset) (swiz z (var_ref P)) () (var_ref lod) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (in) float lod) \n" + " (declare (const_in) ivec2 offset) )\n" + " ((return (txl uvec4 (var_ref sampler) (swiz xy (var_ref P)) (var_ref offset) (swiz z (var_ref P)) () (var_ref lod) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float lod) \n" + " (declare (const_in) ivec2 offset) )\n" + " ((return (txl vec4 (var_ref sampler) (swiz xy (var_ref P)) (var_ref offset) (swiz w (var_ref P)) () (var_ref lod) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float lod) \n" + " (declare (const_in) ivec2 offset) )\n" + " ((return (txl ivec4 (var_ref sampler) (swiz xy (var_ref P)) (var_ref offset) (swiz w (var_ref P)) () (var_ref lod) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float lod) \n" + " (declare (const_in) ivec2 offset) )\n" + " ((return (txl uvec4 (var_ref sampler) (swiz xy (var_ref P)) (var_ref offset) (swiz w (var_ref P)) () (var_ref lod) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float lod) \n" + " (declare (const_in) ivec3 offset) )\n" + " ((return (txl vec4 (var_ref sampler) (swiz xyz (var_ref P)) (var_ref offset) (swiz w (var_ref P)) () (var_ref lod) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler3D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float lod) \n" + " (declare (const_in) ivec3 offset) )\n" + " ((return (txl ivec4 (var_ref sampler) (swiz xyz (var_ref P)) (var_ref offset) (swiz w (var_ref P)) () (var_ref lod) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler3D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float lod) \n" + " (declare (const_in) ivec3 offset) )\n" + " ((return (txl uvec4 (var_ref sampler) (swiz xyz (var_ref P)) (var_ref offset) (swiz w (var_ref P)) () (var_ref lod) ))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) sampler1DShadow sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float lod) \n" + " (declare (const_in) int offset) )\n" + " ((return (txl float (var_ref sampler) (swiz x (var_ref P)) (var_ref offset) (swiz w (var_ref P)) (swiz z (var_ref P)) (var_ref lod) ))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) sampler2DShadow sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (in) float lod) \n" + " (declare (const_in) ivec2 offset) )\n" + " ((return (txl float (var_ref sampler) (swiz xy (var_ref P)) (var_ref offset) (swiz w (var_ref P)) (swiz z (var_ref P)) (var_ref lod) ))))\n" + "\n" + "))\n" + "" +; +static const char builtin_textureProjOffset[] = + "((function textureProjOffset\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (const_in) int offset) )\n" + " ((return (tex vec4 (var_ref sampler) (swiz x (var_ref P)) (var_ref offset) (swiz y (var_ref P)) () ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (const_in) int offset) )\n" + " ((return (tex ivec4 (var_ref sampler) (swiz x (var_ref P)) (var_ref offset) (swiz y (var_ref P)) () ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (const_in) int offset) )\n" + " ((return (tex uvec4 (var_ref sampler) (swiz x (var_ref P)) (var_ref offset) (swiz y (var_ref P)) () ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (const_in) int offset) )\n" + " ((return (tex vec4 (var_ref sampler) (swiz x (var_ref P)) (var_ref offset) (swiz w (var_ref P)) () ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (const_in) int offset) )\n" + " ((return (tex ivec4 (var_ref sampler) (swiz x (var_ref P)) (var_ref offset) (swiz w (var_ref P)) () ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (const_in) int offset) )\n" + " ((return (tex uvec4 (var_ref sampler) (swiz x (var_ref P)) (var_ref offset) (swiz w (var_ref P)) () ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (const_in) ivec2 offset) )\n" + " ((return (tex vec4 (var_ref sampler) (swiz xy (var_ref P)) (var_ref offset) (swiz z (var_ref P)) () ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (const_in) ivec2 offset) )\n" + " ((return (tex ivec4 (var_ref sampler) (swiz xy (var_ref P)) (var_ref offset) (swiz z (var_ref P)) () ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (const_in) ivec2 offset) )\n" + " ((return (tex uvec4 (var_ref sampler) (swiz xy (var_ref P)) (var_ref offset) (swiz z (var_ref P)) () ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (const_in) ivec2 offset) )\n" + " ((return (tex vec4 (var_ref sampler) (swiz xy (var_ref P)) (var_ref offset) (swiz w (var_ref P)) () ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (const_in) ivec2 offset) )\n" + " ((return (tex ivec4 (var_ref sampler) (swiz xy (var_ref P)) (var_ref offset) (swiz w (var_ref P)) () ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (const_in) ivec2 offset) )\n" + " ((return (tex uvec4 (var_ref sampler) (swiz xy (var_ref P)) (var_ref offset) (swiz w (var_ref P)) () ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (const_in) ivec3 offset) )\n" + " ((return (tex vec4 (var_ref sampler) (swiz xyz (var_ref P)) (var_ref offset) (swiz w (var_ref P)) () ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler3D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (const_in) ivec3 offset) )\n" + " ((return (tex ivec4 (var_ref sampler) (swiz xyz (var_ref P)) (var_ref offset) (swiz w (var_ref P)) () ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler3D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (const_in) ivec3 offset) )\n" + " ((return (tex uvec4 (var_ref sampler) (swiz xyz (var_ref P)) (var_ref offset) (swiz w (var_ref P)) () ))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) sampler1DShadow sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (const_in) int offset) )\n" + " ((return (tex float (var_ref sampler) (swiz x (var_ref P)) (var_ref offset) (swiz w (var_ref P)) (swiz z (var_ref P)) ))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) sampler2DShadow sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (const_in) ivec2 offset) )\n" + " ((return (tex float (var_ref sampler) (swiz xy (var_ref P)) (var_ref offset) (swiz w (var_ref P)) (swiz z (var_ref P)) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (const_in) int offset) \n" + " (declare (in) float bias) )\n" + " ((return (txb vec4 (var_ref sampler) (swiz x (var_ref P)) (var_ref offset) (swiz y (var_ref P)) () (var_ref bias) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (const_in) int offset) \n" + " (declare (in) float bias) )\n" + " ((return (txb ivec4 (var_ref sampler) (swiz x (var_ref P)) (var_ref offset) (swiz y (var_ref P)) () (var_ref bias) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1D sampler)\n" + " (declare (in) vec2 P) \n" + " (declare (const_in) int offset) \n" + " (declare (in) float bias) )\n" + " ((return (txb uvec4 (var_ref sampler) (swiz x (var_ref P)) (var_ref offset) (swiz y (var_ref P)) () (var_ref bias) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (const_in) int offset) \n" + " (declare (in) float bias) )\n" + " ((return (txb vec4 (var_ref sampler) (swiz x (var_ref P)) (var_ref offset) (swiz w (var_ref P)) () (var_ref bias) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler1D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (const_in) int offset) \n" + " (declare (in) float bias) )\n" + " ((return (txb ivec4 (var_ref sampler) (swiz x (var_ref P)) (var_ref offset) (swiz w (var_ref P)) () (var_ref bias) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler1D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (const_in) int offset) \n" + " (declare (in) float bias) )\n" + " ((return (txb uvec4 (var_ref sampler) (swiz x (var_ref P)) (var_ref offset) (swiz w (var_ref P)) () (var_ref bias) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (const_in) ivec2 offset) \n" + " (declare (in) float bias) )\n" + " ((return (txb vec4 (var_ref sampler) (swiz xy (var_ref P)) (var_ref offset) (swiz z (var_ref P)) () (var_ref bias) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (const_in) ivec2 offset) \n" + " (declare (in) float bias) )\n" + " ((return (txb ivec4 (var_ref sampler) (swiz xy (var_ref P)) (var_ref offset) (swiz z (var_ref P)) () (var_ref bias) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2D sampler)\n" + " (declare (in) vec3 P) \n" + " (declare (const_in) ivec2 offset) \n" + " (declare (in) float bias) )\n" + " ((return (txb uvec4 (var_ref sampler) (swiz xy (var_ref P)) (var_ref offset) (swiz z (var_ref P)) () (var_ref bias) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (const_in) ivec2 offset) \n" + " (declare (in) float bias) )\n" + " ((return (txb vec4 (var_ref sampler) (swiz xy (var_ref P)) (var_ref offset) (swiz w (var_ref P)) () (var_ref bias) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler2D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (const_in) ivec2 offset) \n" + " (declare (in) float bias) )\n" + " ((return (txb ivec4 (var_ref sampler) (swiz xy (var_ref P)) (var_ref offset) (swiz w (var_ref P)) () (var_ref bias) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler2D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (const_in) ivec2 offset) \n" + " (declare (in) float bias) )\n" + " ((return (txb uvec4 (var_ref sampler) (swiz xy (var_ref P)) (var_ref offset) (swiz w (var_ref P)) () (var_ref bias) ))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (const_in) ivec3 offset) \n" + " (declare (in) float bias) )\n" + " ((return (txb vec4 (var_ref sampler) (swiz xyz (var_ref P)) (var_ref offset) (swiz w (var_ref P)) () (var_ref bias) ))))\n" + "\n" + " (signature ivec4\n" + " (parameters\n" + " (declare (in) isampler3D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (const_in) ivec3 offset) \n" + " (declare (in) float bias) )\n" + " ((return (txb ivec4 (var_ref sampler) (swiz xyz (var_ref P)) (var_ref offset) (swiz w (var_ref P)) () (var_ref bias) ))))\n" + "\n" + " (signature uvec4\n" + " (parameters\n" + " (declare (in) usampler3D sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (const_in) ivec3 offset) \n" + " (declare (in) float bias) )\n" + " ((return (txb uvec4 (var_ref sampler) (swiz xyz (var_ref P)) (var_ref offset) (swiz w (var_ref P)) () (var_ref bias) ))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) sampler1DShadow sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (const_in) int offset) \n" + " (declare (in) float bias) )\n" + " ((return (txb float (var_ref sampler) (swiz x (var_ref P)) (var_ref offset) (swiz w (var_ref P)) (swiz z (var_ref P)) (var_ref bias) ))))\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) sampler2DShadow sampler)\n" + " (declare (in) vec4 P) \n" + " (declare (const_in) ivec2 offset) \n" + " (declare (in) float bias) )\n" + " ((return (txb float (var_ref sampler) (swiz xy (var_ref P)) (var_ref offset) (swiz w (var_ref P)) (swiz z (var_ref P)) (var_ref bias) ))))\n" + "\n" + "))\n" + "" +; +static const char builtin_transpose[] = + "((function transpose\n" + " (signature mat2\n" + " (parameters\n" + " (declare (in) mat2 m))\n" + " ((declare () mat2 t)\n" + " (assign (x) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (0)))))\n" + " (assign (x) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (0)))))\n" + " (assign (y) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (1)))))\n" + " (assign (y) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (1)))))\n" + "(return (var_ref t))))\n" + "\n" + " (signature mat3x2\n" + " (parameters\n" + " (declare (in) mat2x3 m))\n" + " ((declare () mat3x2 t)\n" + " (assign (x) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (0)))))\n" + " (assign (x) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (0)))))\n" + " (assign (x) (array_ref (var_ref t) (constant int (2))) (swiz z (array_ref (var_ref m) (constant int (0)))))\n" + " (assign (y) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (1)))))\n" + " (assign (y) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (1)))))\n" + " (assign (y) (array_ref (var_ref t) (constant int (2))) (swiz z (array_ref (var_ref m) (constant int (1)))))\n" + "(return (var_ref t))))\n" + "\n" + " (signature mat4x2\n" + " (parameters\n" + " (declare (in) mat2x4 m))\n" + " ((declare () mat4x2 t)\n" + " (assign (x) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (0)))))\n" + " (assign (x) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (0)))))\n" + " (assign (x) (array_ref (var_ref t) (constant int (2))) (swiz z (array_ref (var_ref m) (constant int (0)))))\n" + " (assign (x) (array_ref (var_ref t) (constant int (3))) (swiz w (array_ref (var_ref m) (constant int (0)))))\n" + " (assign (y) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (1)))))\n" + " (assign (y) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (1)))))\n" + " (assign (y) (array_ref (var_ref t) (constant int (2))) (swiz z (array_ref (var_ref m) (constant int (1)))))\n" + " (assign (y) (array_ref (var_ref t) (constant int (3))) (swiz w (array_ref (var_ref m) (constant int (1)))))\n" + "(return (var_ref t))))\n" + "\n" + " (signature mat2x3\n" + " (parameters\n" + " (declare (in) mat3x2 m))\n" + " ((declare () mat2x3 t)\n" + " (assign (x) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (0)))))\n" + " (assign (x) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (0)))))\n" + " (assign (y) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (1)))))\n" + " (assign (y) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (1)))))\n" + " (assign (z) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (2)))))\n" + " (assign (z) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (2)))))\n" + "(return (var_ref t))))\n" + "\n" + " (signature mat3\n" + " (parameters\n" + " (declare (in) mat3 m))\n" + " ((declare () mat3 t)\n" + " (assign (x) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (0)))))\n" + " (assign (x) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (0)))))\n" + " (assign (x) (array_ref (var_ref t) (constant int (2))) (swiz z (array_ref (var_ref m) (constant int (0)))))\n" + " (assign (y) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (1)))))\n" + " (assign (y) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (1)))))\n" + " (assign (y) (array_ref (var_ref t) (constant int (2))) (swiz z (array_ref (var_ref m) (constant int (1)))))\n" + " (assign (z) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (2)))))\n" + " (assign (z) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (2)))))\n" + " (assign (z) (array_ref (var_ref t) (constant int (2))) (swiz z (array_ref (var_ref m) (constant int (2)))))\n" + "(return (var_ref t))))\n" + "\n" + " (signature mat4x3\n" + " (parameters\n" + " (declare (in) mat3x4 m))\n" + " ((declare () mat4x3 t)\n" + " (assign (x) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (0)))))\n" + " (assign (x) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (0)))))\n" + " (assign (x) (array_ref (var_ref t) (constant int (2))) (swiz z (array_ref (var_ref m) (constant int (0)))))\n" + " (assign (x) (array_ref (var_ref t) (constant int (3))) (swiz w (array_ref (var_ref m) (constant int (0)))))\n" + " (assign (y) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (1)))))\n" + " (assign (y) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (1)))))\n" + " (assign (y) (array_ref (var_ref t) (constant int (2))) (swiz z (array_ref (var_ref m) (constant int (1)))))\n" + " (assign (y) (array_ref (var_ref t) (constant int (3))) (swiz w (array_ref (var_ref m) (constant int (1)))))\n" + " (assign (z) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (2)))))\n" + " (assign (z) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (2)))))\n" + " (assign (z) (array_ref (var_ref t) (constant int (2))) (swiz z (array_ref (var_ref m) (constant int (2)))))\n" + " (assign (z) (array_ref (var_ref t) (constant int (3))) (swiz w (array_ref (var_ref m) (constant int (2)))))\n" + "(return (var_ref t))))\n" + "\n" + " (signature mat2x4\n" + " (parameters\n" + " (declare (in) mat4x2 m))\n" + " ((declare () mat2x4 t)\n" + " (assign (x) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (0)))))\n" + " (assign (x) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (0)))))\n" + " (assign (y) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (1)))))\n" + " (assign (y) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (1)))))\n" + " (assign (z) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (2)))))\n" + " (assign (z) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (2)))))\n" + " (assign (w) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (3)))))\n" + " (assign (w) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (3)))))\n" + "(return (var_ref t))))\n" + "\n" + " (signature mat3x4\n" + " (parameters\n" + " (declare (in) mat4x3 m))\n" + " ((declare () mat3x4 t)\n" + " (assign (x) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (0)))))\n" + " (assign (x) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (0)))))\n" + " (assign (x) (array_ref (var_ref t) (constant int (2))) (swiz z (array_ref (var_ref m) (constant int (0)))))\n" + " (assign (y) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (1)))))\n" + " (assign (y) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (1)))))\n" + " (assign (y) (array_ref (var_ref t) (constant int (2))) (swiz z (array_ref (var_ref m) (constant int (1)))))\n" + " (assign (z) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (2)))))\n" + " (assign (z) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (2)))))\n" + " (assign (z) (array_ref (var_ref t) (constant int (2))) (swiz z (array_ref (var_ref m) (constant int (2)))))\n" + " (assign (w) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (3)))))\n" + " (assign (w) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (3)))))\n" + " (assign (w) (array_ref (var_ref t) (constant int (2))) (swiz z (array_ref (var_ref m) (constant int (3)))))\n" + "(return (var_ref t))))\n" + "\n" + " (signature mat4\n" + " (parameters\n" + " (declare (in) mat4 m))\n" + " ((declare () mat4 t)\n" + " (assign (x) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (0)))))\n" + " (assign (x) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (0)))))\n" + " (assign (x) (array_ref (var_ref t) (constant int (2))) (swiz z (array_ref (var_ref m) (constant int (0)))))\n" + " (assign (x) (array_ref (var_ref t) (constant int (3))) (swiz w (array_ref (var_ref m) (constant int (0)))))\n" + " (assign (y) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (1)))))\n" + " (assign (y) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (1)))))\n" + " (assign (y) (array_ref (var_ref t) (constant int (2))) (swiz z (array_ref (var_ref m) (constant int (1)))))\n" + " (assign (y) (array_ref (var_ref t) (constant int (3))) (swiz w (array_ref (var_ref m) (constant int (1)))))\n" + " (assign (z) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (2)))))\n" + " (assign (z) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (2)))))\n" + " (assign (z) (array_ref (var_ref t) (constant int (2))) (swiz z (array_ref (var_ref m) (constant int (2)))))\n" + " (assign (z) (array_ref (var_ref t) (constant int (3))) (swiz w (array_ref (var_ref m) (constant int (2)))))\n" + " (assign (w) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (3)))))\n" + " (assign (w) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (3)))))\n" + " (assign (w) (array_ref (var_ref t) (constant int (2))) (swiz z (array_ref (var_ref m) (constant int (3)))))\n" + " (assign (w) (array_ref (var_ref t) (constant int (3))) (swiz w (array_ref (var_ref m) (constant int (3)))))\n" + "(return (var_ref t))))\n" + ")\n" + "\n" + ")\n" + "\n" + "" +; +static const char builtin_trunc[] = + "((function trunc\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float arg0))\n" + " ((return (expression float trunc (var_ref arg0)))))\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 arg0))\n" + " ((return (expression vec2 trunc (var_ref arg0)))))\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 arg0))\n" + " ((return (expression vec3 trunc (var_ref arg0)))))\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 arg0))\n" + " ((return (expression vec4 trunc (var_ref arg0)))))\n" + "))\n" + "" +; +static const char prototypes_for_100_frag[] = + "(\n" + "(function radians\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float degrees))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 degrees))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 degrees))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 degrees))\n" + " ())\n" + ")\n" + "\n" + "(function degrees\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float radians))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 radians))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 radians))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 radians))\n" + " ())\n" + ")\n" + "\n" + "(function sin\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float angle))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 angle))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 angle))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 angle))\n" + " ())\n" + ")\n" + "\n" + "(function cos\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float angle))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 angle))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 angle))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 angle))\n" + " ())\n" + ")\n" + "\n" + "(function tan\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float angle))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 angle))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 angle))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 angle))\n" + " ())\n" + ")\n" + "\n" + "(function asin\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float angle))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 angle))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 angle))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 angle))\n" + " ())\n" + ")\n" + "\n" + "(function acos\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float angle))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 angle))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 angle))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 angle))\n" + " ())\n" + ")\n" + "\n" + "(function atan\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float y)\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 y)\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 y)\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 y)\n" + " (declare (in) vec4 x))\n" + " ())\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float y_over_x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 y_over_x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 y_over_x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 y_over_x))\n" + " ())\n" + ")\n" + "\n" + "(function pow\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x)\n" + " (declare (in) float y))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y))\n" + " ())\n" + ")\n" + "\n" + "(function exp\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function log\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function exp2\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function log2\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function sqrt\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function inversesqrt\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function abs\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function sign\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function floor\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function ceil\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function fract\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function mod\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x)\n" + " (declare (in) float y))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) float y))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) float y))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) float y))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y))\n" + " ())\n" + ")\n" + "\n" + "(function min\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x)\n" + " (declare (in) float y))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) float y))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) float y))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) float y))\n" + " ())\n" + ")\n" + "\n" + "(function max\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x)\n" + " (declare (in) float y))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) float y))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) float y))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) float y))\n" + " ())\n" + ")\n" + "\n" + "(function clamp\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x)\n" + " (declare (in) float minVal)\n" + " (declare (in) float maxVal))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 minVal)\n" + " (declare (in) vec2 maxVal))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 minVal)\n" + " (declare (in) vec3 maxVal))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 minVal)\n" + " (declare (in) vec4 maxVal))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) float minVal)\n" + " (declare (in) float maxVal))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) float minVal)\n" + " (declare (in) float maxVal))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) float minVal)\n" + " (declare (in) float maxVal))\n" + " ())\n" + ")\n" + "\n" + "(function mix\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x)\n" + " (declare (in) float y)\n" + " (declare (in) float a))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y)\n" + " (declare (in) vec2 a))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y)\n" + " (declare (in) vec3 a))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y)\n" + " (declare (in) vec4 a))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y)\n" + " (declare (in) float a))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y)\n" + " (declare (in) float a))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y)\n" + " (declare (in) float a))\n" + " ())\n" + ")\n" + "\n" + "(function step\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float edge)\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 edge)\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 edge)\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 edge)\n" + " (declare (in) vec4 x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) float edge)\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) float edge)\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) float edge)\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function smoothstep\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float edge0)\n" + " (declare (in) float edge1)\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 edge0)\n" + " (declare (in) vec2 edge1)\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 edge0)\n" + " (declare (in) vec3 edge1)\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 edge0)\n" + " (declare (in) vec4 edge1)\n" + " (declare (in) vec4 x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) float edge0)\n" + " (declare (in) float edge1)\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) float edge0)\n" + " (declare (in) float edge1)\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) float edge0)\n" + " (declare (in) float edge1)\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function length\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function distance\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float p0)\n" + " (declare (in) float p1))\n" + " ())\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec2 p0)\n" + " (declare (in) vec2 p1))\n" + " ())\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec3 p0)\n" + " (declare (in) vec3 p1))\n" + " ())\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec4 p0)\n" + " (declare (in) vec4 p1))\n" + " ())\n" + ")\n" + "\n" + "(function dot\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x)\n" + " (declare (in) float y))\n" + " ())\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y))\n" + " ())\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y))\n" + " ())\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y))\n" + " ())\n" + ")\n" + "\n" + "(function cross\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y))\n" + " ())\n" + ")\n" + "\n" + "(function normalize\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function faceforward\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float N)\n" + " (declare (in) float I)\n" + " (declare (in) float Nref))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 N)\n" + " (declare (in) vec2 I)\n" + " (declare (in) vec2 Nref))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 N)\n" + " (declare (in) vec3 I)\n" + " (declare (in) vec3 Nref))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 N)\n" + " (declare (in) vec4 I)\n" + " (declare (in) vec4 Nref))\n" + " ())\n" + ")\n" + "\n" + "(function reflect\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float I)\n" + " (declare (in) float N))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 I)\n" + " (declare (in) vec2 N))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 I)\n" + " (declare (in) vec3 N))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 I)\n" + " (declare (in) vec4 N))\n" + " ())\n" + ")\n" + "\n" + "(function refract\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float I)\n" + " (declare (in) float N)\n" + " (declare (in) float eta))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 I)\n" + " (declare (in) vec2 N)\n" + " (declare (in) float eta))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 I)\n" + " (declare (in) vec3 N)\n" + " (declare (in) float eta))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 I)\n" + " (declare (in) vec4 N)\n" + " (declare (in) float eta))\n" + " ())\n" + ")\n" + "\n" + "(function matrixCompMult\n" + " (signature mat2\n" + " (parameters\n" + " (declare (in) mat2 x)\n" + " (declare (in) mat2 y))\n" + " ())\n" + "\n" + " (signature mat3\n" + " (parameters\n" + " (declare (in) mat3 x)\n" + " (declare (in) mat3 y))\n" + " ())\n" + "\n" + " (signature mat4\n" + " (parameters\n" + " (declare (in) mat4 x)\n" + " (declare (in) mat4 y))\n" + " ())\n" + ")\n" + "\n" + "(function lessThan\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y))\n" + " ())\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) ivec2 x)\n" + " (declare (in) ivec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) ivec3 x)\n" + " (declare (in) ivec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) ivec4 x)\n" + " (declare (in) ivec4 y))\n" + " ())\n" + ")\n" + "\n" + "(function lessThanEqual\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y))\n" + " ())\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) ivec2 x)\n" + " (declare (in) ivec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) ivec3 x)\n" + " (declare (in) ivec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) ivec4 x)\n" + " (declare (in) ivec4 y))\n" + " ())\n" + ")\n" + "\n" + "(function greaterThan\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y))\n" + " ())\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) ivec2 x)\n" + " (declare (in) ivec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) ivec3 x)\n" + " (declare (in) ivec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) ivec4 x)\n" + " (declare (in) ivec4 y))\n" + " ())\n" + ")\n" + "\n" + "(function greaterThanEqual\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y))\n" + " ())\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) ivec2 x)\n" + " (declare (in) ivec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) ivec3 x)\n" + " (declare (in) ivec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) ivec4 x)\n" + " (declare (in) ivec4 y))\n" + " ())\n" + ")\n" + "\n" + "(function equal\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y))\n" + " ())\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) ivec2 x)\n" + " (declare (in) ivec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) ivec3 x)\n" + " (declare (in) ivec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) ivec4 x)\n" + " (declare (in) ivec4 y))\n" + " ())\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) bvec2 x)\n" + " (declare (in) bvec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) bvec3 x)\n" + " (declare (in) bvec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) bvec4 x)\n" + " (declare (in) bvec4 y))\n" + " ())\n" + ")\n" + "\n" + "(function notEqual\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y))\n" + " ())\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) ivec2 x)\n" + " (declare (in) ivec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) ivec3 x)\n" + " (declare (in) ivec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) ivec4 x)\n" + " (declare (in) ivec4 y))\n" + " ())\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) bvec2 x)\n" + " (declare (in) bvec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) bvec3 x)\n" + " (declare (in) bvec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) bvec4 x)\n" + " (declare (in) bvec4 y))\n" + " ())\n" + ")\n" + "\n" + "(function any\n" + " (signature bool\n" + " (parameters\n" + " (declare (in) bvec2 x))\n" + " ())\n" + "\n" + " (signature bool\n" + " (parameters\n" + " (declare (in) bvec3 x))\n" + " ())\n" + "\n" + " (signature bool\n" + " (parameters\n" + " (declare (in) bvec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function all\n" + " (signature bool\n" + " (parameters\n" + " (declare (in) bvec2 x))\n" + " ())\n" + "\n" + " (signature bool\n" + " (parameters\n" + " (declare (in) bvec3 x))\n" + " ())\n" + "\n" + " (signature bool\n" + " (parameters\n" + " (declare (in) bvec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function not\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) bvec2 x))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) bvec3 x))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) bvec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function texture2D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec2 coord))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec2 coord)\n" + " (declare (in) float bias))\n" + " ())\n" + ")\n" + "\n" + "(function texture2DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec3 coord))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec4 coord))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec3 coord)\n" + " (declare (in) float bias))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec4 coord)\n" + " (declare (in) float bias))\n" + " ())\n" + ")\n" + "\n" + "(function textureCube\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) samplerCube sampler)\n" + " (declare (in) vec3 coord))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) samplerCube sampler)\n" + " (declare (in) vec3 coord)\n" + " (declare (in) float bias))\n" + " ())\n" + ")\n" + "\n" + ")" +; +static const char *functions_for_100_frag [] = { + builtin_abs, + builtin_acos, + builtin_all, + builtin_any, + builtin_asin, + builtin_atan, + builtin_ceil, + builtin_clamp, + builtin_cos, + builtin_cross, + builtin_degrees, + builtin_distance, + builtin_dot, + builtin_equal, + builtin_exp, + builtin_exp2, + builtin_faceforward, + builtin_floor, + builtin_fract, + builtin_greaterThan, + builtin_greaterThanEqual, + builtin_inversesqrt, + builtin_length, + builtin_lessThan, + builtin_lessThanEqual, + builtin_log, + builtin_log2, + builtin_matrixCompMult, + builtin_max, + builtin_min, + builtin_mix, + builtin_mod, + builtin_normalize, + builtin_not, + builtin_notEqual, + builtin_pow, + builtin_radians, + builtin_reflect, + builtin_refract, + builtin_sign, + builtin_sin, + builtin_smoothstep, + builtin_sqrt, + builtin_step, + builtin_tan, + builtin_texture2D, + builtin_texture2DProj, + builtin_textureCube, +}; +static const char prototypes_for_100_vert[] = + "(\n" + "(function radians\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float degrees))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 degrees))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 degrees))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 degrees))\n" + " ())\n" + ")\n" + "\n" + "(function degrees\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float radians))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 radians))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 radians))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 radians))\n" + " ())\n" + ")\n" + "\n" + "(function sin\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float angle))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 angle))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 angle))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 angle))\n" + " ())\n" + ")\n" + "\n" + "(function cos\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float angle))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 angle))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 angle))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 angle))\n" + " ())\n" + ")\n" + "\n" + "(function tan\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float angle))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 angle))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 angle))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 angle))\n" + " ())\n" + ")\n" + "\n" + "(function asin\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float angle))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 angle))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 angle))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 angle))\n" + " ())\n" + ")\n" + "\n" + "(function acos\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float angle))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 angle))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 angle))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 angle))\n" + " ())\n" + ")\n" + "\n" + "(function atan\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float y)\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 y)\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 y)\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 y)\n" + " (declare (in) vec4 x))\n" + " ())\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float y_over_x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 y_over_x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 y_over_x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 y_over_x))\n" + " ())\n" + ")\n" + "\n" + "(function pow\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x)\n" + " (declare (in) float y))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y))\n" + " ())\n" + ")\n" + "\n" + "(function exp\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function log\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function exp2\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function log2\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function sqrt\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function inversesqrt\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function abs\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function sign\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function floor\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function ceil\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function fract\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function mod\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x)\n" + " (declare (in) float y))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) float y))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) float y))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) float y))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y))\n" + " ())\n" + ")\n" + "\n" + "(function min\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x)\n" + " (declare (in) float y))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) float y))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) float y))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) float y))\n" + " ())\n" + ")\n" + "\n" + "(function max\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x)\n" + " (declare (in) float y))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) float y))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) float y))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) float y))\n" + " ())\n" + ")\n" + "\n" + "(function clamp\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x)\n" + " (declare (in) float minVal)\n" + " (declare (in) float maxVal))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 minVal)\n" + " (declare (in) vec2 maxVal))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 minVal)\n" + " (declare (in) vec3 maxVal))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 minVal)\n" + " (declare (in) vec4 maxVal))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) float minVal)\n" + " (declare (in) float maxVal))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) float minVal)\n" + " (declare (in) float maxVal))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) float minVal)\n" + " (declare (in) float maxVal))\n" + " ())\n" + ")\n" + "\n" + "(function mix\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x)\n" + " (declare (in) float y)\n" + " (declare (in) float a))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y)\n" + " (declare (in) vec2 a))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y)\n" + " (declare (in) vec3 a))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y)\n" + " (declare (in) vec4 a))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y)\n" + " (declare (in) float a))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y)\n" + " (declare (in) float a))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y)\n" + " (declare (in) float a))\n" + " ())\n" + ")\n" + "\n" + "(function step\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float edge)\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 edge)\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 edge)\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 edge)\n" + " (declare (in) vec4 x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) float edge)\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) float edge)\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) float edge)\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function smoothstep\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float edge0)\n" + " (declare (in) float edge1)\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 edge0)\n" + " (declare (in) vec2 edge1)\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 edge0)\n" + " (declare (in) vec3 edge1)\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 edge0)\n" + " (declare (in) vec4 edge1)\n" + " (declare (in) vec4 x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) float edge0)\n" + " (declare (in) float edge1)\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) float edge0)\n" + " (declare (in) float edge1)\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) float edge0)\n" + " (declare (in) float edge1)\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function length\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function distance\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float p0)\n" + " (declare (in) float p1))\n" + " ())\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec2 p0)\n" + " (declare (in) vec2 p1))\n" + " ())\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec3 p0)\n" + " (declare (in) vec3 p1))\n" + " ())\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec4 p0)\n" + " (declare (in) vec4 p1))\n" + " ())\n" + ")\n" + "\n" + "(function dot\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x)\n" + " (declare (in) float y))\n" + " ())\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y))\n" + " ())\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y))\n" + " ())\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y))\n" + " ())\n" + ")\n" + "\n" + "(function cross\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y))\n" + " ())\n" + ")\n" + "\n" + "(function normalize\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function faceforward\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float N)\n" + " (declare (in) float I)\n" + " (declare (in) float Nref))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 N)\n" + " (declare (in) vec2 I)\n" + " (declare (in) vec2 Nref))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 N)\n" + " (declare (in) vec3 I)\n" + " (declare (in) vec3 Nref))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 N)\n" + " (declare (in) vec4 I)\n" + " (declare (in) vec4 Nref))\n" + " ())\n" + ")\n" + "\n" + "(function reflect\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float I)\n" + " (declare (in) float N))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 I)\n" + " (declare (in) vec2 N))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 I)\n" + " (declare (in) vec3 N))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 I)\n" + " (declare (in) vec4 N))\n" + " ())\n" + ")\n" + "\n" + "(function refract\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float I)\n" + " (declare (in) float N)\n" + " (declare (in) float eta))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 I)\n" + " (declare (in) vec2 N)\n" + " (declare (in) float eta))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 I)\n" + " (declare (in) vec3 N)\n" + " (declare (in) float eta))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 I)\n" + " (declare (in) vec4 N)\n" + " (declare (in) float eta))\n" + " ())\n" + ")\n" + "\n" + "(function matrixCompMult\n" + " (signature mat2\n" + " (parameters\n" + " (declare (in) mat2 x)\n" + " (declare (in) mat2 y))\n" + " ())\n" + "\n" + " (signature mat3\n" + " (parameters\n" + " (declare (in) mat3 x)\n" + " (declare (in) mat3 y))\n" + " ())\n" + "\n" + " (signature mat4\n" + " (parameters\n" + " (declare (in) mat4 x)\n" + " (declare (in) mat4 y))\n" + " ())\n" + ")\n" + "\n" + "(function lessThan\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y))\n" + " ())\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) ivec2 x)\n" + " (declare (in) ivec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) ivec3 x)\n" + " (declare (in) ivec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) ivec4 x)\n" + " (declare (in) ivec4 y))\n" + " ())\n" + ")\n" + "\n" + "(function lessThanEqual\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y))\n" + " ())\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) ivec2 x)\n" + " (declare (in) ivec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) ivec3 x)\n" + " (declare (in) ivec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) ivec4 x)\n" + " (declare (in) ivec4 y))\n" + " ())\n" + ")\n" + "\n" + "(function greaterThan\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y))\n" + " ())\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) ivec2 x)\n" + " (declare (in) ivec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) ivec3 x)\n" + " (declare (in) ivec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) ivec4 x)\n" + " (declare (in) ivec4 y))\n" + " ())\n" + ")\n" + "\n" + "(function greaterThanEqual\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y))\n" + " ())\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) ivec2 x)\n" + " (declare (in) ivec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) ivec3 x)\n" + " (declare (in) ivec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) ivec4 x)\n" + " (declare (in) ivec4 y))\n" + " ())\n" + ")\n" + "\n" + "(function equal\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y))\n" + " ())\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) ivec2 x)\n" + " (declare (in) ivec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) ivec3 x)\n" + " (declare (in) ivec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) ivec4 x)\n" + " (declare (in) ivec4 y))\n" + " ())\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) bvec2 x)\n" + " (declare (in) bvec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) bvec3 x)\n" + " (declare (in) bvec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) bvec4 x)\n" + " (declare (in) bvec4 y))\n" + " ())\n" + ")\n" + "\n" + "(function notEqual\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y))\n" + " ())\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) ivec2 x)\n" + " (declare (in) ivec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) ivec3 x)\n" + " (declare (in) ivec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) ivec4 x)\n" + " (declare (in) ivec4 y))\n" + " ())\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) bvec2 x)\n" + " (declare (in) bvec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) bvec3 x)\n" + " (declare (in) bvec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) bvec4 x)\n" + " (declare (in) bvec4 y))\n" + " ())\n" + ")\n" + "\n" + "(function any\n" + " (signature bool\n" + " (parameters\n" + " (declare (in) bvec2 x))\n" + " ())\n" + "\n" + " (signature bool\n" + " (parameters\n" + " (declare (in) bvec3 x))\n" + " ())\n" + "\n" + " (signature bool\n" + " (parameters\n" + " (declare (in) bvec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function all\n" + " (signature bool\n" + " (parameters\n" + " (declare (in) bvec2 x))\n" + " ())\n" + "\n" + " (signature bool\n" + " (parameters\n" + " (declare (in) bvec3 x))\n" + " ())\n" + "\n" + " (signature bool\n" + " (parameters\n" + " (declare (in) bvec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function not\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) bvec2 x))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) bvec3 x))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) bvec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function texture2D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec2 coord))\n" + " ())\n" + ")\n" + "\n" + "(function texture2DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec3 coord))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec4 coord))\n" + " ())\n" + ")\n" + "\n" + "(function texture2DLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec2 coord)\n" + " (declare (in) float lod))\n" + " ())\n" + ")\n" + "\n" + "(function texture2DProjLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec3 coord)\n" + " (declare (in) float lod))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec4 coord)\n" + " (declare (in) float lod))\n" + " ())\n" + ")\n" + "\n" + "(function textureCube\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) samplerCube sampler)\n" + " (declare (in) vec3 coord))\n" + " ())\n" + ")\n" + "\n" + "(function textureCubeLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) samplerCube sampler)\n" + " (declare (in) vec3 coord)\n" + " (declare (in) float lod))\n" + " ())\n" + ")\n" + "\n" + ")" +; +static const char *functions_for_100_vert [] = { + builtin_abs, + builtin_acos, + builtin_all, + builtin_any, + builtin_asin, + builtin_atan, + builtin_ceil, + builtin_clamp, + builtin_cos, + builtin_cross, + builtin_degrees, + builtin_distance, + builtin_dot, + builtin_equal, + builtin_exp, + builtin_exp2, + builtin_faceforward, + builtin_floor, + builtin_fract, + builtin_greaterThan, + builtin_greaterThanEqual, + builtin_inversesqrt, + builtin_length, + builtin_lessThan, + builtin_lessThanEqual, + builtin_log, + builtin_log2, + builtin_matrixCompMult, + builtin_max, + builtin_min, + builtin_mix, + builtin_mod, + builtin_normalize, + builtin_not, + builtin_notEqual, + builtin_pow, + builtin_radians, + builtin_reflect, + builtin_refract, + builtin_sign, + builtin_sin, + builtin_smoothstep, + builtin_sqrt, + builtin_step, + builtin_tan, + builtin_texture2D, + builtin_texture2DLod, + builtin_texture2DProj, + builtin_texture2DProjLod, + builtin_textureCube, + builtin_textureCubeLod, +}; +static const char prototypes_for_110_frag[] = + "(\n" + "(function radians\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float degrees))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 degrees))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 degrees))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 degrees))\n" + " ())\n" + ")\n" + "\n" + "(function degrees\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float radians))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 radians))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 radians))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 radians))\n" + " ())\n" + ")\n" + "\n" + "(function sin\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float angle))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 angle))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 angle))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 angle))\n" + " ())\n" + ")\n" + "\n" + "(function cos\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float angle))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 angle))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 angle))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 angle))\n" + " ())\n" + ")\n" + "\n" + "(function tan\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float angle))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 angle))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 angle))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 angle))\n" + " ())\n" + ")\n" + "\n" + "(function asin\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float angle))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 angle))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 angle))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 angle))\n" + " ())\n" + ")\n" + "\n" + "(function acos\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float angle))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 angle))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 angle))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 angle))\n" + " ())\n" + ")\n" + "\n" + "(function atan\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float y)\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 y)\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 y)\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 y)\n" + " (declare (in) vec4 x))\n" + " ())\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float y_over_x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 y_over_x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 y_over_x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 y_over_x))\n" + " ())\n" + ")\n" + "\n" + "(function pow\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x)\n" + " (declare (in) float y))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y))\n" + " ())\n" + ")\n" + "\n" + "(function exp\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function log\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function exp2\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function log2\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function sqrt\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function inversesqrt\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function abs\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function sign\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function floor\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function ceil\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function fract\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function mod\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x)\n" + " (declare (in) float y))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) float y))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) float y))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) float y))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y))\n" + " ())\n" + ")\n" + "\n" + "(function min\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x)\n" + " (declare (in) float y))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) float y))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) float y))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) float y))\n" + " ())\n" + ")\n" + "\n" + "(function max\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x)\n" + " (declare (in) float y))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) float y))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) float y))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) float y))\n" + " ())\n" + ")\n" + "\n" + "(function clamp\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x)\n" + " (declare (in) float minVal)\n" + " (declare (in) float maxVal))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 minVal)\n" + " (declare (in) vec2 maxVal))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 minVal)\n" + " (declare (in) vec3 maxVal))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 minVal)\n" + " (declare (in) vec4 maxVal))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) float minVal)\n" + " (declare (in) float maxVal))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) float minVal)\n" + " (declare (in) float maxVal))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) float minVal)\n" + " (declare (in) float maxVal))\n" + " ())\n" + ")\n" + "\n" + "(function mix\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x)\n" + " (declare (in) float y)\n" + " (declare (in) float a))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y)\n" + " (declare (in) vec2 a))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y)\n" + " (declare (in) vec3 a))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y)\n" + " (declare (in) vec4 a))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y)\n" + " (declare (in) float a))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y)\n" + " (declare (in) float a))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y)\n" + " (declare (in) float a))\n" + " ())\n" + ")\n" + "\n" + "(function step\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float edge)\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 edge)\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 edge)\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 edge)\n" + " (declare (in) vec4 x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) float edge)\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) float edge)\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) float edge)\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function smoothstep\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float edge0)\n" + " (declare (in) float edge1)\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 edge0)\n" + " (declare (in) vec2 edge1)\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 edge0)\n" + " (declare (in) vec3 edge1)\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 edge0)\n" + " (declare (in) vec4 edge1)\n" + " (declare (in) vec4 x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) float edge0)\n" + " (declare (in) float edge1)\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) float edge0)\n" + " (declare (in) float edge1)\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) float edge0)\n" + " (declare (in) float edge1)\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function length\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function distance\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float p0)\n" + " (declare (in) float p1))\n" + " ())\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec2 p0)\n" + " (declare (in) vec2 p1))\n" + " ())\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec3 p0)\n" + " (declare (in) vec3 p1))\n" + " ())\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec4 p0)\n" + " (declare (in) vec4 p1))\n" + " ())\n" + ")\n" + "\n" + "(function dot\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x)\n" + " (declare (in) float y))\n" + " ())\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y))\n" + " ())\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y))\n" + " ())\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y))\n" + " ())\n" + ")\n" + "\n" + "(function cross\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y))\n" + " ())\n" + ")\n" + "\n" + "(function normalize\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function faceforward\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float N)\n" + " (declare (in) float I)\n" + " (declare (in) float Nref))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 N)\n" + " (declare (in) vec2 I)\n" + " (declare (in) vec2 Nref))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 N)\n" + " (declare (in) vec3 I)\n" + " (declare (in) vec3 Nref))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 N)\n" + " (declare (in) vec4 I)\n" + " (declare (in) vec4 Nref))\n" + " ())\n" + ")\n" + "\n" + "(function reflect\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float I)\n" + " (declare (in) float N))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 I)\n" + " (declare (in) vec2 N))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 I)\n" + " (declare (in) vec3 N))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 I)\n" + " (declare (in) vec4 N))\n" + " ())\n" + ")\n" + "\n" + "(function refract\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float I)\n" + " (declare (in) float N)\n" + " (declare (in) float eta))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 I)\n" + " (declare (in) vec2 N)\n" + " (declare (in) float eta))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 I)\n" + " (declare (in) vec3 N)\n" + " (declare (in) float eta))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 I)\n" + " (declare (in) vec4 N)\n" + " (declare (in) float eta))\n" + " ())\n" + ")\n" + "\n" + "(function matrixCompMult\n" + " (signature mat2\n" + " (parameters\n" + " (declare (in) mat2 x)\n" + " (declare (in) mat2 y))\n" + " ())\n" + "\n" + " (signature mat3\n" + " (parameters\n" + " (declare (in) mat3 x)\n" + " (declare (in) mat3 y))\n" + " ())\n" + "\n" + " (signature mat4\n" + " (parameters\n" + " (declare (in) mat4 x)\n" + " (declare (in) mat4 y))\n" + " ())\n" + ")\n" + "\n" + "(function lessThan\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y))\n" + " ())\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) ivec2 x)\n" + " (declare (in) ivec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) ivec3 x)\n" + " (declare (in) ivec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) ivec4 x)\n" + " (declare (in) ivec4 y))\n" + " ())\n" + ")\n" + "\n" + "(function lessThanEqual\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y))\n" + " ())\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) ivec2 x)\n" + " (declare (in) ivec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) ivec3 x)\n" + " (declare (in) ivec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) ivec4 x)\n" + " (declare (in) ivec4 y))\n" + " ())\n" + ")\n" + "\n" + "(function greaterThan\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y))\n" + " ())\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) ivec2 x)\n" + " (declare (in) ivec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) ivec3 x)\n" + " (declare (in) ivec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) ivec4 x)\n" + " (declare (in) ivec4 y))\n" + " ())\n" + ")\n" + "\n" + "(function greaterThanEqual\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y))\n" + " ())\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) ivec2 x)\n" + " (declare (in) ivec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) ivec3 x)\n" + " (declare (in) ivec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) ivec4 x)\n" + " (declare (in) ivec4 y))\n" + " ())\n" + ")\n" + "\n" + "(function equal\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y))\n" + " ())\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) ivec2 x)\n" + " (declare (in) ivec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) ivec3 x)\n" + " (declare (in) ivec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) ivec4 x)\n" + " (declare (in) ivec4 y))\n" + " ())\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) bvec2 x)\n" + " (declare (in) bvec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) bvec3 x)\n" + " (declare (in) bvec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) bvec4 x)\n" + " (declare (in) bvec4 y))\n" + " ())\n" + ")\n" + "\n" + "(function notEqual\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y))\n" + " ())\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) ivec2 x)\n" + " (declare (in) ivec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) ivec3 x)\n" + " (declare (in) ivec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) ivec4 x)\n" + " (declare (in) ivec4 y))\n" + " ())\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) bvec2 x)\n" + " (declare (in) bvec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) bvec3 x)\n" + " (declare (in) bvec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) bvec4 x)\n" + " (declare (in) bvec4 y))\n" + " ())\n" + ")\n" + "\n" + "(function any\n" + " (signature bool\n" + " (parameters\n" + " (declare (in) bvec2 x))\n" + " ())\n" + "\n" + " (signature bool\n" + " (parameters\n" + " (declare (in) bvec3 x))\n" + " ())\n" + "\n" + " (signature bool\n" + " (parameters\n" + " (declare (in) bvec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function all\n" + " (signature bool\n" + " (parameters\n" + " (declare (in) bvec2 x))\n" + " ())\n" + "\n" + " (signature bool\n" + " (parameters\n" + " (declare (in) bvec3 x))\n" + " ())\n" + "\n" + " (signature bool\n" + " (parameters\n" + " (declare (in) bvec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function not\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) bvec2 x))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) bvec3 x))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) bvec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function texture1D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) float coord))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) float coord)\n" + " (declare (in) float bias))\n" + " ())\n" + ")\n" + "\n" + "(function texture1DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec2 coord))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec4 coord))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec2 coord)\n" + " (declare (in) float bias))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec4 coord)\n" + " (declare (in) float bias))\n" + " ())\n" + ")\n" + "\n" + "(function texture2D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec2 coord))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec2 coord)\n" + " (declare (in) float bias))\n" + " ())\n" + ")\n" + "\n" + "(function texture2DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec3 coord))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec4 coord))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec3 coord)\n" + " (declare (in) float bias))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec4 coord)\n" + " (declare (in) float bias))\n" + " ())\n" + ")\n" + "\n" + "(function texture3D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec3 coord))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec3 coord)\n" + " (declare (in) float bias))\n" + " ())\n" + ")\n" + "\n" + "(function texture3DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec4 coord))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec4 coord)\n" + " (declare (in) float bias))\n" + " ())\n" + ")\n" + "\n" + "(function textureCube\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) samplerCube sampler)\n" + " (declare (in) vec3 coord))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) samplerCube sampler)\n" + " (declare (in) vec3 coord)\n" + " (declare (in) float bias))\n" + " ())\n" + ")\n" + "\n" + "(function shadow1D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DShadow sampler)\n" + " (declare (in) vec3 coord))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DShadow sampler)\n" + " (declare (in) vec3 coord)\n" + " (declare (in) float bias))\n" + " ())\n" + ")\n" + "\n" + "(function shadow2D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DShadow sampler)\n" + " (declare (in) vec3 coord))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DShadow sampler)\n" + " (declare (in) vec3 coord)\n" + " (declare (in) float bias))\n" + " ())\n" + ")\n" + "\n" + "(function shadow1DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DShadow sampler)\n" + " (declare (in) vec4 coord))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DShadow sampler)\n" + " (declare (in) vec4 coord)\n" + " (declare (in) float bias))\n" + " ())\n" + ")\n" + "\n" + "(function shadow2DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DShadow sampler)\n" + " (declare (in) vec4 coord))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DShadow sampler)\n" + " (declare (in) vec4 coord)\n" + " (declare (in) float bias))\n" + " ())\n" + ")\n" + "\n" + "(function dFdx\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float p))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 p))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 p))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 p))\n" + " ())\n" + ")\n" + "\n" + "(function dFdy\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float p))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 p))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 p))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 p))\n" + " ())\n" + ")\n" + "\n" + "(function fwidth\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float p))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 p))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 p))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 p))\n" + " ())\n" + ")\n" + "\n" + "(function noise1\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function noise2\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function noise3\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function noise4\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + ")" +; +static const char *functions_for_110_frag [] = { + builtin_abs, + builtin_acos, + builtin_all, + builtin_any, + builtin_asin, + builtin_atan, + builtin_ceil, + builtin_clamp, + builtin_cos, + builtin_cross, + builtin_dFdx, + builtin_dFdy, + builtin_degrees, + builtin_distance, + builtin_dot, + builtin_equal, + builtin_exp, + builtin_exp2, + builtin_faceforward, + builtin_floor, + builtin_fract, + builtin_fwidth, + builtin_greaterThan, + builtin_greaterThanEqual, + builtin_inversesqrt, + builtin_length, + builtin_lessThan, + builtin_lessThanEqual, + builtin_log, + builtin_log2, + builtin_matrixCompMult, + builtin_max, + builtin_min, + builtin_mix, + builtin_mod, + builtin_noise1, + builtin_noise2, + builtin_noise3, + builtin_noise4, + builtin_normalize, + builtin_not, + builtin_notEqual, + builtin_pow, + builtin_radians, + builtin_reflect, + builtin_refract, + builtin_shadow1D, + builtin_shadow1DProj, + builtin_shadow2D, + builtin_shadow2DProj, + builtin_sign, + builtin_sin, + builtin_smoothstep, + builtin_sqrt, + builtin_step, + builtin_tan, + builtin_texture1D, + builtin_texture1DProj, + builtin_texture2D, + builtin_texture2DProj, + builtin_texture3D, + builtin_texture3DProj, + builtin_textureCube, +}; +static const char prototypes_for_110_vert[] = + "(\n" + "(function radians\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float degrees))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 degrees))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 degrees))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 degrees))\n" + " ())\n" + ")\n" + "\n" + "(function degrees\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float radians))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 radians))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 radians))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 radians))\n" + " ())\n" + ")\n" + "\n" + "(function sin\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float angle))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 angle))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 angle))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 angle))\n" + " ())\n" + ")\n" + "\n" + "(function cos\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float angle))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 angle))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 angle))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 angle))\n" + " ())\n" + ")\n" + "\n" + "(function tan\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float angle))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 angle))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 angle))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 angle))\n" + " ())\n" + ")\n" + "\n" + "(function asin\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float angle))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 angle))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 angle))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 angle))\n" + " ())\n" + ")\n" + "\n" + "(function acos\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float angle))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 angle))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 angle))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 angle))\n" + " ())\n" + ")\n" + "\n" + "(function atan\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float y)\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 y)\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 y)\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 y)\n" + " (declare (in) vec4 x))\n" + " ())\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float y_over_x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 y_over_x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 y_over_x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 y_over_x))\n" + " ())\n" + ")\n" + "\n" + "(function pow\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x)\n" + " (declare (in) float y))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y))\n" + " ())\n" + ")\n" + "\n" + "(function exp\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function log\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function exp2\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function log2\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function sqrt\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function inversesqrt\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function abs\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function sign\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function floor\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function ceil\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function fract\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function mod\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x)\n" + " (declare (in) float y))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) float y))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) float y))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) float y))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y))\n" + " ())\n" + ")\n" + "\n" + "(function min\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x)\n" + " (declare (in) float y))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) float y))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) float y))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) float y))\n" + " ())\n" + ")\n" + "\n" + "(function max\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x)\n" + " (declare (in) float y))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) float y))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) float y))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) float y))\n" + " ())\n" + ")\n" + "\n" + "(function clamp\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x)\n" + " (declare (in) float minVal)\n" + " (declare (in) float maxVal))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 minVal)\n" + " (declare (in) vec2 maxVal))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 minVal)\n" + " (declare (in) vec3 maxVal))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 minVal)\n" + " (declare (in) vec4 maxVal))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) float minVal)\n" + " (declare (in) float maxVal))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) float minVal)\n" + " (declare (in) float maxVal))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) float minVal)\n" + " (declare (in) float maxVal))\n" + " ())\n" + ")\n" + "\n" + "(function mix\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x)\n" + " (declare (in) float y)\n" + " (declare (in) float a))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y)\n" + " (declare (in) vec2 a))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y)\n" + " (declare (in) vec3 a))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y)\n" + " (declare (in) vec4 a))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y)\n" + " (declare (in) float a))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y)\n" + " (declare (in) float a))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y)\n" + " (declare (in) float a))\n" + " ())\n" + ")\n" + "\n" + "(function step\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float edge)\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 edge)\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 edge)\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 edge)\n" + " (declare (in) vec4 x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) float edge)\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) float edge)\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) float edge)\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function smoothstep\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float edge0)\n" + " (declare (in) float edge1)\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 edge0)\n" + " (declare (in) vec2 edge1)\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 edge0)\n" + " (declare (in) vec3 edge1)\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 edge0)\n" + " (declare (in) vec4 edge1)\n" + " (declare (in) vec4 x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) float edge0)\n" + " (declare (in) float edge1)\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) float edge0)\n" + " (declare (in) float edge1)\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) float edge0)\n" + " (declare (in) float edge1)\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function length\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function distance\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float p0)\n" + " (declare (in) float p1))\n" + " ())\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec2 p0)\n" + " (declare (in) vec2 p1))\n" + " ())\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec3 p0)\n" + " (declare (in) vec3 p1))\n" + " ())\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec4 p0)\n" + " (declare (in) vec4 p1))\n" + " ())\n" + ")\n" + "\n" + "(function dot\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x)\n" + " (declare (in) float y))\n" + " ())\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y))\n" + " ())\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y))\n" + " ())\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y))\n" + " ())\n" + ")\n" + "\n" + "(function cross\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y))\n" + " ())\n" + ")\n" + "\n" + "(function normalize\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function ftransform\n" + " (signature vec4\n" + " (parameters)\n" + " ())\n" + ")\n" + "\n" + "(function faceforward\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float N)\n" + " (declare (in) float I)\n" + " (declare (in) float Nref))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 N)\n" + " (declare (in) vec2 I)\n" + " (declare (in) vec2 Nref))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 N)\n" + " (declare (in) vec3 I)\n" + " (declare (in) vec3 Nref))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 N)\n" + " (declare (in) vec4 I)\n" + " (declare (in) vec4 Nref))\n" + " ())\n" + ")\n" + "\n" + "(function reflect\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float I)\n" + " (declare (in) float N))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 I)\n" + " (declare (in) vec2 N))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 I)\n" + " (declare (in) vec3 N))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 I)\n" + " (declare (in) vec4 N))\n" + " ())\n" + ")\n" + "\n" + "(function refract\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float I)\n" + " (declare (in) float N)\n" + " (declare (in) float eta))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 I)\n" + " (declare (in) vec2 N)\n" + " (declare (in) float eta))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 I)\n" + " (declare (in) vec3 N)\n" + " (declare (in) float eta))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 I)\n" + " (declare (in) vec4 N)\n" + " (declare (in) float eta))\n" + " ())\n" + ")\n" + "\n" + "(function matrixCompMult\n" + " (signature mat2\n" + " (parameters\n" + " (declare (in) mat2 x)\n" + " (declare (in) mat2 y))\n" + " ())\n" + "\n" + " (signature mat3\n" + " (parameters\n" + " (declare (in) mat3 x)\n" + " (declare (in) mat3 y))\n" + " ())\n" + "\n" + " (signature mat4\n" + " (parameters\n" + " (declare (in) mat4 x)\n" + " (declare (in) mat4 y))\n" + " ())\n" + ")\n" + "\n" + "(function lessThan\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y))\n" + " ())\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) ivec2 x)\n" + " (declare (in) ivec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) ivec3 x)\n" + " (declare (in) ivec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) ivec4 x)\n" + " (declare (in) ivec4 y))\n" + " ())\n" + ")\n" + "\n" + "(function lessThanEqual\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y))\n" + " ())\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) ivec2 x)\n" + " (declare (in) ivec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) ivec3 x)\n" + " (declare (in) ivec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) ivec4 x)\n" + " (declare (in) ivec4 y))\n" + " ())\n" + ")\n" + "\n" + "(function greaterThan\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y))\n" + " ())\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) ivec2 x)\n" + " (declare (in) ivec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) ivec3 x)\n" + " (declare (in) ivec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) ivec4 x)\n" + " (declare (in) ivec4 y))\n" + " ())\n" + ")\n" + "\n" + "(function greaterThanEqual\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y))\n" + " ())\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) ivec2 x)\n" + " (declare (in) ivec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) ivec3 x)\n" + " (declare (in) ivec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) ivec4 x)\n" + " (declare (in) ivec4 y))\n" + " ())\n" + ")\n" + "\n" + "(function equal\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y))\n" + " ())\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) ivec2 x)\n" + " (declare (in) ivec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) ivec3 x)\n" + " (declare (in) ivec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) ivec4 x)\n" + " (declare (in) ivec4 y))\n" + " ())\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) bvec2 x)\n" + " (declare (in) bvec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) bvec3 x)\n" + " (declare (in) bvec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) bvec4 x)\n" + " (declare (in) bvec4 y))\n" + " ())\n" + ")\n" + "\n" + "(function notEqual\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y))\n" + " ())\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) ivec2 x)\n" + " (declare (in) ivec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) ivec3 x)\n" + " (declare (in) ivec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) ivec4 x)\n" + " (declare (in) ivec4 y))\n" + " ())\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) bvec2 x)\n" + " (declare (in) bvec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) bvec3 x)\n" + " (declare (in) bvec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) bvec4 x)\n" + " (declare (in) bvec4 y))\n" + " ())\n" + ")\n" + "\n" + "(function any\n" + " (signature bool\n" + " (parameters\n" + " (declare (in) bvec2 x))\n" + " ())\n" + "\n" + " (signature bool\n" + " (parameters\n" + " (declare (in) bvec3 x))\n" + " ())\n" + "\n" + " (signature bool\n" + " (parameters\n" + " (declare (in) bvec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function all\n" + " (signature bool\n" + " (parameters\n" + " (declare (in) bvec2 x))\n" + " ())\n" + "\n" + " (signature bool\n" + " (parameters\n" + " (declare (in) bvec3 x))\n" + " ())\n" + "\n" + " (signature bool\n" + " (parameters\n" + " (declare (in) bvec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function not\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) bvec2 x))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) bvec3 x))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) bvec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function texture1D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) float coord))\n" + " ())\n" + ")\n" + "\n" + "(function texture1DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec2 coord))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec4 coord))\n" + " ())\n" + ")\n" + "\n" + "(function texture1DLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) float coord)\n" + " (declare (in) float lod))\n" + " ())\n" + ")\n" + "\n" + "(function texture1DProjLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec2 coord)\n" + " (declare (in) float lod))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec4 coord)\n" + " (declare (in) float lod))\n" + " ())\n" + ")\n" + "\n" + "(function texture2D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec2 coord))\n" + " ())\n" + ")\n" + "\n" + "(function texture2DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec3 coord))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec4 coord))\n" + " ())\n" + ")\n" + "\n" + "(function texture2DLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec2 coord)\n" + " (declare (in) float lod))\n" + " ())\n" + ")\n" + "\n" + "(function texture2DProjLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec3 coord)\n" + " (declare (in) float lod))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec4 coord)\n" + " (declare (in) float lod))\n" + " ())\n" + ")\n" + "\n" + "(function texture3D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec3 coord))\n" + " ())\n" + ")\n" + "\n" + "(function texture3DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec4 coord))\n" + " ())\n" + ")\n" + "\n" + "(function texture3DLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec3 coord)\n" + " (declare (in) float lod))\n" + " ())\n" + ")\n" + "\n" + "(function texture3DProjLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec4 coord)\n" + " (declare (in) float lod))\n" + " ())\n" + ")\n" + "\n" + "(function textureCube\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) samplerCube sampler)\n" + " (declare (in) vec3 coord))\n" + " ())\n" + ")\n" + "\n" + "(function textureCubeLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) samplerCube sampler)\n" + " (declare (in) vec3 coord)\n" + " (declare (in) float lod))\n" + " ())\n" + ")\n" + "\n" + "(function shadow1D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DShadow sampler)\n" + " (declare (in) vec3 coord))\n" + " ())\n" + ")\n" + "\n" + "(function shadow2D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DShadow sampler)\n" + " (declare (in) vec3 coord))\n" + " ())\n" + ")\n" + "\n" + "(function shadow1DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DShadow sampler)\n" + " (declare (in) vec4 coord))\n" + " ())\n" + ")\n" + "\n" + "(function shadow2DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DShadow sampler)\n" + " (declare (in) vec4 coord))\n" + " ())\n" + ")\n" + "\n" + "(function shadow1DLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DShadow sampler)\n" + " (declare (in) vec3 coord)\n" + " (declare (in) float lod))\n" + " ())\n" + ")\n" + "\n" + "(function shadow2DLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DShadow sampler)\n" + " (declare (in) vec3 coord)\n" + " (declare (in) float lod))\n" + " ())\n" + ")\n" + "\n" + "(function shadow1DProjLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DShadow sampler)\n" + " (declare (in) vec4 coord)\n" + " (declare (in) float lod))\n" + " ())\n" + ")\n" + "\n" + "(function shadow2DProjLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DShadow sampler)\n" + " (declare (in) vec4 coord)\n" + " (declare (in) float lod))\n" + " ())\n" + ")\n" + "\n" + "(function noise1\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function noise2\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function noise3\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function noise4\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + ")" +; +static const char *functions_for_110_vert [] = { + builtin_abs, + builtin_acos, + builtin_all, + builtin_any, + builtin_asin, + builtin_atan, + builtin_ceil, + builtin_clamp, + builtin_cos, + builtin_cross, + builtin_degrees, + builtin_distance, + builtin_dot, + builtin_equal, + builtin_exp, + builtin_exp2, + builtin_faceforward, + builtin_floor, + builtin_fract, + builtin_ftransform, + builtin_greaterThan, + builtin_greaterThanEqual, + builtin_inversesqrt, + builtin_length, + builtin_lessThan, + builtin_lessThanEqual, + builtin_log, + builtin_log2, + builtin_matrixCompMult, + builtin_max, + builtin_min, + builtin_mix, + builtin_mod, + builtin_noise1, + builtin_noise2, + builtin_noise3, + builtin_noise4, + builtin_normalize, + builtin_not, + builtin_notEqual, + builtin_pow, + builtin_radians, + builtin_reflect, + builtin_refract, + builtin_shadow1D, + builtin_shadow1DLod, + builtin_shadow1DProj, + builtin_shadow1DProjLod, + builtin_shadow2D, + builtin_shadow2DLod, + builtin_shadow2DProj, + builtin_shadow2DProjLod, + builtin_sign, + builtin_sin, + builtin_smoothstep, + builtin_sqrt, + builtin_step, + builtin_tan, + builtin_texture1D, + builtin_texture1DLod, + builtin_texture1DProj, + builtin_texture1DProjLod, + builtin_texture2D, + builtin_texture2DLod, + builtin_texture2DProj, + builtin_texture2DProjLod, + builtin_texture3D, + builtin_texture3DLod, + builtin_texture3DProj, + builtin_texture3DProjLod, + builtin_textureCube, + builtin_textureCubeLod, +}; +static const char prototypes_for_120_frag[] = + "(\n" + "(function radians\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float degrees))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 degrees))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 degrees))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 degrees))\n" + " ())\n" + ")\n" + "\n" + "(function degrees\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float radians))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 radians))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 radians))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 radians))\n" + " ())\n" + ")\n" + "\n" + "(function sin\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float angle))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 angle))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 angle))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 angle))\n" + " ())\n" + ")\n" + "\n" + "(function cos\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float angle))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 angle))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 angle))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 angle))\n" + " ())\n" + ")\n" + "\n" + "(function tan\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float angle))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 angle))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 angle))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 angle))\n" + " ())\n" + ")\n" + "\n" + "(function asin\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float angle))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 angle))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 angle))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 angle))\n" + " ())\n" + ")\n" + "\n" + "(function acos\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float angle))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 angle))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 angle))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 angle))\n" + " ())\n" + ")\n" + "\n" + "(function atan\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float y)\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 y)\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 y)\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 y)\n" + " (declare (in) vec4 x))\n" + " ())\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float y_over_x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 y_over_x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 y_over_x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 y_over_x))\n" + " ())\n" + ")\n" + "\n" + "(function pow\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x)\n" + " (declare (in) float y))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y))\n" + " ())\n" + ")\n" + "\n" + "(function exp\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function log\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function exp2\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function log2\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function sqrt\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function inversesqrt\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function abs\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function sign\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function floor\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function ceil\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function fract\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function mod\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x)\n" + " (declare (in) float y))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) float y))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) float y))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) float y))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y))\n" + " ())\n" + ")\n" + "\n" + "(function min\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x)\n" + " (declare (in) float y))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) float y))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) float y))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) float y))\n" + " ())\n" + ")\n" + "\n" + "(function max\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x)\n" + " (declare (in) float y))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) float y))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) float y))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) float y))\n" + " ())\n" + ")\n" + "\n" + "(function clamp\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x)\n" + " (declare (in) float minVal)\n" + " (declare (in) float maxVal))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 minVal)\n" + " (declare (in) vec2 maxVal))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 minVal)\n" + " (declare (in) vec3 maxVal))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 minVal)\n" + " (declare (in) vec4 maxVal))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) float minVal)\n" + " (declare (in) float maxVal))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) float minVal)\n" + " (declare (in) float maxVal))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) float minVal)\n" + " (declare (in) float maxVal))\n" + " ())\n" + ")\n" + "\n" + "(function mix\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x)\n" + " (declare (in) float y)\n" + " (declare (in) float a))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y)\n" + " (declare (in) vec2 a))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y)\n" + " (declare (in) vec3 a))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y)\n" + " (declare (in) vec4 a))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y)\n" + " (declare (in) float a))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y)\n" + " (declare (in) float a))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y)\n" + " (declare (in) float a))\n" + " ())\n" + ")\n" + "\n" + "(function step\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float edge)\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 edge)\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 edge)\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 edge)\n" + " (declare (in) vec4 x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) float edge)\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) float edge)\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) float edge)\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function smoothstep\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float edge0)\n" + " (declare (in) float edge1)\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 edge0)\n" + " (declare (in) vec2 edge1)\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 edge0)\n" + " (declare (in) vec3 edge1)\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 edge0)\n" + " (declare (in) vec4 edge1)\n" + " (declare (in) vec4 x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) float edge0)\n" + " (declare (in) float edge1)\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) float edge0)\n" + " (declare (in) float edge1)\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) float edge0)\n" + " (declare (in) float edge1)\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function length\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function distance\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float p0)\n" + " (declare (in) float p1))\n" + " ())\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec2 p0)\n" + " (declare (in) vec2 p1))\n" + " ())\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec3 p0)\n" + " (declare (in) vec3 p1))\n" + " ())\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec4 p0)\n" + " (declare (in) vec4 p1))\n" + " ())\n" + ")\n" + "\n" + "(function dot\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x)\n" + " (declare (in) float y))\n" + " ())\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y))\n" + " ())\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y))\n" + " ())\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y))\n" + " ())\n" + ")\n" + "\n" + "(function cross\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y))\n" + " ())\n" + ")\n" + "\n" + "(function normalize\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function faceforward\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float N)\n" + " (declare (in) float I)\n" + " (declare (in) float Nref))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 N)\n" + " (declare (in) vec2 I)\n" + " (declare (in) vec2 Nref))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 N)\n" + " (declare (in) vec3 I)\n" + " (declare (in) vec3 Nref))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 N)\n" + " (declare (in) vec4 I)\n" + " (declare (in) vec4 Nref))\n" + " ())\n" + ")\n" + "\n" + "(function reflect\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float I)\n" + " (declare (in) float N))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 I)\n" + " (declare (in) vec2 N))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 I)\n" + " (declare (in) vec3 N))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 I)\n" + " (declare (in) vec4 N))\n" + " ())\n" + ")\n" + "\n" + "(function refract\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float I)\n" + " (declare (in) float N)\n" + " (declare (in) float eta))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 I)\n" + " (declare (in) vec2 N)\n" + " (declare (in) float eta))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 I)\n" + " (declare (in) vec3 N)\n" + " (declare (in) float eta))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 I)\n" + " (declare (in) vec4 N)\n" + " (declare (in) float eta))\n" + " ())\n" + ")\n" + "\n" + "(function matrixCompMult\n" + " (signature mat2\n" + " (parameters\n" + " (declare (in) mat2 x)\n" + " (declare (in) mat2 y))\n" + " ())\n" + "\n" + " (signature mat3\n" + " (parameters\n" + " (declare (in) mat3 x)\n" + " (declare (in) mat3 y))\n" + " ())\n" + "\n" + " (signature mat4\n" + " (parameters\n" + " (declare (in) mat4 x)\n" + " (declare (in) mat4 y))\n" + " ())\n" + "\n" + " (signature mat2x3\n" + " (parameters\n" + " (declare (in) mat2x3 x)\n" + " (declare (in) mat2x3 y))\n" + " ())\n" + "\n" + " (signature mat2x4\n" + " (parameters\n" + " (declare (in) mat2x4 x)\n" + " (declare (in) mat2x4 y))\n" + " ())\n" + "\n" + " (signature mat3x2\n" + " (parameters\n" + " (declare (in) mat3x2 x)\n" + " (declare (in) mat3x2 y))\n" + " ())\n" + "\n" + " (signature mat3x4\n" + " (parameters\n" + " (declare (in) mat3x4 x)\n" + " (declare (in) mat3x4 y))\n" + " ())\n" + "\n" + " (signature mat4x2\n" + " (parameters\n" + " (declare (in) mat4x2 x)\n" + " (declare (in) mat4x2 y))\n" + " ())\n" + "\n" + " (signature mat4x3\n" + " (parameters\n" + " (declare (in) mat4x3 x)\n" + " (declare (in) mat4x3 y))\n" + " ())\n" + ")\n" + "\n" + "(function outerProduct\n" + " (signature mat2\n" + " (parameters\n" + " (declare (in) vec2 c)\n" + " (declare (in) vec2 r))\n" + " ())\n" + "\n" + " (signature mat3\n" + " (parameters\n" + " (declare (in) vec3 c)\n" + " (declare (in) vec3 r))\n" + " ())\n" + "\n" + " (signature mat4\n" + " (parameters\n" + " (declare (in) vec4 c)\n" + " (declare (in) vec4 r))\n" + " ())\n" + "\n" + " (signature mat2x3\n" + " (parameters\n" + " (declare (in) vec3 c)\n" + " (declare (in) vec2 r))\n" + " ())\n" + "\n" + " (signature mat3x2\n" + " (parameters\n" + " (declare (in) vec2 c)\n" + " (declare (in) vec3 r))\n" + " ())\n" + "\n" + " (signature mat2x4\n" + " (parameters\n" + " (declare (in) vec4 c)\n" + " (declare (in) vec2 r))\n" + " ())\n" + "\n" + " (signature mat4x2\n" + " (parameters\n" + " (declare (in) vec2 c)\n" + " (declare (in) vec4 r))\n" + " ())\n" + "\n" + " (signature mat3x4\n" + " (parameters\n" + " (declare (in) vec4 c)\n" + " (declare (in) vec3 r))\n" + " ())\n" + "\n" + " (signature mat4x3\n" + " (parameters\n" + " (declare (in) vec3 c)\n" + " (declare (in) vec4 r))\n" + " ())\n" + ")\n" + "\n" + "(function transpose\n" + " (signature mat2\n" + " (parameters\n" + " (declare (in) mat2 m))\n" + " ())\n" + "\n" + " (signature mat3\n" + " (parameters\n" + " (declare (in) mat3 m))\n" + " ())\n" + "\n" + " (signature mat4\n" + " (parameters\n" + " (declare (in) mat4 m))\n" + " ())\n" + "\n" + " (signature mat2x3\n" + " (parameters\n" + " (declare (in) mat3x2 m))\n" + " ())\n" + "\n" + " (signature mat3x2\n" + " (parameters\n" + " (declare (in) mat2x3 m))\n" + " ())\n" + "\n" + " (signature mat2x4\n" + " (parameters\n" + " (declare (in) mat4x2 m))\n" + " ())\n" + "\n" + " (signature mat4x2\n" + " (parameters\n" + " (declare (in) mat2x4 m))\n" + " ())\n" + "\n" + " (signature mat3x4\n" + " (parameters\n" + " (declare (in) mat4x3 m))\n" + " ())\n" + "\n" + " (signature mat4x3\n" + " (parameters\n" + " (declare (in) mat3x4 m))\n" + " ())\n" + ")\n" + "\n" + "(function lessThan\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y))\n" + " ())\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) ivec2 x)\n" + " (declare (in) ivec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) ivec3 x)\n" + " (declare (in) ivec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) ivec4 x)\n" + " (declare (in) ivec4 y))\n" + " ())\n" + ")\n" + "\n" + "(function lessThanEqual\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y))\n" + " ())\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) ivec2 x)\n" + " (declare (in) ivec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) ivec3 x)\n" + " (declare (in) ivec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) ivec4 x)\n" + " (declare (in) ivec4 y))\n" + " ())\n" + ")\n" + "\n" + "(function greaterThan\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y))\n" + " ())\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) ivec2 x)\n" + " (declare (in) ivec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) ivec3 x)\n" + " (declare (in) ivec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) ivec4 x)\n" + " (declare (in) ivec4 y))\n" + " ())\n" + ")\n" + "\n" + "(function greaterThanEqual\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y))\n" + " ())\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) ivec2 x)\n" + " (declare (in) ivec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) ivec3 x)\n" + " (declare (in) ivec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) ivec4 x)\n" + " (declare (in) ivec4 y))\n" + " ())\n" + ")\n" + "\n" + "(function equal\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y))\n" + " ())\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) ivec2 x)\n" + " (declare (in) ivec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) ivec3 x)\n" + " (declare (in) ivec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) ivec4 x)\n" + " (declare (in) ivec4 y))\n" + " ())\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) bvec2 x)\n" + " (declare (in) bvec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) bvec3 x)\n" + " (declare (in) bvec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) bvec4 x)\n" + " (declare (in) bvec4 y))\n" + " ())\n" + ")\n" + "\n" + "(function notEqual\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y))\n" + " ())\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) ivec2 x)\n" + " (declare (in) ivec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) ivec3 x)\n" + " (declare (in) ivec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) ivec4 x)\n" + " (declare (in) ivec4 y))\n" + " ())\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) bvec2 x)\n" + " (declare (in) bvec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) bvec3 x)\n" + " (declare (in) bvec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) bvec4 x)\n" + " (declare (in) bvec4 y))\n" + " ())\n" + ")\n" + "\n" + "(function any\n" + " (signature bool\n" + " (parameters\n" + " (declare (in) bvec2 x))\n" + " ())\n" + "\n" + " (signature bool\n" + " (parameters\n" + " (declare (in) bvec3 x))\n" + " ())\n" + "\n" + " (signature bool\n" + " (parameters\n" + " (declare (in) bvec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function all\n" + " (signature bool\n" + " (parameters\n" + " (declare (in) bvec2 x))\n" + " ())\n" + "\n" + " (signature bool\n" + " (parameters\n" + " (declare (in) bvec3 x))\n" + " ())\n" + "\n" + " (signature bool\n" + " (parameters\n" + " (declare (in) bvec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function not\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) bvec2 x))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) bvec3 x))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) bvec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function texture1D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) float coord))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) float coord)\n" + " (declare (in) float bias))\n" + " ())\n" + ")\n" + "\n" + "(function texture1DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec2 coord))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec4 coord))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec2 coord)\n" + " (declare (in) float bias))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec4 coord)\n" + " (declare (in) float bias))\n" + " ())\n" + ")\n" + "\n" + "(function texture2D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec2 coord))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec2 coord)\n" + " (declare (in) float bias))\n" + " ())\n" + ")\n" + "\n" + "(function texture2DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec3 coord))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec4 coord))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec3 coord)\n" + " (declare (in) float bias))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec4 coord)\n" + " (declare (in) float bias))\n" + " ())\n" + ")\n" + "\n" + "(function texture3D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec3 coord))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec3 coord)\n" + " (declare (in) float bias))\n" + " ())\n" + ")\n" + "\n" + "(function texture3DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec4 coord))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec4 coord)\n" + " (declare (in) float bias))\n" + " ())\n" + ")\n" + "\n" + "(function textureCube\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) samplerCube sampler)\n" + " (declare (in) vec3 coord))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) samplerCube sampler)\n" + " (declare (in) vec3 coord)\n" + " (declare (in) float bias))\n" + " ())\n" + ")\n" + "\n" + "(function shadow1D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DShadow sampler)\n" + " (declare (in) vec3 coord))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DShadow sampler)\n" + " (declare (in) vec3 coord)\n" + " (declare (in) float bias))\n" + " ())\n" + ")\n" + "\n" + "(function shadow2D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DShadow sampler)\n" + " (declare (in) vec3 coord))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DShadow sampler)\n" + " (declare (in) vec3 coord)\n" + " (declare (in) float bias))\n" + " ())\n" + ")\n" + "\n" + "(function shadow1DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DShadow sampler)\n" + " (declare (in) vec4 coord))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DShadow sampler)\n" + " (declare (in) vec4 coord)\n" + " (declare (in) float bias))\n" + " ())\n" + ")\n" + "\n" + "(function shadow2DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DShadow sampler)\n" + " (declare (in) vec4 coord))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DShadow sampler)\n" + " (declare (in) vec4 coord)\n" + " (declare (in) float bias))\n" + " ())\n" + ")\n" + "\n" + "(function dFdx\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float p))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 p))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 p))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 p))\n" + " ())\n" + ")\n" + "\n" + "(function dFdy\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float p))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 p))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 p))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 p))\n" + " ())\n" + ")\n" + "\n" + "(function fwidth\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float p))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 p))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 p))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 p))\n" + " ())\n" + ")\n" + "\n" + "(function noise1\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function noise2\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function noise3\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function noise4\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + ")" +; +static const char *functions_for_120_frag [] = { + builtin_abs, + builtin_acos, + builtin_all, + builtin_any, + builtin_asin, + builtin_atan, + builtin_ceil, + builtin_clamp, + builtin_cos, + builtin_cross, + builtin_dFdx, + builtin_dFdy, + builtin_degrees, + builtin_distance, + builtin_dot, + builtin_equal, + builtin_exp, + builtin_exp2, + builtin_faceforward, + builtin_floor, + builtin_fract, + builtin_fwidth, + builtin_greaterThan, + builtin_greaterThanEqual, + builtin_inversesqrt, + builtin_length, + builtin_lessThan, + builtin_lessThanEqual, + builtin_log, + builtin_log2, + builtin_matrixCompMult, + builtin_max, + builtin_min, + builtin_mix, + builtin_mod, + builtin_noise1, + builtin_noise2, + builtin_noise3, + builtin_noise4, + builtin_normalize, + builtin_not, + builtin_notEqual, + builtin_outerProduct, + builtin_pow, + builtin_radians, + builtin_reflect, + builtin_refract, + builtin_shadow1D, + builtin_shadow1DProj, + builtin_shadow2D, + builtin_shadow2DProj, + builtin_sign, + builtin_sin, + builtin_smoothstep, + builtin_sqrt, + builtin_step, + builtin_tan, + builtin_texture1D, + builtin_texture1DProj, + builtin_texture2D, + builtin_texture2DProj, + builtin_texture3D, + builtin_texture3DProj, + builtin_textureCube, + builtin_transpose, +}; +static const char prototypes_for_120_vert[] = + "(\n" + "(function radians\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float degrees))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 degrees))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 degrees))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 degrees))\n" + " ())\n" + ")\n" + "\n" + "(function degrees\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float radians))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 radians))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 radians))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 radians))\n" + " ())\n" + ")\n" + "\n" + "(function sin\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float angle))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 angle))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 angle))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 angle))\n" + " ())\n" + ")\n" + "\n" + "(function cos\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float angle))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 angle))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 angle))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 angle))\n" + " ())\n" + ")\n" + "\n" + "(function tan\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float angle))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 angle))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 angle))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 angle))\n" + " ())\n" + ")\n" + "\n" + "(function asin\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float angle))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 angle))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 angle))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 angle))\n" + " ())\n" + ")\n" + "\n" + "(function acos\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float angle))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 angle))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 angle))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 angle))\n" + " ())\n" + ")\n" + "\n" + "(function atan\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float y)\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 y)\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 y)\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 y)\n" + " (declare (in) vec4 x))\n" + " ())\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float y_over_x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 y_over_x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 y_over_x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 y_over_x))\n" + " ())\n" + ")\n" + "\n" + "(function pow\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x)\n" + " (declare (in) float y))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y))\n" + " ())\n" + ")\n" + "\n" + "(function exp\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function log\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function exp2\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function log2\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function sqrt\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function inversesqrt\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function abs\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function sign\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function floor\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function ceil\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function fract\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function mod\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x)\n" + " (declare (in) float y))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) float y))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) float y))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) float y))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y))\n" + " ())\n" + ")\n" + "\n" + "(function min\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x)\n" + " (declare (in) float y))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) float y))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) float y))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) float y))\n" + " ())\n" + ")\n" + "\n" + "(function max\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x)\n" + " (declare (in) float y))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) float y))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) float y))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) float y))\n" + " ())\n" + ")\n" + "\n" + "(function clamp\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x)\n" + " (declare (in) float minVal)\n" + " (declare (in) float maxVal))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 minVal)\n" + " (declare (in) vec2 maxVal))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 minVal)\n" + " (declare (in) vec3 maxVal))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 minVal)\n" + " (declare (in) vec4 maxVal))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) float minVal)\n" + " (declare (in) float maxVal))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) float minVal)\n" + " (declare (in) float maxVal))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) float minVal)\n" + " (declare (in) float maxVal))\n" + " ())\n" + ")\n" + "\n" + "(function mix\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x)\n" + " (declare (in) float y)\n" + " (declare (in) float a))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y)\n" + " (declare (in) vec2 a))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y)\n" + " (declare (in) vec3 a))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y)\n" + " (declare (in) vec4 a))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y)\n" + " (declare (in) float a))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y)\n" + " (declare (in) float a))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y)\n" + " (declare (in) float a))\n" + " ())\n" + ")\n" + "\n" + "(function step\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float edge)\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 edge)\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 edge)\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 edge)\n" + " (declare (in) vec4 x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) float edge)\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) float edge)\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) float edge)\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function smoothstep\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float edge0)\n" + " (declare (in) float edge1)\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 edge0)\n" + " (declare (in) vec2 edge1)\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 edge0)\n" + " (declare (in) vec3 edge1)\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 edge0)\n" + " (declare (in) vec4 edge1)\n" + " (declare (in) vec4 x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) float edge0)\n" + " (declare (in) float edge1)\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) float edge0)\n" + " (declare (in) float edge1)\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) float edge0)\n" + " (declare (in) float edge1)\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function length\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function distance\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float p0)\n" + " (declare (in) float p1))\n" + " ())\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec2 p0)\n" + " (declare (in) vec2 p1))\n" + " ())\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec3 p0)\n" + " (declare (in) vec3 p1))\n" + " ())\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec4 p0)\n" + " (declare (in) vec4 p1))\n" + " ())\n" + ")\n" + "\n" + "(function dot\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x)\n" + " (declare (in) float y))\n" + " ())\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y))\n" + " ())\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y))\n" + " ())\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y))\n" + " ())\n" + ")\n" + "\n" + "(function cross\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y))\n" + " ())\n" + ")\n" + "\n" + "(function normalize\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function ftransform\n" + " (signature vec4\n" + " (parameters)\n" + " ())\n" + ")\n" + "\n" + "(function faceforward\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float N)\n" + " (declare (in) float I)\n" + " (declare (in) float Nref))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 N)\n" + " (declare (in) vec2 I)\n" + " (declare (in) vec2 Nref))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 N)\n" + " (declare (in) vec3 I)\n" + " (declare (in) vec3 Nref))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 N)\n" + " (declare (in) vec4 I)\n" + " (declare (in) vec4 Nref))\n" + " ())\n" + ")\n" + "\n" + "(function reflect\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float I)\n" + " (declare (in) float N))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 I)\n" + " (declare (in) vec2 N))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 I)\n" + " (declare (in) vec3 N))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 I)\n" + " (declare (in) vec4 N))\n" + " ())\n" + ")\n" + "\n" + "(function refract\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float I)\n" + " (declare (in) float N)\n" + " (declare (in) float eta))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 I)\n" + " (declare (in) vec2 N)\n" + " (declare (in) float eta))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 I)\n" + " (declare (in) vec3 N)\n" + " (declare (in) float eta))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 I)\n" + " (declare (in) vec4 N)\n" + " (declare (in) float eta))\n" + " ())\n" + ")\n" + "\n" + "(function matrixCompMult\n" + " (signature mat2\n" + " (parameters\n" + " (declare (in) mat2 x)\n" + " (declare (in) mat2 y))\n" + " ())\n" + "\n" + " (signature mat3\n" + " (parameters\n" + " (declare (in) mat3 x)\n" + " (declare (in) mat3 y))\n" + " ())\n" + "\n" + " (signature mat4\n" + " (parameters\n" + " (declare (in) mat4 x)\n" + " (declare (in) mat4 y))\n" + " ())\n" + "\n" + " (signature mat2x3\n" + " (parameters\n" + " (declare (in) mat2x3 x)\n" + " (declare (in) mat2x3 y))\n" + " ())\n" + "\n" + " (signature mat2x4\n" + " (parameters\n" + " (declare (in) mat2x4 x)\n" + " (declare (in) mat2x4 y))\n" + " ())\n" + "\n" + " (signature mat3x2\n" + " (parameters\n" + " (declare (in) mat3x2 x)\n" + " (declare (in) mat3x2 y))\n" + " ())\n" + "\n" + " (signature mat3x4\n" + " (parameters\n" + " (declare (in) mat3x4 x)\n" + " (declare (in) mat3x4 y))\n" + " ())\n" + "\n" + " (signature mat4x2\n" + " (parameters\n" + " (declare (in) mat4x2 x)\n" + " (declare (in) mat4x2 y))\n" + " ())\n" + "\n" + " (signature mat4x3\n" + " (parameters\n" + " (declare (in) mat4x3 x)\n" + " (declare (in) mat4x3 y))\n" + " ())\n" + ")\n" + "\n" + "(function outerProduct\n" + " (signature mat2\n" + " (parameters\n" + " (declare (in) vec2 c)\n" + " (declare (in) vec2 r))\n" + " ())\n" + "\n" + " (signature mat3\n" + " (parameters\n" + " (declare (in) vec3 c)\n" + " (declare (in) vec3 r))\n" + " ())\n" + "\n" + " (signature mat4\n" + " (parameters\n" + " (declare (in) vec4 c)\n" + " (declare (in) vec4 r))\n" + " ())\n" + "\n" + " (signature mat2x3\n" + " (parameters\n" + " (declare (in) vec3 c)\n" + " (declare (in) vec2 r))\n" + " ())\n" + "\n" + " (signature mat3x2\n" + " (parameters\n" + " (declare (in) vec2 c)\n" + " (declare (in) vec3 r))\n" + " ())\n" + "\n" + " (signature mat2x4\n" + " (parameters\n" + " (declare (in) vec4 c)\n" + " (declare (in) vec2 r))\n" + " ())\n" + "\n" + " (signature mat4x2\n" + " (parameters\n" + " (declare (in) vec2 c)\n" + " (declare (in) vec4 r))\n" + " ())\n" + "\n" + " (signature mat3x4\n" + " (parameters\n" + " (declare (in) vec4 c)\n" + " (declare (in) vec3 r))\n" + " ())\n" + "\n" + " (signature mat4x3\n" + " (parameters\n" + " (declare (in) vec3 c)\n" + " (declare (in) vec4 r))\n" + " ())\n" + ")\n" + "\n" + "(function transpose\n" + " (signature mat2\n" + " (parameters\n" + " (declare (in) mat2 m))\n" + " ())\n" + "\n" + " (signature mat3\n" + " (parameters\n" + " (declare (in) mat3 m))\n" + " ())\n" + "\n" + " (signature mat4\n" + " (parameters\n" + " (declare (in) mat4 m))\n" + " ())\n" + "\n" + " (signature mat2x3\n" + " (parameters\n" + " (declare (in) mat3x2 m))\n" + " ())\n" + "\n" + " (signature mat3x2\n" + " (parameters\n" + " (declare (in) mat2x3 m))\n" + " ())\n" + "\n" + " (signature mat2x4\n" + " (parameters\n" + " (declare (in) mat4x2 m))\n" + " ())\n" + "\n" + " (signature mat4x2\n" + " (parameters\n" + " (declare (in) mat2x4 m))\n" + " ())\n" + "\n" + " (signature mat3x4\n" + " (parameters\n" + " (declare (in) mat4x3 m))\n" + " ())\n" + "\n" + " (signature mat4x3\n" + " (parameters\n" + " (declare (in) mat3x4 m))\n" + " ())\n" + ")\n" + "\n" + "(function lessThan\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y))\n" + " ())\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) ivec2 x)\n" + " (declare (in) ivec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) ivec3 x)\n" + " (declare (in) ivec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) ivec4 x)\n" + " (declare (in) ivec4 y))\n" + " ())\n" + ")\n" + "\n" + "(function lessThanEqual\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y))\n" + " ())\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) ivec2 x)\n" + " (declare (in) ivec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) ivec3 x)\n" + " (declare (in) ivec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) ivec4 x)\n" + " (declare (in) ivec4 y))\n" + " ())\n" + ")\n" + "\n" + "(function greaterThan\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y))\n" + " ())\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) ivec2 x)\n" + " (declare (in) ivec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) ivec3 x)\n" + " (declare (in) ivec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) ivec4 x)\n" + " (declare (in) ivec4 y))\n" + " ())\n" + ")\n" + "\n" + "(function greaterThanEqual\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y))\n" + " ())\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) ivec2 x)\n" + " (declare (in) ivec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) ivec3 x)\n" + " (declare (in) ivec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) ivec4 x)\n" + " (declare (in) ivec4 y))\n" + " ())\n" + ")\n" + "\n" + "(function equal\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y))\n" + " ())\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) ivec2 x)\n" + " (declare (in) ivec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) ivec3 x)\n" + " (declare (in) ivec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) ivec4 x)\n" + " (declare (in) ivec4 y))\n" + " ())\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) bvec2 x)\n" + " (declare (in) bvec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) bvec3 x)\n" + " (declare (in) bvec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) bvec4 x)\n" + " (declare (in) bvec4 y))\n" + " ())\n" + ")\n" + "\n" + "(function notEqual\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) vec2 x)\n" + " (declare (in) vec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) vec3 x)\n" + " (declare (in) vec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) vec4 x)\n" + " (declare (in) vec4 y))\n" + " ())\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) ivec2 x)\n" + " (declare (in) ivec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) ivec3 x)\n" + " (declare (in) ivec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) ivec4 x)\n" + " (declare (in) ivec4 y))\n" + " ())\n" + "\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) bvec2 x)\n" + " (declare (in) bvec2 y))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) bvec3 x)\n" + " (declare (in) bvec3 y))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) bvec4 x)\n" + " (declare (in) bvec4 y))\n" + " ())\n" + ")\n" + "\n" + "(function any\n" + " (signature bool\n" + " (parameters\n" + " (declare (in) bvec2 x))\n" + " ())\n" + "\n" + " (signature bool\n" + " (parameters\n" + " (declare (in) bvec3 x))\n" + " ())\n" + "\n" + " (signature bool\n" + " (parameters\n" + " (declare (in) bvec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function all\n" + " (signature bool\n" + " (parameters\n" + " (declare (in) bvec2 x))\n" + " ())\n" + "\n" + " (signature bool\n" + " (parameters\n" + " (declare (in) bvec3 x))\n" + " ())\n" + "\n" + " (signature bool\n" + " (parameters\n" + " (declare (in) bvec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function not\n" + " (signature bvec2\n" + " (parameters\n" + " (declare (in) bvec2 x))\n" + " ())\n" + "\n" + " (signature bvec3\n" + " (parameters\n" + " (declare (in) bvec3 x))\n" + " ())\n" + "\n" + " (signature bvec4\n" + " (parameters\n" + " (declare (in) bvec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function texture1D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) float coord))\n" + " ())\n" + ")\n" + "\n" + "(function texture1DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec2 coord))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec4 coord))\n" + " ())\n" + ")\n" + "\n" + "(function texture1DLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) float coord)\n" + " (declare (in) float lod))\n" + " ())\n" + ")\n" + "\n" + "(function texture1DProjLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec2 coord)\n" + " (declare (in) float lod))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec4 coord)\n" + " (declare (in) float lod))\n" + " ())\n" + ")\n" + "\n" + "(function texture2D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec2 coord))\n" + " ())\n" + ")\n" + "\n" + "(function texture2DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec3 coord))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec4 coord))\n" + " ())\n" + ")\n" + "\n" + "(function texture2DLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec2 coord)\n" + " (declare (in) float lod))\n" + " ())\n" + ")\n" + "\n" + "(function texture2DProjLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec3 coord)\n" + " (declare (in) float lod))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec4 coord)\n" + " (declare (in) float lod))\n" + " ())\n" + ")\n" + "\n" + "(function texture3D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec3 coord))\n" + " ())\n" + ")\n" + "\n" + "(function texture3DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec4 coord))\n" + " ())\n" + ")\n" + "\n" + "(function texture3DLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec3 coord)\n" + " (declare (in) float lod))\n" + " ())\n" + ")\n" + "\n" + "(function texture3DProjLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec4 coord)\n" + " (declare (in) float lod))\n" + " ())\n" + ")\n" + "\n" + "(function textureCube\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) samplerCube sampler)\n" + " (declare (in) vec3 coord))\n" + " ())\n" + ")\n" + "\n" + "(function textureCubeLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) samplerCube sampler)\n" + " (declare (in) vec3 coord)\n" + " (declare (in) float lod))\n" + " ())\n" + ")\n" + "\n" + "(function shadow1D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DShadow sampler)\n" + " (declare (in) vec3 coord))\n" + " ())\n" + ")\n" + "\n" + "(function shadow2D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DShadow sampler)\n" + " (declare (in) vec3 coord))\n" + " ())\n" + ")\n" + "\n" + "(function shadow1DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DShadow sampler)\n" + " (declare (in) vec4 coord))\n" + " ())\n" + ")\n" + "\n" + "(function shadow2DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DShadow sampler)\n" + " (declare (in) vec4 coord))\n" + " ())\n" + ")\n" + "\n" + "(function shadow1DLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DShadow sampler)\n" + " (declare (in) vec3 coord)\n" + " (declare (in) float lod))\n" + " ())\n" + ")\n" + "\n" + "(function shadow2DLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DShadow sampler)\n" + " (declare (in) vec3 coord)\n" + " (declare (in) float lod))\n" + " ())\n" + ")\n" + "\n" + "(function shadow1DProjLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DShadow sampler)\n" + " (declare (in) vec4 coord)\n" + " (declare (in) float lod))\n" + " ())\n" + ")\n" + "\n" + "(function shadow2DProjLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DShadow sampler)\n" + " (declare (in) vec4 coord)\n" + " (declare (in) float lod))\n" + " ())\n" + ")\n" + "\n" + "(function noise1\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature float\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function noise2\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function noise3\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + "(function noise4\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) float x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec2 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec3 x))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 x))\n" + " ())\n" + ")\n" + "\n" + ")" +; +static const char *functions_for_120_vert [] = { + builtin_abs, + builtin_acos, + builtin_all, + builtin_any, + builtin_asin, + builtin_atan, + builtin_ceil, + builtin_clamp, + builtin_cos, + builtin_cross, + builtin_degrees, + builtin_distance, + builtin_dot, + builtin_equal, + builtin_exp, + builtin_exp2, + builtin_faceforward, + builtin_floor, + builtin_fract, + builtin_ftransform, + builtin_greaterThan, + builtin_greaterThanEqual, + builtin_inversesqrt, + builtin_length, + builtin_lessThan, + builtin_lessThanEqual, + builtin_log, + builtin_log2, + builtin_matrixCompMult, + builtin_max, + builtin_min, + builtin_mix, + builtin_mod, + builtin_noise1, + builtin_noise2, + builtin_noise3, + builtin_noise4, + builtin_normalize, + builtin_not, + builtin_notEqual, + builtin_outerProduct, + builtin_pow, + builtin_radians, + builtin_reflect, + builtin_refract, + builtin_shadow1D, + builtin_shadow1DLod, + builtin_shadow1DProj, + builtin_shadow1DProjLod, + builtin_shadow2D, + builtin_shadow2DLod, + builtin_shadow2DProj, + builtin_shadow2DProjLod, + builtin_sign, + builtin_sin, + builtin_smoothstep, + builtin_sqrt, + builtin_step, + builtin_tan, + builtin_texture1D, + builtin_texture1DLod, + builtin_texture1DProj, + builtin_texture1DProjLod, + builtin_texture2D, + builtin_texture2DLod, + builtin_texture2DProj, + builtin_texture2DProjLod, + builtin_texture3D, + builtin_texture3DLod, + builtin_texture3DProj, + builtin_texture3DProjLod, + builtin_textureCube, + builtin_textureCubeLod, + builtin_transpose, +}; +static const char prototypes_for_130_frag[] = +{' ','(',' ','(','f','u','n','c','t','i','o','n',' ','r','a','d','i','a','n','s',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','e','g','r','e','e','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','e','g','r','e','e','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','d','e','g','r','e','e','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r', +'e',' ','(','i','n',')',' ','v','e','c','4',' ','d','e','g','r','e','e','s',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','d','e','g','r','e','e','s',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','r','a','d','i','a','n','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','r','a','d','i','a','n','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','r','a','d','i','a','n','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c', +'4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','r','a','d','i','a','n','s',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','s','i','n',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','a','n','g','l','e',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','a','n','g','l','e',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','a','n','g','l','e',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a' +,'t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','a','n','g','l','e',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','c','o','s',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','a','n','g','l','e',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','a','n','g','l','e',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','a','n','g','l','e',')','\n',')',' ','(','\n',')',')', +' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','a','n','g','l','e',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','t','a','n',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','a','n','g','l','e',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','a','n','g','l','e',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','a','n' +,'g','l','e',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','a','n','g','l','e',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','a','s','i','n',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','a','n','g','l','e',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','a','n','g','l','e',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ' +,'v','e','c','3',' ','a','n','g','l','e',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','a','n','g','l','e',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','a','c','o','s',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','a','n','g','l','e',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','a','n','g','l','e',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c', +'l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','a','n','g','l','e',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','a','n','g','l','e',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','a','t','a','n',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ' +,'x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','y','_','o','v','e','r','_','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r' +,'s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','y','_','o','v','e','r','_','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','y','_','o','v','e','r','_','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','y','_','o','v','e','r','_','x',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','s','i','n','h',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e' +,'c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','c','o','s','h',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t' +,'e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','t','a','n','h',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r' +,'e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','a','s','i','n','h',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ' +,'x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','a','c','o','s','h',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n', +'a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','a','t','a','n','h',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c' +,'3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','p','o','w',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i' +,'n',')',' ','v','e','c','2',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','y',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','e','x','p',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e' +,'c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','l','o','g',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e' +,'r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','e','x','p','2',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e', +' ','(','i','n',')',' ','v','e','c','2',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','l','o','g','2',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')','\n',')', +' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','s','q','r','t',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u', +'r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','i','n','v','e','r','s','e','s','q','r','t',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ' +,'v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','a','b','s',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e' +,'t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','n','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','x',')','\n',')',' ','(','\n',')',')',' ','(' +,'s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','4',' ','x',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','s','i','g','n',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u', +'r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','n','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l', +'a','r','e',' ','(','i','n',')',' ','i','v','e','c','4',' ','x',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','f','l','o','o','r',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v', +'e','c','4',' ','x',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','t','r','u','n','c',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')','\n',')',' ','(','\n',')',')',' ',')',' ','(', +'f','u','n','c','t','i','o','n',' ','r','o','u','n','d',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ' +,'r','o','u','n','d','E','v','e','n',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','c','e','i','l',' ','(' +,'s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','f','r','a','c','t',' ','(','s','i','g','n','a','t','u','r', +'e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','m','o','d',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r', +'a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i' +,'n',')',' ','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v', +'e','c','4',' ','y',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','m','o','d','f',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','o','u','t',')',' ','f','l','o','a','t',' ','i',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','o','u','t',')',' ','v','e','c','2',' ','i',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','o','u','t',')',' ','v', +'e','c','3',' ','i',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','o','u','t',')',' ','v','e','c','4',' ','i',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','m','i','n',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ' +,'y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p' +,'a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','n','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ', +'i','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','4',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','x',')',' ','(','d','e','c','l' +,'a','r','e',' ','(','i','n',')',' ','i','n','t',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','i','n','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','i','n','t',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','i','n','t',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n', +'a','t','u','r','e',' ','u','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','2',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','3',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','4',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','2',' ','(' +,'p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','i','n','t',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','i','n','t',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','i','n','t',' ','y',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','m','a','x',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p', +'a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i' +,'n',')',' ','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ', +'f','l','o','a','t',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','n','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u', +'r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','4',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t' +,'e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','i','n','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','i','n','t',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','i','n','t',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','2',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v', +'e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','3',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','4',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','i','n','t',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e', +' ','(','i','n',')',' ','u','i','n','t',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','i','n','t',' ','y',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','c','l','a','m','p',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','m','i','n','V','a','l',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','m','a','x','V','a','l',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t' +,'e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','m','i','n','V','a','l',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','m','a','x','V','a','l',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','m','i','n','V','a','l',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','m','a','x','V','a','l',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(' +,'i','n',')',' ','v','e','c','4',' ','m','i','n','V','a','l',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','m','a','x','V','a','l',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','m','i','n','V','a','l',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','m','a','x','V','a','l',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','m','i','n','V','a','l',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ', +'f','l','o','a','t',' ','m','a','x','V','a','l',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','m','i','n','V','a','l',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','m','a','x','V','a','l',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','n','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','m','i','n','V','a','l',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','m','a','x','V','a','l',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','2', +' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','m','i','n','V','a','l',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','m','a','x','V','a','l',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','m','i','n','V','a','l',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','m','a','x','V','a','l',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(', +'i','n',')',' ','i','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','4',' ','m','i','n','V','a','l',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','4',' ','m','a','x','V','a','l',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','m','i','n','V','a','l',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','m','a','x','V','a','l',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ' +,'m','i','n','V','a','l',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','m','a','x','V','a','l',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','m','i','n','V','a','l',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','m','a','x','V','a','l',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','i','n','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','i','n','t',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','i','n','t',' ','m','i','n','V','a','l',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','i','n','t',' ','m','a','x','V','a','l',')','\n',')', +' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','2',' ','m','i','n','V','a','l',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','2',' ','m','a','x','V','a','l',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','3',' ','m','i','n','V','a','l',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','3',' ','m','a','x','V','a','l',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a' +,'r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','4',' ','m','i','n','V','a','l',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','4',' ','m','a','x','V','a','l',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','i','n','t',' ','m','i','n','V','a','l',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','i','n','t',' ','m','a','x','V','a','l',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v', +'e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','i','n','t',' ','m','i','n','V','a','l',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','i','n','t',' ','m','a','x','V','a','l',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','i','n','t',' ','m','i','n','V','a','l',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','i','n','t',' ','m','a','x','V','a','l',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','m','i','x',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','x',')',' ','(','d','e','c','l','a', +'r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','a',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','a',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','a',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p', +'a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','a',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','a',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','y',')',' ','(','d','e','c','l', +'a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','a',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','a',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','s','t','e','p',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','e','d','g','e',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e', +'c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','e','d','g','e',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','e','d','g','e',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','e','d','g','e',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o' +,'a','t',' ','e','d','g','e',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','e','d','g','e',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','e','d','g','e',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','s','m','o','o','t','h','s','t','e','p',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(', +'d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','e','d','g','e','0',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','e','d','g','e','1',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','e','d','g','e','0',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','e','d','g','e','1',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','e','d','g','e','0',')',' ','(','d','e','c','l','a','r','e',' ','(', +'i','n',')',' ','v','e','c','3',' ','e','d','g','e','1',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','e','d','g','e','0',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','e','d','g','e','1',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','e','d','g','e','0',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','e','d','g','e','1',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')','\n',')', +' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','e','d','g','e','0',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','e','d','g','e','1',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','e','d','g','e','0',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','e','d','g','e','1',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','l','e','n','g','t','h',' ','(','s','i','g','n','a','t','u','r','e',' ' +,'f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','d','i','s','t','a','n','c','e',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l', +'o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','p','0',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','p','1',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','p','0',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','p','1',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','p','0',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','p','1',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m', +'e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','p','0',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','p','1',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','d','o','t',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m', +'e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','y',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','c','r','o','s','s',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','y',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','n','o','r','m','a','l','i','z','e',' ','(','s','i','g','n','a' +,'t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','f','a','c','e','f','o','r','w','a','r','d',' ','(','s','i','g','n','a','t','u', +'r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','N',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','I',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','N','r','e','f',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','N',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','I',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','N','r','e','f',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','N',')',' ','(','d','e','c', +'l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','I',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','N','r','e','f',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','N',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','I',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','N','r','e','f',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','r','e','f','l','e','c','t',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','I',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','N',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t' +,'u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','I',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','N',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','I',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','N',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','I',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','N',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','r','e','f','r','a','c','t',' ','(','s','i','g','n','a','t','u','r','e',' ' +,'f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','I',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','N',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','e','t','a',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','I',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','N',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','e','t','a',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','I',')',' ','(','d','e','c','l','a','r','e', +' ','(','i','n',')',' ','v','e','c','3',' ','N',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','e','t','a',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','I',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','N',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','e','t','a',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','m','a','t','r','i','x','C','o','m','p','M','u','l','t',' ','(','s','i','g','n','a','t','u','r','e',' ','m','a','t','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','m','a','t','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','m','a','t','2',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t' +,'u','r','e',' ','m','a','t','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','m','a','t','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','m','a','t','3',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','m','a','t','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','m','a','t','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','m','a','t','4',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','m','a','t','2','x','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','m','a','t','2','x','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','m','a','t','2','x','3',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','m','a','t','2','x','4',' ','(','p','a','r','a' +,'m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','m','a','t','2','x','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','m','a','t','2','x','4',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','m','a','t','3','x','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','m','a','t','3','x','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','m','a','t','3','x','2',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','m','a','t','3','x','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','m','a','t','3','x','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','m','a','t','3','x','4',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','m','a','t','4','x','2',' ','(','p','a','r','a','m','e' +,'t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','m','a','t','4','x','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','m','a','t','4','x','2',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','m','a','t','4','x','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','m','a','t','4','x','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','m','a','t','4','x','3',' ','y',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','o','u','t','e','r','P','r','o','d','u','c','t',' ','(','s','i','g','n','a','t','u','r','e',' ','m','a','t','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','c',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','r',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r', +'e',' ','m','a','t','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','c',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','r',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','m','a','t','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','c',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','r',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','m','a','t','2','x','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','c',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','r',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','m','a','t','3','x','2',' ','(','p','a','r','a','m','e','t','e','r','s', +' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','c',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','r',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','m','a','t','2','x','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','c',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','r',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','m','a','t','4','x','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','c',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','r',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','m','a','t','3','x','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c', +'4',' ','c',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','r',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','m','a','t','4','x','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','c',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','r',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','t','r','a','n','s','p','o','s','e',' ','(','s','i','g','n','a','t','u','r','e',' ','m','a','t','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','m','a','t','2',' ','m',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','m','a','t','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','m','a','t','3',' ','m',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ', +'m','a','t','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','m','a','t','4',' ','m',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','m','a','t','2','x','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','m','a','t','3','x','2',' ','m',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','m','a','t','3','x','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','m','a','t','2','x','3',' ','m',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','m','a','t','2','x','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','m','a','t','4','x','2',' ','m',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','m','a','t','4','x','2',' ','(','p','a','r','a','m','e', +'t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','m','a','t','2','x','4',' ','m',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','m','a','t','3','x','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','m','a','t','4','x','3',' ','m',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','m','a','t','4','x','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','m','a','t','3','x','4',' ','m',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','l','e','s','s','T','h','a','n',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','y',')','\n',')',' ','(','\n',')',')',' ','(', +'s','i','g','n','a','t','u','r','e',' ','b','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','3',' ','(' +,'p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','4',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','2',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(', +'d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','3',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','4',' ','y',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','l','e','s','s','T','h','a','n','E','q','u','a','l',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','3',' ','(','p' +,'a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a', +'r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','4',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','2',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','3',' ', +'x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','3',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','4',' ','y',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','g','r','e','a','t','e','r','T','h','a','n',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(', +'i','n',')',' ','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a', +'r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','4',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','2',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','3',' ', +'y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','4',' ','y',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','g','r','e','a','t','e','r','T','h','a','n','E','q','u','a','l',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')',' ','(','d','e','c','l' +,'a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','y',')','\n',')',' ','(', +'\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','4',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','2',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','3',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ' +,'b','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','4',' ','y',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','e','q','u','a','l',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ', +'b','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','4',' ','(','p','a','r','a','m','e','t', +'e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','4',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','2',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','3',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(' +,'i','n',')',' ','u','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','4',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','b','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','b','v','e','c','2',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','b','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','b','v','e','c','3',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','b','v','e','c','4',' ','x',')',' ','(','d', +'e','c','l','a','r','e',' ','(','i','n',')',' ','b','v','e','c','4',' ','y',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','n','o','t','E','q','u','a','l',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')', +' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i', +'v','e','c','4',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','2',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','3',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','4',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i', +'g','n','a','t','u','r','e',' ','b','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','b','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','b','v','e','c','2',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','b','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','b','v','e','c','3',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','b','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','b','v','e','c','4',' ','y',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','a','n','y',' ','(', +'s','i','g','n','a','t','u','r','e',' ','b','o','o','l',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','b','v','e','c','2',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','o','o','l',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','b','v','e','c','3',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','o','o','l',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','b','v','e','c','4',' ','x',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','a','l','l',' ','(','s','i','g','n','a','t','u','r','e',' ','b','o','o','l',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','b','v','e','c','2',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r', +'e',' ','b','o','o','l',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','b','v','e','c','3',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','o','o','l',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','b','v','e','c','4',' ','x',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','n','o','t',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','b','v','e','c','2',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','b','v','e','c','3',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','4', +' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','b','v','e','c','4',' ','x',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','t','e','x','t','u','r','e',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t' +,'u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r', +'e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e' +,'r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','C','u','b','e',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e', +'r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','C','u','b','e',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','C','u','b','e',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c', +'3',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','C','u','b','e','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s' +,'a','m','p','l','e','r','1','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','1','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','1','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g', +'n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','2','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','2','D','A','r', +'r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','A','r','r','a','y','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D','A','r','r','a','y','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g', +'n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p' +,'a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l', +'a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','3' +,'D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l' +,'a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','C','u','b','e',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','C','u','b','e',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ', +'P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','C','u','b','e',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l', +'a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','C','u','b','e','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a' +,'r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','1','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ' +,'f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','1','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t', +' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','2','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','2','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i', +'a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','A','r','r','a','y','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','t','e','x','t','u','r','e','P','r','o','j',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')','\n',')',' ','(','\n',')',')', +' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d' +,'e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s' +,'a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a', +'m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s' +,'i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e', +'c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e' +,'c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l' +,'e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c' +,'l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e' +,'c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t', +' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u', +'r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t' +,'e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')', +' ','s','a','m','p','l','e','r','1','D','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m', +'p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e', +'r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c', +'4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v' +,'e','c','2',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e', +'t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u' +,'r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r' +,'a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d', +'e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c' +,'l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i', +'g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')', +' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i' +,'n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')', +' ','i','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n' +,'a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s' +,'e','t',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r', +'e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','o','f','f','s','e','t',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','o','f','f','s','e','t',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c' +,'l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','o','f','f','s','e','t',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b', +'i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','t','e','x','t','u','r','e','L','o','d',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d' +,'e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a' +,'t',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a' +,'t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ' +,'i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(' +,'d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','C','u','b','e',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','C','u','b','e',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s' +,'a','m','p','l','e','r','C','u','b','e',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D','S' +,'h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','1','D','A','r','r','a','y',' ','s', +'a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','1','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(', +'d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','2','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','2','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a' +,'r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','A','r','r','a','y','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','t','e','x','t','u','r','e','O','f','f','s','e','t',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e', +'r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(' +,'d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e' +,'c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e', +' ','(','i','n',')',' ','i','v','e','c','3',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ', +'o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o' +,'f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','1','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')', +'\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','1','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(' +,'s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','2','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','2','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n', +')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','A','r','r','a','y','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')',' ','(','d','e','c','l','a' +,'r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o' +,'a','t',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a' +,'m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u', +'r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','o','f','f','s','e','t',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','o','f','f','s','e','t',')',' ','(', +'d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','o','f','f','s','e','t',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e' +,'c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t', +'e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','1','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')',' ','(','d','e','c','l','a','r','e',' ','(','i' +,'n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','1','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')', +' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','2','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d', +'e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','2','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','A','r','r','a','y','S','h','a','d','o','w',' ','s','a','m','p',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')',' ','(','d','e','c','l','a','r','e',' ','(', +'i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','t','e','x','e','l','F','e','t','c','h',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(', +'i','n',')',' ','i','n','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e', +' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d', +'e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','3' +,'D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','1','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(' +,'d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','1','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i', +'n',')',' ','i','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','2','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','2','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ' +,'P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','t','e','x','e','l','F','e','t','c','h','O','f','f','s','e','t',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','1' +,'D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d' +,'e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(', +'s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','l','o','d',')', +' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r', +'e',' ','(','i','n',')',' ','i','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r' +,'e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','1','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','1','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')','\n',')',' ','(', +'\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','2','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a' +,'r','e',' ','(','i','n',')',' ','i','n','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','2','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','t','e','x','t','u','r','e','L','o','d','O','f','f','s','e','t',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a' +,'m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f' +,'f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ', +'f','l','o','a','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','2','D',' ','s','a','m','p', +'l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e' +,'r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','o','f','f' +,'s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','S','h','a','d','o','w',' ','s','a','m','p',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D','S','h','a','d','o','w',' ','s','a','m','p',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r', +'e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','1','D' +,'A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','1','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v' +,'e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D','A','r','r','a','y',' ','s','a','m','p',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','2','D','A','r','r','a','y',' ','s','a','m','p',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')',' ','(','d','e','c','l' +,'a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','2','D','A','r','r','a','y',' ','s','a','m','p',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','A','r','r','a','y','S','h','a','d','o','w',' ','s',')',' ','(','d','e','c','l' +,'a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','t','e','x','t','u','r','e','P','r','o','j','L','o','d',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a', +'r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D',' ','s', +'a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i' +,'n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')', +' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a' +,'t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e' +,'t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u', +'s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D','S','h' +,'a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','t','e','x','t','u','r','e','P','r','o','j','L','o','d','O','f','f','s','e','t',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e', +' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r', +'e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e' +,'c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D',' ','s','a', +'m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a' +,'m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o' +,'f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r', +'e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','3','D',' ','s','a', +'m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a' +,'m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','S','h','a','d','o','w',' ','s',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D','S','h','a','d','o','w',' ','s',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f' +,'s','e','t',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','t','e','x','t','u','r','e','G','r','a','d',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r' +,'e',' ','(','i','n',')',' ','f','l','o','a','t',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r' +,'e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ' +,'u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ' +,'v','e','c','3',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r' +,'e',' ','(','i','n',')',' ','v','e','c','3',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','C','u','b','e',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','C','u','b','e',' ','s','a','m','p', +'l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','C','u','b','e',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s', +' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v', +'e','c','2',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','C','u','b','e','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c' +,'2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','1','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i', +'n',')',' ','u','s','a','m','p','l','e','r','1','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ','(','s' +,'i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','2','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','2','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i' +,'n',')',' ','v','e','c','2',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','A','r','r','a','y','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r', +'2','D','A','r','r','a','y','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','t','e','x','t','u','r','e','G','r','a','d','O','f','f','s','e','t',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D',' ','s',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l', +'o','a','t',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','1','D',' ','s',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','1','D',' ','s',')',' ','(','d' +,'e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D',' ','s',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i', +'g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','2','D',' ','s',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','2','D',' ','s',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c', +'2',' ','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','3','D',' ','s',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r' +,'e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','3','D',' ','s',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','3','D',' ','s',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i', +'n',')',' ','i','v','e','c','3',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','C','u','b','e',' ','s',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','C','u','b','e',' ','s',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')', +' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','C','u','b','e',' ','s',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r' +,'e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','S','h','a','d','o','w',' ','s',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D','S','h','a','d','o','w',' ','s',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e', +'c','2',' ','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','A','r','r','a','y',' ','s',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r' +,'e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','1','D','A','r','r','a','y',' ','s',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','1','D','A','r','r','a','y',' ','s',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','y',')',' ','(' +,'d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D','A','r','r','a','y',' ','s',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','2','D','A','r','r','a','y',' ','s',')',' ','(','d','e','c' +,'l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','2','D','A','r','r','a','y',' ','s',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n', +'a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','A','r','r','a','y','S','h','a','d','o','w',' ','s',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D','A','r','r','a','y','S','h','a','d','o','w',' ','s',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(', +'d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','t','e','x','t','u','r','e','P','r','o','j','G','r','a','d',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e', +' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','P','d','x',')',' ','(','d','e','c','l', +'a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ', +'P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e', +'r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a', +'m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','P','d','y',')','\n',')', +' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d' +,'P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ', +'v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l' +,'e','r','1','D','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t' +,'i','o','n',' ','t','e','x','t','u','r','e','P','r','o','j','G','r','a','d','O','f','f','s','e','t',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D',' ','s',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','1','D',' ','s',')',' ','(','d','e','c','l','a','r','e',' ','(' +,'i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','1','D',' ','s',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(' +,'p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D',' ','s',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','1','D',' ','s',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l', +'o','a','t',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','1','D',' ','s',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D',' ','s',')',' ','(','d','e','c','l','a','r','e', +' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','2','D',' ','s',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c' +,'4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','2','D',' ','s',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D',' ','s',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c' +,'2',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','2','D',' ','s',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','2','D',' ','s',')',' ','(','d','e','c','l','a' +,'r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','3','D',' ','s',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','o','f','f',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c' +,'4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','3','D',' ','s',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','o','f','f',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','3','D',' ','s',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v' +,'e','c','3',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','o','f','f',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','S','h','a','d','o','w',' ','s',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D','S','h','a' +,'d','o','w',' ','s',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','o',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','t','e','x','t','u','r','e','1','D',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','c','o','o','r','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a', +'r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','c','o','o','r','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','t','e','x','t','u','r','e','1','D','P','r','o','j',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','c','o','o','r','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ', +'s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','c','o','o','r','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','c','o','o','r','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e' +,'c','4',' ','c','o','o','r','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','t','e','x','t','u','r','e','1','D','L','o','d',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','c','o','o','r','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','t','e','x','t','u','r','e','1','D','P','r','o','j','L','o','d',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d' +,'e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','c','o','o','r','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','c','o','o','r','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','t','e','x','t','u','r','e','2','D',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a' +,'m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','c','o','o','r','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','c','o','o','r','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','t','e','x','t','u','r','e','2','D','P','r','o','j',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(' +,'d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','c','o','o','r','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','c','o','o','r','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','c','o','o','r','d',')',' ','(','d','e' +,'c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','c','o','o','r','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','t','e','x','t','u','r','e','2','D','L','o','d',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')', +' ','v','e','c','2',' ','c','o','o','r','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','t','e','x','t','u','r','e','2','D','P','r','o','j','L','o','d',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','c','o','o','r','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D',' ','s','a', +'m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','c','o','o','r','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','t','e','x','t','u','r','e','3','D',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','c','o','o','r','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r' +,'e',' ','(','i','n',')',' ','v','e','c','3',' ','c','o','o','r','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','t','e','x','t','u','r','e','3','D','P','r','o','j',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','c','o','o','r','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e', +'c','4',' ','c','o','o','r','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','t','e','x','t','u','r','e','3','D','L','o','d',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','c','o','o','r','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','t','e','x','t','u','r','e','3','D','P','r','o','j','L','o','d',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e' +,'c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','c','o','o','r','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','t','e','x','t','u','r','e','C','u','b','e',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','C','u','b','e',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','c','o','o','r','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')', +' ','s','a','m','p','l','e','r','C','u','b','e',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','c','o','o','r','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','t','e','x','t','u','r','e','C','u','b','e','L','o','d',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','C','u','b','e',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','c','o','o','r','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','s','h','a','d','o','w','1', +'D',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','c','o','o','r','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','c','o','o','r','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','s','h','a','d','o','w', +'2','D',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','c','o','o','r','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','c','o','o','r','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','s','h','a','d','o', +'w','1','D','P','r','o','j',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','c','o','o','r','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','c','o','o','r','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ', +'s','h','a','d','o','w','2','D','P','r','o','j',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','c','o','o','r','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','c','o','o','r','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c' +,'t','i','o','n',' ','s','h','a','d','o','w','1','D','L','o','d',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','c','o','o','r','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','s','h','a','d','o','w','2','D','L','o','d',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l' +,'a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','c','o','o','r','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','s','h','a','d','o','w','1','D','P','r','o','j','L','o','d',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','c','o','o','r','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','s','h','a','d','o','w','2','D','P','r','o','j','L','o','d',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e' +,'c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','c','o','o','r','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','d','F','d','x',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','p',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','p',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r' +,'e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','p',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','p',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','d','F','d','y',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','p',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','p',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r', +'a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','p',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','p',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','f','w','i','d','t','h',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','p',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','p',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(' +,'d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','p',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','p',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','n','o','i','s','e','1',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a', +'r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','n','o','i','s','e','2',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e', +'c','3',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','n','o','i','s','e','3',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i' +,'g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','n','o','i','s','e','4',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v' +,'e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')','\n',')',' ','(','\n',')',')',' ',')',' ',')'} ; +static const char *functions_for_130_frag [] = { + builtin_abs, + builtin_acos, + builtin_acosh, + builtin_all, + builtin_any, + builtin_asin, + builtin_asinh, + builtin_atan, + builtin_atanh, + builtin_ceil, + builtin_clamp, + builtin_cos, + builtin_cosh, + builtin_cross, + builtin_dFdx, + builtin_dFdy, + builtin_degrees, + builtin_distance, + builtin_dot, + builtin_equal, + builtin_exp, + builtin_exp2, + builtin_faceforward, + builtin_floor, + builtin_fract, + builtin_fwidth, + builtin_greaterThan, + builtin_greaterThanEqual, + builtin_inversesqrt, + builtin_length, + builtin_lessThan, + builtin_lessThanEqual, + builtin_log, + builtin_log2, + builtin_matrixCompMult, + builtin_max, + builtin_min, + builtin_mix, + builtin_mod, + builtin_modf, + builtin_noise1, + builtin_noise2, + builtin_noise3, + builtin_noise4, + builtin_normalize, + builtin_not, + builtin_notEqual, + builtin_outerProduct, + builtin_pow, + builtin_radians, + builtin_reflect, + builtin_refract, + builtin_round, + builtin_roundEven, + builtin_shadow1D, + builtin_shadow1DLod, + builtin_shadow1DProj, + builtin_shadow1DProjLod, + builtin_shadow2D, + builtin_shadow2DLod, + builtin_shadow2DProj, + builtin_shadow2DProjLod, + builtin_sign, + builtin_sin, + builtin_sinh, + builtin_smoothstep, + builtin_sqrt, + builtin_step, + builtin_tan, + builtin_tanh, + builtin_texelFetch, + builtin_texelFetchOffset, + builtin_texture, + builtin_texture1D, + builtin_texture1DLod, + builtin_texture1DProj, + builtin_texture1DProjLod, + builtin_texture2D, + builtin_texture2DLod, + builtin_texture2DProj, + builtin_texture2DProjLod, + builtin_texture3D, + builtin_texture3DLod, + builtin_texture3DProj, + builtin_texture3DProjLod, + builtin_textureCube, + builtin_textureCubeLod, + builtin_textureGrad, + builtin_textureGradOffset, + builtin_textureLod, + builtin_textureLodOffset, + builtin_textureOffset, + builtin_textureProj, + builtin_textureProjGrad, + builtin_textureProjGradOffset, + builtin_textureProjLod, + builtin_textureProjLodOffset, + builtin_transpose, + builtin_trunc, +}; +static const char prototypes_for_130_vert[] = +{' ','(',' ','(','f','u','n','c','t','i','o','n',' ','r','a','d','i','a','n','s',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','e','g','r','e','e','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','e','g','r','e','e','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','d','e','g','r','e','e','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r', +'e',' ','(','i','n',')',' ','v','e','c','4',' ','d','e','g','r','e','e','s',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','d','e','g','r','e','e','s',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','r','a','d','i','a','n','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','r','a','d','i','a','n','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','r','a','d','i','a','n','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c', +'4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','r','a','d','i','a','n','s',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','s','i','n',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','a','n','g','l','e',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','a','n','g','l','e',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','a','n','g','l','e',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a' +,'t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','a','n','g','l','e',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','c','o','s',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','a','n','g','l','e',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','a','n','g','l','e',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','a','n','g','l','e',')','\n',')',' ','(','\n',')',')', +' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','a','n','g','l','e',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','t','a','n',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','a','n','g','l','e',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','a','n','g','l','e',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','a','n' +,'g','l','e',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','a','n','g','l','e',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','a','s','i','n',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','a','n','g','l','e',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','a','n','g','l','e',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ' +,'v','e','c','3',' ','a','n','g','l','e',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','a','n','g','l','e',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','a','c','o','s',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','a','n','g','l','e',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','a','n','g','l','e',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c', +'l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','a','n','g','l','e',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','a','n','g','l','e',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','a','t','a','n',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ' +,'x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','y','_','o','v','e','r','_','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r' +,'s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','y','_','o','v','e','r','_','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','y','_','o','v','e','r','_','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','y','_','o','v','e','r','_','x',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','s','i','n','h',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e' +,'c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','c','o','s','h',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t' +,'e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','t','a','n','h',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r' +,'e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','a','s','i','n','h',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ' +,'x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','a','c','o','s','h',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n', +'a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','a','t','a','n','h',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c' +,'3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','p','o','w',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i' +,'n',')',' ','v','e','c','2',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','y',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','e','x','p',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e' +,'c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','l','o','g',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e' +,'r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','e','x','p','2',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e', +' ','(','i','n',')',' ','v','e','c','2',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','l','o','g','2',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')','\n',')', +' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','s','q','r','t',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u', +'r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','i','n','v','e','r','s','e','s','q','r','t',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ' +,'v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','a','b','s',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e' +,'t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','n','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','x',')','\n',')',' ','(','\n',')',')',' ','(' +,'s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','4',' ','x',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','s','i','g','n',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u', +'r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','n','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l', +'a','r','e',' ','(','i','n',')',' ','i','v','e','c','4',' ','x',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','f','l','o','o','r',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v', +'e','c','4',' ','x',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','t','r','u','n','c',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')','\n',')',' ','(','\n',')',')',' ',')',' ','(', +'f','u','n','c','t','i','o','n',' ','r','o','u','n','d',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ' +,'r','o','u','n','d','E','v','e','n',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','c','e','i','l',' ','(' +,'s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','f','r','a','c','t',' ','(','s','i','g','n','a','t','u','r', +'e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','m','o','d',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r', +'a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i' +,'n',')',' ','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v', +'e','c','4',' ','y',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','m','o','d','f',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','o','u','t',')',' ','f','l','o','a','t',' ','i',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','o','u','t',')',' ','v','e','c','2',' ','i',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','o','u','t',')',' ','v', +'e','c','3',' ','i',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','o','u','t',')',' ','v','e','c','4',' ','i',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','m','i','n',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ' +,'y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p' +,'a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','n','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ', +'i','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','4',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','x',')',' ','(','d','e','c','l' +,'a','r','e',' ','(','i','n',')',' ','i','n','t',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','i','n','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','i','n','t',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','i','n','t',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n', +'a','t','u','r','e',' ','u','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','2',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','3',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','4',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','2',' ','(' +,'p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','i','n','t',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','i','n','t',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','i','n','t',' ','y',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','m','a','x',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p', +'a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i' +,'n',')',' ','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ', +'f','l','o','a','t',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','n','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u', +'r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','4',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t' +,'e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','i','n','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','i','n','t',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','i','n','t',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','2',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v', +'e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','3',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','4',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','i','n','t',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e', +' ','(','i','n',')',' ','u','i','n','t',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','i','n','t',' ','y',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','c','l','a','m','p',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','m','i','n','V','a','l',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','m','a','x','V','a','l',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t' +,'e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','m','i','n','V','a','l',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','m','a','x','V','a','l',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','m','i','n','V','a','l',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','m','a','x','V','a','l',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(' +,'i','n',')',' ','v','e','c','4',' ','m','i','n','V','a','l',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','m','a','x','V','a','l',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','m','i','n','V','a','l',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','m','a','x','V','a','l',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','m','i','n','V','a','l',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ', +'f','l','o','a','t',' ','m','a','x','V','a','l',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','m','i','n','V','a','l',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','m','a','x','V','a','l',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','n','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','m','i','n','V','a','l',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','m','a','x','V','a','l',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','2', +' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','m','i','n','V','a','l',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','m','a','x','V','a','l',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','m','i','n','V','a','l',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','m','a','x','V','a','l',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(', +'i','n',')',' ','i','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','4',' ','m','i','n','V','a','l',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','4',' ','m','a','x','V','a','l',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','m','i','n','V','a','l',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','m','a','x','V','a','l',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ' +,'m','i','n','V','a','l',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','m','a','x','V','a','l',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','m','i','n','V','a','l',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','m','a','x','V','a','l',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','i','n','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','i','n','t',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','i','n','t',' ','m','i','n','V','a','l',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','i','n','t',' ','m','a','x','V','a','l',')','\n',')', +' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','2',' ','m','i','n','V','a','l',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','2',' ','m','a','x','V','a','l',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','3',' ','m','i','n','V','a','l',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','3',' ','m','a','x','V','a','l',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a' +,'r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','4',' ','m','i','n','V','a','l',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','4',' ','m','a','x','V','a','l',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','i','n','t',' ','m','i','n','V','a','l',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','i','n','t',' ','m','a','x','V','a','l',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v', +'e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','i','n','t',' ','m','i','n','V','a','l',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','i','n','t',' ','m','a','x','V','a','l',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','i','n','t',' ','m','i','n','V','a','l',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','i','n','t',' ','m','a','x','V','a','l',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','m','i','x',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','x',')',' ','(','d','e','c','l','a', +'r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','a',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','a',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','a',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p', +'a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','a',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','a',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','y',')',' ','(','d','e','c','l', +'a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','a',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','a',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','s','t','e','p',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','e','d','g','e',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e', +'c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','e','d','g','e',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','e','d','g','e',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','e','d','g','e',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o' +,'a','t',' ','e','d','g','e',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','e','d','g','e',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','e','d','g','e',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','s','m','o','o','t','h','s','t','e','p',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(', +'d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','e','d','g','e','0',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','e','d','g','e','1',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','e','d','g','e','0',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','e','d','g','e','1',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','e','d','g','e','0',')',' ','(','d','e','c','l','a','r','e',' ','(', +'i','n',')',' ','v','e','c','3',' ','e','d','g','e','1',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','e','d','g','e','0',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','e','d','g','e','1',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','e','d','g','e','0',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','e','d','g','e','1',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')','\n',')', +' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','e','d','g','e','0',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','e','d','g','e','1',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','e','d','g','e','0',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','e','d','g','e','1',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','l','e','n','g','t','h',' ','(','s','i','g','n','a','t','u','r','e',' ' +,'f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','d','i','s','t','a','n','c','e',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l', +'o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','p','0',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','p','1',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','p','0',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','p','1',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','p','0',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','p','1',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m', +'e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','p','0',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','p','1',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','d','o','t',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m', +'e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','y',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','c','r','o','s','s',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','y',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','n','o','r','m','a','l','i','z','e',' ','(','s','i','g','n','a' +,'t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','f','t','r','a','n','s','f','o','r','m',' ','(','s','i','g','n','a','t','u','r', +'e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','f','a','c','e','f','o','r','w','a','r','d',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','N',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','I',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','N','r','e','f',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','N',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','I',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','N','r','e','f',')','\n', +')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','N',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','I',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','N','r','e','f',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','N',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','I',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','N','r','e','f',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','r','e','f','l','e','c','t',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e', +'t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','I',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','N',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','I',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','N',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','I',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','N',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c', +'4',' ','I',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','N',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','r','e','f','r','a','c','t',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','I',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','N',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','e','t','a',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','I',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','N',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','e','t','a',')','\n',')',' ','(','\n',')',')',' ','(' +,'s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','I',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','N',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','e','t','a',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','I',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','N',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','e','t','a',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','m','a','t','r','i','x','C','o','m','p','M','u','l','t',' ','(','s','i','g','n','a','t','u','r','e',' ','m','a','t','2',' ','(','p','a','r', +'a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','m','a','t','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','m','a','t','2',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','m','a','t','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','m','a','t','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','m','a','t','3',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','m','a','t','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','m','a','t','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','m','a','t','4',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','m','a','t','2','x','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ', +'m','a','t','2','x','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','m','a','t','2','x','3',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','m','a','t','2','x','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','m','a','t','2','x','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','m','a','t','2','x','4',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','m','a','t','3','x','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','m','a','t','3','x','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','m','a','t','3','x','2',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','m','a','t','3','x','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','m','a' +,'t','3','x','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','m','a','t','3','x','4',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','m','a','t','4','x','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','m','a','t','4','x','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','m','a','t','4','x','2',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','m','a','t','4','x','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','m','a','t','4','x','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','m','a','t','4','x','3',' ','y',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','o','u','t','e','r','P','r','o','d','u','c','t',' ','(','s','i','g','n','a','t','u','r','e',' ','m','a','t','2',' ','(','p','a','r','a','m' +,'e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','c',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','r',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','m','a','t','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','c',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','r',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','m','a','t','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','c',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','r',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','m','a','t','2','x','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e', +'c','3',' ','c',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','r',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','m','a','t','3','x','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','c',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','r',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','m','a','t','2','x','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','c',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','r',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','m','a','t','4','x','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','c',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ' +,'v','e','c','4',' ','r',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','m','a','t','3','x','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','c',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','r',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','m','a','t','4','x','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','c',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','r',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','t','r','a','n','s','p','o','s','e',' ','(','s','i','g','n','a','t','u','r','e',' ','m','a','t','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','m','a','t','2',' ','m',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a' +,'t','u','r','e',' ','m','a','t','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','m','a','t','3',' ','m',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','m','a','t','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','m','a','t','4',' ','m',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','m','a','t','2','x','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','m','a','t','3','x','2',' ','m',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','m','a','t','3','x','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','m','a','t','2','x','3',' ','m',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','m','a','t','2','x','4',' ','(','p','a','r','a','m','e' +,'t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','m','a','t','4','x','2',' ','m',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','m','a','t','4','x','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','m','a','t','2','x','4',' ','m',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','m','a','t','3','x','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','m','a','t','4','x','3',' ','m',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','m','a','t','4','x','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','m','a','t','3','x','4',' ','m',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','l','e','s','s','T','h','a','n',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c' +,'2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a' +,'r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','4',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','2',' ', +'x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','2',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','3',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','4',' ','y',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','l','e','s','s','T','h','a','n','E','q','u','a','l',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l' +,'a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','x',')',' ','(','d','e','c','l' +,'a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','4',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','2', +' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','3',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','4',' ','y',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','g','r','e','a','t','e','r','T','h','a','n',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r', +'e',' ','(','i','n',')',' ','v','e','c','2',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i', +'g','n','a','t','u','r','e',' ','b','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','4',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','2',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e', +'c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','3',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','4',' ','y',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','g','r','e','a','t','e','r','T','h','a','n','E','q','u','a','l',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','y',')','\n',')',' ','(','\n',')',')',' ','(' +,'s','i','g','n','a','t','u','r','e',' ','b','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','3',' ','(' +,'p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','4',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','2',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(', +'d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','3',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','4',' ','y',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','e','q','u','a','l',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r' +,'s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e', +'c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','4',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','2',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e', +' ','(','i','n',')',' ','u','v','e','c','3',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','4',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','b','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','b','v','e','c','2',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','b','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','b','v','e','c','3',' ','y',')','\n',')',' ','(', +'\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','b','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','b','v','e','c','4',' ','y',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','n','o','t','E','q','u','a','l',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ' +,'y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e', +' ','b','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','4',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','2',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','3',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','4',' ','(','p','a','r','a','m' +,'e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','v','e','c','4',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','b','v','e','c','2',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','b','v','e','c','2',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','b','v','e','c','3',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','b','v','e','c','3',' ','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a', +'r','e',' ','(','i','n',')',' ','b','v','e','c','4',' ','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','b','v','e','c','4',' ','y',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','a','n','y',' ','(','s','i','g','n','a','t','u','r','e',' ','b','o','o','l',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','b','v','e','c','2',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','o','o','l',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','b','v','e','c','3',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','o','o','l',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','b','v','e','c','4',' ','x',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','a','l','l',' ','(','s','i','g','n','a','t','u','r', +'e',' ','b','o','o','l',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','b','v','e','c','2',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','o','o','l',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','b','v','e','c','3',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','o','o','l',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','b','v','e','c','4',' ','x',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','n','o','t',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','b','v','e','c','2',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','3',' ','(', +'p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','b','v','e','c','3',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','b','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','b','v','e','c','4',' ','x',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','t','e','x','t','u','r','e',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i', +'n',')',' ','i','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(' +,'p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')','\n',')', +' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','C','u','b','e',' ','s','a','m','p','l' +,'e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','C','u','b','e',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','C','u','b','e',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e', +'c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','C','u','b','e','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ' +,'v','e','c','4',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','1','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u' +,'s','a','m','p','l','e','r','1','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','2','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n', +'a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','2','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','A','r','r','a','y','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e', +'r','2','D','A','r','r','a','y','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l' +,'o','a','t',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i', +'n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n' +,')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c' +,'4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','C','u','b','e',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d' +,'e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','C','u','b','e',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','C','u','b','e',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ' +,'s','a','m','p','l','e','r','1','D','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m' +,'p','l','e','r','C','u','b','e','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l' +,'e','r','1','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','1','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D','A' +,'r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','2','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','2','D','A','r','r','a' +,'y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','A','r','r','a','y','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','t','e','x','t','u','r','e','P','r','o','j',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e', +'c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ' +,'v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v' +,'e','c','4',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','2','D',' ','s', +'a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l', +'a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e' +,'c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e' +,'c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(', +'\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c' +,'4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e' +,'c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l' +,'e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c' +,'l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e' +,'c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t', +' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i', +'a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ', +'u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r', +'s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a', +'m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','2','D',' ','s', +'a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l', +'a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ', +'P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(' +,'i','n',')',' ','i','v','e','c','3',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i' +,'n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d', +'e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D', +' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r', +'a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o', +'a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l' +,'a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','2' +,'D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4', +' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','o','f','f','s','e','t',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','o','f','f','s','e','t',')',' ','(','d','e','c','l','a','r','e', +' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','o','f','f','s','e','t',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i', +'n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','t','e','x','t','u','r','e','L','o','d',' ','(','s','i','g','n','a','t','u','r', +'e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e' +,'r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a', +'m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e' +,'c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d' +,'e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','C','u','b','e',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','C','u','b','e',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a' +,'t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','C','u','b','e',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(', +'s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u' +,'r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','1','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','1','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e', +'c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','2','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r', +'a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','2','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','A','r','r','a','y','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','t','e','x','t','u','r','e','O','f' +,'f','s','e','t',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r', +'e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m' +,'e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l', +'a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m' +,'p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D','S' +,'h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','1','D','A','r','r' +,'a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','1','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D','A','r','r','a','y',' ','s','a', +'m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','2','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','2','D','A','r','r','a','y',' ','s' +,'a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','A','r','r','a','y','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D',' ','s','a','m','p' +,'l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e' +,'t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ' +,'b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r', +'e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','o','f','f','s','e','t',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','3','D',' ', +'s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','o','f','f','s','e','t',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','o','f','f','s','e','t',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(' +,'p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e' +,'t',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','1','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')', +' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','1','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t' +,'e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','2','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')',' ','(','d','e','c','l', +'a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','2','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','A','r','r','a','y','S','h','a','d','o','w',' ','s','a','m', +'p',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','t','e','x','e','l','F','e','t','c','h',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r' +,'e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d' +,'e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','P',')',' ','(','d' +,'e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(', +'s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c', +'4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','1','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','1','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e', +'t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','2','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c', +'l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','2','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','t','e','x','e','l','F','e','t','c','h','O','f','f','s','e','t',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n', +')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','l','o','d',')',' ','(','d','e' +,'c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e' +,'c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l' +,'e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4', +' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i', +'n',')',' ','i','n','t',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','1','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','1','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')', +' ','i','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')', +' ','i','s','a','m','p','l','e','r','2','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','2','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')','\n',')', +' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','t','e','x','t','u','r','e','L','o','d','O','f','f','s','e','t',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r' +,'e',' ','(','i','n',')',' ','f','l','o','a','t',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(', +'i','n',')',' ','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a' +,'t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')',' ','(','d','e', +'c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(', +'i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','S','h','a','d','o','w',' ','s','a','m','p',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r', +'e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D','S','h','a','d','o','w',' ','s','a','m','p',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')', +' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','1','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','1','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r' +,'e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D','A','r','r','a','y',' ','s','a','m','p',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','2','D','A','r','r' +,'a','y',' ','s','a','m','p',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','2','D','A','r','r','a','y',' ','s','a','m','p',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(', +'p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','A','r','r','a','y','S','h','a','d','o','w',' ','s',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','t','e','x','t','u','r','e','P','r','o','j','L','o','d',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r' +,'e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')', +' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p', +'a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(' +,'i','n',')',' ','i','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D',' ','s','a','m','p' +,'l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v', +'e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l' +,'o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(', +'s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','t','e','x','t','u','r','e','P','r','o','j','L','o','d','O','f','f','s','e','t',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l' +,'a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','1','D',' ','s','a', +'m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s', +' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(' +,'s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l' +,'o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a', +'r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l' +,'a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i', +'g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l' +,'o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','S','h','a','d','o','w',' ','s',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D','S','h','a','d','o','w',' ','s',')',' ','(','d','e','c','l','a','r','e',' ','(' +,'i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','t','e','x','t','u','r','e','G','r','a','d',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c' +,'4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e', +' ','(','i','n',')',' ','f','l','o','a','t',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l' +,'a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e', +'r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c', +'l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','C','u','b','e',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a', +'t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','C','u','b','e',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','C','u','b','e',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','d','P','d','x',')', +' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')', +' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','C','u','b','e','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r' +,'s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','1','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ', +'f','l','o','a','t',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','1','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v' +,'e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','2','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u' +,'s','a','m','p','l','e','r','2','D','A','r','r','a','y',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','A','r','r','a','y','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','P','d', +'y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D','A','r','r','a','y','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','t','e','x','t','u','r','e','G','r','a','d','O','f','f','s','e','t',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D',' ','s',')',' ','(','d' +,'e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','1','D',' ','s',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i', +'g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','1','D',' ','s',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D',' ','s',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ' +,'d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','2','D',' ','s',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a', +'r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','2','D',' ','s',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','3','D',' ','s',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ' +,'i','v','e','c','3',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','3','D',' ','s',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','3','D',' ','s',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c' +,'3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','C','u','b','e',' ','s',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c' +,'4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','C','u','b','e',' ','s',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','C','u','b','e',' ','s',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','d','x',')',' ','(','d','e','c','l' +,'a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','o','f','f','s','e','t',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','S','h','a','d','o','w',' ','s',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ' +,'s','a','m','p','l','e','r','2','D','S','h','a','d','o','w',' ','s',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','A','r','r','a','y',' ','s',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','y',')',' ','(','d','e','c','l','a','r' +,'e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','1','D','A','r','r','a','y',' ','s',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','1','D','A','r','r','a','y',' ','s',')',' ','(','d','e','c','l','a','r','e', +' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D','A','r','r','a','y',' ','s',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i' +,'v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','2','D','A','r','r','a','y',' ','s',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','2','D','A','r','r','a','y',' ','s',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ', +'d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','A','r','r','a','y','S','h','a','d','o','w',' ','s',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c', +'l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D','A','r','r','a','y','S','h','a','d','o','w',' ','s',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','t','e','x','t','u','r','e','P','r','o','j','G','r','a','d',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r', +'e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','1','D',' ','s','a', +'m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e' +,'r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','P','d' +,'y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d' +,'P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ', +'v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p' +,'l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a', +'m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','d','P','d' +,'y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d', +'e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','P','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','P','d','y',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','t','e','x','t','u','r','e','P','r','o','j','G','r','a','d','O','f','f','s','e','t',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D',' ','s',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ', +'i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','1','D',' ','s',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','1','D',' ','s',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','x',')',' ','(','d','e','c','l','a','r' +,'e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D',' ','s',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','1','D',' ','s',')',' ','(','d' +,'e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','1','D',' ','s',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o','f','f',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u', +'r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D',' ','s',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','2','D',' ','s',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','x',')',' ','(','d','e','c','l','a','r', +'e',' ','(','i','n',')',' ','v','e','c','2',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','2','D',' ','s',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D',' ','s',')',' ','(' +,'d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','2','D',' ','s',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t', +'u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','2','D',' ','s',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','2',' ','o','f','f',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','3','D',' ','s',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','d','x',')',' ','(','d','e','c','l','a', +'r','e',' ','(','i','n',')',' ','v','e','c','3',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','o','f','f',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','i','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','s','a','m','p','l','e','r','3','D',' ','s',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','o','f','f',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','u','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','u','s','a','m','p','l','e','r','3' +,'D',' ','s',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','v','e','c','3',' ','o','f','f',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','S','h','a','d','o','w',' ','s',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','i','n','t',' ','o',')','\n',')',' ','(','\n',')',')',' ','(', +'s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D','S','h','a','d','o','w',' ','s',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','P',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','x',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','d','y',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','o',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','t','e','x','t','u','r','e','1','D',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r' +,'e',' ','(','i','n',')',' ','f','l','o','a','t',' ','c','o','o','r','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','c','o','o','r','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','t','e','x','t','u','r','e','1','D','P','r','o','j',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ', +'v','e','c','2',' ','c','o','o','r','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','c','o','o','r','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','c','o','o','r','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a', +'r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','c','o','o','r','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','t','e','x','t','u','r','e','1','D','L','o','d',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','c','o','o','r','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n' +,'c','t','i','o','n',' ','t','e','x','t','u','r','e','1','D','P','r','o','j','L','o','d',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','c','o','o','r','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','c','o','o','r','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ', +'f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','t','e','x','t','u','r','e','2','D',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','c','o','o','r','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','c','o','o','r','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n', +')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','t','e','x','t','u','r','e','2','D','P','r','o','j',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','c','o','o','r','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','c','o','o','r','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(', +'d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','c','o','o','r','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','c','o','o','r','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','t','e','x','t','u','r','e','2','D','L','o','d',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e', +'c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','c','o','o','r','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','t','e','x','t','u','r','e','2','D','P','r','o','j','L','o','d',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','c','o','o','r','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')', +'\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','c','o','o','r','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','t','e','x','t','u','r','e','3','D',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','c','o','o','r','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r', +'e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','c','o','o','r','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','t','e','x','t','u','r','e','3','D','P','r','o','j',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','c','o','o','r','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(', +'p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','c','o','o','r','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','t','e','x','t','u','r','e','3','D','L','o','d',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','c','o','o','r','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u' +,'n','c','t','i','o','n',' ','t','e','x','t','u','r','e','3','D','P','r','o','j','L','o','d',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','3','D',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','c','o','o','r','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','t','e','x','t','u','r','e','C','u','b','e',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','C','u','b','e',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e', +' ','(','i','n',')',' ','v','e','c','3',' ','c','o','o','r','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','C','u','b','e',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','c','o','o','r','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','t','e','x','t','u','r','e','C','u','b','e','L','o','d',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','C','u','b','e',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i' +,'n',')',' ','v','e','c','3',' ','c','o','o','r','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','s','h','a','d','o','w','1','D',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','c','o','o','r','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i', +'n',')',' ','v','e','c','3',' ','c','o','o','r','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','s','h','a','d','o','w','2','D',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','c','o','o','r','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(', +'i','n',')',' ','v','e','c','3',' ','c','o','o','r','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','s','h','a','d','o','w','1','D','P','r','o','j',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','c','o','o','r','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c' +,'l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','c','o','o','r','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','s','h','a','d','o','w','2','D','P','r','o','j',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','c','o','o','r','d',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D','S','h','a','d','o','w',' ','s','a','m','p','l','e' +,'r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','c','o','o','r','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','b','i','a','s',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','s','h','a','d','o','w','1','D','L','o','d',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','c','o','o','r','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','s','h','a','d','o','w','2','D','L','o','d',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c', +'4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','c','o','o','r','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','s','h','a','d','o','w','1','D','P','r','o','j','L','o','d',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','1','D','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','c','o','o','r','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i' +,'n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','s','h','a','d','o','w','2','D','P','r','o','j','L','o','d',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','s','a','m','p','l','e','r','2','D','S','h','a','d','o','w',' ','s','a','m','p','l','e','r',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','c','o','o','r','d',')',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','l','o','d',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','n','o','i','s','e','1',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','x',')','\n',')',' ','(','\n',')',')',' ','(' +,'s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','f','l','o','a','t',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','n','o','i','s','e','2',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a', +'t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','2',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','n','o','i','s','e','3',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3', +' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','3',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')','\n',')',' ','(','\n',')',')',' ',')',' ','(','f','u','n','c','t','i','o','n',' ','n','o','i','s','e','4',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','f','l','o','a','t',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e' +,'r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','2',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','3',' ','x',')','\n',')',' ','(','\n',')',')',' ','(','s','i','g','n','a','t','u','r','e',' ','v','e','c','4',' ','(','p','a','r','a','m','e','t','e','r','s',' ','(','d','e','c','l','a','r','e',' ','(','i','n',')',' ','v','e','c','4',' ','x',')','\n',')',' ','(','\n',')',')',' ',')',' ',')'} ; +static const char *functions_for_130_vert [] = { + builtin_abs, + builtin_acos, + builtin_acosh, + builtin_all, + builtin_any, + builtin_asin, + builtin_asinh, + builtin_atan, + builtin_atanh, + builtin_ceil, + builtin_clamp, + builtin_cos, + builtin_cosh, + builtin_cross, + builtin_degrees, + builtin_distance, + builtin_dot, + builtin_equal, + builtin_exp, + builtin_exp2, + builtin_faceforward, + builtin_floor, + builtin_fract, + builtin_ftransform, + builtin_greaterThan, + builtin_greaterThanEqual, + builtin_inversesqrt, + builtin_length, + builtin_lessThan, + builtin_lessThanEqual, + builtin_log, + builtin_log2, + builtin_matrixCompMult, + builtin_max, + builtin_min, + builtin_mix, + builtin_mod, + builtin_modf, + builtin_noise1, + builtin_noise2, + builtin_noise3, + builtin_noise4, + builtin_normalize, + builtin_not, + builtin_notEqual, + builtin_outerProduct, + builtin_pow, + builtin_radians, + builtin_reflect, + builtin_refract, + builtin_round, + builtin_roundEven, + builtin_shadow1D, + builtin_shadow1DLod, + builtin_shadow1DProj, + builtin_shadow1DProjLod, + builtin_shadow2D, + builtin_shadow2DLod, + builtin_shadow2DProj, + builtin_shadow2DProjLod, + builtin_sign, + builtin_sin, + builtin_sinh, + builtin_smoothstep, + builtin_sqrt, + builtin_step, + builtin_tan, + builtin_tanh, + builtin_texelFetch, + builtin_texelFetchOffset, + builtin_texture, + builtin_texture1D, + builtin_texture1DLod, + builtin_texture1DProj, + builtin_texture1DProjLod, + builtin_texture2D, + builtin_texture2DLod, + builtin_texture2DProj, + builtin_texture2DProjLod, + builtin_texture3D, + builtin_texture3DLod, + builtin_texture3DProj, + builtin_texture3DProjLod, + builtin_textureCube, + builtin_textureCubeLod, + builtin_textureGrad, + builtin_textureGradOffset, + builtin_textureLod, + builtin_textureLodOffset, + builtin_textureOffset, + builtin_textureProj, + builtin_textureProjGrad, + builtin_textureProjGradOffset, + builtin_textureProjLod, + builtin_textureProjLodOffset, + builtin_transpose, + builtin_trunc, +}; +static const char prototypes_for_ARB_shader_texture_lod_frag[] = + "(\n" + "(function texture1DLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) float coord)\n" + " (declare (in) float lod))\n" + " ())\n" + ")\n" + "\n" + "(function texture1DProjLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec2 coord)\n" + " (declare (in) float lod))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec4 coord)\n" + " (declare (in) float lod))\n" + " ())\n" + ")\n" + "\n" + "(function texture2DLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec2 coord)\n" + " (declare (in) float lod))\n" + " ())\n" + ")\n" + "\n" + "(function texture2DProjLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec3 coord)\n" + " (declare (in) float lod))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec4 coord)\n" + " (declare (in) float lod))\n" + " ())\n" + ")\n" + "\n" + "(function texture3DLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec3 coord)\n" + " (declare (in) float lod))\n" + " ())\n" + ")\n" + "\n" + "(function texture3DProjLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec4 coord)\n" + " (declare (in) float lod))\n" + " ())\n" + ")\n" + "\n" + "(function textureCubeLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) samplerCube sampler)\n" + " (declare (in) vec3 coord)\n" + " (declare (in) float lod))\n" + " ())\n" + ")\n" + "\n" + "(function shadow1DLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DShadow sampler)\n" + " (declare (in) vec3 coord)\n" + " (declare (in) float lod))\n" + " ())\n" + ")\n" + "\n" + "(function shadow2DLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DShadow sampler)\n" + " (declare (in) vec3 coord)\n" + " (declare (in) float lod))\n" + " ())\n" + ")\n" + "\n" + "(function shadow1DProjLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DShadow sampler)\n" + " (declare (in) vec4 coord)\n" + " (declare (in) float lod))\n" + " ())\n" + ")\n" + "\n" + "(function shadow2DProjLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DShadow sampler)\n" + " (declare (in) vec4 coord)\n" + " (declare (in) float lod))\n" + " ())\n" + ")\n" + "\n" + "(function texture1DGradARB\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) float P)\n" + " (declare (in) float dPdx)\n" + " (declare (in) float dPdy))\n" + " ())\n" + ")\n" + "\n" + "(function texture1DProjGradARB\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec2 P)\n" + " (declare (in) float dPdx)\n" + " (declare (in) float dPdy))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec4 P)\n" + " (declare (in) float dPdx)\n" + " (declare (in) float dPdy))\n" + " ())\n" + ")\n" + "\n" + "(function texture2DGradARB\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec2 P)\n" + " (declare (in) vec2 dPdx)\n" + " (declare (in) vec2 dPdy))\n" + " ())\n" + ")\n" + "\n" + "(function texture2DProjGradARB\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec3 P)\n" + " (declare (in) vec2 dPdx)\n" + " (declare (in) vec2 dPdy))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec4 P)\n" + " (declare (in) vec2 dPdx)\n" + " (declare (in) vec2 dPdy))\n" + " ())\n" + ")\n" + "\n" + "(function texture3DGradARB\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec3 P)\n" + " (declare (in) vec3 dPdx)\n" + " (declare (in) vec3 dPdy))\n" + " ())\n" + ")\n" + "\n" + "(function texture3DProjGradARB\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec4 P)\n" + " (declare (in) vec3 dPdx)\n" + " (declare (in) vec3 dPdy))\n" + " ())\n" + ")\n" + "\n" + "(function textureCubeGradARB\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) samplerCube sampler)\n" + " (declare (in) vec3 P)\n" + " (declare (in) vec3 dPdx)\n" + " (declare (in) vec3 dPdy))\n" + " ())\n" + ")\n" + "\n" + "(function shadow1DGradARB\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DShadow sampler)\n" + " (declare (in) vec3 P)\n" + " (declare (in) float dPdx)\n" + " (declare (in) float dPdy))\n" + " ())\n" + ")\n" + "\n" + "(function shadow1DProjGradARB\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DShadow sampler)\n" + " (declare (in) vec4 P)\n" + " (declare (in) float dPdx)\n" + " (declare (in) float dPdy))\n" + " ())\n" + ")\n" + "\n" + "(function shadow2DGradARB\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DShadow sampler)\n" + " (declare (in) vec3 P)\n" + " (declare (in) vec2 dPdx)\n" + " (declare (in) vec2 dPdy))\n" + " ())\n" + ")\n" + "\n" + "(function shadow2DProjGradARB\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DShadow sampler)\n" + " (declare (in) vec4 P)\n" + " (declare (in) vec2 dPdx)\n" + " (declare (in) vec2 dPdy))\n" + " ())\n" + ")\n" + "\n" + "(function texture2DRectGradARB\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DRect sampler)\n" + " (declare (in) vec2 P)\n" + " (declare (in) vec2 dPdx)\n" + " (declare (in) vec2 dPdy))\n" + " ())\n" + ")\n" + "\n" + "(function texture2DRectProjGradARB\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DRect sampler)\n" + " (declare (in) vec3 P)\n" + " (declare (in) vec2 dPdx)\n" + " (declare (in) vec2 dPdy))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DRect sampler)\n" + " (declare (in) vec4 P)\n" + " (declare (in) vec2 dPdx)\n" + " (declare (in) vec2 dPdy))\n" + " ())\n" + ")\n" + "\n" + "(function shadow2DRectGradARB\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DRectShadow sampler)\n" + " (declare (in) vec3 P)\n" + " (declare (in) vec2 dPdx)\n" + " (declare (in) vec2 dPdy))\n" + " ())\n" + ")\n" + "\n" + "(function shadow2DRectProjGradARB\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DRectShadow sampler)\n" + " (declare (in) vec4 P)\n" + " (declare (in) vec2 dPdx)\n" + " (declare (in) vec2 dPdy))\n" + " ())\n" + ")\n" + "\n" + ")" +; +static const char *functions_for_ARB_shader_texture_lod_frag [] = { + builtin_shadow1DGradARB, + builtin_shadow1DLod, + builtin_shadow1DProjGradARB, + builtin_shadow1DProjLod, + builtin_shadow2DGradARB, + builtin_shadow2DLod, + builtin_shadow2DProjGradARB, + builtin_shadow2DProjLod, + builtin_shadow2DRectGradARB, + builtin_shadow2DRectProjGradARB, + builtin_texture1DGradARB, + builtin_texture1DLod, + builtin_texture1DProjGradARB, + builtin_texture1DProjLod, + builtin_texture2DGradARB, + builtin_texture2DLod, + builtin_texture2DProjGradARB, + builtin_texture2DProjLod, + builtin_texture2DRectGradARB, + builtin_texture2DRectProjGradARB, + builtin_texture3DGradARB, + builtin_texture3DLod, + builtin_texture3DProjGradARB, + builtin_texture3DProjLod, + builtin_textureCubeGradARB, + builtin_textureCubeLod, +}; +static const char prototypes_for_ARB_shader_texture_lod_vert[] = + "(\n" + "(function texture1DGradARB\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) float P)\n" + " (declare (in) float dPdx)\n" + " (declare (in) float dPdy))\n" + " ())\n" + ")\n" + "\n" + "(function texture1DProjGradARB\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec2 P)\n" + " (declare (in) float dPdx)\n" + " (declare (in) float dPdy))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1D sampler)\n" + " (declare (in) vec4 P)\n" + " (declare (in) float dPdx)\n" + " (declare (in) float dPdy))\n" + " ())\n" + ")\n" + "\n" + "(function texture2DGradARB\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec2 P)\n" + " (declare (in) vec2 dPdx)\n" + " (declare (in) vec2 dPdy))\n" + " ())\n" + ")\n" + "\n" + "(function texture2DProjGradARB\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec3 P)\n" + " (declare (in) vec2 dPdx)\n" + " (declare (in) vec2 dPdy))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec4 P)\n" + " (declare (in) vec2 dPdx)\n" + " (declare (in) vec2 dPdy))\n" + " ())\n" + ")\n" + "\n" + "(function texture3DGradARB\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec3 P)\n" + " (declare (in) vec3 dPdx)\n" + " (declare (in) vec3 dPdy))\n" + " ())\n" + ")\n" + "\n" + "(function texture3DProjGradARB\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec4 P)\n" + " (declare (in) vec3 dPdx)\n" + " (declare (in) vec3 dPdy))\n" + " ())\n" + ")\n" + "\n" + "(function textureCubeGradARB\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) samplerCube sampler)\n" + " (declare (in) vec3 P)\n" + " (declare (in) vec3 dPdx)\n" + " (declare (in) vec3 dPdy))\n" + " ())\n" + ")\n" + "\n" + "(function shadow1DGradARB\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DShadow sampler)\n" + " (declare (in) vec3 P)\n" + " (declare (in) float dPdx)\n" + " (declare (in) float dPdy))\n" + " ())\n" + ")\n" + "\n" + "(function shadow1DProjGradARB\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DShadow sampler)\n" + " (declare (in) vec4 P)\n" + " (declare (in) float dPdx)\n" + " (declare (in) float dPdy))\n" + " ())\n" + ")\n" + "\n" + "(function shadow2DGradARB\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DShadow sampler)\n" + " (declare (in) vec3 P)\n" + " (declare (in) vec2 dPdx)\n" + " (declare (in) vec2 dPdy))\n" + " ())\n" + ")\n" + "\n" + "(function shadow2DProjGradARB\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DShadow sampler)\n" + " (declare (in) vec4 P)\n" + " (declare (in) vec2 dPdx)\n" + " (declare (in) vec2 dPdy))\n" + " ())\n" + ")\n" + "\n" + "(function texture2DRectGradARB\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DRect sampler)\n" + " (declare (in) vec2 P)\n" + " (declare (in) vec2 dPdx)\n" + " (declare (in) vec2 dPdy))\n" + " ())\n" + ")\n" + "\n" + "(function texture2DRectProjGradARB\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DRect sampler)\n" + " (declare (in) vec3 P)\n" + " (declare (in) vec2 dPdx)\n" + " (declare (in) vec2 dPdy))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DRect sampler)\n" + " (declare (in) vec4 P)\n" + " (declare (in) vec2 dPdx)\n" + " (declare (in) vec2 dPdy))\n" + " ())\n" + ")\n" + "\n" + "(function shadow2DRectGradARB\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DRectShadow sampler)\n" + " (declare (in) vec3 P)\n" + " (declare (in) vec2 dPdx)\n" + " (declare (in) vec2 dPdy))\n" + " ())\n" + ")\n" + "\n" + "(function shadow2DRectProjGradARB\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DRectShadow sampler)\n" + " (declare (in) vec4 P)\n" + " (declare (in) vec2 dPdx)\n" + " (declare (in) vec2 dPdy))\n" + " ())\n" + ")\n" + "\n" + ")" +; +static const char *functions_for_ARB_shader_texture_lod_vert [] = { + builtin_shadow1DGradARB, + builtin_shadow1DProjGradARB, + builtin_shadow2DGradARB, + builtin_shadow2DProjGradARB, + builtin_shadow2DRectGradARB, + builtin_shadow2DRectProjGradARB, + builtin_texture1DGradARB, + builtin_texture1DProjGradARB, + builtin_texture2DGradARB, + builtin_texture2DProjGradARB, + builtin_texture2DRectGradARB, + builtin_texture2DRectProjGradARB, + builtin_texture3DGradARB, + builtin_texture3DProjGradARB, + builtin_textureCubeGradARB, +}; +static const char prototypes_for_ARB_texture_rectangle_frag[] = + "(\n" + "(function texture2DRect\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DRect sampler)\n" + " (declare (in) vec2 coord))\n" + " ())\n" + ")\n" + "\n" + "(function texture2DRectProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DRect sampler)\n" + " (declare (in) vec3 coord))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DRect sampler)\n" + " (declare (in) vec4 coord))\n" + " ())\n" + ")\n" + "\n" + "(function shadow2DRect\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DRectShadow sampler)\n" + " (declare (in) vec3 coord))\n" + " ())\n" + ")\n" + "\n" + "(function shadow2DRectProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DRectShadow sampler)\n" + " (declare (in) vec4 coord))\n" + " ())\n" + ")\n" + "\n" + ")" +; +static const char *functions_for_ARB_texture_rectangle_frag [] = { + builtin_shadow2DRect, + builtin_shadow2DRectProj, + builtin_texture2DRect, + builtin_texture2DRectProj, +}; +static const char prototypes_for_ARB_texture_rectangle_vert[] = + "(\n" + "(function texture2DRect\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DRect sampler)\n" + " (declare (in) vec2 coord))\n" + " ())\n" + ")\n" + "\n" + "(function texture2DRectProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DRect sampler)\n" + " (declare (in) vec3 coord))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DRect sampler)\n" + " (declare (in) vec4 coord))\n" + " ())\n" + ")\n" + "\n" + "(function shadow2DRect\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DRectShadow sampler)\n" + " (declare (in) vec3 coord))\n" + " ())\n" + ")\n" + "\n" + "(function shadow2DRectProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DRectShadow sampler)\n" + " (declare (in) vec4 coord))\n" + " ())\n" + ")\n" + "\n" + ")" +; +static const char *functions_for_ARB_texture_rectangle_vert [] = { + builtin_shadow2DRect, + builtin_shadow2DRectProj, + builtin_texture2DRect, + builtin_texture2DRectProj, +}; +static const char prototypes_for_EXT_shader_texture_lod_frag[] = + "(\n" + "(function texture2DLodEXT\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec2 coord)\n" + " (declare (in) float lod))\n" + " ())\n" + ")\n" + "\n" + "(function texture2DProjLodEXT\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec3 coord)\n" + " (declare (in) float lod))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec4 coord)\n" + " (declare (in) float lod))\n" + " ())\n" + ")\n" + "\n" + "(function textureCubeLodEXT\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) samplerCube sampler)\n" + " (declare (in) vec3 coord)\n" + " (declare (in) float lod))\n" + " ())\n" + ")\n" + "\n" + "(function texture2DGradEXT\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec2 P)\n" + " (declare (in) vec2 dPdx)\n" + " (declare (in) vec2 dPdy))\n" + " ())\n" + ")\n" + "\n" + "(function texture2DProjGradEXT\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec3 P)\n" + " (declare (in) vec2 dPdx)\n" + " (declare (in) vec2 dPdy))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec4 P)\n" + " (declare (in) vec2 dPdx)\n" + " (declare (in) vec2 dPdy))\n" + " ())\n" + ")\n" + "\n" + "(function textureCubeGradEXT\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) samplerCube sampler)\n" + " (declare (in) vec3 P)\n" + " (declare (in) vec3 dPdx)\n" + " (declare (in) vec3 dPdy))\n" + " ())\n" + ")\n" + "\n" + ")" +; +static const char *functions_for_EXT_shader_texture_lod_frag [] = { + builtin_texture2DGradEXT, + builtin_texture2DLodEXT, + builtin_texture2DProjGradEXT, + builtin_texture2DProjLodEXT, + builtin_textureCubeGradEXT, + builtin_textureCubeLodEXT, +}; +static const char prototypes_for_EXT_shader_texture_lod_vert[] = + "(\n" + "(function texture2DGradEXT\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec2 P)\n" + " (declare (in) vec2 dPdx)\n" + " (declare (in) vec2 dPdy))\n" + " ())\n" + ")\n" + "\n" + "(function texture2DProjGradEXT\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec3 P)\n" + " (declare (in) vec2 dPdx)\n" + " (declare (in) vec2 dPdy))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2D sampler)\n" + " (declare (in) vec4 P)\n" + " (declare (in) vec2 dPdx)\n" + " (declare (in) vec2 dPdy))\n" + " ())\n" + ")\n" + "\n" + "(function textureCubeGradEXT\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) samplerCube sampler)\n" + " (declare (in) vec3 P)\n" + " (declare (in) vec3 dPdx)\n" + " (declare (in) vec3 dPdy))\n" + " ())\n" + ")\n" + "\n" + ")" +; +static const char *functions_for_EXT_shader_texture_lod_vert [] = { + builtin_texture2DGradEXT, + builtin_texture2DProjGradEXT, + builtin_textureCubeGradEXT, +}; +static const char prototypes_for_EXT_texture_array_frag[] = + "(\n" + "(function texture1DArray\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DArray sampler)\n" + " (declare (in) vec2 coord))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DArray sampler)\n" + " (declare (in) vec2 coord)\n" + " (declare (in) float bias))\n" + " ())\n" + ")\n" + "\n" + "(function texture2DArray\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DArray sampler)\n" + " (declare (in) vec3 coord))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DArray sampler)\n" + " (declare (in) vec3 coord)\n" + " (declare (in) float bias))\n" + " ())\n" + ")\n" + "\n" + "(function shadow1DArray\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DArrayShadow sampler)\n" + " (declare (in) vec3 coord))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DArrayShadow sampler)\n" + " (declare (in) vec3 coord)\n" + " (declare (in) float bias))\n" + " ())\n" + ")\n" + "\n" + "(function shadow2DArray\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DArrayShadow sampler)\n" + " (declare (in) vec4 coord))\n" + " ())\n" + ")\n" + "\n" + ")" +; +static const char *functions_for_EXT_texture_array_frag [] = { + builtin_shadow1DArray, + builtin_shadow2DArray, + builtin_texture1DArray, + builtin_texture2DArray, +}; +static const char prototypes_for_EXT_texture_array_vert[] = + "(\n" + "(function texture1DArray\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DArray sampler)\n" + " (declare (in) vec2 coord))\n" + " ())\n" + ")\n" + "\n" + "(function texture1DArrayLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DArray sampler)\n" + " (declare (in) vec2 coord)\n" + " (declare (in) float lod))\n" + " ())\n" + ")\n" + "\n" + "(function texture2DArray\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DArray sampler)\n" + " (declare (in) vec3 coord))\n" + " ())\n" + ")\n" + "\n" + "(function texture2DArrayLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DArray sampler)\n" + " (declare (in) vec3 coord)\n" + " (declare (in) float lod))\n" + " ())\n" + ")\n" + "\n" + "(function shadow1DArray\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DArrayShadow sampler)\n" + " (declare (in) vec3 coord))\n" + " ())\n" + ")\n" + "\n" + "(function shadow1DArrayLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler1DArrayShadow sampler)\n" + " (declare (in) vec3 coord)\n" + " (declare (in) float lod))\n" + " ())\n" + ")\n" + "\n" + "(function shadow2DArray\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler2DArrayShadow sampler)\n" + " (declare (in) vec4 coord))\n" + " ())\n" + ")\n" + "\n" + ")" +; +static const char *functions_for_EXT_texture_array_vert [] = { + builtin_shadow1DArray, + builtin_shadow1DArrayLod, + builtin_shadow2DArray, + builtin_texture1DArray, + builtin_texture1DArrayLod, + builtin_texture2DArray, + builtin_texture2DArrayLod, +}; +static const char prototypes_for_OES_standard_derivatives_frag[] = + "(\n" + "(function dFdx\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float p))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 p))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 p))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 p))\n" + " ())\n" + ")\n" + "\n" + "(function dFdy\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float p))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 p))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 p))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 p))\n" + " ())\n" + ")\n" + "\n" + "(function fwidth\n" + " (signature float\n" + " (parameters\n" + " (declare (in) float p))\n" + " ())\n" + "\n" + " (signature vec2\n" + " (parameters\n" + " (declare (in) vec2 p))\n" + " ())\n" + "\n" + " (signature vec3\n" + " (parameters\n" + " (declare (in) vec3 p))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) vec4 p))\n" + " ())\n" + ")\n" + "\n" + ")" +; +static const char *functions_for_OES_standard_derivatives_frag [] = { + builtin_dFdx, + builtin_dFdy, + builtin_fwidth, +}; +static const char prototypes_for_OES_texture_3D_frag[] = + "(\n" + "(function texture3D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec3 coord))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec3 coord)\n" + " (declare (in) float bias))\n" + " ())\n" + ")\n" + "\n" + "(function texture3DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec4 coord))\n" + " ())\n" + "\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec4 coord)\n" + " (declare (in) float bias))\n" + " ())\n" + ")\n" + "\n" + ")" +; +static const char *functions_for_OES_texture_3D_frag [] = { + builtin_texture3D, + builtin_texture3DProj, +}; +static const char prototypes_for_OES_texture_3D_vert[] = + "(\n" + "(function texture3D\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec3 coord))\n" + " ())\n" + ")\n" + "\n" + "(function texture3DProj\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec4 coord))\n" + " ())\n" + ")\n" + "\n" + "(function texture3DLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec3 coord)\n" + " (declare (in) float lod))\n" + " ())\n" + ")\n" + "\n" + "(function texture3DProjLod\n" + " (signature vec4\n" + " (parameters\n" + " (declare (in) sampler3D sampler)\n" + " (declare (in) vec4 coord)\n" + " (declare (in) float lod))\n" + " ())\n" + ")\n" + "\n" + ")" +; +static const char *functions_for_OES_texture_3D_vert [] = { + builtin_texture3D, + builtin_texture3DLod, + builtin_texture3DProj, + builtin_texture3DProjLod, +}; +static gl_shader *builtin_profiles[19]; + +void *builtin_mem_ctx = NULL; + +void +_mesa_glsl_release_functions(void) +{ + ralloc_free(builtin_mem_ctx); + builtin_mem_ctx = NULL; + memset(builtin_profiles, 0, sizeof(builtin_profiles)); +} + +static void +_mesa_read_profile(struct _mesa_glsl_parse_state *state, + int profile_index, + const char *prototypes, + const char **functions, + int count) +{ + gl_shader *sh = builtin_profiles[profile_index]; + + if (sh == NULL) { + sh = read_builtins(GL_VERTEX_SHADER, prototypes, functions, count); + ralloc_steal(builtin_mem_ctx, sh); + builtin_profiles[profile_index] = sh; + } + + state->builtins_to_link[state->num_builtins_to_link] = sh; + state->num_builtins_to_link++; +} + +void +_mesa_glsl_initialize_functions(struct _mesa_glsl_parse_state *state) +{ + if (builtin_mem_ctx == NULL) { + builtin_mem_ctx = ralloc_context(NULL); // "GLSL built-in functions" + memset(&builtin_profiles, 0, sizeof(builtin_profiles)); + } + + state->num_builtins_to_link = 0; + + if (state->target == fragment_shader && state->language_version == 100) { + _mesa_read_profile(state, 0, + prototypes_for_100_frag, + functions_for_100_frag, + Elements(functions_for_100_frag)); + } + + if (state->target == vertex_shader && state->language_version == 100) { + _mesa_read_profile(state, 1, + prototypes_for_100_vert, + functions_for_100_vert, + Elements(functions_for_100_vert)); + } + + if (state->target == fragment_shader && state->language_version == 110) { + _mesa_read_profile(state, 2, + prototypes_for_110_frag, + functions_for_110_frag, + Elements(functions_for_110_frag)); + } + + if (state->target == vertex_shader && state->language_version == 110) { + _mesa_read_profile(state, 3, + prototypes_for_110_vert, + functions_for_110_vert, + Elements(functions_for_110_vert)); + } + + if (state->target == fragment_shader && state->language_version == 120) { + _mesa_read_profile(state, 4, + prototypes_for_120_frag, + functions_for_120_frag, + Elements(functions_for_120_frag)); + } + + if (state->target == vertex_shader && state->language_version == 120) { + _mesa_read_profile(state, 5, + prototypes_for_120_vert, + functions_for_120_vert, + Elements(functions_for_120_vert)); + } + + if (state->target == fragment_shader && state->language_version == 130) { + _mesa_read_profile(state, 6, + prototypes_for_130_frag, + functions_for_130_frag, + Elements(functions_for_130_frag)); + } + + if (state->target == vertex_shader && state->language_version == 130) { + _mesa_read_profile(state, 7, + prototypes_for_130_vert, + functions_for_130_vert, + Elements(functions_for_130_vert)); + } + + if (state->target == fragment_shader && state->ARB_shader_texture_lod_enable) { + _mesa_read_profile(state, 8, + prototypes_for_ARB_shader_texture_lod_frag, + functions_for_ARB_shader_texture_lod_frag, + Elements(functions_for_ARB_shader_texture_lod_frag)); + } + + if (state->target == vertex_shader && state->ARB_shader_texture_lod_enable) { + _mesa_read_profile(state, 9, + prototypes_for_ARB_shader_texture_lod_vert, + functions_for_ARB_shader_texture_lod_vert, + Elements(functions_for_ARB_shader_texture_lod_vert)); + } + + if (state->target == fragment_shader && state->ARB_texture_rectangle_enable) { + _mesa_read_profile(state, 10, + prototypes_for_ARB_texture_rectangle_frag, + functions_for_ARB_texture_rectangle_frag, + Elements(functions_for_ARB_texture_rectangle_frag)); + } + + if (state->target == vertex_shader && state->ARB_texture_rectangle_enable) { + _mesa_read_profile(state, 11, + prototypes_for_ARB_texture_rectangle_vert, + functions_for_ARB_texture_rectangle_vert, + Elements(functions_for_ARB_texture_rectangle_vert)); + } + + if (state->target == fragment_shader && state->EXT_shader_texture_lod_enable) { + _mesa_read_profile(state, 12, + prototypes_for_EXT_shader_texture_lod_frag, + functions_for_EXT_shader_texture_lod_frag, + Elements(functions_for_EXT_shader_texture_lod_frag)); + } + + if (state->target == vertex_shader && state->EXT_shader_texture_lod_enable) { + _mesa_read_profile(state, 13, + prototypes_for_EXT_shader_texture_lod_vert, + functions_for_EXT_shader_texture_lod_vert, + Elements(functions_for_EXT_shader_texture_lod_vert)); + } + + if (state->target == fragment_shader && state->EXT_texture_array_enable) { + _mesa_read_profile(state, 14, + prototypes_for_EXT_texture_array_frag, + functions_for_EXT_texture_array_frag, + Elements(functions_for_EXT_texture_array_frag)); + } + + if (state->target == vertex_shader && state->EXT_texture_array_enable) { + _mesa_read_profile(state, 15, + prototypes_for_EXT_texture_array_vert, + functions_for_EXT_texture_array_vert, + Elements(functions_for_EXT_texture_array_vert)); + } + + if (state->target == fragment_shader && state->OES_standard_derivatives_enable) { + _mesa_read_profile(state, 16, + prototypes_for_OES_standard_derivatives_frag, + functions_for_OES_standard_derivatives_frag, + Elements(functions_for_OES_standard_derivatives_frag)); + } + + if (state->target == fragment_shader && state->OES_texture_3D_enable) { + _mesa_read_profile(state, 17, + prototypes_for_OES_texture_3D_frag, + functions_for_OES_texture_3D_frag, + Elements(functions_for_OES_texture_3D_frag)); + } + + if (state->target == vertex_shader && state->OES_texture_3D_enable) { + _mesa_read_profile(state, 18, + prototypes_for_OES_texture_3D_vert, + functions_for_OES_texture_3D_vert, + Elements(functions_for_OES_texture_3D_vert)); + } + +} diff --git a/3rdparty/glsl-optimizer/src/glsl/builtin_stubs.cpp b/3rdparty/glsl-optimizer/src/glsl/builtin_stubs.cpp new file mode 100644 index 000000000..00b329491 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtin_stubs.cpp @@ -0,0 +1,38 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include +#include "glsl_parser_extras.h" + +/* A dummy file. When compiling prototypes, we don't care about builtins. + * We really don't want to half-compile builtin_functions.cpp and fail, though. + */ +void +_mesa_glsl_release_functions(void) +{ +} + +void +_mesa_glsl_initialize_functions(_mesa_glsl_parse_state *state) +{ +} diff --git a/3rdparty/glsl-optimizer/src/glsl/builtin_types.h b/3rdparty/glsl-optimizer/src/glsl/builtin_types.h new file mode 100644 index 000000000..58b9a8127 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtin_types.h @@ -0,0 +1,302 @@ +/* + * Copyright © 2009 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +const glsl_type glsl_type::_error_type = + glsl_type(GL_INVALID_ENUM, GLSL_TYPE_ERROR, 0, 0, ""); + +const glsl_type glsl_type::_void_type = + glsl_type(GL_INVALID_ENUM, GLSL_TYPE_VOID, 0, 0, "void"); + +const glsl_type glsl_type::_sampler3D_type = + glsl_type(GL_SAMPLER_3D, GLSL_SAMPLER_DIM_3D, 0, 0, GLSL_TYPE_FLOAT, + "sampler3D"); + +const glsl_type *const glsl_type::error_type = & glsl_type::_error_type; +const glsl_type *const glsl_type::void_type = & glsl_type::_void_type; + +/** \name Core built-in types + * + * These types exist in all versions of GLSL. + */ +/*@{*/ + +const glsl_type glsl_type::builtin_core_types[] = { + glsl_type(GL_BOOL, GLSL_TYPE_BOOL, 1, 1, "bool"), + glsl_type(GL_BOOL_VEC2, GLSL_TYPE_BOOL, 2, 1, "bvec2"), + glsl_type(GL_BOOL_VEC3, GLSL_TYPE_BOOL, 3, 1, "bvec3"), + glsl_type(GL_BOOL_VEC4, GLSL_TYPE_BOOL, 4, 1, "bvec4"), + glsl_type(GL_INT, GLSL_TYPE_INT, 1, 1, "int"), + glsl_type(GL_INT_VEC2, GLSL_TYPE_INT, 2, 1, "ivec2"), + glsl_type(GL_INT_VEC3, GLSL_TYPE_INT, 3, 1, "ivec3"), + glsl_type(GL_INT_VEC4, GLSL_TYPE_INT, 4, 1, "ivec4"), + glsl_type(GL_FLOAT, GLSL_TYPE_FLOAT, 1, 1, "float"), + glsl_type(GL_FLOAT_VEC2, GLSL_TYPE_FLOAT, 2, 1, "vec2"), + glsl_type(GL_FLOAT_VEC3, GLSL_TYPE_FLOAT, 3, 1, "vec3"), + glsl_type(GL_FLOAT_VEC4, GLSL_TYPE_FLOAT, 4, 1, "vec4"), + glsl_type(GL_FLOAT_MAT2, GLSL_TYPE_FLOAT, 2, 2, "mat2"), + glsl_type(GL_FLOAT_MAT3, GLSL_TYPE_FLOAT, 3, 3, "mat3"), + glsl_type(GL_FLOAT_MAT4, GLSL_TYPE_FLOAT, 4, 4, "mat4"), + glsl_type(GL_SAMPLER_2D, GLSL_SAMPLER_DIM_2D, 0, 0, GLSL_TYPE_FLOAT, + "sampler2D"), + glsl_type(GL_SAMPLER_CUBE, GLSL_SAMPLER_DIM_CUBE, 0, 0, GLSL_TYPE_FLOAT, + "samplerCube"), +}; + +const glsl_type *const glsl_type::bool_type = & builtin_core_types[0]; +const glsl_type *const glsl_type::int_type = & builtin_core_types[4]; +const glsl_type *const glsl_type::ivec4_type = & builtin_core_types[7]; +const glsl_type *const glsl_type::float_type = & builtin_core_types[8]; +const glsl_type *const glsl_type::vec2_type = & builtin_core_types[9]; +const glsl_type *const glsl_type::vec3_type = & builtin_core_types[10]; +const glsl_type *const glsl_type::vec4_type = & builtin_core_types[11]; +const glsl_type *const glsl_type::mat2_type = & builtin_core_types[12]; +const glsl_type *const glsl_type::mat3_type = & builtin_core_types[13]; +const glsl_type *const glsl_type::mat4_type = & builtin_core_types[14]; +/*@}*/ + +/** \name GLSL structures that have not been deprecated. + */ +/*@{*/ + +static const struct glsl_struct_field gl_DepthRangeParameters_fields[] = { + { glsl_type::float_type, "near" }, + { glsl_type::float_type, "far" }, + { glsl_type::float_type, "diff" }, +}; + +const glsl_type glsl_type::builtin_structure_types[] = { + glsl_type(gl_DepthRangeParameters_fields, + Elements(gl_DepthRangeParameters_fields), + "gl_DepthRangeParameters"), +}; +/*@}*/ + +/** \name GLSL 1.00 / 1.10 structures that are deprecated in GLSL 1.30 + */ +/*@{*/ + +static const struct glsl_struct_field gl_PointParameters_fields[] = { + { glsl_type::float_type, "size" }, + { glsl_type::float_type, "sizeMin" }, + { glsl_type::float_type, "sizeMax" }, + { glsl_type::float_type, "fadeThresholdSize" }, + { glsl_type::float_type, "distanceConstantAttenuation" }, + { glsl_type::float_type, "distanceLinearAttenuation" }, + { glsl_type::float_type, "distanceQuadraticAttenuation" }, +}; + +static const struct glsl_struct_field gl_MaterialParameters_fields[] = { + { glsl_type::vec4_type, "emission" }, + { glsl_type::vec4_type, "ambient" }, + { glsl_type::vec4_type, "diffuse" }, + { glsl_type::vec4_type, "specular" }, + { glsl_type::float_type, "shininess" }, +}; + +static const struct glsl_struct_field gl_LightSourceParameters_fields[] = { + { glsl_type::vec4_type, "ambient" }, + { glsl_type::vec4_type, "diffuse" }, + { glsl_type::vec4_type, "specular" }, + { glsl_type::vec4_type, "position" }, + { glsl_type::vec4_type, "halfVector" }, + { glsl_type::vec3_type, "spotDirection" }, + { glsl_type::float_type, "spotExponent" }, + { glsl_type::float_type, "spotCutoff" }, + { glsl_type::float_type, "spotCosCutoff" }, + { glsl_type::float_type, "constantAttenuation" }, + { glsl_type::float_type, "linearAttenuation" }, + { glsl_type::float_type, "quadraticAttenuation" }, +}; + +static const struct glsl_struct_field gl_LightModelParameters_fields[] = { + { glsl_type::vec4_type, "ambient" }, +}; + +static const struct glsl_struct_field gl_LightModelProducts_fields[] = { + { glsl_type::vec4_type, "sceneColor" }, +}; + +static const struct glsl_struct_field gl_LightProducts_fields[] = { + { glsl_type::vec4_type, "ambient" }, + { glsl_type::vec4_type, "diffuse" }, + { glsl_type::vec4_type, "specular" }, +}; + +static const struct glsl_struct_field gl_FogParameters_fields[] = { + { glsl_type::vec4_type, "color" }, + { glsl_type::float_type, "density" }, + { glsl_type::float_type, "start" }, + { glsl_type::float_type, "end" }, + { glsl_type::float_type, "scale" }, +}; + +const glsl_type glsl_type::builtin_110_deprecated_structure_types[] = { + glsl_type(gl_PointParameters_fields, + Elements(gl_PointParameters_fields), + "gl_PointParameters"), + glsl_type(gl_MaterialParameters_fields, + Elements(gl_MaterialParameters_fields), + "gl_MaterialParameters"), + glsl_type(gl_LightSourceParameters_fields, + Elements(gl_LightSourceParameters_fields), + "gl_LightSourceParameters"), + glsl_type(gl_LightModelParameters_fields, + Elements(gl_LightModelParameters_fields), + "gl_LightModelParameters"), + glsl_type(gl_LightModelProducts_fields, + Elements(gl_LightModelProducts_fields), + "gl_LightModelProducts"), + glsl_type(gl_LightProducts_fields, + Elements(gl_LightProducts_fields), + "gl_LightProducts"), + glsl_type(gl_FogParameters_fields, + Elements(gl_FogParameters_fields), + "gl_FogParameters"), +}; +/*@}*/ + +/** \name Types in GLSL 1.10 (but not GLSL ES 1.00) + */ +/*@{*/ +const glsl_type glsl_type::builtin_110_types[] = { + glsl_type(GL_SAMPLER_1D, GLSL_SAMPLER_DIM_1D, 0, 0, GLSL_TYPE_FLOAT, + "sampler1D"), + glsl_type(GL_SAMPLER_1D_SHADOW, GLSL_SAMPLER_DIM_1D, 1, 0, GLSL_TYPE_FLOAT, + "sampler1DShadow"), + glsl_type(GL_SAMPLER_2D_SHADOW, GLSL_SAMPLER_DIM_2D, 1, 0, GLSL_TYPE_FLOAT, + "sampler2DShadow"), +}; +/*@}*/ + +/** \name Types added in GLSL 1.20 + */ +/*@{*/ + +const glsl_type glsl_type::builtin_120_types[] = { + glsl_type(GL_FLOAT_MAT2x3, GLSL_TYPE_FLOAT, 3, 2, "mat2x3"), + glsl_type(GL_FLOAT_MAT2x4, GLSL_TYPE_FLOAT, 4, 2, "mat2x4"), + glsl_type(GL_FLOAT_MAT3x2, GLSL_TYPE_FLOAT, 2, 3, "mat3x2"), + glsl_type(GL_FLOAT_MAT3x4, GLSL_TYPE_FLOAT, 4, 3, "mat3x4"), + glsl_type(GL_FLOAT_MAT4x2, GLSL_TYPE_FLOAT, 2, 4, "mat4x2"), + glsl_type(GL_FLOAT_MAT4x3, GLSL_TYPE_FLOAT, 3, 4, "mat4x3"), +}; +const glsl_type *const glsl_type::mat2x3_type = & builtin_120_types[0]; +const glsl_type *const glsl_type::mat2x4_type = & builtin_120_types[1]; +const glsl_type *const glsl_type::mat3x2_type = & builtin_120_types[2]; +const glsl_type *const glsl_type::mat3x4_type = & builtin_120_types[3]; +const glsl_type *const glsl_type::mat4x2_type = & builtin_120_types[4]; +const glsl_type *const glsl_type::mat4x3_type = & builtin_120_types[5]; +/*@}*/ + +/** \name Types added in GLSL 1.30 + */ +/*@{*/ + +const glsl_type glsl_type::builtin_130_types[] = { + glsl_type(GL_UNSIGNED_INT, GLSL_TYPE_UINT, 1, 1, "uint"), + glsl_type(GL_UNSIGNED_INT_VEC2, GLSL_TYPE_UINT, 2, 1, "uvec2"), + glsl_type(GL_UNSIGNED_INT_VEC3, GLSL_TYPE_UINT, 3, 1, "uvec3"), + glsl_type(GL_UNSIGNED_INT_VEC4, GLSL_TYPE_UINT, 4, 1, "uvec4"), + + /* 1D and 2D texture arrays - several of these are included only in + * builtin_EXT_texture_array_types. + */ + glsl_type(GL_INT_SAMPLER_1D_ARRAY, + GLSL_SAMPLER_DIM_1D, 0, 1, GLSL_TYPE_INT, "isampler1DArray"), + glsl_type(GL_UNSIGNED_INT_SAMPLER_1D_ARRAY, + GLSL_SAMPLER_DIM_1D, 0, 1, GLSL_TYPE_UINT, "usampler1DArray"), + glsl_type(GL_INT_SAMPLER_2D_ARRAY, + GLSL_SAMPLER_DIM_2D, 0, 1, GLSL_TYPE_INT, "isampler2DArray"), + glsl_type(GL_UNSIGNED_INT_SAMPLER_2D_ARRAY, + GLSL_SAMPLER_DIM_2D, 0, 1, GLSL_TYPE_UINT, "usampler2DArray"), + + /* cube shadow samplers */ + glsl_type(GL_SAMPLER_CUBE_SHADOW, + GLSL_SAMPLER_DIM_CUBE, 1, 0, GLSL_TYPE_FLOAT, "samplerCubeShadow"), + + /* signed and unsigned integer samplers */ + glsl_type(GL_INT_SAMPLER_1D, + GLSL_SAMPLER_DIM_1D, 0, 0, GLSL_TYPE_INT, "isampler1D"), + glsl_type(GL_UNSIGNED_INT_SAMPLER_1D, + GLSL_SAMPLER_DIM_1D, 0, 0, GLSL_TYPE_UINT, "usampler1D"), + glsl_type(GL_INT_SAMPLER_2D, + GLSL_SAMPLER_DIM_2D, 0, 0, GLSL_TYPE_INT, "isampler2D"), + glsl_type(GL_UNSIGNED_INT_SAMPLER_2D, + GLSL_SAMPLER_DIM_2D, 0, 0, GLSL_TYPE_UINT, "usampler2D"), + glsl_type(GL_INT_SAMPLER_3D, + GLSL_SAMPLER_DIM_3D, 0, 0, GLSL_TYPE_INT, "isampler3D"), + glsl_type(GL_UNSIGNED_INT_SAMPLER_3D, + GLSL_SAMPLER_DIM_3D, 0, 0, GLSL_TYPE_UINT, "usampler3D"), + glsl_type(GL_INT_SAMPLER_CUBE, + GLSL_SAMPLER_DIM_CUBE, 0, 0, GLSL_TYPE_INT, "isamplerCube"), + glsl_type(GL_INT_SAMPLER_CUBE, + GLSL_SAMPLER_DIM_CUBE, 0, 0, GLSL_TYPE_UINT, "usamplerCube"), +}; + +const glsl_type *const glsl_type::uint_type = & builtin_130_types[0]; +const glsl_type *const glsl_type::uvec2_type = & builtin_130_types[1]; +const glsl_type *const glsl_type::uvec3_type = & builtin_130_types[2]; +const glsl_type *const glsl_type::uvec4_type = & builtin_130_types[3]; +/*@}*/ + +/** \name Sampler types added by GL_ARB_texture_rectangle + */ +/*@{*/ + +const glsl_type glsl_type::builtin_ARB_texture_rectangle_types[] = { + glsl_type(GL_SAMPLER_2D_RECT, + GLSL_SAMPLER_DIM_RECT, 0, 0, GLSL_TYPE_FLOAT, "sampler2DRect"), + glsl_type(GL_SAMPLER_2D_RECT_SHADOW, + GLSL_SAMPLER_DIM_RECT, 1, 0, GLSL_TYPE_FLOAT, "sampler2DRectShadow"), +}; +/*@}*/ + +/** \name Sampler types added by GL_EXT_texture_array + */ +/*@{*/ + +const glsl_type glsl_type::builtin_EXT_texture_array_types[] = { + glsl_type(GL_SAMPLER_1D_ARRAY, + GLSL_SAMPLER_DIM_1D, 0, 1, GLSL_TYPE_FLOAT, "sampler1DArray"), + glsl_type(GL_SAMPLER_2D_ARRAY, + GLSL_SAMPLER_DIM_2D, 0, 1, GLSL_TYPE_FLOAT, "sampler2DArray"), + glsl_type(GL_SAMPLER_1D_ARRAY_SHADOW, + GLSL_SAMPLER_DIM_1D, 1, 1, GLSL_TYPE_FLOAT, "sampler1DArrayShadow"), + glsl_type(GL_SAMPLER_2D_ARRAY_SHADOW, + GLSL_SAMPLER_DIM_2D, 1, 1, GLSL_TYPE_FLOAT, "sampler2DArrayShadow"), +}; +/*@}*/ + +/** \name Sampler types added by GL_EXT_texture_buffer_object + */ +/*@{*/ + +const glsl_type glsl_type::builtin_EXT_texture_buffer_object_types[] = { + glsl_type(GL_SAMPLER_BUFFER, + GLSL_SAMPLER_DIM_BUF, 0, 0, GLSL_TYPE_FLOAT, "samplerBuffer"), + glsl_type(GL_INT_SAMPLER_BUFFER, + GLSL_SAMPLER_DIM_BUF, 0, 0, GLSL_TYPE_INT, "isamplerBuffer"), + glsl_type(GL_UNSIGNED_INT_SAMPLER_BUFFER, + GLSL_SAMPLER_DIM_BUF, 0, 0, GLSL_TYPE_UINT, "usamplerBuffer"), +}; +/*@}*/ diff --git a/3rdparty/glsl-optimizer/src/glsl/builtin_variables.h b/3rdparty/glsl-optimizer/src/glsl/builtin_variables.h new file mode 100644 index 000000000..9b4f5d9e3 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtin_variables.h @@ -0,0 +1,110 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include "main/core.h" /* for slot numbers */ + +struct builtin_variable { + enum ir_variable_mode mode; + int slot; + const char *type; + const char *name; +}; + +static const builtin_variable builtin_core_vs_variables[] = { + { ir_var_out, VERT_RESULT_HPOS, "vec4", "gl_Position" }, + { ir_var_out, VERT_RESULT_PSIZ, "float", "gl_PointSize" }, +}; + +static const builtin_variable builtin_core_fs_variables[] = { + { ir_var_in, FRAG_ATTRIB_WPOS, "vec4", "gl_FragCoord" }, + { ir_var_in, FRAG_ATTRIB_FACE, "bool", "gl_FrontFacing" }, + { ir_var_out, FRAG_RESULT_COLOR, "vec4", "gl_FragColor" }, +}; + +static const builtin_variable builtin_100ES_fs_variables[] = { + { ir_var_in, FRAG_ATTRIB_PNTC, "vec2", "gl_PointCoord" }, +}; + +static const builtin_variable builtin_110_fs_variables[] = { + { ir_var_out, FRAG_RESULT_DEPTH, "float", "gl_FragDepth" }, +}; + +static const builtin_variable builtin_110_deprecated_fs_variables[] = { + { ir_var_in, FRAG_ATTRIB_COL0, "vec4", "gl_Color" }, + { ir_var_in, FRAG_ATTRIB_COL1, "vec4", "gl_SecondaryColor" }, + { ir_var_in, FRAG_ATTRIB_FOGC, "float", "gl_FogFragCoord" }, +}; + +static const builtin_variable builtin_110_deprecated_vs_variables[] = { + { ir_var_in, VERT_ATTRIB_POS, "vec4", "gl_Vertex" }, + { ir_var_in, VERT_ATTRIB_NORMAL, "vec3", "gl_Normal" }, + { ir_var_in, VERT_ATTRIB_COLOR0, "vec4", "gl_Color" }, + { ir_var_in, VERT_ATTRIB_COLOR1, "vec4", "gl_SecondaryColor" }, + { ir_var_in, VERT_ATTRIB_TEX0, "vec4", "gl_MultiTexCoord0" }, + { ir_var_in, VERT_ATTRIB_TEX1, "vec4", "gl_MultiTexCoord1" }, + { ir_var_in, VERT_ATTRIB_TEX2, "vec4", "gl_MultiTexCoord2" }, + { ir_var_in, VERT_ATTRIB_TEX3, "vec4", "gl_MultiTexCoord3" }, + { ir_var_in, VERT_ATTRIB_TEX4, "vec4", "gl_MultiTexCoord4" }, + { ir_var_in, VERT_ATTRIB_TEX5, "vec4", "gl_MultiTexCoord5" }, + { ir_var_in, VERT_ATTRIB_TEX6, "vec4", "gl_MultiTexCoord6" }, + { ir_var_in, VERT_ATTRIB_TEX7, "vec4", "gl_MultiTexCoord7" }, + { ir_var_in, VERT_ATTRIB_FOG, "float", "gl_FogCoord" }, + { ir_var_out, VERT_RESULT_HPOS, "vec4", "gl_ClipVertex" }, + { ir_var_out, VERT_RESULT_COL0, "vec4", "gl_FrontColor" }, + { ir_var_out, VERT_RESULT_BFC0, "vec4", "gl_BackColor" }, + { ir_var_out, VERT_RESULT_COL1, "vec4", "gl_FrontSecondaryColor" }, + { ir_var_out, VERT_RESULT_BFC1, "vec4", "gl_BackSecondaryColor" }, + { ir_var_out, VERT_RESULT_FOGC, "float", "gl_FogFragCoord" }, +}; + +static const builtin_variable builtin_120_fs_variables[] = { + { ir_var_in, FRAG_ATTRIB_PNTC, "vec2", "gl_PointCoord" }, +}; + +static const builtin_variable builtin_130_vs_variables[] = { + { ir_var_in, -1, "int", "gl_VertexID" }, +}; + +static const builtin_variable builtin_110_deprecated_uniforms[] = { + { ir_var_uniform, -1, "mat4", "gl_ModelViewMatrix" }, + { ir_var_uniform, -1, "mat4", "gl_ProjectionMatrix" }, + { ir_var_uniform, -1, "mat4", "gl_ModelViewProjectionMatrix" }, + { ir_var_uniform, -1, "mat3", "gl_NormalMatrix" }, + { ir_var_uniform, -1, "mat4", "gl_ModelViewMatrixInverse" }, + { ir_var_uniform, -1, "mat4", "gl_ProjectionMatrixInverse" }, + { ir_var_uniform, -1, "mat4", "gl_ModelViewProjectionMatrixInverse" }, + { ir_var_uniform, -1, "mat4", "gl_ModelViewMatrixTranspose" }, + { ir_var_uniform, -1, "mat4", "gl_ProjectionMatrixTranspose" }, + { ir_var_uniform, -1, "mat4", "gl_ModelViewProjectionMatrixTranspose" }, + { ir_var_uniform, -1, "mat4", "gl_ModelViewMatrixInverseTranspose" }, + { ir_var_uniform, -1, "mat4", "gl_ProjectionMatrixInverseTranspose" }, + { ir_var_uniform, -1, "mat4", "gl_ModelViewProjectionMatrixInverseTranspose" }, + { ir_var_uniform, -1, "float", "gl_NormalScale" }, + { ir_var_uniform, -1, "gl_LightModelParameters", "gl_LightModel"}, + + /* Mesa-internal ATI_envmap_bumpmap state. */ + { ir_var_uniform, -1, "vec2", "gl_MESABumpRotMatrix0"}, + { ir_var_uniform, -1, "vec2", "gl_MESABumpRotMatrix1"}, + { ir_var_uniform, -1, "vec4", "gl_MESAFogParamsOptimized"}, +}; + diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/ir/abs b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/abs new file mode 100644 index 000000000..d07d1d99e --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/abs @@ -0,0 +1,41 @@ +((function abs + (signature float + (parameters + (declare (in) float arg0)) + ((return (expression float abs (var_ref arg0))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0)) + ((return (expression vec2 abs (var_ref arg0))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0)) + ((return (expression vec3 abs (var_ref arg0))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0)) + ((return (expression vec4 abs (var_ref arg0))))) + + (signature int + (parameters + (declare (in) int arg0)) + ((return (expression int abs (var_ref arg0))))) + + (signature ivec2 + (parameters + (declare (in) ivec2 arg0)) + ((return (expression ivec2 abs (var_ref arg0))))) + + (signature ivec3 + (parameters + (declare (in) ivec3 arg0)) + ((return (expression ivec3 abs (var_ref arg0))))) + + (signature ivec4 + (parameters + (declare (in) ivec4 arg0)) + ((return (expression ivec4 abs (var_ref arg0))))) +)) diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/ir/acos b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/acos new file mode 100644 index 000000000..d1cfebeff --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/acos @@ -0,0 +1,22 @@ +((function acos + (signature float + (parameters + (declare (in) float x)) + ((return (expression float - (constant float (1.5707963)) + (call asin ((var_ref x))))))) + (signature vec2 + (parameters + (declare (in) vec2 x)) + ((return (expression vec2 - (constant float (1.5707963)) + (call asin ((var_ref x))))))) + (signature vec3 + (parameters + (declare (in) vec3 x)) + ((return (expression vec3 - (constant float (1.5707963)) + (call asin ((var_ref x))))))) + (signature vec4 + (parameters + (declare (in) vec4 x)) + ((return (expression vec4 - (constant float (1.5707963)) + (call asin ((var_ref x))))))) +)) diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/ir/acosh b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/acosh new file mode 100644 index 000000000..5518e7575 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/acosh @@ -0,0 +1,21 @@ +((function acosh + (signature float + (parameters + (declare (in) float x)) + ((return (expression float log (expression float + (var_ref x) (expression float sqrt (expression float - (expression float * (var_ref x) (var_ref x)) (constant float (1))))))))) + + (signature vec2 + (parameters + (declare (in) vec2 x)) + ((return (expression vec2 log (expression vec2 + (var_ref x) (expression vec2 sqrt (expression vec2 - (expression vec2 * (var_ref x) (var_ref x)) (constant vec2 (1))))))))) + + (signature vec3 + (parameters + (declare (in) vec3 x)) + ((return (expression vec3 log (expression vec3 + (var_ref x) (expression vec3 sqrt (expression vec3 - (expression vec3 * (var_ref x) (var_ref x)) (constant vec3 (1))))))))) + + (signature vec4 + (parameters + (declare (in) vec4 x)) + ((return (expression vec4 log (expression vec4 + (var_ref x) (expression vec4 sqrt (expression vec4 - (expression vec4 * (var_ref x) (var_ref x)) (constant vec4 (1))))))))) +)) diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/ir/all b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/all new file mode 100644 index 000000000..2cac0dfb6 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/all @@ -0,0 +1,16 @@ +((function all + (signature bool + (parameters + (declare (in) bvec2 arg0)) + ((return (expression bool && (swiz x (var_ref arg0))(swiz y (var_ref arg0)))))) + + (signature bool + (parameters + (declare (in) bvec3 arg0)) + ((return (expression bool && (expression bool && (swiz x (var_ref arg0))(swiz y (var_ref arg0))) (swiz z (var_ref arg0)))))) + + (signature bool + (parameters + (declare (in) bvec4 arg0)) + ((return (expression bool && (expression bool && (expression bool && (swiz x (var_ref arg0))(swiz y (var_ref arg0))) (swiz z (var_ref arg0))) (swiz w (var_ref arg0)))))) +)) diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/ir/any b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/any new file mode 100644 index 000000000..cc6038a31 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/any @@ -0,0 +1,16 @@ +((function any + (signature bool + (parameters + (declare (in) bvec2 arg0)) + ((return (expression bool any (var_ref arg0))))) + + (signature bool + (parameters + (declare (in) bvec3 arg0)) + ((return (expression bool any (var_ref arg0))))) + + (signature bool + (parameters + (declare (in) bvec4 arg0)) + ((return (expression bool any (var_ref arg0))))) +)) diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/ir/asin b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/asin new file mode 100644 index 000000000..45d9e6729 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/asin @@ -0,0 +1,109 @@ +((function asin + (signature float + (parameters + (declare (in) float x)) + ((return (expression float * + (expression float sign (var_ref x)) + (expression float - + (constant float (1.5707964)) + (expression float * + (expression float sqrt + (expression float - + (constant float (1.0)) + (expression float abs (var_ref x)))) + (expression float + + (constant float (1.5707964)) + (expression float * + (expression float abs (var_ref x)) + (expression float + + (constant float (-0.21460183)) + (expression float * + (expression float abs (var_ref x)) + (expression float + + (constant float (0.086566724)) + (expression float * + (expression float abs (var_ref x)) + (constant float (-0.03102955)) + )))))))))))) + + (signature vec2 + (parameters + (declare (in) vec2 x)) + ((return (expression vec2 * + (expression vec2 sign (var_ref x)) + (expression vec2 - + (constant float (1.5707964)) + (expression vec2 * + (expression vec2 sqrt + (expression vec2 - + (constant float (1.0)) + (expression vec2 abs (var_ref x)))) + (expression vec2 + + (constant float (1.5707964)) + (expression vec2 * + (expression vec2 abs (var_ref x)) + (expression vec2 + + (constant float (-0.21460183)) + (expression vec2 * + (expression vec2 abs (var_ref x)) + (expression vec2 + + (constant float (0.086566724)) + (expression vec2 * + (expression vec2 abs (var_ref x)) + (constant float (-0.03102955)) + )))))))))))) + + (signature vec3 + (parameters + (declare (in) vec3 x)) + ((return (expression vec3 * + (expression vec3 sign (var_ref x)) + (expression vec3 - + (constant float (1.5707964)) + (expression vec3 * + (expression vec3 sqrt + (expression vec3 - + (constant float (1.0)) + (expression vec3 abs (var_ref x)))) + (expression vec3 + + (constant float (1.5707964)) + (expression vec3 * + (expression vec3 abs (var_ref x)) + (expression vec3 + + (constant float (-0.21460183)) + (expression vec3 * + (expression vec3 abs (var_ref x)) + (expression vec3 + + (constant float (0.086566724)) + (expression vec3 * + (expression vec3 abs (var_ref x)) + (constant float (-0.03102955)) + )))))))))))) + + (signature vec4 + (parameters + (declare (in) vec4 x)) + ((return (expression vec4 * + (expression vec4 sign (var_ref x)) + (expression vec4 - + (constant float (1.5707964)) + (expression vec4 * + (expression vec4 sqrt + (expression vec4 - + (constant float (1.0)) + (expression vec4 abs (var_ref x)))) + (expression vec4 + + (constant float (1.5707964)) + (expression vec4 * + (expression vec4 abs (var_ref x)) + (expression vec4 + + (constant float (-0.21460183)) + (expression vec4 * + (expression vec4 abs (var_ref x)) + (expression vec4 + + (constant float (0.086566724)) + (expression vec4 * + (expression vec4 abs (var_ref x)) + (constant float (-0.03102955)) + )))))))))))) +)) diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/ir/asinh b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/asinh new file mode 100644 index 000000000..cdc2c20e7 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/asinh @@ -0,0 +1,21 @@ +((function asinh + (signature float + (parameters + (declare (in) float x)) + ((return (expression float log (expression float + (var_ref x) (expression float sqrt (expression float + (expression float * (var_ref x) (var_ref x)) (constant float (1))))))))) + + (signature vec2 + (parameters + (declare (in) vec2 x)) + ((return (expression vec2 log (expression vec2 + (var_ref x) (expression vec2 sqrt (expression vec2 + (expression vec2 * (var_ref x) (var_ref x)) (constant vec2 (1))))))))) + + (signature vec3 + (parameters + (declare (in) vec3 x)) + ((return (expression vec3 log (expression vec3 + (var_ref x) (expression vec3 sqrt (expression vec3 + (expression vec3 * (var_ref x) (var_ref x)) (constant vec3 (1))))))))) + + (signature vec4 + (parameters + (declare (in) vec4 x)) + ((return (expression vec4 log (expression vec4 + (var_ref x) (expression vec4 sqrt (expression vec4 + (expression vec4 * (var_ref x) (var_ref x)) (constant vec4 (1))))))))) +)) diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/ir/atan b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/atan new file mode 100644 index 000000000..7b5ea13c6 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/atan @@ -0,0 +1,128 @@ +((function atan + (signature float + (parameters + (declare (in) float y_over_x)) + ((return (call asin ((expression float * + (var_ref y_over_x) + (expression float rsq + (expression float + + (expression float * + (var_ref y_over_x) + (var_ref y_over_x)) + (constant float (1.0)))))))))) + + (signature vec2 + (parameters + (declare (in) vec2 y_over_x)) + ((return (call asin ((expression vec2 * + (var_ref y_over_x) + (expression vec2 rsq + (expression vec2 + + (expression vec2 * + (var_ref y_over_x) + (var_ref y_over_x)) + (constant float (1.0)))))))))) + + (signature vec3 + (parameters + (declare (in) vec3 y_over_x)) + ((return (call asin ((expression vec3 * + (var_ref y_over_x) + (expression vec3 rsq + (expression vec3 + + (expression vec3 * + (var_ref y_over_x) + (var_ref y_over_x)) + (constant float (1.0)))))))))) + + (signature vec4 + (parameters + (declare (in) vec4 y_over_x)) + ((return (call asin ((expression vec4 * + (var_ref y_over_x) + (expression vec4 rsq + (expression vec4 + + (expression vec4 * + (var_ref y_over_x) + (var_ref y_over_x)) + (constant float (1.0)))))))))) + + (signature float + (parameters + (declare (in ) float y) + (declare (in ) float x) + ) + ( + (declare () float r) + (if (expression bool > + (expression float abs (var_ref x)) + (expression float * (constant float (1.0e-8)) (expression float abs (var_ref y)))) ( + (assign (x) (var_ref r) (call atan ((expression float / (var_ref y) (var_ref x))))) + (if (expression bool < (var_ref x) (constant float (0.000000)) ) ( + (if (expression bool >= (var_ref y) (constant float (0.000000)) ) + ((assign (x) (var_ref r) (expression float + (var_ref r) (constant float (3.141593))))) + ((assign (x) (var_ref r) (expression float - (var_ref r) (constant float (3.141593)))))) + ) + ( + )) + ) + ( + (declare () float sgn) + (assign (x) (var_ref sgn) (expression float sign (var_ref y))) + (assign (x) (var_ref r) (expression float * (var_ref sgn) (constant float (1.5707965)))) + )) + + (return (var_ref r) ) + )) + + + + (signature vec2 + (parameters + (declare (in) vec2 y) + (declare (in) vec2 x)) + ((declare () vec2 r) + (assign (x) (var_ref r) + (call atan ((swiz x (var_ref y)) + (swiz x (var_ref x))))) + (assign (y) (var_ref r) + (call atan ((swiz y (var_ref y)) + (swiz y (var_ref x))))) + (return (var_ref r)))) + + (signature vec3 + (parameters + (declare (in) vec3 y) + (declare (in) vec3 x)) + ((declare () vec3 r) + (assign (x) (var_ref r) + (call atan ((swiz x (var_ref y)) + (swiz x (var_ref x))))) + (assign (y) (var_ref r) + (call atan ((swiz y (var_ref y)) + (swiz y (var_ref x))))) + (assign (z) (var_ref r) + (call atan ((swiz z (var_ref y)) + (swiz z (var_ref x))))) + (return (var_ref r)))) + + (signature vec4 + (parameters + (declare (in) vec4 y) + (declare (in) vec4 x)) + ((declare () vec4 r) + (assign (x) (var_ref r) + (call atan ((swiz x (var_ref y)) + (swiz x (var_ref x))))) + (assign (y) (var_ref r) + (call atan ((swiz y (var_ref y)) + (swiz y (var_ref x))))) + (assign (z) (var_ref r) + (call atan ((swiz z (var_ref y)) + (swiz z (var_ref x))))) + (assign (w) (var_ref r) + (call atan ((swiz w (var_ref y)) + (swiz w (var_ref x))))) + (return (var_ref r))))) + +)) diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/ir/atanh b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/atanh new file mode 100644 index 000000000..5559e9740 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/atanh @@ -0,0 +1,37 @@ +((function atanh + (signature float + (parameters + (declare (in) float x)) + ((return (expression float * (constant float (0.5)) + (expression float log + (expression float / + (expression float + (constant float (1)) (var_ref x)) + (expression float - (constant float (1)) (var_ref x)))))))) + + (signature vec2 + (parameters + (declare (in) vec2 x)) + ((return (expression vec2 * (constant vec2 (0.5)) + (expression vec2 log + (expression vec2 / + (expression vec2 + (constant vec2 (1)) (var_ref x)) + (expression vec2 - (constant vec2 (1)) (var_ref x)))))))) + + (signature vec3 + (parameters + (declare (in) vec3 x)) + ((return (expression vec3 * (constant vec3 (0.5)) + (expression vec3 log + (expression vec3 / + (expression vec3 + (constant vec3 (1)) (var_ref x)) + (expression vec3 - (constant vec3 (1)) (var_ref x)))))))) + + (signature vec4 + (parameters + (declare (in) vec4 x)) + ((return (expression vec4 * (constant vec4 (0.5)) + (expression vec4 log + (expression vec4 / + (expression vec4 + (constant vec4 (1)) (var_ref x)) + (expression vec4 - (constant vec4 (1)) (var_ref x)))))))) +)) diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/ir/ceil b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/ceil new file mode 100644 index 000000000..a26a77504 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/ceil @@ -0,0 +1,21 @@ +((function ceil + (signature float + (parameters + (declare (in) float arg0)) + ((return (expression float ceil (var_ref arg0))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0)) + ((return (expression vec2 ceil (var_ref arg0))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0)) + ((return (expression vec3 ceil (var_ref arg0))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0)) + ((return (expression vec4 ceil (var_ref arg0))))) +)) diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/ir/clamp b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/clamp new file mode 100644 index 000000000..2bdc466b2 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/clamp @@ -0,0 +1,148 @@ +((function clamp + (signature float + (parameters + (declare (in) float arg0) + (declare (in) float arg1) + (declare (in) float arg2)) + ((return (expression float max (expression float min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0) + (declare (in) vec2 arg1) + (declare (in) vec2 arg2)) + ((return (expression vec2 max (expression vec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0) + (declare (in) vec3 arg1) + (declare (in) vec3 arg2)) + ((return (expression vec3 max (expression vec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0) + (declare (in) vec4 arg1) + (declare (in) vec4 arg2)) + ((return (expression vec4 max (expression vec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0) + (declare (in) float arg1) + (declare (in) float arg2)) + ((return (expression vec2 max (expression vec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0) + (declare (in) float arg1) + (declare (in) float arg2)) + ((return (expression vec3 max (expression vec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0) + (declare (in) float arg1) + (declare (in) float arg2)) + ((return (expression vec4 max (expression vec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) + + (signature int + (parameters + (declare (in) int arg0) + (declare (in) int arg1) + (declare (in) int arg2)) + ((return (expression int max (expression int min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) + + (signature ivec2 + (parameters + (declare (in) ivec2 arg0) + (declare (in) ivec2 arg1) + (declare (in) ivec2 arg2)) + ((return (expression ivec2 max (expression ivec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) + + (signature ivec3 + (parameters + (declare (in) ivec3 arg0) + (declare (in) ivec3 arg1) + (declare (in) ivec3 arg2)) + ((return (expression ivec3 max (expression ivec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) + + (signature ivec4 + (parameters + (declare (in) ivec4 arg0) + (declare (in) ivec4 arg1) + (declare (in) ivec4 arg2)) + ((return (expression ivec4 max (expression ivec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) + + (signature ivec2 + (parameters + (declare (in) ivec2 arg0) + (declare (in) int arg1) + (declare (in) int arg2)) + ((return (expression ivec2 max (expression ivec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) + + (signature ivec3 + (parameters + (declare (in) ivec3 arg0) + (declare (in) int arg1) + (declare (in) int arg2)) + ((return (expression ivec3 max (expression ivec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) + + (signature ivec4 + (parameters + (declare (in) ivec4 arg0) + (declare (in) int arg1) + (declare (in) int arg2)) + ((return (expression ivec4 max (expression ivec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) + + (signature uint + (parameters + (declare (in) uint arg0) + (declare (in) uint arg1) + (declare (in) uint arg2)) + ((return (expression uint max (expression uint min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) + + (signature uvec2 + (parameters + (declare (in) uvec2 arg0) + (declare (in) uvec2 arg1) + (declare (in) uvec2 arg2)) + ((return (expression uvec2 max (expression uvec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) + + (signature uvec3 + (parameters + (declare (in) uvec3 arg0) + (declare (in) uvec3 arg1) + (declare (in) uvec3 arg2)) + ((return (expression uvec3 max (expression uvec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) + + (signature uvec4 + (parameters + (declare (in) uvec4 arg0) + (declare (in) uvec4 arg1) + (declare (in) uvec4 arg2)) + ((return (expression uvec4 max (expression uvec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) + + (signature uvec2 + (parameters + (declare (in) uvec2 arg0) + (declare (in) uint arg1) + (declare (in) uint arg2)) + ((return (expression uvec2 max (expression uvec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) + + (signature uvec3 + (parameters + (declare (in) uvec3 arg0) + (declare (in) uint arg1) + (declare (in) uint arg2)) + ((return (expression uvec3 max (expression uvec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) + + (signature uvec4 + (parameters + (declare (in) uvec4 arg0) + (declare (in) uint arg1) + (declare (in) uint arg2)) + ((return (expression uvec4 max (expression uvec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1))))) +)) diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/ir/cos b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/cos new file mode 100644 index 000000000..88f266ecc --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/cos @@ -0,0 +1,21 @@ +((function cos + (signature float + (parameters + (declare (in) float angle)) + ((return (expression float cos (var_ref angle))))) + + (signature vec2 + (parameters + (declare (in) vec2 angle)) + ((return (expression vec2 cos (var_ref angle))))) + + (signature vec3 + (parameters + (declare (in) vec3 angle)) + ((return (expression vec3 cos (var_ref angle))))) + + (signature vec4 + (parameters + (declare (in) vec4 angle)) + ((return (expression vec4 cos (var_ref angle))))) +)) diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/ir/cosh b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/cosh new file mode 100644 index 000000000..45e0ae427 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/cosh @@ -0,0 +1,30 @@ +((function cosh + (signature float + (parameters + (declare (in) float x)) + ((return (expression float * (constant float (0.5)) + (expression float + + (expression float exp (var_ref x)) + (expression float exp (expression float neg (var_ref x)))))))) + (signature vec2 + (parameters + (declare (in) vec2 x)) + ((return (expression vec2 * (constant vec2 (0.5)) + (expression vec2 + + (expression vec2 exp (var_ref x)) + (expression vec2 exp (expression vec2 neg (var_ref x)))))))) + (signature vec3 + (parameters + (declare (in) vec3 x)) + ((return (expression vec3 * (constant vec3 (0.5)) + (expression vec3 + + (expression vec3 exp (var_ref x)) + (expression vec3 exp (expression vec3 neg (var_ref x)))))))) + (signature vec4 + (parameters + (declare (in) vec4 x)) + ((return (expression vec4 * (constant vec4 (0.5)) + (expression vec4 + + (expression vec4 exp (var_ref x)) + (expression vec4 exp (expression vec4 neg (var_ref x)))))))) +)) diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/ir/cross b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/cross new file mode 100644 index 000000000..02991fe42 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/cross @@ -0,0 +1,9 @@ +((function cross + (signature vec3 + (parameters + (declare (in) vec3 a) + (declare (in) vec3 b)) + ((return (expression vec3 - + (expression vec3 * (swiz yzx (var_ref a)) (swiz zxy (var_ref b))) + (expression vec3 * (swiz zxy (var_ref a)) (swiz yzx (var_ref b))))))) +)) diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/ir/dFdx b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/dFdx new file mode 100644 index 000000000..30594d33c --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/dFdx @@ -0,0 +1,21 @@ +((function dFdx + (signature float + (parameters + (declare (in) float p)) + ((return (expression float dFdx (var_ref p))))) + + (signature vec2 + (parameters + (declare (in) vec2 p)) + ((return (expression vec2 dFdx (var_ref p))))) + + (signature vec3 + (parameters + (declare (in) vec3 p)) + ((return (expression vec3 dFdx (var_ref p))))) + + (signature vec4 + (parameters + (declare (in) vec4 p)) + ((return (expression vec4 dFdx (var_ref p))))) +)) diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/ir/dFdy b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/dFdy new file mode 100644 index 000000000..fb5798d3c --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/dFdy @@ -0,0 +1,21 @@ +((function dFdy + (signature float + (parameters + (declare (in) float p)) + ((return (expression float dFdy (var_ref p))))) + + (signature vec2 + (parameters + (declare (in) vec2 p)) + ((return (expression vec2 dFdy (var_ref p))))) + + (signature vec3 + (parameters + (declare (in) vec3 p)) + ((return (expression vec3 dFdy (var_ref p))))) + + (signature vec4 + (parameters + (declare (in) vec4 p)) + ((return (expression vec4 dFdy (var_ref p))))) +)) diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/ir/degrees b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/degrees new file mode 100644 index 000000000..dc0d7b9e2 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/degrees @@ -0,0 +1,21 @@ +((function degrees + (signature float + (parameters + (declare (in) float arg0)) + ((return (expression float * (var_ref arg0) (constant float (57.295780)))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0)) + ((return (expression vec2 * (var_ref arg0) (constant float (57.295780)))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0)) + ((return (expression vec3 * (var_ref arg0) (constant float (57.295780)))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0)) + ((return (expression vec4 * (var_ref arg0) (constant float (57.295780)))))) +)) diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/ir/distance b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/distance new file mode 100644 index 000000000..c249f8c99 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/distance @@ -0,0 +1,31 @@ +((function distance + (signature float + (parameters + (declare (in) float p0) + (declare (in) float p1)) + ((return (expression float abs (expression float - (var_ref p0) (var_ref p1)))))) + + (signature float + (parameters + (declare (in) vec2 p0) + (declare (in) vec2 p1)) + ((declare () vec2 p) + (assign (xy) (var_ref p) (expression vec2 - (var_ref p0) (var_ref p1))) + (return (expression float sqrt (expression float dot (var_ref p) (var_ref p)))))) + + (signature float + (parameters + (declare (in) vec3 p0) + (declare (in) vec3 p1)) + ((declare () vec3 p) + (assign (xyz) (var_ref p) (expression vec3 - (var_ref p0) (var_ref p1))) + (return (expression float sqrt (expression float dot (var_ref p) (var_ref p)))))) + + (signature float + (parameters + (declare (in) vec4 p0) + (declare (in) vec4 p1)) + ((declare () vec4 p) + (assign (xyzw) (var_ref p) (expression vec4 - (var_ref p0) (var_ref p1))) + (return (expression float sqrt (expression float dot (var_ref p) (var_ref p)))))) +)) diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/ir/dot b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/dot new file mode 100644 index 000000000..1f27f3235 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/dot @@ -0,0 +1,25 @@ +((function dot + (signature float + (parameters + (declare (in) float arg0) + (declare (in) float arg1)) + ((return (expression float * (var_ref arg0) (var_ref arg1))))) + + (signature float + (parameters + (declare (in) vec2 arg0) + (declare (in) vec2 arg1)) + ((return (expression float dot (var_ref arg0) (var_ref arg1))))) + + (signature float + (parameters + (declare (in) vec3 arg0) + (declare (in) vec3 arg1)) + ((return (expression float dot (var_ref arg0) (var_ref arg1))))) + + (signature float + (parameters + (declare (in) vec4 arg0) + (declare (in) vec4 arg1)) + ((return (expression float dot (var_ref arg0) (var_ref arg1))))) +)) diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/ir/equal b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/equal new file mode 100644 index 000000000..a414b3e53 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/equal @@ -0,0 +1,73 @@ +((function equal + (signature bvec2 + (parameters + (declare (in) vec2 arg0) + (declare (in) vec2 arg1)) + ((return (expression bvec2 == (var_ref arg0) (var_ref arg1))))) + + (signature bvec3 + (parameters + (declare (in) vec3 arg0) + (declare (in) vec3 arg1)) + ((return (expression bvec3 == (var_ref arg0) (var_ref arg1))))) + + (signature bvec4 + (parameters + (declare (in) vec4 arg0) + (declare (in) vec4 arg1)) + ((return (expression bvec4 == (var_ref arg0) (var_ref arg1))))) + + (signature bvec2 + (parameters + (declare (in) bvec2 arg0) + (declare (in) bvec2 arg1)) + ((return (expression bvec2 == (var_ref arg0) (var_ref arg1))))) + + (signature bvec3 + (parameters + (declare (in) bvec3 arg0) + (declare (in) bvec3 arg1)) + ((return (expression bvec3 == (var_ref arg0) (var_ref arg1))))) + + (signature bvec4 + (parameters + (declare (in) bvec4 arg0) + (declare (in) bvec4 arg1)) + ((return (expression bvec4 == (var_ref arg0) (var_ref arg1))))) + + (signature bvec2 + (parameters + (declare (in) ivec2 arg0) + (declare (in) ivec2 arg1)) + ((return (expression bvec2 == (var_ref arg0) (var_ref arg1))))) + + (signature bvec3 + (parameters + (declare (in) ivec3 arg0) + (declare (in) ivec3 arg1)) + ((return (expression bvec3 == (var_ref arg0) (var_ref arg1))))) + + (signature bvec4 + (parameters + (declare (in) ivec4 arg0) + (declare (in) ivec4 arg1)) + ((return (expression bvec4 == (var_ref arg0) (var_ref arg1))))) + + (signature bvec2 + (parameters + (declare (in) uvec2 arg0) + (declare (in) uvec2 arg1)) + ((return (expression bvec2 == (var_ref arg0) (var_ref arg1))))) + + (signature bvec3 + (parameters + (declare (in) uvec3 arg0) + (declare (in) uvec3 arg1)) + ((return (expression bvec3 == (var_ref arg0) (var_ref arg1))))) + + (signature bvec4 + (parameters + (declare (in) uvec4 arg0) + (declare (in) uvec4 arg1)) + ((return (expression bvec4 == (var_ref arg0) (var_ref arg1))))) +)) diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/ir/exp b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/exp new file mode 100644 index 000000000..a73bd6a7f --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/exp @@ -0,0 +1,21 @@ +((function exp + (signature float + (parameters + (declare (in) float arg0)) + ((return (expression float exp (var_ref arg0))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0)) + ((return (expression vec2 exp (var_ref arg0))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0)) + ((return (expression vec3 exp (var_ref arg0))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0)) + ((return (expression vec4 exp (var_ref arg0))))) +)) diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/ir/exp2 b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/exp2 new file mode 100644 index 000000000..a842d3fe6 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/exp2 @@ -0,0 +1,21 @@ +((function exp2 + (signature float + (parameters + (declare (in) float arg0)) + ((return (expression float exp2 (var_ref arg0))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0)) + ((return (expression vec2 exp2 (var_ref arg0))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0)) + ((return (expression vec3 exp2 (var_ref arg0))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0)) + ((return (expression vec4 exp2 (var_ref arg0))))) +)) diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/ir/faceforward b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/faceforward new file mode 100644 index 000000000..35b79571c --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/faceforward @@ -0,0 +1,37 @@ +((function faceforward + (signature float + (parameters + (declare (in) float N) + (declare (in) float I) + (declare (in) float Nref)) + ((if (expression bool < (expression float * (var_ref Nref) (var_ref I)) (constant float (0))) + ((return (var_ref N))) + ((return (expression float neg (var_ref N))))))) + + (signature vec2 + (parameters + (declare (in) vec2 N) + (declare (in) vec2 I) + (declare (in) vec2 Nref)) + ((if (expression bool < (expression float dot (var_ref Nref) (var_ref I)) (constant float (0))) + ((return (var_ref N))) + ((return (expression vec2 neg (var_ref N))))))) + + (signature vec3 + (parameters + (declare (in) vec3 N) + (declare (in) vec3 I) + (declare (in) vec3 Nref)) + ((if (expression bool < (expression float dot (var_ref Nref) (var_ref I)) (constant float (0))) + ((return (var_ref N))) + ((return (expression vec3 neg (var_ref N))))))) + + (signature vec4 + (parameters + (declare (in) vec4 N) + (declare (in) vec4 I) + (declare (in) vec4 Nref)) + ((if (expression bool < (expression float dot (var_ref Nref) (var_ref I)) (constant float (0))) + ((return (var_ref N))) + ((return (expression vec4 neg (var_ref N))))))) +)) diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/ir/floor b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/floor new file mode 100644 index 000000000..8dd805279 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/floor @@ -0,0 +1,21 @@ +((function floor + (signature float + (parameters + (declare (in) float arg0)) + ((return (expression float floor (var_ref arg0))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0)) + ((return (expression vec2 floor (var_ref arg0))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0)) + ((return (expression vec3 floor (var_ref arg0))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0)) + ((return (expression vec4 floor (var_ref arg0))))) +)) diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/ir/fract b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/fract new file mode 100644 index 000000000..3f0763d1b --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/fract @@ -0,0 +1,22 @@ +((function fract + (signature float + (parameters + (declare (in) float x)) + ((return (expression float fract (var_ref x))))) + + (signature vec2 + (parameters + (declare (in) vec2 x)) + ((return (expression vec2 fract (var_ref x))))) + + (signature vec3 + (parameters + (declare (in) vec3 x)) + ((return (expression vec3 fract (var_ref x))))) + + (signature vec4 + (parameters + (declare (in) vec4 x)) + ((return (expression vec4 fract (var_ref x))))) +)) + diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/ir/ftransform b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/ftransform new file mode 100644 index 000000000..9ca63dc1e --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/ftransform @@ -0,0 +1,9 @@ +((declare (uniform) mat4 gl_ModelViewProjectionMatrix) + (declare (in) vec4 gl_Vertex) + (function ftransform + (signature vec4 + (parameters) + ((return (expression vec4 * + (var_ref gl_ModelViewProjectionMatrix) + (var_ref gl_Vertex))))) +)) diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/ir/fwidth b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/fwidth new file mode 100644 index 000000000..385e05d6a --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/fwidth @@ -0,0 +1,29 @@ +((function fwidth + (signature float + (parameters + (declare (in) float p)) + ((return (expression float + + (expression float abs (expression float dFdx (var_ref p))) + (expression float abs (expression float dFdy (var_ref p))))))) + + (signature vec2 + (parameters + (declare (in) vec2 p)) + ((return (expression vec2 + + (expression vec2 abs (expression vec2 dFdx (var_ref p))) + (expression vec2 abs (expression vec2 dFdy (var_ref p))))))) + + (signature vec3 + (parameters + (declare (in) vec3 p)) + ((return (expression vec3 + + (expression vec3 abs (expression vec3 dFdx (var_ref p))) + (expression vec3 abs (expression vec3 dFdy (var_ref p))))))) + + (signature vec4 + (parameters + (declare (in) vec4 p)) + ((return (expression vec4 + + (expression vec4 abs (expression vec4 dFdx (var_ref p))) + (expression vec4 abs (expression vec4 dFdy (var_ref p))))))) +)) diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/ir/greaterThan b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/greaterThan new file mode 100644 index 000000000..18af86528 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/greaterThan @@ -0,0 +1,55 @@ +((function greaterThan + (signature bvec2 + (parameters + (declare (in) vec2 arg0) + (declare (in) vec2 arg1)) + ((return (expression bvec2 > (var_ref arg0) (var_ref arg1))))) + + (signature bvec3 + (parameters + (declare (in) vec3 arg0) + (declare (in) vec3 arg1)) + ((return (expression bvec3 > (var_ref arg0) (var_ref arg1))))) + + (signature bvec4 + (parameters + (declare (in) vec4 arg0) + (declare (in) vec4 arg1)) + ((return (expression bvec4 > (var_ref arg0) (var_ref arg1))))) + + (signature bvec2 + (parameters + (declare (in) ivec2 arg0) + (declare (in) ivec2 arg1)) + ((return (expression bvec2 > (var_ref arg0) (var_ref arg1))))) + + (signature bvec3 + (parameters + (declare (in) ivec3 arg0) + (declare (in) ivec3 arg1)) + ((return (expression bvec3 > (var_ref arg0) (var_ref arg1))))) + + (signature bvec4 + (parameters + (declare (in) ivec4 arg0) + (declare (in) ivec4 arg1)) + ((return (expression bvec4 > (var_ref arg0) (var_ref arg1))))) + + (signature bvec2 + (parameters + (declare (in) uvec2 arg0) + (declare (in) uvec2 arg1)) + ((return (expression bvec2 > (var_ref arg0) (var_ref arg1))))) + + (signature bvec3 + (parameters + (declare (in) uvec3 arg0) + (declare (in) uvec3 arg1)) + ((return (expression bvec3 > (var_ref arg0) (var_ref arg1))))) + + (signature bvec4 + (parameters + (declare (in) uvec4 arg0) + (declare (in) uvec4 arg1)) + ((return (expression bvec4 > (var_ref arg0) (var_ref arg1))))) +)) diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/ir/greaterThanEqual b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/greaterThanEqual new file mode 100644 index 000000000..6d3bc892c --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/greaterThanEqual @@ -0,0 +1,55 @@ +((function greaterThanEqual + (signature bvec2 + (parameters + (declare (in) vec2 arg0) + (declare (in) vec2 arg1)) + ((return (expression bvec2 >= (var_ref arg0) (var_ref arg1))))) + + (signature bvec3 + (parameters + (declare (in) vec3 arg0) + (declare (in) vec3 arg1)) + ((return (expression bvec3 >= (var_ref arg0) (var_ref arg1))))) + + (signature bvec4 + (parameters + (declare (in) vec4 arg0) + (declare (in) vec4 arg1)) + ((return (expression bvec4 >= (var_ref arg0) (var_ref arg1))))) + + (signature bvec2 + (parameters + (declare (in) ivec2 arg0) + (declare (in) ivec2 arg1)) + ((return (expression bvec2 >= (var_ref arg0) (var_ref arg1))))) + + (signature bvec3 + (parameters + (declare (in) ivec3 arg0) + (declare (in) ivec3 arg1)) + ((return (expression bvec3 >= (var_ref arg0) (var_ref arg1))))) + + (signature bvec4 + (parameters + (declare (in) ivec4 arg0) + (declare (in) ivec4 arg1)) + ((return (expression bvec4 >= (var_ref arg0) (var_ref arg1))))) + + (signature bvec2 + (parameters + (declare (in) uvec2 arg0) + (declare (in) uvec2 arg1)) + ((return (expression bvec2 >= (var_ref arg0) (var_ref arg1))))) + + (signature bvec3 + (parameters + (declare (in) uvec3 arg0) + (declare (in) uvec3 arg1)) + ((return (expression bvec3 >= (var_ref arg0) (var_ref arg1))))) + + (signature bvec4 + (parameters + (declare (in) uvec4 arg0) + (declare (in) uvec4 arg1)) + ((return (expression bvec4 >= (var_ref arg0) (var_ref arg1))))) +)) diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/ir/inversesqrt b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/inversesqrt new file mode 100644 index 000000000..5b66d2b36 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/inversesqrt @@ -0,0 +1,21 @@ +((function inversesqrt + (signature float + (parameters + (declare (in) float arg0)) + ((return (expression float rsq (var_ref arg0))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0)) + ((return (expression vec2 rsq (var_ref arg0))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0)) + ((return (expression vec3 rsq (var_ref arg0))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0)) + ((return (expression vec4 rsq (var_ref arg0))))) +)) diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/ir/length b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/length new file mode 100644 index 000000000..b72334ee8 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/length @@ -0,0 +1,21 @@ +((function length + (signature float + (parameters + (declare (in) float arg0)) + ((return (expression float abs (var_ref arg0))))) + + (signature float + (parameters + (declare (in) vec2 arg0)) + ((return (expression float sqrt (expression float dot (var_ref arg0) (var_ref arg0)))))) + + (signature float + (parameters + (declare (in) vec3 arg0)) + ((return (expression float sqrt (expression float dot (var_ref arg0) (var_ref arg0)))))) + + (signature float + (parameters + (declare (in) vec4 arg0)) + ((return (expression float sqrt (expression float dot (var_ref arg0) (var_ref arg0)))))) +)) diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/ir/lessThan b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/lessThan new file mode 100644 index 000000000..8401fe9db --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/lessThan @@ -0,0 +1,55 @@ +((function lessThan + (signature bvec2 + (parameters + (declare (in) vec2 arg0) + (declare (in) vec2 arg1)) + ((return (expression bvec2 < (var_ref arg0) (var_ref arg1))))) + + (signature bvec3 + (parameters + (declare (in) vec3 arg0) + (declare (in) vec3 arg1)) + ((return (expression bvec3 < (var_ref arg0) (var_ref arg1))))) + + (signature bvec4 + (parameters + (declare (in) vec4 arg0) + (declare (in) vec4 arg1)) + ((return (expression bvec4 < (var_ref arg0) (var_ref arg1))))) + + (signature bvec2 + (parameters + (declare (in) ivec2 arg0) + (declare (in) ivec2 arg1)) + ((return (expression bvec2 < (var_ref arg0) (var_ref arg1))))) + + (signature bvec3 + (parameters + (declare (in) ivec3 arg0) + (declare (in) ivec3 arg1)) + ((return (expression bvec3 < (var_ref arg0) (var_ref arg1))))) + + (signature bvec4 + (parameters + (declare (in) ivec4 arg0) + (declare (in) ivec4 arg1)) + ((return (expression bvec4 < (var_ref arg0) (var_ref arg1))))) + + (signature bvec2 + (parameters + (declare (in) uvec2 arg0) + (declare (in) uvec2 arg1)) + ((return (expression bvec2 < (var_ref arg0) (var_ref arg1))))) + + (signature bvec3 + (parameters + (declare (in) uvec3 arg0) + (declare (in) uvec3 arg1)) + ((return (expression bvec3 < (var_ref arg0) (var_ref arg1))))) + + (signature bvec4 + (parameters + (declare (in) uvec4 arg0) + (declare (in) uvec4 arg1)) + ((return (expression bvec4 < (var_ref arg0) (var_ref arg1))))) +)) diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/ir/lessThanEqual b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/lessThanEqual new file mode 100644 index 000000000..c1cdd3fb6 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/lessThanEqual @@ -0,0 +1,55 @@ +((function lessThanEqual + (signature bvec2 + (parameters + (declare (in) vec2 arg0) + (declare (in) vec2 arg1)) + ((return (expression bvec2 <= (var_ref arg0) (var_ref arg1))))) + + (signature bvec3 + (parameters + (declare (in) vec3 arg0) + (declare (in) vec3 arg1)) + ((return (expression bvec3 <= (var_ref arg0) (var_ref arg1))))) + + (signature bvec4 + (parameters + (declare (in) vec4 arg0) + (declare (in) vec4 arg1)) + ((return (expression bvec4 <= (var_ref arg0) (var_ref arg1))))) + + (signature bvec2 + (parameters + (declare (in) ivec2 arg0) + (declare (in) ivec2 arg1)) + ((return (expression bvec2 <= (var_ref arg0) (var_ref arg1))))) + + (signature bvec3 + (parameters + (declare (in) ivec3 arg0) + (declare (in) ivec3 arg1)) + ((return (expression bvec3 <= (var_ref arg0) (var_ref arg1))))) + + (signature bvec4 + (parameters + (declare (in) ivec4 arg0) + (declare (in) ivec4 arg1)) + ((return (expression bvec4 <= (var_ref arg0) (var_ref arg1))))) + + (signature bvec2 + (parameters + (declare (in) uvec2 arg0) + (declare (in) uvec2 arg1)) + ((return (expression bvec2 <= (var_ref arg0) (var_ref arg1))))) + + (signature bvec3 + (parameters + (declare (in) uvec3 arg0) + (declare (in) uvec3 arg1)) + ((return (expression bvec3 <= (var_ref arg0) (var_ref arg1))))) + + (signature bvec4 + (parameters + (declare (in) uvec4 arg0) + (declare (in) uvec4 arg1)) + ((return (expression bvec4 <= (var_ref arg0) (var_ref arg1))))) +)) diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/ir/log b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/log new file mode 100644 index 000000000..d168abb5a --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/log @@ -0,0 +1,21 @@ +((function log + (signature float + (parameters + (declare (in) float arg0)) + ((return (expression float log (var_ref arg0))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0)) + ((return (expression vec2 log (var_ref arg0))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0)) + ((return (expression vec3 log (var_ref arg0))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0)) + ((return (expression vec4 log (var_ref arg0))))) +)) diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/ir/log2 b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/log2 new file mode 100644 index 000000000..b96c6276f --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/log2 @@ -0,0 +1,21 @@ +((function log2 + (signature float + (parameters + (declare (in) float arg0)) + ((return (expression float log2 (var_ref arg0))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0)) + ((return (expression vec2 log2 (var_ref arg0))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0)) + ((return (expression vec3 log2 (var_ref arg0))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0)) + ((return (expression vec4 log2 (var_ref arg0))))) +)) diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/ir/matrixCompMult b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/matrixCompMult new file mode 100644 index 000000000..2400f11af --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/matrixCompMult @@ -0,0 +1,91 @@ +((function matrixCompMult + (signature mat2 + (parameters + (declare (in) mat2 x) + (declare (in) mat2 y)) + ((declare () mat2 z) + (assign (xy) (array_ref (var_ref z) (constant int (0))) (expression vec2 * (array_ref (var_ref x) (constant int (0))) (array_ref (var_ref y) (constant int (0))))) + (assign (xy) (array_ref (var_ref z) (constant int (1))) (expression vec2 * (array_ref (var_ref x) (constant int (1))) (array_ref (var_ref y) (constant int (1))))) +(return (var_ref z)))) + + (signature mat3 + (parameters + (declare (in) mat3 x) + (declare (in) mat3 y)) + ((declare () mat3 z) + (assign (xyz) (array_ref (var_ref z) (constant int (0))) (expression vec3 * (array_ref (var_ref x) (constant int (0))) (array_ref (var_ref y) (constant int (0))))) + (assign (xyz) (array_ref (var_ref z) (constant int (1))) (expression vec3 * (array_ref (var_ref x) (constant int (1))) (array_ref (var_ref y) (constant int (1))))) + (assign (xyz) (array_ref (var_ref z) (constant int (2))) (expression vec3 * (array_ref (var_ref x) (constant int (2))) (array_ref (var_ref y) (constant int (2))))) +(return (var_ref z)))) + + (signature mat4 + (parameters + (declare (in) mat4 x) + (declare (in) mat4 y)) + ((declare () mat4 z) + (assign (xyzw) (array_ref (var_ref z) (constant int (0))) (expression vec4 * (array_ref (var_ref x) (constant int (0))) (array_ref (var_ref y) (constant int (0))))) + (assign (xyzw) (array_ref (var_ref z) (constant int (1))) (expression vec4 * (array_ref (var_ref x) (constant int (1))) (array_ref (var_ref y) (constant int (1))))) + (assign (xyzw) (array_ref (var_ref z) (constant int (2))) (expression vec4 * (array_ref (var_ref x) (constant int (2))) (array_ref (var_ref y) (constant int (2))))) + (assign (xyzw) (array_ref (var_ref z) (constant int (3))) (expression vec4 * (array_ref (var_ref x) (constant int (3))) (array_ref (var_ref y) (constant int (3))))) +(return (var_ref z)))) + + (signature mat2x3 + (parameters + (declare (in) mat2x3 x) + (declare (in) mat2x3 y)) + ((declare () mat2x3 z) + (assign (xyz) (array_ref (var_ref z) (constant int (0))) (expression vec3 * (array_ref (var_ref x) (constant int (0))) (array_ref (var_ref y) (constant int (0))))) + (assign (xyz) (array_ref (var_ref z) (constant int (1))) (expression vec3 * (array_ref (var_ref x) (constant int (1))) (array_ref (var_ref y) (constant int (1))))) +(return (var_ref z)))) + + (signature mat3x2 + (parameters + (declare (in) mat3x2 x) + (declare (in) mat3x2 y)) + ((declare () mat3x2 z) + (assign (xy) (array_ref (var_ref z) (constant int (0))) (expression vec2 * (array_ref (var_ref x) (constant int (0))) (array_ref (var_ref y) (constant int (0))))) + (assign (xy) (array_ref (var_ref z) (constant int (1))) (expression vec2 * (array_ref (var_ref x) (constant int (1))) (array_ref (var_ref y) (constant int (1))))) + (assign (xy) (array_ref (var_ref z) (constant int (2))) (expression vec2 * (array_ref (var_ref x) (constant int (2))) (array_ref (var_ref y) (constant int (2))))) +(return (var_ref z)))) + + (signature mat2x4 + (parameters + (declare (in) mat2x4 x) + (declare (in) mat2x4 y)) + ((declare () mat2x4 z) + (assign (xyzw) (array_ref (var_ref z) (constant int (0))) (expression vec4 * (array_ref (var_ref x) (constant int (0))) (array_ref (var_ref y) (constant int (0))))) + (assign (xyzw) (array_ref (var_ref z) (constant int (1))) (expression vec4 * (array_ref (var_ref x) (constant int (1))) (array_ref (var_ref y) (constant int (1))))) +(return (var_ref z)))) + + (signature mat4x2 + (parameters + (declare (in) mat4x2 x) + (declare (in) mat4x2 y)) + ((declare () mat4x2 z) + (assign (xy) (array_ref (var_ref z) (constant int (0))) (expression vec2 * (array_ref (var_ref x) (constant int (0))) (array_ref (var_ref y) (constant int (0))))) + (assign (xy) (array_ref (var_ref z) (constant int (1))) (expression vec2 * (array_ref (var_ref x) (constant int (1))) (array_ref (var_ref y) (constant int (1))))) + (assign (xy) (array_ref (var_ref z) (constant int (2))) (expression vec2 * (array_ref (var_ref x) (constant int (2))) (array_ref (var_ref y) (constant int (2))))) + (assign (xy) (array_ref (var_ref z) (constant int (3))) (expression vec2 * (array_ref (var_ref x) (constant int (3))) (array_ref (var_ref y) (constant int (3))))) +(return (var_ref z)))) + + (signature mat3x4 + (parameters + (declare (in) mat3x4 x) + (declare (in) mat3x4 y)) + ((declare () mat3x4 z) + (assign (xyzw) (array_ref (var_ref z) (constant int (0))) (expression vec4 * (array_ref (var_ref x) (constant int (0))) (array_ref (var_ref y) (constant int (0))))) + (assign (xyzw) (array_ref (var_ref z) (constant int (1))) (expression vec4 * (array_ref (var_ref x) (constant int (1))) (array_ref (var_ref y) (constant int (1))))) + (assign (xyzw) (array_ref (var_ref z) (constant int (2))) (expression vec4 * (array_ref (var_ref x) (constant int (2))) (array_ref (var_ref y) (constant int (2))))) +(return (var_ref z)))) + + (signature mat4x3 + (parameters + (declare (in) mat4x3 x) + (declare (in) mat4x3 y)) + ((declare () mat4x3 z) + (assign (xyz) (array_ref (var_ref z) (constant int (0))) (expression vec3 * (array_ref (var_ref x) (constant int (0))) (array_ref (var_ref y) (constant int (0))))) + (assign (xyz) (array_ref (var_ref z) (constant int (1))) (expression vec3 * (array_ref (var_ref x) (constant int (1))) (array_ref (var_ref y) (constant int (1))))) + (assign (xyz) (array_ref (var_ref z) (constant int (2))) (expression vec3 * (array_ref (var_ref x) (constant int (2))) (array_ref (var_ref y) (constant int (2))))) + (assign (xyz) (array_ref (var_ref z) (constant int (3))) (expression vec3 * (array_ref (var_ref x) (constant int (3))) (array_ref (var_ref y) (constant int (3))))) +(return (var_ref z)))) +)) diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/ir/max b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/max new file mode 100644 index 000000000..2b5a02868 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/max @@ -0,0 +1,127 @@ +((function max + (signature float + (parameters + (declare (in) float arg0) + (declare (in) float arg1)) + ((return (expression float max (var_ref arg0) (var_ref arg1))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0) + (declare (in) vec2 arg1)) + ((return (expression vec2 max (var_ref arg0) (var_ref arg1))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0) + (declare (in) vec3 arg1)) + ((return (expression vec3 max (var_ref arg0) (var_ref arg1))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0) + (declare (in) vec4 arg1)) + ((return (expression vec4 max (var_ref arg0) (var_ref arg1))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0) + (declare (in) float arg1)) + ((return (expression vec2 max (var_ref arg0) (var_ref arg1))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0) + (declare (in) float arg1)) + ((return (expression vec3 max (var_ref arg0) (var_ref arg1))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0) + (declare (in) float arg1)) + ((return (expression vec4 max (var_ref arg0) (var_ref arg1))))) + + (signature int + (parameters + (declare (in) int arg0) + (declare (in) int arg1)) + ((return (expression int max (var_ref arg0) (var_ref arg1))))) + + (signature ivec2 + (parameters + (declare (in) ivec2 arg0) + (declare (in) ivec2 arg1)) + ((return (expression ivec2 max (var_ref arg0) (var_ref arg1))))) + + (signature ivec3 + (parameters + (declare (in) ivec3 arg0) + (declare (in) ivec3 arg1)) + ((return (expression ivec3 max (var_ref arg0) (var_ref arg1))))) + + (signature ivec4 + (parameters + (declare (in) ivec4 arg0) + (declare (in) ivec4 arg1)) + ((return (expression ivec4 max (var_ref arg0) (var_ref arg1))))) + + (signature ivec2 + (parameters + (declare (in) ivec2 arg0) + (declare (in) int arg1)) + ((return (expression ivec2 max (var_ref arg0) (var_ref arg1))))) + + (signature ivec3 + (parameters + (declare (in) ivec3 arg0) + (declare (in) int arg1)) + ((return (expression ivec3 max (var_ref arg0) (var_ref arg1))))) + + (signature ivec4 + (parameters + (declare (in) ivec4 arg0) + (declare (in) int arg1)) + ((return (expression ivec4 max (var_ref arg0) (var_ref arg1))))) + + (signature uint + (parameters + (declare (in) uint arg0) + (declare (in) uint arg1)) + ((return (expression uint max (var_ref arg0) (var_ref arg1))))) + + (signature uvec2 + (parameters + (declare (in) uvec2 arg0) + (declare (in) uvec2 arg1)) + ((return (expression uvec2 max (var_ref arg0) (var_ref arg1))))) + + (signature uvec3 + (parameters + (declare (in) uvec3 arg0) + (declare (in) uvec3 arg1)) + ((return (expression uvec3 max (var_ref arg0) (var_ref arg1))))) + + (signature uvec4 + (parameters + (declare (in) uvec4 arg0) + (declare (in) uvec4 arg1)) + ((return (expression uvec4 max (var_ref arg0) (var_ref arg1))))) + + (signature uvec2 + (parameters + (declare (in) uvec2 arg0) + (declare (in) uint arg1)) + ((return (expression uvec2 max (var_ref arg0) (var_ref arg1))))) + + (signature uvec3 + (parameters + (declare (in) uvec3 arg0) + (declare (in) uint arg1)) + ((return (expression uvec3 max (var_ref arg0) (var_ref arg1))))) + + (signature uvec4 + (parameters + (declare (in) uvec4 arg0) + (declare (in) uint arg1)) + ((return (expression uvec4 max (var_ref arg0) (var_ref arg1))))) +)) diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/ir/min b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/min new file mode 100644 index 000000000..2deef1118 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/min @@ -0,0 +1,127 @@ +((function min + (signature float + (parameters + (declare (in) float arg0) + (declare (in) float arg1)) + ((return (expression float min (var_ref arg0) (var_ref arg1))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0) + (declare (in) vec2 arg1)) + ((return (expression vec2 min (var_ref arg0) (var_ref arg1))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0) + (declare (in) vec3 arg1)) + ((return (expression vec3 min (var_ref arg0) (var_ref arg1))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0) + (declare (in) vec4 arg1)) + ((return (expression vec4 min (var_ref arg0) (var_ref arg1))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0) + (declare (in) float arg1)) + ((return (expression vec2 min (var_ref arg0) (var_ref arg1))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0) + (declare (in) float arg1)) + ((return (expression vec3 min (var_ref arg0) (var_ref arg1))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0) + (declare (in) float arg1)) + ((return (expression vec4 min (var_ref arg0) (var_ref arg1))))) + + (signature int + (parameters + (declare (in) int arg0) + (declare (in) int arg1)) + ((return (expression int min (var_ref arg0) (var_ref arg1))))) + + (signature ivec2 + (parameters + (declare (in) ivec2 arg0) + (declare (in) ivec2 arg1)) + ((return (expression ivec2 min (var_ref arg0) (var_ref arg1))))) + + (signature ivec3 + (parameters + (declare (in) ivec3 arg0) + (declare (in) ivec3 arg1)) + ((return (expression ivec3 min (var_ref arg0) (var_ref arg1))))) + + (signature ivec4 + (parameters + (declare (in) ivec4 arg0) + (declare (in) ivec4 arg1)) + ((return (expression ivec4 min (var_ref arg0) (var_ref arg1))))) + + (signature ivec2 + (parameters + (declare (in) ivec2 arg0) + (declare (in) int arg1)) + ((return (expression ivec2 min (var_ref arg0) (var_ref arg1))))) + + (signature ivec3 + (parameters + (declare (in) ivec3 arg0) + (declare (in) int arg1)) + ((return (expression ivec3 min (var_ref arg0) (var_ref arg1))))) + + (signature ivec4 + (parameters + (declare (in) ivec4 arg0) + (declare (in) int arg1)) + ((return (expression ivec4 min (var_ref arg0) (var_ref arg1))))) + + (signature uint + (parameters + (declare (in) uint arg0) + (declare (in) uint arg1)) + ((return (expression uint min (var_ref arg0) (var_ref arg1))))) + + (signature uvec2 + (parameters + (declare (in) uvec2 arg0) + (declare (in) uvec2 arg1)) + ((return (expression uvec2 min (var_ref arg0) (var_ref arg1))))) + + (signature uvec3 + (parameters + (declare (in) uvec3 arg0) + (declare (in) uvec3 arg1)) + ((return (expression uvec3 min (var_ref arg0) (var_ref arg1))))) + + (signature uvec4 + (parameters + (declare (in) uvec4 arg0) + (declare (in) uvec4 arg1)) + ((return (expression uvec4 min (var_ref arg0) (var_ref arg1))))) + + (signature uvec2 + (parameters + (declare (in) uvec2 arg0) + (declare (in) uint arg1)) + ((return (expression uvec2 min (var_ref arg0) (var_ref arg1))))) + + (signature uvec3 + (parameters + (declare (in) uvec3 arg0) + (declare (in) uint arg1)) + ((return (expression uvec3 min (var_ref arg0) (var_ref arg1))))) + + (signature uvec4 + (parameters + (declare (in) uvec4 arg0) + (declare (in) uint arg1)) + ((return (expression uvec4 min (var_ref arg0) (var_ref arg1))))) +)) diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/ir/mix b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/mix new file mode 100644 index 000000000..a31f0fa70 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/mix @@ -0,0 +1,88 @@ +((function mix + (signature float + (parameters + (declare (in) float arg0) + (declare (in) float arg1) + (declare (in) float arg2)) + ((return (expression float + (expression float * (var_ref arg0) (expression float - (constant float (1.000000)) (var_ref arg2))) (expression float * (var_ref arg1) (var_ref arg2)))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0) + (declare (in) vec2 arg1) + (declare (in) vec2 arg2)) + ((return (expression vec2 + (expression vec2 * (var_ref arg0) (expression vec2 - (constant float (1.000000)) (var_ref arg2))) (expression vec2 * (var_ref arg1) (var_ref arg2)))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0) + (declare (in) vec3 arg1) + (declare (in) vec3 arg2)) + ((return (expression vec3 + (expression vec3 * (var_ref arg0) (expression vec3 - (constant float (1.000000)) (var_ref arg2))) (expression vec3 * (var_ref arg1) (var_ref arg2)))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0) + (declare (in) vec4 arg1) + (declare (in) vec4 arg2)) + ((return (expression vec4 + (expression vec4 * (var_ref arg0) (expression vec4 - (constant float (1.000000)) (var_ref arg2))) (expression vec4 * (var_ref arg1) (var_ref arg2)))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0) + (declare (in) vec2 arg1) + (declare (in) float arg2)) + ((return (expression vec2 + (expression vec2 * (var_ref arg0) (expression float - (constant float (1.000000)) (var_ref arg2))) (expression vec2 * (var_ref arg1) (var_ref arg2)))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0) + (declare (in) vec3 arg1) + (declare (in) float arg2)) + ((return (expression vec3 + (expression vec3 * (var_ref arg0) (expression float - (constant float (1.000000)) (var_ref arg2))) (expression vec3 * (var_ref arg1) (var_ref arg2)))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0) + (declare (in) vec4 arg1) + (declare (in) float arg2)) + ((return (expression vec4 + (expression vec4 * (var_ref arg0) (expression float - (constant float (1.000000)) (var_ref arg2))) (expression vec4 * (var_ref arg1) (var_ref arg2)))))) + + (signature float + (parameters + (declare (in) float v1) + (declare (in) float v2) + (declare (in) bool a)) + ((assign (var_ref a) (var_ref v1) (var_ref v2)) + (return (var_ref v1)))) + + (signature vec2 + (parameters + (declare (in) vec2 v1) + (declare (in) vec2 v2) + (declare (in) bvec2 a)) + ((assign (swiz x (var_ref a)) (x) (var_ref v1) (swiz x (var_ref v2))) + (assign (swiz y (var_ref a)) (y) (var_ref v1) (swiz y (var_ref v2))) + (return (var_ref v1)))) + + (signature vec3 + (parameters + (declare (in) vec3 v1) + (declare (in) vec3 v2) + (declare (in) bvec3 a)) + ((assign (swiz x (var_ref a)) (x) (var_ref v1) (swiz x (var_ref v2))) + (assign (swiz y (var_ref a)) (y) (var_ref v1) (swiz y (var_ref v2))) + (assign (swiz z (var_ref a)) (z) (var_ref v1) (swiz z (var_ref v2))) + (return (var_ref v1)))) + + (signature vec4 + (parameters + (declare (in) vec4 v1) + (declare (in) vec4 v2) + (declare (in) bvec4 a)) + ((assign (swiz x (var_ref a)) (x) (var_ref v1) (swiz x (var_ref v2))) + (assign (swiz y (var_ref a)) (y) (var_ref v1) (swiz y (var_ref v2))) + (assign (swiz z (var_ref a)) (z) (var_ref v1) (swiz z (var_ref v2))) + (assign (swiz w (var_ref a)) (w) (var_ref v1) (swiz w (var_ref v2))) + (return (var_ref v1)))) +)) diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/ir/mod b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/mod new file mode 100644 index 000000000..aeaea240e --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/mod @@ -0,0 +1,43 @@ +((function mod + (signature float + (parameters + (declare (in) float arg0) + (declare (in) float arg1)) + ((return (expression float % (var_ref arg0) (var_ref arg1))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0) + (declare (in) vec2 arg1)) + ((return (expression vec2 % (var_ref arg0) (var_ref arg1))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0) + (declare (in) vec3 arg1)) + ((return (expression vec3 % (var_ref arg0) (var_ref arg1))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0) + (declare (in) vec4 arg1)) + ((return (expression vec4 % (var_ref arg0) (var_ref arg1))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0) + (declare (in) float arg1)) + ((return (expression vec2 % (var_ref arg0) (var_ref arg1))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0) + (declare (in) float arg1)) + ((return (expression vec3 % (var_ref arg0) (var_ref arg1))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0) + (declare (in) float arg1)) + ((return (expression vec4 % (var_ref arg0) (var_ref arg1))))) +)) diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/ir/modf b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/modf new file mode 100644 index 000000000..f4f631567 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/modf @@ -0,0 +1,37 @@ +((function modf + (signature float + (parameters + (declare (in) float x) + (declare (out) float i)) + ((declare () float t) + (assign (x) (var_ref t) (expression float trunc (var_ref x))) + (assign (x) (var_ref i) (var_ref t)) + (return (expression float - (var_ref x) (var_ref t))))) + + (signature vec2 + (parameters + (declare (in) vec2 x) + (declare (out) vec2 i)) + ((declare () vec2 t) + (assign (xy) (var_ref t) (expression vec2 trunc (var_ref x))) + (assign (xy) (var_ref i) (var_ref t)) + (return (expression vec2 - (var_ref x) (var_ref t))))) + + (signature vec3 + (parameters + (declare (in) vec3 x) + (declare (out) vec3 i)) + ((declare () vec3 t) + (assign (xyz) (var_ref t) (expression vec3 trunc (var_ref x))) + (assign (xyz) (var_ref i) (var_ref t)) + (return (expression vec3 - (var_ref x) (var_ref t))))) + + (signature vec4 + (parameters + (declare (in) vec4 x) + (declare (out) vec4 i)) + ((declare () vec4 t) + (assign (xyzw) (var_ref t) (expression vec4 trunc (var_ref x))) + (assign (xyzw) (var_ref i) (var_ref t)) + (return (expression vec4 - (var_ref x) (var_ref t))))) +)) diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/ir/noise1 b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/noise1 new file mode 100644 index 000000000..115505610 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/noise1 @@ -0,0 +1,18 @@ +((function noise1 + (signature float + (parameters + (declare (in) float x)) + ((return (expression float noise (var_ref x))))) + (signature float + (parameters + (declare (in) vec2 x)) + ((return (expression float noise (var_ref x))))) + (signature float + (parameters + (declare (in) vec3 x)) + ((return (expression float noise (var_ref x))))) + (signature float + (parameters + (declare (in) vec4 x)) + ((return (expression float noise (var_ref x))))) +)) diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/ir/noise2 b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/noise2 new file mode 100644 index 000000000..d3366145f --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/noise2 @@ -0,0 +1,61 @@ +((function noise2 + (signature vec2 + (parameters (declare (in) vec4 p)) + ( + (declare () float a) + (declare () float b) + (declare () vec2 t) + + (assign (x) (var_ref a) (expression float noise (var_ref p))) + (assign (x) (var_ref b) (expression float noise (expression vec4 + (var_ref p) (constant vec4 (601.0 313.0 29.0 277.0))))) + (assign (x) (var_ref t) (var_ref a)) + (assign (y) (var_ref t) (var_ref b)) + (return (var_ref t)) + )) + + (signature vec2 + (parameters (declare (in) vec3 p)) + ( + (declare () float a) + (declare () float b) + (declare () vec2 t) + + (assign (x) (var_ref a) (expression float noise (var_ref p))) + (assign (x) (var_ref b) (expression float noise (expression vec3 + (var_ref p) (constant vec3 (601.0 313.0 29.0))))) + (assign (x) (var_ref t) (var_ref a)) + (assign (y) (var_ref t) (var_ref b)) + (return (var_ref t)) + )) + + (signature vec2 + (parameters + (declare (in ) vec2 p) + ) + ( + (declare () float a) + (declare () float b) + (declare () vec2 t) + + (assign (x) (var_ref a) (expression float noise (var_ref p))) + (assign (x) (var_ref b) (expression float noise (expression vec2 + (var_ref p) (constant vec2 (601.0 313.0))))) + (assign (x) (var_ref t) (var_ref a)) + (assign (y) (var_ref t) (var_ref b)) + (return (var_ref t)) + )) + + (signature vec2 + (parameters + (declare (in ) float p) + ) + ( + (declare () float a) + (declare () float b) + (declare () vec2 t) + + (assign (x) (var_ref a) (expression float noise (var_ref p))) + (assign (x) (var_ref b) (expression float noise (expression float + (var_ref p) (constant float (601.0))))) + (assign (x) (var_ref t) (var_ref a)) + (assign (y) (var_ref t) (var_ref b)) + (return (var_ref t)) + )) +)) diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/ir/noise3 b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/noise3 new file mode 100644 index 000000000..1d8aa3f30 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/noise3 @@ -0,0 +1,73 @@ +((function noise3 + (signature vec3 + (parameters (declare (in) vec4 p)) + ( + (declare () float a) + (declare () float b) + (declare () float c) + (declare () vec3 t) + + (assign (x) (var_ref a) (expression float noise (var_ref p))) + (assign (x) (var_ref b) (expression float noise (expression vec4 + (var_ref p) (constant vec4 (601.0 313.0 29.0 277.0))))) + (assign (x) (var_ref c) (expression float noise (expression vec4 + (var_ref p) (constant vec4 (1559.0 113.0 1861.0 797.0))))) + + (assign (x) (var_ref t) (var_ref a)) + (assign (y) (var_ref t) (var_ref b)) + (assign (z) (var_ref t) (var_ref c)) + (return (var_ref t)) + )) + + (signature vec3 + (parameters (declare (in) vec3 p)) + ( + (declare () float a) + (declare () float b) + (declare () float c) + (declare () vec3 t) + + (assign (x) (var_ref a) (expression float noise (var_ref p))) + (assign (x) (var_ref b) (expression float noise (expression vec3 + (var_ref p) (constant vec3 (601.0 313.0 29.0))))) + (assign (x) (var_ref c) (expression float noise (expression vec3 + (var_ref p) (constant vec3 (1559.0 113.0 1861.0))))) + + (assign (x) (var_ref t) (var_ref a)) + (assign (y) (var_ref t) (var_ref b)) + (assign (z) (var_ref t) (var_ref c)) + (return (var_ref t)) + )) + + (signature vec3 + (parameters (declare (in) vec2 p)) + ( + (declare () float a) + (declare () float b) + (declare () float c) + (declare () vec3 t) + + (assign (x) (var_ref a) (expression float noise (var_ref p))) + (assign (x) (var_ref b) (expression float noise (expression vec2 + (var_ref p) (constant vec2 (601.0 313.0))))) + (assign (x) (var_ref c) (expression float noise (expression vec2 + (var_ref p) (constant vec2 (1559.0 113.0))))) + + (assign (x) (var_ref t) (var_ref a)) + (assign (y) (var_ref t) (var_ref b)) + (assign (z) (var_ref t) (var_ref c)) + (return (var_ref t)) + )) + + (signature vec3 + (parameters (declare (in) float p)) + ( + (declare () float a) + (declare () float b) + (declare () float c) + (declare () vec3 t) + + (assign (x) (var_ref a) (expression float noise (var_ref p))) + (assign (x) (var_ref b) (expression float noise (expression float + (var_ref p) (constant float (601.0))))) + (assign (x) (var_ref c) (expression float noise (expression float + (var_ref p) (constant float (1559.0))))) + + (assign (x) (var_ref t) (var_ref a)) + (assign (y) (var_ref t) (var_ref b)) + (assign (z) (var_ref t) (var_ref c)) + (return (var_ref t)) + )) +)) diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/ir/noise4 b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/noise4 new file mode 100644 index 000000000..d0894fd5e --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/noise4 @@ -0,0 +1,97 @@ +((function noise4 + (signature vec4 + (parameters (declare (in) vec4 p)) + ( + (declare () float _x) + (declare () float _y) + (declare () float _z) + (declare () float _w) + (declare () vec4 _r) + + (declare () vec4 _p) + (assign (xyzw) (var_ref _p) (expression vec4 + (var_ref p) (constant vec4 (1559.0 113.0 1861.0 797.0))) ) + + (assign (x) (var_ref _x) (expression float noise(var_ref p))) + (assign (x) (var_ref _y) (expression float noise(expression vec4 + (var_ref p) (constant vec4 (601.0 313.0 29.0 277.0))))) + (assign (x) (var_ref _z) (expression float noise(var_ref _p))) + (assign (x) (var_ref _w) (expression float noise(expression vec4 + (var_ref _p) (constant vec4 (601.0 313.0 29.0 277.0))))) + + (assign (x) (var_ref _r) (var_ref _x)) + (assign (y) (var_ref _r) (var_ref _y)) + (assign (z) (var_ref _r) (var_ref _z)) + (assign (w) (var_ref _r) (var_ref _w)) + (return (var_ref _r)) + )) + + (signature vec4 + (parameters (declare (in) vec3 p)) + ( + (declare () float _x) + (declare () float _y) + (declare () float _z) + (declare () float _w) + (declare () vec4 _r) + + (declare () vec3 _p) + (assign (xyz) (var_ref _p) (expression vec3 + (var_ref p) (constant vec3 (1559.0 113.0 1861.0))) ) + + (assign (x) (var_ref _x) (expression float noise(var_ref p))) + (assign (x) (var_ref _y) (expression float noise(expression vec3 + (var_ref p) (constant vec3 (601.0 313.0 29.0))))) + (assign (x) (var_ref _z) (expression float noise(var_ref _p))) + (assign (x) (var_ref _w) (expression float noise(expression vec3 + (var_ref _p) (constant vec3 (601.0 313.0 29.0))))) + + (assign (x) (var_ref _r) (var_ref _x)) + (assign (y) (var_ref _r) (var_ref _y)) + (assign (z) (var_ref _r) (var_ref _z)) + (assign (w) (var_ref _r) (var_ref _w)) + (return (var_ref _r)) + )) + + (signature vec4 + (parameters (declare (in) vec2 p)) + ( + (declare () float _x) + (declare () float _y) + (declare () float _z) + (declare () float _w) + (declare () vec4 _r) + + (declare () vec2 _p) + (assign (xy) (var_ref _p) (expression vec2 + (var_ref p) (constant vec2 (1559.0 113.0))) ) + + (assign (x) (var_ref _x) (expression float noise(var_ref p))) + (assign (x) (var_ref _y) (expression float noise(expression vec2 + (var_ref p) (constant vec2 (601.0 313.0))))) + (assign (x) (var_ref _z) (expression float noise(var_ref _p))) + (assign (x) (var_ref _w) (expression float noise(expression vec2 + (var_ref _p) (constant vec2 (601.0 313.0))))) + + (assign (x) (var_ref _r) (var_ref _x)) + (assign (y) (var_ref _r) (var_ref _y)) + (assign (z) (var_ref _r) (var_ref _z)) + (assign (w) (var_ref _r) (var_ref _w)) + (return (var_ref _r)) + )) + + (signature vec4 + (parameters (declare (in) float p)) + ( + (declare () float _x) + (declare () float _y) + (declare () float _z) + (declare () float _w) + (declare () vec4 _r) + + (declare () float _p) + (assign (x) (var_ref _p) (expression float + (var_ref p) (constant float (1559.0))) ) + + (assign (x) (var_ref _x) (expression float noise(var_ref p))) + (assign (x) (var_ref _y) (expression float noise(expression float + (var_ref p) (constant float (601.0 313.0 29.0 277.0))))) + (assign (x) (var_ref _z) (expression float noise(var_ref _p))) + (assign (x) (var_ref _w) (expression float noise(expression float + (var_ref _p) (constant float (601.0 313.0 29.0 277.0))))) + + (assign (x) (var_ref _r) (var_ref _x)) + (assign (y) (var_ref _r) (var_ref _y)) + (assign (z) (var_ref _r) (var_ref _z)) + (assign (w) (var_ref _r) (var_ref _w)) + (return (var_ref _r)) + )) +)) diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/ir/normalize b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/normalize new file mode 100644 index 000000000..0de0db0b6 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/normalize @@ -0,0 +1,21 @@ +((function normalize + (signature float + (parameters + (declare (in) float arg0)) + ((return (expression float sign (var_ref arg0))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0)) + ((return (expression vec2 * (var_ref arg0) (expression float rsq (expression float dot (var_ref arg0) (var_ref arg0))))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0)) + ((return (expression vec3 * (var_ref arg0) (expression float rsq (expression float dot (var_ref arg0) (var_ref arg0))))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0)) + ((return (expression vec4 * (var_ref arg0) (expression float rsq (expression float dot (var_ref arg0) (var_ref arg0))))))) +)) diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/ir/not b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/not new file mode 100644 index 000000000..b696b0655 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/not @@ -0,0 +1,16 @@ +((function not + (signature bvec2 + (parameters + (declare (in) bvec2 arg0)) + ((return (expression bvec2 ! (var_ref arg0))))) + + (signature bvec3 + (parameters + (declare (in) bvec3 arg0)) + ((return (expression bvec3 ! (var_ref arg0))))) + + (signature bvec4 + (parameters + (declare (in) bvec4 arg0)) + ((return (expression bvec4 ! (var_ref arg0))))) +)) diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/ir/notEqual b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/notEqual new file mode 100644 index 000000000..abaf1914c --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/notEqual @@ -0,0 +1,73 @@ +((function notEqual + (signature bvec2 + (parameters + (declare (in) vec2 arg0) + (declare (in) vec2 arg1)) + ((return (expression bvec2 != (var_ref arg0) (var_ref arg1))))) + + (signature bvec3 + (parameters + (declare (in) vec3 arg0) + (declare (in) vec3 arg1)) + ((return (expression bvec3 != (var_ref arg0) (var_ref arg1))))) + + (signature bvec4 + (parameters + (declare (in) vec4 arg0) + (declare (in) vec4 arg1)) + ((return (expression bvec4 != (var_ref arg0) (var_ref arg1))))) + + (signature bvec2 + (parameters + (declare (in) bvec2 arg0) + (declare (in) bvec2 arg1)) + ((return (expression bvec2 != (var_ref arg0) (var_ref arg1))))) + + (signature bvec3 + (parameters + (declare (in) bvec3 arg0) + (declare (in) bvec3 arg1)) + ((return (expression bvec3 != (var_ref arg0) (var_ref arg1))))) + + (signature bvec4 + (parameters + (declare (in) bvec4 arg0) + (declare (in) bvec4 arg1)) + ((return (expression bvec4 != (var_ref arg0) (var_ref arg1))))) + + (signature bvec2 + (parameters + (declare (in) ivec2 arg0) + (declare (in) ivec2 arg1)) + ((return (expression bvec2 != (var_ref arg0) (var_ref arg1))))) + + (signature bvec3 + (parameters + (declare (in) ivec3 arg0) + (declare (in) ivec3 arg1)) + ((return (expression bvec3 != (var_ref arg0) (var_ref arg1))))) + + (signature bvec4 + (parameters + (declare (in) ivec4 arg0) + (declare (in) ivec4 arg1)) + ((return (expression bvec4 != (var_ref arg0) (var_ref arg1))))) + + (signature bvec2 + (parameters + (declare (in) uvec2 arg0) + (declare (in) uvec2 arg1)) + ((return (expression bvec2 != (var_ref arg0) (var_ref arg1))))) + + (signature bvec3 + (parameters + (declare (in) uvec3 arg0) + (declare (in) uvec3 arg1)) + ((return (expression bvec3 != (var_ref arg0) (var_ref arg1))))) + + (signature bvec4 + (parameters + (declare (in) uvec4 arg0) + (declare (in) uvec4 arg1)) + ((return (expression bvec4 != (var_ref arg0) (var_ref arg1))))) +)) diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/ir/outerProduct b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/outerProduct new file mode 100644 index 000000000..0e3f375bb --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/outerProduct @@ -0,0 +1,92 @@ +((function outerProduct + (signature mat2 + (parameters + (declare (in) vec2 u) + (declare (in) vec2 v)) + ((declare () mat2 m) + (assign (xy) (array_ref (var_ref m) (constant int (0))) (expression vec2 * (var_ref u) (swiz x (var_ref v)))) + (assign (xy) (array_ref (var_ref m) (constant int (1))) (expression vec2 * (var_ref u) (swiz y (var_ref v)))) + (return (var_ref m)))) + + (signature mat2x3 + (parameters + (declare (in) vec3 u) + (declare (in) vec2 v)) + ((declare () mat2x3 m) + (assign (xyz) (array_ref (var_ref m) (constant int (0))) (expression vec3 * (var_ref u) (swiz x (var_ref v)))) + (assign (xyz) (array_ref (var_ref m) (constant int (1))) (expression vec3 * (var_ref u) (swiz y (var_ref v)))) + (return (var_ref m)))) + + (signature mat2x4 + (parameters + (declare (in) vec4 u) + (declare (in) vec2 v)) + ((declare () mat2x4 m) + (assign (xyzw) (array_ref (var_ref m) (constant int (0))) (expression vec4 * (var_ref u) (swiz x (var_ref v)))) + (assign (xyzw) (array_ref (var_ref m) (constant int (1))) (expression vec4 * (var_ref u) (swiz y (var_ref v)))) + (return (var_ref m)))) + + (signature mat3x2 + (parameters + (declare (in) vec2 u) + (declare (in) vec3 v)) + ((declare () mat3x2 m) + (assign (xy) (array_ref (var_ref m) (constant int (0))) (expression vec2 * (var_ref u) (swiz x (var_ref v)))) + (assign (xy) (array_ref (var_ref m) (constant int (1))) (expression vec2 * (var_ref u) (swiz y (var_ref v)))) + (assign (xy) (array_ref (var_ref m) (constant int (2))) (expression vec2 * (var_ref u) (swiz z (var_ref v)))) + (return (var_ref m)) + )) + + (signature mat3 + (parameters + (declare (in) vec3 u) + (declare (in) vec3 v)) + ((declare () mat3 m) + (assign (xyz) (array_ref (var_ref m) (constant int (0))) (expression vec3 * (var_ref u) (swiz x (var_ref v)))) + (assign (xyz) (array_ref (var_ref m) (constant int (1))) (expression vec3 * (var_ref u) (swiz y (var_ref v)))) + (assign (xyz) (array_ref (var_ref m) (constant int (2))) (expression vec3 * (var_ref u) (swiz z (var_ref v)))) + (return (var_ref m)))) + + (signature mat3x4 + (parameters + (declare (in) vec4 u) + (declare (in) vec3 v)) + ((declare () mat3x4 m) + (assign (xyzw) (array_ref (var_ref m) (constant int (0))) (expression vec4 * (var_ref u) (swiz x (var_ref v)))) + (assign (xyzw) (array_ref (var_ref m) (constant int (1))) (expression vec4 * (var_ref u) (swiz y (var_ref v)))) + (assign (xyzw) (array_ref (var_ref m) (constant int (2))) (expression vec4 * (var_ref u) (swiz z (var_ref v)))) + (return (var_ref m)))) + + (signature mat4x2 + (parameters + (declare (in) vec2 u) + (declare (in) vec4 v)) + ((declare () mat4x2 m) + (assign (xy) (array_ref (var_ref m) (constant int (0))) (expression vec2 * (var_ref u) (swiz x (var_ref v)))) + (assign (xy) (array_ref (var_ref m) (constant int (1))) (expression vec2 * (var_ref u) (swiz y (var_ref v)))) + (assign (xy) (array_ref (var_ref m) (constant int (2))) (expression vec2 * (var_ref u) (swiz z (var_ref v)))) + (assign (xy) (array_ref (var_ref m) (constant int (3))) (expression vec2 * (var_ref u) (swiz w (var_ref v)))) + (return (var_ref m)))) + + (signature mat4x3 + (parameters + (declare (in) vec3 u) + (declare (in) vec4 v)) + ((declare () mat4x3 m) + (assign (xyz) (array_ref (var_ref m) (constant int (0))) (expression vec3 * (var_ref u) (swiz x (var_ref v)))) + (assign (xyz) (array_ref (var_ref m) (constant int (1))) (expression vec3 * (var_ref u) (swiz y (var_ref v)))) + (assign (xyz) (array_ref (var_ref m) (constant int (2))) (expression vec3 * (var_ref u) (swiz z (var_ref v)))) + (assign (xyz) (array_ref (var_ref m) (constant int (3))) (expression vec3 * (var_ref u) (swiz w (var_ref v)))) + (return (var_ref m)))) + + (signature mat4 + (parameters + (declare (in) vec4 u) + (declare (in) vec4 v)) + ((declare () mat4 m) + (assign (xyzw) (array_ref (var_ref m) (constant int (0))) (expression vec4 * (var_ref u) (swiz x (var_ref v)))) + (assign (xyzw) (array_ref (var_ref m) (constant int (1))) (expression vec4 * (var_ref u) (swiz y (var_ref v)))) + (assign (xyzw) (array_ref (var_ref m) (constant int (2))) (expression vec4 * (var_ref u) (swiz z (var_ref v)))) + (assign (xyzw) (array_ref (var_ref m) (constant int (3))) (expression vec4 * (var_ref u) (swiz w (var_ref v)))) + (return (var_ref m)))) +)) diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/ir/pow b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/pow new file mode 100644 index 000000000..a61bc4418 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/pow @@ -0,0 +1,25 @@ +((function pow + (signature float + (parameters + (declare (in) float arg0) + (declare (in) float arg1)) + ((return (expression float pow (var_ref arg0) (var_ref arg1))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0) + (declare (in) vec2 arg1)) + ((return (expression vec2 pow (var_ref arg0) (var_ref arg1))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0) + (declare (in) vec3 arg1)) + ((return (expression vec3 pow (var_ref arg0) (var_ref arg1))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0) + (declare (in) vec4 arg1)) + ((return (expression vec4 pow (var_ref arg0) (var_ref arg1))))) +)) diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/ir/radians b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/radians new file mode 100644 index 000000000..a419101cf --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/radians @@ -0,0 +1,21 @@ +((function radians + (signature float + (parameters + (declare (in) float arg0)) + ((return (expression float * (var_ref arg0) (constant float (0.0174532925)))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0)) + ((return (expression vec2 * (var_ref arg0) (constant float (0.0174532925)))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0)) + ((return (expression vec3 * (var_ref arg0) (constant float (0.0174532925)))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0)) + ((return (expression vec4 * (var_ref arg0) (constant float (0.0174532925)))))) +)) diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/ir/reflect b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/reflect new file mode 100644 index 000000000..1fa394e3c --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/reflect @@ -0,0 +1,58 @@ +((function reflect + (signature float + (parameters + (declare (in) float i) + (declare (in) float n)) + ((return (expression float - + (var_ref i) + (expression float * + (constant float (2.0)) + (expression float * + (expression float * + (var_ref n) + (var_ref i)) + (var_ref n))))))) + + (signature vec2 + (parameters + (declare (in) vec2 i) + (declare (in) vec2 n)) + ((return (expression vec2 - + (var_ref i) + (expression vec2 * + (constant float (2.0)) + (expression vec2 * + (expression float dot + (var_ref n) + (var_ref i)) + (var_ref n))))))) + + (signature vec3 + (parameters + (declare (in) vec3 i) + (declare (in) vec3 n)) + ((return (expression vec3 - + (var_ref i) + (expression vec3 * + (constant float (2.0)) + (expression vec3 * + (expression float dot + (var_ref n) + (var_ref i)) + (var_ref n))))))) + + (signature vec4 + (parameters + (declare (in) vec4 i) + (declare (in) vec4 n)) + ((return (expression vec4 - + (var_ref i) + (expression vec4 * + (constant float (2.0)) + (expression vec4 * + (expression float dot + (var_ref n) + (var_ref i)) + (var_ref n))))))) + +)) diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/ir/refract b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/refract new file mode 100644 index 000000000..60899f01c --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/refract @@ -0,0 +1,102 @@ +((function refract + (signature float + (parameters + (declare (in) float i) + (declare (in) float n) + (declare (in) float eta)) + ((declare () float k) + (assign (x) (var_ref k) + (expression float - (constant float (1.0)) + (expression float * (var_ref eta) + (expression float * (var_ref eta) + (expression float - (constant float (1.0)) + (expression float * + (expression float * (var_ref n) (var_ref i)) + (expression float * (var_ref n) (var_ref i)))))))) + (if (expression bool < (var_ref k) (constant float (0.0))) + ((return (constant float (0.0)))) + ((return (expression float - + (expression float * (var_ref eta) (var_ref i)) + (expression float * + (expression float + + (expression float * (var_ref eta) + (expression float * (var_ref n) (var_ref i))) + (expression float sqrt (var_ref k))) + (var_ref n)))))))) + + (signature vec2 + (parameters + (declare (in) vec2 i) + (declare (in) vec2 n) + (declare (in) float eta)) + ((declare () float k) + (assign (x) (var_ref k) + (expression float - (constant float (1.0)) + (expression float * (var_ref eta) + (expression float * (var_ref eta) + (expression float - (constant float (1.0)) + (expression float * + (expression float dot (var_ref n) (var_ref i)) + (expression float dot (var_ref n) (var_ref i)))))))) + (if (expression bool < (var_ref k) (constant float (0.0))) + ((return (constant vec2 (0.0 0.0)))) + ((return (expression vec2 - + (expression vec2 * (var_ref eta) (var_ref i)) + (expression vec2 * + (expression float + + (expression float * (var_ref eta) + (expression float dot (var_ref n) (var_ref i))) + (expression float sqrt (var_ref k))) + (var_ref n)))))))) + + (signature vec3 + (parameters + (declare (in) vec3 i) + (declare (in) vec3 n) + (declare (in) float eta)) + ((declare () float k) + (assign (x) (var_ref k) + (expression float - (constant float (1.0)) + (expression float * (var_ref eta) + (expression float * (var_ref eta) + (expression float - (constant float (1.0)) + (expression float * + (expression float dot (var_ref n) (var_ref i)) + (expression float dot (var_ref n) (var_ref i)))))))) + (if (expression bool < (var_ref k) (constant float (0.0))) + ((return (constant vec3 (0.0 0.0 0.0)))) + ((return (expression vec3 - + (expression vec3 * (var_ref eta) (var_ref i)) + (expression vec3 * + (expression float + + (expression float * (var_ref eta) + (expression float dot (var_ref n) (var_ref i))) + (expression float sqrt (var_ref k))) + (var_ref n)))))))) + + (signature vec4 + (parameters + (declare (in) vec4 i) + (declare (in) vec4 n) + (declare (in) float eta)) + ((declare () float k) + (assign (x) (var_ref k) + (expression float - (constant float (1.0)) + (expression float * (var_ref eta) + (expression float * (var_ref eta) + (expression float - (constant float (1.0)) + (expression float * + (expression float dot (var_ref n) (var_ref i)) + (expression float dot (var_ref n) (var_ref i)))))))) + (if (expression bool < (var_ref k) (constant float (0.0))) + ((return (constant vec4 (0.0 0.0 0.0 0.0)))) + ((return (expression vec4 - + (expression vec4 * (var_ref eta) (var_ref i)) + (expression vec4 * + (expression float + + (expression float * (var_ref eta) + (expression float dot (var_ref n) (var_ref i))) + (expression float sqrt (var_ref k))) + (var_ref n)))))))) + +)) diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/ir/round b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/round new file mode 100644 index 000000000..d0d425bd6 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/round @@ -0,0 +1,21 @@ +((function round + (signature float + (parameters + (declare (in) float arg0)) + ((return (expression float round_even (var_ref arg0))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0)) + ((return (expression vec2 round_even (var_ref arg0))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0)) + ((return (expression vec3 round_even (var_ref arg0))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0)) + ((return (expression vec4 round_even (var_ref arg0))))) +)) diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/ir/roundEven b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/roundEven new file mode 100644 index 000000000..a9c99b6f4 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/roundEven @@ -0,0 +1,21 @@ +((function roundEven + (signature float + (parameters + (declare (in) float arg0)) + ((return (expression float round_even (var_ref arg0))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0)) + ((return (expression vec2 round_even (var_ref arg0))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0)) + ((return (expression vec3 round_even (var_ref arg0))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0)) + ((return (expression vec4 round_even (var_ref arg0))))) +)) diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/ir/sign b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/sign new file mode 100644 index 000000000..1f51718da --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/sign @@ -0,0 +1,42 @@ +((function sign + (signature float + (parameters + (declare (in) float x)) + ((return (expression float sign (var_ref x))))) + + (signature vec2 + (parameters + (declare (in) vec2 x)) + ((return (expression vec2 sign (var_ref x))))) + + (signature vec3 + (parameters + (declare (in) vec3 x)) + ((return (expression vec3 sign (var_ref x))))) + + (signature vec4 + (parameters + (declare (in) vec4 x)) + ((return (expression vec4 sign (var_ref x))))) + + (signature int + (parameters + (declare (in) int x)) + ((return (expression int sign (var_ref x))))) + + (signature ivec2 + (parameters + (declare (in) ivec2 x)) + ((return (expression ivec2 sign (var_ref x))))) + + (signature ivec3 + (parameters + (declare (in) ivec3 x)) + ((return (expression ivec3 sign (var_ref x))))) + + (signature ivec4 + (parameters + (declare (in) ivec4 x)) + ((return (expression ivec4 sign (var_ref x))))) +)) + diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/ir/sin b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/sin new file mode 100644 index 000000000..e6009d8ef --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/sin @@ -0,0 +1,21 @@ +((function sin + (signature float + (parameters + (declare (in) float angle)) + ((return (expression float sin (var_ref angle))))) + + (signature vec2 + (parameters + (declare (in) vec2 angle)) + ((return (expression vec2 sin (var_ref angle))))) + + (signature vec3 + (parameters + (declare (in) vec3 angle)) + ((return (expression vec3 sin (var_ref angle))))) + + (signature vec4 + (parameters + (declare (in) vec4 angle)) + ((return (expression vec4 sin (var_ref angle))))) +)) diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/ir/sinh b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/sinh new file mode 100644 index 000000000..7ad4f58e2 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/sinh @@ -0,0 +1,30 @@ +((function sinh + (signature float + (parameters + (declare (in) float x)) + ((return (expression float * (constant float (0.5)) + (expression float - + (expression float exp (var_ref x)) + (expression float exp (expression float neg (var_ref x)))))))) + (signature vec2 + (parameters + (declare (in) vec2 x)) + ((return (expression vec2 * (constant vec2 (0.5)) + (expression vec2 - + (expression vec2 exp (var_ref x)) + (expression vec2 exp (expression vec2 neg (var_ref x)))))))) + (signature vec3 + (parameters + (declare (in) vec3 x)) + ((return (expression vec3 * (constant vec3 (0.5)) + (expression vec3 - + (expression vec3 exp (var_ref x)) + (expression vec3 exp (expression vec3 neg (var_ref x)))))))) + (signature vec4 + (parameters + (declare (in) vec4 x)) + ((return (expression vec4 * (constant vec4 (0.5)) + (expression vec4 - + (expression vec4 exp (var_ref x)) + (expression vec4 exp (expression vec4 neg (var_ref x)))))))) +)) diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/ir/smoothstep b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/smoothstep new file mode 100644 index 000000000..94c98b29e --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/smoothstep @@ -0,0 +1,100 @@ +((function smoothstep + (signature float + (parameters + (declare (in) float edge0) + (declare (in) float edge1) + (declare (in) float x)) + ((declare () float t) + (assign (x) (var_ref t) + (expression float max + (expression float min + (expression float / (expression float - (var_ref x) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0))) + (constant float (1.0))) + (constant float (0.0)))) + (return (expression float * (var_ref t) (expression float * (var_ref t) (expression float - (constant float (3.0)) (expression float * (constant float (2.0)) (var_ref t)))))))) + (signature vec2 + (parameters + (declare (in) float edge0) + (declare (in) float edge1) + (declare (in) vec2 x)) + ((declare () vec2 t) + (assign (xy) (var_ref t) + (expression vec2 max + (expression vec2 min + (expression vec2 / (expression vec2 - (var_ref x) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0))) + (constant float (1.0))) + (constant float (0.0)))) + (return (expression vec2 * (var_ref t) (expression vec2 * (var_ref t) (expression vec2 - (constant float (3.0)) (expression vec2 * (constant float (2.0)) (var_ref t)))))))) + + (signature vec3 + (parameters + (declare (in) float edge0) + (declare (in) float edge1) + (declare (in) vec3 x)) + ((declare () vec3 t) + (assign (xyz) (var_ref t) + (expression vec3 max + (expression vec3 min + (expression vec3 / (expression vec3 - (var_ref x) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0))) + (constant float (1.0))) + (constant float (0.0)))) + (return (expression vec3 * (var_ref t) (expression vec3 * (var_ref t) (expression vec3 - (constant float (3.0)) (expression vec3 * (constant float (2.0)) (var_ref t)))))))) + + + (signature vec4 + (parameters + (declare (in) float edge0) + (declare (in) float edge1) + (declare (in) vec4 x)) + ((declare () vec4 t) + (assign (xyzw) (var_ref t) + (expression vec4 max + (expression vec4 min + (expression vec4 / (expression vec4 - (var_ref x) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0))) + (constant float (1.0))) + (constant float (0.0)))) + (return (expression vec4 * (var_ref t) (expression vec4 * (var_ref t) (expression vec4 - (constant float (3.0)) (expression vec4 * (constant float (2.0)) (var_ref t)))))))) + + (signature vec2 + (parameters + (declare (in) vec2 edge0) + (declare (in) vec2 edge1) + (declare (in) vec2 x)) + ((declare () vec2 t) + (assign (xy) (var_ref t) + (expression vec2 max + (expression vec2 min + (expression vec2 / (expression vec2 - (var_ref x) (var_ref edge0)) (expression vec2 - (var_ref edge1) (var_ref edge0))) + (constant float (1.0))) + (constant float (0.0)))) + (return (expression vec2 * (var_ref t) (expression vec2 * (var_ref t) (expression vec2 - (constant float (3.0)) (expression vec2 * (constant float (2.0)) (var_ref t)))))))) + + (signature vec3 + (parameters + (declare (in) vec3 edge0) + (declare (in) vec3 edge1) + (declare (in) vec3 x)) + ((declare () vec3 t) + (assign (xyz) (var_ref t) + (expression vec3 max + (expression vec3 min + (expression vec3 / (expression vec3 - (var_ref x) (var_ref edge0)) (expression vec3 - (var_ref edge1) (var_ref edge0))) + (constant float (1.0))) + (constant float (0.0)))) + (return (expression vec3 * (var_ref t) (expression vec3 * (var_ref t) (expression vec3 - (constant float (3.0)) (expression vec3 * (constant float (2.0)) (var_ref t)))))))) + + (signature vec4 + (parameters + (declare (in) vec4 edge0) + (declare (in) vec4 edge1) + (declare (in) vec4 x)) + ((declare () vec4 t) + (assign (xyzw) (var_ref t) + (expression vec4 max + (expression vec4 min + (expression vec4 / (expression vec4 - (var_ref x) (var_ref edge0)) (expression vec4 - (var_ref edge1) (var_ref edge0))) + (constant float (1.0))) + (constant float (0.0)))) + (return (expression vec4 * (var_ref t) (expression vec4 * (var_ref t) (expression vec4 - (constant float (3.0)) (expression vec4 * (constant float (2.0)) (var_ref t)))))))) +)) + diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/ir/sqrt b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/sqrt new file mode 100644 index 000000000..0302d164a --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/sqrt @@ -0,0 +1,21 @@ +((function sqrt + (signature float + (parameters + (declare (in) float arg0)) + ((return (expression float sqrt (var_ref arg0))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0)) + ((return (expression vec2 sqrt (var_ref arg0))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0)) + ((return (expression vec3 sqrt (var_ref arg0))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0)) + ((return (expression vec4 sqrt (var_ref arg0))))) +)) diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/ir/step b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/step new file mode 100644 index 000000000..efcd7bc80 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/step @@ -0,0 +1,68 @@ +((function step + (signature float + (parameters + (declare (in) float edge) + (declare (in) float x)) + ((return (expression float b2f (expression bool >= (var_ref x) (var_ref edge)))))) + + (signature vec2 + (parameters + (declare (in) float edge) + (declare (in) vec2 x)) + ((declare () vec2 t) + (assign (x) (var_ref t) (expression float b2f (expression bool >= (swiz x (var_ref x))(var_ref edge)))) + (assign (y) (var_ref t) (expression float b2f (expression bool >= (swiz y (var_ref x))(var_ref edge)))) + (return (var_ref t)))) + + (signature vec3 + (parameters + (declare (in) float edge) + (declare (in) vec3 x)) + ((declare () vec3 t) + (assign (x) (var_ref t) (expression float b2f (expression bool >= (swiz x (var_ref x))(var_ref edge)))) + (assign (y) (var_ref t) (expression float b2f (expression bool >= (swiz y (var_ref x))(var_ref edge)))) + (assign (z) (var_ref t) (expression float b2f (expression bool >= (swiz z (var_ref x))(var_ref edge)))) + (return (var_ref t)))) + + (signature vec4 + (parameters + (declare (in) float edge) + (declare (in) vec4 x)) + ((declare () vec4 t) + (assign (x) (var_ref t) (expression float b2f (expression bool >= (swiz x (var_ref x))(var_ref edge)))) + (assign (y) (var_ref t) (expression float b2f (expression bool >= (swiz y (var_ref x))(var_ref edge)))) + (assign (z) (var_ref t) (expression float b2f (expression bool >= (swiz z (var_ref x))(var_ref edge)))) + (assign (w) (var_ref t) (expression float b2f (expression bool >= (swiz w (var_ref x))(var_ref edge)))) + (return (var_ref t)))) + + (signature vec2 + (parameters + (declare (in) vec2 edge) + (declare (in) vec2 x)) + ((declare () vec2 t) + (assign (x) (var_ref t) (expression float b2f (expression bool >= (swiz x (var_ref x))(swiz x (var_ref edge))))) + (assign (y) (var_ref t) (expression float b2f (expression bool >= (swiz y (var_ref x))(swiz y (var_ref edge))))) + (return (var_ref t)))) + + (signature vec3 + (parameters + (declare (in) vec3 edge) + (declare (in) vec3 x)) + ((declare () vec3 t) + (assign (x) (var_ref t) (expression float b2f (expression bool >= (swiz x (var_ref x))(swiz x (var_ref edge))))) + (assign (y) (var_ref t) (expression float b2f (expression bool >= (swiz y (var_ref x))(swiz y (var_ref edge))))) + (assign (z) (var_ref t) (expression float b2f (expression bool >= (swiz z (var_ref x))(swiz z (var_ref edge))))) + (return (var_ref t)))) + + (signature vec4 + (parameters + (declare (in) vec4 edge) + (declare (in) vec4 x)) + ((declare () vec4 t) + (assign (x) (var_ref t) (expression float b2f (expression bool >= (swiz x (var_ref x))(swiz x (var_ref edge))))) + (assign (y) (var_ref t) (expression float b2f (expression bool >= (swiz y (var_ref x))(swiz y (var_ref edge))))) + (assign (z) (var_ref t) (expression float b2f (expression bool >= (swiz z (var_ref x))(swiz z (var_ref edge))))) + (assign (w) (var_ref t) (expression float b2f (expression bool >= (swiz w (var_ref x))(swiz w (var_ref edge))))) + (return (var_ref t)))) +)) + diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/ir/tan b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/tan new file mode 100644 index 000000000..997986318 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/tan @@ -0,0 +1,21 @@ +((function tan + (signature float + (parameters + (declare (in) float angle)) + ((return (expression float / (expression float sin (var_ref angle)) (expression float cos (var_ref angle)))))) + + (signature vec2 + (parameters + (declare (in) vec2 angle)) + ((return (expression vec2 / (expression vec2 sin (var_ref angle)) (expression vec2 cos (var_ref angle)))))) + + (signature vec3 + (parameters + (declare (in) vec3 angle)) + ((return (expression vec3 / (expression vec3 sin (var_ref angle)) (expression vec3 cos (var_ref angle)))))) + + (signature vec4 + (parameters + (declare (in) vec4 angle)) + ((return (expression vec4 / (expression vec4 sin (var_ref angle)) (expression vec4 cos (var_ref angle)))))) +)) diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/ir/tanh b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/tanh new file mode 100644 index 000000000..3b7271bf7 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/tanh @@ -0,0 +1,42 @@ +((function tanh + (signature float + (parameters + (declare (in) float x)) + ((return (expression float / + (expression float - + (expression float exp (var_ref x)) + (expression float exp (expression float neg (var_ref x)))) + (expression float + + (expression float exp (var_ref x)) + (expression float exp (expression float neg (var_ref x)))))))) + (signature vec2 + (parameters + (declare (in) vec2 x)) + ((return (expression vec2 / + (expression vec2 - + (expression vec2 exp (var_ref x)) + (expression vec2 exp (expression vec2 neg (var_ref x)))) + (expression vec2 + + (expression vec2 exp (var_ref x)) + (expression vec2 exp (expression vec2 neg (var_ref x)))))))) + (signature vec3 + (parameters + (declare (in) vec3 x)) + ((return (expression vec3 / + (expression vec3 - + (expression vec3 exp (var_ref x)) + (expression vec3 exp (expression vec3 neg (var_ref x)))) + (expression vec3 + + (expression vec3 exp (var_ref x)) + (expression vec3 exp (expression vec3 neg (var_ref x)))))))) + (signature vec4 + (parameters + (declare (in) vec4 x)) + ((return (expression vec4 / + (expression vec4 - + (expression vec4 exp (var_ref x)) + (expression vec4 exp (expression vec4 neg (var_ref x)))) + (expression vec4 + + (expression vec4 exp (var_ref x)) + (expression vec4 exp (expression vec4 neg (var_ref x)))))))) +)) diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/ir/transpose b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/transpose new file mode 100644 index 000000000..043327d23 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/transpose @@ -0,0 +1,139 @@ +((function transpose + (signature mat2 + (parameters + (declare (in) mat2 m)) + ((declare () mat2 t) + (assign (x) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (0))))) + (assign (x) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (0))))) + (assign (y) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (1))))) + (assign (y) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (1))))) +(return (var_ref t)))) + + (signature mat3x2 + (parameters + (declare (in) mat2x3 m)) + ((declare () mat3x2 t) + (assign (x) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (0))))) + (assign (x) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (0))))) + (assign (x) (array_ref (var_ref t) (constant int (2))) (swiz z (array_ref (var_ref m) (constant int (0))))) + (assign (y) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (1))))) + (assign (y) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (1))))) + (assign (y) (array_ref (var_ref t) (constant int (2))) (swiz z (array_ref (var_ref m) (constant int (1))))) +(return (var_ref t)))) + + (signature mat4x2 + (parameters + (declare (in) mat2x4 m)) + ((declare () mat4x2 t) + (assign (x) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (0))))) + (assign (x) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (0))))) + (assign (x) (array_ref (var_ref t) (constant int (2))) (swiz z (array_ref (var_ref m) (constant int (0))))) + (assign (x) (array_ref (var_ref t) (constant int (3))) (swiz w (array_ref (var_ref m) (constant int (0))))) + (assign (y) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (1))))) + (assign (y) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (1))))) + (assign (y) (array_ref (var_ref t) (constant int (2))) (swiz z (array_ref (var_ref m) (constant int (1))))) + (assign (y) (array_ref (var_ref t) (constant int (3))) (swiz w (array_ref (var_ref m) (constant int (1))))) +(return (var_ref t)))) + + (signature mat2x3 + (parameters + (declare (in) mat3x2 m)) + ((declare () mat2x3 t) + (assign (x) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (0))))) + (assign (x) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (0))))) + (assign (y) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (1))))) + (assign (y) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (1))))) + (assign (z) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (2))))) + (assign (z) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (2))))) +(return (var_ref t)))) + + (signature mat3 + (parameters + (declare (in) mat3 m)) + ((declare () mat3 t) + (assign (x) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (0))))) + (assign (x) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (0))))) + (assign (x) (array_ref (var_ref t) (constant int (2))) (swiz z (array_ref (var_ref m) (constant int (0))))) + (assign (y) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (1))))) + (assign (y) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (1))))) + (assign (y) (array_ref (var_ref t) (constant int (2))) (swiz z (array_ref (var_ref m) (constant int (1))))) + (assign (z) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (2))))) + (assign (z) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (2))))) + (assign (z) (array_ref (var_ref t) (constant int (2))) (swiz z (array_ref (var_ref m) (constant int (2))))) +(return (var_ref t)))) + + (signature mat4x3 + (parameters + (declare (in) mat3x4 m)) + ((declare () mat4x3 t) + (assign (x) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (0))))) + (assign (x) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (0))))) + (assign (x) (array_ref (var_ref t) (constant int (2))) (swiz z (array_ref (var_ref m) (constant int (0))))) + (assign (x) (array_ref (var_ref t) (constant int (3))) (swiz w (array_ref (var_ref m) (constant int (0))))) + (assign (y) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (1))))) + (assign (y) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (1))))) + (assign (y) (array_ref (var_ref t) (constant int (2))) (swiz z (array_ref (var_ref m) (constant int (1))))) + (assign (y) (array_ref (var_ref t) (constant int (3))) (swiz w (array_ref (var_ref m) (constant int (1))))) + (assign (z) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (2))))) + (assign (z) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (2))))) + (assign (z) (array_ref (var_ref t) (constant int (2))) (swiz z (array_ref (var_ref m) (constant int (2))))) + (assign (z) (array_ref (var_ref t) (constant int (3))) (swiz w (array_ref (var_ref m) (constant int (2))))) +(return (var_ref t)))) + + (signature mat2x4 + (parameters + (declare (in) mat4x2 m)) + ((declare () mat2x4 t) + (assign (x) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (0))))) + (assign (x) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (0))))) + (assign (y) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (1))))) + (assign (y) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (1))))) + (assign (z) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (2))))) + (assign (z) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (2))))) + (assign (w) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (3))))) + (assign (w) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (3))))) +(return (var_ref t)))) + + (signature mat3x4 + (parameters + (declare (in) mat4x3 m)) + ((declare () mat3x4 t) + (assign (x) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (0))))) + (assign (x) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (0))))) + (assign (x) (array_ref (var_ref t) (constant int (2))) (swiz z (array_ref (var_ref m) (constant int (0))))) + (assign (y) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (1))))) + (assign (y) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (1))))) + (assign (y) (array_ref (var_ref t) (constant int (2))) (swiz z (array_ref (var_ref m) (constant int (1))))) + (assign (z) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (2))))) + (assign (z) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (2))))) + (assign (z) (array_ref (var_ref t) (constant int (2))) (swiz z (array_ref (var_ref m) (constant int (2))))) + (assign (w) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (3))))) + (assign (w) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (3))))) + (assign (w) (array_ref (var_ref t) (constant int (2))) (swiz z (array_ref (var_ref m) (constant int (3))))) +(return (var_ref t)))) + + (signature mat4 + (parameters + (declare (in) mat4 m)) + ((declare () mat4 t) + (assign (x) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (0))))) + (assign (x) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (0))))) + (assign (x) (array_ref (var_ref t) (constant int (2))) (swiz z (array_ref (var_ref m) (constant int (0))))) + (assign (x) (array_ref (var_ref t) (constant int (3))) (swiz w (array_ref (var_ref m) (constant int (0))))) + (assign (y) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (1))))) + (assign (y) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (1))))) + (assign (y) (array_ref (var_ref t) (constant int (2))) (swiz z (array_ref (var_ref m) (constant int (1))))) + (assign (y) (array_ref (var_ref t) (constant int (3))) (swiz w (array_ref (var_ref m) (constant int (1))))) + (assign (z) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (2))))) + (assign (z) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (2))))) + (assign (z) (array_ref (var_ref t) (constant int (2))) (swiz z (array_ref (var_ref m) (constant int (2))))) + (assign (z) (array_ref (var_ref t) (constant int (3))) (swiz w (array_ref (var_ref m) (constant int (2))))) + (assign (w) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (3))))) + (assign (w) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (3))))) + (assign (w) (array_ref (var_ref t) (constant int (2))) (swiz z (array_ref (var_ref m) (constant int (3))))) + (assign (w) (array_ref (var_ref t) (constant int (3))) (swiz w (array_ref (var_ref m) (constant int (3))))) +(return (var_ref t)))) +) + +) + diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/ir/trunc b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/trunc new file mode 100644 index 000000000..d320a2a77 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/ir/trunc @@ -0,0 +1,21 @@ +((function trunc + (signature float + (parameters + (declare (in) float arg0)) + ((return (expression float trunc (var_ref arg0))))) + + (signature vec2 + (parameters + (declare (in) vec2 arg0)) + ((return (expression vec2 trunc (var_ref arg0))))) + + (signature vec3 + (parameters + (declare (in) vec3 arg0)) + ((return (expression vec3 trunc (var_ref arg0))))) + + (signature vec4 + (parameters + (declare (in) vec4 arg0)) + ((return (expression vec4 trunc (var_ref arg0))))) +)) diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/profiles/100.frag b/3rdparty/glsl-optimizer/src/glsl/builtins/profiles/100.frag new file mode 100644 index 000000000..df4c7f042 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/profiles/100.frag @@ -0,0 +1,300 @@ +#version 100 +/* + * 8.1 - Angle and Trigonometry Functions + */ +float radians(float degrees); +vec2 radians(vec2 degrees); +vec3 radians(vec3 degrees); +vec4 radians(vec4 degrees); + +float degrees(float radians); +vec2 degrees(vec2 radians); +vec3 degrees(vec3 radians); +vec4 degrees(vec4 radians); + +float sin(float angle); +vec2 sin(vec2 angle); +vec3 sin(vec3 angle); +vec4 sin(vec4 angle); + +float cos(float angle); +vec2 cos(vec2 angle); +vec3 cos(vec3 angle); +vec4 cos(vec4 angle); + +float tan(float angle); +vec2 tan(vec2 angle); +vec3 tan(vec3 angle); +vec4 tan(vec4 angle); + +float asin(float angle); +vec2 asin(vec2 angle); +vec3 asin(vec3 angle); +vec4 asin(vec4 angle); + +float acos(float angle); +vec2 acos(vec2 angle); +vec3 acos(vec3 angle); +vec4 acos(vec4 angle); + +float atan(float y, float x); +vec2 atan(vec2 y, vec2 x); +vec3 atan(vec3 y, vec3 x); +vec4 atan(vec4 y, vec4 x); + +float atan(float y_over_x); +vec2 atan(vec2 y_over_x); +vec3 atan(vec3 y_over_x); +vec4 atan(vec4 y_over_x); + +/* + * 8.2 - Exponential Functions + */ +float pow(float x, float y); +vec2 pow(vec2 x, vec2 y); +vec3 pow(vec3 x, vec3 y); +vec4 pow(vec4 x, vec4 y); + +float exp(float x); +vec2 exp(vec2 x); +vec3 exp(vec3 x); +vec4 exp(vec4 x); + +float log(float x); +vec2 log(vec2 x); +vec3 log(vec3 x); +vec4 log(vec4 x); + +float exp2(float x); +vec2 exp2(vec2 x); +vec3 exp2(vec3 x); +vec4 exp2(vec4 x); + +float log2(float x); +vec2 log2(vec2 x); +vec3 log2(vec3 x); +vec4 log2(vec4 x); + +float sqrt(float x); +vec2 sqrt(vec2 x); +vec3 sqrt(vec3 x); +vec4 sqrt(vec4 x); + +float inversesqrt(float x); +vec2 inversesqrt(vec2 x); +vec3 inversesqrt(vec3 x); +vec4 inversesqrt(vec4 x); + +/* + * 8.3 - Common Functions + */ +float abs(float x); +vec2 abs(vec2 x); +vec3 abs(vec3 x); +vec4 abs(vec4 x); + +float sign(float x); +vec2 sign(vec2 x); +vec3 sign(vec3 x); +vec4 sign(vec4 x); + +float floor(float x); +vec2 floor(vec2 x); +vec3 floor(vec3 x); +vec4 floor(vec4 x); + +float ceil(float x); +vec2 ceil(vec2 x); +vec3 ceil(vec3 x); +vec4 ceil(vec4 x); + +float fract(float x); +vec2 fract(vec2 x); +vec3 fract(vec3 x); +vec4 fract(vec4 x); + +float mod(float x, float y); +vec2 mod(vec2 x, float y); +vec3 mod(vec3 x, float y); +vec4 mod(vec4 x, float y); + +vec2 mod(vec2 x, vec2 y); +vec3 mod(vec3 x, vec3 y); +vec4 mod(vec4 x, vec4 y); + +float min(float x, float y); +vec2 min(vec2 x, vec2 y); +vec3 min(vec3 x, vec3 y); +vec4 min(vec4 x, vec4 y); + +vec2 min(vec2 x, float y); +vec3 min(vec3 x, float y); +vec4 min(vec4 x, float y); + +float max(float x, float y); +vec2 max(vec2 x, vec2 y); +vec3 max(vec3 x, vec3 y); +vec4 max(vec4 x, vec4 y); + +vec2 max(vec2 x, float y); +vec3 max(vec3 x, float y); +vec4 max(vec4 x, float y); + +float clamp(float x, float minVal, float maxVal); +vec2 clamp(vec2 x, vec2 minVal, vec2 maxVal); +vec3 clamp(vec3 x, vec3 minVal, vec3 maxVal); +vec4 clamp(vec4 x, vec4 minVal, vec4 maxVal); + +vec2 clamp(vec2 x, float minVal, float maxVal); +vec3 clamp(vec3 x, float minVal, float maxVal); +vec4 clamp(vec4 x, float minVal, float maxVal); + +float mix(float x, float y, float a); +vec2 mix(vec2 x, vec2 y, vec2 a); +vec3 mix(vec3 x, vec3 y, vec3 a); +vec4 mix(vec4 x, vec4 y, vec4 a); + +vec2 mix(vec2 x, vec2 y, float a); +vec3 mix(vec3 x, vec3 y, float a); +vec4 mix(vec4 x, vec4 y, float a); + +float step(float edge, float x); +vec2 step(vec2 edge, vec2 x); +vec3 step(vec3 edge, vec3 x); +vec4 step(vec4 edge, vec4 x); + +vec2 step(float edge, vec2 x); +vec3 step(float edge, vec3 x); +vec4 step(float edge, vec4 x); + +float smoothstep(float edge0, float edge1, float x); +vec2 smoothstep(vec2 edge0, vec2 edge1, vec2 x); +vec3 smoothstep(vec3 edge0, vec3 edge1, vec3 x); +vec4 smoothstep(vec4 edge0, vec4 edge1, vec4 x); + +vec2 smoothstep(float edge0, float edge1, vec2 x); +vec3 smoothstep(float edge0, float edge1, vec3 x); +vec4 smoothstep(float edge0, float edge1, vec4 x); + +/* + * 8.4 - Geometric Functions + */ +float length(float x); +float length(vec2 x); +float length(vec3 x); +float length(vec4 x); + +float distance(float p0, float p1); +float distance(vec2 p0, vec2 p1); +float distance(vec3 p0, vec3 p1); +float distance(vec4 p0, vec4 p1); + +float dot(float x, float y); +float dot(vec2 x, vec2 y); +float dot(vec3 x, vec3 y); +float dot(vec4 x, vec4 y); + +vec3 cross(vec3 x, vec3 y); + +float normalize(float x); +vec2 normalize(vec2 x); +vec3 normalize(vec3 x); +vec4 normalize(vec4 x); + +float faceforward(float N, float I, float Nref); +vec2 faceforward(vec2 N, vec2 I, vec2 Nref); +vec3 faceforward(vec3 N, vec3 I, vec3 Nref); +vec4 faceforward(vec4 N, vec4 I, vec4 Nref); + +float reflect(float I, float N); +vec2 reflect(vec2 I, vec2 N); +vec3 reflect(vec3 I, vec3 N); +vec4 reflect(vec4 I, vec4 N); + +float refract(float I, float N, float eta); +vec2 refract(vec2 I, vec2 N, float eta); +vec3 refract(vec3 I, vec3 N, float eta); +vec4 refract(vec4 I, vec4 N, float eta); + +/* + * 8.5 - Matrix Functions + */ +mat2 matrixCompMult(mat2 x, mat2 y); +mat3 matrixCompMult(mat3 x, mat3 y); +mat4 matrixCompMult(mat4 x, mat4 y); + +/* + * 8.6 - Vector Relational Functions + */ +bvec2 lessThan( vec2 x, vec2 y); +bvec3 lessThan( vec3 x, vec3 y); +bvec4 lessThan( vec4 x, vec4 y); +bvec2 lessThan(ivec2 x, ivec2 y); +bvec3 lessThan(ivec3 x, ivec3 y); +bvec4 lessThan(ivec4 x, ivec4 y); + +bvec2 lessThanEqual( vec2 x, vec2 y); +bvec3 lessThanEqual( vec3 x, vec3 y); +bvec4 lessThanEqual( vec4 x, vec4 y); +bvec2 lessThanEqual(ivec2 x, ivec2 y); +bvec3 lessThanEqual(ivec3 x, ivec3 y); +bvec4 lessThanEqual(ivec4 x, ivec4 y); + +bvec2 greaterThan( vec2 x, vec2 y); +bvec3 greaterThan( vec3 x, vec3 y); +bvec4 greaterThan( vec4 x, vec4 y); +bvec2 greaterThan(ivec2 x, ivec2 y); +bvec3 greaterThan(ivec3 x, ivec3 y); +bvec4 greaterThan(ivec4 x, ivec4 y); + +bvec2 greaterThanEqual( vec2 x, vec2 y); +bvec3 greaterThanEqual( vec3 x, vec3 y); +bvec4 greaterThanEqual( vec4 x, vec4 y); +bvec2 greaterThanEqual(ivec2 x, ivec2 y); +bvec3 greaterThanEqual(ivec3 x, ivec3 y); +bvec4 greaterThanEqual(ivec4 x, ivec4 y); + +bvec2 equal( vec2 x, vec2 y); +bvec3 equal( vec3 x, vec3 y); +bvec4 equal( vec4 x, vec4 y); +bvec2 equal(ivec2 x, ivec2 y); +bvec3 equal(ivec3 x, ivec3 y); +bvec4 equal(ivec4 x, ivec4 y); +bvec2 equal(bvec2 x, bvec2 y); +bvec3 equal(bvec3 x, bvec3 y); +bvec4 equal(bvec4 x, bvec4 y); + +bvec2 notEqual( vec2 x, vec2 y); +bvec3 notEqual( vec3 x, vec3 y); +bvec4 notEqual( vec4 x, vec4 y); +bvec2 notEqual(ivec2 x, ivec2 y); +bvec3 notEqual(ivec3 x, ivec3 y); +bvec4 notEqual(ivec4 x, ivec4 y); +bvec2 notEqual(bvec2 x, bvec2 y); +bvec3 notEqual(bvec3 x, bvec3 y); +bvec4 notEqual(bvec4 x, bvec4 y); + +bool any(bvec2 x); +bool any(bvec3 x); +bool any(bvec4 x); + +bool all(bvec2 x); +bool all(bvec3 x); +bool all(bvec4 x); + +bvec2 not(bvec2 x); +bvec3 not(bvec3 x); +bvec4 not(bvec4 x); + +/* + * 8.7 - Texture Lookup Functions + */ +vec4 texture2D (sampler2D sampler, vec2 coord); +vec4 texture2DProj (sampler2D sampler, vec3 coord); +vec4 texture2DProj (sampler2D sampler, vec4 coord); +vec4 texture2D (sampler2D sampler, vec2 coord, float bias); +vec4 texture2DProj (sampler2D sampler, vec3 coord, float bias); +vec4 texture2DProj (sampler2D sampler, vec4 coord, float bias); + +vec4 textureCube (samplerCube sampler, vec3 coord); +vec4 textureCube (samplerCube sampler, vec3 coord, float bias); diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/profiles/100.vert b/3rdparty/glsl-optimizer/src/glsl/builtins/profiles/100.vert new file mode 100644 index 000000000..e5d96f1db --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/profiles/100.vert @@ -0,0 +1,300 @@ +#version 100 +/* + * 8.1 - Angle and Trigonometry Functions + */ +float radians(float degrees); +vec2 radians(vec2 degrees); +vec3 radians(vec3 degrees); +vec4 radians(vec4 degrees); + +float degrees(float radians); +vec2 degrees(vec2 radians); +vec3 degrees(vec3 radians); +vec4 degrees(vec4 radians); + +float sin(float angle); +vec2 sin(vec2 angle); +vec3 sin(vec3 angle); +vec4 sin(vec4 angle); + +float cos(float angle); +vec2 cos(vec2 angle); +vec3 cos(vec3 angle); +vec4 cos(vec4 angle); + +float tan(float angle); +vec2 tan(vec2 angle); +vec3 tan(vec3 angle); +vec4 tan(vec4 angle); + +float asin(float angle); +vec2 asin(vec2 angle); +vec3 asin(vec3 angle); +vec4 asin(vec4 angle); + +float acos(float angle); +vec2 acos(vec2 angle); +vec3 acos(vec3 angle); +vec4 acos(vec4 angle); + +float atan(float y, float x); +vec2 atan(vec2 y, vec2 x); +vec3 atan(vec3 y, vec3 x); +vec4 atan(vec4 y, vec4 x); + +float atan(float y_over_x); +vec2 atan(vec2 y_over_x); +vec3 atan(vec3 y_over_x); +vec4 atan(vec4 y_over_x); + +/* + * 8.2 - Exponential Functions + */ +float pow(float x, float y); +vec2 pow(vec2 x, vec2 y); +vec3 pow(vec3 x, vec3 y); +vec4 pow(vec4 x, vec4 y); + +float exp(float x); +vec2 exp(vec2 x); +vec3 exp(vec3 x); +vec4 exp(vec4 x); + +float log(float x); +vec2 log(vec2 x); +vec3 log(vec3 x); +vec4 log(vec4 x); + +float exp2(float x); +vec2 exp2(vec2 x); +vec3 exp2(vec3 x); +vec4 exp2(vec4 x); + +float log2(float x); +vec2 log2(vec2 x); +vec3 log2(vec3 x); +vec4 log2(vec4 x); + +float sqrt(float x); +vec2 sqrt(vec2 x); +vec3 sqrt(vec3 x); +vec4 sqrt(vec4 x); + +float inversesqrt(float x); +vec2 inversesqrt(vec2 x); +vec3 inversesqrt(vec3 x); +vec4 inversesqrt(vec4 x); + +/* + * 8.3 - Common Functions + */ +float abs(float x); +vec2 abs(vec2 x); +vec3 abs(vec3 x); +vec4 abs(vec4 x); + +float sign(float x); +vec2 sign(vec2 x); +vec3 sign(vec3 x); +vec4 sign(vec4 x); + +float floor(float x); +vec2 floor(vec2 x); +vec3 floor(vec3 x); +vec4 floor(vec4 x); + +float ceil(float x); +vec2 ceil(vec2 x); +vec3 ceil(vec3 x); +vec4 ceil(vec4 x); + +float fract(float x); +vec2 fract(vec2 x); +vec3 fract(vec3 x); +vec4 fract(vec4 x); + +float mod(float x, float y); +vec2 mod(vec2 x, float y); +vec3 mod(vec3 x, float y); +vec4 mod(vec4 x, float y); + +vec2 mod(vec2 x, vec2 y); +vec3 mod(vec3 x, vec3 y); +vec4 mod(vec4 x, vec4 y); + +float min(float x, float y); +vec2 min(vec2 x, vec2 y); +vec3 min(vec3 x, vec3 y); +vec4 min(vec4 x, vec4 y); + +vec2 min(vec2 x, float y); +vec3 min(vec3 x, float y); +vec4 min(vec4 x, float y); + +float max(float x, float y); +vec2 max(vec2 x, vec2 y); +vec3 max(vec3 x, vec3 y); +vec4 max(vec4 x, vec4 y); + +vec2 max(vec2 x, float y); +vec3 max(vec3 x, float y); +vec4 max(vec4 x, float y); + +float clamp(float x, float minVal, float maxVal); +vec2 clamp(vec2 x, vec2 minVal, vec2 maxVal); +vec3 clamp(vec3 x, vec3 minVal, vec3 maxVal); +vec4 clamp(vec4 x, vec4 minVal, vec4 maxVal); + +vec2 clamp(vec2 x, float minVal, float maxVal); +vec3 clamp(vec3 x, float minVal, float maxVal); +vec4 clamp(vec4 x, float minVal, float maxVal); + +float mix(float x, float y, float a); +vec2 mix(vec2 x, vec2 y, vec2 a); +vec3 mix(vec3 x, vec3 y, vec3 a); +vec4 mix(vec4 x, vec4 y, vec4 a); + +vec2 mix(vec2 x, vec2 y, float a); +vec3 mix(vec3 x, vec3 y, float a); +vec4 mix(vec4 x, vec4 y, float a); + +float step(float edge, float x); +vec2 step(vec2 edge, vec2 x); +vec3 step(vec3 edge, vec3 x); +vec4 step(vec4 edge, vec4 x); + +vec2 step(float edge, vec2 x); +vec3 step(float edge, vec3 x); +vec4 step(float edge, vec4 x); + +float smoothstep(float edge0, float edge1, float x); +vec2 smoothstep(vec2 edge0, vec2 edge1, vec2 x); +vec3 smoothstep(vec3 edge0, vec3 edge1, vec3 x); +vec4 smoothstep(vec4 edge0, vec4 edge1, vec4 x); + +vec2 smoothstep(float edge0, float edge1, vec2 x); +vec3 smoothstep(float edge0, float edge1, vec3 x); +vec4 smoothstep(float edge0, float edge1, vec4 x); + +/* + * 8.4 - Geometric Functions + */ +float length(float x); +float length(vec2 x); +float length(vec3 x); +float length(vec4 x); + +float distance(float p0, float p1); +float distance(vec2 p0, vec2 p1); +float distance(vec3 p0, vec3 p1); +float distance(vec4 p0, vec4 p1); + +float dot(float x, float y); +float dot(vec2 x, vec2 y); +float dot(vec3 x, vec3 y); +float dot(vec4 x, vec4 y); + +vec3 cross(vec3 x, vec3 y); + +float normalize(float x); +vec2 normalize(vec2 x); +vec3 normalize(vec3 x); +vec4 normalize(vec4 x); + +float faceforward(float N, float I, float Nref); +vec2 faceforward(vec2 N, vec2 I, vec2 Nref); +vec3 faceforward(vec3 N, vec3 I, vec3 Nref); +vec4 faceforward(vec4 N, vec4 I, vec4 Nref); + +float reflect(float I, float N); +vec2 reflect(vec2 I, vec2 N); +vec3 reflect(vec3 I, vec3 N); +vec4 reflect(vec4 I, vec4 N); + +float refract(float I, float N, float eta); +vec2 refract(vec2 I, vec2 N, float eta); +vec3 refract(vec3 I, vec3 N, float eta); +vec4 refract(vec4 I, vec4 N, float eta); + +/* + * 8.5 - Matrix Functions + */ +mat2 matrixCompMult(mat2 x, mat2 y); +mat3 matrixCompMult(mat3 x, mat3 y); +mat4 matrixCompMult(mat4 x, mat4 y); + +/* + * 8.6 - Vector Relational Functions + */ +bvec2 lessThan( vec2 x, vec2 y); +bvec3 lessThan( vec3 x, vec3 y); +bvec4 lessThan( vec4 x, vec4 y); +bvec2 lessThan(ivec2 x, ivec2 y); +bvec3 lessThan(ivec3 x, ivec3 y); +bvec4 lessThan(ivec4 x, ivec4 y); + +bvec2 lessThanEqual( vec2 x, vec2 y); +bvec3 lessThanEqual( vec3 x, vec3 y); +bvec4 lessThanEqual( vec4 x, vec4 y); +bvec2 lessThanEqual(ivec2 x, ivec2 y); +bvec3 lessThanEqual(ivec3 x, ivec3 y); +bvec4 lessThanEqual(ivec4 x, ivec4 y); + +bvec2 greaterThan( vec2 x, vec2 y); +bvec3 greaterThan( vec3 x, vec3 y); +bvec4 greaterThan( vec4 x, vec4 y); +bvec2 greaterThan(ivec2 x, ivec2 y); +bvec3 greaterThan(ivec3 x, ivec3 y); +bvec4 greaterThan(ivec4 x, ivec4 y); + +bvec2 greaterThanEqual( vec2 x, vec2 y); +bvec3 greaterThanEqual( vec3 x, vec3 y); +bvec4 greaterThanEqual( vec4 x, vec4 y); +bvec2 greaterThanEqual(ivec2 x, ivec2 y); +bvec3 greaterThanEqual(ivec3 x, ivec3 y); +bvec4 greaterThanEqual(ivec4 x, ivec4 y); + +bvec2 equal( vec2 x, vec2 y); +bvec3 equal( vec3 x, vec3 y); +bvec4 equal( vec4 x, vec4 y); +bvec2 equal(ivec2 x, ivec2 y); +bvec3 equal(ivec3 x, ivec3 y); +bvec4 equal(ivec4 x, ivec4 y); +bvec2 equal(bvec2 x, bvec2 y); +bvec3 equal(bvec3 x, bvec3 y); +bvec4 equal(bvec4 x, bvec4 y); + +bvec2 notEqual( vec2 x, vec2 y); +bvec3 notEqual( vec3 x, vec3 y); +bvec4 notEqual( vec4 x, vec4 y); +bvec2 notEqual(ivec2 x, ivec2 y); +bvec3 notEqual(ivec3 x, ivec3 y); +bvec4 notEqual(ivec4 x, ivec4 y); +bvec2 notEqual(bvec2 x, bvec2 y); +bvec3 notEqual(bvec3 x, bvec3 y); +bvec4 notEqual(bvec4 x, bvec4 y); + +bool any(bvec2 x); +bool any(bvec3 x); +bool any(bvec4 x); + +bool all(bvec2 x); +bool all(bvec3 x); +bool all(bvec4 x); + +bvec2 not(bvec2 x); +bvec3 not(bvec3 x); +bvec4 not(bvec4 x); + +/* + * 8.7 - Texture Lookup Functions + */ +vec4 texture2D (sampler2D sampler, vec2 coord); +vec4 texture2DProj (sampler2D sampler, vec3 coord); +vec4 texture2DProj (sampler2D sampler, vec4 coord); +vec4 texture2DLod (sampler2D sampler, vec2 coord, float lod); +vec4 texture2DProjLod(sampler2D sampler, vec3 coord, float lod); +vec4 texture2DProjLod(sampler2D sampler, vec4 coord, float lod); + +vec4 textureCube (samplerCube sampler, vec3 coord); +vec4 textureCubeLod (samplerCube sampler, vec3 coord, float lod); diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/profiles/110.frag b/3rdparty/glsl-optimizer/src/glsl/builtins/profiles/110.frag new file mode 100644 index 000000000..25bc62c09 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/profiles/110.frag @@ -0,0 +1,364 @@ +#version 110 +/* + * 8.1 - Angle and Trigonometry Functions + */ +float radians(float degrees); +vec2 radians(vec2 degrees); +vec3 radians(vec3 degrees); +vec4 radians(vec4 degrees); + +float degrees(float radians); +vec2 degrees(vec2 radians); +vec3 degrees(vec3 radians); +vec4 degrees(vec4 radians); + +float sin(float angle); +vec2 sin(vec2 angle); +vec3 sin(vec3 angle); +vec4 sin(vec4 angle); + +float cos(float angle); +vec2 cos(vec2 angle); +vec3 cos(vec3 angle); +vec4 cos(vec4 angle); + +float tan(float angle); +vec2 tan(vec2 angle); +vec3 tan(vec3 angle); +vec4 tan(vec4 angle); + +float asin(float angle); +vec2 asin(vec2 angle); +vec3 asin(vec3 angle); +vec4 asin(vec4 angle); + +float acos(float angle); +vec2 acos(vec2 angle); +vec3 acos(vec3 angle); +vec4 acos(vec4 angle); + +float atan(float y, float x); +vec2 atan(vec2 y, vec2 x); +vec3 atan(vec3 y, vec3 x); +vec4 atan(vec4 y, vec4 x); + +float atan(float y_over_x); +vec2 atan(vec2 y_over_x); +vec3 atan(vec3 y_over_x); +vec4 atan(vec4 y_over_x); + +/* + * 8.2 - Exponential Functions + */ +float pow(float x, float y); +vec2 pow(vec2 x, vec2 y); +vec3 pow(vec3 x, vec3 y); +vec4 pow(vec4 x, vec4 y); + +float exp(float x); +vec2 exp(vec2 x); +vec3 exp(vec3 x); +vec4 exp(vec4 x); + +float log(float x); +vec2 log(vec2 x); +vec3 log(vec3 x); +vec4 log(vec4 x); + +float exp2(float x); +vec2 exp2(vec2 x); +vec3 exp2(vec3 x); +vec4 exp2(vec4 x); + +float log2(float x); +vec2 log2(vec2 x); +vec3 log2(vec3 x); +vec4 log2(vec4 x); + +float sqrt(float x); +vec2 sqrt(vec2 x); +vec3 sqrt(vec3 x); +vec4 sqrt(vec4 x); + +float inversesqrt(float x); +vec2 inversesqrt(vec2 x); +vec3 inversesqrt(vec3 x); +vec4 inversesqrt(vec4 x); + +/* + * 8.3 - Common Functions + */ +float abs(float x); +vec2 abs(vec2 x); +vec3 abs(vec3 x); +vec4 abs(vec4 x); + +float sign(float x); +vec2 sign(vec2 x); +vec3 sign(vec3 x); +vec4 sign(vec4 x); + +float floor(float x); +vec2 floor(vec2 x); +vec3 floor(vec3 x); +vec4 floor(vec4 x); + +float ceil(float x); +vec2 ceil(vec2 x); +vec3 ceil(vec3 x); +vec4 ceil(vec4 x); + +float fract(float x); +vec2 fract(vec2 x); +vec3 fract(vec3 x); +vec4 fract(vec4 x); + +float mod(float x, float y); +vec2 mod(vec2 x, float y); +vec3 mod(vec3 x, float y); +vec4 mod(vec4 x, float y); + +vec2 mod(vec2 x, vec2 y); +vec3 mod(vec3 x, vec3 y); +vec4 mod(vec4 x, vec4 y); + +float min(float x, float y); +vec2 min(vec2 x, vec2 y); +vec3 min(vec3 x, vec3 y); +vec4 min(vec4 x, vec4 y); + +vec2 min(vec2 x, float y); +vec3 min(vec3 x, float y); +vec4 min(vec4 x, float y); + +float max(float x, float y); +vec2 max(vec2 x, vec2 y); +vec3 max(vec3 x, vec3 y); +vec4 max(vec4 x, vec4 y); + +vec2 max(vec2 x, float y); +vec3 max(vec3 x, float y); +vec4 max(vec4 x, float y); + +float clamp(float x, float minVal, float maxVal); +vec2 clamp(vec2 x, vec2 minVal, vec2 maxVal); +vec3 clamp(vec3 x, vec3 minVal, vec3 maxVal); +vec4 clamp(vec4 x, vec4 minVal, vec4 maxVal); + +vec2 clamp(vec2 x, float minVal, float maxVal); +vec3 clamp(vec3 x, float minVal, float maxVal); +vec4 clamp(vec4 x, float minVal, float maxVal); + +float mix(float x, float y, float a); +vec2 mix(vec2 x, vec2 y, vec2 a); +vec3 mix(vec3 x, vec3 y, vec3 a); +vec4 mix(vec4 x, vec4 y, vec4 a); + +vec2 mix(vec2 x, vec2 y, float a); +vec3 mix(vec3 x, vec3 y, float a); +vec4 mix(vec4 x, vec4 y, float a); + +float step(float edge, float x); +vec2 step(vec2 edge, vec2 x); +vec3 step(vec3 edge, vec3 x); +vec4 step(vec4 edge, vec4 x); + +vec2 step(float edge, vec2 x); +vec3 step(float edge, vec3 x); +vec4 step(float edge, vec4 x); + +float smoothstep(float edge0, float edge1, float x); +vec2 smoothstep(vec2 edge0, vec2 edge1, vec2 x); +vec3 smoothstep(vec3 edge0, vec3 edge1, vec3 x); +vec4 smoothstep(vec4 edge0, vec4 edge1, vec4 x); + +vec2 smoothstep(float edge0, float edge1, vec2 x); +vec3 smoothstep(float edge0, float edge1, vec3 x); +vec4 smoothstep(float edge0, float edge1, vec4 x); + +/* + * 8.4 - Geometric Functions + */ +float length(float x); +float length(vec2 x); +float length(vec3 x); +float length(vec4 x); + +float distance(float p0, float p1); +float distance(vec2 p0, vec2 p1); +float distance(vec3 p0, vec3 p1); +float distance(vec4 p0, vec4 p1); + +float dot(float x, float y); +float dot(vec2 x, vec2 y); +float dot(vec3 x, vec3 y); +float dot(vec4 x, vec4 y); + +vec3 cross(vec3 x, vec3 y); + +float normalize(float x); +vec2 normalize(vec2 x); +vec3 normalize(vec3 x); +vec4 normalize(vec4 x); + +float faceforward(float N, float I, float Nref); +vec2 faceforward(vec2 N, vec2 I, vec2 Nref); +vec3 faceforward(vec3 N, vec3 I, vec3 Nref); +vec4 faceforward(vec4 N, vec4 I, vec4 Nref); + +float reflect(float I, float N); +vec2 reflect(vec2 I, vec2 N); +vec3 reflect(vec3 I, vec3 N); +vec4 reflect(vec4 I, vec4 N); + +float refract(float I, float N, float eta); +vec2 refract(vec2 I, vec2 N, float eta); +vec3 refract(vec3 I, vec3 N, float eta); +vec4 refract(vec4 I, vec4 N, float eta); + + +/* + * 8.5 - Matrix Functions + */ +mat2 matrixCompMult(mat2 x, mat2 y); +mat3 matrixCompMult(mat3 x, mat3 y); +mat4 matrixCompMult(mat4 x, mat4 y); + +/* + * 8.6 - Vector Relational Functions + */ +bvec2 lessThan( vec2 x, vec2 y); +bvec3 lessThan( vec3 x, vec3 y); +bvec4 lessThan( vec4 x, vec4 y); +bvec2 lessThan(ivec2 x, ivec2 y); +bvec3 lessThan(ivec3 x, ivec3 y); +bvec4 lessThan(ivec4 x, ivec4 y); + +bvec2 lessThanEqual( vec2 x, vec2 y); +bvec3 lessThanEqual( vec3 x, vec3 y); +bvec4 lessThanEqual( vec4 x, vec4 y); +bvec2 lessThanEqual(ivec2 x, ivec2 y); +bvec3 lessThanEqual(ivec3 x, ivec3 y); +bvec4 lessThanEqual(ivec4 x, ivec4 y); + +bvec2 greaterThan( vec2 x, vec2 y); +bvec3 greaterThan( vec3 x, vec3 y); +bvec4 greaterThan( vec4 x, vec4 y); +bvec2 greaterThan(ivec2 x, ivec2 y); +bvec3 greaterThan(ivec3 x, ivec3 y); +bvec4 greaterThan(ivec4 x, ivec4 y); + +bvec2 greaterThanEqual( vec2 x, vec2 y); +bvec3 greaterThanEqual( vec3 x, vec3 y); +bvec4 greaterThanEqual( vec4 x, vec4 y); +bvec2 greaterThanEqual(ivec2 x, ivec2 y); +bvec3 greaterThanEqual(ivec3 x, ivec3 y); +bvec4 greaterThanEqual(ivec4 x, ivec4 y); + +bvec2 equal( vec2 x, vec2 y); +bvec3 equal( vec3 x, vec3 y); +bvec4 equal( vec4 x, vec4 y); +bvec2 equal(ivec2 x, ivec2 y); +bvec3 equal(ivec3 x, ivec3 y); +bvec4 equal(ivec4 x, ivec4 y); +bvec2 equal(bvec2 x, bvec2 y); +bvec3 equal(bvec3 x, bvec3 y); +bvec4 equal(bvec4 x, bvec4 y); + +bvec2 notEqual( vec2 x, vec2 y); +bvec3 notEqual( vec3 x, vec3 y); +bvec4 notEqual( vec4 x, vec4 y); +bvec2 notEqual(ivec2 x, ivec2 y); +bvec3 notEqual(ivec3 x, ivec3 y); +bvec4 notEqual(ivec4 x, ivec4 y); +bvec2 notEqual(bvec2 x, bvec2 y); +bvec3 notEqual(bvec3 x, bvec3 y); +bvec4 notEqual(bvec4 x, bvec4 y); + +bool any(bvec2 x); +bool any(bvec3 x); +bool any(bvec4 x); + +bool all(bvec2 x); +bool all(bvec3 x); +bool all(bvec4 x); + +bvec2 not(bvec2 x); +bvec3 not(bvec3 x); +bvec4 not(bvec4 x); + +/* + * 8.7 - Texture Lookup Functions + */ +vec4 texture1D (sampler1D sampler, float coord); +vec4 texture1DProj (sampler1D sampler, vec2 coord); +vec4 texture1DProj (sampler1D sampler, vec4 coord); +vec4 texture1D (sampler1D sampler, float coord, float bias); +vec4 texture1DProj (sampler1D sampler, vec2 coord, float bias); +vec4 texture1DProj (sampler1D sampler, vec4 coord, float bias); + +vec4 texture2D (sampler2D sampler, vec2 coord); +vec4 texture2DProj (sampler2D sampler, vec3 coord); +vec4 texture2DProj (sampler2D sampler, vec4 coord); +vec4 texture2D (sampler2D sampler, vec2 coord, float bias); +vec4 texture2DProj (sampler2D sampler, vec3 coord, float bias); +vec4 texture2DProj (sampler2D sampler, vec4 coord, float bias); + +vec4 texture3D (sampler3D sampler, vec3 coord); +vec4 texture3DProj (sampler3D sampler, vec4 coord); +vec4 texture3D (sampler3D sampler, vec3 coord, float bias); +vec4 texture3DProj (sampler3D sampler, vec4 coord, float bias); + +vec4 textureCube (samplerCube sampler, vec3 coord); +vec4 textureCube (samplerCube sampler, vec3 coord, float bias); + +vec4 shadow1D (sampler1DShadow sampler, vec3 coord); +vec4 shadow2D (sampler2DShadow sampler, vec3 coord); +vec4 shadow1DProj (sampler1DShadow sampler, vec4 coord); +vec4 shadow2DProj (sampler2DShadow sampler, vec4 coord); +vec4 shadow1D (sampler1DShadow sampler, vec3 coord, float bias); +vec4 shadow2D (sampler2DShadow sampler, vec3 coord, float bias); +vec4 shadow1DProj (sampler1DShadow sampler, vec4 coord, float bias); +vec4 shadow2DProj (sampler2DShadow sampler, vec4 coord, float bias); + + +/* + * 8.8 - Fragment Processing Functions + */ +float dFdx(float p); +vec2 dFdx(vec2 p); +vec3 dFdx(vec3 p); +vec4 dFdx(vec4 p); + +float dFdy(float p); +vec2 dFdy(vec2 p); +vec3 dFdy(vec3 p); +vec4 dFdy(vec4 p); + +float fwidth(float p); +vec2 fwidth(vec2 p); +vec3 fwidth(vec3 p); +vec4 fwidth(vec4 p); + +/* + * 8.9 - Noise Functions + */ +float noise1(float x); +float noise1(vec2 x); +float noise1(vec3 x); +float noise1(vec4 x); + +vec2 noise2(float x); +vec2 noise2(vec2 x); +vec2 noise2(vec3 x); +vec2 noise2(vec4 x); + +vec3 noise3(float x); +vec3 noise3(vec2 x); +vec3 noise3(vec3 x); +vec3 noise3(vec4 x); + +vec4 noise4(float x); +vec4 noise4(vec2 x); +vec4 noise4(vec3 x); +vec4 noise4(vec4 x); diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/profiles/110.vert b/3rdparty/glsl-optimizer/src/glsl/builtins/profiles/110.vert new file mode 100644 index 000000000..545e59c53 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/profiles/110.vert @@ -0,0 +1,351 @@ +#version 110 +/* + * 8.1 - Angle and Trigonometry Functions + */ +float radians(float degrees); +vec2 radians(vec2 degrees); +vec3 radians(vec3 degrees); +vec4 radians(vec4 degrees); + +float degrees(float radians); +vec2 degrees(vec2 radians); +vec3 degrees(vec3 radians); +vec4 degrees(vec4 radians); + +float sin(float angle); +vec2 sin(vec2 angle); +vec3 sin(vec3 angle); +vec4 sin(vec4 angle); + +float cos(float angle); +vec2 cos(vec2 angle); +vec3 cos(vec3 angle); +vec4 cos(vec4 angle); + +float tan(float angle); +vec2 tan(vec2 angle); +vec3 tan(vec3 angle); +vec4 tan(vec4 angle); + +float asin(float angle); +vec2 asin(vec2 angle); +vec3 asin(vec3 angle); +vec4 asin(vec4 angle); + +float acos(float angle); +vec2 acos(vec2 angle); +vec3 acos(vec3 angle); +vec4 acos(vec4 angle); + +float atan(float y, float x); +vec2 atan(vec2 y, vec2 x); +vec3 atan(vec3 y, vec3 x); +vec4 atan(vec4 y, vec4 x); + +float atan(float y_over_x); +vec2 atan(vec2 y_over_x); +vec3 atan(vec3 y_over_x); +vec4 atan(vec4 y_over_x); + +/* + * 8.2 - Exponential Functions + */ +float pow(float x, float y); +vec2 pow(vec2 x, vec2 y); +vec3 pow(vec3 x, vec3 y); +vec4 pow(vec4 x, vec4 y); + +float exp(float x); +vec2 exp(vec2 x); +vec3 exp(vec3 x); +vec4 exp(vec4 x); + +float log(float x); +vec2 log(vec2 x); +vec3 log(vec3 x); +vec4 log(vec4 x); + +float exp2(float x); +vec2 exp2(vec2 x); +vec3 exp2(vec3 x); +vec4 exp2(vec4 x); + +float log2(float x); +vec2 log2(vec2 x); +vec3 log2(vec3 x); +vec4 log2(vec4 x); + +float sqrt(float x); +vec2 sqrt(vec2 x); +vec3 sqrt(vec3 x); +vec4 sqrt(vec4 x); + +float inversesqrt(float x); +vec2 inversesqrt(vec2 x); +vec3 inversesqrt(vec3 x); +vec4 inversesqrt(vec4 x); + +/* + * 8.3 - Common Functions + */ +float abs(float x); +vec2 abs(vec2 x); +vec3 abs(vec3 x); +vec4 abs(vec4 x); + +float sign(float x); +vec2 sign(vec2 x); +vec3 sign(vec3 x); +vec4 sign(vec4 x); + +float floor(float x); +vec2 floor(vec2 x); +vec3 floor(vec3 x); +vec4 floor(vec4 x); + +float ceil(float x); +vec2 ceil(vec2 x); +vec3 ceil(vec3 x); +vec4 ceil(vec4 x); + +float fract(float x); +vec2 fract(vec2 x); +vec3 fract(vec3 x); +vec4 fract(vec4 x); + +float mod(float x, float y); +vec2 mod(vec2 x, float y); +vec3 mod(vec3 x, float y); +vec4 mod(vec4 x, float y); + +vec2 mod(vec2 x, vec2 y); +vec3 mod(vec3 x, vec3 y); +vec4 mod(vec4 x, vec4 y); + +float min(float x, float y); +vec2 min(vec2 x, vec2 y); +vec3 min(vec3 x, vec3 y); +vec4 min(vec4 x, vec4 y); + +vec2 min(vec2 x, float y); +vec3 min(vec3 x, float y); +vec4 min(vec4 x, float y); + +float max(float x, float y); +vec2 max(vec2 x, vec2 y); +vec3 max(vec3 x, vec3 y); +vec4 max(vec4 x, vec4 y); + +vec2 max(vec2 x, float y); +vec3 max(vec3 x, float y); +vec4 max(vec4 x, float y); + +float clamp(float x, float minVal, float maxVal); +vec2 clamp(vec2 x, vec2 minVal, vec2 maxVal); +vec3 clamp(vec3 x, vec3 minVal, vec3 maxVal); +vec4 clamp(vec4 x, vec4 minVal, vec4 maxVal); + +vec2 clamp(vec2 x, float minVal, float maxVal); +vec3 clamp(vec3 x, float minVal, float maxVal); +vec4 clamp(vec4 x, float minVal, float maxVal); + +float mix(float x, float y, float a); +vec2 mix(vec2 x, vec2 y, vec2 a); +vec3 mix(vec3 x, vec3 y, vec3 a); +vec4 mix(vec4 x, vec4 y, vec4 a); + +vec2 mix(vec2 x, vec2 y, float a); +vec3 mix(vec3 x, vec3 y, float a); +vec4 mix(vec4 x, vec4 y, float a); + +float step(float edge, float x); +vec2 step(vec2 edge, vec2 x); +vec3 step(vec3 edge, vec3 x); +vec4 step(vec4 edge, vec4 x); + +vec2 step(float edge, vec2 x); +vec3 step(float edge, vec3 x); +vec4 step(float edge, vec4 x); + +float smoothstep(float edge0, float edge1, float x); +vec2 smoothstep(vec2 edge0, vec2 edge1, vec2 x); +vec3 smoothstep(vec3 edge0, vec3 edge1, vec3 x); +vec4 smoothstep(vec4 edge0, vec4 edge1, vec4 x); + +vec2 smoothstep(float edge0, float edge1, vec2 x); +vec3 smoothstep(float edge0, float edge1, vec3 x); +vec4 smoothstep(float edge0, float edge1, vec4 x); + +/* + * 8.4 - Geometric Functions + */ +float length(float x); +float length(vec2 x); +float length(vec3 x); +float length(vec4 x); + +float distance(float p0, float p1); +float distance(vec2 p0, vec2 p1); +float distance(vec3 p0, vec3 p1); +float distance(vec4 p0, vec4 p1); + +float dot(float x, float y); +float dot(vec2 x, vec2 y); +float dot(vec3 x, vec3 y); +float dot(vec4 x, vec4 y); + +vec3 cross(vec3 x, vec3 y); + +float normalize(float x); +vec2 normalize(vec2 x); +vec3 normalize(vec3 x); +vec4 normalize(vec4 x); + +vec4 ftransform(); + +float faceforward(float N, float I, float Nref); +vec2 faceforward(vec2 N, vec2 I, vec2 Nref); +vec3 faceforward(vec3 N, vec3 I, vec3 Nref); +vec4 faceforward(vec4 N, vec4 I, vec4 Nref); + +float reflect(float I, float N); +vec2 reflect(vec2 I, vec2 N); +vec3 reflect(vec3 I, vec3 N); +vec4 reflect(vec4 I, vec4 N); + +float refract(float I, float N, float eta); +vec2 refract(vec2 I, vec2 N, float eta); +vec3 refract(vec3 I, vec3 N, float eta); +vec4 refract(vec4 I, vec4 N, float eta); + + +/* + * 8.5 - Matrix Functions + */ +mat2 matrixCompMult(mat2 x, mat2 y); +mat3 matrixCompMult(mat3 x, mat3 y); +mat4 matrixCompMult(mat4 x, mat4 y); + +/* + * 8.6 - Vector Relational Functions + */ +bvec2 lessThan( vec2 x, vec2 y); +bvec3 lessThan( vec3 x, vec3 y); +bvec4 lessThan( vec4 x, vec4 y); +bvec2 lessThan(ivec2 x, ivec2 y); +bvec3 lessThan(ivec3 x, ivec3 y); +bvec4 lessThan(ivec4 x, ivec4 y); + +bvec2 lessThanEqual( vec2 x, vec2 y); +bvec3 lessThanEqual( vec3 x, vec3 y); +bvec4 lessThanEqual( vec4 x, vec4 y); +bvec2 lessThanEqual(ivec2 x, ivec2 y); +bvec3 lessThanEqual(ivec3 x, ivec3 y); +bvec4 lessThanEqual(ivec4 x, ivec4 y); + +bvec2 greaterThan( vec2 x, vec2 y); +bvec3 greaterThan( vec3 x, vec3 y); +bvec4 greaterThan( vec4 x, vec4 y); +bvec2 greaterThan(ivec2 x, ivec2 y); +bvec3 greaterThan(ivec3 x, ivec3 y); +bvec4 greaterThan(ivec4 x, ivec4 y); + +bvec2 greaterThanEqual( vec2 x, vec2 y); +bvec3 greaterThanEqual( vec3 x, vec3 y); +bvec4 greaterThanEqual( vec4 x, vec4 y); +bvec2 greaterThanEqual(ivec2 x, ivec2 y); +bvec3 greaterThanEqual(ivec3 x, ivec3 y); +bvec4 greaterThanEqual(ivec4 x, ivec4 y); + +bvec2 equal( vec2 x, vec2 y); +bvec3 equal( vec3 x, vec3 y); +bvec4 equal( vec4 x, vec4 y); +bvec2 equal(ivec2 x, ivec2 y); +bvec3 equal(ivec3 x, ivec3 y); +bvec4 equal(ivec4 x, ivec4 y); +bvec2 equal(bvec2 x, bvec2 y); +bvec3 equal(bvec3 x, bvec3 y); +bvec4 equal(bvec4 x, bvec4 y); + +bvec2 notEqual( vec2 x, vec2 y); +bvec3 notEqual( vec3 x, vec3 y); +bvec4 notEqual( vec4 x, vec4 y); +bvec2 notEqual(ivec2 x, ivec2 y); +bvec3 notEqual(ivec3 x, ivec3 y); +bvec4 notEqual(ivec4 x, ivec4 y); +bvec2 notEqual(bvec2 x, bvec2 y); +bvec3 notEqual(bvec3 x, bvec3 y); +bvec4 notEqual(bvec4 x, bvec4 y); + +bool any(bvec2 x); +bool any(bvec3 x); +bool any(bvec4 x); + +bool all(bvec2 x); +bool all(bvec3 x); +bool all(bvec4 x); + +bvec2 not(bvec2 x); +bvec3 not(bvec3 x); +bvec4 not(bvec4 x); + +/* + * 8.7 - Texture Lookup Functions + */ +vec4 texture1D (sampler1D sampler, float coord); +vec4 texture1DProj (sampler1D sampler, vec2 coord); +vec4 texture1DProj (sampler1D sampler, vec4 coord); +vec4 texture1DLod (sampler1D sampler, float coord, float lod); +vec4 texture1DProjLod(sampler1D sampler, vec2 coord, float lod); +vec4 texture1DProjLod(sampler1D sampler, vec4 coord, float lod); + +vec4 texture2D (sampler2D sampler, vec2 coord); +vec4 texture2DProj (sampler2D sampler, vec3 coord); +vec4 texture2DProj (sampler2D sampler, vec4 coord); +vec4 texture2DLod (sampler2D sampler, vec2 coord, float lod); +vec4 texture2DProjLod(sampler2D sampler, vec3 coord, float lod); +vec4 texture2DProjLod(sampler2D sampler, vec4 coord, float lod); + +vec4 texture3D (sampler3D sampler, vec3 coord); +vec4 texture3DProj (sampler3D sampler, vec4 coord); +vec4 texture3DLod (sampler3D sampler, vec3 coord, float lod); +vec4 texture3DProjLod(sampler3D sampler, vec4 coord, float lod); + +vec4 textureCube (samplerCube sampler, vec3 coord); +vec4 textureCubeLod (samplerCube sampler, vec3 coord, float lod); + +vec4 shadow1D (sampler1DShadow sampler, vec3 coord); +vec4 shadow2D (sampler2DShadow sampler, vec3 coord); +vec4 shadow1DProj (sampler1DShadow sampler, vec4 coord); +vec4 shadow2DProj (sampler2DShadow sampler, vec4 coord); +vec4 shadow1DLod (sampler1DShadow sampler, vec3 coord, float lod); +vec4 shadow2DLod (sampler2DShadow sampler, vec3 coord, float lod); +vec4 shadow1DProjLod(sampler1DShadow sampler, vec4 coord, float lod); +vec4 shadow2DProjLod(sampler2DShadow sampler, vec4 coord, float lod); + +/* + * 8.8 - Fragment Processing Functions (none in vertex shader) + */ + +/* + * 8.9 - Noise Functions + */ +float noise1(float x); +float noise1(vec2 x); +float noise1(vec3 x); +float noise1(vec4 x); + +vec2 noise2(float x); +vec2 noise2(vec2 x); +vec2 noise2(vec3 x); +vec2 noise2(vec4 x); + +vec3 noise3(float x); +vec3 noise3(vec2 x); +vec3 noise3(vec3 x); +vec3 noise3(vec4 x); + +vec4 noise4(float x); +vec4 noise4(vec2 x); +vec4 noise4(vec3 x); +vec4 noise4(vec4 x); diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/profiles/120.frag b/3rdparty/glsl-optimizer/src/glsl/builtins/profiles/120.frag new file mode 100644 index 000000000..a207435f3 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/profiles/120.frag @@ -0,0 +1,396 @@ +#version 120 +/* + * 8.1 - Angle and Trigonometry Functions + */ +float radians(float degrees); +vec2 radians(vec2 degrees); +vec3 radians(vec3 degrees); +vec4 radians(vec4 degrees); + +float degrees(float radians); +vec2 degrees(vec2 radians); +vec3 degrees(vec3 radians); +vec4 degrees(vec4 radians); + +float sin(float angle); +vec2 sin(vec2 angle); +vec3 sin(vec3 angle); +vec4 sin(vec4 angle); + +float cos(float angle); +vec2 cos(vec2 angle); +vec3 cos(vec3 angle); +vec4 cos(vec4 angle); + +float tan(float angle); +vec2 tan(vec2 angle); +vec3 tan(vec3 angle); +vec4 tan(vec4 angle); + +float asin(float angle); +vec2 asin(vec2 angle); +vec3 asin(vec3 angle); +vec4 asin(vec4 angle); + +float acos(float angle); +vec2 acos(vec2 angle); +vec3 acos(vec3 angle); +vec4 acos(vec4 angle); + +float atan(float y, float x); +vec2 atan(vec2 y, vec2 x); +vec3 atan(vec3 y, vec3 x); +vec4 atan(vec4 y, vec4 x); + +float atan(float y_over_x); +vec2 atan(vec2 y_over_x); +vec3 atan(vec3 y_over_x); +vec4 atan(vec4 y_over_x); + +/* + * 8.2 - Exponential Functions + */ +float pow(float x, float y); +vec2 pow(vec2 x, vec2 y); +vec3 pow(vec3 x, vec3 y); +vec4 pow(vec4 x, vec4 y); + +float exp(float x); +vec2 exp(vec2 x); +vec3 exp(vec3 x); +vec4 exp(vec4 x); + +float log(float x); +vec2 log(vec2 x); +vec3 log(vec3 x); +vec4 log(vec4 x); + +float exp2(float x); +vec2 exp2(vec2 x); +vec3 exp2(vec3 x); +vec4 exp2(vec4 x); + +float log2(float x); +vec2 log2(vec2 x); +vec3 log2(vec3 x); +vec4 log2(vec4 x); + +float sqrt(float x); +vec2 sqrt(vec2 x); +vec3 sqrt(vec3 x); +vec4 sqrt(vec4 x); + +float inversesqrt(float x); +vec2 inversesqrt(vec2 x); +vec3 inversesqrt(vec3 x); +vec4 inversesqrt(vec4 x); + +/* + * 8.3 - Common Functions + */ +float abs(float x); +vec2 abs(vec2 x); +vec3 abs(vec3 x); +vec4 abs(vec4 x); + +float sign(float x); +vec2 sign(vec2 x); +vec3 sign(vec3 x); +vec4 sign(vec4 x); + +float floor(float x); +vec2 floor(vec2 x); +vec3 floor(vec3 x); +vec4 floor(vec4 x); + +float ceil(float x); +vec2 ceil(vec2 x); +vec3 ceil(vec3 x); +vec4 ceil(vec4 x); + +float fract(float x); +vec2 fract(vec2 x); +vec3 fract(vec3 x); +vec4 fract(vec4 x); + +float mod(float x, float y); +vec2 mod(vec2 x, float y); +vec3 mod(vec3 x, float y); +vec4 mod(vec4 x, float y); + +vec2 mod(vec2 x, vec2 y); +vec3 mod(vec3 x, vec3 y); +vec4 mod(vec4 x, vec4 y); + +float min(float x, float y); +vec2 min(vec2 x, vec2 y); +vec3 min(vec3 x, vec3 y); +vec4 min(vec4 x, vec4 y); + +vec2 min(vec2 x, float y); +vec3 min(vec3 x, float y); +vec4 min(vec4 x, float y); + +float max(float x, float y); +vec2 max(vec2 x, vec2 y); +vec3 max(vec3 x, vec3 y); +vec4 max(vec4 x, vec4 y); + +vec2 max(vec2 x, float y); +vec3 max(vec3 x, float y); +vec4 max(vec4 x, float y); + +float clamp(float x, float minVal, float maxVal); +vec2 clamp(vec2 x, vec2 minVal, vec2 maxVal); +vec3 clamp(vec3 x, vec3 minVal, vec3 maxVal); +vec4 clamp(vec4 x, vec4 minVal, vec4 maxVal); + +vec2 clamp(vec2 x, float minVal, float maxVal); +vec3 clamp(vec3 x, float minVal, float maxVal); +vec4 clamp(vec4 x, float minVal, float maxVal); + +float mix(float x, float y, float a); +vec2 mix(vec2 x, vec2 y, vec2 a); +vec3 mix(vec3 x, vec3 y, vec3 a); +vec4 mix(vec4 x, vec4 y, vec4 a); + +vec2 mix(vec2 x, vec2 y, float a); +vec3 mix(vec3 x, vec3 y, float a); +vec4 mix(vec4 x, vec4 y, float a); + +float step(float edge, float x); +vec2 step(vec2 edge, vec2 x); +vec3 step(vec3 edge, vec3 x); +vec4 step(vec4 edge, vec4 x); + +vec2 step(float edge, vec2 x); +vec3 step(float edge, vec3 x); +vec4 step(float edge, vec4 x); + +float smoothstep(float edge0, float edge1, float x); +vec2 smoothstep(vec2 edge0, vec2 edge1, vec2 x); +vec3 smoothstep(vec3 edge0, vec3 edge1, vec3 x); +vec4 smoothstep(vec4 edge0, vec4 edge1, vec4 x); + +vec2 smoothstep(float edge0, float edge1, vec2 x); +vec3 smoothstep(float edge0, float edge1, vec3 x); +vec4 smoothstep(float edge0, float edge1, vec4 x); + +/* + * 8.4 - Geometric Functions + */ +float length(float x); +float length(vec2 x); +float length(vec3 x); +float length(vec4 x); + +float distance(float p0, float p1); +float distance(vec2 p0, vec2 p1); +float distance(vec3 p0, vec3 p1); +float distance(vec4 p0, vec4 p1); + +float dot(float x, float y); +float dot(vec2 x, vec2 y); +float dot(vec3 x, vec3 y); +float dot(vec4 x, vec4 y); + +vec3 cross(vec3 x, vec3 y); + +float normalize(float x); +vec2 normalize(vec2 x); +vec3 normalize(vec3 x); +vec4 normalize(vec4 x); + +float faceforward(float N, float I, float Nref); +vec2 faceforward(vec2 N, vec2 I, vec2 Nref); +vec3 faceforward(vec3 N, vec3 I, vec3 Nref); +vec4 faceforward(vec4 N, vec4 I, vec4 Nref); + +float reflect(float I, float N); +vec2 reflect(vec2 I, vec2 N); +vec3 reflect(vec3 I, vec3 N); +vec4 reflect(vec4 I, vec4 N); + +float refract(float I, float N, float eta); +vec2 refract(vec2 I, vec2 N, float eta); +vec3 refract(vec3 I, vec3 N, float eta); +vec4 refract(vec4 I, vec4 N, float eta); + + +/* + * 8.5 - Matrix Functions + */ +mat2 matrixCompMult(mat2 x, mat2 y); +mat3 matrixCompMult(mat3 x, mat3 y); +mat4 matrixCompMult(mat4 x, mat4 y); +mat2x3 matrixCompMult(mat2x3 x, mat2x3 y); +mat2x4 matrixCompMult(mat2x4 x, mat2x4 y); +mat3x2 matrixCompMult(mat3x2 x, mat3x2 y); +mat3x4 matrixCompMult(mat3x4 x, mat3x4 y); +mat4x2 matrixCompMult(mat4x2 x, mat4x2 y); +mat4x3 matrixCompMult(mat4x3 x, mat4x3 y); + +mat2 outerProduct(vec2 c, vec2 r); +mat3 outerProduct(vec3 c, vec3 r); +mat4 outerProduct(vec4 c, vec4 r); + +mat2x3 outerProduct(vec3 c, vec2 r); +mat3x2 outerProduct(vec2 c, vec3 r); + +mat2x4 outerProduct(vec4 c, vec2 r); +mat4x2 outerProduct(vec2 c, vec4 r); + +mat3x4 outerProduct(vec4 c, vec3 r); +mat4x3 outerProduct(vec3 c, vec4 r); + +mat2 transpose(mat2 m); +mat3 transpose(mat3 m); +mat4 transpose(mat4 m); + +mat2x3 transpose(mat3x2 m); +mat3x2 transpose(mat2x3 m); + +mat2x4 transpose(mat4x2 m); +mat4x2 transpose(mat2x4 m); + +mat3x4 transpose(mat4x3 m); +mat4x3 transpose(mat3x4 m); + +/* + * 8.6 - Vector Relational Functions + */ +bvec2 lessThan( vec2 x, vec2 y); +bvec3 lessThan( vec3 x, vec3 y); +bvec4 lessThan( vec4 x, vec4 y); +bvec2 lessThan(ivec2 x, ivec2 y); +bvec3 lessThan(ivec3 x, ivec3 y); +bvec4 lessThan(ivec4 x, ivec4 y); + +bvec2 lessThanEqual( vec2 x, vec2 y); +bvec3 lessThanEqual( vec3 x, vec3 y); +bvec4 lessThanEqual( vec4 x, vec4 y); +bvec2 lessThanEqual(ivec2 x, ivec2 y); +bvec3 lessThanEqual(ivec3 x, ivec3 y); +bvec4 lessThanEqual(ivec4 x, ivec4 y); + +bvec2 greaterThan( vec2 x, vec2 y); +bvec3 greaterThan( vec3 x, vec3 y); +bvec4 greaterThan( vec4 x, vec4 y); +bvec2 greaterThan(ivec2 x, ivec2 y); +bvec3 greaterThan(ivec3 x, ivec3 y); +bvec4 greaterThan(ivec4 x, ivec4 y); + +bvec2 greaterThanEqual( vec2 x, vec2 y); +bvec3 greaterThanEqual( vec3 x, vec3 y); +bvec4 greaterThanEqual( vec4 x, vec4 y); +bvec2 greaterThanEqual(ivec2 x, ivec2 y); +bvec3 greaterThanEqual(ivec3 x, ivec3 y); +bvec4 greaterThanEqual(ivec4 x, ivec4 y); + +bvec2 equal( vec2 x, vec2 y); +bvec3 equal( vec3 x, vec3 y); +bvec4 equal( vec4 x, vec4 y); +bvec2 equal(ivec2 x, ivec2 y); +bvec3 equal(ivec3 x, ivec3 y); +bvec4 equal(ivec4 x, ivec4 y); +bvec2 equal(bvec2 x, bvec2 y); +bvec3 equal(bvec3 x, bvec3 y); +bvec4 equal(bvec4 x, bvec4 y); + +bvec2 notEqual( vec2 x, vec2 y); +bvec3 notEqual( vec3 x, vec3 y); +bvec4 notEqual( vec4 x, vec4 y); +bvec2 notEqual(ivec2 x, ivec2 y); +bvec3 notEqual(ivec3 x, ivec3 y); +bvec4 notEqual(ivec4 x, ivec4 y); +bvec2 notEqual(bvec2 x, bvec2 y); +bvec3 notEqual(bvec3 x, bvec3 y); +bvec4 notEqual(bvec4 x, bvec4 y); + +bool any(bvec2 x); +bool any(bvec3 x); +bool any(bvec4 x); + +bool all(bvec2 x); +bool all(bvec3 x); +bool all(bvec4 x); + +bvec2 not(bvec2 x); +bvec3 not(bvec3 x); +bvec4 not(bvec4 x); + +/* + * 8.7 - Texture Lookup Functions + */ +vec4 texture1D (sampler1D sampler, float coord); +vec4 texture1DProj (sampler1D sampler, vec2 coord); +vec4 texture1DProj (sampler1D sampler, vec4 coord); +vec4 texture1D (sampler1D sampler, float coord, float bias); +vec4 texture1DProj (sampler1D sampler, vec2 coord, float bias); +vec4 texture1DProj (sampler1D sampler, vec4 coord, float bias); + +vec4 texture2D (sampler2D sampler, vec2 coord); +vec4 texture2DProj (sampler2D sampler, vec3 coord); +vec4 texture2DProj (sampler2D sampler, vec4 coord); +vec4 texture2D (sampler2D sampler, vec2 coord, float bias); +vec4 texture2DProj (sampler2D sampler, vec3 coord, float bias); +vec4 texture2DProj (sampler2D sampler, vec4 coord, float bias); + +vec4 texture3D (sampler3D sampler, vec3 coord); +vec4 texture3DProj (sampler3D sampler, vec4 coord); +vec4 texture3D (sampler3D sampler, vec3 coord, float bias); +vec4 texture3DProj (sampler3D sampler, vec4 coord, float bias); + +vec4 textureCube (samplerCube sampler, vec3 coord); +vec4 textureCube (samplerCube sampler, vec3 coord, float bias); + +vec4 shadow1D (sampler1DShadow sampler, vec3 coord); +vec4 shadow2D (sampler2DShadow sampler, vec3 coord); +vec4 shadow1DProj (sampler1DShadow sampler, vec4 coord); +vec4 shadow2DProj (sampler2DShadow sampler, vec4 coord); +vec4 shadow1D (sampler1DShadow sampler, vec3 coord, float bias); +vec4 shadow2D (sampler2DShadow sampler, vec3 coord, float bias); +vec4 shadow1DProj (sampler1DShadow sampler, vec4 coord, float bias); +vec4 shadow2DProj (sampler2DShadow sampler, vec4 coord, float bias); + + +/* + * 8.8 - Fragment Processing Functions + */ +float dFdx(float p); +vec2 dFdx(vec2 p); +vec3 dFdx(vec3 p); +vec4 dFdx(vec4 p); + +float dFdy(float p); +vec2 dFdy(vec2 p); +vec3 dFdy(vec3 p); +vec4 dFdy(vec4 p); + +float fwidth(float p); +vec2 fwidth(vec2 p); +vec3 fwidth(vec3 p); +vec4 fwidth(vec4 p); + +/* + * 8.9 - Noise Functions + */ +float noise1(float x); +float noise1(vec2 x); +float noise1(vec3 x); +float noise1(vec4 x); + +vec2 noise2(float x); +vec2 noise2(vec2 x); +vec2 noise2(vec3 x); +vec2 noise2(vec4 x); + +vec3 noise3(float x); +vec3 noise3(vec2 x); +vec3 noise3(vec3 x); +vec3 noise3(vec4 x); + +vec4 noise4(float x); +vec4 noise4(vec2 x); +vec4 noise4(vec3 x); +vec4 noise4(vec4 x); diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/profiles/120.vert b/3rdparty/glsl-optimizer/src/glsl/builtins/profiles/120.vert new file mode 100644 index 000000000..e14c93164 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/profiles/120.vert @@ -0,0 +1,383 @@ +#version 120 +/* + * 8.1 - Angle and Trigonometry Functions + */ +float radians(float degrees); +vec2 radians(vec2 degrees); +vec3 radians(vec3 degrees); +vec4 radians(vec4 degrees); + +float degrees(float radians); +vec2 degrees(vec2 radians); +vec3 degrees(vec3 radians); +vec4 degrees(vec4 radians); + +float sin(float angle); +vec2 sin(vec2 angle); +vec3 sin(vec3 angle); +vec4 sin(vec4 angle); + +float cos(float angle); +vec2 cos(vec2 angle); +vec3 cos(vec3 angle); +vec4 cos(vec4 angle); + +float tan(float angle); +vec2 tan(vec2 angle); +vec3 tan(vec3 angle); +vec4 tan(vec4 angle); + +float asin(float angle); +vec2 asin(vec2 angle); +vec3 asin(vec3 angle); +vec4 asin(vec4 angle); + +float acos(float angle); +vec2 acos(vec2 angle); +vec3 acos(vec3 angle); +vec4 acos(vec4 angle); + +float atan(float y, float x); +vec2 atan(vec2 y, vec2 x); +vec3 atan(vec3 y, vec3 x); +vec4 atan(vec4 y, vec4 x); + +float atan(float y_over_x); +vec2 atan(vec2 y_over_x); +vec3 atan(vec3 y_over_x); +vec4 atan(vec4 y_over_x); + +/* + * 8.2 - Exponential Functions + */ +float pow(float x, float y); +vec2 pow(vec2 x, vec2 y); +vec3 pow(vec3 x, vec3 y); +vec4 pow(vec4 x, vec4 y); + +float exp(float x); +vec2 exp(vec2 x); +vec3 exp(vec3 x); +vec4 exp(vec4 x); + +float log(float x); +vec2 log(vec2 x); +vec3 log(vec3 x); +vec4 log(vec4 x); + +float exp2(float x); +vec2 exp2(vec2 x); +vec3 exp2(vec3 x); +vec4 exp2(vec4 x); + +float log2(float x); +vec2 log2(vec2 x); +vec3 log2(vec3 x); +vec4 log2(vec4 x); + +float sqrt(float x); +vec2 sqrt(vec2 x); +vec3 sqrt(vec3 x); +vec4 sqrt(vec4 x); + +float inversesqrt(float x); +vec2 inversesqrt(vec2 x); +vec3 inversesqrt(vec3 x); +vec4 inversesqrt(vec4 x); + +/* + * 8.3 - Common Functions + */ +float abs(float x); +vec2 abs(vec2 x); +vec3 abs(vec3 x); +vec4 abs(vec4 x); + +float sign(float x); +vec2 sign(vec2 x); +vec3 sign(vec3 x); +vec4 sign(vec4 x); + +float floor(float x); +vec2 floor(vec2 x); +vec3 floor(vec3 x); +vec4 floor(vec4 x); + +float ceil(float x); +vec2 ceil(vec2 x); +vec3 ceil(vec3 x); +vec4 ceil(vec4 x); + +float fract(float x); +vec2 fract(vec2 x); +vec3 fract(vec3 x); +vec4 fract(vec4 x); + +float mod(float x, float y); +vec2 mod(vec2 x, float y); +vec3 mod(vec3 x, float y); +vec4 mod(vec4 x, float y); + +vec2 mod(vec2 x, vec2 y); +vec3 mod(vec3 x, vec3 y); +vec4 mod(vec4 x, vec4 y); + +float min(float x, float y); +vec2 min(vec2 x, vec2 y); +vec3 min(vec3 x, vec3 y); +vec4 min(vec4 x, vec4 y); + +vec2 min(vec2 x, float y); +vec3 min(vec3 x, float y); +vec4 min(vec4 x, float y); + +float max(float x, float y); +vec2 max(vec2 x, vec2 y); +vec3 max(vec3 x, vec3 y); +vec4 max(vec4 x, vec4 y); + +vec2 max(vec2 x, float y); +vec3 max(vec3 x, float y); +vec4 max(vec4 x, float y); + +float clamp(float x, float minVal, float maxVal); +vec2 clamp(vec2 x, vec2 minVal, vec2 maxVal); +vec3 clamp(vec3 x, vec3 minVal, vec3 maxVal); +vec4 clamp(vec4 x, vec4 minVal, vec4 maxVal); + +vec2 clamp(vec2 x, float minVal, float maxVal); +vec3 clamp(vec3 x, float minVal, float maxVal); +vec4 clamp(vec4 x, float minVal, float maxVal); + +float mix(float x, float y, float a); +vec2 mix(vec2 x, vec2 y, vec2 a); +vec3 mix(vec3 x, vec3 y, vec3 a); +vec4 mix(vec4 x, vec4 y, vec4 a); + +vec2 mix(vec2 x, vec2 y, float a); +vec3 mix(vec3 x, vec3 y, float a); +vec4 mix(vec4 x, vec4 y, float a); + +float step(float edge, float x); +vec2 step(vec2 edge, vec2 x); +vec3 step(vec3 edge, vec3 x); +vec4 step(vec4 edge, vec4 x); + +vec2 step(float edge, vec2 x); +vec3 step(float edge, vec3 x); +vec4 step(float edge, vec4 x); + +float smoothstep(float edge0, float edge1, float x); +vec2 smoothstep(vec2 edge0, vec2 edge1, vec2 x); +vec3 smoothstep(vec3 edge0, vec3 edge1, vec3 x); +vec4 smoothstep(vec4 edge0, vec4 edge1, vec4 x); + +vec2 smoothstep(float edge0, float edge1, vec2 x); +vec3 smoothstep(float edge0, float edge1, vec3 x); +vec4 smoothstep(float edge0, float edge1, vec4 x); + +/* + * 8.4 - Geometric Functions + */ +float length(float x); +float length(vec2 x); +float length(vec3 x); +float length(vec4 x); + +float distance(float p0, float p1); +float distance(vec2 p0, vec2 p1); +float distance(vec3 p0, vec3 p1); +float distance(vec4 p0, vec4 p1); + +float dot(float x, float y); +float dot(vec2 x, vec2 y); +float dot(vec3 x, vec3 y); +float dot(vec4 x, vec4 y); + +vec3 cross(vec3 x, vec3 y); + +float normalize(float x); +vec2 normalize(vec2 x); +vec3 normalize(vec3 x); +vec4 normalize(vec4 x); + +vec4 ftransform(); + +float faceforward(float N, float I, float Nref); +vec2 faceforward(vec2 N, vec2 I, vec2 Nref); +vec3 faceforward(vec3 N, vec3 I, vec3 Nref); +vec4 faceforward(vec4 N, vec4 I, vec4 Nref); + +float reflect(float I, float N); +vec2 reflect(vec2 I, vec2 N); +vec3 reflect(vec3 I, vec3 N); +vec4 reflect(vec4 I, vec4 N); + +float refract(float I, float N, float eta); +vec2 refract(vec2 I, vec2 N, float eta); +vec3 refract(vec3 I, vec3 N, float eta); +vec4 refract(vec4 I, vec4 N, float eta); + + +/* + * 8.5 - Matrix Functions + */ +mat2 matrixCompMult(mat2 x, mat2 y); +mat3 matrixCompMult(mat3 x, mat3 y); +mat4 matrixCompMult(mat4 x, mat4 y); +mat2x3 matrixCompMult(mat2x3 x, mat2x3 y); +mat2x4 matrixCompMult(mat2x4 x, mat2x4 y); +mat3x2 matrixCompMult(mat3x2 x, mat3x2 y); +mat3x4 matrixCompMult(mat3x4 x, mat3x4 y); +mat4x2 matrixCompMult(mat4x2 x, mat4x2 y); +mat4x3 matrixCompMult(mat4x3 x, mat4x3 y); + +mat2 outerProduct(vec2 c, vec2 r); +mat3 outerProduct(vec3 c, vec3 r); +mat4 outerProduct(vec4 c, vec4 r); + +mat2x3 outerProduct(vec3 c, vec2 r); +mat3x2 outerProduct(vec2 c, vec3 r); + +mat2x4 outerProduct(vec4 c, vec2 r); +mat4x2 outerProduct(vec2 c, vec4 r); + +mat3x4 outerProduct(vec4 c, vec3 r); +mat4x3 outerProduct(vec3 c, vec4 r); + +mat2 transpose(mat2 m); +mat3 transpose(mat3 m); +mat4 transpose(mat4 m); + +mat2x3 transpose(mat3x2 m); +mat3x2 transpose(mat2x3 m); + +mat2x4 transpose(mat4x2 m); +mat4x2 transpose(mat2x4 m); + +mat3x4 transpose(mat4x3 m); +mat4x3 transpose(mat3x4 m); + +/* + * 8.6 - Vector Relational Functions + */ +bvec2 lessThan( vec2 x, vec2 y); +bvec3 lessThan( vec3 x, vec3 y); +bvec4 lessThan( vec4 x, vec4 y); +bvec2 lessThan(ivec2 x, ivec2 y); +bvec3 lessThan(ivec3 x, ivec3 y); +bvec4 lessThan(ivec4 x, ivec4 y); + +bvec2 lessThanEqual( vec2 x, vec2 y); +bvec3 lessThanEqual( vec3 x, vec3 y); +bvec4 lessThanEqual( vec4 x, vec4 y); +bvec2 lessThanEqual(ivec2 x, ivec2 y); +bvec3 lessThanEqual(ivec3 x, ivec3 y); +bvec4 lessThanEqual(ivec4 x, ivec4 y); + +bvec2 greaterThan( vec2 x, vec2 y); +bvec3 greaterThan( vec3 x, vec3 y); +bvec4 greaterThan( vec4 x, vec4 y); +bvec2 greaterThan(ivec2 x, ivec2 y); +bvec3 greaterThan(ivec3 x, ivec3 y); +bvec4 greaterThan(ivec4 x, ivec4 y); + +bvec2 greaterThanEqual( vec2 x, vec2 y); +bvec3 greaterThanEqual( vec3 x, vec3 y); +bvec4 greaterThanEqual( vec4 x, vec4 y); +bvec2 greaterThanEqual(ivec2 x, ivec2 y); +bvec3 greaterThanEqual(ivec3 x, ivec3 y); +bvec4 greaterThanEqual(ivec4 x, ivec4 y); + +bvec2 equal( vec2 x, vec2 y); +bvec3 equal( vec3 x, vec3 y); +bvec4 equal( vec4 x, vec4 y); +bvec2 equal(ivec2 x, ivec2 y); +bvec3 equal(ivec3 x, ivec3 y); +bvec4 equal(ivec4 x, ivec4 y); +bvec2 equal(bvec2 x, bvec2 y); +bvec3 equal(bvec3 x, bvec3 y); +bvec4 equal(bvec4 x, bvec4 y); + +bvec2 notEqual( vec2 x, vec2 y); +bvec3 notEqual( vec3 x, vec3 y); +bvec4 notEqual( vec4 x, vec4 y); +bvec2 notEqual(ivec2 x, ivec2 y); +bvec3 notEqual(ivec3 x, ivec3 y); +bvec4 notEqual(ivec4 x, ivec4 y); +bvec2 notEqual(bvec2 x, bvec2 y); +bvec3 notEqual(bvec3 x, bvec3 y); +bvec4 notEqual(bvec4 x, bvec4 y); + +bool any(bvec2 x); +bool any(bvec3 x); +bool any(bvec4 x); + +bool all(bvec2 x); +bool all(bvec3 x); +bool all(bvec4 x); + +bvec2 not(bvec2 x); +bvec3 not(bvec3 x); +bvec4 not(bvec4 x); + +/* + * 8.7 - Texture Lookup Functions + */ +vec4 texture1D (sampler1D sampler, float coord); +vec4 texture1DProj (sampler1D sampler, vec2 coord); +vec4 texture1DProj (sampler1D sampler, vec4 coord); +vec4 texture1DLod (sampler1D sampler, float coord, float lod); +vec4 texture1DProjLod(sampler1D sampler, vec2 coord, float lod); +vec4 texture1DProjLod(sampler1D sampler, vec4 coord, float lod); + +vec4 texture2D (sampler2D sampler, vec2 coord); +vec4 texture2DProj (sampler2D sampler, vec3 coord); +vec4 texture2DProj (sampler2D sampler, vec4 coord); +vec4 texture2DLod (sampler2D sampler, vec2 coord, float lod); +vec4 texture2DProjLod(sampler2D sampler, vec3 coord, float lod); +vec4 texture2DProjLod(sampler2D sampler, vec4 coord, float lod); + +vec4 texture3D (sampler3D sampler, vec3 coord); +vec4 texture3DProj (sampler3D sampler, vec4 coord); +vec4 texture3DLod (sampler3D sampler, vec3 coord, float lod); +vec4 texture3DProjLod(sampler3D sampler, vec4 coord, float lod); + +vec4 textureCube (samplerCube sampler, vec3 coord); +vec4 textureCubeLod (samplerCube sampler, vec3 coord, float lod); + +vec4 shadow1D (sampler1DShadow sampler, vec3 coord); +vec4 shadow2D (sampler2DShadow sampler, vec3 coord); +vec4 shadow1DProj (sampler1DShadow sampler, vec4 coord); +vec4 shadow2DProj (sampler2DShadow sampler, vec4 coord); +vec4 shadow1DLod (sampler1DShadow sampler, vec3 coord, float lod); +vec4 shadow2DLod (sampler2DShadow sampler, vec3 coord, float lod); +vec4 shadow1DProjLod(sampler1DShadow sampler, vec4 coord, float lod); +vec4 shadow2DProjLod(sampler2DShadow sampler, vec4 coord, float lod); + +/* + * 8.8 - Fragment Processing Functions (none in vertex shader) + */ + +/* + * 8.9 - Noise Functions + */ +float noise1(float x); +float noise1(vec2 x); +float noise1(vec3 x); +float noise1(vec4 x); + +vec2 noise2(float x); +vec2 noise2(vec2 x); +vec2 noise2(vec3 x); +vec2 noise2(vec4 x); + +vec3 noise3(float x); +vec3 noise3(vec2 x); +vec3 noise3(vec3 x); +vec3 noise3(vec4 x); + +vec4 noise4(float x); +vec4 noise4(vec2 x); +vec4 noise4(vec3 x); +vec4 noise4(vec4 x); diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/profiles/130.frag b/3rdparty/glsl-optimizer/src/glsl/builtins/profiles/130.frag new file mode 100644 index 000000000..0e3c7ac41 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/profiles/130.frag @@ -0,0 +1,1039 @@ +#version 130 +/* + * 8.1 - Angle and Trigonometry Functions + */ +float radians(float degrees); +vec2 radians(vec2 degrees); +vec3 radians(vec3 degrees); +vec4 radians(vec4 degrees); + +float degrees(float radians); +vec2 degrees(vec2 radians); +vec3 degrees(vec3 radians); +vec4 degrees(vec4 radians); + +float sin(float angle); +vec2 sin(vec2 angle); +vec3 sin(vec3 angle); +vec4 sin(vec4 angle); + +float cos(float angle); +vec2 cos(vec2 angle); +vec3 cos(vec3 angle); +vec4 cos(vec4 angle); + +float tan(float angle); +vec2 tan(vec2 angle); +vec3 tan(vec3 angle); +vec4 tan(vec4 angle); + +float asin(float angle); +vec2 asin(vec2 angle); +vec3 asin(vec3 angle); +vec4 asin(vec4 angle); + +float acos(float angle); +vec2 acos(vec2 angle); +vec3 acos(vec3 angle); +vec4 acos(vec4 angle); + +float atan(float y, float x); +vec2 atan(vec2 y, vec2 x); +vec3 atan(vec3 y, vec3 x); +vec4 atan(vec4 y, vec4 x); + +float atan(float y_over_x); +vec2 atan(vec2 y_over_x); +vec3 atan(vec3 y_over_x); +vec4 atan(vec4 y_over_x); + +float sinh(float x); +vec2 sinh(vec2 x); +vec3 sinh(vec3 x); +vec4 sinh(vec4 x); + +float cosh(float x); +vec2 cosh(vec2 x); +vec3 cosh(vec3 x); +vec4 cosh(vec4 x); + +float tanh(float x); +vec2 tanh(vec2 x); +vec3 tanh(vec3 x); +vec4 tanh(vec4 x); + +float asinh(float x); +vec2 asinh(vec2 x); +vec3 asinh(vec3 x); +vec4 asinh(vec4 x); + +float acosh(float x); +vec2 acosh(vec2 x); +vec3 acosh(vec3 x); +vec4 acosh(vec4 x); + +float atanh(float x); +vec2 atanh(vec2 x); +vec3 atanh(vec3 x); +vec4 atanh(vec4 x); + +/* + * 8.2 - Exponential Functions + */ +float pow(float x, float y); +vec2 pow(vec2 x, vec2 y); +vec3 pow(vec3 x, vec3 y); +vec4 pow(vec4 x, vec4 y); + +float exp(float x); +vec2 exp(vec2 x); +vec3 exp(vec3 x); +vec4 exp(vec4 x); + +float log(float x); +vec2 log(vec2 x); +vec3 log(vec3 x); +vec4 log(vec4 x); + +float exp2(float x); +vec2 exp2(vec2 x); +vec3 exp2(vec3 x); +vec4 exp2(vec4 x); + +float log2(float x); +vec2 log2(vec2 x); +vec3 log2(vec3 x); +vec4 log2(vec4 x); + +float sqrt(float x); +vec2 sqrt(vec2 x); +vec3 sqrt(vec3 x); +vec4 sqrt(vec4 x); + +float inversesqrt(float x); +vec2 inversesqrt(vec2 x); +vec3 inversesqrt(vec3 x); +vec4 inversesqrt(vec4 x); + +/* + * 8.3 - Common Functions + */ +float abs(float x); +vec2 abs(vec2 x); +vec3 abs(vec3 x); +vec4 abs(vec4 x); +int abs(int x); +ivec2 abs(ivec2 x); +ivec3 abs(ivec3 x); +ivec4 abs(ivec4 x); + +float sign(float x); +vec2 sign(vec2 x); +vec3 sign(vec3 x); +vec4 sign(vec4 x); +int sign(int x); +ivec2 sign(ivec2 x); +ivec3 sign(ivec3 x); +ivec4 sign(ivec4 x); + +float floor(float x); +vec2 floor(vec2 x); +vec3 floor(vec3 x); +vec4 floor(vec4 x); + +float trunc(float x); +vec2 trunc(vec2 x); +vec3 trunc(vec3 x); +vec4 trunc(vec4 x); + +float round(float x); +vec2 round(vec2 x); +vec3 round(vec3 x); +vec4 round(vec4 x); + +float roundEven(float x); +vec2 roundEven(vec2 x); +vec3 roundEven(vec3 x); +vec4 roundEven(vec4 x); + +float ceil(float x); +vec2 ceil(vec2 x); +vec3 ceil(vec3 x); +vec4 ceil(vec4 x); + +float fract(float x); +vec2 fract(vec2 x); +vec3 fract(vec3 x); +vec4 fract(vec4 x); + +float mod(float x, float y); +vec2 mod(vec2 x, float y); +vec3 mod(vec3 x, float y); +vec4 mod(vec4 x, float y); + +vec2 mod(vec2 x, vec2 y); +vec3 mod(vec3 x, vec3 y); +vec4 mod(vec4 x, vec4 y); + +float modf(float x, out float i); +vec2 modf(vec2 x, out vec2 i); +vec3 modf(vec3 x, out vec3 i); +vec4 modf(vec4 x, out vec4 i); + +float min(float x, float y); +vec2 min(vec2 x, vec2 y); +vec3 min(vec3 x, vec3 y); +vec4 min(vec4 x, vec4 y); + +vec2 min(vec2 x, float y); +vec3 min(vec3 x, float y); +vec4 min(vec4 x, float y); + +int min(int x, int y); +ivec2 min(ivec2 x, ivec2 y); +ivec3 min(ivec3 x, ivec3 y); +ivec4 min(ivec4 x, ivec4 y); + +ivec2 min(ivec2 x, int y); +ivec3 min(ivec3 x, int y); +ivec4 min(ivec4 x, int y); + +uint min(uint x, uint y); +uvec2 min(uvec2 x, uvec2 y); +uvec3 min(uvec3 x, uvec3 y); +uvec4 min(uvec4 x, uvec4 y); + +uvec2 min(uvec2 x, uint y); +uvec3 min(uvec3 x, uint y); +uvec4 min(uvec4 x, uint y); + +float max(float x, float y); +vec2 max(vec2 x, vec2 y); +vec3 max(vec3 x, vec3 y); +vec4 max(vec4 x, vec4 y); + +vec2 max(vec2 x, float y); +vec3 max(vec3 x, float y); +vec4 max(vec4 x, float y); + +int max(int x, int y); +ivec2 max(ivec2 x, ivec2 y); +ivec3 max(ivec3 x, ivec3 y); +ivec4 max(ivec4 x, ivec4 y); + +ivec2 max(ivec2 x, int y); +ivec3 max(ivec3 x, int y); +ivec4 max(ivec4 x, int y); + +uint max(uint x, uint y); +uvec2 max(uvec2 x, uvec2 y); +uvec3 max(uvec3 x, uvec3 y); +uvec4 max(uvec4 x, uvec4 y); + +uvec2 max(uvec2 x, uint y); +uvec3 max(uvec3 x, uint y); +uvec4 max(uvec4 x, uint y); + +float clamp(float x, float minVal, float maxVal); +vec2 clamp(vec2 x, vec2 minVal, vec2 maxVal); +vec3 clamp(vec3 x, vec3 minVal, vec3 maxVal); +vec4 clamp(vec4 x, vec4 minVal, vec4 maxVal); + +vec2 clamp(vec2 x, float minVal, float maxVal); +vec3 clamp(vec3 x, float minVal, float maxVal); +vec4 clamp(vec4 x, float minVal, float maxVal); + +int clamp(int x, int minVal, int maxVal); +ivec2 clamp(ivec2 x, ivec2 minVal, ivec2 maxVal); +ivec3 clamp(ivec3 x, ivec3 minVal, ivec3 maxVal); +ivec4 clamp(ivec4 x, ivec4 minVal, ivec4 maxVal); + +ivec2 clamp(ivec2 x, int minVal, int maxVal); +ivec3 clamp(ivec3 x, int minVal, int maxVal); +ivec4 clamp(ivec4 x, int minVal, int maxVal); + +uint clamp(uint x, uint minVal, uint maxVal); +uvec2 clamp(uvec2 x, uvec2 minVal, uvec2 maxVal); +uvec3 clamp(uvec3 x, uvec3 minVal, uvec3 maxVal); +uvec4 clamp(uvec4 x, uvec4 minVal, uvec4 maxVal); + +uvec2 clamp(uvec2 x, uint minVal, uint maxVal); +uvec3 clamp(uvec3 x, uint minVal, uint maxVal); +uvec4 clamp(uvec4 x, uint minVal, uint maxVal); + +float mix(float x, float y, float a); +vec2 mix(vec2 x, vec2 y, vec2 a); +vec3 mix(vec3 x, vec3 y, vec3 a); +vec4 mix(vec4 x, vec4 y, vec4 a); + +vec2 mix(vec2 x, vec2 y, float a); +vec3 mix(vec3 x, vec3 y, float a); +vec4 mix(vec4 x, vec4 y, float a); + +float step(float edge, float x); +vec2 step(vec2 edge, vec2 x); +vec3 step(vec3 edge, vec3 x); +vec4 step(vec4 edge, vec4 x); + +vec2 step(float edge, vec2 x); +vec3 step(float edge, vec3 x); +vec4 step(float edge, vec4 x); + +float smoothstep(float edge0, float edge1, float x); +vec2 smoothstep(vec2 edge0, vec2 edge1, vec2 x); +vec3 smoothstep(vec3 edge0, vec3 edge1, vec3 x); +vec4 smoothstep(vec4 edge0, vec4 edge1, vec4 x); + +vec2 smoothstep(float edge0, float edge1, vec2 x); +vec3 smoothstep(float edge0, float edge1, vec3 x); +vec4 smoothstep(float edge0, float edge1, vec4 x); + +#if 0 +bool isnan(float x); +bvec2 isnan(vec2 x); +bvec3 isnan(vec3 x); +bvec4 isnan(vec4 x); + +bool isinf(float x); +bvec2 isinf(vec2 x); +bvec3 isinf(vec3 x); +bvec4 isinf(vec4 x); +#endif + +/* + * 8.4 - Geometric Functions + */ +float length(float x); +float length(vec2 x); +float length(vec3 x); +float length(vec4 x); + +float distance(float p0, float p1); +float distance(vec2 p0, vec2 p1); +float distance(vec3 p0, vec3 p1); +float distance(vec4 p0, vec4 p1); + +float dot(float x, float y); +float dot(vec2 x, vec2 y); +float dot(vec3 x, vec3 y); +float dot(vec4 x, vec4 y); + +vec3 cross(vec3 x, vec3 y); + +float normalize(float x); +vec2 normalize(vec2 x); +vec3 normalize(vec3 x); +vec4 normalize(vec4 x); + +float faceforward(float N, float I, float Nref); +vec2 faceforward(vec2 N, vec2 I, vec2 Nref); +vec3 faceforward(vec3 N, vec3 I, vec3 Nref); +vec4 faceforward(vec4 N, vec4 I, vec4 Nref); + +float reflect(float I, float N); +vec2 reflect(vec2 I, vec2 N); +vec3 reflect(vec3 I, vec3 N); +vec4 reflect(vec4 I, vec4 N); + +float refract(float I, float N, float eta); +vec2 refract(vec2 I, vec2 N, float eta); +vec3 refract(vec3 I, vec3 N, float eta); +vec4 refract(vec4 I, vec4 N, float eta); + + +/* + * 8.5 - Matrix Functions + */ +mat2 matrixCompMult(mat2 x, mat2 y); +mat3 matrixCompMult(mat3 x, mat3 y); +mat4 matrixCompMult(mat4 x, mat4 y); +mat2x3 matrixCompMult(mat2x3 x, mat2x3 y); +mat2x4 matrixCompMult(mat2x4 x, mat2x4 y); +mat3x2 matrixCompMult(mat3x2 x, mat3x2 y); +mat3x4 matrixCompMult(mat3x4 x, mat3x4 y); +mat4x2 matrixCompMult(mat4x2 x, mat4x2 y); +mat4x3 matrixCompMult(mat4x3 x, mat4x3 y); + +mat2 outerProduct(vec2 c, vec2 r); +mat3 outerProduct(vec3 c, vec3 r); +mat4 outerProduct(vec4 c, vec4 r); + +mat2x3 outerProduct(vec3 c, vec2 r); +mat3x2 outerProduct(vec2 c, vec3 r); + +mat2x4 outerProduct(vec4 c, vec2 r); +mat4x2 outerProduct(vec2 c, vec4 r); + +mat3x4 outerProduct(vec4 c, vec3 r); +mat4x3 outerProduct(vec3 c, vec4 r); + +mat2 transpose(mat2 m); +mat3 transpose(mat3 m); +mat4 transpose(mat4 m); + +mat2x3 transpose(mat3x2 m); +mat3x2 transpose(mat2x3 m); + +mat2x4 transpose(mat4x2 m); +mat4x2 transpose(mat2x4 m); + +mat3x4 transpose(mat4x3 m); +mat4x3 transpose(mat3x4 m); + +/* + * 8.6 - Vector Relational Functions + */ +bvec2 lessThan( vec2 x, vec2 y); +bvec3 lessThan( vec3 x, vec3 y); +bvec4 lessThan( vec4 x, vec4 y); +bvec2 lessThan(ivec2 x, ivec2 y); +bvec3 lessThan(ivec3 x, ivec3 y); +bvec4 lessThan(ivec4 x, ivec4 y); +bvec2 lessThan(uvec2 x, uvec2 y); +bvec3 lessThan(uvec3 x, uvec3 y); +bvec4 lessThan(uvec4 x, uvec4 y); + +bvec2 lessThanEqual( vec2 x, vec2 y); +bvec3 lessThanEqual( vec3 x, vec3 y); +bvec4 lessThanEqual( vec4 x, vec4 y); +bvec2 lessThanEqual(ivec2 x, ivec2 y); +bvec3 lessThanEqual(ivec3 x, ivec3 y); +bvec4 lessThanEqual(ivec4 x, ivec4 y); +bvec2 lessThanEqual(uvec2 x, uvec2 y); +bvec3 lessThanEqual(uvec3 x, uvec3 y); +bvec4 lessThanEqual(uvec4 x, uvec4 y); + +bvec2 greaterThan( vec2 x, vec2 y); +bvec3 greaterThan( vec3 x, vec3 y); +bvec4 greaterThan( vec4 x, vec4 y); +bvec2 greaterThan(ivec2 x, ivec2 y); +bvec3 greaterThan(ivec3 x, ivec3 y); +bvec4 greaterThan(ivec4 x, ivec4 y); +bvec2 greaterThan(uvec2 x, uvec2 y); +bvec3 greaterThan(uvec3 x, uvec3 y); +bvec4 greaterThan(uvec4 x, uvec4 y); + +bvec2 greaterThanEqual( vec2 x, vec2 y); +bvec3 greaterThanEqual( vec3 x, vec3 y); +bvec4 greaterThanEqual( vec4 x, vec4 y); +bvec2 greaterThanEqual(ivec2 x, ivec2 y); +bvec3 greaterThanEqual(ivec3 x, ivec3 y); +bvec4 greaterThanEqual(ivec4 x, ivec4 y); +bvec2 greaterThanEqual(uvec2 x, uvec2 y); +bvec3 greaterThanEqual(uvec3 x, uvec3 y); +bvec4 greaterThanEqual(uvec4 x, uvec4 y); + +bvec2 equal( vec2 x, vec2 y); +bvec3 equal( vec3 x, vec3 y); +bvec4 equal( vec4 x, vec4 y); +bvec2 equal(ivec2 x, ivec2 y); +bvec3 equal(ivec3 x, ivec3 y); +bvec4 equal(ivec4 x, ivec4 y); +bvec2 equal(uvec2 x, uvec2 y); +bvec3 equal(uvec3 x, uvec3 y); +bvec4 equal(uvec4 x, uvec4 y); +bvec2 equal(bvec2 x, bvec2 y); +bvec3 equal(bvec3 x, bvec3 y); +bvec4 equal(bvec4 x, bvec4 y); + +bvec2 notEqual( vec2 x, vec2 y); +bvec3 notEqual( vec3 x, vec3 y); +bvec4 notEqual( vec4 x, vec4 y); +bvec2 notEqual(ivec2 x, ivec2 y); +bvec3 notEqual(ivec3 x, ivec3 y); +bvec4 notEqual(ivec4 x, ivec4 y); +bvec2 notEqual(uvec2 x, uvec2 y); +bvec3 notEqual(uvec3 x, uvec3 y); +bvec4 notEqual(uvec4 x, uvec4 y); +bvec2 notEqual(bvec2 x, bvec2 y); +bvec3 notEqual(bvec3 x, bvec3 y); +bvec4 notEqual(bvec4 x, bvec4 y); + +bool any(bvec2 x); +bool any(bvec3 x); +bool any(bvec4 x); + +bool all(bvec2 x); +bool all(bvec3 x); +bool all(bvec4 x); + +bvec2 not(bvec2 x); +bvec3 not(bvec3 x); +bvec4 not(bvec4 x); + +/* + * 8.7 - Texture Lookup Functions + */ + +#if 0 +/* textureSize */ +int textureSize( sampler1D sampler, int lod); +int textureSize(isampler1D sampler, int lod); +int textureSize(usampler1D sampler, int lod); + +ivec2 textureSize( sampler2D sampler, int lod); +ivec2 textureSize(isampler2D sampler, int lod); +ivec2 textureSize(usampler2D sampler, int lod); + +ivec3 textureSize( sampler3D sampler, int lod); +ivec3 textureSize(isampler3D sampler, int lod); +ivec3 textureSize(usampler3D sampler, int lod); + +ivec2 textureSize( samplerCube sampler, int lod); +ivec2 textureSize(isamplerCube sampler, int lod); +ivec2 textureSize(usamplerCube sampler, int lod); + +int textureSize(sampler1DShadow sampler, int lod); +ivec2 textureSize(sampler2DShadow sampler, int lod); +ivec2 textureSize(samplerCubeShadow sampler, int lod); + +ivec2 textureSize( sampler1DArray sampler, int lod); +ivec2 textureSize(isampler1DArray sampler, int lod); +ivec2 textureSize(usampler1DArray sampler, int lod); +ivec3 textureSize( sampler2DArray sampler, int lod); +ivec3 textureSize(isampler2DArray sampler, int lod); +ivec3 textureSize(usampler2DArray sampler, int lod); + +ivec2 textureSize(sampler1DArrayShadow sampler, int lod); +ivec3 textureSize(sampler2DArrayShadow sampler, int lod); +#endif + +/* texture - no bias */ + vec4 texture( sampler1D sampler, float P); +ivec4 texture(isampler1D sampler, float P); +uvec4 texture(usampler1D sampler, float P); + + vec4 texture( sampler2D sampler, vec2 P); +ivec4 texture(isampler2D sampler, vec2 P); +uvec4 texture(usampler2D sampler, vec2 P); + + vec4 texture( sampler3D sampler, vec3 P); +ivec4 texture(isampler3D sampler, vec3 P); +uvec4 texture(usampler3D sampler, vec3 P); + + vec4 texture( samplerCube sampler, vec3 P); +ivec4 texture(isamplerCube sampler, vec3 P); +uvec4 texture(usamplerCube sampler, vec3 P); + +float texture(sampler1DShadow sampler, vec3 P); +float texture(sampler2DShadow sampler, vec3 P); +float texture(samplerCubeShadow sampler, vec4 P); + + vec4 texture( sampler1DArray sampler, vec2 P); +ivec4 texture(isampler1DArray sampler, vec2 P); +uvec4 texture(usampler1DArray sampler, vec2 P); + + vec4 texture( sampler2DArray sampler, vec3 P); +ivec4 texture(isampler2DArray sampler, vec3 P); +uvec4 texture(usampler2DArray sampler, vec3 P); + +float texture(sampler1DArrayShadow sampler, vec3 P); +float texture(sampler2DArrayShadow sampler, vec4 P); + +/* texture - bias variants */ + vec4 texture( sampler1D sampler, float P, float bias); +ivec4 texture(isampler1D sampler, float P, float bias); +uvec4 texture(usampler1D sampler, float P, float bias); + + vec4 texture( sampler2D sampler, vec2 P, float bias); +ivec4 texture(isampler2D sampler, vec2 P, float bias); +uvec4 texture(usampler2D sampler, vec2 P, float bias); + + vec4 texture( sampler3D sampler, vec3 P, float bias); +ivec4 texture(isampler3D sampler, vec3 P, float bias); +uvec4 texture(usampler3D sampler, vec3 P, float bias); + + vec4 texture( samplerCube sampler, vec3 P, float bias); +ivec4 texture(isamplerCube sampler, vec3 P, float bias); +uvec4 texture(usamplerCube sampler, vec3 P, float bias); + +float texture(sampler1DShadow sampler, vec3 P, float bias); +float texture(sampler2DShadow sampler, vec3 P, float bias); +float texture(samplerCubeShadow sampler, vec4 P, float bias); + + vec4 texture( sampler1DArray sampler, vec2 P, float bias); +ivec4 texture(isampler1DArray sampler, vec2 P, float bias); +uvec4 texture(usampler1DArray sampler, vec2 P, float bias); + + vec4 texture( sampler2DArray sampler, vec3 P, float bias); +ivec4 texture(isampler2DArray sampler, vec3 P, float bias); +uvec4 texture(usampler2DArray sampler, vec3 P, float bias); + +float texture(sampler1DArrayShadow sampler, vec3 P, float bias); + +/* textureProj - no bias */ + vec4 textureProj( sampler1D sampler, vec2 P); +ivec4 textureProj(isampler1D sampler, vec2 P); +uvec4 textureProj(usampler1D sampler, vec2 P); + vec4 textureProj( sampler1D sampler, vec4 P); +ivec4 textureProj(isampler1D sampler, vec4 P); +uvec4 textureProj(usampler1D sampler, vec4 P); + + vec4 textureProj( sampler2D sampler, vec3 P); +ivec4 textureProj(isampler2D sampler, vec3 P); +uvec4 textureProj(usampler2D sampler, vec3 P); + vec4 textureProj( sampler2D sampler, vec4 P); +ivec4 textureProj(isampler2D sampler, vec4 P); +uvec4 textureProj(usampler2D sampler, vec4 P); + + vec4 textureProj( sampler3D sampler, vec4 P); +ivec4 textureProj(isampler3D sampler, vec4 P); +uvec4 textureProj(usampler3D sampler, vec4 P); + +float textureProj(sampler1DShadow sampler, vec4 P); +float textureProj(sampler2DShadow sampler, vec4 P); + +/* textureProj - bias variants */ + vec4 textureProj( sampler1D sampler, vec2 P, float bias); +ivec4 textureProj(isampler1D sampler, vec2 P, float bias); +uvec4 textureProj(usampler1D sampler, vec2 P, float bias); + vec4 textureProj( sampler1D sampler, vec4 P, float bias); +ivec4 textureProj(isampler1D sampler, vec4 P, float bias); +uvec4 textureProj(usampler1D sampler, vec4 P, float bias); + + vec4 textureProj( sampler2D sampler, vec3 P, float bias); +ivec4 textureProj(isampler2D sampler, vec3 P, float bias); +uvec4 textureProj(usampler2D sampler, vec3 P, float bias); + vec4 textureProj( sampler2D sampler, vec4 P, float bias); +ivec4 textureProj(isampler2D sampler, vec4 P, float bias); +uvec4 textureProj(usampler2D sampler, vec4 P, float bias); + + vec4 textureProj( sampler3D sampler, vec4 P, float bias); +ivec4 textureProj(isampler3D sampler, vec4 P, float bias); +uvec4 textureProj(usampler3D sampler, vec4 P, float bias); + +float textureProj(sampler1DShadow sampler, vec4 P, float bias); +float textureProj(sampler2DShadow sampler, vec4 P, float bias); + +/* textureLod */ + vec4 textureLod( sampler1D sampler, float P, float lod); +ivec4 textureLod(isampler1D sampler, float P, float lod); +uvec4 textureLod(usampler1D sampler, float P, float lod); + + vec4 textureLod( sampler2D sampler, vec2 P, float lod); +ivec4 textureLod(isampler2D sampler, vec2 P, float lod); +uvec4 textureLod(usampler2D sampler, vec2 P, float lod); + + vec4 textureLod( sampler3D sampler, vec3 P, float lod); +ivec4 textureLod(isampler3D sampler, vec3 P, float lod); +uvec4 textureLod(usampler3D sampler, vec3 P, float lod); + + vec4 textureLod( samplerCube sampler, vec3 P, float lod); +ivec4 textureLod(isamplerCube sampler, vec3 P, float lod); +uvec4 textureLod(usamplerCube sampler, vec3 P, float lod); + +float textureLod(sampler1DShadow sampler, vec3 P, float lod); +float textureLod(sampler2DShadow sampler, vec3 P, float lod); + + vec4 textureLod( sampler1DArray sampler, vec2 P, float lod); +ivec4 textureLod(isampler1DArray sampler, vec2 P, float lod); +uvec4 textureLod(usampler1DArray sampler, vec2 P, float lod); + + vec4 textureLod( sampler2DArray sampler, vec3 P, float lod); +ivec4 textureLod(isampler2DArray sampler, vec3 P, float lod); +uvec4 textureLod(usampler2DArray sampler, vec3 P, float lod); + +float textureLod(sampler1DArrayShadow sampler, vec3 P, float lod); + +/* textureOffset - no bias */ + vec4 textureOffset( sampler1D sampler, float P, int offset); +ivec4 textureOffset(isampler1D sampler, float P, int offset); +uvec4 textureOffset(usampler1D sampler, float P, int offset); + + vec4 textureOffset( sampler2D sampler, vec2 P, ivec2 offset); +ivec4 textureOffset(isampler2D sampler, vec2 P, ivec2 offset); +uvec4 textureOffset(usampler2D sampler, vec2 P, ivec2 offset); + + vec4 textureOffset( sampler3D sampler, vec3 P, ivec3 offset); +ivec4 textureOffset(isampler3D sampler, vec3 P, ivec3 offset); +uvec4 textureOffset(usampler3D sampler, vec3 P, ivec3 offset); + +float textureOffset(sampler1DShadow sampler, vec3 P, int offset); +float textureOffset(sampler2DShadow sampler, vec3 P, ivec2 offset); + + vec4 textureOffset( sampler1DArray sampler, vec2 P, int offset); +ivec4 textureOffset(isampler1DArray sampler, vec2 P, int offset); +uvec4 textureOffset(usampler1DArray sampler, vec2 P, int offset); + + vec4 textureOffset( sampler2DArray sampler, vec3 P, ivec2 offset); +ivec4 textureOffset(isampler2DArray sampler, vec3 P, ivec2 offset); +uvec4 textureOffset(usampler2DArray sampler, vec3 P, ivec2 offset); + +float textureOffset(sampler1DArrayShadow sampler, vec3 P, int offset); + +/* textureOffset - bias variants */ + vec4 textureOffset( sampler1D sampler, float P, int offset, float bias); +ivec4 textureOffset(isampler1D sampler, float P, int offset, float bias); +uvec4 textureOffset(usampler1D sampler, float P, int offset, float bias); + + vec4 textureOffset( sampler2D sampler, vec2 P, ivec2 offset, float bias); +ivec4 textureOffset(isampler2D sampler, vec2 P, ivec2 offset, float bias); +uvec4 textureOffset(usampler2D sampler, vec2 P, ivec2 offset, float bias); + + vec4 textureOffset( sampler3D sampler, vec3 P, ivec3 offset, float bias); +ivec4 textureOffset(isampler3D sampler, vec3 P, ivec3 offset, float bias); +uvec4 textureOffset(usampler3D sampler, vec3 P, ivec3 offset, float bias); + +float textureOffset(sampler1DShadow sampler, vec3 P, int offset, float bias); +float textureOffset(sampler2DShadow sampler, vec3 P, ivec2 offset, float bias); + + vec4 textureOffset( sampler1DArray sampler, vec2 P, int offset, float bias); +ivec4 textureOffset(isampler1DArray sampler, vec2 P, int offset, float bias); +uvec4 textureOffset(usampler1DArray sampler, vec2 P, int offset, float bias); + + vec4 textureOffset( sampler2DArray sampler, vec3 P, ivec2 offset, float bias); +ivec4 textureOffset(isampler2DArray sampler, vec3 P, ivec2 offset, float bias); +uvec4 textureOffset(usampler2DArray sampler, vec3 P, ivec2 offset, float bias); + +float textureOffset(sampler1DArrayShadow samp, vec3 P, int offset, float bias); + +/* texelFetch */ + vec4 texelFetch( sampler1D sampler, int P, int lod); +ivec4 texelFetch(isampler1D sampler, int P, int lod); +uvec4 texelFetch(usampler1D sampler, int P, int lod); + + vec4 texelFetch( sampler2D sampler, ivec2 P, int lod); +ivec4 texelFetch(isampler2D sampler, ivec2 P, int lod); +uvec4 texelFetch(usampler2D sampler, ivec2 P, int lod); + + vec4 texelFetch( sampler3D sampler, ivec3 P, int lod); +ivec4 texelFetch(isampler3D sampler, ivec3 P, int lod); +uvec4 texelFetch(usampler3D sampler, ivec3 P, int lod); + + vec4 texelFetch( sampler1DArray sampler, ivec2 P, int lod); +ivec4 texelFetch(isampler1DArray sampler, ivec2 P, int lod); +uvec4 texelFetch(usampler1DArray sampler, ivec2 P, int lod); + + vec4 texelFetch( sampler2DArray sampler, ivec3 P, int lod); +ivec4 texelFetch(isampler2DArray sampler, ivec3 P, int lod); +uvec4 texelFetch(usampler2DArray sampler, ivec3 P, int lod); + +/* texelFetchOffset */ + vec4 texelFetchOffset( sampler1D sampler, int P, int lod, int offset); +ivec4 texelFetchOffset(isampler1D sampler, int P, int lod, int offset); +uvec4 texelFetchOffset(usampler1D sampler, int P, int lod, int offset); + + vec4 texelFetchOffset( sampler2D sampler, ivec2 P, int lod, ivec2 offset); +ivec4 texelFetchOffset(isampler2D sampler, ivec2 P, int lod, ivec2 offset); +uvec4 texelFetchOffset(usampler2D sampler, ivec2 P, int lod, ivec2 offset); + + vec4 texelFetchOffset( sampler3D sampler, ivec3 P, int lod, ivec3 offset); +ivec4 texelFetchOffset(isampler3D sampler, ivec3 P, int lod, ivec3 offset); +uvec4 texelFetchOffset(usampler3D sampler, ivec3 P, int lod, ivec3 offset); + + vec4 texelFetchOffset( sampler1DArray sampler, ivec2 P, int lod, int offset); +ivec4 texelFetchOffset(isampler1DArray sampler, ivec2 P, int lod, int offset); +uvec4 texelFetchOffset(usampler1DArray sampler, ivec2 P, int lod, int offset); + + vec4 texelFetchOffset( sampler2DArray sampler, ivec3 P, int lod, ivec2 offset); +ivec4 texelFetchOffset(isampler2DArray sampler, ivec3 P, int lod, ivec2 offset); +uvec4 texelFetchOffset(usampler2DArray sampler, ivec3 P, int lod, ivec2 offset); + +/* textureProjOffset - no bias */ + vec4 textureProj( sampler1D sampler, vec2 P, int offset); +ivec4 textureProj(isampler1D sampler, vec2 P, int offset); +uvec4 textureProj(usampler1D sampler, vec2 P, int offset); + vec4 textureProj( sampler1D sampler, vec4 P, int offset); +ivec4 textureProj(isampler1D sampler, vec4 P, int offset); +uvec4 textureProj(usampler1D sampler, vec4 P, int offset); + + vec4 textureProj( sampler2D sampler, vec3 P, ivec2 offset); +ivec4 textureProj(isampler2D sampler, vec3 P, ivec2 offset); +uvec4 textureProj(usampler2D sampler, vec3 P, ivec2 offset); + vec4 textureProj( sampler2D sampler, vec4 P, ivec2 offset); +ivec4 textureProj(isampler2D sampler, vec4 P, ivec2 offset); +uvec4 textureProj(usampler2D sampler, vec4 P, ivec2 offset); + + vec4 textureProj( sampler3D sampler, vec4 P, ivec3 offset); +ivec4 textureProj(isampler3D sampler, vec4 P, ivec3 offset); +uvec4 textureProj(usampler3D sampler, vec4 P, ivec3 offset); + +float textureProj(sampler1DShadow sampler, vec4 P, int offset); +float textureProj(sampler2DShadow sampler, vec4 P, ivec2 offset); + +/* textureProjOffset - bias variants */ + vec4 textureProj( sampler1D sampler, vec2 P, int offset, float bias); +ivec4 textureProj(isampler1D sampler, vec2 P, int offset, float bias); +uvec4 textureProj(usampler1D sampler, vec2 P, int offset, float bias); + vec4 textureProj( sampler1D sampler, vec4 P, int offset, float bias); +ivec4 textureProj(isampler1D sampler, vec4 P, int offset, float bias); +uvec4 textureProj(usampler1D sampler, vec4 P, int offset, float bias); + + vec4 textureProj( sampler2D sampler, vec3 P, ivec2 offset, float bias); +ivec4 textureProj(isampler2D sampler, vec3 P, ivec2 offset, float bias); +uvec4 textureProj(usampler2D sampler, vec3 P, ivec2 offset, float bias); + vec4 textureProj( sampler2D sampler, vec4 P, ivec2 offset, float bias); +ivec4 textureProj(isampler2D sampler, vec4 P, ivec2 offset, float bias); +uvec4 textureProj(usampler2D sampler, vec4 P, ivec2 offset, float bias); + + vec4 textureProj( sampler3D sampler, vec4 P, ivec3 offset, float bias); +ivec4 textureProj(isampler3D sampler, vec4 P, ivec3 offset, float bias); +uvec4 textureProj(usampler3D sampler, vec4 P, ivec3 offset, float bias); + +float textureProj(sampler1DShadow sampler, vec4 P, int offset, float bias); +float textureProj(sampler2DShadow sampler, vec4 P, ivec2 offset, float bias); + +/* textureLodOffset */ + vec4 textureLodOffset( sampler1D sampler, float P, float lod, int offset); +ivec4 textureLodOffset(isampler1D sampler, float P, float lod, int offset); +uvec4 textureLodOffset(usampler1D sampler, float P, float lod, int offset); + + vec4 textureLodOffset( sampler2D sampler, vec2 P, float lod, ivec2 offset); +ivec4 textureLodOffset(isampler2D sampler, vec2 P, float lod, ivec2 offset); +uvec4 textureLodOffset(usampler2D sampler, vec2 P, float lod, ivec2 offset); + + vec4 textureLodOffset( sampler3D sampler, vec3 P, float lod, ivec3 offset); +ivec4 textureLodOffset(isampler3D sampler, vec3 P, float lod, ivec3 offset); +uvec4 textureLodOffset(usampler3D sampler, vec3 P, float lod, ivec3 offset); + +float textureLodOffset(sampler1DShadow samp, vec3 P, float lod, int offset); +float textureLodOffset(sampler2DShadow samp, vec3 P, float lod, ivec2 offset); + + vec4 textureLodOffset( sampler1DArray sampler, vec2 P, float lod, int offset); +ivec4 textureLodOffset(isampler1DArray sampler, vec2 P, float lod, int offset); +uvec4 textureLodOffset(usampler1DArray sampler, vec2 P, float lod, int offset); + + vec4 textureLodOffset( sampler2DArray samp, vec3 P, float lod, ivec2 offset); +ivec4 textureLodOffset(isampler2DArray samp, vec3 P, float lod, ivec2 offset); +uvec4 textureLodOffset(usampler2DArray samp, vec3 P, float lod, ivec2 offset); + +float textureLodOffset(sampler1DArrayShadow s, vec3 P, float lod, int offset); + +/* textureProjLod */ + vec4 textureProjLod( sampler1D sampler, vec2 P, float lod); +ivec4 textureProjLod(isampler1D sampler, vec2 P, float lod); +uvec4 textureProjLod(usampler1D sampler, vec2 P, float lod); + vec4 textureProjLod( sampler1D sampler, vec4 P, float lod); +ivec4 textureProjLod(isampler1D sampler, vec4 P, float lod); +uvec4 textureProjLod(usampler1D sampler, vec4 P, float lod); + + vec4 textureProjLod( sampler2D sampler, vec3 P, float lod); +ivec4 textureProjLod(isampler2D sampler, vec3 P, float lod); +uvec4 textureProjLod(usampler2D sampler, vec3 P, float lod); + vec4 textureProjLod( sampler2D sampler, vec4 P, float lod); +ivec4 textureProjLod(isampler2D sampler, vec4 P, float lod); +uvec4 textureProjLod(usampler2D sampler, vec4 P, float lod); + + vec4 textureProjLod( sampler3D sampler, vec4 P, float lod); +ivec4 textureProjLod(isampler3D sampler, vec4 P, float lod); +uvec4 textureProjLod(usampler3D sampler, vec4 P, float lod); + +float textureProjLod(sampler1DShadow sampler, vec4 P, float lod); +float textureProjLod(sampler2DShadow sampler, vec4 P, float lod); + +/* textureProjLodOffset */ + vec4 textureProjLodOffset( sampler1D sampler, vec2 P, float lod, int offset); +ivec4 textureProjLodOffset(isampler1D sampler, vec2 P, float lod, int offset); +uvec4 textureProjLodOffset(usampler1D sampler, vec2 P, float lod, int offset); + vec4 textureProjLodOffset( sampler1D sampler, vec4 P, float lod, int offset); +ivec4 textureProjLodOffset(isampler1D sampler, vec4 P, float lod, int offset); +uvec4 textureProjLodOffset(usampler1D sampler, vec4 P, float lod, int offset); + + vec4 textureProjLodOffset( sampler2D sampler, vec3 P, float lod, ivec2 offset); +ivec4 textureProjLodOffset(isampler2D sampler, vec3 P, float lod, ivec2 offset); +uvec4 textureProjLodOffset(usampler2D sampler, vec3 P, float lod, ivec2 offset); + vec4 textureProjLodOffset( sampler2D sampler, vec4 P, float lod, ivec2 offset); +ivec4 textureProjLodOffset(isampler2D sampler, vec4 P, float lod, ivec2 offset); +uvec4 textureProjLodOffset(usampler2D sampler, vec4 P, float lod, ivec2 offset); + + vec4 textureProjLodOffset( sampler3D sampler, vec4 P, float lod, ivec3 offset); +ivec4 textureProjLodOffset(isampler3D sampler, vec4 P, float lod, ivec3 offset); +uvec4 textureProjLodOffset(usampler3D sampler, vec4 P, float lod, ivec3 offset); + +float textureProjLodOffset(sampler1DShadow s, vec4 P, float lod, int offset); +float textureProjLodOffset(sampler2DShadow s, vec4 P, float lod, ivec2 offset); + +/* textureGrad */ + vec4 textureGrad( sampler1D sampler, float P, float dPdx, float dPdy); +ivec4 textureGrad(isampler1D sampler, float P, float dPdx, float dPdy); +uvec4 textureGrad(usampler1D sampler, float P, float dPdx, float dPdy); + + vec4 textureGrad( sampler2D sampler, vec2 P, vec2 dPdx, vec2 dPdy); +ivec4 textureGrad(isampler2D sampler, vec2 P, vec2 dPdx, vec2 dPdy); +uvec4 textureGrad(usampler2D sampler, vec2 P, vec2 dPdx, vec2 dPdy); + + vec4 textureGrad( sampler3D sampler, vec3 P, vec3 dPdx, vec3 dPdy); +ivec4 textureGrad(isampler3D sampler, vec3 P, vec3 dPdx, vec3 dPdy); +uvec4 textureGrad(usampler3D sampler, vec3 P, vec3 dPdx, vec3 dPdy); + + vec4 textureGrad( samplerCube sampler, vec3 P, vec3 dPdx, vec3 dPdy); +ivec4 textureGrad(isamplerCube sampler, vec3 P, vec3 dPdx, vec3 dPdy); +uvec4 textureGrad(usamplerCube sampler, vec3 P, vec3 dPdx, vec3 dPdy); + +float textureGrad(sampler1DShadow sampler, vec3 P, float dPdx, float dPdy); +float textureGrad(sampler2DShadow sampler, vec3 P, vec2 dPdx, vec2 dPdy); +float textureGrad(samplerCubeShadow sampler, vec4 P, vec3 dPdx, vec3 dPdy); + + vec4 textureGrad( sampler1DArray sampler, vec2 P, float dPdx, float dPdy); +ivec4 textureGrad(isampler1DArray sampler, vec2 P, float dPdx, float dPdy); +uvec4 textureGrad(usampler1DArray sampler, vec2 P, float dPdx, float dPdy); + + vec4 textureGrad( sampler2DArray sampler, vec3 P, vec2 dPdx, vec2 dPdy); +ivec4 textureGrad(isampler2DArray sampler, vec3 P, vec2 dPdx, vec2 dPdy); +uvec4 textureGrad(usampler2DArray sampler, vec3 P, vec2 dPdx, vec2 dPdy); + +float textureGrad(sampler1DArrayShadow sampler, vec3 P, float dPdx, float dPdy); +float textureGrad(sampler2DArrayShadow sampler, vec4 P, vec2 dPdx, vec2 dPdy); + +/* textureGradOffset */ + vec4 textureGradOffset( sampler1D s, float P, float dx, float dy, int off); +ivec4 textureGradOffset(isampler1D s, float P, float dx, float dy, int offset); +uvec4 textureGradOffset(usampler1D s, float P, float dx, float dy, int offset); + + vec4 textureGradOffset( sampler2D s, vec2 P, vec2 dx, vec2 dy, ivec2 offset); +ivec4 textureGradOffset(isampler2D s, vec2 P, vec2 dx, vec2 dy, ivec2 offset); +uvec4 textureGradOffset(usampler2D s, vec2 P, vec2 dx, vec2 dy, ivec2 offset); + + vec4 textureGradOffset( sampler3D s, vec3 P, vec3 dx, vec3 dy, ivec3 offset); +ivec4 textureGradOffset(isampler3D s, vec3 P, vec3 dx, vec3 dy, ivec3 offset); +uvec4 textureGradOffset(usampler3D s, vec3 P, vec3 dx, vec3 dy, ivec3 offset); + + vec4 textureGradOffset( samplerCube s, vec3 P, vec3 dx, vec3 dy, ivec3 offset); +ivec4 textureGradOffset(isamplerCube s, vec3 P, vec3 dx, vec3 dy, ivec3 offset); +uvec4 textureGradOffset(usamplerCube s, vec3 P, vec3 dx, vec3 dy, ivec3 offset); + +float textureGradOffset(sampler1DShadow s, vec3 P, float dx, float dy, int off); +float textureGradOffset(sampler2DShadow s, vec3 P, vec2 dx, vec2 dy, ivec2 off); + + vec4 textureGradOffset( sampler1DArray s, vec2 P, float dx, float dy, int off); +ivec4 textureGradOffset(isampler1DArray s, vec2 P, float dx, float dy, int off); +uvec4 textureGradOffset(usampler1DArray s, vec2 P, float dx, float dy, int off); + + vec4 textureGradOffset( sampler2DArray s, vec3 P, vec2 dx, vec2 dy, ivec2 off); +ivec4 textureGradOffset(isampler2DArray s, vec3 P, vec2 dx, vec2 dy, ivec2 off); +uvec4 textureGradOffset(usampler2DArray s, vec3 P, vec2 dx, vec2 dy, ivec2 off); + +float textureGradOffset(sampler1DArrayShadow s, vec3 P, float dx, float dy, int o); +float textureGradOffset(sampler2DArrayShadow s, vec4 P, vec2 dx, vec2 dy, ivec2 o); + +/* textureProjGrad */ + vec4 textureProjGrad( sampler1D sampler, vec2 P, float dPdx, float dPdy); +ivec4 textureProjGrad(isampler1D sampler, vec2 P, float dPdx, float dPdy); +uvec4 textureProjGrad(usampler1D sampler, vec2 P, float dPdx, float dPdy); + vec4 textureProjGrad( sampler1D sampler, vec4 P, float dPdx, float dPdy); +ivec4 textureProjGrad(isampler1D sampler, vec4 P, float dPdx, float dPdy); +uvec4 textureProjGrad(usampler1D sampler, vec4 P, float dPdx, float dPdy); + + vec4 textureProjGrad( sampler2D sampler, vec3 P, vec2 dPdx, vec2 dPdy); +ivec4 textureProjGrad(isampler2D sampler, vec3 P, vec2 dPdx, vec2 dPdy); +uvec4 textureProjGrad(usampler2D sampler, vec3 P, vec2 dPdx, vec2 dPdy); + vec4 textureProjGrad( sampler2D sampler, vec4 P, vec2 dPdx, vec2 dPdy); +ivec4 textureProjGrad(isampler2D sampler, vec4 P, vec2 dPdx, vec2 dPdy); +uvec4 textureProjGrad(usampler2D sampler, vec4 P, vec2 dPdx, vec2 dPdy); + + vec4 textureProjGrad( sampler3D sampler, vec4 P, vec3 dPdx, vec3 dPdy); +ivec4 textureProjGrad(isampler3D sampler, vec4 P, vec3 dPdx, vec3 dPdy); +uvec4 textureProjGrad(usampler3D sampler, vec4 P, vec3 dPdx, vec3 dPdy); + +float textureProjGrad(sampler1DShadow sampler, vec4 P, float dPdx, float dPdy); +float textureProjGrad(sampler2DShadow sampler, vec4 P, vec2 dPdx, vec2 dPdy); + +/* textureProjGradOffset */ + vec4 textureProjGradOffset( sampler1D s, vec2 P, float dx, float dy, int off); +ivec4 textureProjGradOffset(isampler1D s, vec2 P, float dx, float dy, int off); +uvec4 textureProjGradOffset(usampler1D s, vec2 P, float dx, float dy, int off); + vec4 textureProjGradOffset( sampler1D s, vec4 P, float dx, float dy, int off); +ivec4 textureProjGradOffset(isampler1D s, vec4 P, float dx, float dy, int off); +uvec4 textureProjGradOffset(usampler1D s, vec4 P, float dx, float dy, int off); + + vec4 textureProjGradOffset( sampler2D s, vec3 P, vec2 dx, vec2 dy, ivec2 off); +ivec4 textureProjGradOffset(isampler2D s, vec3 P, vec2 dx, vec2 dy, ivec2 off); +uvec4 textureProjGradOffset(usampler2D s, vec3 P, vec2 dx, vec2 dy, ivec2 off); + vec4 textureProjGradOffset( sampler2D s, vec4 P, vec2 dx, vec2 dy, ivec2 off); +ivec4 textureProjGradOffset(isampler2D s, vec4 P, vec2 dx, vec2 dy, ivec2 off); +uvec4 textureProjGradOffset(usampler2D s, vec4 P, vec2 dx, vec2 dy, ivec2 off); + + vec4 textureProjGradOffset( sampler3D s, vec4 P, vec3 dx, vec3 dy, ivec3 off); +ivec4 textureProjGradOffset(isampler3D s, vec4 P, vec3 dx, vec3 dy, ivec3 off); +uvec4 textureProjGradOffset(usampler3D s, vec4 P, vec3 dx, vec3 dy, ivec3 off); + +float textureProjGradOffset(sampler1DShadow s, vec4 P, float dx, float dy, int o); +float textureProjGradOffset(sampler2DShadow s, vec4 P, vec2 dx, vec2 dy, vec2 o); + +/* + * The following texture functions are deprecated: + */ +vec4 texture1D (sampler1D sampler, float coord); +vec4 texture1DProj (sampler1D sampler, vec2 coord); +vec4 texture1DProj (sampler1D sampler, vec4 coord); +vec4 texture1D (sampler1D sampler, float coord, float bias); +vec4 texture1DProj (sampler1D sampler, vec2 coord, float bias); +vec4 texture1DProj (sampler1D sampler, vec4 coord, float bias); +vec4 texture1DLod (sampler1D sampler, float coord, float lod); +vec4 texture1DProjLod(sampler1D sampler, vec2 coord, float lod); +vec4 texture1DProjLod(sampler1D sampler, vec4 coord, float lod); + +vec4 texture2D (sampler2D sampler, vec2 coord); +vec4 texture2DProj (sampler2D sampler, vec3 coord); +vec4 texture2DProj (sampler2D sampler, vec4 coord); +vec4 texture2D (sampler2D sampler, vec2 coord, float bias); +vec4 texture2DProj (sampler2D sampler, vec3 coord, float bias); +vec4 texture2DProj (sampler2D sampler, vec4 coord, float bias); +vec4 texture2DLod (sampler2D sampler, vec2 coord, float lod); +vec4 texture2DProjLod(sampler2D sampler, vec3 coord, float lod); +vec4 texture2DProjLod(sampler2D sampler, vec4 coord, float lod); + +vec4 texture3D (sampler3D sampler, vec3 coord); +vec4 texture3DProj (sampler3D sampler, vec4 coord); +vec4 texture3D (sampler3D sampler, vec3 coord, float bias); +vec4 texture3DProj (sampler3D sampler, vec4 coord, float bias); +vec4 texture3DLod (sampler3D sampler, vec3 coord, float lod); +vec4 texture3DProjLod(sampler3D sampler, vec4 coord, float lod); + +vec4 textureCube (samplerCube sampler, vec3 coord); +vec4 textureCube (samplerCube sampler, vec3 coord, float bias); +vec4 textureCubeLod (samplerCube sampler, vec3 coord, float lod); + +vec4 shadow1D (sampler1DShadow sampler, vec3 coord); +vec4 shadow2D (sampler2DShadow sampler, vec3 coord); +vec4 shadow1DProj (sampler1DShadow sampler, vec4 coord); +vec4 shadow2DProj (sampler2DShadow sampler, vec4 coord); +vec4 shadow1D (sampler1DShadow sampler, vec3 coord, float bias); +vec4 shadow2D (sampler2DShadow sampler, vec3 coord, float bias); +vec4 shadow1DProj (sampler1DShadow sampler, vec4 coord, float bias); +vec4 shadow2DProj (sampler2DShadow sampler, vec4 coord, float bias); +vec4 shadow1DLod (sampler1DShadow sampler, vec3 coord, float lod); +vec4 shadow2DLod (sampler2DShadow sampler, vec3 coord, float lod); +vec4 shadow1DProjLod(sampler1DShadow sampler, vec4 coord, float lod); +vec4 shadow2DProjLod(sampler2DShadow sampler, vec4 coord, float lod); + +/* + * 8.8 - Fragment Processing Functions + */ +float dFdx(float p); +vec2 dFdx(vec2 p); +vec3 dFdx(vec3 p); +vec4 dFdx(vec4 p); + +float dFdy(float p); +vec2 dFdy(vec2 p); +vec3 dFdy(vec3 p); +vec4 dFdy(vec4 p); + +float fwidth(float p); +vec2 fwidth(vec2 p); +vec3 fwidth(vec3 p); +vec4 fwidth(vec4 p); + +/* + * 8.9 - Noise Functions + */ +float noise1(float x); +float noise1(vec2 x); +float noise1(vec3 x); +float noise1(vec4 x); + +vec2 noise2(float x); +vec2 noise2(vec2 x); +vec2 noise2(vec3 x); +vec2 noise2(vec4 x); + +vec3 noise3(float x); +vec3 noise3(vec2 x); +vec3 noise3(vec3 x); +vec3 noise3(vec4 x); + +vec4 noise4(float x); +vec4 noise4(vec2 x); +vec4 noise4(vec3 x); +vec4 noise4(vec4 x); diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/profiles/130.vert b/3rdparty/glsl-optimizer/src/glsl/builtins/profiles/130.vert new file mode 100644 index 000000000..f85b27f8f --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/profiles/130.vert @@ -0,0 +1,1027 @@ +#version 130 +/* + * 8.1 - Angle and Trigonometry Functions + */ +float radians(float degrees); +vec2 radians(vec2 degrees); +vec3 radians(vec3 degrees); +vec4 radians(vec4 degrees); + +float degrees(float radians); +vec2 degrees(vec2 radians); +vec3 degrees(vec3 radians); +vec4 degrees(vec4 radians); + +float sin(float angle); +vec2 sin(vec2 angle); +vec3 sin(vec3 angle); +vec4 sin(vec4 angle); + +float cos(float angle); +vec2 cos(vec2 angle); +vec3 cos(vec3 angle); +vec4 cos(vec4 angle); + +float tan(float angle); +vec2 tan(vec2 angle); +vec3 tan(vec3 angle); +vec4 tan(vec4 angle); + +float asin(float angle); +vec2 asin(vec2 angle); +vec3 asin(vec3 angle); +vec4 asin(vec4 angle); + +float acos(float angle); +vec2 acos(vec2 angle); +vec3 acos(vec3 angle); +vec4 acos(vec4 angle); + +float atan(float y, float x); +vec2 atan(vec2 y, vec2 x); +vec3 atan(vec3 y, vec3 x); +vec4 atan(vec4 y, vec4 x); + +float atan(float y_over_x); +vec2 atan(vec2 y_over_x); +vec3 atan(vec3 y_over_x); +vec4 atan(vec4 y_over_x); + +float sinh(float x); +vec2 sinh(vec2 x); +vec3 sinh(vec3 x); +vec4 sinh(vec4 x); + +float cosh(float x); +vec2 cosh(vec2 x); +vec3 cosh(vec3 x); +vec4 cosh(vec4 x); + +float tanh(float x); +vec2 tanh(vec2 x); +vec3 tanh(vec3 x); +vec4 tanh(vec4 x); + +float asinh(float x); +vec2 asinh(vec2 x); +vec3 asinh(vec3 x); +vec4 asinh(vec4 x); + +float acosh(float x); +vec2 acosh(vec2 x); +vec3 acosh(vec3 x); +vec4 acosh(vec4 x); + +float atanh(float x); +vec2 atanh(vec2 x); +vec3 atanh(vec3 x); +vec4 atanh(vec4 x); + +/* + * 8.2 - Exponential Functions + */ +float pow(float x, float y); +vec2 pow(vec2 x, vec2 y); +vec3 pow(vec3 x, vec3 y); +vec4 pow(vec4 x, vec4 y); + +float exp(float x); +vec2 exp(vec2 x); +vec3 exp(vec3 x); +vec4 exp(vec4 x); + +float log(float x); +vec2 log(vec2 x); +vec3 log(vec3 x); +vec4 log(vec4 x); + +float exp2(float x); +vec2 exp2(vec2 x); +vec3 exp2(vec3 x); +vec4 exp2(vec4 x); + +float log2(float x); +vec2 log2(vec2 x); +vec3 log2(vec3 x); +vec4 log2(vec4 x); + +float sqrt(float x); +vec2 sqrt(vec2 x); +vec3 sqrt(vec3 x); +vec4 sqrt(vec4 x); + +float inversesqrt(float x); +vec2 inversesqrt(vec2 x); +vec3 inversesqrt(vec3 x); +vec4 inversesqrt(vec4 x); + +/* + * 8.3 - Common Functions + */ +float abs(float x); +vec2 abs(vec2 x); +vec3 abs(vec3 x); +vec4 abs(vec4 x); +int abs(int x); +ivec2 abs(ivec2 x); +ivec3 abs(ivec3 x); +ivec4 abs(ivec4 x); + +float sign(float x); +vec2 sign(vec2 x); +vec3 sign(vec3 x); +vec4 sign(vec4 x); +int sign(int x); +ivec2 sign(ivec2 x); +ivec3 sign(ivec3 x); +ivec4 sign(ivec4 x); + +float floor(float x); +vec2 floor(vec2 x); +vec3 floor(vec3 x); +vec4 floor(vec4 x); + +float trunc(float x); +vec2 trunc(vec2 x); +vec3 trunc(vec3 x); +vec4 trunc(vec4 x); + +float round(float x); +vec2 round(vec2 x); +vec3 round(vec3 x); +vec4 round(vec4 x); + +float roundEven(float x); +vec2 roundEven(vec2 x); +vec3 roundEven(vec3 x); +vec4 roundEven(vec4 x); + +float ceil(float x); +vec2 ceil(vec2 x); +vec3 ceil(vec3 x); +vec4 ceil(vec4 x); + +float fract(float x); +vec2 fract(vec2 x); +vec3 fract(vec3 x); +vec4 fract(vec4 x); + +float mod(float x, float y); +vec2 mod(vec2 x, float y); +vec3 mod(vec3 x, float y); +vec4 mod(vec4 x, float y); + +vec2 mod(vec2 x, vec2 y); +vec3 mod(vec3 x, vec3 y); +vec4 mod(vec4 x, vec4 y); + +float modf(float x, out float i); +vec2 modf(vec2 x, out vec2 i); +vec3 modf(vec3 x, out vec3 i); +vec4 modf(vec4 x, out vec4 i); + +float min(float x, float y); +vec2 min(vec2 x, vec2 y); +vec3 min(vec3 x, vec3 y); +vec4 min(vec4 x, vec4 y); + +vec2 min(vec2 x, float y); +vec3 min(vec3 x, float y); +vec4 min(vec4 x, float y); + +int min(int x, int y); +ivec2 min(ivec2 x, ivec2 y); +ivec3 min(ivec3 x, ivec3 y); +ivec4 min(ivec4 x, ivec4 y); + +ivec2 min(ivec2 x, int y); +ivec3 min(ivec3 x, int y); +ivec4 min(ivec4 x, int y); + +uint min(uint x, uint y); +uvec2 min(uvec2 x, uvec2 y); +uvec3 min(uvec3 x, uvec3 y); +uvec4 min(uvec4 x, uvec4 y); + +uvec2 min(uvec2 x, uint y); +uvec3 min(uvec3 x, uint y); +uvec4 min(uvec4 x, uint y); + +float max(float x, float y); +vec2 max(vec2 x, vec2 y); +vec3 max(vec3 x, vec3 y); +vec4 max(vec4 x, vec4 y); + +vec2 max(vec2 x, float y); +vec3 max(vec3 x, float y); +vec4 max(vec4 x, float y); + +int max(int x, int y); +ivec2 max(ivec2 x, ivec2 y); +ivec3 max(ivec3 x, ivec3 y); +ivec4 max(ivec4 x, ivec4 y); + +ivec2 max(ivec2 x, int y); +ivec3 max(ivec3 x, int y); +ivec4 max(ivec4 x, int y); + +uint max(uint x, uint y); +uvec2 max(uvec2 x, uvec2 y); +uvec3 max(uvec3 x, uvec3 y); +uvec4 max(uvec4 x, uvec4 y); + +uvec2 max(uvec2 x, uint y); +uvec3 max(uvec3 x, uint y); +uvec4 max(uvec4 x, uint y); + +float clamp(float x, float minVal, float maxVal); +vec2 clamp(vec2 x, vec2 minVal, vec2 maxVal); +vec3 clamp(vec3 x, vec3 minVal, vec3 maxVal); +vec4 clamp(vec4 x, vec4 minVal, vec4 maxVal); + +vec2 clamp(vec2 x, float minVal, float maxVal); +vec3 clamp(vec3 x, float minVal, float maxVal); +vec4 clamp(vec4 x, float minVal, float maxVal); + +int clamp(int x, int minVal, int maxVal); +ivec2 clamp(ivec2 x, ivec2 minVal, ivec2 maxVal); +ivec3 clamp(ivec3 x, ivec3 minVal, ivec3 maxVal); +ivec4 clamp(ivec4 x, ivec4 minVal, ivec4 maxVal); + +ivec2 clamp(ivec2 x, int minVal, int maxVal); +ivec3 clamp(ivec3 x, int minVal, int maxVal); +ivec4 clamp(ivec4 x, int minVal, int maxVal); + +uint clamp(uint x, uint minVal, uint maxVal); +uvec2 clamp(uvec2 x, uvec2 minVal, uvec2 maxVal); +uvec3 clamp(uvec3 x, uvec3 minVal, uvec3 maxVal); +uvec4 clamp(uvec4 x, uvec4 minVal, uvec4 maxVal); + +uvec2 clamp(uvec2 x, uint minVal, uint maxVal); +uvec3 clamp(uvec3 x, uint minVal, uint maxVal); +uvec4 clamp(uvec4 x, uint minVal, uint maxVal); + +float mix(float x, float y, float a); +vec2 mix(vec2 x, vec2 y, vec2 a); +vec3 mix(vec3 x, vec3 y, vec3 a); +vec4 mix(vec4 x, vec4 y, vec4 a); + +vec2 mix(vec2 x, vec2 y, float a); +vec3 mix(vec3 x, vec3 y, float a); +vec4 mix(vec4 x, vec4 y, float a); + +float step(float edge, float x); +vec2 step(vec2 edge, vec2 x); +vec3 step(vec3 edge, vec3 x); +vec4 step(vec4 edge, vec4 x); + +vec2 step(float edge, vec2 x); +vec3 step(float edge, vec3 x); +vec4 step(float edge, vec4 x); + +float smoothstep(float edge0, float edge1, float x); +vec2 smoothstep(vec2 edge0, vec2 edge1, vec2 x); +vec3 smoothstep(vec3 edge0, vec3 edge1, vec3 x); +vec4 smoothstep(vec4 edge0, vec4 edge1, vec4 x); + +vec2 smoothstep(float edge0, float edge1, vec2 x); +vec3 smoothstep(float edge0, float edge1, vec3 x); +vec4 smoothstep(float edge0, float edge1, vec4 x); + +#if 0 +bool isnan(float x); +bvec2 isnan(vec2 x); +bvec3 isnan(vec3 x); +bvec4 isnan(vec4 x); + +bool isinf(float x); +bvec2 isinf(vec2 x); +bvec3 isinf(vec3 x); +bvec4 isinf(vec4 x); +#endif + +/* + * 8.4 - Geometric Functions + */ +float length(float x); +float length(vec2 x); +float length(vec3 x); +float length(vec4 x); + +float distance(float p0, float p1); +float distance(vec2 p0, vec2 p1); +float distance(vec3 p0, vec3 p1); +float distance(vec4 p0, vec4 p1); + +float dot(float x, float y); +float dot(vec2 x, vec2 y); +float dot(vec3 x, vec3 y); +float dot(vec4 x, vec4 y); + +vec3 cross(vec3 x, vec3 y); + +float normalize(float x); +vec2 normalize(vec2 x); +vec3 normalize(vec3 x); +vec4 normalize(vec4 x); + +vec4 ftransform(); + +float faceforward(float N, float I, float Nref); +vec2 faceforward(vec2 N, vec2 I, vec2 Nref); +vec3 faceforward(vec3 N, vec3 I, vec3 Nref); +vec4 faceforward(vec4 N, vec4 I, vec4 Nref); + +float reflect(float I, float N); +vec2 reflect(vec2 I, vec2 N); +vec3 reflect(vec3 I, vec3 N); +vec4 reflect(vec4 I, vec4 N); + +float refract(float I, float N, float eta); +vec2 refract(vec2 I, vec2 N, float eta); +vec3 refract(vec3 I, vec3 N, float eta); +vec4 refract(vec4 I, vec4 N, float eta); + + +/* + * 8.5 - Matrix Functions + */ +mat2 matrixCompMult(mat2 x, mat2 y); +mat3 matrixCompMult(mat3 x, mat3 y); +mat4 matrixCompMult(mat4 x, mat4 y); +mat2x3 matrixCompMult(mat2x3 x, mat2x3 y); +mat2x4 matrixCompMult(mat2x4 x, mat2x4 y); +mat3x2 matrixCompMult(mat3x2 x, mat3x2 y); +mat3x4 matrixCompMult(mat3x4 x, mat3x4 y); +mat4x2 matrixCompMult(mat4x2 x, mat4x2 y); +mat4x3 matrixCompMult(mat4x3 x, mat4x3 y); + +mat2 outerProduct(vec2 c, vec2 r); +mat3 outerProduct(vec3 c, vec3 r); +mat4 outerProduct(vec4 c, vec4 r); + +mat2x3 outerProduct(vec3 c, vec2 r); +mat3x2 outerProduct(vec2 c, vec3 r); + +mat2x4 outerProduct(vec4 c, vec2 r); +mat4x2 outerProduct(vec2 c, vec4 r); + +mat3x4 outerProduct(vec4 c, vec3 r); +mat4x3 outerProduct(vec3 c, vec4 r); + +mat2 transpose(mat2 m); +mat3 transpose(mat3 m); +mat4 transpose(mat4 m); + +mat2x3 transpose(mat3x2 m); +mat3x2 transpose(mat2x3 m); + +mat2x4 transpose(mat4x2 m); +mat4x2 transpose(mat2x4 m); + +mat3x4 transpose(mat4x3 m); +mat4x3 transpose(mat3x4 m); + +/* + * 8.6 - Vector Relational Functions + */ +bvec2 lessThan( vec2 x, vec2 y); +bvec3 lessThan( vec3 x, vec3 y); +bvec4 lessThan( vec4 x, vec4 y); +bvec2 lessThan(ivec2 x, ivec2 y); +bvec3 lessThan(ivec3 x, ivec3 y); +bvec4 lessThan(ivec4 x, ivec4 y); +bvec2 lessThan(uvec2 x, uvec2 y); +bvec3 lessThan(uvec3 x, uvec3 y); +bvec4 lessThan(uvec4 x, uvec4 y); + +bvec2 lessThanEqual( vec2 x, vec2 y); +bvec3 lessThanEqual( vec3 x, vec3 y); +bvec4 lessThanEqual( vec4 x, vec4 y); +bvec2 lessThanEqual(ivec2 x, ivec2 y); +bvec3 lessThanEqual(ivec3 x, ivec3 y); +bvec4 lessThanEqual(ivec4 x, ivec4 y); +bvec2 lessThanEqual(uvec2 x, uvec2 y); +bvec3 lessThanEqual(uvec3 x, uvec3 y); +bvec4 lessThanEqual(uvec4 x, uvec4 y); + +bvec2 greaterThan( vec2 x, vec2 y); +bvec3 greaterThan( vec3 x, vec3 y); +bvec4 greaterThan( vec4 x, vec4 y); +bvec2 greaterThan(ivec2 x, ivec2 y); +bvec3 greaterThan(ivec3 x, ivec3 y); +bvec4 greaterThan(ivec4 x, ivec4 y); +bvec2 greaterThan(uvec2 x, uvec2 y); +bvec3 greaterThan(uvec3 x, uvec3 y); +bvec4 greaterThan(uvec4 x, uvec4 y); + +bvec2 greaterThanEqual( vec2 x, vec2 y); +bvec3 greaterThanEqual( vec3 x, vec3 y); +bvec4 greaterThanEqual( vec4 x, vec4 y); +bvec2 greaterThanEqual(ivec2 x, ivec2 y); +bvec3 greaterThanEqual(ivec3 x, ivec3 y); +bvec4 greaterThanEqual(ivec4 x, ivec4 y); +bvec2 greaterThanEqual(uvec2 x, uvec2 y); +bvec3 greaterThanEqual(uvec3 x, uvec3 y); +bvec4 greaterThanEqual(uvec4 x, uvec4 y); + +bvec2 equal( vec2 x, vec2 y); +bvec3 equal( vec3 x, vec3 y); +bvec4 equal( vec4 x, vec4 y); +bvec2 equal(ivec2 x, ivec2 y); +bvec3 equal(ivec3 x, ivec3 y); +bvec4 equal(ivec4 x, ivec4 y); +bvec2 equal(uvec2 x, uvec2 y); +bvec3 equal(uvec3 x, uvec3 y); +bvec4 equal(uvec4 x, uvec4 y); +bvec2 equal(bvec2 x, bvec2 y); +bvec3 equal(bvec3 x, bvec3 y); +bvec4 equal(bvec4 x, bvec4 y); + +bvec2 notEqual( vec2 x, vec2 y); +bvec3 notEqual( vec3 x, vec3 y); +bvec4 notEqual( vec4 x, vec4 y); +bvec2 notEqual(ivec2 x, ivec2 y); +bvec3 notEqual(ivec3 x, ivec3 y); +bvec4 notEqual(ivec4 x, ivec4 y); +bvec2 notEqual(uvec2 x, uvec2 y); +bvec3 notEqual(uvec3 x, uvec3 y); +bvec4 notEqual(uvec4 x, uvec4 y); +bvec2 notEqual(bvec2 x, bvec2 y); +bvec3 notEqual(bvec3 x, bvec3 y); +bvec4 notEqual(bvec4 x, bvec4 y); + +bool any(bvec2 x); +bool any(bvec3 x); +bool any(bvec4 x); + +bool all(bvec2 x); +bool all(bvec3 x); +bool all(bvec4 x); + +bvec2 not(bvec2 x); +bvec3 not(bvec3 x); +bvec4 not(bvec4 x); + +/* + * 8.7 - Texture Lookup Functions + */ + +#if 0 +/* textureSize */ +int textureSize( sampler1D sampler, int lod); +int textureSize(isampler1D sampler, int lod); +int textureSize(usampler1D sampler, int lod); + +ivec2 textureSize( sampler2D sampler, int lod); +ivec2 textureSize(isampler2D sampler, int lod); +ivec2 textureSize(usampler2D sampler, int lod); + +ivec3 textureSize( sampler3D sampler, int lod); +ivec3 textureSize(isampler3D sampler, int lod); +ivec3 textureSize(usampler3D sampler, int lod); + +ivec2 textureSize( samplerCube sampler, int lod); +ivec2 textureSize(isamplerCube sampler, int lod); +ivec2 textureSize(usamplerCube sampler, int lod); + +int textureSize(sampler1DShadow sampler, int lod); +ivec2 textureSize(sampler2DShadow sampler, int lod); +ivec2 textureSize(samplerCubeShadow sampler, int lod); + +ivec2 textureSize( sampler1DArray sampler, int lod); +ivec2 textureSize(isampler1DArray sampler, int lod); +ivec2 textureSize(usampler1DArray sampler, int lod); +ivec3 textureSize( sampler2DArray sampler, int lod); +ivec3 textureSize(isampler2DArray sampler, int lod); +ivec3 textureSize(usampler2DArray sampler, int lod); + +ivec2 textureSize(sampler1DArrayShadow sampler, int lod); +ivec3 textureSize(sampler2DArrayShadow sampler, int lod); +#endif + +/* texture - no bias */ + vec4 texture( sampler1D sampler, float P); +ivec4 texture(isampler1D sampler, float P); +uvec4 texture(usampler1D sampler, float P); + + vec4 texture( sampler2D sampler, vec2 P); +ivec4 texture(isampler2D sampler, vec2 P); +uvec4 texture(usampler2D sampler, vec2 P); + + vec4 texture( sampler3D sampler, vec3 P); +ivec4 texture(isampler3D sampler, vec3 P); +uvec4 texture(usampler3D sampler, vec3 P); + + vec4 texture( samplerCube sampler, vec3 P); +ivec4 texture(isamplerCube sampler, vec3 P); +uvec4 texture(usamplerCube sampler, vec3 P); + +float texture(sampler1DShadow sampler, vec3 P); +float texture(sampler2DShadow sampler, vec3 P); +float texture(samplerCubeShadow sampler, vec4 P); + + vec4 texture( sampler1DArray sampler, vec2 P); +ivec4 texture(isampler1DArray sampler, vec2 P); +uvec4 texture(usampler1DArray sampler, vec2 P); + + vec4 texture( sampler2DArray sampler, vec3 P); +ivec4 texture(isampler2DArray sampler, vec3 P); +uvec4 texture(usampler2DArray sampler, vec3 P); + +float texture(sampler1DArrayShadow sampler, vec3 P); +float texture(sampler2DArrayShadow sampler, vec4 P); + +/* texture - bias variants */ + vec4 texture( sampler1D sampler, float P, float bias); +ivec4 texture(isampler1D sampler, float P, float bias); +uvec4 texture(usampler1D sampler, float P, float bias); + + vec4 texture( sampler2D sampler, vec2 P, float bias); +ivec4 texture(isampler2D sampler, vec2 P, float bias); +uvec4 texture(usampler2D sampler, vec2 P, float bias); + + vec4 texture( sampler3D sampler, vec3 P, float bias); +ivec4 texture(isampler3D sampler, vec3 P, float bias); +uvec4 texture(usampler3D sampler, vec3 P, float bias); + + vec4 texture( samplerCube sampler, vec3 P, float bias); +ivec4 texture(isamplerCube sampler, vec3 P, float bias); +uvec4 texture(usamplerCube sampler, vec3 P, float bias); + +float texture(sampler1DShadow sampler, vec3 P, float bias); +float texture(sampler2DShadow sampler, vec3 P, float bias); +float texture(samplerCubeShadow sampler, vec4 P, float bias); + + vec4 texture( sampler1DArray sampler, vec2 P, float bias); +ivec4 texture(isampler1DArray sampler, vec2 P, float bias); +uvec4 texture(usampler1DArray sampler, vec2 P, float bias); + + vec4 texture( sampler2DArray sampler, vec3 P, float bias); +ivec4 texture(isampler2DArray sampler, vec3 P, float bias); +uvec4 texture(usampler2DArray sampler, vec3 P, float bias); + +float texture(sampler1DArrayShadow sampler, vec3 P, float bias); + +/* textureProj - no bias */ + vec4 textureProj( sampler1D sampler, vec2 P); +ivec4 textureProj(isampler1D sampler, vec2 P); +uvec4 textureProj(usampler1D sampler, vec2 P); + vec4 textureProj( sampler1D sampler, vec4 P); +ivec4 textureProj(isampler1D sampler, vec4 P); +uvec4 textureProj(usampler1D sampler, vec4 P); + + vec4 textureProj( sampler2D sampler, vec3 P); +ivec4 textureProj(isampler2D sampler, vec3 P); +uvec4 textureProj(usampler2D sampler, vec3 P); + vec4 textureProj( sampler2D sampler, vec4 P); +ivec4 textureProj(isampler2D sampler, vec4 P); +uvec4 textureProj(usampler2D sampler, vec4 P); + + vec4 textureProj( sampler3D sampler, vec4 P); +ivec4 textureProj(isampler3D sampler, vec4 P); +uvec4 textureProj(usampler3D sampler, vec4 P); + +float textureProj(sampler1DShadow sampler, vec4 P); +float textureProj(sampler2DShadow sampler, vec4 P); + +/* textureProj - bias variants */ + vec4 textureProj( sampler1D sampler, vec2 P, float bias); +ivec4 textureProj(isampler1D sampler, vec2 P, float bias); +uvec4 textureProj(usampler1D sampler, vec2 P, float bias); + vec4 textureProj( sampler1D sampler, vec4 P, float bias); +ivec4 textureProj(isampler1D sampler, vec4 P, float bias); +uvec4 textureProj(usampler1D sampler, vec4 P, float bias); + + vec4 textureProj( sampler2D sampler, vec3 P, float bias); +ivec4 textureProj(isampler2D sampler, vec3 P, float bias); +uvec4 textureProj(usampler2D sampler, vec3 P, float bias); + vec4 textureProj( sampler2D sampler, vec4 P, float bias); +ivec4 textureProj(isampler2D sampler, vec4 P, float bias); +uvec4 textureProj(usampler2D sampler, vec4 P, float bias); + + vec4 textureProj( sampler3D sampler, vec4 P, float bias); +ivec4 textureProj(isampler3D sampler, vec4 P, float bias); +uvec4 textureProj(usampler3D sampler, vec4 P, float bias); + +float textureProj(sampler1DShadow sampler, vec4 P, float bias); +float textureProj(sampler2DShadow sampler, vec4 P, float bias); + +/* textureLod */ + vec4 textureLod( sampler1D sampler, float P, float lod); +ivec4 textureLod(isampler1D sampler, float P, float lod); +uvec4 textureLod(usampler1D sampler, float P, float lod); + + vec4 textureLod( sampler2D sampler, vec2 P, float lod); +ivec4 textureLod(isampler2D sampler, vec2 P, float lod); +uvec4 textureLod(usampler2D sampler, vec2 P, float lod); + + vec4 textureLod( sampler3D sampler, vec3 P, float lod); +ivec4 textureLod(isampler3D sampler, vec3 P, float lod); +uvec4 textureLod(usampler3D sampler, vec3 P, float lod); + + vec4 textureLod( samplerCube sampler, vec3 P, float lod); +ivec4 textureLod(isamplerCube sampler, vec3 P, float lod); +uvec4 textureLod(usamplerCube sampler, vec3 P, float lod); + +float textureLod(sampler1DShadow sampler, vec3 P, float lod); +float textureLod(sampler2DShadow sampler, vec3 P, float lod); + + vec4 textureLod( sampler1DArray sampler, vec2 P, float lod); +ivec4 textureLod(isampler1DArray sampler, vec2 P, float lod); +uvec4 textureLod(usampler1DArray sampler, vec2 P, float lod); + + vec4 textureLod( sampler2DArray sampler, vec3 P, float lod); +ivec4 textureLod(isampler2DArray sampler, vec3 P, float lod); +uvec4 textureLod(usampler2DArray sampler, vec3 P, float lod); + +float textureLod(sampler1DArrayShadow sampler, vec3 P, float lod); + +/* textureOffset - no bias */ + vec4 textureOffset( sampler1D sampler, float P, int offset); +ivec4 textureOffset(isampler1D sampler, float P, int offset); +uvec4 textureOffset(usampler1D sampler, float P, int offset); + + vec4 textureOffset( sampler2D sampler, vec2 P, ivec2 offset); +ivec4 textureOffset(isampler2D sampler, vec2 P, ivec2 offset); +uvec4 textureOffset(usampler2D sampler, vec2 P, ivec2 offset); + + vec4 textureOffset( sampler3D sampler, vec3 P, ivec3 offset); +ivec4 textureOffset(isampler3D sampler, vec3 P, ivec3 offset); +uvec4 textureOffset(usampler3D sampler, vec3 P, ivec3 offset); + +float textureOffset(sampler1DShadow sampler, vec3 P, int offset); +float textureOffset(sampler2DShadow sampler, vec3 P, ivec2 offset); + + vec4 textureOffset( sampler1DArray sampler, vec2 P, int offset); +ivec4 textureOffset(isampler1DArray sampler, vec2 P, int offset); +uvec4 textureOffset(usampler1DArray sampler, vec2 P, int offset); + + vec4 textureOffset( sampler2DArray sampler, vec3 P, ivec2 offset); +ivec4 textureOffset(isampler2DArray sampler, vec3 P, ivec2 offset); +uvec4 textureOffset(usampler2DArray sampler, vec3 P, ivec2 offset); + +float textureOffset(sampler1DArrayShadow sampler, vec3 P, int offset); + +/* textureOffset - bias variants */ + vec4 textureOffset( sampler1D sampler, float P, int offset, float bias); +ivec4 textureOffset(isampler1D sampler, float P, int offset, float bias); +uvec4 textureOffset(usampler1D sampler, float P, int offset, float bias); + + vec4 textureOffset( sampler2D sampler, vec2 P, ivec2 offset, float bias); +ivec4 textureOffset(isampler2D sampler, vec2 P, ivec2 offset, float bias); +uvec4 textureOffset(usampler2D sampler, vec2 P, ivec2 offset, float bias); + + vec4 textureOffset( sampler3D sampler, vec3 P, ivec3 offset, float bias); +ivec4 textureOffset(isampler3D sampler, vec3 P, ivec3 offset, float bias); +uvec4 textureOffset(usampler3D sampler, vec3 P, ivec3 offset, float bias); + +float textureOffset(sampler1DShadow sampler, vec3 P, int offset, float bias); +float textureOffset(sampler2DShadow sampler, vec3 P, ivec2 offset, float bias); + + vec4 textureOffset( sampler1DArray sampler, vec2 P, int offset, float bias); +ivec4 textureOffset(isampler1DArray sampler, vec2 P, int offset, float bias); +uvec4 textureOffset(usampler1DArray sampler, vec2 P, int offset, float bias); + + vec4 textureOffset( sampler2DArray sampler, vec3 P, ivec2 offset, float bias); +ivec4 textureOffset(isampler2DArray sampler, vec3 P, ivec2 offset, float bias); +uvec4 textureOffset(usampler2DArray sampler, vec3 P, ivec2 offset, float bias); + +float textureOffset(sampler1DArrayShadow samp, vec3 P, int offset, float bias); + +/* texelFetch */ + vec4 texelFetch( sampler1D sampler, int P, int lod); +ivec4 texelFetch(isampler1D sampler, int P, int lod); +uvec4 texelFetch(usampler1D sampler, int P, int lod); + + vec4 texelFetch( sampler2D sampler, ivec2 P, int lod); +ivec4 texelFetch(isampler2D sampler, ivec2 P, int lod); +uvec4 texelFetch(usampler2D sampler, ivec2 P, int lod); + + vec4 texelFetch( sampler3D sampler, ivec3 P, int lod); +ivec4 texelFetch(isampler3D sampler, ivec3 P, int lod); +uvec4 texelFetch(usampler3D sampler, ivec3 P, int lod); + + vec4 texelFetch( sampler1DArray sampler, ivec2 P, int lod); +ivec4 texelFetch(isampler1DArray sampler, ivec2 P, int lod); +uvec4 texelFetch(usampler1DArray sampler, ivec2 P, int lod); + + vec4 texelFetch( sampler2DArray sampler, ivec3 P, int lod); +ivec4 texelFetch(isampler2DArray sampler, ivec3 P, int lod); +uvec4 texelFetch(usampler2DArray sampler, ivec3 P, int lod); + +/* texelFetchOffset */ + vec4 texelFetchOffset( sampler1D sampler, int P, int lod, int offset); +ivec4 texelFetchOffset(isampler1D sampler, int P, int lod, int offset); +uvec4 texelFetchOffset(usampler1D sampler, int P, int lod, int offset); + + vec4 texelFetchOffset( sampler2D sampler, ivec2 P, int lod, ivec2 offset); +ivec4 texelFetchOffset(isampler2D sampler, ivec2 P, int lod, ivec2 offset); +uvec4 texelFetchOffset(usampler2D sampler, ivec2 P, int lod, ivec2 offset); + + vec4 texelFetchOffset( sampler3D sampler, ivec3 P, int lod, ivec3 offset); +ivec4 texelFetchOffset(isampler3D sampler, ivec3 P, int lod, ivec3 offset); +uvec4 texelFetchOffset(usampler3D sampler, ivec3 P, int lod, ivec3 offset); + + vec4 texelFetchOffset( sampler1DArray sampler, ivec2 P, int lod, int offset); +ivec4 texelFetchOffset(isampler1DArray sampler, ivec2 P, int lod, int offset); +uvec4 texelFetchOffset(usampler1DArray sampler, ivec2 P, int lod, int offset); + + vec4 texelFetchOffset( sampler2DArray sampler, ivec3 P, int lod, ivec2 offset); +ivec4 texelFetchOffset(isampler2DArray sampler, ivec3 P, int lod, ivec2 offset); +uvec4 texelFetchOffset(usampler2DArray sampler, ivec3 P, int lod, ivec2 offset); + +/* textureProjOffset - no bias */ + vec4 textureProj( sampler1D sampler, vec2 P, int offset); +ivec4 textureProj(isampler1D sampler, vec2 P, int offset); +uvec4 textureProj(usampler1D sampler, vec2 P, int offset); + vec4 textureProj( sampler1D sampler, vec4 P, int offset); +ivec4 textureProj(isampler1D sampler, vec4 P, int offset); +uvec4 textureProj(usampler1D sampler, vec4 P, int offset); + + vec4 textureProj( sampler2D sampler, vec3 P, ivec2 offset); +ivec4 textureProj(isampler2D sampler, vec3 P, ivec2 offset); +uvec4 textureProj(usampler2D sampler, vec3 P, ivec2 offset); + vec4 textureProj( sampler2D sampler, vec4 P, ivec2 offset); +ivec4 textureProj(isampler2D sampler, vec4 P, ivec2 offset); +uvec4 textureProj(usampler2D sampler, vec4 P, ivec2 offset); + + vec4 textureProj( sampler3D sampler, vec4 P, ivec3 offset); +ivec4 textureProj(isampler3D sampler, vec4 P, ivec3 offset); +uvec4 textureProj(usampler3D sampler, vec4 P, ivec3 offset); + +float textureProj(sampler1DShadow sampler, vec4 P, int offset); +float textureProj(sampler2DShadow sampler, vec4 P, ivec2 offset); + +/* textureProjOffset - bias variants */ + vec4 textureProj( sampler1D sampler, vec2 P, int offset, float bias); +ivec4 textureProj(isampler1D sampler, vec2 P, int offset, float bias); +uvec4 textureProj(usampler1D sampler, vec2 P, int offset, float bias); + vec4 textureProj( sampler1D sampler, vec4 P, int offset, float bias); +ivec4 textureProj(isampler1D sampler, vec4 P, int offset, float bias); +uvec4 textureProj(usampler1D sampler, vec4 P, int offset, float bias); + + vec4 textureProj( sampler2D sampler, vec3 P, ivec2 offset, float bias); +ivec4 textureProj(isampler2D sampler, vec3 P, ivec2 offset, float bias); +uvec4 textureProj(usampler2D sampler, vec3 P, ivec2 offset, float bias); + vec4 textureProj( sampler2D sampler, vec4 P, ivec2 offset, float bias); +ivec4 textureProj(isampler2D sampler, vec4 P, ivec2 offset, float bias); +uvec4 textureProj(usampler2D sampler, vec4 P, ivec2 offset, float bias); + + vec4 textureProj( sampler3D sampler, vec4 P, ivec3 offset, float bias); +ivec4 textureProj(isampler3D sampler, vec4 P, ivec3 offset, float bias); +uvec4 textureProj(usampler3D sampler, vec4 P, ivec3 offset, float bias); + +float textureProj(sampler1DShadow sampler, vec4 P, int offset, float bias); +float textureProj(sampler2DShadow sampler, vec4 P, ivec2 offset, float bias); + +/* textureLodOffset */ + vec4 textureLodOffset( sampler1D sampler, float P, float lod, int offset); +ivec4 textureLodOffset(isampler1D sampler, float P, float lod, int offset); +uvec4 textureLodOffset(usampler1D sampler, float P, float lod, int offset); + + vec4 textureLodOffset( sampler2D sampler, vec2 P, float lod, ivec2 offset); +ivec4 textureLodOffset(isampler2D sampler, vec2 P, float lod, ivec2 offset); +uvec4 textureLodOffset(usampler2D sampler, vec2 P, float lod, ivec2 offset); + + vec4 textureLodOffset( sampler3D sampler, vec3 P, float lod, ivec3 offset); +ivec4 textureLodOffset(isampler3D sampler, vec3 P, float lod, ivec3 offset); +uvec4 textureLodOffset(usampler3D sampler, vec3 P, float lod, ivec3 offset); + +float textureLodOffset(sampler1DShadow samp, vec3 P, float lod, int offset); +float textureLodOffset(sampler2DShadow samp, vec3 P, float lod, ivec2 offset); + + vec4 textureLodOffset( sampler1DArray sampler, vec2 P, float lod, int offset); +ivec4 textureLodOffset(isampler1DArray sampler, vec2 P, float lod, int offset); +uvec4 textureLodOffset(usampler1DArray sampler, vec2 P, float lod, int offset); + + vec4 textureLodOffset( sampler2DArray samp, vec3 P, float lod, ivec2 offset); +ivec4 textureLodOffset(isampler2DArray samp, vec3 P, float lod, ivec2 offset); +uvec4 textureLodOffset(usampler2DArray samp, vec3 P, float lod, ivec2 offset); + +float textureLodOffset(sampler1DArrayShadow s, vec3 P, float lod, int offset); + +/* textureProjLod */ + vec4 textureProjLod( sampler1D sampler, vec2 P, float lod); +ivec4 textureProjLod(isampler1D sampler, vec2 P, float lod); +uvec4 textureProjLod(usampler1D sampler, vec2 P, float lod); + vec4 textureProjLod( sampler1D sampler, vec4 P, float lod); +ivec4 textureProjLod(isampler1D sampler, vec4 P, float lod); +uvec4 textureProjLod(usampler1D sampler, vec4 P, float lod); + + vec4 textureProjLod( sampler2D sampler, vec3 P, float lod); +ivec4 textureProjLod(isampler2D sampler, vec3 P, float lod); +uvec4 textureProjLod(usampler2D sampler, vec3 P, float lod); + vec4 textureProjLod( sampler2D sampler, vec4 P, float lod); +ivec4 textureProjLod(isampler2D sampler, vec4 P, float lod); +uvec4 textureProjLod(usampler2D sampler, vec4 P, float lod); + + vec4 textureProjLod( sampler3D sampler, vec4 P, float lod); +ivec4 textureProjLod(isampler3D sampler, vec4 P, float lod); +uvec4 textureProjLod(usampler3D sampler, vec4 P, float lod); + +float textureProjLod(sampler1DShadow sampler, vec4 P, float lod); +float textureProjLod(sampler2DShadow sampler, vec4 P, float lod); + +/* textureProjLodOffset */ + vec4 textureProjLodOffset( sampler1D sampler, vec2 P, float lod, int offset); +ivec4 textureProjLodOffset(isampler1D sampler, vec2 P, float lod, int offset); +uvec4 textureProjLodOffset(usampler1D sampler, vec2 P, float lod, int offset); + vec4 textureProjLodOffset( sampler1D sampler, vec4 P, float lod, int offset); +ivec4 textureProjLodOffset(isampler1D sampler, vec4 P, float lod, int offset); +uvec4 textureProjLodOffset(usampler1D sampler, vec4 P, float lod, int offset); + + vec4 textureProjLodOffset( sampler2D sampler, vec3 P, float lod, ivec2 offset); +ivec4 textureProjLodOffset(isampler2D sampler, vec3 P, float lod, ivec2 offset); +uvec4 textureProjLodOffset(usampler2D sampler, vec3 P, float lod, ivec2 offset); + vec4 textureProjLodOffset( sampler2D sampler, vec4 P, float lod, ivec2 offset); +ivec4 textureProjLodOffset(isampler2D sampler, vec4 P, float lod, ivec2 offset); +uvec4 textureProjLodOffset(usampler2D sampler, vec4 P, float lod, ivec2 offset); + + vec4 textureProjLodOffset( sampler3D sampler, vec4 P, float lod, ivec3 offset); +ivec4 textureProjLodOffset(isampler3D sampler, vec4 P, float lod, ivec3 offset); +uvec4 textureProjLodOffset(usampler3D sampler, vec4 P, float lod, ivec3 offset); + +float textureProjLodOffset(sampler1DShadow s, vec4 P, float lod, int offset); +float textureProjLodOffset(sampler2DShadow s, vec4 P, float lod, ivec2 offset); + +/* textureGrad */ + vec4 textureGrad( sampler1D sampler, float P, float dPdx, float dPdy); +ivec4 textureGrad(isampler1D sampler, float P, float dPdx, float dPdy); +uvec4 textureGrad(usampler1D sampler, float P, float dPdx, float dPdy); + + vec4 textureGrad( sampler2D sampler, vec2 P, vec2 dPdx, vec2 dPdy); +ivec4 textureGrad(isampler2D sampler, vec2 P, vec2 dPdx, vec2 dPdy); +uvec4 textureGrad(usampler2D sampler, vec2 P, vec2 dPdx, vec2 dPdy); + + vec4 textureGrad( sampler3D sampler, vec3 P, vec3 dPdx, vec3 dPdy); +ivec4 textureGrad(isampler3D sampler, vec3 P, vec3 dPdx, vec3 dPdy); +uvec4 textureGrad(usampler3D sampler, vec3 P, vec3 dPdx, vec3 dPdy); + + vec4 textureGrad( samplerCube sampler, vec3 P, vec3 dPdx, vec3 dPdy); +ivec4 textureGrad(isamplerCube sampler, vec3 P, vec3 dPdx, vec3 dPdy); +uvec4 textureGrad(usamplerCube sampler, vec3 P, vec3 dPdx, vec3 dPdy); + +float textureGrad(sampler1DShadow sampler, vec3 P, float dPdx, float dPdy); +float textureGrad(sampler2DShadow sampler, vec3 P, vec2 dPdx, vec2 dPdy); +float textureGrad(samplerCubeShadow sampler, vec4 P, vec3 dPdx, vec3 dPdy); + + vec4 textureGrad( sampler1DArray sampler, vec2 P, float dPdx, float dPdy); +ivec4 textureGrad(isampler1DArray sampler, vec2 P, float dPdx, float dPdy); +uvec4 textureGrad(usampler1DArray sampler, vec2 P, float dPdx, float dPdy); + + vec4 textureGrad( sampler2DArray sampler, vec3 P, vec2 dPdx, vec2 dPdy); +ivec4 textureGrad(isampler2DArray sampler, vec3 P, vec2 dPdx, vec2 dPdy); +uvec4 textureGrad(usampler2DArray sampler, vec3 P, vec2 dPdx, vec2 dPdy); + +float textureGrad(sampler1DArrayShadow sampler, vec3 P, float dPdx, float dPdy); +float textureGrad(sampler2DArrayShadow sampler, vec4 P, vec2 dPdx, vec2 dPdy); + +/* textureGradOffset */ + vec4 textureGradOffset( sampler1D s, float P, float dx, float dy, int off); +ivec4 textureGradOffset(isampler1D s, float P, float dx, float dy, int offset); +uvec4 textureGradOffset(usampler1D s, float P, float dx, float dy, int offset); + + vec4 textureGradOffset( sampler2D s, vec2 P, vec2 dx, vec2 dy, ivec2 offset); +ivec4 textureGradOffset(isampler2D s, vec2 P, vec2 dx, vec2 dy, ivec2 offset); +uvec4 textureGradOffset(usampler2D s, vec2 P, vec2 dx, vec2 dy, ivec2 offset); + + vec4 textureGradOffset( sampler3D s, vec3 P, vec3 dx, vec3 dy, ivec3 offset); +ivec4 textureGradOffset(isampler3D s, vec3 P, vec3 dx, vec3 dy, ivec3 offset); +uvec4 textureGradOffset(usampler3D s, vec3 P, vec3 dx, vec3 dy, ivec3 offset); + + vec4 textureGradOffset( samplerCube s, vec3 P, vec3 dx, vec3 dy, ivec3 offset); +ivec4 textureGradOffset(isamplerCube s, vec3 P, vec3 dx, vec3 dy, ivec3 offset); +uvec4 textureGradOffset(usamplerCube s, vec3 P, vec3 dx, vec3 dy, ivec3 offset); + +float textureGradOffset(sampler1DShadow s, vec3 P, float dx, float dy, int off); +float textureGradOffset(sampler2DShadow s, vec3 P, vec2 dx, vec2 dy, ivec2 off); + + vec4 textureGradOffset( sampler1DArray s, vec2 P, float dx, float dy, int off); +ivec4 textureGradOffset(isampler1DArray s, vec2 P, float dx, float dy, int off); +uvec4 textureGradOffset(usampler1DArray s, vec2 P, float dx, float dy, int off); + + vec4 textureGradOffset( sampler2DArray s, vec3 P, vec2 dx, vec2 dy, ivec2 off); +ivec4 textureGradOffset(isampler2DArray s, vec3 P, vec2 dx, vec2 dy, ivec2 off); +uvec4 textureGradOffset(usampler2DArray s, vec3 P, vec2 dx, vec2 dy, ivec2 off); + +float textureGradOffset(sampler1DArrayShadow s, vec3 P, float dx, float dy, int o); +float textureGradOffset(sampler2DArrayShadow s, vec4 P, vec2 dx, vec2 dy, ivec2 o); + +/* textureProjGrad */ + vec4 textureProjGrad( sampler1D sampler, vec2 P, float dPdx, float dPdy); +ivec4 textureProjGrad(isampler1D sampler, vec2 P, float dPdx, float dPdy); +uvec4 textureProjGrad(usampler1D sampler, vec2 P, float dPdx, float dPdy); + vec4 textureProjGrad( sampler1D sampler, vec4 P, float dPdx, float dPdy); +ivec4 textureProjGrad(isampler1D sampler, vec4 P, float dPdx, float dPdy); +uvec4 textureProjGrad(usampler1D sampler, vec4 P, float dPdx, float dPdy); + + vec4 textureProjGrad( sampler2D sampler, vec3 P, vec2 dPdx, vec2 dPdy); +ivec4 textureProjGrad(isampler2D sampler, vec3 P, vec2 dPdx, vec2 dPdy); +uvec4 textureProjGrad(usampler2D sampler, vec3 P, vec2 dPdx, vec2 dPdy); + vec4 textureProjGrad( sampler2D sampler, vec4 P, vec2 dPdx, vec2 dPdy); +ivec4 textureProjGrad(isampler2D sampler, vec4 P, vec2 dPdx, vec2 dPdy); +uvec4 textureProjGrad(usampler2D sampler, vec4 P, vec2 dPdx, vec2 dPdy); + + vec4 textureProjGrad( sampler3D sampler, vec4 P, vec3 dPdx, vec3 dPdy); +ivec4 textureProjGrad(isampler3D sampler, vec4 P, vec3 dPdx, vec3 dPdy); +uvec4 textureProjGrad(usampler3D sampler, vec4 P, vec3 dPdx, vec3 dPdy); + +float textureProjGrad(sampler1DShadow sampler, vec4 P, float dPdx, float dPdy); +float textureProjGrad(sampler2DShadow sampler, vec4 P, vec2 dPdx, vec2 dPdy); + +/* textureProjGradOffset */ + vec4 textureProjGradOffset( sampler1D s, vec2 P, float dx, float dy, int off); +ivec4 textureProjGradOffset(isampler1D s, vec2 P, float dx, float dy, int off); +uvec4 textureProjGradOffset(usampler1D s, vec2 P, float dx, float dy, int off); + vec4 textureProjGradOffset( sampler1D s, vec4 P, float dx, float dy, int off); +ivec4 textureProjGradOffset(isampler1D s, vec4 P, float dx, float dy, int off); +uvec4 textureProjGradOffset(usampler1D s, vec4 P, float dx, float dy, int off); + + vec4 textureProjGradOffset( sampler2D s, vec3 P, vec2 dx, vec2 dy, ivec2 off); +ivec4 textureProjGradOffset(isampler2D s, vec3 P, vec2 dx, vec2 dy, ivec2 off); +uvec4 textureProjGradOffset(usampler2D s, vec3 P, vec2 dx, vec2 dy, ivec2 off); + vec4 textureProjGradOffset( sampler2D s, vec4 P, vec2 dx, vec2 dy, ivec2 off); +ivec4 textureProjGradOffset(isampler2D s, vec4 P, vec2 dx, vec2 dy, ivec2 off); +uvec4 textureProjGradOffset(usampler2D s, vec4 P, vec2 dx, vec2 dy, ivec2 off); + + vec4 textureProjGradOffset( sampler3D s, vec4 P, vec3 dx, vec3 dy, ivec3 off); +ivec4 textureProjGradOffset(isampler3D s, vec4 P, vec3 dx, vec3 dy, ivec3 off); +uvec4 textureProjGradOffset(usampler3D s, vec4 P, vec3 dx, vec3 dy, ivec3 off); + +float textureProjGradOffset(sampler1DShadow s, vec4 P, float dx, float dy, int o); +float textureProjGradOffset(sampler2DShadow s, vec4 P, vec2 dx, vec2 dy, vec2 o); + +/* + * The following texture functions are deprecated: + */ +vec4 texture1D (sampler1D sampler, float coord); +vec4 texture1DProj (sampler1D sampler, vec2 coord); +vec4 texture1DProj (sampler1D sampler, vec4 coord); +vec4 texture1D (sampler1D sampler, float coord, float bias); +vec4 texture1DProj (sampler1D sampler, vec2 coord, float bias); +vec4 texture1DProj (sampler1D sampler, vec4 coord, float bias); +vec4 texture1DLod (sampler1D sampler, float coord, float lod); +vec4 texture1DProjLod(sampler1D sampler, vec2 coord, float lod); +vec4 texture1DProjLod(sampler1D sampler, vec4 coord, float lod); + +vec4 texture2D (sampler2D sampler, vec2 coord); +vec4 texture2DProj (sampler2D sampler, vec3 coord); +vec4 texture2DProj (sampler2D sampler, vec4 coord); +vec4 texture2D (sampler2D sampler, vec2 coord, float bias); +vec4 texture2DProj (sampler2D sampler, vec3 coord, float bias); +vec4 texture2DProj (sampler2D sampler, vec4 coord, float bias); +vec4 texture2DLod (sampler2D sampler, vec2 coord, float lod); +vec4 texture2DProjLod(sampler2D sampler, vec3 coord, float lod); +vec4 texture2DProjLod(sampler2D sampler, vec4 coord, float lod); + +vec4 texture3D (sampler3D sampler, vec3 coord); +vec4 texture3DProj (sampler3D sampler, vec4 coord); +vec4 texture3D (sampler3D sampler, vec3 coord, float bias); +vec4 texture3DProj (sampler3D sampler, vec4 coord, float bias); +vec4 texture3DLod (sampler3D sampler, vec3 coord, float lod); +vec4 texture3DProjLod(sampler3D sampler, vec4 coord, float lod); + +vec4 textureCube (samplerCube sampler, vec3 coord); +vec4 textureCube (samplerCube sampler, vec3 coord, float bias); +vec4 textureCubeLod (samplerCube sampler, vec3 coord, float lod); + +vec4 shadow1D (sampler1DShadow sampler, vec3 coord); +vec4 shadow2D (sampler2DShadow sampler, vec3 coord); +vec4 shadow1DProj (sampler1DShadow sampler, vec4 coord); +vec4 shadow2DProj (sampler2DShadow sampler, vec4 coord); +vec4 shadow1D (sampler1DShadow sampler, vec3 coord, float bias); +vec4 shadow2D (sampler2DShadow sampler, vec3 coord, float bias); +vec4 shadow1DProj (sampler1DShadow sampler, vec4 coord, float bias); +vec4 shadow2DProj (sampler2DShadow sampler, vec4 coord, float bias); +vec4 shadow1DLod (sampler1DShadow sampler, vec3 coord, float lod); +vec4 shadow2DLod (sampler2DShadow sampler, vec3 coord, float lod); +vec4 shadow1DProjLod(sampler1DShadow sampler, vec4 coord, float lod); +vec4 shadow2DProjLod(sampler2DShadow sampler, vec4 coord, float lod); + +/* + * 8.8 - Fragment Processing Functions (none in vertex shader) + */ + +/* + * 8.9 - Noise Functions + */ +float noise1(float x); +float noise1(vec2 x); +float noise1(vec3 x); +float noise1(vec4 x); + +vec2 noise2(float x); +vec2 noise2(vec2 x); +vec2 noise2(vec3 x); +vec2 noise2(vec4 x); + +vec3 noise3(float x); +vec3 noise3(vec2 x); +vec3 noise3(vec3 x); +vec3 noise3(vec4 x); + +vec4 noise4(float x); +vec4 noise4(vec2 x); +vec4 noise4(vec3 x); +vec4 noise4(vec4 x); diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/profiles/ARB_shader_texture_lod.frag b/3rdparty/glsl-optimizer/src/glsl/builtins/profiles/ARB_shader_texture_lod.frag new file mode 100644 index 000000000..c15e2a10a --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/profiles/ARB_shader_texture_lod.frag @@ -0,0 +1,64 @@ +/* + * The existing isotropic vertex texture functions are added to the + * built-in functions for fragment shaders. + */ +vec4 texture1DLod (sampler1D sampler, float coord, float lod); +vec4 texture1DProjLod(sampler1D sampler, vec2 coord, float lod); +vec4 texture1DProjLod(sampler1D sampler, vec4 coord, float lod); +vec4 texture2DLod (sampler2D sampler, vec2 coord, float lod); +vec4 texture2DProjLod(sampler2D sampler, vec3 coord, float lod); +vec4 texture2DProjLod(sampler2D sampler, vec4 coord, float lod); +vec4 texture3DLod (sampler3D sampler, vec3 coord, float lod); +vec4 texture3DProjLod(sampler3D sampler, vec4 coord, float lod); +vec4 textureCubeLod (samplerCube sampler, vec3 coord, float lod); +vec4 shadow1DLod (sampler1DShadow sampler, vec3 coord, float lod); +vec4 shadow2DLod (sampler2DShadow sampler, vec3 coord, float lod); +vec4 shadow1DProjLod(sampler1DShadow sampler, vec4 coord, float lod); +vec4 shadow2DProjLod(sampler2DShadow sampler, vec4 coord, float lod); + +/* New anisotropic texture functions, providing explicit derivatives: */ +vec4 texture1DGradARB (sampler1D sampler, + float P, float dPdx, float dPdy); +vec4 texture1DProjGradARB (sampler1D sampler, + vec2 P, float dPdx, float dPdy); +vec4 texture1DProjGradARB (sampler1D sampler, + vec4 P, float dPdx, float dPdy); + +vec4 texture2DGradARB (sampler2D sampler, + vec2 P, vec2 dPdx, vec2 dPdy); +vec4 texture2DProjGradARB (sampler2D sampler, + vec3 P, vec2 dPdx, vec2 dPdy); +vec4 texture2DProjGradARB (sampler2D sampler, + vec4 P, vec2 dPdx, vec2 dPdy); + +vec4 texture3DGradARB (sampler3D sampler, + vec3 P, vec3 dPdx, vec3 dPdy); +vec4 texture3DProjGradARB (sampler3D sampler, + vec4 P, vec3 dPdx, vec3 dPdy); + +vec4 textureCubeGradARB (samplerCube sampler, + vec3 P, vec3 dPdx, vec3 dPdy); + +vec4 shadow1DGradARB (sampler1DShadow sampler, + vec3 P, float dPdx, float dPdy); +vec4 shadow1DProjGradARB (sampler1DShadow sampler, + vec4 P, float dPdx, float dPdy); + +vec4 shadow2DGradARB (sampler2DShadow sampler, + vec3 P, vec2 dPdx, vec2 dPdy); +vec4 shadow2DProjGradARB (sampler2DShadow sampler, + vec4 P, vec2 dPdx, vec2 dPdy); + +#ifdef GL_ARB_texture_rectangle +vec4 texture2DRectGradARB (sampler2DRect sampler, + vec2 P, vec2 dPdx, vec2 dPdy); +vec4 texture2DRectProjGradARB(sampler2DRect sampler, + vec3 P, vec2 dPdx, vec2 dPdy); +vec4 texture2DRectProjGradARB(sampler2DRect sampler, + vec4 P, vec2 dPdx, vec2 dPdy); + +vec4 shadow2DRectGradARB (sampler2DRectShadow sampler, + vec3 P, vec2 dPdx, vec2 dPdy); +vec4 shadow2DRectProjGradARB (sampler2DRectShadow sampler, + vec4 P, vec2 dPdx, vec2 dPdy); +#endif diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/profiles/ARB_shader_texture_lod.vert b/3rdparty/glsl-optimizer/src/glsl/builtins/profiles/ARB_shader_texture_lod.vert new file mode 100644 index 000000000..edfed26fc --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/profiles/ARB_shader_texture_lod.vert @@ -0,0 +1,46 @@ +/* New anisotropic texture functions, providing explicit derivatives: */ +vec4 texture1DGradARB (sampler1D sampler, + float P, float dPdx, float dPdy); +vec4 texture1DProjGradARB (sampler1D sampler, + vec2 P, float dPdx, float dPdy); +vec4 texture1DProjGradARB (sampler1D sampler, + vec4 P, float dPdx, float dPdy); + +vec4 texture2DGradARB (sampler2D sampler, + vec2 P, vec2 dPdx, vec2 dPdy); +vec4 texture2DProjGradARB (sampler2D sampler, + vec3 P, vec2 dPdx, vec2 dPdy); +vec4 texture2DProjGradARB (sampler2D sampler, + vec4 P, vec2 dPdx, vec2 dPdy); + +vec4 texture3DGradARB (sampler3D sampler, + vec3 P, vec3 dPdx, vec3 dPdy); +vec4 texture3DProjGradARB (sampler3D sampler, + vec4 P, vec3 dPdx, vec3 dPdy); + +vec4 textureCubeGradARB (samplerCube sampler, + vec3 P, vec3 dPdx, vec3 dPdy); + +vec4 shadow1DGradARB (sampler1DShadow sampler, + vec3 P, float dPdx, float dPdy); +vec4 shadow1DProjGradARB (sampler1DShadow sampler, + vec4 P, float dPdx, float dPdy); + +vec4 shadow2DGradARB (sampler2DShadow sampler, + vec3 P, vec2 dPdx, vec2 dPdy); +vec4 shadow2DProjGradARB (sampler2DShadow sampler, + vec4 P, vec2 dPdx, vec2 dPdy); + +#ifdef GL_ARB_texture_rectangle +vec4 texture2DRectGradARB (sampler2DRect sampler, + vec2 P, vec2 dPdx, vec2 dPdy); +vec4 texture2DRectProjGradARB(sampler2DRect sampler, + vec3 P, vec2 dPdx, vec2 dPdy); +vec4 texture2DRectProjGradARB(sampler2DRect sampler, + vec4 P, vec2 dPdx, vec2 dPdy); + +vec4 shadow2DRectGradARB (sampler2DRectShadow sampler, + vec3 P, vec2 dPdx, vec2 dPdy); +vec4 shadow2DRectProjGradARB (sampler2DRectShadow sampler, + vec4 P, vec2 dPdx, vec2 dPdy); +#endif diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/profiles/ARB_texture_rectangle.frag b/3rdparty/glsl-optimizer/src/glsl/builtins/profiles/ARB_texture_rectangle.frag new file mode 100644 index 000000000..8938aa3e9 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/profiles/ARB_texture_rectangle.frag @@ -0,0 +1,7 @@ +#extension GL_ARB_texture_rectangle : enable +vec4 texture2DRect(sampler2DRect sampler, vec2 coord); +vec4 texture2DRectProj(sampler2DRect sampler, vec3 coord); +vec4 texture2DRectProj(sampler2DRect sampler, vec4 coord); + +vec4 shadow2DRect(sampler2DRectShadow sampler, vec3 coord); +vec4 shadow2DRectProj(sampler2DRectShadow sampler, vec4 coord); diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/profiles/ARB_texture_rectangle.vert b/3rdparty/glsl-optimizer/src/glsl/builtins/profiles/ARB_texture_rectangle.vert new file mode 100644 index 000000000..8938aa3e9 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/profiles/ARB_texture_rectangle.vert @@ -0,0 +1,7 @@ +#extension GL_ARB_texture_rectangle : enable +vec4 texture2DRect(sampler2DRect sampler, vec2 coord); +vec4 texture2DRectProj(sampler2DRect sampler, vec3 coord); +vec4 texture2DRectProj(sampler2DRect sampler, vec4 coord); + +vec4 shadow2DRect(sampler2DRectShadow sampler, vec3 coord); +vec4 shadow2DRectProj(sampler2DRectShadow sampler, vec4 coord); diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/profiles/EXT_shader_texture_lod.frag b/3rdparty/glsl-optimizer/src/glsl/builtins/profiles/EXT_shader_texture_lod.frag new file mode 100644 index 000000000..689d713c3 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/profiles/EXT_shader_texture_lod.frag @@ -0,0 +1,19 @@ +/* + * The existing isotropic vertex texture functions are added to the + * built-in functions for fragment shaders. + */ +vec4 texture2DLodEXT (sampler2D sampler, vec2 coord, float lod); +vec4 texture2DProjLodEXT(sampler2D sampler, vec3 coord, float lod); +vec4 texture2DProjLodEXT(sampler2D sampler, vec4 coord, float lod); +vec4 textureCubeLodEXT (samplerCube sampler, vec3 coord, float lod); + +/* New anisotropic texture functions, providing explicit derivatives: */ +vec4 texture2DGradEXT (sampler2D sampler, + vec2 P, vec2 dPdx, vec2 dPdy); +vec4 texture2DProjGradEXT (sampler2D sampler, + vec3 P, vec2 dPdx, vec2 dPdy); +vec4 texture2DProjGradEXT (sampler2D sampler, + vec4 P, vec2 dPdx, vec2 dPdy); + +vec4 textureCubeGradEXT (samplerCube sampler, + vec3 P, vec3 dPdx, vec3 dPdy); diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/profiles/EXT_shader_texture_lod.vert b/3rdparty/glsl-optimizer/src/glsl/builtins/profiles/EXT_shader_texture_lod.vert new file mode 100644 index 000000000..5d2d20b29 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/profiles/EXT_shader_texture_lod.vert @@ -0,0 +1,10 @@ +/* New anisotropic texture functions, providing explicit derivatives: */ +vec4 texture2DGradEXT (sampler2D sampler, + vec2 P, vec2 dPdx, vec2 dPdy); +vec4 texture2DProjGradEXT (sampler2D sampler, + vec3 P, vec2 dPdx, vec2 dPdy); +vec4 texture2DProjGradEXT (sampler2D sampler, + vec4 P, vec2 dPdx, vec2 dPdy); + +vec4 textureCubeGradEXT (samplerCube sampler, + vec3 P, vec3 dPdx, vec3 dPdy); \ No newline at end of file diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/profiles/EXT_texture_array.frag b/3rdparty/glsl-optimizer/src/glsl/builtins/profiles/EXT_texture_array.frag new file mode 100644 index 000000000..d0ce981dd --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/profiles/EXT_texture_array.frag @@ -0,0 +1,11 @@ +#extension GL_EXT_texture_array : enable +vec4 texture1DArray(sampler1DArray sampler, vec2 coord); +vec4 texture1DArray(sampler1DArray sampler, vec2 coord, float bias); + +vec4 texture2DArray(sampler2DArray sampler, vec3 coord); +vec4 texture2DArray(sampler2DArray sampler, vec3 coord, float bias); + +vec4 shadow1DArray(sampler1DArrayShadow sampler, vec3 coord); +vec4 shadow1DArray(sampler1DArrayShadow sampler, vec3 coord, float bias); + +vec4 shadow2DArray(sampler2DArrayShadow sampler, vec4 coord); diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/profiles/EXT_texture_array.vert b/3rdparty/glsl-optimizer/src/glsl/builtins/profiles/EXT_texture_array.vert new file mode 100644 index 000000000..6b1b7f2f1 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/profiles/EXT_texture_array.vert @@ -0,0 +1,11 @@ +#extension GL_EXT_texture_array : enable +vec4 texture1DArray(sampler1DArray sampler, vec2 coord); +vec4 texture1DArrayLod(sampler1DArray sampler, vec2 coord, float lod); + +vec4 texture2DArray(sampler2DArray sampler, vec3 coord); +vec4 texture2DArrayLod(sampler2DArray sampler, vec3 coord, float lod); + +vec4 shadow1DArray(sampler1DArrayShadow sampler, vec3 coord); +vec4 shadow1DArrayLod(sampler1DArrayShadow sampler, vec3 coord, float lod); + +vec4 shadow2DArray(sampler2DArrayShadow sampler, vec4 coord); diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/profiles/OES_standard_derivatives.frag b/3rdparty/glsl-optimizer/src/glsl/builtins/profiles/OES_standard_derivatives.frag new file mode 100644 index 000000000..2c358ab16 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/profiles/OES_standard_derivatives.frag @@ -0,0 +1,17 @@ +#version 100 +#extension GL_OES_standard_derivatives : enable + +float dFdx(float p); +vec2 dFdx(vec2 p); +vec3 dFdx(vec3 p); +vec4 dFdx(vec4 p); + +float dFdy(float p); +vec2 dFdy(vec2 p); +vec3 dFdy(vec3 p); +vec4 dFdy(vec4 p); + +float fwidth(float p); +vec2 fwidth(vec2 p); +vec3 fwidth(vec3 p); +vec4 fwidth(vec4 p); diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/profiles/OES_texture_3D.frag b/3rdparty/glsl-optimizer/src/glsl/builtins/profiles/OES_texture_3D.frag new file mode 100644 index 000000000..b6ebd6a31 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/profiles/OES_texture_3D.frag @@ -0,0 +1,7 @@ +#version 100 +#extension GL_OES_texture_3D : enable + +vec4 texture3D (sampler3D sampler, vec3 coord); +vec4 texture3DProj (sampler3D sampler, vec4 coord); +vec4 texture3D (sampler3D sampler, vec3 coord, float bias); +vec4 texture3DProj (sampler3D sampler, vec4 coord, float bias); diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/profiles/OES_texture_3D.vert b/3rdparty/glsl-optimizer/src/glsl/builtins/profiles/OES_texture_3D.vert new file mode 100644 index 000000000..81d12f51e --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/profiles/OES_texture_3D.vert @@ -0,0 +1,7 @@ +#version 100 +#extension GL_OES_texture_3D : enable + +vec4 texture3D (sampler3D sampler, vec3 coord); +vec4 texture3DProj (sampler3D sampler, vec4 coord); +vec4 texture3DLod (sampler3D sampler, vec3 coord, float lod); +vec4 texture3DProjLod (sampler3D sampler, vec4 coord, float lod); diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/tools/generate_builtins.py b/3rdparty/glsl-optimizer/src/glsl/builtins/tools/generate_builtins.py new file mode 100644 index 000000000..17d528c21 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/tools/generate_builtins.py @@ -0,0 +1,261 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +from __future__ import with_statement + +import re +import sys +from glob import glob +from os import path +from subprocess import Popen, PIPE +from sys import argv + +# Local module: generator for texture lookup builtins +from texture_builtins import generate_texture_functions + +builtins_dir = path.join(path.dirname(path.abspath(__file__)), "..") + +# Get the path to the standalone GLSL compiler +if len(argv) != 2: + print "Usage:", argv[0], "" + sys.exit(1) + +compiler = argv[1] + +# Read the files in builtins/ir/*...add them to the supplied dictionary. +def read_ir_files(fs): + for filename in glob(path.join(path.join(builtins_dir, 'ir'), '*')): + with open(filename) as f: + fs[path.basename(filename)] = f.read() + +# Return a dictionary containing all builtin definitions (even generated) +def get_builtin_definitions(): + fs = {} + generate_texture_functions(fs) + read_ir_files(fs) + return fs + +def stringify(s): + # Work around MSVC's 65535 byte limit by outputting an array of characters + # rather than actual string literals. + if len(s) >= 65535: + #t = "/* Warning: length " + repr(len(s)) + " too large */\n" + t = "" + for c in re.sub('\s\s+', ' ', s): + if c == '\n': + t += '\n' + else: + t += "'" + c + "'," + return '{' + t[:-1] + '}' + + t = s.replace('\\', '\\\\').replace('"', '\\"').replace('\n', '\\n"\n "') + return ' "' + t + '"\n' + +def write_function_definitions(): + fs = get_builtin_definitions() + for k, v in sorted(fs.iteritems()): + print 'static const char builtin_' + k + '[] =' + print stringify(v), ';' + +def run_compiler(args): + command = [compiler, '--dump-lir'] + args + p = Popen(command, 1, stdout=PIPE, shell=False) + output = p.communicate()[0] + + # Clean up output a bit by killing whitespace before a closing paren. + kill_paren_whitespace = re.compile(r'[ \n]*\)', re.MULTILINE) + output = kill_paren_whitespace.sub(')', output) + + # Also toss any duplicate newlines + output = output.replace('\n\n', '\n') + + return (output, p.returncode) + +def write_profile(filename, profile): + (proto_ir, returncode) = run_compiler([filename]) + + if returncode != 0: + print '#error builtins profile', profile, 'failed to compile' + return + + # Kill any global variable declarations. We don't want them. + kill_globals = re.compile(r'^\(declare.*\n', re.MULTILINE) + proto_ir = kill_globals.sub('', proto_ir) + + print 'static const char prototypes_for_' + profile + '[] =' + print stringify(proto_ir), ';' + + # Print a table of all the functions (not signatures) referenced. + # This is done so we can avoid bothering with a hash table in the C++ code. + + function_names = set() + for func in re.finditer(r'\(function (.+)\n', proto_ir): + function_names.add(func.group(1)) + + print 'static const char *functions_for_' + profile + ' [] = {' + for func in sorted(function_names): + print ' builtin_' + func + ',' + print '};' + +def write_profiles(): + profiles = get_profile_list() + for (filename, profile) in profiles: + write_profile(filename, profile) + +def get_profile_list(): + profiles = [] + for pfile in sorted(glob(path.join(path.join(builtins_dir, 'profiles'), '*'))): + profiles.append((pfile, path.basename(pfile).replace('.', '_'))) + return profiles + +if __name__ == "__main__": + print """/* DO NOT MODIFY - automatically generated by generate_builtins.py */ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include +#include "main/core.h" /* for struct gl_shader */ +#include "glsl_parser_extras.h" +#include "ir_reader.h" +#include "program.h" +#include "ast.h" + +extern "C" struct gl_shader * +_mesa_new_shader(struct gl_context *ctx, GLuint name, GLenum type); + +gl_shader * +read_builtins(GLenum target, const char *protos, const char **functions, unsigned count) +{ + struct gl_context fakeCtx; + fakeCtx.API = API_OPENGL; + fakeCtx.Const.GLSLVersion = 130; + fakeCtx.Extensions.ARB_ES2_compatibility = true; + gl_shader *sh = _mesa_new_shader(NULL, 0, target); + struct _mesa_glsl_parse_state *st = + new(sh) _mesa_glsl_parse_state(&fakeCtx, target, sh); + + st->language_version = 130; + st->symbols->language_version = 130; + st->ARB_texture_rectangle_enable = true; + st->EXT_texture_array_enable = true; + _mesa_glsl_initialize_types(st); + + sh->ir = new(sh) exec_list; + sh->symbols = st->symbols; + + /* Read the IR containing the prototypes */ + _mesa_glsl_read_ir(st, sh->ir, protos, true); + + /* Read ALL the function bodies, telling the IR reader not to scan for + * prototypes (we've already created them). The IR reader will skip any + * signature that does not already exist as a prototype. + */ + for (unsigned i = 0; i < count; i++) { + _mesa_glsl_read_ir(st, sh->ir, functions[i], false); + + if (st->error) { + printf("error reading builtin: %.35s ...\\n", functions[i]); + printf("Info log:\\n%s\\n", st->info_log); + ralloc_free(sh); + return NULL; + } + } + + reparent_ir(sh->ir, sh); + delete st; + + return sh; +} +""" + + write_function_definitions() + write_profiles() + + profiles = get_profile_list() + + print 'static gl_shader *builtin_profiles[%d];' % len(profiles) + + print """ +void *builtin_mem_ctx = NULL; + +void +_mesa_glsl_release_functions(void) +{ + ralloc_free(builtin_mem_ctx); + builtin_mem_ctx = NULL; + memset(builtin_profiles, 0, sizeof(builtin_profiles)); +} + +static void +_mesa_read_profile(struct _mesa_glsl_parse_state *state, + int profile_index, + const char *prototypes, + const char **functions, + int count) +{ + gl_shader *sh = builtin_profiles[profile_index]; + + if (sh == NULL) { + sh = read_builtins(GL_VERTEX_SHADER, prototypes, functions, count); + ralloc_steal(builtin_mem_ctx, sh); + builtin_profiles[profile_index] = sh; + } + + state->builtins_to_link[state->num_builtins_to_link] = sh; + state->num_builtins_to_link++; +} + +void +_mesa_glsl_initialize_functions(struct _mesa_glsl_parse_state *state) +{ + if (builtin_mem_ctx == NULL) { + builtin_mem_ctx = ralloc_context(NULL); // "GLSL built-in functions" + memset(&builtin_profiles, 0, sizeof(builtin_profiles)); + } + + state->num_builtins_to_link = 0; +""" + + i = 0 + for (filename, profile) in profiles: + if profile.endswith('_vert'): + check = 'state->target == vertex_shader && ' + elif profile.endswith('_frag'): + check = 'state->target == fragment_shader && ' + + version = re.sub(r'_(vert|frag)$', '', profile) + if version.isdigit(): + check += 'state->language_version == ' + version + else: # an extension name + check += 'state->' + version + '_enable' + + print ' if (' + check + ') {' + print ' _mesa_read_profile(state, %d,' % i + print ' prototypes_for_' + profile + ',' + print ' functions_for_' + profile + ',' + print ' Elements(functions_for_' + profile + '));' + print ' }' + print + i = i + 1 + print '}' + diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/tools/generate_matrixCompMultGLSL.py b/3rdparty/glsl-optimizer/src/glsl/builtins/tools/generate_matrixCompMultGLSL.py new file mode 100644 index 000000000..391ad110d --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/tools/generate_matrixCompMultGLSL.py @@ -0,0 +1,28 @@ +#!/usr/bin/python + +def gen_matrix(x, y = 0): + if y == 0: + y = x + type = "mat" + str(x) + if x != y: + type = type + "x" + str(y) + print type + " matrixCompMult(" + type + " x, " + type + " y)\n{" + print " " + type + " z;" + + for i in range(x): + print " z[" + str(i) + "] = x[" + str(i) + "] * y[" + str(i) + "];" + print " return z;\n}" + +print "#version 120" +# 1.10 +gen_matrix(2) +gen_matrix(3) +gen_matrix(4) + +# 1.20 +gen_matrix(2,3) # mat2x3 means 2 columns, 3 rows +gen_matrix(3,2) +gen_matrix(2,4) +gen_matrix(4,2) +gen_matrix(3,4) +gen_matrix(4,3) diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/tools/generate_outerProductGLSL.py b/3rdparty/glsl-optimizer/src/glsl/builtins/tools/generate_outerProductGLSL.py new file mode 100644 index 000000000..c561cc3ba --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/tools/generate_outerProductGLSL.py @@ -0,0 +1,23 @@ +#!/usr/bin/python + +def gen(x, y): + type = "mat" + str(x) + if x != y: + type = type + "x" + str(y) + print type + " outerProduct(vec" + str(y) + " u, vec" + str(x) + " v)\n{" + print " " + type + " m;" + + for i in range(x): + print " m[" + str(i) + "] = u * v[" + str(i) + "];" + print " return m;\n}" + +print "#version 120" +gen(2,2) +gen(2,3) # mat2x3 means 2 columns, 3 rows +gen(2,4) +gen(3,2) +gen(3,3) +gen(3,4) +gen(4,2) +gen(4,3) +gen(4,4) diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/tools/generate_transposeGLSL.py b/3rdparty/glsl-optimizer/src/glsl/builtins/tools/generate_transposeGLSL.py new file mode 100644 index 000000000..8f669ce98 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/tools/generate_transposeGLSL.py @@ -0,0 +1,28 @@ +#!/usr/bin/python + +def gen(x, y): + origtype = "mat" + str(x) + trantype = "mat" + str(y) + if x != y: + origtype = origtype + "x" + str(y) + trantype = trantype + "x" + str(x) + print trantype + " transpose(" + origtype + " m)\n{" + print " " + trantype + " t;" + + # The obvious implementation of transpose + for i in range(x): + for j in range(y): + print " t[" + str(j) + "][" + str(i) + "] =", + print "m[" + str(i) + "][" + str(j) + "];" + print " return t;\n}" + +print "#version 120" +gen(2,2) +gen(2,3) # mat2x3 means 2 columns, 3 rows +gen(2,4) +gen(3,2) +gen(3,3) +gen(3,4) +gen(4,2) +gen(4,3) +gen(4,4) diff --git a/3rdparty/glsl-optimizer/src/glsl/builtins/tools/texture_builtins.py b/3rdparty/glsl-optimizer/src/glsl/builtins/tools/texture_builtins.py new file mode 100644 index 000000000..faf32f20a --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/builtins/tools/texture_builtins.py @@ -0,0 +1,576 @@ +#!/usr/bin/python + +import sys +import StringIO + +# Bitfield constants for the 'variant' argument to generate_sigs +Proj = 1 +Offset = 2 +Single = 4 + +def vec_type(g, size): + if size == 1: + if g == "i": + return "int" + elif g == "u": + return "uint" + return "float" + return g + "vec" + str(size) + +# Get the sampler dimension - i.e. sampler3D gives 3 +def get_sampler_dim(sampler_type): + if sampler_type[0].isdigit(): + sampler_dim = int(sampler_type[0]) + elif sampler_type.startswith("Cube"): + sampler_dim = 3 + else: + assert False ("coord_dim: invalid sampler_type: " + sampler_type) + return sampler_dim + +# Get the coordinate dimension for a given sampler type. +# Array samplers also get +1 here since the layer is really an extra coordinate +def get_coord_dim(sampler_type): + coord_dim = get_sampler_dim(sampler_type) + if sampler_type.find("Array") != -1: + coord_dim += 1 + return coord_dim + +# Get the number of extra vector components (i.e. shadow comparitor) +def get_extra_dim(sampler_type, use_proj, unused_fields): + extra_dim = unused_fields + if sampler_type.find("Shadow") != -1: + extra_dim += 1 + if use_proj: + extra_dim += 1 + return extra_dim + +def generate_sigs(g, tex_inst, sampler_type, variant = 0, unused_fields = 0): + coord_dim = get_coord_dim(sampler_type) + extra_dim = get_extra_dim(sampler_type, variant & Proj, unused_fields) + offset_dim = get_sampler_dim(sampler_type) + + if variant & Single: + return_type = "float" + else: + return_type = g + "vec4" + + # Print parameters + print " (signature", return_type + print " (parameters" + print " (declare (in) " + g + "sampler" + sampler_type + " sampler)" + print " (declare (in) " + vec_type("i" if tex_inst == "txf" else "", coord_dim + extra_dim) + " P)", + if tex_inst == "txl": + print "\n (declare (in) float lod)", + elif tex_inst == "txf": + print "\n (declare (in) int lod)", + elif tex_inst == "txd": + grad_type = vec_type("", coord_dim) + print "\n (declare (in) " + grad_type + " dPdx)", + print "\n (declare (in) " + grad_type + " dPdy)", + + if variant & Offset: + print "\n (declare (const_in) " + vec_type("i", offset_dim) + " offset)", + if tex_inst == "txb": + print "\n (declare (in) float bias)", + + print ")\n ((return (" + tex_inst, return_type, "(var_ref sampler)", + + # Coordinate + if extra_dim > 0: + print "(swiz " + "xyzw"[:coord_dim] + " (var_ref P))", + else: + print "(var_ref P)", + + if variant & Offset: + print "(var_ref offset)", + else: + print "0", + + if tex_inst != "txf": + # Projective divisor + if variant & Proj: + print "(swiz " + "xyzw"[coord_dim + extra_dim-1] + " (var_ref P))", + else: + print "1", + + # Shadow comparitor + if sampler_type == "2DArrayShadow": # a special case: + print "(swiz w (var_ref P))", # ...array layer is z; shadow is w + elif sampler_type.endswith("Shadow"): + print "(swiz z (var_ref P))", + else: + print "()", + + # Bias/explicit LOD/gradient: + if tex_inst == "txb": + print "(var_ref bias)", + elif tex_inst == "txl" or tex_inst == "txf": + print "(var_ref lod)", + elif tex_inst == "txd": + print "((var_ref dPdx) (var_ref dPdy))", + print "))))\n" + +def generate_fiu_sigs(tex_inst, sampler_type, variant = 0, unused_fields = 0): + generate_sigs("", tex_inst, sampler_type, variant, unused_fields) + generate_sigs("i", tex_inst, sampler_type, variant, unused_fields) + generate_sigs("u", tex_inst, sampler_type, variant, unused_fields) + +def start_function(name): + sys.stdout = StringIO.StringIO() + print "((function " + name + +def end_function(fs, name): + print "))" + fs[name] = sys.stdout.getvalue(); + sys.stdout.close() + +# Generate all the functions and store them in the supplied dictionary. +# This is better than writing them to actual files since they should never be +# edited; it'd also be easy to confuse them with the many hand-generated files. +# +# Takes a dictionary as an argument. +def generate_texture_functions(fs): + start_function("texture") + generate_fiu_sigs("tex", "1D") + generate_fiu_sigs("tex", "2D") + generate_fiu_sigs("tex", "3D") + generate_fiu_sigs("tex", "Cube") + generate_fiu_sigs("tex", "1DArray") + generate_fiu_sigs("tex", "2DArray") + generate_sigs("", "tex", "1DShadow", Single, 1); + generate_sigs("", "tex", "2DShadow", Single); + generate_sigs("", "tex", "CubeShadow", Single); + generate_sigs("", "tex", "1DArrayShadow", Single); + generate_sigs("", "tex", "2DArrayShadow", Single); + + generate_fiu_sigs("txb", "1D") + generate_fiu_sigs("txb", "2D") + generate_fiu_sigs("txb", "3D") + generate_fiu_sigs("txb", "Cube") + generate_fiu_sigs("txb", "1DArray") + generate_fiu_sigs("txb", "2DArray") + generate_sigs("", "txb", "1DShadow", Single, 1); + generate_sigs("", "txb", "2DShadow", Single); + generate_sigs("", "txb", "CubeShadow", Single); + generate_sigs("", "txb", "1DArrayShadow", Single); + generate_sigs("", "txb", "2DArrayShadow", Single); + end_function(fs, "texture") + + start_function("textureProj") + generate_fiu_sigs("tex", "1D", Proj) + generate_fiu_sigs("tex", "1D", Proj, 2) + generate_fiu_sigs("tex", "2D", Proj) + generate_fiu_sigs("tex", "2D", Proj, 1) + generate_fiu_sigs("tex", "3D", Proj) + generate_sigs("", "tex", "1DShadow", Proj | Single, 1); + generate_sigs("", "tex", "2DShadow", Proj | Single); + + generate_fiu_sigs("txb", "1D", Proj) + generate_fiu_sigs("txb", "1D", Proj, 2) + generate_fiu_sigs("txb", "2D", Proj) + generate_fiu_sigs("txb", "2D", Proj, 1) + generate_fiu_sigs("txb", "3D", Proj) + generate_sigs("", "txb", "1DShadow", Proj | Single, 1); + generate_sigs("", "txb", "2DShadow", Proj | Single); + end_function(fs, "textureProj") + + start_function("textureLod") + generate_fiu_sigs("txl", "1D") + generate_fiu_sigs("txl", "2D") + generate_fiu_sigs("txl", "3D") + generate_fiu_sigs("txl", "Cube") + generate_fiu_sigs("txl", "1DArray") + generate_fiu_sigs("txl", "2DArray") + generate_sigs("", "txl", "1DShadow", Single, 1); + generate_sigs("", "txl", "2DShadow", Single); + generate_sigs("", "txl", "1DArrayShadow", Single); + end_function(fs, "textureLod") + + start_function("textureLodOffset") + generate_fiu_sigs("txl", "1D", Offset) + generate_fiu_sigs("txl", "2D", Offset) + generate_fiu_sigs("txl", "3D", Offset) + generate_fiu_sigs("txl", "1DArray", Offset) + generate_fiu_sigs("txl", "2DArray", Offset) + generate_sigs("", "txl", "1DShadow", Offset | Single, 1); + generate_sigs("", "txl", "2DShadow", Offset | Single); + generate_sigs("", "txl", "1DArrayShadow", Offset | Single); + end_function(fs, "textureLodOffset") + + start_function("textureOffset") + generate_fiu_sigs("tex", "1D", Offset) + generate_fiu_sigs("tex", "2D", Offset) + generate_fiu_sigs("tex", "3D", Offset) + generate_fiu_sigs("tex", "1DArray", Offset) + generate_fiu_sigs("tex", "2DArray", Offset) + generate_sigs("", "tex", "1DShadow", Offset | Single, 1); + generate_sigs("", "tex", "2DShadow", Offset | Single); + generate_sigs("", "tex", "1DArrayShadow", Offset | Single); + + generate_fiu_sigs("txb", "1D", Offset) + generate_fiu_sigs("txb", "2D", Offset) + generate_fiu_sigs("txb", "3D", Offset) + generate_fiu_sigs("txb", "1DArray", Offset) + generate_fiu_sigs("txb", "2DArray", Offset) + generate_sigs("", "txb", "1DShadow", Offset | Single, 1); + generate_sigs("", "txb", "2DShadow", Offset | Single); + generate_sigs("", "txb", "1DArrayShadow", Offset | Single); + end_function(fs, "textureOffset") + + start_function("texelFetch") + generate_fiu_sigs("txf", "1D") + generate_fiu_sigs("txf", "2D") + generate_fiu_sigs("txf", "3D") + generate_fiu_sigs("txf", "1DArray") + generate_fiu_sigs("txf", "2DArray") + end_function(fs, "texelFetch") + + start_function("texelFetchOffset") + generate_fiu_sigs("txf", "1D", Offset) + generate_fiu_sigs("txf", "2D", Offset) + generate_fiu_sigs("txf", "3D", Offset) + generate_fiu_sigs("txf", "1DArray", Offset) + generate_fiu_sigs("txf", "2DArray", Offset) + end_function(fs, "texelFetchOffset") + + start_function("textureProjOffset") + generate_fiu_sigs("tex", "1D", Proj | Offset) + generate_fiu_sigs("tex", "1D", Proj | Offset, 2) + generate_fiu_sigs("tex", "2D", Proj | Offset) + generate_fiu_sigs("tex", "2D", Proj | Offset, 1) + generate_fiu_sigs("tex", "3D", Proj | Offset) + generate_sigs("", "tex", "1DShadow", Proj | Offset | Single, 1); + generate_sigs("", "tex", "2DShadow", Proj | Offset | Single); + + generate_fiu_sigs("txb", "1D", Proj | Offset) + generate_fiu_sigs("txb", "1D", Proj | Offset, 2) + generate_fiu_sigs("txb", "2D", Proj | Offset) + generate_fiu_sigs("txb", "2D", Proj | Offset, 1) + generate_fiu_sigs("txb", "3D", Proj | Offset) + generate_sigs("", "txb", "1DShadow", Proj | Offset | Single, 1); + generate_sigs("", "txb", "2DShadow", Proj | Offset | Single); + end_function(fs, "textureProjOffset") + + start_function("textureProjLod") + generate_fiu_sigs("txl", "1D", Proj) + generate_fiu_sigs("txl", "1D", Proj, 2) + generate_fiu_sigs("txl", "2D", Proj) + generate_fiu_sigs("txl", "2D", Proj, 1) + generate_fiu_sigs("txl", "3D", Proj) + generate_sigs("", "txl", "1DShadow", Proj | Single, 1); + generate_sigs("", "txl", "2DShadow", Proj | Single); + end_function(fs, "textureProjLod") + + start_function("textureProjLodOffset") + generate_fiu_sigs("txl", "1D", Proj | Offset) + generate_fiu_sigs("txl", "1D", Proj | Offset, 2) + generate_fiu_sigs("txl", "2D", Proj | Offset) + generate_fiu_sigs("txl", "2D", Proj | Offset, 1) + generate_fiu_sigs("txl", "3D", Proj | Offset) + generate_sigs("", "txl", "1DShadow", Proj | Offset | Single, 1); + generate_sigs("", "txl", "2DShadow", Proj | Offset | Single); + end_function(fs, "textureProjLodOffset") + + start_function("textureGrad") + generate_fiu_sigs("txd", "1D") + generate_fiu_sigs("txd", "2D") + generate_fiu_sigs("txd", "3D") + generate_fiu_sigs("txd", "Cube") + generate_fiu_sigs("txd", "1DArray") + generate_fiu_sigs("txd", "2DArray") + generate_sigs("", "txd", "1DShadow", Single, 1); + generate_sigs("", "txd", "2DShadow", Single); + generate_sigs("", "txd", "CubeShadow", Single); + generate_sigs("", "txd", "1DArrayShadow", Single); + generate_sigs("", "txd", "2DArrayShadow", Single); + end_function(fs, "textureGrad") + + start_function("textureGradOffset") + generate_fiu_sigs("txd", "1D", Offset) + generate_fiu_sigs("txd", "2D", Offset) + generate_fiu_sigs("txd", "3D", Offset) + generate_fiu_sigs("txd", "Cube", Offset) + generate_fiu_sigs("txd", "1DArray", Offset) + generate_fiu_sigs("txd", "2DArray", Offset) + generate_sigs("", "txd", "1DShadow", Offset | Single, 1); + generate_sigs("", "txd", "2DShadow", Offset | Single); + generate_sigs("", "txd", "1DArrayShadow", Offset | Single); + generate_sigs("", "txd", "2DArrayShadow", Offset | Single); + end_function(fs, "textureGradOffset") + + start_function("textureProjGrad") + generate_fiu_sigs("txd", "1D", Proj) + generate_fiu_sigs("txd", "1D", Proj, 2) + generate_fiu_sigs("txd", "2D", Proj) + generate_fiu_sigs("txd", "2D", Proj, 1) + generate_fiu_sigs("txd", "3D", Proj) + generate_sigs("", "txd", "1DShadow", Proj | Single, 1); + generate_sigs("", "txd", "2DShadow", Proj | Single); + end_function(fs, "textureProjGrad") + + start_function("textureProjGradOffset") + generate_fiu_sigs("txd", "1D", Proj | Offset) + generate_fiu_sigs("txd", "1D", Proj | Offset, 2) + generate_fiu_sigs("txd", "2D", Proj | Offset) + generate_fiu_sigs("txd", "2D", Proj | Offset, 1) + generate_fiu_sigs("txd", "3D", Proj | Offset) + generate_sigs("", "txd", "1DShadow", Proj | Offset | Single, 1); + generate_sigs("", "txd", "2DShadow", Proj | Offset | Single); + end_function(fs, "textureProjGradOffset") + + + # ARB_texture_rectangle extension + start_function("texture2DRect") + generate_sigs("", "tex", "2DRect") + end_function(fs, "texture2DRect") + + start_function("texture2DRectProj") + generate_sigs("", "tex", "2DRect", Proj) + generate_sigs("", "tex", "2DRect", Proj, 1) + end_function(fs, "texture2DRectProj") + + start_function("shadow2DRect") + generate_sigs("", "tex", "2DRectShadow") + end_function(fs, "shadow2DRect") + + start_function("shadow2DRectProj") + generate_sigs("", "tex", "2DRectShadow", Proj) + end_function(fs, "shadow2DRectProj") + + # EXT_texture_array extension + start_function("texture1DArray") + generate_sigs("", "tex", "1DArray") + generate_sigs("", "txb", "1DArray") + end_function(fs, "texture1DArray") + + start_function("texture1DArrayLod") + generate_sigs("", "txl", "1DArray") + end_function(fs, "texture1DArrayLod") + + start_function("texture2DArray") + generate_sigs("", "tex", "2DArray") + generate_sigs("", "txb", "2DArray") + end_function(fs, "texture2DArray") + + start_function("texture2DArrayLod") + generate_sigs("", "txl", "2DArray") + end_function(fs, "texture2DArrayLod") + + start_function("shadow1DArray") + generate_sigs("", "tex", "1DArrayShadow") + generate_sigs("", "txb", "1DArrayShadow") + end_function(fs, "shadow1DArray") + + start_function("shadow1DArrayLod") + generate_sigs("", "txl", "1DArrayShadow") + end_function(fs, "shadow1DArrayLod") + + start_function("shadow2DArray") + generate_sigs("", "tex", "2DArrayShadow") + end_function(fs, "shadow2DArray") + + # ARB_shader_texture_lod extension + start_function("texture1DGradARB") + generate_fiu_sigs("txd", "1D") + end_function(fs, "texture1DGradARB") + + start_function("texture2DGradARB") + generate_fiu_sigs("txd", "2D") + end_function(fs, "texture2DGradARB") + + start_function("texture2DGradEXT") + generate_fiu_sigs("txd", "2D") + end_function(fs, "texture2DGradEXT") + + start_function("texture3DGradARB") + generate_fiu_sigs("txd", "3D") + end_function(fs, "texture3DGradARB") + + start_function("textureCubeGradARB") + generate_fiu_sigs("txd", "Cube") + end_function(fs, "textureCubeGradARB") + + start_function("textureCubeGradEXT") + generate_fiu_sigs("txd", "Cube") + end_function(fs, "textureCubeGradEXT") + + start_function("texture1DProjGradARB") + generate_fiu_sigs("txd", "1D", True) + generate_fiu_sigs("txd", "1D", True, 2) + end_function(fs, "texture1DProjGradARB") + + start_function("texture2DProjGradARB") + generate_fiu_sigs("txd", "2D", True) + generate_fiu_sigs("txd", "2D", True, 1) + end_function(fs, "texture2DProjGradARB") + + start_function("texture2DProjGradEXT") + generate_fiu_sigs("txd", "2D", True) + generate_fiu_sigs("txd", "2D", True, 1) + end_function(fs, "texture2DProjGradEXT") + + start_function("texture3DProjGradARB") + generate_fiu_sigs("txd", "3D", True) + end_function(fs, "texture3DProjGradARB") + + start_function("shadow1DGradARB") + generate_sigs("", "txd", "1DShadow", False, 1) + end_function(fs, "shadow1DGradARB") + + start_function("shadow1DProjGradARB") + generate_sigs("", "txd", "1DShadow", True, 1) + end_function(fs, "shadow1DProjGradARB") + + start_function("shadow2DGradARB") + generate_sigs("", "txd", "2DShadow", False) + end_function(fs, "shadow2DGradARB") + + start_function("shadow2DProjGradARB") + generate_sigs("", "txd", "2DShadow", True) + end_function(fs, "shadow2DProjGradARB") + + start_function("texture2DRectGradARB") + generate_sigs("", "txd", "2DRect") + end_function(fs, "texture2DRectGradARB") + + start_function("texture2DRectProjGradARB") + generate_sigs("", "txd", "2DRect", True) + generate_sigs("", "txd", "2DRect", True, 1) + end_function(fs, "texture2DRectProjGradARB") + + start_function("shadow2DRectGradARB") + generate_sigs("", "txd", "2DRectShadow", False) + end_function(fs, "shadow2DRectGradARB") + + start_function("shadow2DRectProjGradARB") + generate_sigs("", "txd", "2DRectShadow", True) + end_function(fs, "shadow2DRectProjGradARB") + + # Deprecated (110/120 style) functions with silly names: + start_function("texture1D") + generate_sigs("", "tex", "1D") + generate_sigs("", "txb", "1D") + end_function(fs, "texture1D") + + start_function("texture1DLod") + generate_sigs("", "txl", "1D") + end_function(fs, "texture1DLod") + + start_function("texture1DProj") + generate_sigs("", "tex", "1D", Proj) + generate_sigs("", "tex", "1D", Proj, 2) + generate_sigs("", "txb", "1D", Proj) + generate_sigs("", "txb", "1D", Proj, 2) + end_function(fs, "texture1DProj") + + start_function("texture1DProjLod") + generate_sigs("", "txl", "1D", Proj) + generate_sigs("", "txl", "1D", Proj, 2) + end_function(fs, "texture1DProjLod") + + start_function("texture2D") + generate_sigs("", "tex", "2D") + generate_sigs("", "txb", "2D") + end_function(fs, "texture2D") + + start_function("texture2DLod") + generate_sigs("", "txl", "2D") + end_function(fs, "texture2DLod") + + start_function("texture2DLodEXT") + generate_sigs("", "txl", "2D") + end_function(fs, "texture2DLodEXT") + + start_function("texture2DProj") + generate_sigs("", "tex", "2D", Proj) + generate_sigs("", "tex", "2D", Proj, 1) + generate_sigs("", "txb", "2D", Proj) + generate_sigs("", "txb", "2D", Proj, 1) + end_function(fs, "texture2DProj") + + start_function("texture2DProjLod") + generate_sigs("", "txl", "2D", Proj) + generate_sigs("", "txl", "2D", Proj, 1) + end_function(fs, "texture2DProjLod") + + start_function("texture2DProjLodEXT") + generate_sigs("", "txl", "2D", Proj) + generate_sigs("", "txl", "2D", Proj, 1) + end_function(fs, "texture2DProjLodEXT") + + start_function("texture3D") + generate_sigs("", "tex", "3D") + generate_sigs("", "txb", "3D") + end_function(fs, "texture3D") + + start_function("texture3DLod") + generate_sigs("", "txl", "3D") + end_function(fs, "texture3DLod") + + start_function("texture3DProj") + generate_sigs("", "tex", "3D", Proj) + generate_sigs("", "txb", "3D", Proj) + end_function(fs, "texture3DProj") + + start_function("texture3DProjLod") + generate_sigs("", "txl", "3D", Proj) + end_function(fs, "texture3DProjLod") + + start_function("textureCube") + generate_sigs("", "tex", "Cube") + generate_sigs("", "txb", "Cube") + end_function(fs, "textureCube") + + start_function("textureCubeLod") + generate_sigs("", "txl", "Cube") + end_function(fs, "textureCubeLod") + + start_function("textureCubeLodEXT") + generate_sigs("", "txl", "Cube") + end_function(fs, "textureCubeLodEXT") + + start_function("shadow1D") + generate_sigs("", "tex", "1DShadow", False, 1) + generate_sigs("", "txb", "1DShadow", False, 1) + end_function(fs, "shadow1D") + + start_function("shadow1DLod") + generate_sigs("", "txl", "1DShadow", False, 1) + end_function(fs, "shadow1DLod") + + start_function("shadow1DProj") + generate_sigs("", "tex", "1DShadow", Proj, 1) + generate_sigs("", "txb", "1DShadow", Proj, 1) + end_function(fs, "shadow1DProj") + + start_function("shadow1DProjLod") + generate_sigs("", "txl", "1DShadow", Proj, 1) + end_function(fs, "shadow1DProjLod") + + start_function("shadow2D") + generate_sigs("", "tex", "2DShadow") + generate_sigs("", "txb", "2DShadow") + end_function(fs, "shadow2D") + + start_function("shadow2DLod") + generate_sigs("", "txl", "2DShadow") + end_function(fs, "shadow2DLod") + + start_function("shadow2DProj") + generate_sigs("", "tex", "2DShadow", Proj) + generate_sigs("", "txb", "2DShadow", Proj) + end_function(fs, "shadow2DProj") + + start_function("shadow2DProjLod") + generate_sigs("", "txl", "2DShadow", Proj) + end_function(fs, "shadow2DProjLod") + + sys.stdout = sys.__stdout__ + return fs + +# If you actually run this script, it'll print out all the functions. +if __name__ == "__main__": + fs = {} + generate_texture_functions(fs); + for k, v in fs.iteritems(): + print v diff --git a/3rdparty/glsl-optimizer/src/glsl/glsl_lexer.cpp b/3rdparty/glsl-optimizer/src/glsl/glsl_lexer.cpp new file mode 100644 index 000000000..69e3f604b --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/glsl_lexer.cpp @@ -0,0 +1,3725 @@ +#line 2 "src/glsl/glsl_lexer.cpp" + +#line 4 "src/glsl/glsl_lexer.cpp" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 5 +#define YY_FLEX_SUBMINOR_VERSION 35 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ +#include +#include +#include +#include + +/* end standard C headers. */ + +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have . Non-C99 systems may or may not. */ + +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + +/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, + * if you want the limit (max/min) macros for int types. + */ +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 +#endif + +#include +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; +#endif /* ! C99 */ + +/* Limits of integral types. */ +#ifndef INT8_MIN +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#endif /* ! FLEXINT_H */ + +#ifdef __cplusplus + +/* The "const" storage-class-modifier is valid. */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +/* C99 requires __STDC__ to be defined as 1. */ +#if defined (__STDC__) + +#define YY_USE_CONST + +#endif /* defined (__STDC__) */ +#endif /* ! __cplusplus */ + +#ifdef YY_USE_CONST +#define yyconst const +#else +#define yyconst +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an unsigned + * integer for use as an array index. If the signed char is negative, + * we want to instead treat it as an 8-bit unsigned char, hence the + * double cast. + */ +#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) + +/* An opaque pointer. */ +#ifndef YY_TYPEDEF_YY_SCANNER_T +#define YY_TYPEDEF_YY_SCANNER_T +typedef void* yyscan_t; +#endif + +/* For convenience, these vars (plus the bison vars far below) + are macros in the reentrant scanner. */ +#define yyin yyg->yyin_r +#define yyout yyg->yyout_r +#define yyextra yyg->yyextra_r +#define yyleng yyg->yyleng_r +#define yytext yyg->yytext_r +#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) +#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) +#define yy_flex_debug yyg->yy_flex_debug_r + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN yyg->yy_start = 1 + 2 * + +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START ((yyg->yy_start - 1) / 2) +#define YYSTATE YY_START + +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) + +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE _mesa_glsl_restart(yyin ,yyscanner ) + +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#ifndef YY_BUF_SIZE +#define YY_BUF_SIZE 16384 +#endif + +/* The state buf must be large enough to hold one state per character in the main buffer. + */ +#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + + #define YY_LESS_LINENO(n) + +/* Return all but the first "n" matched characters back to the input stream. */ +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = yyg->yy_hold_char; \ + YY_RESTORE_YY_MORE_OFFSET \ + yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) + +#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner ) + +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE +struct yy_buffer_state + { + FILE *yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + yy_size_t yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + yy_size_t yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; + +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via _mesa_glsl_restart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + * + * Returns the top of the stack, or NULL. + */ +#define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \ + ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \ + : NULL) + +/* Same as previous macro, but useful when we know that the buffer stack is not + * NULL or when we need an lvalue. For internal use only. + */ +#define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] + +void _mesa_glsl_restart (FILE *input_file ,yyscan_t yyscanner ); +void _mesa_glsl__switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); +YY_BUFFER_STATE _mesa_glsl__create_buffer (FILE *file,int size ,yyscan_t yyscanner ); +void _mesa_glsl__delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); +void _mesa_glsl__flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); +void _mesa_glsl_push_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); +void _mesa_glsl_pop_buffer_state (yyscan_t yyscanner ); + +static void _mesa_glsl_ensure_buffer_stack (yyscan_t yyscanner ); +static void _mesa_glsl__load_buffer_state (yyscan_t yyscanner ); +static void _mesa_glsl__init_buffer (YY_BUFFER_STATE b,FILE *file ,yyscan_t yyscanner ); + +#define YY_FLUSH_BUFFER _mesa_glsl__flush_buffer(YY_CURRENT_BUFFER ,yyscanner) + +YY_BUFFER_STATE _mesa_glsl__scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner ); +YY_BUFFER_STATE _mesa_glsl__scan_string (yyconst char *yy_str ,yyscan_t yyscanner ); +YY_BUFFER_STATE _mesa_glsl__scan_bytes (yyconst char *bytes,yy_size_t len ,yyscan_t yyscanner ); + +void *_mesa_glsl_alloc (yy_size_t ,yyscan_t yyscanner ); +void *_mesa_glsl_realloc (void *,yy_size_t ,yyscan_t yyscanner ); +void _mesa_glsl_free (void * ,yyscan_t yyscanner ); + +#define yy_new_buffer _mesa_glsl__create_buffer + +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ + _mesa_glsl_ensure_buffer_stack (yyscanner); \ + YY_CURRENT_BUFFER_LVALUE = \ + _mesa_glsl__create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + } + +#define yy_set_bol(at_bol) \ + { \ + if ( ! YY_CURRENT_BUFFER ){\ + _mesa_glsl_ensure_buffer_stack (yyscanner); \ + YY_CURRENT_BUFFER_LVALUE = \ + _mesa_glsl__create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + } + +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) + +/* Begin user sect3 */ + +#define _mesa_glsl_wrap(n) 1 +#define YY_SKIP_YYWRAP + +typedef unsigned char YY_CHAR; + +typedef int yy_state_type; + +#define yytext_ptr yytext_r + +static yy_state_type yy_get_previous_state (yyscan_t yyscanner ); +static yy_state_type yy_try_NUL_trans (yy_state_type current_state ,yyscan_t yyscanner); +static int yy_get_next_buffer (yyscan_t yyscanner ); +static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner ); + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + yyg->yytext_ptr = yy_bp; \ + yyleng = (size_t) (yy_cp - yy_bp); \ + yyg->yy_hold_char = *yy_cp; \ + *yy_cp = '\0'; \ + yyg->yy_c_buf_p = yy_cp; + +#define YY_NUM_RULES 210 +#define YY_END_OF_BUFFER 211 +/* This struct is not used in this scanner, + but its presence is necessary. */ +struct yy_trans_info + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; +static yyconst flex_int16_t yy_accept[836] = + { 0, + 0, 0, 16, 16, 0, 0, 211, 209, 1, 21, + 209, 209, 209, 209, 209, 209, 209, 209, 120, 118, + 209, 209, 209, 208, 209, 208, 208, 208, 208, 208, + 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, + 208, 208, 208, 208, 208, 209, 1, 209, 210, 16, + 20, 210, 19, 17, 18, 14, 13, 1, 102, 111, + 103, 114, 108, 97, 110, 98, 117, 122, 109, 123, + 120, 0, 0, 125, 120, 0, 118, 118, 106, 99, + 101, 100, 107, 208, 115, 105, 208, 208, 208, 208, + 208, 208, 208, 208, 208, 208, 208, 208, 30, 208, + + 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, + 208, 208, 34, 208, 208, 61, 208, 208, 208, 208, + 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, + 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, + 208, 208, 208, 208, 208, 208, 208, 208, 208, 116, + 104, 1, 0, 0, 2, 0, 0, 0, 0, 16, + 15, 19, 18, 0, 122, 121, 0, 123, 0, 124, + 119, 112, 113, 208, 128, 208, 208, 208, 208, 208, + 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, + 208, 208, 208, 208, 208, 208, 33, 208, 208, 208, + + 208, 208, 208, 208, 208, 208, 208, 26, 208, 208, + 208, 208, 208, 208, 208, 208, 208, 208, 208, 62, + 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, + 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, + 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, + 0, 0, 0, 0, 15, 0, 122, 0, 121, 0, + 123, 124, 119, 208, 208, 24, 208, 208, 175, 168, + 208, 208, 208, 208, 208, 208, 208, 208, 208, 32, + 131, 208, 208, 208, 208, 68, 208, 208, 136, 150, + 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, + + 208, 208, 147, 171, 49, 50, 51, 208, 208, 208, + 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, + 208, 208, 208, 208, 208, 208, 208, 134, 126, 208, + 208, 27, 208, 208, 208, 208, 208, 208, 208, 46, + 47, 48, 95, 208, 208, 0, 0, 0, 0, 0, + 121, 208, 208, 28, 37, 38, 39, 208, 129, 208, + 23, 208, 208, 208, 208, 158, 159, 160, 208, 127, + 208, 151, 25, 161, 162, 163, 173, 155, 156, 157, + 208, 208, 208, 63, 153, 208, 208, 208, 40, 41, + 42, 208, 208, 208, 208, 208, 208, 208, 208, 208, + + 208, 208, 208, 208, 208, 208, 208, 148, 208, 208, + 208, 208, 208, 208, 208, 208, 208, 208, 130, 208, + 208, 170, 43, 44, 45, 208, 208, 31, 0, 0, + 0, 0, 178, 208, 208, 176, 208, 208, 208, 149, + 144, 181, 208, 208, 208, 208, 208, 208, 139, 208, + 208, 208, 96, 52, 53, 54, 55, 56, 57, 58, + 59, 60, 208, 208, 208, 208, 154, 135, 208, 208, + 142, 36, 208, 208, 167, 69, 143, 94, 179, 137, + 208, 208, 208, 208, 208, 208, 208, 208, 0, 0, + 0, 0, 208, 208, 208, 138, 35, 208, 208, 208, + + 208, 208, 208, 182, 183, 184, 208, 208, 208, 208, + 208, 172, 208, 208, 208, 208, 208, 208, 208, 208, + 132, 208, 208, 208, 208, 208, 64, 208, 208, 65, + 208, 0, 0, 0, 0, 0, 208, 66, 29, 145, + 186, 187, 188, 208, 208, 208, 208, 208, 208, 208, + 208, 208, 208, 208, 208, 140, 208, 208, 208, 208, + 208, 208, 208, 208, 208, 133, 190, 191, 192, 208, + 208, 152, 208, 141, 0, 0, 6, 0, 0, 0, + 12, 3, 22, 208, 208, 208, 208, 208, 208, 208, + 208, 208, 185, 146, 67, 208, 208, 208, 208, 169, + + 208, 177, 174, 207, 71, 72, 73, 208, 208, 208, + 208, 208, 208, 208, 208, 208, 208, 0, 0, 0, + 0, 0, 0, 0, 208, 208, 208, 189, 208, 208, + 208, 208, 208, 82, 83, 84, 208, 208, 208, 208, + 208, 208, 208, 208, 208, 208, 208, 208, 208, 193, + 88, 89, 90, 208, 4, 0, 5, 0, 0, 0, + 0, 0, 0, 208, 208, 208, 208, 208, 208, 208, + 204, 208, 208, 208, 208, 208, 208, 208, 208, 208, + 208, 208, 74, 208, 208, 208, 208, 208, 208, 0, + 0, 0, 0, 208, 208, 205, 194, 208, 195, 208, + + 208, 208, 85, 208, 208, 208, 208, 208, 208, 208, + 208, 208, 208, 208, 206, 208, 208, 91, 0, 0, + 0, 196, 197, 208, 200, 208, 201, 208, 208, 70, + 208, 208, 208, 164, 208, 165, 180, 208, 198, 199, + 208, 208, 0, 0, 0, 208, 208, 208, 208, 75, + 208, 76, 208, 208, 208, 208, 208, 0, 0, 0, + 0, 208, 208, 86, 87, 208, 77, 208, 208, 78, + 208, 92, 93, 0, 0, 0, 0, 208, 208, 208, + 208, 208, 208, 0, 0, 0, 0, 208, 208, 208, + 208, 208, 79, 0, 0, 0, 7, 0, 0, 202, + + 203, 208, 208, 208, 0, 0, 8, 0, 0, 208, + 208, 166, 0, 0, 0, 80, 81, 0, 0, 0, + 9, 0, 0, 10, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 11, 0 + } ; + +static yyconst flex_int32_t yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 5, 1, 6, 1, 7, 8, 1, 9, + 10, 11, 12, 1, 13, 14, 15, 16, 17, 18, + 19, 20, 21, 21, 21, 22, 22, 23, 1, 24, + 25, 26, 1, 1, 27, 28, 29, 30, 31, 32, + 33, 34, 34, 34, 34, 35, 34, 34, 34, 34, + 34, 36, 37, 38, 39, 34, 34, 40, 34, 34, + 1, 1, 1, 41, 42, 1, 43, 44, 45, 46, + + 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, + 57, 58, 34, 59, 60, 61, 62, 63, 64, 65, + 66, 67, 1, 68, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1 + } ; + +static yyconst flex_int32_t yy_meta[69] = + { 0, + 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, + 3, 3, 1, 1, 1, 1, 4, 4, 4, 4, + 3, 3, 5, 5, 5, 5, 5, 5, 5, 5, + 1, 5, 4, 4, 4, 4, 3, 3, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 1 + } ; + +static yyconst flex_int16_t yy_base[845] = + { 0, + 0, 67, 73, 0, 1210, 1209, 1211, 1214, 68, 1214, + 1185, 1184, 134, 1183, 131, 132, 130, 1182, 146, 198, + 129, 1181, 144, 0, 130, 113, 124, 141, 150, 126, + 181, 1148, 159, 192, 118, 129, 146, 1142, 147, 174, + 206, 192, 203, 222, 1153, 203, 221, 231, 1214, 260, + 1214, 1187, 279, 1214, 0, 1214, 1214, 270, 1214, 1214, + 1214, 1214, 1214, 1214, 1214, 1214, 1214, 244, 1214, 255, + 139, 290, 307, 1214, 1214, 0, 0, 1214, 1176, 1214, + 1214, 1214, 1175, 0, 1214, 1214, 1138, 1143, 1136, 1139, + 1148, 1147, 1133, 1136, 1148, 144, 1142, 1129, 1126, 1140, + + 1126, 1123, 1123, 1129, 219, 193, 1123, 1134, 1119, 1125, + 1129, 1130, 0, 1121, 1132, 278, 1131, 1126, 1106, 224, + 1110, 1124, 1114, 232, 1107, 271, 1120, 1122, 1104, 1100, + 1108, 1105, 1094, 1103, 234, 1101, 1107, 1102, 1105, 1093, + 1096, 226, 145, 262, 1106, 1093, 1106, 263, 1099, 1214, + 1214, 338, 331, 343, 1214, 1084, 1097, 1088, 1099, 345, + 0, 334, 0, 345, 1214, 328, 391, 1214, 352, 398, + 338, 1214, 1214, 1094, 0, 1085, 1089, 1099, 1096, 332, + 1079, 1079, 1083, 320, 1094, 1091, 1091, 1089, 1086, 1077, + 1084, 1070, 1068, 1081, 1066, 1083, 0, 1080, 1067, 1075, + + 1072, 1076, 1077, 1070, 1067, 1055, 1054, 1068, 1071, 1058, + 1067, 1054, 1061, 1051, 364, 1057, 1060, 1050, 1058, 1046, + 1050, 1041, 1056, 1046, 1037, 1056, 1039, 1037, 1048, 1037, + 1032, 1030, 1044, 1029, 1031, 1028, 1040, 1039, 1042, 1023, + 338, 1032, 1027, 1025, 1035, 1013, 403, 1032, 1034, 1022, + 1014, 1018, 1030, 1013, 0, 415, 422, 439, 1214, 446, + 455, 1214, 1214, 1008, 1019, 0, 1016, 406, 0, 0, + 1009, 1007, 1009, 1004, 1013, 1001, 1019, 1007, 409, 0, + 0, 1001, 1012, 1011, 1011, 0, 995, 429, 0, 0, + 997, 460, 1005, 1006, 996, 990, 989, 990, 989, 989, + + 463, 984, 0, 0, 980, 979, 978, 980, 981, 986, + 980, 976, 990, 985, 984, 983, 974, 977, 977, 969, + 972, 967, 976, 981, 966, 979, 969, 0, 0, 976, + 972, 0, 963, 963, 969, 959, 967, 466, 964, 0, + 0, 0, 0, 953, 966, 965, 964, 961, 949, 472, + 479, 961, 963, 0, 0, 0, 0, 949, 0, 949, + 0, 948, 949, 943, 954, 0, 0, 0, 944, 0, + 940, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 951, 487, 950, 0, 0, 948, 944, 940, 0, 0, + 0, 932, 489, 494, 499, 937, 933, 939, 929, 927, + + 941, 925, 925, 939, 927, 939, 934, 0, 932, 929, + 933, 916, 918, 925, 931, 926, 925, 912, 0, 914, + 915, 0, 0, 0, 0, 912, 916, 0, 910, 963, + 909, 912, 0, 900, 910, 0, 898, 898, 912, 0, + 914, 0, 503, 926, 925, 924, 891, 890, 0, 908, + 907, 902, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 890, 904, 890, 887, 0, 0, 893, 892, + 0, 0, 890, 882, 0, 0, 0, 0, 0, 0, + 879, 891, 506, 883, 890, 889, 886, 880, 873, 524, + 889, 874, 869, 883, 881, 0, 0, 873, 896, 895, + + 894, 861, 860, 361, 365, 0, 873, 876, 874, 862, + 858, 0, 871, 868, 867, 856, 855, 854, 519, 863, + 0, 879, 878, 877, 844, 843, 0, 858, 844, 0, + 855, 850, 547, 553, 898, 843, 851, 0, 0, 0, + 870, 869, 0, 847, 850, 834, 842, 832, 840, 841, + 841, 840, 825, 559, 838, 0, 839, 827, 826, 822, + 850, 849, 848, 815, 814, 0, 848, 847, 0, 825, + 828, 0, 562, 0, 814, 580, 1214, 587, 0, 607, + 584, 1214, 0, 811, 810, 820, 820, 807, 822, 805, + 820, 815, 0, 0, 0, 831, 830, 829, 796, 0, + + 796, 0, 0, 0, 502, 524, 820, 807, 810, 794, + 793, 803, 803, 819, 818, 817, 784, 789, 615, 640, + 550, 806, 796, 784, 782, 781, 792, 0, 795, 791, + 793, 789, 775, 806, 805, 0, 787, 779, 770, 778, + 768, 779, 775, 777, 775, 775, 762, 761, 772, 0, + 791, 790, 0, 772, 1214, 555, 1214, 647, 0, 667, + 785, 770, 752, 769, 768, 751, 743, 751, 741, 749, + 0, 746, 745, 756, 739, 742, 757, 740, 753, 754, + 751, 748, 757, 750, 749, 732, 731, 730, 741, 582, + 754, 724, 734, 718, 717, 0, 745, 717, 743, 715, + + 719, 718, 0, 729, 732, 728, 730, 711, 725, 709, + 710, 718, 701, 700, 0, 706, 705, 0, 728, 713, + 706, 0, 0, 710, 0, 709, 0, 715, 714, 0, + 690, 698, 688, 716, 695, 0, 0, 708, 0, 0, + 707, 706, 746, 611, 696, 703, 702, 678, 677, 705, + 677, 703, 689, 674, 691, 670, 669, 190, 613, 557, + 667, 687, 686, 0, 0, 681, 0, 680, 686, 0, + 671, 0, 0, 671, 590, 343, 672, 645, 644, 654, + 635, 631, 612, 612, 604, 443, 635, 576, 575, 549, + 25, 87, 0, 183, 500, 552, 1214, 636, 591, 0, + + 0, 196, 258, 254, 272, 609, 1214, 614, 598, 279, + 284, 0, 336, 348, 671, 0, 0, 362, 672, 688, + 1214, 394, 689, 1214, 408, 670, 691, 649, 651, 474, + 476, 693, 694, 1214, 1214, 704, 707, 710, 530, 591, + 713, 717, 720, 722 + } ; + +static yyconst flex_int16_t yy_def[845] = + { 0, + 835, 1, 835, 3, 836, 836, 835, 835, 835, 835, + 835, 835, 835, 835, 835, 835, 835, 835, 835, 835, + 835, 835, 835, 837, 835, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 835, 835, 835, 835, 835, + 835, 835, 835, 835, 838, 835, 835, 835, 835, 835, + 835, 835, 835, 835, 835, 835, 835, 839, 835, 840, + 19, 835, 835, 835, 835, 841, 20, 835, 835, 835, + 835, 835, 835, 837, 835, 835, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 835, + 835, 835, 835, 835, 835, 835, 835, 835, 835, 835, + 842, 835, 838, 835, 835, 840, 835, 835, 835, 835, + 841, 835, 835, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 835, 835, 835, 835, 842, 835, 835, 835, 835, 835, + 835, 835, 835, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 835, 835, 835, 835, 835, + 835, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 835, 835, + 835, 835, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 835, 835, + 835, 835, 837, 837, 837, 837, 837, 837, 837, 837, + + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 835, 835, 835, 835, 835, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 835, 835, 835, 835, 843, 835, + 835, 835, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 835, 835, 835, + 843, 835, 835, 835, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 835, 835, 835, 835, 844, 835, + 835, 835, 835, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 844, + 835, 835, 835, 837, 837, 837, 837, 837, 837, 837, + + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 835, 835, + 835, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 835, 835, 835, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 835, 835, 835, + 835, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 835, 835, 835, 835, 837, 837, 837, + 837, 837, 837, 835, 835, 835, 835, 837, 837, 837, + 837, 837, 837, 835, 835, 835, 835, 835, 835, 837, + + 837, 837, 837, 837, 835, 835, 835, 835, 835, 837, + 837, 837, 835, 835, 835, 837, 837, 835, 835, 835, + 835, 835, 835, 835, 835, 835, 835, 835, 835, 835, + 835, 835, 835, 835, 0, 835, 835, 835, 835, 835, + 835, 835, 835, 835 + } ; + +static yyconst flex_int16_t yy_nxt[1283] = + { 0, + 8, 9, 10, 9, 11, 8, 12, 13, 8, 8, + 14, 15, 16, 17, 18, 19, 20, 20, 20, 20, + 20, 20, 8, 21, 22, 23, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 25, 24, 26, 27, 28, 29, 30, 31, 32, 33, + 34, 24, 24, 35, 36, 37, 38, 39, 40, 41, + 42, 43, 44, 45, 24, 24, 24, 46, 47, 58, + 803, 58, 48, 49, 50, 51, 50, 49, 49, 49, + 49, 49, 49, 49, 49, 49, 49, 52, 49, 53, + 53, 53, 53, 53, 53, 54, 49, 49, 49, 55, + + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 49, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 49, 61, 64, 804, 66, 68, 68, 68, 68, 68, + 68, 68, 79, 80, 85, 65, 67, 87, 62, 70, + 119, 71, 71, 71, 71, 71, 71, 72, 82, 83, + 86, 121, 88, 89, 120, 122, 73, 74, 835, 101, + 90, 102, 91, 93, 75, 76, 92, 94, 123, 126, + 103, 758, 73, 74, 95, 241, 97, 96, 183, 184, + + 98, 110, 124, 835, 242, 127, 99, 75, 128, 111, + 76, 70, 100, 77, 77, 77, 77, 77, 77, 77, + 129, 112, 152, 104, 58, 805, 153, 150, 73, 74, + 130, 105, 154, 155, 106, 195, 78, 107, 138, 113, + 774, 139, 114, 108, 73, 74, 115, 116, 131, 196, + 140, 117, 810, 142, 118, 132, 133, 141, 143, 78, + 134, 160, 144, 160, 146, 145, 135, 136, 147, 137, + 151, 58, 193, 58, 164, 165, 231, 156, 148, 213, + 239, 240, 218, 194, 157, 167, 168, 214, 158, 219, + 164, 165, 232, 159, 162, 162, 162, 162, 162, 162, + + 162, 167, 168, 70, 243, 72, 72, 72, 72, 72, + 72, 72, 244, 248, 811, 221, 249, 812, 169, 169, + 73, 74, 170, 170, 170, 170, 170, 170, 170, 222, + 813, 205, 154, 155, 206, 207, 73, 74, 208, 152, + 209, 58, 816, 153, 154, 155, 160, 817, 160, 162, + 162, 162, 162, 162, 162, 162, 256, 256, 258, 259, + 257, 257, 257, 257, 257, 257, 257, 170, 170, 170, + 170, 170, 170, 170, 258, 259, 263, 156, 269, 274, + 275, 305, 306, 307, 157, 333, 818, 546, 158, 156, + 785, 548, 270, 159, 334, 819, 157, 547, 786, 263, + + 158, 549, 260, 260, 822, 159, 261, 261, 261, 261, + 261, 261, 261, 170, 170, 170, 170, 170, 170, 170, + 340, 341, 342, 355, 356, 357, 366, 367, 368, 262, + 257, 257, 257, 257, 257, 257, 257, 257, 257, 257, + 257, 257, 257, 257, 796, 262, 374, 375, 376, 825, + 350, 350, 797, 165, 351, 351, 351, 351, 351, 351, + 351, 261, 261, 261, 261, 261, 261, 261, 826, 165, + 261, 261, 261, 261, 261, 261, 261, 378, 379, 380, + 389, 390, 391, 423, 424, 425, 168, 351, 351, 351, + 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, + + 351, 806, 168, 444, 445, 446, 454, 455, 456, 807, + 259, 457, 458, 459, 447, 448, 460, 461, 462, 499, + 500, 501, 522, 523, 524, 490, 259, 831, 639, 832, + 502, 503, 68, 525, 526, 561, 562, 563, 640, 533, + 534, 534, 534, 534, 534, 534, 564, 565, 576, 577, + 641, 576, 577, 796, 576, 577, 656, 657, 775, 642, + 643, 797, 578, 578, 578, 578, 578, 578, 580, 580, + 580, 580, 580, 580, 580, 596, 597, 598, 614, 615, + 616, 576, 577, 656, 657, 581, 579, 599, 576, 577, + 617, 775, 808, 166, 802, 619, 620, 620, 620, 620, + + 620, 620, 578, 578, 578, 578, 578, 578, 576, 577, + 806, 579, 759, 776, 759, 808, 656, 657, 807, 760, + 622, 760, 580, 580, 580, 580, 580, 580, 580, 623, + 658, 658, 658, 658, 658, 658, 798, 798, 801, 800, + 624, 656, 657, 799, 799, 814, 776, 809, 656, 657, + 829, 795, 829, 815, 659, 660, 660, 660, 660, 660, + 660, 660, 658, 658, 658, 658, 658, 658, 656, 657, + 809, 827, 820, 823, 794, 793, 792, 791, 828, 659, + 821, 824, 660, 660, 660, 660, 660, 660, 660, 820, + 823, 830, 827, 830, 833, 833, 790, 821, 824, 828, + + 789, 788, 834, 834, 56, 56, 56, 56, 56, 84, + 84, 84, 163, 163, 163, 171, 171, 255, 787, 255, + 255, 255, 621, 621, 690, 690, 784, 783, 782, 781, + 780, 779, 778, 777, 773, 772, 771, 770, 769, 768, + 767, 766, 765, 764, 763, 762, 761, 758, 757, 756, + 755, 754, 753, 752, 751, 750, 749, 748, 747, 746, + 745, 744, 743, 742, 741, 740, 739, 738, 737, 736, + 735, 734, 733, 732, 731, 730, 729, 728, 727, 726, + 725, 724, 723, 722, 721, 720, 719, 718, 717, 716, + 715, 714, 713, 712, 711, 710, 709, 708, 707, 706, + + 705, 704, 703, 702, 701, 700, 699, 698, 697, 696, + 695, 694, 693, 692, 691, 689, 688, 687, 686, 685, + 684, 683, 682, 681, 680, 679, 678, 677, 676, 675, + 674, 673, 672, 671, 670, 669, 668, 667, 666, 665, + 664, 663, 662, 661, 655, 654, 653, 652, 651, 650, + 649, 648, 647, 646, 645, 644, 638, 637, 636, 635, + 634, 633, 632, 631, 630, 629, 628, 627, 626, 625, + 618, 613, 612, 611, 610, 609, 608, 607, 606, 605, + 604, 603, 602, 601, 600, 595, 594, 593, 592, 591, + 590, 589, 588, 587, 586, 585, 584, 583, 582, 581, + + 575, 574, 573, 572, 571, 570, 569, 568, 567, 566, + 560, 559, 558, 557, 556, 555, 554, 553, 552, 551, + 550, 545, 544, 543, 542, 541, 540, 539, 538, 537, + 536, 535, 532, 531, 530, 529, 528, 527, 521, 520, + 519, 518, 517, 516, 515, 514, 513, 512, 511, 510, + 509, 508, 507, 506, 505, 504, 498, 497, 496, 495, + 494, 493, 492, 491, 490, 489, 488, 487, 486, 485, + 484, 483, 482, 481, 480, 479, 478, 477, 476, 475, + 474, 473, 472, 471, 470, 469, 468, 467, 466, 465, + 464, 463, 453, 452, 451, 450, 449, 443, 442, 441, + + 440, 439, 438, 437, 436, 435, 434, 433, 432, 431, + 430, 429, 428, 427, 426, 422, 421, 420, 419, 418, + 417, 416, 415, 414, 413, 412, 411, 410, 409, 408, + 407, 406, 405, 404, 403, 402, 401, 400, 399, 398, + 397, 396, 395, 394, 393, 392, 388, 387, 386, 385, + 384, 383, 382, 381, 377, 373, 372, 371, 370, 369, + 365, 364, 363, 362, 361, 360, 359, 358, 354, 353, + 352, 349, 348, 347, 346, 345, 344, 343, 339, 338, + 337, 336, 335, 332, 331, 330, 329, 328, 327, 326, + 325, 324, 323, 322, 321, 320, 319, 318, 317, 316, + + 315, 314, 313, 312, 311, 310, 309, 308, 304, 303, + 302, 301, 300, 299, 298, 297, 296, 295, 294, 293, + 292, 291, 290, 289, 288, 287, 286, 285, 284, 283, + 282, 281, 280, 279, 278, 277, 276, 273, 272, 271, + 268, 267, 266, 265, 264, 254, 253, 252, 251, 250, + 247, 246, 245, 238, 237, 236, 235, 234, 233, 230, + 229, 228, 227, 226, 225, 224, 223, 220, 217, 216, + 215, 212, 211, 210, 204, 203, 202, 201, 200, 199, + 198, 197, 192, 191, 190, 189, 188, 187, 186, 185, + 182, 181, 180, 179, 178, 177, 176, 175, 174, 173, + + 172, 161, 149, 125, 109, 81, 69, 63, 60, 59, + 835, 57, 57, 7, 835, 835, 835, 835, 835, 835, + 835, 835, 835, 835, 835, 835, 835, 835, 835, 835, + 835, 835, 835, 835, 835, 835, 835, 835, 835, 835, + 835, 835, 835, 835, 835, 835, 835, 835, 835, 835, + 835, 835, 835, 835, 835, 835, 835, 835, 835, 835, + 835, 835, 835, 835, 835, 835, 835, 835, 835, 835, + 835, 835, 835, 835, 835, 835, 835, 835, 835, 835, + 835, 835 + } ; + +static yyconst flex_int16_t yy_chk[1283] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 9, + 791, 9, 2, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 13, 15, 792, 16, 17, 17, 17, 17, 17, + 17, 17, 21, 21, 25, 15, 16, 26, 13, 19, + 35, 19, 19, 19, 19, 19, 19, 19, 23, 23, + 25, 36, 26, 26, 35, 36, 19, 19, 71, 30, + 27, 30, 27, 28, 19, 19, 27, 28, 37, 39, + 30, 758, 19, 19, 28, 143, 29, 28, 96, 96, + + 29, 33, 37, 71, 143, 39, 29, 19, 39, 33, + 19, 20, 29, 20, 20, 20, 20, 20, 20, 20, + 40, 33, 47, 31, 47, 794, 47, 46, 20, 20, + 40, 31, 48, 48, 31, 106, 20, 31, 42, 34, + 758, 42, 34, 31, 20, 20, 34, 34, 41, 106, + 42, 34, 802, 43, 34, 41, 41, 42, 43, 20, + 41, 50, 43, 50, 44, 43, 41, 41, 44, 41, + 46, 58, 105, 58, 68, 68, 135, 48, 44, 120, + 142, 142, 124, 105, 48, 70, 70, 120, 48, 124, + 68, 68, 135, 48, 53, 53, 53, 53, 53, 53, + + 53, 70, 70, 72, 144, 72, 72, 72, 72, 72, + 72, 72, 144, 148, 803, 126, 148, 804, 73, 73, + 72, 72, 73, 73, 73, 73, 73, 73, 73, 126, + 805, 116, 153, 153, 116, 116, 72, 72, 116, 152, + 116, 152, 810, 152, 154, 154, 160, 811, 160, 162, + 162, 162, 162, 162, 162, 162, 164, 164, 166, 166, + 164, 164, 164, 164, 164, 164, 164, 169, 169, 169, + 169, 169, 169, 169, 166, 166, 171, 153, 180, 184, + 184, 215, 215, 215, 153, 241, 813, 504, 153, 154, + 776, 505, 180, 153, 241, 814, 154, 504, 776, 171, + + 154, 505, 167, 167, 818, 154, 167, 167, 167, 167, + 167, 167, 167, 170, 170, 170, 170, 170, 170, 170, + 247, 247, 247, 268, 268, 268, 279, 279, 279, 170, + 256, 256, 256, 256, 256, 256, 256, 257, 257, 257, + 257, 257, 257, 257, 786, 170, 288, 288, 288, 822, + 258, 258, 786, 257, 258, 258, 258, 258, 258, 258, + 258, 260, 260, 260, 260, 260, 260, 260, 825, 257, + 261, 261, 261, 261, 261, 261, 261, 292, 292, 292, + 301, 301, 301, 338, 338, 338, 261, 350, 350, 350, + 350, 350, 350, 350, 351, 351, 351, 351, 351, 351, + + 351, 795, 261, 382, 382, 382, 393, 393, 393, 795, + 351, 394, 394, 394, 382, 382, 395, 395, 395, 443, + 443, 443, 483, 483, 483, 490, 351, 830, 605, 831, + 443, 443, 839, 483, 483, 519, 519, 519, 605, 490, + 490, 490, 490, 490, 490, 490, 519, 519, 533, 533, + 606, 621, 621, 796, 534, 534, 656, 656, 760, 606, + 606, 796, 533, 533, 533, 533, 533, 533, 534, 534, + 534, 534, 534, 534, 534, 554, 554, 554, 573, 573, + 573, 576, 576, 690, 690, 581, 533, 554, 578, 578, + 573, 775, 799, 840, 790, 576, 576, 576, 576, 576, + + 576, 576, 578, 578, 578, 578, 578, 578, 580, 580, + 806, 533, 744, 760, 759, 808, 619, 619, 806, 744, + 581, 759, 580, 580, 580, 580, 580, 580, 580, 581, + 619, 619, 619, 619, 619, 619, 787, 798, 789, 788, + 581, 620, 620, 787, 798, 809, 775, 799, 658, 658, + 828, 785, 829, 809, 619, 620, 620, 620, 620, 620, + 620, 620, 658, 658, 658, 658, 658, 658, 660, 660, + 808, 826, 815, 819, 784, 783, 782, 781, 826, 619, + 815, 819, 660, 660, 660, 660, 660, 660, 660, 820, + 823, 828, 827, 829, 832, 833, 780, 820, 823, 827, + + 779, 778, 832, 833, 836, 836, 836, 836, 836, 837, + 837, 837, 838, 838, 838, 841, 841, 842, 777, 842, + 842, 842, 843, 843, 844, 844, 774, 771, 769, 768, + 766, 763, 762, 761, 757, 756, 755, 754, 753, 752, + 751, 750, 749, 748, 747, 746, 745, 743, 742, 741, + 738, 735, 734, 733, 732, 731, 729, 728, 726, 724, + 721, 720, 719, 717, 716, 714, 713, 712, 711, 710, + 709, 708, 707, 706, 705, 704, 702, 701, 700, 699, + 698, 697, 695, 694, 693, 692, 691, 689, 688, 687, + 686, 685, 684, 683, 682, 681, 680, 679, 678, 677, + + 676, 675, 674, 673, 672, 670, 669, 668, 667, 666, + 665, 664, 663, 662, 661, 654, 652, 651, 649, 648, + 647, 646, 645, 644, 643, 642, 641, 640, 639, 638, + 637, 635, 634, 633, 632, 631, 630, 629, 627, 626, + 625, 624, 623, 622, 618, 617, 616, 615, 614, 613, + 612, 611, 610, 609, 608, 607, 601, 599, 598, 597, + 596, 592, 591, 590, 589, 588, 587, 586, 585, 584, + 575, 571, 570, 568, 567, 565, 564, 563, 562, 561, + 560, 559, 558, 557, 555, 553, 552, 551, 550, 549, + 548, 547, 546, 545, 544, 542, 541, 537, 536, 535, + + 532, 531, 529, 528, 526, 525, 524, 523, 522, 520, + 518, 517, 516, 515, 514, 513, 511, 510, 509, 508, + 507, 503, 502, 501, 500, 499, 498, 495, 494, 493, + 492, 491, 489, 488, 487, 486, 485, 484, 482, 481, + 474, 473, 470, 469, 466, 465, 464, 463, 452, 451, + 450, 448, 447, 446, 445, 444, 441, 439, 438, 437, + 435, 434, 432, 431, 430, 429, 427, 426, 421, 420, + 418, 417, 416, 415, 414, 413, 412, 411, 410, 409, + 407, 406, 405, 404, 403, 402, 401, 400, 399, 398, + 397, 396, 392, 388, 387, 386, 383, 381, 371, 369, + + 365, 364, 363, 362, 360, 358, 353, 352, 349, 348, + 347, 346, 345, 344, 339, 337, 336, 335, 334, 333, + 331, 330, 327, 326, 325, 324, 323, 322, 321, 320, + 319, 318, 317, 316, 315, 314, 313, 312, 311, 310, + 309, 308, 307, 306, 305, 302, 300, 299, 298, 297, + 296, 295, 294, 293, 291, 287, 285, 284, 283, 282, + 278, 277, 276, 275, 274, 273, 272, 271, 267, 265, + 264, 254, 253, 252, 251, 250, 249, 248, 246, 245, + 244, 243, 242, 240, 239, 238, 237, 236, 235, 234, + 233, 232, 231, 230, 229, 228, 227, 226, 225, 224, + + 223, 222, 221, 220, 219, 218, 217, 216, 214, 213, + 212, 211, 210, 209, 208, 207, 206, 205, 204, 203, + 202, 201, 200, 199, 198, 196, 195, 194, 193, 192, + 191, 190, 189, 188, 187, 186, 185, 183, 182, 181, + 179, 178, 177, 176, 174, 159, 158, 157, 156, 149, + 147, 146, 145, 141, 140, 139, 138, 137, 136, 134, + 133, 132, 131, 130, 129, 128, 127, 125, 123, 122, + 121, 119, 118, 117, 115, 114, 112, 111, 110, 109, + 108, 107, 104, 103, 102, 101, 100, 99, 98, 97, + 95, 94, 93, 92, 91, 90, 89, 88, 87, 83, + + 79, 52, 45, 38, 32, 22, 18, 14, 12, 11, + 7, 6, 5, 835, 835, 835, 835, 835, 835, 835, + 835, 835, 835, 835, 835, 835, 835, 835, 835, 835, + 835, 835, 835, 835, 835, 835, 835, 835, 835, 835, + 835, 835, 835, 835, 835, 835, 835, 835, 835, 835, + 835, 835, 835, 835, 835, 835, 835, 835, 835, 835, + 835, 835, 835, 835, 835, 835, 835, 835, 835, 835, + 835, 835, 835, 835, 835, 835, 835, 835, 835, 835, + 835, 835 + } ; + +/* The intent behind this definition is that it'll catch + * any uses of REJECT which flex missed. + */ +#define REJECT reject_used_but_not_detected +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +#line 1 "src/glsl/glsl_lexer.ll" +#line 2 "src/glsl/glsl_lexer.ll" +/* + * Copyright © 2008, 2009 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +#include +#include "strtod.h" +#include "ast.h" +#include "glsl_parser_extras.h" +#include "glsl_parser.h" + +static int classify_identifier(struct _mesa_glsl_parse_state *, const char *); + +#ifdef _MSC_VER +#define YY_NO_UNISTD_H +#endif + +#define YY_USER_ACTION \ + do { \ + yylloc->source = 0; \ + yylloc->first_column = yycolumn + 1; \ + yylloc->first_line = yylineno + 1; \ + yycolumn += yyleng; \ + } while(0); + +#define YY_USER_INIT yylineno = 0; yycolumn = 0; + +#define IS_UINT (yytext[yyleng - 1] == 'u' || yytext[yyleng - 1] == 'U') + +/* A macro for handling reserved words and keywords across language versions. + * + * Certain words start out as identifiers, become reserved words in + * later language revisions, and finally become language keywords. + * + * For example, consider the following lexer rule: + * samplerBuffer KEYWORD(130, 140, SAMPLERBUFFER) + * + * This means that "samplerBuffer" will be treated as: + * - a keyword (SAMPLERBUFFER token) ...in GLSL >= 1.40 + * - a reserved word - error ...in GLSL >= 1.30 + * - an identifier ...in GLSL < 1.30 + */ +#define KEYWORD(reserved_version, allowed_version, token) \ + do { \ + if (yyextra->language_version >= allowed_version) { \ + return token; \ + } else if (yyextra->language_version >= reserved_version) { \ + _mesa_glsl_error(yylloc, yyextra, \ + "Illegal use of reserved word `%s'", yytext); \ + return ERROR_TOK; \ + } else { \ + yylval->identifier = strdup(yytext); \ + return classify_identifier(yyextra, yytext); \ + } \ + } while (0) + +/* The ES macro can be used in KEYWORD checks: + * + * word KEYWORD(110 || ES, 400, TOKEN) + * ...means the word is reserved in GLSL ES 1.00, while + * + * word KEYWORD(110, 130 || ES, TOKEN) + * ...means the word is a legal keyword in GLSL ES 1.00. + */ +#define ES yyextra->es_shader + +#line 1077 "src/glsl/glsl_lexer.cpp" + +#define INITIAL 0 +#define PP 1 +#define PRAGMA 2 + +#define YY_EXTRA_TYPE struct _mesa_glsl_parse_state * + +/* Holds the entire state of the reentrant scanner. */ +struct yyguts_t + { + + /* User-defined. Not touched by flex. */ + YY_EXTRA_TYPE yyextra_r; + + /* The rest are the same as the globals declared in the non-reentrant scanner. */ + FILE *yyin_r, *yyout_r; + size_t yy_buffer_stack_top; /**< index of top of stack. */ + size_t yy_buffer_stack_max; /**< capacity of stack. */ + YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */ + char yy_hold_char; + yy_size_t yy_n_chars; + yy_size_t yyleng_r; + char *yy_c_buf_p; + int yy_init; + int yy_start; + int yy_did_buffer_switch_on_eof; + int yy_start_stack_ptr; + int yy_start_stack_depth; + int *yy_start_stack; + yy_state_type yy_last_accepting_state; + char* yy_last_accepting_cpos; + + int yylineno_r; + int yy_flex_debug_r; + + char *yytext_r; + int yy_more_flag; + int yy_more_len; + + YYSTYPE * yylval_r; + + YYLTYPE * yylloc_r; + + }; /* end struct yyguts_t */ + +static int yy_init_globals (yyscan_t yyscanner ); + + /* This must go here because YYSTYPE and YYLTYPE are included + * from bison output in section 1.*/ + # define yylval yyg->yylval_r + + # define yylloc yyg->yylloc_r + +int _mesa_glsl_lex_init (yyscan_t* scanner); + +int _mesa_glsl_lex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner); + +/* Accessor methods to globals. + These are made visible to non-reentrant scanners for convenience. */ + +int _mesa_glsl_lex_destroy (yyscan_t yyscanner ); + +int _mesa_glsl_get_debug (yyscan_t yyscanner ); + +void _mesa_glsl_set_debug (int debug_flag ,yyscan_t yyscanner ); + +YY_EXTRA_TYPE _mesa_glsl_get_extra (yyscan_t yyscanner ); + +void _mesa_glsl_set_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner ); + +FILE *_mesa_glsl_get_in (yyscan_t yyscanner ); + +void _mesa_glsl_set_in (FILE * in_str ,yyscan_t yyscanner ); + +FILE *_mesa_glsl_get_out (yyscan_t yyscanner ); + +void _mesa_glsl_set_out (FILE * out_str ,yyscan_t yyscanner ); + +yy_size_t _mesa_glsl_get_leng (yyscan_t yyscanner ); + +char *_mesa_glsl_get_text (yyscan_t yyscanner ); + +int _mesa_glsl_get_lineno (yyscan_t yyscanner ); + +void _mesa_glsl_set_lineno (int line_number ,yyscan_t yyscanner ); + +YYSTYPE * _mesa_glsl_get_lval (yyscan_t yyscanner ); + +void _mesa_glsl_set_lval (YYSTYPE * yylval_param ,yyscan_t yyscanner ); + + YYLTYPE *_mesa_glsl_get_lloc (yyscan_t yyscanner ); + + void _mesa_glsl_set_lloc (YYLTYPE * yylloc_param ,yyscan_t yyscanner ); + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int _mesa_glsl_wrap (yyscan_t yyscanner ); +#else +extern int _mesa_glsl_wrap (yyscan_t yyscanner ); +#endif +#endif + +#ifndef yytext_ptr +static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner); +#endif + +#ifndef YY_NO_INPUT + +#ifdef __cplusplus +static int yyinput (yyscan_t yyscanner ); +#else +static int input (yyscan_t yyscanner ); +#endif + +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#define YY_READ_BUF_SIZE 8192 +#endif + +/* Copy whatever the last rule matched to the standard output. */ +#ifndef ECHO +/* This used to be an fputs(), but since the string might contain NUL's, + * we now use fwrite(). + */ +#define ECHO fwrite( yytext, yyleng, 1, yyout ) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ + if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ + { \ + int c = '*'; \ + yy_size_t n; \ + for ( n = 0; n < max_size && \ + (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ + buf[n] = (char) c; \ + if ( c == '\n' ) \ + buf[n++] = (char) c; \ + if ( c == EOF && ferror( yyin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + result = n; \ + } \ + else \ + { \ + errno=0; \ + while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \ + { \ + if( errno != EINTR) \ + { \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + break; \ + } \ + errno=0; \ + clearerr(yyin); \ + } \ + }\ +\ + +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner) +#endif + +/* end tables serialization structures and prototypes */ + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 + +extern int _mesa_glsl_lex \ + (YYSTYPE * yylval_param,YYLTYPE * yylloc_param ,yyscan_t yyscanner); + +#define YY_DECL int _mesa_glsl_lex \ + (YYSTYPE * yylval_param, YYLTYPE * yylloc_param , yyscan_t yyscanner) +#endif /* !YY_DECL */ + +/* Code executed at the beginning of each rule, after yytext and yyleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK break; +#endif + +#define YY_RULE_SETUP \ + if ( yyleng > 0 ) \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = \ + (yytext[yyleng - 1] == '\n'); \ + YY_USER_ACTION + +/** The main scanner function which does all the work. + */ +YY_DECL +{ + register yy_state_type yy_current_state; + register char *yy_cp, *yy_bp; + register int yy_act; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + +#line 101 "src/glsl/glsl_lexer.ll" + + +#line 1314 "src/glsl/glsl_lexer.cpp" + + yylval = yylval_param; + + yylloc = yylloc_param; + + if ( !yyg->yy_init ) + { + yyg->yy_init = 1; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! yyg->yy_start ) + yyg->yy_start = 1; /* first start state */ + + if ( ! yyin ) + yyin = stdin; + + if ( ! yyout ) + yyout = stdout; + + if ( ! YY_CURRENT_BUFFER ) { + _mesa_glsl_ensure_buffer_stack (yyscanner); + YY_CURRENT_BUFFER_LVALUE = + _mesa_glsl__create_buffer(yyin,YY_BUF_SIZE ,yyscanner); + } + + _mesa_glsl__load_buffer_state(yyscanner ); + } + + while ( 1 ) /* loops until end-of-file is reached */ + { + yy_cp = yyg->yy_c_buf_p; + + /* Support of yytext. */ + *yy_cp = yyg->yy_hold_char; + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = yyg->yy_start; + yy_current_state += YY_AT_BOL(); +yy_match: + do + { + register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 836 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + ++yy_cp; + } + while ( yy_current_state != 835 ); + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + + YY_DO_BEFORE_ACTION; + +do_action: /* This label is used only to access EOF actions. */ + + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = yyg->yy_hold_char; + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; + goto yy_find_action; + +case 1: +YY_RULE_SETUP +#line 103 "src/glsl/glsl_lexer.ll" +; + YY_BREAK +/* Preprocessor tokens. */ +case 2: +*yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */ +yyg->yy_c_buf_p = yy_cp -= 1; +YY_DO_BEFORE_ACTION; /* set up yytext again */ +YY_RULE_SETUP +#line 106 "src/glsl/glsl_lexer.ll" +; + YY_BREAK +case 3: +YY_RULE_SETUP +#line 107 "src/glsl/glsl_lexer.ll" +{ BEGIN PP; return VERSION; } + YY_BREAK +case 4: +YY_RULE_SETUP +#line 108 "src/glsl/glsl_lexer.ll" +{ BEGIN PP; return EXTENSION; } + YY_BREAK +case 5: +*yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */ +yyg->yy_c_buf_p = yy_cp -= 1; +YY_DO_BEFORE_ACTION; /* set up yytext again */ +YY_RULE_SETUP +#line 109 "src/glsl/glsl_lexer.ll" +{ + /* Eat characters until the first digit is + * encountered + */ + char *ptr = yytext; + while (!isdigit(*ptr)) + ptr++; + + /* Subtract one from the line number because + * yylineno is zero-based instead of + * one-based. + */ + yylineno = strtol(ptr, &ptr, 0) - 1; + yylloc->source = strtol(ptr, NULL, 0); + } + YY_BREAK +case 6: +*yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */ +yyg->yy_c_buf_p = yy_cp -= 1; +YY_DO_BEFORE_ACTION; /* set up yytext again */ +YY_RULE_SETUP +#line 124 "src/glsl/glsl_lexer.ll" +{ + /* Eat characters until the first digit is + * encountered + */ + char *ptr = yytext; + while (!isdigit(*ptr)) + ptr++; + + /* Subtract one from the line number because + * yylineno is zero-based instead of + * one-based. + */ + yylineno = strtol(ptr, &ptr, 0) - 1; + } + YY_BREAK +case 7: +YY_RULE_SETUP +#line 138 "src/glsl/glsl_lexer.ll" +{ + BEGIN PP; + return PRAGMA_DEBUG_ON; + } + YY_BREAK +case 8: +YY_RULE_SETUP +#line 142 "src/glsl/glsl_lexer.ll" +{ + BEGIN PP; + return PRAGMA_DEBUG_OFF; + } + YY_BREAK +case 9: +YY_RULE_SETUP +#line 146 "src/glsl/glsl_lexer.ll" +{ + BEGIN PP; + return PRAGMA_OPTIMIZE_ON; + } + YY_BREAK +case 10: +YY_RULE_SETUP +#line 150 "src/glsl/glsl_lexer.ll" +{ + BEGIN PP; + return PRAGMA_OPTIMIZE_OFF; + } + YY_BREAK +case 11: +YY_RULE_SETUP +#line 154 "src/glsl/glsl_lexer.ll" +{ + BEGIN PP; + return PRAGMA_INVARIANT_ALL; + } + YY_BREAK +case 12: +YY_RULE_SETUP +#line 158 "src/glsl/glsl_lexer.ll" +{ BEGIN PRAGMA; } + YY_BREAK +case 13: +/* rule 13 can match eol */ +YY_RULE_SETUP +#line 160 "src/glsl/glsl_lexer.ll" +{ BEGIN 0; yylineno++; yycolumn = 0; } + YY_BREAK +case 14: +YY_RULE_SETUP +#line 161 "src/glsl/glsl_lexer.ll" +{ } + YY_BREAK +case 15: +YY_RULE_SETUP +#line 163 "src/glsl/glsl_lexer.ll" +{ } + YY_BREAK +case 16: +YY_RULE_SETUP +#line 164 "src/glsl/glsl_lexer.ll" +{ } + YY_BREAK +case 17: +YY_RULE_SETUP +#line 165 "src/glsl/glsl_lexer.ll" +return COLON; + YY_BREAK +case 18: +YY_RULE_SETUP +#line 166 "src/glsl/glsl_lexer.ll" +{ + yylval->identifier = strdup(yytext); + return IDENTIFIER; + } + YY_BREAK +case 19: +YY_RULE_SETUP +#line 170 "src/glsl/glsl_lexer.ll" +{ + yylval->n = strtol(yytext, NULL, 10); + return INTCONSTANT; + } + YY_BREAK +case 20: +/* rule 20 can match eol */ +YY_RULE_SETUP +#line 174 "src/glsl/glsl_lexer.ll" +{ BEGIN 0; yylineno++; yycolumn = 0; return EOL; } + YY_BREAK +case 21: +/* rule 21 can match eol */ +YY_RULE_SETUP +#line 176 "src/glsl/glsl_lexer.ll" +{ yylineno++; yycolumn = 0; } + YY_BREAK +case 22: +YY_RULE_SETUP +#line 178 "src/glsl/glsl_lexer.ll" +return ATTRIBUTE; + YY_BREAK +case 23: +YY_RULE_SETUP +#line 179 "src/glsl/glsl_lexer.ll" +return CONST_TOK; + YY_BREAK +case 24: +YY_RULE_SETUP +#line 180 "src/glsl/glsl_lexer.ll" +return BOOL_TOK; + YY_BREAK +case 25: +YY_RULE_SETUP +#line 181 "src/glsl/glsl_lexer.ll" +return FLOAT_TOK; + YY_BREAK +case 26: +YY_RULE_SETUP +#line 182 "src/glsl/glsl_lexer.ll" +return INT_TOK; + YY_BREAK +case 27: +YY_RULE_SETUP +#line 183 "src/glsl/glsl_lexer.ll" +KEYWORD(130, 130, UINT_TOK); + YY_BREAK +case 28: +YY_RULE_SETUP +#line 185 "src/glsl/glsl_lexer.ll" +return BREAK; + YY_BREAK +case 29: +YY_RULE_SETUP +#line 186 "src/glsl/glsl_lexer.ll" +return CONTINUE; + YY_BREAK +case 30: +YY_RULE_SETUP +#line 187 "src/glsl/glsl_lexer.ll" +return DO; + YY_BREAK +case 31: +YY_RULE_SETUP +#line 188 "src/glsl/glsl_lexer.ll" +return WHILE; + YY_BREAK +case 32: +YY_RULE_SETUP +#line 189 "src/glsl/glsl_lexer.ll" +return ELSE; + YY_BREAK +case 33: +YY_RULE_SETUP +#line 190 "src/glsl/glsl_lexer.ll" +return FOR; + YY_BREAK +case 34: +YY_RULE_SETUP +#line 191 "src/glsl/glsl_lexer.ll" +return IF; + YY_BREAK +case 35: +YY_RULE_SETUP +#line 192 "src/glsl/glsl_lexer.ll" +return DISCARD; + YY_BREAK +case 36: +YY_RULE_SETUP +#line 193 "src/glsl/glsl_lexer.ll" +return RETURN; + YY_BREAK +case 37: +YY_RULE_SETUP +#line 195 "src/glsl/glsl_lexer.ll" +return BVEC2; + YY_BREAK +case 38: +YY_RULE_SETUP +#line 196 "src/glsl/glsl_lexer.ll" +return BVEC3; + YY_BREAK +case 39: +YY_RULE_SETUP +#line 197 "src/glsl/glsl_lexer.ll" +return BVEC4; + YY_BREAK +case 40: +YY_RULE_SETUP +#line 198 "src/glsl/glsl_lexer.ll" +return IVEC2; + YY_BREAK +case 41: +YY_RULE_SETUP +#line 199 "src/glsl/glsl_lexer.ll" +return IVEC3; + YY_BREAK +case 42: +YY_RULE_SETUP +#line 200 "src/glsl/glsl_lexer.ll" +return IVEC4; + YY_BREAK +case 43: +YY_RULE_SETUP +#line 201 "src/glsl/glsl_lexer.ll" +KEYWORD(130, 130, UVEC2); + YY_BREAK +case 44: +YY_RULE_SETUP +#line 202 "src/glsl/glsl_lexer.ll" +KEYWORD(130, 130, UVEC3); + YY_BREAK +case 45: +YY_RULE_SETUP +#line 203 "src/glsl/glsl_lexer.ll" +KEYWORD(130, 130, UVEC4); + YY_BREAK +case 46: +YY_RULE_SETUP +#line 204 "src/glsl/glsl_lexer.ll" +return VEC2; + YY_BREAK +case 47: +YY_RULE_SETUP +#line 205 "src/glsl/glsl_lexer.ll" +return VEC3; + YY_BREAK +case 48: +YY_RULE_SETUP +#line 206 "src/glsl/glsl_lexer.ll" +return VEC4; + YY_BREAK +case 49: +YY_RULE_SETUP +#line 207 "src/glsl/glsl_lexer.ll" +return MAT2X2; + YY_BREAK +case 50: +YY_RULE_SETUP +#line 208 "src/glsl/glsl_lexer.ll" +return MAT3X3; + YY_BREAK +case 51: +YY_RULE_SETUP +#line 209 "src/glsl/glsl_lexer.ll" +return MAT4X4; + YY_BREAK +case 52: +YY_RULE_SETUP +#line 210 "src/glsl/glsl_lexer.ll" +KEYWORD(120, 120, MAT2X2); + YY_BREAK +case 53: +YY_RULE_SETUP +#line 211 "src/glsl/glsl_lexer.ll" +KEYWORD(120, 120, MAT2X3); + YY_BREAK +case 54: +YY_RULE_SETUP +#line 212 "src/glsl/glsl_lexer.ll" +KEYWORD(120, 120, MAT2X4); + YY_BREAK +case 55: +YY_RULE_SETUP +#line 213 "src/glsl/glsl_lexer.ll" +KEYWORD(120, 120, MAT3X2); + YY_BREAK +case 56: +YY_RULE_SETUP +#line 214 "src/glsl/glsl_lexer.ll" +KEYWORD(120, 120, MAT3X3); + YY_BREAK +case 57: +YY_RULE_SETUP +#line 215 "src/glsl/glsl_lexer.ll" +KEYWORD(120, 120, MAT3X4); + YY_BREAK +case 58: +YY_RULE_SETUP +#line 216 "src/glsl/glsl_lexer.ll" +KEYWORD(120, 120, MAT4X2); + YY_BREAK +case 59: +YY_RULE_SETUP +#line 217 "src/glsl/glsl_lexer.ll" +KEYWORD(120, 120, MAT4X3); + YY_BREAK +case 60: +YY_RULE_SETUP +#line 218 "src/glsl/glsl_lexer.ll" +KEYWORD(120, 120, MAT4X4); + YY_BREAK +case 61: +YY_RULE_SETUP +#line 220 "src/glsl/glsl_lexer.ll" +return IN_TOK; + YY_BREAK +case 62: +YY_RULE_SETUP +#line 221 "src/glsl/glsl_lexer.ll" +return OUT_TOK; + YY_BREAK +case 63: +YY_RULE_SETUP +#line 222 "src/glsl/glsl_lexer.ll" +return INOUT_TOK; + YY_BREAK +case 64: +YY_RULE_SETUP +#line 223 "src/glsl/glsl_lexer.ll" +return UNIFORM; + YY_BREAK +case 65: +YY_RULE_SETUP +#line 224 "src/glsl/glsl_lexer.ll" +return VARYING; + YY_BREAK +case 66: +YY_RULE_SETUP +#line 225 "src/glsl/glsl_lexer.ll" +KEYWORD(120, 120, CENTROID); + YY_BREAK +case 67: +YY_RULE_SETUP +#line 226 "src/glsl/glsl_lexer.ll" +KEYWORD(120 || ES, 120 || ES, INVARIANT); + YY_BREAK +case 68: +YY_RULE_SETUP +#line 227 "src/glsl/glsl_lexer.ll" +KEYWORD(130 || ES, 130, FLAT); + YY_BREAK +case 69: +YY_RULE_SETUP +#line 228 "src/glsl/glsl_lexer.ll" +KEYWORD(130, 130, SMOOTH); + YY_BREAK +case 70: +YY_RULE_SETUP +#line 229 "src/glsl/glsl_lexer.ll" +KEYWORD(130, 130, NOPERSPECTIVE); + YY_BREAK +case 71: +YY_RULE_SETUP +#line 231 "src/glsl/glsl_lexer.ll" +return SAMPLER1D; + YY_BREAK +case 72: +YY_RULE_SETUP +#line 232 "src/glsl/glsl_lexer.ll" +return SAMPLER2D; + YY_BREAK +case 73: +YY_RULE_SETUP +#line 233 "src/glsl/glsl_lexer.ll" +return SAMPLER3D; + YY_BREAK +case 74: +YY_RULE_SETUP +#line 234 "src/glsl/glsl_lexer.ll" +return SAMPLERCUBE; + YY_BREAK +case 75: +YY_RULE_SETUP +#line 235 "src/glsl/glsl_lexer.ll" +KEYWORD(130, 130, SAMPLER1DARRAY); + YY_BREAK +case 76: +YY_RULE_SETUP +#line 236 "src/glsl/glsl_lexer.ll" +KEYWORD(130, 130, SAMPLER2DARRAY); + YY_BREAK +case 77: +YY_RULE_SETUP +#line 237 "src/glsl/glsl_lexer.ll" +return SAMPLER1DSHADOW; + YY_BREAK +case 78: +YY_RULE_SETUP +#line 238 "src/glsl/glsl_lexer.ll" +return SAMPLER2DSHADOW; + YY_BREAK +case 79: +YY_RULE_SETUP +#line 239 "src/glsl/glsl_lexer.ll" +KEYWORD(130, 130, SAMPLERCUBESHADOW); + YY_BREAK +case 80: +YY_RULE_SETUP +#line 240 "src/glsl/glsl_lexer.ll" +KEYWORD(130, 130, SAMPLER1DARRAYSHADOW); + YY_BREAK +case 81: +YY_RULE_SETUP +#line 241 "src/glsl/glsl_lexer.ll" +KEYWORD(130, 130, SAMPLER2DARRAYSHADOW); + YY_BREAK +case 82: +YY_RULE_SETUP +#line 242 "src/glsl/glsl_lexer.ll" +KEYWORD(130, 130, ISAMPLER1D); + YY_BREAK +case 83: +YY_RULE_SETUP +#line 243 "src/glsl/glsl_lexer.ll" +KEYWORD(130, 130, ISAMPLER2D); + YY_BREAK +case 84: +YY_RULE_SETUP +#line 244 "src/glsl/glsl_lexer.ll" +KEYWORD(130, 130, ISAMPLER3D); + YY_BREAK +case 85: +YY_RULE_SETUP +#line 245 "src/glsl/glsl_lexer.ll" +KEYWORD(130, 130, ISAMPLERCUBE); + YY_BREAK +case 86: +YY_RULE_SETUP +#line 246 "src/glsl/glsl_lexer.ll" +KEYWORD(130, 130, ISAMPLER1DARRAY); + YY_BREAK +case 87: +YY_RULE_SETUP +#line 247 "src/glsl/glsl_lexer.ll" +KEYWORD(130, 130, ISAMPLER2DARRAY); + YY_BREAK +case 88: +YY_RULE_SETUP +#line 248 "src/glsl/glsl_lexer.ll" +KEYWORD(130, 130, USAMPLER1D); + YY_BREAK +case 89: +YY_RULE_SETUP +#line 249 "src/glsl/glsl_lexer.ll" +KEYWORD(130, 130, USAMPLER2D); + YY_BREAK +case 90: +YY_RULE_SETUP +#line 250 "src/glsl/glsl_lexer.ll" +KEYWORD(130, 130, USAMPLER3D); + YY_BREAK +case 91: +YY_RULE_SETUP +#line 251 "src/glsl/glsl_lexer.ll" +KEYWORD(130, 130, USAMPLERCUBE); + YY_BREAK +case 92: +YY_RULE_SETUP +#line 252 "src/glsl/glsl_lexer.ll" +KEYWORD(130, 130, USAMPLER1DARRAY); + YY_BREAK +case 93: +YY_RULE_SETUP +#line 253 "src/glsl/glsl_lexer.ll" +KEYWORD(130, 130, USAMPLER2DARRAY); + YY_BREAK +case 94: +YY_RULE_SETUP +#line 256 "src/glsl/glsl_lexer.ll" +return STRUCT; + YY_BREAK +case 95: +YY_RULE_SETUP +#line 257 "src/glsl/glsl_lexer.ll" +return VOID_TOK; + YY_BREAK +case 96: +YY_RULE_SETUP +#line 259 "src/glsl/glsl_lexer.ll" +{ + if ((yyextra->language_version >= 140) + || yyextra->AMD_conservative_depth_enable + || yyextra->ARB_explicit_attrib_location_enable + || yyextra->ARB_fragment_coord_conventions_enable) { + return LAYOUT_TOK; + } else { + yylval->identifier = strdup(yytext); + return IDENTIFIER; + } + } + YY_BREAK +case 97: +YY_RULE_SETUP +#line 271 "src/glsl/glsl_lexer.ll" +return INC_OP; + YY_BREAK +case 98: +YY_RULE_SETUP +#line 272 "src/glsl/glsl_lexer.ll" +return DEC_OP; + YY_BREAK +case 99: +YY_RULE_SETUP +#line 273 "src/glsl/glsl_lexer.ll" +return LE_OP; + YY_BREAK +case 100: +YY_RULE_SETUP +#line 274 "src/glsl/glsl_lexer.ll" +return GE_OP; + YY_BREAK +case 101: +YY_RULE_SETUP +#line 275 "src/glsl/glsl_lexer.ll" +return EQ_OP; + YY_BREAK +case 102: +YY_RULE_SETUP +#line 276 "src/glsl/glsl_lexer.ll" +return NE_OP; + YY_BREAK +case 103: +YY_RULE_SETUP +#line 277 "src/glsl/glsl_lexer.ll" +return AND_OP; + YY_BREAK +case 104: +YY_RULE_SETUP +#line 278 "src/glsl/glsl_lexer.ll" +return OR_OP; + YY_BREAK +case 105: +YY_RULE_SETUP +#line 279 "src/glsl/glsl_lexer.ll" +return XOR_OP; + YY_BREAK +case 106: +YY_RULE_SETUP +#line 280 "src/glsl/glsl_lexer.ll" +return LEFT_OP; + YY_BREAK +case 107: +YY_RULE_SETUP +#line 281 "src/glsl/glsl_lexer.ll" +return RIGHT_OP; + YY_BREAK +case 108: +YY_RULE_SETUP +#line 283 "src/glsl/glsl_lexer.ll" +return MUL_ASSIGN; + YY_BREAK +case 109: +YY_RULE_SETUP +#line 284 "src/glsl/glsl_lexer.ll" +return DIV_ASSIGN; + YY_BREAK +case 110: +YY_RULE_SETUP +#line 285 "src/glsl/glsl_lexer.ll" +return ADD_ASSIGN; + YY_BREAK +case 111: +YY_RULE_SETUP +#line 286 "src/glsl/glsl_lexer.ll" +return MOD_ASSIGN; + YY_BREAK +case 112: +YY_RULE_SETUP +#line 287 "src/glsl/glsl_lexer.ll" +return LEFT_ASSIGN; + YY_BREAK +case 113: +YY_RULE_SETUP +#line 288 "src/glsl/glsl_lexer.ll" +return RIGHT_ASSIGN; + YY_BREAK +case 114: +YY_RULE_SETUP +#line 289 "src/glsl/glsl_lexer.ll" +return AND_ASSIGN; + YY_BREAK +case 115: +YY_RULE_SETUP +#line 290 "src/glsl/glsl_lexer.ll" +return XOR_ASSIGN; + YY_BREAK +case 116: +YY_RULE_SETUP +#line 291 "src/glsl/glsl_lexer.ll" +return OR_ASSIGN; + YY_BREAK +case 117: +YY_RULE_SETUP +#line 292 "src/glsl/glsl_lexer.ll" +return SUB_ASSIGN; + YY_BREAK +case 118: +YY_RULE_SETUP +#line 294 "src/glsl/glsl_lexer.ll" +{ + yylval->n = strtol(yytext, NULL, 10); + return IS_UINT ? UINTCONSTANT : INTCONSTANT; + } + YY_BREAK +case 119: +YY_RULE_SETUP +#line 298 "src/glsl/glsl_lexer.ll" +{ + yylval->n = strtol(yytext + 2, NULL, 16); + return IS_UINT ? UINTCONSTANT : INTCONSTANT; + } + YY_BREAK +case 120: +YY_RULE_SETUP +#line 302 "src/glsl/glsl_lexer.ll" +{ + yylval->n = strtol(yytext, NULL, 8); + return IS_UINT ? UINTCONSTANT : INTCONSTANT; + } + YY_BREAK +case 121: +YY_RULE_SETUP +#line 307 "src/glsl/glsl_lexer.ll" +{ + yylval->real = glsl_strtod(yytext, NULL); + return FLOATCONSTANT; + } + YY_BREAK +case 122: +YY_RULE_SETUP +#line 311 "src/glsl/glsl_lexer.ll" +{ + yylval->real = glsl_strtod(yytext, NULL); + return FLOATCONSTANT; + } + YY_BREAK +case 123: +YY_RULE_SETUP +#line 315 "src/glsl/glsl_lexer.ll" +{ + yylval->real = glsl_strtod(yytext, NULL); + return FLOATCONSTANT; + } + YY_BREAK +case 124: +YY_RULE_SETUP +#line 319 "src/glsl/glsl_lexer.ll" +{ + yylval->real = glsl_strtod(yytext, NULL); + return FLOATCONSTANT; + } + YY_BREAK +case 125: +YY_RULE_SETUP +#line 323 "src/glsl/glsl_lexer.ll" +{ + yylval->real = glsl_strtod(yytext, NULL); + return FLOATCONSTANT; + } + YY_BREAK +case 126: +YY_RULE_SETUP +#line 328 "src/glsl/glsl_lexer.ll" +{ + yylval->n = 1; + return BOOLCONSTANT; + } + YY_BREAK +case 127: +YY_RULE_SETUP +#line 332 "src/glsl/glsl_lexer.ll" +{ + yylval->n = 0; + return BOOLCONSTANT; + } + YY_BREAK +/* Reserved words in GLSL 1.10. */ +case 128: +YY_RULE_SETUP +#line 339 "src/glsl/glsl_lexer.ll" +KEYWORD(110 || ES, 999, ASM); + YY_BREAK +case 129: +YY_RULE_SETUP +#line 340 "src/glsl/glsl_lexer.ll" +KEYWORD(110 || ES, 999, CLASS); + YY_BREAK +case 130: +YY_RULE_SETUP +#line 341 "src/glsl/glsl_lexer.ll" +KEYWORD(110 || ES, 999, UNION); + YY_BREAK +case 131: +YY_RULE_SETUP +#line 342 "src/glsl/glsl_lexer.ll" +KEYWORD(110 || ES, 999, ENUM); + YY_BREAK +case 132: +YY_RULE_SETUP +#line 343 "src/glsl/glsl_lexer.ll" +KEYWORD(110 || ES, 999, TYPEDEF); + YY_BREAK +case 133: +YY_RULE_SETUP +#line 344 "src/glsl/glsl_lexer.ll" +KEYWORD(110 || ES, 999, TEMPLATE); + YY_BREAK +case 134: +YY_RULE_SETUP +#line 345 "src/glsl/glsl_lexer.ll" +KEYWORD(110 || ES, 999, THIS); + YY_BREAK +case 135: +YY_RULE_SETUP +#line 346 "src/glsl/glsl_lexer.ll" +KEYWORD(110 || ES, 999, PACKED_TOK); + YY_BREAK +case 136: +YY_RULE_SETUP +#line 347 "src/glsl/glsl_lexer.ll" +KEYWORD(110 || ES, 999, GOTO); + YY_BREAK +case 137: +YY_RULE_SETUP +#line 348 "src/glsl/glsl_lexer.ll" +KEYWORD(110 || ES, 130, SWITCH); + YY_BREAK +case 138: +YY_RULE_SETUP +#line 349 "src/glsl/glsl_lexer.ll" +KEYWORD(110 || ES, 130, DEFAULT); + YY_BREAK +case 139: +YY_RULE_SETUP +#line 350 "src/glsl/glsl_lexer.ll" +KEYWORD(110 || ES, 999, INLINE_TOK); + YY_BREAK +case 140: +YY_RULE_SETUP +#line 351 "src/glsl/glsl_lexer.ll" +KEYWORD(110 || ES, 999, NOINLINE); + YY_BREAK +case 141: +YY_RULE_SETUP +#line 352 "src/glsl/glsl_lexer.ll" +KEYWORD(110 || ES, 999, VOLATILE); + YY_BREAK +case 142: +YY_RULE_SETUP +#line 353 "src/glsl/glsl_lexer.ll" +KEYWORD(110 || ES, 999, PUBLIC_TOK); + YY_BREAK +case 143: +YY_RULE_SETUP +#line 354 "src/glsl/glsl_lexer.ll" +KEYWORD(110 || ES, 999, STATIC); + YY_BREAK +case 144: +YY_RULE_SETUP +#line 355 "src/glsl/glsl_lexer.ll" +KEYWORD(110 || ES, 999, EXTERN); + YY_BREAK +case 145: +YY_RULE_SETUP +#line 356 "src/glsl/glsl_lexer.ll" +KEYWORD(110 || ES, 999, EXTERNAL); + YY_BREAK +case 146: +YY_RULE_SETUP +#line 357 "src/glsl/glsl_lexer.ll" +KEYWORD(110 || ES, 999, INTERFACE); + YY_BREAK +case 147: +YY_RULE_SETUP +#line 358 "src/glsl/glsl_lexer.ll" +KEYWORD(110 || ES, 999, LONG_TOK); + YY_BREAK +case 148: +YY_RULE_SETUP +#line 359 "src/glsl/glsl_lexer.ll" +KEYWORD(110 || ES, 999, SHORT_TOK); + YY_BREAK +case 149: +YY_RULE_SETUP +#line 360 "src/glsl/glsl_lexer.ll" +KEYWORD(110 || ES, 400, DOUBLE_TOK); + YY_BREAK +case 150: +YY_RULE_SETUP +#line 361 "src/glsl/glsl_lexer.ll" +KEYWORD(110 || ES, 999, HALF); + YY_BREAK +case 151: +YY_RULE_SETUP +#line 362 "src/glsl/glsl_lexer.ll" +KEYWORD(110 || ES, 999, FIXED_TOK); + YY_BREAK +case 152: +YY_RULE_SETUP +#line 363 "src/glsl/glsl_lexer.ll" +KEYWORD(110 || ES, 999, UNSIGNED); + YY_BREAK +case 153: +YY_RULE_SETUP +#line 364 "src/glsl/glsl_lexer.ll" +KEYWORD(110 || ES, 999, INPUT_TOK); + YY_BREAK +case 154: +YY_RULE_SETUP +#line 365 "src/glsl/glsl_lexer.ll" +KEYWORD(110 || ES, 999, OUTPUT); + YY_BREAK +case 155: +YY_RULE_SETUP +#line 366 "src/glsl/glsl_lexer.ll" +KEYWORD(110 || ES, 999, HVEC2); + YY_BREAK +case 156: +YY_RULE_SETUP +#line 367 "src/glsl/glsl_lexer.ll" +KEYWORD(110 || ES, 999, HVEC3); + YY_BREAK +case 157: +YY_RULE_SETUP +#line 368 "src/glsl/glsl_lexer.ll" +KEYWORD(110 || ES, 999, HVEC4); + YY_BREAK +case 158: +YY_RULE_SETUP +#line 369 "src/glsl/glsl_lexer.ll" +KEYWORD(110 || ES, 400, DVEC2); + YY_BREAK +case 159: +YY_RULE_SETUP +#line 370 "src/glsl/glsl_lexer.ll" +KEYWORD(110 || ES, 400, DVEC3); + YY_BREAK +case 160: +YY_RULE_SETUP +#line 371 "src/glsl/glsl_lexer.ll" +KEYWORD(110 || ES, 400, DVEC4); + YY_BREAK +case 161: +YY_RULE_SETUP +#line 372 "src/glsl/glsl_lexer.ll" +KEYWORD(110 || ES, 999, FVEC2); + YY_BREAK +case 162: +YY_RULE_SETUP +#line 373 "src/glsl/glsl_lexer.ll" +KEYWORD(110 || ES, 999, FVEC3); + YY_BREAK +case 163: +YY_RULE_SETUP +#line 374 "src/glsl/glsl_lexer.ll" +KEYWORD(110 || ES, 999, FVEC4); + YY_BREAK +case 164: +YY_RULE_SETUP +#line 375 "src/glsl/glsl_lexer.ll" +return SAMPLER2DRECT; + YY_BREAK +case 165: +YY_RULE_SETUP +#line 376 "src/glsl/glsl_lexer.ll" +KEYWORD(110 || ES, 999, SAMPLER3DRECT); + YY_BREAK +case 166: +YY_RULE_SETUP +#line 377 "src/glsl/glsl_lexer.ll" +return SAMPLER2DRECTSHADOW; + YY_BREAK +case 167: +YY_RULE_SETUP +#line 378 "src/glsl/glsl_lexer.ll" +KEYWORD(110 || ES, 999, SIZEOF); + YY_BREAK +case 168: +YY_RULE_SETUP +#line 379 "src/glsl/glsl_lexer.ll" +KEYWORD(110 || ES, 999, CAST); + YY_BREAK +case 169: +YY_RULE_SETUP +#line 380 "src/glsl/glsl_lexer.ll" +KEYWORD(110 || ES, 999, NAMESPACE); + YY_BREAK +case 170: +YY_RULE_SETUP +#line 381 "src/glsl/glsl_lexer.ll" +KEYWORD(110 || ES, 999, USING); + YY_BREAK +/* Additional reserved words in GLSL 1.20. */ +case 171: +YY_RULE_SETUP +#line 384 "src/glsl/glsl_lexer.ll" +KEYWORD(120, 130 || ES, LOWP); + YY_BREAK +case 172: +YY_RULE_SETUP +#line 385 "src/glsl/glsl_lexer.ll" +KEYWORD(120, 130 || ES, MEDIUMP); + YY_BREAK +case 173: +YY_RULE_SETUP +#line 386 "src/glsl/glsl_lexer.ll" +KEYWORD(120, 130 || ES, HIGHP); + YY_BREAK +case 174: +YY_RULE_SETUP +#line 387 "src/glsl/glsl_lexer.ll" +KEYWORD(120, 130 || ES, PRECISION); + YY_BREAK +/* Additional reserved words in GLSL 1.30. */ +case 175: +YY_RULE_SETUP +#line 390 "src/glsl/glsl_lexer.ll" +KEYWORD(130, 130, CASE); + YY_BREAK +case 176: +YY_RULE_SETUP +#line 391 "src/glsl/glsl_lexer.ll" +KEYWORD(130, 999, COMMON); + YY_BREAK +case 177: +YY_RULE_SETUP +#line 392 "src/glsl/glsl_lexer.ll" +KEYWORD(130, 999, PARTITION); + YY_BREAK +case 178: +YY_RULE_SETUP +#line 393 "src/glsl/glsl_lexer.ll" +KEYWORD(130, 999, ACTIVE); + YY_BREAK +case 179: +YY_RULE_SETUP +#line 394 "src/glsl/glsl_lexer.ll" +KEYWORD(130 || ES, 999, SUPERP); + YY_BREAK +case 180: +YY_RULE_SETUP +#line 395 "src/glsl/glsl_lexer.ll" +KEYWORD(130, 140, SAMPLERBUFFER); + YY_BREAK +case 181: +YY_RULE_SETUP +#line 396 "src/glsl/glsl_lexer.ll" +KEYWORD(130, 999, FILTER); + YY_BREAK +case 182: +YY_RULE_SETUP +#line 397 "src/glsl/glsl_lexer.ll" +KEYWORD(130, 999, IMAGE1D); + YY_BREAK +case 183: +YY_RULE_SETUP +#line 398 "src/glsl/glsl_lexer.ll" +KEYWORD(130, 999, IMAGE2D); + YY_BREAK +case 184: +YY_RULE_SETUP +#line 399 "src/glsl/glsl_lexer.ll" +KEYWORD(130, 999, IMAGE3D); + YY_BREAK +case 185: +YY_RULE_SETUP +#line 400 "src/glsl/glsl_lexer.ll" +KEYWORD(130, 999, IMAGECUBE); + YY_BREAK +case 186: +YY_RULE_SETUP +#line 401 "src/glsl/glsl_lexer.ll" +KEYWORD(130, 999, IIMAGE1D); + YY_BREAK +case 187: +YY_RULE_SETUP +#line 402 "src/glsl/glsl_lexer.ll" +KEYWORD(130, 999, IIMAGE2D); + YY_BREAK +case 188: +YY_RULE_SETUP +#line 403 "src/glsl/glsl_lexer.ll" +KEYWORD(130, 999, IIMAGE3D); + YY_BREAK +case 189: +YY_RULE_SETUP +#line 404 "src/glsl/glsl_lexer.ll" +KEYWORD(130, 999, IIMAGECUBE); + YY_BREAK +case 190: +YY_RULE_SETUP +#line 405 "src/glsl/glsl_lexer.ll" +KEYWORD(130, 999, UIMAGE1D); + YY_BREAK +case 191: +YY_RULE_SETUP +#line 406 "src/glsl/glsl_lexer.ll" +KEYWORD(130, 999, UIMAGE2D); + YY_BREAK +case 192: +YY_RULE_SETUP +#line 407 "src/glsl/glsl_lexer.ll" +KEYWORD(130, 999, UIMAGE3D); + YY_BREAK +case 193: +YY_RULE_SETUP +#line 408 "src/glsl/glsl_lexer.ll" +KEYWORD(130, 999, UIMAGECUBE); + YY_BREAK +case 194: +YY_RULE_SETUP +#line 409 "src/glsl/glsl_lexer.ll" +KEYWORD(130, 999, IMAGE1DARRAY); + YY_BREAK +case 195: +YY_RULE_SETUP +#line 410 "src/glsl/glsl_lexer.ll" +KEYWORD(130, 999, IMAGE2DARRAY); + YY_BREAK +case 196: +YY_RULE_SETUP +#line 411 "src/glsl/glsl_lexer.ll" +KEYWORD(130, 999, IIMAGE1DARRAY); + YY_BREAK +case 197: +YY_RULE_SETUP +#line 412 "src/glsl/glsl_lexer.ll" +KEYWORD(130, 999, IIMAGE2DARRAY); + YY_BREAK +case 198: +YY_RULE_SETUP +#line 413 "src/glsl/glsl_lexer.ll" +KEYWORD(130, 999, UIMAGE1DARRAY); + YY_BREAK +case 199: +YY_RULE_SETUP +#line 414 "src/glsl/glsl_lexer.ll" +KEYWORD(130, 999, UIMAGE2DARRAY); + YY_BREAK +case 200: +YY_RULE_SETUP +#line 415 "src/glsl/glsl_lexer.ll" +KEYWORD(130, 999, IMAGE1DSHADOW); + YY_BREAK +case 201: +YY_RULE_SETUP +#line 416 "src/glsl/glsl_lexer.ll" +KEYWORD(130, 999, IMAGE2DSHADOW); + YY_BREAK +case 202: +YY_RULE_SETUP +#line 417 "src/glsl/glsl_lexer.ll" +KEYWORD(130, 999, IMAGE1DARRAYSHADOW); + YY_BREAK +case 203: +YY_RULE_SETUP +#line 418 "src/glsl/glsl_lexer.ll" +KEYWORD(130, 999, IMAGE2DARRAYSHADOW); + YY_BREAK +case 204: +YY_RULE_SETUP +#line 419 "src/glsl/glsl_lexer.ll" +KEYWORD(130, 999, IMAGEBUFFER); + YY_BREAK +case 205: +YY_RULE_SETUP +#line 420 "src/glsl/glsl_lexer.ll" +KEYWORD(130, 999, IIMAGEBUFFER); + YY_BREAK +case 206: +YY_RULE_SETUP +#line 421 "src/glsl/glsl_lexer.ll" +KEYWORD(130, 999, UIMAGEBUFFER); + YY_BREAK +case 207: +YY_RULE_SETUP +#line 422 "src/glsl/glsl_lexer.ll" +KEYWORD(130, 999, ROW_MAJOR); + YY_BREAK +case 208: +YY_RULE_SETUP +#line 424 "src/glsl/glsl_lexer.ll" +{ + struct _mesa_glsl_parse_state *state = yyextra; + void *ctx = state; + yylval->identifier = ralloc_strdup(ctx, yytext); + return classify_identifier(state, yytext); + } + YY_BREAK +case 209: +YY_RULE_SETUP +#line 431 "src/glsl/glsl_lexer.ll" +{ return yytext[0]; } + YY_BREAK +case 210: +YY_RULE_SETUP +#line 433 "src/glsl/glsl_lexer.ll" +ECHO; + YY_BREAK +#line 2557 "src/glsl/glsl_lexer.cpp" +case YY_STATE_EOF(INITIAL): +case YY_STATE_EOF(PP): +case YY_STATE_EOF(PRAGMA): + yyterminate(); + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = yyg->yy_hold_char; + YY_RESTORE_YY_MORE_OFFSET + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * _mesa_glsl_lex(). If so, then we have to assure + * consistency between YY_CURRENT_BUFFER and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( yyscanner ); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner); + + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++yyg->yy_c_buf_p; + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer( yyscanner ) ) + { + case EOB_ACT_END_OF_FILE: + { + yyg->yy_did_buffer_switch_on_eof = 0; + + if ( _mesa_glsl_wrap(yyscanner ) ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! yyg->yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + yyg->yy_c_buf_p = + yyg->yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( yyscanner ); + + yy_cp = yyg->yy_c_buf_p; + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + yyg->yy_c_buf_p = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars]; + + yy_current_state = yy_get_previous_state( yyscanner ); + + yy_cp = yyg->yy_c_buf_p; + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ +} /* end of _mesa_glsl_lex */ + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ +static int yy_get_next_buffer (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + register char *source = yyg->yytext_ptr; + register int number_to_move, i; + int ret_val; + + if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr) - 1; + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0; + + else + { + yy_size_t num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = YY_CURRENT_BUFFER; + + int yy_c_buf_p_offset = + (int) (yyg->yy_c_buf_p - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + yy_size_t new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + _mesa_glsl_realloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ,yyscanner ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = 0; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + number_to_move - 1; + + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + yyg->yy_n_chars, num_to_read ); + + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + if ( yyg->yy_n_chars == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + _mesa_glsl_restart(yyin ,yyscanner); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + if ((yy_size_t) (yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + yy_size_t new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) _mesa_glsl_realloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ,yyscanner ); + if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + } + + yyg->yy_n_chars += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; + + yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + + return ret_val; +} + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + + static yy_state_type yy_get_previous_state (yyscan_t yyscanner) +{ + register yy_state_type yy_current_state; + register char *yy_cp; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + yy_current_state = yyg->yy_start; + yy_current_state += YY_AT_BOL(); + + for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp ) + { + register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 836 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + } + + return yy_current_state; +} + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner) +{ + register int yy_is_jam; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */ + register char *yy_cp = yyg->yy_c_buf_p; + + register YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 836 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + yy_is_jam = (yy_current_state == 835); + + return yy_is_jam ? 0 : yy_current_state; +} + +#ifndef YY_NO_INPUT +#ifdef __cplusplus + static int yyinput (yyscan_t yyscanner) +#else + static int input (yyscan_t yyscanner) +#endif + +{ + int c; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + *yyg->yy_c_buf_p = yyg->yy_hold_char; + + if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) + /* This was really a NUL. */ + *yyg->yy_c_buf_p = '\0'; + + else + { /* need more input */ + yy_size_t offset = yyg->yy_c_buf_p - yyg->yytext_ptr; + ++yyg->yy_c_buf_p; + + switch ( yy_get_next_buffer( yyscanner ) ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + _mesa_glsl_restart(yyin ,yyscanner); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + { + if ( _mesa_glsl_wrap(yyscanner ) ) + return 0; + + if ( ! yyg->yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(yyscanner); +#else + return input(yyscanner); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + yyg->yy_c_buf_p = yyg->yytext_ptr + offset; + break; + } + } + } + + c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */ + *yyg->yy_c_buf_p = '\0'; /* preserve yytext */ + yyg->yy_hold_char = *++yyg->yy_c_buf_p; + + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = (c == '\n'); + + return c; +} +#endif /* ifndef YY_NO_INPUT */ + +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * @param yyscanner The scanner object. + * @note This function does not reset the start condition to @c INITIAL . + */ + void _mesa_glsl_restart (FILE * input_file , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if ( ! YY_CURRENT_BUFFER ){ + _mesa_glsl_ensure_buffer_stack (yyscanner); + YY_CURRENT_BUFFER_LVALUE = + _mesa_glsl__create_buffer(yyin,YY_BUF_SIZE ,yyscanner); + } + + _mesa_glsl__init_buffer(YY_CURRENT_BUFFER,input_file ,yyscanner); + _mesa_glsl__load_buffer_state(yyscanner ); +} + +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * @param yyscanner The scanner object. + */ + void _mesa_glsl__switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* TODO. We should be able to replace this entire function body + * with + * _mesa_glsl_pop_buffer_state(); + * _mesa_glsl_push_buffer_state(new_buffer); + */ + _mesa_glsl_ensure_buffer_stack (yyscanner); + if ( YY_CURRENT_BUFFER == new_buffer ) + return; + + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *yyg->yy_c_buf_p = yyg->yy_hold_char; + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + _mesa_glsl__load_buffer_state(yyscanner ); + + /* We don't actually know whether we did this switch during + * EOF (_mesa_glsl_wrap()) processing, but the only time this flag + * is looked at is after _mesa_glsl_wrap() is called, so it's safe + * to go ahead and always set it. + */ + yyg->yy_did_buffer_switch_on_eof = 1; +} + +static void _mesa_glsl__load_buffer_state (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + yyg->yy_hold_char = *yyg->yy_c_buf_p; +} + +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * @param yyscanner The scanner object. + * @return the allocated buffer state. + */ + YY_BUFFER_STATE _mesa_glsl__create_buffer (FILE * file, int size , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) _mesa_glsl_alloc(sizeof( struct yy_buffer_state ) ,yyscanner ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in _mesa_glsl__create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) _mesa_glsl_alloc(b->yy_buf_size + 2 ,yyscanner ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in _mesa_glsl__create_buffer()" ); + + b->yy_is_our_buffer = 1; + + _mesa_glsl__init_buffer(b,file ,yyscanner); + + return b; +} + +/** Destroy the buffer. + * @param b a buffer created with _mesa_glsl__create_buffer() + * @param yyscanner The scanner object. + */ + void _mesa_glsl__delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if ( ! b ) + return; + + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + _mesa_glsl_free((void *) b->yy_ch_buf ,yyscanner ); + + _mesa_glsl_free((void *) b ,yyscanner ); +} + +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a _mesa_glsl_restart() or at EOF. + */ + static void _mesa_glsl__init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner) + +{ + int oerrno = errno; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + _mesa_glsl__flush_buffer(b ,yyscanner); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + + /* If b is the current buffer, then _mesa_glsl__init_buffer was _probably_ + * called from _mesa_glsl_restart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } + + b->yy_is_interactive = 0; + + errno = oerrno; +} + +/** Discard all buffered characters. On the next scan, YY_INPUT will be called. + * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. + * @param yyscanner The scanner object. + */ + void _mesa_glsl__flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == YY_CURRENT_BUFFER ) + _mesa_glsl__load_buffer_state(yyscanner ); +} + +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * @param yyscanner The scanner object. + */ +void _mesa_glsl_push_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if (new_buffer == NULL) + return; + + _mesa_glsl_ensure_buffer_stack(yyscanner); + + /* This block is copied from _mesa_glsl__switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *yyg->yy_c_buf_p = yyg->yy_hold_char; + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + yyg->yy_buffer_stack_top++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from _mesa_glsl__switch_to_buffer. */ + _mesa_glsl__load_buffer_state(yyscanner ); + yyg->yy_did_buffer_switch_on_eof = 1; +} + +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * @param yyscanner The scanner object. + */ +void _mesa_glsl_pop_buffer_state (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if (!YY_CURRENT_BUFFER) + return; + + _mesa_glsl__delete_buffer(YY_CURRENT_BUFFER ,yyscanner); + YY_CURRENT_BUFFER_LVALUE = NULL; + if (yyg->yy_buffer_stack_top > 0) + --yyg->yy_buffer_stack_top; + + if (YY_CURRENT_BUFFER) { + _mesa_glsl__load_buffer_state(yyscanner ); + yyg->yy_did_buffer_switch_on_eof = 1; + } +} + +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +static void _mesa_glsl_ensure_buffer_stack (yyscan_t yyscanner) +{ + yy_size_t num_to_alloc; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (!yyg->yy_buffer_stack) { + + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; + yyg->yy_buffer_stack = (struct yy_buffer_state**)_mesa_glsl_alloc + (num_to_alloc * sizeof(struct yy_buffer_state*) + , yyscanner); + if ( ! yyg->yy_buffer_stack ) + YY_FATAL_ERROR( "out of dynamic memory in _mesa_glsl_ensure_buffer_stack()" ); + + memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + yyg->yy_buffer_stack_max = num_to_alloc; + yyg->yy_buffer_stack_top = 0; + return; + } + + if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){ + + /* Increase the buffer to prepare for a possible push. */ + int grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = yyg->yy_buffer_stack_max + grow_size; + yyg->yy_buffer_stack = (struct yy_buffer_state**)_mesa_glsl_realloc + (yyg->yy_buffer_stack, + num_to_alloc * sizeof(struct yy_buffer_state*) + , yyscanner); + if ( ! yyg->yy_buffer_stack ) + YY_FATAL_ERROR( "out of dynamic memory in _mesa_glsl_ensure_buffer_stack()" ); + + /* zero only the new slots.*/ + memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); + yyg->yy_buffer_stack_max = num_to_alloc; + } +} + +/** Setup the input buffer state to scan directly from a user-specified character buffer. + * @param base the character buffer + * @param size the size in bytes of the character buffer + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE _mesa_glsl__scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + + if ( size < 2 || + base[size-2] != YY_END_OF_BUFFER_CHAR || + base[size-1] != YY_END_OF_BUFFER_CHAR ) + /* They forgot to leave room for the EOB's. */ + return 0; + + b = (YY_BUFFER_STATE) _mesa_glsl_alloc(sizeof( struct yy_buffer_state ) ,yyscanner ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in _mesa_glsl__scan_buffer()" ); + + b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ + b->yy_buf_pos = b->yy_ch_buf = base; + b->yy_is_our_buffer = 0; + b->yy_input_file = 0; + b->yy_n_chars = b->yy_buf_size; + b->yy_is_interactive = 0; + b->yy_at_bol = 1; + b->yy_fill_buffer = 0; + b->yy_buffer_status = YY_BUFFER_NEW; + + _mesa_glsl__switch_to_buffer(b ,yyscanner ); + + return b; +} + +/** Setup the input buffer state to scan a string. The next call to _mesa_glsl_lex() will + * scan from a @e copy of @a str. + * @param yystr a NUL-terminated string to scan + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + * @note If you want to scan bytes that may contain NUL values, then use + * _mesa_glsl__scan_bytes() instead. + */ +YY_BUFFER_STATE _mesa_glsl__scan_string (yyconst char * yystr , yyscan_t yyscanner) +{ + + return _mesa_glsl__scan_bytes(yystr,strlen(yystr) ,yyscanner); +} + +/** Setup the input buffer state to scan the given bytes. The next call to _mesa_glsl_lex() will + * scan from a @e copy of @a bytes. + * @param bytes the byte buffer to scan + * @param len the number of bytes in the buffer pointed to by @a bytes. + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE _mesa_glsl__scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + char *buf; + yy_size_t n, i; + + /* Get memory for full buffer, including space for trailing EOB's. */ + n = _yybytes_len + 2; + buf = (char *) _mesa_glsl_alloc(n ,yyscanner ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in _mesa_glsl__scan_bytes()" ); + + for ( i = 0; i < _yybytes_len; ++i ) + buf[i] = yybytes[i]; + + buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; + + b = _mesa_glsl__scan_buffer(buf,n ,yyscanner); + if ( ! b ) + YY_FATAL_ERROR( "bad buffer in _mesa_glsl__scan_bytes()" ); + + /* It's okay to grow etc. this buffer, and we should throw it + * away when we're done. + */ + b->yy_is_our_buffer = 1; + + return b; +} + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +static void yy_fatal_error (yyconst char* msg , yyscan_t yyscanner) +{ + (void) fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); +} + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + yytext[yyleng] = yyg->yy_hold_char; \ + yyg->yy_c_buf_p = yytext + yyless_macro_arg; \ + yyg->yy_hold_char = *yyg->yy_c_buf_p; \ + *yyg->yy_c_buf_p = '\0'; \ + yyleng = yyless_macro_arg; \ + } \ + while ( 0 ) + +/* Accessor methods (get/set functions) to struct members. */ + +/** Get the user-defined data for this scanner. + * @param yyscanner The scanner object. + */ +YY_EXTRA_TYPE _mesa_glsl_get_extra (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyextra; +} + +/** Get the current line number. + * @param yyscanner The scanner object. + */ +int _mesa_glsl_get_lineno (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (! YY_CURRENT_BUFFER) + return 0; + + return yylineno; +} + +/** Get the current column number. + * @param yyscanner The scanner object. + */ +int _mesa_glsl_get_column (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (! YY_CURRENT_BUFFER) + return 0; + + return yycolumn; +} + +/** Get the input stream. + * @param yyscanner The scanner object. + */ +FILE *_mesa_glsl_get_in (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyin; +} + +/** Get the output stream. + * @param yyscanner The scanner object. + */ +FILE *_mesa_glsl_get_out (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyout; +} + +/** Get the length of the current token. + * @param yyscanner The scanner object. + */ +yy_size_t _mesa_glsl_get_leng (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyleng; +} + +/** Get the current token. + * @param yyscanner The scanner object. + */ + +char *_mesa_glsl_get_text (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yytext; +} + +/** Set the user-defined data. This data is never touched by the scanner. + * @param user_defined The data to be associated with this scanner. + * @param yyscanner The scanner object. + */ +void _mesa_glsl_set_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyextra = user_defined ; +} + +/** Set the current line number. + * @param line_number + * @param yyscanner The scanner object. + */ +void _mesa_glsl_set_lineno (int line_number , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* lineno is only valid if an input buffer exists. */ + if (! YY_CURRENT_BUFFER ) + yy_fatal_error( "_mesa_glsl_set_lineno called with no buffer" , yyscanner); + + yylineno = line_number; +} + +/** Set the current column. + * @param line_number + * @param yyscanner The scanner object. + */ +void _mesa_glsl_set_column (int column_no , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* column is only valid if an input buffer exists. */ + if (! YY_CURRENT_BUFFER ) + yy_fatal_error( "_mesa_glsl_set_column called with no buffer" , yyscanner); + + yycolumn = column_no; +} + +/** Set the input stream. This does not discard the current + * input buffer. + * @param in_str A readable stream. + * @param yyscanner The scanner object. + * @see _mesa_glsl__switch_to_buffer + */ +void _mesa_glsl_set_in (FILE * in_str , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyin = in_str ; +} + +void _mesa_glsl_set_out (FILE * out_str , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyout = out_str ; +} + +int _mesa_glsl_get_debug (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yy_flex_debug; +} + +void _mesa_glsl_set_debug (int bdebug , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yy_flex_debug = bdebug ; +} + +/* Accessor methods for yylval and yylloc */ + +YYSTYPE * _mesa_glsl_get_lval (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yylval; +} + +void _mesa_glsl_set_lval (YYSTYPE * yylval_param , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yylval = yylval_param; +} + +YYLTYPE *_mesa_glsl_get_lloc (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yylloc; +} + +void _mesa_glsl_set_lloc (YYLTYPE * yylloc_param , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yylloc = yylloc_param; +} + +/* User-visible API */ + +/* _mesa_glsl_lex_init is special because it creates the scanner itself, so it is + * the ONLY reentrant function that doesn't take the scanner as the last argument. + * That's why we explicitly handle the declaration, instead of using our macros. + */ + +int _mesa_glsl_lex_init(yyscan_t* ptr_yy_globals) + +{ + if (ptr_yy_globals == NULL){ + errno = EINVAL; + return 1; + } + + *ptr_yy_globals = (yyscan_t) _mesa_glsl_alloc ( sizeof( struct yyguts_t ), NULL ); + + if (*ptr_yy_globals == NULL){ + errno = ENOMEM; + return 1; + } + + /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */ + memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); + + return yy_init_globals ( *ptr_yy_globals ); +} + +/* _mesa_glsl_lex_init_extra has the same functionality as _mesa_glsl_lex_init, but follows the + * convention of taking the scanner as the last argument. Note however, that + * this is a *pointer* to a scanner, as it will be allocated by this call (and + * is the reason, too, why this function also must handle its own declaration). + * The user defined value in the first argument will be available to _mesa_glsl_alloc in + * the yyextra field. + */ + +int _mesa_glsl_lex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globals ) + +{ + struct yyguts_t dummy_yyguts; + + _mesa_glsl_set_extra (yy_user_defined, &dummy_yyguts); + + if (ptr_yy_globals == NULL){ + errno = EINVAL; + return 1; + } + + *ptr_yy_globals = (yyscan_t) _mesa_glsl_alloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); + + if (*ptr_yy_globals == NULL){ + errno = ENOMEM; + return 1; + } + + /* By setting to 0xAA, we expose bugs in + yy_init_globals. Leave at 0x00 for releases. */ + memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); + + _mesa_glsl_set_extra (yy_user_defined, *ptr_yy_globals); + + return yy_init_globals ( *ptr_yy_globals ); +} + +static int yy_init_globals (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + /* Initialization is the same as for the non-reentrant scanner. + * This function is called from _mesa_glsl_lex_destroy(), so don't allocate here. + */ + + yyg->yy_buffer_stack = 0; + yyg->yy_buffer_stack_top = 0; + yyg->yy_buffer_stack_max = 0; + yyg->yy_c_buf_p = (char *) 0; + yyg->yy_init = 0; + yyg->yy_start = 0; + + yyg->yy_start_stack_ptr = 0; + yyg->yy_start_stack_depth = 0; + yyg->yy_start_stack = NULL; + +/* Defined in main.c */ +#ifdef YY_STDINIT + yyin = stdin; + yyout = stdout; +#else + yyin = (FILE *) 0; + yyout = (FILE *) 0; +#endif + + /* For future reference: Set errno on error, since we are called by + * _mesa_glsl_lex_init() + */ + return 0; +} + +/* _mesa_glsl_lex_destroy is for both reentrant and non-reentrant scanners. */ +int _mesa_glsl_lex_destroy (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* Pop the buffer stack, destroying each element. */ + while(YY_CURRENT_BUFFER){ + _mesa_glsl__delete_buffer(YY_CURRENT_BUFFER ,yyscanner ); + YY_CURRENT_BUFFER_LVALUE = NULL; + _mesa_glsl_pop_buffer_state(yyscanner); + } + + /* Destroy the stack itself. */ + _mesa_glsl_free(yyg->yy_buffer_stack ,yyscanner); + yyg->yy_buffer_stack = NULL; + + /* Destroy the start condition stack. */ + _mesa_glsl_free(yyg->yy_start_stack ,yyscanner ); + yyg->yy_start_stack = NULL; + + /* Reset the globals. This is important in a non-reentrant scanner so the next time + * _mesa_glsl_lex() is called, initialization will occur. */ + yy_init_globals( yyscanner); + + /* Destroy the main struct (reentrant only). */ + _mesa_glsl_free ( yyscanner , yyscanner ); + yyscanner = NULL; + return 0; +} + +/* + * Internal utility routines. + */ + +#ifndef yytext_ptr +static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner) +{ + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; +} +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner) +{ + register int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; +} +#endif + +void *_mesa_glsl_alloc (yy_size_t size , yyscan_t yyscanner) +{ + return (void *) malloc( size ); +} + +void *_mesa_glsl_realloc (void * ptr, yy_size_t size , yyscan_t yyscanner) +{ + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return (void *) realloc( (char *) ptr, size ); +} + +void _mesa_glsl_free (void * ptr , yyscan_t yyscanner) +{ + free( (char *) ptr ); /* see _mesa_glsl_realloc() for (char *) cast */ +} + +#define YYTABLES_NAME "yytables" + +#line 433 "src/glsl/glsl_lexer.ll" + + + +int +classify_identifier(struct _mesa_glsl_parse_state *state, const char *name) +{ + if (state->symbols->get_variable(name) || state->symbols->get_function(name)) + return IDENTIFIER; + else if (state->symbols->get_type(name)) + return TYPE_IDENTIFIER; + else + return NEW_IDENTIFIER; +} + +void +_mesa_glsl_lexer_ctor(struct _mesa_glsl_parse_state *state, const char *string) +{ + _mesa_glsl_lex_init_extra(state,& state->scanner); + _mesa_glsl__scan_string(string,state->scanner); +} + +void +_mesa_glsl_lexer_dtor(struct _mesa_glsl_parse_state *state) +{ + _mesa_glsl_lex_destroy(state->scanner); +} + diff --git a/3rdparty/glsl-optimizer/src/glsl/glsl_lexer.ll b/3rdparty/glsl-optimizer/src/glsl/glsl_lexer.ll new file mode 100644 index 000000000..43d1ae90b --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/glsl_lexer.ll @@ -0,0 +1,457 @@ +%{ +/* + * Copyright © 2008, 2009 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +#include +#include "strtod.h" +#include "ast.h" +#include "glsl_parser_extras.h" +#include "glsl_parser.h" + +static int classify_identifier(struct _mesa_glsl_parse_state *, const char *); + +#ifdef _MSC_VER +#define YY_NO_UNISTD_H +#endif + +#define YY_USER_ACTION \ + do { \ + yylloc->source = 0; \ + yylloc->first_column = yycolumn + 1; \ + yylloc->first_line = yylineno + 1; \ + yycolumn += yyleng; \ + } while(0); + +#define YY_USER_INIT yylineno = 0; yycolumn = 0; + +#define IS_UINT (yytext[yyleng - 1] == 'u' || yytext[yyleng - 1] == 'U') + +/* A macro for handling reserved words and keywords across language versions. + * + * Certain words start out as identifiers, become reserved words in + * later language revisions, and finally become language keywords. + * + * For example, consider the following lexer rule: + * samplerBuffer KEYWORD(130, 140, SAMPLERBUFFER) + * + * This means that "samplerBuffer" will be treated as: + * - a keyword (SAMPLERBUFFER token) ...in GLSL >= 1.40 + * - a reserved word - error ...in GLSL >= 1.30 + * - an identifier ...in GLSL < 1.30 + */ +#define KEYWORD(reserved_version, allowed_version, token) \ + do { \ + if (yyextra->language_version >= allowed_version) { \ + return token; \ + } else if (yyextra->language_version >= reserved_version) { \ + _mesa_glsl_error(yylloc, yyextra, \ + "Illegal use of reserved word `%s'", yytext); \ + return ERROR_TOK; \ + } else { \ + yylval->identifier = strdup(yytext); \ + return classify_identifier(yyextra, yytext); \ + } \ + } while (0) + +/* The ES macro can be used in KEYWORD checks: + * + * word KEYWORD(110 || ES, 400, TOKEN) + * ...means the word is reserved in GLSL ES 1.00, while + * + * word KEYWORD(110, 130 || ES, TOKEN) + * ...means the word is a legal keyword in GLSL ES 1.00. + */ +#define ES yyextra->es_shader +%} + +%option bison-bridge bison-locations reentrant noyywrap +%option nounput noyy_top_state +%option never-interactive +%option prefix="_mesa_glsl_" +%option extra-type="struct _mesa_glsl_parse_state *" + +%x PP PRAGMA + +DEC_INT [1-9][0-9]* +HEX_INT 0[xX][0-9a-fA-F]+ +OCT_INT 0[0-7]* +INT_T ({DEC_INT}|{HEX_INT}|{OCT_INT}) +SPC [ \t]* +SPCP [ \t]+ +HASH ^{SPC}#{SPC} +%% + +[ \r\t]+ ; + + /* Preprocessor tokens. */ +^[ \t]*#[ \t]*$ ; +^[ \t]*#[ \t]*version { BEGIN PP; return VERSION; } +^[ \t]*#[ \t]*extension { BEGIN PP; return EXTENSION; } +{HASH}line{SPCP}{INT_T}{SPCP}{INT_T}{SPC}$ { + /* Eat characters until the first digit is + * encountered + */ + char *ptr = yytext; + while (!isdigit(*ptr)) + ptr++; + + /* Subtract one from the line number because + * yylineno is zero-based instead of + * one-based. + */ + yylineno = strtol(ptr, &ptr, 0) - 1; + yylloc->source = strtol(ptr, NULL, 0); + } +{HASH}line{SPCP}{INT_T}{SPC}$ { + /* Eat characters until the first digit is + * encountered + */ + char *ptr = yytext; + while (!isdigit(*ptr)) + ptr++; + + /* Subtract one from the line number because + * yylineno is zero-based instead of + * one-based. + */ + yylineno = strtol(ptr, &ptr, 0) - 1; + } +^{SPC}#{SPC}pragma{SPCP}debug{SPC}\({SPC}on{SPC}\) { + BEGIN PP; + return PRAGMA_DEBUG_ON; + } +^{SPC}#{SPC}pragma{SPCP}debug{SPC}\({SPC}off{SPC}\) { + BEGIN PP; + return PRAGMA_DEBUG_OFF; + } +^{SPC}#{SPC}pragma{SPCP}optimize{SPC}\({SPC}on{SPC}\) { + BEGIN PP; + return PRAGMA_OPTIMIZE_ON; + } +^{SPC}#{SPC}pragma{SPCP}optimize{SPC}\({SPC}off{SPC}\) { + BEGIN PP; + return PRAGMA_OPTIMIZE_OFF; + } +^{SPC}#{SPC}pragma{SPCP}STDGL{SPCP}invariant{SPC}\({SPC}all{SPC}\) { + BEGIN PP; + return PRAGMA_INVARIANT_ALL; + } +^{SPC}#{SPC}pragma{SPCP} { BEGIN PRAGMA; } + +\n { BEGIN 0; yylineno++; yycolumn = 0; } +. { } + +\/\/[^\n]* { } +[ \t\r]* { } +: return COLON; +[_a-zA-Z][_a-zA-Z0-9]* { + yylval->identifier = strdup(yytext); + return IDENTIFIER; + } +[1-9][0-9]* { + yylval->n = strtol(yytext, NULL, 10); + return INTCONSTANT; + } +\n { BEGIN 0; yylineno++; yycolumn = 0; return EOL; } + +\n { yylineno++; yycolumn = 0; } + +attribute return ATTRIBUTE; +const return CONST_TOK; +bool return BOOL_TOK; +float return FLOAT_TOK; +int return INT_TOK; +uint KEYWORD(130, 130, UINT_TOK); + +break return BREAK; +continue return CONTINUE; +do return DO; +while return WHILE; +else return ELSE; +for return FOR; +if return IF; +discard return DISCARD; +return return RETURN; + +bvec2 return BVEC2; +bvec3 return BVEC3; +bvec4 return BVEC4; +ivec2 return IVEC2; +ivec3 return IVEC3; +ivec4 return IVEC4; +uvec2 KEYWORD(130, 130, UVEC2); +uvec3 KEYWORD(130, 130, UVEC3); +uvec4 KEYWORD(130, 130, UVEC4); +vec2 return VEC2; +vec3 return VEC3; +vec4 return VEC4; +mat2 return MAT2X2; +mat3 return MAT3X3; +mat4 return MAT4X4; +mat2x2 KEYWORD(120, 120, MAT2X2); +mat2x3 KEYWORD(120, 120, MAT2X3); +mat2x4 KEYWORD(120, 120, MAT2X4); +mat3x2 KEYWORD(120, 120, MAT3X2); +mat3x3 KEYWORD(120, 120, MAT3X3); +mat3x4 KEYWORD(120, 120, MAT3X4); +mat4x2 KEYWORD(120, 120, MAT4X2); +mat4x3 KEYWORD(120, 120, MAT4X3); +mat4x4 KEYWORD(120, 120, MAT4X4); + +in return IN_TOK; +out return OUT_TOK; +inout return INOUT_TOK; +uniform return UNIFORM; +varying return VARYING; +centroid KEYWORD(120, 120, CENTROID); +invariant KEYWORD(120 || ES, 120 || ES, INVARIANT); +flat KEYWORD(130 || ES, 130, FLAT); +smooth KEYWORD(130, 130, SMOOTH); +noperspective KEYWORD(130, 130, NOPERSPECTIVE); + +sampler1D return SAMPLER1D; +sampler2D return SAMPLER2D; +sampler3D return SAMPLER3D; +samplerCube return SAMPLERCUBE; +sampler1DArray KEYWORD(130, 130, SAMPLER1DARRAY); +sampler2DArray KEYWORD(130, 130, SAMPLER2DARRAY); +sampler1DShadow return SAMPLER1DSHADOW; +sampler2DShadow return SAMPLER2DSHADOW; +samplerCubeShadow KEYWORD(130, 130, SAMPLERCUBESHADOW); +sampler1DArrayShadow KEYWORD(130, 130, SAMPLER1DARRAYSHADOW); +sampler2DArrayShadow KEYWORD(130, 130, SAMPLER2DARRAYSHADOW); +isampler1D KEYWORD(130, 130, ISAMPLER1D); +isampler2D KEYWORD(130, 130, ISAMPLER2D); +isampler3D KEYWORD(130, 130, ISAMPLER3D); +isamplerCube KEYWORD(130, 130, ISAMPLERCUBE); +isampler1DArray KEYWORD(130, 130, ISAMPLER1DARRAY); +isampler2DArray KEYWORD(130, 130, ISAMPLER2DARRAY); +usampler1D KEYWORD(130, 130, USAMPLER1D); +usampler2D KEYWORD(130, 130, USAMPLER2D); +usampler3D KEYWORD(130, 130, USAMPLER3D); +usamplerCube KEYWORD(130, 130, USAMPLERCUBE); +usampler1DArray KEYWORD(130, 130, USAMPLER1DARRAY); +usampler2DArray KEYWORD(130, 130, USAMPLER2DARRAY); + + +struct return STRUCT; +void return VOID_TOK; + +layout { + if ((yyextra->language_version >= 140) + || yyextra->AMD_conservative_depth_enable + || yyextra->ARB_explicit_attrib_location_enable + || yyextra->ARB_fragment_coord_conventions_enable) { + return LAYOUT_TOK; + } else { + yylval->identifier = strdup(yytext); + return IDENTIFIER; + } + } + +\+\+ return INC_OP; +-- return DEC_OP; +\<= return LE_OP; +>= return GE_OP; +== return EQ_OP; +!= return NE_OP; +&& return AND_OP; +\|\| return OR_OP; +"^^" return XOR_OP; +"<<" return LEFT_OP; +">>" return RIGHT_OP; + +\*= return MUL_ASSIGN; +\/= return DIV_ASSIGN; +\+= return ADD_ASSIGN; +\%= return MOD_ASSIGN; +\<\<= return LEFT_ASSIGN; +>>= return RIGHT_ASSIGN; +&= return AND_ASSIGN; +"^=" return XOR_ASSIGN; +\|= return OR_ASSIGN; +-= return SUB_ASSIGN; + +[1-9][0-9]*[uU]? { + yylval->n = strtol(yytext, NULL, 10); + return IS_UINT ? UINTCONSTANT : INTCONSTANT; + } +0[xX][0-9a-fA-F]+[uU]? { + yylval->n = strtol(yytext + 2, NULL, 16); + return IS_UINT ? UINTCONSTANT : INTCONSTANT; + } +0[0-7]*[uU]? { + yylval->n = strtol(yytext, NULL, 8); + return IS_UINT ? UINTCONSTANT : INTCONSTANT; + } + +[0-9]+\.[0-9]+([eE][+-]?[0-9]+)?[fF]? { + yylval->real = glsl_strtod(yytext, NULL); + return FLOATCONSTANT; + } +\.[0-9]+([eE][+-]?[0-9]+)?[fF]? { + yylval->real = glsl_strtod(yytext, NULL); + return FLOATCONSTANT; + } +[0-9]+\.([eE][+-]?[0-9]+)?[fF]? { + yylval->real = glsl_strtod(yytext, NULL); + return FLOATCONSTANT; + } +[0-9]+[eE][+-]?[0-9]+[fF]? { + yylval->real = glsl_strtod(yytext, NULL); + return FLOATCONSTANT; + } +[0-9]+[fF] { + yylval->real = glsl_strtod(yytext, NULL); + return FLOATCONSTANT; + } + +true { + yylval->n = 1; + return BOOLCONSTANT; + } +false { + yylval->n = 0; + return BOOLCONSTANT; + } + + + /* Reserved words in GLSL 1.10. */ +asm KEYWORD(110 || ES, 999, ASM); +class KEYWORD(110 || ES, 999, CLASS); +union KEYWORD(110 || ES, 999, UNION); +enum KEYWORD(110 || ES, 999, ENUM); +typedef KEYWORD(110 || ES, 999, TYPEDEF); +template KEYWORD(110 || ES, 999, TEMPLATE); +this KEYWORD(110 || ES, 999, THIS); +packed KEYWORD(110 || ES, 999, PACKED_TOK); +goto KEYWORD(110 || ES, 999, GOTO); +switch KEYWORD(110 || ES, 130, SWITCH); +default KEYWORD(110 || ES, 130, DEFAULT); +inline KEYWORD(110 || ES, 999, INLINE_TOK); +noinline KEYWORD(110 || ES, 999, NOINLINE); +volatile KEYWORD(110 || ES, 999, VOLATILE); +public KEYWORD(110 || ES, 999, PUBLIC_TOK); +static KEYWORD(110 || ES, 999, STATIC); +extern KEYWORD(110 || ES, 999, EXTERN); +external KEYWORD(110 || ES, 999, EXTERNAL); +interface KEYWORD(110 || ES, 999, INTERFACE); +long KEYWORD(110 || ES, 999, LONG_TOK); +short KEYWORD(110 || ES, 999, SHORT_TOK); +double KEYWORD(110 || ES, 400, DOUBLE_TOK); +half KEYWORD(110 || ES, 999, HALF); +fixed KEYWORD(110 || ES, 999, FIXED_TOK); +unsigned KEYWORD(110 || ES, 999, UNSIGNED); +input KEYWORD(110 || ES, 999, INPUT_TOK); +output KEYWORD(110 || ES, 999, OUTPUT); +hvec2 KEYWORD(110 || ES, 999, HVEC2); +hvec3 KEYWORD(110 || ES, 999, HVEC3); +hvec4 KEYWORD(110 || ES, 999, HVEC4); +dvec2 KEYWORD(110 || ES, 400, DVEC2); +dvec3 KEYWORD(110 || ES, 400, DVEC3); +dvec4 KEYWORD(110 || ES, 400, DVEC4); +fvec2 KEYWORD(110 || ES, 999, FVEC2); +fvec3 KEYWORD(110 || ES, 999, FVEC3); +fvec4 KEYWORD(110 || ES, 999, FVEC4); +sampler2DRect return SAMPLER2DRECT; +sampler3DRect KEYWORD(110 || ES, 999, SAMPLER3DRECT); +sampler2DRectShadow return SAMPLER2DRECTSHADOW; +sizeof KEYWORD(110 || ES, 999, SIZEOF); +cast KEYWORD(110 || ES, 999, CAST); +namespace KEYWORD(110 || ES, 999, NAMESPACE); +using KEYWORD(110 || ES, 999, USING); + + /* Additional reserved words in GLSL 1.20. */ +lowp KEYWORD(120, 130 || ES, LOWP); +mediump KEYWORD(120, 130 || ES, MEDIUMP); +highp KEYWORD(120, 130 || ES, HIGHP); +precision KEYWORD(120, 130 || ES, PRECISION); + + /* Additional reserved words in GLSL 1.30. */ +case KEYWORD(130, 130, CASE); +common KEYWORD(130, 999, COMMON); +partition KEYWORD(130, 999, PARTITION); +active KEYWORD(130, 999, ACTIVE); +superp KEYWORD(130 || ES, 999, SUPERP); +samplerBuffer KEYWORD(130, 140, SAMPLERBUFFER); +filter KEYWORD(130, 999, FILTER); +image1D KEYWORD(130, 999, IMAGE1D); +image2D KEYWORD(130, 999, IMAGE2D); +image3D KEYWORD(130, 999, IMAGE3D); +imageCube KEYWORD(130, 999, IMAGECUBE); +iimage1D KEYWORD(130, 999, IIMAGE1D); +iimage2D KEYWORD(130, 999, IIMAGE2D); +iimage3D KEYWORD(130, 999, IIMAGE3D); +iimageCube KEYWORD(130, 999, IIMAGECUBE); +uimage1D KEYWORD(130, 999, UIMAGE1D); +uimage2D KEYWORD(130, 999, UIMAGE2D); +uimage3D KEYWORD(130, 999, UIMAGE3D); +uimageCube KEYWORD(130, 999, UIMAGECUBE); +image1DArray KEYWORD(130, 999, IMAGE1DARRAY); +image2DArray KEYWORD(130, 999, IMAGE2DARRAY); +iimage1DArray KEYWORD(130, 999, IIMAGE1DARRAY); +iimage2DArray KEYWORD(130, 999, IIMAGE2DARRAY); +uimage1DArray KEYWORD(130, 999, UIMAGE1DARRAY); +uimage2DArray KEYWORD(130, 999, UIMAGE2DARRAY); +image1DShadow KEYWORD(130, 999, IMAGE1DSHADOW); +image2DShadow KEYWORD(130, 999, IMAGE2DSHADOW); +image1DArrayShadow KEYWORD(130, 999, IMAGE1DARRAYSHADOW); +image2DArrayShadow KEYWORD(130, 999, IMAGE2DARRAYSHADOW); +imageBuffer KEYWORD(130, 999, IMAGEBUFFER); +iimageBuffer KEYWORD(130, 999, IIMAGEBUFFER); +uimageBuffer KEYWORD(130, 999, UIMAGEBUFFER); +row_major KEYWORD(130, 999, ROW_MAJOR); + +[_a-zA-Z][_a-zA-Z0-9]* { + struct _mesa_glsl_parse_state *state = yyextra; + void *ctx = state; + yylval->identifier = ralloc_strdup(ctx, yytext); + return classify_identifier(state, yytext); + } + +. { return yytext[0]; } + +%% + +int +classify_identifier(struct _mesa_glsl_parse_state *state, const char *name) +{ + if (state->symbols->get_variable(name) || state->symbols->get_function(name)) + return IDENTIFIER; + else if (state->symbols->get_type(name)) + return TYPE_IDENTIFIER; + else + return NEW_IDENTIFIER; +} + +void +_mesa_glsl_lexer_ctor(struct _mesa_glsl_parse_state *state, const char *string) +{ + yylex_init_extra(state, & state->scanner); + yy_scan_string(string, state->scanner); +} + +void +_mesa_glsl_lexer_dtor(struct _mesa_glsl_parse_state *state) +{ + yylex_destroy(state->scanner); +} diff --git a/3rdparty/glsl-optimizer/src/glsl/glsl_optimizer.cpp b/3rdparty/glsl-optimizer/src/glsl/glsl_optimizer.cpp new file mode 100644 index 000000000..bbfec67ab --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/glsl_optimizer.cpp @@ -0,0 +1,341 @@ +#include "glsl_optimizer.h" +#include "ast.h" +#include "glsl_parser_extras.h" +#include "glsl_parser.h" +#include "ir_optimization.h" +#include "ir_print_glsl_visitor.h" +#include "ir_print_visitor.h" +#include "loop_analysis.h" +#include "program.h" + + +extern "C" struct gl_shader * +_mesa_new_shader(struct gl_context *ctx, GLuint name, GLenum type); + + +static void +initialize_mesa_context(struct gl_context *ctx, gl_api api) +{ + memset(ctx, 0, sizeof(*ctx)); + + ctx->API = api; + + ctx->Extensions.ARB_draw_buffers = GL_TRUE; + ctx->Extensions.ARB_fragment_coord_conventions = GL_TRUE; + ctx->Extensions.EXT_texture_array = GL_TRUE; + ctx->Extensions.NV_texture_rectangle = GL_TRUE; + ctx->Extensions.ARB_shader_texture_lod = GL_TRUE; + + // Enable opengl es extensions we care about here + if (api == API_OPENGLES2) + { + ctx->Extensions.OES_standard_derivatives = GL_TRUE; + } + + + /* 1.10 minimums. */ + ctx->Const.MaxLights = 8; + ctx->Const.MaxClipPlanes = 8; + ctx->Const.MaxTextureUnits = 2; + + /* More than the 1.10 minimum to appease parser tests taken from + * apps that (hopefully) already checked the number of coords. + */ + ctx->Const.MaxTextureCoordUnits = 4; + + ctx->Const.VertexProgram.MaxAttribs = 16; + ctx->Const.VertexProgram.MaxUniformComponents = 512; + ctx->Const.MaxVarying = 8; + ctx->Const.MaxVertexTextureImageUnits = 0; + ctx->Const.MaxCombinedTextureImageUnits = 2; + ctx->Const.MaxTextureImageUnits = 2; + ctx->Const.FragmentProgram.MaxUniformComponents = 64; + + ctx->Const.MaxDrawBuffers = 2; + + ctx->Driver.NewShader = _mesa_new_shader; +} + + +struct glslopt_ctx { + glslopt_ctx (bool openglES) { + mem_ctx = ralloc_context (NULL); + initialize_mesa_context (&mesa_ctx, openglES ? API_OPENGLES2 : API_OPENGL); + } + ~glslopt_ctx() { + ralloc_free (mem_ctx); + } + struct gl_context mesa_ctx; + void* mem_ctx; +}; + +glslopt_ctx* glslopt_initialize (bool openglES) +{ + return new glslopt_ctx(openglES); +} + +void glslopt_cleanup (glslopt_ctx* ctx) +{ + delete ctx; + _mesa_glsl_release_types(); + _mesa_glsl_release_functions(); +} + + + +struct glslopt_shader { + static void* operator new(size_t size, void *ctx) + { + void *node; + node = ralloc_size(ctx, size); + assert(node != NULL); + return node; + } + static void operator delete(void *node) + { + ralloc_free(node); + } + + glslopt_shader () + : rawOutput(0) + , optimizedOutput(0) + , status(false) + { + infoLog = "Shader not compiled yet"; + } + + char* rawOutput; + char* optimizedOutput; + const char* infoLog; + bool status; +}; + +static inline void debug_print_ir (const char* name, exec_list* ir, _mesa_glsl_parse_state* state, void* memctx) +{ + #if 0 + printf("**** %s:\n", name); + //_mesa_print_ir (ir, state); + char* foobar = _mesa_print_ir_glsl(ir, state, ralloc_strdup(memctx, ""), kPrintGlslFragment); + printf(foobar); + validate_ir_tree(ir); + #endif +} + +static void propagate_precision_deref(ir_instruction *ir, void *data) +{ + ir_dereference_variable* der = ir->as_dereference_variable(); + if (der && der->get_precision() == glsl_precision_undefined && der->var->precision != glsl_precision_undefined) + { + der->set_precision ((glsl_precision)der->var->precision); + *(bool*)data = true; + } + ir_swizzle* swz = ir->as_swizzle(); + if (swz && swz->get_precision() == glsl_precision_undefined && swz->val->get_precision() != glsl_precision_undefined) + { + swz->set_precision (swz->val->get_precision()); + *(bool*)data = true; + } + +} + +static void propagate_precision_assign(ir_instruction *ir, void *data) +{ + ir_assignment* ass = ir->as_assignment(); + if (ass && ass->lhs && ass->rhs) + { + glsl_precision lp = ass->lhs->get_precision(); + glsl_precision rp = ass->rhs->get_precision(); + if (rp == glsl_precision_undefined) + return; + ir_variable* lhs_var = ass->lhs->variable_referenced(); + if (lp == glsl_precision_undefined) + { + if (lhs_var) + lhs_var->precision = rp; + ass->lhs->set_precision (rp); + *(bool*)data = true; + } + } +} + +static void propagate_precision_call(ir_instruction *ir, void *data) +{ + ir_call* call = ir->as_call(); + if (!call) + return; + if (call->get_precision() == glsl_precision_undefined /*&& call->get_callee()->precision == glsl_precision_undefined*/) + { + glsl_precision prec_params_max = glsl_precision_undefined; + exec_list_iterator iter_sig = call->get_callee()->parameters.iterator(); + foreach_iter(exec_list_iterator, iter_param, call->actual_parameters) + { + ir_variable* sig_param = (ir_variable*)iter_sig.get(); + ir_rvalue* param = (ir_rvalue*)iter_param.get(); + + glsl_precision p = (glsl_precision)sig_param->precision; + if (p == glsl_precision_undefined) + p = param->get_precision(); + + prec_params_max = higher_precision (prec_params_max, p); + + iter_sig.next(); + } + if (call->get_precision() != prec_params_max) + { + call->set_precision (prec_params_max); + *(bool*)data = true; + } + } +} + +static bool propagate_precision(exec_list* list) +{ + bool anyProgress = false; + bool res; + do { + res = false; + foreach_iter(exec_list_iterator, iter, *list) { + ir_instruction* ir = (ir_instruction*)iter.get(); + visit_tree (ir, propagate_precision_deref, &res); + visit_tree (ir, propagate_precision_assign, &res); + visit_tree (ir, propagate_precision_call, &res); + } + anyProgress |= res; + } while (res); + return anyProgress; +} + + +glslopt_shader* glslopt_optimize (glslopt_ctx* ctx, glslopt_shader_type type, const char* shaderSource, unsigned options) +{ + glslopt_shader* shader = new (ctx->mem_ctx) glslopt_shader (); + + GLenum glType = 0; + PrintGlslMode printMode; + switch (type) { + case kGlslOptShaderVertex: glType = GL_VERTEX_SHADER; printMode = kPrintGlslVertex; break; + case kGlslOptShaderFragment: glType = GL_FRAGMENT_SHADER; printMode = kPrintGlslFragment; break; + } + if (!glType) + { + shader->infoLog = ralloc_asprintf (ctx->mem_ctx, "Unknown shader type %d", (int)type); + shader->status = false; + return shader; + } + + _mesa_glsl_parse_state* state = new (ctx->mem_ctx) _mesa_glsl_parse_state (&ctx->mesa_ctx, glType, ctx->mem_ctx); + state->error = 0; + + if (!(options & kGlslOptionSkipPreprocessor)) + { + state->error = preprocess (state, &shaderSource, &state->info_log, state->extensions, ctx->mesa_ctx.API); + if (state->error) + { + shader->status = !state->error; + shader->infoLog = state->info_log; + return shader; + } + } + + _mesa_glsl_lexer_ctor (state, shaderSource); + _mesa_glsl_parse (state); + _mesa_glsl_lexer_dtor (state); + + exec_list* ir = new (ctx->mem_ctx) exec_list(); + + if (!state->error && !state->translation_unit.is_empty()) + _mesa_ast_to_hir (ir, state); + + // Un-optimized output + if (!state->error) { + validate_ir_tree(ir); + shader->rawOutput = _mesa_print_ir_glsl(ir, state, ralloc_strdup(ctx->mem_ctx, ""), printMode); + } + + // Optimization passes + const bool linked = !(options & kGlslOptionNotFullShader); + if (!state->error && !ir->is_empty()) + { + bool progress; + do { + progress = false; + bool progress2; + debug_print_ir ("Initial", ir, state, ctx->mem_ctx); + progress2 = do_function_inlining(ir); progress |= progress2; if (progress2) debug_print_ir ("After inlining", ir, state, ctx->mem_ctx); + progress2 = do_dead_functions(ir); progress |= progress2; if (progress2) debug_print_ir ("After dead functions", ir, state, ctx->mem_ctx); + progress2 = do_structure_splitting(ir); progress |= progress2; if (progress2) debug_print_ir ("After struct splitting", ir, state, ctx->mem_ctx); + progress2 = do_if_simplification(ir); progress |= progress2; if (progress2) debug_print_ir ("After if simpl", ir, state, ctx->mem_ctx); + progress2 = propagate_precision (ir); progress |= progress2; if (progress2) debug_print_ir ("After prec propagation", ir, state, ctx->mem_ctx); + progress2 = do_copy_propagation(ir); progress |= progress2; if (progress2) debug_print_ir ("After copy propagation", ir, state, ctx->mem_ctx); + progress2 = do_copy_propagation_elements(ir); progress |= progress2; if (progress2) debug_print_ir ("After copy propagation elems", ir, state, ctx->mem_ctx); + if (!linked) { + progress2 = do_dead_code_unlinked(ir); progress |= progress2; if (progress2) debug_print_ir ("After dead code unlinked", ir, state, ctx->mem_ctx); + } else { + progress2 = do_dead_code(ir); progress |= progress2; if (progress2) debug_print_ir ("After dead code", ir, state, ctx->mem_ctx); + } + progress2 = do_dead_code_local(ir); progress |= progress2; if (progress2) debug_print_ir ("After dead code local", ir, state, ctx->mem_ctx); + progress2 = propagate_precision (ir); progress |= progress2; if (progress2) debug_print_ir ("After prec propagation", ir, state, ctx->mem_ctx); + progress2 = do_tree_grafting(ir); progress |= progress2; if (progress2) debug_print_ir ("After tree grafting", ir, state, ctx->mem_ctx); + progress2 = do_constant_propagation(ir); progress |= progress2; if (progress2) debug_print_ir ("After const propagation", ir, state, ctx->mem_ctx); + if (!linked) { + progress2 = do_constant_variable_unlinked(ir); progress |= progress2; if (progress2) debug_print_ir ("After const variable unlinked", ir, state, ctx->mem_ctx); + } else { + progress2 = do_constant_variable(ir); progress |= progress2; if (progress2) debug_print_ir ("After const variable", ir, state, ctx->mem_ctx); + } + progress2 = do_constant_folding(ir); progress |= progress2; if (progress2) debug_print_ir ("After const folding", ir, state, ctx->mem_ctx); + progress2 = do_algebraic(ir); progress |= progress2; if (progress2) debug_print_ir ("After algebraic", ir, state, ctx->mem_ctx); + progress2 = do_lower_jumps(ir); progress |= progress2; if (progress2) debug_print_ir ("After lower jumps", ir, state, ctx->mem_ctx); + progress2 = do_vec_index_to_swizzle(ir); progress |= progress2; if (progress2) debug_print_ir ("After vec index to swizzle", ir, state, ctx->mem_ctx); + //progress2 = do_vec_index_to_cond_assign(ir); progress |= progress2; if (progress2) debug_print_ir ("After vec index to cond assign", ir, state, ctx->mem_ctx); + progress2 = do_swizzle_swizzle(ir); progress |= progress2; if (progress2) debug_print_ir ("After swizzle swizzle", ir, state, ctx->mem_ctx); + progress2 = do_noop_swizzle(ir); progress |= progress2; if (progress2) debug_print_ir ("After noop swizzle", ir, state, ctx->mem_ctx); + progress2 = optimize_redundant_jumps(ir); progress |= progress2; if (progress2) debug_print_ir ("After redundant jumps", ir, state, ctx->mem_ctx); + + loop_state *ls = analyze_loop_variables(ir); + progress2 = set_loop_controls(ir, ls); progress |= progress2; + progress2 = unroll_loops(ir, ls, 8); progress |= progress2; + delete ls; + } while (progress); + + validate_ir_tree(ir); + } + + // Final optimized output + if (!state->error) + { + shader->optimizedOutput = _mesa_print_ir_glsl(ir, state, ralloc_strdup(ctx->mem_ctx, ""), printMode); + } + + shader->status = !state->error; + shader->infoLog = state->info_log; + + ralloc_free (ir); + ralloc_free (state); + + return shader; +} + +void glslopt_shader_delete (glslopt_shader* shader) +{ + delete shader; +} + +bool glslopt_get_status (glslopt_shader* shader) +{ + return shader->status; +} + +const char* glslopt_get_output (glslopt_shader* shader) +{ + return shader->optimizedOutput; +} + +const char* glslopt_get_raw_output (glslopt_shader* shader) +{ + return shader->rawOutput; +} + +const char* glslopt_get_log (glslopt_shader* shader) +{ + return shader->infoLog; +} diff --git a/3rdparty/glsl-optimizer/src/glsl/glsl_optimizer.h b/3rdparty/glsl-optimizer/src/glsl/glsl_optimizer.h new file mode 100644 index 000000000..53e66c62b --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/glsl_optimizer.h @@ -0,0 +1,49 @@ +#pragma once +#ifndef GLSL_OPTIMIZER_H +#define GLSL_OPTIMIZER_H + +/* + Main GLSL optimizer interface. + See ../../README.md for more instructions. + + General usage: + + ctx = glslopt_initialize(); + for (lots of shaders) { + shader = glslopt_optimize (ctx, shaderType, shaderSource, options); + if (glslopt_get_status (shader)) { + newSource = glslopt_get_output (shader); + } else { + errorLog = glslopt_get_log (shader); + } + glslopt_shader_delete (shader); + } + glslopt_cleanup (ctx); +*/ + +struct glslopt_shader; +struct glslopt_ctx; + +enum glslopt_shader_type { + kGlslOptShaderVertex = 0, + kGlslOptShaderFragment, +}; + +// Options flags for glsl_optimize +enum glslopt_options { + kGlslOptionSkipPreprocessor = (1<<0), // Skip preprocessing shader source. Saves some time if you know you don't need it. + kGlslOptionNotFullShader = (1<<1), // Passed shader is not the full shader source. This makes some optimizations weaker. +}; + +glslopt_ctx* glslopt_initialize (bool openglES); +void glslopt_cleanup (glslopt_ctx* ctx); + +glslopt_shader* glslopt_optimize (glslopt_ctx* ctx, glslopt_shader_type type, const char* shaderSource, unsigned options); +bool glslopt_get_status (glslopt_shader* shader); +const char* glslopt_get_output (glslopt_shader* shader); +const char* glslopt_get_raw_output (glslopt_shader* shader); +const char* glslopt_get_log (glslopt_shader* shader); +void glslopt_shader_delete (glslopt_shader* shader); + + +#endif /* GLSL_OPTIMIZER_H */ diff --git a/3rdparty/glsl-optimizer/src/glsl/glsl_parser.cpp b/3rdparty/glsl-optimizer/src/glsl/glsl_parser.cpp new file mode 100644 index 000000000..02c2f6403 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/glsl_parser.cpp @@ -0,0 +1,5167 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton implementation for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* C LALR(1) parser skeleton written by Richard Stallman, by + simplifying the original so-called "semantic" parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Bison version. */ +#define YYBISON_VERSION "2.3" + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 1 + +/* Using locations. */ +#define YYLSP_NEEDED 1 + +/* Substitute the variable and function names. */ +#define yyparse _mesa_glsl_parse +#define yylex _mesa_glsl_lex +#define yyerror _mesa_glsl_error +#define yylval _mesa_glsl_lval +#define yychar _mesa_glsl_char +#define yydebug _mesa_glsl_debug +#define yynerrs _mesa_glsl_nerrs +#define yylloc _mesa_glsl_lloc + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + ATTRIBUTE = 258, + CONST_TOK = 259, + BOOL_TOK = 260, + FLOAT_TOK = 261, + INT_TOK = 262, + UINT_TOK = 263, + BREAK = 264, + CONTINUE = 265, + DO = 266, + ELSE = 267, + FOR = 268, + IF = 269, + DISCARD = 270, + RETURN = 271, + SWITCH = 272, + CASE = 273, + DEFAULT = 274, + BVEC2 = 275, + BVEC3 = 276, + BVEC4 = 277, + IVEC2 = 278, + IVEC3 = 279, + IVEC4 = 280, + UVEC2 = 281, + UVEC3 = 282, + UVEC4 = 283, + VEC2 = 284, + VEC3 = 285, + VEC4 = 286, + CENTROID = 287, + IN_TOK = 288, + OUT_TOK = 289, + INOUT_TOK = 290, + UNIFORM = 291, + VARYING = 292, + NOPERSPECTIVE = 293, + FLAT = 294, + SMOOTH = 295, + MAT2X2 = 296, + MAT2X3 = 297, + MAT2X4 = 298, + MAT3X2 = 299, + MAT3X3 = 300, + MAT3X4 = 301, + MAT4X2 = 302, + MAT4X3 = 303, + MAT4X4 = 304, + SAMPLER1D = 305, + SAMPLER2D = 306, + SAMPLER3D = 307, + SAMPLERCUBE = 308, + SAMPLER1DSHADOW = 309, + SAMPLER2DSHADOW = 310, + SAMPLERCUBESHADOW = 311, + SAMPLER1DARRAY = 312, + SAMPLER2DARRAY = 313, + SAMPLER1DARRAYSHADOW = 314, + SAMPLER2DARRAYSHADOW = 315, + ISAMPLER1D = 316, + ISAMPLER2D = 317, + ISAMPLER3D = 318, + ISAMPLERCUBE = 319, + ISAMPLER1DARRAY = 320, + ISAMPLER2DARRAY = 321, + USAMPLER1D = 322, + USAMPLER2D = 323, + USAMPLER3D = 324, + USAMPLERCUBE = 325, + USAMPLER1DARRAY = 326, + USAMPLER2DARRAY = 327, + STRUCT = 328, + VOID_TOK = 329, + WHILE = 330, + IDENTIFIER = 331, + TYPE_IDENTIFIER = 332, + NEW_IDENTIFIER = 333, + FLOATCONSTANT = 334, + INTCONSTANT = 335, + UINTCONSTANT = 336, + BOOLCONSTANT = 337, + FIELD_SELECTION = 338, + LEFT_OP = 339, + RIGHT_OP = 340, + INC_OP = 341, + DEC_OP = 342, + LE_OP = 343, + GE_OP = 344, + EQ_OP = 345, + NE_OP = 346, + AND_OP = 347, + OR_OP = 348, + XOR_OP = 349, + MUL_ASSIGN = 350, + DIV_ASSIGN = 351, + ADD_ASSIGN = 352, + MOD_ASSIGN = 353, + LEFT_ASSIGN = 354, + RIGHT_ASSIGN = 355, + AND_ASSIGN = 356, + XOR_ASSIGN = 357, + OR_ASSIGN = 358, + SUB_ASSIGN = 359, + INVARIANT = 360, + LOWP = 361, + MEDIUMP = 362, + HIGHP = 363, + SUPERP = 364, + PRECISION = 365, + VERSION = 366, + EXTENSION = 367, + LINE = 368, + COLON = 369, + EOL = 370, + INTERFACE = 371, + OUTPUT = 372, + PRAGMA_DEBUG_ON = 373, + PRAGMA_DEBUG_OFF = 374, + PRAGMA_OPTIMIZE_ON = 375, + PRAGMA_OPTIMIZE_OFF = 376, + PRAGMA_INVARIANT_ALL = 377, + LAYOUT_TOK = 378, + ASM = 379, + CLASS = 380, + UNION = 381, + ENUM = 382, + TYPEDEF = 383, + TEMPLATE = 384, + THIS = 385, + PACKED_TOK = 386, + GOTO = 387, + INLINE_TOK = 388, + NOINLINE = 389, + VOLATILE = 390, + PUBLIC_TOK = 391, + STATIC = 392, + EXTERN = 393, + EXTERNAL = 394, + LONG_TOK = 395, + SHORT_TOK = 396, + DOUBLE_TOK = 397, + HALF = 398, + FIXED_TOK = 399, + UNSIGNED = 400, + INPUT_TOK = 401, + OUPTUT = 402, + HVEC2 = 403, + HVEC3 = 404, + HVEC4 = 405, + DVEC2 = 406, + DVEC3 = 407, + DVEC4 = 408, + FVEC2 = 409, + FVEC3 = 410, + FVEC4 = 411, + SAMPLER2DRECT = 412, + SAMPLER3DRECT = 413, + SAMPLER2DRECTSHADOW = 414, + SIZEOF = 415, + CAST = 416, + NAMESPACE = 417, + USING = 418, + ERROR_TOK = 419, + COMMON = 420, + PARTITION = 421, + ACTIVE = 422, + SAMPLERBUFFER = 423, + FILTER = 424, + IMAGE1D = 425, + IMAGE2D = 426, + IMAGE3D = 427, + IMAGECUBE = 428, + IMAGE1DARRAY = 429, + IMAGE2DARRAY = 430, + IIMAGE1D = 431, + IIMAGE2D = 432, + IIMAGE3D = 433, + IIMAGECUBE = 434, + IIMAGE1DARRAY = 435, + IIMAGE2DARRAY = 436, + UIMAGE1D = 437, + UIMAGE2D = 438, + UIMAGE3D = 439, + UIMAGECUBE = 440, + UIMAGE1DARRAY = 441, + UIMAGE2DARRAY = 442, + IMAGE1DSHADOW = 443, + IMAGE2DSHADOW = 444, + IMAGEBUFFER = 445, + IIMAGEBUFFER = 446, + UIMAGEBUFFER = 447, + IMAGE1DARRAYSHADOW = 448, + IMAGE2DARRAYSHADOW = 449, + ROW_MAJOR = 450 + }; +#endif +/* Tokens. */ +#define ATTRIBUTE 258 +#define CONST_TOK 259 +#define BOOL_TOK 260 +#define FLOAT_TOK 261 +#define INT_TOK 262 +#define UINT_TOK 263 +#define BREAK 264 +#define CONTINUE 265 +#define DO 266 +#define ELSE 267 +#define FOR 268 +#define IF 269 +#define DISCARD 270 +#define RETURN 271 +#define SWITCH 272 +#define CASE 273 +#define DEFAULT 274 +#define BVEC2 275 +#define BVEC3 276 +#define BVEC4 277 +#define IVEC2 278 +#define IVEC3 279 +#define IVEC4 280 +#define UVEC2 281 +#define UVEC3 282 +#define UVEC4 283 +#define VEC2 284 +#define VEC3 285 +#define VEC4 286 +#define CENTROID 287 +#define IN_TOK 288 +#define OUT_TOK 289 +#define INOUT_TOK 290 +#define UNIFORM 291 +#define VARYING 292 +#define NOPERSPECTIVE 293 +#define FLAT 294 +#define SMOOTH 295 +#define MAT2X2 296 +#define MAT2X3 297 +#define MAT2X4 298 +#define MAT3X2 299 +#define MAT3X3 300 +#define MAT3X4 301 +#define MAT4X2 302 +#define MAT4X3 303 +#define MAT4X4 304 +#define SAMPLER1D 305 +#define SAMPLER2D 306 +#define SAMPLER3D 307 +#define SAMPLERCUBE 308 +#define SAMPLER1DSHADOW 309 +#define SAMPLER2DSHADOW 310 +#define SAMPLERCUBESHADOW 311 +#define SAMPLER1DARRAY 312 +#define SAMPLER2DARRAY 313 +#define SAMPLER1DARRAYSHADOW 314 +#define SAMPLER2DARRAYSHADOW 315 +#define ISAMPLER1D 316 +#define ISAMPLER2D 317 +#define ISAMPLER3D 318 +#define ISAMPLERCUBE 319 +#define ISAMPLER1DARRAY 320 +#define ISAMPLER2DARRAY 321 +#define USAMPLER1D 322 +#define USAMPLER2D 323 +#define USAMPLER3D 324 +#define USAMPLERCUBE 325 +#define USAMPLER1DARRAY 326 +#define USAMPLER2DARRAY 327 +#define STRUCT 328 +#define VOID_TOK 329 +#define WHILE 330 +#define IDENTIFIER 331 +#define TYPE_IDENTIFIER 332 +#define NEW_IDENTIFIER 333 +#define FLOATCONSTANT 334 +#define INTCONSTANT 335 +#define UINTCONSTANT 336 +#define BOOLCONSTANT 337 +#define FIELD_SELECTION 338 +#define LEFT_OP 339 +#define RIGHT_OP 340 +#define INC_OP 341 +#define DEC_OP 342 +#define LE_OP 343 +#define GE_OP 344 +#define EQ_OP 345 +#define NE_OP 346 +#define AND_OP 347 +#define OR_OP 348 +#define XOR_OP 349 +#define MUL_ASSIGN 350 +#define DIV_ASSIGN 351 +#define ADD_ASSIGN 352 +#define MOD_ASSIGN 353 +#define LEFT_ASSIGN 354 +#define RIGHT_ASSIGN 355 +#define AND_ASSIGN 356 +#define XOR_ASSIGN 357 +#define OR_ASSIGN 358 +#define SUB_ASSIGN 359 +#define INVARIANT 360 +#define LOWP 361 +#define MEDIUMP 362 +#define HIGHP 363 +#define SUPERP 364 +#define PRECISION 365 +#define VERSION 366 +#define EXTENSION 367 +#define LINE 368 +#define COLON 369 +#define EOL 370 +#define INTERFACE 371 +#define OUTPUT 372 +#define PRAGMA_DEBUG_ON 373 +#define PRAGMA_DEBUG_OFF 374 +#define PRAGMA_OPTIMIZE_ON 375 +#define PRAGMA_OPTIMIZE_OFF 376 +#define PRAGMA_INVARIANT_ALL 377 +#define LAYOUT_TOK 378 +#define ASM 379 +#define CLASS 380 +#define UNION 381 +#define ENUM 382 +#define TYPEDEF 383 +#define TEMPLATE 384 +#define THIS 385 +#define PACKED_TOK 386 +#define GOTO 387 +#define INLINE_TOK 388 +#define NOINLINE 389 +#define VOLATILE 390 +#define PUBLIC_TOK 391 +#define STATIC 392 +#define EXTERN 393 +#define EXTERNAL 394 +#define LONG_TOK 395 +#define SHORT_TOK 396 +#define DOUBLE_TOK 397 +#define HALF 398 +#define FIXED_TOK 399 +#define UNSIGNED 400 +#define INPUT_TOK 401 +#define OUPTUT 402 +#define HVEC2 403 +#define HVEC3 404 +#define HVEC4 405 +#define DVEC2 406 +#define DVEC3 407 +#define DVEC4 408 +#define FVEC2 409 +#define FVEC3 410 +#define FVEC4 411 +#define SAMPLER2DRECT 412 +#define SAMPLER3DRECT 413 +#define SAMPLER2DRECTSHADOW 414 +#define SIZEOF 415 +#define CAST 416 +#define NAMESPACE 417 +#define USING 418 +#define ERROR_TOK 419 +#define COMMON 420 +#define PARTITION 421 +#define ACTIVE 422 +#define SAMPLERBUFFER 423 +#define FILTER 424 +#define IMAGE1D 425 +#define IMAGE2D 426 +#define IMAGE3D 427 +#define IMAGECUBE 428 +#define IMAGE1DARRAY 429 +#define IMAGE2DARRAY 430 +#define IIMAGE1D 431 +#define IIMAGE2D 432 +#define IIMAGE3D 433 +#define IIMAGECUBE 434 +#define IIMAGE1DARRAY 435 +#define IIMAGE2DARRAY 436 +#define UIMAGE1D 437 +#define UIMAGE2D 438 +#define UIMAGE3D 439 +#define UIMAGECUBE 440 +#define UIMAGE1DARRAY 441 +#define UIMAGE2DARRAY 442 +#define IMAGE1DSHADOW 443 +#define IMAGE2DSHADOW 444 +#define IMAGEBUFFER 445 +#define IIMAGEBUFFER 446 +#define UIMAGEBUFFER 447 +#define IMAGE1DARRAYSHADOW 448 +#define IMAGE2DARRAYSHADOW 449 +#define ROW_MAJOR 450 + + + + +/* Copy the first part of user declarations. */ +#line 1 "src/glsl/glsl_parser.yy" + +/* + * Copyright © 2008, 2009 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +#include +#include +#include +#include + +#include "ast.h" +#include "glsl_parser_extras.h" +#include "glsl_types.h" + +#define YYLEX_PARAM state->scanner + + + +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 1 +#endif + +/* Enabling the token table. */ +#ifndef YYTOKEN_TABLE +# define YYTOKEN_TABLE 0 +#endif + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 52 "src/glsl/glsl_parser.yy" +{ + int n; + float real; + char *identifier; + + struct ast_type_qualifier type_qualifier; + + ast_node *node; + ast_type_specifier *type_specifier; + ast_fully_specified_type *fully_specified_type; + ast_function *function; + ast_parameter_declarator *parameter_declarator; + ast_function_definition *function_definition; + ast_compound_statement *compound_statement; + ast_expression *expression; + ast_declarator_list *declarator_list; + ast_struct_specifier *struct_specifier; + ast_declaration *declaration; + + struct { + ast_node *cond; + ast_expression *rest; + } for_rest_statement; + + struct { + ast_node *then_statement; + ast_node *else_statement; + } selection_rest_statement; +} +/* Line 193 of yacc.c. */ +#line 560 "src/glsl/glsl_parser.cpp" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + +#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED +typedef struct YYLTYPE +{ + int first_line; + int first_column; + int last_line; + int last_column; +} YYLTYPE; +# define yyltype YYLTYPE /* obsolescent; will be withdrawn */ +# define YYLTYPE_IS_DECLARED 1 +# define YYLTYPE_IS_TRIVIAL 1 +#endif + + +/* Copy the second part of user declarations. */ + + +/* Line 216 of yacc.c. */ +#line 585 "src/glsl/glsl_parser.cpp" + +#ifdef short +# undef short +#endif + +#ifdef YYTYPE_UINT8 +typedef YYTYPE_UINT8 yytype_uint8; +#else +typedef unsigned char yytype_uint8; +#endif + +#ifdef YYTYPE_INT8 +typedef YYTYPE_INT8 yytype_int8; +#elif (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +typedef signed char yytype_int8; +#else +typedef short int yytype_int8; +#endif + +#ifdef YYTYPE_UINT16 +typedef YYTYPE_UINT16 yytype_uint16; +#else +typedef unsigned short int yytype_uint16; +#endif + +#ifdef YYTYPE_INT16 +typedef YYTYPE_INT16 yytype_int16; +#else +typedef short int yytype_int16; +#endif + +#ifndef YYSIZE_T +# ifdef __SIZE_TYPE__ +# define YYSIZE_T __SIZE_TYPE__ +# elif defined size_t +# define YYSIZE_T size_t +# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned int +# endif +#endif + +#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) + +#ifndef YY_ +# if defined YYENABLE_NLS && YYENABLE_NLS +# if ENABLE_NLS +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_(msgid) dgettext ("bison-runtime", msgid) +# endif +# endif +# ifndef YY_ +# define YY_(msgid) msgid +# endif +#endif + +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YYUSE(e) ((void) (e)) +#else +# define YYUSE(e) /* empty */ +#endif + +/* Identity function, used to suppress warnings about constant conditions. */ +#ifndef lint +# define YYID(n) (n) +#else +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static int +YYID (int i) +#else +static int +YYID (i) + int i; +#endif +{ + return i; +} +#endif + +#if ! defined yyoverflow || YYERROR_VERBOSE + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# elif defined __BUILTIN_VA_ARG_INCR +# include /* INFRINGES ON USER NAME SPACE */ +# elif defined _AIX +# define YYSTACK_ALLOC __alloca +# elif defined _MSC_VER +# include /* INFRINGES ON USER NAME SPACE */ +# define alloca _alloca +# else +# define YYSTACK_ALLOC alloca +# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) +# ifndef YYSTACK_ALLOC_MAXIMUM + /* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ +# endif +# else +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# ifndef YYSTACK_ALLOC_MAXIMUM +# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM +# endif +# if (defined __cplusplus && ! defined _STDLIB_H \ + && ! ((defined YYMALLOC || defined malloc) \ + && (defined YYFREE || defined free))) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifndef YYFREE +# define YYFREE free +# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void free (void *); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# endif +#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ + + +#if (! defined yyoverflow \ + && (! defined __cplusplus \ + || (defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \ + && defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + yytype_int16 yyss; + YYSTYPE yyvs; + YYLTYPE yyls; +}; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \ + + 2 * YYSTACK_GAP_MAXIMUM) + +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined __GNUC__ && 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (YYID (0)) +# endif +# endif + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack, Stack, yysize); \ + Stack = &yyptr->Stack; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (YYID (0)) + +#endif + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 5 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 3692 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 220 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 93 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 291 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 434 + +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 450 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +static const yytype_uint8 yytranslate[] = +{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 204, 2, 2, 2, 208, 211, 2, + 196, 197, 206, 202, 201, 203, 200, 207, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 215, 217, + 209, 216, 210, 214, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 198, 2, 199, 212, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 218, 213, 219, 205, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, + 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, + 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, + 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, + 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, + 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, + 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, + 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, + 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, + 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, + 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, + 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, + 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, + 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, + 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, + 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, + 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, + 195 +}; + +#if YYDEBUG +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const yytype_uint16 yyprhs[] = +{ + 0, 0, 3, 4, 9, 10, 14, 17, 20, 23, + 26, 29, 30, 33, 35, 37, 39, 45, 47, 50, + 52, 54, 56, 58, 60, 62, 64, 68, 70, 75, + 77, 81, 84, 87, 89, 91, 93, 97, 100, 103, + 106, 108, 111, 115, 118, 120, 122, 124, 127, 130, + 133, 135, 138, 142, 145, 147, 150, 153, 156, 158, + 160, 162, 164, 166, 170, 174, 178, 180, 184, 188, + 190, 194, 198, 200, 204, 208, 212, 216, 218, 222, + 226, 228, 232, 234, 238, 240, 244, 246, 250, 252, + 256, 258, 262, 264, 270, 272, 276, 278, 280, 282, + 284, 286, 288, 290, 292, 294, 296, 298, 300, 304, + 306, 309, 312, 317, 320, 322, 324, 327, 331, 335, + 338, 344, 348, 351, 355, 358, 359, 361, 363, 365, + 367, 369, 373, 379, 386, 394, 403, 409, 411, 414, + 419, 425, 432, 440, 445, 448, 450, 453, 458, 460, + 464, 466, 470, 472, 474, 476, 478, 480, 482, 485, + 487, 490, 493, 497, 499, 501, 503, 505, 508, 510, + 512, 515, 518, 520, 522, 525, 527, 531, 536, 538, + 540, 542, 544, 546, 548, 550, 552, 554, 556, 558, + 560, 562, 564, 566, 568, 570, 572, 574, 576, 578, + 580, 582, 584, 586, 588, 590, 592, 594, 596, 598, + 600, 602, 604, 606, 608, 610, 612, 614, 616, 618, + 620, 622, 624, 626, 628, 630, 632, 634, 636, 638, + 640, 642, 644, 646, 648, 650, 656, 661, 663, 666, + 670, 672, 676, 678, 683, 685, 687, 689, 691, 693, + 695, 697, 699, 701, 703, 705, 708, 709, 714, 716, + 718, 721, 725, 727, 730, 732, 735, 741, 745, 747, + 749, 754, 760, 764, 767, 773, 781, 788, 790, 792, + 794, 795, 798, 802, 805, 808, 811, 815, 818, 820, + 822, 824 +}; + +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yytype_int16 yyrhs[] = +{ + 221, 0, -1, -1, 223, 225, 222, 228, -1, -1, + 111, 80, 115, -1, 118, 115, -1, 119, 115, -1, + 120, 115, -1, 121, 115, -1, 122, 115, -1, -1, + 225, 227, -1, 76, -1, 77, -1, 78, -1, 112, + 226, 114, 226, 115, -1, 311, -1, 228, 311, -1, + 76, -1, 78, -1, 229, -1, 80, -1, 81, -1, + 79, -1, 82, -1, 196, 260, 197, -1, 230, -1, + 231, 198, 232, 199, -1, 233, -1, 231, 200, 226, + -1, 231, 86, -1, 231, 87, -1, 260, -1, 234, + -1, 235, -1, 231, 200, 240, -1, 237, 197, -1, + 236, 197, -1, 238, 74, -1, 238, -1, 238, 258, + -1, 237, 201, 258, -1, 239, 196, -1, 281, -1, + 229, -1, 83, -1, 242, 197, -1, 241, 197, -1, + 243, 74, -1, 243, -1, 243, 258, -1, 242, 201, + 258, -1, 229, 196, -1, 231, -1, 86, 244, -1, + 87, 244, -1, 245, 244, -1, 202, -1, 203, -1, + 204, -1, 205, -1, 244, -1, 246, 206, 244, -1, + 246, 207, 244, -1, 246, 208, 244, -1, 246, -1, + 247, 202, 246, -1, 247, 203, 246, -1, 247, -1, + 248, 84, 247, -1, 248, 85, 247, -1, 248, -1, + 249, 209, 248, -1, 249, 210, 248, -1, 249, 88, + 248, -1, 249, 89, 248, -1, 249, -1, 250, 90, + 249, -1, 250, 91, 249, -1, 250, -1, 251, 211, + 250, -1, 251, -1, 252, 212, 251, -1, 252, -1, + 253, 213, 252, -1, 253, -1, 254, 92, 253, -1, + 254, -1, 255, 94, 254, -1, 255, -1, 256, 93, + 255, -1, 256, -1, 256, 214, 260, 215, 258, -1, + 257, -1, 244, 259, 258, -1, 216, -1, 95, -1, + 96, -1, 98, -1, 97, -1, 104, -1, 99, -1, + 100, -1, 101, -1, 102, -1, 103, -1, 258, -1, + 260, 201, 258, -1, 257, -1, 263, 217, -1, 271, + 217, -1, 110, 285, 282, 217, -1, 264, 197, -1, + 266, -1, 265, -1, 266, 268, -1, 265, 201, 268, + -1, 273, 229, 196, -1, 281, 226, -1, 281, 226, + 198, 261, 199, -1, 278, 269, 267, -1, 269, 267, + -1, 278, 269, 270, -1, 269, 270, -1, -1, 33, + -1, 34, -1, 35, -1, 281, -1, 272, -1, 271, + 201, 226, -1, 271, 201, 226, 198, 199, -1, 271, + 201, 226, 198, 261, 199, -1, 271, 201, 226, 198, + 199, 216, 291, -1, 271, 201, 226, 198, 261, 199, + 216, 291, -1, 271, 201, 226, 216, 291, -1, 273, + -1, 273, 226, -1, 273, 226, 198, 199, -1, 273, + 226, 198, 261, 199, -1, 273, 226, 198, 199, 216, + 291, -1, 273, 226, 198, 261, 199, 216, 291, -1, + 273, 226, 216, 291, -1, 105, 229, -1, 281, -1, + 279, 281, -1, 123, 196, 275, 197, -1, 276, -1, + 275, 201, 276, -1, 226, -1, 226, 216, 80, -1, + 40, -1, 39, -1, 38, -1, 4, -1, 280, -1, + 274, -1, 274, 280, -1, 277, -1, 277, 280, -1, + 105, 280, -1, 105, 277, 280, -1, 105, -1, 4, + -1, 3, -1, 37, -1, 32, 37, -1, 33, -1, + 34, -1, 32, 33, -1, 32, 34, -1, 36, -1, + 282, -1, 285, 282, -1, 283, -1, 283, 198, 199, + -1, 283, 198, 261, 199, -1, 284, -1, 286, -1, + 77, -1, 74, -1, 6, -1, 7, -1, 8, -1, + 5, -1, 29, -1, 30, -1, 31, -1, 20, -1, + 21, -1, 22, -1, 23, -1, 24, -1, 25, -1, + 26, -1, 27, -1, 28, -1, 41, -1, 42, -1, + 43, -1, 44, -1, 45, -1, 46, -1, 47, -1, + 48, -1, 49, -1, 50, -1, 51, -1, 157, -1, + 52, -1, 53, -1, 54, -1, 55, -1, 159, -1, + 56, -1, 57, -1, 58, -1, 59, -1, 60, -1, + 61, -1, 62, -1, 63, -1, 64, -1, 65, -1, + 66, -1, 67, -1, 68, -1, 69, -1, 70, -1, + 71, -1, 72, -1, 108, -1, 107, -1, 106, -1, + 73, 226, 218, 287, 219, -1, 73, 218, 287, 219, + -1, 288, -1, 287, 288, -1, 281, 289, 217, -1, + 290, -1, 289, 201, 290, -1, 226, -1, 226, 198, + 261, 199, -1, 258, -1, 262, -1, 295, -1, 294, + -1, 292, -1, 300, -1, 301, -1, 304, -1, 305, + -1, 306, -1, 310, -1, 218, 219, -1, -1, 218, + 296, 299, 219, -1, 298, -1, 294, -1, 218, 219, + -1, 218, 299, 219, -1, 293, -1, 299, 293, -1, + 217, -1, 260, 217, -1, 14, 196, 260, 197, 302, + -1, 293, 12, 293, -1, 293, -1, 260, -1, 273, + 226, 216, 291, -1, 17, 196, 260, 197, 295, -1, + 18, 260, 215, -1, 19, 215, -1, 75, 196, 303, + 197, 297, -1, 11, 293, 75, 196, 260, 197, 217, + -1, 13, 196, 307, 309, 197, 297, -1, 300, -1, + 292, -1, 303, -1, -1, 308, 217, -1, 308, 217, + 260, -1, 10, 217, -1, 9, 217, -1, 16, 217, + -1, 16, 260, 217, -1, 15, 217, -1, 312, -1, + 262, -1, 224, -1, 263, 298, -1 +}; + +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const yytype_uint16 yyrline[] = +{ + 0, 218, 218, 217, 229, 231, 271, 272, 273, 274, + 275, 287, 289, 293, 294, 295, 299, 308, 316, 327, + 328, 332, 339, 346, 353, 360, 367, 374, 375, 381, + 385, 392, 398, 407, 411, 415, 416, 425, 426, 430, + 431, 435, 441, 453, 457, 463, 470, 480, 481, 485, + 486, 490, 496, 508, 519, 520, 526, 532, 542, 543, + 544, 545, 549, 550, 556, 562, 571, 572, 578, 587, + 588, 594, 603, 604, 610, 616, 622, 631, 632, 638, + 647, 648, 657, 658, 667, 668, 677, 678, 687, 688, + 697, 698, 707, 708, 717, 718, 727, 728, 729, 730, + 731, 732, 733, 734, 735, 736, 737, 741, 745, 761, + 765, 770, 774, 783, 787, 788, 792, 797, 805, 819, + 829, 844, 851, 856, 867, 880, 883, 888, 893, 902, + 906, 907, 917, 927, 937, 947, 957, 971, 982, 991, + 1000, 1009, 1018, 1027, 1036, 1050, 1057, 1068, 1075, 1076, + 1095, 1147, 1188, 1193, 1198, 1206, 1214, 1215, 1216, 1221, + 1222, 1227, 1232, 1238, 1246, 1251, 1256, 1261, 1267, 1272, + 1277, 1282, 1287, 1295, 1299, 1307, 1308, 1314, 1323, 1329, + 1335, 1344, 1345, 1346, 1347, 1348, 1349, 1350, 1351, 1352, + 1353, 1354, 1355, 1356, 1357, 1358, 1359, 1360, 1361, 1362, + 1363, 1364, 1365, 1366, 1367, 1368, 1369, 1370, 1371, 1372, + 1373, 1374, 1375, 1376, 1377, 1378, 1379, 1380, 1381, 1382, + 1383, 1384, 1385, 1386, 1387, 1388, 1389, 1390, 1391, 1392, + 1393, 1394, 1398, 1408, 1418, 1431, 1438, 1447, 1452, 1460, + 1475, 1480, 1488, 1495, 1504, 1508, 1514, 1515, 1519, 1520, + 1521, 1522, 1523, 1524, 1525, 1529, 1536, 1535, 1549, 1550, + 1554, 1560, 1569, 1579, 1591, 1597, 1606, 1615, 1620, 1628, + 1632, 1646, 1650, 1651, 1655, 1662, 1669, 1679, 1680, 1684, + 1686, 1692, 1697, 1706, 1712, 1718, 1724, 1730, 1739, 1740, + 1741, 1745 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE +/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "ATTRIBUTE", "CONST_TOK", "BOOL_TOK", + "FLOAT_TOK", "INT_TOK", "UINT_TOK", "BREAK", "CONTINUE", "DO", "ELSE", + "FOR", "IF", "DISCARD", "RETURN", "SWITCH", "CASE", "DEFAULT", "BVEC2", + "BVEC3", "BVEC4", "IVEC2", "IVEC3", "IVEC4", "UVEC2", "UVEC3", "UVEC4", + "VEC2", "VEC3", "VEC4", "CENTROID", "IN_TOK", "OUT_TOK", "INOUT_TOK", + "UNIFORM", "VARYING", "NOPERSPECTIVE", "FLAT", "SMOOTH", "MAT2X2", + "MAT2X3", "MAT2X4", "MAT3X2", "MAT3X3", "MAT3X4", "MAT4X2", "MAT4X3", + "MAT4X4", "SAMPLER1D", "SAMPLER2D", "SAMPLER3D", "SAMPLERCUBE", + "SAMPLER1DSHADOW", "SAMPLER2DSHADOW", "SAMPLERCUBESHADOW", + "SAMPLER1DARRAY", "SAMPLER2DARRAY", "SAMPLER1DARRAYSHADOW", + "SAMPLER2DARRAYSHADOW", "ISAMPLER1D", "ISAMPLER2D", "ISAMPLER3D", + "ISAMPLERCUBE", "ISAMPLER1DARRAY", "ISAMPLER2DARRAY", "USAMPLER1D", + "USAMPLER2D", "USAMPLER3D", "USAMPLERCUBE", "USAMPLER1DARRAY", + "USAMPLER2DARRAY", "STRUCT", "VOID_TOK", "WHILE", "IDENTIFIER", + "TYPE_IDENTIFIER", "NEW_IDENTIFIER", "FLOATCONSTANT", "INTCONSTANT", + "UINTCONSTANT", "BOOLCONSTANT", "FIELD_SELECTION", "LEFT_OP", "RIGHT_OP", + "INC_OP", "DEC_OP", "LE_OP", "GE_OP", "EQ_OP", "NE_OP", "AND_OP", + "OR_OP", "XOR_OP", "MUL_ASSIGN", "DIV_ASSIGN", "ADD_ASSIGN", + "MOD_ASSIGN", "LEFT_ASSIGN", "RIGHT_ASSIGN", "AND_ASSIGN", "XOR_ASSIGN", + "OR_ASSIGN", "SUB_ASSIGN", "INVARIANT", "LOWP", "MEDIUMP", "HIGHP", + "SUPERP", "PRECISION", "VERSION", "EXTENSION", "LINE", "COLON", "EOL", + "INTERFACE", "OUTPUT", "PRAGMA_DEBUG_ON", "PRAGMA_DEBUG_OFF", + "PRAGMA_OPTIMIZE_ON", "PRAGMA_OPTIMIZE_OFF", "PRAGMA_INVARIANT_ALL", + "LAYOUT_TOK", "ASM", "CLASS", "UNION", "ENUM", "TYPEDEF", "TEMPLATE", + "THIS", "PACKED_TOK", "GOTO", "INLINE_TOK", "NOINLINE", "VOLATILE", + "PUBLIC_TOK", "STATIC", "EXTERN", "EXTERNAL", "LONG_TOK", "SHORT_TOK", + "DOUBLE_TOK", "HALF", "FIXED_TOK", "UNSIGNED", "INPUT_TOK", "OUPTUT", + "HVEC2", "HVEC3", "HVEC4", "DVEC2", "DVEC3", "DVEC4", "FVEC2", "FVEC3", + "FVEC4", "SAMPLER2DRECT", "SAMPLER3DRECT", "SAMPLER2DRECTSHADOW", + "SIZEOF", "CAST", "NAMESPACE", "USING", "ERROR_TOK", "COMMON", + "PARTITION", "ACTIVE", "SAMPLERBUFFER", "FILTER", "IMAGE1D", "IMAGE2D", + "IMAGE3D", "IMAGECUBE", "IMAGE1DARRAY", "IMAGE2DARRAY", "IIMAGE1D", + "IIMAGE2D", "IIMAGE3D", "IIMAGECUBE", "IIMAGE1DARRAY", "IIMAGE2DARRAY", + "UIMAGE1D", "UIMAGE2D", "UIMAGE3D", "UIMAGECUBE", "UIMAGE1DARRAY", + "UIMAGE2DARRAY", "IMAGE1DSHADOW", "IMAGE2DSHADOW", "IMAGEBUFFER", + "IIMAGEBUFFER", "UIMAGEBUFFER", "IMAGE1DARRAYSHADOW", + "IMAGE2DARRAYSHADOW", "ROW_MAJOR", "'('", "')'", "'['", "']'", "'.'", + "','", "'+'", "'-'", "'!'", "'~'", "'*'", "'/'", "'%'", "'<'", "'>'", + "'&'", "'^'", "'|'", "'?'", "':'", "'='", "';'", "'{'", "'}'", "$accept", + "translation_unit", "@1", "version_statement", "pragma_statement", + "extension_statement_list", "any_identifier", "extension_statement", + "external_declaration_list", "variable_identifier", "primary_expression", + "postfix_expression", "integer_expression", "function_call", + "function_call_or_method", "function_call_generic", + "function_call_header_no_parameters", + "function_call_header_with_parameters", "function_call_header", + "function_identifier", "method_call_generic", + "method_call_header_no_parameters", "method_call_header_with_parameters", + "method_call_header", "unary_expression", "unary_operator", + "multiplicative_expression", "additive_expression", "shift_expression", + "relational_expression", "equality_expression", "and_expression", + "exclusive_or_expression", "inclusive_or_expression", + "logical_and_expression", "logical_xor_expression", + "logical_or_expression", "conditional_expression", + "assignment_expression", "assignment_operator", "expression", + "constant_expression", "declaration", "function_prototype", + "function_declarator", "function_header_with_parameters", + "function_header", "parameter_declarator", "parameter_declaration", + "parameter_qualifier", "parameter_type_specifier", + "init_declarator_list", "single_declaration", "fully_specified_type", + "layout_qualifier", "layout_qualifier_id_list", "layout_qualifier_id", + "interpolation_qualifier", "parameter_type_qualifier", "type_qualifier", + "storage_qualifier", "type_specifier", "type_specifier_no_prec", + "type_specifier_nonarray", "basic_type_specifier_nonarray", + "precision_qualifier", "struct_specifier", "struct_declaration_list", + "struct_declaration", "struct_declarator_list", "struct_declarator", + "initializer", "declaration_statement", "statement", "simple_statement", + "compound_statement", "@2", "statement_no_new_scope", + "compound_statement_no_new_scope", "statement_list", + "expression_statement", "selection_statement", + "selection_rest_statement", "condition", "switch_statement", + "case_label", "iteration_statement", "for_init_statement", + "conditionopt", "for_rest_statement", "jump_statement", + "external_declaration", "function_definition", 0 +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ +static const yytype_uint16 yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, + 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, + 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, + 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, + 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, + 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, + 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, + 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, + 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, + 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, + 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, + 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, + 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, + 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, + 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, + 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, + 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, + 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, + 445, 446, 447, 448, 449, 450, 40, 41, 91, 93, + 46, 44, 43, 45, 33, 126, 42, 47, 37, 60, + 62, 38, 94, 124, 63, 58, 61, 59, 123, 125 +}; +# endif + +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const yytype_uint16 yyr1[] = +{ + 0, 220, 222, 221, 223, 223, 224, 224, 224, 224, + 224, 225, 225, 226, 226, 226, 227, 228, 228, 229, + 229, 230, 230, 230, 230, 230, 230, 231, 231, 231, + 231, 231, 231, 232, 233, 234, 234, 235, 235, 236, + 236, 237, 237, 238, 239, 239, 239, 240, 240, 241, + 241, 242, 242, 243, 244, 244, 244, 244, 245, 245, + 245, 245, 246, 246, 246, 246, 247, 247, 247, 248, + 248, 248, 249, 249, 249, 249, 249, 250, 250, 250, + 251, 251, 252, 252, 253, 253, 254, 254, 255, 255, + 256, 256, 257, 257, 258, 258, 259, 259, 259, 259, + 259, 259, 259, 259, 259, 259, 259, 260, 260, 261, + 262, 262, 262, 263, 264, 264, 265, 265, 266, 267, + 267, 268, 268, 268, 268, 269, 269, 269, 269, 270, + 271, 271, 271, 271, 271, 271, 271, 272, 272, 272, + 272, 272, 272, 272, 272, 273, 273, 274, 275, 275, + 276, 276, 277, 277, 277, 278, 279, 279, 279, 279, + 279, 279, 279, 279, 280, 280, 280, 280, 280, 280, + 280, 280, 280, 281, 281, 282, 282, 282, 283, 283, + 283, 284, 284, 284, 284, 284, 284, 284, 284, 284, + 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, + 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, + 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, + 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, + 284, 284, 285, 285, 285, 286, 286, 287, 287, 288, + 289, 289, 290, 290, 291, 292, 293, 293, 294, 294, + 294, 294, 294, 294, 294, 295, 296, 295, 297, 297, + 298, 298, 299, 299, 300, 300, 301, 302, 302, 303, + 303, 304, 305, 305, 306, 306, 306, 307, 307, 308, + 308, 309, 309, 310, 310, 310, 310, 310, 311, 311, + 311, 312 +}; + +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const yytype_uint8 yyr2[] = +{ + 0, 2, 0, 4, 0, 3, 2, 2, 2, 2, + 2, 0, 2, 1, 1, 1, 5, 1, 2, 1, + 1, 1, 1, 1, 1, 1, 3, 1, 4, 1, + 3, 2, 2, 1, 1, 1, 3, 2, 2, 2, + 1, 2, 3, 2, 1, 1, 1, 2, 2, 2, + 1, 2, 3, 2, 1, 2, 2, 2, 1, 1, + 1, 1, 1, 3, 3, 3, 1, 3, 3, 1, + 3, 3, 1, 3, 3, 3, 3, 1, 3, 3, + 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, + 1, 3, 1, 5, 1, 3, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, + 2, 2, 4, 2, 1, 1, 2, 3, 3, 2, + 5, 3, 2, 3, 2, 0, 1, 1, 1, 1, + 1, 3, 5, 6, 7, 8, 5, 1, 2, 4, + 5, 6, 7, 4, 2, 1, 2, 4, 1, 3, + 1, 3, 1, 1, 1, 1, 1, 1, 2, 1, + 2, 2, 3, 1, 1, 1, 1, 2, 1, 1, + 2, 2, 1, 1, 2, 1, 3, 4, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 5, 4, 1, 2, 3, + 1, 3, 1, 4, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 2, 0, 4, 1, 1, + 2, 3, 1, 2, 1, 2, 5, 3, 1, 1, + 4, 5, 3, 2, 5, 7, 6, 1, 1, 1, + 0, 2, 3, 2, 2, 2, 3, 2, 1, 1, + 1, 2 +}; + +/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state + STATE-NUM when YYTABLE doesn't specify something else to do. Zero + means the default is an error. */ +static const yytype_uint16 yydefact[] = +{ + 4, 0, 0, 11, 0, 1, 2, 5, 0, 0, + 12, 13, 14, 15, 0, 165, 164, 185, 182, 183, + 184, 189, 190, 191, 192, 193, 194, 195, 196, 197, + 186, 187, 188, 0, 168, 169, 172, 166, 154, 153, + 152, 198, 199, 200, 201, 202, 203, 204, 205, 206, + 207, 208, 210, 211, 212, 213, 215, 216, 217, 218, + 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, + 229, 230, 231, 0, 181, 180, 163, 234, 233, 232, + 0, 0, 0, 0, 0, 0, 0, 209, 214, 290, + 3, 289, 0, 0, 115, 125, 0, 130, 137, 157, + 159, 0, 156, 145, 173, 175, 178, 0, 179, 17, + 288, 0, 170, 171, 167, 0, 0, 19, 20, 144, + 0, 161, 0, 6, 7, 8, 9, 10, 0, 18, + 110, 0, 291, 113, 125, 155, 126, 127, 128, 116, + 0, 125, 0, 111, 13, 15, 138, 0, 158, 160, + 146, 0, 174, 0, 0, 0, 237, 0, 162, 0, + 150, 0, 148, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 24, 22, 23, 25, 46, 0, + 0, 0, 58, 59, 60, 61, 264, 256, 260, 21, + 27, 54, 29, 34, 35, 0, 0, 40, 0, 62, + 0, 66, 69, 72, 77, 80, 82, 84, 86, 88, + 90, 92, 94, 107, 0, 245, 0, 145, 248, 262, + 247, 246, 0, 249, 250, 251, 252, 253, 254, 117, + 122, 124, 129, 0, 131, 0, 0, 118, 176, 62, + 109, 0, 44, 16, 242, 0, 240, 236, 238, 0, + 112, 0, 147, 0, 284, 283, 0, 0, 0, 287, + 285, 0, 0, 0, 273, 0, 55, 56, 0, 255, + 0, 31, 32, 0, 0, 38, 37, 0, 181, 41, + 43, 97, 98, 100, 99, 102, 103, 104, 105, 106, + 101, 96, 0, 57, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 265, 261, 263, 119, 121, + 123, 0, 0, 139, 0, 244, 143, 177, 0, 0, + 239, 235, 151, 149, 0, 278, 277, 280, 0, 286, + 0, 272, 163, 269, 0, 0, 26, 0, 0, 33, + 30, 0, 36, 0, 0, 50, 42, 95, 63, 64, + 65, 67, 68, 70, 71, 75, 76, 73, 74, 78, + 79, 81, 83, 85, 87, 89, 91, 0, 108, 0, + 132, 0, 136, 0, 140, 0, 241, 0, 279, 0, + 0, 0, 0, 0, 0, 257, 28, 53, 48, 47, + 0, 181, 51, 0, 0, 0, 133, 141, 0, 243, + 0, 281, 0, 268, 266, 271, 0, 259, 274, 258, + 52, 93, 120, 134, 0, 142, 0, 282, 276, 0, + 270, 135, 275, 267 +}; + +/* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int16 yydefgoto[] = +{ + -1, 2, 9, 3, 89, 6, 160, 10, 90, 189, + 190, 191, 348, 192, 193, 194, 195, 196, 197, 198, + 352, 353, 354, 355, 199, 200, 201, 202, 203, 204, + 205, 206, 207, 208, 209, 210, 211, 212, 213, 292, + 214, 241, 215, 216, 93, 94, 95, 230, 139, 140, + 231, 96, 97, 98, 99, 161, 162, 100, 141, 101, + 102, 242, 104, 105, 106, 107, 108, 155, 156, 245, + 246, 326, 218, 219, 220, 221, 270, 418, 419, 222, + 223, 224, 414, 345, 225, 226, 227, 337, 389, 390, + 228, 109, 110 +}; + +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -366 +static const yytype_int16 yypact[] = +{ + -57, -43, 62, -366, -50, -366, -30, -366, 67, 3341, + -366, -366, -366, -366, -6, -366, -366, -366, -366, -366, + -366, -366, -366, -366, -366, -366, -366, -366, -366, -366, + -366, -366, -366, 8, -366, -366, -366, -366, -366, -366, + -366, -366, -366, -366, -366, -366, -366, -366, -366, -366, + -366, -366, -366, -366, -366, -366, -366, -366, -366, -366, + -366, -366, -366, -366, -366, -366, -366, -366, -366, -366, + -366, -366, -366, -65, -366, -366, 226, -366, -366, -366, + 51, -31, -28, 6, 13, 15, -44, -366, -366, -366, + 3341, -366, -183, -47, -29, 18, -169, -366, 140, 24, + 24, 3460, -366, -366, -366, -24, -366, 3533, -366, -366, + -366, 67, -366, -366, -366, 3460, -48, -366, -366, -366, + 24, -366, 3533, -366, -366, -366, -366, -366, 67, -366, + -366, 408, -366, -366, 55, -366, -366, -366, -366, -366, + 3460, 200, 67, -366, -20, -18, -178, 23, -366, -366, + -366, 2225, -366, 72, 67, 1598, -366, 3460, -366, 4, + 10, -84, -366, 11, 14, 1059, 40, 42, 29, 1836, + 43, 2783, 34, 54, -366, -366, -366, -366, -366, 2783, + 2783, 2783, -366, -366, -366, -366, -366, 32, -366, 56, + -366, -71, -366, -366, -366, 57, -81, 2969, 61, -27, + 2783, 35, -88, -41, -70, 33, 60, 41, 59, 181, + 180, -89, -366, -366, -168, -366, 58, 80, -366, -366, + -366, -366, 625, -366, -366, -366, -366, -366, -366, -366, + -366, -366, 67, 3460, -177, 2411, 2783, -366, -366, -366, + -366, 78, -366, -366, 81, -137, -366, -366, -366, 1717, + -366, 201, -366, 67, -366, -366, 205, 1478, 2783, -366, + -366, -134, 2783, -115, -366, 2039, -366, -366, -60, -366, + 1059, -366, -366, 2783, 140, -366, -366, 2783, 85, -366, + -366, -366, -366, -366, -366, -366, -366, -366, -366, -366, + -366, -366, 2783, -366, 2783, 2783, 2783, 2783, 2783, 2783, + 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, 2783, + 2783, 2783, 2783, 2783, 2783, -366, -366, -366, 86, -366, + -366, 2597, 2783, 69, 87, -366, -366, -366, 2783, 67, + -366, -366, -366, -366, 91, -366, -366, 2039, -59, -366, + -46, -366, 129, 88, 67, 93, -366, 842, 89, 88, + -366, 95, -366, 96, -37, 3155, -366, -366, -366, -366, + -366, 35, 35, -88, -88, -41, -41, -41, -41, -70, + -70, 33, 60, 41, 59, 181, 180, -96, -366, 2783, + 76, 97, -366, 2783, 79, 98, -366, 2783, -366, 77, + 101, 1059, 83, 90, 1275, -366, -366, -366, -366, -366, + 2783, 102, -366, 2783, 108, 2783, 94, -366, 2783, -366, + -26, 2783, 1275, 297, -366, -366, 2783, -366, -366, -366, + -366, -366, -366, -366, 2783, -366, 100, 88, -366, 1059, + -366, -366, -366, -366 +}; + +/* YYPGOTO[NTERM-NUM]. */ +static const yytype_int16 yypgoto[] = +{ + -366, -366, -366, -366, -366, -366, -7, -366, -366, -62, + -366, -366, -366, -366, -366, -366, -366, -366, -366, -366, + -366, -366, -366, -366, -101, -366, -113, -109, -121, -61, + 5, 3, 9, 16, 2, 7, -366, -142, -100, -366, + -164, -225, 21, 22, -366, -366, -366, 82, 186, 173, + 92, -366, -366, -242, -366, -366, 68, -73, -366, -366, + -74, -9, -67, -366, -366, 243, -366, 170, -147, -366, + 0, -298, 73, -159, -365, -58, -366, -80, 239, 63, + 84, -366, -366, -2, -366, -366, -366, -366, -366, -366, + -366, 246, -366 +}; + +/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule which + number is the opposite. If zero, do what YYDEFACT says. + If YYTABLE_NINF, syntax error. */ +#define YYTABLE_NINF -115 +static const yytype_int16 yytable[] = +{ + 103, 14, 121, 120, 312, 261, 256, 263, 248, 240, + 324, 11, 12, 13, 119, 271, 272, 268, 301, 302, + 235, 321, 135, 344, 382, 148, 149, 15, 16, 417, + 91, 92, 142, 314, 130, 131, 147, 4, 236, 322, + 152, 112, 113, 299, 300, 114, 158, 417, 143, 315, + 239, 136, 137, 138, 1, 159, 33, 34, 35, 135, + 36, 37, 5, 317, 329, 7, 116, 314, 281, 282, + 283, 284, 285, 286, 287, 288, 289, 290, 266, 267, + 330, 103, 8, 339, 123, 407, 314, 124, 136, 137, + 138, 146, 150, 240, 338, 344, 381, 279, 340, 293, + 341, 343, 248, 385, 153, 314, 154, 423, 111, 349, + 425, 91, 92, 252, 297, 298, 276, 253, 430, 403, + 277, 125, 217, 305, 306, 313, 431, 273, 126, 274, + 127, 232, 15, 16, 239, 234, 325, 346, 391, 303, + 304, 314, 314, 11, 12, 13, 154, 244, 154, 377, + 133, 392, 128, 115, 404, 314, 217, 77, 78, 79, + 399, 33, 34, 35, 400, 36, 37, 38, 39, 40, + 157, 426, 134, 343, 151, 314, -19, 356, -20, 240, + 365, 366, 367, 368, 361, 362, 240, 243, 317, 291, + 363, 364, 357, 358, 359, 360, 239, 239, 239, 239, + 239, 239, 239, 239, 239, 239, 239, 239, 239, 239, + 239, 239, 351, 217, 378, -114, 144, 12, 145, 237, + 239, 250, 325, 410, 232, 318, 251, 239, 254, 15, + 16, 255, 413, 136, 137, 138, 257, 240, 258, 262, + 154, 294, 295, 296, 369, 370, 259, 427, 217, 264, + 265, 269, -45, 308, 275, 402, 217, 280, 33, 34, + 35, 217, 36, 37, 38, 39, 40, 350, 121, 120, + 433, 307, 309, 310, 311, 130, -44, 327, 239, 328, + 334, 332, -39, 325, 379, 383, 384, 387, 396, 314, + 394, 397, 405, 398, 411, 408, 406, 409, 412, -49, + 420, 187, 117, 421, 118, 325, 416, 422, 325, 429, + 424, 372, 371, 375, 233, 319, 325, 432, 373, 376, + 229, 333, 244, 122, 325, 320, 374, 249, 217, 386, + 335, 132, 428, 347, 415, 388, 129, 393, 217, 0, + 0, 336, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 217, 0, 0, 217, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 217, 0, 0, 0, 0, 0, 0, + 0, 15, 16, 17, 18, 19, 20, 163, 164, 165, + 217, 166, 167, 168, 169, 170, 171, 172, 21, 22, + 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, + 33, 34, 35, 0, 36, 37, 38, 39, 40, 41, + 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, + 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, + 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, + 72, 73, 74, 173, 117, 75, 118, 174, 175, 176, + 177, 178, 0, 0, 179, 180, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 76, 77, 78, 79, 0, 80, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 86, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 87, 0, 88, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 181, 0, 0, 0, 0, 0, + 182, 183, 184, 185, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 186, 187, 188, 15, 16, + 17, 18, 19, 20, 163, 164, 165, 0, 166, 167, + 168, 169, 170, 171, 172, 21, 22, 23, 24, 25, + 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, + 0, 36, 37, 38, 39, 40, 41, 42, 43, 44, + 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, + 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, + 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, + 173, 117, 75, 118, 174, 175, 176, 177, 178, 0, + 0, 179, 180, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 76, 77, 78, 79, 0, 80, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 86, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 87, 0, 88, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 181, 0, 0, 0, 0, 0, 182, 183, 184, + 185, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 186, 187, 316, 15, 16, 17, 18, 19, + 20, 163, 164, 165, 0, 166, 167, 168, 169, 170, + 171, 172, 21, 22, 23, 24, 25, 26, 27, 28, + 29, 30, 31, 32, 33, 34, 35, 0, 36, 37, + 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, + 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, + 68, 69, 70, 71, 72, 73, 74, 173, 117, 75, + 118, 174, 175, 176, 177, 178, 0, 0, 179, 180, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 76, 77, 78, + 79, 0, 80, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 86, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 87, + 0, 88, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 181, 0, + 0, 0, 0, 0, 182, 183, 184, 185, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 186, + 187, 395, 15, 16, 17, 18, 19, 20, 163, 164, + 165, 0, 166, 167, 168, 169, 170, 171, 172, 21, + 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, 35, 0, 36, 37, 38, 39, 40, + 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, + 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, + 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, + 71, 72, 73, 74, 173, 117, 75, 118, 174, 175, + 176, 177, 178, 0, 0, 179, 180, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 76, 77, 78, 79, 0, 80, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 86, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 87, 0, 88, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 181, 0, 0, 0, 0, + 0, 182, 183, 184, 185, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 186, 187, 15, 16, + 17, 18, 19, 20, 163, 164, 165, 0, 166, 167, + 168, 169, 170, 171, 172, 21, 22, 23, 24, 25, + 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, + 0, 36, 37, 38, 39, 40, 41, 42, 43, 44, + 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, + 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, + 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, + 173, 117, 75, 118, 174, 175, 176, 177, 178, 0, + 0, 179, 180, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 76, 77, 78, 79, 0, 80, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 86, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 87, 0, 88, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 181, 0, 0, 0, 0, 0, 182, 183, 184, + 185, 15, 16, 17, 18, 19, 20, 0, 0, 0, + 0, 0, 186, 131, 0, 0, 0, 0, 21, 22, + 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, + 33, 34, 35, 0, 36, 37, 38, 39, 40, 41, + 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, + 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, + 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, + 72, 73, 74, 0, 117, 75, 118, 174, 175, 176, + 177, 178, 0, 0, 179, 180, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 76, 77, 78, 79, 0, 80, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 86, 0, 17, 18, 19, 20, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 21, 22, + 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, + 0, 0, 0, 0, 0, 87, 0, 88, 0, 41, + 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, + 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, + 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, + 72, 73, 74, 0, 181, 75, 0, 0, 0, 0, + 182, 183, 184, 185, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 186, 0, 0, 0, 0, + 0, 0, 0, 0, 77, 78, 79, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 17, 18, 19, 20, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, 32, 0, + 0, 0, 0, 0, 0, 87, 0, 88, 41, 42, + 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, + 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, + 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, + 73, 74, 0, 0, 75, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 247, 0, 0, + 0, 0, 0, 77, 78, 79, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 17, 18, 19, 20, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 0, 0, + 0, 0, 0, 0, 87, 0, 88, 41, 42, 43, + 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, + 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, + 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, + 74, 0, 117, 75, 118, 174, 175, 176, 177, 178, + 0, 0, 179, 180, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 331, 0, 0, 0, + 0, 0, 77, 78, 79, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 87, 0, 88, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 181, 0, 0, 0, 0, 0, 182, 183, + 184, 185, 15, 16, 17, 18, 19, 20, 0, 0, + 0, 0, 0, 260, 0, 0, 0, 0, 0, 21, + 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, 35, 0, 36, 37, 38, 39, 40, + 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, + 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, + 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, + 71, 72, 73, 74, 0, 117, 75, 118, 174, 175, + 176, 177, 178, 0, 0, 179, 180, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 342, 77, 78, 79, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 86, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 87, 0, 88, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 17, 18, 19, 20, 0, 181, 0, 0, 0, 0, + 0, 182, 183, 184, 185, 21, 22, 23, 24, 25, + 26, 27, 28, 29, 30, 31, 32, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 41, 42, 43, 44, + 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, + 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, + 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, + 0, 117, 75, 118, 174, 175, 176, 177, 178, 0, + 0, 179, 180, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 77, 78, 79, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 87, 0, 88, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 17, 18, 19, 20, + 0, 181, 0, 0, 238, 0, 0, 182, 183, 184, + 185, 21, 22, 23, 24, 25, 26, 27, 28, 29, + 30, 31, 32, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 41, 42, 43, 44, 45, 46, 47, 48, + 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, + 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, + 69, 70, 71, 72, 73, 74, 0, 117, 75, 118, + 174, 175, 176, 177, 178, 0, 0, 179, 180, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 77, 78, 79, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 87, 0, + 88, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 17, 18, 19, 20, 0, 181, 0, 0, + 323, 0, 0, 182, 183, 184, 185, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, 32, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 41, 42, + 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, + 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, + 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, + 73, 74, 0, 117, 75, 118, 174, 175, 176, 177, + 178, 0, 0, 179, 180, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 77, 78, 79, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 87, 0, 88, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 17, 18, + 19, 20, 0, 181, 0, 0, 380, 0, 0, 182, + 183, 184, 185, 21, 22, 23, 24, 25, 26, 27, + 28, 29, 30, 31, 32, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 41, 42, 43, 44, 45, 46, + 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, + 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, + 67, 68, 69, 70, 71, 72, 73, 74, 0, 117, + 75, 118, 174, 175, 176, 177, 178, 0, 0, 179, + 180, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 77, + 78, 79, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 87, 0, 88, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 17, 18, 19, 20, 0, 181, + 0, 0, 0, 0, 0, 182, 183, 184, 185, 21, + 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, + 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, + 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, + 71, 72, 73, 278, 0, 117, 75, 118, 174, 175, + 176, 177, 178, 0, 0, 179, 180, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 77, 78, 79, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 87, 0, 88, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 17, 18, 19, 20, 0, 181, 0, 0, 0, 0, + 0, 182, 183, 184, 185, 21, 22, 23, 24, 25, + 26, 27, 28, 29, 30, 31, 32, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 41, 42, 43, 44, + 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, + 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, + 65, 66, 67, 68, 69, 70, 71, 72, 73, 401, + 0, 117, 75, 118, 174, 175, 176, 177, 178, 0, + 0, 179, 180, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 77, 78, 79, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 87, 0, 88, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 15, 16, 17, 18, 19, 20, + 0, 181, 0, 0, 0, 0, 0, 182, 183, 184, + 185, 21, 22, 23, 24, 25, 26, 27, 28, 29, + 30, 31, 32, 33, 34, 35, 0, 36, 37, 38, + 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, + 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, + 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, + 69, 70, 71, 72, 73, 74, 0, 0, 75, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 76, 77, 78, 79, + 0, 80, 0, 0, 0, 0, 0, 0, 0, 81, + 82, 83, 84, 85, 86, 17, 18, 19, 20, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, 0, 0, 0, 0, 0, 0, 87, 0, + 88, 41, 42, 43, 44, 45, 46, 47, 48, 49, + 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, + 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, + 70, 71, 72, 73, 74, 0, 0, 75, 17, 18, + 19, 20, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 21, 22, 23, 24, 25, 26, 27, + 28, 29, 30, 31, 32, 0, 77, 78, 79, 0, + 0, 0, 0, 0, 41, 42, 43, 44, 45, 46, + 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, + 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, + 67, 68, 69, 70, 71, 72, 73, 74, 0, 0, + 75, 0, 0, 0, 0, 0, 0, 87, 0, 88, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 87, 0, 88 +}; + +static const yytype_int16 yycheck[] = +{ + 9, 8, 76, 76, 93, 169, 165, 171, 155, 151, + 235, 76, 77, 78, 76, 86, 87, 181, 88, 89, + 198, 198, 4, 265, 322, 99, 100, 3, 4, 394, + 9, 9, 201, 201, 217, 218, 98, 80, 216, 216, + 107, 33, 34, 84, 85, 37, 120, 412, 217, 217, + 151, 33, 34, 35, 111, 122, 32, 33, 34, 4, + 36, 37, 0, 222, 201, 115, 73, 201, 95, 96, + 97, 98, 99, 100, 101, 102, 103, 104, 179, 180, + 217, 90, 112, 217, 115, 383, 201, 115, 33, 34, + 35, 98, 101, 235, 258, 337, 321, 197, 262, 200, + 215, 265, 249, 328, 111, 201, 115, 405, 114, 273, + 408, 90, 90, 197, 202, 203, 197, 201, 416, 215, + 201, 115, 131, 90, 91, 214, 424, 198, 115, 200, + 115, 140, 3, 4, 235, 142, 236, 197, 197, 209, + 210, 201, 201, 76, 77, 78, 155, 154, 157, 313, + 197, 197, 196, 218, 379, 201, 165, 106, 107, 108, + 197, 32, 33, 34, 201, 36, 37, 38, 39, 40, + 218, 197, 201, 337, 198, 201, 196, 277, 196, 321, + 301, 302, 303, 304, 297, 298, 328, 115, 347, 216, + 299, 300, 292, 294, 295, 296, 297, 298, 299, 300, + 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, + 311, 312, 274, 222, 314, 197, 76, 77, 78, 196, + 321, 217, 322, 387, 233, 232, 216, 328, 217, 3, + 4, 217, 391, 33, 34, 35, 196, 379, 196, 196, + 249, 206, 207, 208, 305, 306, 217, 411, 257, 215, + 196, 219, 196, 212, 197, 355, 265, 196, 32, 33, + 34, 270, 36, 37, 38, 39, 40, 274, 342, 342, + 429, 211, 213, 92, 94, 217, 196, 199, 379, 198, + 75, 80, 197, 383, 198, 216, 199, 196, 199, 201, + 197, 196, 216, 197, 217, 216, 199, 199, 197, 197, + 400, 218, 76, 403, 78, 405, 216, 199, 408, 12, + 216, 308, 307, 311, 141, 233, 416, 217, 309, 312, + 134, 253, 329, 80, 424, 233, 310, 157, 337, 329, + 257, 92, 412, 270, 392, 337, 90, 344, 347, -1, + -1, 257, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 391, -1, -1, 394, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 412, -1, -1, -1, -1, -1, -1, + -1, 3, 4, 5, 6, 7, 8, 9, 10, 11, + 429, 13, 14, 15, 16, 17, 18, 19, 20, 21, + 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, -1, 36, 37, 38, 39, 40, 41, + 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, + 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, + 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, + 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, + 82, 83, -1, -1, 86, 87, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 105, 106, 107, 108, -1, 110, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 123, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 157, -1, 159, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 196, -1, -1, -1, -1, -1, + 202, 203, 204, 205, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 217, 218, 219, 3, 4, + 5, 6, 7, 8, 9, 10, 11, -1, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, + -1, 36, 37, 38, 39, 40, 41, 42, 43, 44, + 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, + 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, + 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, + 75, 76, 77, 78, 79, 80, 81, 82, 83, -1, + -1, 86, 87, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 105, 106, 107, 108, -1, 110, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 123, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 157, -1, 159, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 196, -1, -1, -1, -1, -1, 202, 203, 204, + 205, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 217, 218, 219, 3, 4, 5, 6, 7, + 8, 9, 10, 11, -1, 13, 14, 15, 16, 17, + 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, + 28, 29, 30, 31, 32, 33, 34, -1, 36, 37, + 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, + 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, + 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, + 78, 79, 80, 81, 82, 83, -1, -1, 86, 87, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 105, 106, 107, + 108, -1, 110, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 123, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 157, + -1, 159, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 196, -1, + -1, -1, -1, -1, 202, 203, 204, 205, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 217, + 218, 219, 3, 4, 5, 6, 7, 8, 9, 10, + 11, -1, 13, 14, 15, 16, 17, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 34, -1, 36, 37, 38, 39, 40, + 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, + 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, + 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, + 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, + 81, 82, 83, -1, -1, 86, 87, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 105, 106, 107, 108, -1, 110, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 123, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 157, -1, 159, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 196, -1, -1, -1, -1, + -1, 202, 203, 204, 205, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 217, 218, 3, 4, + 5, 6, 7, 8, 9, 10, 11, -1, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, + -1, 36, 37, 38, 39, 40, 41, 42, 43, 44, + 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, + 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, + 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, + 75, 76, 77, 78, 79, 80, 81, 82, 83, -1, + -1, 86, 87, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 105, 106, 107, 108, -1, 110, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 123, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 157, -1, 159, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 196, -1, -1, -1, -1, -1, 202, 203, 204, + 205, 3, 4, 5, 6, 7, 8, -1, -1, -1, + -1, -1, 217, 218, -1, -1, -1, -1, 20, 21, + 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, -1, 36, 37, 38, 39, 40, 41, + 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, + 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, + 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, + 72, 73, 74, -1, 76, 77, 78, 79, 80, 81, + 82, 83, -1, -1, 86, 87, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 105, 106, 107, 108, -1, 110, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 123, -1, 5, 6, 7, 8, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 20, 21, + 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + -1, -1, -1, -1, -1, 157, -1, 159, -1, 41, + 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, + 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, + 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, + 72, 73, 74, -1, 196, 77, -1, -1, -1, -1, + 202, 203, 204, 205, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 217, -1, -1, -1, -1, + -1, -1, -1, -1, 106, 107, 108, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 5, 6, 7, 8, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 20, 21, 22, + 23, 24, 25, 26, 27, 28, 29, 30, 31, -1, + -1, -1, -1, -1, -1, 157, -1, 159, 41, 42, + 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, + 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, + 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, + 73, 74, -1, -1, 77, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 219, -1, -1, + -1, -1, -1, 106, 107, 108, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 5, 6, 7, 8, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, -1, -1, + -1, -1, -1, -1, 157, -1, 159, 41, 42, 43, + 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, + 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, + 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, + 74, -1, 76, 77, 78, 79, 80, 81, 82, 83, + -1, -1, 86, 87, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 219, -1, -1, -1, + -1, -1, 106, 107, 108, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 157, -1, 159, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 196, -1, -1, -1, -1, -1, 202, 203, + 204, 205, 3, 4, 5, 6, 7, 8, -1, -1, + -1, -1, -1, 217, -1, -1, -1, -1, -1, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 34, -1, 36, 37, 38, 39, 40, + 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, + 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, + 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, + 71, 72, 73, 74, -1, 76, 77, 78, 79, 80, + 81, 82, 83, -1, -1, 86, 87, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 105, 106, 107, 108, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 123, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 157, -1, 159, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 5, 6, 7, 8, -1, 196, -1, -1, -1, -1, + -1, 202, 203, 204, 205, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 41, 42, 43, 44, + 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, + 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, + 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, + -1, 76, 77, 78, 79, 80, 81, 82, 83, -1, + -1, 86, 87, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 106, 107, 108, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 157, -1, 159, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 5, 6, 7, 8, + -1, 196, -1, -1, 199, -1, -1, 202, 203, 204, + 205, 20, 21, 22, 23, 24, 25, 26, 27, 28, + 29, 30, 31, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 41, 42, 43, 44, 45, 46, 47, 48, + 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, + 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, + 69, 70, 71, 72, 73, 74, -1, 76, 77, 78, + 79, 80, 81, 82, 83, -1, -1, 86, 87, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 106, 107, 108, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 157, -1, + 159, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 5, 6, 7, 8, -1, 196, -1, -1, + 199, -1, -1, 202, 203, 204, 205, 20, 21, 22, + 23, 24, 25, 26, 27, 28, 29, 30, 31, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 41, 42, + 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, + 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, + 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, + 73, 74, -1, 76, 77, 78, 79, 80, 81, 82, + 83, -1, -1, 86, 87, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 106, 107, 108, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 157, -1, 159, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 5, 6, + 7, 8, -1, 196, -1, -1, 199, -1, -1, 202, + 203, 204, 205, 20, 21, 22, 23, 24, 25, 26, + 27, 28, 29, 30, 31, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 41, 42, 43, 44, 45, 46, + 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, + 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, + 67, 68, 69, 70, 71, 72, 73, 74, -1, 76, + 77, 78, 79, 80, 81, 82, 83, -1, -1, 86, + 87, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 106, + 107, 108, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 157, -1, 159, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 5, 6, 7, 8, -1, 196, + -1, -1, -1, -1, -1, 202, 203, 204, 205, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, + 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, + 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, + 71, 72, 73, 74, -1, 76, 77, 78, 79, 80, + 81, 82, 83, -1, -1, 86, 87, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 106, 107, 108, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 157, -1, 159, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 5, 6, 7, 8, -1, 196, -1, -1, -1, -1, + -1, 202, 203, 204, 205, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 41, 42, 43, 44, + 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, + 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, + 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, + -1, 76, 77, 78, 79, 80, 81, 82, 83, -1, + -1, 86, 87, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 106, 107, 108, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 157, -1, 159, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 3, 4, 5, 6, 7, 8, + -1, 196, -1, -1, -1, -1, -1, 202, 203, 204, + 205, 20, 21, 22, 23, 24, 25, 26, 27, 28, + 29, 30, 31, 32, 33, 34, -1, 36, 37, 38, + 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, + 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, + 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, + 69, 70, 71, 72, 73, 74, -1, -1, 77, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 105, 106, 107, 108, + -1, 110, -1, -1, -1, -1, -1, -1, -1, 118, + 119, 120, 121, 122, 123, 5, 6, 7, 8, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, + 30, 31, -1, -1, -1, -1, -1, -1, 157, -1, + 159, 41, 42, 43, 44, 45, 46, 47, 48, 49, + 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, + 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, + 70, 71, 72, 73, 74, -1, -1, 77, 5, 6, + 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 20, 21, 22, 23, 24, 25, 26, + 27, 28, 29, 30, 31, -1, 106, 107, 108, -1, + -1, -1, -1, -1, 41, 42, 43, 44, 45, 46, + 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, + 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, + 67, 68, 69, 70, 71, 72, 73, 74, -1, -1, + 77, -1, -1, -1, -1, -1, -1, 157, -1, 159, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 157, -1, 159 +}; + +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const yytype_uint16 yystos[] = +{ + 0, 111, 221, 223, 80, 0, 225, 115, 112, 222, + 227, 76, 77, 78, 226, 3, 4, 5, 6, 7, + 8, 20, 21, 22, 23, 24, 25, 26, 27, 28, + 29, 30, 31, 32, 33, 34, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, + 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, + 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, + 70, 71, 72, 73, 74, 77, 105, 106, 107, 108, + 110, 118, 119, 120, 121, 122, 123, 157, 159, 224, + 228, 262, 263, 264, 265, 266, 271, 272, 273, 274, + 277, 279, 280, 281, 282, 283, 284, 285, 286, 311, + 312, 114, 33, 34, 37, 218, 226, 76, 78, 229, + 277, 280, 285, 115, 115, 115, 115, 115, 196, 311, + 217, 218, 298, 197, 201, 4, 33, 34, 35, 268, + 269, 278, 201, 217, 76, 78, 226, 229, 280, 280, + 281, 198, 282, 226, 281, 287, 288, 218, 280, 282, + 226, 275, 276, 9, 10, 11, 13, 14, 15, 16, + 17, 18, 19, 75, 79, 80, 81, 82, 83, 86, + 87, 196, 202, 203, 204, 205, 217, 218, 219, 229, + 230, 231, 233, 234, 235, 236, 237, 238, 239, 244, + 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, + 255, 256, 257, 258, 260, 262, 263, 281, 292, 293, + 294, 295, 299, 300, 301, 304, 305, 306, 310, 268, + 267, 270, 281, 269, 226, 198, 216, 196, 199, 244, + 257, 261, 281, 115, 226, 289, 290, 219, 288, 287, + 217, 216, 197, 201, 217, 217, 293, 196, 196, 217, + 217, 260, 196, 260, 215, 196, 244, 244, 260, 219, + 296, 86, 87, 198, 200, 197, 197, 201, 74, 258, + 196, 95, 96, 97, 98, 99, 100, 101, 102, 103, + 104, 216, 259, 244, 206, 207, 208, 202, 203, 84, + 85, 88, 89, 209, 210, 90, 91, 211, 212, 213, + 92, 94, 93, 214, 201, 217, 219, 293, 226, 267, + 270, 198, 216, 199, 261, 258, 291, 199, 198, 201, + 217, 219, 80, 276, 75, 292, 300, 307, 260, 217, + 260, 215, 105, 260, 273, 303, 197, 299, 232, 260, + 226, 229, 240, 241, 242, 243, 258, 258, 244, 244, + 244, 246, 246, 247, 247, 248, 248, 248, 248, 249, + 249, 250, 251, 252, 253, 254, 255, 260, 258, 198, + 199, 261, 291, 216, 199, 261, 290, 196, 303, 308, + 309, 197, 197, 226, 197, 219, 199, 196, 197, 197, + 201, 74, 258, 215, 261, 216, 199, 291, 216, 199, + 260, 217, 197, 293, 302, 295, 216, 294, 297, 298, + 258, 258, 199, 291, 216, 291, 197, 260, 297, 12, + 291, 291, 217, 293 +}; + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +/* Like YYERROR except do call yyerror. This remains here temporarily + to ease the transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. */ + +#define YYFAIL goto yyerrlab + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + yytoken = YYTRANSLATE (yychar); \ + YYPOPSTACK (1); \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (&yylloc, state, YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ +while (YYID (0)) + + +#define YYTERROR 1 +#define YYERRCODE 256 + + +/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. + If N is 0, then set CURRENT to the empty location which ends + the previous symbol: RHS[0] (always defined). */ + +#define YYRHSLOC(Rhs, K) ((Rhs)[K]) +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (YYID (N)) \ + { \ + (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ + } \ + else \ + { \ + (Current).first_line = (Current).last_line = \ + YYRHSLOC (Rhs, 0).last_line; \ + (Current).first_column = (Current).last_column = \ + YYRHSLOC (Rhs, 0).last_column; \ + } \ + while (YYID (0)) +#endif + + +/* YY_LOCATION_PRINT -- Print the location on the stream. + This macro was not mandated originally: define only if we know + we won't break user code: when these are the locations we know. */ + +#ifndef YY_LOCATION_PRINT +# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL +# define YY_LOCATION_PRINT(File, Loc) \ + fprintf (File, "%d.%d-%d.%d", \ + (Loc).first_line, (Loc).first_column, \ + (Loc).last_line, (Loc).last_column) +# else +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# endif +#endif + + +/* YYLEX -- calling `yylex' with the right arguments. */ + +#ifdef YYLEX_PARAM +# define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM) +#else +# define YYLEX yylex (&yylval, &yylloc, scanner) +#endif + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (YYID (0)) + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value, Location, state); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (YYID (0)) + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, struct _mesa_glsl_parse_state *state) +#else +static void +yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, state) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + YYLTYPE const * const yylocationp; + struct _mesa_glsl_parse_state *state; +#endif +{ + if (!yyvaluep) + return; + YYUSE (yylocationp); + YYUSE (state); +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# else + YYUSE (yyoutput); +# endif + switch (yytype) + { + default: + break; + } +} + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, struct _mesa_glsl_parse_state *state) +#else +static void +yy_symbol_print (yyoutput, yytype, yyvaluep, yylocationp, state) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + YYLTYPE const * const yylocationp; + struct _mesa_glsl_parse_state *state; +#endif +{ + if (yytype < YYNTOKENS) + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + YY_LOCATION_PRINT (yyoutput, *yylocationp); + YYFPRINTF (yyoutput, ": "); + yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, state); + YYFPRINTF (yyoutput, ")"); +} + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) +#else +static void +yy_stack_print (bottom, top) + yytype_int16 *bottom; + yytype_int16 *top; +#endif +{ + YYFPRINTF (stderr, "Stack now"); + for (; bottom <= top; ++bottom) + YYFPRINTF (stderr, " %d", *bottom); + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (YYID (0)) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_reduce_print (YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule, struct _mesa_glsl_parse_state *state) +#else +static void +yy_reduce_print (yyvsp, yylsp, yyrule, state) + YYSTYPE *yyvsp; + YYLTYPE *yylsp; + int yyrule; + struct _mesa_glsl_parse_state *state; +#endif +{ + int yynrhs = yyr2[yyrule]; + int yyi; + unsigned long int yylno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + yyrule - 1, yylno); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) + { + fprintf (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], + &(yyvsp[(yyi + 1) - (yynrhs)]) + , &(yylsp[(yyi + 1) - (yynrhs)]) , state); + fprintf (stderr, "\n"); + } +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (yyvsp, yylsp, Rule, state); \ +} while (YYID (0)) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined __GLIBC__ && defined _STRING_H +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static YYSIZE_T +yystrlen (const char *yystr) +#else +static YYSIZE_T +yystrlen (yystr) + const char *yystr; +#endif +{ + YYSIZE_T yylen; + for (yylen = 0; yystr[yylen]; yylen++) + continue; + return yylen; +} +# endif +# endif + +# ifndef yystpcpy +# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static char * +yystpcpy (char *yydest, const char *yysrc) +#else +static char * +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +#endif +{ + char *yyd = yydest; + const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif + +# ifndef yytnamerr +/* Copy to YYRES the contents of YYSTR after stripping away unnecessary + quotes and backslashes, so that it's suitable for yyerror. The + heuristic is that double-quoting is unnecessary unless the string + contains an apostrophe, a comma, or backslash (other than + backslash-backslash). YYSTR is taken from yytname. If YYRES is + null, do not copy; instead, return the length of what the result + would have been. */ +static YYSIZE_T +yytnamerr (char *yyres, const char *yystr) +{ + if (*yystr == '"') + { + YYSIZE_T yyn = 0; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } + do_not_strip_quotes: ; + } + + if (! yyres) + return yystrlen (yystr); + + return yystpcpy (yyres, yystr) - yyres; +} +# endif + +/* Copy into YYRESULT an error message about the unexpected token + YYCHAR while in state YYSTATE. Return the number of bytes copied, + including the terminating null byte. If YYRESULT is null, do not + copy anything; just return the number of bytes that would be + copied. As a special case, return 0 if an ordinary "syntax error" + message will do. Return YYSIZE_MAXIMUM if overflow occurs during + size calculation. */ +static YYSIZE_T +yysyntax_error (char *yyresult, int yystate, int yychar) +{ + int yyn = yypact[yystate]; + + if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) + return 0; + else + { + int yytype = YYTRANSLATE (yychar); + YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); + YYSIZE_T yysize = yysize0; + YYSIZE_T yysize1; + int yysize_overflow = 0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + int yyx; + +# if 0 + /* This is so xgettext sees the translatable formats that are + constructed on the fly. */ + YY_("syntax error, unexpected %s"); + YY_("syntax error, unexpected %s, expecting %s"); + YY_("syntax error, unexpected %s, expecting %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); +# endif + char *yyfmt; + char const *yyf; + static char const yyunexpected[] = "syntax error, unexpected %s"; + static char const yyexpecting[] = ", expecting %s"; + static char const yyor[] = " or %s"; + char yyformat[sizeof yyunexpected + + sizeof yyexpecting - 1 + + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) + * (sizeof yyor - 1))]; + char const *yyprefix = yyexpecting; + + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 1; + + yyarg[0] = yytname[yytype]; + yyfmt = yystpcpy (yyformat, yyunexpected); + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + yyformat[sizeof yyunexpected - 1] = '\0'; + break; + } + yyarg[yycount++] = yytname[yyx]; + yysize1 = yysize + yytnamerr (0, yytname[yyx]); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + yyfmt = yystpcpy (yyfmt, yyprefix); + yyprefix = yyor; + } + + yyf = YY_(yyformat); + yysize1 = yysize + yystrlen (yyf); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + + if (yysize_overflow) + return YYSIZE_MAXIMUM; + + if (yyresult) + { + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + char *yyp = yyresult; + int yyi = 0; + while ((*yyp = *yyf) != '\0') + { + if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyf += 2; + } + else + { + yyp++; + yyf++; + } + } + } + return yysize; + } +} +#endif /* YYERROR_VERBOSE */ + + +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp, struct _mesa_glsl_parse_state *state) +#else +static void +yydestruct (yymsg, yytype, yyvaluep, yylocationp, state) + const char *yymsg; + int yytype; + YYSTYPE *yyvaluep; + YYLTYPE *yylocationp; + struct _mesa_glsl_parse_state *state; +#endif +{ + YYUSE (yyvaluep); + YYUSE (yylocationp); + YYUSE (state); + + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + + switch (yytype) + { + + default: + break; + } +} + + +/* Prevent warnings from -Wmissing-prototypes. */ + +#ifdef YYPARSE_PARAM +#if defined __STDC__ || defined __cplusplus +int yyparse (void *YYPARSE_PARAM); +#else +int yyparse (); +#endif +#else /* ! YYPARSE_PARAM */ +#if defined __STDC__ || defined __cplusplus +int yyparse (struct _mesa_glsl_parse_state *state); +#else +int yyparse (); +#endif +#endif /* ! YYPARSE_PARAM */ + + + + + + +/*----------. +| yyparse. | +`----------*/ + +#ifdef YYPARSE_PARAM +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (void *YYPARSE_PARAM) +#else +int +yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +#endif +#else /* ! YYPARSE_PARAM */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (struct _mesa_glsl_parse_state *state) +#else +int +yyparse (state) + struct _mesa_glsl_parse_state *state; +#endif +#endif +{ + /* The look-ahead symbol. */ +int yychar; + +/* The semantic value of the look-ahead symbol. */ +YYSTYPE yylval; + +/* Number of syntax errors so far. */ +int yynerrs; +/* Location data for the look-ahead symbol. */ +YYLTYPE yylloc; + + int yystate; + int yyn; + int yyresult; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + /* Look-ahead token as an internal (translated) token number. */ + int yytoken = 0; +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif + + /* Three stacks and their tools: + `yyss': related to states, + `yyvs': related to semantic values, + `yyls': related to locations. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss = yyssa; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs = yyvsa; + YYSTYPE *yyvsp; + + /* The location stack. */ + YYLTYPE yylsa[YYINITDEPTH]; + YYLTYPE *yyls = yylsa; + YYLTYPE *yylsp; + /* The locations where the error started and ended. */ + YYLTYPE yyerror_range[2]; + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N)) + + YYSIZE_T yystacksize = YYINITDEPTH; + + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + YYLTYPE yyloc; + + /* The number of symbols on the RHS of the reduced rule. + Keep to zero when no symbol should be popped. */ + int yylen = 0; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + + yyssp = yyss; + yyvsp = yyvs; + yylsp = yyls; +#if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL + /* Initialize the default location before parsing starts. */ + yylloc.first_line = yylloc.last_line = 1; + yylloc.first_column = yylloc.last_column = 0; +#endif + + + /* User initialization code. */ +#line 41 "src/glsl/glsl_parser.yy" +{ + yylloc.first_line = 1; + yylloc.first_column = 1; + yylloc.last_line = 1; + yylloc.last_column = 1; + yylloc.source = 0; +} +/* Line 1078 of yacc.c. */ +#line 2817 "src/glsl/glsl_parser.cpp" + yylsp[0] = yylloc; + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. So pushing a state here evens the stacks. */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + yytype_int16 *yyss1 = yyss; + YYLTYPE *yyls1 = yyls; + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + &yyls1, yysize * sizeof (*yylsp), + &yystacksize); + yyls = yyls1; + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyexhaustedlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyexhaustedlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss); + YYSTACK_RELOCATE (yyvs); + YYSTACK_RELOCATE (yyls); +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + yylsp = yyls + yysize - 1; + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + goto yybackup; + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + + /* Do appropriate processing given the current state. Read a + look-ahead token if we need one and don't already have one. */ + + /* First try to decide what to do without reference to look-ahead token. */ + yyn = yypact[yystate]; + if (yyn == YYPACT_NINF) + goto yydefault; + + /* Not known => get a look-ahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = YYLEX; + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yytoken = YYTRANSLATE (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + goto yydefault; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yyn == 0 || yyn == YYTABLE_NINF) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + if (yyn == YYFINAL) + YYACCEPT; + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + + /* Shift the look-ahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + + /* Discard the shifted token unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; + + yystate = yyn; + *++yyvsp = yylval; + *++yylsp = yylloc; + goto yynewstate; + + +/*-----------------------------------------------------------. +| yydefault -- do the default action for the current state. | +`-----------------------------------------------------------*/ +yydefault: + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + +/*-----------------------------. +| yyreduce -- Do a reduction. | +`-----------------------------*/ +yyreduce: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + `$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + /* Default location. */ + YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen); + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 2: +#line 218 "src/glsl/glsl_parser.yy" + { + _mesa_glsl_initialize_types(state); + ;} + break; + + case 3: +#line 222 "src/glsl/glsl_parser.yy" + { + delete state->symbols; + state->symbols = new(ralloc_parent(state)) glsl_symbol_table; + _mesa_glsl_initialize_types(state); + ;} + break; + + case 5: +#line 232 "src/glsl/glsl_parser.yy" + { + bool supported = false; + + switch ((yyvsp[(2) - (3)].n)) { + case 100: + state->es_shader = true; + supported = state->Const.GLSL_100ES; + break; + case 110: + supported = state->Const.GLSL_110; + break; + case 120: + supported = state->Const.GLSL_120; + break; + case 130: + supported = state->Const.GLSL_130; + break; + default: + supported = false; + break; + } + + state->language_version = (yyvsp[(2) - (3)].n); + state->version_string = + ralloc_asprintf(state, "GLSL%s %d.%02d", + state->es_shader ? " ES" : "", + state->language_version / 100, + state->language_version % 100); + + if (!supported) { + _mesa_glsl_error(& (yylsp[(2) - (3)]), state, "%s is not supported. " + "Supported versions are: %s\n", + state->version_string, + state->supported_version_string); + } + ;} + break; + + case 10: +#line 276 "src/glsl/glsl_parser.yy" + { + if (state->language_version < 120) { + _mesa_glsl_warning(& (yylsp[(1) - (2)]), state, + "pragma `invariant(all)' not supported in %s", + state->version_string); + } else { + state->all_invariant = true; + } + ;} + break; + + case 16: +#line 300 "src/glsl/glsl_parser.yy" + { + if (!_mesa_glsl_process_extension((yyvsp[(2) - (5)].identifier), & (yylsp[(2) - (5)]), (yyvsp[(4) - (5)].identifier), & (yylsp[(4) - (5)]), state)) { + YYERROR; + } + ;} + break; + + case 17: +#line 309 "src/glsl/glsl_parser.yy" + { + /* FINISHME: The NULL test is required because pragmas are set to + * FINISHME: NULL. (See production rule for external_declaration.) + */ + if ((yyvsp[(1) - (1)].node) != NULL) + state->translation_unit.push_tail(& (yyvsp[(1) - (1)].node)->link); + ;} + break; + + case 18: +#line 317 "src/glsl/glsl_parser.yy" + { + /* FINISHME: The NULL test is required because pragmas are set to + * FINISHME: NULL. (See production rule for external_declaration.) + */ + if ((yyvsp[(2) - (2)].node) != NULL) + state->translation_unit.push_tail(& (yyvsp[(2) - (2)].node)->link); + ;} + break; + + case 21: +#line 333 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + (yyval.expression) = new(ctx) ast_expression(ast_identifier, NULL, NULL, NULL); + (yyval.expression)->set_location(yylloc); + (yyval.expression)->primary_expression.identifier = (yyvsp[(1) - (1)].identifier); + ;} + break; + + case 22: +#line 340 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + (yyval.expression) = new(ctx) ast_expression(ast_int_constant, NULL, NULL, NULL); + (yyval.expression)->set_location(yylloc); + (yyval.expression)->primary_expression.int_constant = (yyvsp[(1) - (1)].n); + ;} + break; + + case 23: +#line 347 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + (yyval.expression) = new(ctx) ast_expression(ast_uint_constant, NULL, NULL, NULL); + (yyval.expression)->set_location(yylloc); + (yyval.expression)->primary_expression.uint_constant = (yyvsp[(1) - (1)].n); + ;} + break; + + case 24: +#line 354 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + (yyval.expression) = new(ctx) ast_expression(ast_float_constant, NULL, NULL, NULL); + (yyval.expression)->set_location(yylloc); + (yyval.expression)->primary_expression.float_constant = (yyvsp[(1) - (1)].real); + ;} + break; + + case 25: +#line 361 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + (yyval.expression) = new(ctx) ast_expression(ast_bool_constant, NULL, NULL, NULL); + (yyval.expression)->set_location(yylloc); + (yyval.expression)->primary_expression.bool_constant = (yyvsp[(1) - (1)].n); + ;} + break; + + case 26: +#line 368 "src/glsl/glsl_parser.yy" + { + (yyval.expression) = (yyvsp[(2) - (3)].expression); + ;} + break; + + case 28: +#line 376 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + (yyval.expression) = new(ctx) ast_expression(ast_array_index, (yyvsp[(1) - (4)].expression), (yyvsp[(3) - (4)].expression), NULL); + (yyval.expression)->set_location(yylloc); + ;} + break; + + case 29: +#line 382 "src/glsl/glsl_parser.yy" + { + (yyval.expression) = (yyvsp[(1) - (1)].expression); + ;} + break; + + case 30: +#line 386 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + (yyval.expression) = new(ctx) ast_expression(ast_field_selection, (yyvsp[(1) - (3)].expression), NULL, NULL); + (yyval.expression)->set_location(yylloc); + (yyval.expression)->primary_expression.identifier = (yyvsp[(3) - (3)].identifier); + ;} + break; + + case 31: +#line 393 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + (yyval.expression) = new(ctx) ast_expression(ast_post_inc, (yyvsp[(1) - (2)].expression), NULL, NULL); + (yyval.expression)->set_location(yylloc); + ;} + break; + + case 32: +#line 399 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + (yyval.expression) = new(ctx) ast_expression(ast_post_dec, (yyvsp[(1) - (2)].expression), NULL, NULL); + (yyval.expression)->set_location(yylloc); + ;} + break; + + case 36: +#line 417 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + (yyval.expression) = new(ctx) ast_expression(ast_field_selection, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression), NULL); + (yyval.expression)->set_location(yylloc); + ;} + break; + + case 41: +#line 436 "src/glsl/glsl_parser.yy" + { + (yyval.expression) = (yyvsp[(1) - (2)].expression); + (yyval.expression)->set_location(yylloc); + (yyval.expression)->expressions.push_tail(& (yyvsp[(2) - (2)].expression)->link); + ;} + break; + + case 42: +#line 442 "src/glsl/glsl_parser.yy" + { + (yyval.expression) = (yyvsp[(1) - (3)].expression); + (yyval.expression)->set_location(yylloc); + (yyval.expression)->expressions.push_tail(& (yyvsp[(3) - (3)].expression)->link); + ;} + break; + + case 44: +#line 458 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + (yyval.expression) = new(ctx) ast_function_expression((yyvsp[(1) - (1)].type_specifier)); + (yyval.expression)->set_location(yylloc); + ;} + break; + + case 45: +#line 464 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + ast_expression *callee = new(ctx) ast_expression((yyvsp[(1) - (1)].identifier)); + (yyval.expression) = new(ctx) ast_function_expression(callee); + (yyval.expression)->set_location(yylloc); + ;} + break; + + case 46: +#line 471 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + ast_expression *callee = new(ctx) ast_expression((yyvsp[(1) - (1)].identifier)); + (yyval.expression) = new(ctx) ast_function_expression(callee); + (yyval.expression)->set_location(yylloc); + ;} + break; + + case 51: +#line 491 "src/glsl/glsl_parser.yy" + { + (yyval.expression) = (yyvsp[(1) - (2)].expression); + (yyval.expression)->set_location(yylloc); + (yyval.expression)->expressions.push_tail(& (yyvsp[(2) - (2)].expression)->link); + ;} + break; + + case 52: +#line 497 "src/glsl/glsl_parser.yy" + { + (yyval.expression) = (yyvsp[(1) - (3)].expression); + (yyval.expression)->set_location(yylloc); + (yyval.expression)->expressions.push_tail(& (yyvsp[(3) - (3)].expression)->link); + ;} + break; + + case 53: +#line 509 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + ast_expression *callee = new(ctx) ast_expression((yyvsp[(1) - (2)].identifier)); + (yyval.expression) = new(ctx) ast_function_expression(callee); + (yyval.expression)->set_location(yylloc); + ;} + break; + + case 55: +#line 521 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + (yyval.expression) = new(ctx) ast_expression(ast_pre_inc, (yyvsp[(2) - (2)].expression), NULL, NULL); + (yyval.expression)->set_location(yylloc); + ;} + break; + + case 56: +#line 527 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + (yyval.expression) = new(ctx) ast_expression(ast_pre_dec, (yyvsp[(2) - (2)].expression), NULL, NULL); + (yyval.expression)->set_location(yylloc); + ;} + break; + + case 57: +#line 533 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + (yyval.expression) = new(ctx) ast_expression((yyvsp[(1) - (2)].n), (yyvsp[(2) - (2)].expression), NULL, NULL); + (yyval.expression)->set_location(yylloc); + ;} + break; + + case 58: +#line 542 "src/glsl/glsl_parser.yy" + { (yyval.n) = ast_plus; ;} + break; + + case 59: +#line 543 "src/glsl/glsl_parser.yy" + { (yyval.n) = ast_neg; ;} + break; + + case 60: +#line 544 "src/glsl/glsl_parser.yy" + { (yyval.n) = ast_logic_not; ;} + break; + + case 61: +#line 545 "src/glsl/glsl_parser.yy" + { (yyval.n) = ast_bit_not; ;} + break; + + case 63: +#line 551 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + (yyval.expression) = new(ctx) ast_expression_bin(ast_mul, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); + (yyval.expression)->set_location(yylloc); + ;} + break; + + case 64: +#line 557 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + (yyval.expression) = new(ctx) ast_expression_bin(ast_div, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); + (yyval.expression)->set_location(yylloc); + ;} + break; + + case 65: +#line 563 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + (yyval.expression) = new(ctx) ast_expression_bin(ast_mod, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); + (yyval.expression)->set_location(yylloc); + ;} + break; + + case 67: +#line 573 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + (yyval.expression) = new(ctx) ast_expression_bin(ast_add, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); + (yyval.expression)->set_location(yylloc); + ;} + break; + + case 68: +#line 579 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + (yyval.expression) = new(ctx) ast_expression_bin(ast_sub, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); + (yyval.expression)->set_location(yylloc); + ;} + break; + + case 70: +#line 589 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + (yyval.expression) = new(ctx) ast_expression_bin(ast_lshift, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); + (yyval.expression)->set_location(yylloc); + ;} + break; + + case 71: +#line 595 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + (yyval.expression) = new(ctx) ast_expression_bin(ast_rshift, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); + (yyval.expression)->set_location(yylloc); + ;} + break; + + case 73: +#line 605 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + (yyval.expression) = new(ctx) ast_expression_bin(ast_less, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); + (yyval.expression)->set_location(yylloc); + ;} + break; + + case 74: +#line 611 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + (yyval.expression) = new(ctx) ast_expression_bin(ast_greater, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); + (yyval.expression)->set_location(yylloc); + ;} + break; + + case 75: +#line 617 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + (yyval.expression) = new(ctx) ast_expression_bin(ast_lequal, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); + (yyval.expression)->set_location(yylloc); + ;} + break; + + case 76: +#line 623 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + (yyval.expression) = new(ctx) ast_expression_bin(ast_gequal, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); + (yyval.expression)->set_location(yylloc); + ;} + break; + + case 78: +#line 633 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + (yyval.expression) = new(ctx) ast_expression_bin(ast_equal, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); + (yyval.expression)->set_location(yylloc); + ;} + break; + + case 79: +#line 639 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + (yyval.expression) = new(ctx) ast_expression_bin(ast_nequal, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); + (yyval.expression)->set_location(yylloc); + ;} + break; + + case 81: +#line 649 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + (yyval.expression) = new(ctx) ast_expression_bin(ast_bit_and, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); + (yyval.expression)->set_location(yylloc); + ;} + break; + + case 83: +#line 659 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + (yyval.expression) = new(ctx) ast_expression_bin(ast_bit_xor, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); + (yyval.expression)->set_location(yylloc); + ;} + break; + + case 85: +#line 669 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + (yyval.expression) = new(ctx) ast_expression_bin(ast_bit_or, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); + (yyval.expression)->set_location(yylloc); + ;} + break; + + case 87: +#line 679 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + (yyval.expression) = new(ctx) ast_expression_bin(ast_logic_and, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); + (yyval.expression)->set_location(yylloc); + ;} + break; + + case 89: +#line 689 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + (yyval.expression) = new(ctx) ast_expression_bin(ast_logic_xor, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); + (yyval.expression)->set_location(yylloc); + ;} + break; + + case 91: +#line 699 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + (yyval.expression) = new(ctx) ast_expression_bin(ast_logic_or, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); + (yyval.expression)->set_location(yylloc); + ;} + break; + + case 93: +#line 709 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + (yyval.expression) = new(ctx) ast_expression(ast_conditional, (yyvsp[(1) - (5)].expression), (yyvsp[(3) - (5)].expression), (yyvsp[(5) - (5)].expression)); + (yyval.expression)->set_location(yylloc); + ;} + break; + + case 95: +#line 719 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + (yyval.expression) = new(ctx) ast_expression((yyvsp[(2) - (3)].n), (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression), NULL); + (yyval.expression)->set_location(yylloc); + ;} + break; + + case 96: +#line 727 "src/glsl/glsl_parser.yy" + { (yyval.n) = ast_assign; ;} + break; + + case 97: +#line 728 "src/glsl/glsl_parser.yy" + { (yyval.n) = ast_mul_assign; ;} + break; + + case 98: +#line 729 "src/glsl/glsl_parser.yy" + { (yyval.n) = ast_div_assign; ;} + break; + + case 99: +#line 730 "src/glsl/glsl_parser.yy" + { (yyval.n) = ast_mod_assign; ;} + break; + + case 100: +#line 731 "src/glsl/glsl_parser.yy" + { (yyval.n) = ast_add_assign; ;} + break; + + case 101: +#line 732 "src/glsl/glsl_parser.yy" + { (yyval.n) = ast_sub_assign; ;} + break; + + case 102: +#line 733 "src/glsl/glsl_parser.yy" + { (yyval.n) = ast_ls_assign; ;} + break; + + case 103: +#line 734 "src/glsl/glsl_parser.yy" + { (yyval.n) = ast_rs_assign; ;} + break; + + case 104: +#line 735 "src/glsl/glsl_parser.yy" + { (yyval.n) = ast_and_assign; ;} + break; + + case 105: +#line 736 "src/glsl/glsl_parser.yy" + { (yyval.n) = ast_xor_assign; ;} + break; + + case 106: +#line 737 "src/glsl/glsl_parser.yy" + { (yyval.n) = ast_or_assign; ;} + break; + + case 107: +#line 742 "src/glsl/glsl_parser.yy" + { + (yyval.expression) = (yyvsp[(1) - (1)].expression); + ;} + break; + + case 108: +#line 746 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + if ((yyvsp[(1) - (3)].expression)->oper != ast_sequence) { + (yyval.expression) = new(ctx) ast_expression(ast_sequence, NULL, NULL, NULL); + (yyval.expression)->set_location(yylloc); + (yyval.expression)->expressions.push_tail(& (yyvsp[(1) - (3)].expression)->link); + } else { + (yyval.expression) = (yyvsp[(1) - (3)].expression); + } + + (yyval.expression)->expressions.push_tail(& (yyvsp[(3) - (3)].expression)->link); + ;} + break; + + case 110: +#line 766 "src/glsl/glsl_parser.yy" + { + state->symbols->pop_scope(); + (yyval.node) = (yyvsp[(1) - (2)].function); + ;} + break; + + case 111: +#line 771 "src/glsl/glsl_parser.yy" + { + (yyval.node) = (yyvsp[(1) - (2)].declarator_list); + ;} + break; + + case 112: +#line 775 "src/glsl/glsl_parser.yy" + { + (yyvsp[(3) - (4)].type_specifier)->precision = (yyvsp[(2) - (4)].n); + (yyvsp[(3) - (4)].type_specifier)->is_precision_statement = true; + (yyval.node) = (yyvsp[(3) - (4)].type_specifier); + ;} + break; + + case 116: +#line 793 "src/glsl/glsl_parser.yy" + { + (yyval.function) = (yyvsp[(1) - (2)].function); + (yyval.function)->parameters.push_tail(& (yyvsp[(2) - (2)].parameter_declarator)->link); + ;} + break; + + case 117: +#line 798 "src/glsl/glsl_parser.yy" + { + (yyval.function) = (yyvsp[(1) - (3)].function); + (yyval.function)->parameters.push_tail(& (yyvsp[(3) - (3)].parameter_declarator)->link); + ;} + break; + + case 118: +#line 806 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + (yyval.function) = new(ctx) ast_function(); + (yyval.function)->set_location(yylloc); + (yyval.function)->return_type = (yyvsp[(1) - (3)].fully_specified_type); + (yyval.function)->identifier = (yyvsp[(2) - (3)].identifier); + + state->symbols->add_function(new(state) ir_function((yyvsp[(2) - (3)].identifier))); + state->symbols->push_scope(); + ;} + break; + + case 119: +#line 820 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + (yyval.parameter_declarator) = new(ctx) ast_parameter_declarator(); + (yyval.parameter_declarator)->set_location(yylloc); + (yyval.parameter_declarator)->type = new(ctx) ast_fully_specified_type(); + (yyval.parameter_declarator)->type->set_location(yylloc); + (yyval.parameter_declarator)->type->specifier = (yyvsp[(1) - (2)].type_specifier); + (yyval.parameter_declarator)->identifier = (yyvsp[(2) - (2)].identifier); + ;} + break; + + case 120: +#line 830 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + (yyval.parameter_declarator) = new(ctx) ast_parameter_declarator(); + (yyval.parameter_declarator)->set_location(yylloc); + (yyval.parameter_declarator)->type = new(ctx) ast_fully_specified_type(); + (yyval.parameter_declarator)->type->set_location(yylloc); + (yyval.parameter_declarator)->type->specifier = (yyvsp[(1) - (5)].type_specifier); + (yyval.parameter_declarator)->identifier = (yyvsp[(2) - (5)].identifier); + (yyval.parameter_declarator)->is_array = true; + (yyval.parameter_declarator)->array_size = (yyvsp[(4) - (5)].expression); + ;} + break; + + case 121: +#line 845 "src/glsl/glsl_parser.yy" + { + (yyvsp[(1) - (3)].type_qualifier).flags.i |= (yyvsp[(2) - (3)].type_qualifier).flags.i; + + (yyval.parameter_declarator) = (yyvsp[(3) - (3)].parameter_declarator); + (yyval.parameter_declarator)->type->qualifier = (yyvsp[(1) - (3)].type_qualifier); + ;} + break; + + case 122: +#line 852 "src/glsl/glsl_parser.yy" + { + (yyval.parameter_declarator) = (yyvsp[(2) - (2)].parameter_declarator); + (yyval.parameter_declarator)->type->qualifier = (yyvsp[(1) - (2)].type_qualifier); + ;} + break; + + case 123: +#line 857 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + (yyvsp[(1) - (3)].type_qualifier).flags.i |= (yyvsp[(2) - (3)].type_qualifier).flags.i; + + (yyval.parameter_declarator) = new(ctx) ast_parameter_declarator(); + (yyval.parameter_declarator)->set_location(yylloc); + (yyval.parameter_declarator)->type = new(ctx) ast_fully_specified_type(); + (yyval.parameter_declarator)->type->qualifier = (yyvsp[(1) - (3)].type_qualifier); + (yyval.parameter_declarator)->type->specifier = (yyvsp[(3) - (3)].type_specifier); + ;} + break; + + case 124: +#line 868 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + (yyval.parameter_declarator) = new(ctx) ast_parameter_declarator(); + (yyval.parameter_declarator)->set_location(yylloc); + (yyval.parameter_declarator)->type = new(ctx) ast_fully_specified_type(); + (yyval.parameter_declarator)->type->qualifier = (yyvsp[(1) - (2)].type_qualifier); + (yyval.parameter_declarator)->type->specifier = (yyvsp[(2) - (2)].type_specifier); + ;} + break; + + case 125: +#line 880 "src/glsl/glsl_parser.yy" + { + memset(& (yyval.type_qualifier), 0, sizeof((yyval.type_qualifier))); + ;} + break; + + case 126: +#line 884 "src/glsl/glsl_parser.yy" + { + memset(& (yyval.type_qualifier), 0, sizeof((yyval.type_qualifier))); + (yyval.type_qualifier).flags.q.in = 1; + ;} + break; + + case 127: +#line 889 "src/glsl/glsl_parser.yy" + { + memset(& (yyval.type_qualifier), 0, sizeof((yyval.type_qualifier))); + (yyval.type_qualifier).flags.q.out = 1; + ;} + break; + + case 128: +#line 894 "src/glsl/glsl_parser.yy" + { + memset(& (yyval.type_qualifier), 0, sizeof((yyval.type_qualifier))); + (yyval.type_qualifier).flags.q.in = 1; + (yyval.type_qualifier).flags.q.out = 1; + ;} + break; + + case 131: +#line 908 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(3) - (3)].identifier), false, NULL, NULL); + decl->set_location(yylloc); + + (yyval.declarator_list) = (yyvsp[(1) - (3)].declarator_list); + (yyval.declarator_list)->declarations.push_tail(&decl->link); + state->symbols->add_variable(new(state) ir_variable(NULL, (yyvsp[(3) - (3)].identifier), ir_var_auto, glsl_precision_undefined)); + ;} + break; + + case 132: +#line 918 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(3) - (5)].identifier), true, NULL, NULL); + decl->set_location(yylloc); + + (yyval.declarator_list) = (yyvsp[(1) - (5)].declarator_list); + (yyval.declarator_list)->declarations.push_tail(&decl->link); + state->symbols->add_variable(new(state) ir_variable(NULL, (yyvsp[(3) - (5)].identifier), ir_var_auto, glsl_precision_undefined)); + ;} + break; + + case 133: +#line 928 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(3) - (6)].identifier), true, (yyvsp[(5) - (6)].expression), NULL); + decl->set_location(yylloc); + + (yyval.declarator_list) = (yyvsp[(1) - (6)].declarator_list); + (yyval.declarator_list)->declarations.push_tail(&decl->link); + state->symbols->add_variable(new(state) ir_variable(NULL, (yyvsp[(3) - (6)].identifier), ir_var_auto, glsl_precision_undefined)); + ;} + break; + + case 134: +#line 938 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(3) - (7)].identifier), true, NULL, (yyvsp[(7) - (7)].expression)); + decl->set_location(yylloc); + + (yyval.declarator_list) = (yyvsp[(1) - (7)].declarator_list); + (yyval.declarator_list)->declarations.push_tail(&decl->link); + state->symbols->add_variable(new(state) ir_variable(NULL, (yyvsp[(3) - (7)].identifier), ir_var_auto, glsl_precision_undefined)); + ;} + break; + + case 135: +#line 948 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(3) - (8)].identifier), true, (yyvsp[(5) - (8)].expression), (yyvsp[(8) - (8)].expression)); + decl->set_location(yylloc); + + (yyval.declarator_list) = (yyvsp[(1) - (8)].declarator_list); + (yyval.declarator_list)->declarations.push_tail(&decl->link); + state->symbols->add_variable(new(state) ir_variable(NULL, (yyvsp[(3) - (8)].identifier), ir_var_auto, glsl_precision_undefined)); + ;} + break; + + case 136: +#line 958 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(3) - (5)].identifier), false, NULL, (yyvsp[(5) - (5)].expression)); + decl->set_location(yylloc); + + (yyval.declarator_list) = (yyvsp[(1) - (5)].declarator_list); + (yyval.declarator_list)->declarations.push_tail(&decl->link); + state->symbols->add_variable(new(state) ir_variable(NULL, (yyvsp[(3) - (5)].identifier), ir_var_auto, glsl_precision_undefined)); + ;} + break; + + case 137: +#line 972 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + if ((yyvsp[(1) - (1)].fully_specified_type)->specifier->type_specifier != ast_struct) { + _mesa_glsl_error(& (yylsp[(1) - (1)]), state, "empty declaration list\n"); + YYERROR; + } else { + (yyval.declarator_list) = new(ctx) ast_declarator_list((yyvsp[(1) - (1)].fully_specified_type)); + (yyval.declarator_list)->set_location(yylloc); + } + ;} + break; + + case 138: +#line 983 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (2)].identifier), false, NULL, NULL); + + (yyval.declarator_list) = new(ctx) ast_declarator_list((yyvsp[(1) - (2)].fully_specified_type)); + (yyval.declarator_list)->set_location(yylloc); + (yyval.declarator_list)->declarations.push_tail(&decl->link); + ;} + break; + + case 139: +#line 992 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (4)].identifier), true, NULL, NULL); + + (yyval.declarator_list) = new(ctx) ast_declarator_list((yyvsp[(1) - (4)].fully_specified_type)); + (yyval.declarator_list)->set_location(yylloc); + (yyval.declarator_list)->declarations.push_tail(&decl->link); + ;} + break; + + case 140: +#line 1001 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (5)].identifier), true, (yyvsp[(4) - (5)].expression), NULL); + + (yyval.declarator_list) = new(ctx) ast_declarator_list((yyvsp[(1) - (5)].fully_specified_type)); + (yyval.declarator_list)->set_location(yylloc); + (yyval.declarator_list)->declarations.push_tail(&decl->link); + ;} + break; + + case 141: +#line 1010 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (6)].identifier), true, NULL, (yyvsp[(6) - (6)].expression)); + + (yyval.declarator_list) = new(ctx) ast_declarator_list((yyvsp[(1) - (6)].fully_specified_type)); + (yyval.declarator_list)->set_location(yylloc); + (yyval.declarator_list)->declarations.push_tail(&decl->link); + ;} + break; + + case 142: +#line 1019 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (7)].identifier), true, (yyvsp[(4) - (7)].expression), (yyvsp[(7) - (7)].expression)); + + (yyval.declarator_list) = new(ctx) ast_declarator_list((yyvsp[(1) - (7)].fully_specified_type)); + (yyval.declarator_list)->set_location(yylloc); + (yyval.declarator_list)->declarations.push_tail(&decl->link); + ;} + break; + + case 143: +#line 1028 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (4)].identifier), false, NULL, (yyvsp[(4) - (4)].expression)); + + (yyval.declarator_list) = new(ctx) ast_declarator_list((yyvsp[(1) - (4)].fully_specified_type)); + (yyval.declarator_list)->set_location(yylloc); + (yyval.declarator_list)->declarations.push_tail(&decl->link); + ;} + break; + + case 144: +#line 1037 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (2)].identifier), false, NULL, NULL); + + (yyval.declarator_list) = new(ctx) ast_declarator_list(NULL); + (yyval.declarator_list)->set_location(yylloc); + (yyval.declarator_list)->invariant = true; + + (yyval.declarator_list)->declarations.push_tail(&decl->link); + ;} + break; + + case 145: +#line 1051 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + (yyval.fully_specified_type) = new(ctx) ast_fully_specified_type(); + (yyval.fully_specified_type)->set_location(yylloc); + (yyval.fully_specified_type)->specifier = (yyvsp[(1) - (1)].type_specifier); + ;} + break; + + case 146: +#line 1058 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + (yyval.fully_specified_type) = new(ctx) ast_fully_specified_type(); + (yyval.fully_specified_type)->set_location(yylloc); + (yyval.fully_specified_type)->qualifier = (yyvsp[(1) - (2)].type_qualifier); + (yyval.fully_specified_type)->specifier = (yyvsp[(2) - (2)].type_specifier); + ;} + break; + + case 147: +#line 1069 "src/glsl/glsl_parser.yy" + { + (yyval.type_qualifier) = (yyvsp[(3) - (4)].type_qualifier); + ;} + break; + + case 149: +#line 1077 "src/glsl/glsl_parser.yy" + { + if (((yyvsp[(1) - (3)].type_qualifier).flags.i & (yyvsp[(3) - (3)].type_qualifier).flags.i) != 0) { + _mesa_glsl_error(& (yylsp[(3) - (3)]), state, + "duplicate layout qualifiers used\n"); + YYERROR; + } + + (yyval.type_qualifier).flags.i = (yyvsp[(1) - (3)].type_qualifier).flags.i | (yyvsp[(3) - (3)].type_qualifier).flags.i; + + if ((yyvsp[(1) - (3)].type_qualifier).flags.q.explicit_location) + (yyval.type_qualifier).location = (yyvsp[(1) - (3)].type_qualifier).location; + + if ((yyvsp[(3) - (3)].type_qualifier).flags.q.explicit_location) + (yyval.type_qualifier).location = (yyvsp[(3) - (3)].type_qualifier).location; + ;} + break; + + case 150: +#line 1096 "src/glsl/glsl_parser.yy" + { + bool got_one = false; + + memset(& (yyval.type_qualifier), 0, sizeof((yyval.type_qualifier))); + + /* Layout qualifiers for ARB_fragment_coord_conventions. */ + if (!got_one && state->ARB_fragment_coord_conventions_enable) { + if (strcmp((yyvsp[(1) - (1)].identifier), "origin_upper_left") == 0) { + got_one = true; + (yyval.type_qualifier).flags.q.origin_upper_left = 1; + } else if (strcmp((yyvsp[(1) - (1)].identifier), "pixel_center_integer") == 0) { + got_one = true; + (yyval.type_qualifier).flags.q.pixel_center_integer = 1; + } + + if (got_one && state->ARB_fragment_coord_conventions_warn) { + _mesa_glsl_warning(& (yylsp[(1) - (1)]), state, + "GL_ARB_fragment_coord_conventions layout " + "identifier `%s' used\n", (yyvsp[(1) - (1)].identifier)); + } + } + + /* Layout qualifiers for AMD_conservative_depth. */ + if (!got_one && state->AMD_conservative_depth_enable) { + if (strcmp((yyvsp[(1) - (1)].identifier), "depth_any") == 0) { + got_one = true; + (yyval.type_qualifier).flags.q.depth_any = 1; + } else if (strcmp((yyvsp[(1) - (1)].identifier), "depth_greater") == 0) { + got_one = true; + (yyval.type_qualifier).flags.q.depth_greater = 1; + } else if (strcmp((yyvsp[(1) - (1)].identifier), "depth_less") == 0) { + got_one = true; + (yyval.type_qualifier).flags.q.depth_less = 1; + } else if (strcmp((yyvsp[(1) - (1)].identifier), "depth_unchanged") == 0) { + got_one = true; + (yyval.type_qualifier).flags.q.depth_unchanged = 1; + } + + if (got_one && state->AMD_conservative_depth_warn) { + _mesa_glsl_warning(& (yylsp[(1) - (1)]), state, + "GL_AMD_conservative_depth " + "layout qualifier `%s' is used\n", (yyvsp[(1) - (1)].identifier)); + } + } + + if (!got_one) { + _mesa_glsl_error(& (yylsp[(1) - (1)]), state, "unrecognized layout identifier " + "`%s'\n", (yyvsp[(1) - (1)].identifier)); + YYERROR; + } + ;} + break; + + case 151: +#line 1148 "src/glsl/glsl_parser.yy" + { + bool got_one = false; + + memset(& (yyval.type_qualifier), 0, sizeof((yyval.type_qualifier))); + + if (state->ARB_explicit_attrib_location_enable) { + /* FINISHME: Handle 'index' once GL_ARB_blend_func_exteneded and + * FINISHME: GLSL 1.30 (or later) are supported. + */ + if (strcmp("location", (yyvsp[(1) - (3)].identifier)) == 0) { + got_one = true; + + (yyval.type_qualifier).flags.q.explicit_location = 1; + + if ((yyvsp[(3) - (3)].n) >= 0) { + (yyval.type_qualifier).location = (yyvsp[(3) - (3)].n); + } else { + _mesa_glsl_error(& (yylsp[(3) - (3)]), state, + "invalid location %d specified\n", (yyvsp[(3) - (3)].n)); + YYERROR; + } + } + } + + /* If the identifier didn't match any known layout identifiers, + * emit an error. + */ + if (!got_one) { + _mesa_glsl_error(& (yylsp[(1) - (3)]), state, "unrecognized layout identifier " + "`%s'\n", (yyvsp[(1) - (3)].identifier)); + YYERROR; + } else if (state->ARB_explicit_attrib_location_warn) { + _mesa_glsl_warning(& (yylsp[(1) - (3)]), state, + "GL_ARB_explicit_attrib_location layout " + "identifier `%s' used\n", (yyvsp[(1) - (3)].identifier)); + } + ;} + break; + + case 152: +#line 1189 "src/glsl/glsl_parser.yy" + { + memset(& (yyval.type_qualifier), 0, sizeof((yyval.type_qualifier))); + (yyval.type_qualifier).flags.q.smooth = 1; + ;} + break; + + case 153: +#line 1194 "src/glsl/glsl_parser.yy" + { + memset(& (yyval.type_qualifier), 0, sizeof((yyval.type_qualifier))); + (yyval.type_qualifier).flags.q.flat = 1; + ;} + break; + + case 154: +#line 1199 "src/glsl/glsl_parser.yy" + { + memset(& (yyval.type_qualifier), 0, sizeof((yyval.type_qualifier))); + (yyval.type_qualifier).flags.q.noperspective = 1; + ;} + break; + + case 155: +#line 1207 "src/glsl/glsl_parser.yy" + { + memset(& (yyval.type_qualifier), 0, sizeof((yyval.type_qualifier))); + (yyval.type_qualifier).flags.q.constant = 1; + ;} + break; + + case 158: +#line 1217 "src/glsl/glsl_parser.yy" + { + (yyval.type_qualifier) = (yyvsp[(1) - (2)].type_qualifier); + (yyval.type_qualifier).flags.i |= (yyvsp[(2) - (2)].type_qualifier).flags.i; + ;} + break; + + case 160: +#line 1223 "src/glsl/glsl_parser.yy" + { + (yyval.type_qualifier) = (yyvsp[(1) - (2)].type_qualifier); + (yyval.type_qualifier).flags.i |= (yyvsp[(2) - (2)].type_qualifier).flags.i; + ;} + break; + + case 161: +#line 1228 "src/glsl/glsl_parser.yy" + { + (yyval.type_qualifier) = (yyvsp[(2) - (2)].type_qualifier); + (yyval.type_qualifier).flags.q.invariant = 1; + ;} + break; + + case 162: +#line 1233 "src/glsl/glsl_parser.yy" + { + (yyval.type_qualifier) = (yyvsp[(2) - (3)].type_qualifier); + (yyval.type_qualifier).flags.i |= (yyvsp[(3) - (3)].type_qualifier).flags.i; + (yyval.type_qualifier).flags.q.invariant = 1; + ;} + break; + + case 163: +#line 1239 "src/glsl/glsl_parser.yy" + { + memset(& (yyval.type_qualifier), 0, sizeof((yyval.type_qualifier))); + (yyval.type_qualifier).flags.q.invariant = 1; + ;} + break; + + case 164: +#line 1247 "src/glsl/glsl_parser.yy" + { + memset(& (yyval.type_qualifier), 0, sizeof((yyval.type_qualifier))); + (yyval.type_qualifier).flags.q.constant = 1; + ;} + break; + + case 165: +#line 1252 "src/glsl/glsl_parser.yy" + { + memset(& (yyval.type_qualifier), 0, sizeof((yyval.type_qualifier))); + (yyval.type_qualifier).flags.q.attribute = 1; + ;} + break; + + case 166: +#line 1257 "src/glsl/glsl_parser.yy" + { + memset(& (yyval.type_qualifier), 0, sizeof((yyval.type_qualifier))); + (yyval.type_qualifier).flags.q.varying = 1; + ;} + break; + + case 167: +#line 1262 "src/glsl/glsl_parser.yy" + { + memset(& (yyval.type_qualifier), 0, sizeof((yyval.type_qualifier))); + (yyval.type_qualifier).flags.q.centroid = 1; + (yyval.type_qualifier).flags.q.varying = 1; + ;} + break; + + case 168: +#line 1268 "src/glsl/glsl_parser.yy" + { + memset(& (yyval.type_qualifier), 0, sizeof((yyval.type_qualifier))); + (yyval.type_qualifier).flags.q.in = 1; + ;} + break; + + case 169: +#line 1273 "src/glsl/glsl_parser.yy" + { + memset(& (yyval.type_qualifier), 0, sizeof((yyval.type_qualifier))); + (yyval.type_qualifier).flags.q.out = 1; + ;} + break; + + case 170: +#line 1278 "src/glsl/glsl_parser.yy" + { + memset(& (yyval.type_qualifier), 0, sizeof((yyval.type_qualifier))); + (yyval.type_qualifier).flags.q.centroid = 1; (yyval.type_qualifier).flags.q.in = 1; + ;} + break; + + case 171: +#line 1283 "src/glsl/glsl_parser.yy" + { + memset(& (yyval.type_qualifier), 0, sizeof((yyval.type_qualifier))); + (yyval.type_qualifier).flags.q.centroid = 1; (yyval.type_qualifier).flags.q.out = 1; + ;} + break; + + case 172: +#line 1288 "src/glsl/glsl_parser.yy" + { + memset(& (yyval.type_qualifier), 0, sizeof((yyval.type_qualifier))); + (yyval.type_qualifier).flags.q.uniform = 1; + ;} + break; + + case 173: +#line 1296 "src/glsl/glsl_parser.yy" + { + (yyval.type_specifier) = (yyvsp[(1) - (1)].type_specifier); + ;} + break; + + case 174: +#line 1300 "src/glsl/glsl_parser.yy" + { + (yyval.type_specifier) = (yyvsp[(2) - (2)].type_specifier); + (yyval.type_specifier)->precision = (yyvsp[(1) - (2)].n); + ;} + break; + + case 176: +#line 1309 "src/glsl/glsl_parser.yy" + { + (yyval.type_specifier) = (yyvsp[(1) - (3)].type_specifier); + (yyval.type_specifier)->is_array = true; + (yyval.type_specifier)->array_size = NULL; + ;} + break; + + case 177: +#line 1315 "src/glsl/glsl_parser.yy" + { + (yyval.type_specifier) = (yyvsp[(1) - (4)].type_specifier); + (yyval.type_specifier)->is_array = true; + (yyval.type_specifier)->array_size = (yyvsp[(3) - (4)].expression); + ;} + break; + + case 178: +#line 1324 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + (yyval.type_specifier) = new(ctx) ast_type_specifier((yyvsp[(1) - (1)].n)); + (yyval.type_specifier)->set_location(yylloc); + ;} + break; + + case 179: +#line 1330 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + (yyval.type_specifier) = new(ctx) ast_type_specifier((yyvsp[(1) - (1)].struct_specifier)); + (yyval.type_specifier)->set_location(yylloc); + ;} + break; + + case 180: +#line 1336 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + (yyval.type_specifier) = new(ctx) ast_type_specifier((yyvsp[(1) - (1)].identifier)); + (yyval.type_specifier)->set_location(yylloc); + ;} + break; + + case 181: +#line 1344 "src/glsl/glsl_parser.yy" + { (yyval.n) = ast_void; ;} + break; + + case 182: +#line 1345 "src/glsl/glsl_parser.yy" + { (yyval.n) = ast_float; ;} + break; + + case 183: +#line 1346 "src/glsl/glsl_parser.yy" + { (yyval.n) = ast_int; ;} + break; + + case 184: +#line 1347 "src/glsl/glsl_parser.yy" + { (yyval.n) = ast_uint; ;} + break; + + case 185: +#line 1348 "src/glsl/glsl_parser.yy" + { (yyval.n) = ast_bool; ;} + break; + + case 186: +#line 1349 "src/glsl/glsl_parser.yy" + { (yyval.n) = ast_vec2; ;} + break; + + case 187: +#line 1350 "src/glsl/glsl_parser.yy" + { (yyval.n) = ast_vec3; ;} + break; + + case 188: +#line 1351 "src/glsl/glsl_parser.yy" + { (yyval.n) = ast_vec4; ;} + break; + + case 189: +#line 1352 "src/glsl/glsl_parser.yy" + { (yyval.n) = ast_bvec2; ;} + break; + + case 190: +#line 1353 "src/glsl/glsl_parser.yy" + { (yyval.n) = ast_bvec3; ;} + break; + + case 191: +#line 1354 "src/glsl/glsl_parser.yy" + { (yyval.n) = ast_bvec4; ;} + break; + + case 192: +#line 1355 "src/glsl/glsl_parser.yy" + { (yyval.n) = ast_ivec2; ;} + break; + + case 193: +#line 1356 "src/glsl/glsl_parser.yy" + { (yyval.n) = ast_ivec3; ;} + break; + + case 194: +#line 1357 "src/glsl/glsl_parser.yy" + { (yyval.n) = ast_ivec4; ;} + break; + + case 195: +#line 1358 "src/glsl/glsl_parser.yy" + { (yyval.n) = ast_uvec2; ;} + break; + + case 196: +#line 1359 "src/glsl/glsl_parser.yy" + { (yyval.n) = ast_uvec3; ;} + break; + + case 197: +#line 1360 "src/glsl/glsl_parser.yy" + { (yyval.n) = ast_uvec4; ;} + break; + + case 198: +#line 1361 "src/glsl/glsl_parser.yy" + { (yyval.n) = ast_mat2; ;} + break; + + case 199: +#line 1362 "src/glsl/glsl_parser.yy" + { (yyval.n) = ast_mat2x3; ;} + break; + + case 200: +#line 1363 "src/glsl/glsl_parser.yy" + { (yyval.n) = ast_mat2x4; ;} + break; + + case 201: +#line 1364 "src/glsl/glsl_parser.yy" + { (yyval.n) = ast_mat3x2; ;} + break; + + case 202: +#line 1365 "src/glsl/glsl_parser.yy" + { (yyval.n) = ast_mat3; ;} + break; + + case 203: +#line 1366 "src/glsl/glsl_parser.yy" + { (yyval.n) = ast_mat3x4; ;} + break; + + case 204: +#line 1367 "src/glsl/glsl_parser.yy" + { (yyval.n) = ast_mat4x2; ;} + break; + + case 205: +#line 1368 "src/glsl/glsl_parser.yy" + { (yyval.n) = ast_mat4x3; ;} + break; + + case 206: +#line 1369 "src/glsl/glsl_parser.yy" + { (yyval.n) = ast_mat4; ;} + break; + + case 207: +#line 1370 "src/glsl/glsl_parser.yy" + { (yyval.n) = ast_sampler1d; ;} + break; + + case 208: +#line 1371 "src/glsl/glsl_parser.yy" + { (yyval.n) = ast_sampler2d; ;} + break; + + case 209: +#line 1372 "src/glsl/glsl_parser.yy" + { (yyval.n) = ast_sampler2drect; ;} + break; + + case 210: +#line 1373 "src/glsl/glsl_parser.yy" + { (yyval.n) = ast_sampler3d; ;} + break; + + case 211: +#line 1374 "src/glsl/glsl_parser.yy" + { (yyval.n) = ast_samplercube; ;} + break; + + case 212: +#line 1375 "src/glsl/glsl_parser.yy" + { (yyval.n) = ast_sampler1dshadow; ;} + break; + + case 213: +#line 1376 "src/glsl/glsl_parser.yy" + { (yyval.n) = ast_sampler2dshadow; ;} + break; + + case 214: +#line 1377 "src/glsl/glsl_parser.yy" + { (yyval.n) = ast_sampler2drectshadow; ;} + break; + + case 215: +#line 1378 "src/glsl/glsl_parser.yy" + { (yyval.n) = ast_samplercubeshadow; ;} + break; + + case 216: +#line 1379 "src/glsl/glsl_parser.yy" + { (yyval.n) = ast_sampler1darray; ;} + break; + + case 217: +#line 1380 "src/glsl/glsl_parser.yy" + { (yyval.n) = ast_sampler2darray; ;} + break; + + case 218: +#line 1381 "src/glsl/glsl_parser.yy" + { (yyval.n) = ast_sampler1darrayshadow; ;} + break; + + case 219: +#line 1382 "src/glsl/glsl_parser.yy" + { (yyval.n) = ast_sampler2darrayshadow; ;} + break; + + case 220: +#line 1383 "src/glsl/glsl_parser.yy" + { (yyval.n) = ast_isampler1d; ;} + break; + + case 221: +#line 1384 "src/glsl/glsl_parser.yy" + { (yyval.n) = ast_isampler2d; ;} + break; + + case 222: +#line 1385 "src/glsl/glsl_parser.yy" + { (yyval.n) = ast_isampler3d; ;} + break; + + case 223: +#line 1386 "src/glsl/glsl_parser.yy" + { (yyval.n) = ast_isamplercube; ;} + break; + + case 224: +#line 1387 "src/glsl/glsl_parser.yy" + { (yyval.n) = ast_isampler1darray; ;} + break; + + case 225: +#line 1388 "src/glsl/glsl_parser.yy" + { (yyval.n) = ast_isampler2darray; ;} + break; + + case 226: +#line 1389 "src/glsl/glsl_parser.yy" + { (yyval.n) = ast_usampler1d; ;} + break; + + case 227: +#line 1390 "src/glsl/glsl_parser.yy" + { (yyval.n) = ast_usampler2d; ;} + break; + + case 228: +#line 1391 "src/glsl/glsl_parser.yy" + { (yyval.n) = ast_usampler3d; ;} + break; + + case 229: +#line 1392 "src/glsl/glsl_parser.yy" + { (yyval.n) = ast_usamplercube; ;} + break; + + case 230: +#line 1393 "src/glsl/glsl_parser.yy" + { (yyval.n) = ast_usampler1darray; ;} + break; + + case 231: +#line 1394 "src/glsl/glsl_parser.yy" + { (yyval.n) = ast_usampler2darray; ;} + break; + + case 232: +#line 1398 "src/glsl/glsl_parser.yy" + { + if (!state->es_shader && state->language_version < 130) + _mesa_glsl_error(& (yylsp[(1) - (1)]), state, + "precision qualifier forbidden " + "in %s (1.30 or later " + "required)\n", + state->version_string); + + (yyval.n) = ast_precision_high; + ;} + break; + + case 233: +#line 1408 "src/glsl/glsl_parser.yy" + { + if (!state->es_shader && state->language_version < 130) + _mesa_glsl_error(& (yylsp[(1) - (1)]), state, + "precision qualifier forbidden " + "in %s (1.30 or later " + "required)\n", + state->version_string); + + (yyval.n) = ast_precision_medium; + ;} + break; + + case 234: +#line 1418 "src/glsl/glsl_parser.yy" + { + if (!state->es_shader && state->language_version < 130) + _mesa_glsl_error(& (yylsp[(1) - (1)]), state, + "precision qualifier forbidden " + "in %s (1.30 or later " + "required)\n", + state->version_string); + + (yyval.n) = ast_precision_low; + ;} + break; + + case 235: +#line 1432 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + (yyval.struct_specifier) = new(ctx) ast_struct_specifier((yyvsp[(2) - (5)].identifier), (yyvsp[(4) - (5)].node)); + (yyval.struct_specifier)->set_location(yylloc); + state->symbols->add_type((yyvsp[(2) - (5)].identifier), glsl_type::void_type); + ;} + break; + + case 236: +#line 1439 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + (yyval.struct_specifier) = new(ctx) ast_struct_specifier(NULL, (yyvsp[(3) - (4)].node)); + (yyval.struct_specifier)->set_location(yylloc); + ;} + break; + + case 237: +#line 1448 "src/glsl/glsl_parser.yy" + { + (yyval.node) = (ast_node *) (yyvsp[(1) - (1)].declarator_list); + (yyvsp[(1) - (1)].declarator_list)->link.self_link(); + ;} + break; + + case 238: +#line 1453 "src/glsl/glsl_parser.yy" + { + (yyval.node) = (ast_node *) (yyvsp[(1) - (2)].node); + (yyval.node)->link.insert_before(& (yyvsp[(2) - (2)].declarator_list)->link); + ;} + break; + + case 239: +#line 1461 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + ast_fully_specified_type *type = new(ctx) ast_fully_specified_type(); + type->set_location(yylloc); + + type->specifier = (yyvsp[(1) - (3)].type_specifier); + (yyval.declarator_list) = new(ctx) ast_declarator_list(type); + (yyval.declarator_list)->set_location(yylloc); + + (yyval.declarator_list)->declarations.push_degenerate_list_at_head(& (yyvsp[(2) - (3)].declaration)->link); + ;} + break; + + case 240: +#line 1476 "src/glsl/glsl_parser.yy" + { + (yyval.declaration) = (yyvsp[(1) - (1)].declaration); + (yyvsp[(1) - (1)].declaration)->link.self_link(); + ;} + break; + + case 241: +#line 1481 "src/glsl/glsl_parser.yy" + { + (yyval.declaration) = (yyvsp[(1) - (3)].declaration); + (yyval.declaration)->link.insert_before(& (yyvsp[(3) - (3)].declaration)->link); + ;} + break; + + case 242: +#line 1489 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + (yyval.declaration) = new(ctx) ast_declaration((yyvsp[(1) - (1)].identifier), false, NULL, NULL); + (yyval.declaration)->set_location(yylloc); + state->symbols->add_variable(new(state) ir_variable(NULL, (yyvsp[(1) - (1)].identifier), ir_var_auto, glsl_precision_undefined)); + ;} + break; + + case 243: +#line 1496 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + (yyval.declaration) = new(ctx) ast_declaration((yyvsp[(1) - (4)].identifier), true, (yyvsp[(3) - (4)].expression), NULL); + (yyval.declaration)->set_location(yylloc); + ;} + break; + + case 246: +#line 1514 "src/glsl/glsl_parser.yy" + { (yyval.node) = (ast_node *) (yyvsp[(1) - (1)].compound_statement); ;} + break; + + case 251: +#line 1522 "src/glsl/glsl_parser.yy" + { (yyval.node) = NULL; ;} + break; + + case 252: +#line 1523 "src/glsl/glsl_parser.yy" + { (yyval.node) = NULL; ;} + break; + + case 255: +#line 1530 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + (yyval.compound_statement) = new(ctx) ast_compound_statement(true, NULL); + (yyval.compound_statement)->set_location(yylloc); + ;} + break; + + case 256: +#line 1536 "src/glsl/glsl_parser.yy" + { + state->symbols->push_scope(); + ;} + break; + + case 257: +#line 1540 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + (yyval.compound_statement) = new(ctx) ast_compound_statement(true, (yyvsp[(3) - (4)].node)); + (yyval.compound_statement)->set_location(yylloc); + state->symbols->pop_scope(); + ;} + break; + + case 258: +#line 1549 "src/glsl/glsl_parser.yy" + { (yyval.node) = (ast_node *) (yyvsp[(1) - (1)].compound_statement); ;} + break; + + case 260: +#line 1555 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + (yyval.compound_statement) = new(ctx) ast_compound_statement(false, NULL); + (yyval.compound_statement)->set_location(yylloc); + ;} + break; + + case 261: +#line 1561 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + (yyval.compound_statement) = new(ctx) ast_compound_statement(false, (yyvsp[(2) - (3)].node)); + (yyval.compound_statement)->set_location(yylloc); + ;} + break; + + case 262: +#line 1570 "src/glsl/glsl_parser.yy" + { + if ((yyvsp[(1) - (1)].node) == NULL) { + _mesa_glsl_error(& (yylsp[(1) - (1)]), state, " statement\n"); + assert((yyvsp[(1) - (1)].node) != NULL); + } + + (yyval.node) = (yyvsp[(1) - (1)].node); + (yyval.node)->link.self_link(); + ;} + break; + + case 263: +#line 1580 "src/glsl/glsl_parser.yy" + { + if ((yyvsp[(2) - (2)].node) == NULL) { + _mesa_glsl_error(& (yylsp[(2) - (2)]), state, " statement\n"); + assert((yyvsp[(2) - (2)].node) != NULL); + } + (yyval.node) = (yyvsp[(1) - (2)].node); + (yyval.node)->link.insert_before(& (yyvsp[(2) - (2)].node)->link); + ;} + break; + + case 264: +#line 1592 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + (yyval.node) = new(ctx) ast_expression_statement(NULL); + (yyval.node)->set_location(yylloc); + ;} + break; + + case 265: +#line 1598 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + (yyval.node) = new(ctx) ast_expression_statement((yyvsp[(1) - (2)].expression)); + (yyval.node)->set_location(yylloc); + ;} + break; + + case 266: +#line 1607 "src/glsl/glsl_parser.yy" + { + (yyval.node) = new(state) ast_selection_statement((yyvsp[(3) - (5)].expression), (yyvsp[(5) - (5)].selection_rest_statement).then_statement, + (yyvsp[(5) - (5)].selection_rest_statement).else_statement); + (yyval.node)->set_location(yylloc); + ;} + break; + + case 267: +#line 1616 "src/glsl/glsl_parser.yy" + { + (yyval.selection_rest_statement).then_statement = (yyvsp[(1) - (3)].node); + (yyval.selection_rest_statement).else_statement = (yyvsp[(3) - (3)].node); + ;} + break; + + case 268: +#line 1621 "src/glsl/glsl_parser.yy" + { + (yyval.selection_rest_statement).then_statement = (yyvsp[(1) - (1)].node); + (yyval.selection_rest_statement).else_statement = NULL; + ;} + break; + + case 269: +#line 1629 "src/glsl/glsl_parser.yy" + { + (yyval.node) = (ast_node *) (yyvsp[(1) - (1)].expression); + ;} + break; + + case 270: +#line 1633 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (4)].identifier), false, NULL, (yyvsp[(4) - (4)].expression)); + ast_declarator_list *declarator = new(ctx) ast_declarator_list((yyvsp[(1) - (4)].fully_specified_type)); + decl->set_location(yylloc); + declarator->set_location(yylloc); + + declarator->declarations.push_tail(&decl->link); + (yyval.node) = declarator; + ;} + break; + + case 274: +#line 1656 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + (yyval.node) = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_while, + NULL, (yyvsp[(3) - (5)].node), NULL, (yyvsp[(5) - (5)].node)); + (yyval.node)->set_location(yylloc); + ;} + break; + + case 275: +#line 1663 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + (yyval.node) = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_do_while, + NULL, (yyvsp[(5) - (7)].expression), NULL, (yyvsp[(2) - (7)].node)); + (yyval.node)->set_location(yylloc); + ;} + break; + + case 276: +#line 1670 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + (yyval.node) = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_for, + (yyvsp[(3) - (6)].node), (yyvsp[(4) - (6)].for_rest_statement).cond, (yyvsp[(4) - (6)].for_rest_statement).rest, (yyvsp[(6) - (6)].node)); + (yyval.node)->set_location(yylloc); + ;} + break; + + case 280: +#line 1686 "src/glsl/glsl_parser.yy" + { + (yyval.node) = NULL; + ;} + break; + + case 281: +#line 1693 "src/glsl/glsl_parser.yy" + { + (yyval.for_rest_statement).cond = (yyvsp[(1) - (2)].node); + (yyval.for_rest_statement).rest = NULL; + ;} + break; + + case 282: +#line 1698 "src/glsl/glsl_parser.yy" + { + (yyval.for_rest_statement).cond = (yyvsp[(1) - (3)].node); + (yyval.for_rest_statement).rest = (yyvsp[(3) - (3)].expression); + ;} + break; + + case 283: +#line 1707 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + (yyval.node) = new(ctx) ast_jump_statement(ast_jump_statement::ast_continue, NULL); + (yyval.node)->set_location(yylloc); + ;} + break; + + case 284: +#line 1713 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + (yyval.node) = new(ctx) ast_jump_statement(ast_jump_statement::ast_break, NULL); + (yyval.node)->set_location(yylloc); + ;} + break; + + case 285: +#line 1719 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + (yyval.node) = new(ctx) ast_jump_statement(ast_jump_statement::ast_return, NULL); + (yyval.node)->set_location(yylloc); + ;} + break; + + case 286: +#line 1725 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + (yyval.node) = new(ctx) ast_jump_statement(ast_jump_statement::ast_return, (yyvsp[(2) - (3)].expression)); + (yyval.node)->set_location(yylloc); + ;} + break; + + case 287: +#line 1731 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + (yyval.node) = new(ctx) ast_jump_statement(ast_jump_statement::ast_discard, NULL); + (yyval.node)->set_location(yylloc); + ;} + break; + + case 288: +#line 1739 "src/glsl/glsl_parser.yy" + { (yyval.node) = (yyvsp[(1) - (1)].function_definition); ;} + break; + + case 289: +#line 1740 "src/glsl/glsl_parser.yy" + { (yyval.node) = (yyvsp[(1) - (1)].node); ;} + break; + + case 290: +#line 1741 "src/glsl/glsl_parser.yy" + { (yyval.node) = NULL; ;} + break; + + case 291: +#line 1746 "src/glsl/glsl_parser.yy" + { + void *ctx = state; + (yyval.function_definition) = new(ctx) ast_function_definition(); + (yyval.function_definition)->set_location(yylloc); + (yyval.function_definition)->prototype = (yyvsp[(1) - (2)].function); + (yyval.function_definition)->body = (yyvsp[(2) - (2)].compound_statement); + + state->symbols->pop_scope(); + ;} + break; + + +/* Line 1267 of yacc.c. */ +#line 4948 "src/glsl/glsl_parser.cpp" + default: break; + } + YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + + *++yyvsp = yyval; + *++yylsp = yyloc; + + /* Now `shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTOKENS]; + + goto yynewstate; + + +/*------------------------------------. +| yyerrlab -- here on detecting error | +`------------------------------------*/ +yyerrlab: + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) + { + ++yynerrs; +#if ! YYERROR_VERBOSE + yyerror (&yylloc, state, YY_("syntax error")); +#else + { + YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); + if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) + { + YYSIZE_T yyalloc = 2 * yysize; + if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) + yyalloc = YYSTACK_ALLOC_MAXIMUM; + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yyalloc); + if (yymsg) + yymsg_alloc = yyalloc; + else + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + } + } + + if (0 < yysize && yysize <= yymsg_alloc) + { + (void) yysyntax_error (yymsg, yystate, yychar); + yyerror (&yylloc, state, yymsg); + } + else + { + yyerror (&yylloc, state, YY_("syntax error")); + if (yysize != 0) + goto yyexhaustedlab; + } + } +#endif + } + + yyerror_range[0] = yylloc; + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse look-ahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } + else + { + yydestruct ("Error: discarding", + yytoken, &yylval, &yylloc, state); + yychar = YYEMPTY; + } + } + + /* Else will try to reuse look-ahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (/*CONSTCOND*/ 0) + goto yyerrorlab; + + yyerror_range[0] = yylsp[1-yylen]; + /* Do not reclaim the symbols of the rule which action triggered + this YYERROR. */ + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + yystate = *yyssp; + goto yyerrlab1; + + +/*-------------------------------------------------------------. +| yyerrlab1 -- common code for both syntax error and YYERROR. | +`-------------------------------------------------------------*/ +yyerrlab1: + yyerrstatus = 3; /* Each real token shifted decrements this. */ + + for (;;) + { + yyn = yypact[yystate]; + if (yyn != YYPACT_NINF) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) + YYABORT; + + yyerror_range[0] = *yylsp; + yydestruct ("Error: popping", + yystos[yystate], yyvsp, yylsp, state); + YYPOPSTACK (1); + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + if (yyn == YYFINAL) + YYACCEPT; + + *++yyvsp = yylval; + + yyerror_range[1] = yylloc; + /* Using YYLLOC is tempting, but would change the location of + the look-ahead. YYLOC is available though. */ + YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2); + *++yylsp = yyloc; + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#ifndef yyoverflow +/*-------------------------------------------------. +| yyexhaustedlab -- memory exhaustion comes here. | +`-------------------------------------------------*/ +yyexhaustedlab: + yyerror (&yylloc, state, YY_("memory exhausted")); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: + if (yychar != YYEOF && yychar != YYEMPTY) + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval, &yylloc, state); + /* Do not reclaim the symbols of the rule which action triggered + this YYABORT or YYACCEPT. */ + YYPOPSTACK (yylen); + YY_STACK_PRINT (yyss, yyssp); + while (yyssp != yyss) + { + yydestruct ("Cleanup: popping", + yystos[*yyssp], yyvsp, yylsp, state); + YYPOPSTACK (1); + } +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif +#if YYERROR_VERBOSE + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); +#endif + /* Make sure YYID is used. */ + return YYID (yyresult); +} + + + diff --git a/3rdparty/glsl-optimizer/src/glsl/glsl_parser.h b/3rdparty/glsl-optimizer/src/glsl/glsl_parser.h new file mode 100644 index 000000000..c30dd5f87 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/glsl_parser.h @@ -0,0 +1,490 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton interface for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + ATTRIBUTE = 258, + CONST_TOK = 259, + BOOL_TOK = 260, + FLOAT_TOK = 261, + INT_TOK = 262, + UINT_TOK = 263, + BREAK = 264, + CONTINUE = 265, + DO = 266, + ELSE = 267, + FOR = 268, + IF = 269, + DISCARD = 270, + RETURN = 271, + SWITCH = 272, + CASE = 273, + DEFAULT = 274, + BVEC2 = 275, + BVEC3 = 276, + BVEC4 = 277, + IVEC2 = 278, + IVEC3 = 279, + IVEC4 = 280, + UVEC2 = 281, + UVEC3 = 282, + UVEC4 = 283, + VEC2 = 284, + VEC3 = 285, + VEC4 = 286, + CENTROID = 287, + IN_TOK = 288, + OUT_TOK = 289, + INOUT_TOK = 290, + UNIFORM = 291, + VARYING = 292, + NOPERSPECTIVE = 293, + FLAT = 294, + SMOOTH = 295, + MAT2X2 = 296, + MAT2X3 = 297, + MAT2X4 = 298, + MAT3X2 = 299, + MAT3X3 = 300, + MAT3X4 = 301, + MAT4X2 = 302, + MAT4X3 = 303, + MAT4X4 = 304, + SAMPLER1D = 305, + SAMPLER2D = 306, + SAMPLER3D = 307, + SAMPLERCUBE = 308, + SAMPLER1DSHADOW = 309, + SAMPLER2DSHADOW = 310, + SAMPLERCUBESHADOW = 311, + SAMPLER1DARRAY = 312, + SAMPLER2DARRAY = 313, + SAMPLER1DARRAYSHADOW = 314, + SAMPLER2DARRAYSHADOW = 315, + ISAMPLER1D = 316, + ISAMPLER2D = 317, + ISAMPLER3D = 318, + ISAMPLERCUBE = 319, + ISAMPLER1DARRAY = 320, + ISAMPLER2DARRAY = 321, + USAMPLER1D = 322, + USAMPLER2D = 323, + USAMPLER3D = 324, + USAMPLERCUBE = 325, + USAMPLER1DARRAY = 326, + USAMPLER2DARRAY = 327, + STRUCT = 328, + VOID_TOK = 329, + WHILE = 330, + IDENTIFIER = 331, + TYPE_IDENTIFIER = 332, + NEW_IDENTIFIER = 333, + FLOATCONSTANT = 334, + INTCONSTANT = 335, + UINTCONSTANT = 336, + BOOLCONSTANT = 337, + FIELD_SELECTION = 338, + LEFT_OP = 339, + RIGHT_OP = 340, + INC_OP = 341, + DEC_OP = 342, + LE_OP = 343, + GE_OP = 344, + EQ_OP = 345, + NE_OP = 346, + AND_OP = 347, + OR_OP = 348, + XOR_OP = 349, + MUL_ASSIGN = 350, + DIV_ASSIGN = 351, + ADD_ASSIGN = 352, + MOD_ASSIGN = 353, + LEFT_ASSIGN = 354, + RIGHT_ASSIGN = 355, + AND_ASSIGN = 356, + XOR_ASSIGN = 357, + OR_ASSIGN = 358, + SUB_ASSIGN = 359, + INVARIANT = 360, + LOWP = 361, + MEDIUMP = 362, + HIGHP = 363, + SUPERP = 364, + PRECISION = 365, + VERSION = 366, + EXTENSION = 367, + LINE = 368, + COLON = 369, + EOL = 370, + INTERFACE = 371, + OUTPUT = 372, + PRAGMA_DEBUG_ON = 373, + PRAGMA_DEBUG_OFF = 374, + PRAGMA_OPTIMIZE_ON = 375, + PRAGMA_OPTIMIZE_OFF = 376, + PRAGMA_INVARIANT_ALL = 377, + LAYOUT_TOK = 378, + ASM = 379, + CLASS = 380, + UNION = 381, + ENUM = 382, + TYPEDEF = 383, + TEMPLATE = 384, + THIS = 385, + PACKED_TOK = 386, + GOTO = 387, + INLINE_TOK = 388, + NOINLINE = 389, + VOLATILE = 390, + PUBLIC_TOK = 391, + STATIC = 392, + EXTERN = 393, + EXTERNAL = 394, + LONG_TOK = 395, + SHORT_TOK = 396, + DOUBLE_TOK = 397, + HALF = 398, + FIXED_TOK = 399, + UNSIGNED = 400, + INPUT_TOK = 401, + OUPTUT = 402, + HVEC2 = 403, + HVEC3 = 404, + HVEC4 = 405, + DVEC2 = 406, + DVEC3 = 407, + DVEC4 = 408, + FVEC2 = 409, + FVEC3 = 410, + FVEC4 = 411, + SAMPLER2DRECT = 412, + SAMPLER3DRECT = 413, + SAMPLER2DRECTSHADOW = 414, + SIZEOF = 415, + CAST = 416, + NAMESPACE = 417, + USING = 418, + ERROR_TOK = 419, + COMMON = 420, + PARTITION = 421, + ACTIVE = 422, + SAMPLERBUFFER = 423, + FILTER = 424, + IMAGE1D = 425, + IMAGE2D = 426, + IMAGE3D = 427, + IMAGECUBE = 428, + IMAGE1DARRAY = 429, + IMAGE2DARRAY = 430, + IIMAGE1D = 431, + IIMAGE2D = 432, + IIMAGE3D = 433, + IIMAGECUBE = 434, + IIMAGE1DARRAY = 435, + IIMAGE2DARRAY = 436, + UIMAGE1D = 437, + UIMAGE2D = 438, + UIMAGE3D = 439, + UIMAGECUBE = 440, + UIMAGE1DARRAY = 441, + UIMAGE2DARRAY = 442, + IMAGE1DSHADOW = 443, + IMAGE2DSHADOW = 444, + IMAGEBUFFER = 445, + IIMAGEBUFFER = 446, + UIMAGEBUFFER = 447, + IMAGE1DARRAYSHADOW = 448, + IMAGE2DARRAYSHADOW = 449, + ROW_MAJOR = 450 + }; +#endif +/* Tokens. */ +#define ATTRIBUTE 258 +#define CONST_TOK 259 +#define BOOL_TOK 260 +#define FLOAT_TOK 261 +#define INT_TOK 262 +#define UINT_TOK 263 +#define BREAK 264 +#define CONTINUE 265 +#define DO 266 +#define ELSE 267 +#define FOR 268 +#define IF 269 +#define DISCARD 270 +#define RETURN 271 +#define SWITCH 272 +#define CASE 273 +#define DEFAULT 274 +#define BVEC2 275 +#define BVEC3 276 +#define BVEC4 277 +#define IVEC2 278 +#define IVEC3 279 +#define IVEC4 280 +#define UVEC2 281 +#define UVEC3 282 +#define UVEC4 283 +#define VEC2 284 +#define VEC3 285 +#define VEC4 286 +#define CENTROID 287 +#define IN_TOK 288 +#define OUT_TOK 289 +#define INOUT_TOK 290 +#define UNIFORM 291 +#define VARYING 292 +#define NOPERSPECTIVE 293 +#define FLAT 294 +#define SMOOTH 295 +#define MAT2X2 296 +#define MAT2X3 297 +#define MAT2X4 298 +#define MAT3X2 299 +#define MAT3X3 300 +#define MAT3X4 301 +#define MAT4X2 302 +#define MAT4X3 303 +#define MAT4X4 304 +#define SAMPLER1D 305 +#define SAMPLER2D 306 +#define SAMPLER3D 307 +#define SAMPLERCUBE 308 +#define SAMPLER1DSHADOW 309 +#define SAMPLER2DSHADOW 310 +#define SAMPLERCUBESHADOW 311 +#define SAMPLER1DARRAY 312 +#define SAMPLER2DARRAY 313 +#define SAMPLER1DARRAYSHADOW 314 +#define SAMPLER2DARRAYSHADOW 315 +#define ISAMPLER1D 316 +#define ISAMPLER2D 317 +#define ISAMPLER3D 318 +#define ISAMPLERCUBE 319 +#define ISAMPLER1DARRAY 320 +#define ISAMPLER2DARRAY 321 +#define USAMPLER1D 322 +#define USAMPLER2D 323 +#define USAMPLER3D 324 +#define USAMPLERCUBE 325 +#define USAMPLER1DARRAY 326 +#define USAMPLER2DARRAY 327 +#define STRUCT 328 +#define VOID_TOK 329 +#define WHILE 330 +#define IDENTIFIER 331 +#define TYPE_IDENTIFIER 332 +#define NEW_IDENTIFIER 333 +#define FLOATCONSTANT 334 +#define INTCONSTANT 335 +#define UINTCONSTANT 336 +#define BOOLCONSTANT 337 +#define FIELD_SELECTION 338 +#define LEFT_OP 339 +#define RIGHT_OP 340 +#define INC_OP 341 +#define DEC_OP 342 +#define LE_OP 343 +#define GE_OP 344 +#define EQ_OP 345 +#define NE_OP 346 +#define AND_OP 347 +#define OR_OP 348 +#define XOR_OP 349 +#define MUL_ASSIGN 350 +#define DIV_ASSIGN 351 +#define ADD_ASSIGN 352 +#define MOD_ASSIGN 353 +#define LEFT_ASSIGN 354 +#define RIGHT_ASSIGN 355 +#define AND_ASSIGN 356 +#define XOR_ASSIGN 357 +#define OR_ASSIGN 358 +#define SUB_ASSIGN 359 +#define INVARIANT 360 +#define LOWP 361 +#define MEDIUMP 362 +#define HIGHP 363 +#define SUPERP 364 +#define PRECISION 365 +#define VERSION 366 +#define EXTENSION 367 +#define LINE 368 +#define COLON 369 +#define EOL 370 +#define INTERFACE 371 +#define OUTPUT 372 +#define PRAGMA_DEBUG_ON 373 +#define PRAGMA_DEBUG_OFF 374 +#define PRAGMA_OPTIMIZE_ON 375 +#define PRAGMA_OPTIMIZE_OFF 376 +#define PRAGMA_INVARIANT_ALL 377 +#define LAYOUT_TOK 378 +#define ASM 379 +#define CLASS 380 +#define UNION 381 +#define ENUM 382 +#define TYPEDEF 383 +#define TEMPLATE 384 +#define THIS 385 +#define PACKED_TOK 386 +#define GOTO 387 +#define INLINE_TOK 388 +#define NOINLINE 389 +#define VOLATILE 390 +#define PUBLIC_TOK 391 +#define STATIC 392 +#define EXTERN 393 +#define EXTERNAL 394 +#define LONG_TOK 395 +#define SHORT_TOK 396 +#define DOUBLE_TOK 397 +#define HALF 398 +#define FIXED_TOK 399 +#define UNSIGNED 400 +#define INPUT_TOK 401 +#define OUPTUT 402 +#define HVEC2 403 +#define HVEC3 404 +#define HVEC4 405 +#define DVEC2 406 +#define DVEC3 407 +#define DVEC4 408 +#define FVEC2 409 +#define FVEC3 410 +#define FVEC4 411 +#define SAMPLER2DRECT 412 +#define SAMPLER3DRECT 413 +#define SAMPLER2DRECTSHADOW 414 +#define SIZEOF 415 +#define CAST 416 +#define NAMESPACE 417 +#define USING 418 +#define ERROR_TOK 419 +#define COMMON 420 +#define PARTITION 421 +#define ACTIVE 422 +#define SAMPLERBUFFER 423 +#define FILTER 424 +#define IMAGE1D 425 +#define IMAGE2D 426 +#define IMAGE3D 427 +#define IMAGECUBE 428 +#define IMAGE1DARRAY 429 +#define IMAGE2DARRAY 430 +#define IIMAGE1D 431 +#define IIMAGE2D 432 +#define IIMAGE3D 433 +#define IIMAGECUBE 434 +#define IIMAGE1DARRAY 435 +#define IIMAGE2DARRAY 436 +#define UIMAGE1D 437 +#define UIMAGE2D 438 +#define UIMAGE3D 439 +#define UIMAGECUBE 440 +#define UIMAGE1DARRAY 441 +#define UIMAGE2DARRAY 442 +#define IMAGE1DSHADOW 443 +#define IMAGE2DSHADOW 444 +#define IMAGEBUFFER 445 +#define IIMAGEBUFFER 446 +#define UIMAGEBUFFER 447 +#define IMAGE1DARRAYSHADOW 448 +#define IMAGE2DARRAYSHADOW 449 +#define ROW_MAJOR 450 + + + + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 52 "src/glsl/glsl_parser.yy" +{ + int n; + float real; + char *identifier; + + struct ast_type_qualifier type_qualifier; + + ast_node *node; + ast_type_specifier *type_specifier; + ast_fully_specified_type *fully_specified_type; + ast_function *function; + ast_parameter_declarator *parameter_declarator; + ast_function_definition *function_definition; + ast_compound_statement *compound_statement; + ast_expression *expression; + ast_declarator_list *declarator_list; + ast_struct_specifier *struct_specifier; + ast_declaration *declaration; + + struct { + ast_node *cond; + ast_expression *rest; + } for_rest_statement; + + struct { + ast_node *then_statement; + ast_node *else_statement; + } selection_rest_statement; +} +/* Line 1529 of yacc.c. */ +#line 469 "src/glsl/glsl_parser.h" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + +#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED +typedef struct YYLTYPE +{ + int first_line; + int first_column; + int last_line; + int last_column; +} YYLTYPE; +# define yyltype YYLTYPE /* obsolescent; will be withdrawn */ +# define YYLTYPE_IS_DECLARED 1 +# define YYLTYPE_IS_TRIVIAL 1 +#endif + + diff --git a/3rdparty/glsl-optimizer/src/glsl/glsl_parser.yy b/3rdparty/glsl-optimizer/src/glsl/glsl_parser.yy new file mode 100644 index 000000000..69222a1d0 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/glsl_parser.yy @@ -0,0 +1,1751 @@ +%{ +/* + * Copyright © 2008, 2009 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +#include +#include +#include +#include + +#include "ast.h" +#include "glsl_parser_extras.h" +#include "glsl_types.h" + +#define YYLEX_PARAM state->scanner + +%} + +%pure-parser +%error-verbose + +%locations +%initial-action { + @$.first_line = 1; + @$.first_column = 1; + @$.last_line = 1; + @$.last_column = 1; + @$.source = 0; +} + +%lex-param {void *scanner} +%parse-param {struct _mesa_glsl_parse_state *state} + +%union { + int n; + float real; + char *identifier; + + struct ast_type_qualifier type_qualifier; + + ast_node *node; + ast_type_specifier *type_specifier; + ast_fully_specified_type *fully_specified_type; + ast_function *function; + ast_parameter_declarator *parameter_declarator; + ast_function_definition *function_definition; + ast_compound_statement *compound_statement; + ast_expression *expression; + ast_declarator_list *declarator_list; + ast_struct_specifier *struct_specifier; + ast_declaration *declaration; + + struct { + ast_node *cond; + ast_expression *rest; + } for_rest_statement; + + struct { + ast_node *then_statement; + ast_node *else_statement; + } selection_rest_statement; +} + +%token ATTRIBUTE CONST_TOK BOOL_TOK FLOAT_TOK INT_TOK UINT_TOK +%token BREAK CONTINUE DO ELSE FOR IF DISCARD RETURN SWITCH CASE DEFAULT +%token BVEC2 BVEC3 BVEC4 IVEC2 IVEC3 IVEC4 UVEC2 UVEC3 UVEC4 VEC2 VEC3 VEC4 +%token CENTROID IN_TOK OUT_TOK INOUT_TOK UNIFORM VARYING +%token NOPERSPECTIVE FLAT SMOOTH +%token MAT2X2 MAT2X3 MAT2X4 +%token MAT3X2 MAT3X3 MAT3X4 +%token MAT4X2 MAT4X3 MAT4X4 +%token SAMPLER1D SAMPLER2D SAMPLER3D SAMPLERCUBE SAMPLER1DSHADOW SAMPLER2DSHADOW +%token SAMPLERCUBESHADOW SAMPLER1DARRAY SAMPLER2DARRAY SAMPLER1DARRAYSHADOW +%token SAMPLER2DARRAYSHADOW ISAMPLER1D ISAMPLER2D ISAMPLER3D ISAMPLERCUBE +%token ISAMPLER1DARRAY ISAMPLER2DARRAY USAMPLER1D USAMPLER2D USAMPLER3D +%token USAMPLERCUBE USAMPLER1DARRAY USAMPLER2DARRAY +%token STRUCT VOID_TOK WHILE +%token IDENTIFIER TYPE_IDENTIFIER NEW_IDENTIFIER +%type any_identifier +%token FLOATCONSTANT +%token INTCONSTANT UINTCONSTANT BOOLCONSTANT +%token FIELD_SELECTION +%token LEFT_OP RIGHT_OP +%token INC_OP DEC_OP LE_OP GE_OP EQ_OP NE_OP +%token AND_OP OR_OP XOR_OP MUL_ASSIGN DIV_ASSIGN ADD_ASSIGN +%token MOD_ASSIGN LEFT_ASSIGN RIGHT_ASSIGN AND_ASSIGN XOR_ASSIGN OR_ASSIGN +%token SUB_ASSIGN +%token INVARIANT +%token LOWP MEDIUMP HIGHP SUPERP PRECISION + +%token VERSION EXTENSION LINE COLON EOL INTERFACE OUTPUT +%token PRAGMA_DEBUG_ON PRAGMA_DEBUG_OFF +%token PRAGMA_OPTIMIZE_ON PRAGMA_OPTIMIZE_OFF +%token PRAGMA_INVARIANT_ALL +%token LAYOUT_TOK + + /* Reserved words that are not actually used in the grammar. + */ +%token ASM CLASS UNION ENUM TYPEDEF TEMPLATE THIS PACKED_TOK GOTO +%token INLINE_TOK NOINLINE VOLATILE PUBLIC_TOK STATIC EXTERN EXTERNAL +%token LONG_TOK SHORT_TOK DOUBLE_TOK HALF FIXED_TOK UNSIGNED INPUT_TOK OUPTUT +%token HVEC2 HVEC3 HVEC4 DVEC2 DVEC3 DVEC4 FVEC2 FVEC3 FVEC4 +%token SAMPLER2DRECT SAMPLER3DRECT SAMPLER2DRECTSHADOW +%token SIZEOF CAST NAMESPACE USING + +%token ERROR_TOK + +%token COMMON PARTITION ACTIVE SAMPLERBUFFER FILTER +%token IMAGE1D IMAGE2D IMAGE3D IMAGECUBE IMAGE1DARRAY IMAGE2DARRAY +%token IIMAGE1D IIMAGE2D IIMAGE3D IIMAGECUBE IIMAGE1DARRAY IIMAGE2DARRAY +%token UIMAGE1D UIMAGE2D UIMAGE3D UIMAGECUBE UIMAGE1DARRAY UIMAGE2DARRAY +%token IMAGE1DSHADOW IMAGE2DSHADOW IMAGEBUFFER IIMAGEBUFFER UIMAGEBUFFER +%token IMAGE1DARRAYSHADOW IMAGE2DARRAYSHADOW +%token ROW_MAJOR + +%type variable_identifier +%type statement +%type statement_list +%type simple_statement +%type precision_qualifier +%type type_qualifier +%type storage_qualifier +%type interpolation_qualifier +%type layout_qualifier +%type layout_qualifier_id_list layout_qualifier_id +%type type_specifier +%type type_specifier_no_prec +%type type_specifier_nonarray +%type basic_type_specifier_nonarray +%type fully_specified_type +%type function_prototype +%type function_header +%type function_header_with_parameters +%type function_declarator +%type parameter_declarator +%type parameter_declaration +%type parameter_qualifier +%type parameter_type_qualifier +%type parameter_type_specifier +%type function_definition +%type compound_statement_no_new_scope +%type compound_statement +%type statement_no_new_scope +%type expression_statement +%type expression +%type primary_expression +%type assignment_expression +%type conditional_expression +%type logical_or_expression +%type logical_xor_expression +%type logical_and_expression +%type inclusive_or_expression +%type exclusive_or_expression +%type and_expression +%type equality_expression +%type relational_expression +%type shift_expression +%type additive_expression +%type multiplicative_expression +%type unary_expression +%type constant_expression +%type integer_expression +%type postfix_expression +%type function_call_header_with_parameters +%type function_call_header_no_parameters +%type function_call_header +%type function_call_generic +%type function_call_or_method +%type function_call +%type method_call_generic +%type method_call_header_with_parameters +%type method_call_header_no_parameters +%type method_call_header +%type assignment_operator +%type unary_operator +%type function_identifier +%type external_declaration +%type init_declarator_list +%type single_declaration +%type initializer +%type declaration +%type declaration_statement +%type jump_statement +%type struct_specifier +%type struct_declaration_list +%type struct_declaration +%type struct_declarator +%type struct_declarator_list +%type selection_statement +%type selection_rest_statement +%type iteration_statement +%type condition +%type conditionopt +%type for_init_statement +%type for_rest_statement +%% + +translation_unit: + version_statement extension_statement_list + { + _mesa_glsl_initialize_types(state); + } + external_declaration_list + { + delete state->symbols; + state->symbols = new(ralloc_parent(state)) glsl_symbol_table; + _mesa_glsl_initialize_types(state); + } + ; + +version_statement: + /* blank - no #version specified: defaults are already set */ + | VERSION INTCONSTANT EOL + { + bool supported = false; + + switch ($2) { + case 100: + state->es_shader = true; + supported = state->Const.GLSL_100ES; + break; + case 110: + supported = state->Const.GLSL_110; + break; + case 120: + supported = state->Const.GLSL_120; + break; + case 130: + supported = state->Const.GLSL_130; + break; + default: + supported = false; + break; + } + + state->language_version = $2; + state->version_string = + ralloc_asprintf(state, "GLSL%s %d.%02d", + state->es_shader ? " ES" : "", + state->language_version / 100, + state->language_version % 100); + + if (!supported) { + _mesa_glsl_error(& @2, state, "%s is not supported. " + "Supported versions are: %s\n", + state->version_string, + state->supported_version_string); + } + } + ; + +pragma_statement: + PRAGMA_DEBUG_ON EOL + | PRAGMA_DEBUG_OFF EOL + | PRAGMA_OPTIMIZE_ON EOL + | PRAGMA_OPTIMIZE_OFF EOL + | PRAGMA_INVARIANT_ALL EOL + { + if (state->language_version < 120) { + _mesa_glsl_warning(& @1, state, + "pragma `invariant(all)' not supported in %s", + state->version_string); + } else { + state->all_invariant = true; + } + } + ; + +extension_statement_list: + + | extension_statement_list extension_statement + ; + +any_identifier: + IDENTIFIER + | TYPE_IDENTIFIER + | NEW_IDENTIFIER + ; + +extension_statement: + EXTENSION any_identifier COLON any_identifier EOL + { + if (!_mesa_glsl_process_extension($2, & @2, $4, & @4, state)) { + YYERROR; + } + } + ; + +external_declaration_list: + external_declaration + { + /* FINISHME: The NULL test is required because pragmas are set to + * FINISHME: NULL. (See production rule for external_declaration.) + */ + if ($1 != NULL) + state->translation_unit.push_tail(& $1->link); + } + | external_declaration_list external_declaration + { + /* FINISHME: The NULL test is required because pragmas are set to + * FINISHME: NULL. (See production rule for external_declaration.) + */ + if ($2 != NULL) + state->translation_unit.push_tail(& $2->link); + } + ; + +variable_identifier: + IDENTIFIER + | NEW_IDENTIFIER + ; + +primary_expression: + variable_identifier + { + void *ctx = state; + $$ = new(ctx) ast_expression(ast_identifier, NULL, NULL, NULL); + $$->set_location(yylloc); + $$->primary_expression.identifier = $1; + } + | INTCONSTANT + { + void *ctx = state; + $$ = new(ctx) ast_expression(ast_int_constant, NULL, NULL, NULL); + $$->set_location(yylloc); + $$->primary_expression.int_constant = $1; + } + | UINTCONSTANT + { + void *ctx = state; + $$ = new(ctx) ast_expression(ast_uint_constant, NULL, NULL, NULL); + $$->set_location(yylloc); + $$->primary_expression.uint_constant = $1; + } + | FLOATCONSTANT + { + void *ctx = state; + $$ = new(ctx) ast_expression(ast_float_constant, NULL, NULL, NULL); + $$->set_location(yylloc); + $$->primary_expression.float_constant = $1; + } + | BOOLCONSTANT + { + void *ctx = state; + $$ = new(ctx) ast_expression(ast_bool_constant, NULL, NULL, NULL); + $$->set_location(yylloc); + $$->primary_expression.bool_constant = $1; + } + | '(' expression ')' + { + $$ = $2; + } + ; + +postfix_expression: + primary_expression + | postfix_expression '[' integer_expression ']' + { + void *ctx = state; + $$ = new(ctx) ast_expression(ast_array_index, $1, $3, NULL); + $$->set_location(yylloc); + } + | function_call + { + $$ = $1; + } + | postfix_expression '.' any_identifier + { + void *ctx = state; + $$ = new(ctx) ast_expression(ast_field_selection, $1, NULL, NULL); + $$->set_location(yylloc); + $$->primary_expression.identifier = $3; + } + | postfix_expression INC_OP + { + void *ctx = state; + $$ = new(ctx) ast_expression(ast_post_inc, $1, NULL, NULL); + $$->set_location(yylloc); + } + | postfix_expression DEC_OP + { + void *ctx = state; + $$ = new(ctx) ast_expression(ast_post_dec, $1, NULL, NULL); + $$->set_location(yylloc); + } + ; + +integer_expression: + expression + ; + +function_call: + function_call_or_method + ; + +function_call_or_method: + function_call_generic + | postfix_expression '.' method_call_generic + { + void *ctx = state; + $$ = new(ctx) ast_expression(ast_field_selection, $1, $3, NULL); + $$->set_location(yylloc); + } + ; + +function_call_generic: + function_call_header_with_parameters ')' + | function_call_header_no_parameters ')' + ; + +function_call_header_no_parameters: + function_call_header VOID_TOK + | function_call_header + ; + +function_call_header_with_parameters: + function_call_header assignment_expression + { + $$ = $1; + $$->set_location(yylloc); + $$->expressions.push_tail(& $2->link); + } + | function_call_header_with_parameters ',' assignment_expression + { + $$ = $1; + $$->set_location(yylloc); + $$->expressions.push_tail(& $3->link); + } + ; + + // Grammar Note: Constructors look like functions, but lexical + // analysis recognized most of them as keywords. They are now + // recognized through "type_specifier". +function_call_header: + function_identifier '(' + ; + +function_identifier: + type_specifier + { + void *ctx = state; + $$ = new(ctx) ast_function_expression($1); + $$->set_location(yylloc); + } + | variable_identifier + { + void *ctx = state; + ast_expression *callee = new(ctx) ast_expression($1); + $$ = new(ctx) ast_function_expression(callee); + $$->set_location(yylloc); + } + | FIELD_SELECTION + { + void *ctx = state; + ast_expression *callee = new(ctx) ast_expression($1); + $$ = new(ctx) ast_function_expression(callee); + $$->set_location(yylloc); + } + ; + +method_call_generic: + method_call_header_with_parameters ')' + | method_call_header_no_parameters ')' + ; + +method_call_header_no_parameters: + method_call_header VOID_TOK + | method_call_header + ; + +method_call_header_with_parameters: + method_call_header assignment_expression + { + $$ = $1; + $$->set_location(yylloc); + $$->expressions.push_tail(& $2->link); + } + | method_call_header_with_parameters ',' assignment_expression + { + $$ = $1; + $$->set_location(yylloc); + $$->expressions.push_tail(& $3->link); + } + ; + + // Grammar Note: Constructors look like methods, but lexical + // analysis recognized most of them as keywords. They are now + // recognized through "type_specifier". +method_call_header: + variable_identifier '(' + { + void *ctx = state; + ast_expression *callee = new(ctx) ast_expression($1); + $$ = new(ctx) ast_function_expression(callee); + $$->set_location(yylloc); + } + ; + + // Grammar Note: No traditional style type casts. +unary_expression: + postfix_expression + | INC_OP unary_expression + { + void *ctx = state; + $$ = new(ctx) ast_expression(ast_pre_inc, $2, NULL, NULL); + $$->set_location(yylloc); + } + | DEC_OP unary_expression + { + void *ctx = state; + $$ = new(ctx) ast_expression(ast_pre_dec, $2, NULL, NULL); + $$->set_location(yylloc); + } + | unary_operator unary_expression + { + void *ctx = state; + $$ = new(ctx) ast_expression($1, $2, NULL, NULL); + $$->set_location(yylloc); + } + ; + + // Grammar Note: No '*' or '&' unary ops. Pointers are not supported. +unary_operator: + '+' { $$ = ast_plus; } + | '-' { $$ = ast_neg; } + | '!' { $$ = ast_logic_not; } + | '~' { $$ = ast_bit_not; } + ; + +multiplicative_expression: + unary_expression + | multiplicative_expression '*' unary_expression + { + void *ctx = state; + $$ = new(ctx) ast_expression_bin(ast_mul, $1, $3); + $$->set_location(yylloc); + } + | multiplicative_expression '/' unary_expression + { + void *ctx = state; + $$ = new(ctx) ast_expression_bin(ast_div, $1, $3); + $$->set_location(yylloc); + } + | multiplicative_expression '%' unary_expression + { + void *ctx = state; + $$ = new(ctx) ast_expression_bin(ast_mod, $1, $3); + $$->set_location(yylloc); + } + ; + +additive_expression: + multiplicative_expression + | additive_expression '+' multiplicative_expression + { + void *ctx = state; + $$ = new(ctx) ast_expression_bin(ast_add, $1, $3); + $$->set_location(yylloc); + } + | additive_expression '-' multiplicative_expression + { + void *ctx = state; + $$ = new(ctx) ast_expression_bin(ast_sub, $1, $3); + $$->set_location(yylloc); + } + ; + +shift_expression: + additive_expression + | shift_expression LEFT_OP additive_expression + { + void *ctx = state; + $$ = new(ctx) ast_expression_bin(ast_lshift, $1, $3); + $$->set_location(yylloc); + } + | shift_expression RIGHT_OP additive_expression + { + void *ctx = state; + $$ = new(ctx) ast_expression_bin(ast_rshift, $1, $3); + $$->set_location(yylloc); + } + ; + +relational_expression: + shift_expression + | relational_expression '<' shift_expression + { + void *ctx = state; + $$ = new(ctx) ast_expression_bin(ast_less, $1, $3); + $$->set_location(yylloc); + } + | relational_expression '>' shift_expression + { + void *ctx = state; + $$ = new(ctx) ast_expression_bin(ast_greater, $1, $3); + $$->set_location(yylloc); + } + | relational_expression LE_OP shift_expression + { + void *ctx = state; + $$ = new(ctx) ast_expression_bin(ast_lequal, $1, $3); + $$->set_location(yylloc); + } + | relational_expression GE_OP shift_expression + { + void *ctx = state; + $$ = new(ctx) ast_expression_bin(ast_gequal, $1, $3); + $$->set_location(yylloc); + } + ; + +equality_expression: + relational_expression + | equality_expression EQ_OP relational_expression + { + void *ctx = state; + $$ = new(ctx) ast_expression_bin(ast_equal, $1, $3); + $$->set_location(yylloc); + } + | equality_expression NE_OP relational_expression + { + void *ctx = state; + $$ = new(ctx) ast_expression_bin(ast_nequal, $1, $3); + $$->set_location(yylloc); + } + ; + +and_expression: + equality_expression + | and_expression '&' equality_expression + { + void *ctx = state; + $$ = new(ctx) ast_expression_bin(ast_bit_and, $1, $3); + $$->set_location(yylloc); + } + ; + +exclusive_or_expression: + and_expression + | exclusive_or_expression '^' and_expression + { + void *ctx = state; + $$ = new(ctx) ast_expression_bin(ast_bit_xor, $1, $3); + $$->set_location(yylloc); + } + ; + +inclusive_or_expression: + exclusive_or_expression + | inclusive_or_expression '|' exclusive_or_expression + { + void *ctx = state; + $$ = new(ctx) ast_expression_bin(ast_bit_or, $1, $3); + $$->set_location(yylloc); + } + ; + +logical_and_expression: + inclusive_or_expression + | logical_and_expression AND_OP inclusive_or_expression + { + void *ctx = state; + $$ = new(ctx) ast_expression_bin(ast_logic_and, $1, $3); + $$->set_location(yylloc); + } + ; + +logical_xor_expression: + logical_and_expression + | logical_xor_expression XOR_OP logical_and_expression + { + void *ctx = state; + $$ = new(ctx) ast_expression_bin(ast_logic_xor, $1, $3); + $$->set_location(yylloc); + } + ; + +logical_or_expression: + logical_xor_expression + | logical_or_expression OR_OP logical_xor_expression + { + void *ctx = state; + $$ = new(ctx) ast_expression_bin(ast_logic_or, $1, $3); + $$->set_location(yylloc); + } + ; + +conditional_expression: + logical_or_expression + | logical_or_expression '?' expression ':' assignment_expression + { + void *ctx = state; + $$ = new(ctx) ast_expression(ast_conditional, $1, $3, $5); + $$->set_location(yylloc); + } + ; + +assignment_expression: + conditional_expression + | unary_expression assignment_operator assignment_expression + { + void *ctx = state; + $$ = new(ctx) ast_expression($2, $1, $3, NULL); + $$->set_location(yylloc); + } + ; + +assignment_operator: + '=' { $$ = ast_assign; } + | MUL_ASSIGN { $$ = ast_mul_assign; } + | DIV_ASSIGN { $$ = ast_div_assign; } + | MOD_ASSIGN { $$ = ast_mod_assign; } + | ADD_ASSIGN { $$ = ast_add_assign; } + | SUB_ASSIGN { $$ = ast_sub_assign; } + | LEFT_ASSIGN { $$ = ast_ls_assign; } + | RIGHT_ASSIGN { $$ = ast_rs_assign; } + | AND_ASSIGN { $$ = ast_and_assign; } + | XOR_ASSIGN { $$ = ast_xor_assign; } + | OR_ASSIGN { $$ = ast_or_assign; } + ; + +expression: + assignment_expression + { + $$ = $1; + } + | expression ',' assignment_expression + { + void *ctx = state; + if ($1->oper != ast_sequence) { + $$ = new(ctx) ast_expression(ast_sequence, NULL, NULL, NULL); + $$->set_location(yylloc); + $$->expressions.push_tail(& $1->link); + } else { + $$ = $1; + } + + $$->expressions.push_tail(& $3->link); + } + ; + +constant_expression: + conditional_expression + ; + +declaration: + function_prototype ';' + { + state->symbols->pop_scope(); + $$ = $1; + } + | init_declarator_list ';' + { + $$ = $1; + } + | PRECISION precision_qualifier type_specifier_no_prec ';' + { + $3->precision = $2; + $3->is_precision_statement = true; + $$ = $3; + } + ; + +function_prototype: + function_declarator ')' + ; + +function_declarator: + function_header + | function_header_with_parameters + ; + +function_header_with_parameters: + function_header parameter_declaration + { + $$ = $1; + $$->parameters.push_tail(& $2->link); + } + | function_header_with_parameters ',' parameter_declaration + { + $$ = $1; + $$->parameters.push_tail(& $3->link); + } + ; + +function_header: + fully_specified_type variable_identifier '(' + { + void *ctx = state; + $$ = new(ctx) ast_function(); + $$->set_location(yylloc); + $$->return_type = $1; + $$->identifier = $2; + + state->symbols->add_function(new(state) ir_function($2)); + state->symbols->push_scope(); + } + ; + +parameter_declarator: + type_specifier any_identifier + { + void *ctx = state; + $$ = new(ctx) ast_parameter_declarator(); + $$->set_location(yylloc); + $$->type = new(ctx) ast_fully_specified_type(); + $$->type->set_location(yylloc); + $$->type->specifier = $1; + $$->identifier = $2; + } + | type_specifier any_identifier '[' constant_expression ']' + { + void *ctx = state; + $$ = new(ctx) ast_parameter_declarator(); + $$->set_location(yylloc); + $$->type = new(ctx) ast_fully_specified_type(); + $$->type->set_location(yylloc); + $$->type->specifier = $1; + $$->identifier = $2; + $$->is_array = true; + $$->array_size = $4; + } + ; + +parameter_declaration: + parameter_type_qualifier parameter_qualifier parameter_declarator + { + $1.flags.i |= $2.flags.i; + + $$ = $3; + $$->type->qualifier = $1; + } + | parameter_qualifier parameter_declarator + { + $$ = $2; + $$->type->qualifier = $1; + } + | parameter_type_qualifier parameter_qualifier parameter_type_specifier + { + void *ctx = state; + $1.flags.i |= $2.flags.i; + + $$ = new(ctx) ast_parameter_declarator(); + $$->set_location(yylloc); + $$->type = new(ctx) ast_fully_specified_type(); + $$->type->qualifier = $1; + $$->type->specifier = $3; + } + | parameter_qualifier parameter_type_specifier + { + void *ctx = state; + $$ = new(ctx) ast_parameter_declarator(); + $$->set_location(yylloc); + $$->type = new(ctx) ast_fully_specified_type(); + $$->type->qualifier = $1; + $$->type->specifier = $2; + } + ; + +parameter_qualifier: + /* empty */ + { + memset(& $$, 0, sizeof($$)); + } + | IN_TOK + { + memset(& $$, 0, sizeof($$)); + $$.flags.q.in = 1; + } + | OUT_TOK + { + memset(& $$, 0, sizeof($$)); + $$.flags.q.out = 1; + } + | INOUT_TOK + { + memset(& $$, 0, sizeof($$)); + $$.flags.q.in = 1; + $$.flags.q.out = 1; + } + ; + +parameter_type_specifier: + type_specifier + ; + +init_declarator_list: + single_declaration + | init_declarator_list ',' any_identifier + { + void *ctx = state; + ast_declaration *decl = new(ctx) ast_declaration($3, false, NULL, NULL); + decl->set_location(yylloc); + + $$ = $1; + $$->declarations.push_tail(&decl->link); + state->symbols->add_variable(new(state) ir_variable(NULL, $3, ir_var_auto, glsl_precision_undefined)); + } + | init_declarator_list ',' any_identifier '[' ']' + { + void *ctx = state; + ast_declaration *decl = new(ctx) ast_declaration($3, true, NULL, NULL); + decl->set_location(yylloc); + + $$ = $1; + $$->declarations.push_tail(&decl->link); + state->symbols->add_variable(new(state) ir_variable(NULL, $3, ir_var_auto, glsl_precision_undefined)); + } + | init_declarator_list ',' any_identifier '[' constant_expression ']' + { + void *ctx = state; + ast_declaration *decl = new(ctx) ast_declaration($3, true, $5, NULL); + decl->set_location(yylloc); + + $$ = $1; + $$->declarations.push_tail(&decl->link); + state->symbols->add_variable(new(state) ir_variable(NULL, $3, ir_var_auto, glsl_precision_undefined)); + } + | init_declarator_list ',' any_identifier '[' ']' '=' initializer + { + void *ctx = state; + ast_declaration *decl = new(ctx) ast_declaration($3, true, NULL, $7); + decl->set_location(yylloc); + + $$ = $1; + $$->declarations.push_tail(&decl->link); + state->symbols->add_variable(new(state) ir_variable(NULL, $3, ir_var_auto, glsl_precision_undefined)); + } + | init_declarator_list ',' any_identifier '[' constant_expression ']' '=' initializer + { + void *ctx = state; + ast_declaration *decl = new(ctx) ast_declaration($3, true, $5, $8); + decl->set_location(yylloc); + + $$ = $1; + $$->declarations.push_tail(&decl->link); + state->symbols->add_variable(new(state) ir_variable(NULL, $3, ir_var_auto, glsl_precision_undefined)); + } + | init_declarator_list ',' any_identifier '=' initializer + { + void *ctx = state; + ast_declaration *decl = new(ctx) ast_declaration($3, false, NULL, $5); + decl->set_location(yylloc); + + $$ = $1; + $$->declarations.push_tail(&decl->link); + state->symbols->add_variable(new(state) ir_variable(NULL, $3, ir_var_auto, glsl_precision_undefined)); + } + ; + + // Grammar Note: No 'enum', or 'typedef'. +single_declaration: + fully_specified_type + { + void *ctx = state; + /* Empty declaration list is valid. */ + $$ = new(ctx) ast_declarator_list($1); + $$->set_location(yylloc); + } + | fully_specified_type any_identifier + { + void *ctx = state; + ast_declaration *decl = new(ctx) ast_declaration($2, false, NULL, NULL); + + $$ = new(ctx) ast_declarator_list($1); + $$->set_location(yylloc); + $$->declarations.push_tail(&decl->link); + } + | fully_specified_type any_identifier '[' ']' + { + void *ctx = state; + ast_declaration *decl = new(ctx) ast_declaration($2, true, NULL, NULL); + + $$ = new(ctx) ast_declarator_list($1); + $$->set_location(yylloc); + $$->declarations.push_tail(&decl->link); + } + | fully_specified_type any_identifier '[' constant_expression ']' + { + void *ctx = state; + ast_declaration *decl = new(ctx) ast_declaration($2, true, $4, NULL); + + $$ = new(ctx) ast_declarator_list($1); + $$->set_location(yylloc); + $$->declarations.push_tail(&decl->link); + } + | fully_specified_type any_identifier '[' ']' '=' initializer + { + void *ctx = state; + ast_declaration *decl = new(ctx) ast_declaration($2, true, NULL, $6); + + $$ = new(ctx) ast_declarator_list($1); + $$->set_location(yylloc); + $$->declarations.push_tail(&decl->link); + } + | fully_specified_type any_identifier '[' constant_expression ']' '=' initializer + { + void *ctx = state; + ast_declaration *decl = new(ctx) ast_declaration($2, true, $4, $7); + + $$ = new(ctx) ast_declarator_list($1); + $$->set_location(yylloc); + $$->declarations.push_tail(&decl->link); + } + | fully_specified_type any_identifier '=' initializer + { + void *ctx = state; + ast_declaration *decl = new(ctx) ast_declaration($2, false, NULL, $4); + + $$ = new(ctx) ast_declarator_list($1); + $$->set_location(yylloc); + $$->declarations.push_tail(&decl->link); + } + | INVARIANT variable_identifier // Vertex only. + { + void *ctx = state; + ast_declaration *decl = new(ctx) ast_declaration($2, false, NULL, NULL); + + $$ = new(ctx) ast_declarator_list(NULL); + $$->set_location(yylloc); + $$->invariant = true; + + $$->declarations.push_tail(&decl->link); + } + ; + +fully_specified_type: + type_specifier + { + void *ctx = state; + $$ = new(ctx) ast_fully_specified_type(); + $$->set_location(yylloc); + $$->specifier = $1; + } + | type_qualifier type_specifier + { + void *ctx = state; + $$ = new(ctx) ast_fully_specified_type(); + $$->set_location(yylloc); + $$->qualifier = $1; + $$->specifier = $2; + } + ; + +layout_qualifier: + LAYOUT_TOK '(' layout_qualifier_id_list ')' + { + $$ = $3; + } + ; + +layout_qualifier_id_list: + layout_qualifier_id + | layout_qualifier_id_list ',' layout_qualifier_id + { + if (($1.flags.i & $3.flags.i) != 0) { + _mesa_glsl_error(& @3, state, + "duplicate layout qualifiers used\n"); + YYERROR; + } + + $$.flags.i = $1.flags.i | $3.flags.i; + + if ($1.flags.q.explicit_location) + $$.location = $1.location; + + if ($3.flags.q.explicit_location) + $$.location = $3.location; + } + ; + +layout_qualifier_id: + any_identifier + { + bool got_one = false; + + memset(& $$, 0, sizeof($$)); + + /* Layout qualifiers for ARB_fragment_coord_conventions. */ + if (!got_one && state->ARB_fragment_coord_conventions_enable) { + if (strcmp($1, "origin_upper_left") == 0) { + got_one = true; + $$.flags.q.origin_upper_left = 1; + } else if (strcmp($1, "pixel_center_integer") == 0) { + got_one = true; + $$.flags.q.pixel_center_integer = 1; + } + + if (got_one && state->ARB_fragment_coord_conventions_warn) { + _mesa_glsl_warning(& @1, state, + "GL_ARB_fragment_coord_conventions layout " + "identifier `%s' used\n", $1); + } + } + + /* Layout qualifiers for AMD_conservative_depth. */ + if (!got_one && state->AMD_conservative_depth_enable) { + if (strcmp($1, "depth_any") == 0) { + got_one = true; + $$.flags.q.depth_any = 1; + } else if (strcmp($1, "depth_greater") == 0) { + got_one = true; + $$.flags.q.depth_greater = 1; + } else if (strcmp($1, "depth_less") == 0) { + got_one = true; + $$.flags.q.depth_less = 1; + } else if (strcmp($1, "depth_unchanged") == 0) { + got_one = true; + $$.flags.q.depth_unchanged = 1; + } + + if (got_one && state->AMD_conservative_depth_warn) { + _mesa_glsl_warning(& @1, state, + "GL_AMD_conservative_depth " + "layout qualifier `%s' is used\n", $1); + } + } + + if (!got_one) { + _mesa_glsl_error(& @1, state, "unrecognized layout identifier " + "`%s'\n", $1); + YYERROR; + } + } + | any_identifier '=' INTCONSTANT + { + bool got_one = false; + + memset(& $$, 0, sizeof($$)); + + if (state->ARB_explicit_attrib_location_enable) { + /* FINISHME: Handle 'index' once GL_ARB_blend_func_exteneded and + * FINISHME: GLSL 1.30 (or later) are supported. + */ + if (strcmp("location", $1) == 0) { + got_one = true; + + $$.flags.q.explicit_location = 1; + + if ($3 >= 0) { + $$.location = $3; + } else { + _mesa_glsl_error(& @3, state, + "invalid location %d specified\n", $3); + YYERROR; + } + } + } + + /* If the identifier didn't match any known layout identifiers, + * emit an error. + */ + if (!got_one) { + _mesa_glsl_error(& @1, state, "unrecognized layout identifier " + "`%s'\n", $1); + YYERROR; + } else if (state->ARB_explicit_attrib_location_warn) { + _mesa_glsl_warning(& @1, state, + "GL_ARB_explicit_attrib_location layout " + "identifier `%s' used\n", $1); + } + } + ; + +interpolation_qualifier: + SMOOTH + { + memset(& $$, 0, sizeof($$)); + $$.flags.q.smooth = 1; + } + | FLAT + { + memset(& $$, 0, sizeof($$)); + $$.flags.q.flat = 1; + } + | NOPERSPECTIVE + { + memset(& $$, 0, sizeof($$)); + $$.flags.q.noperspective = 1; + } + ; + +parameter_type_qualifier: + CONST_TOK + { + memset(& $$, 0, sizeof($$)); + $$.flags.q.constant = 1; + } + ; + +type_qualifier: + storage_qualifier + | layout_qualifier + | layout_qualifier storage_qualifier + { + $$ = $1; + $$.flags.i |= $2.flags.i; + } + | interpolation_qualifier + | interpolation_qualifier storage_qualifier + { + $$ = $1; + $$.flags.i |= $2.flags.i; + } + | INVARIANT storage_qualifier + { + $$ = $2; + $$.flags.q.invariant = 1; + } + | INVARIANT interpolation_qualifier storage_qualifier + { + $$ = $2; + $$.flags.i |= $3.flags.i; + $$.flags.q.invariant = 1; + } + | INVARIANT + { + memset(& $$, 0, sizeof($$)); + $$.flags.q.invariant = 1; + } + ; + +storage_qualifier: + CONST_TOK + { + memset(& $$, 0, sizeof($$)); + $$.flags.q.constant = 1; + } + | ATTRIBUTE + { + memset(& $$, 0, sizeof($$)); + $$.flags.q.attribute = 1; + } + | VARYING + { + memset(& $$, 0, sizeof($$)); + $$.flags.q.varying = 1; + } + | CENTROID VARYING + { + memset(& $$, 0, sizeof($$)); + $$.flags.q.centroid = 1; + $$.flags.q.varying = 1; + } + | IN_TOK + { + memset(& $$, 0, sizeof($$)); + $$.flags.q.in = 1; + } + | OUT_TOK + { + memset(& $$, 0, sizeof($$)); + $$.flags.q.out = 1; + } + | CENTROID IN_TOK + { + memset(& $$, 0, sizeof($$)); + $$.flags.q.centroid = 1; $$.flags.q.in = 1; + } + | CENTROID OUT_TOK + { + memset(& $$, 0, sizeof($$)); + $$.flags.q.centroid = 1; $$.flags.q.out = 1; + } + | UNIFORM + { + memset(& $$, 0, sizeof($$)); + $$.flags.q.uniform = 1; + } + ; + +type_specifier: + type_specifier_no_prec + { + $$ = $1; + } + | precision_qualifier type_specifier_no_prec + { + $$ = $2; + $$->precision = $1; + } + ; + +type_specifier_no_prec: + type_specifier_nonarray + | type_specifier_nonarray '[' ']' + { + $$ = $1; + $$->is_array = true; + $$->array_size = NULL; + } + | type_specifier_nonarray '[' constant_expression ']' + { + $$ = $1; + $$->is_array = true; + $$->array_size = $3; + } + ; + +type_specifier_nonarray: + basic_type_specifier_nonarray + { + void *ctx = state; + $$ = new(ctx) ast_type_specifier($1); + $$->set_location(yylloc); + } + | struct_specifier + { + void *ctx = state; + $$ = new(ctx) ast_type_specifier($1); + $$->set_location(yylloc); + } + | TYPE_IDENTIFIER + { + void *ctx = state; + $$ = new(ctx) ast_type_specifier($1); + $$->set_location(yylloc); + } + ; + +basic_type_specifier_nonarray: + VOID_TOK { $$ = ast_void; } + | FLOAT_TOK { $$ = ast_float; } + | INT_TOK { $$ = ast_int; } + | UINT_TOK { $$ = ast_uint; } + | BOOL_TOK { $$ = ast_bool; } + | VEC2 { $$ = ast_vec2; } + | VEC3 { $$ = ast_vec3; } + | VEC4 { $$ = ast_vec4; } + | BVEC2 { $$ = ast_bvec2; } + | BVEC3 { $$ = ast_bvec3; } + | BVEC4 { $$ = ast_bvec4; } + | IVEC2 { $$ = ast_ivec2; } + | IVEC3 { $$ = ast_ivec3; } + | IVEC4 { $$ = ast_ivec4; } + | UVEC2 { $$ = ast_uvec2; } + | UVEC3 { $$ = ast_uvec3; } + | UVEC4 { $$ = ast_uvec4; } + | MAT2X2 { $$ = ast_mat2; } + | MAT2X3 { $$ = ast_mat2x3; } + | MAT2X4 { $$ = ast_mat2x4; } + | MAT3X2 { $$ = ast_mat3x2; } + | MAT3X3 { $$ = ast_mat3; } + | MAT3X4 { $$ = ast_mat3x4; } + | MAT4X2 { $$ = ast_mat4x2; } + | MAT4X3 { $$ = ast_mat4x3; } + | MAT4X4 { $$ = ast_mat4; } + | SAMPLER1D { $$ = ast_sampler1d; } + | SAMPLER2D { $$ = ast_sampler2d; } + | SAMPLER2DRECT { $$ = ast_sampler2drect; } + | SAMPLER3D { $$ = ast_sampler3d; } + | SAMPLERCUBE { $$ = ast_samplercube; } + | SAMPLER1DSHADOW { $$ = ast_sampler1dshadow; } + | SAMPLER2DSHADOW { $$ = ast_sampler2dshadow; } + | SAMPLER2DRECTSHADOW { $$ = ast_sampler2drectshadow; } + | SAMPLERCUBESHADOW { $$ = ast_samplercubeshadow; } + | SAMPLER1DARRAY { $$ = ast_sampler1darray; } + | SAMPLER2DARRAY { $$ = ast_sampler2darray; } + | SAMPLER1DARRAYSHADOW { $$ = ast_sampler1darrayshadow; } + | SAMPLER2DARRAYSHADOW { $$ = ast_sampler2darrayshadow; } + | ISAMPLER1D { $$ = ast_isampler1d; } + | ISAMPLER2D { $$ = ast_isampler2d; } + | ISAMPLER3D { $$ = ast_isampler3d; } + | ISAMPLERCUBE { $$ = ast_isamplercube; } + | ISAMPLER1DARRAY { $$ = ast_isampler1darray; } + | ISAMPLER2DARRAY { $$ = ast_isampler2darray; } + | USAMPLER1D { $$ = ast_usampler1d; } + | USAMPLER2D { $$ = ast_usampler2d; } + | USAMPLER3D { $$ = ast_usampler3d; } + | USAMPLERCUBE { $$ = ast_usamplercube; } + | USAMPLER1DARRAY { $$ = ast_usampler1darray; } + | USAMPLER2DARRAY { $$ = ast_usampler2darray; } + ; + +precision_qualifier: + HIGHP { + if (!state->es_shader && state->language_version < 130) + _mesa_glsl_error(& @1, state, + "precision qualifier forbidden " + "in %s (1.30 or later " + "required)\n", + state->version_string); + + $$ = ast_precision_high; + } + | MEDIUMP { + if (!state->es_shader && state->language_version < 130) + _mesa_glsl_error(& @1, state, + "precision qualifier forbidden " + "in %s (1.30 or later " + "required)\n", + state->version_string); + + $$ = ast_precision_medium; + } + | LOWP { + if (!state->es_shader && state->language_version < 130) + _mesa_glsl_error(& @1, state, + "precision qualifier forbidden " + "in %s (1.30 or later " + "required)\n", + state->version_string); + + $$ = ast_precision_low; + } + ; + +struct_specifier: + STRUCT any_identifier '{' struct_declaration_list '}' + { + void *ctx = state; + $$ = new(ctx) ast_struct_specifier($2, $4); + $$->set_location(yylloc); + state->symbols->add_type($2, glsl_type::void_type); + } + | STRUCT '{' struct_declaration_list '}' + { + void *ctx = state; + $$ = new(ctx) ast_struct_specifier(NULL, $3); + $$->set_location(yylloc); + } + ; + +struct_declaration_list: + struct_declaration + { + $$ = (ast_node *) $1; + $1->link.self_link(); + } + | struct_declaration_list struct_declaration + { + $$ = (ast_node *) $1; + $$->link.insert_before(& $2->link); + } + ; + +struct_declaration: + type_specifier struct_declarator_list ';' + { + void *ctx = state; + ast_fully_specified_type *type = new(ctx) ast_fully_specified_type(); + type->set_location(yylloc); + + type->specifier = $1; + $$ = new(ctx) ast_declarator_list(type); + $$->set_location(yylloc); + + $$->declarations.push_degenerate_list_at_head(& $2->link); + } + ; + +struct_declarator_list: + struct_declarator + { + $$ = $1; + $1->link.self_link(); + } + | struct_declarator_list ',' struct_declarator + { + $$ = $1; + $$->link.insert_before(& $3->link); + } + ; + +struct_declarator: + any_identifier + { + void *ctx = state; + $$ = new(ctx) ast_declaration($1, false, NULL, NULL); + $$->set_location(yylloc); + state->symbols->add_variable(new(state) ir_variable(NULL, $1, ir_var_auto, glsl_precision_undefined)); + } + | any_identifier '[' constant_expression ']' + { + void *ctx = state; + $$ = new(ctx) ast_declaration($1, true, $3, NULL); + $$->set_location(yylloc); + } + ; + +initializer: + assignment_expression + ; + +declaration_statement: + declaration + ; + + // Grammar Note: labeled statements for SWITCH only; 'goto' is not + // supported. +statement: + compound_statement { $$ = (ast_node *) $1; } + | simple_statement + ; + +simple_statement: + declaration_statement + | expression_statement + | selection_statement + | switch_statement { $$ = NULL; } + | case_label { $$ = NULL; } + | iteration_statement + | jump_statement + ; + +compound_statement: + '{' '}' + { + void *ctx = state; + $$ = new(ctx) ast_compound_statement(true, NULL); + $$->set_location(yylloc); + } + | '{' + { + state->symbols->push_scope(); + } + statement_list '}' + { + void *ctx = state; + $$ = new(ctx) ast_compound_statement(true, $3); + $$->set_location(yylloc); + state->symbols->pop_scope(); + } + ; + +statement_no_new_scope: + compound_statement_no_new_scope { $$ = (ast_node *) $1; } + | simple_statement + ; + +compound_statement_no_new_scope: + '{' '}' + { + void *ctx = state; + $$ = new(ctx) ast_compound_statement(false, NULL); + $$->set_location(yylloc); + } + | '{' statement_list '}' + { + void *ctx = state; + $$ = new(ctx) ast_compound_statement(false, $2); + $$->set_location(yylloc); + } + ; + +statement_list: + statement + { + if ($1 == NULL) { + _mesa_glsl_error(& @1, state, " statement\n"); + assert($1 != NULL); + } + + $$ = $1; + $$->link.self_link(); + } + | statement_list statement + { + if ($2 == NULL) { + _mesa_glsl_error(& @2, state, " statement\n"); + assert($2 != NULL); + } + $$ = $1; + $$->link.insert_before(& $2->link); + } + ; + +expression_statement: + ';' + { + void *ctx = state; + $$ = new(ctx) ast_expression_statement(NULL); + $$->set_location(yylloc); + } + | expression ';' + { + void *ctx = state; + $$ = new(ctx) ast_expression_statement($1); + $$->set_location(yylloc); + } + ; + +selection_statement: + IF '(' expression ')' selection_rest_statement + { + $$ = new(state) ast_selection_statement($3, $5.then_statement, + $5.else_statement); + $$->set_location(yylloc); + } + ; + +selection_rest_statement: + statement ELSE statement + { + $$.then_statement = $1; + $$.else_statement = $3; + } + | statement + { + $$.then_statement = $1; + $$.else_statement = NULL; + } + ; + +condition: + expression + { + $$ = (ast_node *) $1; + } + | fully_specified_type any_identifier '=' initializer + { + void *ctx = state; + ast_declaration *decl = new(ctx) ast_declaration($2, false, NULL, $4); + ast_declarator_list *declarator = new(ctx) ast_declarator_list($1); + decl->set_location(yylloc); + declarator->set_location(yylloc); + + declarator->declarations.push_tail(&decl->link); + $$ = declarator; + } + ; + +switch_statement: + SWITCH '(' expression ')' compound_statement + ; + +case_label: + CASE expression ':' + | DEFAULT ':' + ; + +iteration_statement: + WHILE '(' condition ')' statement_no_new_scope + { + void *ctx = state; + $$ = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_while, + NULL, $3, NULL, $5); + $$->set_location(yylloc); + } + | DO statement WHILE '(' expression ')' ';' + { + void *ctx = state; + $$ = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_do_while, + NULL, $5, NULL, $2); + $$->set_location(yylloc); + } + | FOR '(' for_init_statement for_rest_statement ')' statement_no_new_scope + { + void *ctx = state; + $$ = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_for, + $3, $4.cond, $4.rest, $6); + $$->set_location(yylloc); + } + ; + +for_init_statement: + expression_statement + | declaration_statement + ; + +conditionopt: + condition + | /* empty */ + { + $$ = NULL; + } + ; + +for_rest_statement: + conditionopt ';' + { + $$.cond = $1; + $$.rest = NULL; + } + | conditionopt ';' expression + { + $$.cond = $1; + $$.rest = $3; + } + ; + + // Grammar Note: No 'goto'. Gotos are not supported. +jump_statement: + CONTINUE ';' + { + void *ctx = state; + $$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_continue, NULL); + $$->set_location(yylloc); + } + | BREAK ';' + { + void *ctx = state; + $$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_break, NULL); + $$->set_location(yylloc); + } + | RETURN ';' + { + void *ctx = state; + $$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_return, NULL); + $$->set_location(yylloc); + } + | RETURN expression ';' + { + void *ctx = state; + $$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_return, $2); + $$->set_location(yylloc); + } + | DISCARD ';' // Fragment shader only. + { + void *ctx = state; + $$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_discard, NULL); + $$->set_location(yylloc); + } + ; + +external_declaration: + function_definition { $$ = $1; } + | declaration { $$ = $1; } + | pragma_statement { $$ = NULL; } + ; + +function_definition: + function_prototype compound_statement_no_new_scope + { + void *ctx = state; + $$ = new(ctx) ast_function_definition(); + $$->set_location(yylloc); + $$->prototype = $1; + $$->body = $2; + + state->symbols->pop_scope(); + } + ; diff --git a/3rdparty/glsl-optimizer/src/glsl/glsl_parser_extras.cpp b/3rdparty/glsl-optimizer/src/glsl/glsl_parser_extras.cpp new file mode 100644 index 000000000..590bb3b78 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/glsl_parser_extras.cpp @@ -0,0 +1,959 @@ +/* + * Copyright © 2008, 2009 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +#include +#include +#include +#include + +extern "C" { +#include "main/core.h" /* for struct gl_context */ +} + +#include "ralloc.h" +#include "ast.h" +#include "glsl_parser_extras.h" +#include "glsl_parser.h" +#include "ir_optimization.h" +#include "loop_analysis.h" + +_mesa_glsl_parse_state::_mesa_glsl_parse_state(struct gl_context *ctx, + GLenum target, void *mem_ctx) +{ + switch (target) { + case GL_VERTEX_SHADER: this->target = vertex_shader; break; + case GL_FRAGMENT_SHADER: this->target = fragment_shader; break; + case GL_GEOMETRY_SHADER: this->target = geometry_shader; break; + } + + this->scanner = NULL; + this->translation_unit.make_empty(); + this->symbols = new(mem_ctx) glsl_symbol_table; + this->info_log = ralloc_strdup(mem_ctx, ""); + this->error = false; + this->loop_or_switch_nesting = NULL; + + /* Set default language version and extensions */ + this->language_version = 110; + this->es_shader = false; + this->ARB_texture_rectangle_enable = true; + + /* OpenGL ES 2.0 has different defaults from desktop GL. */ + if (ctx->API == API_OPENGLES2) { + this->language_version = 100; + this->es_shader = true; + this->ARB_texture_rectangle_enable = false; + } + + this->extensions = &ctx->Extensions; + + this->Const.MaxLights = ctx->Const.MaxLights; + this->Const.MaxClipPlanes = ctx->Const.MaxClipPlanes; + this->Const.MaxTextureUnits = ctx->Const.MaxTextureUnits; + this->Const.MaxTextureCoords = ctx->Const.MaxTextureCoordUnits; + this->Const.MaxVertexAttribs = ctx->Const.VertexProgram.MaxAttribs; + this->Const.MaxVertexUniformComponents = ctx->Const.VertexProgram.MaxUniformComponents; + this->Const.MaxVaryingFloats = ctx->Const.MaxVarying * 4; + this->Const.MaxVertexTextureImageUnits = ctx->Const.MaxVertexTextureImageUnits; + this->Const.MaxCombinedTextureImageUnits = ctx->Const.MaxCombinedTextureImageUnits; + this->Const.MaxTextureImageUnits = ctx->Const.MaxTextureImageUnits; + this->Const.MaxFragmentUniformComponents = ctx->Const.FragmentProgram.MaxUniformComponents; + + this->Const.MaxDrawBuffers = ctx->Const.MaxDrawBuffers; + + /* Note: Once the OpenGL 3.0 'forward compatible' context or the OpenGL 3.2 + * Core context is supported, this logic will need change. Older versions of + * GLSL are no longer supported outside the compatibility contexts of 3.x. + */ + this->Const.GLSL_100ES = (ctx->API == API_OPENGLES2) + || ctx->Extensions.ARB_ES2_compatibility; + this->Const.GLSL_110 = (ctx->API == API_OPENGL); + this->Const.GLSL_120 = (ctx->API == API_OPENGL) + && (ctx->Const.GLSLVersion >= 120); + this->Const.GLSL_130 = (ctx->API == API_OPENGL) + && (ctx->Const.GLSLVersion >= 130); + + const unsigned lowest_version = + (ctx->API == API_OPENGLES2) || ctx->Extensions.ARB_ES2_compatibility + ? 100 : 110; + const unsigned highest_version = + (ctx->API == API_OPENGL) ? ctx->Const.GLSLVersion : 100; + char *supported = ralloc_strdup(this, ""); + + for (unsigned ver = lowest_version; ver <= highest_version; ver += 10) { + const char *const prefix = (ver == lowest_version) + ? "" + : ((ver == highest_version) ? ", and " : ", "); + + ralloc_asprintf_append(& supported, "%s%d.%02d%s", + prefix, + ver / 100, ver % 100, + (ver == 100) ? " ES" : ""); + } + + this->supported_version_string = supported; +} + +const char * +_mesa_glsl_shader_target_name(enum _mesa_glsl_parser_targets target) +{ + switch (target) { + case vertex_shader: return "vertex"; + case fragment_shader: return "fragment"; + case geometry_shader: return "geometry"; + } + + assert(!"Should not get here."); + return "unknown"; +} + + +void +_mesa_glsl_error(YYLTYPE *locp, _mesa_glsl_parse_state *state, + const char *fmt, ...) +{ + va_list ap; + + state->error = true; + + assert(state->info_log != NULL); + ralloc_asprintf_append(&state->info_log, "%u:%u(%u): error: ", + locp->source, + locp->first_line, + locp->first_column); + va_start(ap, fmt); + ralloc_vasprintf_append(&state->info_log, fmt, ap); + va_end(ap); + ralloc_strcat(&state->info_log, "\n"); +} + + +void +_mesa_glsl_warning(const YYLTYPE *locp, _mesa_glsl_parse_state *state, + const char *fmt, ...) +{ + va_list ap; + + assert(state->info_log != NULL); + ralloc_asprintf_append(&state->info_log, "%u:%u(%u): warning: ", + locp->source, + locp->first_line, + locp->first_column); + va_start(ap, fmt); + ralloc_vasprintf_append(&state->info_log, fmt, ap); + va_end(ap); + ralloc_strcat(&state->info_log, "\n"); +} + + +/** + * Enum representing the possible behaviors that can be specified in + * an #extension directive. + */ +enum ext_behavior { + extension_disable, + extension_enable, + extension_require, + extension_warn +}; + +/** + * Element type for _mesa_glsl_supported_extensions + */ +struct _mesa_glsl_extension { + /** + * Name of the extension when referred to in a GLSL extension + * statement + */ + const char *name; + + /** True if this extension is available to vertex shaders */ + bool avail_in_VS; + + /** True if this extension is available to geometry shaders */ + bool avail_in_GS; + + /** True if this extension is available to fragment shaders */ + bool avail_in_FS; + + /** True if this extension is available to desktop GL shaders */ + bool avail_in_GL; + + /** True if this extension is available to GLES shaders */ + bool avail_in_ES; + + /** + * Flag in the gl_extensions struct indicating whether this + * extension is supported by the driver, or + * &gl_extensions::dummy_true if supported by all drivers. + * + * Note: the type (GLboolean gl_extensions::*) is a "pointer to + * member" type, the type-safe alternative to the "offsetof" macro. + * In a nutshell: + * + * - foo bar::* p declares p to be an "offset" to a field of type + * foo that exists within struct bar + * - &bar::baz computes the "offset" of field baz within struct bar + * - x.*p accesses the field of x that exists at "offset" p + * - x->*p is equivalent to (*x).*p + */ + const GLboolean gl_extensions::* supported_flag; + + /** + * Flag in the _mesa_glsl_parse_state struct that should be set + * when this extension is enabled. + * + * See note in _mesa_glsl_extension::supported_flag about "pointer + * to member" types. + */ + bool _mesa_glsl_parse_state::* enable_flag; + + /** + * Flag in the _mesa_glsl_parse_state struct that should be set + * when the shader requests "warn" behavior for this extension. + * + * See note in _mesa_glsl_extension::supported_flag about "pointer + * to member" types. + */ + bool _mesa_glsl_parse_state::* warn_flag; + + + bool compatible_with_state(const _mesa_glsl_parse_state *state) const; + void set_flags(_mesa_glsl_parse_state *state, ext_behavior behavior) const; +}; + +#define EXT(NAME, VS, GS, FS, GL, ES, SUPPORTED_FLAG) \ + { "GL_" #NAME, VS, GS, FS, GL, ES, &gl_extensions::SUPPORTED_FLAG, \ + &_mesa_glsl_parse_state::NAME##_enable, \ + &_mesa_glsl_parse_state::NAME##_warn } + +/** + * Table of extensions that can be enabled/disabled within a shader, + * and the conditions under which they are supported. + */ +static const _mesa_glsl_extension _mesa_glsl_supported_extensions[] = { + /* target availability API availability */ + /* name VS GS FS GL ES supported flag */ + EXT(ARB_draw_buffers, false, false, true, true, false, dummy_true), + EXT(ARB_draw_instanced, true, false, false, true, false, ARB_draw_instanced), + EXT(ARB_explicit_attrib_location, true, false, true, true, false, ARB_explicit_attrib_location), + EXT(ARB_fragment_coord_conventions, true, false, true, true, false, ARB_fragment_coord_conventions), + EXT(ARB_texture_rectangle, true, false, true, true, false, dummy_true), + EXT(EXT_texture_array, true, false, true, true, false, EXT_texture_array), + EXT(ARB_shader_texture_lod, true, false, true, true, true, ARB_shader_texture_lod), + EXT(EXT_shader_texture_lod, true, false, true, true, true, ARB_shader_texture_lod), + EXT(ARB_shader_stencil_export, false, false, true, true, false, ARB_shader_stencil_export), + EXT(AMD_conservative_depth, true, false, true, true, false, AMD_conservative_depth), + EXT(AMD_shader_stencil_export, false, false, true, true, false, ARB_shader_stencil_export), + EXT(OES_texture_3D, true, false, true, false, true, EXT_texture3D), + EXT(OES_standard_derivatives, false, false, true, false, true, OES_standard_derivatives), +}; + +#undef EXT + + +/** + * Determine whether a given extension is compatible with the target, + * API, and extension information in the current parser state. + */ +bool _mesa_glsl_extension::compatible_with_state(const _mesa_glsl_parse_state * + state) const +{ + /* Check that this extension matches the type of shader we are + * compiling to. + */ + switch (state->target) { + case vertex_shader: + if (!this->avail_in_VS) { + return false; + } + break; + case geometry_shader: + if (!this->avail_in_GS) { + return false; + } + break; + case fragment_shader: + if (!this->avail_in_FS) { + return false; + } + break; + default: + assert (!"Unrecognized shader target"); + return false; + } + + /* Check that this extension matches whether we are compiling + * for desktop GL or GLES. + */ + if (state->es_shader) { + if (!this->avail_in_ES) return false; + } else { + if (!this->avail_in_GL) return false; + } + + /* Check that this extension is supported by the OpenGL + * implementation. + * + * Note: the ->* operator indexes into state->extensions by the + * offset this->supported_flag. See + * _mesa_glsl_extension::supported_flag for more info. + */ + return state->extensions->*(this->supported_flag); +} + +/** + * Set the appropriate flags in the parser state to establish the + * given behavior for this extension. + */ +void _mesa_glsl_extension::set_flags(_mesa_glsl_parse_state *state, + ext_behavior behavior) const +{ + /* Note: the ->* operator indexes into state by the + * offsets this->enable_flag and this->warn_flag. See + * _mesa_glsl_extension::supported_flag for more info. + */ + state->*(this->enable_flag) = (behavior != extension_disable); + state->*(this->warn_flag) = (behavior == extension_warn); +} + +/** + * Find an extension by name in _mesa_glsl_supported_extensions. If + * the name is not found, return NULL. + */ +static const _mesa_glsl_extension *find_extension(const char *name) +{ + for (unsigned i = 0; i < Elements(_mesa_glsl_supported_extensions); ++i) { + if (strcmp(name, _mesa_glsl_supported_extensions[i].name) == 0) { + return &_mesa_glsl_supported_extensions[i]; + } + } + return NULL; +} + + +bool +_mesa_glsl_process_extension(const char *name, YYLTYPE *name_locp, + const char *behavior_string, YYLTYPE *behavior_locp, + _mesa_glsl_parse_state *state) +{ + ext_behavior behavior; + if (strcmp(behavior_string, "warn") == 0) { + behavior = extension_warn; + } else if (strcmp(behavior_string, "require") == 0) { + behavior = extension_require; + } else if (strcmp(behavior_string, "enable") == 0) { + behavior = extension_enable; + } else if (strcmp(behavior_string, "disable") == 0) { + behavior = extension_disable; + } else { + _mesa_glsl_error(behavior_locp, state, + "Unknown extension behavior `%s'", + behavior_string); + return false; + } + + if (strcmp(name, "all") == 0) { + if ((behavior == extension_enable) || (behavior == extension_require)) { + _mesa_glsl_error(name_locp, state, "Cannot %s all extensions", + (behavior == extension_enable) + ? "enable" : "require"); + return false; + } else { + for (unsigned i = 0; + i < Elements(_mesa_glsl_supported_extensions); ++i) { + const _mesa_glsl_extension *extension + = &_mesa_glsl_supported_extensions[i]; + if (extension->compatible_with_state(state)) { + _mesa_glsl_supported_extensions[i].set_flags(state, behavior); + } + } + } + } else { + const _mesa_glsl_extension *extension = find_extension(name); + if (extension && extension->compatible_with_state(state)) { + extension->set_flags(state, behavior); + } else { + static const char *const fmt = "extension `%s' unsupported in %s shader"; + + if (behavior == extension_require) { + _mesa_glsl_error(name_locp, state, fmt, + name, _mesa_glsl_shader_target_name(state->target)); + return false; + } else { + _mesa_glsl_warning(name_locp, state, fmt, + name, _mesa_glsl_shader_target_name(state->target)); + } + } + } + + return true; +} + +void +_mesa_ast_type_qualifier_print(const struct ast_type_qualifier *q) +{ + if (q->flags.q.constant) + printf("const "); + + if (q->flags.q.invariant) + printf("invariant "); + + if (q->flags.q.attribute) + printf("attribute "); + + if (q->flags.q.varying) + printf("varying "); + + if (q->flags.q.in && q->flags.q.out) + printf("inout "); + else { + if (q->flags.q.in) + printf("in "); + + if (q->flags.q.out) + printf("out "); + } + + if (q->flags.q.centroid) + printf("centroid "); + if (q->flags.q.uniform) + printf("uniform "); + if (q->flags.q.smooth) + printf("smooth "); + if (q->flags.q.flat) + printf("flat "); + if (q->flags.q.noperspective) + printf("noperspective "); +} + + +void +ast_node::print(void) const +{ + printf("unhandled node "); +} + + +ast_node::ast_node(void) +{ + this->location.source = 0; + this->location.line = 0; + this->location.column = 0; +} + + +static void +ast_opt_array_size_print(bool is_array, const ast_expression *array_size) +{ + if (is_array) { + printf("[ "); + + if (array_size) + array_size->print(); + + printf("] "); + } +} + + +void +ast_compound_statement::print(void) const +{ + printf("{\n"); + + foreach_list_const(n, &this->statements) { + ast_node *ast = exec_node_data(ast_node, n, link); + ast->print(); + } + + printf("}\n"); +} + + +ast_compound_statement::ast_compound_statement(int new_scope, + ast_node *statements) +{ + this->new_scope = new_scope; + + if (statements != NULL) { + this->statements.push_degenerate_list_at_head(&statements->link); + } +} + + +void +ast_expression::print(void) const +{ + switch (oper) { + case ast_assign: + case ast_mul_assign: + case ast_div_assign: + case ast_mod_assign: + case ast_add_assign: + case ast_sub_assign: + case ast_ls_assign: + case ast_rs_assign: + case ast_and_assign: + case ast_xor_assign: + case ast_or_assign: + subexpressions[0]->print(); + printf("%s ", operator_string(oper)); + subexpressions[1]->print(); + break; + + case ast_field_selection: + subexpressions[0]->print(); + printf(". %s ", primary_expression.identifier); + break; + + case ast_plus: + case ast_neg: + case ast_bit_not: + case ast_logic_not: + case ast_pre_inc: + case ast_pre_dec: + printf("%s ", operator_string(oper)); + subexpressions[0]->print(); + break; + + case ast_post_inc: + case ast_post_dec: + subexpressions[0]->print(); + printf("%s ", operator_string(oper)); + break; + + case ast_conditional: + subexpressions[0]->print(); + printf("? "); + subexpressions[1]->print(); + printf(": "); + subexpressions[2]->print(); + break; + + case ast_array_index: + subexpressions[0]->print(); + printf("[ "); + subexpressions[1]->print(); + printf("] "); + break; + + case ast_function_call: { + subexpressions[0]->print(); + printf("( "); + + foreach_list_const (n, &this->expressions) { + if (n != this->expressions.get_head()) + printf(", "); + + ast_node *ast = exec_node_data(ast_node, n, link); + ast->print(); + } + + printf(") "); + break; + } + + case ast_identifier: + printf("%s ", primary_expression.identifier); + break; + + case ast_int_constant: + printf("%d ", primary_expression.int_constant); + break; + + case ast_uint_constant: + printf("%u ", primary_expression.uint_constant); + break; + + case ast_float_constant: + printf("%f ", primary_expression.float_constant); + break; + + case ast_bool_constant: + printf("%s ", + primary_expression.bool_constant + ? "true" : "false"); + break; + + case ast_sequence: { + printf("( "); + foreach_list_const(n, & this->expressions) { + if (n != this->expressions.get_head()) + printf(", "); + + ast_node *ast = exec_node_data(ast_node, n, link); + ast->print(); + } + printf(") "); + break; + } + + default: + assert(0); + break; + } +} + +ast_expression::ast_expression(int oper, + ast_expression *ex0, + ast_expression *ex1, + ast_expression *ex2) +{ + this->oper = ast_operators(oper); + this->subexpressions[0] = ex0; + this->subexpressions[1] = ex1; + this->subexpressions[2] = ex2; +} + + +void +ast_expression_statement::print(void) const +{ + if (expression) + expression->print(); + + printf("; "); +} + + +ast_expression_statement::ast_expression_statement(ast_expression *ex) : + expression(ex) +{ + /* empty */ +} + + +void +ast_function::print(void) const +{ + return_type->print(); + printf(" %s (", identifier); + + foreach_list_const(n, & this->parameters) { + ast_node *ast = exec_node_data(ast_node, n, link); + ast->print(); + } + + printf(")"); +} + + +ast_function::ast_function(void) + : is_definition(false), signature(NULL) +{ + /* empty */ +} + + +void +ast_fully_specified_type::print(void) const +{ + _mesa_ast_type_qualifier_print(& qualifier); + specifier->print(); +} + + +void +ast_parameter_declarator::print(void) const +{ + type->print(); + if (identifier) + printf("%s ", identifier); + ast_opt_array_size_print(is_array, array_size); +} + + +void +ast_function_definition::print(void) const +{ + prototype->print(); + body->print(); +} + + +void +ast_declaration::print(void) const +{ + printf("%s ", identifier); + ast_opt_array_size_print(is_array, array_size); + + if (initializer) { + printf("= "); + initializer->print(); + } +} + + +ast_declaration::ast_declaration(char *identifier, int is_array, + ast_expression *array_size, + ast_expression *initializer) +{ + this->identifier = identifier; + this->is_array = is_array; + this->array_size = array_size; + this->initializer = initializer; +} + + +void +ast_declarator_list::print(void) const +{ + assert(type || invariant); + + if (type) + type->print(); + else + printf("invariant "); + + foreach_list_const (ptr, & this->declarations) { + if (ptr != this->declarations.get_head()) + printf(", "); + + ast_node *ast = exec_node_data(ast_node, ptr, link); + ast->print(); + } + + printf("; "); +} + + +ast_declarator_list::ast_declarator_list(ast_fully_specified_type *type) +{ + this->type = type; + this->invariant = false; +} + +void +ast_jump_statement::print(void) const +{ + switch (mode) { + case ast_continue: + printf("continue; "); + break; + case ast_break: + printf("break; "); + break; + case ast_return: + printf("return "); + if (opt_return_value) + opt_return_value->print(); + + printf("; "); + break; + case ast_discard: + printf("discard; "); + break; + } +} + + +ast_jump_statement::ast_jump_statement(int mode, ast_expression *return_value) +{ + this->mode = ast_jump_modes(mode); + + if (mode == ast_return) + opt_return_value = return_value; +} + + +void +ast_selection_statement::print(void) const +{ + printf("if ( "); + condition->print(); + printf(") "); + + then_statement->print(); + + if (else_statement) { + printf("else "); + else_statement->print(); + } + +} + + +ast_selection_statement::ast_selection_statement(ast_expression *condition, + ast_node *then_statement, + ast_node *else_statement) +{ + this->condition = condition; + this->then_statement = then_statement; + this->else_statement = else_statement; +} + + +void +ast_iteration_statement::print(void) const +{ + switch (mode) { + case ast_for: + printf("for( "); + if (init_statement) + init_statement->print(); + printf("; "); + + if (condition) + condition->print(); + printf("; "); + + if (rest_expression) + rest_expression->print(); + printf(") "); + + body->print(); + break; + + case ast_while: + printf("while ( "); + if (condition) + condition->print(); + printf(") "); + body->print(); + break; + + case ast_do_while: + printf("do "); + body->print(); + printf("while ( "); + if (condition) + condition->print(); + printf("); "); + break; + } +} + + +ast_iteration_statement::ast_iteration_statement(int mode, + ast_node *init, + ast_node *condition, + ast_expression *rest_expression, + ast_node *body) +{ + this->mode = ast_iteration_modes(mode); + this->init_statement = init; + this->condition = condition; + this->rest_expression = rest_expression; + this->body = body; +} + + +void +ast_struct_specifier::print(void) const +{ + printf("struct %s { ", name); + foreach_list_const(n, &this->declarations) { + ast_node *ast = exec_node_data(ast_node, n, link); + ast->print(); + } + printf("} "); +} + + +ast_struct_specifier::ast_struct_specifier(char *identifier, + ast_node *declarator_list) +{ + if (identifier == NULL) { + static unsigned anon_count = 1; + identifier = ralloc_asprintf(this, "#anon_struct_%04x", anon_count); + anon_count++; + } + name = identifier; + this->declarations.push_degenerate_list_at_head(&declarator_list->link); +} + +bool +do_common_optimization(exec_list *ir, bool linked, unsigned max_unroll_iterations) +{ + GLboolean progress = GL_FALSE; + + progress = lower_instructions(ir, SUB_TO_ADD_NEG) || progress; + + if (linked) { + progress = do_function_inlining(ir) || progress; + progress = do_dead_functions(ir) || progress; + } + progress = do_structure_splitting(ir) || progress; + progress = do_if_simplification(ir) || progress; + progress = do_discard_simplification(ir) || progress; + progress = do_copy_propagation(ir) || progress; + progress = do_copy_propagation_elements(ir) || progress; + if (linked) + progress = do_dead_code(ir) || progress; + else + progress = do_dead_code_unlinked(ir) || progress; + progress = do_dead_code_local(ir) || progress; + progress = do_tree_grafting(ir) || progress; + progress = do_constant_propagation(ir) || progress; + if (linked) + progress = do_constant_variable(ir) || progress; + else + progress = do_constant_variable_unlinked(ir) || progress; + progress = do_constant_folding(ir) || progress; + progress = do_algebraic(ir) || progress; + progress = do_lower_jumps(ir) || progress; + progress = do_vec_index_to_swizzle(ir) || progress; + progress = do_swizzle_swizzle(ir) || progress; + progress = do_noop_swizzle(ir) || progress; + + progress = optimize_redundant_jumps(ir) || progress; + + loop_state *ls = analyze_loop_variables(ir); + if (ls->loop_found) { + progress = set_loop_controls(ir, ls) || progress; + progress = unroll_loops(ir, ls, max_unroll_iterations) || progress; + } + delete ls; + + return progress; +} + +extern "C" { + +/** + * To be called at GL teardown time, this frees compiler datastructures. + * + * After calling this, any previously compiled shaders and shader + * programs would be invalid. So this should happen at approximately + * program exit. + */ +void +_mesa_destroy_shader_compiler(void) +{ + _mesa_destroy_shader_compiler_caches(); + + _mesa_glsl_release_types(); +} + +/** + * Releases compiler caches to trade off performance for memory. + * + * Intended to be used with glReleaseShaderCompiler(). + */ +void +_mesa_destroy_shader_compiler_caches(void) +{ + _mesa_glsl_release_functions(); +} + +} diff --git a/3rdparty/glsl-optimizer/src/glsl/glsl_parser_extras.h b/3rdparty/glsl-optimizer/src/glsl/glsl_parser_extras.h new file mode 100644 index 000000000..7847760e8 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/glsl_parser_extras.h @@ -0,0 +1,293 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#pragma once +#ifndef GLSL_PARSER_EXTRAS_H +#define GLSL_PARSER_EXTRAS_H + +/* + * Most of the definitions here only apply to C++ + */ +#ifdef __cplusplus + + +#include +#include "glsl_symbol_table.h" + +enum _mesa_glsl_parser_targets { + vertex_shader, + geometry_shader, + fragment_shader +}; + +struct gl_context; + +struct _mesa_glsl_parse_state { + _mesa_glsl_parse_state(struct gl_context *ctx, GLenum target, + void *mem_ctx); + + /* Callers of this ralloc-based new need not call delete. It's + * easier to just ralloc_free 'ctx' (or any of its ancestors). */ + static void* operator new(size_t size, void *ctx) + { + void *mem = rzalloc_size(ctx, size); + assert(mem != NULL); + + return mem; + } + + /* If the user *does* call delete, that's OK, we will just + * ralloc_free in that case. */ + static void operator delete(void *mem) + { + ralloc_free(mem); + } + + void *scanner; + exec_list translation_unit; + glsl_symbol_table *symbols; + + bool es_shader; + unsigned language_version; + const char *version_string; + enum _mesa_glsl_parser_targets target; + + /** + * Printable list of GLSL versions supported by the current context + * + * \note + * This string should probably be generated per-context instead of per + * invokation of the compiler. This should be changed when the method of + * tracking supported GLSL versions changes. + */ + const char *supported_version_string; + + /** + * Implementation defined limits that affect built-in variables, etc. + * + * \sa struct gl_constants (in mtypes.h) + */ + struct { + /* 1.10 */ + unsigned MaxLights; + unsigned MaxClipPlanes; + unsigned MaxTextureUnits; + unsigned MaxTextureCoords; + unsigned MaxVertexAttribs; + unsigned MaxVertexUniformComponents; + unsigned MaxVaryingFloats; + unsigned MaxVertexTextureImageUnits; + unsigned MaxCombinedTextureImageUnits; + unsigned MaxTextureImageUnits; + unsigned MaxFragmentUniformComponents; + + /* ARB_draw_buffers */ + unsigned MaxDrawBuffers; + + /** + * Set of GLSL versions supported by the current context + * + * Knowing that version X is supported doesn't mean that versions before + * X are also supported. Version 1.00 is only supported in an ES2 + * context or when GL_ARB_ES2_compatibility is supported. In an OpenGL + * 3.0 "forward compatible" context, GLSL 1.10 and 1.20 are \b not + * supported. + */ + /*@{*/ + unsigned GLSL_100ES:1; + unsigned GLSL_110:1; + unsigned GLSL_120:1; + unsigned GLSL_130:1; + /*@}*/ + } Const; + + /** + * During AST to IR conversion, pointer to current IR function + * + * Will be \c NULL whenever the AST to IR conversion is not inside a + * function definition. + */ + class ir_function_signature *current_function; + + /** + * During AST to IR conversion, pointer to the toplevel IR + * instruction list being generated. + */ + exec_list *toplevel_ir; + + /** Have we found a return statement in this function? */ + bool found_return; + + /** Was there an error during compilation? */ + bool error; + + /** + * Are all shader inputs / outputs invariant? + * + * This is set when the 'STDGL invariant(all)' pragma is used. + */ + bool all_invariant; + + /** Loop or switch statement containing the current instructions. */ + class ir_instruction *loop_or_switch_nesting; + class ast_iteration_statement *loop_or_switch_nesting_ast; + + /** List of structures defined in user code. */ + const glsl_type **user_structures; + unsigned num_user_structures; + + char *info_log; + + /** + * \name Enable bits for GLSL extensions + */ + /*@{*/ + bool ARB_draw_buffers_enable; + bool ARB_draw_buffers_warn; + bool ARB_draw_instanced_enable; + bool ARB_draw_instanced_warn; + bool ARB_explicit_attrib_location_enable; + bool ARB_explicit_attrib_location_warn; + bool ARB_fragment_coord_conventions_enable; + bool ARB_fragment_coord_conventions_warn; + bool ARB_texture_rectangle_enable; + bool ARB_texture_rectangle_warn; + bool EXT_texture_array_enable; + bool EXT_texture_array_warn; + bool ARB_shader_texture_lod_enable; + bool ARB_shader_texture_lod_warn; + bool EXT_shader_texture_lod_enable; + bool EXT_shader_texture_lod_warn; + bool ARB_shader_stencil_export_enable; + bool ARB_shader_stencil_export_warn; + bool AMD_conservative_depth_enable; + bool AMD_conservative_depth_warn; + bool AMD_shader_stencil_export_enable; + bool AMD_shader_stencil_export_warn; + bool OES_texture_3D_enable; + bool OES_texture_3D_warn; + bool OES_standard_derivatives_enable; + bool OES_standard_derivatives_warn; + /*@}*/ + + /** Extensions supported by the OpenGL implementation. */ + const struct gl_extensions *extensions; + + /** Shaders containing built-in functions that are used for linking. */ + struct gl_shader *builtins_to_link[16]; + unsigned num_builtins_to_link; +}; + +typedef struct YYLTYPE { + int first_line; + int first_column; + int last_line; + int last_column; + unsigned source; +} YYLTYPE; +# define YYLTYPE_IS_DECLARED 1 +# define YYLTYPE_IS_TRIVIAL 1 + +# define YYLLOC_DEFAULT(Current, Rhs, N) \ +do { \ + if (N) \ + { \ + (Current).first_line = YYRHSLOC(Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC(Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC(Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC(Rhs, N).last_column; \ + } \ + else \ + { \ + (Current).first_line = (Current).last_line = \ + YYRHSLOC(Rhs, 0).last_line; \ + (Current).first_column = (Current).last_column = \ + YYRHSLOC(Rhs, 0).last_column; \ + } \ + (Current).source = 0; \ +} while (0) + +extern void _mesa_glsl_error(YYLTYPE *locp, _mesa_glsl_parse_state *state, + const char *fmt, ...); + +/** + * Emit a warning to the shader log + * + * \sa _mesa_glsl_error + */ +extern void _mesa_glsl_warning(const YYLTYPE *locp, + _mesa_glsl_parse_state *state, + const char *fmt, ...); + +extern void _mesa_glsl_lexer_ctor(struct _mesa_glsl_parse_state *state, + const char *string); + +extern void _mesa_glsl_lexer_dtor(struct _mesa_glsl_parse_state *state); + +union YYSTYPE; +extern int _mesa_glsl_lex(union YYSTYPE *yylval, YYLTYPE *yylloc, + void *scanner); + +extern int _mesa_glsl_parse(struct _mesa_glsl_parse_state *); + +/** + * Process elements of the #extension directive + * + * \return + * If \c name and \c behavior are valid, \c true is returned. Otherwise + * \c false is returned. + */ +extern bool _mesa_glsl_process_extension(const char *name, YYLTYPE *name_locp, + const char *behavior, + YYLTYPE *behavior_locp, + _mesa_glsl_parse_state *state); + +/** + * Get the textual name of the specified shader target + */ +extern const char * +_mesa_glsl_shader_target_name(enum _mesa_glsl_parser_targets target); + + +#endif /* __cplusplus */ + + +/* + * These definitions apply to C and C++ + */ +#ifdef __cplusplus +extern "C" { +#endif + +extern int preprocess(void *ctx, const char **shader, char **info_log, + const struct gl_extensions *extensions, int api); + +extern void _mesa_destroy_shader_compiler(void); +extern void _mesa_destroy_shader_compiler_caches(void); + +#ifdef __cplusplus +} +#endif + + +#endif /* GLSL_PARSER_EXTRAS_H */ diff --git a/3rdparty/glsl-optimizer/src/glsl/glsl_symbol_table.cpp b/3rdparty/glsl-optimizer/src/glsl/glsl_symbol_table.cpp new file mode 100644 index 000000000..bcb65d301 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/glsl_symbol_table.cpp @@ -0,0 +1,165 @@ +/* -*- c++ -*- */ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include "glsl_symbol_table.h" + +class symbol_table_entry { +public: + /* Callers of this ralloc-based new need not call delete. It's + * easier to just ralloc_free 'ctx' (or any of its ancestors). */ + static void* operator new(size_t size, void *ctx) + { + void *entry = ralloc_size(ctx, size); + assert(entry != NULL); + return entry; + } + + /* If the user *does* call delete, that's OK, we will just ralloc_free. */ + static void operator delete(void *entry) + { + ralloc_free(entry); + } + + symbol_table_entry(ir_variable *v) : v(v), f(0), t(0) {} + symbol_table_entry(ir_function *f) : v(0), f(f), t(0) {} + symbol_table_entry(const glsl_type *t) : v(0), f(0), t(t) {} + + ir_variable *v; + ir_function *f; + const glsl_type *t; +}; + +glsl_symbol_table::glsl_symbol_table() +{ + this->language_version = 120; + this->table = _mesa_symbol_table_ctor(); + this->mem_ctx = ralloc_context(NULL); +} + +glsl_symbol_table::~glsl_symbol_table() +{ + _mesa_symbol_table_dtor(table); + ralloc_free(mem_ctx); +} + +void glsl_symbol_table::push_scope() +{ + _mesa_symbol_table_push_scope(table); +} + +void glsl_symbol_table::pop_scope() +{ + _mesa_symbol_table_pop_scope(table); +} + +bool glsl_symbol_table::name_declared_this_scope(const char *name) +{ + return _mesa_symbol_table_symbol_scope(table, -1, name) == 0; +} + +bool glsl_symbol_table::add_variable(ir_variable *v) +{ + if (this->language_version == 110) { + /* In 1.10, functions and variables have separate namespaces. */ + symbol_table_entry *existing = get_entry(v->name); + if (name_declared_this_scope(v->name)) { + /* If there's already an existing function (not a constructor!) in + * the current scope, just update the existing entry to include 'v'. + */ + if (existing->v == NULL && existing->t == NULL) { + existing->v = v; + return true; + } + } else { + /* If not declared at this scope, add a new entry. But if an existing + * entry includes a function, propagate that to this block - otherwise + * the new variable declaration would shadow the function. + */ + symbol_table_entry *entry = new(mem_ctx) symbol_table_entry(v); + if (existing != NULL) + entry->f = existing->f; + int added = _mesa_symbol_table_add_symbol(table, -1, v->name, entry); + assert(added == 0); + (void)added; + return true; + } + return false; + } + + /* 1.20+ rules: */ + symbol_table_entry *entry = new(mem_ctx) symbol_table_entry(v); + return _mesa_symbol_table_add_symbol(table, -1, v->name, entry) == 0; +} + +bool glsl_symbol_table::add_type(const char *name, const glsl_type *t) +{ + symbol_table_entry *entry = new(mem_ctx) symbol_table_entry(t); + return _mesa_symbol_table_add_symbol(table, -1, name, entry) == 0; +} + +bool glsl_symbol_table::add_function(ir_function *f) +{ + if (this->language_version == 110 && name_declared_this_scope(f->name)) { + /* In 1.10, functions and variables have separate namespaces. */ + symbol_table_entry *existing = get_entry(f->name); + if ((existing->f == NULL) && (existing->t == NULL)) { + existing->f = f; + return true; + } + } + symbol_table_entry *entry = new(mem_ctx) symbol_table_entry(f); + return _mesa_symbol_table_add_symbol(table, -1, f->name, entry) == 0; +} + +void glsl_symbol_table::add_global_function(ir_function *f) +{ + symbol_table_entry *entry = new(mem_ctx) symbol_table_entry(f); + int added = _mesa_symbol_table_add_global_symbol(table, -1, f->name, entry); + assert(added == 0); + (void)added; +} + +ir_variable *glsl_symbol_table::get_variable(const char *name) +{ + symbol_table_entry *entry = get_entry(name); + return entry != NULL ? entry->v : NULL; +} + +const glsl_type *glsl_symbol_table::get_type(const char *name) +{ + symbol_table_entry *entry = get_entry(name); + return entry != NULL ? entry->t : NULL; +} + +ir_function *glsl_symbol_table::get_function(const char *name) +{ + symbol_table_entry *entry = get_entry(name); + return entry != NULL ? entry->f : NULL; +} + +symbol_table_entry *glsl_symbol_table::get_entry(const char *name) +{ + return (symbol_table_entry *) + _mesa_symbol_table_find_symbol(table, -1, name); +} diff --git a/3rdparty/glsl-optimizer/src/glsl/glsl_symbol_table.h b/3rdparty/glsl-optimizer/src/glsl/glsl_symbol_table.h new file mode 100644 index 000000000..637bc033b --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/glsl_symbol_table.h @@ -0,0 +1,124 @@ +/* -*- c++ -*- */ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#pragma once +#ifndef GLSL_SYMBOL_TABLE +#define GLSL_SYMBOL_TABLE + +#include + +extern "C" { +#include "program/symbol_table.h" +} +#include "ir.h" +#include "glsl_types.h" + +class symbol_table_entry; + +/** + * Facade class for _mesa_symbol_table + * + * Wraps the existing \c _mesa_symbol_table data structure to enforce some + * type safe and some symbol table invariants. + */ +struct glsl_symbol_table { +private: + static void + _glsl_symbol_table_destructor (glsl_symbol_table *table) + { + table->~glsl_symbol_table(); + } + +public: + /* Callers of this ralloc-based new need not call delete. It's + * easier to just ralloc_free 'ctx' (or any of its ancestors). */ + static void* operator new(size_t size, void *ctx) + { + void *table; + + table = ralloc_size(ctx, size); + assert(table != NULL); + + ralloc_set_destructor(table, (void (*)(void*)) _glsl_symbol_table_destructor); + + return table; + } + + /* If the user *does* call delete, that's OK, we will just + * ralloc_free in that case. Here, C++ will have already called the + * destructor so tell ralloc not to do that again. */ + static void operator delete(void *table) + { + ralloc_set_destructor(table, NULL); + ralloc_free(table); + } + + glsl_symbol_table(); + ~glsl_symbol_table(); + + unsigned int language_version; + + void push_scope(); + void pop_scope(); + + /** + * Determine whether a name was declared at the current scope + */ + bool name_declared_this_scope(const char *name); + + /** + * \name Methods to add symbols to the table + * + * There is some temptation to rename all these functions to \c add_symbol + * or similar. However, this breaks symmetry with the getter functions and + * reduces the clarity of the intention of code that uses these methods. + */ + /*@{*/ + bool add_variable(ir_variable *v); + bool add_type(const char *name, const glsl_type *t); + bool add_function(ir_function *f); + /*@}*/ + + /** + * Add an function at global scope without checking for scoping conflicts. + */ + void add_global_function(ir_function *f); + + /** + * \name Methods to get symbols from the table + */ + /*@{*/ + ir_variable *get_variable(const char *name); + const glsl_type *get_type(const char *name); + ir_function *get_function(const char *name); + /*@}*/ + +private: + symbol_table_entry *get_entry(const char *name); + + struct _mesa_symbol_table *table; + void *mem_ctx; +}; + +#endif /* GLSL_SYMBOL_TABLE */ diff --git a/3rdparty/glsl-optimizer/src/glsl/glsl_types.cpp b/3rdparty/glsl-optimizer/src/glsl/glsl_types.cpp new file mode 100644 index 000000000..daf951d87 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/glsl_types.cpp @@ -0,0 +1,558 @@ +/* + * Copyright © 2009 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include +#include +#include "main/core.h" /* for Elements */ +#include "glsl_symbol_table.h" +#include "glsl_parser_extras.h" +#include "glsl_types.h" +#include "builtin_types.h" +extern "C" { +#include "program/hash_table.h" +} + +hash_table *glsl_type::array_types = NULL; +hash_table *glsl_type::record_types = NULL; +void *glsl_type::mem_ctx = NULL; + +void +glsl_type::init_ralloc_type_ctx(void) +{ + if (glsl_type::mem_ctx == NULL) { + glsl_type::mem_ctx = ralloc_autofree_context(); + assert(glsl_type::mem_ctx != NULL); + } +} + +glsl_type::glsl_type(GLenum gl_type, + glsl_base_type base_type, unsigned vector_elements, + unsigned matrix_columns, const char *name) : + gl_type(gl_type), + base_type(base_type), + sampler_dimensionality(0), sampler_shadow(0), sampler_array(0), + sampler_type(0), + vector_elements(vector_elements), matrix_columns(matrix_columns), + length(0) +{ + init_ralloc_type_ctx(); + this->name = ralloc_strdup(this->mem_ctx, name); + /* Neither dimension is zero or both dimensions are zero. + */ + assert((vector_elements == 0) == (matrix_columns == 0)); + memset(& fields, 0, sizeof(fields)); +} + +glsl_type::glsl_type(GLenum gl_type, + enum glsl_sampler_dim dim, bool shadow, bool array, + unsigned type, const char *name) : + gl_type(gl_type), + base_type(GLSL_TYPE_SAMPLER), + sampler_dimensionality(dim), sampler_shadow(shadow), + sampler_array(array), sampler_type(type), + vector_elements(0), matrix_columns(0), + length(0) +{ + init_ralloc_type_ctx(); + this->name = ralloc_strdup(this->mem_ctx, name); + memset(& fields, 0, sizeof(fields)); +} + +glsl_type::glsl_type(const glsl_struct_field *fields, unsigned num_fields, + const char *name) : + base_type(GLSL_TYPE_STRUCT), + sampler_dimensionality(0), sampler_shadow(0), sampler_array(0), + sampler_type(0), + vector_elements(0), matrix_columns(0), + length(num_fields) +{ + unsigned int i; + + init_ralloc_type_ctx(); + this->name = ralloc_strdup(this->mem_ctx, name); + this->fields.structure = ralloc_array(this->mem_ctx, + glsl_struct_field, length); + for (i = 0; i < length; i++) { + this->fields.structure[i].type = fields[i].type; + this->fields.structure[i].name = ralloc_strdup(this->fields.structure, + fields[i].name); + this->fields.structure[i].precision = fields[i].precision; + } +} + +static void +add_types_to_symbol_table(glsl_symbol_table *symtab, + const struct glsl_type *types, + unsigned num_types, bool warn) +{ + (void) warn; + + for (unsigned i = 0; i < num_types; i++) { + symtab->add_type(types[i].name, & types[i]); + } +} + +bool +glsl_type::contains_sampler() const +{ + if (this->is_array()) { + return this->fields.array->contains_sampler(); + } else if (this->is_record()) { + for (unsigned int i = 0; i < this->length; i++) { + if (this->fields.structure[i].type->contains_sampler()) + return true; + } + return false; + } else { + return this->is_sampler(); + } +} + +void +glsl_type::generate_100ES_types(glsl_symbol_table *symtab) +{ + add_types_to_symbol_table(symtab, builtin_core_types, + Elements(builtin_core_types), + false); + add_types_to_symbol_table(symtab, builtin_structure_types, + Elements(builtin_structure_types), + false); + add_types_to_symbol_table(symtab, void_type, 1, false); +} + +void +glsl_type::generate_110_types(glsl_symbol_table *symtab) +{ + generate_100ES_types(symtab); + + add_types_to_symbol_table(symtab, builtin_110_types, + Elements(builtin_110_types), + false); + add_types_to_symbol_table(symtab, &_sampler3D_type, 1, false); + add_types_to_symbol_table(symtab, builtin_110_deprecated_structure_types, + Elements(builtin_110_deprecated_structure_types), + false); +} + + +void +glsl_type::generate_120_types(glsl_symbol_table *symtab) +{ + generate_110_types(symtab); + + add_types_to_symbol_table(symtab, builtin_120_types, + Elements(builtin_120_types), false); +} + + +void +glsl_type::generate_130_types(glsl_symbol_table *symtab) +{ + generate_120_types(symtab); + + add_types_to_symbol_table(symtab, builtin_130_types, + Elements(builtin_130_types), false); + generate_EXT_texture_array_types(symtab, false); +} + + +void +glsl_type::generate_ARB_texture_rectangle_types(glsl_symbol_table *symtab, + bool warn) +{ + add_types_to_symbol_table(symtab, builtin_ARB_texture_rectangle_types, + Elements(builtin_ARB_texture_rectangle_types), + warn); +} + + +void +glsl_type::generate_EXT_texture_array_types(glsl_symbol_table *symtab, + bool warn) +{ + add_types_to_symbol_table(symtab, builtin_EXT_texture_array_types, + Elements(builtin_EXT_texture_array_types), + warn); +} + + +void +glsl_type::generate_OES_texture_3D_types(glsl_symbol_table *symtab, bool warn) +{ + add_types_to_symbol_table(symtab, &_sampler3D_type, 1, warn); +} + + +void +_mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state) +{ + switch (state->language_version) { + case 100: + assert(state->es_shader); + glsl_type::generate_100ES_types(state->symbols); + break; + case 110: + glsl_type::generate_110_types(state->symbols); + break; + case 120: + glsl_type::generate_120_types(state->symbols); + break; + case 130: + glsl_type::generate_130_types(state->symbols); + break; + default: + /* error */ + break; + } + + if (state->ARB_texture_rectangle_enable) { + glsl_type::generate_ARB_texture_rectangle_types(state->symbols, + state->ARB_texture_rectangle_warn); + } + if (state->OES_texture_3D_enable && state->language_version == 100) { + glsl_type::generate_OES_texture_3D_types(state->symbols, + state->OES_texture_3D_warn); + } + + if (state->EXT_texture_array_enable && state->language_version < 130) { + // These are already included in 130; don't create twice. + glsl_type::generate_EXT_texture_array_types(state->symbols, + state->EXT_texture_array_warn); + } +} + + +const glsl_type *glsl_type::get_base_type() const +{ + switch (base_type) { + case GLSL_TYPE_UINT: + return uint_type; + case GLSL_TYPE_INT: + return int_type; + case GLSL_TYPE_FLOAT: + return float_type; + case GLSL_TYPE_BOOL: + return bool_type; + default: + return error_type; + } +} + + +void +_mesa_glsl_release_types(void) +{ + if (glsl_type::array_types != NULL) { + hash_table_dtor(glsl_type::array_types); + glsl_type::array_types = NULL; + } + + if (glsl_type::record_types != NULL) { + hash_table_dtor(glsl_type::record_types); + glsl_type::record_types = NULL; + } +} + + +glsl_type::glsl_type(const glsl_type *array, unsigned length) : + base_type(GLSL_TYPE_ARRAY), + sampler_dimensionality(0), sampler_shadow(0), sampler_array(0), + sampler_type(0), + vector_elements(0), matrix_columns(0), + name(NULL), length(length) +{ + this->fields.array = array; + /* Inherit the gl type of the base. The GL type is used for + * uniform/statevar handling in Mesa and the arrayness of the type + * is represented by the size rather than the type. + */ + this->gl_type = array->gl_type; + + /* Allow a maximum of 10 characters for the array size. This is enough + * for 32-bits of ~0. The extra 3 are for the '[', ']', and terminating + * NUL. + */ + const unsigned name_length = strlen(array->name) + 10 + 3; + char *const n = (char *) ralloc_size(this->mem_ctx, name_length); + + if (length == 0) + snprintf(n, name_length, "%s[]", array->name); + else + snprintf(n, name_length, "%s[%u]", array->name, length); + + this->name = n; +} + + +const glsl_type * +glsl_type::get_instance(unsigned base_type, unsigned rows, unsigned columns) +{ + if (base_type == GLSL_TYPE_VOID) + return void_type; + + if ((rows < 1) || (rows > 4) || (columns < 1) || (columns > 4)) + return error_type; + + /* Treat GLSL vectors as Nx1 matrices. + */ + if (columns == 1) { + switch (base_type) { + case GLSL_TYPE_UINT: + return uint_type + (rows - 1); + case GLSL_TYPE_INT: + return int_type + (rows - 1); + case GLSL_TYPE_FLOAT: + return float_type + (rows - 1); + case GLSL_TYPE_BOOL: + return bool_type + (rows - 1); + default: + return error_type; + } + } else { + if ((base_type != GLSL_TYPE_FLOAT) || (rows == 1)) + return error_type; + + /* GLSL matrix types are named mat{COLUMNS}x{ROWS}. Only the following + * combinations are valid: + * + * 1 2 3 4 + * 1 + * 2 x x x + * 3 x x x + * 4 x x x + */ +#define IDX(c,r) (((c-1)*3) + (r-1)) + + switch (IDX(columns, rows)) { + case IDX(2,2): return mat2_type; + case IDX(2,3): return mat2x3_type; + case IDX(2,4): return mat2x4_type; + case IDX(3,2): return mat3x2_type; + case IDX(3,3): return mat3_type; + case IDX(3,4): return mat3x4_type; + case IDX(4,2): return mat4x2_type; + case IDX(4,3): return mat4x3_type; + case IDX(4,4): return mat4_type; + default: return error_type; + } + } + + assert(!"Should not get here."); + return error_type; +} + + +const glsl_type * +glsl_type::get_array_instance(const glsl_type *base, unsigned array_size) +{ + + if (array_types == NULL) { + array_types = hash_table_ctor(64, hash_table_string_hash, + hash_table_string_compare); + } + + /* Generate a name using the base type pointer in the key. This is + * done because the name of the base type may not be unique across + * shaders. For example, two shaders may have different record types + * named 'foo'. + */ + char key[128]; + snprintf(key, sizeof(key), "%p[%u]", (void *) base, array_size); + + const glsl_type *t = (glsl_type *) hash_table_find(array_types, key); + if (t == NULL) { + t = new glsl_type(base, array_size); + + hash_table_insert(array_types, (void *) t, ralloc_strdup(mem_ctx, key)); + } + + assert(t->base_type == GLSL_TYPE_ARRAY); + assert(t->length == array_size); + assert(t->fields.array == base); + + return t; +} + + +int +glsl_type::record_key_compare(const void *a, const void *b) +{ + const glsl_type *const key1 = (glsl_type *) a; + const glsl_type *const key2 = (glsl_type *) b; + + /* Return zero is the types match (there is zero difference) or non-zero + * otherwise. + */ + if (strcmp(key1->name, key2->name) != 0) + return 1; + + if (key1->length != key2->length) + return 1; + + for (unsigned i = 0; i < key1->length; i++) { + if (key1->fields.structure[i].type != key2->fields.structure[i].type) + return 1; + if (key1->fields.structure[i].precision != key2->fields.structure[i].precision) + return 1; + if (strcmp(key1->fields.structure[i].name, + key2->fields.structure[i].name) != 0) + return 1; + } + + return 0; +} + + +unsigned +glsl_type::record_key_hash(const void *a) +{ + const glsl_type *const key = (glsl_type *) a; + char hash_key[128]; + unsigned size = 0; + + size = snprintf(hash_key, sizeof(hash_key), "%08x", key->length); + + for (unsigned i = 0; i < key->length; i++) { + if (size >= sizeof(hash_key)) + break; + + size += snprintf(& hash_key[size], sizeof(hash_key) - size, + "%p", (void *) key->fields.structure[i].type); + } + + return hash_table_string_hash(& hash_key); +} + + +const glsl_type * +glsl_type::get_record_instance(const glsl_struct_field *fields, + unsigned num_fields, + const char *name) +{ + const glsl_type key(fields, num_fields, name); + + if (record_types == NULL) { + record_types = hash_table_ctor(64, record_key_hash, record_key_compare); + } + + const glsl_type *t = (glsl_type *) hash_table_find(record_types, & key); + if (t == NULL) { + t = new glsl_type(fields, num_fields, name); + + hash_table_insert(record_types, (void *) t, t); + } + + assert(t->base_type == GLSL_TYPE_STRUCT); + assert(t->length == num_fields); + assert(strcmp(t->name, name) == 0); + + return t; +} + + +const glsl_type * +glsl_type::field_type(const char *name) const +{ + if (this->base_type != GLSL_TYPE_STRUCT) + return error_type; + + for (unsigned i = 0; i < this->length; i++) { + if (strcmp(name, this->fields.structure[i].name) == 0) + return this->fields.structure[i].type; + } + + return error_type; +} + +const glsl_precision +glsl_type::field_precision(const char *name) const +{ + if (this->base_type != GLSL_TYPE_STRUCT) + return glsl_precision_undefined; + + for (unsigned i = 0; i < this->length; i++) { + if (strcmp(name, this->fields.structure[i].name) == 0) + return this->fields.structure[i].precision; + } + + return glsl_precision_undefined; +} + + +int +glsl_type::field_index(const char *name) const +{ + if (this->base_type != GLSL_TYPE_STRUCT) + return -1; + + for (unsigned i = 0; i < this->length; i++) { + if (strcmp(name, this->fields.structure[i].name) == 0) + return i; + } + + return -1; +} + + +unsigned +glsl_type::component_slots() const +{ + switch (this->base_type) { + case GLSL_TYPE_UINT: + case GLSL_TYPE_INT: + case GLSL_TYPE_FLOAT: + case GLSL_TYPE_BOOL: + return this->components(); + + case GLSL_TYPE_STRUCT: { + unsigned size = 0; + + for (unsigned i = 0; i < this->length; i++) + size += this->fields.structure[i].type->component_slots(); + + return size; + } + + case GLSL_TYPE_ARRAY: + return this->length * this->fields.array->component_slots(); + + default: + return 0; + } +} + +bool +glsl_type::can_implicitly_convert_to(const glsl_type *desired) const +{ + if (this == desired) + return true; + + /* There is no conversion among matrix types. */ + if (this->matrix_columns > 1 || desired->matrix_columns > 1) + return false; + + /* int and uint can be converted to float. */ + return desired->is_float() + && this->is_integer() + && this->vector_elements == desired->vector_elements; +} diff --git a/3rdparty/glsl-optimizer/src/glsl/glsl_types.h b/3rdparty/glsl-optimizer/src/glsl/glsl_types.h new file mode 100644 index 000000000..a20ff9375 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/glsl_types.h @@ -0,0 +1,528 @@ +/* -*- c++ -*- */ +/* + * Copyright © 2009 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#pragma once +#ifndef GLSL_TYPES_H +#define GLSL_TYPES_H + +#include +#include + +extern "C" { +#include "GL/gl.h" +} + +#include "ralloc.h" + +struct _mesa_glsl_parse_state; +struct glsl_symbol_table; + +extern "C" void +_mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state); + +extern "C" void +_mesa_glsl_release_types(void); + +enum glsl_base_type { + GLSL_TYPE_UINT = 0, + GLSL_TYPE_INT, + GLSL_TYPE_FLOAT, + GLSL_TYPE_BOOL, + GLSL_TYPE_SAMPLER, + GLSL_TYPE_STRUCT, + GLSL_TYPE_ARRAY, + GLSL_TYPE_VOID, + GLSL_TYPE_ERROR +}; + +enum glsl_sampler_dim { + GLSL_SAMPLER_DIM_1D = 0, + GLSL_SAMPLER_DIM_2D, + GLSL_SAMPLER_DIM_3D, + GLSL_SAMPLER_DIM_CUBE, + GLSL_SAMPLER_DIM_RECT, + GLSL_SAMPLER_DIM_BUF +}; + +enum glsl_precision { + glsl_precision_high = 0, + glsl_precision_medium, + glsl_precision_low, + glsl_precision_undefined, +}; + +struct glsl_type { + GLenum gl_type; + glsl_base_type base_type; + + unsigned sampler_dimensionality:3; /**< \see glsl_sampler_dim */ + unsigned sampler_shadow:1; + unsigned sampler_array:1; + unsigned sampler_type:2; /**< Type of data returned using this sampler. + * only \c GLSL_TYPE_FLOAT, \c GLSL_TYPE_INT, + * and \c GLSL_TYPE_UINT are valid. + */ + + /* Callers of this ralloc-based new need not call delete. It's + * easier to just ralloc_free 'mem_ctx' (or any of its ancestors). */ + static void* operator new(size_t size) + { + if (glsl_type::mem_ctx == NULL) { + glsl_type::mem_ctx = ralloc_context(NULL); + assert(glsl_type::mem_ctx != NULL); + } + + void *type; + + type = ralloc_size(glsl_type::mem_ctx, size); + assert(type != NULL); + + return type; + } + + /* If the user *does* call delete, that's OK, we will just + * ralloc_free in that case. */ + static void operator delete(void *type) + { + ralloc_free(type); + } + + /** + * \name Vector and matrix element counts + * + * For scalars, each of these values will be 1. For non-numeric types + * these will be 0. + */ + /*@{*/ + unsigned vector_elements:3; /**< 1, 2, 3, or 4 vector elements. */ + unsigned matrix_columns:3; /**< 1, 2, 3, or 4 matrix columns. */ + /*@}*/ + + /** + * Name of the data type + * + * This may be \c NULL for anonymous structures, for arrays, or for + * function types. + */ + const char *name; + + /** + * For \c GLSL_TYPE_ARRAY, this is the length of the array. For + * \c GLSL_TYPE_STRUCT, it is the number of elements in the structure and + * the number of values pointed to by \c fields.structure (below). + */ + unsigned length; + + /** + * Subtype of composite data types. + */ + union { + const struct glsl_type *array; /**< Type of array elements. */ + const struct glsl_type *parameters; /**< Parameters to function. */ + struct glsl_struct_field *structure; /**< List of struct fields. */ + } fields; + + + /** + * \name Pointers to various public type singletons + */ + /*@{*/ + static const glsl_type *const error_type; + static const glsl_type *const void_type; + static const glsl_type *const int_type; + static const glsl_type *const ivec4_type; + static const glsl_type *const uint_type; + static const glsl_type *const uvec2_type; + static const glsl_type *const uvec3_type; + static const glsl_type *const uvec4_type; + static const glsl_type *const float_type; + static const glsl_type *const vec2_type; + static const glsl_type *const vec3_type; + static const glsl_type *const vec4_type; + static const glsl_type *const bool_type; + static const glsl_type *const mat2_type; + static const glsl_type *const mat2x3_type; + static const glsl_type *const mat2x4_type; + static const glsl_type *const mat3x2_type; + static const glsl_type *const mat3_type; + static const glsl_type *const mat3x4_type; + static const glsl_type *const mat4x2_type; + static const glsl_type *const mat4x3_type; + static const glsl_type *const mat4_type; + /*@}*/ + + + /** + * For numeric and boolean derrived types returns the basic scalar type + * + * If the type is a numeric or boolean scalar, vector, or matrix type, + * this function gets the scalar type of the individual components. For + * all other types, including arrays of numeric or boolean types, the + * error type is returned. + */ + const glsl_type *get_base_type() const; + + /** + * Query the type of elements in an array + * + * \return + * Pointer to the type of elements in the array for array types, or \c NULL + * for non-array types. + */ + const glsl_type *element_type() const + { + return is_array() ? fields.array : NULL; + } + + /** + * Get the instance of a built-in scalar, vector, or matrix type + */ + static const glsl_type *get_instance(unsigned base_type, unsigned rows, + unsigned columns); + + /** + * Get the instance of an array type + */ + static const glsl_type *get_array_instance(const glsl_type *base, + unsigned elements); + + /** + * Get the instance of a record type + */ + static const glsl_type *get_record_instance(const glsl_struct_field *fields, + unsigned num_fields, + const char *name); + + /** + * Query the total number of scalars that make up a scalar, vector or matrix + */ + unsigned components() const + { + return vector_elements * matrix_columns; + } + + /** + * Calculate the number of components slots required to hold this type + * + * This is used to determine how many uniform or varying locations a type + * might occupy. + */ + unsigned component_slots() const; + + /** + * \brief Can this type be implicitly converted to another? + * + * \return True if the types are identical or if this type can be converted + * to \c desired according to Section 4.1.10 of the GLSL spec. + * + * \verbatim + * From page 25 (31 of the pdf) of the GLSL 1.50 spec, Section 4.1.10 + * Implicit Conversions: + * + * In some situations, an expression and its type will be implicitly + * converted to a different type. The following table shows all allowed + * implicit conversions: + * + * Type of expression | Can be implicitly converted to + * -------------------------------------------------- + * int float + * uint + * + * ivec2 vec2 + * uvec2 + * + * ivec3 vec3 + * uvec3 + * + * ivec4 vec4 + * uvec4 + * + * There are no implicit array or structure conversions. For example, + * an array of int cannot be implicitly converted to an array of float. + * There are no implicit conversions between signed and unsigned + * integers. + * \endverbatim + */ + bool can_implicitly_convert_to(const glsl_type *desired) const; + + /** + * Query whether or not a type is a scalar (non-vector and non-matrix). + */ + bool is_scalar() const + { + return (vector_elements == 1) + && (base_type >= GLSL_TYPE_UINT) + && (base_type <= GLSL_TYPE_BOOL); + } + + /** + * Query whether or not a type is a vector + */ + bool is_vector() const + { + return (vector_elements > 1) + && (matrix_columns == 1) + && (base_type >= GLSL_TYPE_UINT) + && (base_type <= GLSL_TYPE_BOOL); + } + + /** + * Query whether or not a type is a matrix + */ + bool is_matrix() const + { + /* GLSL only has float matrices. */ + return (matrix_columns > 1) && (base_type == GLSL_TYPE_FLOAT); + } + + /** + * Query whether or not a type is a non-array numeric type + */ + bool is_numeric() const + { + return (base_type >= GLSL_TYPE_UINT) && (base_type <= GLSL_TYPE_FLOAT); + } + + /** + * Query whether or not a type is an integral type + */ + bool is_integer() const + { + return (base_type == GLSL_TYPE_UINT) || (base_type == GLSL_TYPE_INT); + } + + /** + * Query whether or not a type is a float type + */ + bool is_float() const + { + return base_type == GLSL_TYPE_FLOAT; + } + + /** + * Query whether or not a type is a non-array boolean type + */ + bool is_boolean() const + { + return base_type == GLSL_TYPE_BOOL; + } + + /** + * Query whether or not a type is a sampler + */ + bool is_sampler() const + { + return base_type == GLSL_TYPE_SAMPLER; + } + + /** + * Query whether or not type is a sampler, or for struct and array + * types, contains a sampler. + */ + bool contains_sampler() const; + + /** + * Query whether or not a type is an array + */ + bool is_array() const + { + return base_type == GLSL_TYPE_ARRAY; + } + + /** + * Query whether or not a type is a record + */ + bool is_record() const + { + return base_type == GLSL_TYPE_STRUCT; + } + + /** + * Query whether or not a type is the void type singleton. + */ + bool is_void() const + { + return base_type == GLSL_TYPE_VOID; + } + + /** + * Query whether or not a type is the error type singleton. + */ + bool is_error() const + { + return base_type == GLSL_TYPE_ERROR; + } + + /** + * Query the full type of a matrix row + * + * \return + * If the type is not a matrix, \c glsl_type::error_type is returned. + * Otherwise a type matching the rows of the matrix is returned. + */ + const glsl_type *row_type() const + { + return is_matrix() + ? get_instance(base_type, matrix_columns, 1) + : error_type; + } + + /** + * Query the full type of a matrix column + * + * \return + * If the type is not a matrix, \c glsl_type::error_type is returned. + * Otherwise a type matching the columns of the matrix is returned. + */ + const glsl_type *column_type() const + { + return is_matrix() + ? get_instance(base_type, vector_elements, 1) + : error_type; + } + + + /** + * Get the type of a structure field + * + * \return + * Pointer to the type of the named field. If the type is not a structure + * or the named field does not exist, \c glsl_type::error_type is returned. + */ + const glsl_type *field_type(const char *name) const; + + const glsl_precision field_precision(const char *name) const; + + + /** + * Get the location of a filed within a record type + */ + int field_index(const char *name) const; + + + /** + * Query the number of elements in an array type + * + * \return + * The number of elements in the array for array types or -1 for non-array + * types. If the number of elements in the array has not yet been declared, + * zero is returned. + */ + int array_size() const + { + return is_array() ? length : -1; + } + +private: + /** + * ralloc context for all glsl_type allocations + * + * Set on the first call to \c glsl_type::new. + */ + static void *mem_ctx; + + void init_ralloc_type_ctx(void); + + /** Constructor for vector and matrix types */ + glsl_type(GLenum gl_type, + glsl_base_type base_type, unsigned vector_elements, + unsigned matrix_columns, const char *name); + + /** Constructor for sampler types */ + glsl_type(GLenum gl_type, + enum glsl_sampler_dim dim, bool shadow, bool array, + unsigned type, const char *name); + + /** Constructor for record types */ + glsl_type(const glsl_struct_field *fields, unsigned num_fields, + const char *name); + + /** Constructor for array types */ + glsl_type(const glsl_type *array, unsigned length); + + /** Hash table containing the known array types. */ + static struct hash_table *array_types; + + /** Hash table containing the known record types. */ + static struct hash_table *record_types; + + static int record_key_compare(const void *a, const void *b); + static unsigned record_key_hash(const void *key); + + /** + * \name Pointers to various type singletons + */ + /*@{*/ + static const glsl_type _error_type; + static const glsl_type _void_type; + static const glsl_type _sampler3D_type; + static const glsl_type builtin_core_types[]; + static const glsl_type builtin_structure_types[]; + static const glsl_type builtin_110_deprecated_structure_types[]; + static const glsl_type builtin_110_types[]; + static const glsl_type builtin_120_types[]; + static const glsl_type builtin_130_types[]; + static const glsl_type builtin_ARB_texture_rectangle_types[]; + static const glsl_type builtin_EXT_texture_array_types[]; + static const glsl_type builtin_EXT_texture_buffer_object_types[]; + /*@}*/ + + /** + * \name Methods to populate a symbol table with built-in types. + * + * \internal + * This is one of the truely annoying things about C++. Methods that are + * completely internal and private to a type still have to be advertised to + * the world in a public header file. + */ + /*@{*/ + static void generate_100ES_types(glsl_symbol_table *); + static void generate_110_types(glsl_symbol_table *); + static void generate_120_types(glsl_symbol_table *); + static void generate_130_types(glsl_symbol_table *); + static void generate_ARB_texture_rectangle_types(glsl_symbol_table *, bool); + static void generate_EXT_texture_array_types(glsl_symbol_table *, bool); + static void generate_OES_texture_3D_types(glsl_symbol_table *, bool); + /*@}*/ + + /** + * \name Friend functions. + * + * These functions are friends because they must have C linkage and the + * need to call various private methods or access various private static + * data. + */ + /*@{*/ + friend void _mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *); + friend void _mesa_glsl_release_types(void); + /*@}*/ +}; + +struct glsl_struct_field { + const struct glsl_type *type; + const char *name; + glsl_precision precision; +}; + +#endif /* GLSL_TYPES_H */ diff --git a/3rdparty/glsl-optimizer/src/glsl/hir_field_selection.cpp b/3rdparty/glsl-optimizer/src/glsl/hir_field_selection.cpp new file mode 100644 index 000000000..3c33127b5 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/hir_field_selection.cpp @@ -0,0 +1,102 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include "ir.h" +#include "program/symbol_table.h" +#include "glsl_parser_extras.h" +#include "ast.h" +#include "glsl_types.h" + +ir_rvalue * +_mesa_ast_field_selection_to_hir(const ast_expression *expr, + exec_list *instructions, + struct _mesa_glsl_parse_state *state) +{ + void *ctx = state; + ir_rvalue *result = NULL; + ir_rvalue *op; + + op = expr->subexpressions[0]->hir(instructions, state); + + /* There are two kinds of field selection. There is the selection of a + * specific field from a structure, and there is the selection of a + * swizzle / mask from a vector. Which is which is determined entirely + * by the base type of the thing to which the field selection operator is + * being applied. + */ + YYLTYPE loc = expr->get_location(); + if (op->type->is_error()) { + /* silently propagate the error */ + } else if (op->type->is_vector()) { + ir_swizzle *swiz = ir_swizzle::create(op, + expr->primary_expression.identifier, + op->type->vector_elements); + if (swiz != NULL) { + result = swiz; + } else { + /* FINISHME: Logging of error messages should be moved into + * FINISHME: ir_swizzle::create. This allows the generation of more + * FINISHME: specific error messages. + */ + _mesa_glsl_error(& loc, state, "Invalid swizzle / mask `%s'", + expr->primary_expression.identifier); + } + } else if (op->type->base_type == GLSL_TYPE_STRUCT) { + result = new(ctx) ir_dereference_record(op, + expr->primary_expression.identifier); + + if (result->type->is_error()) { + _mesa_glsl_error(& loc, state, "Cannot access field `%s' of " + "structure", + expr->primary_expression.identifier); + } + } else if (expr->subexpressions[1] != NULL) { + /* Handle "method calls" in GLSL 1.20 - namely, array.length() */ + if (state->language_version < 120) + _mesa_glsl_error(&loc, state, "Methods not supported in GLSL 1.10."); + + ast_expression *call = expr->subexpressions[1]; + assert(call->oper == ast_function_call); + + const char *method; + method = call->subexpressions[0]->primary_expression.identifier; + + if (op->type->is_array() && strcmp(method, "length") == 0) { + if (!call->expressions.is_empty()) + _mesa_glsl_error(&loc, state, "length method takes no arguments."); + + if (op->type->array_size() == 0) + _mesa_glsl_error(&loc, state, "length called on unsized array."); + + result = new(ctx) ir_constant(op->type->array_size()); + } else { + _mesa_glsl_error(&loc, state, "Unknown method: `%s'.", method); + } + } else { + _mesa_glsl_error(& loc, state, "Cannot access field `%s' of " + "non-structure / non-vector.", + expr->primary_expression.identifier); + } + + return result ? result : ir_call::get_error_instruction(ctx); +} diff --git a/3rdparty/glsl-optimizer/src/glsl/ir.cpp b/3rdparty/glsl-optimizer/src/glsl/ir.cpp new file mode 100644 index 000000000..6ea946113 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/ir.cpp @@ -0,0 +1,1620 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +#include +#include "main/core.h" /* for MAX2 */ +#include "ir.h" +#include "ir_visitor.h" +#include "glsl_types.h" + +glsl_precision higher_precision (ir_instruction* a, ir_instruction* b) +{ + if (!a && !b) + return glsl_precision_undefined; + if (!a) + return precision_from_ir (b); + if (!b) + return precision_from_ir (a); + return higher_precision (precision_from_ir(a), precision_from_ir(b)); +} + + +ir_rvalue::ir_rvalue(glsl_precision precision) +: precision(precision) +{ + this->type = glsl_type::error_type; +} + +bool ir_rvalue::is_zero() const +{ + return false; +} + +bool ir_rvalue::is_one() const +{ + return false; +} + +bool ir_rvalue::is_negative_one() const +{ + return false; +} + +/** + * Modify the swizzle make to move one component to another + * + * \param m IR swizzle to be modified + * \param from Component in the RHS that is to be swizzled + * \param to Desired swizzle location of \c from + */ +static void +update_rhs_swizzle(ir_swizzle_mask &m, unsigned from, unsigned to) +{ + switch (to) { + case 0: m.x = from; break; + case 1: m.y = from; break; + case 2: m.z = from; break; + case 3: m.w = from; break; + default: assert(!"Should not get here."); + } + + m.num_components = MAX2(m.num_components, (to + 1)); +} + +void +ir_assignment::set_lhs(ir_rvalue *lhs) +{ + void *mem_ctx = this; + bool swizzled = false; + + while (lhs != NULL) { + ir_swizzle *swiz = lhs->as_swizzle(); + + if (swiz == NULL) + break; + + unsigned write_mask = 0; + ir_swizzle_mask rhs_swiz = { 0, 0, 0, 0, 0, 0 }; + + for (unsigned i = 0; i < swiz->mask.num_components; i++) { + unsigned c = 0; + + switch (i) { + case 0: c = swiz->mask.x; break; + case 1: c = swiz->mask.y; break; + case 2: c = swiz->mask.z; break; + case 3: c = swiz->mask.w; break; + default: assert(!"Should not get here."); + } + + write_mask |= (((this->write_mask >> i) & 1) << c); + update_rhs_swizzle(rhs_swiz, i, c); + } + + this->write_mask = write_mask; + lhs = swiz->val; + + this->rhs = new(mem_ctx) ir_swizzle(this->rhs, rhs_swiz); + swizzled = true; + } + + if (swizzled) { + /* Now, RHS channels line up with the LHS writemask. Collapse it + * to just the channels that will be written. + */ + ir_swizzle_mask rhs_swiz = { 0, 0, 0, 0, 0, 0 }; + int rhs_chan = 0; + for (int i = 0; i < 4; i++) { + if (write_mask & (1 << i)) + update_rhs_swizzle(rhs_swiz, i, rhs_chan++); + } + this->rhs = new(mem_ctx) ir_swizzle(this->rhs, rhs_swiz); + } + + assert((lhs == NULL) || lhs->as_dereference()); + + this->lhs = (ir_dereference *) lhs; +} + +ir_variable * +ir_assignment::whole_variable_written() +{ + ir_variable *v = this->lhs->whole_variable_referenced(); + + if (v == NULL) + return NULL; + + if (v->type->is_scalar()) + return v; + + if (v->type->is_vector()) { + const unsigned mask = (1U << v->type->vector_elements) - 1; + + if (mask != this->write_mask) + return NULL; + } + + /* Either all the vector components are assigned or the variable is some + * composite type (and the whole thing is assigned. + */ + return v; +} + +ir_assignment::ir_assignment(ir_dereference *lhs, ir_rvalue *rhs, + ir_rvalue *condition, unsigned write_mask) +{ + this->ir_type = ir_type_assignment; + this->condition = condition; + this->rhs = rhs; + this->lhs = lhs; + this->write_mask = write_mask; + + if (lhs->type->is_scalar() || lhs->type->is_vector()) { + int lhs_components = 0; + for (int i = 0; i < 4; i++) { + if (write_mask & (1 << i)) + lhs_components++; + } + + assert(lhs_components == this->rhs->type->vector_elements); + } +} + +ir_assignment::ir_assignment(ir_rvalue *lhs, ir_rvalue *rhs, + ir_rvalue *condition) +{ + this->ir_type = ir_type_assignment; + this->condition = condition; + this->rhs = rhs; + + /* If the RHS is a vector type, assume that all components of the vector + * type are being written to the LHS. The write mask comes from the RHS + * because we can have a case where the LHS is a vec4 and the RHS is a + * vec3. In that case, the assignment is: + * + * (assign (...) (xyz) (var_ref lhs) (var_ref rhs)) + */ + if (rhs->type->is_vector()) + this->write_mask = (1U << rhs->type->vector_elements) - 1; + else if (rhs->type->is_scalar()) + this->write_mask = 1; + else + this->write_mask = 0; + + this->set_lhs(lhs); +} + + +ir_expression::ir_expression(int op, const struct glsl_type *type, + ir_rvalue *op0) +: ir_rvalue(precision_from_ir(op0)) +{ + assert(get_num_operands(ir_expression_operation(op)) == 1); + this->ir_type = ir_type_expression; + this->type = type; + this->operation = ir_expression_operation(op); + this->operands[0] = op0; + this->operands[1] = NULL; + this->operands[2] = NULL; + this->operands[3] = NULL; +} + +ir_expression::ir_expression(int op, const struct glsl_type *type, + ir_rvalue *op0, ir_rvalue *op1) +: ir_rvalue(higher_precision(op0,op1)) +{ + assert(((op1 == NULL) && (get_num_operands(ir_expression_operation(op)) == 1)) + || (get_num_operands(ir_expression_operation(op)) == 2)); + this->ir_type = ir_type_expression; + this->type = type; + this->operation = ir_expression_operation(op); + this->operands[0] = op0; + this->operands[1] = op1; + this->operands[2] = NULL; + this->operands[3] = NULL; +} + +ir_expression::ir_expression(int op, const struct glsl_type *type, + ir_rvalue *op0, ir_rvalue *op1, + ir_rvalue *op2, ir_rvalue *op3) +: ir_rvalue(higher_precision(higher_precision(op0,op1), higher_precision(op2,op3))) +{ + this->ir_type = ir_type_expression; + this->type = type; + this->operation = ir_expression_operation(op); + this->operands[0] = op0; + this->operands[1] = op1; + this->operands[2] = op2; + this->operands[3] = op3; +} + +ir_expression::ir_expression(int op, ir_rvalue *op0) +: ir_rvalue(precision_from_ir(op0)) +{ + this->ir_type = ir_type_expression; + + this->operation = ir_expression_operation(op); + this->operands[0] = op0; + this->operands[1] = NULL; + this->operands[2] = NULL; + this->operands[3] = NULL; + + assert(op <= ir_last_unop); + + switch (this->operation) { + case ir_unop_bit_not: + case ir_unop_logic_not: + case ir_unop_neg: + case ir_unop_abs: + case ir_unop_sign: + case ir_unop_rcp: + case ir_unop_rsq: + case ir_unop_sqrt: + case ir_unop_exp: + case ir_unop_log: + case ir_unop_exp2: + case ir_unop_log2: + case ir_unop_trunc: + case ir_unop_ceil: + case ir_unop_floor: + case ir_unop_fract: + case ir_unop_round_even: + case ir_unop_sin: + case ir_unop_cos: + case ir_unop_sin_reduced: + case ir_unop_cos_reduced: + case ir_unop_dFdx: + case ir_unop_dFdy: + this->type = op0->type; + break; + + case ir_unop_f2i: + case ir_unop_b2i: + case ir_unop_u2i: + this->type = glsl_type::get_instance(GLSL_TYPE_INT, + op0->type->vector_elements, 1); + break; + + case ir_unop_b2f: + case ir_unop_i2f: + case ir_unop_u2f: + this->type = glsl_type::get_instance(GLSL_TYPE_FLOAT, + op0->type->vector_elements, 1); + break; + + case ir_unop_f2b: + case ir_unop_i2b: + this->type = glsl_type::get_instance(GLSL_TYPE_BOOL, + op0->type->vector_elements, 1); + break; + + case ir_unop_i2u: + this->type = glsl_type::get_instance(GLSL_TYPE_UINT, + op0->type->vector_elements, 1); + break; + + case ir_unop_noise: + this->type = glsl_type::float_type; + break; + + case ir_unop_any: + this->type = glsl_type::bool_type; + break; + + default: + assert(!"not reached: missing automatic type setup for ir_expression"); + this->type = op0->type; + break; + } +} + +ir_expression::ir_expression(int op, ir_rvalue *op0, ir_rvalue *op1) +: ir_rvalue(higher_precision(op0,op1)) +{ + this->ir_type = ir_type_expression; + + this->operation = ir_expression_operation(op); + this->operands[0] = op0; + this->operands[1] = op1; + this->operands[2] = NULL; + this->operands[3] = NULL; + + assert(op > ir_last_unop); + + switch (this->operation) { + case ir_binop_all_equal: + case ir_binop_any_nequal: + this->type = glsl_type::bool_type; + break; + + case ir_binop_add: + case ir_binop_sub: + case ir_binop_min: + case ir_binop_max: + case ir_binop_pow: + case ir_binop_mul: + case ir_binop_div: + case ir_binop_mod: + if (op0->type->is_scalar()) { + this->type = op1->type; + } else if (op1->type->is_scalar()) { + this->type = op0->type; + } else { + /* FINISHME: matrix types */ + assert(!op0->type->is_matrix() && !op1->type->is_matrix()); + assert(op0->type == op1->type); + this->type = op0->type; + } + break; + + case ir_binop_logic_and: + case ir_binop_logic_xor: + case ir_binop_logic_or: + case ir_binop_bit_and: + case ir_binop_bit_xor: + case ir_binop_bit_or: + if (op0->type->is_scalar()) { + this->type = op1->type; + } else if (op1->type->is_scalar()) { + this->type = op0->type; + } + break; + + case ir_binop_equal: + case ir_binop_nequal: + case ir_binop_lequal: + case ir_binop_gequal: + case ir_binop_less: + case ir_binop_greater: + assert(op0->type == op1->type); + this->type = glsl_type::get_instance(GLSL_TYPE_BOOL, + op0->type->vector_elements, 1); + break; + + case ir_binop_dot: + this->type = glsl_type::float_type; + break; + + case ir_binop_lshift: + case ir_binop_rshift: + this->type = op0->type; + break; + + default: + assert(!"not reached: missing automatic type setup for ir_expression"); + this->type = glsl_type::float_type; + } +} + +unsigned int +ir_expression::get_num_operands(ir_expression_operation op) +{ + assert(op <= ir_last_opcode); + + if (op <= ir_last_unop) + return 1; + + if (op <= ir_last_binop) + return 2; + + if (op == ir_quadop_vector) + return 4; + + assert(false); + return 0; +} + +static const char *const operator_strs[] = { + "~", + "!", + "neg", + "abs", + "sign", + "rcp", + "rsq", + "sqrt", + "exp", + "log", + "exp2", + "log2", + "f2i", + "i2f", + "f2b", + "b2f", + "i2b", + "b2i", + "u2f", + "i2u", + "u2i", + "any", + "trunc", + "ceil", + "floor", + "fract", + "round_even", + "sin", + "cos", + "sin_reduced", + "cos_reduced", + "dFdx", + "dFdy", + "noise", + "+", + "-", + "*", + "/", + "%", + "<", + ">", + "<=", + ">=", + "==", + "!=", + "all_equal", + "any_nequal", + "<<", + ">>", + "&", + "^", + "|", + "&&", + "^^", + "||", + "dot", + "min", + "max", + "pow", + "vector", +}; + +const char *ir_expression::operator_string(ir_expression_operation op) +{ + assert((unsigned int) op < Elements(operator_strs)); + assert(Elements(operator_strs) == (ir_quadop_vector + 1)); + return operator_strs[op]; +} + +const char *ir_expression::operator_string() +{ + return operator_string(this->operation); +} + +const char* +depth_layout_string(ir_depth_layout layout) +{ + switch(layout) { + case ir_depth_layout_none: return ""; + case ir_depth_layout_any: return "depth_any"; + case ir_depth_layout_greater: return "depth_greater"; + case ir_depth_layout_less: return "depth_less"; + case ir_depth_layout_unchanged: return "depth_unchanged"; + + default: + assert(0); + return ""; + } +} + +ir_expression_operation +ir_expression::get_operator(const char *str) +{ + const int operator_count = sizeof(operator_strs) / sizeof(operator_strs[0]); + for (int op = 0; op < operator_count; op++) { + if (strcmp(str, operator_strs[op]) == 0) + return (ir_expression_operation) op; + } + return (ir_expression_operation) -1; +} + +ir_constant::ir_constant() +: ir_rvalue(glsl_precision_undefined) +{ + this->ir_type = ir_type_constant; +} + +ir_constant::ir_constant(const struct glsl_type *type, + const ir_constant_data *data) +: ir_rvalue(glsl_precision_undefined) +{ + assert((type->base_type >= GLSL_TYPE_UINT) + && (type->base_type <= GLSL_TYPE_BOOL)); + + this->ir_type = ir_type_constant; + this->type = type; + memcpy(& this->value, data, sizeof(this->value)); +} + +ir_constant::ir_constant(float f) +: ir_rvalue(glsl_precision_undefined) +{ + this->ir_type = ir_type_constant; + this->type = glsl_type::float_type; + this->value.f[0] = f; + for (int i = 1; i < 16; i++) { + this->value.f[i] = 0; + } +} + +ir_constant::ir_constant(unsigned int u) +: ir_rvalue(glsl_precision_undefined) +{ + this->ir_type = ir_type_constant; + this->type = glsl_type::uint_type; + this->value.u[0] = u; + for (int i = 1; i < 16; i++) { + this->value.u[i] = 0; + } +} + +ir_constant::ir_constant(int i) +: ir_rvalue(glsl_precision_undefined) +{ + this->ir_type = ir_type_constant; + this->type = glsl_type::int_type; + this->value.i[0] = i; + for (int i = 1; i < 16; i++) { + this->value.i[i] = 0; + } +} + +ir_constant::ir_constant(bool b) +: ir_rvalue(glsl_precision_undefined) +{ + this->ir_type = ir_type_constant; + this->type = glsl_type::bool_type; + this->value.b[0] = b; + for (int i = 1; i < 16; i++) { + this->value.b[i] = false; + } +} + +ir_constant::ir_constant(const ir_constant *c, unsigned i) +: ir_rvalue(c->precision) +{ + this->ir_type = ir_type_constant; + this->type = c->type->get_base_type(); + + switch (this->type->base_type) { + case GLSL_TYPE_UINT: this->value.u[0] = c->value.u[i]; break; + case GLSL_TYPE_INT: this->value.i[0] = c->value.i[i]; break; + case GLSL_TYPE_FLOAT: this->value.f[0] = c->value.f[i]; break; + case GLSL_TYPE_BOOL: this->value.b[0] = c->value.b[i]; break; + default: assert(!"Should not get here."); break; + } +} + +ir_constant::ir_constant(const struct glsl_type *type, exec_list *value_list) +: ir_rvalue(glsl_precision_undefined) +{ + this->ir_type = ir_type_constant; + this->type = type; + + assert(type->is_scalar() || type->is_vector() || type->is_matrix() + || type->is_record() || type->is_array()); + + if (type->is_array()) { + this->array_elements = ralloc_array(this, ir_constant *, type->length); + unsigned i = 0; + foreach_list(node, value_list) { + ir_constant *value = (ir_constant *) node; + assert(value->as_constant() != NULL); + + this->array_elements[i++] = value; + } + return; + } + + /* If the constant is a record, the types of each of the entries in + * value_list must be a 1-for-1 match with the structure components. Each + * entry must also be a constant. Just move the nodes from the value_list + * to the list in the ir_constant. + */ + /* FINISHME: Should there be some type checking and / or assertions here? */ + /* FINISHME: Should the new constant take ownership of the nodes from + * FINISHME: value_list, or should it make copies? + */ + if (type->is_record()) { + value_list->move_nodes_to(& this->components); + return; + } + + for (unsigned i = 0; i < 16; i++) { + this->value.u[i] = 0; + } + + ir_constant *value = (ir_constant *) (value_list->head); + + /* Constructors with exactly one scalar argument are special for vectors + * and matrices. For vectors, the scalar value is replicated to fill all + * the components. For matrices, the scalar fills the components of the + * diagonal while the rest is filled with 0. + */ + if (value->type->is_scalar() && value->next->is_tail_sentinel()) { + if (type->is_matrix()) { + /* Matrix - fill diagonal (rest is already set to 0) */ + assert(type->base_type == GLSL_TYPE_FLOAT); + for (unsigned i = 0; i < type->matrix_columns; i++) + this->value.f[i * type->vector_elements + i] = value->value.f[0]; + } else { + /* Vector or scalar - fill all components */ + switch (type->base_type) { + case GLSL_TYPE_UINT: + case GLSL_TYPE_INT: + for (unsigned i = 0; i < type->components(); i++) + this->value.u[i] = value->value.u[0]; + break; + case GLSL_TYPE_FLOAT: + for (unsigned i = 0; i < type->components(); i++) + this->value.f[i] = value->value.f[0]; + break; + case GLSL_TYPE_BOOL: + for (unsigned i = 0; i < type->components(); i++) + this->value.b[i] = value->value.b[0]; + break; + default: + assert(!"Should not get here."); + break; + } + } + return; + } + + if (type->is_matrix() && value->type->is_matrix()) { + assert(value->next->is_tail_sentinel()); + + /* From section 5.4.2 of the GLSL 1.20 spec: + * "If a matrix is constructed from a matrix, then each component + * (column i, row j) in the result that has a corresponding component + * (column i, row j) in the argument will be initialized from there." + */ + unsigned cols = MIN2(type->matrix_columns, value->type->matrix_columns); + unsigned rows = MIN2(type->vector_elements, value->type->vector_elements); + for (unsigned i = 0; i < cols; i++) { + for (unsigned j = 0; j < rows; j++) { + const unsigned src = i * value->type->vector_elements + j; + const unsigned dst = i * type->vector_elements + j; + this->value.f[dst] = value->value.f[src]; + } + } + + /* "All other components will be initialized to the identity matrix." */ + for (unsigned i = cols; i < type->matrix_columns; i++) + this->value.f[i * type->vector_elements + i] = 1.0; + + return; + } + + /* Use each component from each entry in the value_list to initialize one + * component of the constant being constructed. + */ + for (unsigned i = 0; i < type->components(); /* empty */) { + assert(value->as_constant() != NULL); + assert(!value->is_tail_sentinel()); + + for (unsigned j = 0; j < value->type->components(); j++) { + switch (type->base_type) { + case GLSL_TYPE_UINT: + this->value.u[i] = value->get_uint_component(j); + break; + case GLSL_TYPE_INT: + this->value.i[i] = value->get_int_component(j); + break; + case GLSL_TYPE_FLOAT: + this->value.f[i] = value->get_float_component(j); + break; + case GLSL_TYPE_BOOL: + this->value.b[i] = value->get_bool_component(j); + break; + default: + /* FINISHME: What to do? Exceptions are not the answer. + */ + break; + } + + i++; + if (i >= type->components()) + break; + } + + value = (ir_constant *) value->next; + } +} + +ir_constant * +ir_constant::zero(void *mem_ctx, const glsl_type *type) +{ + assert(type->is_numeric() || type->is_boolean()); + + ir_constant *c = new(mem_ctx) ir_constant; + c->type = type; + memset(&c->value, 0, sizeof(c->value)); + + return c; +} + +bool +ir_constant::get_bool_component(unsigned i) const +{ + switch (this->type->base_type) { + case GLSL_TYPE_UINT: return this->value.u[i] != 0; + case GLSL_TYPE_INT: return this->value.i[i] != 0; + case GLSL_TYPE_FLOAT: return ((int)this->value.f[i]) != 0; + case GLSL_TYPE_BOOL: return this->value.b[i]; + default: assert(!"Should not get here."); break; + } + + /* Must return something to make the compiler happy. This is clearly an + * error case. + */ + return false; +} + +float +ir_constant::get_float_component(unsigned i) const +{ + switch (this->type->base_type) { + case GLSL_TYPE_UINT: return (float) this->value.u[i]; + case GLSL_TYPE_INT: return (float) this->value.i[i]; + case GLSL_TYPE_FLOAT: return this->value.f[i]; + case GLSL_TYPE_BOOL: return this->value.b[i] ? 1.0 : 0.0; + default: assert(!"Should not get here."); break; + } + + /* Must return something to make the compiler happy. This is clearly an + * error case. + */ + return 0.0; +} + +int +ir_constant::get_int_component(unsigned i) const +{ + switch (this->type->base_type) { + case GLSL_TYPE_UINT: return this->value.u[i]; + case GLSL_TYPE_INT: return this->value.i[i]; + case GLSL_TYPE_FLOAT: return (int) this->value.f[i]; + case GLSL_TYPE_BOOL: return this->value.b[i] ? 1 : 0; + default: assert(!"Should not get here."); break; + } + + /* Must return something to make the compiler happy. This is clearly an + * error case. + */ + return 0; +} + +unsigned +ir_constant::get_uint_component(unsigned i) const +{ + switch (this->type->base_type) { + case GLSL_TYPE_UINT: return this->value.u[i]; + case GLSL_TYPE_INT: return this->value.i[i]; + case GLSL_TYPE_FLOAT: return (unsigned) this->value.f[i]; + case GLSL_TYPE_BOOL: return this->value.b[i] ? 1 : 0; + default: assert(!"Should not get here."); break; + } + + /* Must return something to make the compiler happy. This is clearly an + * error case. + */ + return 0; +} + +ir_constant * +ir_constant::get_array_element(unsigned i) const +{ + assert(this->type->is_array()); + + /* From page 35 (page 41 of the PDF) of the GLSL 1.20 spec: + * + * "Behavior is undefined if a shader subscripts an array with an index + * less than 0 or greater than or equal to the size the array was + * declared with." + * + * Most out-of-bounds accesses are removed before things could get this far. + * There are cases where non-constant array index values can get constant + * folded. + */ + if (int(i) < 0) + i = 0; + else if (i >= this->type->length) + i = this->type->length - 1; + + return array_elements[i]; +} + +ir_constant * +ir_constant::get_record_field(const char *name) +{ + int idx = this->type->field_index(name); + + if (idx < 0) + return NULL; + + if (this->components.is_empty()) + return NULL; + + exec_node *node = this->components.head; + for (int i = 0; i < idx; i++) { + node = node->next; + + /* If the end of the list is encountered before the element matching the + * requested field is found, return NULL. + */ + if (node->is_tail_sentinel()) + return NULL; + } + + return (ir_constant *) node; +} + + +bool +ir_constant::has_value(const ir_constant *c) const +{ + if (this->type != c->type) + return false; + + if (this->type->is_array()) { + for (unsigned i = 0; i < this->type->length; i++) { + if (!this->array_elements[i]->has_value(c->array_elements[i])) + return false; + } + return true; + } + + if (this->type->base_type == GLSL_TYPE_STRUCT) { + const exec_node *a_node = this->components.head; + const exec_node *b_node = c->components.head; + + while (!a_node->is_tail_sentinel()) { + assert(!b_node->is_tail_sentinel()); + + const ir_constant *const a_field = (ir_constant *) a_node; + const ir_constant *const b_field = (ir_constant *) b_node; + + if (!a_field->has_value(b_field)) + return false; + + a_node = a_node->next; + b_node = b_node->next; + } + + return true; + } + + for (unsigned i = 0; i < this->type->components(); i++) { + switch (this->type->base_type) { + case GLSL_TYPE_UINT: + if (this->value.u[i] != c->value.u[i]) + return false; + break; + case GLSL_TYPE_INT: + if (this->value.i[i] != c->value.i[i]) + return false; + break; + case GLSL_TYPE_FLOAT: + if (this->value.f[i] != c->value.f[i]) + return false; + break; + case GLSL_TYPE_BOOL: + if (this->value.b[i] != c->value.b[i]) + return false; + break; + default: + assert(!"Should not get here."); + return false; + } + } + + return true; +} + +bool +ir_constant::is_zero() const +{ + if (!this->type->is_scalar() && !this->type->is_vector()) + return false; + + for (unsigned c = 0; c < this->type->vector_elements; c++) { + switch (this->type->base_type) { + case GLSL_TYPE_FLOAT: + if (this->value.f[c] != 0.0) + return false; + break; + case GLSL_TYPE_INT: + if (this->value.i[c] != 0) + return false; + break; + case GLSL_TYPE_UINT: + if (this->value.u[c] != 0) + return false; + break; + case GLSL_TYPE_BOOL: + if (this->value.b[c] != false) + return false; + break; + default: + /* The only other base types are structures, arrays, and samplers. + * Samplers cannot be constants, and the others should have been + * filtered out above. + */ + assert(!"Should not get here."); + return false; + } + } + + return true; +} + +bool +ir_constant::is_one() const +{ + if (!this->type->is_scalar() && !this->type->is_vector()) + return false; + + for (unsigned c = 0; c < this->type->vector_elements; c++) { + switch (this->type->base_type) { + case GLSL_TYPE_FLOAT: + if (this->value.f[c] != 1.0) + return false; + break; + case GLSL_TYPE_INT: + if (this->value.i[c] != 1) + return false; + break; + case GLSL_TYPE_UINT: + if (this->value.u[c] != 1) + return false; + break; + case GLSL_TYPE_BOOL: + if (this->value.b[c] != true) + return false; + break; + default: + /* The only other base types are structures, arrays, and samplers. + * Samplers cannot be constants, and the others should have been + * filtered out above. + */ + assert(!"Should not get here."); + return false; + } + } + + return true; +} + +bool +ir_constant::is_negative_one() const +{ + if (!this->type->is_scalar() && !this->type->is_vector()) + return false; + + if (this->type->is_boolean()) + return false; + + for (unsigned c = 0; c < this->type->vector_elements; c++) { + switch (this->type->base_type) { + case GLSL_TYPE_FLOAT: + if (this->value.f[c] != -1.0) + return false; + break; + case GLSL_TYPE_INT: + if (this->value.i[c] != -1) + return false; + break; + case GLSL_TYPE_UINT: + if (int(this->value.u[c]) != -1) + return false; + break; + default: + /* The only other base types are structures, arrays, samplers, and + * booleans. Samplers cannot be constants, and the others should + * have been filtered out above. + */ + assert(!"Should not get here."); + return false; + } + } + + return true; +} + +ir_loop::ir_loop() +{ + this->ir_type = ir_type_loop; + this->cmp = ir_unop_neg; + this->from = NULL; + this->to = NULL; + this->increment = NULL; + this->counter = NULL; +} + + +ir_dereference_variable::ir_dereference_variable(ir_variable *var) +: ir_dereference(precision_from_ir(var)) +{ + this->ir_type = ir_type_dereference_variable; + this->var = var; + this->type = (var != NULL) ? var->type : glsl_type::error_type; +} + + +ir_dereference_array::ir_dereference_array(ir_rvalue *value, + ir_rvalue *array_index) +: ir_dereference(precision_from_ir(value)) +{ + this->ir_type = ir_type_dereference_array; + this->array_index = array_index; + this->set_array(value); +} + + +ir_dereference_array::ir_dereference_array(ir_variable *var, + ir_rvalue *array_index) +: ir_dereference(precision_from_ir(var)) +{ + void *ctx = ralloc_parent(var); + + this->ir_type = ir_type_dereference_array; + this->array_index = array_index; + this->set_array(new(ctx) ir_dereference_variable(var)); +} + + +void +ir_dereference_array::set_array(ir_rvalue *value) +{ + this->array = value; + this->type = glsl_type::error_type; + + if (this->array != NULL) { + const glsl_type *const vt = this->array->type; + + if (vt->is_array()) { + type = vt->element_type(); + } else if (vt->is_matrix()) { + type = vt->column_type(); + } else if (vt->is_vector()) { + type = vt->get_base_type(); + } + } +} + + +ir_dereference_record::ir_dereference_record(ir_rvalue *value, + const char *field) +: ir_dereference(precision_from_ir(value)) +{ + this->ir_type = ir_type_dereference_record; + this->record = value; + this->field = ralloc_strdup(this, field); + this->type = (this->record != NULL) + ? this->record->type->field_type(field) : glsl_type::error_type; + if (this->record) + this->precision = this->record->type->field_precision(field); +} + + +ir_dereference_record::ir_dereference_record(ir_variable *var, + const char *field) +: ir_dereference(precision_from_ir(var)) +{ + void *ctx = ralloc_parent(var); + + this->ir_type = ir_type_dereference_record; + this->record = new(ctx) ir_dereference_variable(var); + this->field = ralloc_strdup(this, field); + this->type = (this->record != NULL) + ? this->record->type->field_type(field) : glsl_type::error_type; + if (this->record) + this->precision = this->record->type->field_precision(field); +} + +bool +ir_dereference::is_lvalue() const +{ + ir_variable *var = this->variable_referenced(); + + /* Every l-value derference chain eventually ends in a variable. + */ + if ((var == NULL) || var->read_only) + return false; + + if (this->type->is_array() && !var->array_lvalue) + return false; + + /* From page 17 (page 23 of the PDF) of the GLSL 1.20 spec: + * + * "Samplers cannot be treated as l-values; hence cannot be used + * as out or inout function parameters, nor can they be + * assigned into." + */ + if (this->type->contains_sampler()) + return false; + + return true; +} + + +const char *tex_opcode_strs[] = { "tex", "txb", "txl", "txd", "txf" }; + +const char *ir_texture::opcode_string() +{ + assert((unsigned int) op <= + sizeof(tex_opcode_strs) / sizeof(tex_opcode_strs[0])); + return tex_opcode_strs[op]; +} + +ir_texture_opcode +ir_texture::get_opcode(const char *str) +{ + const int count = sizeof(tex_opcode_strs) / sizeof(tex_opcode_strs[0]); + for (int op = 0; op < count; op++) { + if (strcmp(str, tex_opcode_strs[op]) == 0) + return (ir_texture_opcode) op; + } + return (ir_texture_opcode) -1; +} + + +void +ir_texture::set_sampler(ir_dereference *sampler, const glsl_type *type) +{ + assert(sampler != NULL); + assert(type != NULL); + this->sampler = sampler; + this->type = type; + + assert(sampler->type->sampler_type == (int) type->base_type); + if (sampler->type->sampler_shadow) + assert(type->vector_elements == 4 || type->vector_elements == 1); + else + assert(type->vector_elements == 4); +} + + +void +ir_swizzle::init_mask(const unsigned *comp, unsigned count) +{ + assert((count >= 1) && (count <= 4)); + + memset(&this->mask, 0, sizeof(this->mask)); + this->mask.num_components = count; + + unsigned dup_mask = 0; + switch (count) { + case 4: + assert(comp[3] <= 3); + dup_mask |= (1U << comp[3]) + & ((1U << comp[0]) | (1U << comp[1]) | (1U << comp[2])); + this->mask.w = comp[3]; + + case 3: + assert(comp[2] <= 3); + dup_mask |= (1U << comp[2]) + & ((1U << comp[0]) | (1U << comp[1])); + this->mask.z = comp[2]; + + case 2: + assert(comp[1] <= 3); + dup_mask |= (1U << comp[1]) + & ((1U << comp[0])); + this->mask.y = comp[1]; + + case 1: + assert(comp[0] <= 3); + this->mask.x = comp[0]; + } + + this->mask.has_duplicates = dup_mask != 0; + + /* Based on the number of elements in the swizzle and the base type + * (i.e., float, int, unsigned, or bool) of the vector being swizzled, + * generate the type of the resulting value. + */ + type = glsl_type::get_instance(val->type->base_type, mask.num_components, 1); +} + +ir_swizzle::ir_swizzle(ir_rvalue *val, unsigned x, unsigned y, unsigned z, + unsigned w, unsigned count) + : ir_rvalue(precision_from_ir(val)), val(val) +{ + const unsigned components[4] = { x, y, z, w }; + this->ir_type = ir_type_swizzle; + this->init_mask(components, count); +} + +ir_swizzle::ir_swizzle(ir_rvalue *val, const unsigned *comp, + unsigned count) + : ir_rvalue(precision_from_ir(val)), val(val) +{ + this->ir_type = ir_type_swizzle; + this->init_mask(comp, count); +} + +ir_swizzle::ir_swizzle(ir_rvalue *val, ir_swizzle_mask mask) +: ir_rvalue(precision_from_ir(val)) +{ + this->ir_type = ir_type_swizzle; + this->val = val; + this->mask = mask; + this->type = glsl_type::get_instance(val->type->base_type, + mask.num_components, 1); +} + +#define X 1 +#define R 5 +#define S 9 +#define I 13 + +ir_swizzle * +ir_swizzle::create(ir_rvalue *val, const char *str, unsigned vector_length) +{ + void *ctx = ralloc_parent(val); + + /* For each possible swizzle character, this table encodes the value in + * \c idx_map that represents the 0th element of the vector. For invalid + * swizzle characters (e.g., 'k'), a special value is used that will allow + * detection of errors. + */ + static const unsigned char base_idx[26] = { + /* a b c d e f g h i j k l m */ + R, R, I, I, I, I, R, I, I, I, I, I, I, + /* n o p q r s t u v w x y z */ + I, I, S, S, R, S, S, I, I, X, X, X, X + }; + + /* Each valid swizzle character has an entry in the previous table. This + * table encodes the base index encoded in the previous table plus the actual + * index of the swizzle character. When processing swizzles, the first + * character in the string is indexed in the previous table. Each character + * in the string is indexed in this table, and the value found there has the + * value form the first table subtracted. The result must be on the range + * [0,3]. + * + * For example, the string "wzyx" will get X from the first table. Each of + * the charcaters will get X+3, X+2, X+1, and X+0 from this table. After + * subtraction, the swizzle values are { 3, 2, 1, 0 }. + * + * The string "wzrg" will get X from the first table. Each of the characters + * will get X+3, X+2, R+0, and R+1 from this table. After subtraction, the + * swizzle values are { 3, 2, 4, 5 }. Since 4 and 5 are outside the range + * [0,3], the error is detected. + */ + static const unsigned char idx_map[26] = { + /* a b c d e f g h i j k l m */ + R+3, R+2, 0, 0, 0, 0, R+1, 0, 0, 0, 0, 0, 0, + /* n o p q r s t u v w x y z */ + 0, 0, S+2, S+3, R+0, S+0, S+1, 0, 0, X+3, X+0, X+1, X+2 + }; + + int swiz_idx[4] = { 0, 0, 0, 0 }; + unsigned i; + + + /* Validate the first character in the swizzle string and look up the base + * index value as described above. + */ + if ((str[0] < 'a') || (str[0] > 'z')) + return NULL; + + const unsigned base = base_idx[str[0] - 'a']; + + + for (i = 0; (i < 4) && (str[i] != '\0'); i++) { + /* Validate the next character, and, as described above, convert it to a + * swizzle index. + */ + if ((str[i] < 'a') || (str[i] > 'z')) + return NULL; + + swiz_idx[i] = idx_map[str[i] - 'a'] - base; + if ((swiz_idx[i] < 0) || (swiz_idx[i] >= (int) vector_length)) + return NULL; + } + + if (str[i] != '\0') + return NULL; + + return new(ctx) ir_swizzle(val, swiz_idx[0], swiz_idx[1], swiz_idx[2], + swiz_idx[3], i); +} + +#undef X +#undef R +#undef S +#undef I + +ir_variable * +ir_swizzle::variable_referenced() const +{ + return this->val->variable_referenced(); +} + +ir_variable::ir_variable(const struct glsl_type *type, const char *name, + ir_variable_mode mode, glsl_precision precision) + : max_array_access(0), read_only(false), centroid(false), invariant(false), + mode(mode), interpolation(ir_var_smooth), precision(precision), array_lvalue(false) +{ + this->ir_type = ir_type_variable; + this->type = type; + this->name = ralloc_strdup(this, name); + this->explicit_location = false; + this->location = -1; + this->warn_extension = NULL; + this->constant_value = NULL; + this->origin_upper_left = false; + this->pixel_center_integer = false; + this->depth_layout = ir_depth_layout_none; + this->used = false; + + if (type && type->base_type == GLSL_TYPE_SAMPLER) + this->read_only = true; +} + + +const char * +ir_variable::interpolation_string() const +{ + switch (this->interpolation) { + case ir_var_smooth: return "smooth"; + case ir_var_flat: return "flat"; + case ir_var_noperspective: return "noperspective"; + } + + assert(!"Should not get here."); + return ""; +} + +unsigned +ir_variable::component_slots() const +{ + /* FINISHME: Sparsely accessed arrays require fewer slots. */ + return this->type->component_slots(); +} + + +ir_function_signature::ir_function_signature(const glsl_type *return_type, glsl_precision precision) + : return_type(return_type), precision(precision), is_defined(false), _function(NULL) +{ + this->ir_type = ir_type_function_signature; + this->is_builtin = false; +} + + +static bool +modes_match(unsigned a, unsigned b) +{ + if (a == b) + return true; + + /* Accept "in" vs. "const in" */ + if ((a == ir_var_const_in && b == ir_var_in) || + (b == ir_var_const_in && a == ir_var_in)) + return true; + + return false; +} + + +const char * +ir_function_signature::qualifiers_match(exec_list *params) +{ + exec_list_iterator iter_a = parameters.iterator(); + exec_list_iterator iter_b = params->iterator(); + + /* check that the qualifiers match. */ + while (iter_a.has_next()) { + ir_variable *a = (ir_variable *)iter_a.get(); + ir_variable *b = (ir_variable *)iter_b.get(); + + /* NOTE: precision does not affect qualifier matching */ + if (a->read_only != b->read_only || + !modes_match(a->mode, b->mode) || + a->interpolation != b->interpolation || + a->centroid != b->centroid) { + + /* parameter a's qualifiers don't match */ + return a->name; + } + + iter_a.next(); + iter_b.next(); + } + return NULL; +} + + +void +ir_function_signature::replace_parameters(exec_list *new_params) +{ + /* Destroy all of the previous parameter information. If the previous + * parameter information comes from the function prototype, it may either + * specify incorrect parameter names or not have names at all. + */ + foreach_iter(exec_list_iterator, iter, parameters) { + assert(((ir_instruction *) iter.get())->as_variable() != NULL); + + iter.remove(); + } + + new_params->move_nodes_to(¶meters); +} + + +ir_function::ir_function(const char *name) +{ + this->ir_type = ir_type_function; + this->name = ralloc_strdup(this, name); +} + + +bool +ir_function::has_user_signature() +{ + foreach_list(n, &this->signatures) { + ir_function_signature *const sig = (ir_function_signature *) n; + if (!sig->is_builtin) + return true; + } + return false; +} + + +ir_call * +ir_call::get_error_instruction(void *ctx) +{ + ir_call *call = new(ctx) ir_call; + + call->type = glsl_type::error_type; + return call; +} + +void +ir_call::set_callee(ir_function_signature *sig) +{ + assert((this->type == NULL) || (this->type == sig->return_type)); + + this->callee = sig; + this->precision = sig->precision; +} + +void +visit_exec_list(exec_list *list, ir_visitor *visitor) +{ + foreach_iter(exec_list_iterator, iter, *list) { + ((ir_instruction *)iter.get())->accept(visitor); + } +} + + +static void +steal_memory(ir_instruction *ir, void *new_ctx) +{ + ir_variable *var = ir->as_variable(); + ir_constant *constant = ir->as_constant(); + if (var != NULL && var->constant_value != NULL) + steal_memory(var->constant_value, ir); + + /* The components of aggregate constants are not visited by the normal + * visitor, so steal their values by hand. + */ + if (constant != NULL) { + if (constant->type->is_record()) { + foreach_iter(exec_list_iterator, iter, constant->components) { + ir_constant *field = (ir_constant *)iter.get(); + steal_memory(field, ir); + } + } else if (constant->type->is_array()) { + for (unsigned int i = 0; i < constant->type->length; i++) { + steal_memory(constant->array_elements[i], ir); + } + } + } + + ralloc_steal(new_ctx, ir); +} + + +void +reparent_ir(exec_list *list, void *mem_ctx) +{ + foreach_list(node, list) { + visit_tree((ir_instruction *) node, steal_memory, mem_ctx); + } +} + + +glsl_precision +precision_from_ir (ir_instruction* ir) +{ + if (!ir) + return glsl_precision_undefined; + ir_variable* var = ir->as_variable(); + if (var) + return (glsl_precision)var->precision; + ir_rvalue* rv = ir->as_rvalue(); + if (rv) + return rv->get_precision(); + if (ir->ir_type == ir_type_function_signature) + { + ir_function_signature* sig = (ir_function_signature*)ir; + return sig->precision; + } + return glsl_precision_high; +} + +static ir_rvalue * +try_min_one(ir_rvalue *ir) +{ + ir_expression *expr = ir->as_expression(); + + if (!expr || expr->operation != ir_binop_min) + return NULL; + + if (expr->operands[0]->is_one()) + return expr->operands[1]; + + if (expr->operands[1]->is_one()) + return expr->operands[0]; + + return NULL; +} + +static ir_rvalue * +try_max_zero(ir_rvalue *ir) +{ + ir_expression *expr = ir->as_expression(); + + if (!expr || expr->operation != ir_binop_max) + return NULL; + + if (expr->operands[0]->is_zero()) + return expr->operands[1]; + + if (expr->operands[1]->is_zero()) + return expr->operands[0]; + + return NULL; +} + +ir_rvalue * +ir_rvalue::as_rvalue_to_saturate() +{ + ir_expression *expr = this->as_expression(); + + if (!expr) + return NULL; + + ir_rvalue *max_zero = try_max_zero(expr); + if (max_zero) { + return try_min_one(max_zero); + } else { + ir_rvalue *min_one = try_min_one(expr); + if (min_one) { + return try_max_zero(min_one); + } + } + + return NULL; +} diff --git a/3rdparty/glsl-optimizer/src/glsl/ir.h b/3rdparty/glsl-optimizer/src/glsl/ir.h new file mode 100644 index 000000000..774ef5ec0 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/ir.h @@ -0,0 +1,1728 @@ +/* -*- c++ -*- */ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#pragma once +#ifndef IR_H +#define IR_H + +#include +#include + +#include "ralloc.h" +#include "glsl_types.h" +#include "list.h" +#include "ir_visitor.h" +#include "ir_hierarchical_visitor.h" +#include "main/macros.h" + +/** + * \defgroup IR Intermediate representation nodes + * + * @{ + */ + +/** + * Class tags + * + * Each concrete class derived from \c ir_instruction has a value in this + * enumerant. The value for the type is stored in \c ir_instruction::ir_type + * by the constructor. While using type tags is not very C++, it is extremely + * convenient. For example, during debugging you can simply inspect + * \c ir_instruction::ir_type to find out the actual type of the object. + * + * In addition, it is possible to use a switch-statement based on \c + * \c ir_instruction::ir_type to select different behavior for different object + * types. For functions that have only slight differences for several object + * types, this allows writing very straightforward, readable code. + */ +enum ir_node_type { + /** + * Zero is unused so that the IR validator can detect cases where + * \c ir_instruction::ir_type has not been initialized. + */ + ir_type_unset, + ir_type_variable, + ir_type_assignment, + ir_type_call, + ir_type_constant, + ir_type_dereference_array, + ir_type_dereference_record, + ir_type_dereference_variable, + ir_type_discard, + ir_type_expression, + ir_type_function, + ir_type_function_signature, + ir_type_if, + ir_type_loop, + ir_type_loop_jump, + ir_type_return, + ir_type_swizzle, + ir_type_texture, + ir_type_max /**< maximum ir_type enum number, for validation */ +}; + + +/** + * Base class of all IR instructions + */ +class ir_instruction : public exec_node { +public: + enum ir_node_type ir_type; + const struct glsl_type *type; + + /** ir_print_visitor helper for debugging. */ + void print(void) const; + + virtual void accept(ir_visitor *) = 0; + virtual ir_visitor_status accept(ir_hierarchical_visitor *) = 0; + virtual ir_instruction *clone(void *mem_ctx, + struct hash_table *ht) const = 0; + + /** + * \name IR instruction downcast functions + * + * These functions either cast the object to a derived class or return + * \c NULL if the object's type does not match the specified derived class. + * Additional downcast functions will be added as needed. + */ + /*@{*/ + virtual class ir_variable * as_variable() { return NULL; } + virtual class ir_function * as_function() { return NULL; } + virtual class ir_dereference * as_dereference() { return NULL; } + virtual class ir_dereference_array * as_dereference_array() { return NULL; } + virtual class ir_dereference_variable *as_dereference_variable() { return NULL; } + virtual class ir_expression * as_expression() { return NULL; } + virtual class ir_rvalue * as_rvalue() { return NULL; } + virtual class ir_loop * as_loop() { return NULL; } + virtual class ir_assignment * as_assignment() { return NULL; } + virtual class ir_call * as_call() { return NULL; } + virtual class ir_return * as_return() { return NULL; } + virtual class ir_if * as_if() { return NULL; } + virtual class ir_swizzle * as_swizzle() { return NULL; } + virtual class ir_constant * as_constant() { return NULL; } + virtual class ir_discard * as_discard() { return NULL; } + /*@}*/ + +protected: + ir_instruction() + { + ir_type = ir_type_unset; + type = NULL; + } +}; + + +class ir_rvalue : public ir_instruction { +public: + virtual ir_rvalue *clone(void *mem_ctx, struct hash_table *) const = 0; + + virtual ir_constant *constant_expression_value() = 0; + + virtual ir_rvalue * as_rvalue() + { + return this; + } + + ir_rvalue *as_rvalue_to_saturate(); + + virtual bool is_lvalue() const + { + return false; + } + + /** + * Get the variable that is ultimately referenced by an r-value + */ + virtual ir_variable *variable_referenced() const + { + return NULL; + } + + + /** + * If an r-value is a reference to a whole variable, get that variable + * + * \return + * Pointer to a variable that is completely dereferenced by the r-value. If + * the r-value is not a dereference or the dereference does not access the + * entire variable (i.e., it's just one array element, struct field), \c NULL + * is returned. + */ + virtual ir_variable *whole_variable_referenced() + { + return NULL; + } + + glsl_precision get_precision() const { return precision; } + void set_precision (glsl_precision prec) { precision = prec; } + + /** + * Determine if an r-value has the value zero + * + * The base implementation of this function always returns \c false. The + * \c ir_constant class over-rides this function to return \c true \b only + * for vector and scalar types that have all elements set to the value + * zero (or \c false for booleans). + * + * \sa ir_constant::has_value, ir_rvalue::is_one, ir_rvalue::is_negative_one + */ + virtual bool is_zero() const; + + /** + * Determine if an r-value has the value one + * + * The base implementation of this function always returns \c false. The + * \c ir_constant class over-rides this function to return \c true \b only + * for vector and scalar types that have all elements set to the value + * one (or \c true for booleans). + * + * \sa ir_constant::has_value, ir_rvalue::is_zero, ir_rvalue::is_negative_one + */ + virtual bool is_one() const; + + /** + * Determine if an r-value has the value negative one + * + * The base implementation of this function always returns \c false. The + * \c ir_constant class over-rides this function to return \c true \b only + * for vector and scalar types that have all elements set to the value + * negative one. For boolean times, the result is always \c false. + * + * \sa ir_constant::has_value, ir_rvalue::is_zero, ir_rvalue::is_one + */ + virtual bool is_negative_one() const; + +protected: + ir_rvalue(glsl_precision precision); + + glsl_precision precision; +}; + + +/** + * Variable storage classes + */ +enum ir_variable_mode { + ir_var_auto = 0, /**< Function local variables and globals. */ + ir_var_uniform, /**< Variable declared as a uniform. */ + ir_var_in, + ir_var_out, + ir_var_inout, + ir_var_const_in, /**< "in" param that must be a constant expression */ + ir_var_system_value, /**< Ex: front-face, instance-id, etc. */ + ir_var_temporary /**< Temporary variable generated during compilation. */ +}; + +enum ir_variable_interpolation { + ir_var_smooth = 0, + ir_var_flat, + ir_var_noperspective +}; + +/** + * \brief Layout qualifiers for gl_FragDepth. + * + * The AMD_conservative_depth extension allows gl_FragDepth to be redeclared + * with a layout qualifier. + */ +enum ir_depth_layout { + ir_depth_layout_none, /**< No depth layout is specified. */ + ir_depth_layout_any, + ir_depth_layout_greater, + ir_depth_layout_less, + ir_depth_layout_unchanged +}; + +/** + * \brief Convert depth layout qualifier to string. + */ +const char* +depth_layout_string(ir_depth_layout layout); + +/** + * Description of built-in state associated with a uniform + * + * \sa ir_variable::state_slots + */ +struct ir_state_slot { + int tokens[5]; + int swizzle; +}; + + +class ir_variable : public ir_instruction { +public: + ir_variable(const struct glsl_type *, const char *, ir_variable_mode, glsl_precision); + + virtual ir_variable *clone(void *mem_ctx, struct hash_table *ht) const; + + virtual ir_variable *as_variable() + { + return this; + } + + virtual void accept(ir_visitor *v) + { + v->visit(this); + } + + virtual ir_visitor_status accept(ir_hierarchical_visitor *); + + + /** + * Get the string value for the interpolation qualifier + * + * \return The string that would be used in a shader to specify \c + * mode will be returned. + * + * This function should only be used on a shader input or output variable. + */ + const char *interpolation_string() const; + + /** + * Calculate the number of slots required to hold this variable + * + * This is used to determine how many uniform or varying locations a variable + * occupies. The count is in units of floating point components. + */ + unsigned component_slots() const; + + /** + * Delcared name of the variable + */ + const char *name; + + /** + * Highest element accessed with a constant expression array index + * + * Not used for non-array variables. + */ + unsigned max_array_access; + + /** + * Is the variable read-only? + * + * This is set for variables declared as \c const, shader inputs, + * and uniforms. + */ + unsigned read_only:1; + unsigned centroid:1; + unsigned invariant:1; + + /** + * Has this variable been used for reading or writing? + * + * Several GLSL semantic checks require knowledge of whether or not a + * variable has been used. For example, it is an error to redeclare a + * variable as invariant after it has been used. + */ + unsigned used:1; + + /** + * Storage class of the variable. + * + * \sa ir_variable_mode + */ + unsigned mode:3; + + /** + * Interpolation mode for shader inputs / outputs + * + * \sa ir_variable_interpolation + */ + unsigned interpolation:2; + + unsigned precision:2; + + /** + * Flag that the whole array is assignable + * + * In GLSL 1.20 and later whole arrays are assignable (and comparable for + * equality). This flag enables this behavior. + */ + unsigned array_lvalue:1; + + /** + * \name ARB_fragment_coord_conventions + * @{ + */ + unsigned origin_upper_left:1; + unsigned pixel_center_integer:1; + /*@}*/ + + /** + * \brief Layout qualifier for gl_FragDepth. + * + * This is not equal to \c ir_depth_layout_none if and only if this + * variable is \c gl_FragDepth and a layout qualifier is specified. + */ + ir_depth_layout depth_layout; + + /** + * Was the location explicitly set in the shader? + * + * If the location is explicitly set in the shader, it \b cannot be changed + * by the linker or by the API (e.g., calls to \c glBindAttribLocation have + * no effect). + */ + unsigned explicit_location:1; + + /** + * Storage location of the base of this variable + * + * The precise meaning of this field depends on the nature of the variable. + * + * - Vertex shader input: one of the values from \c gl_vert_attrib. + * - Vertex shader output: one of the values from \c gl_vert_result. + * - Fragment shader input: one of the values from \c gl_frag_attrib. + * - Fragment shader output: one of the values from \c gl_frag_result. + * - Uniforms: Per-stage uniform slot number. + * - Other: This field is not currently used. + * + * If the variable is a uniform, shader input, or shader output, and the + * slot has not been assigned, the value will be -1. + */ + int location; + + /** + * Built-in state that backs this uniform + * + * Once set at variable creation, \c state_slots must remain invariant. + * This is because, ideally, this array would be shared by all clones of + * this variable in the IR tree. In other words, we'd really like for it + * to be a fly-weight. + * + * If the variable is not a uniform, \c num_state_slots will be zero and + * \c state_slots will be \c NULL. + */ + /*@{*/ + unsigned num_state_slots; /**< Number of state slots used */ + ir_state_slot *state_slots; /**< State descriptors. */ + /*@}*/ + + /** + * Emit a warning if this variable is accessed. + */ + const char *warn_extension; + + /** + * Value assigned in the initializer of a variable declared "const" + */ + ir_constant *constant_value; +}; + + +/*@{*/ +/** + * The representation of a function instance; may be the full definition or + * simply a prototype. + */ +class ir_function_signature : public ir_instruction { + /* An ir_function_signature will be part of the list of signatures in + * an ir_function. + */ +public: + ir_function_signature(const glsl_type *return_type, glsl_precision precision); + + virtual ir_function_signature *clone(void *mem_ctx, + struct hash_table *ht) const; + ir_function_signature *clone_prototype(void *mem_ctx, + struct hash_table *ht) const; + + virtual void accept(ir_visitor *v) + { + v->visit(this); + } + + virtual ir_visitor_status accept(ir_hierarchical_visitor *); + + /** + * Get the name of the function for which this is a signature + */ + const char *function_name() const; + + /** + * Get a handle to the function for which this is a signature + * + * There is no setter function, this function returns a \c const pointer, + * and \c ir_function_signature::_function is private for a reason. The + * only way to make a connection between a function and function signature + * is via \c ir_function::add_signature. This helps ensure that certain + * invariants (i.e., a function signature is in the list of signatures for + * its \c _function) are met. + * + * \sa ir_function::add_signature + */ + inline const class ir_function *function() const + { + return this->_function; + } + + /** + * Check whether the qualifiers match between this signature's parameters + * and the supplied parameter list. If not, returns the name of the first + * parameter with mismatched qualifiers (for use in error messages). + */ + const char *qualifiers_match(exec_list *params); + + /** + * Replace the current parameter list with the given one. This is useful + * if the current information came from a prototype, and either has invalid + * or missing parameter names. + */ + void replace_parameters(exec_list *new_params); + + /** + * Function return type. + */ + const struct glsl_type *return_type; + + glsl_precision precision; + + /** + * List of ir_variable of function parameters. + * + * This represents the storage. The paramaters passed in a particular + * call will be in ir_call::actual_paramaters. + */ + struct exec_list parameters; + + /** Whether or not this function has a body (which may be empty). */ + unsigned is_defined:1; + + /** Whether or not this function signature is a built-in. */ + unsigned is_builtin:1; + + /** Body of instructions in the function. */ + struct exec_list body; + +private: + /** Function of which this signature is one overload. */ + class ir_function *_function; + + friend class ir_function; +}; + + +/** + * Header for tracking multiple overloaded functions with the same name. + * Contains a list of ir_function_signatures representing each of the + * actual functions. + */ +class ir_function : public ir_instruction { +public: + ir_function(const char *name); + + virtual ir_function *clone(void *mem_ctx, struct hash_table *ht) const; + + virtual ir_function *as_function() + { + return this; + } + + virtual void accept(ir_visitor *v) + { + v->visit(this); + } + + virtual ir_visitor_status accept(ir_hierarchical_visitor *); + + void add_signature(ir_function_signature *sig) + { + sig->_function = this; + this->signatures.push_tail(sig); + } + + /** + * Get an iterator for the set of function signatures + */ + exec_list_iterator iterator() + { + return signatures.iterator(); + } + + /** + * Find a signature that matches a set of actual parameters, taking implicit + * conversions into account. + */ + ir_function_signature *matching_signature(const exec_list *actual_param); + + /** + * Find a signature that exactly matches a set of actual parameters without + * any implicit type conversions. + */ + ir_function_signature *exact_matching_signature(const exec_list *actual_ps); + + /** + * Name of the function. + */ + const char *name; + + /** Whether or not this function has a signature that isn't a built-in. */ + bool has_user_signature(); + + /** + * List of ir_function_signature for each overloaded function with this name. + */ + struct exec_list signatures; +}; + +inline const char *ir_function_signature::function_name() const +{ + return this->_function->name; +} +/*@}*/ + + +/** + * IR instruction representing high-level if-statements + */ +class ir_if : public ir_instruction { +public: + ir_if(ir_rvalue *condition) + : condition(condition) + { + ir_type = ir_type_if; + } + + virtual ir_if *clone(void *mem_ctx, struct hash_table *ht) const; + + virtual ir_if *as_if() + { + return this; + } + + virtual void accept(ir_visitor *v) + { + v->visit(this); + } + + virtual ir_visitor_status accept(ir_hierarchical_visitor *); + + ir_rvalue *condition; + /** List of ir_instruction for the body of the then branch */ + exec_list then_instructions; + /** List of ir_instruction for the body of the else branch */ + exec_list else_instructions; +}; + + +/** + * IR instruction representing a high-level loop structure. + */ +class ir_loop : public ir_instruction { +public: + ir_loop(); + + virtual ir_loop *clone(void *mem_ctx, struct hash_table *ht) const; + + virtual void accept(ir_visitor *v) + { + v->visit(this); + } + + virtual ir_visitor_status accept(ir_hierarchical_visitor *); + + virtual ir_loop *as_loop() + { + return this; + } + + /** + * Get an iterator for the instructions of the loop body + */ + exec_list_iterator iterator() + { + return body_instructions.iterator(); + } + + /** List of ir_instruction that make up the body of the loop. */ + exec_list body_instructions; + + /** + * \name Loop counter and controls + * + * Represents a loop like a FORTRAN \c do-loop. + * + * \note + * If \c from and \c to are the same value, the loop will execute once. + */ + /*@{*/ + ir_rvalue *from; /** Value of the loop counter on the first + * iteration of the loop. + */ + ir_rvalue *to; /** Value of the loop counter on the last + * iteration of the loop. + */ + ir_rvalue *increment; + ir_variable *counter; + + /** + * Comparison operation in the loop terminator. + * + * If any of the loop control fields are non-\c NULL, this field must be + * one of \c ir_binop_less, \c ir_binop_greater, \c ir_binop_lequal, + * \c ir_binop_gequal, \c ir_binop_equal, or \c ir_binop_nequal. + */ + int cmp; + /*@}*/ +}; + + +class ir_assignment : public ir_instruction { +public: + ir_assignment(ir_rvalue *lhs, ir_rvalue *rhs, ir_rvalue *condition = NULL); + + /** + * Construct an assignment with an explicit write mask + * + * \note + * Since a write mask is supplied, the LHS must already be a bare + * \c ir_dereference. The cannot be any swizzles in the LHS. + */ + ir_assignment(ir_dereference *lhs, ir_rvalue *rhs, ir_rvalue *condition, + unsigned write_mask); + + virtual ir_assignment *clone(void *mem_ctx, struct hash_table *ht) const; + + virtual ir_constant *constant_expression_value(); + + virtual void accept(ir_visitor *v) + { + v->visit(this); + } + + virtual ir_visitor_status accept(ir_hierarchical_visitor *); + + virtual ir_assignment * as_assignment() + { + return this; + } + + /** + * Get a whole variable written by an assignment + * + * If the LHS of the assignment writes a whole variable, the variable is + * returned. Otherwise \c NULL is returned. Examples of whole-variable + * assignment are: + * + * - Assigning to a scalar + * - Assigning to all components of a vector + * - Whole array (or matrix) assignment + * - Whole structure assignment + */ + ir_variable *whole_variable_written(); + + /** + * Set the LHS of an assignment + */ + void set_lhs(ir_rvalue *lhs); + + /** + * Left-hand side of the assignment. + * + * This should be treated as read only. If you need to set the LHS of an + * assignment, use \c ir_assignment::set_lhs. + */ + ir_dereference *lhs; + + /** + * Value being assigned + */ + ir_rvalue *rhs; + + /** + * Optional condition for the assignment. + */ + ir_rvalue *condition; + + + /** + * Component mask written + * + * For non-vector types in the LHS, this field will be zero. For vector + * types, a bit will be set for each component that is written. Note that + * for \c vec2 and \c vec3 types only the lower bits will ever be set. + * + * A partially-set write mask means that each enabled channel gets + * the value from a consecutive channel of the rhs. For example, + * to write just .xyw of gl_FrontColor with color: + * + * (assign (constant bool (1)) (xyw) + * (var_ref gl_FragColor) + * (swiz xyw (var_ref color))) + */ + unsigned write_mask:4; +}; + +/* Update ir_expression::num_operands() and operator_strs when + * updating this list. + */ +enum ir_expression_operation { + ir_unop_bit_not, + ir_unop_logic_not, + ir_unop_neg, + ir_unop_abs, + ir_unop_sign, + ir_unop_rcp, + ir_unop_rsq, + ir_unop_sqrt, + ir_unop_exp, /**< Log base e on gentype */ + ir_unop_log, /**< Natural log on gentype */ + ir_unop_exp2, + ir_unop_log2, + ir_unop_f2i, /**< Float-to-integer conversion. */ + ir_unop_i2f, /**< Integer-to-float conversion. */ + ir_unop_f2b, /**< Float-to-boolean conversion */ + ir_unop_b2f, /**< Boolean-to-float conversion */ + ir_unop_i2b, /**< int-to-boolean conversion */ + ir_unop_b2i, /**< Boolean-to-int conversion */ + ir_unop_u2f, /**< Unsigned-to-float conversion. */ + ir_unop_i2u, /**< Integer-to-unsigned conversion. */ + ir_unop_u2i, /**< Unsigned-to-integer conversion. */ + ir_unop_any, + + /** + * \name Unary floating-point rounding operations. + */ + /*@{*/ + ir_unop_trunc, + ir_unop_ceil, + ir_unop_floor, + ir_unop_fract, + ir_unop_round_even, + /*@}*/ + + /** + * \name Trigonometric operations. + */ + /*@{*/ + ir_unop_sin, + ir_unop_cos, + ir_unop_sin_reduced, /**< Reduced range sin. [-pi, pi] */ + ir_unop_cos_reduced, /**< Reduced range cos. [-pi, pi] */ + /*@}*/ + + /** + * \name Partial derivatives. + */ + /*@{*/ + ir_unop_dFdx, + ir_unop_dFdy, + /*@}*/ + + ir_unop_noise, + + /** + * A sentinel marking the last of the unary operations. + */ + ir_last_unop = ir_unop_noise, + + ir_binop_add, + ir_binop_sub, + ir_binop_mul, + ir_binop_div, + + /** + * Takes one of two combinations of arguments: + * + * - mod(vecN, vecN) + * - mod(vecN, float) + * + * Does not take integer types. + */ + ir_binop_mod, + + /** + * \name Binary comparison operators which return a boolean vector. + * The type of both operands must be equal. + */ + /*@{*/ + ir_binop_less, + ir_binop_greater, + ir_binop_lequal, + ir_binop_gequal, + ir_binop_equal, + ir_binop_nequal, + /** + * Returns single boolean for whether all components of operands[0] + * equal the components of operands[1]. + */ + ir_binop_all_equal, + /** + * Returns single boolean for whether any component of operands[0] + * is not equal to the corresponding component of operands[1]. + */ + ir_binop_any_nequal, + /*@}*/ + + /** + * \name Bit-wise binary operations. + */ + /*@{*/ + ir_binop_lshift, + ir_binop_rshift, + ir_binop_bit_and, + ir_binop_bit_xor, + ir_binop_bit_or, + /*@}*/ + + ir_binop_logic_and, + ir_binop_logic_xor, + ir_binop_logic_or, + + ir_binop_dot, + ir_binop_min, + ir_binop_max, + + ir_binop_pow, + + /** + * A sentinel marking the last of the binary operations. + */ + ir_last_binop = ir_binop_pow, + + ir_quadop_vector, + + /** + * A sentinel marking the last of all operations. + */ + ir_last_opcode = ir_last_binop +}; + +class ir_expression : public ir_rvalue { +public: + /** + * Constructor for unary operation expressions + */ + ir_expression(int op, const struct glsl_type *type, ir_rvalue *); + ir_expression(int op, ir_rvalue *); + + /** + * Constructor for binary operation expressions + */ + ir_expression(int op, const struct glsl_type *type, + ir_rvalue *, ir_rvalue *); + ir_expression(int op, ir_rvalue *op0, ir_rvalue *op1); + + /** + * Constructor for quad operator expressions + */ + ir_expression(int op, const struct glsl_type *type, + ir_rvalue *, ir_rvalue *, ir_rvalue *, ir_rvalue *); + + virtual ir_expression *as_expression() + { + return this; + } + + virtual ir_expression *clone(void *mem_ctx, struct hash_table *ht) const; + + /** + * Attempt to constant-fold the expression + * + * If the expression cannot be constant folded, this method will return + * \c NULL. + */ + virtual ir_constant *constant_expression_value(); + + /** + * Determine the number of operands used by an expression + */ + static unsigned int get_num_operands(ir_expression_operation); + + /** + * Determine the number of operands used by an expression + */ + unsigned int get_num_operands() const + { + return (this->operation == ir_quadop_vector) + ? this->type->vector_elements : get_num_operands(operation); + } + + /** + * Return a string representing this expression's operator. + */ + const char *operator_string(); + + /** + * Return a string representing this expression's operator. + */ + static const char *operator_string(ir_expression_operation); + + + /** + * Do a reverse-lookup to translate the given string into an operator. + */ + static ir_expression_operation get_operator(const char *); + + virtual void accept(ir_visitor *v) + { + v->visit(this); + } + + virtual ir_visitor_status accept(ir_hierarchical_visitor *); + + ir_expression_operation operation; + ir_rvalue *operands[4]; +}; + + +/** + * IR instruction representing a function call + */ +class ir_call : public ir_rvalue { +public: + ir_call(ir_function_signature *callee, exec_list *actual_parameters) + : ir_rvalue(callee->precision), callee(callee) + { + ir_type = ir_type_call; + assert(callee->return_type != NULL); + type = callee->return_type; + actual_parameters->move_nodes_to(& this->actual_parameters); + this->use_builtin = callee->is_builtin; + } + + virtual ir_call *clone(void *mem_ctx, struct hash_table *ht) const; + + virtual ir_constant *constant_expression_value(); + + virtual ir_call *as_call() + { + return this; + } + + virtual void accept(ir_visitor *v) + { + v->visit(this); + } + + virtual ir_visitor_status accept(ir_hierarchical_visitor *); + + /** + * Get a generic ir_call object when an error occurs + * + * Any allocation will be performed with 'ctx' as ralloc owner. + */ + static ir_call *get_error_instruction(void *ctx); + + /** + * Get an iterator for the set of acutal parameters + */ + exec_list_iterator iterator() + { + return actual_parameters.iterator(); + } + + /** + * Get the name of the function being called. + */ + const char *callee_name() const + { + return callee->function_name(); + } + + /** + * Get the function signature bound to this function call + */ + ir_function_signature *get_callee() + { + return callee; + } + + /** + * Set the function call target + */ + void set_callee(ir_function_signature *sig); + + /** + * Generates an inline version of the function before @ir, + * returning the return value of the function. + */ + ir_rvalue *generate_inline(ir_instruction *ir, ir_function_signature* parent); + + /* List of ir_rvalue of paramaters passed in this call. */ + exec_list actual_parameters; + + /** Should this call only bind to a built-in function? */ + bool use_builtin; + +private: + ir_call() + : ir_rvalue(glsl_precision_undefined), callee(NULL) + { + this->ir_type = ir_type_call; + } + + ir_function_signature *callee; +}; + + +/** + * \name Jump-like IR instructions. + * + * These include \c break, \c continue, \c return, and \c discard. + */ +/*@{*/ +class ir_jump : public ir_instruction { +protected: + ir_jump() + { + ir_type = ir_type_unset; + } +}; + +class ir_return : public ir_jump { +public: + ir_return() + : value(NULL) + { + this->ir_type = ir_type_return; + } + + ir_return(ir_rvalue *value) + : value(value) + { + this->ir_type = ir_type_return; + } + + virtual ir_return *clone(void *mem_ctx, struct hash_table *) const; + + virtual ir_return *as_return() + { + return this; + } + + ir_rvalue *get_value() const + { + return value; + } + + virtual void accept(ir_visitor *v) + { + v->visit(this); + } + + virtual ir_visitor_status accept(ir_hierarchical_visitor *); + + ir_rvalue *value; +}; + + +/** + * Jump instructions used inside loops + * + * These include \c break and \c continue. The \c break within a loop is + * different from the \c break within a switch-statement. + * + * \sa ir_switch_jump + */ +class ir_loop_jump : public ir_jump { +public: + enum jump_mode { + jump_break, + jump_continue + }; + + ir_loop_jump(jump_mode mode) + { + this->ir_type = ir_type_loop_jump; + this->mode = mode; + this->loop = loop; + } + + virtual ir_loop_jump *clone(void *mem_ctx, struct hash_table *) const; + + virtual void accept(ir_visitor *v) + { + v->visit(this); + } + + virtual ir_visitor_status accept(ir_hierarchical_visitor *); + + bool is_break() const + { + return mode == jump_break; + } + + bool is_continue() const + { + return mode == jump_continue; + } + + /** Mode selector for the jump instruction. */ + enum jump_mode mode; +private: + /** Loop containing this break instruction. */ + ir_loop *loop; +}; + +/** + * IR instruction representing discard statements. + */ +class ir_discard : public ir_jump { +public: + ir_discard() + { + this->ir_type = ir_type_discard; + this->condition = NULL; + } + + ir_discard(ir_rvalue *cond) + { + this->ir_type = ir_type_discard; + this->condition = cond; + } + + virtual ir_discard *clone(void *mem_ctx, struct hash_table *ht) const; + + virtual void accept(ir_visitor *v) + { + v->visit(this); + } + + virtual ir_visitor_status accept(ir_hierarchical_visitor *); + + virtual ir_discard *as_discard() + { + return this; + } + + ir_rvalue *condition; +}; +/*@}*/ + + +/** + * Texture sampling opcodes used in ir_texture + */ +enum ir_texture_opcode { + ir_tex, /**< Regular texture look-up */ + ir_txb, /**< Texture look-up with LOD bias */ + ir_txl, /**< Texture look-up with explicit LOD */ + ir_txd, /**< Texture look-up with partial derivatvies */ + ir_txf /**< Texel fetch with explicit LOD */ +}; + + +/** + * IR instruction to sample a texture + * + * The specific form of the IR instruction depends on the \c mode value + * selected from \c ir_texture_opcodes. In the printed IR, these will + * appear as: + * + * Texel offset (0 or an expression) + * | Projection divisor + * | | Shadow comparitor + * | | | + * v v v + * (tex 0 1 ( )) + * (txb 0 1 ( ) ) + * (txl 0 1 ( ) ) + * (txd 0 1 ( ) (dPdx dPdy)) + * (txf 0 ) + */ +class ir_texture : public ir_rvalue { +public: + ir_texture(enum ir_texture_opcode op) + : ir_rvalue(glsl_precision_low), op(op), projector(NULL), shadow_comparitor(NULL), offset(NULL) + { + this->ir_type = ir_type_texture; + } + + virtual ir_texture *clone(void *mem_ctx, struct hash_table *) const; + + virtual ir_constant *constant_expression_value(); + + virtual void accept(ir_visitor *v) + { + v->visit(this); + } + + virtual ir_visitor_status accept(ir_hierarchical_visitor *); + + /** + * Return a string representing the ir_texture_opcode. + */ + const char *opcode_string(); + + /** Set the sampler and type. */ + void set_sampler(ir_dereference *sampler, const glsl_type *type); + + /** + * Do a reverse-lookup to translate a string into an ir_texture_opcode. + */ + static ir_texture_opcode get_opcode(const char *); + + enum ir_texture_opcode op; + + /** Sampler to use for the texture access. */ + ir_dereference *sampler; + + /** Texture coordinate to sample */ + ir_rvalue *coordinate; + + /** + * Value used for projective divide. + * + * If there is no projective divide (the common case), this will be + * \c NULL. Optimization passes should check for this to point to a constant + * of 1.0 and replace that with \c NULL. + */ + ir_rvalue *projector; + + /** + * Coordinate used for comparison on shadow look-ups. + * + * If there is no shadow comparison, this will be \c NULL. For the + * \c ir_txf opcode, this *must* be \c NULL. + */ + ir_rvalue *shadow_comparitor; + + /** Texel offset. */ + ir_rvalue *offset; + + union { + ir_rvalue *lod; /**< Floating point LOD */ + ir_rvalue *bias; /**< Floating point LOD bias */ + struct { + ir_rvalue *dPdx; /**< Partial derivative of coordinate wrt X */ + ir_rvalue *dPdy; /**< Partial derivative of coordinate wrt Y */ + } grad; + } lod_info; +}; + + +struct ir_swizzle_mask { + unsigned x:2; + unsigned y:2; + unsigned z:2; + unsigned w:2; + + /** + * Number of components in the swizzle. + */ + unsigned num_components:3; + + /** + * Does the swizzle contain duplicate components? + * + * L-value swizzles cannot contain duplicate components. + */ + unsigned has_duplicates:1; +}; + + +class ir_swizzle : public ir_rvalue { +public: + ir_swizzle(ir_rvalue *, unsigned x, unsigned y, unsigned z, unsigned w, + unsigned count); + + ir_swizzle(ir_rvalue *val, const unsigned *components, unsigned count); + + ir_swizzle(ir_rvalue *val, ir_swizzle_mask mask); + + virtual ir_swizzle *clone(void *mem_ctx, struct hash_table *) const; + + virtual ir_constant *constant_expression_value(); + + virtual ir_swizzle *as_swizzle() + { + return this; + } + + /** + * Construct an ir_swizzle from the textual representation. Can fail. + */ + static ir_swizzle *create(ir_rvalue *, const char *, unsigned vector_length); + + virtual void accept(ir_visitor *v) + { + v->visit(this); + } + + virtual ir_visitor_status accept(ir_hierarchical_visitor *); + + bool is_lvalue() const + { + return val->is_lvalue() && !mask.has_duplicates; + } + + /** + * Get the variable that is ultimately referenced by an r-value + */ + virtual ir_variable *variable_referenced() const; + + ir_rvalue *val; + ir_swizzle_mask mask; + +private: + /** + * Initialize the mask component of a swizzle + * + * This is used by the \c ir_swizzle constructors. + */ + void init_mask(const unsigned *components, unsigned count); +}; + + +class ir_dereference : public ir_rvalue { +public: + virtual ir_dereference *clone(void *mem_ctx, struct hash_table *) const = 0; + + virtual ir_dereference *as_dereference() + { + return this; + } + + bool is_lvalue() const; + + /** + * Get the variable that is ultimately referenced by an r-value + */ + virtual ir_variable *variable_referenced() const = 0; + +protected: + ir_dereference(glsl_precision precision) : ir_rvalue(precision) { } +}; + + +class ir_dereference_variable : public ir_dereference { +public: + ir_dereference_variable(ir_variable *var); + + virtual ir_dereference_variable *clone(void *mem_ctx, + struct hash_table *) const; + + virtual ir_constant *constant_expression_value(); + + virtual ir_dereference_variable *as_dereference_variable() + { + return this; + } + + /** + * Get the variable that is ultimately referenced by an r-value + */ + virtual ir_variable *variable_referenced() const + { + return this->var; + } + + virtual ir_variable *whole_variable_referenced() + { + /* ir_dereference_variable objects always dereference the entire + * variable. However, if this dereference is dereferenced by anything + * else, the complete deferefernce chain is not a whole-variable + * dereference. This method should only be called on the top most + * ir_rvalue in a dereference chain. + */ + return this->var; + } + + virtual void accept(ir_visitor *v) + { + v->visit(this); + } + + virtual ir_visitor_status accept(ir_hierarchical_visitor *); + + /** + * Object being dereferenced. + */ + ir_variable *var; +}; + + +class ir_dereference_array : public ir_dereference { +public: + ir_dereference_array(ir_rvalue *value, ir_rvalue *array_index); + + ir_dereference_array(ir_variable *var, ir_rvalue *array_index); + + virtual ir_dereference_array *clone(void *mem_ctx, + struct hash_table *) const; + + virtual ir_constant *constant_expression_value(); + + virtual ir_dereference_array *as_dereference_array() + { + return this; + } + + /** + * Get the variable that is ultimately referenced by an r-value + */ + virtual ir_variable *variable_referenced() const + { + return this->array->variable_referenced(); + } + + virtual void accept(ir_visitor *v) + { + v->visit(this); + } + + virtual ir_visitor_status accept(ir_hierarchical_visitor *); + + ir_rvalue *array; + ir_rvalue *array_index; + +private: + void set_array(ir_rvalue *value); +}; + + +class ir_dereference_record : public ir_dereference { +public: + ir_dereference_record(ir_rvalue *value, const char *field); + + ir_dereference_record(ir_variable *var, const char *field); + + virtual ir_dereference_record *clone(void *mem_ctx, + struct hash_table *) const; + + virtual ir_constant *constant_expression_value(); + + /** + * Get the variable that is ultimately referenced by an r-value + */ + virtual ir_variable *variable_referenced() const + { + return this->record->variable_referenced(); + } + + virtual void accept(ir_visitor *v) + { + v->visit(this); + } + + virtual ir_visitor_status accept(ir_hierarchical_visitor *); + + ir_rvalue *record; + const char *field; +}; + + +/** + * Data stored in an ir_constant + */ +union ir_constant_data { + unsigned u[16]; + int i[16]; + float f[16]; + bool b[16]; +}; + + +class ir_constant : public ir_rvalue { +public: + ir_constant(const struct glsl_type *type, const ir_constant_data *data); + ir_constant(bool b); + ir_constant(unsigned int u); + ir_constant(int i); + ir_constant(float f); + + /** + * Construct an ir_constant from a list of ir_constant values + */ + ir_constant(const struct glsl_type *type, exec_list *values); + + /** + * Construct an ir_constant from a scalar component of another ir_constant + * + * The new \c ir_constant inherits the type of the component from the + * source constant. + * + * \note + * In the case of a matrix constant, the new constant is a scalar, \b not + * a vector. + */ + ir_constant(const ir_constant *c, unsigned i); + + /** + * Return a new ir_constant of the specified type containing all zeros. + */ + static ir_constant *zero(void *mem_ctx, const glsl_type *type); + + virtual ir_constant *clone(void *mem_ctx, struct hash_table *) const; + + virtual ir_constant *constant_expression_value(); + + virtual ir_constant *as_constant() + { + return this; + } + + virtual void accept(ir_visitor *v) + { + v->visit(this); + } + + virtual ir_visitor_status accept(ir_hierarchical_visitor *); + + /** + * Get a particular component of a constant as a specific type + * + * This is useful, for example, to get a value from an integer constant + * as a float or bool. This appears frequently when constructors are + * called with all constant parameters. + */ + /*@{*/ + bool get_bool_component(unsigned i) const; + float get_float_component(unsigned i) const; + int get_int_component(unsigned i) const; + unsigned get_uint_component(unsigned i) const; + /*@}*/ + + ir_constant *get_array_element(unsigned i) const; + + ir_constant *get_record_field(const char *name); + + /** + * Determine whether a constant has the same value as another constant + * + * \sa ir_constant::is_zero, ir_constant::is_one, + * ir_constant::is_negative_one + */ + bool has_value(const ir_constant *) const; + + virtual bool is_zero() const; + virtual bool is_one() const; + virtual bool is_negative_one() const; + + /** + * Value of the constant. + * + * The field used to back the values supplied by the constant is determined + * by the type associated with the \c ir_instruction. Constants may be + * scalars, vectors, or matrices. + */ + union ir_constant_data value; + + /* Array elements */ + ir_constant **array_elements; + + /* Structure fields */ + exec_list components; + +private: + /** + * Parameterless constructor only used by the clone method + */ + ir_constant(void); +}; + +/*@}*/ + +/** + * Apply a visitor to each IR node in a list + */ +void +visit_exec_list(exec_list *list, ir_visitor *visitor); + +/** + * Validate invariants on each IR node in a list + */ +void validate_ir_tree(exec_list *instructions); + +struct _mesa_glsl_parse_state; +struct gl_shader_program; + +/** + * Detect whether an unlinked shader contains static recursion + * + * If the list of instructions is determined to contain static recursion, + * \c _mesa_glsl_error will be called to emit error messages for each function + * that is in the recursion cycle. + */ +void +detect_recursion_unlinked(struct _mesa_glsl_parse_state *state, + exec_list *instructions); + +/** + * Detect whether a linked shader contains static recursion + * + * If the list of instructions is determined to contain static recursion, + * \c link_error_printf will be called to emit error messages for each function + * that is in the recursion cycle. In addition, + * \c gl_shader_program::LinkStatus will be set to false. + */ +void +detect_recursion_linked(struct gl_shader_program *prog, + exec_list *instructions); + +/** + * Make a clone of each IR instruction in a list + * + * \param in List of IR instructions that are to be cloned + * \param out List to hold the cloned instructions + */ +void +clone_ir_list(void *mem_ctx, exec_list *out, const exec_list *in); + +extern void +_mesa_glsl_initialize_variables(exec_list *instructions, + struct _mesa_glsl_parse_state *state); + +extern void +_mesa_glsl_initialize_functions(_mesa_glsl_parse_state *state); + +extern void +_mesa_glsl_release_functions(void); + +extern void +reparent_ir(exec_list *list, void *mem_ctx); + +struct glsl_symbol_table; + +extern void +import_prototypes(const exec_list *source, exec_list *dest, + struct glsl_symbol_table *symbols, void *mem_ctx); + +extern bool +ir_has_call(ir_instruction *ir); + +extern bool +ir_has_call_skip_builtins(ir_instruction *ir); + +extern void +do_set_program_inouts(exec_list *instructions, struct gl_program *prog); + +extern glsl_precision +precision_from_ir (ir_instruction* ir); + + +extern glsl_precision higher_precision (ir_instruction* a, ir_instruction* b); +static inline glsl_precision higher_precision (glsl_precision a, glsl_precision b) +{ + return MIN2 (a, b); +} + +extern char * +prototype_string(const glsl_type *return_type, const char *name, + exec_list *parameters); + +#endif /* IR_H */ diff --git a/3rdparty/glsl-optimizer/src/glsl/ir_basic_block.cpp b/3rdparty/glsl-optimizer/src/glsl/ir_basic_block.cpp new file mode 100644 index 000000000..4361c2380 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/ir_basic_block.cpp @@ -0,0 +1,160 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file ir_basic_block.cpp + * + * Basic block analysis of instruction streams. + */ + +#include "ir.h" +#include "ir_visitor.h" +#include "ir_basic_block.h" +#include "glsl_types.h" + +class ir_has_call_visitor : public ir_hierarchical_visitor { +public: + ir_has_call_visitor(bool skipBuiltins) + { + has_call = false; + skip_builtins = skipBuiltins; + } + + virtual ir_visitor_status visit_enter(ir_call *ir) + { + (void) ir; + if (!skip_builtins || !ir->get_callee() || !ir->get_callee()->is_builtin) + has_call = true; + return visit_stop; + } + + bool has_call; + bool skip_builtins; +}; + +bool +ir_has_call(ir_instruction *ir) +{ + ir_has_call_visitor v(false); + ir->accept(&v); + return v.has_call; +} + +bool +ir_has_call_skip_builtins(ir_instruction *ir) +{ + ir_has_call_visitor v(true); + ir->accept(&v); + return v.has_call; +} + +/** + * Calls a user function for every basic block in the instruction stream. + * + * Basic block analysis is pretty easy in our IR thanks to the lack of + * unstructured control flow. We've got: + * + * ir_loop (for () {}, while () {}, do {} while ()) + * ir_loop_jump ( + * ir_if () {} + * ir_return + * ir_call() + * + * Note that the basic blocks returned by this don't encompass all + * operations performed by the program -- for example, if conditions + * don't get returned, nor do the assignments that will be generated + * for ir_call parameters. + */ +void call_for_basic_blocks(exec_list *instructions, + void (*callback)(ir_instruction *first, + ir_instruction *last, + void *data), + void *data) +{ + ir_instruction *leader = NULL; + ir_instruction *last = NULL; + + foreach_iter(exec_list_iterator, iter, *instructions) { + ir_instruction *ir = (ir_instruction *)iter.get(); + ir_if *ir_if; + ir_loop *ir_loop; + ir_function *ir_function; + + if (!leader) + leader = ir; + + if ((ir_if = ir->as_if())) { + callback(leader, ir, data); + leader = NULL; + + call_for_basic_blocks(&ir_if->then_instructions, callback, data); + call_for_basic_blocks(&ir_if->else_instructions, callback, data); + } else if ((ir_loop = ir->as_loop())) { + callback(leader, ir, data); + leader = NULL; + call_for_basic_blocks(&ir_loop->body_instructions, callback, data); + } else if (ir->as_return() || ir->as_call()) { + callback(leader, ir, data); + leader = NULL; + } else if ((ir_function = ir->as_function())) { + /* A function definition doesn't interrupt our basic block + * since execution doesn't go into it. We should process the + * bodies of its signatures for BBs, though. + * + * Note that we miss an opportunity for producing more + * maximal BBs between the instructions that precede main() + * and the body of main(). Perhaps those instructions ought + * to live inside of main(). + */ + foreach_iter(exec_list_iterator, fun_iter, *ir_function) { + ir_function_signature *ir_sig; + + ir_sig = (ir_function_signature *)fun_iter.get(); + + call_for_basic_blocks(&ir_sig->body, callback, data); + } + } else if (ir->as_assignment()) { + /* If there's a call in the expression tree being assigned, + * then that ends the BB too. + * + * The assumption is that any consumer of the basic block + * walker is fine with the fact that the call is somewhere in + * the tree even if portions of the tree may be evaluated + * after the call. + * + * A consumer that has an issue with this could not process + * the last instruction of the basic block. If doing so, + * expression flattener may be useful before using the basic + * block finder to get more maximal basic blocks out. + */ + if (ir_has_call_skip_builtins(ir)) { + callback(leader, ir, data); + leader = NULL; + } + } + last = ir; + } + if (leader) { + callback(leader, last, data); + } +} diff --git a/3rdparty/glsl-optimizer/src/glsl/ir_basic_block.h b/3rdparty/glsl-optimizer/src/glsl/ir_basic_block.h new file mode 100644 index 000000000..dbd678b5c --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/ir_basic_block.h @@ -0,0 +1,28 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +void call_for_basic_blocks(exec_list *instructions, + void (*callback)(ir_instruction *first, + ir_instruction *last, + void *data), + void *data); diff --git a/3rdparty/glsl-optimizer/src/glsl/ir_clone.cpp b/3rdparty/glsl-optimizer/src/glsl/ir_clone.cpp new file mode 100644 index 000000000..acc258141 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/ir_clone.cpp @@ -0,0 +1,440 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include +#include "main/compiler.h" +#include "ir.h" +#include "glsl_types.h" +extern "C" { +#include "program/hash_table.h" +} + +/** + * Duplicate an IR variable + * + * \note + * This will probably be made \c virtual and moved to the base class + * eventually. + */ +ir_variable * +ir_variable::clone(void *mem_ctx, struct hash_table *ht) const +{ + ir_variable *var = new(mem_ctx) ir_variable(this->type, this->name, + (ir_variable_mode) this->mode, (glsl_precision)this->precision); + + var->max_array_access = this->max_array_access; + var->read_only = this->read_only; + var->centroid = this->centroid; + var->invariant = this->invariant; + var->interpolation = this->interpolation; + var->array_lvalue = this->array_lvalue; + var->location = this->location; + var->warn_extension = this->warn_extension; + var->origin_upper_left = this->origin_upper_left; + var->pixel_center_integer = this->pixel_center_integer; + var->explicit_location = this->explicit_location; + + var->num_state_slots = this->num_state_slots; + if (this->state_slots) { + /* FINISHME: This really wants to use something like talloc_reference, but + * FINISHME: ralloc doesn't have any similar function. + */ + var->state_slots = ralloc_array(var, ir_state_slot, + this->num_state_slots); + memcpy(var->state_slots, this->state_slots, + sizeof(this->state_slots[0]) * var->num_state_slots); + } + + if (this->explicit_location) + var->location = this->location; + + if (this->constant_value) + var->constant_value = this->constant_value->clone(mem_ctx, ht); + + if (ht) { + hash_table_insert(ht, var, (void *)const_cast(this)); + } + + return var; +} + +ir_swizzle * +ir_swizzle::clone(void *mem_ctx, struct hash_table *ht) const +{ + ir_swizzle* rv = new(mem_ctx) ir_swizzle(this->val->clone(mem_ctx, ht), this->mask); + rv->set_precision (this->get_precision()); + return rv; +} + +ir_return * +ir_return::clone(void *mem_ctx, struct hash_table *ht) const +{ + ir_rvalue *new_value = NULL; + + if (this->value) + new_value = this->value->clone(mem_ctx, ht); + + return new(mem_ctx) ir_return(new_value); +} + +ir_discard * +ir_discard::clone(void *mem_ctx, struct hash_table *ht) const +{ + ir_rvalue *new_condition = NULL; + + if (this->condition != NULL) + new_condition = this->condition->clone(mem_ctx, ht); + + return new(mem_ctx) ir_discard(new_condition); +} + +ir_loop_jump * +ir_loop_jump::clone(void *mem_ctx, struct hash_table *ht) const +{ + (void)ht; + + return new(mem_ctx) ir_loop_jump(this->mode); +} + +ir_if * +ir_if::clone(void *mem_ctx, struct hash_table *ht) const +{ + ir_if *new_if = new(mem_ctx) ir_if(this->condition->clone(mem_ctx, ht)); + + foreach_iter(exec_list_iterator, iter, this->then_instructions) { + ir_instruction *ir = (ir_instruction *)iter.get(); + new_if->then_instructions.push_tail(ir->clone(mem_ctx, ht)); + } + + foreach_iter(exec_list_iterator, iter, this->else_instructions) { + ir_instruction *ir = (ir_instruction *)iter.get(); + new_if->else_instructions.push_tail(ir->clone(mem_ctx, ht)); + } + + return new_if; +} + +ir_loop * +ir_loop::clone(void *mem_ctx, struct hash_table *ht) const +{ + ir_loop *new_loop = new(mem_ctx) ir_loop(); + + if (this->from) + new_loop->from = this->from->clone(mem_ctx, ht); + if (this->to) + new_loop->to = this->to->clone(mem_ctx, ht); + if (this->increment) + new_loop->increment = this->increment->clone(mem_ctx, ht); + new_loop->counter = counter; + + foreach_iter(exec_list_iterator, iter, this->body_instructions) { + ir_instruction *ir = (ir_instruction *)iter.get(); + new_loop->body_instructions.push_tail(ir->clone(mem_ctx, ht)); + } + + new_loop->cmp = this->cmp; + return new_loop; +} + +ir_call * +ir_call::clone(void *mem_ctx, struct hash_table *ht) const +{ + if (this->type == glsl_type::error_type) + return ir_call::get_error_instruction(mem_ctx); + + exec_list new_parameters; + + foreach_iter(exec_list_iterator, iter, this->actual_parameters) { + ir_instruction *ir = (ir_instruction *)iter.get(); + new_parameters.push_tail(ir->clone(mem_ctx, ht)); + } + + ir_call* rv = new(mem_ctx) ir_call(this->callee, &new_parameters); + rv->set_precision (this->get_precision()); + return rv; +} + +ir_expression * +ir_expression::clone(void *mem_ctx, struct hash_table *ht) const +{ + ir_rvalue *op[Elements(this->operands)] = { NULL, }; + unsigned int i; + + for (i = 0; i < get_num_operands(); i++) { + op[i] = this->operands[i]->clone(mem_ctx, ht); + } + + ir_expression* rv = new(mem_ctx) ir_expression(this->operation, this->type, + op[0], op[1], op[2], op[3]); + rv->set_precision (this->get_precision()); + return rv; +} + +ir_dereference_variable * +ir_dereference_variable::clone(void *mem_ctx, struct hash_table *ht) const +{ + ir_variable *new_var; + + if (ht) { + new_var = (ir_variable *)hash_table_find(ht, this->var); + if (!new_var) + new_var = this->var; + } else { + new_var = this->var; + } + + ir_dereference_variable* rv = new(mem_ctx) ir_dereference_variable(new_var); + rv->set_precision (this->get_precision()); + return rv; +} + +ir_dereference_array * +ir_dereference_array::clone(void *mem_ctx, struct hash_table *ht) const +{ + return new(mem_ctx) ir_dereference_array(this->array->clone(mem_ctx, ht), + this->array_index->clone(mem_ctx, + ht)); +} + +ir_dereference_record * +ir_dereference_record::clone(void *mem_ctx, struct hash_table *ht) const +{ + return new(mem_ctx) ir_dereference_record(this->record->clone(mem_ctx, ht), + this->field); +} + +ir_texture * +ir_texture::clone(void *mem_ctx, struct hash_table *ht) const +{ + ir_texture *new_tex = new(mem_ctx) ir_texture(this->op); + new_tex->type = this->type; + + new_tex->sampler = this->sampler->clone(mem_ctx, ht); + new_tex->coordinate = this->coordinate->clone(mem_ctx, ht); + if (this->projector) + new_tex->projector = this->projector->clone(mem_ctx, ht); + if (this->shadow_comparitor) { + new_tex->shadow_comparitor = this->shadow_comparitor->clone(mem_ctx, ht); + } + + if (this->offset != NULL) + new_tex->offset = this->offset->clone(mem_ctx, ht); + + switch (this->op) { + case ir_tex: + break; + case ir_txb: + new_tex->lod_info.bias = this->lod_info.bias->clone(mem_ctx, ht); + break; + case ir_txl: + case ir_txf: + new_tex->lod_info.lod = this->lod_info.lod->clone(mem_ctx, ht); + break; + case ir_txd: + new_tex->lod_info.grad.dPdx = this->lod_info.grad.dPdx->clone(mem_ctx, ht); + new_tex->lod_info.grad.dPdy = this->lod_info.grad.dPdy->clone(mem_ctx, ht); + break; + } + + return new_tex; +} + +ir_assignment * +ir_assignment::clone(void *mem_ctx, struct hash_table *ht) const +{ + ir_rvalue *new_condition = NULL; + + if (this->condition) + new_condition = this->condition->clone(mem_ctx, ht); + + return new(mem_ctx) ir_assignment(this->lhs->clone(mem_ctx, ht), + this->rhs->clone(mem_ctx, ht), + new_condition, + this->write_mask); +} + +ir_function * +ir_function::clone(void *mem_ctx, struct hash_table *ht) const +{ + ir_function *copy = new(mem_ctx) ir_function(this->name); + + foreach_list_const(node, &this->signatures) { + const ir_function_signature *const sig = + (const ir_function_signature *const) node; + + ir_function_signature *sig_copy = sig->clone(mem_ctx, ht); + copy->add_signature(sig_copy); + + if (ht != NULL) + hash_table_insert(ht, sig_copy, + (void *)const_cast(sig)); + } + + return copy; +} + +ir_function_signature * +ir_function_signature::clone(void *mem_ctx, struct hash_table *ht) const +{ + ir_function_signature *copy = this->clone_prototype(mem_ctx, ht); + + copy->is_defined = this->is_defined; + + /* Clone the instruction list. + */ + foreach_list_const(node, &this->body) { + const ir_instruction *const inst = (const ir_instruction *) node; + + ir_instruction *const inst_copy = inst->clone(mem_ctx, ht); + copy->body.push_tail(inst_copy); + } + + return copy; +} + +ir_function_signature * +ir_function_signature::clone_prototype(void *mem_ctx, struct hash_table *ht) const +{ + ir_function_signature *copy = + new(mem_ctx) ir_function_signature(this->return_type, this->precision); + + copy->is_defined = false; + copy->is_builtin = this->is_builtin; + + /* Clone the parameter list, but NOT the body. + */ + foreach_list_const(node, &this->parameters) { + const ir_variable *const param = (const ir_variable *) node; + + assert(const_cast(param)->as_variable() != NULL); + + ir_variable *const param_copy = param->clone(mem_ctx, ht); + copy->parameters.push_tail(param_copy); + } + + return copy; +} + +ir_constant * +ir_constant::clone(void *mem_ctx, struct hash_table *ht) const +{ + (void)ht; + + switch (this->type->base_type) { + case GLSL_TYPE_UINT: + case GLSL_TYPE_INT: + case GLSL_TYPE_FLOAT: + case GLSL_TYPE_BOOL: + return new(mem_ctx) ir_constant(this->type, &this->value); + + case GLSL_TYPE_STRUCT: { + ir_constant *c = new(mem_ctx) ir_constant; + + c->type = this->type; + for (exec_node *node = this->components.head + ; !node->is_tail_sentinel() + ; node = node->next) { + ir_constant *const orig = (ir_constant *) node; + + c->components.push_tail(orig->clone(mem_ctx, NULL)); + } + + return c; + } + + case GLSL_TYPE_ARRAY: { + ir_constant *c = new(mem_ctx) ir_constant; + + c->type = this->type; + c->array_elements = ralloc_array(c, ir_constant *, this->type->length); + for (unsigned i = 0; i < this->type->length; i++) { + c->array_elements[i] = this->array_elements[i]->clone(mem_ctx, NULL); + } + return c; + } + + default: + assert(!"Should not get here."); + return NULL; + } +} + + +class fixup_ir_call_visitor : public ir_hierarchical_visitor { +public: + fixup_ir_call_visitor(struct hash_table *ht) + { + this->ht = ht; + } + + virtual ir_visitor_status visit_enter(ir_call *ir) + { + /* Try to find the function signature referenced by the ir_call in the + * table. If it is found, replace it with the value from the table. + */ + ir_function_signature *sig = + (ir_function_signature *) hash_table_find(this->ht, ir->get_callee()); + if (sig != NULL) + ir->set_callee(sig); + + /* Since this may be used before function call parameters are flattened, + * the children also need to be processed. + */ + return visit_continue; + } + +private: + struct hash_table *ht; +}; + + +static void +fixup_function_calls(struct hash_table *ht, exec_list *instructions) +{ + fixup_ir_call_visitor v(ht); + v.run(instructions); +} + + +void +clone_ir_list(void *mem_ctx, exec_list *out, const exec_list *in) +{ + struct hash_table *ht = + hash_table_ctor(0, hash_table_pointer_hash, hash_table_pointer_compare); + + foreach_list_const(node, in) { + const ir_instruction *const original = (ir_instruction *) node; + ir_instruction *copy = original->clone(mem_ctx, ht); + + out->push_tail(copy); + } + + /* Make a pass over the cloned tree to fix up ir_call nodes to point to the + * cloned ir_function_signature nodes. This cannot be done automatically + * during cloning because the ir_call might be a forward reference (i.e., + * the function signature that it references may not have been cloned yet). + */ + fixup_function_calls(ht, out); + + hash_table_dtor(ht); +} diff --git a/3rdparty/glsl-optimizer/src/glsl/ir_constant_expression.cpp b/3rdparty/glsl-optimizer/src/glsl/ir_constant_expression.cpp new file mode 100644 index 000000000..f0299a2c4 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/ir_constant_expression.cpp @@ -0,0 +1,1383 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file ir_constant_expression.cpp + * Evaluate and process constant valued expressions + * + * In GLSL, constant valued expressions are used in several places. These + * must be processed and evaluated very early in the compilation process. + * + * * Sizes of arrays + * * Initializers for uniforms + * * Initializers for \c const variables + */ + +#include +#include "main/core.h" /* for MAX2, MIN2, CLAMP */ +#include "ir.h" +#include "ir_visitor.h" +#include "glsl_types.h" + +static float +dot(ir_constant *op0, ir_constant *op1) +{ + assert(op0->type->is_float() && op1->type->is_float()); + + float result = 0; + for (unsigned c = 0; c < op0->type->components(); c++) + result += op0->value.f[c] * op1->value.f[c]; + + return result; +} + +ir_constant * +ir_expression::constant_expression_value() +{ + if (this->type->is_error()) + return NULL; + + ir_constant *op[Elements(this->operands)] = { NULL, }; + ir_constant_data data; + + memset(&data, 0, sizeof(data)); + + for (unsigned operand = 0; operand < this->get_num_operands(); operand++) { + op[operand] = this->operands[operand]->constant_expression_value(); + if (!op[operand]) + return NULL; + } + + if (op[1] != NULL) + assert(op[0]->type->base_type == op[1]->type->base_type); + + bool op0_scalar = op[0]->type->is_scalar(); + bool op1_scalar = op[1] != NULL && op[1]->type->is_scalar(); + + /* When iterating over a vector or matrix's components, we want to increase + * the loop counter. However, for scalars, we want to stay at 0. + */ + unsigned c0_inc = op0_scalar ? 0 : 1; + unsigned c1_inc = op1_scalar ? 0 : 1; + unsigned components; + if (op1_scalar || !op[1]) { + components = op[0]->type->components(); + } else { + components = op[1]->type->components(); + } + + void *ctx = ralloc_parent(this); + + /* Handle array operations here, rather than below. */ + if (op[0]->type->is_array()) { + assert(op[1] != NULL && op[1]->type->is_array()); + switch (this->operation) { + case ir_binop_all_equal: + return new(ctx) ir_constant(op[0]->has_value(op[1])); + case ir_binop_any_nequal: + return new(ctx) ir_constant(!op[0]->has_value(op[1])); + default: + break; + } + return NULL; + } + + switch (this->operation) { + case ir_unop_bit_not: + switch (op[0]->type->base_type) { + case GLSL_TYPE_INT: + for (unsigned c = 0; c < components; c++) + data.i[c] = ~ op[0]->value.i[c]; + break; + case GLSL_TYPE_UINT: + for (unsigned c = 0; c < components; c++) + data.u[c] = ~ op[0]->value.u[c]; + break; + default: + assert(0); + } + break; + + case ir_unop_logic_not: + assert(op[0]->type->base_type == GLSL_TYPE_BOOL); + for (unsigned c = 0; c < op[0]->type->components(); c++) + data.b[c] = !op[0]->value.b[c]; + break; + + case ir_unop_f2i: + assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); + for (unsigned c = 0; c < op[0]->type->components(); c++) { + data.i[c] = (int) op[0]->value.f[c]; + } + break; + case ir_unop_i2f: + assert(op[0]->type->base_type == GLSL_TYPE_INT); + for (unsigned c = 0; c < op[0]->type->components(); c++) { + data.f[c] = (float) op[0]->value.i[c]; + } + break; + case ir_unop_u2f: + assert(op[0]->type->base_type == GLSL_TYPE_UINT); + for (unsigned c = 0; c < op[0]->type->components(); c++) { + data.f[c] = (float) op[0]->value.u[c]; + } + break; + case ir_unop_b2f: + assert(op[0]->type->base_type == GLSL_TYPE_BOOL); + for (unsigned c = 0; c < op[0]->type->components(); c++) { + data.f[c] = op[0]->value.b[c] ? 1.0F : 0.0F; + } + break; + case ir_unop_f2b: + assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); + for (unsigned c = 0; c < op[0]->type->components(); c++) { + data.b[c] = op[0]->value.f[c] != 0.0F ? true : false; + } + break; + case ir_unop_b2i: + assert(op[0]->type->base_type == GLSL_TYPE_BOOL); + for (unsigned c = 0; c < op[0]->type->components(); c++) { + data.u[c] = op[0]->value.b[c] ? 1 : 0; + } + break; + case ir_unop_i2b: + assert(op[0]->type->is_integer()); + for (unsigned c = 0; c < op[0]->type->components(); c++) { + data.b[c] = op[0]->value.u[c] ? true : false; + } + break; + case ir_unop_u2i: + assert(op[0]->type->base_type == GLSL_TYPE_UINT); + for (unsigned c = 0; c < op[0]->type->components(); c++) { + data.i[c] = op[0]->value.u[c]; + } + break; + case ir_unop_i2u: + assert(op[0]->type->base_type == GLSL_TYPE_INT); + for (unsigned c = 0; c < op[0]->type->components(); c++) { + data.u[c] = op[0]->value.i[c]; + } + break; + case ir_unop_any: + assert(op[0]->type->is_boolean()); + data.b[0] = false; + for (unsigned c = 0; c < op[0]->type->components(); c++) { + if (op[0]->value.b[c]) + data.b[0] = true; + } + break; + + case ir_unop_trunc: + assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); + for (unsigned c = 0; c < op[0]->type->components(); c++) { + data.f[c] = truncf(op[0]->value.f[c]); + } + break; + + case ir_unop_ceil: + assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); + for (unsigned c = 0; c < op[0]->type->components(); c++) { + data.f[c] = ceilf(op[0]->value.f[c]); + } + break; + + case ir_unop_floor: + assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); + for (unsigned c = 0; c < op[0]->type->components(); c++) { + data.f[c] = floorf(op[0]->value.f[c]); + } + break; + + case ir_unop_fract: + for (unsigned c = 0; c < op[0]->type->components(); c++) { + switch (this->type->base_type) { + case GLSL_TYPE_UINT: + data.u[c] = 0; + break; + case GLSL_TYPE_INT: + data.i[c] = 0; + break; + case GLSL_TYPE_FLOAT: + data.f[c] = op[0]->value.f[c] - floor(op[0]->value.f[c]); + break; + default: + assert(0); + } + } + break; + + case ir_unop_sin: + case ir_unop_sin_reduced: + assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); + for (unsigned c = 0; c < op[0]->type->components(); c++) { + data.f[c] = sinf(op[0]->value.f[c]); + } + break; + + case ir_unop_cos: + case ir_unop_cos_reduced: + assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); + for (unsigned c = 0; c < op[0]->type->components(); c++) { + data.f[c] = cosf(op[0]->value.f[c]); + } + break; + + case ir_unop_neg: + for (unsigned c = 0; c < op[0]->type->components(); c++) { + switch (this->type->base_type) { + case GLSL_TYPE_UINT: + data.u[c] = -((int) op[0]->value.u[c]); + break; + case GLSL_TYPE_INT: + data.i[c] = -op[0]->value.i[c]; + break; + case GLSL_TYPE_FLOAT: + data.f[c] = -op[0]->value.f[c]; + break; + default: + assert(0); + } + } + break; + + case ir_unop_abs: + for (unsigned c = 0; c < op[0]->type->components(); c++) { + switch (this->type->base_type) { + case GLSL_TYPE_UINT: + data.u[c] = op[0]->value.u[c]; + break; + case GLSL_TYPE_INT: + data.i[c] = op[0]->value.i[c]; + if (data.i[c] < 0) + data.i[c] = -data.i[c]; + break; + case GLSL_TYPE_FLOAT: + data.f[c] = fabs(op[0]->value.f[c]); + break; + default: + assert(0); + } + } + break; + + case ir_unop_sign: + for (unsigned c = 0; c < op[0]->type->components(); c++) { + switch (this->type->base_type) { + case GLSL_TYPE_UINT: + data.u[c] = op[0]->value.i[c] > 0; + break; + case GLSL_TYPE_INT: + data.i[c] = (op[0]->value.i[c] > 0) - (op[0]->value.i[c] < 0); + break; + case GLSL_TYPE_FLOAT: + data.f[c] = float((op[0]->value.f[c] > 0)-(op[0]->value.f[c] < 0)); + break; + default: + assert(0); + } + } + break; + + case ir_unop_rcp: + assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); + for (unsigned c = 0; c < op[0]->type->components(); c++) { + switch (this->type->base_type) { + case GLSL_TYPE_UINT: + if (op[0]->value.u[c] != 0.0) + data.u[c] = 1 / op[0]->value.u[c]; + break; + case GLSL_TYPE_INT: + if (op[0]->value.i[c] != 0.0) + data.i[c] = 1 / op[0]->value.i[c]; + break; + case GLSL_TYPE_FLOAT: + if (op[0]->value.f[c] != 0.0) + data.f[c] = 1.0F / op[0]->value.f[c]; + break; + default: + assert(0); + } + } + break; + + case ir_unop_rsq: + assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); + for (unsigned c = 0; c < op[0]->type->components(); c++) { + data.f[c] = 1.0F / sqrtf(op[0]->value.f[c]); + } + break; + + case ir_unop_sqrt: + assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); + for (unsigned c = 0; c < op[0]->type->components(); c++) { + data.f[c] = sqrtf(op[0]->value.f[c]); + } + break; + + case ir_unop_exp: + assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); + for (unsigned c = 0; c < op[0]->type->components(); c++) { + data.f[c] = expf(op[0]->value.f[c]); + } + break; + + case ir_unop_exp2: + assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); + for (unsigned c = 0; c < op[0]->type->components(); c++) { + data.f[c] = exp2f(op[0]->value.f[c]); + } + break; + + case ir_unop_log: + assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); + for (unsigned c = 0; c < op[0]->type->components(); c++) { + data.f[c] = logf(op[0]->value.f[c]); + } + break; + + case ir_unop_log2: + assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); + for (unsigned c = 0; c < op[0]->type->components(); c++) { + data.f[c] = log2f(op[0]->value.f[c]); + } + break; + + case ir_unop_dFdx: + case ir_unop_dFdy: + assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); + for (unsigned c = 0; c < op[0]->type->components(); c++) { + data.f[c] = 0.0; + } + break; + + case ir_binop_pow: + assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); + for (unsigned c = 0; c < op[0]->type->components(); c++) { + data.f[c] = powf(op[0]->value.f[c], op[1]->value.f[c]); + } + break; + + case ir_binop_dot: + data.f[0] = dot(op[0], op[1]); + break; + + case ir_binop_min: + assert(op[0]->type == op[1]->type || op0_scalar || op1_scalar); + for (unsigned c = 0, c0 = 0, c1 = 0; + c < components; + c0 += c0_inc, c1 += c1_inc, c++) { + + switch (op[0]->type->base_type) { + case GLSL_TYPE_UINT: + data.u[c] = MIN2(op[0]->value.u[c0], op[1]->value.u[c1]); + break; + case GLSL_TYPE_INT: + data.i[c] = MIN2(op[0]->value.i[c0], op[1]->value.i[c1]); + break; + case GLSL_TYPE_FLOAT: + data.f[c] = MIN2(op[0]->value.f[c0], op[1]->value.f[c1]); + break; + default: + assert(0); + } + } + + break; + case ir_binop_max: + assert(op[0]->type == op[1]->type || op0_scalar || op1_scalar); + for (unsigned c = 0, c0 = 0, c1 = 0; + c < components; + c0 += c0_inc, c1 += c1_inc, c++) { + + switch (op[0]->type->base_type) { + case GLSL_TYPE_UINT: + data.u[c] = MAX2(op[0]->value.u[c0], op[1]->value.u[c1]); + break; + case GLSL_TYPE_INT: + data.i[c] = MAX2(op[0]->value.i[c0], op[1]->value.i[c1]); + break; + case GLSL_TYPE_FLOAT: + data.f[c] = MAX2(op[0]->value.f[c0], op[1]->value.f[c1]); + break; + default: + assert(0); + } + } + break; + + case ir_binop_add: + assert(op[0]->type == op[1]->type || op0_scalar || op1_scalar); + for (unsigned c = 0, c0 = 0, c1 = 0; + c < components; + c0 += c0_inc, c1 += c1_inc, c++) { + + switch (op[0]->type->base_type) { + case GLSL_TYPE_UINT: + data.u[c] = op[0]->value.u[c0] + op[1]->value.u[c1]; + break; + case GLSL_TYPE_INT: + data.i[c] = op[0]->value.i[c0] + op[1]->value.i[c1]; + break; + case GLSL_TYPE_FLOAT: + data.f[c] = op[0]->value.f[c0] + op[1]->value.f[c1]; + break; + default: + assert(0); + } + } + + break; + case ir_binop_sub: + assert(op[0]->type == op[1]->type || op0_scalar || op1_scalar); + for (unsigned c = 0, c0 = 0, c1 = 0; + c < components; + c0 += c0_inc, c1 += c1_inc, c++) { + + switch (op[0]->type->base_type) { + case GLSL_TYPE_UINT: + data.u[c] = op[0]->value.u[c0] - op[1]->value.u[c1]; + break; + case GLSL_TYPE_INT: + data.i[c] = op[0]->value.i[c0] - op[1]->value.i[c1]; + break; + case GLSL_TYPE_FLOAT: + data.f[c] = op[0]->value.f[c0] - op[1]->value.f[c1]; + break; + default: + assert(0); + } + } + + break; + case ir_binop_mul: + /* Check for equal types, or unequal types involving scalars */ + if ((op[0]->type == op[1]->type && !op[0]->type->is_matrix()) + || op0_scalar || op1_scalar) { + for (unsigned c = 0, c0 = 0, c1 = 0; + c < components; + c0 += c0_inc, c1 += c1_inc, c++) { + + switch (op[0]->type->base_type) { + case GLSL_TYPE_UINT: + data.u[c] = op[0]->value.u[c0] * op[1]->value.u[c1]; + break; + case GLSL_TYPE_INT: + data.i[c] = op[0]->value.i[c0] * op[1]->value.i[c1]; + break; + case GLSL_TYPE_FLOAT: + data.f[c] = op[0]->value.f[c0] * op[1]->value.f[c1]; + break; + default: + assert(0); + } + } + } else { + assert(op[0]->type->is_matrix() || op[1]->type->is_matrix()); + + /* Multiply an N-by-M matrix with an M-by-P matrix. Since either + * matrix can be a GLSL vector, either N or P can be 1. + * + * For vec*mat, the vector is treated as a row vector. This + * means the vector is a 1-row x M-column matrix. + * + * For mat*vec, the vector is treated as a column vector. Since + * matrix_columns is 1 for vectors, this just works. + */ + const unsigned n = op[0]->type->is_vector() + ? 1 : op[0]->type->vector_elements; + const unsigned m = op[1]->type->vector_elements; + const unsigned p = op[1]->type->matrix_columns; + for (unsigned j = 0; j < p; j++) { + for (unsigned i = 0; i < n; i++) { + for (unsigned k = 0; k < m; k++) { + data.f[i+n*j] += op[0]->value.f[i+n*k]*op[1]->value.f[k+m*j]; + } + } + } + } + + break; + case ir_binop_div: + /* FINISHME: Emit warning when division-by-zero is detected. */ + assert(op[0]->type == op[1]->type || op0_scalar || op1_scalar); + for (unsigned c = 0, c0 = 0, c1 = 0; + c < components; + c0 += c0_inc, c1 += c1_inc, c++) { + + switch (op[0]->type->base_type) { + case GLSL_TYPE_UINT: + if (op[1]->value.u[c1] == 0) { + data.u[c] = 0; + } else { + data.u[c] = op[0]->value.u[c0] / op[1]->value.u[c1]; + } + break; + case GLSL_TYPE_INT: + if (op[1]->value.i[c1] == 0) { + data.i[c] = 0; + } else { + data.i[c] = op[0]->value.i[c0] / op[1]->value.i[c1]; + } + break; + case GLSL_TYPE_FLOAT: + data.f[c] = op[0]->value.f[c0] / op[1]->value.f[c1]; + break; + default: + assert(0); + } + } + + break; + case ir_binop_mod: + /* FINISHME: Emit warning when division-by-zero is detected. */ + assert(op[0]->type == op[1]->type || op0_scalar || op1_scalar); + for (unsigned c = 0, c0 = 0, c1 = 0; + c < components; + c0 += c0_inc, c1 += c1_inc, c++) { + + switch (op[0]->type->base_type) { + case GLSL_TYPE_UINT: + if (op[1]->value.u[c1] == 0) { + data.u[c] = 0; + } else { + data.u[c] = op[0]->value.u[c0] % op[1]->value.u[c1]; + } + break; + case GLSL_TYPE_INT: + if (op[1]->value.i[c1] == 0) { + data.i[c] = 0; + } else { + data.i[c] = op[0]->value.i[c0] % op[1]->value.i[c1]; + } + break; + case GLSL_TYPE_FLOAT: + /* We don't use fmod because it rounds toward zero; GLSL specifies + * the use of floor. + */ + data.f[c] = op[0]->value.f[c0] - op[1]->value.f[c1] + * floorf(op[0]->value.f[c0] / op[1]->value.f[c1]); + break; + default: + assert(0); + } + } + + break; + + case ir_binop_logic_and: + assert(op[0]->type->base_type == GLSL_TYPE_BOOL); + for (unsigned c = 0; c < op[0]->type->components(); c++) + data.b[c] = op[0]->value.b[c] && op[1]->value.b[c]; + break; + case ir_binop_logic_xor: + assert(op[0]->type->base_type == GLSL_TYPE_BOOL); + for (unsigned c = 0; c < op[0]->type->components(); c++) + data.b[c] = op[0]->value.b[c] ^ op[1]->value.b[c]; + break; + case ir_binop_logic_or: + assert(op[0]->type->base_type == GLSL_TYPE_BOOL); + for (unsigned c = 0; c < op[0]->type->components(); c++) + data.b[c] = op[0]->value.b[c] || op[1]->value.b[c]; + break; + + case ir_binop_less: + assert(op[0]->type == op[1]->type); + for (unsigned c = 0; c < op[0]->type->components(); c++) { + switch (op[0]->type->base_type) { + case GLSL_TYPE_UINT: + data.b[0] = op[0]->value.u[0] < op[1]->value.u[0]; + break; + case GLSL_TYPE_INT: + data.b[0] = op[0]->value.i[0] < op[1]->value.i[0]; + break; + case GLSL_TYPE_FLOAT: + data.b[0] = op[0]->value.f[0] < op[1]->value.f[0]; + break; + default: + assert(0); + } + } + break; + case ir_binop_greater: + assert(op[0]->type == op[1]->type); + for (unsigned c = 0; c < op[0]->type->components(); c++) { + switch (op[0]->type->base_type) { + case GLSL_TYPE_UINT: + data.b[c] = op[0]->value.u[c] > op[1]->value.u[c]; + break; + case GLSL_TYPE_INT: + data.b[c] = op[0]->value.i[c] > op[1]->value.i[c]; + break; + case GLSL_TYPE_FLOAT: + data.b[c] = op[0]->value.f[c] > op[1]->value.f[c]; + break; + default: + assert(0); + } + } + break; + case ir_binop_lequal: + assert(op[0]->type == op[1]->type); + for (unsigned c = 0; c < op[0]->type->components(); c++) { + switch (op[0]->type->base_type) { + case GLSL_TYPE_UINT: + data.b[0] = op[0]->value.u[0] <= op[1]->value.u[0]; + break; + case GLSL_TYPE_INT: + data.b[0] = op[0]->value.i[0] <= op[1]->value.i[0]; + break; + case GLSL_TYPE_FLOAT: + data.b[0] = op[0]->value.f[0] <= op[1]->value.f[0]; + break; + default: + assert(0); + } + } + break; + case ir_binop_gequal: + assert(op[0]->type == op[1]->type); + for (unsigned c = 0; c < op[0]->type->components(); c++) { + switch (op[0]->type->base_type) { + case GLSL_TYPE_UINT: + data.b[0] = op[0]->value.u[0] >= op[1]->value.u[0]; + break; + case GLSL_TYPE_INT: + data.b[0] = op[0]->value.i[0] >= op[1]->value.i[0]; + break; + case GLSL_TYPE_FLOAT: + data.b[0] = op[0]->value.f[0] >= op[1]->value.f[0]; + break; + default: + assert(0); + } + } + break; + case ir_binop_equal: + assert(op[0]->type == op[1]->type); + for (unsigned c = 0; c < components; c++) { + switch (op[0]->type->base_type) { + case GLSL_TYPE_UINT: + data.b[c] = op[0]->value.u[c] == op[1]->value.u[c]; + break; + case GLSL_TYPE_INT: + data.b[c] = op[0]->value.i[c] == op[1]->value.i[c]; + break; + case GLSL_TYPE_FLOAT: + data.b[c] = op[0]->value.f[c] == op[1]->value.f[c]; + break; + default: + assert(0); + } + } + break; + case ir_binop_nequal: + assert(op[0]->type != op[1]->type); + for (unsigned c = 0; c < components; c++) { + switch (op[0]->type->base_type) { + case GLSL_TYPE_UINT: + data.b[c] = op[0]->value.u[c] != op[1]->value.u[c]; + break; + case GLSL_TYPE_INT: + data.b[c] = op[0]->value.i[c] != op[1]->value.i[c]; + break; + case GLSL_TYPE_FLOAT: + data.b[c] = op[0]->value.f[c] != op[1]->value.f[c]; + break; + default: + assert(0); + } + } + break; + case ir_binop_all_equal: + data.b[0] = op[0]->has_value(op[1]); + break; + case ir_binop_any_nequal: + data.b[0] = !op[0]->has_value(op[1]); + break; + + case ir_binop_lshift: + for (unsigned c = 0, c0 = 0, c1 = 0; + c < components; + c0 += c0_inc, c1 += c1_inc, c++) { + + if (op[0]->type->base_type == GLSL_TYPE_INT && + op[1]->type->base_type == GLSL_TYPE_INT) { + data.i[c] = op[0]->value.i[c0] << op[1]->value.i[c1]; + + } else if (op[0]->type->base_type == GLSL_TYPE_INT && + op[1]->type->base_type == GLSL_TYPE_UINT) { + data.i[c] = op[0]->value.i[c0] << op[1]->value.u[c1]; + + } else if (op[0]->type->base_type == GLSL_TYPE_UINT && + op[1]->type->base_type == GLSL_TYPE_INT) { + data.u[c] = op[0]->value.u[c0] << op[1]->value.i[c1]; + + } else if (op[0]->type->base_type == GLSL_TYPE_UINT && + op[1]->type->base_type == GLSL_TYPE_UINT) { + data.u[c] = op[0]->value.u[c0] << op[1]->value.u[c1]; + } + } + break; + + case ir_binop_rshift: + for (unsigned c = 0, c0 = 0, c1 = 0; + c < components; + c0 += c0_inc, c1 += c1_inc, c++) { + + if (op[0]->type->base_type == GLSL_TYPE_INT && + op[1]->type->base_type == GLSL_TYPE_INT) { + data.i[c] = op[0]->value.i[c0] >> op[1]->value.i[c1]; + + } else if (op[0]->type->base_type == GLSL_TYPE_INT && + op[1]->type->base_type == GLSL_TYPE_UINT) { + data.i[c] = op[0]->value.i[c0] >> op[1]->value.u[c1]; + + } else if (op[0]->type->base_type == GLSL_TYPE_UINT && + op[1]->type->base_type == GLSL_TYPE_INT) { + data.u[c] = op[0]->value.u[c0] >> op[1]->value.i[c1]; + + } else if (op[0]->type->base_type == GLSL_TYPE_UINT && + op[1]->type->base_type == GLSL_TYPE_UINT) { + data.u[c] = op[0]->value.u[c0] >> op[1]->value.u[c1]; + } + } + break; + + case ir_binop_bit_and: + for (unsigned c = 0, c0 = 0, c1 = 0; + c < components; + c0 += c0_inc, c1 += c1_inc, c++) { + + switch (op[0]->type->base_type) { + case GLSL_TYPE_INT: + data.i[c] = op[0]->value.i[c0] & op[1]->value.i[c1]; + break; + case GLSL_TYPE_UINT: + data.u[c] = op[0]->value.u[c0] & op[1]->value.u[c1]; + break; + default: + assert(0); + } + } + break; + + case ir_binop_bit_or: + for (unsigned c = 0, c0 = 0, c1 = 0; + c < components; + c0 += c0_inc, c1 += c1_inc, c++) { + + switch (op[0]->type->base_type) { + case GLSL_TYPE_INT: + data.i[c] = op[0]->value.i[c0] | op[1]->value.i[c1]; + break; + case GLSL_TYPE_UINT: + data.u[c] = op[0]->value.u[c0] | op[1]->value.u[c1]; + break; + default: + assert(0); + } + } + break; + + case ir_binop_bit_xor: + for (unsigned c = 0, c0 = 0, c1 = 0; + c < components; + c0 += c0_inc, c1 += c1_inc, c++) { + + switch (op[0]->type->base_type) { + case GLSL_TYPE_INT: + data.i[c] = op[0]->value.i[c0] ^ op[1]->value.i[c1]; + break; + case GLSL_TYPE_UINT: + data.u[c] = op[0]->value.u[c0] ^ op[1]->value.u[c1]; + break; + default: + assert(0); + } + } + break; + + case ir_quadop_vector: + for (unsigned c = 0; c < this->type->vector_elements; c++) { + switch (this->type->base_type) { + case GLSL_TYPE_INT: + data.i[c] = op[c]->value.i[0]; + break; + case GLSL_TYPE_UINT: + data.u[c] = op[c]->value.u[0]; + break; + case GLSL_TYPE_FLOAT: + data.f[c] = op[c]->value.f[0]; + break; + default: + assert(0); + } + } + break; + + default: + /* FINISHME: Should handle all expression types. */ + return NULL; + } + + return new(ctx) ir_constant(this->type, &data); +} + + +ir_constant * +ir_texture::constant_expression_value() +{ + /* texture lookups aren't constant expressions */ + return NULL; +} + + +ir_constant * +ir_swizzle::constant_expression_value() +{ + ir_constant *v = this->val->constant_expression_value(); + + if (v != NULL) { + ir_constant_data data = { { 0 } }; + + const unsigned swiz_idx[4] = { + this->mask.x, this->mask.y, this->mask.z, this->mask.w + }; + + for (unsigned i = 0; i < this->mask.num_components; i++) { + switch (v->type->base_type) { + case GLSL_TYPE_UINT: + case GLSL_TYPE_INT: data.u[i] = v->value.u[swiz_idx[i]]; break; + case GLSL_TYPE_FLOAT: data.f[i] = v->value.f[swiz_idx[i]]; break; + case GLSL_TYPE_BOOL: data.b[i] = v->value.b[swiz_idx[i]]; break; + default: assert(!"Should not get here."); break; + } + } + + void *ctx = ralloc_parent(this); + return new(ctx) ir_constant(this->type, &data); + } + return NULL; +} + + +ir_constant * +ir_dereference_variable::constant_expression_value() +{ + /* This may occur during compile and var->type is glsl_type::error_type */ + if (!var) + return NULL; + + /* The constant_value of a uniform variable is its initializer, + * not the lifetime constant value of the uniform. + */ + if (var->mode == ir_var_uniform) + return NULL; + + if (!var->constant_value) + return NULL; + + return var->constant_value->clone(ralloc_parent(var), NULL); +} + + +ir_constant * +ir_dereference_array::constant_expression_value() +{ + ir_constant *array = this->array->constant_expression_value(); + ir_constant *idx = this->array_index->constant_expression_value(); + + if ((array != NULL) && (idx != NULL)) { + void *ctx = ralloc_parent(this); + if (array->type->is_matrix()) { + /* Array access of a matrix results in a vector. + */ + const unsigned column = idx->value.u[0]; + + const glsl_type *const column_type = array->type->column_type(); + + /* Offset in the constant matrix to the first element of the column + * to be extracted. + */ + const unsigned mat_idx = column * column_type->vector_elements; + + ir_constant_data data = { { 0 } }; + + switch (column_type->base_type) { + case GLSL_TYPE_UINT: + case GLSL_TYPE_INT: + for (unsigned i = 0; i < column_type->vector_elements; i++) + data.u[i] = array->value.u[mat_idx + i]; + + break; + + case GLSL_TYPE_FLOAT: + for (unsigned i = 0; i < column_type->vector_elements; i++) + data.f[i] = array->value.f[mat_idx + i]; + + break; + + default: + assert(!"Should not get here."); + break; + } + + return new(ctx) ir_constant(column_type, &data); + } else if (array->type->is_vector()) { + const unsigned component = idx->value.u[0]; + + return new(ctx) ir_constant(array, component); + } else { + const unsigned index = idx->value.u[0]; + return array->get_array_element(index)->clone(ctx, NULL); + } + } + return NULL; +} + + +ir_constant * +ir_dereference_record::constant_expression_value() +{ + ir_constant *v = this->record->constant_expression_value(); + + return (v != NULL) ? v->get_record_field(this->field) : NULL; +} + + +ir_constant * +ir_assignment::constant_expression_value() +{ + /* FINISHME: Handle CEs involving assignment (return RHS) */ + return NULL; +} + + +ir_constant * +ir_constant::constant_expression_value() +{ + return this; +} + + +ir_constant * +ir_call::constant_expression_value() +{ + if (this->type == glsl_type::error_type) + return NULL; + + /* From the GLSL 1.20 spec, page 23: + * "Function calls to user-defined functions (non-built-in functions) + * cannot be used to form constant expressions." + */ + if (!this->callee->is_builtin) + return NULL; + + unsigned num_parameters = 0; + + /* Check if all parameters are constant */ + ir_constant *op[3]; + foreach_list(n, &this->actual_parameters) { + ir_constant *constant = ((ir_rvalue *) n)->constant_expression_value(); + if (constant == NULL) + return NULL; + + op[num_parameters] = constant; + + assert(num_parameters < 3); + num_parameters++; + } + + /* Individual cases below can either: + * - Assign "expr" a new ir_expression to evaluate (for basic opcodes) + * - Fill "data" with appopriate constant data + * - Return an ir_constant directly. + */ + void *mem_ctx = ralloc_parent(this); + ir_expression *expr = NULL; + + ir_constant_data data; + memset(&data, 0, sizeof(data)); + + const char *callee = this->callee_name(); + if (strcmp(callee, "abs") == 0) { + expr = new(mem_ctx) ir_expression(ir_unop_abs, type, op[0], NULL); + } else if (strcmp(callee, "all") == 0) { + assert(op[0]->type->is_boolean()); + for (unsigned c = 0; c < op[0]->type->components(); c++) { + if (!op[0]->value.b[c]) + return new(mem_ctx) ir_constant(false); + } + return new(mem_ctx) ir_constant(true); + } else if (strcmp(callee, "any") == 0) { + assert(op[0]->type->is_boolean()); + for (unsigned c = 0; c < op[0]->type->components(); c++) { + if (op[0]->value.b[c]) + return new(mem_ctx) ir_constant(true); + } + return new(mem_ctx) ir_constant(false); + } else if (strcmp(callee, "acos") == 0) { + assert(op[0]->type->is_float()); + for (unsigned c = 0; c < op[0]->type->components(); c++) + data.f[c] = acosf(op[0]->value.f[c]); + } else if (strcmp(callee, "acosh") == 0) { + assert(op[0]->type->is_float()); + for (unsigned c = 0; c < op[0]->type->components(); c++) + data.f[c] = acoshf(op[0]->value.f[c]); + } else if (strcmp(callee, "asin") == 0) { + assert(op[0]->type->is_float()); + for (unsigned c = 0; c < op[0]->type->components(); c++) + data.f[c] = asinf(op[0]->value.f[c]); + } else if (strcmp(callee, "asinh") == 0) { + assert(op[0]->type->is_float()); + for (unsigned c = 0; c < op[0]->type->components(); c++) + data.f[c] = asinhf(op[0]->value.f[c]); + } else if (strcmp(callee, "atan") == 0) { + assert(op[0]->type->is_float()); + if (num_parameters == 2) { + assert(op[1]->type->is_float()); + for (unsigned c = 0; c < op[0]->type->components(); c++) + data.f[c] = atan2f(op[0]->value.f[c], op[1]->value.f[c]); + } else { + for (unsigned c = 0; c < op[0]->type->components(); c++) + data.f[c] = atanf(op[0]->value.f[c]); + } + } else if (strcmp(callee, "atanh") == 0) { + assert(op[0]->type->is_float()); + for (unsigned c = 0; c < op[0]->type->components(); c++) + data.f[c] = atanhf(op[0]->value.f[c]); + } else if (strcmp(callee, "dFdx") == 0 || strcmp(callee, "dFdy") == 0) { + return ir_constant::zero(mem_ctx, this->type); + } else if (strcmp(callee, "ceil") == 0) { + expr = new(mem_ctx) ir_expression(ir_unop_ceil, type, op[0], NULL); + } else if (strcmp(callee, "clamp") == 0) { + assert(num_parameters == 3); + unsigned c1_inc = op[1]->type->is_scalar() ? 0 : 1; + unsigned c2_inc = op[2]->type->is_scalar() ? 0 : 1; + for (unsigned c = 0, c1 = 0, c2 = 0; + c < op[0]->type->components(); + c1 += c1_inc, c2 += c2_inc, c++) { + + switch (op[0]->type->base_type) { + case GLSL_TYPE_UINT: + data.u[c] = CLAMP(op[0]->value.u[c], op[1]->value.u[c1], + op[2]->value.u[c2]); + break; + case GLSL_TYPE_INT: + data.i[c] = CLAMP(op[0]->value.i[c], op[1]->value.i[c1], + op[2]->value.i[c2]); + break; + case GLSL_TYPE_FLOAT: + data.f[c] = CLAMP(op[0]->value.f[c], op[1]->value.f[c1], + op[2]->value.f[c2]); + break; + default: + assert(!"Should not get here."); + } + } + } else if (strcmp(callee, "cos") == 0) { + expr = new(mem_ctx) ir_expression(ir_unop_cos, type, op[0], NULL); + } else if (strcmp(callee, "cosh") == 0) { + assert(op[0]->type->is_float()); + for (unsigned c = 0; c < op[0]->type->components(); c++) + data.f[c] = coshf(op[0]->value.f[c]); + } else if (strcmp(callee, "cross") == 0) { + assert(op[0]->type == glsl_type::vec3_type); + assert(op[1]->type == glsl_type::vec3_type); + data.f[0] = (op[0]->value.f[1] * op[1]->value.f[2] - + op[1]->value.f[1] * op[0]->value.f[2]); + data.f[1] = (op[0]->value.f[2] * op[1]->value.f[0] - + op[1]->value.f[2] * op[0]->value.f[0]); + data.f[2] = (op[0]->value.f[0] * op[1]->value.f[1] - + op[1]->value.f[0] * op[0]->value.f[1]); + } else if (strcmp(callee, "degrees") == 0) { + assert(op[0]->type->is_float()); + for (unsigned c = 0; c < op[0]->type->components(); c++) + data.f[c] = 180.0F / M_PI * op[0]->value.f[c]; + } else if (strcmp(callee, "distance") == 0) { + assert(op[0]->type->is_float() && op[1]->type->is_float()); + float length_squared = 0.0; + for (unsigned c = 0; c < op[0]->type->components(); c++) { + float t = op[0]->value.f[c] - op[1]->value.f[c]; + length_squared += t * t; + } + return new(mem_ctx) ir_constant(sqrtf(length_squared)); + } else if (strcmp(callee, "dot") == 0) { + return new(mem_ctx) ir_constant(dot(op[0], op[1])); + } else if (strcmp(callee, "equal") == 0) { + assert(op[0]->type->is_vector() && op[1] && op[1]->type->is_vector()); + for (unsigned c = 0; c < op[0]->type->components(); c++) { + switch (op[0]->type->base_type) { + case GLSL_TYPE_UINT: + data.b[c] = op[0]->value.u[c] == op[1]->value.u[c]; + break; + case GLSL_TYPE_INT: + data.b[c] = op[0]->value.i[c] == op[1]->value.i[c]; + break; + case GLSL_TYPE_FLOAT: + data.b[c] = op[0]->value.f[c] == op[1]->value.f[c]; + break; + case GLSL_TYPE_BOOL: + data.b[c] = op[0]->value.b[c] == op[1]->value.b[c]; + break; + default: + assert(!"Should not get here."); + } + } + } else if (strcmp(callee, "exp") == 0) { + expr = new(mem_ctx) ir_expression(ir_unop_exp, type, op[0], NULL); + } else if (strcmp(callee, "exp2") == 0) { + expr = new(mem_ctx) ir_expression(ir_unop_exp2, type, op[0], NULL); + } else if (strcmp(callee, "faceforward") == 0) { + if (dot(op[2], op[1]) < 0) + return op[0]; + for (unsigned c = 0; c < op[0]->type->components(); c++) + data.f[c] = -op[0]->value.f[c]; + } else if (strcmp(callee, "floor") == 0) { + expr = new(mem_ctx) ir_expression(ir_unop_floor, type, op[0], NULL); + } else if (strcmp(callee, "fract") == 0) { + expr = new(mem_ctx) ir_expression(ir_unop_fract, type, op[0], NULL); + } else if (strcmp(callee, "fwidth") == 0) { + return ir_constant::zero(mem_ctx, this->type); + } else if (strcmp(callee, "greaterThan") == 0) { + assert(op[0]->type->is_vector() && op[1] && op[1]->type->is_vector()); + for (unsigned c = 0; c < op[0]->type->components(); c++) { + switch (op[0]->type->base_type) { + case GLSL_TYPE_UINT: + data.b[c] = op[0]->value.u[c] > op[1]->value.u[c]; + break; + case GLSL_TYPE_INT: + data.b[c] = op[0]->value.i[c] > op[1]->value.i[c]; + break; + case GLSL_TYPE_FLOAT: + data.b[c] = op[0]->value.f[c] > op[1]->value.f[c]; + break; + default: + assert(!"Should not get here."); + } + } + } else if (strcmp(callee, "greaterThanEqual") == 0) { + assert(op[0]->type->is_vector() && op[1] && op[1]->type->is_vector()); + for (unsigned c = 0; c < op[0]->type->components(); c++) { + switch (op[0]->type->base_type) { + case GLSL_TYPE_UINT: + data.b[c] = op[0]->value.u[c] >= op[1]->value.u[c]; + break; + case GLSL_TYPE_INT: + data.b[c] = op[0]->value.i[c] >= op[1]->value.i[c]; + break; + case GLSL_TYPE_FLOAT: + data.b[c] = op[0]->value.f[c] >= op[1]->value.f[c]; + break; + default: + assert(!"Should not get here."); + } + } + } else if (strcmp(callee, "inversesqrt") == 0) { + expr = new(mem_ctx) ir_expression(ir_unop_rsq, type, op[0], NULL); + } else if (strcmp(callee, "length") == 0) { + return new(mem_ctx) ir_constant(sqrtf(dot(op[0], op[0]))); + } else if (strcmp(callee, "lessThan") == 0) { + assert(op[0]->type->is_vector() && op[1] && op[1]->type->is_vector()); + for (unsigned c = 0; c < op[0]->type->components(); c++) { + switch (op[0]->type->base_type) { + case GLSL_TYPE_UINT: + data.b[c] = op[0]->value.u[c] < op[1]->value.u[c]; + break; + case GLSL_TYPE_INT: + data.b[c] = op[0]->value.i[c] < op[1]->value.i[c]; + break; + case GLSL_TYPE_FLOAT: + data.b[c] = op[0]->value.f[c] < op[1]->value.f[c]; + break; + default: + assert(!"Should not get here."); + } + } + } else if (strcmp(callee, "lessThanEqual") == 0) { + assert(op[0]->type->is_vector() && op[1] && op[1]->type->is_vector()); + for (unsigned c = 0; c < op[0]->type->components(); c++) { + switch (op[0]->type->base_type) { + case GLSL_TYPE_UINT: + data.b[c] = op[0]->value.u[c] <= op[1]->value.u[c]; + break; + case GLSL_TYPE_INT: + data.b[c] = op[0]->value.i[c] <= op[1]->value.i[c]; + break; + case GLSL_TYPE_FLOAT: + data.b[c] = op[0]->value.f[c] <= op[1]->value.f[c]; + break; + default: + assert(!"Should not get here."); + } + } + } else if (strcmp(callee, "log") == 0) { + expr = new(mem_ctx) ir_expression(ir_unop_log, type, op[0], NULL); + } else if (strcmp(callee, "log2") == 0) { + expr = new(mem_ctx) ir_expression(ir_unop_log2, type, op[0], NULL); + } else if (strcmp(callee, "matrixCompMult") == 0) { + assert(op[0]->type->is_float() && op[1]->type->is_float()); + for (unsigned c = 0; c < op[0]->type->components(); c++) + data.f[c] = op[0]->value.f[c] * op[1]->value.f[c]; + } else if (strcmp(callee, "max") == 0) { + expr = new(mem_ctx) ir_expression(ir_binop_max, type, op[0], op[1]); + } else if (strcmp(callee, "min") == 0) { + expr = new(mem_ctx) ir_expression(ir_binop_min, type, op[0], op[1]); + } else if (strcmp(callee, "mix") == 0) { + assert(op[0]->type->is_float() && op[1]->type->is_float()); + if (op[2]->type->is_float()) { + unsigned c2_inc = op[2]->type->is_scalar() ? 0 : 1; + unsigned components = op[0]->type->components(); + for (unsigned c = 0, c2 = 0; c < components; c2 += c2_inc, c++) { + data.f[c] = op[0]->value.f[c] * (1 - op[2]->value.f[c2]) + + op[1]->value.f[c] * op[2]->value.f[c2]; + } + } else { + assert(op[2]->type->is_boolean()); + for (unsigned c = 0; c < op[0]->type->components(); c++) + data.f[c] = op[op[2]->value.b[c] ? 1 : 0]->value.f[c]; + } + } else if (strcmp(callee, "mod") == 0) { + expr = new(mem_ctx) ir_expression(ir_binop_mod, type, op[0], op[1]); + } else if (strcmp(callee, "normalize") == 0) { + assert(op[0]->type->is_float()); + float length = sqrtf(dot(op[0], op[0])); + + if (length == 0) + return ir_constant::zero(mem_ctx, this->type); + + for (unsigned c = 0; c < op[0]->type->components(); c++) + data.f[c] = op[0]->value.f[c] / length; + } else if (strcmp(callee, "not") == 0) { + expr = new(mem_ctx) ir_expression(ir_unop_logic_not, type, op[0], NULL); + } else if (strcmp(callee, "notEqual") == 0) { + assert(op[0]->type->is_vector() && op[1] && op[1]->type->is_vector()); + for (unsigned c = 0; c < op[0]->type->components(); c++) { + switch (op[0]->type->base_type) { + case GLSL_TYPE_UINT: + data.b[c] = op[0]->value.u[c] != op[1]->value.u[c]; + break; + case GLSL_TYPE_INT: + data.b[c] = op[0]->value.i[c] != op[1]->value.i[c]; + break; + case GLSL_TYPE_FLOAT: + data.b[c] = op[0]->value.f[c] != op[1]->value.f[c]; + break; + case GLSL_TYPE_BOOL: + data.b[c] = op[0]->value.b[c] != op[1]->value.b[c]; + break; + default: + assert(!"Should not get here."); + } + } + } else if (strcmp(callee, "outerProduct") == 0) { + assert(op[0]->type->is_vector() && op[1]->type->is_vector()); + const unsigned m = op[0]->type->vector_elements; + const unsigned n = op[1]->type->vector_elements; + for (unsigned j = 0; j < n; j++) { + for (unsigned i = 0; i < m; i++) { + data.f[i+m*j] = op[0]->value.f[i] * op[1]->value.f[j]; + } + } + } else if (strcmp(callee, "pow") == 0) { + expr = new(mem_ctx) ir_expression(ir_binop_pow, type, op[0], op[1]); + } else if (strcmp(callee, "radians") == 0) { + assert(op[0]->type->is_float()); + for (unsigned c = 0; c < op[0]->type->components(); c++) + data.f[c] = M_PI / 180.0F * op[0]->value.f[c]; + } else if (strcmp(callee, "reflect") == 0) { + assert(op[0]->type->is_float()); + float dot_NI = dot(op[1], op[0]); + for (unsigned c = 0; c < op[0]->type->components(); c++) + data.f[c] = op[0]->value.f[c] - 2 * dot_NI * op[1]->value.f[c]; + } else if (strcmp(callee, "refract") == 0) { + const float eta = op[2]->value.f[0]; + const float dot_NI = dot(op[1], op[0]); + const float k = 1.0F - eta * eta * (1.0F - dot_NI * dot_NI); + if (k < 0.0) { + return ir_constant::zero(mem_ctx, this->type); + } else { + for (unsigned c = 0; c < type->components(); c++) { + data.f[c] = eta * op[0]->value.f[c] - (eta * dot_NI + sqrtf(k)) + * op[1]->value.f[c]; + } + } + } else if (strcmp(callee, "sign") == 0) { + expr = new(mem_ctx) ir_expression(ir_unop_sign, type, op[0], NULL); + } else if (strcmp(callee, "sin") == 0) { + expr = new(mem_ctx) ir_expression(ir_unop_sin, type, op[0], NULL); + } else if (strcmp(callee, "sinh") == 0) { + assert(op[0]->type->is_float()); + for (unsigned c = 0; c < op[0]->type->components(); c++) + data.f[c] = sinhf(op[0]->value.f[c]); + } else if (strcmp(callee, "smoothstep") == 0) { + assert(num_parameters == 3); + assert(op[1]->type == op[0]->type); + unsigned edge_inc = op[0]->type->is_scalar() ? 0 : 1; + for (unsigned c = 0, e = 0; c < type->components(); e += edge_inc, c++) { + const float edge0 = op[0]->value.f[e]; + const float edge1 = op[1]->value.f[e]; + if (edge0 == edge1) { + data.f[c] = 0.0; /* Avoid a crash - results are undefined anyway */ + } else { + const float numerator = op[2]->value.f[c] - edge0; + const float denominator = edge1 - edge0; + const float t = CLAMP(numerator/denominator, 0, 1); + data.f[c] = t * t * (3 - 2 * t); + } + } + } else if (strcmp(callee, "sqrt") == 0) { + expr = new(mem_ctx) ir_expression(ir_unop_sqrt, type, op[0], NULL); + } else if (strcmp(callee, "step") == 0) { + assert(op[0]->type->is_float() && op[1]->type->is_float()); + /* op[0] (edge) may be either a scalar or a vector */ + const unsigned c0_inc = op[0]->type->is_scalar() ? 0 : 1; + for (unsigned c = 0, c0 = 0; c < type->components(); c0 += c0_inc, c++) + data.f[c] = (op[1]->value.f[c] < op[0]->value.f[c0]) ? 0.0F : 1.0F; + } else if (strcmp(callee, "tan") == 0) { + assert(op[0]->type->is_float()); + for (unsigned c = 0; c < op[0]->type->components(); c++) + data.f[c] = tanf(op[0]->value.f[c]); + } else if (strcmp(callee, "tanh") == 0) { + assert(op[0]->type->is_float()); + for (unsigned c = 0; c < op[0]->type->components(); c++) + data.f[c] = tanhf(op[0]->value.f[c]); + } else if (strcmp(callee, "transpose") == 0) { + assert(op[0]->type->is_matrix()); + const unsigned n = op[0]->type->vector_elements; + const unsigned m = op[0]->type->matrix_columns; + for (unsigned j = 0; j < m; j++) { + for (unsigned i = 0; i < n; i++) { + data.f[m*i+j] += op[0]->value.f[i+n*j]; + } + } + } else { + /* Unsupported builtin - some are not allowed in constant expressions. */ + return NULL; + } + + if (expr != NULL) + return expr->constant_expression_value(); + + return new(mem_ctx) ir_constant(this->type, &data); +} diff --git a/3rdparty/glsl-optimizer/src/glsl/ir_expression_flattening.cpp b/3rdparty/glsl-optimizer/src/glsl/ir_expression_flattening.cpp new file mode 100644 index 000000000..ce8c20487 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/ir_expression_flattening.cpp @@ -0,0 +1,92 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file ir_expression_flattening.cpp + * + * Takes the leaves of expression trees and makes them dereferences of + * assignments of the leaves to temporaries, according to a predicate. + * + * This is used for automatic function inlining, where we want to take + * an expression containing a call and move the call out to its own + * assignment so that we can inline it at the appropriate place in the + * instruction stream. + */ + +#include "ir.h" +#include "ir_visitor.h" +#include "ir_rvalue_visitor.h" +#include "ir_expression_flattening.h" +#include "glsl_types.h" + +class ir_expression_flattening_visitor : public ir_rvalue_visitor { +public: + ir_expression_flattening_visitor(bool (*predicate)(ir_instruction *ir)) + { + this->predicate = predicate; + } + + virtual ~ir_expression_flattening_visitor() + { + /* empty */ + } + + void handle_rvalue(ir_rvalue **rvalue); + bool (*predicate)(ir_instruction *ir); +}; + +void +do_expression_flattening(exec_list *instructions, + bool (*predicate)(ir_instruction *ir)) +{ + ir_expression_flattening_visitor v(predicate); + + foreach_iter(exec_list_iterator, iter, *instructions) { + ir_instruction *ir = (ir_instruction *)iter.get(); + + ir->accept(&v); + } +} + +void +ir_expression_flattening_visitor::handle_rvalue(ir_rvalue **rvalue) +{ + ir_variable *var; + ir_assignment *assign; + ir_rvalue *ir = *rvalue; + + if (!ir || !this->predicate(ir)) + return; + + void *ctx = ralloc_parent(ir); + + var = new(ctx) ir_variable(ir->type, "flattening_tmp", ir_var_temporary, precision_from_ir(ir)); + base_ir->insert_before(var); + + assign = new(ctx) ir_assignment(new(ctx) ir_dereference_variable(var), + ir, + NULL); + base_ir->insert_before(assign); + + *rvalue = new(ctx) ir_dereference_variable(var); +} diff --git a/3rdparty/glsl-optimizer/src/glsl/ir_expression_flattening.h b/3rdparty/glsl-optimizer/src/glsl/ir_expression_flattening.h new file mode 100644 index 000000000..2eda15900 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/ir_expression_flattening.h @@ -0,0 +1,38 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + + +/** + * \file ir_expression_flattening.h + * + * Takes the leaves of expression trees and makes them dereferences of + * assignments of the leaves to temporaries, according to a predicate. + * + * This is used for automatic function inlining, where we want to take + * an expression containing a call and move the call out to its own + * assignment so that we can inline it at the appropriate place in the + * instruction stream. + */ + +void do_expression_flattening(exec_list *instructions, + bool (*predicate)(ir_instruction *ir)); diff --git a/3rdparty/glsl-optimizer/src/glsl/ir_function.cpp b/3rdparty/glsl-optimizer/src/glsl/ir_function.cpp new file mode 100644 index 000000000..51d32b46f --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/ir_function.cpp @@ -0,0 +1,205 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include "glsl_types.h" +#include "ir.h" + +typedef enum { + PARAMETER_LIST_NO_MATCH, + PARAMETER_LIST_EXACT_MATCH, + PARAMETER_LIST_INEXACT_MATCH /*< Match requires implicit conversion. */ +} parameter_list_match_t; + +/** + * \brief Check if two parameter lists match. + * + * \param list_a Parameters of the function definition. + * \param list_b Actual parameters passed to the function. + * \see matching_signature() + */ +static parameter_list_match_t +parameter_lists_match(const exec_list *list_a, const exec_list *list_b) +{ + const exec_node *node_a = list_a->head; + const exec_node *node_b = list_b->head; + + /* This is set to true if there is an inexact match requiring an implicit + * conversion. */ + bool inexact_match = false; + + for (/* empty */ + ; !node_a->is_tail_sentinel() + ; node_a = node_a->next, node_b = node_b->next) { + /* If all of the parameters from the other parameter list have been + * exhausted, the lists have different length and, by definition, + * do not match. + */ + if (node_b->is_tail_sentinel()) + return PARAMETER_LIST_NO_MATCH; + + + const ir_variable *const param = (ir_variable *) node_a; + const ir_instruction *const actual = (ir_instruction *) node_b; + + if (param->type == actual->type) + continue; + + /* Try to find an implicit conversion from actual to param. */ + inexact_match = true; + switch ((enum ir_variable_mode)(param->mode)) { + case ir_var_auto: + case ir_var_uniform: + case ir_var_temporary: + /* These are all error conditions. It is invalid for a parameter to + * a function to be declared as auto (not in, out, or inout) or + * as uniform. + */ + assert(0); + return PARAMETER_LIST_NO_MATCH; + + case ir_var_const_in: + case ir_var_in: + if (!actual->type->can_implicitly_convert_to(param->type)) + return PARAMETER_LIST_NO_MATCH; + break; + + case ir_var_out: + if (!param->type->can_implicitly_convert_to(actual->type)) + return PARAMETER_LIST_NO_MATCH; + break; + + case ir_var_inout: + /* Since there are no bi-directional automatic conversions (e.g., + * there is int -> float but no float -> int), inout parameters must + * be exact matches. + */ + return PARAMETER_LIST_NO_MATCH; + + default: + assert(false); + return PARAMETER_LIST_NO_MATCH; + } + } + + /* If all of the parameters from the other parameter list have been + * exhausted, the lists have different length and, by definition, do not + * match. + */ + if (!node_b->is_tail_sentinel()) + return PARAMETER_LIST_NO_MATCH; + + if (inexact_match) + return PARAMETER_LIST_INEXACT_MATCH; + else + return PARAMETER_LIST_EXACT_MATCH; +} + + +ir_function_signature * +ir_function::matching_signature(const exec_list *actual_parameters) +{ + ir_function_signature *match = NULL; + bool multiple_inexact_matches = false; + + /* From page 42 (page 49 of the PDF) of the GLSL 1.20 spec: + * + * "If an exact match is found, the other signatures are ignored, and + * the exact match is used. Otherwise, if no exact match is found, then + * the implicit conversions in Section 4.1.10 "Implicit Conversions" will + * be applied to the calling arguments if this can make their types match + * a signature. In this case, it is a semantic error if there are + * multiple ways to apply these conversions to the actual arguments of a + * call such that the call can be made to match multiple signatures." + */ + foreach_iter(exec_list_iterator, iter, signatures) { + ir_function_signature *const sig = + (ir_function_signature *) iter.get(); + + switch (parameter_lists_match(& sig->parameters, actual_parameters)) { + case PARAMETER_LIST_EXACT_MATCH: + return sig; + case PARAMETER_LIST_INEXACT_MATCH: + if (match == NULL) + match = sig; + else + multiple_inexact_matches = true; + continue; + case PARAMETER_LIST_NO_MATCH: + continue; + default: + assert(false); + return NULL; + } + } + + /* There is no exact match (we would have returned it by now). If there + * are multiple inexact matches, the call is ambiguous, which is an error. + * + * FINISHME: Report a decent error. Returning NULL will likely result in + * FINISHME: a "no matching signature" error; it should report that the + * FINISHME: call is ambiguous. But reporting errors from here is hard. + */ + if (multiple_inexact_matches) + return NULL; + + return match; +} + + +static bool +parameter_lists_match_exact(const exec_list *list_a, const exec_list *list_b) +{ + const exec_node *node_a = list_a->head; + const exec_node *node_b = list_b->head; + + for (/* empty */ + ; !node_a->is_tail_sentinel() && !node_b->is_tail_sentinel() + ; node_a = node_a->next, node_b = node_b->next) { + ir_variable *a = (ir_variable *) node_a; + ir_variable *b = (ir_variable *) node_b; + + /* If the types of the parameters do not match, the parameters lists + * are different. + */ + if (a->type != b->type) + return false; + } + + /* Unless both lists are exhausted, they differ in length and, by + * definition, do not match. + */ + return (node_a->is_tail_sentinel() == node_b->is_tail_sentinel()); +} + +ir_function_signature * +ir_function::exact_matching_signature(const exec_list *actual_parameters) +{ + foreach_iter(exec_list_iterator, iter, signatures) { + ir_function_signature *const sig = + (ir_function_signature *) iter.get(); + + if (parameter_lists_match_exact(&sig->parameters, actual_parameters)) + return sig; + } + return NULL; +} diff --git a/3rdparty/glsl-optimizer/src/glsl/ir_function_can_inline.cpp b/3rdparty/glsl-optimizer/src/glsl/ir_function_can_inline.cpp new file mode 100644 index 000000000..055fb42a3 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/ir_function_can_inline.cpp @@ -0,0 +1,78 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file ir_function_can_inline.cpp + * + * Determines if we can inline a function call using ir_function_inlining.cpp. + * + * The primary restriction is that we can't return from the function + * other than as the last instruction. We could potentially work + * around this for some constructs by flattening control flow and + * moving the return to the end, or by using breaks from a do {} while + * (0) loop surrounding the function body. + */ + +#include "ir.h" + +class ir_function_can_inline_visitor : public ir_hierarchical_visitor { +public: + ir_function_can_inline_visitor() + { + this->num_returns = 0; + } + + virtual ir_visitor_status visit_enter(ir_return *); + + int num_returns; +}; + +ir_visitor_status +ir_function_can_inline_visitor::visit_enter(ir_return *ir) +{ + (void) ir; + this->num_returns++; + return visit_continue; +} + +bool +can_inline(ir_call *call) +{ + ir_function_can_inline_visitor v; + const ir_function_signature *callee = call->get_callee(); + if (callee->is_builtin) + return false; + if (!callee->is_defined) + return false; + + v.run((exec_list *) &callee->body); + + /* If the function is empty (no last instruction) or does not end with a + * return statement, we need to count the implicit return. + */ + ir_instruction *last = (ir_instruction *)callee->body.get_tail(); + if (last == NULL || !last->as_return()) + v.num_returns++; + + return v.num_returns == 1; +} diff --git a/3rdparty/glsl-optimizer/src/glsl/ir_function_detect_recursion.cpp b/3rdparty/glsl-optimizer/src/glsl/ir_function_detect_recursion.cpp new file mode 100644 index 000000000..8f805bf1b --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/ir_function_detect_recursion.cpp @@ -0,0 +1,370 @@ +/* + * Copyright © 2011 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file ir_function_detect_recursion.cpp + * Determine whether a shader contains static recursion. + * + * Consider the (possibly disjoint) graph of function calls in a shader. If a + * program contains recursion, this graph will contain a cycle. If a function + * is part of a cycle, it will have a caller and it will have a callee (it + * calls another function). + * + * To detect recursion, the function call graph is constructed. The graph is + * repeatedly reduced by removing any function that either has no callees + * (leaf functions) or has no caller. Eventually the only functions that + * remain will be the functions in the cycles. + * + * The GLSL spec is a bit wishy-washy about recursion. + * + * From page 39 (page 45 of the PDF) of the GLSL 1.10 spec: + * + * "Behavior is undefined if recursion is used. Recursion means having any + * function appearing more than once at any one time in the run-time stack + * of function calls. That is, a function may not call itself either + * directly or indirectly. Compilers may give diagnostic messages when + * this is detectable at compile time, but not all such cases can be + * detected at compile time." + * + * From page 79 (page 85 of the PDF): + * + * "22) Should recursion be supported? + * + * DISCUSSION: Probably not necessary, but another example of limiting + * the language based on how it would directly map to hardware. One + * thought is that recursion would benefit ray tracing shaders. On the + * other hand, many recursion operations can also be implemented with the + * user managing the recursion through arrays. RenderMan doesn't support + * recursion. This could be added at a later date, if it proved to be + * necessary. + * + * RESOLVED on September 10, 2002: Implementations are not required to + * support recursion. + * + * CLOSED on September 10, 2002." + * + * From page 79 (page 85 of the PDF): + * + * "56) Is it an error for an implementation to support recursion if the + * specification says recursion is not supported? + * + * ADDED on September 10, 2002. + * + * DISCUSSION: This issues is related to Issue (22). If we say that + * recursion (or some other piece of functionality) is not supported, is + * it an error for an implementation to support it? Perhaps the + * specification should remain silent on these kind of things so that they + * could be gracefully added later as an extension or as part of the + * standard. + * + * RESOLUTION: Languages, in general, have programs that are not + * well-formed in ways a compiler cannot detect. Portability is only + * ensured for well-formed programs. Detecting recursion is an example of + * this. The language will say a well-formed program may not recurse, but + * compilers are not forced to detect that recursion may happen. + * + * CLOSED: November 29, 2002." + * + * In GLSL 1.10 the behavior of recursion is undefined. Compilers don't have + * to reject shaders (at compile-time or link-time) that contain recursion. + * Instead they could work, or crash, or kill a kitten. + * + * From page 44 (page 50 of the PDF) of the GLSL 1.20 spec: + * + * "Recursion is not allowed, not even statically. Static recursion is + * present if the static function call graph of the program contains + * cycles." + * + * This langauge clears things up a bit, but it still leaves a lot of + * questions unanswered. + * + * - Is the error generated at compile-time or link-time? + * + * - Is it an error to have a recursive function that is never statically + * called by main or any function called directly or indirectly by main? + * Technically speaking, such a function is not in the "static function + * call graph of the program" at all. + * + * \bug + * If a shader has multiple cycles, this algorithm may erroneously complain + * about functions that aren't in any cycle, but are in the part of the call + * tree that connects them. For example, if the call graph consists of a + * cycle between A and B, and a cycle between D and E, and B also calls C + * which calls D, then this algorithm will report C as a function which "has + * static recursion" even though it is not part of any cycle. + * + * A better algorithm for cycle detection that doesn't have this drawback can + * be found here: + * + * http://en.wikipedia.org/wiki/Tarjan%E2%80%99s_strongly_connected_components_algorithm + * + * \author Ian Romanick + */ +#include "main/core.h" +#include "ir.h" +#include "glsl_parser_extras.h" +#include "linker.h" +#include "program/hash_table.h" +#include "program.h" + +struct call_node : public exec_node { + class function *func; +}; + +class function { +public: + function(ir_function_signature *sig) + : sig(sig) + { + /* empty */ + } + + + /* Callers of this ralloc-based new need not call delete. It's + * easier to just ralloc_free 'ctx' (or any of its ancestors). */ + static void* operator new(size_t size, void *ctx) + { + void *node; + + node = ralloc_size(ctx, size); + assert(node != NULL); + + return node; + } + + /* If the user *does* call delete, that's OK, we will just + * ralloc_free in that case. */ + static void operator delete(void *node) + { + ralloc_free(node); + } + + ir_function_signature *sig; + + /** List of functions called by this function. */ + exec_list callees; + + /** List of functions that call this function. */ + exec_list callers; +}; + +class has_recursion_visitor : public ir_hierarchical_visitor { +public: + has_recursion_visitor() + : current(NULL) + { + this->mem_ctx = ralloc_context(NULL); + this->function_hash = hash_table_ctor(0, hash_table_pointer_hash, + hash_table_pointer_compare); + } + + ~has_recursion_visitor() + { + hash_table_dtor(this->function_hash); + ralloc_free(this->mem_ctx); + } + + function *get_function(ir_function_signature *sig) + { + function *f = (function *) hash_table_find(this->function_hash, sig); + if (f == NULL) { + f = new(mem_ctx) function(sig); + hash_table_insert(this->function_hash, f, sig); + } + + return f; + } + + virtual ir_visitor_status visit_enter(ir_function_signature *sig) + { + this->current = this->get_function(sig); + return visit_continue; + } + + virtual ir_visitor_status visit_leave(ir_function_signature *sig) + { + (void) sig; + this->current = NULL; + return visit_continue; + } + + virtual ir_visitor_status visit_enter(ir_call *call) + { + /* At global scope this->current will be NULL. Since there is no way to + * call global scope, it can never be part of a cycle. Don't bother + * adding calls from global scope to the graph. + */ + if (this->current == NULL) + return visit_continue; + + function *const target = this->get_function(call->get_callee()); + + /* Create a link from the caller to the callee. + */ + call_node *node = new(mem_ctx) call_node; + node->func = target; + this->current->callees.push_tail(node); + + /* Create a link from the callee to the caller. + */ + node = new(mem_ctx) call_node; + node->func = this->current; + target->callers.push_tail(node); + return visit_continue; + } + + function *current; + struct hash_table *function_hash; + void *mem_ctx; + bool progress; +}; + +static void +destroy_links(exec_list *list, function *f) +{ + foreach_list_safe(node, list) { + struct call_node *n = (struct call_node *) node; + + /* If this is the right function, remove it. Note that the loop cannot + * terminate now. There can be multiple links to a function if it is + * either called multiple times or calls multiple times. + */ + if (n->func == f) + n->remove(); + } +} + + +/** + * Remove a function if it has either no in or no out links + */ +static void +remove_unlinked_functions(const void *key, void *data, void *closure) +{ + has_recursion_visitor *visitor = (has_recursion_visitor *) closure; + function *f = (function *) data; + + if (f->callers.is_empty() || f->callees.is_empty()) { + while (!f->callers.is_empty()) { + struct call_node *n = (struct call_node *) f->callers.pop_head(); + destroy_links(& n->func->callees, f); + } + + while (!f->callees.is_empty()) { + struct call_node *n = (struct call_node *) f->callees.pop_head(); + destroy_links(& n->func->callers, f); + } + + hash_table_remove(visitor->function_hash, key); + visitor->progress = true; + } +} + + +static void +emit_errors_unlinked(const void *key, void *data, void *closure) +{ + struct _mesa_glsl_parse_state *state = + (struct _mesa_glsl_parse_state *) closure; + function *f = (function *) data; + YYLTYPE loc; + + char *proto = prototype_string(f->sig->return_type, + f->sig->function_name(), + &f->sig->parameters); + + memset(&loc, 0, sizeof(loc)); + _mesa_glsl_error(&loc, state, + "function `%s' has static recursion.", + proto); + ralloc_free(proto); +} + + +static void +emit_errors_linked(const void *key, void *data, void *closure) +{ + struct gl_shader_program *prog = + (struct gl_shader_program *) closure; + function *f = (function *) data; + + char *proto = prototype_string(f->sig->return_type, + f->sig->function_name(), + &f->sig->parameters); + + linker_error(prog, "function `%s' has static recursion.\n", proto); + ralloc_free(proto); + prog->LinkStatus = false; +} + + +void +detect_recursion_unlinked(struct _mesa_glsl_parse_state *state, + exec_list *instructions) +{ + has_recursion_visitor v; + + /* Collect all of the information about which functions call which other + * functions. + */ + v.run(instructions); + + /* Remove from the set all of the functions that either have no caller or + * call no other functions. Repeat until no functions are removed. + */ + do { + v.progress = false; + hash_table_call_foreach(v.function_hash, remove_unlinked_functions, & v); + } while (v.progress); + + + /* At this point any functions still in the hash must be part of a cycle. + */ + hash_table_call_foreach(v.function_hash, emit_errors_unlinked, state); +} + + +void +detect_recursion_linked(struct gl_shader_program *prog, + exec_list *instructions) +{ + has_recursion_visitor v; + + /* Collect all of the information about which functions call which other + * functions. + */ + v.run(instructions); + + /* Remove from the set all of the functions that either have no caller or + * call no other functions. Repeat until no functions are removed. + */ + do { + v.progress = false; + hash_table_call_foreach(v.function_hash, remove_unlinked_functions, & v); + } while (v.progress); + + + /* At this point any functions still in the hash must be part of a cycle. + */ + hash_table_call_foreach(v.function_hash, emit_errors_linked, prog); +} diff --git a/3rdparty/glsl-optimizer/src/glsl/ir_function_inlining.h b/3rdparty/glsl-optimizer/src/glsl/ir_function_inlining.h new file mode 100644 index 000000000..6db011bbc --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/ir_function_inlining.h @@ -0,0 +1,30 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file ir_function_inlining.h + * + * Replaces calls to functions with the body of the function. + */ + +bool can_inline(ir_call *call); diff --git a/3rdparty/glsl-optimizer/src/glsl/ir_hierarchical_visitor.cpp b/3rdparty/glsl-optimizer/src/glsl/ir_hierarchical_visitor.cpp new file mode 100644 index 000000000..b5eacd6d2 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/ir_hierarchical_visitor.cpp @@ -0,0 +1,297 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include "ir.h" +#include "ir_hierarchical_visitor.h" + +ir_hierarchical_visitor::ir_hierarchical_visitor() +{ + this->base_ir = NULL; + this->callback = NULL; + this->data = NULL; + this->in_assignee = false; +} + +ir_visitor_status +ir_hierarchical_visitor::visit(ir_variable *ir) +{ + if (this->callback != NULL) + this->callback(ir, this->data); + + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit(ir_constant *ir) +{ + if (this->callback != NULL) + this->callback(ir, this->data); + + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit(ir_loop_jump *ir) +{ + if (this->callback != NULL) + this->callback(ir, this->data); + + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit(ir_dereference_variable *ir) +{ + if (this->callback != NULL) + this->callback(ir, this->data); + + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_enter(ir_loop *ir) +{ + if (this->callback != NULL) + this->callback(ir, this->data); + + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_leave(ir_loop *ir) +{ + (void) ir; + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_enter(ir_function_signature *ir) +{ + if (this->callback != NULL) + this->callback(ir, this->data); + + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_leave(ir_function_signature *ir) +{ + (void) ir; + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_enter(ir_function *ir) +{ + if (this->callback != NULL) + this->callback(ir, this->data); + + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_leave(ir_function *ir) +{ + (void) ir; + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_enter(ir_expression *ir) +{ + if (this->callback != NULL) + this->callback(ir, this->data); + + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_leave(ir_expression *ir) +{ + (void) ir; + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_enter(ir_texture *ir) +{ + if (this->callback != NULL) + this->callback(ir, this->data); + + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_leave(ir_texture *ir) +{ + (void) ir; + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_enter(ir_swizzle *ir) +{ + if (this->callback != NULL) + this->callback(ir, this->data); + + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_leave(ir_swizzle *ir) +{ + (void) ir; + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_enter(ir_dereference_array *ir) +{ + if (this->callback != NULL) + this->callback(ir, this->data); + + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_leave(ir_dereference_array *ir) +{ + (void) ir; + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_enter(ir_dereference_record *ir) +{ + if (this->callback != NULL) + this->callback(ir, this->data); + + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_leave(ir_dereference_record *ir) +{ + (void) ir; + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_enter(ir_assignment *ir) +{ + if (this->callback != NULL) + this->callback(ir, this->data); + + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_leave(ir_assignment *ir) +{ + (void) ir; + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_enter(ir_call *ir) +{ + if (this->callback != NULL) + this->callback(ir, this->data); + + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_leave(ir_call *ir) +{ + (void) ir; + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_enter(ir_return *ir) +{ + if (this->callback != NULL) + this->callback(ir, this->data); + + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_leave(ir_return *ir) +{ + (void) ir; + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_enter(ir_discard *ir) +{ + if (this->callback != NULL) + this->callback(ir, this->data); + + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_leave(ir_discard *ir) +{ + (void) ir; + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_enter(ir_if *ir) +{ + if (this->callback != NULL) + this->callback(ir, this->data); + + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_leave(ir_if *ir) +{ + (void) ir; + return visit_continue; +} + +void +ir_hierarchical_visitor::run(exec_list *instructions) +{ + visit_list_elements(this, instructions); +} + + +void +visit_tree(ir_instruction *ir, + void (*callback)(class ir_instruction *ir, void *data), + void *data) +{ + ir_hierarchical_visitor v; + + v.callback = callback; + v.data = data; + + ir->accept(&v); +} diff --git a/3rdparty/glsl-optimizer/src/glsl/ir_hierarchical_visitor.h b/3rdparty/glsl-optimizer/src/glsl/ir_hierarchical_visitor.h new file mode 100644 index 000000000..bba046db4 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/ir_hierarchical_visitor.h @@ -0,0 +1,184 @@ +/* -*- c++ -*- */ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#pragma once +#ifndef IR_HIERARCHICAL_VISITOR_H +#define IR_HIERARCHICAL_VISITOR_H + +/** + * Enumeration values returned by visit methods to guide processing + */ +enum ir_visitor_status { + visit_continue, /**< Continue visiting as normal. */ + visit_continue_with_parent, /**< Don't visit siblings, continue w/parent. */ + visit_stop /**< Stop visiting immediately. */ +}; + + +/** + * Base class of hierarchical visitors of IR instruction trees + * + * Hierarchical visitors differ from traditional visitors in a couple of + * important ways. Rather than having a single \c visit method for each + * subclass in the composite, there are three kinds of visit methods. + * Leaf-node classes have a traditional \c visit method. Internal-node + * classes have a \c visit_enter method, which is invoked just before + * processing child nodes, and a \c visit_leave method which is invoked just + * after processing child nodes. + * + * In addition, each visit method and the \c accept methods in the composite + * have a return value which guides the navigation. Any of the visit methods + * can choose to continue visiting the tree as normal (by returning \c + * visit_continue), terminate visiting any further nodes immediately (by + * returning \c visit_stop), or stop visiting sibling nodes (by returning \c + * visit_continue_with_parent). + * + * These two changes combine to allow nagivation of children to be implemented + * in the composite's \c accept method. The \c accept method for a leaf-node + * class will simply call the \c visit method, as usual, and pass its return + * value on. The \c accept method for internal-node classes will call the \c + * visit_enter method, call the \c accpet method of each child node, and, + * finally, call the \c visit_leave method. If any of these return a value + * other that \c visit_continue, the correct action must be taken. + * + * The final benefit is that the hierarchical visitor base class need not be + * abstract. Default implementations of every \c visit, \c visit_enter, and + * \c visit_leave method can be provided. By default each of these methods + * simply returns \c visit_continue. This allows a significant reduction in + * derived class code. + * + * For more information about hierarchical visitors, see: + * + * http://c2.com/cgi/wiki?HierarchicalVisitorPattern + * http://c2.com/cgi/wiki?HierarchicalVisitorDiscussion + */ + +class ir_hierarchical_visitor { +public: + ir_hierarchical_visitor(); + + /** + * \name Visit methods for leaf-node classes + */ + /*@{*/ + virtual ir_visitor_status visit(class ir_variable *); + virtual ir_visitor_status visit(class ir_constant *); + virtual ir_visitor_status visit(class ir_loop_jump *); + + /** + * ir_dereference_variable isn't technically a leaf, but it is treated as a + * leaf here for a couple reasons. By not automatically visiting the one + * child ir_variable node from the ir_dereference_variable, ir_variable + * nodes can always be handled as variable declarations. Code that used + * non-hierarchical visitors had to set an "in a dereference" flag to + * determine how to handle an ir_variable. By forcing the visitor to + * handle the ir_variable within the ir_dereference_variable visitor, this + * kludge can be avoided. + * + * In addition, I can envision no use for having separate enter and leave + * methods. Anything that could be done in the enter and leave methods + * that couldn't just be done in the visit method. + */ + virtual ir_visitor_status visit(class ir_dereference_variable *); + /*@}*/ + + /** + * \name Visit methods for internal-node classes + */ + /*@{*/ + virtual ir_visitor_status visit_enter(class ir_loop *); + virtual ir_visitor_status visit_leave(class ir_loop *); + virtual ir_visitor_status visit_enter(class ir_function_signature *); + virtual ir_visitor_status visit_leave(class ir_function_signature *); + virtual ir_visitor_status visit_enter(class ir_function *); + virtual ir_visitor_status visit_leave(class ir_function *); + virtual ir_visitor_status visit_enter(class ir_expression *); + virtual ir_visitor_status visit_leave(class ir_expression *); + virtual ir_visitor_status visit_enter(class ir_texture *); + virtual ir_visitor_status visit_leave(class ir_texture *); + virtual ir_visitor_status visit_enter(class ir_swizzle *); + virtual ir_visitor_status visit_leave(class ir_swizzle *); + virtual ir_visitor_status visit_enter(class ir_dereference_array *); + virtual ir_visitor_status visit_leave(class ir_dereference_array *); + virtual ir_visitor_status visit_enter(class ir_dereference_record *); + virtual ir_visitor_status visit_leave(class ir_dereference_record *); + virtual ir_visitor_status visit_enter(class ir_assignment *); + virtual ir_visitor_status visit_leave(class ir_assignment *); + virtual ir_visitor_status visit_enter(class ir_call *); + virtual ir_visitor_status visit_leave(class ir_call *); + virtual ir_visitor_status visit_enter(class ir_return *); + virtual ir_visitor_status visit_leave(class ir_return *); + virtual ir_visitor_status visit_enter(class ir_discard *); + virtual ir_visitor_status visit_leave(class ir_discard *); + virtual ir_visitor_status visit_enter(class ir_if *); + virtual ir_visitor_status visit_leave(class ir_if *); + /*@}*/ + + + /** + * Utility function to process a linked list of instructions with a visitor + */ + void run(struct exec_list *instructions); + + /* Some visitors may need to insert new variable declarations and + * assignments for portions of a subtree, which means they need a + * pointer to the current instruction in the stream, not just their + * node in the tree rooted at that instruction. + * + * This is implemented by visit_list_elements -- if the visitor is + * not called by it, nothing good will happen. + */ + class ir_instruction *base_ir; + + /** + * Callback function that is invoked on entry to each node visited. + * + * \warning + * Visitor classes derived from \c ir_hierarchical_visitor \b may \b not + * invoke this function. This can be used, for example, to cause the + * callback to be invoked on every node type execpt one. + */ + void (*callback)(class ir_instruction *ir, void *data); + + /** + * Extra data parameter passed to the per-node callback function + */ + void *data; + + /** + * Currently in the LHS of an assignment? + * + * This is set and cleared by the \c ir_assignment::accept method. + */ + bool in_assignee; +}; + +void visit_tree(ir_instruction *ir, + void (*callback)(class ir_instruction *ir, void *data), + void *data); + +ir_visitor_status visit_list_elements(ir_hierarchical_visitor *v, exec_list *l, + bool statement_list = true); + +#endif /* IR_HIERARCHICAL_VISITOR_H */ diff --git a/3rdparty/glsl-optimizer/src/glsl/ir_hv_accept.cpp b/3rdparty/glsl-optimizer/src/glsl/ir_hv_accept.cpp new file mode 100644 index 000000000..8bb578864 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/ir_hv_accept.cpp @@ -0,0 +1,393 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include "ir.h" + +/** + * \file ir_hv_accept.cpp + * Implementations of all hierarchical visitor accept methods for IR + * instructions. + */ + +/** + * Process a list of nodes using a hierarchical vistor. + * + * If statement_list is true (the default), this is a list of statements, so + * v->base_ir will be set to point to each statement just before iterating + * over it, and restored after iteration is complete. If statement_list is + * false, this is a list that appears inside a statement (e.g. a parameter + * list), so v->base_ir will be left alone. + * + * \warning + * This function will operate correctly if a node being processed is removed + * from the list. However, if nodes are added to the list after the node being + * processed, some of the added nodes may not be processed. + */ +ir_visitor_status +visit_list_elements(ir_hierarchical_visitor *v, exec_list *l, + bool statement_list) +{ + ir_instruction *prev_base_ir = v->base_ir; + + foreach_list_safe(n, l) { + ir_instruction *const ir = (ir_instruction *) n; + if (statement_list) + v->base_ir = ir; + ir_visitor_status s = ir->accept(v); + + if (s != visit_continue) + return s; + } + if (statement_list) + v->base_ir = prev_base_ir; + + return visit_continue; +} + + +ir_visitor_status +ir_variable::accept(ir_hierarchical_visitor *v) +{ + return v->visit(this); +} + + +ir_visitor_status +ir_loop::accept(ir_hierarchical_visitor *v) +{ + ir_visitor_status s = v->visit_enter(this); + + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + + s = visit_list_elements(v, &this->body_instructions); + if (s == visit_stop) + return s; + + if (s != visit_continue_with_parent) { + if (this->from) { + s = this->from->accept(v); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + } + + if (this->to) { + s = this->to->accept(v); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + } + + if (this->increment) { + s = this->increment->accept(v); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + } + } + + return v->visit_leave(this); +} + + +ir_visitor_status +ir_loop_jump::accept(ir_hierarchical_visitor *v) +{ + return v->visit(this); +} + + +ir_visitor_status +ir_function_signature::accept(ir_hierarchical_visitor *v) +{ + ir_visitor_status s = v->visit_enter(this); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + + s = visit_list_elements(v, &this->parameters); + if (s == visit_stop) + return s; + + s = visit_list_elements(v, &this->body); + return (s == visit_stop) ? s : v->visit_leave(this); +} + + +ir_visitor_status +ir_function::accept(ir_hierarchical_visitor *v) +{ + ir_visitor_status s = v->visit_enter(this); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + + s = visit_list_elements(v, &this->signatures, false); + return (s == visit_stop) ? s : v->visit_leave(this); +} + + +ir_visitor_status +ir_expression::accept(ir_hierarchical_visitor *v) +{ + ir_visitor_status s = v->visit_enter(this); + + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + + for (unsigned i = 0; i < this->get_num_operands(); i++) { + switch (this->operands[i]->accept(v)) { + case visit_continue: + break; + + case visit_continue_with_parent: + // I wish for Java's labeled break-statement here. + goto done; + + case visit_stop: + return s; + } + } + +done: + return v->visit_leave(this); +} + +ir_visitor_status +ir_texture::accept(ir_hierarchical_visitor *v) +{ + ir_visitor_status s = v->visit_enter(this); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + + s = this->sampler->accept(v); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + + s = this->coordinate->accept(v); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + + if (this->projector) { + s = this->projector->accept(v); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + } + + if (this->shadow_comparitor) { + s = this->shadow_comparitor->accept(v); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + } + + if (this->offset) { + s = this->offset->accept(v); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + } + + switch (this->op) { + case ir_tex: + break; + case ir_txb: + s = this->lod_info.bias->accept(v); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + break; + case ir_txl: + case ir_txf: + s = this->lod_info.lod->accept(v); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + break; + case ir_txd: + s = this->lod_info.grad.dPdx->accept(v); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + + s = this->lod_info.grad.dPdy->accept(v); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + break; + } + + return (s == visit_stop) ? s : v->visit_leave(this); +} + + +ir_visitor_status +ir_swizzle::accept(ir_hierarchical_visitor *v) +{ + ir_visitor_status s = v->visit_enter(this); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + + s = this->val->accept(v); + return (s == visit_stop) ? s : v->visit_leave(this); +} + + +ir_visitor_status +ir_dereference_variable::accept(ir_hierarchical_visitor *v) +{ + return v->visit(this); +} + + +ir_visitor_status +ir_dereference_array::accept(ir_hierarchical_visitor *v) +{ + ir_visitor_status s = v->visit_enter(this); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + + /* The array index is not the target of the assignment, so clear the + * 'in_assignee' flag. Restore it after returning from the array index. + */ + const bool was_in_assignee = v->in_assignee; + v->in_assignee = false; + s = this->array_index->accept(v); + v->in_assignee = was_in_assignee; + + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + + s = this->array->accept(v); + return (s == visit_stop) ? s : v->visit_leave(this); +} + + +ir_visitor_status +ir_dereference_record::accept(ir_hierarchical_visitor *v) +{ + ir_visitor_status s = v->visit_enter(this); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + + s = this->record->accept(v); + return (s == visit_stop) ? s : v->visit_leave(this); +} + + +ir_visitor_status +ir_assignment::accept(ir_hierarchical_visitor *v) +{ + ir_visitor_status s = v->visit_enter(this); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + + v->in_assignee = true; + s = this->lhs->accept(v); + v->in_assignee = false; + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + + s = this->rhs->accept(v); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + + if (this->condition) + s = this->condition->accept(v); + + return (s == visit_stop) ? s : v->visit_leave(this); +} + + +ir_visitor_status +ir_constant::accept(ir_hierarchical_visitor *v) +{ + return v->visit(this); +} + + +ir_visitor_status +ir_call::accept(ir_hierarchical_visitor *v) +{ + ir_visitor_status s = v->visit_enter(this); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + + s = visit_list_elements(v, &this->actual_parameters, false); + if (s == visit_stop) + return s; + + return v->visit_leave(this); +} + + +ir_visitor_status +ir_return::accept(ir_hierarchical_visitor *v) +{ + ir_visitor_status s = v->visit_enter(this); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + + ir_rvalue *val = this->get_value(); + if (val) { + s = val->accept(v); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + } + + return v->visit_leave(this); +} + + +ir_visitor_status +ir_discard::accept(ir_hierarchical_visitor *v) +{ + ir_visitor_status s = v->visit_enter(this); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + + if (this->condition != NULL) { + s = this->condition->accept(v); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + } + + return v->visit_leave(this); +} + + +ir_visitor_status +ir_if::accept(ir_hierarchical_visitor *v) +{ + ir_visitor_status s = v->visit_enter(this); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + + s = this->condition->accept(v); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + + if (s != visit_continue_with_parent) { + s = visit_list_elements(v, &this->then_instructions); + if (s == visit_stop) + return s; + } + + if (s != visit_continue_with_parent) { + s = visit_list_elements(v, &this->else_instructions); + if (s == visit_stop) + return s; + } + + return v->visit_leave(this); +} diff --git a/3rdparty/glsl-optimizer/src/glsl/ir_import_prototypes.cpp b/3rdparty/glsl-optimizer/src/glsl/ir_import_prototypes.cpp new file mode 100644 index 000000000..3585bf6b2 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/ir_import_prototypes.cpp @@ -0,0 +1,122 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file ir_import_prototypes.cpp + * Import function prototypes from one IR tree into another. + * + * \author Ian Romanick + */ +#include "ir.h" +#include "glsl_symbol_table.h" + +/** + * Visitor used to import function prototypes + * + * Normally the \c clone method of either \c ir_function or + * \c ir_function_signature could be used. However, we don't want a complete + * clone of the \c ir_function_signature. We want everything \b except the + * body of the function. + */ +class import_prototype_visitor : public ir_hierarchical_visitor { +public: + /** + */ + import_prototype_visitor(exec_list *list, glsl_symbol_table *symbols, + void *mem_ctx) + { + this->mem_ctx = mem_ctx; + this->list = list; + this->symbols = symbols; + this->function = NULL; + } + + virtual ir_visitor_status visit_enter(ir_function *ir) + { + assert(this->function == NULL); + + this->function = this->symbols->get_function(ir->name); + if (!this->function) { + this->function = new(this->mem_ctx) ir_function(ir->name); + + list->push_tail(this->function); + + /* Add the new function to the symbol table. + */ + this->symbols->add_function(this->function); + } + return visit_continue; + } + + virtual ir_visitor_status visit_leave(ir_function *ir) + { + (void) ir; + assert(this->function != NULL); + + this->function = NULL; + return visit_continue; + } + + ir_visitor_status visit_enter(ir_function_signature *ir) + { + assert(this->function != NULL); + + ir_function_signature *copy = ir->clone_prototype(mem_ctx, NULL); + + this->function->add_signature(copy); + + /* Do not process child nodes of the ir_function_signature. There can + * never be any nodes inside the ir_function_signature that we care + * about. Instead continue with the next sibling. + */ + return visit_continue_with_parent; + } + +private: + exec_list *list; + ir_function *function; + glsl_symbol_table *symbols; + void *mem_ctx; +}; + + +/** + * Import function prototypes from one IR tree into another + * + * \param source Source instruction stream containing functions whose + * prototypes are to be imported + * \param dest Destination instruction stream where new \c ir_function and + * \c ir_function_signature nodes will be stored + * \param symbols Symbol table where new functions will be stored + * \param mem_ctx ralloc memory context used for new allocations + */ +void +import_prototypes(const exec_list *source, exec_list *dest, + glsl_symbol_table *symbols, void *mem_ctx) +{ + import_prototype_visitor v(dest, symbols, mem_ctx); + + /* Making source be const is just extra documentation. + */ + v.run(const_cast(source)); +} diff --git a/3rdparty/glsl-optimizer/src/glsl/ir_optimization.h b/3rdparty/glsl-optimizer/src/glsl/ir_optimization.h new file mode 100644 index 000000000..f7808bdda --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/ir_optimization.h @@ -0,0 +1,75 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + + +/** + * \file ir_optimization.h + * + * Prototypes for optimization passes to be called by the compiler and drivers. + */ + +/* Operations for lower_instructions() */ +#define SUB_TO_ADD_NEG 0x01 +#define DIV_TO_MUL_RCP 0x02 +#define EXP_TO_EXP2 0x04 +#define POW_TO_EXP2 0x08 +#define LOG_TO_LOG2 0x10 +#define MOD_TO_FRACT 0x20 + +bool do_common_optimization(exec_list *ir, bool linked, unsigned max_unroll_iterations); + +bool do_algebraic(exec_list *instructions); +bool do_constant_folding(exec_list *instructions); +bool do_constant_variable(exec_list *instructions); +bool do_constant_variable_unlinked(exec_list *instructions); +bool do_copy_propagation(exec_list *instructions); +bool do_copy_propagation_elements(exec_list *instructions); +bool do_constant_propagation(exec_list *instructions); +bool do_dead_code(exec_list *instructions); +bool do_dead_code_local(exec_list *instructions); +bool do_dead_code_unlinked(exec_list *instructions); +bool do_dead_functions(exec_list *instructions); +bool do_function_inlining(exec_list *instructions); +bool do_lower_jumps(exec_list *instructions, bool pull_out_jumps = true, bool lower_sub_return = true, bool lower_main_return = false, bool lower_continue = false, bool lower_break = false); +bool do_lower_texture_projection(exec_list *instructions); +bool do_if_simplification(exec_list *instructions); +bool do_discard_simplification(exec_list *instructions); +bool lower_if_to_cond_assign(exec_list *instructions, unsigned max_depth = 0); +bool do_mat_op_to_vec(exec_list *instructions); +bool do_noop_swizzle(exec_list *instructions); +bool do_structure_splitting(exec_list *instructions); +bool do_swizzle_swizzle(exec_list *instructions); +bool do_tree_grafting(exec_list *instructions); +bool do_vec_index_to_cond_assign(exec_list *instructions); +bool do_vec_index_to_swizzle(exec_list *instructions); +bool lower_discard(exec_list *instructions); +bool lower_instructions(exec_list *instructions, unsigned what_to_lower); +bool lower_noise(exec_list *instructions); +bool lower_variable_index_to_cond_assign(exec_list *instructions, + bool lower_input, bool lower_output, bool lower_temp, bool lower_uniform); +bool lower_quadop_vector(exec_list *instructions, bool dont_lower_swz); +bool optimize_redundant_jumps(exec_list *instructions); + +ir_rvalue * +compare_index_block(exec_list *instructions, ir_variable *index, + unsigned base, unsigned components, void *mem_ctx); diff --git a/3rdparty/glsl-optimizer/src/glsl/ir_print_glsl_visitor.cpp b/3rdparty/glsl-optimizer/src/glsl/ir_print_glsl_visitor.cpp new file mode 100644 index 000000000..b518bdfc6 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/ir_print_glsl_visitor.cpp @@ -0,0 +1,893 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include "ir_print_glsl_visitor.h" +#include "ir_visitor.h" +#include "glsl_types.h" +#include "glsl_parser_extras.h" +#include "ir_unused_structs.h" +#include "program/hash_table.h" +#include + +static char* print_type(char* buffer, const glsl_type *t, bool arraySize); +static char* print_type_post(char* buffer, const glsl_type *t, bool arraySize); + +static inline const char* get_precision_string (glsl_precision p) +{ + switch (p) { + case glsl_precision_high: return "highp "; + case glsl_precision_medium: return "mediump "; + case glsl_precision_low: return "lowp "; + case glsl_precision_undefined: return ""; + } + assert(!"Should not get here."); + return ""; +} + +struct ga_entry : public exec_node +{ + ga_entry(ir_assignment *ass) + { + assert(ass); + this->ass = ass; + } + ir_assignment* ass; +}; + + +struct global_print_tracker { + global_print_tracker () { + mem_ctx = ralloc_context(0); + temp_var_counter = 0; + temp_var_hash = hash_table_ctor(0, hash_table_pointer_hash, hash_table_pointer_compare); + main_function_done = false; + } + + ~global_print_tracker() { + hash_table_dtor (temp_var_hash); + ralloc_free(mem_ctx); + } + + unsigned temp_var_counter; + hash_table* temp_var_hash; + exec_list global_assignements; + void* mem_ctx; + bool main_function_done; +}; + +class ir_print_glsl_visitor : public ir_visitor { +public: + ir_print_glsl_visitor(char* buf, global_print_tracker* globals_, PrintGlslMode mode_, bool use_precision_) + { + indentation = 0; + buffer = buf; + globals = globals_; + mode = mode_; + use_precision = use_precision_; + } + + virtual ~ir_print_glsl_visitor() + { + } + + + void indent(void); + void print_var_name (ir_variable* v); + void print_precision (ir_instruction* ir); + + virtual void visit(ir_variable *); + virtual void visit(ir_function_signature *); + virtual void visit(ir_function *); + virtual void visit(ir_expression *); + virtual void visit(ir_texture *); + virtual void visit(ir_swizzle *); + virtual void visit(ir_dereference_variable *); + virtual void visit(ir_dereference_array *); + virtual void visit(ir_dereference_record *); + virtual void visit(ir_assignment *); + virtual void visit(ir_constant *); + virtual void visit(ir_call *); + virtual void visit(ir_return *); + virtual void visit(ir_discard *); + virtual void visit(ir_if *); + virtual void visit(ir_loop *); + virtual void visit(ir_loop_jump *); + + int indentation; + char* buffer; + global_print_tracker* globals; + PrintGlslMode mode; + bool use_precision; +}; + + +char* +_mesa_print_ir_glsl(exec_list *instructions, + struct _mesa_glsl_parse_state *state, + char* buffer, PrintGlslMode mode) +{ + if (state) { + if (state->ARB_shader_texture_lod_enable) + ralloc_strcat (&buffer, "#extension GL_ARB_shader_texture_lod : enable\n"); + if (state->EXT_shader_texture_lod_enable) + ralloc_strcat (&buffer, "#extension GL_EXT_shader_texture_lod : enable\n"); + if (state->OES_standard_derivatives_enable) + ralloc_strcat (&buffer, "#extension GL_OES_standard_derivatives : enable\n"); + } + if (state) { + ir_struct_usage_visitor v; + v.run (instructions); + + for (unsigned i = 0; i < state->num_user_structures; i++) { + const glsl_type *const s = state->user_structures[i]; + + if (!v.has_struct_entry(s)) + continue; + + ralloc_asprintf_append (&buffer, "struct %s {\n", + s->name); + + for (unsigned j = 0; j < s->length; j++) { + ralloc_asprintf_append (&buffer, " "); + if (state->es_shader) + ralloc_asprintf_append (&buffer, "%s", get_precision_string(s->fields.structure[j].precision)); + buffer = print_type(buffer, s->fields.structure[j].type, false); + ralloc_asprintf_append (&buffer, " %s", s->fields.structure[j].name); + buffer = print_type_post(buffer, s->fields.structure[j].type, false); + ralloc_asprintf_append (&buffer, ";\n"); + } + + ralloc_asprintf_append (&buffer, "};\n"); + } + } + + global_print_tracker gtracker; + + foreach_iter(exec_list_iterator, iter, *instructions) { + ir_instruction *ir = (ir_instruction *)iter.get(); + if (ir->ir_type == ir_type_variable) { + ir_variable *var = static_cast(ir); + if (strstr(var->name, "gl_") == var->name) + continue; + } + + ir_print_glsl_visitor v (buffer, >racker, mode, state->es_shader); + ir->accept(&v); + buffer = v.buffer; + if (ir->ir_type != ir_type_function) + ralloc_asprintf_append (&buffer, ";\n"); + } + + return buffer; +} + + +void ir_print_glsl_visitor::indent(void) +{ + for (int i = 0; i < indentation; i++) + ralloc_asprintf_append (&buffer, " "); +} + +void ir_print_glsl_visitor::print_var_name (ir_variable* v) +{ + if (v->mode == ir_var_temporary) + { + long tempID = (long)hash_table_find (globals->temp_var_hash, v); + if (tempID == 0) + { + tempID = ++globals->temp_var_counter; + hash_table_insert (globals->temp_var_hash, (void*)tempID, v); + } + ralloc_asprintf_append (&buffer, "tmpvar_%d", tempID); + } + else + { + ralloc_asprintf_append (&buffer, "%s", v->name); + } +} + +void ir_print_glsl_visitor::print_precision (ir_instruction* ir) +{ + if (!this->use_precision) + return; + if (ir->type && !ir->type->is_float() && (!ir->type->is_array() || !ir->type->element_type()->is_float())) + return; + glsl_precision prec = precision_from_ir(ir); + if (prec == glsl_precision_high || prec == glsl_precision_undefined) + { + if (ir->ir_type == ir_type_function_signature) + return; + } + ralloc_asprintf_append (&buffer, "%s", get_precision_string(prec)); +} + + +static char* +print_type(char* buffer, const glsl_type *t, bool arraySize) +{ + if (t->base_type == GLSL_TYPE_ARRAY) { + buffer = print_type(buffer, t->fields.array, true); + if (arraySize) + ralloc_asprintf_append (&buffer, "[%u]", t->length); + } else if ((t->base_type == GLSL_TYPE_STRUCT) + && (strncmp("gl_", t->name, 3) != 0)) { + ralloc_asprintf_append (&buffer, "%s", t->name); + } else { + ralloc_asprintf_append (&buffer, "%s", t->name); + } + return buffer; +} + +static char* +print_type_post(char* buffer, const glsl_type *t, bool arraySize) +{ + if (t->base_type == GLSL_TYPE_ARRAY) { + if (!arraySize) + ralloc_asprintf_append (&buffer, "[%u]", t->length); + } + return buffer; +} + + +void ir_print_glsl_visitor::visit(ir_variable *ir) +{ + const char *const cent = (ir->centroid) ? "centroid " : ""; + const char *const inv = (ir->invariant) ? "invariant " : ""; + const char *const mode[3][8] = + { + { "", "uniform ", "in ", "out ", "inout ", "", "", "" }, + { "", "uniform ", "attribute ", "varying ", "inout ", "", "", "" }, + { "", "uniform ", "varying ", "out ", "inout ", "", "", "" }, + }; + const char *const interp[] = { "", "flat ", "noperspective " }; + + ralloc_asprintf_append (&buffer, "%s%s%s%s", + cent, inv, mode[this->mode][ir->mode], interp[ir->interpolation]); + print_precision (ir); + buffer = print_type(buffer, ir->type, false); + ralloc_asprintf_append (&buffer, " "); + print_var_name (ir); + buffer = print_type_post(buffer, ir->type, false); +} + + +void ir_print_glsl_visitor::visit(ir_function_signature *ir) +{ + this->globals->temp_var_counter = 0; + print_precision (ir); + buffer = print_type(buffer, ir->return_type, true); + ralloc_asprintf_append (&buffer, " %s (", ir->function_name()); + + if (!ir->parameters.is_empty()) + { + ralloc_asprintf_append (&buffer, "\n"); + + indentation++; + bool first = true; + foreach_iter(exec_list_iterator, iter, ir->parameters) { + ir_variable *const inst = (ir_variable *) iter.get(); + + if (!first) + ralloc_asprintf_append (&buffer, ",\n"); + indent(); + inst->accept(this); + first = false; + } + indentation--; + + ralloc_asprintf_append (&buffer, "\n"); + indent(); + } + + if (ir->body.is_empty()) + { + ralloc_asprintf_append (&buffer, ");\n"); + return; + } + + ralloc_asprintf_append (&buffer, ")\n"); + + indent(); + ralloc_asprintf_append (&buffer, "{\n"); + indentation++; + + // insert postponed global assigments + if (strcmp(ir->function()->name, "main") == 0) + { + assert (!globals->main_function_done); + globals->main_function_done = true; + foreach_iter(exec_list_iterator, it, globals->global_assignements) + { + ir_assignment* as = ((ga_entry *)it.get())->ass; + as->accept(this); + ralloc_asprintf_append(&buffer, ";\n"); + } + } + + foreach_iter(exec_list_iterator, iter, ir->body) { + ir_instruction *const inst = (ir_instruction *) iter.get(); + + indent(); + inst->accept(this); + ralloc_asprintf_append (&buffer, ";\n"); + } + indentation--; + indent(); + ralloc_asprintf_append (&buffer, "}\n"); +} + + +void ir_print_glsl_visitor::visit(ir_function *ir) +{ + bool found_non_builtin_proto = false; + + foreach_iter(exec_list_iterator, iter, *ir) { + ir_function_signature *const sig = (ir_function_signature *) iter.get(); + if (sig->is_defined || !sig->is_builtin) + found_non_builtin_proto = true; + } + if (!found_non_builtin_proto) + return; + + PrintGlslMode oldMode = this->mode; + this->mode = kPrintGlslNone; + + foreach_iter(exec_list_iterator, iter, *ir) { + ir_function_signature *const sig = (ir_function_signature *) iter.get(); + + indent(); + sig->accept(this); + ralloc_asprintf_append (&buffer, "\n"); + } + + this->mode = oldMode; + + indent(); +} + + +static const char *const operator_glsl_strs[] = { + "~", + "!", + "-", + "abs", + "sign", + "1.0/", + "inversesqrt", + "sqrt", + "exp", + "log", + "exp2", + "log2", + "int", + "float", + "bool", + "float", + "bool", + "int", + "float", + "int", + "int", + "any", + "trunc", + "ceil", + "floor", + "fract", + "roundEven", + "sin", + "cos", + "sin", // reduced + "cos", // reduced + "dFdx", + "dFdy", + "noise", + "+", + "-", + "*", + "/", + "mod", + "<", + ">", + "<=", + ">=", + "equal", + "notEqual", + "==", + "!=", + "<<", + ">>", + "&", + "^", + "|", + "&&", + "^^", + "||", + "dot", + "min", + "max", + "pow", + "vectorTODO", +}; + +void ir_print_glsl_visitor::visit(ir_expression *ir) +{ + if (ir->get_num_operands() == 1) { + if (ir->operation >= ir_unop_f2i && ir->operation <= ir_unop_u2f) { + buffer = print_type(buffer, ir->type, true); + ralloc_asprintf_append(&buffer, "("); + } else if (ir->operation == ir_unop_rcp) { + ralloc_asprintf_append (&buffer, "(1.0/("); + } else { + ralloc_asprintf_append (&buffer, "%s(", operator_glsl_strs[ir->operation]); + } + if (ir->operands[0]) + ir->operands[0]->accept(this); + ralloc_asprintf_append (&buffer, ")"); + if (ir->operation == ir_unop_rcp) { + ralloc_asprintf_append (&buffer, ")"); + } + } + else if (ir->operation == ir_binop_equal || + ir->operation == ir_binop_nequal || + ir->operation == ir_binop_mod || + ir->operation == ir_binop_dot) + { + if (ir->operation == ir_binop_mod) + { + ralloc_asprintf_append (&buffer, "("); + buffer = print_type(buffer, ir->type, true); + ralloc_asprintf_append (&buffer, "("); + } + ralloc_asprintf_append (&buffer, "%s (", operator_glsl_strs[ir->operation]); + if (ir->operands[0]) + ir->operands[0]->accept(this); + ralloc_asprintf_append (&buffer, ", "); + if (ir->operands[1]) + ir->operands[1]->accept(this); + ralloc_asprintf_append (&buffer, ")"); + if (ir->operation == ir_binop_mod) + ralloc_asprintf_append (&buffer, "))"); + } + else { + ralloc_asprintf_append (&buffer, "("); + if (ir->operands[0]) + ir->operands[0]->accept(this); + + ralloc_asprintf_append (&buffer, " %s ", operator_glsl_strs[ir->operation]); + + if (ir->operands[1]) + ir->operands[1]->accept(this); + ralloc_asprintf_append (&buffer, ")"); + } + +} + + +void ir_print_glsl_visitor::visit(ir_texture *ir) +{ + ralloc_asprintf_append (&buffer, "(%s ", ir->opcode_string()); + + ir->sampler->accept(this); + ralloc_asprintf_append (&buffer, " "); + + ir->coordinate->accept(this); + + if (ir->offset != NULL) { + ir->offset->accept(this); + } + + if (ir->op != ir_txf) { + if (ir->projector) + ir->projector->accept(this); + else + ralloc_asprintf_append (&buffer, "1"); + + if (ir->shadow_comparitor) { + ralloc_asprintf_append (&buffer, " "); + ir->shadow_comparitor->accept(this); + } else { + ralloc_asprintf_append (&buffer, " ()"); + } + } + + ralloc_asprintf_append (&buffer, " "); + switch (ir->op) + { + case ir_tex: + break; + case ir_txb: + ir->lod_info.bias->accept(this); + break; + case ir_txl: + case ir_txf: + ir->lod_info.lod->accept(this); + break; + case ir_txd: + ralloc_asprintf_append (&buffer, "("); + ir->lod_info.grad.dPdx->accept(this); + ralloc_asprintf_append (&buffer, " "); + ir->lod_info.grad.dPdy->accept(this); + ralloc_asprintf_append (&buffer, ")"); + break; + }; + ralloc_asprintf_append (&buffer, ")"); +} + + +void ir_print_glsl_visitor::visit(ir_swizzle *ir) +{ + const unsigned swiz[4] = { + ir->mask.x, + ir->mask.y, + ir->mask.z, + ir->mask.w, + }; + + if (ir->val->type == glsl_type::float_type) + { + if (ir->mask.num_components != 1) + { + buffer = print_type(buffer, ir->type, true); + ralloc_asprintf_append (&buffer, "("); + } + } + + ir->val->accept(this); + + if (ir->val->type == glsl_type::float_type) + { + if (ir->mask.num_components != 1) + { + ralloc_asprintf_append (&buffer, ")"); + } + return; + } + + ralloc_asprintf_append (&buffer, "."); + for (unsigned i = 0; i < ir->mask.num_components; i++) { + ralloc_asprintf_append (&buffer, "%c", "xyzw"[swiz[i]]); + } +} + + +void ir_print_glsl_visitor::visit(ir_dereference_variable *ir) +{ + ir_variable *var = ir->variable_referenced(); + print_var_name (var); +} + + +void ir_print_glsl_visitor::visit(ir_dereference_array *ir) +{ + ir->array->accept(this); + ralloc_asprintf_append (&buffer, "["); + ir->array_index->accept(this); + ralloc_asprintf_append (&buffer, "]"); +} + + +void ir_print_glsl_visitor::visit(ir_dereference_record *ir) +{ + ir->record->accept(this); + ralloc_asprintf_append (&buffer, ".%s", ir->field); +} + +void ir_print_glsl_visitor::visit(ir_assignment *ir) +{ + // assignement in global scope are postponed to main function + if (this->mode != kPrintGlslNone) + { + assert (!this->globals->main_function_done); + this->globals->global_assignements.push_tail (new(this->globals->mem_ctx) ga_entry(ir)); + ralloc_asprintf_append(&buffer, "//"); // for the ; that will follow (ugly, I know) + return; + } + + if (ir->condition) + { + ir->condition->accept(this); + ralloc_asprintf_append (&buffer, " "); + } + + ir->lhs->accept(this); + + char mask[5]; + unsigned j = 0; + const glsl_type* lhsType = ir->lhs->type; + const glsl_type* rhsType = ir->rhs->type; + if (ir->lhs->type->vector_elements > 1 && ir->write_mask != (1<lhs->type->vector_elements)-1) + { + for (unsigned i = 0; i < 4; i++) { + if ((ir->write_mask & (1 << i)) != 0) { + mask[j] = "xyzw"[i]; + j++; + } + } + lhsType = glsl_type::get_instance(lhsType->base_type, j, 1); + } + mask[j] = '\0'; + bool hasWriteMask = false; + if (mask[0]) + { + ralloc_asprintf_append (&buffer, ".%s", mask); + hasWriteMask = true; + } + + ralloc_asprintf_append (&buffer, " = "); + + bool typeMismatch = (lhsType != rhsType); + const bool addSwizzle = hasWriteMask && typeMismatch; + if (typeMismatch) + { + if (!addSwizzle) + buffer = print_type(buffer, lhsType, true); + ralloc_asprintf_append (&buffer, "("); + } + + ir->rhs->accept(this); + + if (typeMismatch) + { + ralloc_asprintf_append (&buffer, ")"); + if (addSwizzle) + ralloc_asprintf_append (&buffer, ".%s", mask); + } + +} + +static char* print_float (char* buffer, float f) +{ + const char* fmt = "%.6g"; + if (fabsf(fmodf(f,1.0f)) < 0.00001f) + fmt = "%.1f"; + ralloc_asprintf_append (&buffer, fmt, f); + return buffer; +} + +void ir_print_glsl_visitor::visit(ir_constant *ir) +{ + const glsl_type* type = ir->type; + + if (type == glsl_type::float_type) + { + buffer = print_float (buffer, ir->value.f[0]); + return; + } + else if (type == glsl_type::int_type) + { + ralloc_asprintf_append (&buffer, "%d", ir->value.i[0]); + return; + } + else if (type == glsl_type::uint_type) + { + ralloc_asprintf_append (&buffer, "%u", ir->value.u[0]); + return; + } + + const glsl_type *const base_type = ir->type->get_base_type(); + + buffer = print_type(buffer, type, true); + ralloc_asprintf_append (&buffer, "("); + + if (ir->type->is_array()) { + for (unsigned i = 0; i < ir->type->length; i++) + ir->get_array_element(i)->accept(this); + } else { + bool first = true; + for (unsigned i = 0; i < ir->type->components(); i++) { + if (!first) + ralloc_asprintf_append (&buffer, ", "); + first = false; + switch (base_type->base_type) { + case GLSL_TYPE_UINT: ralloc_asprintf_append (&buffer, "%u", ir->value.u[i]); break; + case GLSL_TYPE_INT: ralloc_asprintf_append (&buffer, "%d", ir->value.i[i]); break; + case GLSL_TYPE_FLOAT: buffer = print_float(buffer, ir->value.f[i]); break; + case GLSL_TYPE_BOOL: ralloc_asprintf_append (&buffer, "%d", ir->value.b[i]); break; + default: assert(0); + } + } + } + ralloc_asprintf_append (&buffer, ")"); +} + + +void +ir_print_glsl_visitor::visit(ir_call *ir) +{ + ralloc_asprintf_append (&buffer, "%s (", ir->callee_name()); + bool first = true; + foreach_iter(exec_list_iterator, iter, *ir) { + ir_instruction *const inst = (ir_instruction *) iter.get(); + if (!first) + ralloc_asprintf_append (&buffer, ", "); + inst->accept(this); + first = false; + } + ralloc_asprintf_append (&buffer, ")"); +} + + +void +ir_print_glsl_visitor::visit(ir_return *ir) +{ + ralloc_asprintf_append (&buffer, "return"); + + ir_rvalue *const value = ir->get_value(); + if (value) { + ralloc_asprintf_append (&buffer, " "); + value->accept(this); + } +} + + +void +ir_print_glsl_visitor::visit(ir_discard *ir) +{ + ralloc_asprintf_append (&buffer, "discard"); + + if (ir->condition != NULL) { + ralloc_asprintf_append (&buffer, " TODO "); + ir->condition->accept(this); + } +} + + +void +ir_print_glsl_visitor::visit(ir_if *ir) +{ + ralloc_asprintf_append (&buffer, "if ("); + ir->condition->accept(this); + + ralloc_asprintf_append (&buffer, ") {\n"); + indentation++; + + foreach_iter(exec_list_iterator, iter, ir->then_instructions) { + ir_instruction *const inst = (ir_instruction *) iter.get(); + + indent(); + inst->accept(this); + ralloc_asprintf_append (&buffer, ";\n"); + } + + indentation--; + indent(); + ralloc_asprintf_append (&buffer, "}"); + + if (!ir->else_instructions.is_empty()) + { + ralloc_asprintf_append (&buffer, " else {\n"); + indentation++; + + foreach_iter(exec_list_iterator, iter, ir->else_instructions) { + ir_instruction *const inst = (ir_instruction *) iter.get(); + + indent(); + inst->accept(this); + ralloc_asprintf_append (&buffer, ";\n"); + } + indentation--; + indent(); + ralloc_asprintf_append (&buffer, "}"); + } +} + + +void +ir_print_glsl_visitor::visit(ir_loop *ir) +{ + bool noData = (ir->counter == NULL && ir->from == NULL && ir->to == NULL && ir->increment == NULL); + if (noData) { + ralloc_asprintf_append (&buffer, "while (true) {\n"); + indentation++; + foreach_iter(exec_list_iterator, iter, ir->body_instructions) { + ir_instruction *const inst = (ir_instruction *) iter.get(); + indent(); + inst->accept(this); + ralloc_asprintf_append (&buffer, ";\n"); + } + indentation--; + indent(); + ralloc_asprintf_append (&buffer, "}"); + return; + } + + bool canonicalFor = (ir->counter && ir->from && ir->to && ir->increment); + if (canonicalFor) + { + ralloc_asprintf_append (&buffer, "for ("); + ir->counter->accept (this); + ralloc_asprintf_append (&buffer, " = "); + ir->from->accept (this); + ralloc_asprintf_append (&buffer, "; "); + print_var_name (ir->counter); + + // IR cmp operator is when to terminate loop; whereas GLSL for loop syntax + // is while to continue the loop. Invert the meaning of operator when outputting. + const char* termOp = NULL; + switch (ir->cmp) { + case ir_binop_less: termOp = ">="; break; + case ir_binop_greater: termOp = "<="; break; + case ir_binop_lequal: termOp = ">"; break; + case ir_binop_gequal: termOp = "<"; break; + case ir_binop_equal: termOp = "!="; break; + case ir_binop_nequal: termOp = "=="; break; + default: assert(false); + } + ralloc_asprintf_append (&buffer, " %s ", termOp); + ir->to->accept (this); + ralloc_asprintf_append (&buffer, "; "); + // IR already has instructions that modify the loop counter in the body + //print_var_name (ir->counter); + //ralloc_asprintf_append (&buffer, " = "); + //print_var_name (ir->counter); + //ralloc_asprintf_append (&buffer, "+("); + //ir->increment->accept (this); + //ralloc_asprintf_append (&buffer, ")"); + ralloc_asprintf_append (&buffer, ") {\n"); + indentation++; + foreach_iter(exec_list_iterator, iter, ir->body_instructions) { + ir_instruction *const inst = (ir_instruction *) iter.get(); + indent(); + inst->accept(this); + ralloc_asprintf_append (&buffer, ";\n"); + } + indentation--; + indent(); + ralloc_asprintf_append (&buffer, "}"); + return; + } + + + ralloc_asprintf_append (&buffer, "( TODO loop ("); + if (ir->counter != NULL) + ir->counter->accept(this); + ralloc_asprintf_append (&buffer, ") ("); + if (ir->from != NULL) + ir->from->accept(this); + ralloc_asprintf_append (&buffer, ") ("); + if (ir->to != NULL) + ir->to->accept(this); + ralloc_asprintf_append (&buffer, ") ("); + if (ir->increment != NULL) + ir->increment->accept(this); + ralloc_asprintf_append (&buffer, ") (\n"); + indentation++; + + foreach_iter(exec_list_iterator, iter, ir->body_instructions) { + ir_instruction *const inst = (ir_instruction *) iter.get(); + + indent(); + inst->accept(this); + ralloc_asprintf_append (&buffer, ";\n"); + } + indentation--; + indent(); + ralloc_asprintf_append (&buffer, "))\n"); +} + + +void +ir_print_glsl_visitor::visit(ir_loop_jump *ir) +{ + ralloc_asprintf_append (&buffer, "%s", ir->is_break() ? "break" : "continue"); +} diff --git a/3rdparty/glsl-optimizer/src/glsl/ir_print_glsl_visitor.h b/3rdparty/glsl-optimizer/src/glsl/ir_print_glsl_visitor.h new file mode 100644 index 000000000..0e6f565f0 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/ir_print_glsl_visitor.h @@ -0,0 +1,41 @@ +/* -*- c++ -*- */ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#pragma once +#ifndef IR_PRINT_GLSL_VISITOR_H +#define IR_PRINT_GLSL_VISITOR_H + +#include "ir.h" + +enum PrintGlslMode { + kPrintGlslNone = 0, + kPrintGlslVertex, + kPrintGlslFragment, +}; + +extern char* _mesa_print_ir_glsl(exec_list *instructions, + struct _mesa_glsl_parse_state *state, + char* buf, PrintGlslMode mode); + +#endif /* IR_PRINT_GLSL_VISITOR_H */ diff --git a/3rdparty/glsl-optimizer/src/glsl/ir_print_visitor.cpp b/3rdparty/glsl-optimizer/src/glsl/ir_print_visitor.cpp new file mode 100644 index 000000000..518910bd1 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/ir_print_visitor.cpp @@ -0,0 +1,525 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include "ir_print_visitor.h" +#include "glsl_types.h" +#include "glsl_parser_extras.h" + +extern "C" { +#include "program/hash_table.h" +} + +static void print_type(const glsl_type *t); + +void +ir_instruction::print(void) const +{ + ir_instruction *deconsted = const_cast(this); + + ir_print_visitor v; + deconsted->accept(&v); +} + +void +_mesa_print_ir(exec_list *instructions, + struct _mesa_glsl_parse_state *state) +{ + if (state) { + for (unsigned i = 0; i < state->num_user_structures; i++) { + const glsl_type *const s = state->user_structures[i]; + + printf("(structure (%s) (%s@%p) (%u) (\n", + s->name, s->name, (void *) s, s->length); + + for (unsigned j = 0; j < s->length; j++) { + printf("\t(("); + print_type(s->fields.structure[j].type); + printf(")(%s))\n", s->fields.structure[j].name); + } + + printf(")\n"); + } + } + + printf("(\n"); + foreach_iter(exec_list_iterator, iter, *instructions) { + ir_instruction *ir = (ir_instruction *)iter.get(); + ir->print(); + if (ir->ir_type != ir_type_function) + printf("\n"); + } + printf("\n)"); +} + +ir_print_visitor::ir_print_visitor() +{ + indentation = 0; + printable_names = + hash_table_ctor(32, hash_table_pointer_hash, hash_table_pointer_compare); + symbols = _mesa_symbol_table_ctor(); + mem_ctx = ralloc_context(NULL); +} + +ir_print_visitor::~ir_print_visitor() +{ + hash_table_dtor(printable_names); + _mesa_symbol_table_dtor(symbols); + ralloc_free(mem_ctx); +} + +void ir_print_visitor::indent(void) +{ + for (int i = 0; i < indentation; i++) + printf(" "); +} + +const char * +ir_print_visitor::unique_name(ir_variable *var) +{ + /* var->name can be NULL in function prototypes when a type is given for a + * parameter but no name is given. In that case, just return an empty + * string. Don't worry about tracking the generated name in the printable + * names hash because this is the only scope where it can ever appear. + */ + if (var->name == NULL) { + static unsigned arg = 1; + return ralloc_asprintf(this->mem_ctx, "parameter@%u", arg++); + } + + /* Do we already have a name for this variable? */ + const char *name = (const char *) hash_table_find(this->printable_names, var); + if (name != NULL) + return name; + + /* If there's no conflict, just use the original name */ + if (_mesa_symbol_table_find_symbol(this->symbols, -1, var->name) == NULL) { + name = var->name; + } else { + static unsigned i = 1; + name = ralloc_asprintf(this->mem_ctx, "%s@%u", var->name, ++i); + } + hash_table_insert(this->printable_names, (void *) name, var); + _mesa_symbol_table_add_symbol(this->symbols, -1, name, var); + return name; +} + +static void +print_type(const glsl_type *t) +{ + if (t->base_type == GLSL_TYPE_ARRAY) { + printf("(array "); + print_type(t->fields.array); + printf(" %u)", t->length); + } else if ((t->base_type == GLSL_TYPE_STRUCT) + && (strncmp("gl_", t->name, 3) != 0)) { + printf("%s@%p", t->name, (void *) t); + } else { + printf("%s", t->name); + } +} + + +void ir_print_visitor::visit(ir_variable *ir) +{ + printf("(declare "); + + const char *const cent = (ir->centroid) ? "centroid " : ""; + const char *const inv = (ir->invariant) ? "invariant " : ""; + const char *const mode[] = { "", "uniform ", "in ", "out ", "inout ", + "const_in ", "sys ", "temporary " }; + const char *const interp[] = { "", "flat", "noperspective" }; + + printf("(%s%s%s%s) ", + cent, inv, mode[ir->mode], interp[ir->interpolation]); + + print_type(ir->type); + printf(" %s)", unique_name(ir)); +} + + +void ir_print_visitor::visit(ir_function_signature *ir) +{ + _mesa_symbol_table_push_scope(symbols); + printf("(signature "); + indentation++; + + print_type(ir->return_type); + printf("\n"); + indent(); + + printf("(parameters\n"); + indentation++; + + foreach_iter(exec_list_iterator, iter, ir->parameters) { + ir_variable *const inst = (ir_variable *) iter.get(); + + indent(); + inst->accept(this); + printf("\n"); + } + indentation--; + + indent(); + printf(")\n"); + + indent(); + + printf("(\n"); + indentation++; + + foreach_iter(exec_list_iterator, iter, ir->body) { + ir_instruction *const inst = (ir_instruction *) iter.get(); + + indent(); + inst->accept(this); + printf("\n"); + } + indentation--; + indent(); + printf("))\n"); + indentation--; + _mesa_symbol_table_pop_scope(symbols); +} + + +void ir_print_visitor::visit(ir_function *ir) +{ + printf("(function %s\n", ir->name); + indentation++; + foreach_iter(exec_list_iterator, iter, *ir) { + ir_function_signature *const sig = (ir_function_signature *) iter.get(); + indent(); + sig->accept(this); + printf("\n"); + } + indentation--; + indent(); + printf(")\n\n"); +} + + +void ir_print_visitor::visit(ir_expression *ir) +{ + printf("(expression "); + + print_type(ir->type); + + printf(" %s ", ir->operator_string()); + + for (unsigned i = 0; i < ir->get_num_operands(); i++) { + ir->operands[i]->accept(this); + } + + printf(") "); +} + + +void ir_print_visitor::visit(ir_texture *ir) +{ + printf("(%s ", ir->opcode_string()); + + print_type(ir->type); + printf(" "); + + ir->sampler->accept(this); + printf(" "); + + ir->coordinate->accept(this); + + printf(" "); + + if (ir->offset != NULL) { + ir->offset->accept(this); + } else { + printf("0"); + } + + printf(" "); + + if (ir->op != ir_txf) { + if (ir->projector) + ir->projector->accept(this); + else + printf("1"); + + if (ir->shadow_comparitor) { + printf(" "); + ir->shadow_comparitor->accept(this); + } else { + printf(" ()"); + } + } + + printf(" "); + switch (ir->op) + { + case ir_tex: + break; + case ir_txb: + ir->lod_info.bias->accept(this); + break; + case ir_txl: + case ir_txf: + ir->lod_info.lod->accept(this); + break; + case ir_txd: + printf("("); + ir->lod_info.grad.dPdx->accept(this); + printf(" "); + ir->lod_info.grad.dPdy->accept(this); + printf(")"); + break; + }; + printf(")"); +} + + +void ir_print_visitor::visit(ir_swizzle *ir) +{ + const unsigned swiz[4] = { + ir->mask.x, + ir->mask.y, + ir->mask.z, + ir->mask.w, + }; + + printf("(swiz "); + for (unsigned i = 0; i < ir->mask.num_components; i++) { + printf("%c", "xyzw"[swiz[i]]); + } + printf(" "); + ir->val->accept(this); + printf(")"); +} + + +void ir_print_visitor::visit(ir_dereference_variable *ir) +{ + ir_variable *var = ir->variable_referenced(); + printf("(var_ref %s) ", unique_name(var)); +} + + +void ir_print_visitor::visit(ir_dereference_array *ir) +{ + printf("(array_ref "); + ir->array->accept(this); + ir->array_index->accept(this); + printf(") "); +} + + +void ir_print_visitor::visit(ir_dereference_record *ir) +{ + printf("(record_ref "); + ir->record->accept(this); + printf(" %s) ", ir->field); +} + + +void ir_print_visitor::visit(ir_assignment *ir) +{ + printf("(assign "); + + if (ir->condition) + ir->condition->accept(this); + + char mask[5]; + unsigned j = 0; + + for (unsigned i = 0; i < 4; i++) { + if ((ir->write_mask & (1 << i)) != 0) { + mask[j] = "xyzw"[i]; + j++; + } + } + mask[j] = '\0'; + + printf(" (%s) ", mask); + + ir->lhs->accept(this); + + printf(" "); + + ir->rhs->accept(this); + printf(") "); +} + + +void ir_print_visitor::visit(ir_constant *ir) +{ + const glsl_type *const base_type = ir->type->get_base_type(); + + printf("(constant "); + print_type(ir->type); + printf(" ("); + + if (ir->type->is_array()) { + for (unsigned i = 0; i < ir->type->length; i++) + ir->get_array_element(i)->accept(this); + } else if (ir->type->is_record()) { + ir_constant *value = (ir_constant *) ir->components.get_head(); + for (unsigned i = 0; i < ir->type->length; i++) { + printf("(%s ", ir->type->fields.structure[i].name); + value->accept(this); + printf(")"); + + value = (ir_constant *) value->next; + } + } else { + for (unsigned i = 0; i < ir->type->components(); i++) { + if (i != 0) + printf(" "); + switch (base_type->base_type) { + case GLSL_TYPE_UINT: printf("%u", ir->value.u[i]); break; + case GLSL_TYPE_INT: printf("%d", ir->value.i[i]); break; + case GLSL_TYPE_FLOAT: printf("%f", ir->value.f[i]); break; + case GLSL_TYPE_BOOL: printf("%d", ir->value.b[i]); break; + default: assert(0); + } + } + } + printf(")) "); +} + + +void +ir_print_visitor::visit(ir_call *ir) +{ + printf("(call %s (", ir->callee_name()); + foreach_iter(exec_list_iterator, iter, *ir) { + ir_instruction *const inst = (ir_instruction *) iter.get(); + + inst->accept(this); + } + printf("))\n"); +} + + +void +ir_print_visitor::visit(ir_return *ir) +{ + printf("(return"); + + ir_rvalue *const value = ir->get_value(); + if (value) { + printf(" "); + value->accept(this); + } + + printf(")"); +} + + +void +ir_print_visitor::visit(ir_discard *ir) +{ + printf("(discard "); + + if (ir->condition != NULL) { + printf(" "); + ir->condition->accept(this); + } + + printf(")"); +} + + +void +ir_print_visitor::visit(ir_if *ir) +{ + printf("(if "); + ir->condition->accept(this); + + printf("(\n"); + indentation++; + + foreach_iter(exec_list_iterator, iter, ir->then_instructions) { + ir_instruction *const inst = (ir_instruction *) iter.get(); + + indent(); + inst->accept(this); + printf("\n"); + } + + indentation--; + indent(); + printf(")\n"); + + indent(); + if (!ir->else_instructions.is_empty()) { + printf("(\n"); + indentation++; + + foreach_iter(exec_list_iterator, iter, ir->else_instructions) { + ir_instruction *const inst = (ir_instruction *) iter.get(); + + indent(); + inst->accept(this); + printf("\n"); + } + indentation--; + indent(); + printf("))\n"); + } else { + printf("())\n"); + } +} + + +void +ir_print_visitor::visit(ir_loop *ir) +{ + printf("(loop ("); + if (ir->counter != NULL) + ir->counter->accept(this); + printf(") ("); + if (ir->from != NULL) + ir->from->accept(this); + printf(") ("); + if (ir->to != NULL) + ir->to->accept(this); + printf(") ("); + if (ir->increment != NULL) + ir->increment->accept(this); + printf(") (\n"); + indentation++; + + foreach_iter(exec_list_iterator, iter, ir->body_instructions) { + ir_instruction *const inst = (ir_instruction *) iter.get(); + + indent(); + inst->accept(this); + printf("\n"); + } + indentation--; + indent(); + printf("))\n"); +} + + +void +ir_print_visitor::visit(ir_loop_jump *ir) +{ + printf("%s", ir->is_break() ? "break" : "continue"); +} diff --git a/3rdparty/glsl-optimizer/src/glsl/ir_print_visitor.h b/3rdparty/glsl-optimizer/src/glsl/ir_print_visitor.h new file mode 100644 index 000000000..c7136f11a --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/ir_print_visitor.h @@ -0,0 +1,94 @@ +/* -*- c++ -*- */ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#pragma once +#ifndef IR_PRINT_VISITOR_H +#define IR_PRINT_VISITOR_H + +#include "ir.h" +#include "ir_visitor.h" + +extern "C" { +#include "program/symbol_table.h" +} + +extern void _mesa_print_ir(exec_list *instructions, + struct _mesa_glsl_parse_state *state); + +/** + * Abstract base class of visitors of IR instruction trees + */ +class ir_print_visitor : public ir_visitor { +public: + ir_print_visitor(); + virtual ~ir_print_visitor(); + + void indent(void); + + /** + * \name Visit methods + * + * As typical for the visitor pattern, there must be one \c visit method for + * each concrete subclass of \c ir_instruction. Virtual base classes within + * the hierarchy should not have \c visit methods. + */ + /*@{*/ + virtual void visit(ir_variable *); + virtual void visit(ir_function_signature *); + virtual void visit(ir_function *); + virtual void visit(ir_expression *); + virtual void visit(ir_texture *); + virtual void visit(ir_swizzle *); + virtual void visit(ir_dereference_variable *); + virtual void visit(ir_dereference_array *); + virtual void visit(ir_dereference_record *); + virtual void visit(ir_assignment *); + virtual void visit(ir_constant *); + virtual void visit(ir_call *); + virtual void visit(ir_return *); + virtual void visit(ir_discard *); + virtual void visit(ir_if *); + virtual void visit(ir_loop *); + virtual void visit(ir_loop_jump *); + /*@}*/ + +private: + /** + * Fetch/generate a unique name for ir_variable. + * + * GLSL IR permits multiple ir_variables to share the same name. This works + * fine until we try to print it, when we really need a unique one. + */ + const char *unique_name(ir_variable *var); + + /** A mapping from ir_variable * -> unique printable names. */ + hash_table *printable_names; + _mesa_symbol_table *symbols; + + void *mem_ctx; + + int indentation; +}; + +#endif /* IR_PRINT_VISITOR_H */ diff --git a/3rdparty/glsl-optimizer/src/glsl/ir_reader.cpp b/3rdparty/glsl-optimizer/src/glsl/ir_reader.cpp new file mode 100644 index 000000000..cdedec1ff --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/ir_reader.cpp @@ -0,0 +1,1007 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include "ir_reader.h" +#include "glsl_parser_extras.h" +#include "glsl_types.h" +#include "s_expression.h" + +const static bool debug = false; + +class ir_reader { +public: + ir_reader(_mesa_glsl_parse_state *); + + void read(exec_list *instructions, const char *src, bool scan_for_protos); + +private: + void *mem_ctx; + _mesa_glsl_parse_state *state; + + void ir_read_error(s_expression *, const char *fmt, ...); + + const glsl_type *read_type(s_expression *); + + void scan_for_prototypes(exec_list *, s_expression *); + ir_function *read_function(s_expression *, bool skip_body); + void read_function_sig(ir_function *, s_expression *, bool skip_body); + + void read_instructions(exec_list *, s_expression *, ir_loop *); + ir_instruction *read_instruction(s_expression *, ir_loop *); + ir_variable *read_declaration(s_expression *); + ir_if *read_if(s_expression *, ir_loop *); + ir_loop *read_loop(s_expression *); + ir_return *read_return(s_expression *); + ir_rvalue *read_rvalue(s_expression *); + ir_assignment *read_assignment(s_expression *); + ir_expression *read_expression(s_expression *); + ir_call *read_call(s_expression *); + ir_swizzle *read_swizzle(s_expression *); + ir_constant *read_constant(s_expression *); + ir_texture *read_texture(s_expression *); + + ir_dereference *read_dereference(s_expression *); +}; + +ir_reader::ir_reader(_mesa_glsl_parse_state *state) : state(state) +{ + this->mem_ctx = state; +} + +void +_mesa_glsl_read_ir(_mesa_glsl_parse_state *state, exec_list *instructions, + const char *src, bool scan_for_protos) +{ + ir_reader r(state); + r.read(instructions, src, scan_for_protos); +} + +void +ir_reader::read(exec_list *instructions, const char *src, bool scan_for_protos) +{ + s_expression *expr = s_expression::read_expression(mem_ctx, src); + if (expr == NULL) { + ir_read_error(NULL, "couldn't parse S-Expression."); + return; + } + + if (scan_for_protos) { + scan_for_prototypes(instructions, expr); + if (state->error) + return; + } + + read_instructions(instructions, expr, NULL); + ralloc_free(expr); + + if (debug) + validate_ir_tree(instructions); +} + +void +ir_reader::ir_read_error(s_expression *expr, const char *fmt, ...) +{ + va_list ap; + + state->error = true; + + if (state->current_function != NULL) + ralloc_asprintf_append(&state->info_log, "In function %s:\n", + state->current_function->function_name()); + ralloc_strcat(&state->info_log, "error: "); + + va_start(ap, fmt); + ralloc_vasprintf_append(&state->info_log, fmt, ap); + va_end(ap); + ralloc_strcat(&state->info_log, "\n"); + + if (expr != NULL) { + ralloc_strcat(&state->info_log, "...in this context:\n "); + expr->print(); + ralloc_strcat(&state->info_log, "\n\n"); + } +} + +const glsl_type * +ir_reader::read_type(s_expression *expr) +{ + s_expression *s_base_type; + s_int *s_size; + + s_pattern pat[] = { "array", s_base_type, s_size }; + if (MATCH(expr, pat)) { + const glsl_type *base_type = read_type(s_base_type); + if (base_type == NULL) { + ir_read_error(NULL, "when reading base type of array type"); + return NULL; + } + + return glsl_type::get_array_instance(base_type, s_size->value()); + } + + s_symbol *type_sym = SX_AS_SYMBOL(expr); + if (type_sym == NULL) { + ir_read_error(expr, "expected "); + return NULL; + } + + const glsl_type *type = state->symbols->get_type(type_sym->value()); + if (type == NULL) + ir_read_error(expr, "invalid type: %s", type_sym->value()); + + return type; +} + + +void +ir_reader::scan_for_prototypes(exec_list *instructions, s_expression *expr) +{ + s_list *list = SX_AS_LIST(expr); + if (list == NULL) { + ir_read_error(expr, "Expected ( ...); found an atom."); + return; + } + + foreach_iter(exec_list_iterator, it, list->subexpressions) { + s_list *sub = SX_AS_LIST(it.get()); + if (sub == NULL) + continue; // not a (function ...); ignore it. + + s_symbol *tag = SX_AS_SYMBOL(sub->subexpressions.get_head()); + if (tag == NULL || strcmp(tag->value(), "function") != 0) + continue; // not a (function ...); ignore it. + + ir_function *f = read_function(sub, true); + if (f == NULL) + return; + instructions->push_tail(f); + } +} + +ir_function * +ir_reader::read_function(s_expression *expr, bool skip_body) +{ + bool added = false; + s_symbol *name; + + s_pattern pat[] = { "function", name }; + if (!PARTIAL_MATCH(expr, pat)) { + ir_read_error(expr, "Expected (function (signature ...) ...)"); + return NULL; + } + + ir_function *f = state->symbols->get_function(name->value()); + if (f == NULL) { + f = new(mem_ctx) ir_function(name->value()); + added = state->symbols->add_function(f); + assert(added); + } + + exec_list_iterator it = ((s_list *) expr)->subexpressions.iterator(); + it.next(); // skip "function" tag + it.next(); // skip function name + for (/* nothing */; it.has_next(); it.next()) { + s_expression *s_sig = (s_expression *) it.get(); + read_function_sig(f, s_sig, skip_body); + } + return added ? f : NULL; +} + +void +ir_reader::read_function_sig(ir_function *f, s_expression *expr, bool skip_body) +{ + s_expression *type_expr; + s_list *paramlist; + s_list *body_list; + + s_pattern pat[] = { "signature", type_expr, paramlist, body_list }; + if (!MATCH(expr, pat)) { + ir_read_error(expr, "Expected (signature (parameters ...) " + "( ...))"); + return; + } + + const glsl_type *return_type = read_type(type_expr); + if (return_type == NULL) + return; + + s_symbol *paramtag = SX_AS_SYMBOL(paramlist->subexpressions.get_head()); + if (paramtag == NULL || strcmp(paramtag->value(), "parameters") != 0) { + ir_read_error(paramlist, "Expected (parameters ...)"); + return; + } + + // Read the parameters list into a temporary place. + exec_list hir_parameters; + state->symbols->push_scope(); + + exec_list_iterator it = paramlist->subexpressions.iterator(); + for (it.next() /* skip "parameters" */; it.has_next(); it.next()) { + ir_variable *var = read_declaration((s_expression *) it.get()); + if (var == NULL) + return; + + hir_parameters.push_tail(var); + } + + ir_function_signature *sig = f->exact_matching_signature(&hir_parameters); + if (sig == NULL && skip_body) { + /* If scanning for prototypes, generate a new signature. */ + sig = new(mem_ctx) ir_function_signature(return_type, glsl_precision_undefined); + sig->is_builtin = true; + f->add_signature(sig); + } else if (sig != NULL) { + const char *badvar = sig->qualifiers_match(&hir_parameters); + if (badvar != NULL) { + ir_read_error(expr, "function `%s' parameter `%s' qualifiers " + "don't match prototype", f->name, badvar); + return; + } + + if (sig->return_type != return_type) { + ir_read_error(expr, "function `%s' return type doesn't " + "match prototype", f->name); + return; + } + } else { + /* No prototype for this body exists - skip it. */ + state->symbols->pop_scope(); + return; + } + assert(sig != NULL); + + sig->replace_parameters(&hir_parameters); + + if (!skip_body && !body_list->subexpressions.is_empty()) { + if (sig->is_defined) { + ir_read_error(expr, "function %s redefined", f->name); + return; + } + state->current_function = sig; + read_instructions(&sig->body, body_list, NULL); + state->current_function = NULL; + sig->is_defined = true; + } + + state->symbols->pop_scope(); +} + +void +ir_reader::read_instructions(exec_list *instructions, s_expression *expr, + ir_loop *loop_ctx) +{ + // Read in a list of instructions + s_list *list = SX_AS_LIST(expr); + if (list == NULL) { + ir_read_error(expr, "Expected ( ...); found an atom."); + return; + } + + foreach_iter(exec_list_iterator, it, list->subexpressions) { + s_expression *sub = (s_expression*) it.get(); + ir_instruction *ir = read_instruction(sub, loop_ctx); + if (ir != NULL) { + /* Global variable declarations should be moved to the top, before + * any functions that might use them. Functions are added to the + * instruction stream when scanning for prototypes, so without this + * hack, they always appear before variable declarations. + */ + if (state->current_function == NULL && ir->as_variable() != NULL) + instructions->push_head(ir); + else + instructions->push_tail(ir); + } + } +} + + +ir_instruction * +ir_reader::read_instruction(s_expression *expr, ir_loop *loop_ctx) +{ + s_symbol *symbol = SX_AS_SYMBOL(expr); + if (symbol != NULL) { + if (strcmp(symbol->value(), "break") == 0 && loop_ctx != NULL) + return new(mem_ctx) ir_loop_jump(ir_loop_jump::jump_break); + if (strcmp(symbol->value(), "continue") == 0 && loop_ctx != NULL) + return new(mem_ctx) ir_loop_jump(ir_loop_jump::jump_continue); + } + + s_list *list = SX_AS_LIST(expr); + if (list == NULL || list->subexpressions.is_empty()) { + ir_read_error(expr, "Invalid instruction.\n"); + return NULL; + } + + s_symbol *tag = SX_AS_SYMBOL(list->subexpressions.get_head()); + if (tag == NULL) { + ir_read_error(expr, "expected instruction tag"); + return NULL; + } + + ir_instruction *inst = NULL; + if (strcmp(tag->value(), "declare") == 0) { + inst = read_declaration(list); + } else if (strcmp(tag->value(), "assign") == 0) { + inst = read_assignment(list); + } else if (strcmp(tag->value(), "if") == 0) { + inst = read_if(list, loop_ctx); + } else if (strcmp(tag->value(), "loop") == 0) { + inst = read_loop(list); + } else if (strcmp(tag->value(), "return") == 0) { + inst = read_return(list); + } else if (strcmp(tag->value(), "function") == 0) { + inst = read_function(list, false); + } else { + inst = read_rvalue(list); + if (inst == NULL) + ir_read_error(NULL, "when reading instruction"); + } + return inst; +} + +ir_variable * +ir_reader::read_declaration(s_expression *expr) +{ + s_list *s_quals; + s_expression *s_type; + s_symbol *s_name; + + s_pattern pat[] = { "declare", s_quals, s_type, s_name }; + if (!MATCH(expr, pat)) { + ir_read_error(expr, "expected (declare () )"); + return NULL; + } + + const glsl_type *type = read_type(s_type); + if (type == NULL) + return NULL; + + ir_variable *var = new(mem_ctx) ir_variable(type, s_name->value(), + ir_var_auto, glsl_precision_undefined); + + foreach_iter(exec_list_iterator, it, s_quals->subexpressions) { + s_symbol *qualifier = SX_AS_SYMBOL(it.get()); + if (qualifier == NULL) { + ir_read_error(expr, "qualifier list must contain only symbols"); + return NULL; + } + + // FINISHME: Check for duplicate/conflicting qualifiers. + if (strcmp(qualifier->value(), "centroid") == 0) { + var->centroid = 1; + } else if (strcmp(qualifier->value(), "invariant") == 0) { + var->invariant = 1; + } else if (strcmp(qualifier->value(), "uniform") == 0) { + var->mode = ir_var_uniform; + } else if (strcmp(qualifier->value(), "auto") == 0) { + var->mode = ir_var_auto; + } else if (strcmp(qualifier->value(), "in") == 0) { + var->mode = ir_var_in; + } else if (strcmp(qualifier->value(), "const_in") == 0) { + var->mode = ir_var_const_in; + } else if (strcmp(qualifier->value(), "out") == 0) { + var->mode = ir_var_out; + } else if (strcmp(qualifier->value(), "inout") == 0) { + var->mode = ir_var_inout; + } else if (strcmp(qualifier->value(), "smooth") == 0) { + var->interpolation = ir_var_smooth; + } else if (strcmp(qualifier->value(), "flat") == 0) { + var->interpolation = ir_var_flat; + } else if (strcmp(qualifier->value(), "noperspective") == 0) { + var->interpolation = ir_var_noperspective; + } else { + ir_read_error(expr, "unknown qualifier: %s", qualifier->value()); + return NULL; + } + } + + // Add the variable to the symbol table + state->symbols->add_variable(var); + + return var; +} + + +ir_if * +ir_reader::read_if(s_expression *expr, ir_loop *loop_ctx) +{ + s_expression *s_cond; + s_expression *s_then; + s_expression *s_else; + + s_pattern pat[] = { "if", s_cond, s_then, s_else }; + if (!MATCH(expr, pat)) { + ir_read_error(expr, "expected (if (...) (...))"); + return NULL; + } + + ir_rvalue *condition = read_rvalue(s_cond); + if (condition == NULL) { + ir_read_error(NULL, "when reading condition of (if ...)"); + return NULL; + } + + ir_if *iff = new(mem_ctx) ir_if(condition); + + read_instructions(&iff->then_instructions, s_then, loop_ctx); + read_instructions(&iff->else_instructions, s_else, loop_ctx); + if (state->error) { + delete iff; + iff = NULL; + } + return iff; +} + + +ir_loop * +ir_reader::read_loop(s_expression *expr) +{ + s_expression *s_counter, *s_from, *s_to, *s_inc, *s_body; + + s_pattern pat[] = { "loop", s_counter, s_from, s_to, s_inc, s_body }; + if (!MATCH(expr, pat)) { + ir_read_error(expr, "expected (loop " + " )"); + return NULL; + } + + // FINISHME: actually read the count/from/to fields. + + ir_loop *loop = new(mem_ctx) ir_loop; + read_instructions(&loop->body_instructions, s_body, loop); + if (state->error) { + delete loop; + loop = NULL; + } + return loop; +} + + +ir_return * +ir_reader::read_return(s_expression *expr) +{ + s_expression *s_retval; + + s_pattern return_value_pat[] = { "return", s_retval}; + s_pattern return_void_pat[] = { "return" }; + if (MATCH(expr, return_value_pat)) { + ir_rvalue *retval = read_rvalue(s_retval); + if (retval == NULL) { + ir_read_error(NULL, "when reading return value"); + return NULL; + } + return new(mem_ctx) ir_return(retval); + } else if (MATCH(expr, return_void_pat)) { + return new(mem_ctx) ir_return; + } else { + ir_read_error(expr, "expected (return ) or (return)"); + return NULL; + } +} + + +ir_rvalue * +ir_reader::read_rvalue(s_expression *expr) +{ + s_list *list = SX_AS_LIST(expr); + if (list == NULL || list->subexpressions.is_empty()) + return NULL; + + s_symbol *tag = SX_AS_SYMBOL(list->subexpressions.get_head()); + if (tag == NULL) { + ir_read_error(expr, "expected rvalue tag"); + return NULL; + } + + ir_rvalue *rvalue = read_dereference(list); + if (rvalue != NULL || state->error) + return rvalue; + else if (strcmp(tag->value(), "swiz") == 0) { + rvalue = read_swizzle(list); + } else if (strcmp(tag->value(), "expression") == 0) { + rvalue = read_expression(list); + } else if (strcmp(tag->value(), "call") == 0) { + rvalue = read_call(list); + } else if (strcmp(tag->value(), "constant") == 0) { + rvalue = read_constant(list); + } else { + rvalue = read_texture(list); + if (rvalue == NULL && !state->error) + ir_read_error(expr, "unrecognized rvalue tag: %s", tag->value()); + } + + return rvalue; +} + +ir_assignment * +ir_reader::read_assignment(s_expression *expr) +{ + s_expression *cond_expr = NULL; + s_expression *lhs_expr, *rhs_expr; + s_list *mask_list; + + s_pattern pat4[] = { "assign", mask_list, lhs_expr, rhs_expr }; + s_pattern pat5[] = { "assign", cond_expr, mask_list, lhs_expr, rhs_expr }; + if (!MATCH(expr, pat4) && !MATCH(expr, pat5)) { + ir_read_error(expr, "expected (assign [] () " + " )"); + return NULL; + } + + ir_rvalue *condition = NULL; + if (cond_expr != NULL) { + condition = read_rvalue(cond_expr); + if (condition == NULL) { + ir_read_error(NULL, "when reading condition of assignment"); + return NULL; + } + } + + unsigned mask = 0; + + s_symbol *mask_symbol; + s_pattern mask_pat[] = { mask_symbol }; + if (MATCH(mask_list, mask_pat)) { + const char *mask_str = mask_symbol->value(); + unsigned mask_length = strlen(mask_str); + if (mask_length > 4) { + ir_read_error(expr, "invalid write mask: %s", mask_str); + return NULL; + } + + const unsigned idx_map[] = { 3, 0, 1, 2 }; /* w=bit 3, x=0, y=1, z=2 */ + + for (unsigned i = 0; i < mask_length; i++) { + if (mask_str[i] < 'w' || mask_str[i] > 'z') { + ir_read_error(expr, "write mask contains invalid character: %c", + mask_str[i]); + return NULL; + } + mask |= 1 << idx_map[mask_str[i] - 'w']; + } + } else if (!mask_list->subexpressions.is_empty()) { + ir_read_error(mask_list, "expected () or ()"); + return NULL; + } + + ir_dereference *lhs = read_dereference(lhs_expr); + if (lhs == NULL) { + ir_read_error(NULL, "when reading left-hand side of assignment"); + return NULL; + } + + ir_rvalue *rhs = read_rvalue(rhs_expr); + if (rhs == NULL) { + ir_read_error(NULL, "when reading right-hand side of assignment"); + return NULL; + } + + if (mask == 0 && (lhs->type->is_vector() || lhs->type->is_scalar())) { + ir_read_error(expr, "non-zero write mask required."); + return NULL; + } + + return new(mem_ctx) ir_assignment(lhs, rhs, condition, mask); +} + +ir_call * +ir_reader::read_call(s_expression *expr) +{ + s_symbol *name; + s_list *params; + + s_pattern pat[] = { "call", name, params }; + if (!MATCH(expr, pat)) { + ir_read_error(expr, "expected (call ( ...))"); + return NULL; + } + + exec_list parameters; + + foreach_iter(exec_list_iterator, it, params->subexpressions) { + s_expression *expr = (s_expression*) it.get(); + ir_rvalue *param = read_rvalue(expr); + if (param == NULL) { + ir_read_error(expr, "when reading parameter to function call"); + return NULL; + } + parameters.push_tail(param); + } + + ir_function *f = state->symbols->get_function(name->value()); + if (f == NULL) { + ir_read_error(expr, "found call to undefined function %s", + name->value()); + return NULL; + } + + ir_function_signature *callee = f->matching_signature(¶meters); + if (callee == NULL) { + ir_read_error(expr, "couldn't find matching signature for function " + "%s", name->value()); + return NULL; + } + + return new(mem_ctx) ir_call(callee, ¶meters); +} + +ir_expression * +ir_reader::read_expression(s_expression *expr) +{ + s_expression *s_type; + s_symbol *s_op; + s_expression *s_arg1; + + s_pattern pat[] = { "expression", s_type, s_op, s_arg1 }; + if (!PARTIAL_MATCH(expr, pat)) { + ir_read_error(expr, "expected (expression " + " [])"); + return NULL; + } + s_expression *s_arg2 = (s_expression *) s_arg1->next; // may be tail sentinel + + const glsl_type *type = read_type(s_type); + if (type == NULL) + return NULL; + + /* Read the operator */ + ir_expression_operation op = ir_expression::get_operator(s_op->value()); + if (op == (ir_expression_operation) -1) { + ir_read_error(expr, "invalid operator: %s", s_op->value()); + return NULL; + } + + unsigned num_operands = ir_expression::get_num_operands(op); + if (num_operands == 1 && !s_arg1->next->is_tail_sentinel()) { + ir_read_error(expr, "expected (expression %s )", + s_op->value()); + return NULL; + } + + ir_rvalue *arg1 = read_rvalue(s_arg1); + ir_rvalue *arg2 = NULL; + if (arg1 == NULL) { + ir_read_error(NULL, "when reading first operand of %s", s_op->value()); + return NULL; + } + + if (num_operands == 2) { + if (s_arg2->is_tail_sentinel() || !s_arg2->next->is_tail_sentinel()) { + ir_read_error(expr, "expected (expression %s " + ")", s_op->value()); + return NULL; + } + arg2 = read_rvalue(s_arg2); + if (arg2 == NULL) { + ir_read_error(NULL, "when reading second operand of %s", + s_op->value()); + return NULL; + } + } + + return new(mem_ctx) ir_expression(op, type, arg1, arg2); +} + +ir_swizzle * +ir_reader::read_swizzle(s_expression *expr) +{ + s_symbol *swiz; + s_expression *sub; + + s_pattern pat[] = { "swiz", swiz, sub }; + if (!MATCH(expr, pat)) { + ir_read_error(expr, "expected (swiz )"); + return NULL; + } + + if (strlen(swiz->value()) > 4) { + ir_read_error(expr, "expected a valid swizzle; found %s", swiz->value()); + return NULL; + } + + ir_rvalue *rvalue = read_rvalue(sub); + if (rvalue == NULL) + return NULL; + + ir_swizzle *ir = ir_swizzle::create(rvalue, swiz->value(), + rvalue->type->vector_elements); + if (ir == NULL) + ir_read_error(expr, "invalid swizzle"); + + return ir; +} + +ir_constant * +ir_reader::read_constant(s_expression *expr) +{ + s_expression *type_expr; + s_list *values; + + s_pattern pat[] = { "constant", type_expr, values }; + if (!MATCH(expr, pat)) { + ir_read_error(expr, "expected (constant (...))"); + return NULL; + } + + const glsl_type *type = read_type(type_expr); + if (type == NULL) + return NULL; + + if (values == NULL) { + ir_read_error(expr, "expected (constant (...))"); + return NULL; + } + + if (type->is_array()) { + unsigned elements_supplied = 0; + exec_list elements; + foreach_iter(exec_list_iterator, it, values->subexpressions) { + s_expression *elt = (s_expression *) it.get(); + ir_constant *ir_elt = read_constant(elt); + if (ir_elt == NULL) + return NULL; + elements.push_tail(ir_elt); + elements_supplied++; + } + + if (elements_supplied != type->length) { + ir_read_error(values, "expected exactly %u array elements, " + "given %u", type->length, elements_supplied); + return NULL; + } + return new(mem_ctx) ir_constant(type, &elements); + } + + const glsl_type *const base_type = type->get_base_type(); + + ir_constant_data data = { { 0 } }; + + // Read in list of values (at most 16). + int k = 0; + foreach_iter(exec_list_iterator, it, values->subexpressions) { + if (k >= 16) { + ir_read_error(values, "expected at most 16 numbers"); + return NULL; + } + + s_expression *expr = (s_expression*) it.get(); + + if (base_type->base_type == GLSL_TYPE_FLOAT) { + s_number *value = SX_AS_NUMBER(expr); + if (value == NULL) { + ir_read_error(values, "expected numbers"); + return NULL; + } + data.f[k] = value->fvalue(); + } else { + s_int *value = SX_AS_INT(expr); + if (value == NULL) { + ir_read_error(values, "expected integers"); + return NULL; + } + + switch (base_type->base_type) { + case GLSL_TYPE_UINT: { + data.u[k] = value->value(); + break; + } + case GLSL_TYPE_INT: { + data.i[k] = value->value(); + break; + } + case GLSL_TYPE_BOOL: { + data.b[k] = value->value(); + break; + } + default: + ir_read_error(values, "unsupported constant type"); + return NULL; + } + } + ++k; + } + + return new(mem_ctx) ir_constant(type, &data); +} + +ir_dereference * +ir_reader::read_dereference(s_expression *expr) +{ + s_symbol *s_var; + s_expression *s_subject; + s_expression *s_index; + s_symbol *s_field; + + s_pattern var_pat[] = { "var_ref", s_var }; + s_pattern array_pat[] = { "array_ref", s_subject, s_index }; + s_pattern record_pat[] = { "record_ref", s_subject, s_field }; + + if (MATCH(expr, var_pat)) { + ir_variable *var = state->symbols->get_variable(s_var->value()); + if (var == NULL) { + ir_read_error(expr, "undeclared variable: %s", s_var->value()); + return NULL; + } + return new(mem_ctx) ir_dereference_variable(var); + } else if (MATCH(expr, array_pat)) { + ir_rvalue *subject = read_rvalue(s_subject); + if (subject == NULL) { + ir_read_error(NULL, "when reading the subject of an array_ref"); + return NULL; + } + + ir_rvalue *idx = read_rvalue(s_index); + if (subject == NULL) { + ir_read_error(NULL, "when reading the index of an array_ref"); + return NULL; + } + return new(mem_ctx) ir_dereference_array(subject, idx); + } else if (MATCH(expr, record_pat)) { + ir_rvalue *subject = read_rvalue(s_subject); + if (subject == NULL) { + ir_read_error(NULL, "when reading the subject of a record_ref"); + return NULL; + } + return new(mem_ctx) ir_dereference_record(subject, s_field->value()); + } + return NULL; +} + +ir_texture * +ir_reader::read_texture(s_expression *expr) +{ + s_symbol *tag = NULL; + s_expression *s_type = NULL; + s_expression *s_sampler = NULL; + s_expression *s_coord = NULL; + s_expression *s_offset = NULL; + s_expression *s_proj = NULL; + s_list *s_shadow = NULL; + s_expression *s_lod = NULL; + + ir_texture_opcode op = ir_tex; /* silence warning */ + + s_pattern tex_pattern[] = + { "tex", s_type, s_sampler, s_coord, s_offset, s_proj, s_shadow }; + s_pattern txf_pattern[] = + { "txf", s_type, s_sampler, s_coord, s_offset, s_lod }; + s_pattern other_pattern[] = + { tag, s_type, s_sampler, s_coord, s_offset, s_proj, s_shadow, s_lod }; + + if (MATCH(expr, tex_pattern)) { + op = ir_tex; + } else if (MATCH(expr, txf_pattern)) { + op = ir_txf; + } else if (MATCH(expr, other_pattern)) { + op = ir_texture::get_opcode(tag->value()); + if (op == -1) + return NULL; + } else { + ir_read_error(NULL, "unexpected texture pattern"); + return NULL; + } + + ir_texture *tex = new(mem_ctx) ir_texture(op); + + // Read return type + const glsl_type *type = read_type(s_type); + if (type == NULL) { + ir_read_error(NULL, "when reading type in (%s ...)", + tex->opcode_string()); + return NULL; + } + + // Read sampler (must be a deref) + ir_dereference *sampler = read_dereference(s_sampler); + if (sampler == NULL) { + ir_read_error(NULL, "when reading sampler in (%s ...)", + tex->opcode_string()); + return NULL; + } + tex->set_sampler(sampler, type); + + // Read coordinate (any rvalue) + tex->coordinate = read_rvalue(s_coord); + if (tex->coordinate == NULL) { + ir_read_error(NULL, "when reading coordinate in (%s ...)", + tex->opcode_string()); + return NULL; + } + + // Read texel offset - either 0 or an rvalue. + s_int *si_offset = SX_AS_INT(s_offset); + if (si_offset == NULL || si_offset->value() != 0) { + tex->offset = read_rvalue(s_offset); + if (tex->offset == NULL) { + ir_read_error(s_offset, "expected 0 or an expression"); + return NULL; + } + } + + if (op != ir_txf) { + s_int *proj_as_int = SX_AS_INT(s_proj); + if (proj_as_int && proj_as_int->value() == 1) { + tex->projector = NULL; + } else { + tex->projector = read_rvalue(s_proj); + if (tex->projector == NULL) { + ir_read_error(NULL, "when reading projective divide in (%s ..)", + tex->opcode_string()); + return NULL; + } + } + + if (s_shadow->subexpressions.is_empty()) { + tex->shadow_comparitor = NULL; + } else { + tex->shadow_comparitor = read_rvalue(s_shadow); + if (tex->shadow_comparitor == NULL) { + ir_read_error(NULL, "when reading shadow comparitor in (%s ..)", + tex->opcode_string()); + return NULL; + } + } + } + + switch (op) { + case ir_txb: + tex->lod_info.bias = read_rvalue(s_lod); + if (tex->lod_info.bias == NULL) { + ir_read_error(NULL, "when reading LOD bias in (txb ...)"); + return NULL; + } + break; + case ir_txl: + case ir_txf: + tex->lod_info.lod = read_rvalue(s_lod); + if (tex->lod_info.lod == NULL) { + ir_read_error(NULL, "when reading LOD in (%s ...)", + tex->opcode_string()); + return NULL; + } + break; + case ir_txd: { + s_expression *s_dx, *s_dy; + s_pattern dxdy_pat[] = { s_dx, s_dy }; + if (!MATCH(s_lod, dxdy_pat)) { + ir_read_error(s_lod, "expected (dPdx dPdy) in (txd ...)"); + return NULL; + } + tex->lod_info.grad.dPdx = read_rvalue(s_dx); + if (tex->lod_info.grad.dPdx == NULL) { + ir_read_error(NULL, "when reading dPdx in (txd ...)"); + return NULL; + } + tex->lod_info.grad.dPdy = read_rvalue(s_dy); + if (tex->lod_info.grad.dPdy == NULL) { + ir_read_error(NULL, "when reading dPdy in (txd ...)"); + return NULL; + } + break; + } + default: + // tex doesn't have any extra parameters. + break; + }; + return tex; +} diff --git a/3rdparty/glsl-optimizer/src/glsl/ir_reader.h b/3rdparty/glsl-optimizer/src/glsl/ir_reader.h new file mode 100644 index 000000000..aef2ca23b --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/ir_reader.h @@ -0,0 +1,34 @@ +/* -*- c++ -*- */ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#pragma once +#ifndef IR_READER_H +#define IR_READER_H + +#include "ir.h" + +void _mesa_glsl_read_ir(_mesa_glsl_parse_state *state, exec_list *instructions, + const char *src, bool scan_for_prototypes); + +#endif /* IR_READER_H */ diff --git a/3rdparty/glsl-optimizer/src/glsl/ir_rvalue_visitor.cpp b/3rdparty/glsl-optimizer/src/glsl/ir_rvalue_visitor.cpp new file mode 100644 index 000000000..ed6c7cb6a --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/ir_rvalue_visitor.cpp @@ -0,0 +1,142 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file ir_rvalue_visitor.cpp + * + * Generic class to implement the common pattern we have of wanting to + * visit each ir_rvalue * and possibly change that node to a different + * class. + */ + +#include "ir.h" +#include "ir_visitor.h" +#include "ir_rvalue_visitor.h" +#include "ir_print_visitor.h" +#include "glsl_types.h" + +ir_visitor_status +ir_rvalue_visitor::visit_leave(ir_expression *ir) +{ + unsigned int operand; + + for (operand = 0; operand < ir->get_num_operands(); operand++) { + handle_rvalue(&ir->operands[operand]); + } + + return visit_continue; +} + +ir_visitor_status +ir_rvalue_visitor::visit_leave(ir_texture *ir) +{ + handle_rvalue(&ir->coordinate); + handle_rvalue(&ir->projector); + handle_rvalue(&ir->shadow_comparitor); + handle_rvalue(&ir->offset); + + switch (ir->op) { + case ir_tex: + break; + case ir_txb: + handle_rvalue(&ir->lod_info.bias); + break; + case ir_txf: + case ir_txl: + handle_rvalue(&ir->lod_info.lod); + break; + case ir_txd: + handle_rvalue(&ir->lod_info.grad.dPdx); + handle_rvalue(&ir->lod_info.grad.dPdy); + break; + } + + return visit_continue; +} + +ir_visitor_status +ir_rvalue_visitor::visit_leave(ir_swizzle *ir) +{ + handle_rvalue(&ir->val); + return visit_continue; +} + +ir_visitor_status +ir_rvalue_visitor::visit_leave(ir_dereference_array *ir) +{ + /* The array index is not the target of the assignment, so clear the + * 'in_assignee' flag. Restore it after returning from the array index. + */ + const bool was_in_assignee = this->in_assignee; + this->in_assignee = false; + handle_rvalue(&ir->array_index); + this->in_assignee = was_in_assignee; + + handle_rvalue(&ir->array); + return visit_continue; +} + +ir_visitor_status +ir_rvalue_visitor::visit_leave(ir_dereference_record *ir) +{ + handle_rvalue(&ir->record); + return visit_continue; +} + +ir_visitor_status +ir_rvalue_visitor::visit_leave(ir_assignment *ir) +{ + handle_rvalue(&ir->rhs); + handle_rvalue(&ir->condition); + + return visit_continue; +} + +ir_visitor_status +ir_rvalue_visitor::visit_leave(ir_call *ir) +{ + foreach_iter(exec_list_iterator, iter, *ir) { + ir_rvalue *param = (ir_rvalue *)iter.get(); + ir_rvalue *new_param = param; + handle_rvalue(&new_param); + + if (new_param != param) { + param->replace_with(new_param); + } + } + return visit_continue; +} + +ir_visitor_status +ir_rvalue_visitor::visit_leave(ir_return *ir) +{ + handle_rvalue(&ir->value);; + return visit_continue; +} + +ir_visitor_status +ir_rvalue_visitor::visit_leave(ir_if *ir) +{ + handle_rvalue(&ir->condition); + return visit_continue; +} diff --git a/3rdparty/glsl-optimizer/src/glsl/ir_rvalue_visitor.h b/3rdparty/glsl-optimizer/src/glsl/ir_rvalue_visitor.h new file mode 100644 index 000000000..31a56beb9 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/ir_rvalue_visitor.h @@ -0,0 +1,47 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file ir_rvalue_visitor.h + * + * Generic class to implement the common pattern we have of wanting to + * visit each ir_rvalue * and possibly change that node to a different + * class. Just implement handle_rvalue() and you will be called with + * a pointer to each rvalue in the tree. + */ + +class ir_rvalue_visitor : public ir_hierarchical_visitor { +public: + + virtual ir_visitor_status visit_leave(ir_assignment *); + virtual ir_visitor_status visit_leave(ir_call *); + virtual ir_visitor_status visit_leave(ir_dereference_array *); + virtual ir_visitor_status visit_leave(ir_dereference_record *); + virtual ir_visitor_status visit_leave(ir_expression *); + virtual ir_visitor_status visit_leave(ir_if *); + virtual ir_visitor_status visit_leave(ir_return *); + virtual ir_visitor_status visit_leave(ir_swizzle *); + virtual ir_visitor_status visit_leave(ir_texture *); + + virtual void handle_rvalue(ir_rvalue **rvalue) = 0; +}; diff --git a/3rdparty/glsl-optimizer/src/glsl/ir_set_program_inouts.cpp b/3rdparty/glsl-optimizer/src/glsl/ir_set_program_inouts.cpp new file mode 100644 index 000000000..085456533 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/ir_set_program_inouts.cpp @@ -0,0 +1,166 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file ir_set_program_inouts.cpp + * + * Sets the InputsRead and OutputsWritten of Mesa programs. + * + * Mesa programs (gl_program, not gl_shader_program) have a set of + * flags indicating which varyings are read and written. Computing + * which are actually read from some sort of backend code can be + * tricky when variable array indexing involved. So this pass + * provides support for setting InputsRead and OutputsWritten right + * from the GLSL IR. + */ + +extern "C" { +#include "main/core.h" /* for struct gl_program */ +#include "program/hash_table.h" +} +#include "ir.h" +#include "ir_visitor.h" +#include "glsl_types.h" + +class ir_set_program_inouts_visitor : public ir_hierarchical_visitor { +public: + ir_set_program_inouts_visitor(struct gl_program *prog) + { + this->prog = prog; + this->ht = hash_table_ctor(0, + hash_table_pointer_hash, + hash_table_pointer_compare); + } + ~ir_set_program_inouts_visitor() + { + hash_table_dtor(this->ht); + } + + virtual ir_visitor_status visit_enter(ir_dereference_array *); + virtual ir_visitor_status visit_enter(ir_function_signature *); + virtual ir_visitor_status visit(ir_dereference_variable *); + virtual ir_visitor_status visit(ir_variable *); + + struct gl_program *prog; + struct hash_table *ht; +}; + +static void +mark(struct gl_program *prog, ir_variable *var, int offset, int len) +{ + /* As of GLSL 1.20, varyings can only be floats, floating-point + * vectors or matrices, or arrays of them. For Mesa programs using + * InputsRead/OutputsWritten, everything but matrices uses one + * slot, while matrices use a slot per column. Presumably + * something doing a more clever packing would use something other + * than InputsRead/OutputsWritten. + */ + + for (int i = 0; i < len; i++) { + if (var->mode == ir_var_in) + prog->InputsRead |= BITFIELD64_BIT(var->location + offset + i); + else if (var->mode == ir_var_system_value) + prog->SystemValuesRead |= (1 << (var->location + offset + i)); + else + prog->OutputsWritten |= BITFIELD64_BIT(var->location + offset + i); + } +} + +/* Default handler: Mark all the locations in the variable as used. */ +ir_visitor_status +ir_set_program_inouts_visitor::visit(ir_dereference_variable *ir) +{ + if (hash_table_find(this->ht, ir->var) == NULL) + return visit_continue; + + if (ir->type->is_array()) { + for (unsigned int i = 0; i < ir->type->length; i++) { + mark(this->prog, ir->var, i, + ir->type->length * ir->type->fields.array->matrix_columns); + } + } else { + mark(this->prog, ir->var, 0, ir->type->matrix_columns); + } + + return visit_continue; +} + +ir_visitor_status +ir_set_program_inouts_visitor::visit_enter(ir_dereference_array *ir) +{ + ir_dereference_variable *deref_var; + ir_constant *index = ir->array_index->as_constant(); + deref_var = ir->array->as_dereference_variable(); + ir_variable *var = NULL; + + /* Check that we're dereferencing a shader in or out */ + if (deref_var) + var = (ir_variable *)hash_table_find(this->ht, deref_var->var); + + if (index && var) { + int width = 1; + + if (deref_var->type->is_array() && + deref_var->type->fields.array->is_matrix()) { + width = deref_var->type->fields.array->matrix_columns; + } + + mark(this->prog, var, index->value.i[0] * width, width); + return visit_continue_with_parent; + } + + return visit_continue; +} + +ir_visitor_status +ir_set_program_inouts_visitor::visit(ir_variable *ir) +{ + if (ir->mode == ir_var_in || + ir->mode == ir_var_out || + ir->mode == ir_var_system_value) { + hash_table_insert(this->ht, ir, ir); + } + + return visit_continue; +} + +ir_visitor_status +ir_set_program_inouts_visitor::visit_enter(ir_function_signature *ir) +{ + /* We don't want to descend into the function parameters and + * consider them as shader inputs or outputs. + */ + visit_list_elements(this, &ir->body); + return visit_continue_with_parent; +} + +void +do_set_program_inouts(exec_list *instructions, struct gl_program *prog) +{ + ir_set_program_inouts_visitor v(prog); + + prog->InputsRead = 0; + prog->OutputsWritten = 0; + prog->SystemValuesRead = 0; + visit_list_elements(&v, instructions); +} diff --git a/3rdparty/glsl-optimizer/src/glsl/ir_unused_structs.cpp b/3rdparty/glsl-optimizer/src/glsl/ir_unused_structs.cpp new file mode 100644 index 000000000..8abae4afd --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/ir_unused_structs.cpp @@ -0,0 +1,93 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include "ir.h" +#include "ir_visitor.h" +#include "ir_unused_structs.h" +#include "glsl_types.h" + +struct struct_entry : public exec_node +{ + struct_entry(const glsl_type *type_) : type(type_) { } + const glsl_type *type; +}; + + +bool +ir_struct_usage_visitor::has_struct_entry(const glsl_type *t) const +{ + assert(t); + foreach_iter(exec_list_iterator, iter, this->struct_list) { + struct_entry *entry = (struct_entry *)iter.get(); + if (entry->type == t) + return true; + } + return false; +} + + +ir_visitor_status +ir_struct_usage_visitor::visit(ir_dereference_variable *ir) +{ + const glsl_type* t = ir->type; + if (t->base_type == GLSL_TYPE_STRUCT) + { + if (!has_struct_entry (t)) + { + struct_entry *entry = new(mem_ctx) struct_entry(t); + this->struct_list.push_tail (entry); + } + } + return visit_continue; +} + +static void visit_variable (ir_instruction* ir, void* data) +{ + ir_variable* var = ir->as_variable(); + if (!var) + return; + ir_struct_usage_visitor* self = reinterpret_cast(data); + const glsl_type* t = ir->type; + if (t->base_type == GLSL_TYPE_STRUCT) + { + if (!self->has_struct_entry (t)) + { + struct_entry *entry = new(self->mem_ctx) struct_entry(t); + self->struct_list.push_tail (entry); + } + } + +} + +ir_struct_usage_visitor::ir_struct_usage_visitor() +{ + this->mem_ctx = ralloc_context(NULL); + this->struct_list.make_empty(); + this->callback = visit_variable; + this->data = this; +} + +ir_struct_usage_visitor::~ir_struct_usage_visitor(void) +{ + ralloc_free(mem_ctx); +} diff --git a/3rdparty/glsl-optimizer/src/glsl/ir_unused_structs.h b/3rdparty/glsl-optimizer/src/glsl/ir_unused_structs.h new file mode 100644 index 000000000..217dd4615 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/ir_unused_structs.h @@ -0,0 +1,38 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include "ir.h" +#include "ir_visitor.h" + +class ir_struct_usage_visitor : public ir_hierarchical_visitor { +public: + ir_struct_usage_visitor(); + ~ir_struct_usage_visitor(void); + + virtual ir_visitor_status visit(ir_dereference_variable *); + + bool has_struct_entry(const glsl_type *t) const; + + exec_list struct_list; + void *mem_ctx; +}; diff --git a/3rdparty/glsl-optimizer/src/glsl/ir_validate.cpp b/3rdparty/glsl-optimizer/src/glsl/ir_validate.cpp new file mode 100644 index 000000000..b3ca72ef0 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/ir_validate.cpp @@ -0,0 +1,621 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file ir_validate.cpp + * + * Attempts to verify that various invariants of the IR tree are true. + * + * In particular, at the moment it makes sure that no single + * ir_instruction node except for ir_variable appears multiple times + * in the ir tree. ir_variable does appear multiple times: Once as a + * declaration in an exec_list, and multiple times as the endpoint of + * a dereference chain. + */ + +#include +#include "ir.h" +#include "ir_hierarchical_visitor.h" +#include "program/hash_table.h" +#include "glsl_types.h" + +class ir_validate : public ir_hierarchical_visitor { +public: + ir_validate() + { + this->ht = hash_table_ctor(0, hash_table_pointer_hash, + hash_table_pointer_compare); + + this->current_function = NULL; + + this->callback = ir_validate::validate_ir; + this->data = ht; + } + + ~ir_validate() + { + hash_table_dtor(this->ht); + } + + virtual ir_visitor_status visit(ir_variable *v); + virtual ir_visitor_status visit(ir_dereference_variable *ir); + virtual ir_visitor_status visit(ir_if *ir); + + virtual ir_visitor_status visit_leave(ir_loop *ir); + virtual ir_visitor_status visit_enter(ir_function *ir); + virtual ir_visitor_status visit_leave(ir_function *ir); + virtual ir_visitor_status visit_enter(ir_function_signature *ir); + + virtual ir_visitor_status visit_leave(ir_expression *ir); + virtual ir_visitor_status visit_leave(ir_swizzle *ir); + + virtual ir_visitor_status visit_enter(ir_assignment *ir); + virtual ir_visitor_status visit_enter(ir_call *ir); + + static void validate_ir(ir_instruction *ir, void *data); + + ir_function *current_function; + + struct hash_table *ht; +}; + + +ir_visitor_status +ir_validate::visit(ir_dereference_variable *ir) +{ + if ((ir->var == NULL) || (ir->var->as_variable() == NULL)) { + printf("ir_dereference_variable @ %p does not specify a variable %p\n", + (void *) ir, (void *) ir->var); + abort(); + } + + if (hash_table_find(ht, ir->var) == NULL) { + printf("ir_dereference_variable @ %p specifies undeclared variable " + "`%s' @ %p\n", + (void *) ir, ir->var->name, (void *) ir->var); + abort(); + } + + this->validate_ir(ir, this->data); + + return visit_continue; +} + +ir_visitor_status +ir_validate::visit(ir_if *ir) +{ + if (ir->condition->type != glsl_type::bool_type) { + printf("ir_if condition %s type instead of bool.\n", + ir->condition->type->name); + ir->print(); + printf("\n"); + abort(); + } + + return visit_continue; +} + + +ir_visitor_status +ir_validate::visit_leave(ir_loop *ir) +{ + if (ir->counter != NULL) { + if ((ir->from == NULL) || (ir->from == NULL) || (ir->increment == NULL)) { + printf("ir_loop has invalid loop controls:\n" + " counter: %p\n" + " from: %p\n" + " to: %p\n" + " increment: %p\n", + (void *) ir->counter, (void *) ir->from, (void *) ir->to, + (void *) ir->increment); + abort(); + } + + if ((ir->cmp < ir_binop_less) || (ir->cmp > ir_binop_nequal)) { + printf("ir_loop has invalid comparitor %d\n", ir->cmp); + abort(); + } + } else { + if ((ir->from != NULL) || (ir->from != NULL) || (ir->increment != NULL)) { + printf("ir_loop has invalid loop controls:\n" + " counter: %p\n" + " from: %p\n" + " to: %p\n" + " increment: %p\n", + (void *) ir->counter, (void *) ir->from, (void *) ir->to, + (void *) ir->increment); + abort(); + } + } + + return visit_continue; +} + + +ir_visitor_status +ir_validate::visit_enter(ir_function *ir) +{ + /* Function definitions cannot be nested. + */ + if (this->current_function != NULL) { + printf("Function definition nested inside another function " + "definition:\n"); + printf("%s %p inside %s %p\n", + ir->name, (void *) ir, + this->current_function->name, (void *) this->current_function); + abort(); + } + + /* Store the current function hierarchy being traversed. This is used + * by the function signature visitor to ensure that the signatures are + * linked with the correct functions. + */ + this->current_function = ir; + + this->validate_ir(ir, this->data); + + /* Verify that all of the things stored in the list of signatures are, + * in fact, function signatures. + */ + foreach_list(node, &ir->signatures) { + ir_instruction *sig = (ir_instruction *) node; + + if (sig->ir_type != ir_type_function_signature) { + printf("Non-signature in signature list of function `%s'\n", + ir->name); + abort(); + } + } + + return visit_continue; +} + +ir_visitor_status +ir_validate::visit_leave(ir_function *ir) +{ + assert(ralloc_parent(ir->name) == ir); + + this->current_function = NULL; + return visit_continue; +} + +ir_visitor_status +ir_validate::visit_enter(ir_function_signature *ir) +{ + if (this->current_function != ir->function()) { + printf("Function signature nested inside wrong function " + "definition:\n"); + printf("%p inside %s %p instead of %s %p\n", + (void *) ir, + this->current_function->name, (void *) this->current_function, + ir->function_name(), (void *) ir->function()); + abort(); + } + + if (ir->return_type == NULL) { + printf("Function signature %p for function %s has NULL return type.\n", + (void *) ir, ir->function_name()); + abort(); + } + + this->validate_ir(ir, this->data); + + return visit_continue; +} + +ir_visitor_status +ir_validate::visit_leave(ir_expression *ir) +{ + switch (ir->operation) { + case ir_unop_bit_not: + assert(ir->operands[0]->type == ir->type); + break; + case ir_unop_logic_not: + assert(ir->type->base_type == GLSL_TYPE_BOOL); + assert(ir->operands[0]->type->base_type == GLSL_TYPE_BOOL); + break; + + case ir_unop_neg: + case ir_unop_abs: + case ir_unop_sign: + case ir_unop_rcp: + case ir_unop_rsq: + case ir_unop_sqrt: + assert(ir->type == ir->operands[0]->type); + break; + + case ir_unop_exp: + case ir_unop_log: + case ir_unop_exp2: + case ir_unop_log2: + assert(ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT); + assert(ir->type == ir->operands[0]->type); + break; + + case ir_unop_f2i: + assert(ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT); + assert(ir->type->base_type == GLSL_TYPE_INT); + break; + case ir_unop_i2f: + assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT); + assert(ir->type->base_type == GLSL_TYPE_FLOAT); + break; + case ir_unop_f2b: + assert(ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT); + assert(ir->type->base_type == GLSL_TYPE_BOOL); + break; + case ir_unop_b2f: + assert(ir->operands[0]->type->base_type == GLSL_TYPE_BOOL); + assert(ir->type->base_type == GLSL_TYPE_FLOAT); + break; + case ir_unop_i2b: + assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT); + assert(ir->type->base_type == GLSL_TYPE_BOOL); + break; + case ir_unop_b2i: + assert(ir->operands[0]->type->base_type == GLSL_TYPE_BOOL); + assert(ir->type->base_type == GLSL_TYPE_INT); + break; + case ir_unop_u2f: + assert(ir->operands[0]->type->base_type == GLSL_TYPE_UINT); + assert(ir->type->base_type == GLSL_TYPE_FLOAT); + break; + case ir_unop_i2u: + assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT); + assert(ir->type->base_type == GLSL_TYPE_UINT); + break; + case ir_unop_u2i: + assert(ir->operands[0]->type->base_type == GLSL_TYPE_UINT); + assert(ir->type->base_type == GLSL_TYPE_INT); + break; + + case ir_unop_any: + assert(ir->operands[0]->type->base_type == GLSL_TYPE_BOOL); + assert(ir->type == glsl_type::bool_type); + break; + + case ir_unop_trunc: + case ir_unop_round_even: + case ir_unop_ceil: + case ir_unop_floor: + case ir_unop_fract: + case ir_unop_sin: + case ir_unop_cos: + case ir_unop_sin_reduced: + case ir_unop_cos_reduced: + case ir_unop_dFdx: + case ir_unop_dFdy: + assert(ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT); + assert(ir->operands[0]->type == ir->type); + break; + + case ir_unop_noise: + /* XXX what can we assert here? */ + break; + + case ir_binop_add: + case ir_binop_sub: + case ir_binop_mul: + case ir_binop_div: + case ir_binop_mod: + case ir_binop_min: + case ir_binop_max: + case ir_binop_pow: + if (ir->operands[0]->type->is_scalar()) + assert(ir->operands[1]->type == ir->type); + else if (ir->operands[1]->type->is_scalar()) + assert(ir->operands[0]->type == ir->type); + else if (ir->operands[0]->type->is_vector() && + ir->operands[1]->type->is_vector()) { + assert(ir->operands[0]->type == ir->operands[1]->type); + assert(ir->operands[0]->type == ir->type); + } + break; + + case ir_binop_less: + case ir_binop_greater: + case ir_binop_lequal: + case ir_binop_gequal: + case ir_binop_equal: + case ir_binop_nequal: + /* The semantics of the IR operators differ from the GLSL <, >, <=, >=, + * ==, and != operators. The IR operators perform a component-wise + * comparison on scalar or vector types and return a boolean scalar or + * vector type of the same size. + */ + assert(ir->type->base_type == GLSL_TYPE_BOOL); + assert(ir->operands[0]->type == ir->operands[1]->type); + assert(ir->operands[0]->type->is_vector() + || ir->operands[0]->type->is_scalar()); + assert(ir->operands[0]->type->vector_elements + == ir->type->vector_elements); + break; + + case ir_binop_all_equal: + case ir_binop_any_nequal: + /* GLSL == and != operate on scalars, vectors, matrices and arrays, and + * return a scalar boolean. The IR matches that. + */ + assert(ir->type == glsl_type::bool_type); + assert(ir->operands[0]->type == ir->operands[1]->type); + break; + + case ir_binop_lshift: + case ir_binop_rshift: + assert(ir->operands[0]->type->is_integer() && + ir->operands[1]->type->is_integer()); + if (ir->operands[0]->type->is_scalar()) { + assert(ir->operands[1]->type->is_scalar()); + } + if (ir->operands[0]->type->is_vector() && + ir->operands[1]->type->is_vector()) { + assert(ir->operands[0]->type->components() == + ir->operands[1]->type->components()); + } + assert(ir->type == ir->operands[0]->type); + break; + + case ir_binop_bit_and: + case ir_binop_bit_xor: + case ir_binop_bit_or: + assert(ir->operands[0]->type->base_type == + ir->operands[1]->type->base_type); + assert(ir->type->is_integer()); + if (ir->operands[0]->type->is_vector() && + ir->operands[1]->type->is_vector()) { + assert(ir->operands[0]->type->vector_elements == + ir->operands[1]->type->vector_elements); + } + break; + + case ir_binop_logic_and: + case ir_binop_logic_xor: + case ir_binop_logic_or: + assert(ir->type == glsl_type::bool_type); + assert(ir->operands[0]->type == glsl_type::bool_type); + assert(ir->operands[1]->type == glsl_type::bool_type); + break; + + case ir_binop_dot: + assert(ir->type == glsl_type::float_type); + assert(ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT); + assert(ir->operands[0]->type->is_vector()); + assert(ir->operands[0]->type == ir->operands[1]->type); + break; + + case ir_quadop_vector: + /* The vector operator collects some number of scalars and generates a + * vector from them. + * + * - All of the operands must be scalar. + * - Number of operands must matche the size of the resulting vector. + * - Base type of the operands must match the base type of the result. + */ + assert(ir->type->is_vector()); + switch (ir->type->vector_elements) { + case 2: + assert(ir->operands[0]->type->is_scalar()); + assert(ir->operands[0]->type->base_type == ir->type->base_type); + assert(ir->operands[1]->type->is_scalar()); + assert(ir->operands[1]->type->base_type == ir->type->base_type); + assert(ir->operands[2] == NULL); + assert(ir->operands[3] == NULL); + break; + case 3: + assert(ir->operands[0]->type->is_scalar()); + assert(ir->operands[0]->type->base_type == ir->type->base_type); + assert(ir->operands[1]->type->is_scalar()); + assert(ir->operands[1]->type->base_type == ir->type->base_type); + assert(ir->operands[2]->type->is_scalar()); + assert(ir->operands[2]->type->base_type == ir->type->base_type); + assert(ir->operands[3] == NULL); + break; + case 4: + assert(ir->operands[0]->type->is_scalar()); + assert(ir->operands[0]->type->base_type == ir->type->base_type); + assert(ir->operands[1]->type->is_scalar()); + assert(ir->operands[1]->type->base_type == ir->type->base_type); + assert(ir->operands[2]->type->is_scalar()); + assert(ir->operands[2]->type->base_type == ir->type->base_type); + assert(ir->operands[3]->type->is_scalar()); + assert(ir->operands[3]->type->base_type == ir->type->base_type); + break; + default: + /* The is_vector assertion above should prevent execution from ever + * getting here. + */ + assert(!"Should not get here."); + break; + } + } + + return visit_continue; +} + +ir_visitor_status +ir_validate::visit_leave(ir_swizzle *ir) +{ + int chans[4] = {ir->mask.x, ir->mask.y, ir->mask.z, ir->mask.w}; + + for (unsigned int i = 0; i < ir->type->vector_elements; i++) { + if (chans[i] >= ir->val->type->vector_elements) { + printf("ir_swizzle @ %p specifies a channel not present " + "in the value.\n", (void *) ir); + ir->print(); + abort(); + } + } + + return visit_continue; +} + +ir_visitor_status +ir_validate::visit(ir_variable *ir) +{ + /* An ir_variable is the one thing that can (and will) appear multiple times + * in an IR tree. It is added to the hashtable so that it can be used + * in the ir_dereference_variable handler to ensure that a variable is + * declared before it is dereferenced. + */ + if (ir->name) + assert(ralloc_parent(ir->name) == ir); + + hash_table_insert(ht, ir, ir); + + + /* If a variable is an array, verify that the maximum array index is in + * bounds. There was once an error in AST-to-HIR conversion that set this + * to be out of bounds. + */ + if (ir->type->array_size() > 0) { + if (ir->max_array_access >= ir->type->length) { + printf("ir_variable has maximum access out of bounds (%d vs %d)\n", + ir->max_array_access, ir->type->length - 1); + ir->print(); + abort(); + } + } + + return visit_continue; +} + +ir_visitor_status +ir_validate::visit_enter(ir_assignment *ir) +{ + const ir_dereference *const lhs = ir->lhs; + if (lhs->type->is_scalar() || lhs->type->is_vector()) { + if (ir->write_mask == 0) { + printf("Assignment LHS is %s, but write mask is 0:\n", + lhs->type->is_scalar() ? "scalar" : "vector"); + ir->print(); + abort(); + } + + int lhs_components = 0; + for (int i = 0; i < 4; i++) { + if (ir->write_mask & (1 << i)) + lhs_components++; + } + + if (lhs_components != ir->rhs->type->vector_elements) { + printf("Assignment count of LHS write mask channels enabled not\n" + "matching RHS vector size (%d LHS, %d RHS).\n", + lhs_components, ir->rhs->type->vector_elements); + ir->print(); + abort(); + } + } + + this->validate_ir(ir, this->data); + + return visit_continue; +} + +ir_visitor_status +ir_validate::visit_enter(ir_call *ir) +{ + ir_function_signature *const callee = ir->get_callee(); + + if (callee->ir_type != ir_type_function_signature) { + printf("IR called by ir_call is not ir_function_signature!\n"); + abort(); + } + + const exec_node *formal_param_node = callee->parameters.head; + const exec_node *actual_param_node = ir->actual_parameters.head; + while (true) { + if (formal_param_node->is_tail_sentinel() + != actual_param_node->is_tail_sentinel()) { + printf("ir_call has the wrong number of parameters:\n"); + goto dump_ir; + } + if (formal_param_node->is_tail_sentinel()) { + break; + } + const ir_variable *formal_param + = (const ir_variable *) formal_param_node; + const ir_rvalue *actual_param + = (const ir_rvalue *) actual_param_node; + if (formal_param->type != actual_param->type) { + printf("ir_call parameter type mismatch:\n"); + goto dump_ir; + } + if (formal_param->mode == ir_var_out + || formal_param->mode == ir_var_inout) { + if (!actual_param->is_lvalue()) { + printf("ir_call out/inout parameters must be lvalues:\n"); + goto dump_ir; + } + } + formal_param_node = formal_param_node->next; + actual_param_node = actual_param_node->next; + } + + return visit_continue; + +dump_ir: + ir->print(); + printf("callee:\n"); + callee->print(); + abort(); +} + +void +ir_validate::validate_ir(ir_instruction *ir, void *data) +{ + struct hash_table *ht = (struct hash_table *) data; + + if (hash_table_find(ht, ir)) { + printf("Instruction node present twice in ir tree:\n"); + ir->print(); + printf("\n"); + abort(); + } + hash_table_insert(ht, ir, ir); +} + +void +check_node_type(ir_instruction *ir, void *data) +{ + (void) data; + + if (ir->ir_type <= ir_type_unset || ir->ir_type >= ir_type_max) { + printf("Instruction node with unset type\n"); + ir->print(); printf("\n"); + } + assert(ir->type != glsl_type::error_type); +} + +void +validate_ir_tree(exec_list *instructions) +{ + ir_validate v; + + v.run(instructions); + + foreach_iter(exec_list_iterator, iter, *instructions) { + ir_instruction *ir = (ir_instruction *)iter.get(); + + visit_tree(ir, check_node_type, NULL); + } +} diff --git a/3rdparty/glsl-optimizer/src/glsl/ir_variable.cpp b/3rdparty/glsl-optimizer/src/glsl/ir_variable.cpp new file mode 100644 index 000000000..084439ffa --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/ir_variable.cpp @@ -0,0 +1,857 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include "ir.h" +#include "glsl_parser_extras.h" +#include "glsl_symbol_table.h" +#include "builtin_variables.h" +#include "main/uniforms.h" +#include "program/prog_parameter.h" +#include "program/prog_statevars.h" +#include "program/prog_instruction.h" + +static void generate_ARB_draw_buffers_variables(exec_list *, + struct _mesa_glsl_parse_state *, + bool, _mesa_glsl_parser_targets); + +static void +generate_ARB_draw_instanced_variables(exec_list *, + struct _mesa_glsl_parse_state *, + bool, _mesa_glsl_parser_targets); + +static struct gl_builtin_uniform_element gl_DepthRange_elements[] = { + {"near", {STATE_DEPTH_RANGE, 0, 0}, SWIZZLE_XXXX}, + {"far", {STATE_DEPTH_RANGE, 0, 0}, SWIZZLE_YYYY}, + {"diff", {STATE_DEPTH_RANGE, 0, 0}, SWIZZLE_ZZZZ}, +}; + +static struct gl_builtin_uniform_element gl_ClipPlane_elements[] = { + {NULL, {STATE_CLIPPLANE, 0, 0}, SWIZZLE_XYZW} +}; + +static struct gl_builtin_uniform_element gl_Point_elements[] = { + {"size", {STATE_POINT_SIZE}, SWIZZLE_XXXX}, + {"sizeMin", {STATE_POINT_SIZE}, SWIZZLE_YYYY}, + {"sizeMax", {STATE_POINT_SIZE}, SWIZZLE_ZZZZ}, + {"fadeThresholdSize", {STATE_POINT_SIZE}, SWIZZLE_WWWW}, + {"distanceConstantAttenuation", {STATE_POINT_ATTENUATION}, SWIZZLE_XXXX}, + {"distanceLinearAttenuation", {STATE_POINT_ATTENUATION}, SWIZZLE_YYYY}, + {"distanceQuadraticAttenuation", {STATE_POINT_ATTENUATION}, SWIZZLE_ZZZZ}, +}; + +static struct gl_builtin_uniform_element gl_FrontMaterial_elements[] = { + {"emission", {STATE_MATERIAL, 0, STATE_EMISSION}, SWIZZLE_XYZW}, + {"ambient", {STATE_MATERIAL, 0, STATE_AMBIENT}, SWIZZLE_XYZW}, + {"diffuse", {STATE_MATERIAL, 0, STATE_DIFFUSE}, SWIZZLE_XYZW}, + {"specular", {STATE_MATERIAL, 0, STATE_SPECULAR}, SWIZZLE_XYZW}, + {"shininess", {STATE_MATERIAL, 0, STATE_SHININESS}, SWIZZLE_XXXX}, +}; + +static struct gl_builtin_uniform_element gl_BackMaterial_elements[] = { + {"emission", {STATE_MATERIAL, 1, STATE_EMISSION}, SWIZZLE_XYZW}, + {"ambient", {STATE_MATERIAL, 1, STATE_AMBIENT}, SWIZZLE_XYZW}, + {"diffuse", {STATE_MATERIAL, 1, STATE_DIFFUSE}, SWIZZLE_XYZW}, + {"specular", {STATE_MATERIAL, 1, STATE_SPECULAR}, SWIZZLE_XYZW}, + {"shininess", {STATE_MATERIAL, 1, STATE_SHININESS}, SWIZZLE_XXXX}, +}; + +static struct gl_builtin_uniform_element gl_LightSource_elements[] = { + {"ambient", {STATE_LIGHT, 0, STATE_AMBIENT}, SWIZZLE_XYZW}, + {"diffuse", {STATE_LIGHT, 0, STATE_DIFFUSE}, SWIZZLE_XYZW}, + {"specular", {STATE_LIGHT, 0, STATE_SPECULAR}, SWIZZLE_XYZW}, + {"position", {STATE_LIGHT, 0, STATE_POSITION}, SWIZZLE_XYZW}, + {"halfVector", {STATE_LIGHT, 0, STATE_HALF_VECTOR}, SWIZZLE_XYZW}, + {"spotDirection", {STATE_LIGHT, 0, STATE_SPOT_DIRECTION}, + MAKE_SWIZZLE4(SWIZZLE_X, + SWIZZLE_Y, + SWIZZLE_Z, + SWIZZLE_Z)}, + {"spotCosCutoff", {STATE_LIGHT, 0, STATE_SPOT_DIRECTION}, SWIZZLE_WWWW}, + {"spotCutoff", {STATE_LIGHT, 0, STATE_SPOT_CUTOFF}, SWIZZLE_XXXX}, + {"spotExponent", {STATE_LIGHT, 0, STATE_ATTENUATION}, SWIZZLE_WWWW}, + {"constantAttenuation", {STATE_LIGHT, 0, STATE_ATTENUATION}, SWIZZLE_XXXX}, + {"linearAttenuation", {STATE_LIGHT, 0, STATE_ATTENUATION}, SWIZZLE_YYYY}, + {"quadraticAttenuation", {STATE_LIGHT, 0, STATE_ATTENUATION}, SWIZZLE_ZZZZ}, +}; + +static struct gl_builtin_uniform_element gl_LightModel_elements[] = { + {"ambient", {STATE_LIGHTMODEL_AMBIENT, 0}, SWIZZLE_XYZW}, +}; + +static struct gl_builtin_uniform_element gl_FrontLightModelProduct_elements[] = { + {"sceneColor", {STATE_LIGHTMODEL_SCENECOLOR, 0}, SWIZZLE_XYZW}, +}; + +static struct gl_builtin_uniform_element gl_BackLightModelProduct_elements[] = { + {"sceneColor", {STATE_LIGHTMODEL_SCENECOLOR, 1}, SWIZZLE_XYZW}, +}; + +static struct gl_builtin_uniform_element gl_FrontLightProduct_elements[] = { + {"ambient", {STATE_LIGHTPROD, 0, 0, STATE_AMBIENT}, SWIZZLE_XYZW}, + {"diffuse", {STATE_LIGHTPROD, 0, 0, STATE_DIFFUSE}, SWIZZLE_XYZW}, + {"specular", {STATE_LIGHTPROD, 0, 0, STATE_SPECULAR}, SWIZZLE_XYZW}, +}; + +static struct gl_builtin_uniform_element gl_BackLightProduct_elements[] = { + {"ambient", {STATE_LIGHTPROD, 0, 1, STATE_AMBIENT}, SWIZZLE_XYZW}, + {"diffuse", {STATE_LIGHTPROD, 0, 1, STATE_DIFFUSE}, SWIZZLE_XYZW}, + {"specular", {STATE_LIGHTPROD, 0, 1, STATE_SPECULAR}, SWIZZLE_XYZW}, +}; + +static struct gl_builtin_uniform_element gl_TextureEnvColor_elements[] = { + {NULL, {STATE_TEXENV_COLOR, 0}, SWIZZLE_XYZW}, +}; + +static struct gl_builtin_uniform_element gl_EyePlaneS_elements[] = { + {NULL, {STATE_TEXGEN, 0, STATE_TEXGEN_EYE_S}, SWIZZLE_XYZW}, +}; + +static struct gl_builtin_uniform_element gl_EyePlaneT_elements[] = { + {NULL, {STATE_TEXGEN, 0, STATE_TEXGEN_EYE_T}, SWIZZLE_XYZW}, +}; + +static struct gl_builtin_uniform_element gl_EyePlaneR_elements[] = { + {NULL, {STATE_TEXGEN, 0, STATE_TEXGEN_EYE_R}, SWIZZLE_XYZW}, +}; + +static struct gl_builtin_uniform_element gl_EyePlaneQ_elements[] = { + {NULL, {STATE_TEXGEN, 0, STATE_TEXGEN_EYE_Q}, SWIZZLE_XYZW}, +}; + +static struct gl_builtin_uniform_element gl_ObjectPlaneS_elements[] = { + {NULL, {STATE_TEXGEN, 0, STATE_TEXGEN_OBJECT_S}, SWIZZLE_XYZW}, +}; + +static struct gl_builtin_uniform_element gl_ObjectPlaneT_elements[] = { + {NULL, {STATE_TEXGEN, 0, STATE_TEXGEN_OBJECT_T}, SWIZZLE_XYZW}, +}; + +static struct gl_builtin_uniform_element gl_ObjectPlaneR_elements[] = { + {NULL, {STATE_TEXGEN, 0, STATE_TEXGEN_OBJECT_R}, SWIZZLE_XYZW}, +}; + +static struct gl_builtin_uniform_element gl_ObjectPlaneQ_elements[] = { + {NULL, {STATE_TEXGEN, 0, STATE_TEXGEN_OBJECT_Q}, SWIZZLE_XYZW}, +}; + +static struct gl_builtin_uniform_element gl_Fog_elements[] = { + {"color", {STATE_FOG_COLOR}, SWIZZLE_XYZW}, + {"density", {STATE_FOG_PARAMS}, SWIZZLE_XXXX}, + {"start", {STATE_FOG_PARAMS}, SWIZZLE_YYYY}, + {"end", {STATE_FOG_PARAMS}, SWIZZLE_ZZZZ}, + {"scale", {STATE_FOG_PARAMS}, SWIZZLE_WWWW}, +}; + +static struct gl_builtin_uniform_element gl_NormalScale_elements[] = { + {NULL, {STATE_NORMAL_SCALE}, SWIZZLE_XXXX}, +}; + +static struct gl_builtin_uniform_element gl_MESABumpRotMatrix0_elements[] = { + {NULL, {STATE_INTERNAL, STATE_ROT_MATRIX_0}, SWIZZLE_XYZW}, +}; + +static struct gl_builtin_uniform_element gl_MESABumpRotMatrix1_elements[] = { + {NULL, {STATE_INTERNAL, STATE_ROT_MATRIX_1}, SWIZZLE_XYZW}, +}; + +static struct gl_builtin_uniform_element gl_MESAFogParamsOptimized_elements[] = { + {NULL, {STATE_INTERNAL, STATE_FOG_PARAMS_OPTIMIZED}, SWIZZLE_XYZW}, +}; + +#define MATRIX(name, statevar, modifier) \ + static struct gl_builtin_uniform_element name ## _elements[] = { \ + { NULL, { statevar, 0, 0, 0, modifier}, SWIZZLE_XYZW }, \ + { NULL, { statevar, 0, 1, 1, modifier}, SWIZZLE_XYZW }, \ + { NULL, { statevar, 0, 2, 2, modifier}, SWIZZLE_XYZW }, \ + { NULL, { statevar, 0, 3, 3, modifier}, SWIZZLE_XYZW }, \ + } + +MATRIX(gl_ModelViewMatrix, + STATE_MODELVIEW_MATRIX, STATE_MATRIX_TRANSPOSE); +MATRIX(gl_ModelViewMatrixInverse, + STATE_MODELVIEW_MATRIX, STATE_MATRIX_INVTRANS); +MATRIX(gl_ModelViewMatrixTranspose, + STATE_MODELVIEW_MATRIX, 0); +MATRIX(gl_ModelViewMatrixInverseTranspose, + STATE_MODELVIEW_MATRIX, STATE_MATRIX_INVERSE); + +MATRIX(gl_ProjectionMatrix, + STATE_PROJECTION_MATRIX, STATE_MATRIX_TRANSPOSE); +MATRIX(gl_ProjectionMatrixInverse, + STATE_PROJECTION_MATRIX, STATE_MATRIX_INVTRANS); +MATRIX(gl_ProjectionMatrixTranspose, + STATE_PROJECTION_MATRIX, 0); +MATRIX(gl_ProjectionMatrixInverseTranspose, + STATE_PROJECTION_MATRIX, STATE_MATRIX_INVERSE); + +MATRIX(gl_ModelViewProjectionMatrix, + STATE_MVP_MATRIX, STATE_MATRIX_TRANSPOSE); +MATRIX(gl_ModelViewProjectionMatrixInverse, + STATE_MVP_MATRIX, STATE_MATRIX_INVTRANS); +MATRIX(gl_ModelViewProjectionMatrixTranspose, + STATE_MVP_MATRIX, 0); +MATRIX(gl_ModelViewProjectionMatrixInverseTranspose, + STATE_MVP_MATRIX, STATE_MATRIX_INVERSE); + +MATRIX(gl_TextureMatrix, + STATE_TEXTURE_MATRIX, STATE_MATRIX_TRANSPOSE); +MATRIX(gl_TextureMatrixInverse, + STATE_TEXTURE_MATRIX, STATE_MATRIX_INVTRANS); +MATRIX(gl_TextureMatrixTranspose, + STATE_TEXTURE_MATRIX, 0); +MATRIX(gl_TextureMatrixInverseTranspose, + STATE_TEXTURE_MATRIX, STATE_MATRIX_INVERSE); + +static struct gl_builtin_uniform_element gl_NormalMatrix_elements[] = { + { NULL, { STATE_MODELVIEW_MATRIX, 0, 0, 0, STATE_MATRIX_INVERSE}, + SWIZZLE_XYZW }, + { NULL, { STATE_MODELVIEW_MATRIX, 0, 1, 1, STATE_MATRIX_INVERSE}, + SWIZZLE_XYZW }, + { NULL, { STATE_MODELVIEW_MATRIX, 0, 2, 2, STATE_MATRIX_INVERSE}, + SWIZZLE_XYZW }, +}; + +#undef MATRIX + +#define STATEVAR(name) {#name, name ## _elements, Elements(name ## _elements)} + +const struct gl_builtin_uniform_desc _mesa_builtin_uniform_desc[] = { + STATEVAR(gl_DepthRange), + STATEVAR(gl_ClipPlane), + STATEVAR(gl_Point), + STATEVAR(gl_FrontMaterial), + STATEVAR(gl_BackMaterial), + STATEVAR(gl_LightSource), + STATEVAR(gl_LightModel), + STATEVAR(gl_FrontLightModelProduct), + STATEVAR(gl_BackLightModelProduct), + STATEVAR(gl_FrontLightProduct), + STATEVAR(gl_BackLightProduct), + STATEVAR(gl_TextureEnvColor), + STATEVAR(gl_EyePlaneS), + STATEVAR(gl_EyePlaneT), + STATEVAR(gl_EyePlaneR), + STATEVAR(gl_EyePlaneQ), + STATEVAR(gl_ObjectPlaneS), + STATEVAR(gl_ObjectPlaneT), + STATEVAR(gl_ObjectPlaneR), + STATEVAR(gl_ObjectPlaneQ), + STATEVAR(gl_Fog), + + STATEVAR(gl_ModelViewMatrix), + STATEVAR(gl_ModelViewMatrixInverse), + STATEVAR(gl_ModelViewMatrixTranspose), + STATEVAR(gl_ModelViewMatrixInverseTranspose), + + STATEVAR(gl_ProjectionMatrix), + STATEVAR(gl_ProjectionMatrixInverse), + STATEVAR(gl_ProjectionMatrixTranspose), + STATEVAR(gl_ProjectionMatrixInverseTranspose), + + STATEVAR(gl_ModelViewProjectionMatrix), + STATEVAR(gl_ModelViewProjectionMatrixInverse), + STATEVAR(gl_ModelViewProjectionMatrixTranspose), + STATEVAR(gl_ModelViewProjectionMatrixInverseTranspose), + + STATEVAR(gl_TextureMatrix), + STATEVAR(gl_TextureMatrixInverse), + STATEVAR(gl_TextureMatrixTranspose), + STATEVAR(gl_TextureMatrixInverseTranspose), + + STATEVAR(gl_NormalMatrix), + STATEVAR(gl_NormalScale), + + STATEVAR(gl_MESABumpRotMatrix0), + STATEVAR(gl_MESABumpRotMatrix1), + STATEVAR(gl_MESAFogParamsOptimized), + + {NULL, NULL, 0} +}; + +static ir_variable * +add_variable(exec_list *instructions, glsl_symbol_table *symtab, + const char *name, const glsl_type *type, + enum ir_variable_mode mode, int slot) +{ + ir_variable *var = new(symtab) ir_variable(type, name, mode, glsl_precision_undefined); + + switch (var->mode) { + case ir_var_auto: + case ir_var_in: + case ir_var_const_in: + case ir_var_uniform: + case ir_var_system_value: + var->read_only = true; + break; + case ir_var_inout: + case ir_var_out: + break; + default: + assert(0); + break; + } + + var->location = slot; + var->explicit_location = (slot >= 0); + + /* Once the variable is created an initialized, add it to the symbol table + * and add the declaration to the IR stream. + */ + instructions->push_tail(var); + + symtab->add_variable(var); + return var; +} + +static ir_variable * +add_uniform(exec_list *instructions, glsl_symbol_table *symtab, + const char *name, const glsl_type *type) +{ + ir_variable *const uni = + add_variable(instructions, symtab, name, type, ir_var_uniform, -1); + + unsigned i; + for (i = 0; _mesa_builtin_uniform_desc[i].name != NULL; i++) { + if (strcmp(_mesa_builtin_uniform_desc[i].name, name) == 0) { + break; + } + } + + assert(_mesa_builtin_uniform_desc[i].name != NULL); + const struct gl_builtin_uniform_desc* const statevar = + &_mesa_builtin_uniform_desc[i]; + + const unsigned array_count = type->is_array() ? type->length : 1; + uni->num_state_slots = array_count * statevar->num_elements; + + ir_state_slot *slots = + ralloc_array(uni, ir_state_slot, uni->num_state_slots); + + uni->state_slots = slots; + + for (unsigned a = 0; a < array_count; a++) { + for (unsigned j = 0; j < statevar->num_elements; j++) { + struct gl_builtin_uniform_element *element = &statevar->elements[j]; + + memcpy(slots->tokens, element->tokens, sizeof(element->tokens)); + if (type->is_array()) { + slots->tokens[1] = a; + } + + slots->swizzle = element->swizzle; + slots++; + } + } + + return uni; +} + +static void +add_builtin_variable(exec_list *instructions, glsl_symbol_table *symtab, + const builtin_variable *proto) +{ + /* Create a new variable declaration from the description supplied by + * the caller. + */ + const glsl_type *const type = symtab->get_type(proto->type); + + assert(type != NULL); + + if (proto->mode == ir_var_uniform) { + add_uniform(instructions, symtab, proto->name, type); + } else { + add_variable(instructions, symtab, proto->name, type, proto->mode, + proto->slot); + } +} + +static void +add_builtin_constant(exec_list *instructions, glsl_symbol_table *symtab, + const char *name, int value) +{ + ir_variable *const var = add_variable(instructions, symtab, + name, glsl_type::int_type, + ir_var_auto, -1); + var->constant_value = new(var) ir_constant(value); +} + +/* Several constants in GLSL ES have different names than normal desktop GLSL. + * Therefore, this function should only be called on the ES path. + */ +static void +generate_100ES_uniforms(exec_list *instructions, + struct _mesa_glsl_parse_state *state) +{ + glsl_symbol_table *const symtab = state->symbols; + + add_builtin_constant(instructions, symtab, "gl_MaxVertexAttribs", + state->Const.MaxVertexAttribs); + add_builtin_constant(instructions, symtab, "gl_MaxVertexUniformVectors", + state->Const.MaxVertexUniformComponents); + add_builtin_constant(instructions, symtab, "gl_MaxVaryingVectors", + state->Const.MaxVaryingFloats / 4); + add_builtin_constant(instructions, symtab, "gl_MaxVertexTextureImageUnits", + state->Const.MaxVertexTextureImageUnits); + add_builtin_constant(instructions, symtab, "gl_MaxCombinedTextureImageUnits", + state->Const.MaxCombinedTextureImageUnits); + add_builtin_constant(instructions, symtab, "gl_MaxTextureImageUnits", + state->Const.MaxTextureImageUnits); + add_builtin_constant(instructions, symtab, "gl_MaxFragmentUniformVectors", + state->Const.MaxFragmentUniformComponents); + + add_uniform(instructions, symtab, "gl_DepthRange", + state->symbols->get_type("gl_DepthRangeParameters")); +} + +static void +generate_110_uniforms(exec_list *instructions, + struct _mesa_glsl_parse_state *state) +{ + glsl_symbol_table *const symtab = state->symbols; + + for (unsigned i = 0 + ; i < Elements(builtin_110_deprecated_uniforms) + ; i++) { + add_builtin_variable(instructions, symtab, + & builtin_110_deprecated_uniforms[i]); + } + + add_builtin_constant(instructions, symtab, "gl_MaxLights", + state->Const.MaxLights); + add_builtin_constant(instructions, symtab, "gl_MaxClipPlanes", + state->Const.MaxClipPlanes); + add_builtin_constant(instructions, symtab, "gl_MaxTextureUnits", + state->Const.MaxTextureUnits); + add_builtin_constant(instructions, symtab, "gl_MaxTextureCoords", + state->Const.MaxTextureCoords); + add_builtin_constant(instructions, symtab, "gl_MaxVertexAttribs", + state->Const.MaxVertexAttribs); + add_builtin_constant(instructions, symtab, "gl_MaxVertexUniformComponents", + state->Const.MaxVertexUniformComponents); + add_builtin_constant(instructions, symtab, "gl_MaxVaryingFloats", + state->Const.MaxVaryingFloats); + add_builtin_constant(instructions, symtab, "gl_MaxVertexTextureImageUnits", + state->Const.MaxVertexTextureImageUnits); + add_builtin_constant(instructions, symtab, "gl_MaxCombinedTextureImageUnits", + state->Const.MaxCombinedTextureImageUnits); + add_builtin_constant(instructions, symtab, "gl_MaxTextureImageUnits", + state->Const.MaxTextureImageUnits); + add_builtin_constant(instructions, symtab, "gl_MaxFragmentUniformComponents", + state->Const.MaxFragmentUniformComponents); + + const glsl_type *const mat4_array_type = + glsl_type::get_array_instance(glsl_type::mat4_type, + state->Const.MaxTextureCoords); + + add_uniform(instructions, symtab, "gl_TextureMatrix", mat4_array_type); + add_uniform(instructions, symtab, "gl_TextureMatrixInverse", mat4_array_type); + add_uniform(instructions, symtab, "gl_TextureMatrixTranspose", mat4_array_type); + add_uniform(instructions, symtab, "gl_TextureMatrixInverseTranspose", mat4_array_type); + + add_uniform(instructions, symtab, "gl_DepthRange", + symtab->get_type("gl_DepthRangeParameters")); + + add_uniform(instructions, symtab, "gl_ClipPlane", + glsl_type::get_array_instance(glsl_type::vec4_type, + state->Const.MaxClipPlanes)); + add_uniform(instructions, symtab, "gl_Point", + symtab->get_type("gl_PointParameters")); + + const glsl_type *const material_parameters_type = + symtab->get_type("gl_MaterialParameters"); + add_uniform(instructions, symtab, "gl_FrontMaterial", material_parameters_type); + add_uniform(instructions, symtab, "gl_BackMaterial", material_parameters_type); + + const glsl_type *const light_source_array_type = + glsl_type::get_array_instance(symtab->get_type("gl_LightSourceParameters"), state->Const.MaxLights); + + add_uniform(instructions, symtab, "gl_LightSource", light_source_array_type); + + const glsl_type *const light_model_products_type = + symtab->get_type("gl_LightModelProducts"); + add_uniform(instructions, symtab, "gl_FrontLightModelProduct", + light_model_products_type); + add_uniform(instructions, symtab, "gl_BackLightModelProduct", + light_model_products_type); + + const glsl_type *const light_products_type = + glsl_type::get_array_instance(symtab->get_type("gl_LightProducts"), + state->Const.MaxLights); + add_uniform(instructions, symtab, "gl_FrontLightProduct", light_products_type); + add_uniform(instructions, symtab, "gl_BackLightProduct", light_products_type); + + add_uniform(instructions, symtab, "gl_TextureEnvColor", + glsl_type::get_array_instance(glsl_type::vec4_type, + state->Const.MaxTextureUnits)); + + const glsl_type *const texcoords_vec4 = + glsl_type::get_array_instance(glsl_type::vec4_type, + state->Const.MaxTextureCoords); + add_uniform(instructions, symtab, "gl_EyePlaneS", texcoords_vec4); + add_uniform(instructions, symtab, "gl_EyePlaneT", texcoords_vec4); + add_uniform(instructions, symtab, "gl_EyePlaneR", texcoords_vec4); + add_uniform(instructions, symtab, "gl_EyePlaneQ", texcoords_vec4); + add_uniform(instructions, symtab, "gl_ObjectPlaneS", texcoords_vec4); + add_uniform(instructions, symtab, "gl_ObjectPlaneT", texcoords_vec4); + add_uniform(instructions, symtab, "gl_ObjectPlaneR", texcoords_vec4); + add_uniform(instructions, symtab, "gl_ObjectPlaneQ", texcoords_vec4); + + add_uniform(instructions, symtab, "gl_Fog", + symtab->get_type("gl_FogParameters")); +} + +/* This function should only be called for ES, not desktop GL. */ +static void +generate_100ES_vs_variables(exec_list *instructions, + struct _mesa_glsl_parse_state *state) +{ + for (unsigned i = 0; i < Elements(builtin_core_vs_variables); i++) { + add_builtin_variable(instructions, state->symbols, + & builtin_core_vs_variables[i]); + } + + generate_100ES_uniforms(instructions, state); + + generate_ARB_draw_buffers_variables(instructions, state, false, + vertex_shader); +} + + +static void +generate_110_vs_variables(exec_list *instructions, + struct _mesa_glsl_parse_state *state) +{ + for (unsigned i = 0; i < Elements(builtin_core_vs_variables); i++) { + add_builtin_variable(instructions, state->symbols, + & builtin_core_vs_variables[i]); + } + + for (unsigned i = 0 + ; i < Elements(builtin_110_deprecated_vs_variables) + ; i++) { + add_builtin_variable(instructions, state->symbols, + & builtin_110_deprecated_vs_variables[i]); + } + generate_110_uniforms(instructions, state); + + /* From page 54 (page 60 of the PDF) of the GLSL 1.20 spec: + * + * "As with all arrays, indices used to subscript gl_TexCoord must + * either be an integral constant expressions, or this array must be + * re-declared by the shader with a size. The size can be at most + * gl_MaxTextureCoords. Using indexes close to 0 may aid the + * implementation in preserving varying resources." + */ + const glsl_type *const vec4_array_type = + glsl_type::get_array_instance(glsl_type::vec4_type, 0); + + add_variable(instructions, state->symbols, + "gl_TexCoord", vec4_array_type, ir_var_out, VERT_RESULT_TEX0); + + generate_ARB_draw_buffers_variables(instructions, state, false, + vertex_shader); +} + + +static void +generate_120_vs_variables(exec_list *instructions, + struct _mesa_glsl_parse_state *state) +{ + /* GLSL version 1.20 did not add any built-in variables in the vertex + * shader. + */ + generate_110_vs_variables(instructions, state); +} + + +static void +generate_130_vs_variables(exec_list *instructions, + struct _mesa_glsl_parse_state *state) +{ + generate_120_vs_variables(instructions, state); + + for (unsigned i = 0; i < Elements(builtin_130_vs_variables); i++) { + add_builtin_variable(instructions, state->symbols, + & builtin_130_vs_variables[i]); + } + + const glsl_type *const clip_distance_array_type = + glsl_type::get_array_instance(glsl_type::float_type, + state->Const.MaxClipPlanes); + + /* FINISHME: gl_ClipDistance needs a real location assigned. */ + add_variable(instructions, state->symbols, + "gl_ClipDistance", clip_distance_array_type, ir_var_out, -1); + +} + + +static void +initialize_vs_variables(exec_list *instructions, + struct _mesa_glsl_parse_state *state) +{ + + switch (state->language_version) { + case 100: + generate_100ES_vs_variables(instructions, state); + break; + case 110: + generate_110_vs_variables(instructions, state); + break; + case 120: + generate_120_vs_variables(instructions, state); + break; + case 130: + generate_130_vs_variables(instructions, state); + break; + } + + if (state->ARB_draw_instanced_enable) + generate_ARB_draw_instanced_variables(instructions, state, false, + vertex_shader); +} + + +/* This function should only be called for ES, not desktop GL. */ +static void +generate_100ES_fs_variables(exec_list *instructions, + struct _mesa_glsl_parse_state *state) +{ + for (unsigned i = 0; i < Elements(builtin_core_fs_variables); i++) { + add_builtin_variable(instructions, state->symbols, + & builtin_core_fs_variables[i]); + } + + for (unsigned i = 0; i < Elements(builtin_100ES_fs_variables); i++) { + add_builtin_variable(instructions, state->symbols, + & builtin_100ES_fs_variables[i]); + } + + generate_100ES_uniforms(instructions, state); + + generate_ARB_draw_buffers_variables(instructions, state, false, + fragment_shader); +} + +static void +generate_110_fs_variables(exec_list *instructions, + struct _mesa_glsl_parse_state *state) +{ + for (unsigned i = 0; i < Elements(builtin_core_fs_variables); i++) { + add_builtin_variable(instructions, state->symbols, + & builtin_core_fs_variables[i]); + } + + for (unsigned i = 0; i < Elements(builtin_110_fs_variables); i++) { + add_builtin_variable(instructions, state->symbols, + & builtin_110_fs_variables[i]); + } + + for (unsigned i = 0 + ; i < Elements(builtin_110_deprecated_fs_variables) + ; i++) { + add_builtin_variable(instructions, state->symbols, + & builtin_110_deprecated_fs_variables[i]); + } + generate_110_uniforms(instructions, state); + + /* From page 54 (page 60 of the PDF) of the GLSL 1.20 spec: + * + * "As with all arrays, indices used to subscript gl_TexCoord must + * either be an integral constant expressions, or this array must be + * re-declared by the shader with a size. The size can be at most + * gl_MaxTextureCoords. Using indexes close to 0 may aid the + * implementation in preserving varying resources." + */ + const glsl_type *const vec4_array_type = + glsl_type::get_array_instance(glsl_type::vec4_type, 0); + + add_variable(instructions, state->symbols, + "gl_TexCoord", vec4_array_type, ir_var_in, FRAG_ATTRIB_TEX0); + + generate_ARB_draw_buffers_variables(instructions, state, false, + fragment_shader); +} + + +static void +generate_ARB_draw_buffers_variables(exec_list *instructions, + struct _mesa_glsl_parse_state *state, + bool warn, _mesa_glsl_parser_targets target) +{ + /* gl_MaxDrawBuffers is available in all shader stages. + */ + ir_variable *const mdb = + add_variable(instructions, state->symbols, + "gl_MaxDrawBuffers", glsl_type::int_type, ir_var_auto, -1); + + if (warn) + mdb->warn_extension = "GL_ARB_draw_buffers"; + + mdb->constant_value = new(mdb) + ir_constant(int(state->Const.MaxDrawBuffers)); + + + /* gl_FragData is only available in the fragment shader. + */ + if (target == fragment_shader) { + const glsl_type *const vec4_array_type = + glsl_type::get_array_instance(glsl_type::vec4_type, + state->Const.MaxDrawBuffers); + + ir_variable *const fd = + add_variable(instructions, state->symbols, + "gl_FragData", vec4_array_type, + ir_var_out, FRAG_RESULT_DATA0); + + if (warn) + fd->warn_extension = "GL_ARB_draw_buffers"; + } +} + + +static void +generate_ARB_draw_instanced_variables(exec_list *instructions, + struct _mesa_glsl_parse_state *state, + bool warn, + _mesa_glsl_parser_targets target) +{ + /* gl_InstanceIDARB is only available in the vertex shader. + */ + if (target == vertex_shader) { + ir_variable *const inst = + add_variable(instructions, state->symbols, + "gl_InstanceIDARB", glsl_type::int_type, + ir_var_system_value, SYSTEM_VALUE_INSTANCE_ID); + + if (warn) + inst->warn_extension = "GL_ARB_draw_instanced"; + } +} + + +static void +generate_ARB_shader_stencil_export_variables(exec_list *instructions, + struct _mesa_glsl_parse_state *state, + bool warn) +{ + /* gl_FragStencilRefARB is only available in the fragment shader. + */ + ir_variable *const fd = + add_variable(instructions, state->symbols, + "gl_FragStencilRefARB", glsl_type::int_type, + ir_var_out, FRAG_RESULT_STENCIL); + + if (warn) + fd->warn_extension = "GL_ARB_shader_stencil_export"; +} + +static void +generate_AMD_shader_stencil_export_variables(exec_list *instructions, + struct _mesa_glsl_parse_state *state, + bool warn) +{ + /* gl_FragStencilRefAMD is only available in the fragment shader. + */ + ir_variable *const fd = + add_variable(instructions, state->symbols, + "gl_FragStencilRefAMD", glsl_type::int_type, + ir_var_out, FRAG_RESULT_STENCIL); + + if (warn) + fd->warn_extension = "GL_AMD_shader_stencil_export"; +} + +static void +generate_120_fs_variables(exec_list *instructions, + struct _mesa_glsl_parse_state *state) +{ + generate_110_fs_variables(instructions, state); + + for (unsigned i = 0 + ; i < Elements(builtin_120_fs_variables) + ; i++) { + add_builtin_variable(instructions, state->symbols, + & builtin_120_fs_variables[i]); + } +} + +static void +generate_130_fs_variables(exec_list *instructions, + struct _mesa_glsl_parse_state *state) +{ + generate_120_fs_variables(instructions, state); + + const glsl_type *const clip_distance_array_type = + glsl_type::get_array_instance(glsl_type::float_type, + state->Const.MaxClipPlanes); + + /* FINISHME: gl_ClipDistance needs a real location assigned. */ + add_variable(instructions, state->symbols, + "gl_ClipDistance", clip_distance_array_type, ir_var_in, -1); +} + +static void +initialize_fs_variables(exec_list *instructions, + struct _mesa_glsl_parse_state *state) +{ + + switch (state->language_version) { + case 100: + generate_100ES_fs_variables(instructions, state); + break; + case 110: + generate_110_fs_variables(instructions, state); + break; + case 120: + generate_120_fs_variables(instructions, state); + break; + case 130: + generate_130_fs_variables(instructions, state); + break; + } + + if (state->ARB_shader_stencil_export_enable) + generate_ARB_shader_stencil_export_variables(instructions, state, + state->ARB_shader_stencil_export_warn); + + if (state->AMD_shader_stencil_export_enable) + generate_AMD_shader_stencil_export_variables(instructions, state, + state->AMD_shader_stencil_export_warn); +} + +void +_mesa_glsl_initialize_variables(exec_list *instructions, + struct _mesa_glsl_parse_state *state) +{ + switch (state->target) { + case vertex_shader: + initialize_vs_variables(instructions, state); + break; + case geometry_shader: + break; + case fragment_shader: + initialize_fs_variables(instructions, state); + break; + } +} diff --git a/3rdparty/glsl-optimizer/src/glsl/ir_variable_refcount.cpp b/3rdparty/glsl-optimizer/src/glsl/ir_variable_refcount.cpp new file mode 100644 index 000000000..7d39abb36 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/ir_variable_refcount.cpp @@ -0,0 +1,113 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file ir_variable_refcount.cpp + * + * Provides a visitor which produces a list of variables referenced, + * how many times they were referenced and assigned, and whether they + * were defined in the scope. + */ + +#include "ir.h" +#include "ir_visitor.h" +#include "ir_variable_refcount.h" +#include "glsl_types.h" + + +// constructor +variable_entry::variable_entry(ir_variable *var) +{ + this->var = var; + assign = NULL; + assigned_count = 0; + declaration = false; + referenced_count = 0; +} + + +variable_entry * +ir_variable_refcount_visitor::get_variable_entry(ir_variable *var) +{ + assert(var); + foreach_iter(exec_list_iterator, iter, this->variable_list) { + variable_entry *entry = (variable_entry *)iter.get(); + if (entry->var == var) + return entry; + } + + variable_entry *entry = new(mem_ctx) variable_entry(var); + assert(entry->referenced_count == 0); + this->variable_list.push_tail(entry); + return entry; +} + + +ir_visitor_status +ir_variable_refcount_visitor::visit(ir_variable *ir) +{ + variable_entry *entry = this->get_variable_entry(ir); + if (entry) + entry->declaration = true; + + return visit_continue; +} + + +ir_visitor_status +ir_variable_refcount_visitor::visit(ir_dereference_variable *ir) +{ + ir_variable *const var = ir->variable_referenced(); + variable_entry *entry = this->get_variable_entry(var); + + if (entry) + entry->referenced_count++; + + return visit_continue; +} + + +ir_visitor_status +ir_variable_refcount_visitor::visit_enter(ir_function_signature *ir) +{ + /* We don't want to descend into the function parameters and + * dead-code eliminate them, so just accept the body here. + */ + visit_list_elements(this, &ir->body); + return visit_continue_with_parent; +} + + +ir_visitor_status +ir_variable_refcount_visitor::visit_leave(ir_assignment *ir) +{ + variable_entry *entry; + entry = this->get_variable_entry(ir->lhs->variable_referenced()); + if (entry) { + entry->assigned_count++; + if (entry->assign == NULL) + entry->assign = ir; + } + + return visit_continue; +} diff --git a/3rdparty/glsl-optimizer/src/glsl/ir_variable_refcount.h b/3rdparty/glsl-optimizer/src/glsl/ir_variable_refcount.h new file mode 100644 index 000000000..906135a9e --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/ir_variable_refcount.h @@ -0,0 +1,78 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file ir_variable_refcount.h + * + * Provides a visitor which produces a list of variables referenced, + * how many times they were referenced and assigned, and whether they + * were defined in the scope. + */ + +#include "ir.h" +#include "ir_visitor.h" +#include "glsl_types.h" + +class variable_entry : public exec_node +{ +public: + variable_entry(ir_variable *var); + + ir_variable *var; /* The key: the variable's pointer. */ + ir_assignment *assign; /* An assignment to the variable, if any */ + + /** Number of times the variable is referenced, including assignments. */ + unsigned referenced_count; + + /** Number of times the variable is assigned. */ + unsigned assigned_count; + + bool declaration; /* If the variable had a decl in the instruction stream */ +}; + +class ir_variable_refcount_visitor : public ir_hierarchical_visitor { +public: + ir_variable_refcount_visitor(void) + { + this->mem_ctx = ralloc_context(NULL); + this->variable_list.make_empty(); + } + + ~ir_variable_refcount_visitor(void) + { + ralloc_free(this->mem_ctx); + } + + virtual ir_visitor_status visit(ir_variable *); + virtual ir_visitor_status visit(ir_dereference_variable *); + + virtual ir_visitor_status visit_enter(ir_function_signature *); + virtual ir_visitor_status visit_leave(ir_assignment *); + + variable_entry *get_variable_entry(ir_variable *var); + + /* List of variable_entry */ + exec_list variable_list; + + void *mem_ctx; +}; diff --git a/3rdparty/glsl-optimizer/src/glsl/ir_visitor.h b/3rdparty/glsl-optimizer/src/glsl/ir_visitor.h new file mode 100644 index 000000000..7dd35fe1d --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/ir_visitor.h @@ -0,0 +1,84 @@ +/* -*- c++ -*- */ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#pragma once +#ifndef IR_VISITOR_H +#define IR_VISITOR_H + +/** + * Abstract base class of visitors of IR instruction trees + */ +class ir_visitor { +public: + virtual ~ir_visitor() + { + /* empty */ + } + + /** + * \name Visit methods + * + * As typical for the visitor pattern, there must be one \c visit method for + * each concrete subclass of \c ir_instruction. Virtual base classes within + * the hierarchy should not have \c visit methods. + */ + /*@{*/ + virtual void visit(class ir_variable *) = 0; + virtual void visit(class ir_function_signature *) = 0; + virtual void visit(class ir_function *) = 0; + virtual void visit(class ir_expression *) = 0; + virtual void visit(class ir_texture *) = 0; + virtual void visit(class ir_swizzle *) = 0; + virtual void visit(class ir_dereference_variable *) = 0; + virtual void visit(class ir_dereference_array *) = 0; + virtual void visit(class ir_dereference_record *) = 0; + virtual void visit(class ir_assignment *) = 0; + virtual void visit(class ir_constant *) = 0; + virtual void visit(class ir_call *) = 0; + virtual void visit(class ir_return *) = 0; + virtual void visit(class ir_discard *) = 0; + virtual void visit(class ir_if *) = 0; + virtual void visit(class ir_loop *) = 0; + virtual void visit(class ir_loop_jump *) = 0; + /*@}*/ +}; + +/* NOTE: function calls may never return due to discards inside them + * This is usually not an issue, but if it is, keep it in mind + */ +class ir_control_flow_visitor : public ir_visitor { +public: + virtual void visit(class ir_variable *) {} + virtual void visit(class ir_expression *) {} + virtual void visit(class ir_texture *) {} + virtual void visit(class ir_swizzle *) {} + virtual void visit(class ir_dereference_variable *) {} + virtual void visit(class ir_dereference_array *) {} + virtual void visit(class ir_dereference_record *) {} + virtual void visit(class ir_assignment *) {} + virtual void visit(class ir_constant *) {} + virtual void visit(class ir_call *) {} +}; + +#endif /* IR_VISITOR_H */ diff --git a/3rdparty/glsl-optimizer/src/glsl/link_functions.cpp b/3rdparty/glsl-optimizer/src/glsl/link_functions.cpp new file mode 100644 index 000000000..92c36dc95 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/link_functions.cpp @@ -0,0 +1,286 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include "main/core.h" +#include "glsl_symbol_table.h" +#include "glsl_parser_extras.h" +#include "ir.h" +#include "program.h" +#include "program/hash_table.h" +#include "linker.h" + +static ir_function_signature * +find_matching_signature(const char *name, const exec_list *actual_parameters, + gl_shader **shader_list, unsigned num_shaders, + bool use_builtin); + +class call_link_visitor : public ir_hierarchical_visitor { +public: + call_link_visitor(gl_shader_program *prog, gl_shader *linked, + gl_shader **shader_list, unsigned num_shaders) + { + this->prog = prog; + this->shader_list = shader_list; + this->num_shaders = num_shaders; + this->success = true; + this->linked = linked; + + this->locals = hash_table_ctor(0, hash_table_pointer_hash, + hash_table_pointer_compare); + } + + ~call_link_visitor() + { + hash_table_dtor(this->locals); + } + + virtual ir_visitor_status visit(ir_variable *ir) + { + hash_table_insert(locals, ir, ir); + return visit_continue; + } + + virtual ir_visitor_status visit_enter(ir_call *ir) + { + /* If ir is an ir_call from a function that was imported from another + * shader callee will point to an ir_function_signature in the original + * shader. In this case the function signature MUST NOT BE MODIFIED. + * Doing so will modify the original shader. This may prevent that + * shader from being linkable in other programs. + */ + const ir_function_signature *const callee = ir->get_callee(); + assert(callee != NULL); + const char *const name = callee->function_name(); + + /* Determine if the requested function signature already exists in the + * final linked shader. If it does, use it as the target of the call. + */ + ir_function_signature *sig = + find_matching_signature(name, &callee->parameters, &linked, 1, + ir->use_builtin); + if (sig != NULL) { + ir->set_callee(sig); + return visit_continue; + } + + /* Try to find the signature in one of the other shaders that is being + * linked. If it's not found there, return an error. + */ + sig = find_matching_signature(name, &ir->actual_parameters, shader_list, + num_shaders, ir->use_builtin); + if (sig == NULL) { + /* FINISHME: Log the full signature of unresolved function. + */ + linker_error(this->prog, "unresolved reference to function `%s'\n", + name); + this->success = false; + return visit_stop; + } + + /* Find the prototype information in the linked shader. Generate any + * details that may be missing. + */ + ir_function *f = linked->symbols->get_function(name); + if (f == NULL) { + f = new(linked) ir_function(name); + + /* Add the new function to the linked IR. Put it at the end + * so that it comes after any global variable declarations + * that it refers to. + */ + linked->symbols->add_function(f); + linked->ir->push_tail(f); + } + + ir_function_signature *linked_sig = + f->exact_matching_signature(&callee->parameters); + if ((linked_sig == NULL) + || ((linked_sig != NULL) + && (linked_sig->is_builtin != ir->use_builtin))) { + linked_sig = new(linked) ir_function_signature(callee->return_type, callee->precision); + f->add_signature(linked_sig); + } + + /* At this point linked_sig and called may be the same. If ir is an + * ir_call from linked then linked_sig and callee will be + * ir_function_signatures that have no definitions (is_defined is false). + */ + assert(!linked_sig->is_defined); + assert(linked_sig->body.is_empty()); + + /* Create an in-place clone of the function definition. This multistep + * process introduces some complexity here, but it has some advantages. + * The parameter list and the and function body are cloned separately. + * The clone of the parameter list is used to prime the hashtable used + * to replace variable references in the cloned body. + * + * The big advantage is that the ir_function_signature does not change. + * This means that we don't have to process the rest of the IR tree to + * patch ir_call nodes. In addition, there is no way to remove or + * replace signature stored in a function. One could easily be added, + * but this avoids the need. + */ + struct hash_table *ht = hash_table_ctor(0, hash_table_pointer_hash, + hash_table_pointer_compare); + exec_list formal_parameters; + foreach_list_const(node, &sig->parameters) { + const ir_instruction *const original = (ir_instruction *) node; + assert(const_cast(original)->as_variable()); + + ir_instruction *copy = original->clone(linked, ht); + formal_parameters.push_tail(copy); + } + + linked_sig->replace_parameters(&formal_parameters); + + foreach_list_const(node, &sig->body) { + const ir_instruction *const original = (ir_instruction *) node; + + ir_instruction *copy = original->clone(linked, ht); + linked_sig->body.push_tail(copy); + } + + linked_sig->is_defined = true; + hash_table_dtor(ht); + + /* Patch references inside the function to things outside the function + * (i.e., function calls and global variables). + */ + linked_sig->accept(this); + + ir->set_callee(linked_sig); + + return visit_continue; + } + + virtual ir_visitor_status visit(ir_dereference_variable *ir) + { + if (hash_table_find(locals, ir->var) == NULL) { + /* The non-function variable must be a global, so try to find the + * variable in the shader's symbol table. If the variable is not + * found, then it's a global that *MUST* be defined in the original + * shader. + */ + ir_variable *var = linked->symbols->get_variable(ir->var->name); + if (var == NULL) { + /* Clone the ir_variable that the dereference already has and add + * it to the linked shader. + */ + var = ir->var->clone(linked, NULL); + linked->symbols->add_variable(var); + linked->ir->push_head(var); + } else if (var->type->is_array()) { + /* It is possible to have a global array declared in multiple + * shaders without a size. The array is implicitly sized by the + * maximal access to it in *any* shader. Because of this, we + * need to track the maximal access to the array as linking pulls + * more functions in that access the array. + */ + var->max_array_access = + MAX2(var->max_array_access, ir->var->max_array_access); + + if (var->type->length == 0 && ir->var->type->length != 0) + var->type = ir->var->type; + } + + ir->var = var; + } + + return visit_continue; + } + + /** Was function linking successful? */ + bool success; + +private: + /** + * Shader program being linked + * + * This is only used for logging error messages. + */ + gl_shader_program *prog; + + /** List of shaders available for linking. */ + gl_shader **shader_list; + + /** Number of shaders available for linking. */ + unsigned num_shaders; + + /** + * Final linked shader + * + * This is used two ways. It is used to find global variables in the + * linked shader that are accessed by the function. It is also used to add + * global variables from the shader where the function originated. + */ + gl_shader *linked; + + /** + * Table of variables local to the function. + */ + hash_table *locals; +}; + + +/** + * Searches a list of shaders for a particular function definition + */ +ir_function_signature * +find_matching_signature(const char *name, const exec_list *actual_parameters, + gl_shader **shader_list, unsigned num_shaders, + bool use_builtin) +{ + for (unsigned i = 0; i < num_shaders; i++) { + ir_function *const f = shader_list[i]->symbols->get_function(name); + + if (f == NULL) + continue; + + ir_function_signature *sig = f->matching_signature(actual_parameters); + + if ((sig == NULL) || !sig->is_defined) + continue; + + /* If this function expects to bind to a built-in function and the + * signature that we found isn't a built-in, keep looking. Also keep + * looking if we expect a non-built-in but found a built-in. + */ + if (use_builtin != sig->is_builtin) + continue; + + return sig; + } + + return NULL; +} + + +bool +link_function_calls(gl_shader_program *prog, gl_shader *main, + gl_shader **shader_list, unsigned num_shaders) +{ + call_link_visitor v(prog, main, shader_list, num_shaders); + + v.run(main->ir); + return v.success; +} diff --git a/3rdparty/glsl-optimizer/src/glsl/linker.cpp b/3rdparty/glsl-optimizer/src/glsl/linker.cpp new file mode 100644 index 000000000..b54ef4108 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/linker.cpp @@ -0,0 +1,1812 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file linker.cpp + * GLSL linker implementation + * + * Given a set of shaders that are to be linked to generate a final program, + * there are three distinct stages. + * + * In the first stage shaders are partitioned into groups based on the shader + * type. All shaders of a particular type (e.g., vertex shaders) are linked + * together. + * + * - Undefined references in each shader are resolve to definitions in + * another shader. + * - Types and qualifiers of uniforms, outputs, and global variables defined + * in multiple shaders with the same name are verified to be the same. + * - Initializers for uniforms and global variables defined + * in multiple shaders with the same name are verified to be the same. + * + * The result, in the terminology of the GLSL spec, is a set of shader + * executables for each processing unit. + * + * After the first stage is complete, a series of semantic checks are performed + * on each of the shader executables. + * + * - Each shader executable must define a \c main function. + * - Each vertex shader executable must write to \c gl_Position. + * - Each fragment shader executable must write to either \c gl_FragData or + * \c gl_FragColor. + * + * In the final stage individual shader executables are linked to create a + * complete exectuable. + * + * - Types of uniforms defined in multiple shader stages with the same name + * are verified to be the same. + * - Initializers for uniforms defined in multiple shader stages with the + * same name are verified to be the same. + * - Types and qualifiers of outputs defined in one stage are verified to + * be the same as the types and qualifiers of inputs defined with the same + * name in a later stage. + * + * \author Ian Romanick + */ + +#include "main/core.h" +#include "glsl_symbol_table.h" +#include "ir.h" +#include "program.h" +#include "program/hash_table.h" +#include "linker.h" +#include "ir_optimization.h" + +extern "C" { +#include "main/shaderobj.h" +} + +/** + * Visitor that determines whether or not a variable is ever written. + */ +class find_assignment_visitor : public ir_hierarchical_visitor { +public: + find_assignment_visitor(const char *name) + : name(name), found(false) + { + /* empty */ + } + + virtual ir_visitor_status visit_enter(ir_assignment *ir) + { + ir_variable *const var = ir->lhs->variable_referenced(); + + if (strcmp(name, var->name) == 0) { + found = true; + return visit_stop; + } + + return visit_continue_with_parent; + } + + virtual ir_visitor_status visit_enter(ir_call *ir) + { + exec_list_iterator sig_iter = ir->get_callee()->parameters.iterator(); + foreach_iter(exec_list_iterator, iter, *ir) { + ir_rvalue *param_rval = (ir_rvalue *)iter.get(); + ir_variable *sig_param = (ir_variable *)sig_iter.get(); + + if (sig_param->mode == ir_var_out || + sig_param->mode == ir_var_inout) { + ir_variable *var = param_rval->variable_referenced(); + if (var && strcmp(name, var->name) == 0) { + found = true; + return visit_stop; + } + } + sig_iter.next(); + } + + return visit_continue_with_parent; + } + + bool variable_found() + { + return found; + } + +private: + const char *name; /**< Find writes to a variable with this name. */ + bool found; /**< Was a write to the variable found? */ +}; + + +/** + * Visitor that determines whether or not a variable is ever read. + */ +class find_deref_visitor : public ir_hierarchical_visitor { +public: + find_deref_visitor(const char *name) + : name(name), found(false) + { + /* empty */ + } + + virtual ir_visitor_status visit(ir_dereference_variable *ir) + { + if (strcmp(this->name, ir->var->name) == 0) { + this->found = true; + return visit_stop; + } + + return visit_continue; + } + + bool variable_found() const + { + return this->found; + } + +private: + const char *name; /**< Find writes to a variable with this name. */ + bool found; /**< Was a write to the variable found? */ +}; + + +void +linker_error(gl_shader_program *prog, const char *fmt, ...) +{ + va_list ap; + + ralloc_strcat(&prog->InfoLog, "error: "); + va_start(ap, fmt); + ralloc_vasprintf_append(&prog->InfoLog, fmt, ap); + va_end(ap); + + prog->LinkStatus = false; +} + + +void +linker_warning(gl_shader_program *prog, const char *fmt, ...) +{ + va_list ap; + + ralloc_strcat(&prog->InfoLog, "error: "); + va_start(ap, fmt); + ralloc_vasprintf_append(&prog->InfoLog, fmt, ap); + va_end(ap); + +} + + +void +invalidate_variable_locations(gl_shader *sh, enum ir_variable_mode mode, + int generic_base) +{ + foreach_list(node, sh->ir) { + ir_variable *const var = ((ir_instruction *) node)->as_variable(); + + if ((var == NULL) || (var->mode != (unsigned) mode)) + continue; + + /* Only assign locations for generic attributes / varyings / etc. + */ + if ((var->location >= generic_base) && !var->explicit_location) + var->location = -1; + } +} + + +/** + * Determine the number of attribute slots required for a particular type + * + * This code is here because it implements the language rules of a specific + * GLSL version. Since it's a property of the language and not a property of + * types in general, it doesn't really belong in glsl_type. + */ +unsigned +count_attribute_slots(const glsl_type *t) +{ + /* From page 31 (page 37 of the PDF) of the GLSL 1.50 spec: + * + * "A scalar input counts the same amount against this limit as a vec4, + * so applications may want to consider packing groups of four + * unrelated float inputs together into a vector to better utilize the + * capabilities of the underlying hardware. A matrix input will use up + * multiple locations. The number of locations used will equal the + * number of columns in the matrix." + * + * The spec does not explicitly say how arrays are counted. However, it + * should be safe to assume the total number of slots consumed by an array + * is the number of entries in the array multiplied by the number of slots + * consumed by a single element of the array. + */ + + if (t->is_array()) + return t->array_size() * count_attribute_slots(t->element_type()); + + if (t->is_matrix()) + return t->matrix_columns; + + return 1; +} + + +/** + * Verify that a vertex shader executable meets all semantic requirements + * + * \param shader Vertex shader executable to be verified + */ +bool +validate_vertex_shader_executable(struct gl_shader_program *prog, + struct gl_shader *shader) +{ + if (shader == NULL) + return true; + + find_assignment_visitor find("gl_Position"); + find.run(shader->ir); + if (!find.variable_found()) { + linker_error(prog, "vertex shader does not write to `gl_Position'\n"); + return false; + } + + return true; +} + + +/** + * Verify that a fragment shader executable meets all semantic requirements + * + * \param shader Fragment shader executable to be verified + */ +bool +validate_fragment_shader_executable(struct gl_shader_program *prog, + struct gl_shader *shader) +{ + if (shader == NULL) + return true; + + find_assignment_visitor frag_color("gl_FragColor"); + find_assignment_visitor frag_data("gl_FragData"); + + frag_color.run(shader->ir); + frag_data.run(shader->ir); + + if (frag_color.variable_found() && frag_data.variable_found()) { + linker_error(prog, "fragment shader writes to both " + "`gl_FragColor' and `gl_FragData'\n"); + return false; + } + + return true; +} + + +/** + * Generate a string describing the mode of a variable + */ +static const char * +mode_string(const ir_variable *var) +{ + switch (var->mode) { + case ir_var_auto: + return (var->read_only) ? "global constant" : "global variable"; + + case ir_var_uniform: return "uniform"; + case ir_var_in: return "shader input"; + case ir_var_out: return "shader output"; + case ir_var_inout: return "shader inout"; + + case ir_var_const_in: + case ir_var_temporary: + default: + assert(!"Should not get here."); + return "invalid variable"; + } +} + + +/** + * Perform validation of global variables used across multiple shaders + */ +bool +cross_validate_globals(struct gl_shader_program *prog, + struct gl_shader **shader_list, + unsigned num_shaders, + bool uniforms_only) +{ + /* Examine all of the uniforms in all of the shaders and cross validate + * them. + */ + glsl_symbol_table variables; + for (unsigned i = 0; i < num_shaders; i++) { + if (shader_list[i] == NULL) + continue; + + foreach_list(node, shader_list[i]->ir) { + ir_variable *const var = ((ir_instruction *) node)->as_variable(); + + if (var == NULL) + continue; + + if (uniforms_only && (var->mode != ir_var_uniform)) + continue; + + /* Don't cross validate temporaries that are at global scope. These + * will eventually get pulled into the shaders 'main'. + */ + if (var->mode == ir_var_temporary) + continue; + + /* If a global with this name has already been seen, verify that the + * new instance has the same type. In addition, if the globals have + * initializers, the values of the initializers must be the same. + */ + ir_variable *const existing = variables.get_variable(var->name); + if (existing != NULL) { + if (var->type != existing->type) { + /* Consider the types to be "the same" if both types are arrays + * of the same type and one of the arrays is implicitly sized. + * In addition, set the type of the linked variable to the + * explicitly sized array. + */ + if (var->type->is_array() + && existing->type->is_array() + && (var->type->fields.array == existing->type->fields.array) + && ((var->type->length == 0) + || (existing->type->length == 0))) { + if (var->type->length != 0) { + existing->type = var->type; + } + } else { + linker_error(prog, "%s `%s' declared as type " + "`%s' and type `%s'\n", + mode_string(var), + var->name, var->type->name, + existing->type->name); + return false; + } + } + + if (var->explicit_location) { + if (existing->explicit_location + && (var->location != existing->location)) { + linker_error(prog, "explicit locations for %s " + "`%s' have differing values\n", + mode_string(var), var->name); + return false; + } + + existing->location = var->location; + existing->explicit_location = true; + } + + /* Validate layout qualifiers for gl_FragDepth. + * + * From the AMD_conservative_depth spec: + * "If gl_FragDepth is redeclared in any fragment shader in + * a program, it must be redeclared in all fragment shaders in that + * program that have static assignments to gl_FragDepth. All + * redeclarations of gl_FragDepth in all fragment shaders in + * a single program must have the same set of qualifiers." + */ + if (strcmp(var->name, "gl_FragDepth") == 0) { + bool layout_declared = var->depth_layout != ir_depth_layout_none; + bool layout_differs = var->depth_layout != existing->depth_layout; + if (layout_declared && layout_differs) { + linker_error(prog, + "All redeclarations of gl_FragDepth in all fragment shaders " + "in a single program must have the same set of qualifiers."); + } + if (var->used && layout_differs) { + linker_error(prog, + "If gl_FragDepth is redeclared with a layout qualifier in" + "any fragment shader, it must be redeclared with the same" + "layout qualifier in all fragment shaders that have" + "assignments to gl_FragDepth"); + } + } + + /* FINISHME: Handle non-constant initializers. + */ + if (var->constant_value != NULL) { + if (existing->constant_value != NULL) { + if (!var->constant_value->has_value(existing->constant_value)) { + linker_error(prog, "initializers for %s " + "`%s' have differing values\n", + mode_string(var), var->name); + return false; + } + } else + /* If the first-seen instance of a particular uniform did not + * have an initializer but a later instance does, copy the + * initializer to the version stored in the symbol table. + */ + /* FINISHME: This is wrong. The constant_value field should + * FINISHME: not be modified! Imagine a case where a shader + * FINISHME: without an initializer is linked in two different + * FINISHME: programs with shaders that have differing + * FINISHME: initializers. Linking with the first will + * FINISHME: modify the shader, and linking with the second + * FINISHME: will fail. + */ + existing->constant_value = + var->constant_value->clone(ralloc_parent(existing), NULL); + } + + if (existing->invariant != var->invariant) { + linker_error(prog, "declarations for %s `%s' have " + "mismatching invariant qualifiers\n", + mode_string(var), var->name); + return false; + } + if (existing->centroid != var->centroid) { + linker_error(prog, "declarations for %s `%s' have " + "mismatching centroid qualifiers\n", + mode_string(var), var->name); + return false; + } + } else + variables.add_variable(var); + } + } + + return true; +} + + +/** + * Perform validation of uniforms used across multiple shader stages + */ +bool +cross_validate_uniforms(struct gl_shader_program *prog) +{ + return cross_validate_globals(prog, prog->_LinkedShaders, + MESA_SHADER_TYPES, true); +} + + +/** + * Validate that outputs from one stage match inputs of another + */ +bool +cross_validate_outputs_to_inputs(struct gl_shader_program *prog, + gl_shader *producer, gl_shader *consumer) +{ + glsl_symbol_table parameters; + /* FINISHME: Figure these out dynamically. */ + const char *const producer_stage = "vertex"; + const char *const consumer_stage = "fragment"; + + /* Find all shader outputs in the "producer" stage. + */ + foreach_list(node, producer->ir) { + ir_variable *const var = ((ir_instruction *) node)->as_variable(); + + /* FINISHME: For geometry shaders, this should also look for inout + * FINISHME: variables. + */ + if ((var == NULL) || (var->mode != ir_var_out)) + continue; + + parameters.add_variable(var); + } + + + /* Find all shader inputs in the "consumer" stage. Any variables that have + * matching outputs already in the symbol table must have the same type and + * qualifiers. + */ + foreach_list(node, consumer->ir) { + ir_variable *const input = ((ir_instruction *) node)->as_variable(); + + /* FINISHME: For geometry shaders, this should also look for inout + * FINISHME: variables. + */ + if ((input == NULL) || (input->mode != ir_var_in)) + continue; + + ir_variable *const output = parameters.get_variable(input->name); + if (output != NULL) { + /* Check that the types match between stages. + */ + if (input->type != output->type) { + /* There is a bit of a special case for gl_TexCoord. This + * built-in is unsized by default. Applications that variable + * access it must redeclare it with a size. There is some + * language in the GLSL spec that implies the fragment shader + * and vertex shader do not have to agree on this size. Other + * driver behave this way, and one or two applications seem to + * rely on it. + * + * Neither declaration needs to be modified here because the array + * sizes are fixed later when update_array_sizes is called. + * + * From page 48 (page 54 of the PDF) of the GLSL 1.10 spec: + * + * "Unlike user-defined varying variables, the built-in + * varying variables don't have a strict one-to-one + * correspondence between the vertex language and the + * fragment language." + */ + if (!output->type->is_array() + || (strncmp("gl_", output->name, 3) != 0)) { + linker_error(prog, + "%s shader output `%s' declared as type `%s', " + "but %s shader input declared as type `%s'\n", + producer_stage, output->name, + output->type->name, + consumer_stage, input->type->name); + return false; + } + } + + /* Check that all of the qualifiers match between stages. + */ + if (input->centroid != output->centroid) { + linker_error(prog, + "%s shader output `%s' %s centroid qualifier, " + "but %s shader input %s centroid qualifier\n", + producer_stage, + output->name, + (output->centroid) ? "has" : "lacks", + consumer_stage, + (input->centroid) ? "has" : "lacks"); + return false; + } + + if (input->invariant != output->invariant) { + linker_error(prog, + "%s shader output `%s' %s invariant qualifier, " + "but %s shader input %s invariant qualifier\n", + producer_stage, + output->name, + (output->invariant) ? "has" : "lacks", + consumer_stage, + (input->invariant) ? "has" : "lacks"); + return false; + } + + if (input->interpolation != output->interpolation) { + linker_error(prog, + "%s shader output `%s' specifies %s " + "interpolation qualifier, " + "but %s shader input specifies %s " + "interpolation qualifier\n", + producer_stage, + output->name, + output->interpolation_string(), + consumer_stage, + input->interpolation_string()); + return false; + } + } + } + + return true; +} + + +/** + * Populates a shaders symbol table with all global declarations + */ +static void +populate_symbol_table(gl_shader *sh) +{ + sh->symbols = new(sh) glsl_symbol_table; + + foreach_list(node, sh->ir) { + ir_instruction *const inst = (ir_instruction *) node; + ir_variable *var; + ir_function *func; + + if ((func = inst->as_function()) != NULL) { + sh->symbols->add_function(func); + } else if ((var = inst->as_variable()) != NULL) { + sh->symbols->add_variable(var); + } + } +} + + +/** + * Remap variables referenced in an instruction tree + * + * This is used when instruction trees are cloned from one shader and placed in + * another. These trees will contain references to \c ir_variable nodes that + * do not exist in the target shader. This function finds these \c ir_variable + * references and replaces the references with matching variables in the target + * shader. + * + * If there is no matching variable in the target shader, a clone of the + * \c ir_variable is made and added to the target shader. The new variable is + * added to \b both the instruction stream and the symbol table. + * + * \param inst IR tree that is to be processed. + * \param symbols Symbol table containing global scope symbols in the + * linked shader. + * \param instructions Instruction stream where new variable declarations + * should be added. + */ +void +remap_variables(ir_instruction *inst, struct gl_shader *target, + hash_table *temps) +{ + class remap_visitor : public ir_hierarchical_visitor { + public: + remap_visitor(struct gl_shader *target, + hash_table *temps) + { + this->target = target; + this->symbols = target->symbols; + this->instructions = target->ir; + this->temps = temps; + } + + virtual ir_visitor_status visit(ir_dereference_variable *ir) + { + if (ir->var->mode == ir_var_temporary) { + ir_variable *var = (ir_variable *) hash_table_find(temps, ir->var); + + assert(var != NULL); + ir->var = var; + return visit_continue; + } + + ir_variable *const existing = + this->symbols->get_variable(ir->var->name); + if (existing != NULL) + ir->var = existing; + else { + ir_variable *copy = ir->var->clone(this->target, NULL); + + this->symbols->add_variable(copy); + this->instructions->push_head(copy); + ir->var = copy; + } + + return visit_continue; + } + + private: + struct gl_shader *target; + glsl_symbol_table *symbols; + exec_list *instructions; + hash_table *temps; + }; + + remap_visitor v(target, temps); + + inst->accept(&v); +} + + +/** + * Move non-declarations from one instruction stream to another + * + * The intended usage pattern of this function is to pass the pointer to the + * head sentinel of a list (i.e., a pointer to the list cast to an \c exec_node + * pointer) for \c last and \c false for \c make_copies on the first + * call. Successive calls pass the return value of the previous call for + * \c last and \c true for \c make_copies. + * + * \param instructions Source instruction stream + * \param last Instruction after which new instructions should be + * inserted in the target instruction stream + * \param make_copies Flag selecting whether instructions in \c instructions + * should be copied (via \c ir_instruction::clone) into the + * target list or moved. + * + * \return + * The new "last" instruction in the target instruction stream. This pointer + * is suitable for use as the \c last parameter of a later call to this + * function. + */ +exec_node * +move_non_declarations(exec_list *instructions, exec_node *last, + bool make_copies, gl_shader *target) +{ + hash_table *temps = NULL; + + if (make_copies) + temps = hash_table_ctor(0, hash_table_pointer_hash, + hash_table_pointer_compare); + + foreach_list_safe(node, instructions) { + ir_instruction *inst = (ir_instruction *) node; + + if (inst->as_function()) + continue; + + ir_variable *var = inst->as_variable(); + if ((var != NULL) && (var->mode != ir_var_temporary)) + continue; + + assert(inst->as_assignment() + || ((var != NULL) && (var->mode == ir_var_temporary))); + + if (make_copies) { + inst = inst->clone(target, NULL); + + if (var != NULL) + hash_table_insert(temps, inst, var); + else + remap_variables(inst, target, temps); + } else { + inst->remove(); + } + + last->insert_after(inst); + last = inst; + } + + if (make_copies) + hash_table_dtor(temps); + + return last; +} + +/** + * Get the function signature for main from a shader + */ +static ir_function_signature * +get_main_function_signature(gl_shader *sh) +{ + ir_function *const f = sh->symbols->get_function("main"); + if (f != NULL) { + exec_list void_parameters; + + /* Look for the 'void main()' signature and ensure that it's defined. + * This keeps the linker from accidentally pick a shader that just + * contains a prototype for main. + * + * We don't have to check for multiple definitions of main (in multiple + * shaders) because that would have already been caught above. + */ + ir_function_signature *sig = f->matching_signature(&void_parameters); + if ((sig != NULL) && sig->is_defined) { + return sig; + } + } + + return NULL; +} + + +/** + * Combine a group of shaders for a single stage to generate a linked shader + * + * \note + * If this function is supplied a single shader, it is cloned, and the new + * shader is returned. + */ +static struct gl_shader * +link_intrastage_shaders(void *mem_ctx, + struct gl_context *ctx, + struct gl_shader_program *prog, + struct gl_shader **shader_list, + unsigned num_shaders) +{ + /* Check that global variables defined in multiple shaders are consistent. + */ + if (!cross_validate_globals(prog, shader_list, num_shaders, false)) + return NULL; + + /* Check that there is only a single definition of each function signature + * across all shaders. + */ + for (unsigned i = 0; i < (num_shaders - 1); i++) { + foreach_list(node, shader_list[i]->ir) { + ir_function *const f = ((ir_instruction *) node)->as_function(); + + if (f == NULL) + continue; + + for (unsigned j = i + 1; j < num_shaders; j++) { + ir_function *const other = + shader_list[j]->symbols->get_function(f->name); + + /* If the other shader has no function (and therefore no function + * signatures) with the same name, skip to the next shader. + */ + if (other == NULL) + continue; + + foreach_iter (exec_list_iterator, iter, *f) { + ir_function_signature *sig = + (ir_function_signature *) iter.get(); + + if (!sig->is_defined || sig->is_builtin) + continue; + + ir_function_signature *other_sig = + other->exact_matching_signature(& sig->parameters); + + if ((other_sig != NULL) && other_sig->is_defined + && !other_sig->is_builtin) { + linker_error(prog, "function `%s' is multiply defined", + f->name); + return NULL; + } + } + } + } + } + + /* Find the shader that defines main, and make a clone of it. + * + * Starting with the clone, search for undefined references. If one is + * found, find the shader that defines it. Clone the reference and add + * it to the shader. Repeat until there are no undefined references or + * until a reference cannot be resolved. + */ + gl_shader *main = NULL; + for (unsigned i = 0; i < num_shaders; i++) { + if (get_main_function_signature(shader_list[i]) != NULL) { + main = shader_list[i]; + break; + } + } + + if (main == NULL) { + linker_error(prog, "%s shader lacks `main'\n", + (shader_list[0]->Type == GL_VERTEX_SHADER) + ? "vertex" : "fragment"); + return NULL; + } + + gl_shader *linked = ctx->Driver.NewShader(NULL, 0, main->Type); + linked->ir = new(linked) exec_list; + clone_ir_list(mem_ctx, linked->ir, main->ir); + + populate_symbol_table(linked); + + /* The a pointer to the main function in the final linked shader (i.e., the + * copy of the original shader that contained the main function). + */ + ir_function_signature *const main_sig = get_main_function_signature(linked); + + /* Move any instructions other than variable declarations or function + * declarations into main. + */ + exec_node *insertion_point = + move_non_declarations(linked->ir, (exec_node *) &main_sig->body, false, + linked); + + for (unsigned i = 0; i < num_shaders; i++) { + if (shader_list[i] == main) + continue; + + insertion_point = move_non_declarations(shader_list[i]->ir, + insertion_point, true, linked); + } + + /* Resolve initializers for global variables in the linked shader. + */ + unsigned num_linking_shaders = num_shaders; + for (unsigned i = 0; i < num_shaders; i++) + num_linking_shaders += shader_list[i]->num_builtins_to_link; + + gl_shader **linking_shaders = + (gl_shader **) calloc(num_linking_shaders, sizeof(gl_shader *)); + + memcpy(linking_shaders, shader_list, + sizeof(linking_shaders[0]) * num_shaders); + + unsigned idx = num_shaders; + for (unsigned i = 0; i < num_shaders; i++) { + memcpy(&linking_shaders[idx], shader_list[i]->builtins_to_link, + sizeof(linking_shaders[0]) * shader_list[i]->num_builtins_to_link); + idx += shader_list[i]->num_builtins_to_link; + } + + assert(idx == num_linking_shaders); + + if (!link_function_calls(prog, linked, linking_shaders, + num_linking_shaders)) { + ctx->Driver.DeleteShader(ctx, linked); + linked = NULL; + } + + free(linking_shaders); + +#ifdef DEBUG + /* At this point linked should contain all of the linked IR, so + * validate it to make sure nothing went wrong. + */ + if (linked) + validate_ir_tree(linked->ir); +#endif + + /* Make a pass over all variable declarations to ensure that arrays with + * unspecified sizes have a size specified. The size is inferred from the + * max_array_access field. + */ + if (linked != NULL) { + class array_sizing_visitor : public ir_hierarchical_visitor { + public: + virtual ir_visitor_status visit(ir_variable *var) + { + if (var->type->is_array() && (var->type->length == 0)) { + const glsl_type *type = + glsl_type::get_array_instance(var->type->fields.array, + var->max_array_access + 1); + + assert(type != NULL); + var->type = type; + } + + return visit_continue; + } + } v; + + v.run(linked->ir); + } + + return linked; +} + + +struct uniform_node { + exec_node link; + struct gl_uniform *u; + unsigned slots; +}; + +/** + * Update the sizes of linked shader uniform arrays to the maximum + * array index used. + * + * From page 81 (page 95 of the PDF) of the OpenGL 2.1 spec: + * + * If one or more elements of an array are active, + * GetActiveUniform will return the name of the array in name, + * subject to the restrictions listed above. The type of the array + * is returned in type. The size parameter contains the highest + * array element index used, plus one. The compiler or linker + * determines the highest index used. There will be only one + * active uniform reported by the GL per uniform array. + + */ +static void +update_array_sizes(struct gl_shader_program *prog) +{ + for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) { + if (prog->_LinkedShaders[i] == NULL) + continue; + + foreach_list(node, prog->_LinkedShaders[i]->ir) { + ir_variable *const var = ((ir_instruction *) node)->as_variable(); + + if ((var == NULL) || (var->mode != ir_var_uniform && + var->mode != ir_var_in && + var->mode != ir_var_out) || + !var->type->is_array()) + continue; + + unsigned int size = var->max_array_access; + for (unsigned j = 0; j < MESA_SHADER_TYPES; j++) { + if (prog->_LinkedShaders[j] == NULL) + continue; + + foreach_list(node2, prog->_LinkedShaders[j]->ir) { + ir_variable *other_var = ((ir_instruction *) node2)->as_variable(); + if (!other_var) + continue; + + if (strcmp(var->name, other_var->name) == 0 && + other_var->max_array_access > size) { + size = other_var->max_array_access; + } + } + } + + if (size + 1 != var->type->fields.array->length) { + /* If this is a built-in uniform (i.e., it's backed by some + * fixed-function state), adjust the number of state slots to + * match the new array size. The number of slots per array entry + * is not known. It seems safe to assume that the total number of + * slots is an integer multiple of the number of array elements. + * Determine the number of slots per array element by dividing by + * the old (total) size. + */ + if (var->num_state_slots > 0) { + var->num_state_slots = (size + 1) + * (var->num_state_slots / var->type->length); + } + + var->type = glsl_type::get_array_instance(var->type->fields.array, + size + 1); + /* FINISHME: We should update the types of array + * dereferences of this variable now. + */ + } + } + } +} + +static void +add_uniform(void *mem_ctx, exec_list *uniforms, struct hash_table *ht, + const char *name, const glsl_type *type, GLenum shader_type, + unsigned *next_shader_pos, unsigned *total_uniforms) +{ + if (type->is_record()) { + for (unsigned int i = 0; i < type->length; i++) { + const glsl_type *field_type = type->fields.structure[i].type; + char *field_name = ralloc_asprintf(mem_ctx, "%s.%s", name, + type->fields.structure[i].name); + + add_uniform(mem_ctx, uniforms, ht, field_name, field_type, + shader_type, next_shader_pos, total_uniforms); + } + } else { + uniform_node *n = (uniform_node *) hash_table_find(ht, name); + unsigned int vec4_slots; + const glsl_type *array_elem_type = NULL; + + if (type->is_array()) { + array_elem_type = type->fields.array; + /* Array of structures. */ + if (array_elem_type->is_record()) { + for (unsigned int i = 0; i < type->length; i++) { + char *elem_name = ralloc_asprintf(mem_ctx, "%s[%d]", name, i); + add_uniform(mem_ctx, uniforms, ht, elem_name, array_elem_type, + shader_type, next_shader_pos, total_uniforms); + } + return; + } + } + + /* Fix the storage size of samplers at 1 vec4 each. Be sure to pad out + * vectors to vec4 slots. + */ + if (type->is_array()) { + if (array_elem_type->is_sampler()) + vec4_slots = type->length; + else + vec4_slots = type->length * array_elem_type->matrix_columns; + } else if (type->is_sampler()) { + vec4_slots = 1; + } else { + vec4_slots = type->matrix_columns; + } + + if (n == NULL) { + n = (uniform_node *) calloc(1, sizeof(struct uniform_node)); + n->u = (gl_uniform *) calloc(1, sizeof(struct gl_uniform)); + n->slots = vec4_slots; + + n->u->Name = strdup(name); + n->u->Type = type; + n->u->VertPos = -1; + n->u->FragPos = -1; + n->u->GeomPos = -1; + (*total_uniforms)++; + + hash_table_insert(ht, n, name); + uniforms->push_tail(& n->link); + } + + switch (shader_type) { + case GL_VERTEX_SHADER: + n->u->VertPos = *next_shader_pos; + break; + case GL_FRAGMENT_SHADER: + n->u->FragPos = *next_shader_pos; + break; + case GL_GEOMETRY_SHADER: + n->u->GeomPos = *next_shader_pos; + break; + } + + (*next_shader_pos) += vec4_slots; + } +} + +void +assign_uniform_locations(struct gl_shader_program *prog) +{ + /* */ + exec_list uniforms; + unsigned total_uniforms = 0; + hash_table *ht = hash_table_ctor(32, hash_table_string_hash, + hash_table_string_compare); + void *mem_ctx = ralloc_context(NULL); + + for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) { + if (prog->_LinkedShaders[i] == NULL) + continue; + + unsigned next_position = 0; + + foreach_list(node, prog->_LinkedShaders[i]->ir) { + ir_variable *const var = ((ir_instruction *) node)->as_variable(); + + if ((var == NULL) || (var->mode != ir_var_uniform)) + continue; + + if (strncmp(var->name, "gl_", 3) == 0) { + /* At the moment, we don't allocate uniform locations for + * builtin uniforms. It's permitted by spec, and we'll + * likely switch to doing that at some point, but not yet. + */ + continue; + } + + var->location = next_position; + add_uniform(mem_ctx, &uniforms, ht, var->name, var->type, + prog->_LinkedShaders[i]->Type, + &next_position, &total_uniforms); + } + } + + ralloc_free(mem_ctx); + + gl_uniform_list *ul = (gl_uniform_list *) + calloc(1, sizeof(gl_uniform_list)); + + ul->Size = total_uniforms; + ul->NumUniforms = total_uniforms; + ul->Uniforms = (gl_uniform *) calloc(total_uniforms, sizeof(gl_uniform)); + + unsigned idx = 0; + uniform_node *next; + for (uniform_node *node = (uniform_node *) uniforms.head + ; node->link.next != NULL + ; node = next) { + next = (uniform_node *) node->link.next; + + node->link.remove(); + memcpy(&ul->Uniforms[idx], node->u, sizeof(gl_uniform)); + idx++; + + free(node->u); + free(node); + } + + hash_table_dtor(ht); + + prog->Uniforms = ul; +} + + +/** + * Find a contiguous set of available bits in a bitmask. + * + * \param used_mask Bits representing used (1) and unused (0) locations + * \param needed_count Number of contiguous bits needed. + * + * \return + * Base location of the available bits on success or -1 on failure. + */ +int +find_available_slots(unsigned used_mask, unsigned needed_count) +{ + unsigned needed_mask = (1 << needed_count) - 1; + const int max_bit_to_test = (8 * sizeof(used_mask)) - needed_count; + + /* The comparison to 32 is redundant, but without it GCC emits "warning: + * cannot optimize possibly infinite loops" for the loop below. + */ + if ((needed_count == 0) || (max_bit_to_test < 0) || (max_bit_to_test > 32)) + return -1; + + for (int i = 0; i <= max_bit_to_test; i++) { + if ((needed_mask & ~used_mask) == needed_mask) + return i; + + needed_mask <<= 1; + } + + return -1; +} + + +/** + * Assign locations for either VS inputs for FS outputs + * + * \param prog Shader program whose variables need locations assigned + * \param target_index Selector for the program target to receive location + * assignmnets. Must be either \c MESA_SHADER_VERTEX or + * \c MESA_SHADER_FRAGMENT. + * \param max_index Maximum number of generic locations. This corresponds + * to either the maximum number of draw buffers or the + * maximum number of generic attributes. + * + * \return + * If locations are successfully assigned, true is returned. Otherwise an + * error is emitted to the shader link log and false is returned. + * + * \bug + * Locations set via \c glBindFragDataLocation are not currently supported. + * Only locations assigned automatically by the linker, explicitly set by a + * layout qualifier, or explicitly set by a built-in variable (e.g., \c + * gl_FragColor) are supported for fragment shaders. + */ +bool +assign_attribute_or_color_locations(gl_shader_program *prog, + unsigned target_index, + unsigned max_index) +{ + /* Mark invalid locations as being used. + */ + unsigned used_locations = (max_index >= 32) + ? ~0 : ~((1 << max_index) - 1); + + assert((target_index == MESA_SHADER_VERTEX) + || (target_index == MESA_SHADER_FRAGMENT)); + + gl_shader *const sh = prog->_LinkedShaders[target_index]; + if (sh == NULL) + return true; + + /* Operate in a total of four passes. + * + * 1. Invalidate the location assignments for all vertex shader inputs. + * + * 2. Assign locations for inputs that have user-defined (via + * glBindVertexAttribLocation) locations. + * + * 3. Sort the attributes without assigned locations by number of slots + * required in decreasing order. Fragmentation caused by attribute + * locations assigned by the application may prevent large attributes + * from having enough contiguous space. + * + * 4. Assign locations to any inputs without assigned locations. + */ + + const int generic_base = (target_index == MESA_SHADER_VERTEX) + ? (int) VERT_ATTRIB_GENERIC0 : (int) FRAG_RESULT_DATA0; + + const enum ir_variable_mode direction = + (target_index == MESA_SHADER_VERTEX) ? ir_var_in : ir_var_out; + + + invalidate_variable_locations(sh, direction, generic_base); + + if ((target_index == MESA_SHADER_VERTEX) && (prog->Attributes != NULL)) { + for (unsigned i = 0; i < prog->Attributes->NumParameters; i++) { + ir_variable *const var = + sh->symbols->get_variable(prog->Attributes->Parameters[i].Name); + + /* Note: attributes that occupy multiple slots, such as arrays or + * matrices, may appear in the attrib array multiple times. + */ + if ((var == NULL) || (var->location != -1)) + continue; + + /* From page 61 of the OpenGL 4.0 spec: + * + * "LinkProgram will fail if the attribute bindings assigned by + * BindAttribLocation do not leave not enough space to assign a + * location for an active matrix attribute or an active attribute + * array, both of which require multiple contiguous generic + * attributes." + * + * Previous versions of the spec contain similar language but omit the + * bit about attribute arrays. + * + * Page 61 of the OpenGL 4.0 spec also says: + * + * "It is possible for an application to bind more than one + * attribute name to the same location. This is referred to as + * aliasing. This will only work if only one of the aliased + * attributes is active in the executable program, or if no path + * through the shader consumes more than one attribute of a set + * of attributes aliased to the same location. A link error can + * occur if the linker determines that every path through the + * shader consumes multiple aliased attributes, but + * implementations are not required to generate an error in this + * case." + * + * These two paragraphs are either somewhat contradictory, or I don't + * fully understand one or both of them. + */ + /* FINISHME: The code as currently written does not support attribute + * FINISHME: location aliasing (see comment above). + */ + const int attr = prog->Attributes->Parameters[i].StateIndexes[0]; + const unsigned slots = count_attribute_slots(var->type); + + /* Mask representing the contiguous slots that will be used by this + * attribute. + */ + const unsigned use_mask = (1 << slots) - 1; + + /* Generate a link error if the set of bits requested for this + * attribute overlaps any previously allocated bits. + */ + if ((~(use_mask << attr) & used_locations) != used_locations) { + linker_error(prog, + "insufficient contiguous attribute locations " + "available for vertex shader input `%s'", + var->name); + return false; + } + + var->location = VERT_ATTRIB_GENERIC0 + attr; + used_locations |= (use_mask << attr); + } + } + + /* Temporary storage for the set of attributes that need locations assigned. + */ + struct temp_attr { + unsigned slots; + ir_variable *var; + + /* Used below in the call to qsort. */ + static int compare(const void *a, const void *b) + { + const temp_attr *const l = (const temp_attr *) a; + const temp_attr *const r = (const temp_attr *) b; + + /* Reversed because we want a descending order sort below. */ + return r->slots - l->slots; + } + } to_assign[16]; + + unsigned num_attr = 0; + + foreach_list(node, sh->ir) { + ir_variable *const var = ((ir_instruction *) node)->as_variable(); + + if ((var == NULL) || (var->mode != (unsigned) direction)) + continue; + + if (var->explicit_location) { + const unsigned slots = count_attribute_slots(var->type); + const unsigned use_mask = (1 << slots) - 1; + const int attr = var->location - generic_base; + + if ((var->location >= (int)(max_index + generic_base)) + || (var->location < 0)) { + linker_error(prog, + "invalid explicit location %d specified for `%s'\n", + (var->location < 0) ? var->location : attr, + var->name); + return false; + } else if (var->location >= generic_base) { + used_locations |= (use_mask << attr); + } + } + + /* The location was explicitly assigned, nothing to do here. + */ + if (var->location != -1) + continue; + + to_assign[num_attr].slots = count_attribute_slots(var->type); + to_assign[num_attr].var = var; + num_attr++; + } + + /* If all of the attributes were assigned locations by the application (or + * are built-in attributes with fixed locations), return early. This should + * be the common case. + */ + if (num_attr == 0) + return true; + + qsort(to_assign, num_attr, sizeof(to_assign[0]), temp_attr::compare); + + if (target_index == MESA_SHADER_VERTEX) { + /* VERT_ATTRIB_GENERIC0 is a pseudo-alias for VERT_ATTRIB_POS. It can + * only be explicitly assigned by via glBindAttribLocation. Mark it as + * reserved to prevent it from being automatically allocated below. + */ + find_deref_visitor find("gl_Vertex"); + find.run(sh->ir); + if (find.variable_found()) + used_locations |= (1 << 0); + } + + for (unsigned i = 0; i < num_attr; i++) { + /* Mask representing the contiguous slots that will be used by this + * attribute. + */ + const unsigned use_mask = (1 << to_assign[i].slots) - 1; + + int location = find_available_slots(used_locations, to_assign[i].slots); + + if (location < 0) { + const char *const string = (target_index == MESA_SHADER_VERTEX) + ? "vertex shader input" : "fragment shader output"; + + linker_error(prog, + "insufficient contiguous attribute locations " + "available for %s `%s'", + string, to_assign[i].var->name); + return false; + } + + to_assign[i].var->location = generic_base + location; + used_locations |= (use_mask << location); + } + + return true; +} + + +/** + * Demote shader inputs and outputs that are not used in other stages + */ +void +demote_shader_inputs_and_outputs(gl_shader *sh, enum ir_variable_mode mode) +{ + foreach_list(node, sh->ir) { + ir_variable *const var = ((ir_instruction *) node)->as_variable(); + + if ((var == NULL) || (var->mode != int(mode))) + continue; + + /* A shader 'in' or 'out' variable is only really an input or output if + * its value is used by other shader stages. This will cause the variable + * to have a location assigned. + */ + if (var->location == -1) { + var->mode = ir_var_auto; + } + } +} + + +bool +assign_varying_locations(struct gl_context *ctx, + struct gl_shader_program *prog, + gl_shader *producer, gl_shader *consumer) +{ + /* FINISHME: Set dynamically when geometry shader support is added. */ + unsigned output_index = VERT_RESULT_VAR0; + unsigned input_index = FRAG_ATTRIB_VAR0; + + /* Operate in a total of three passes. + * + * 1. Assign locations for any matching inputs and outputs. + * + * 2. Mark output variables in the producer that do not have locations as + * not being outputs. This lets the optimizer eliminate them. + * + * 3. Mark input variables in the consumer that do not have locations as + * not being inputs. This lets the optimizer eliminate them. + */ + + invalidate_variable_locations(producer, ir_var_out, VERT_RESULT_VAR0); + invalidate_variable_locations(consumer, ir_var_in, FRAG_ATTRIB_VAR0); + + foreach_list(node, producer->ir) { + ir_variable *const output_var = ((ir_instruction *) node)->as_variable(); + + if ((output_var == NULL) || (output_var->mode != ir_var_out) + || (output_var->location != -1)) + continue; + + ir_variable *const input_var = + consumer->symbols->get_variable(output_var->name); + + if ((input_var == NULL) || (input_var->mode != ir_var_in)) + continue; + + assert(input_var->location == -1); + + output_var->location = output_index; + input_var->location = input_index; + + /* FINISHME: Support for "varying" records in GLSL 1.50. */ + assert(!output_var->type->is_record()); + + if (output_var->type->is_array()) { + const unsigned slots = output_var->type->length + * output_var->type->fields.array->matrix_columns; + + output_index += slots; + input_index += slots; + } else { + const unsigned slots = output_var->type->matrix_columns; + + output_index += slots; + input_index += slots; + } + } + + unsigned varying_vectors = 0; + + foreach_list(node, consumer->ir) { + ir_variable *const var = ((ir_instruction *) node)->as_variable(); + + if ((var == NULL) || (var->mode != ir_var_in)) + continue; + + if (var->location == -1) { + if (prog->Version <= 120) { + /* On page 25 (page 31 of the PDF) of the GLSL 1.20 spec: + * + * Only those varying variables used (i.e. read) in + * the fragment shader executable must be written to + * by the vertex shader executable; declaring + * superfluous varying variables in a vertex shader is + * permissible. + * + * We interpret this text as meaning that the VS must + * write the variable for the FS to read it. See + * "glsl1-varying read but not written" in piglit. + */ + + linker_error(prog, "fragment shader varying %s not written " + "by vertex shader\n.", var->name); + } + + /* An 'in' variable is only really a shader input if its + * value is written by the previous stage. + */ + var->mode = ir_var_auto; + } else { + /* The packing rules are used for vertex shader inputs are also used + * for fragment shader inputs. + */ + varying_vectors += count_attribute_slots(var->type); + } + } + + if (ctx->API == API_OPENGLES2 || prog->Version == 100) { + if (varying_vectors > ctx->Const.MaxVarying) { + linker_error(prog, "shader uses too many varying vectors " + "(%u > %u)\n", + varying_vectors, ctx->Const.MaxVarying); + return false; + } + } else { + const unsigned float_components = varying_vectors * 4; + if (float_components > ctx->Const.MaxVarying * 4) { + linker_error(prog, "shader uses too many varying components " + "(%u > %u)\n", + float_components, ctx->Const.MaxVarying * 4); + return false; + } + } + + return true; +} + + +void +link_shaders(struct gl_context *ctx, struct gl_shader_program *prog) +{ + void *mem_ctx = ralloc_context(NULL); // temporary linker context + + prog->LinkStatus = false; + prog->Validated = false; + prog->_Used = false; + + if (prog->InfoLog != NULL) + ralloc_free(prog->InfoLog); + + prog->InfoLog = ralloc_strdup(NULL, ""); + + /* Separate the shaders into groups based on their type. + */ + struct gl_shader **vert_shader_list; + unsigned num_vert_shaders = 0; + struct gl_shader **frag_shader_list; + unsigned num_frag_shaders = 0; + + vert_shader_list = (struct gl_shader **) + calloc(2 * prog->NumShaders, sizeof(struct gl_shader *)); + frag_shader_list = &vert_shader_list[prog->NumShaders]; + + unsigned min_version = UINT_MAX; + unsigned max_version = 0; + for (unsigned i = 0; i < prog->NumShaders; i++) { + min_version = MIN2(min_version, prog->Shaders[i]->Version); + max_version = MAX2(max_version, prog->Shaders[i]->Version); + + switch (prog->Shaders[i]->Type) { + case GL_VERTEX_SHADER: + vert_shader_list[num_vert_shaders] = prog->Shaders[i]; + num_vert_shaders++; + break; + case GL_FRAGMENT_SHADER: + frag_shader_list[num_frag_shaders] = prog->Shaders[i]; + num_frag_shaders++; + break; + case GL_GEOMETRY_SHADER: + /* FINISHME: Support geometry shaders. */ + assert(prog->Shaders[i]->Type != GL_GEOMETRY_SHADER); + break; + } + } + + /* Previous to GLSL version 1.30, different compilation units could mix and + * match shading language versions. With GLSL 1.30 and later, the versions + * of all shaders must match. + */ + assert(min_version >= 100); + assert(max_version <= 130); + if ((max_version >= 130 || min_version == 100) + && min_version != max_version) { + linker_error(prog, "all shaders must use same shading " + "language version\n"); + goto done; + } + + prog->Version = max_version; + + for (unsigned int i = 0; i < MESA_SHADER_TYPES; i++) { + if (prog->_LinkedShaders[i] != NULL) + ctx->Driver.DeleteShader(ctx, prog->_LinkedShaders[i]); + + prog->_LinkedShaders[i] = NULL; + } + + /* Link all shaders for a particular stage and validate the result. + */ + if (num_vert_shaders > 0) { + gl_shader *const sh = + link_intrastage_shaders(mem_ctx, ctx, prog, vert_shader_list, + num_vert_shaders); + + if (sh == NULL) + goto done; + + if (!validate_vertex_shader_executable(prog, sh)) + goto done; + + _mesa_reference_shader(ctx, &prog->_LinkedShaders[MESA_SHADER_VERTEX], + sh); + } + + if (num_frag_shaders > 0) { + gl_shader *const sh = + link_intrastage_shaders(mem_ctx, ctx, prog, frag_shader_list, + num_frag_shaders); + + if (sh == NULL) + goto done; + + if (!validate_fragment_shader_executable(prog, sh)) + goto done; + + _mesa_reference_shader(ctx, &prog->_LinkedShaders[MESA_SHADER_FRAGMENT], + sh); + } + + /* Here begins the inter-stage linking phase. Some initial validation is + * performed, then locations are assigned for uniforms, attributes, and + * varyings. + */ + if (cross_validate_uniforms(prog)) { + unsigned prev; + + for (prev = 0; prev < MESA_SHADER_TYPES; prev++) { + if (prog->_LinkedShaders[prev] != NULL) + break; + } + + /* Validate the inputs of each stage with the output of the preceding + * stage. + */ + for (unsigned i = prev + 1; i < MESA_SHADER_TYPES; i++) { + if (prog->_LinkedShaders[i] == NULL) + continue; + + if (!cross_validate_outputs_to_inputs(prog, + prog->_LinkedShaders[prev], + prog->_LinkedShaders[i])) + goto done; + + prev = i; + } + + prog->LinkStatus = true; + } + + /* Do common optimization before assigning storage for attributes, + * uniforms, and varyings. Later optimization could possibly make + * some of that unused. + */ + for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) { + if (prog->_LinkedShaders[i] == NULL) + continue; + + detect_recursion_linked(prog, prog->_LinkedShaders[i]->ir); + if (!prog->LinkStatus) + goto done; + + while (do_common_optimization(prog->_LinkedShaders[i]->ir, true, 32)) + ; + } + + update_array_sizes(prog); + + assign_uniform_locations(prog); + + /* FINISHME: The value of the max_attribute_index parameter is + * FINISHME: implementation dependent based on the value of + * FINISHME: GL_MAX_VERTEX_ATTRIBS. GL_MAX_VERTEX_ATTRIBS must be + * FINISHME: at least 16, so hardcode 16 for now. + */ + if (!assign_attribute_or_color_locations(prog, MESA_SHADER_VERTEX, 16)) { + goto done; + } + + if (!assign_attribute_or_color_locations(prog, MESA_SHADER_FRAGMENT, ctx->Const.MaxDrawBuffers)) { + goto done; + } + + unsigned prev; + for (prev = 0; prev < MESA_SHADER_TYPES; prev++) { + if (prog->_LinkedShaders[prev] != NULL) + break; + } + + for (unsigned i = prev + 1; i < MESA_SHADER_TYPES; i++) { + if (prog->_LinkedShaders[i] == NULL) + continue; + + if (!assign_varying_locations(ctx, prog, + prog->_LinkedShaders[prev], + prog->_LinkedShaders[i])) { + goto done; + } + + prev = i; + } + + if (prog->_LinkedShaders[MESA_SHADER_VERTEX] != NULL) { + demote_shader_inputs_and_outputs(prog->_LinkedShaders[MESA_SHADER_VERTEX], + ir_var_out); + } + + if (prog->_LinkedShaders[MESA_SHADER_GEOMETRY] != NULL) { + gl_shader *const sh = prog->_LinkedShaders[MESA_SHADER_GEOMETRY]; + + demote_shader_inputs_and_outputs(sh, ir_var_in); + demote_shader_inputs_and_outputs(sh, ir_var_inout); + demote_shader_inputs_and_outputs(sh, ir_var_out); + } + + if (prog->_LinkedShaders[MESA_SHADER_FRAGMENT] != NULL) { + gl_shader *const sh = prog->_LinkedShaders[MESA_SHADER_FRAGMENT]; + + demote_shader_inputs_and_outputs(sh, ir_var_in); + } + + /* OpenGL ES requires that a vertex shader and a fragment shader both be + * present in a linked program. By checking for use of shading language + * version 1.00, we also catch the GL_ARB_ES2_compatibility case. + */ + if (ctx->API == API_OPENGLES2 || prog->Version == 100) { + if (prog->_LinkedShaders[MESA_SHADER_VERTEX] == NULL) { + linker_error(prog, "program lacks a vertex shader\n"); + } else if (prog->_LinkedShaders[MESA_SHADER_FRAGMENT] == NULL) { + linker_error(prog, "program lacks a fragment shader\n"); + } + } + + /* FINISHME: Assign fragment shader output locations. */ + +done: + free(vert_shader_list); + + for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) { + if (prog->_LinkedShaders[i] == NULL) + continue; + + /* Retain any live IR, but trash the rest. */ + reparent_ir(prog->_LinkedShaders[i]->ir, prog->_LinkedShaders[i]->ir); + } + + ralloc_free(mem_ctx); +} diff --git a/3rdparty/glsl-optimizer/src/glsl/linker.h b/3rdparty/glsl-optimizer/src/glsl/linker.h new file mode 100644 index 000000000..769cf68b6 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/linker.h @@ -0,0 +1,32 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#pragma once +#ifndef GLSL_LINKER_H +#define GLSL_LINKER_H + +extern bool +link_function_calls(gl_shader_program *prog, gl_shader *main, + gl_shader **shader_list, unsigned num_shaders); + +#endif /* GLSL_LINKER_H */ diff --git a/3rdparty/glsl-optimizer/src/glsl/list.h b/3rdparty/glsl-optimizer/src/glsl/list.h new file mode 100644 index 000000000..1d46365fa --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/list.h @@ -0,0 +1,501 @@ +/* + * Copyright © 2008, 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file list.h + * \brief Doubly-linked list abstract container type. + * + * Each doubly-linked list has a sentinel head and tail node. These nodes + * contain no data. The head sentinel can be identified by its \c prev + * pointer being \c NULL. The tail sentinel can be identified by its + * \c next pointer being \c NULL. + * + * A list is empty if either the head sentinel's \c next pointer points to the + * tail sentinel or the tail sentinel's \c prev poiner points to the head + * sentinel. + * + * Instead of tracking two separate \c node structures and a \c list structure + * that points to them, the sentinel nodes are in a single structure. Noting + * that each sentinel node always has one \c NULL pointer, the \c NULL + * pointers occupy the same memory location. In the \c list structure + * contains a the following: + * + * - A \c head pointer that represents the \c next pointer of the + * head sentinel node. + * - A \c tail pointer that represents the \c prev pointer of the head + * sentinel node and the \c next pointer of the tail sentinel node. This + * pointer is \b always \c NULL. + * - A \c tail_prev pointer that represents the \c prev pointer of the + * tail sentinel node. + * + * Therefore, if \c head->next is \c NULL or \c tail_prev->prev is \c NULL, + * the list is empty. + * + * To anyone familiar with "exec lists" on the Amiga, this structure should + * be immediately recognizable. See the following link for the original Amiga + * operating system documentation on the subject. + * + * http://www.natami.net/dev/Libraries_Manual_guide/node02D7.html + * + * \author Ian Romanick + */ + +#pragma once +#ifndef LIST_CONTAINER_H +#define LIST_CONTAINER_H + +#ifndef __cplusplus +#include +#endif +#include + +#include "ralloc.h" + +struct exec_node { + struct exec_node *next; + struct exec_node *prev; + +#ifdef __cplusplus + /* Callers of this ralloc-based new need not call delete. It's + * easier to just ralloc_free 'ctx' (or any of its ancestors). */ + static void* operator new(size_t size, void *ctx) + { + void *node; + + node = ralloc_size(ctx, size); + assert(node != NULL); + + return node; + } + + /* If the user *does* call delete, that's OK, we will just + * ralloc_free in that case. */ + static void operator delete(void *node) + { + ralloc_free(node); + } + + exec_node() : next(NULL), prev(NULL) + { + /* empty */ + } + + const exec_node *get_next() const + { + return next; + } + + exec_node *get_next() + { + return next; + } + + const exec_node *get_prev() const + { + return prev; + } + + exec_node *get_prev() + { + return prev; + } + + void remove() + { + next->prev = prev; + prev->next = next; + next = NULL; + prev = NULL; + } + + /** + * Link a node with itself + * + * This creates a sort of degenerate list that is occasionally useful. + */ + void self_link() + { + next = this; + prev = this; + } + + /** + * Insert a node in the list after the current node + */ + void insert_after(exec_node *after) + { + after->next = this->next; + after->prev = this; + + this->next->prev = after; + this->next = after; + } + /** + * Insert a node in the list before the current node + */ + void insert_before(exec_node *before) + { + before->next = this; + before->prev = this->prev; + + this->prev->next = before; + this->prev = before; + } + + /** + * Insert another list in the list before the current node + */ + void insert_before(struct exec_list *before); + + /** + * Replace the current node with the given node. + */ + void replace_with(exec_node *replacement) + { + replacement->prev = this->prev; + replacement->next = this->next; + + this->prev->next = replacement; + this->next->prev = replacement; + } + + /** + * Is this the sentinel at the tail of the list? + */ + bool is_tail_sentinel() const + { + return this->next == NULL; + } + + /** + * Is this the sentinel at the head of the list? + */ + bool is_head_sentinel() const + { + return this->prev == NULL; + } +#endif +}; + + +#ifdef __cplusplus +/* This macro will not work correctly if `t' uses virtual inheritance. If you + * are using virtual inheritance, you deserve a slow and painful death. Enjoy! + */ +#define exec_list_offsetof(t, f, p) \ + (((char *) &((t *) p)->f) - ((char *) p)) +#else +#define exec_list_offsetof(t, f, p) offsetof(t, f) +#endif + +/** + * Get a pointer to the structure containing an exec_node + * + * Given a pointer to an \c exec_node embedded in a structure, get a pointer to + * the containing structure. + * + * \param type Base type of the structure containing the node + * \param node Pointer to the \c exec_node + * \param field Name of the field in \c type that is the embedded \c exec_node + */ +#define exec_node_data(type, node, field) \ + ((type *) (((char *) node) - exec_list_offsetof(type, field, node))) + +#ifdef __cplusplus +struct exec_node; + +class iterator { +public: + void next() + { + } + + void *get() + { + return NULL; + } + + bool has_next() const + { + return false; + } +}; + +class exec_list_iterator : public iterator { +public: + exec_list_iterator(exec_node *n) : node(n), _next(n->next) + { + /* empty */ + } + + void next() + { + node = _next; + _next = node->next; + } + + void remove() + { + node->remove(); + } + + exec_node *get() + { + return node; + } + + bool has_next() const + { + return _next != NULL; + } + +private: + exec_node *node; + exec_node *_next; +}; + +#define foreach_iter(iter_type, iter, container) \ + for (iter_type iter = (container) . iterator(); iter.has_next(); iter.next()) +#endif + + +struct exec_list { + struct exec_node *head; + struct exec_node *tail; + struct exec_node *tail_pred; + +#ifdef __cplusplus + /* Callers of this ralloc-based new need not call delete. It's + * easier to just ralloc_free 'ctx' (or any of its ancestors). */ + static void* operator new(size_t size, void *ctx) + { + void *node; + + node = ralloc_size(ctx, size); + assert(node != NULL); + + return node; + } + + /* If the user *does* call delete, that's OK, we will just + * ralloc_free in that case. */ + static void operator delete(void *node) + { + ralloc_free(node); + } + + exec_list() + { + make_empty(); + } + + void make_empty() + { + head = (exec_node *) & tail; + tail = NULL; + tail_pred = (exec_node *) & head; + } + + bool is_empty() const + { + /* There are three ways to test whether a list is empty or not. + * + * - Check to see if the \c head points to the \c tail. + * - Check to see if the \c tail_pred points to the \c head. + * - Check to see if the \c head is the sentinel node by test whether its + * \c next pointer is \c NULL. + * + * The first two methods tend to generate better code on modern systems + * because they save a pointer dereference. + */ + return head == (exec_node *) &tail; + } + + const exec_node *get_head() const + { + return !is_empty() ? head : NULL; + } + + exec_node *get_head() + { + return !is_empty() ? head : NULL; + } + + const exec_node *get_tail() const + { + return !is_empty() ? tail_pred : NULL; + } + + exec_node *get_tail() + { + return !is_empty() ? tail_pred : NULL; + } + + void push_head(exec_node *n) + { + n->next = head; + n->prev = (exec_node *) &head; + + n->next->prev = n; + head = n; + } + + void push_tail(exec_node *n) + { + n->next = (exec_node *) &tail; + n->prev = tail_pred; + + n->prev->next = n; + tail_pred = n; + } + + void push_degenerate_list_at_head(exec_node *n) + { + assert(n->prev->next == n); + + n->prev->next = head; + head->prev = n->prev; + n->prev = (exec_node *) &head; + head = n; + } + + /** + * Remove the first node from a list and return it + * + * \return + * The first node in the list or \c NULL if the list is empty. + * + * \sa exec_list::get_head + */ + exec_node *pop_head() + { + exec_node *const n = this->get_head(); + if (n != NULL) + n->remove(); + + return n; + } + + /** + * Move all of the nodes from this list to the target list + */ + void move_nodes_to(exec_list *target) + { + if (is_empty()) { + target->make_empty(); + } else { + target->head = head; + target->tail = NULL; + target->tail_pred = tail_pred; + + target->head->prev = (exec_node *) &target->head; + target->tail_pred->next = (exec_node *) &target->tail; + + make_empty(); + } + } + + /** + * Append all nodes from the source list to the target list + */ + void + append_list(exec_list *source) + { + if (source->is_empty()) + return; + + /* Link the first node of the source with the last node of the target list. + */ + this->tail_pred->next = source->head; + source->head->prev = this->tail_pred; + + /* Make the tail of the source list be the tail of the target list. + */ + this->tail_pred = source->tail_pred; + this->tail_pred->next = (exec_node *) &this->tail; + + /* Make the source list empty for good measure. + */ + source->make_empty(); + } + + exec_list_iterator iterator() + { + return exec_list_iterator(head); + } + + exec_list_iterator iterator() const + { + return exec_list_iterator((exec_node *) head); + } +#endif +}; + + +#ifdef __cplusplus +inline void exec_node::insert_before(exec_list *before) +{ + if (before->is_empty()) + return; + + before->tail_pred->next = this; + before->head->prev = this->prev; + + this->prev->next = before->head; + this->prev = before->tail_pred; + + before->make_empty(); +} +#endif + +/** + * This version is safe even if the current node is removed. + */ +#define foreach_list_safe(__node, __list) \ + for (exec_node * __node = (__list)->head, * __next = __node->next \ + ; __next != NULL \ + ; __node = __next, __next = __next->next) + +#define foreach_list(__node, __list) \ + for (exec_node * __node = (__list)->head \ + ; (__node)->next != NULL \ + ; (__node) = (__node)->next) + +#define foreach_list_const(__node, __list) \ + for (const exec_node * __node = (__list)->head \ + ; (__node)->next != NULL \ + ; (__node) = (__node)->next) + +#define foreach_list_typed(__type, __node, __field, __list) \ + for (__type * __node = \ + exec_node_data(__type, (__list)->head, __field); \ + (__node)->__field.next != NULL; \ + (__node) = exec_node_data(__type, (__node)->__field.next, __field)) + +#define foreach_list_typed_const(__type, __node, __field, __list) \ + for (const __type * __node = \ + exec_node_data(__type, (__list)->head, __field); \ + (__node)->__field.next != NULL; \ + (__node) = exec_node_data(__type, (__node)->__field.next, __field)) + +#endif /* LIST_CONTAINER_H */ diff --git a/3rdparty/glsl-optimizer/src/glsl/loop_analysis.cpp b/3rdparty/glsl-optimizer/src/glsl/loop_analysis.cpp new file mode 100644 index 000000000..9bba6a97c --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/loop_analysis.cpp @@ -0,0 +1,500 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include "glsl_types.h" +#include "loop_analysis.h" +#include "ir_hierarchical_visitor.h" + +static bool is_loop_terminator(ir_if *ir); + +static bool all_expression_operands_are_loop_constant(ir_rvalue *, + hash_table *); + +static ir_rvalue *get_basic_induction_increment(ir_assignment *, hash_table *); + + +loop_state::loop_state() +{ + this->ht = hash_table_ctor(0, hash_table_pointer_hash, + hash_table_pointer_compare); + this->mem_ctx = ralloc_context(NULL); + this->loop_found = false; +} + + +loop_state::~loop_state() +{ + hash_table_dtor(this->ht); + ralloc_free(this->mem_ctx); +} + + +loop_variable_state * +loop_state::insert(ir_loop *ir) +{ + loop_variable_state *ls = new(this->mem_ctx) loop_variable_state; + + hash_table_insert(this->ht, ls, ir); + this->loop_found = true; + + return ls; +} + + +loop_variable_state * +loop_state::get(const ir_loop *ir) +{ + return (loop_variable_state *) hash_table_find(this->ht, ir); +} + + +loop_variable * +loop_variable_state::get(const ir_variable *ir) +{ + return (loop_variable *) hash_table_find(this->var_hash, ir); +} + + +loop_variable * +loop_variable_state::insert(ir_variable *var) +{ + void *mem_ctx = ralloc_parent(this); + loop_variable *lv = rzalloc(mem_ctx, loop_variable); + + lv->var = var; + + hash_table_insert(this->var_hash, lv, lv->var); + this->variables.push_tail(lv); + + return lv; +} + + +loop_terminator * +loop_variable_state::insert(ir_if *if_stmt) +{ + void *mem_ctx = ralloc_parent(this); + loop_terminator *t = rzalloc(mem_ctx, loop_terminator); + + t->ir = if_stmt; + this->terminators.push_tail(t); + + return t; +} + + +class loop_analysis : public ir_hierarchical_visitor { +public: + loop_analysis(); + + virtual ir_visitor_status visit(ir_loop_jump *); + virtual ir_visitor_status visit(ir_dereference_variable *); + + virtual ir_visitor_status visit_enter(ir_loop *); + virtual ir_visitor_status visit_leave(ir_loop *); + virtual ir_visitor_status visit_enter(ir_assignment *); + virtual ir_visitor_status visit_leave(ir_assignment *); + virtual ir_visitor_status visit_enter(ir_if *); + virtual ir_visitor_status visit_leave(ir_if *); + + loop_state *loops; + + int if_statement_depth; + + ir_assignment *current_assignment; + + exec_list state; +}; + + +loop_analysis::loop_analysis() +{ + this->loops = new loop_state; + + this->if_statement_depth = 0; + this->current_assignment = NULL; +} + + +ir_visitor_status +loop_analysis::visit(ir_loop_jump *ir) +{ + (void) ir; + + assert(!this->state.is_empty()); + + loop_variable_state *const ls = + (loop_variable_state *) this->state.get_head(); + + ls->num_loop_jumps++; + + return visit_continue; +} + + +ir_visitor_status +loop_analysis::visit(ir_dereference_variable *ir) +{ + /* If we're not somewhere inside a loop, there's nothing to do. + */ + if (this->state.is_empty()) + return visit_continue; + + loop_variable_state *const ls = + (loop_variable_state *) this->state.get_head(); + + ir_variable *var = ir->variable_referenced(); + loop_variable *lv = ls->get(var); + + if (lv == NULL) { + lv = ls->insert(var); + lv->read_before_write = !this->in_assignee; + } + + if (this->in_assignee) { + assert(this->current_assignment != NULL); + + lv->conditional_assignment = (this->if_statement_depth > 0) + || (this->current_assignment->condition != NULL); + + if (lv->first_assignment == NULL) { + assert(lv->num_assignments == 0); + + lv->first_assignment = this->current_assignment; + } + + lv->num_assignments++; + } else if (lv->first_assignment == this->current_assignment) { + /* This catches the case where the variable is used in the RHS of an + * assignment where it is also in the LHS. + */ + lv->read_before_write = true; + } + + return visit_continue; +} + +ir_visitor_status +loop_analysis::visit_enter(ir_loop *ir) +{ + loop_variable_state *ls = this->loops->insert(ir); + this->state.push_head(ls); + + return visit_continue; +} + +ir_visitor_status +loop_analysis::visit_leave(ir_loop *ir) +{ + loop_variable_state *const ls = + (loop_variable_state *) this->state.pop_head(); + + + foreach_list(node, &ir->body_instructions) { + /* Skip over declarations at the start of a loop. + */ + if (((ir_instruction *) node)->as_variable()) + continue; + + ir_if *if_stmt = ((ir_instruction *) node)->as_if(); + + if ((if_stmt != NULL) && is_loop_terminator(if_stmt)) + ls->insert(if_stmt); + else + break; + } + + + foreach_list_safe(node, &ls->variables) { + loop_variable *lv = (loop_variable *) node; + + /* Move variables that are already marked as being loop constant to + * a separate list. These trivially don't need to be tested. + */ + if (lv->is_loop_constant()) { + lv->remove(); + ls->constants.push_tail(lv); + } + } + + /* Each variable assigned in the loop that isn't already marked as being loop + * constant might still be loop constant. The requirements at this point + * are: + * + * - Variable is written before it is read. + * + * - Only one assignment to the variable. + * + * - All operands on the RHS of the assignment are also loop constants. + * + * The last requirement is the reason for the progress loop. A variable + * marked as a loop constant on one pass may allow other variables to be + * marked as loop constant on following passes. + */ + bool progress; + do { + progress = false; + + foreach_list_safe(node, &ls->variables) { + loop_variable *lv = (loop_variable *) node; + + if (lv->conditional_assignment || (lv->num_assignments > 1)) + continue; + + /* Process the RHS of the assignment. If all of the variables + * accessed there are loop constants, then add this + */ + ir_rvalue *const rhs = lv->first_assignment->rhs; + if (all_expression_operands_are_loop_constant(rhs, ls->var_hash)) { + lv->rhs_clean = true; + + if (lv->is_loop_constant()) { + progress = true; + + lv->remove(); + ls->constants.push_tail(lv); + } + } + } + } while (progress); + + /* The remaining variables that are not loop invariant might be loop + * induction variables. + */ + foreach_list_safe(node, &ls->variables) { + loop_variable *lv = (loop_variable *) node; + + /* If there is more than one assignment to a variable, it cannot be a + * loop induction variable. This isn't strictly true, but this is a + * very simple induction variable detector, and it can't handle more + * complex cases. + */ + if (lv->num_assignments > 1) + continue; + + /* All of the variables with zero assignments in the loop are loop + * invariant, and they should have already been filtered out. + */ + assert(lv->num_assignments == 1); + assert(lv->first_assignment != NULL); + + /* The assignmnet to the variable in the loop must be unconditional. + */ + if (lv->conditional_assignment) + continue; + + /* Basic loop induction variables have a single assignment in the loop + * that has the form 'VAR = VAR + i' or 'VAR = VAR - i' where i is a + * loop invariant. + */ + ir_rvalue *const inc = + get_basic_induction_increment(lv->first_assignment, ls->var_hash); + if (inc != NULL) { + lv->iv_scale = NULL; + lv->biv = lv->var; + lv->increment = inc; + + lv->remove(); + ls->induction_variables.push_tail(lv); + } + } + + return visit_continue; +} + +ir_visitor_status +loop_analysis::visit_enter(ir_if *ir) +{ + (void) ir; + + if (!this->state.is_empty()) + this->if_statement_depth++; + + return visit_continue; +} + +ir_visitor_status +loop_analysis::visit_leave(ir_if *ir) +{ + (void) ir; + + if (!this->state.is_empty()) + this->if_statement_depth--; + + return visit_continue; +} + +ir_visitor_status +loop_analysis::visit_enter(ir_assignment *ir) +{ + /* If we're not somewhere inside a loop, there's nothing to do. + */ + if (this->state.is_empty()) + return visit_continue_with_parent; + + this->current_assignment = ir; + + return visit_continue; +} + +ir_visitor_status +loop_analysis::visit_leave(ir_assignment *ir) +{ + /* Since the visit_enter exits with visit_continue_with_parent for this + * case, the loop state stack should never be empty here. + */ + assert(!this->state.is_empty()); + + assert(this->current_assignment == ir); + this->current_assignment = NULL; + + return visit_continue; +} + + +class examine_rhs : public ir_hierarchical_visitor { +public: + examine_rhs(hash_table *loop_variables) + { + this->only_uses_loop_constants = true; + this->loop_variables = loop_variables; + } + + virtual ir_visitor_status visit(ir_dereference_variable *ir) + { + loop_variable *lv = + (loop_variable *) hash_table_find(this->loop_variables, ir->var); + + assert(lv != NULL); + + if (lv->is_loop_constant()) { + return visit_continue; + } else { + this->only_uses_loop_constants = false; + return visit_stop; + } + } + + hash_table *loop_variables; + bool only_uses_loop_constants; +}; + + +bool +all_expression_operands_are_loop_constant(ir_rvalue *ir, hash_table *variables) +{ + examine_rhs v(variables); + + ir->accept(&v); + + return v.only_uses_loop_constants; +} + + +ir_rvalue * +get_basic_induction_increment(ir_assignment *ir, hash_table *var_hash) +{ + /* The RHS must be a binary expression. + */ + ir_expression *const rhs = ir->rhs->as_expression(); + if ((rhs == NULL) + || ((rhs->operation != ir_binop_add) + && (rhs->operation != ir_binop_sub))) + return NULL; + + /* One of the of operands of the expression must be the variable assigned. + * If the operation is subtraction, the variable in question must be the + * "left" operand. + */ + ir_variable *const var = ir->lhs->variable_referenced(); + + ir_variable *const op0 = rhs->operands[0]->variable_referenced(); + ir_variable *const op1 = rhs->operands[1]->variable_referenced(); + + if (((op0 != var) && (op1 != var)) + || ((op1 == var) && (rhs->operation == ir_binop_sub))) + return NULL; + + ir_rvalue *inc = (op0 == var) ? rhs->operands[1] : rhs->operands[0]; + + if (inc->as_constant() == NULL) { + ir_variable *const inc_var = inc->variable_referenced(); + if (inc_var != NULL) { + loop_variable *lv = + (loop_variable *) hash_table_find(var_hash, inc_var); + + if (!lv->is_loop_constant()) + inc = NULL; + } else + inc = NULL; + } + + if ((inc != NULL) && (rhs->operation == ir_binop_sub)) { + void *mem_ctx = ralloc_parent(ir); + + inc = new(mem_ctx) ir_expression(ir_unop_neg, + inc->type, + inc->clone(mem_ctx, NULL), + NULL); + } + + return inc; +} + + +/** + * Detect whether an if-statement is a loop terminating condition + * + * Detects if-statements of the form + * + * (if (expression bool ...) (break)) + */ +bool +is_loop_terminator(ir_if *ir) +{ + if (!ir->else_instructions.is_empty()) + return false; + + ir_instruction *const inst = + (ir_instruction *) ir->then_instructions.get_head(); + assert(inst != NULL); + + if (inst->ir_type != ir_type_loop_jump) + return false; + + ir_loop_jump *const jump = (ir_loop_jump *) inst; + if (jump->mode != ir_loop_jump::jump_break) + return false; + + return true; +} + + +loop_state * +analyze_loop_variables(exec_list *instructions) +{ + loop_analysis v; + + v.run(instructions); + return v.loops; +} diff --git a/3rdparty/glsl-optimizer/src/glsl/loop_analysis.h b/3rdparty/glsl-optimizer/src/glsl/loop_analysis.h new file mode 100644 index 000000000..229730836 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/loop_analysis.h @@ -0,0 +1,232 @@ +/* -*- c++ -*- */ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#pragma once +#ifndef LOOP_ANALYSIS_H +#define LOOP_ANALYSIS_H + +#include "ir.h" +#include "program/hash_table.h" + +/** + * Analyze and classify all variables used in all loops in the instruction list + */ +extern class loop_state * +analyze_loop_variables(exec_list *instructions); + + +/** + * Fill in loop control fields + * + * Based on analysis of loop variables, this function tries to remove sequences + * in the loop of the form + * + * (if (expression bool ...) (break)) + * + * and fill in the \c ir_loop::from, \c ir_loop::to, and \c ir_loop::counter + * fields of the \c ir_loop. + * + * In this process, some conditional break-statements may be eliminated + * altogether. For example, if it is provable that one loop exit condition will + * always be satisfied before another, the unnecessary exit condition will be + * removed. + */ +extern bool +set_loop_controls(exec_list *instructions, loop_state *ls); + + +extern bool +unroll_loops(exec_list *instructions, loop_state *ls, unsigned max_iterations); + + +/** + * Tracking for all variables used in a loop + */ +class loop_variable_state : public exec_node { +public: + class loop_variable *get(const ir_variable *); + class loop_variable *insert(ir_variable *); + class loop_terminator *insert(ir_if *); + + + /** + * Loop whose variable state is being tracked by this structure + */ + ir_loop *loop; + + /** + * Variables that have not yet been classified + */ + exec_list variables; + + /** + * Variables whose values are constant within the body of the loop + * + * This list contains \c loop_variable objects. + */ + exec_list constants; + + /** + * Induction variables for this loop + * + * This list contains \c loop_variable objects. + */ + exec_list induction_variables; + + /** + * Simple if-statements that lead to the termination of the loop + * + * This list contains \c loop_terminator objects. + * + * \sa is_loop_terminator + */ + exec_list terminators; + + /** + * Hash table containing all variables accessed in this loop + */ + hash_table *var_hash; + + /** + * Maximum number of loop iterations. + * + * If this value is negative, then the loop may be infinite. This actually + * means that analysis was unable to determine an upper bound on the number + * of loop iterations. + */ + int max_iterations; + + /** + * Number of ir_loop_jump instructions that operate on this loop + */ + unsigned num_loop_jumps; + + loop_variable_state() + { + this->max_iterations = -1; + this->num_loop_jumps = 0; + this->var_hash = hash_table_ctor(0, hash_table_pointer_hash, + hash_table_pointer_compare); + } + + ~loop_variable_state() + { + hash_table_dtor(this->var_hash); + } +}; + + +class loop_variable : public exec_node { +public: + /** The variable in question. */ + ir_variable *var; + + /** Is the variable read in the loop before it is written? */ + bool read_before_write; + + /** Are all variables in the RHS of the assignment loop constants? */ + bool rhs_clean; + + /** Is there an assignment to the variable that is conditional? */ + bool conditional_assignment; + + /** Reference to the first assignment to the variable in the loop body. */ + ir_assignment *first_assignment; + + /** Number of assignments to the variable in the loop body. */ + unsigned num_assignments; + + /** + * Increment values for loop induction variables + * + * Loop induction variables have a single increment of the form + * \c b * \c biv + \c c, where \c b and \c c are loop constants and \c i + * is a basic loop induction variable. + * + * If \c iv_scale is \c NULL, 1 is used. If \c biv is the same as \c var, + * then \c var is a basic loop induction variable. + */ + /*@{*/ + ir_rvalue *iv_scale; + ir_variable *biv; + ir_rvalue *increment; + /*@}*/ + + + inline bool is_loop_constant() const + { + const bool is_const = (this->num_assignments == 0) + || ((this->num_assignments == 1) + && !this->conditional_assignment + && !this->read_before_write + && this->rhs_clean); + + /* If the RHS of *the* assignment is clean, then there must be exactly + * one assignment of the variable. + */ + assert((this->rhs_clean && (this->num_assignments == 1)) + || !this->rhs_clean); + + /* Variables that are marked read-only *MUST* be loop constant. + */ + assert(!this->var->read_only || (this->var->read_only && is_const)); + + return is_const; + } +}; + + +class loop_terminator : public exec_node { +public: + ir_if *ir; +}; + + +class loop_state { +public: + ~loop_state(); + + /** + * Get the loop variable state data for a particular loop + */ + loop_variable_state *get(const ir_loop *); + + loop_variable_state *insert(ir_loop *ir); + + bool loop_found; + +private: + loop_state(); + + /** + * Hash table containing all loops that have been analyzed. + */ + hash_table *ht; + + void *mem_ctx; + + friend class loop_analysis; +}; + +#endif /* LOOP_ANALYSIS_H */ diff --git a/3rdparty/glsl-optimizer/src/glsl/loop_controls.cpp b/3rdparty/glsl-optimizer/src/glsl/loop_controls.cpp new file mode 100644 index 000000000..9acbadc50 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/loop_controls.cpp @@ -0,0 +1,304 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include +#include "main/compiler.h" +#include "glsl_types.h" +#include "loop_analysis.h" +#include "ir_hierarchical_visitor.h" + +/** + * Find an initializer of a variable outside a loop + * + * Works backwards from the loop to find the pre-loop value of the variable. + * This is used, for example, to find the initial value of loop induction + * variables. + * + * \param loop Loop where \c var is an induction variable + * \param var Variable whose initializer is to be found + * + * \return + * The \c ir_rvalue assigned to the variable outside the loop. May return + * \c NULL if no initializer can be found. + */ +ir_rvalue * +find_initial_value(ir_loop *loop, ir_variable *var) +{ + for (exec_node *node = loop->prev; + !node->is_head_sentinel(); + node = node->prev) { + ir_instruction *ir = (ir_instruction *) node; + + switch (ir->ir_type) { + case ir_type_call: + case ir_type_loop: + case ir_type_loop_jump: + case ir_type_return: + case ir_type_if: + return NULL; + + case ir_type_function: + case ir_type_function_signature: + assert(!"Should not get here."); + return NULL; + + case ir_type_assignment: { + ir_assignment *assign = ir->as_assignment(); + ir_variable *assignee = assign->lhs->whole_variable_referenced(); + + if (assignee == var) + return (assign->condition != NULL) ? NULL : assign->rhs; + + break; + } + + default: + break; + } + } + + return NULL; +} + + +int +calculate_iterations(ir_rvalue *from, ir_rvalue *to, ir_rvalue *increment, + enum ir_expression_operation op) +{ + if (from == NULL || to == NULL || increment == NULL) + return -1; + + void *mem_ctx = ralloc_context(NULL); + + ir_expression *const sub = + new(mem_ctx) ir_expression(ir_binop_sub, from->type, to, from); + + ir_expression *const div = + new(mem_ctx) ir_expression(ir_binop_div, sub->type, sub, increment); + + ir_constant *iter = div->constant_expression_value(); + + if (iter == NULL) + return -1; + + if (!iter->type->is_integer()) { + ir_rvalue *cast = + new(mem_ctx) ir_expression(ir_unop_f2i, glsl_type::int_type, iter, + NULL); + + iter = cast->constant_expression_value(); + } + + int iter_value = iter->get_int_component(0); + + /* Make sure that the calculated number of iterations satisfies the exit + * condition. This is needed to catch off-by-one errors and some types of + * ill-formed loops. For example, we need to detect that the following + * loop does not have a maximum iteration count. + * + * for (float x = 0.0; x != 0.9; x += 0.2) + * ; + */ + const int bias[] = { -1, 0, 1 }; + bool valid_loop = false; + + for (unsigned i = 0; i < Elements(bias); i++) { + iter = (increment->type->is_integer()) + ? new(mem_ctx) ir_constant(iter_value + bias[i]) + : new(mem_ctx) ir_constant(float(iter_value + bias[i])); + + ir_expression *const mul = + new(mem_ctx) ir_expression(ir_binop_mul, increment->type, iter, + increment); + + ir_expression *const add = + new(mem_ctx) ir_expression(ir_binop_add, mul->type, mul, from); + + ir_expression *const cmp = + new(mem_ctx) ir_expression(op, glsl_type::bool_type, add, to); + + ir_constant *const cmp_result = cmp->constant_expression_value(); + + assert(cmp_result != NULL); + if (cmp_result->get_bool_component(0)) { + iter_value += bias[i]; + valid_loop = true; + break; + } + } + + ralloc_free(mem_ctx); + return (valid_loop) ? iter_value : -1; +} + + +class loop_control_visitor : public ir_hierarchical_visitor { +public: + loop_control_visitor(loop_state *state) + { + this->state = state; + this->progress = false; + } + + virtual ir_visitor_status visit_leave(ir_loop *ir); + + loop_state *state; + + bool progress; +}; + + +ir_visitor_status +loop_control_visitor::visit_leave(ir_loop *ir) +{ + loop_variable_state *const ls = this->state->get(ir); + + /* If we've entered a loop that hasn't been analyzed, something really, + * really bad has happened. + */ + if (ls == NULL) { + assert(ls != NULL); + return visit_continue; + } + + /* Search the loop terminating conditions for one of the form 'i < c' where + * i is a loop induction variable, c is a constant, and < is any relative + * operator. + */ + int max_iterations = ls->max_iterations; + + if(ir->from && ir->to && ir->increment) + max_iterations = calculate_iterations(ir->from, ir->to, ir->increment, (ir_expression_operation)ir->cmp); + + if(max_iterations < 0) + max_iterations = INT_MAX; + + foreach_list(node, &ls->terminators) { + loop_terminator *t = (loop_terminator *) node; + ir_if *if_stmt = t->ir; + + /* If-statements can be either 'if (expr)' or 'if (deref)'. We only care + * about the former here. + */ + ir_expression *cond = if_stmt->condition->as_expression(); + if (cond == NULL) + continue; + + switch (cond->operation) { + case ir_binop_less: + case ir_binop_greater: + case ir_binop_lequal: + case ir_binop_gequal: { + /* The expressions that we care about will either be of the form + * 'counter < limit' or 'limit < counter'. Figure out which is + * which. + */ + ir_rvalue *counter = cond->operands[0]->as_dereference_variable(); + ir_constant *limit = cond->operands[1]->as_constant(); + enum ir_expression_operation cmp = cond->operation; + + if (limit == NULL) { + counter = cond->operands[1]->as_dereference_variable(); + limit = cond->operands[0]->as_constant(); + + switch (cmp) { + case ir_binop_less: cmp = ir_binop_gequal; break; + case ir_binop_greater: cmp = ir_binop_lequal; break; + case ir_binop_lequal: cmp = ir_binop_greater; break; + case ir_binop_gequal: cmp = ir_binop_less; break; + default: assert(!"Should not get here."); + } + } + + if ((counter == NULL) || (limit == NULL)) + break; + + ir_variable *var = counter->variable_referenced(); + + ir_rvalue *init = find_initial_value(ir, var); + + foreach_list(iv_node, &ls->induction_variables) { + loop_variable *lv = (loop_variable *) iv_node; + + if (lv->var == var) { + const int iterations = calculate_iterations(init, limit, + lv->increment, + cmp); + if (iterations >= 0) { + /* If the new iteration count is lower than the previously + * believed iteration count, update the loop control values. + */ + if (iterations < max_iterations) { + ir->from = init->clone(ir, NULL); + ir->to = limit->clone(ir, NULL); + ir->increment = lv->increment->clone(ir, NULL); + ir->counter = lv->var; + ir->cmp = cmp; + + max_iterations = iterations; + } + + /* Remove the conditional break statement. The loop + * controls are now set such that the exit condition will be + * satisfied. + */ + if_stmt->remove(); + + assert(ls->num_loop_jumps > 0); + ls->num_loop_jumps--; + + this->progress = true; + } + + break; + } + } + break; + } + + default: + break; + } + } + + /* If we have proven the one of the loop exit conditions is satisifed before + * running the loop once, remove the loop. + */ + if (max_iterations == 0) + ir->remove(); + else + ls->max_iterations = max_iterations; + + return visit_continue; +} + + +bool +set_loop_controls(exec_list *instructions, loop_state *ls) +{ + loop_control_visitor v(ls); + + v.run(instructions); + + return v.progress; +} diff --git a/3rdparty/glsl-optimizer/src/glsl/loop_unroll.cpp b/3rdparty/glsl-optimizer/src/glsl/loop_unroll.cpp new file mode 100644 index 000000000..5b84e1014 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/loop_unroll.cpp @@ -0,0 +1,214 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include "glsl_types.h" +#include "loop_analysis.h" +#include "ir_hierarchical_visitor.h" + +class loop_unroll_visitor : public ir_hierarchical_visitor { +public: + loop_unroll_visitor(loop_state *state, unsigned max_iterations) + { + this->state = state; + this->progress = false; + this->max_iterations = max_iterations; + } + + virtual ir_visitor_status visit_leave(ir_loop *ir); + + loop_state *state; + + bool progress; + unsigned max_iterations; +}; + + +static bool +is_break(ir_instruction *ir) +{ + return ir != NULL && ir->ir_type == ir_type_loop_jump + && ((ir_loop_jump *) ir)->is_break(); +} + + +ir_visitor_status +loop_unroll_visitor::visit_leave(ir_loop *ir) +{ + loop_variable_state *const ls = this->state->get(ir); + int iterations; + + /* If we've entered a loop that hasn't been analyzed, something really, + * really bad has happened. + */ + if (ls == NULL) { + assert(ls != NULL); + return visit_continue; + } + + iterations = ls->max_iterations; + + /* Don't try to unroll loops where the number of iterations is not known + * at compile-time. + */ + if (iterations < 0) + return visit_continue; + + /* Don't try to unroll loops that have zillions of iterations either. + */ + if (iterations > (int) max_iterations) + return visit_continue; + + if (ls->num_loop_jumps > 1) + return visit_continue; + else if (ls->num_loop_jumps) { + ir_instruction *last_ir = (ir_instruction *) ir->body_instructions.get_tail(); + assert(last_ir != NULL); + + if (is_break(last_ir)) { + /* If the only loop-jump is a break at the end of the loop, the loop + * will execute exactly once. Remove the break, set the iteration + * count, and fall through to the normal unroller. + */ + last_ir->remove(); + iterations = 1; + + this->progress = true; + } else { + ir_if *ir_if = NULL; + ir_instruction *break_ir = NULL; + bool continue_from_then_branch = false; + + foreach_list(node, &ir->body_instructions) { + /* recognize loops in the form produced by ir_lower_jumps */ + ir_instruction *cur_ir = (ir_instruction *) node; + + ir_if = cur_ir->as_if(); + if (ir_if != NULL) { + /* Determine which if-statement branch, if any, ends with a + * break. The branch that did *not* have the break will get a + * temporary continue inserted in each iteration of the loop + * unroll. + * + * Note that since ls->num_loop_jumps is <= 1, it is impossible + * for both branches to end with a break. + */ + ir_instruction *ir_if_last = + (ir_instruction *) ir_if->then_instructions.get_tail(); + + if (is_break(ir_if_last)) { + continue_from_then_branch = false; + break_ir = ir_if_last; + break; + } else { + ir_if_last = + (ir_instruction *) ir_if->else_instructions.get_tail(); + + if (is_break(ir_if_last)) { + break_ir = ir_if_last; + continue_from_then_branch = true; + break; + } + } + } + } + + if (break_ir == NULL) + return visit_continue; + + /* move instructions after then if in the continue branch */ + while (!ir_if->get_next()->is_tail_sentinel()) { + ir_instruction *move_ir = (ir_instruction *) ir_if->get_next(); + + move_ir->remove(); + if (continue_from_then_branch) + ir_if->then_instructions.push_tail(move_ir); + else + ir_if->else_instructions.push_tail(move_ir); + } + + /* Remove the break from the if-statement. + */ + break_ir->remove(); + + void *const mem_ctx = ralloc_parent(ir); + ir_instruction *ir_to_replace = ir; + + for (int i = 0; i < iterations; i++) { + exec_list copy_list; + + copy_list.make_empty(); + clone_ir_list(mem_ctx, ©_list, &ir->body_instructions); + + ir_if = ((ir_instruction *) copy_list.get_tail())->as_if(); + assert(ir_if != NULL); + + ir_to_replace->insert_before(©_list); + ir_to_replace->remove(); + + /* placeholder that will be removed in the next iteration */ + ir_to_replace = + new(mem_ctx) ir_loop_jump(ir_loop_jump::jump_continue); + + exec_list *const list = (continue_from_then_branch) + ? &ir_if->then_instructions : &ir_if->else_instructions; + + list->push_tail(ir_to_replace); + } + + ir_to_replace->remove(); + + this->progress = true; + return visit_continue; + } + } + + void *const mem_ctx = ralloc_parent(ir); + + for (int i = 0; i < iterations; i++) { + exec_list copy_list; + + copy_list.make_empty(); + clone_ir_list(mem_ctx, ©_list, &ir->body_instructions); + + ir->insert_before(©_list); + } + + /* The loop has been replaced by the unrolled copies. Remove the original + * loop from the IR sequence. + */ + ir->remove(); + + this->progress = true; + return visit_continue; +} + + +bool +unroll_loops(exec_list *instructions, loop_state *ls, unsigned max_iterations) +{ + loop_unroll_visitor v(ls, max_iterations); + + v.run(instructions); + + return v.progress; +} diff --git a/3rdparty/glsl-optimizer/src/glsl/lower_discard.cpp b/3rdparty/glsl-optimizer/src/glsl/lower_discard.cpp new file mode 100644 index 000000000..55ae0b182 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/lower_discard.cpp @@ -0,0 +1,198 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file lower_discard.cpp + * + * This pass moves discards out of if-statements. + * + * Case 1: The "then" branch contains a conditional discard: + * --------------------------------------------------------- + * + * if (cond1) { + * s1; + * discard cond2; + * s2; + * } else { + * s3; + * } + * + * becomes: + * + * temp = false; + * if (cond1) { + * s1; + * temp = cond2; + * s2; + * } else { + * s3; + * } + * discard temp; + * + * Case 2: The "else" branch contains a conditional discard: + * --------------------------------------------------------- + * + * if (cond1) { + * s1; + * } else { + * s2; + * discard cond2; + * s3; + * } + * + * becomes: + * + * temp = false; + * if (cond1) { + * s1; + * } else { + * s2; + * temp = cond2; + * s3; + * } + * discard temp; + * + * Case 3: Both branches contain a conditional discard: + * ---------------------------------------------------- + * + * if (cond1) { + * s1; + * discard cond2; + * s2; + * } else { + * s3; + * discard cond3; + * s4; + * } + * + * becomes: + * + * temp = false; + * if (cond1) { + * s1; + * temp = cond2; + * s2; + * } else { + * s3; + * temp = cond3; + * s4; + * } + * discard temp; + * + * If there are multiple conditional discards, we need only deal with one of + * them. Repeatedly applying this pass will take care of the others. + * + * Unconditional discards are treated as having a condition of "true". + */ + +#include "glsl_types.h" +#include "ir.h" + +class lower_discard_visitor : public ir_hierarchical_visitor { +public: + lower_discard_visitor() + { + this->progress = false; + } + + ir_visitor_status visit_leave(ir_if *); + + bool progress; +}; + + +bool +lower_discard(exec_list *instructions) +{ + lower_discard_visitor v; + + visit_list_elements(&v, instructions); + + return v.progress; +} + + +static ir_discard * +find_discard(exec_list &instructions) +{ + foreach_list(n, &instructions) { + ir_discard *ir = ((ir_instruction *) n)->as_discard(); + if (ir != NULL) + return ir; + } + return NULL; +} + + +static void +replace_discard(void *mem_ctx, ir_variable *var, ir_discard *ir) +{ + ir_rvalue *condition = ir->condition; + + /* For unconditional discards, use "true" as the condition. */ + if (condition == NULL) + condition = new(mem_ctx) ir_constant(true); + + ir_assignment *assignment = + new(mem_ctx) ir_assignment(new(mem_ctx) ir_dereference_variable(var), + condition, NULL); + + ir->replace_with(assignment); +} + + +ir_visitor_status +lower_discard_visitor::visit_leave(ir_if *ir) +{ + ir_discard *then_discard = find_discard(ir->then_instructions); + ir_discard *else_discard = find_discard(ir->else_instructions); + + if (then_discard == NULL && else_discard == NULL) + return visit_continue; + + void *mem_ctx = ralloc_parent(ir); + + ir_variable *temp = new(mem_ctx) ir_variable(glsl_type::bool_type, + "discard_cond_temp", + ir_var_temporary, glsl_precision_low); + ir_assignment *temp_initializer = + new(mem_ctx) ir_assignment(new(mem_ctx) ir_dereference_variable(temp), + new(mem_ctx) ir_constant(false), NULL); + + ir->insert_before(temp); + ir->insert_before(temp_initializer); + + if (then_discard != NULL) + replace_discard(mem_ctx, temp, then_discard); + + if (else_discard != NULL) + replace_discard(mem_ctx, temp, else_discard); + + ir_discard *discard = then_discard != NULL ? then_discard : else_discard; + discard->condition = new(mem_ctx) ir_dereference_variable(temp); + ir->insert_after(discard); + + this->progress = true; + + return visit_continue; +} diff --git a/3rdparty/glsl-optimizer/src/glsl/lower_if_to_cond_assign.cpp b/3rdparty/glsl-optimizer/src/glsl/lower_if_to_cond_assign.cpp new file mode 100644 index 000000000..097d2c11f --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/lower_if_to_cond_assign.cpp @@ -0,0 +1,249 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file lower_if_to_cond_assign.cpp + * + * This attempts to flatten if-statements to conditional assignments for + * GPUs with limited or no flow control support. + * + * It can't handle other control flow being inside of its block, such + * as calls or loops. Hopefully loop unrolling and inlining will take + * care of those. + * + * Drivers for GPUs with no control flow support should simply call + * + * lower_if_to_cond_assign(instructions) + * + * to attempt to flatten all if-statements. + * + * Some GPUs (such as i965 prior to gen6) do support control flow, but have a + * maximum nesting depth N. Drivers for such hardware can call + * + * lower_if_to_cond_assign(instructions, N) + * + * to attempt to flatten any if-statements appearing at depth > N. + */ + +#include "glsl_types.h" +#include "ir.h" +#include "program/hash_table.h" + +class ir_if_to_cond_assign_visitor : public ir_hierarchical_visitor { +public: + ir_if_to_cond_assign_visitor(unsigned max_depth) + { + this->progress = false; + this->max_depth = max_depth; + this->depth = 0; + + this->condition_variables = hash_table_ctor(0, hash_table_pointer_hash, + hash_table_pointer_compare); + } + + ~ir_if_to_cond_assign_visitor() + { + hash_table_dtor(this->condition_variables); + } + + ir_visitor_status visit_enter(ir_if *); + ir_visitor_status visit_leave(ir_if *); + + bool progress; + unsigned max_depth; + unsigned depth; + + struct hash_table *condition_variables; +}; + +bool +lower_if_to_cond_assign(exec_list *instructions, unsigned max_depth) +{ + ir_if_to_cond_assign_visitor v(max_depth); + + visit_list_elements(&v, instructions); + + return v.progress; +} + +void +check_control_flow(ir_instruction *ir, void *data) +{ + bool *found_control_flow = (bool *)data; + switch (ir->ir_type) { + case ir_type_call: + case ir_type_discard: + case ir_type_loop: + case ir_type_loop_jump: + case ir_type_return: + *found_control_flow = true; + break; + default: + break; + } +} + +void +move_block_to_cond_assign(void *mem_ctx, + ir_if *if_ir, ir_rvalue *cond_expr, + exec_list *instructions, + struct hash_table *ht) +{ + foreach_list_safe(node, instructions) { + ir_instruction *ir = (ir_instruction *) node; + + if (ir->ir_type == ir_type_assignment) { + ir_assignment *assign = (ir_assignment *)ir; + + if (hash_table_find(ht, assign) == NULL) { + hash_table_insert(ht, assign, assign); + + /* If the LHS of the assignment is a condition variable that was + * previously added, insert an additional assignment of false to + * the variable. + */ + const bool assign_to_cv = + hash_table_find(ht, assign->lhs->variable_referenced()) != NULL; + + if (!assign->condition) { + if (assign_to_cv) { + assign->rhs = + new(mem_ctx) ir_expression(ir_binop_logic_and, + glsl_type::bool_type, + cond_expr->clone(mem_ctx, NULL), + assign->rhs); + } else { + assign->condition = cond_expr->clone(mem_ctx, NULL); + } + } else { + assign->condition = + new(mem_ctx) ir_expression(ir_binop_logic_and, + glsl_type::bool_type, + cond_expr->clone(mem_ctx, NULL), + assign->condition); + } + } + } + + /* Now, move from the if block to the block surrounding it. */ + ir->remove(); + if_ir->insert_before(ir); + } +} + +ir_visitor_status +ir_if_to_cond_assign_visitor::visit_enter(ir_if *ir) +{ + (void) ir; + this->depth++; + + return visit_continue; +} + +ir_visitor_status +ir_if_to_cond_assign_visitor::visit_leave(ir_if *ir) +{ + /* Only flatten when beyond the GPU's maximum supported nesting depth. */ + if (this->depth-- <= this->max_depth) + return visit_continue; + + bool found_control_flow = false; + ir_assignment *assign; + + /* Check that both blocks don't contain anything we can't support. */ + foreach_iter(exec_list_iterator, then_iter, ir->then_instructions) { + ir_instruction *then_ir = (ir_instruction *)then_iter.get(); + visit_tree(then_ir, check_control_flow, &found_control_flow); + } + foreach_iter(exec_list_iterator, else_iter, ir->else_instructions) { + ir_instruction *else_ir = (ir_instruction *)else_iter.get(); + visit_tree(else_ir, check_control_flow, &found_control_flow); + } + if (found_control_flow) + return visit_continue; + + void *mem_ctx = ralloc_parent(ir); + + /* Store the condition to a variable. Move all of the instructions from + * the then-clause of the if-statement. Use the condition variable as a + * condition for all assignments. + */ + ir_variable *const then_var = + new(mem_ctx) ir_variable(glsl_type::bool_type, + "if_to_cond_assign_then", + ir_var_temporary, glsl_precision_low); + ir->insert_before(then_var); + + ir_dereference_variable *then_cond = + new(mem_ctx) ir_dereference_variable(then_var); + + assign = new(mem_ctx) ir_assignment(then_cond, ir->condition); + ir->insert_before(assign); + + move_block_to_cond_assign(mem_ctx, ir, then_cond, + &ir->then_instructions, + this->condition_variables); + + /* Add the new condition variable to the hash table. This allows us to + * find this variable when lowering other (enclosing) if-statements. + */ + hash_table_insert(this->condition_variables, then_var, then_var); + + /* If there are instructions in the else-clause, store the inverse of the + * condition to a variable. Move all of the instructions from the + * else-clause if the if-statement. Use the (inverse) condition variable + * as a condition for all assignments. + */ + if (!ir->else_instructions.is_empty()) { + ir_variable *const else_var = + new(mem_ctx) ir_variable(glsl_type::bool_type, + "if_to_cond_assign_else", + ir_var_temporary, glsl_precision_low); + ir->insert_before(else_var); + + ir_dereference_variable *else_cond = + new(mem_ctx) ir_dereference_variable(else_var); + + ir_rvalue *inverse = + new(mem_ctx) ir_expression(ir_unop_logic_not, + then_cond->clone(mem_ctx, NULL)); + + assign = new(mem_ctx) ir_assignment(else_cond, inverse); + ir->insert_before(assign); + + move_block_to_cond_assign(mem_ctx, ir, else_cond, + &ir->else_instructions, + this->condition_variables); + + /* Add the new condition variable to the hash table. This allows us to + * find this variable when lowering other (enclosing) if-statements. + */ + hash_table_insert(this->condition_variables, else_var, else_var); + } + + ir->remove(); + + this->progress = true; + + return visit_continue; +} diff --git a/3rdparty/glsl-optimizer/src/glsl/lower_instructions.cpp b/3rdparty/glsl-optimizer/src/glsl/lower_instructions.cpp new file mode 100644 index 000000000..09737a24f --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/lower_instructions.cpp @@ -0,0 +1,297 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file lower_instructions.cpp + * + * Many GPUs lack native instructions for certain expression operations, and + * must replace them with some other expression tree. This pass lowers some + * of the most common cases, allowing the lowering code to be implemented once + * rather than in each driver backend. + * + * Currently supported transformations: + * - SUB_TO_ADD_NEG + * - DIV_TO_MUL_RCP + * - EXP_TO_EXP2 + * - POW_TO_EXP2 + * - LOG_TO_LOG2 + * - MOD_TO_FRACT + * + * SUB_TO_ADD_NEG: + * --------------- + * Breaks an ir_binop_sub expression down to add(op0, neg(op1)) + * + * This simplifies expression reassociation, and for many backends + * there is no subtract operation separate from adding the negation. + * For backends with native subtract operations, they will probably + * want to recognize add(op0, neg(op1)) or the other way around to + * produce a subtract anyway. + * + * DIV_TO_MUL_RCP: + * --------------- + * Breaks an ir_unop_div expression down to op0 * (rcp(op1)). + * + * Many GPUs don't have a divide instruction (945 and 965 included), + * but they do have an RCP instruction to compute an approximate + * reciprocal. By breaking the operation down, constant reciprocals + * can get constant folded. + * + * EXP_TO_EXP2 and LOG_TO_LOG2: + * ---------------------------- + * Many GPUs don't have a base e log or exponent instruction, but they + * do have base 2 versions, so this pass converts exp and log to exp2 + * and log2 operations. + * + * POW_TO_EXP2: + * ----------- + * Many older GPUs don't have an x**y instruction. For these GPUs, convert + * x**y to 2**(y * log2(x)). + * + * MOD_TO_FRACT: + * ------------- + * Breaks an ir_unop_mod expression down to (op1 * fract(op0 / op1)) + * + * Many GPUs don't have a MOD instruction (945 and 965 included), and + * if we have to break it down like this anyway, it gives an + * opportunity to do things like constant fold the (1.0 / op1) easily. + */ + +#include "main/core.h" /* for M_LOG2E */ +#include "glsl_types.h" +#include "ir.h" +#include "ir_optimization.h" + +class lower_instructions_visitor : public ir_hierarchical_visitor { +public: + lower_instructions_visitor(unsigned lower) + : progress(false), lower(lower) { } + + ir_visitor_status visit_leave(ir_expression *); + + bool progress; + +private: + unsigned lower; /** Bitfield of which operations to lower */ + + void sub_to_add_neg(ir_expression *); + void div_to_mul_rcp(ir_expression *); + void mod_to_fract(ir_expression *); + void exp_to_exp2(ir_expression *); + void pow_to_exp2(ir_expression *); + void log_to_log2(ir_expression *); +}; + +/** + * Determine if a particular type of lowering should occur + */ +#define lowering(x) (this->lower & x) + +bool +lower_instructions(exec_list *instructions, unsigned what_to_lower) +{ + lower_instructions_visitor v(what_to_lower); + + visit_list_elements(&v, instructions); + return v.progress; +} + +void +lower_instructions_visitor::sub_to_add_neg(ir_expression *ir) +{ + ir->operation = ir_binop_add; + ir->operands[1] = new(ir) ir_expression(ir_unop_neg, ir->operands[1]->type, + ir->operands[1], NULL); + this->progress = true; +} + +void +lower_instructions_visitor::div_to_mul_rcp(ir_expression *ir) +{ + if (!ir->operands[1]->type->is_integer()) { + /* New expression for the 1.0 / op1 */ + ir_rvalue *expr; + expr = new(ir) ir_expression(ir_unop_rcp, + ir->operands[1]->type, + ir->operands[1], + NULL); + + /* op0 / op1 -> op0 * (1.0 / op1) */ + ir->operation = ir_binop_mul; + ir->operands[1] = expr; + } else { + /* Be careful with integer division -- we need to do it as a + * float and re-truncate, since rcp(n > 1) of an integer would + * just be 0. + */ + ir_rvalue *op0, *op1; + const struct glsl_type *vec_type; + + vec_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, + ir->operands[1]->type->vector_elements, + ir->operands[1]->type->matrix_columns); + + if (ir->operands[1]->type->base_type == GLSL_TYPE_INT) + op1 = new(ir) ir_expression(ir_unop_i2f, vec_type, ir->operands[1], NULL); + else + op1 = new(ir) ir_expression(ir_unop_u2f, vec_type, ir->operands[1], NULL); + + op1 = new(ir) ir_expression(ir_unop_rcp, op1->type, op1, NULL); + + vec_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, + ir->operands[0]->type->vector_elements, + ir->operands[0]->type->matrix_columns); + + if (ir->operands[0]->type->base_type == GLSL_TYPE_INT) + op0 = new(ir) ir_expression(ir_unop_i2f, vec_type, ir->operands[0], NULL); + else + op0 = new(ir) ir_expression(ir_unop_u2f, vec_type, ir->operands[0], NULL); + + vec_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, + ir->type->vector_elements, + ir->type->matrix_columns); + + op0 = new(ir) ir_expression(ir_binop_mul, vec_type, op0, op1); + + if (ir->operands[1]->type->base_type == GLSL_TYPE_INT) { + ir->operation = ir_unop_f2i; + ir->operands[0] = op0; + } else { + ir->operation = ir_unop_i2u; + ir->operands[0] = new(ir) ir_expression(ir_unop_f2i, op0); + } + ir->operands[1] = NULL; + } + + this->progress = true; +} + +void +lower_instructions_visitor::exp_to_exp2(ir_expression *ir) +{ + ir_constant *log2_e = new(ir) ir_constant(float(M_LOG2E)); + + ir->operation = ir_unop_exp2; + ir->operands[0] = new(ir) ir_expression(ir_binop_mul, ir->operands[0]->type, + ir->operands[0], log2_e); + this->progress = true; +} + +void +lower_instructions_visitor::pow_to_exp2(ir_expression *ir) +{ + ir_expression *const log2_x = + new(ir) ir_expression(ir_unop_log2, ir->operands[0]->type, + ir->operands[0]); + + ir->operation = ir_unop_exp2; + ir->operands[0] = new(ir) ir_expression(ir_binop_mul, ir->operands[1]->type, + ir->operands[1], log2_x); + ir->operands[1] = NULL; + this->progress = true; +} + +void +lower_instructions_visitor::log_to_log2(ir_expression *ir) +{ + ir->operation = ir_binop_mul; + ir->operands[0] = new(ir) ir_expression(ir_unop_log2, ir->operands[0]->type, + ir->operands[0], NULL); + ir->operands[1] = new(ir) ir_constant(float(1.0 / M_LOG2E)); + this->progress = true; +} + +void +lower_instructions_visitor::mod_to_fract(ir_expression *ir) +{ + ir_variable *temp = new(ir) ir_variable(ir->operands[1]->type, "mod_b", + ir_var_temporary, precision_from_ir(ir->operands[1])); + this->base_ir->insert_before(temp); + + ir_assignment *const assign = + new(ir) ir_assignment(new(ir) ir_dereference_variable(temp), + ir->operands[1], NULL); + + this->base_ir->insert_before(assign); + + ir_expression *const div_expr = + new(ir) ir_expression(ir_binop_div, ir->operands[0]->type, + ir->operands[0], + new(ir) ir_dereference_variable(temp)); + + /* Don't generate new IR that would need to be lowered in an additional + * pass. + */ + if (lowering(DIV_TO_MUL_RCP)) + div_to_mul_rcp(div_expr); + + ir_rvalue *expr = new(ir) ir_expression(ir_unop_fract, + ir->operands[0]->type, + div_expr, + NULL); + + ir->operation = ir_binop_mul; + ir->operands[0] = new(ir) ir_dereference_variable(temp); + ir->operands[1] = expr; + this->progress = true; +} + +ir_visitor_status +lower_instructions_visitor::visit_leave(ir_expression *ir) +{ + switch (ir->operation) { + case ir_binop_sub: + if (lowering(SUB_TO_ADD_NEG)) + sub_to_add_neg(ir); + break; + + case ir_binop_div: + if (lowering(DIV_TO_MUL_RCP)) + div_to_mul_rcp(ir); + break; + + case ir_unop_exp: + if (lowering(EXP_TO_EXP2)) + exp_to_exp2(ir); + break; + + case ir_unop_log: + if (lowering(LOG_TO_LOG2)) + log_to_log2(ir); + break; + + case ir_binop_mod: + if (lowering(MOD_TO_FRACT) && ir->type->is_float()) + mod_to_fract(ir); + break; + + case ir_binop_pow: + if (lowering(POW_TO_EXP2)) + pow_to_exp2(ir); + break; + + default: + return visit_continue; + } + + return visit_continue; +} diff --git a/3rdparty/glsl-optimizer/src/glsl/lower_jumps.cpp b/3rdparty/glsl-optimizer/src/glsl/lower_jumps.cpp new file mode 100644 index 000000000..30f5881dd --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/lower_jumps.cpp @@ -0,0 +1,1010 @@ +/* + * Copyright © 2010 Luca Barbieri + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file lower_jumps.cpp + * + * This pass lowers jumps (break, continue, and return) to if/else structures. + * + * It can be asked to: + * 1. Pull jumps out of ifs where possible + * 2. Remove all "continue"s, replacing them with an "execute flag" + * 3. Replace all "break" with a single conditional one at the end of the loop + * 4. Replace all "return"s with a single return at the end of the function, + * for the main function and/or other functions + * + * Applying this pass gives several benefits: + * 1. All functions can be inlined. + * 2. nv40 and other pre-DX10 chips without "continue" can be supported + * 3. nv30 and other pre-DX10 chips with no control flow at all are better + * supported + * + * Continues are lowered by adding a per-loop "execute flag", initialized to + * true, that when cleared inhibits all execution until the end of the loop. + * + * Breaks are lowered to continues, plus setting a "break flag" that is checked + * at the end of the loop, and trigger the unique "break". + * + * Returns are lowered to breaks/continues, plus adding a "return flag" that + * causes loops to break again out of their enclosing loops until all the + * loops are exited: then the "execute flag" logic will ignore everything + * until the end of the function. + * + * Note that "continue" and "return" can also be implemented by adding + * a dummy loop and using break. + * However, this is bad for hardware with limited nesting depth, and + * prevents further optimization, and thus is not currently performed. + */ + +#include "glsl_types.h" +#include +#include "ir.h" + +/** + * Enum recording the result of analyzing how control flow might exit + * an IR node. + * + * Each possible value of jump_strength indicates a strictly stronger + * guarantee on control flow than the previous value. + * + * The ordering of strengths roughly reflects the way jumps are + * lowered: jumps with higher strength tend to be lowered to jumps of + * lower strength. Accordingly, strength is used as a heuristic to + * determine which lowering to perform first. + * + * This enum is also used by get_jump_strength() to categorize + * instructions as either break, continue, return, or other. When + * used in this fashion, strength_always_clears_execute_flag is not + * used. + * + * The control flow analysis made by this optimization pass makes two + * simplifying assumptions: + * + * - It ignores discard instructions, since they are lowered by a + * separate pass (lower_discard.cpp). + * + * - It assumes it is always possible for control to flow from a loop + * to the instruction immediately following it. Technically, this + * is not true (since all execution paths through the loop might + * jump back to the top, or return from the function). + * + * Both of these simplifying assumtions are safe, since they can never + * cause reachable code to be incorrectly classified as unreachable; + * they can only do the opposite. + */ +enum jump_strength +{ + /** + * Analysis has produced no guarantee on how control flow might + * exit this IR node. It might fall out the bottom (with or + * without clearing the execute flag, if present), or it might + * continue to the top of the innermost enclosing loop, break out + * of it, or return from the function. + */ + strength_none, + + /** + * The only way control can fall out the bottom of this node is + * through a code path that clears the execute flag. It might also + * continue to the top of the innermost enclosing loop, break out + * of it, or return from the function. + */ + strength_always_clears_execute_flag, + + /** + * Control cannot fall out the bottom of this node. It might + * continue to the top of the innermost enclosing loop, break out + * of it, or return from the function. + */ + strength_continue, + + /** + * Control cannot fall out the bottom of this node, or continue the + * top of the innermost enclosing loop. It can only break out of + * it or return from the function. + */ + strength_break, + + /** + * Control cannot fall out the bottom of this node, continue to the + * top of the innermost enclosing loop, or break out of it. It can + * only return from the function. + */ + strength_return +}; + +struct block_record +{ + /* minimum jump strength (of lowered IR, not pre-lowering IR) + * + * If the block ends with a jump, must be the strength of the jump. + * Otherwise, the jump would be dead and have been deleted before) + * + * If the block doesn't end with a jump, it can be different than strength_none if all paths before it lead to some jump + * (e.g. an if with a return in one branch, and a break in the other, while not lowering them) + * Note that identical jumps are usually unified though. + */ + jump_strength min_strength; + + /* can anything clear the execute flag? */ + bool may_clear_execute_flag; + + block_record() + { + this->min_strength = strength_none; + this->may_clear_execute_flag = false; + } +}; + +struct loop_record +{ + ir_function_signature* signature; + ir_loop* loop; + + /* used to avoid lowering the break used to represent lowered breaks */ + unsigned nesting_depth; + bool in_if_at_the_end_of_the_loop; + + bool may_set_return_flag; + + ir_variable* break_flag; + ir_variable* execute_flag; /* cleared to emulate continue */ + + loop_record(ir_function_signature* p_signature = 0, ir_loop* p_loop = 0) + { + this->signature = p_signature; + this->loop = p_loop; + this->nesting_depth = 0; + this->in_if_at_the_end_of_the_loop = false; + this->may_set_return_flag = false; + this->break_flag = 0; + this->execute_flag = 0; + } + + ir_variable* get_execute_flag() + { + /* also supported for the "function loop" */ + if(!this->execute_flag) { + exec_list& list = this->loop ? this->loop->body_instructions : signature->body; + this->execute_flag = new(this->signature) ir_variable(glsl_type::bool_type, "execute_flag", ir_var_temporary, glsl_precision_low); + list.push_head(new(this->signature) ir_assignment(new(this->signature) ir_dereference_variable(execute_flag), new(this->signature) ir_constant(true), 0)); + list.push_head(this->execute_flag); + } + return this->execute_flag; + } + + ir_variable* get_break_flag() + { + assert(this->loop); + if(!this->break_flag) { + this->break_flag = new(this->signature) ir_variable(glsl_type::bool_type, "break_flag", ir_var_temporary, glsl_precision_low); + this->loop->insert_before(this->break_flag); + this->loop->insert_before(new(this->signature) ir_assignment(new(this->signature) ir_dereference_variable(break_flag), new(this->signature) ir_constant(false), 0)); + } + return this->break_flag; + } +}; + +struct function_record +{ + ir_function_signature* signature; + ir_variable* return_flag; /* used to break out of all loops and then jump to the return instruction */ + ir_variable* return_value; + bool lower_return; + unsigned nesting_depth; + + function_record(ir_function_signature* p_signature = 0, + bool lower_return = false) + { + this->signature = p_signature; + this->return_flag = 0; + this->return_value = 0; + this->nesting_depth = 0; + this->lower_return = lower_return; + } + + ir_variable* get_return_flag() + { + if(!this->return_flag) { + this->return_flag = new(this->signature) ir_variable(glsl_type::bool_type, "return_flag", ir_var_temporary, glsl_precision_low); + this->signature->body.push_head(new(this->signature) ir_assignment(new(this->signature) ir_dereference_variable(return_flag), new(this->signature) ir_constant(false), 0)); + this->signature->body.push_head(this->return_flag); + } + return this->return_flag; + } + + ir_variable* get_return_value() + { + if(!this->return_value) { + assert(!this->signature->return_type->is_void()); + return_value = new(this->signature) ir_variable(this->signature->return_type, "return_value", ir_var_temporary, this->signature->precision); + this->signature->body.push_head(this->return_value); + } + return this->return_value; + } +}; + +struct ir_lower_jumps_visitor : public ir_control_flow_visitor { + /* Postconditions: on exit of any visit() function: + * + * ANALYSIS: this->block.min_strength, + * this->block.may_clear_execute_flag, and + * this->loop.may_set_return_flag are updated to reflect the + * characteristics of the visited statement. + * + * DEAD_CODE_ELIMINATION: If this->block.min_strength is not + * strength_none, the visited node is at the end of its exec_list. + * In other words, any unreachable statements that follow the + * visited statement in its exec_list have been removed. + * + * CONTAINED_JUMPS_LOWERED: If the visited statement contains other + * statements, then should_lower_jump() is false for all of the + * return, break, or continue statements it contains. + * + * Note that visiting a jump does not lower it. That is the + * responsibility of the statement (or function signature) that + * contains the jump. + */ + + bool progress; + + struct function_record function; + struct loop_record loop; + struct block_record block; + + bool pull_out_jumps; + bool lower_continue; + bool lower_break; + bool lower_sub_return; + bool lower_main_return; + + ir_lower_jumps_visitor() + { + this->progress = false; + } + + void truncate_after_instruction(exec_node *ir) + { + if (!ir) + return; + + while (!ir->get_next()->is_tail_sentinel()) { + ((ir_instruction *)ir->get_next())->remove(); + this->progress = true; + } + } + + void move_outer_block_inside(ir_instruction *ir, exec_list *inner_block) + { + while (!ir->get_next()->is_tail_sentinel()) { + ir_instruction *move_ir = (ir_instruction *)ir->get_next(); + + move_ir->remove(); + inner_block->push_tail(move_ir); + } + } + + /** + * Insert the instructions necessary to lower a return statement, + * before the given return instruction. + */ + void insert_lowered_return(ir_return *ir) + { + ir_variable* return_flag = this->function.get_return_flag(); + if(!this->function.signature->return_type->is_void()) { + ir_variable* return_value = this->function.get_return_value(); + ir->insert_before( + new(ir) ir_assignment( + new (ir) ir_dereference_variable(return_value), + ir->value)); + } + ir->insert_before( + new(ir) ir_assignment( + new (ir) ir_dereference_variable(return_flag), + new (ir) ir_constant(true))); + this->loop.may_set_return_flag = true; + } + + /** + * If the given instruction is a return, lower it to instructions + * that store the return value (if there is one), set the return + * flag, and then break. + * + * It is safe to pass NULL to this function. + */ + void lower_return_unconditionally(ir_instruction *ir) + { + if (get_jump_strength(ir) != strength_return) { + return; + } + insert_lowered_return((ir_return*)ir); + ir->replace_with(new(ir) ir_loop_jump(ir_loop_jump::jump_break)); + } + + /** + * Create the necessary instruction to replace a break instruction. + */ + ir_instruction *create_lowered_break() + { + void *ctx = this->function.signature; + return new(ctx) ir_assignment( + new(ctx) ir_dereference_variable(this->loop.get_break_flag()), + new(ctx) ir_constant(true), + 0); + } + + /** + * If the given instruction is a break, lower it to an instruction + * that sets the break flag, without consulting + * should_lower_jump(). + * + * It is safe to pass NULL to this function. + */ + void lower_break_unconditionally(ir_instruction *ir) + { + if (get_jump_strength(ir) != strength_break) { + return; + } + ir->replace_with(create_lowered_break()); + } + + /** + * If the block ends in a conditional or unconditional break, lower + * it, even though should_lower_jump() says it needn't be lowered. + */ + void lower_final_breaks(exec_list *block) + { + ir_instruction *ir = (ir_instruction *) block->get_tail(); + lower_break_unconditionally(ir); + ir_if *ir_if = ir->as_if(); + if (ir_if) { + lower_break_unconditionally( + (ir_instruction *) ir_if->then_instructions.get_tail()); + lower_break_unconditionally( + (ir_instruction *) ir_if->else_instructions.get_tail()); + } + } + + virtual void visit(class ir_loop_jump * ir) + { + /* Eliminate all instructions after each one, since they are + * unreachable. This satisfies the DEAD_CODE_ELIMINATION + * postcondition. + */ + truncate_after_instruction(ir); + + /* Set this->block.min_strength based on this instruction. This + * satisfies the ANALYSIS postcondition. It is not necessary to + * update this->block.may_clear_execute_flag or + * this->loop.may_set_return_flag, because an unlowered jump + * instruction can't change any flags. + */ + this->block.min_strength = ir->is_break() ? strength_break : strength_continue; + + /* The CONTAINED_JUMPS_LOWERED postcondition is already + * satisfied, because jump statements can't contain other + * statements. + */ + } + + virtual void visit(class ir_return * ir) + { + /* Eliminate all instructions after each one, since they are + * unreachable. This satisfies the DEAD_CODE_ELIMINATION + * postcondition. + */ + truncate_after_instruction(ir); + + /* Set this->block.min_strength based on this instruction. This + * satisfies the ANALYSIS postcondition. It is not necessary to + * update this->block.may_clear_execute_flag or + * this->loop.may_set_return_flag, because an unlowered return + * instruction can't change any flags. + */ + this->block.min_strength = strength_return; + + /* The CONTAINED_JUMPS_LOWERED postcondition is already + * satisfied, because jump statements can't contain other + * statements. + */ + } + + virtual void visit(class ir_discard * ir) + { + /* Nothing needs to be done. The ANALYSIS and + * DEAD_CODE_ELIMINATION postconditions are already satisfied, + * because discard statements are ignored by this optimization + * pass. The CONTAINED_JUMPS_LOWERED postcondition is already + * satisfied, because discard statements can't contain other + * statements. + */ + } + + enum jump_strength get_jump_strength(ir_instruction* ir) + { + if(!ir) + return strength_none; + else if(ir->ir_type == ir_type_loop_jump) { + if(((ir_loop_jump*)ir)->is_break()) + return strength_break; + else + return strength_continue; + } else if(ir->ir_type == ir_type_return) + return strength_return; + else + return strength_none; + } + + bool should_lower_jump(ir_jump* ir) + { + unsigned strength = get_jump_strength(ir); + bool lower; + switch(strength) + { + case strength_none: + lower = false; /* don't change this, code relies on it */ + break; + case strength_continue: + lower = lower_continue; + break; + case strength_break: + assert(this->loop.loop); + /* never lower "canonical break" */ + if(ir->get_next()->is_tail_sentinel() && (this->loop.nesting_depth == 0 + || (this->loop.nesting_depth == 1 && this->loop.in_if_at_the_end_of_the_loop))) + lower = false; + else + lower = lower_break; + break; + case strength_return: + /* never lower return at the end of a this->function */ + if(this->function.nesting_depth == 0 && ir->get_next()->is_tail_sentinel()) + lower = false; + else + lower = this->function.lower_return; + break; + } + return lower; + } + + block_record visit_block(exec_list* list) + { + /* Note: since visiting a node may change that node's next + * pointer, we can't use visit_exec_list(), because + * visit_exec_list() caches the node's next pointer before + * visiting it. So we use foreach_list() instead. + * + * foreach_list() isn't safe if the node being visited gets + * removed, but fortunately this visitor doesn't do that. + */ + + block_record saved_block = this->block; + this->block = block_record(); + foreach_list(node, list) { + ((ir_instruction *) node)->accept(this); + } + block_record ret = this->block; + this->block = saved_block; + return ret; + } + + virtual void visit(ir_if *ir) + { + if(this->loop.nesting_depth == 0 && ir->get_next()->is_tail_sentinel()) + this->loop.in_if_at_the_end_of_the_loop = true; + + ++this->function.nesting_depth; + ++this->loop.nesting_depth; + + block_record block_records[2]; + ir_jump* jumps[2]; + + /* Recursively lower nested jumps. This satisfies the + * CONTAINED_JUMPS_LOWERED postcondition, except in the case of + * unconditional jumps at the end of ir->then_instructions and + * ir->else_instructions, which are handled below. + */ + block_records[0] = visit_block(&ir->then_instructions); + block_records[1] = visit_block(&ir->else_instructions); + +retry: /* we get here if we put code after the if inside a branch */ + + /* Determine which of ir->then_instructions and + * ir->else_instructions end with an unconditional jump. + */ + for(unsigned i = 0; i < 2; ++i) { + exec_list& list = i ? ir->else_instructions : ir->then_instructions; + jumps[i] = 0; + if(!list.is_empty() && get_jump_strength((ir_instruction*)list.get_tail())) + jumps[i] = (ir_jump*)list.get_tail(); + } + + /* Loop until we have satisfied the CONTAINED_JUMPS_LOWERED + * postcondition by lowering jumps in both then_instructions and + * else_instructions. + */ + for(;;) { + /* Determine the types of the jumps that terminate + * ir->then_instructions and ir->else_instructions. + */ + jump_strength jump_strengths[2]; + + for(unsigned i = 0; i < 2; ++i) { + if(jumps[i]) { + jump_strengths[i] = block_records[i].min_strength; + assert(jump_strengths[i] == get_jump_strength(jumps[i])); + } else + jump_strengths[i] = strength_none; + } + + /* If both code paths end in a jump, and the jumps are the + * same, and we are pulling out jumps, replace them with a + * single jump that comes after the if instruction. The new + * jump will be visited next, and it will be lowered if + * necessary by the loop or conditional that encloses it. + */ + if(pull_out_jumps && jump_strengths[0] == jump_strengths[1]) { + bool unify = true; + if(jump_strengths[0] == strength_continue) + ir->insert_after(new(ir) ir_loop_jump(ir_loop_jump::jump_continue)); + else if(jump_strengths[0] == strength_break) + ir->insert_after(new(ir) ir_loop_jump(ir_loop_jump::jump_break)); + /* FINISHME: unify returns with identical expressions */ + else if(jump_strengths[0] == strength_return && this->function.signature->return_type->is_void()) + ir->insert_after(new(ir) ir_return(NULL)); + else + unify = false; + + if(unify) { + jumps[0]->remove(); + jumps[1]->remove(); + this->progress = true; + + /* Update jumps[] to reflect the fact that the jumps + * are gone, and update block_records[] to reflect the + * fact that control can now flow to the next + * instruction. + */ + jumps[0] = 0; + jumps[1] = 0; + block_records[0].min_strength = strength_none; + block_records[1].min_strength = strength_none; + + /* The CONTAINED_JUMPS_LOWERED postcondition is now + * satisfied, so we can break out of the loop. + */ + break; + } + } + + /* lower a jump: if both need to lowered, start with the strongest one, so that + * we might later unify the lowered version with the other one + */ + bool should_lower[2]; + for(unsigned i = 0; i < 2; ++i) + should_lower[i] = should_lower_jump(jumps[i]); + + int lower; + if(should_lower[1] && should_lower[0]) + lower = jump_strengths[1] > jump_strengths[0]; + else if(should_lower[0]) + lower = 0; + else if(should_lower[1]) + lower = 1; + else + /* Neither code path ends in a jump that needs to be + * lowered, so the CONTAINED_JUMPS_LOWERED postcondition + * is satisfied and we can break out of the loop. + */ + break; + + if(jump_strengths[lower] == strength_return) { + /* To lower a return, we create a return flag (if the + * function doesn't have one already) and add instructions + * that: 1. store the return value (if this function has a + * non-void return) and 2. set the return flag + */ + insert_lowered_return((ir_return*)jumps[lower]); + if(this->loop.loop) { + /* If we are in a loop, replace the return instruction + * with a break instruction, and then loop so that the + * break instruction can be lowered if necessary. + */ + ir_loop_jump* lowered = 0; + lowered = new(ir) ir_loop_jump(ir_loop_jump::jump_break); + /* Note: we must update block_records and jumps to + * reflect the fact that the control path has been + * altered from a return to a break. + */ + block_records[lower].min_strength = strength_break; + jumps[lower]->replace_with(lowered); + jumps[lower] = lowered; + } else { + /* If we are not in a loop, we then proceed as we would + * for a continue statement (set the execute flag to + * false to prevent the rest of the function from + * executing). + */ + goto lower_continue; + } + this->progress = true; + } else if(jump_strengths[lower] == strength_break) { + /* To lower a break, we create a break flag (if the loop + * doesn't have one already) and add an instruction that + * sets it. + * + * Then we proceed as we would for a continue statement + * (set the execute flag to false to prevent the rest of + * the loop body from executing). + * + * The visit() function for the loop will ensure that the + * break flag is checked after executing the loop body. + */ + jumps[lower]->insert_before(create_lowered_break()); + goto lower_continue; + } else if(jump_strengths[lower] == strength_continue) { +lower_continue: + /* To lower a continue, we create an execute flag (if the + * loop doesn't have one already) and replace the continue + * with an instruction that clears it. + * + * Note that this code path gets exercised when lowering + * return statements that are not inside a loop, so + * this->loop must be initialized even outside of loops. + */ + ir_variable* execute_flag = this->loop.get_execute_flag(); + jumps[lower]->replace_with(new(ir) ir_assignment(new (ir) ir_dereference_variable(execute_flag), new (ir) ir_constant(false), 0)); + /* Note: we must update block_records and jumps to reflect + * the fact that the control path has been altered to an + * instruction that clears the execute flag. + */ + jumps[lower] = 0; + block_records[lower].min_strength = strength_always_clears_execute_flag; + block_records[lower].may_clear_execute_flag = true; + this->progress = true; + + /* Let the loop run again, in case the other branch of the + * if needs to be lowered too. + */ + } + } + + /* move out a jump out if possible */ + if(pull_out_jumps) { + /* If one of the branches ends in a jump, and control cannot + * fall out the bottom of the other branch, then we can move + * the jump after the if. + * + * Set move_out to the branch we are moving a jump out of. + */ + int move_out = -1; + if(jumps[0] && block_records[1].min_strength >= strength_continue) + move_out = 0; + else if(jumps[1] && block_records[0].min_strength >= strength_continue) + move_out = 1; + + if(move_out >= 0) + { + jumps[move_out]->remove(); + ir->insert_after(jumps[move_out]); + /* Note: we must update block_records and jumps to reflect + * the fact that the jump has been moved out of the if. + */ + jumps[move_out] = 0; + block_records[move_out].min_strength = strength_none; + this->progress = true; + } + } + + /* Now satisfy the ANALYSIS postcondition by setting + * this->block.min_strength and + * this->block.may_clear_execute_flag based on the + * characteristics of the two branches. + */ + if(block_records[0].min_strength < block_records[1].min_strength) + this->block.min_strength = block_records[0].min_strength; + else + this->block.min_strength = block_records[1].min_strength; + this->block.may_clear_execute_flag = this->block.may_clear_execute_flag || block_records[0].may_clear_execute_flag || block_records[1].may_clear_execute_flag; + + /* Now we need to clean up the instructions that follow the + * if. + * + * If those instructions are unreachable, then satisfy the + * DEAD_CODE_ELIMINATION postcondition by eliminating them. + * Otherwise that postcondition is already satisfied. + */ + if(this->block.min_strength) + truncate_after_instruction(ir); + else if(this->block.may_clear_execute_flag) + { + /* If the "if" instruction might clear the execute flag, then + * we need to guard any instructions that follow so that they + * are only executed if the execute flag is set. + * + * If one of the branches of the "if" always clears the + * execute flag, and the other branch never clears it, then + * this is easy: just move all the instructions following the + * "if" into the branch that never clears it. + */ + int move_into = -1; + if(block_records[0].min_strength && !block_records[1].may_clear_execute_flag) + move_into = 1; + else if(block_records[1].min_strength && !block_records[0].may_clear_execute_flag) + move_into = 0; + + if(move_into >= 0) { + assert(!block_records[move_into].min_strength && !block_records[move_into].may_clear_execute_flag); /* otherwise, we just truncated */ + + exec_list* list = move_into ? &ir->else_instructions : &ir->then_instructions; + exec_node* next = ir->get_next(); + if(!next->is_tail_sentinel()) { + move_outer_block_inside(ir, list); + + /* If any instructions moved, then we need to visit + * them (since they are now inside the "if"). Since + * block_records[move_into] is in its default state + * (see assertion above), we can safely replace + * block_records[move_into] with the result of this + * analysis. + */ + exec_list list; + list.head = next; + block_records[move_into] = visit_block(&list); + + /* + * Then we need to re-start our jump lowering, since one + * of the instructions we moved might be a jump that + * needs to be lowered. + */ + this->progress = true; + goto retry; + } + } else { + /* If we get here, then the simple case didn't apply; we + * need to actually guard the instructions that follow. + * + * To avoid creating unnecessarily-deep nesting, first + * look through the instructions that follow and unwrap + * any instructions that that are already wrapped in the + * appropriate guard. + */ + ir_instruction* ir_after; + for(ir_after = (ir_instruction*)ir->get_next(); !ir_after->is_tail_sentinel();) + { + ir_if* ir_if = ir_after->as_if(); + if(ir_if && ir_if->else_instructions.is_empty()) { + ir_dereference_variable* ir_if_cond_deref = ir_if->condition->as_dereference_variable(); + if(ir_if_cond_deref && ir_if_cond_deref->var == this->loop.execute_flag) { + ir_instruction* ir_next = (ir_instruction*)ir_after->get_next(); + ir_after->insert_before(&ir_if->then_instructions); + ir_after->remove(); + ir_after = ir_next; + continue; + } + } + ir_after = (ir_instruction*)ir_after->get_next(); + + /* only set this if we find any unprotected instruction */ + this->progress = true; + } + + /* Then, wrap all the instructions that follow in a single + * guard. + */ + if(!ir->get_next()->is_tail_sentinel()) { + assert(this->loop.execute_flag); + ir_if* if_execute = new(ir) ir_if(new(ir) ir_dereference_variable(this->loop.execute_flag)); + move_outer_block_inside(ir, &if_execute->then_instructions); + ir->insert_after(if_execute); + } + } + } + --this->loop.nesting_depth; + --this->function.nesting_depth; + } + + virtual void visit(ir_loop *ir) + { + /* Visit the body of the loop, with a fresh data structure in + * this->loop so that the analysis we do here won't bleed into + * enclosing loops. + * + * We assume that all code after a loop is reachable from the + * loop (see comments on enum jump_strength), so the + * DEAD_CODE_ELIMINATION postcondition is automatically + * satisfied, as is the block.min_strength portion of the + * ANALYSIS postcondition. + * + * The block.may_clear_execute_flag portion of the ANALYSIS + * postcondition is automatically satisfied because execute + * flags do not propagate outside of loops. + * + * The loop.may_set_return_flag portion of the ANALYSIS + * postcondition is handled below. + */ + ++this->function.nesting_depth; + loop_record saved_loop = this->loop; + this->loop = loop_record(this->function.signature, ir); + + /* Recursively lower nested jumps. This satisfies the + * CONTAINED_JUMPS_LOWERED postcondition, except in the case of + * an unconditional continue or return at the bottom of the + * loop, which are handled below. + */ + block_record body = visit_block(&ir->body_instructions); + + /* If the loop ends in an unconditional continue, eliminate it + * because it is redundant. + */ + ir_instruction *ir_last + = (ir_instruction *) ir->body_instructions.get_tail(); + if (get_jump_strength(ir_last) == strength_continue) { + ir_last->remove(); + } + + /* If the loop ends in an unconditional return, and we are + * lowering returns, lower it. + */ + if (this->function.lower_return) + lower_return_unconditionally(ir_last); + + if(body.min_strength >= strength_break) { + /* FINISHME: If the min_strength of the loop body is + * strength_break or strength_return, that means that it + * isn't a loop at all, since control flow always leaves the + * body of the loop via break or return. In principle the + * loop could be eliminated in this case. This optimization + * is not implemented yet. + */ + } + + if(this->loop.break_flag) { + /* We only get here if we are lowering breaks */ + assert (lower_break); + + /* If a break flag was generated while visiting the body of + * the loop, then at least one break was lowered, so we need + * to generate an if statement at the end of the loop that + * does a "break" if the break flag is set. The break we + * generate won't violate the CONTAINED_JUMPS_LOWERED + * postcondition, because should_lower_jump() always returns + * false for a break that happens at the end of a loop. + * + * However, if the loop already ends in a conditional or + * unconditional break, then we need to lower that break, + * because it won't be at the end of the loop anymore. + */ + lower_final_breaks(&ir->body_instructions); + + ir_if* break_if = new(ir) ir_if(new(ir) ir_dereference_variable(this->loop.break_flag)); + break_if->then_instructions.push_tail(new(ir) ir_loop_jump(ir_loop_jump::jump_break)); + ir->body_instructions.push_tail(break_if); + } + + /* If the body of the loop may set the return flag, then at + * least one return was lowered to a break, so we need to ensure + * that the return flag is checked after the body of the loop is + * executed. + */ + if(this->loop.may_set_return_flag) { + assert(this->function.return_flag); + /* Generate the if statement to check the return flag */ + ir_if* return_if = new(ir) ir_if(new(ir) ir_dereference_variable(this->function.return_flag)); + /* Note: we also need to propagate the knowledge that the + * return flag may get set to the outer context. This + * satisfies the loop.may_set_return_flag part of the + * ANALYSIS postcondition. + */ + saved_loop.may_set_return_flag = true; + if(saved_loop.loop) + /* If this loop is nested inside another one, then the if + * statement that we generated should break out of that + * loop if the return flag is set. Caller will lower that + * break statement if necessary. + */ + return_if->then_instructions.push_tail(new(ir) ir_loop_jump(ir_loop_jump::jump_break)); + else + /* Otherwise, all we need to do is ensure that the + * instructions that follow are only executed if the + * return flag is clear. We can do that by moving those + * instructions into the else clause of the generated if + * statement. + */ + move_outer_block_inside(ir, &return_if->else_instructions); + ir->insert_after(return_if); + } + + this->loop = saved_loop; + --this->function.nesting_depth; + } + + virtual void visit(ir_function_signature *ir) + { + /* these are not strictly necessary */ + assert(!this->function.signature); + assert(!this->loop.loop); + + bool lower_return; + if (strcmp(ir->function_name(), "main") == 0) + lower_return = lower_main_return; + else + lower_return = lower_sub_return; + + function_record saved_function = this->function; + loop_record saved_loop = this->loop; + this->function = function_record(ir, lower_return); + this->loop = loop_record(ir); + + assert(!this->loop.loop); + + /* Visit the body of the function to lower any jumps that occur + * in it, except possibly an unconditional return statement at + * the end of it. + */ + visit_block(&ir->body); + + /* If the body ended in an unconditional return of non-void, + * then we don't need to lower it because it's the one canonical + * return. + * + * If the body ended in a return of void, eliminate it because + * it is redundant. + */ + if (ir->return_type->is_void() && + get_jump_strength((ir_instruction *) ir->body.get_tail())) { + ir_jump *jump = (ir_jump *) ir->body.get_tail(); + assert (jump->ir_type == ir_type_return); + jump->remove(); + } + + if(this->function.return_value) + ir->body.push_tail(new(ir) ir_return(new (ir) ir_dereference_variable(this->function.return_value))); + + this->loop = saved_loop; + this->function = saved_function; + } + + virtual void visit(class ir_function * ir) + { + visit_block(&ir->signatures); + } +}; + +bool +do_lower_jumps(exec_list *instructions, bool pull_out_jumps, bool lower_sub_return, bool lower_main_return, bool lower_continue, bool lower_break) +{ + ir_lower_jumps_visitor v; + v.pull_out_jumps = pull_out_jumps; + v.lower_continue = lower_continue; + v.lower_break = lower_break; + v.lower_sub_return = lower_sub_return; + v.lower_main_return = lower_main_return; + + do { + v.progress = false; + visit_exec_list(instructions, &v); + } while (v.progress); + + return v.progress; +} diff --git a/3rdparty/glsl-optimizer/src/glsl/lower_mat_op_to_vec.cpp b/3rdparty/glsl-optimizer/src/glsl/lower_mat_op_to_vec.cpp new file mode 100644 index 000000000..593fc866e --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/lower_mat_op_to_vec.cpp @@ -0,0 +1,428 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file lower_mat_op_to_vec.cpp + * + * Breaks matrix operation expressions down to a series of vector operations. + * + * Generally this is how we have to codegen matrix operations for a + * GPU, so this gives us the chance to constant fold operations on a + * column or row. + */ + +#include "ir.h" +#include "ir_expression_flattening.h" +#include "glsl_types.h" + +class ir_mat_op_to_vec_visitor : public ir_hierarchical_visitor { +public: + ir_mat_op_to_vec_visitor() + { + this->made_progress = false; + this->mem_ctx = NULL; + } + + ir_visitor_status visit_leave(ir_assignment *); + + ir_dereference *get_column(ir_dereference *val, int col); + ir_rvalue *get_element(ir_dereference *val, int col, int row); + + void do_mul_mat_mat(ir_dereference *result, + ir_dereference *a, ir_dereference *b); + void do_mul_mat_vec(ir_dereference *result, + ir_dereference *a, ir_dereference *b); + void do_mul_vec_mat(ir_dereference *result, + ir_dereference *a, ir_dereference *b); + void do_mul_mat_scalar(ir_dereference *result, + ir_dereference *a, ir_dereference *b); + void do_equal_mat_mat(ir_dereference *result, ir_dereference *a, + ir_dereference *b, bool test_equal); + + void *mem_ctx; + bool made_progress; +}; + +static bool +mat_op_to_vec_predicate(ir_instruction *ir) +{ + ir_expression *expr = ir->as_expression(); + unsigned int i; + + if (!expr) + return false; + + for (i = 0; i < expr->get_num_operands(); i++) { + if (expr->operands[i]->type->is_matrix()) + return true; + } + + return false; +} + +bool +do_mat_op_to_vec(exec_list *instructions) +{ + ir_mat_op_to_vec_visitor v; + + /* Pull out any matrix expression to a separate assignment to a + * temp. This will make our handling of the breakdown to + * operations on the matrix's vector components much easier. + */ + do_expression_flattening(instructions, mat_op_to_vec_predicate); + + visit_list_elements(&v, instructions); + + return v.made_progress; +} + +ir_rvalue * +ir_mat_op_to_vec_visitor::get_element(ir_dereference *val, int col, int row) +{ + val = get_column(val, col); + + return new(mem_ctx) ir_swizzle(val, row, 0, 0, 0, 1); +} + +ir_dereference * +ir_mat_op_to_vec_visitor::get_column(ir_dereference *val, int row) +{ + val = val->clone(mem_ctx, NULL); + + if (val->type->is_matrix()) { + val = new(mem_ctx) ir_dereference_array(val, + new(mem_ctx) ir_constant(row)); + } + + return val; +} + +void +ir_mat_op_to_vec_visitor::do_mul_mat_mat(ir_dereference *result, + ir_dereference *a, + ir_dereference *b) +{ + int b_col, i; + ir_assignment *assign; + ir_expression *expr; + + for (b_col = 0; b_col < b->type->matrix_columns; b_col++) { + /* first column */ + expr = new(mem_ctx) ir_expression(ir_binop_mul, + get_column(a, 0), + get_element(b, b_col, 0)); + + /* following columns */ + for (i = 1; i < a->type->matrix_columns; i++) { + ir_expression *mul_expr; + + mul_expr = new(mem_ctx) ir_expression(ir_binop_mul, + get_column(a, i), + get_element(b, b_col, i)); + expr = new(mem_ctx) ir_expression(ir_binop_add, + expr, + mul_expr); + } + + assign = new(mem_ctx) ir_assignment(get_column(result, b_col), expr); + base_ir->insert_before(assign); + } +} + +void +ir_mat_op_to_vec_visitor::do_mul_mat_vec(ir_dereference *result, + ir_dereference *a, + ir_dereference *b) +{ + int i; + ir_assignment *assign; + ir_expression *expr; + + /* first column */ + expr = new(mem_ctx) ir_expression(ir_binop_mul, + get_column(a, 0), + get_element(b, 0, 0)); + + /* following columns */ + for (i = 1; i < a->type->matrix_columns; i++) { + ir_expression *mul_expr; + + mul_expr = new(mem_ctx) ir_expression(ir_binop_mul, + get_column(a, i), + get_element(b, 0, i)); + expr = new(mem_ctx) ir_expression(ir_binop_add, expr, mul_expr); + } + + result = result->clone(mem_ctx, NULL); + assign = new(mem_ctx) ir_assignment(result, expr); + base_ir->insert_before(assign); +} + +void +ir_mat_op_to_vec_visitor::do_mul_vec_mat(ir_dereference *result, + ir_dereference *a, + ir_dereference *b) +{ + int i; + + for (i = 0; i < b->type->matrix_columns; i++) { + ir_rvalue *column_result; + ir_expression *column_expr; + ir_assignment *column_assign; + + column_result = result->clone(mem_ctx, NULL); + column_result = new(mem_ctx) ir_swizzle(column_result, i, 0, 0, 0, 1); + + column_expr = new(mem_ctx) ir_expression(ir_binop_dot, + a->clone(mem_ctx, NULL), + get_column(b, i)); + + column_assign = new(mem_ctx) ir_assignment(column_result, + column_expr); + base_ir->insert_before(column_assign); + } +} + +void +ir_mat_op_to_vec_visitor::do_mul_mat_scalar(ir_dereference *result, + ir_dereference *a, + ir_dereference *b) +{ + int i; + + for (i = 0; i < a->type->matrix_columns; i++) { + ir_expression *column_expr; + ir_assignment *column_assign; + + column_expr = new(mem_ctx) ir_expression(ir_binop_mul, + get_column(a, i), + b->clone(mem_ctx, NULL)); + + column_assign = new(mem_ctx) ir_assignment(get_column(result, i), + column_expr); + base_ir->insert_before(column_assign); + } +} + +void +ir_mat_op_to_vec_visitor::do_equal_mat_mat(ir_dereference *result, + ir_dereference *a, + ir_dereference *b, + bool test_equal) +{ + /* This essentially implements the following GLSL: + * + * bool equal(mat4 a, mat4 b) + * { + * return !any(bvec4(a[0] != b[0], + * a[1] != b[1], + * a[2] != b[2], + * a[3] != b[3]); + * } + * + * bool nequal(mat4 a, mat4 b) + * { + * return any(bvec4(a[0] != b[0], + * a[1] != b[1], + * a[2] != b[2], + * a[3] != b[3]); + * } + */ + const unsigned columns = a->type->matrix_columns; + const glsl_type *const bvec_type = + glsl_type::get_instance(GLSL_TYPE_BOOL, columns, 1); + + ir_variable *const tmp_bvec = + new(this->mem_ctx) ir_variable(bvec_type, "mat_cmp_bvec", + ir_var_temporary, glsl_precision_low); + this->base_ir->insert_before(tmp_bvec); + + for (unsigned i = 0; i < columns; i++) { + ir_expression *const cmp = + new(this->mem_ctx) ir_expression(ir_binop_any_nequal, + get_column(a, i), + get_column(b, i)); + + ir_dereference *const lhs = + new(this->mem_ctx) ir_dereference_variable(tmp_bvec); + + ir_assignment *const assign = + new(this->mem_ctx) ir_assignment(lhs, cmp, NULL, (1U << i)); + + this->base_ir->insert_before(assign); + } + + ir_rvalue *const val = new(this->mem_ctx) ir_dereference_variable(tmp_bvec); + ir_expression *any = new(this->mem_ctx) ir_expression(ir_unop_any, val); + + if (test_equal) + any = new(this->mem_ctx) ir_expression(ir_unop_logic_not, any); + + ir_assignment *const assign = + new(mem_ctx) ir_assignment(result->clone(mem_ctx, NULL), any); + base_ir->insert_before(assign); +} + +static bool +has_matrix_operand(const ir_expression *expr, unsigned &columns) +{ + for (unsigned i = 0; i < expr->get_num_operands(); i++) { + if (expr->operands[i]->type->is_matrix()) { + columns = expr->operands[i]->type->matrix_columns; + return true; + } + } + + return false; +} + + +ir_visitor_status +ir_mat_op_to_vec_visitor::visit_leave(ir_assignment *orig_assign) +{ + ir_expression *orig_expr = orig_assign->rhs->as_expression(); + unsigned int i, matrix_columns = 1; + ir_dereference *op[2]; + + if (!orig_expr) + return visit_continue; + + if (!has_matrix_operand(orig_expr, matrix_columns)) + return visit_continue; + + assert(orig_expr->get_num_operands() <= 2); + + mem_ctx = ralloc_parent(orig_assign); + + ir_dereference_variable *result = + orig_assign->lhs->as_dereference_variable(); + assert(result); + + /* Store the expression operands in temps so we can use them + * multiple times. + */ + for (i = 0; i < orig_expr->get_num_operands(); i++) { + ir_assignment *assign; + ir_dereference *deref = orig_expr->operands[i]->as_dereference(); + + /* Avoid making a temporary if we don't need to to avoid aliasing. */ + if (deref && + deref->variable_referenced() != result->variable_referenced()) { + op[i] = deref; + continue; + } + + /* Otherwise, store the operand in a temporary generally if it's + * not a dereference. + */ + ir_variable *var = new(mem_ctx) ir_variable(orig_expr->operands[i]->type, + "mat_op_to_vec", + ir_var_temporary, precision_from_ir(orig_expr->operands[i])); + base_ir->insert_before(var); + + /* Note that we use this dereference for the assignment. That means + * that others that want to use op[i] have to clone the deref. + */ + op[i] = new(mem_ctx) ir_dereference_variable(var); + assign = new(mem_ctx) ir_assignment(op[i], orig_expr->operands[i]); + base_ir->insert_before(assign); + } + + /* OK, time to break down this matrix operation. */ + switch (orig_expr->operation) { + case ir_unop_neg: { + /* Apply the operation to each column.*/ + for (i = 0; i < matrix_columns; i++) { + ir_expression *column_expr; + ir_assignment *column_assign; + + column_expr = new(mem_ctx) ir_expression(orig_expr->operation, + get_column(op[0], i)); + + column_assign = new(mem_ctx) ir_assignment(get_column(result, i), + column_expr); + assert(column_assign->write_mask != 0); + base_ir->insert_before(column_assign); + } + break; + } + case ir_binop_add: + case ir_binop_sub: + case ir_binop_div: + case ir_binop_mod: { + /* For most operations, the matrix version is just going + * column-wise through and applying the operation to each column + * if available. + */ + for (i = 0; i < matrix_columns; i++) { + ir_expression *column_expr; + ir_assignment *column_assign; + + column_expr = new(mem_ctx) ir_expression(orig_expr->operation, + get_column(op[0], i), + get_column(op[1], i)); + + column_assign = new(mem_ctx) ir_assignment(get_column(result, i), + column_expr); + assert(column_assign->write_mask != 0); + base_ir->insert_before(column_assign); + } + break; + } + case ir_binop_mul: + if (op[0]->type->is_matrix()) { + if (op[1]->type->is_matrix()) { + do_mul_mat_mat(result, op[0], op[1]); + } else if (op[1]->type->is_vector()) { + do_mul_mat_vec(result, op[0], op[1]); + } else { + assert(op[1]->type->is_scalar()); + do_mul_mat_scalar(result, op[0], op[1]); + } + } else { + assert(op[1]->type->is_matrix()); + if (op[0]->type->is_vector()) { + do_mul_vec_mat(result, op[0], op[1]); + } else { + assert(op[0]->type->is_scalar()); + do_mul_mat_scalar(result, op[1], op[0]); + } + } + break; + + case ir_binop_all_equal: + case ir_binop_any_nequal: + do_equal_mat_mat(result, op[1], op[0], + (orig_expr->operation == ir_binop_all_equal)); + break; + + default: + printf("FINISHME: Handle matrix operation for %s\n", + orig_expr->operator_string()); + abort(); + } + orig_assign->remove(); + this->made_progress = true; + + return visit_continue; +} diff --git a/3rdparty/glsl-optimizer/src/glsl/lower_noise.cpp b/3rdparty/glsl-optimizer/src/glsl/lower_noise.cpp new file mode 100644 index 000000000..85f59b675 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/lower_noise.cpp @@ -0,0 +1,71 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file lower_noise.cpp + * IR lower pass to remove noise opcodes. + * + * \author Ian Romanick + */ + +#include "ir.h" +#include "ir_rvalue_visitor.h" + +class lower_noise_visitor : public ir_rvalue_visitor { +public: + lower_noise_visitor() : progress(false) + { + /* empty */ + } + + void handle_rvalue(ir_rvalue **rvalue) + { + if (!*rvalue) + return; + + ir_expression *expr = (*rvalue)->as_expression(); + if (!expr) + return; + + /* In the future, ir_unop_noise may be replaced by a call to a function + * that implements noise. No hardware has a noise instruction. + */ + if (expr->operation == ir_unop_noise) { + *rvalue = ir_constant::zero(ralloc_parent(expr), expr->type); + this->progress = true; + } + } + + bool progress; +}; + + +bool +lower_noise(exec_list *instructions) +{ + lower_noise_visitor v; + + visit_list_elements(&v, instructions); + + return v.progress; +} diff --git a/3rdparty/glsl-optimizer/src/glsl/lower_texture_projection.cpp b/3rdparty/glsl-optimizer/src/glsl/lower_texture_projection.cpp new file mode 100644 index 000000000..ec8903661 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/lower_texture_projection.cpp @@ -0,0 +1,99 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file lower_texture_projection.cpp + * + * IR lower pass to perform the division of texture coordinates by the texture + * projector if present. + * + * Many GPUs have a texture sampling opcode that takes the projector + * and does the divide internally, thus the presence of the projector + * in the IR. For GPUs that don't, this saves the driver needing the + * logic for handling the divide. + * + * \author Eric Anholt + */ + +#include "ir.h" + +class lower_texture_projection_visitor : public ir_hierarchical_visitor { +public: + lower_texture_projection_visitor() + { + progress = false; + } + + ir_visitor_status visit_leave(ir_texture *ir); + + bool progress; +}; + +ir_visitor_status +lower_texture_projection_visitor::visit_leave(ir_texture *ir) +{ + if (!ir->projector) + return visit_continue; + + void *mem_ctx = ralloc_parent(ir); + + ir_variable *var = new(mem_ctx) ir_variable(ir->projector->type, + "projector", ir_var_auto, glsl_precision_undefined); + base_ir->insert_before(var); + ir_dereference *deref = new(mem_ctx) ir_dereference_variable(var); + ir_expression *expr = new(mem_ctx) ir_expression(ir_unop_rcp, + ir->projector->type, + ir->projector, + NULL); + ir_assignment *assign = new(mem_ctx) ir_assignment(deref, expr, NULL); + base_ir->insert_before(assign); + + deref = new(mem_ctx) ir_dereference_variable(var); + ir->coordinate = new(mem_ctx) ir_expression(ir_binop_mul, + ir->coordinate->type, + ir->coordinate, + deref); + + if (ir->shadow_comparitor) { + deref = new(mem_ctx) ir_dereference_variable(var); + ir->shadow_comparitor = new(mem_ctx) ir_expression(ir_binop_mul, + ir->shadow_comparitor->type, + ir->shadow_comparitor, + deref); + } + + ir->projector = NULL; + + progress = true; + return visit_continue; +} + +bool +do_lower_texture_projection(exec_list *instructions) +{ + lower_texture_projection_visitor v; + + visit_list_elements(&v, instructions); + + return v.progress; +} diff --git a/3rdparty/glsl-optimizer/src/glsl/lower_variable_index_to_cond_assign.cpp b/3rdparty/glsl-optimizer/src/glsl/lower_variable_index_to_cond_assign.cpp new file mode 100644 index 000000000..084a44767 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/lower_variable_index_to_cond_assign.cpp @@ -0,0 +1,536 @@ +/* + * Copyright © 2010 Luca Barbieri + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file lower_variable_index_to_cond_assign.cpp + * + * Turns non-constant indexing into array types to a series of + * conditional moves of each element into a temporary. + * + * Pre-DX10 GPUs often don't have a native way to do this operation, + * and this works around that. + * + * The lowering process proceeds as follows. Each non-constant index + * found in an r-value is converted to a canonical form \c array[i]. Each + * element of the array is conditionally assigned to a temporary by comparing + * \c i to a constant index. This is done by cloning the canonical form and + * replacing all occurances of \c i with a constant. Each remaining occurance + * of the canonical form in the IR is replaced with a dereference of the + * temporary variable. + * + * L-values with non-constant indices are handled similarly. In this case, + * the RHS of the assignment is assigned to a temporary. The non-constant + * index is replace with the canonical form (just like for r-values). The + * temporary is conditionally assigned to each element of the canonical form + * by comparing \c i with each index. The same clone-and-replace scheme is + * used. + */ + +#include "ir.h" +#include "ir_rvalue_visitor.h" +#include "ir_optimization.h" +#include "glsl_types.h" +#include "main/macros.h" + +/** + * Generate a comparison value for a block of indices + * + * Lowering passes for non-constant indexing of arrays, matrices, or vectors + * can use this to generate blocks of index comparison values. + * + * \param instructions List where new instructions will be appended + * \param index \c ir_variable containing the desired index + * \param base Base value for this block of comparisons + * \param components Number of unique index values to compare. This must + * be on the range [1, 4]. + * \param mem_ctx ralloc memory context to be used for all allocations. + * + * \returns + * An \c ir_rvalue that \b must be cloned for each use in conditional + * assignments, etc. + */ +ir_rvalue * +compare_index_block(exec_list *instructions, ir_variable *index, + unsigned base, unsigned components, void *mem_ctx) +{ + ir_rvalue *broadcast_index = new(mem_ctx) ir_dereference_variable(index); + + assert(index->type->is_scalar()); + assert(index->type->base_type == GLSL_TYPE_INT); + assert(components >= 1 && components <= 4); + + if (components > 1) { + const ir_swizzle_mask m = { 0, 0, 0, 0, components, false }; + broadcast_index = new(mem_ctx) ir_swizzle(broadcast_index, m); + } + + /* Compare the desired index value with the next block of four indices. + */ + ir_constant_data test_indices_data; + memset(&test_indices_data, 0, sizeof(test_indices_data)); + test_indices_data.i[0] = base; + test_indices_data.i[1] = base + 1; + test_indices_data.i[2] = base + 2; + test_indices_data.i[3] = base + 3; + + ir_constant *const test_indices = + new(mem_ctx) ir_constant(broadcast_index->type, + &test_indices_data); + + ir_rvalue *const condition_val = + new(mem_ctx) ir_expression(ir_binop_equal, + &glsl_type::bool_type[components - 1], + broadcast_index, + test_indices); + + ir_variable *const condition = + new(mem_ctx) ir_variable(condition_val->type, + "dereference_condition", + ir_var_temporary, precision_from_ir(condition_val)); + instructions->push_tail(condition); + + ir_rvalue *const cond_deref = + new(mem_ctx) ir_dereference_variable(condition); + instructions->push_tail(new(mem_ctx) ir_assignment(cond_deref, condition_val, 0)); + + return cond_deref; +} + +static inline bool +is_array_or_matrix(const ir_instruction *ir) +{ + return (ir->type->is_array() || ir->type->is_matrix()); +} + +/** + * Replace a dereference of a variable with a specified r-value + * + * Each time a dereference of the specified value is replaced, the r-value + * tree is cloned. + */ +class deref_replacer : public ir_rvalue_visitor { +public: + deref_replacer(const ir_variable *variable_to_replace, ir_rvalue *value) + : variable_to_replace(variable_to_replace), value(value), + progress(false) + { + assert(this->variable_to_replace != NULL); + assert(this->value != NULL); + } + + virtual void handle_rvalue(ir_rvalue **rvalue) + { + ir_dereference_variable *const dv = (*rvalue)->as_dereference_variable(); + + if ((dv != NULL) && (dv->var == this->variable_to_replace)) { + this->progress = true; + *rvalue = this->value->clone(ralloc_parent(*rvalue), NULL); + } + } + + const ir_variable *variable_to_replace; + ir_rvalue *value; + bool progress; +}; + +/** + * Find a variable index dereference of an array in an rvalue tree + */ +class find_variable_index : public ir_hierarchical_visitor { +public: + find_variable_index() + : deref(NULL) + { + /* empty */ + } + + virtual ir_visitor_status visit_enter(ir_dereference_array *ir) + { + if (is_array_or_matrix(ir->array) + && (ir->array_index->as_constant() == NULL)) { + this->deref = ir; + return visit_stop; + } + + return visit_continue; + } + + /** + * First array dereference found in the tree that has a non-constant index. + */ + ir_dereference_array *deref; +}; + +struct assignment_generator +{ + ir_instruction* base_ir; + ir_dereference *rvalue; + ir_variable *old_index; + bool is_write; + unsigned int write_mask; + ir_variable* var; + + assignment_generator() + { + } + + void generate(unsigned i, ir_rvalue* condition, exec_list *list) const + { + /* Just clone the rest of the deref chain when trying to get at the + * underlying variable. + */ + void *mem_ctx = ralloc_parent(base_ir); + + /* Clone the old r-value in its entirety. Then replace any occurances of + * the old variable index with the new constant index. + */ + ir_dereference *element = this->rvalue->clone(mem_ctx, NULL); + ir_constant *const index = new(mem_ctx) ir_constant(i); + deref_replacer r(this->old_index, index); + element->accept(&r); + assert(r.progress); + + /* Generate a conditional assignment to (or from) the constant indexed + * array dereference. + */ + ir_rvalue *variable = new(mem_ctx) ir_dereference_variable(this->var); + ir_assignment *const assignment = (is_write) + ? new(mem_ctx) ir_assignment(element, variable, condition, write_mask) + : new(mem_ctx) ir_assignment(variable, element, condition); + + list->push_tail(assignment); + } +}; + +struct switch_generator +{ + /* make TFunction a template parameter if you need to use other generators */ + typedef assignment_generator TFunction; + const TFunction& generator; + + ir_variable* index; + unsigned linear_sequence_max_length; + unsigned condition_components; + + void *mem_ctx; + + switch_generator(const TFunction& generator, ir_variable *index, + unsigned linear_sequence_max_length, + unsigned condition_components) + : generator(generator), index(index), + linear_sequence_max_length(linear_sequence_max_length), + condition_components(condition_components) + { + this->mem_ctx = ralloc_parent(index); + } + + void linear_sequence(unsigned begin, unsigned end, exec_list *list) + { + if (begin == end) + return; + + /* If the array access is a read, read the first element of this subregion + * unconditionally. The remaining tests will possibly overwrite this + * value with one of the other array elements. + * + * This optimization cannot be done for writes because it will cause the + * first element of the subregion to be written possibly *in addition* to + * one of the other elements. + */ + unsigned first; + if (!this->generator.is_write) { + this->generator.generate(begin, 0, list); + first = begin + 1; + } else { + first = begin; + } + + for (unsigned i = first; i < end; i += 4) { + const unsigned comps = MIN2(condition_components, end - i); + + ir_rvalue *const cond_deref = + compare_index_block(list, index, i, comps, this->mem_ctx); + + if (comps == 1) { + this->generator.generate(i, cond_deref->clone(this->mem_ctx, NULL), + list); + } else { + for (unsigned j = 0; j < comps; j++) { + ir_rvalue *const cond_swiz = + new(this->mem_ctx) ir_swizzle(cond_deref->clone(this->mem_ctx, NULL), + j, 0, 0, 0, 1); + + this->generator.generate(i + j, cond_swiz, list); + } + } + } + } + + void bisect(unsigned begin, unsigned end, exec_list *list) + { + unsigned middle = (begin + end) >> 1; + + assert(index->type->is_integer()); + + ir_constant *const middle_c = (index->type->base_type == GLSL_TYPE_UINT) + ? new(this->mem_ctx) ir_constant((unsigned)middle) + : new(this->mem_ctx) ir_constant((int)middle); + + + ir_dereference_variable *deref = + new(this->mem_ctx) ir_dereference_variable(this->index); + + ir_expression *less = + new(this->mem_ctx) ir_expression(ir_binop_less, glsl_type::bool_type, + deref, middle_c); + + ir_if *if_less = new(this->mem_ctx) ir_if(less); + + generate(begin, middle, &if_less->then_instructions); + generate(middle, end, &if_less->else_instructions); + + list->push_tail(if_less); + } + + void generate(unsigned begin, unsigned end, exec_list *list) + { + unsigned length = end - begin; + if (length <= this->linear_sequence_max_length) + return linear_sequence(begin, end, list); + else + return bisect(begin, end, list); + } +}; + +/** + * Visitor class for replacing expressions with ir_constant values. + */ + +class variable_index_to_cond_assign_visitor : public ir_rvalue_visitor { +public: + variable_index_to_cond_assign_visitor(bool lower_input, + bool lower_output, + bool lower_temp, + bool lower_uniform) + { + this->progress = false; + this->lower_inputs = lower_input; + this->lower_outputs = lower_output; + this->lower_temps = lower_temp; + this->lower_uniforms = lower_uniform; + } + + bool progress; + bool lower_inputs; + bool lower_outputs; + bool lower_temps; + bool lower_uniforms; + + bool storage_type_needs_lowering(ir_dereference_array *deref) const + { + /* If a variable isn't eventually the target of this dereference, then + * it must be a constant or some sort of anonymous temporary storage. + * + * FINISHME: Is this correct? Most drivers treat arrays of constants as + * FINISHME: uniforms. It seems like this should do the same. + */ + const ir_variable *const var = deref->array->variable_referenced(); + if (var == NULL) + return this->lower_temps; + + switch (var->mode) { + case ir_var_auto: + case ir_var_temporary: + return this->lower_temps; + case ir_var_uniform: + return this->lower_uniforms; + case ir_var_in: + case ir_var_const_in: + return (var->location == -1) ? this->lower_temps : this->lower_inputs; + case ir_var_out: + return (var->location == -1) ? this->lower_temps : this->lower_outputs; + case ir_var_inout: + return this->lower_temps; + } + + assert(!"Should not get here."); + return false; + } + + bool needs_lowering(ir_dereference_array *deref) const + { + if (deref == NULL || deref->array_index->as_constant() + || !is_array_or_matrix(deref->array)) + return false; + + return this->storage_type_needs_lowering(deref); + } + + ir_variable *convert_dereference_array(ir_dereference_array *orig_deref, + ir_assignment* orig_assign, + ir_dereference *orig_base) + { + assert(is_array_or_matrix(orig_deref->array)); + + const unsigned length = (orig_deref->array->type->is_array()) + ? orig_deref->array->type->length + : orig_deref->array->type->matrix_columns; + + void *const mem_ctx = ralloc_parent(base_ir); + + /* Temporary storage for either the result of the dereference of + * the array, or the RHS that's being assigned into the + * dereference of the array. + */ + ir_variable *var; + + if (orig_assign) { + var = new(mem_ctx) ir_variable(orig_assign->rhs->type, + "dereference_array_value", + ir_var_temporary, precision_from_ir(orig_deref)); + base_ir->insert_before(var); + + ir_dereference *lhs = new(mem_ctx) ir_dereference_variable(var); + ir_assignment *assign = new(mem_ctx) ir_assignment(lhs, + orig_assign->rhs, + NULL); + + base_ir->insert_before(assign); + } else { + var = new(mem_ctx) ir_variable(orig_deref->type, + "dereference_array_value", + ir_var_temporary, precision_from_ir(orig_deref)); + base_ir->insert_before(var); + } + + /* Store the index to a temporary to avoid reusing its tree. */ + ir_variable *index = + new(mem_ctx) ir_variable(orig_deref->array_index->type, + "dereference_array_index", ir_var_temporary, precision_from_ir(orig_deref->array_index)); + base_ir->insert_before(index); + + ir_dereference *lhs = new(mem_ctx) ir_dereference_variable(index); + ir_assignment *assign = + new(mem_ctx) ir_assignment(lhs, orig_deref->array_index, NULL); + base_ir->insert_before(assign); + + orig_deref->array_index = lhs->clone(mem_ctx, NULL); + + assignment_generator ag; + ag.rvalue = orig_base; + ag.base_ir = base_ir; + ag.old_index = index; + ag.var = var; + if (orig_assign) { + ag.is_write = true; + ag.write_mask = orig_assign->write_mask; + } else { + ag.is_write = false; + } + + switch_generator sg(ag, index, 4, 4); + + /* If the original assignment has a condition, respect that original + * condition! This is acomplished by wrapping the new conditional + * assignments in an if-statement that uses the original condition. + */ + if ((orig_assign != NULL) && (orig_assign->condition != NULL)) { + /* No need to clone the condition because the IR that it hangs on is + * going to be removed from the instruction sequence. + */ + ir_if *if_stmt = new(mem_ctx) ir_if(orig_assign->condition); + + sg.generate(0, length, &if_stmt->then_instructions); + base_ir->insert_before(if_stmt); + } else { + exec_list list; + + sg.generate(0, length, &list); + base_ir->insert_before(&list); + } + + return var; + } + + virtual void handle_rvalue(ir_rvalue **pir) + { + if (this->in_assignee) + return; + + if (!*pir) + return; + + ir_dereference_array* orig_deref = (*pir)->as_dereference_array(); + if (needs_lowering(orig_deref)) { + ir_variable *var = + convert_dereference_array(orig_deref, NULL, orig_deref); + assert(var); + *pir = new(ralloc_parent(base_ir)) ir_dereference_variable(var); + this->progress = true; + } + } + + ir_visitor_status + visit_leave(ir_assignment *ir) + { + ir_rvalue_visitor::visit_leave(ir); + + find_variable_index f; + ir->lhs->accept(&f); + + if ((f.deref != NULL) && storage_type_needs_lowering(f.deref)) { + convert_dereference_array(f.deref, ir, ir->lhs); + ir->remove(); + this->progress = true; + } + + return visit_continue; + } +}; + +bool +lower_variable_index_to_cond_assign(exec_list *instructions, + bool lower_input, + bool lower_output, + bool lower_temp, + bool lower_uniform) +{ + variable_index_to_cond_assign_visitor v(lower_input, + lower_output, + lower_temp, + lower_uniform); + + /* Continue lowering until no progress is made. If there are multiple + * levels of indirection (e.g., non-constant indexing of array elements and + * matrix columns of an array of matrix), each pass will only lower one + * level of indirection. + */ + bool progress_ever = false; + do { + v.progress = false; + visit_list_elements(&v, instructions); + progress_ever = v.progress || progress_ever; + } while (v.progress); + + return progress_ever; +} diff --git a/3rdparty/glsl-optimizer/src/glsl/lower_vec_index_to_cond_assign.cpp b/3rdparty/glsl-optimizer/src/glsl/lower_vec_index_to_cond_assign.cpp new file mode 100644 index 000000000..679a4f730 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/lower_vec_index_to_cond_assign.cpp @@ -0,0 +1,293 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file lower_vec_index_to_cond_assign.cpp + * + * Turns indexing into vector types to a series of conditional moves + * of each channel's swizzle into a temporary. + * + * Most GPUs don't have a native way to do this operation, and this + * works around that. For drivers using both this pass and + * ir_vec_index_to_swizzle, there's a risk that this pass will happen + * before sufficient constant folding to find that the array index is + * constant. However, we hope that other optimization passes, + * particularly constant folding of assignment conditions and copy + * propagation, will result in the same code in the end. + */ + +#include "ir.h" +#include "ir_visitor.h" +#include "ir_optimization.h" +#include "glsl_types.h" + +/** + * Visitor class for replacing expressions with ir_constant values. + */ + +class ir_vec_index_to_cond_assign_visitor : public ir_hierarchical_visitor { +public: + ir_vec_index_to_cond_assign_visitor() + { + progress = false; + } + + ir_rvalue *convert_vec_index_to_cond_assign(ir_rvalue *val); + + virtual ir_visitor_status visit_enter(ir_expression *); + virtual ir_visitor_status visit_enter(ir_swizzle *); + virtual ir_visitor_status visit_leave(ir_assignment *); + virtual ir_visitor_status visit_enter(ir_return *); + virtual ir_visitor_status visit_enter(ir_call *); + virtual ir_visitor_status visit_enter(ir_if *); + + bool progress; +}; + +ir_rvalue * +ir_vec_index_to_cond_assign_visitor::convert_vec_index_to_cond_assign(ir_rvalue *ir) +{ + ir_dereference_array *orig_deref = ir->as_dereference_array(); + ir_assignment *assign; + ir_variable *index, *var; + ir_dereference *deref; + int i; + + if (!orig_deref) + return ir; + + if (orig_deref->array->type->is_matrix() || + orig_deref->array->type->is_array()) + return ir; + + void *mem_ctx = ralloc_parent(ir); + + assert(orig_deref->array_index->type->base_type == GLSL_TYPE_INT); + + exec_list list; + + /* Store the index to a temporary to avoid reusing its tree. */ + index = new(base_ir) ir_variable(glsl_type::int_type, + "vec_index_tmp_i", + ir_var_temporary, glsl_precision_undefined); + list.push_tail(index); + deref = new(base_ir) ir_dereference_variable(index); + assign = new(base_ir) ir_assignment(deref, orig_deref->array_index, NULL); + list.push_tail(assign); + + /* Temporary where we store whichever value we swizzle out. */ + var = new(base_ir) ir_variable(ir->type, "vec_index_tmp_v", + ir_var_temporary, precision_from_ir(ir)); + list.push_tail(var); + + /* Generate a single comparison condition "mask" for all of the components + * in the vector. + */ + ir_rvalue *const cond_deref = + compare_index_block(&list, index, 0, + orig_deref->array->type->vector_elements, + mem_ctx); + + /* Generate a conditional move of each vector element to the temp. */ + for (i = 0; i < orig_deref->array->type->vector_elements; i++) { + ir_rvalue *condition_swizzle = + new(base_ir) ir_swizzle(cond_deref->clone(ir, NULL), i, 0, 0, 0, 1); + + /* Just clone the rest of the deref chain when trying to get at the + * underlying variable. + */ + ir_rvalue *swizzle = + new(base_ir) ir_swizzle(orig_deref->array->clone(mem_ctx, NULL), + i, 0, 0, 0, 1); + + deref = new(base_ir) ir_dereference_variable(var); + assign = new(base_ir) ir_assignment(deref, swizzle, condition_swizzle); + list.push_tail(assign); + } + + /* Put all of the new instructions in the IR stream before the old + * instruction. + */ + base_ir->insert_before(&list); + + this->progress = true; + return new(base_ir) ir_dereference_variable(var); +} + +ir_visitor_status +ir_vec_index_to_cond_assign_visitor::visit_enter(ir_expression *ir) +{ + unsigned int i; + + for (i = 0; i < ir->get_num_operands(); i++) { + ir->operands[i] = convert_vec_index_to_cond_assign(ir->operands[i]); + } + + return visit_continue; +} + +ir_visitor_status +ir_vec_index_to_cond_assign_visitor::visit_enter(ir_swizzle *ir) +{ + /* Can't be hit from normal GLSL, since you can't swizzle a scalar (which + * the result of indexing a vector is. But maybe at some point we'll end up + * using swizzling of scalars for vector construction. + */ + ir->val = convert_vec_index_to_cond_assign(ir->val); + + return visit_continue; +} + +ir_visitor_status +ir_vec_index_to_cond_assign_visitor::visit_leave(ir_assignment *ir) +{ + ir_variable *index, *var; + ir_dereference_variable *deref; + ir_assignment *assign; + int i; + + ir->rhs = convert_vec_index_to_cond_assign(ir->rhs); + if (ir->condition) + ir->condition = convert_vec_index_to_cond_assign(ir->condition); + + /* Last, handle the LHS */ + ir_dereference_array *orig_deref = ir->lhs->as_dereference_array(); + + if (!orig_deref || + orig_deref->array->type->is_matrix() || + orig_deref->array->type->is_array()) + return visit_continue; + + void *mem_ctx = ralloc_parent(ir); + + assert(orig_deref->array_index->type->base_type == GLSL_TYPE_INT); + + exec_list list; + + /* Store the index to a temporary to avoid reusing its tree. */ + index = new(ir) ir_variable(glsl_type::int_type, "vec_index_tmp_i", + ir_var_temporary, glsl_precision_undefined); + list.push_tail(index); + deref = new(ir) ir_dereference_variable(index); + assign = new(ir) ir_assignment(deref, orig_deref->array_index, NULL); + list.push_tail(assign); + + /* Store the RHS to a temporary to avoid reusing its tree. */ + var = new(ir) ir_variable(ir->rhs->type, "vec_index_tmp_v", + ir_var_temporary, precision_from_ir(ir->rhs)); + list.push_tail(var); + deref = new(ir) ir_dereference_variable(var); + assign = new(ir) ir_assignment(deref, ir->rhs, NULL); + list.push_tail(assign); + + /* Generate a single comparison condition "mask" for all of the components + * in the vector. + */ + ir_rvalue *const cond_deref = + compare_index_block(&list, index, 0, + orig_deref->array->type->vector_elements, + mem_ctx); + + /* Generate a conditional move of each vector element to the temp. */ + for (i = 0; i < orig_deref->array->type->vector_elements; i++) { + ir_rvalue *condition_swizzle = + new(ir) ir_swizzle(cond_deref->clone(ir, NULL), i, 0, 0, 0, 1); + + + /* Just clone the rest of the deref chain when trying to get at the + * underlying variable. + */ + ir_rvalue *swizzle = + new(ir) ir_swizzle(orig_deref->array->clone(mem_ctx, NULL), + i, 0, 0, 0, 1); + + deref = new(ir) ir_dereference_variable(var); + assign = new(ir) ir_assignment(swizzle, deref, condition_swizzle); + list.push_tail(assign); + } + + /* If the original assignment has a condition, respect that original + * condition! This is acomplished by wrapping the new conditional + * assignments in an if-statement that uses the original condition. + */ + if (ir->condition != NULL) { + /* No need to clone the condition because the IR that it hangs on is + * going to be removed from the instruction sequence. + */ + ir_if *if_stmt = new(mem_ctx) ir_if(ir->condition); + + list.move_nodes_to(&if_stmt->then_instructions); + ir->insert_before(if_stmt); + } else { + ir->insert_before(&list); + } + + ir->remove(); + + this->progress = true; + + return visit_continue; +} + +ir_visitor_status +ir_vec_index_to_cond_assign_visitor::visit_enter(ir_call *ir) +{ + foreach_iter(exec_list_iterator, iter, *ir) { + ir_rvalue *param = (ir_rvalue *)iter.get(); + ir_rvalue *new_param = convert_vec_index_to_cond_assign(param); + + if (new_param != param) { + param->replace_with(new_param); + } + } + + return visit_continue; +} + +ir_visitor_status +ir_vec_index_to_cond_assign_visitor::visit_enter(ir_return *ir) +{ + if (ir->value) { + ir->value = convert_vec_index_to_cond_assign(ir->value); + } + + return visit_continue; +} + +ir_visitor_status +ir_vec_index_to_cond_assign_visitor::visit_enter(ir_if *ir) +{ + ir->condition = convert_vec_index_to_cond_assign(ir->condition); + + return visit_continue; +} + +bool +do_vec_index_to_cond_assign(exec_list *instructions) +{ + ir_vec_index_to_cond_assign_visitor v; + + visit_list_elements(&v, instructions); + + return v.progress; +} diff --git a/3rdparty/glsl-optimizer/src/glsl/lower_vec_index_to_swizzle.cpp b/3rdparty/glsl-optimizer/src/glsl/lower_vec_index_to_swizzle.cpp new file mode 100644 index 000000000..c7630c28a --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/lower_vec_index_to_swizzle.cpp @@ -0,0 +1,157 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file lower_vec_index_to_swizzle.cpp + * + * Turns constant indexing into vector types to swizzles. This will + * let other swizzle-aware optimization passes catch these constructs, + * and codegen backends not have to worry about this case. + */ + +#include "ir.h" +#include "ir_visitor.h" +#include "ir_optimization.h" +#include "glsl_types.h" + +/** + * Visitor class for replacing expressions with ir_constant values. + */ + +class ir_vec_index_to_swizzle_visitor : public ir_hierarchical_visitor { +public: + ir_vec_index_to_swizzle_visitor() + { + progress = false; + } + + ir_rvalue *convert_vec_index_to_swizzle(ir_rvalue *val); + + virtual ir_visitor_status visit_enter(ir_expression *); + virtual ir_visitor_status visit_enter(ir_swizzle *); + virtual ir_visitor_status visit_enter(ir_assignment *); + virtual ir_visitor_status visit_enter(ir_return *); + virtual ir_visitor_status visit_enter(ir_call *); + virtual ir_visitor_status visit_enter(ir_if *); + + bool progress; +}; + +ir_rvalue * +ir_vec_index_to_swizzle_visitor::convert_vec_index_to_swizzle(ir_rvalue *ir) +{ + ir_dereference_array *deref = ir->as_dereference_array(); + ir_constant *ir_constant; + + if (!deref) + return ir; + + if (deref->array->type->is_matrix() || deref->array->type->is_array()) + return ir; + + assert(deref->array_index->type->base_type == GLSL_TYPE_INT); + ir_constant = deref->array_index->constant_expression_value(); + if (!ir_constant) + return ir; + + void *ctx = ralloc_parent(ir); + this->progress = true; + return new(ctx) ir_swizzle(deref->array, + ir_constant->value.i[0], 0, 0, 0, 1); +} + +ir_visitor_status +ir_vec_index_to_swizzle_visitor::visit_enter(ir_expression *ir) +{ + unsigned int i; + + for (i = 0; i < ir->get_num_operands(); i++) { + ir->operands[i] = convert_vec_index_to_swizzle(ir->operands[i]); + } + + return visit_continue; +} + +ir_visitor_status +ir_vec_index_to_swizzle_visitor::visit_enter(ir_swizzle *ir) +{ + /* Can't be hit from normal GLSL, since you can't swizzle a scalar (which + * the result of indexing a vector is. But maybe at some point we'll end up + * using swizzling of scalars for vector construction. + */ + ir->val = convert_vec_index_to_swizzle(ir->val); + + return visit_continue; +} + +ir_visitor_status +ir_vec_index_to_swizzle_visitor::visit_enter(ir_assignment *ir) +{ + ir->set_lhs(convert_vec_index_to_swizzle(ir->lhs)); + ir->rhs = convert_vec_index_to_swizzle(ir->rhs); + + return visit_continue; +} + +ir_visitor_status +ir_vec_index_to_swizzle_visitor::visit_enter(ir_call *ir) +{ + foreach_iter(exec_list_iterator, iter, *ir) { + ir_rvalue *param = (ir_rvalue *)iter.get(); + ir_rvalue *new_param = convert_vec_index_to_swizzle(param); + + if (new_param != param) { + param->replace_with(new_param); + } + } + + return visit_continue; +} + +ir_visitor_status +ir_vec_index_to_swizzle_visitor::visit_enter(ir_return *ir) +{ + if (ir->value) { + ir->value = convert_vec_index_to_swizzle(ir->value); + } + + return visit_continue; +} + +ir_visitor_status +ir_vec_index_to_swizzle_visitor::visit_enter(ir_if *ir) +{ + ir->condition = convert_vec_index_to_swizzle(ir->condition); + + return visit_continue; +} + +bool +do_vec_index_to_swizzle(exec_list *instructions) +{ + ir_vec_index_to_swizzle_visitor v; + + v.run(instructions); + + return v.progress; +} diff --git a/3rdparty/glsl-optimizer/src/glsl/lower_vector.cpp b/3rdparty/glsl-optimizer/src/glsl/lower_vector.cpp new file mode 100644 index 000000000..d989ba7fb --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/lower_vector.cpp @@ -0,0 +1,224 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file lower_vector.cpp + * IR lowering pass to remove some types of ir_quadop_vector + * + * \author Ian Romanick + */ + +#include "ir.h" +#include "ir_rvalue_visitor.h" + +class lower_vector_visitor : public ir_rvalue_visitor { +public: + lower_vector_visitor() : progress(false) + { + /* empty */ + } + + void handle_rvalue(ir_rvalue **rvalue); + + /** + * Should SWZ-like expressions be lowered? + */ + bool dont_lower_swz; + + bool progress; +}; + +/** + * Determine if an IR expression tree looks like an extended swizzle + * + * Extended swizzles consist of access of a single vector source (with possible + * per component negation) and the constants -1, 0, or 1. + */ +bool +is_extended_swizzle(ir_expression *ir) +{ + /* Track any variables that are accessed by this expression. + */ + ir_variable *var = NULL; + + assert(ir->operation == ir_quadop_vector); + + for (unsigned i = 0; i < ir->type->vector_elements; i++) { + ir_rvalue *op = ir->operands[i]; + + while (op != NULL) { + switch (op->ir_type) { + case ir_type_constant: { + const ir_constant *const c = op->as_constant(); + + if (!c->is_one() && !c->is_zero() && !c->is_negative_one()) + return false; + + op = NULL; + break; + } + + case ir_type_dereference_variable: { + ir_dereference_variable *const d = (ir_dereference_variable *) op; + + if ((var != NULL) && (var != d->var)) + return false; + + var = d->var; + op = NULL; + break; + } + + case ir_type_expression: { + ir_expression *const ex = (ir_expression *) op; + + if (ex->operation != ir_unop_neg) + return false; + + op = ex->operands[0]; + break; + } + + case ir_type_swizzle: + op = ((ir_swizzle *) op)->val; + break; + + default: + return false; + } + } + } + + return true; +} + +void +lower_vector_visitor::handle_rvalue(ir_rvalue **rvalue) +{ + if (!*rvalue) + return; + + ir_expression *expr = (*rvalue)->as_expression(); + if ((expr == NULL) || (expr->operation != ir_quadop_vector)) + return; + + if (this->dont_lower_swz && is_extended_swizzle(expr)) + return; + + /* FINISHME: Is this the right thing to use for the ralloc context? + */ + void *const mem_ctx = expr; + + assert(expr->type->vector_elements == expr->get_num_operands()); + + /* Generate a temporary with the same type as the ir_quadop_operation. + */ + ir_variable *const temp = + new(mem_ctx) ir_variable(expr->type, "vecop_tmp", ir_var_temporary, precision_from_ir(expr)); + + this->base_ir->insert_before(temp); + + /* Counter of the number of components collected so far. + */ + unsigned assigned; + + /* Write-mask in the destination that receives counted by 'assigned'. + */ + unsigned write_mask; + + + /* Generate upto four assignments to that variable. Try to group component + * assignments together: + * + * - All constant components can be assigned at once. + * - All assigments of components from a single variable with the same + * unary operator can be assigned at once. + */ + ir_constant_data d = { { 0 } }; + + assigned = 0; + write_mask = 0; + for (unsigned i = 0; i < expr->type->vector_elements; i++) { + const ir_constant *const c = expr->operands[i]->as_constant(); + + if (c == NULL) + continue; + + switch (expr->type->base_type) { + case GLSL_TYPE_UINT: d.u[assigned] = c->value.u[0]; break; + case GLSL_TYPE_INT: d.i[assigned] = c->value.i[0]; break; + case GLSL_TYPE_FLOAT: d.f[assigned] = c->value.f[0]; break; + case GLSL_TYPE_BOOL: d.b[assigned] = c->value.b[0]; break; + default: assert(!"Should not get here."); break; + } + + write_mask |= (1U << i); + assigned++; + } + + assert((write_mask == 0) == (assigned == 0)); + + /* If there were constant values, generate an assignment. + */ + if (assigned > 0) { + ir_constant *const c = + new(mem_ctx) ir_constant(glsl_type::get_instance(expr->type->base_type, + assigned, 0), + &d); + ir_dereference *const lhs = new(mem_ctx) ir_dereference_variable(temp); + ir_assignment *const assign = + new(mem_ctx) ir_assignment(lhs, c, NULL, write_mask); + + this->base_ir->insert_before(assign); + } + + /* FINISHME: This should try to coalesce assignments. + */ + for (unsigned i = 0; i < expr->type->vector_elements; i++) { + if (expr->operands[i]->ir_type == ir_type_constant) + continue; + + ir_dereference *const lhs = new(mem_ctx) ir_dereference_variable(temp); + ir_assignment *const assign = + new(mem_ctx) ir_assignment(lhs, expr->operands[i], NULL, (1U << i)); + + this->base_ir->insert_before(assign); + assigned++; + } + + assert(assigned == expr->type->vector_elements); + + *rvalue = new(mem_ctx) ir_dereference_variable(temp); + this->progress = true; +} + +bool +lower_quadop_vector(exec_list *instructions, bool dont_lower_swz) +{ + lower_vector_visitor v; + + v.dont_lower_swz = dont_lower_swz; + visit_list_elements(&v, instructions); + + return v.progress; +} diff --git a/3rdparty/glsl-optimizer/src/glsl/main.cpp b/3rdparty/glsl-optimizer/src/glsl/main.cpp new file mode 100644 index 000000000..9b8a50738 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/main.cpp @@ -0,0 +1,282 @@ +/* + * Copyright © 2008, 2009 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +#include + +#include "ast.h" +#include "glsl_parser_extras.h" +#include "glsl_parser.h" +#include "ir_optimization.h" +#include "ir_print_visitor.h" +#include "program.h" +#include "loop_analysis.h" +#include "standalone_scaffolding.h" + +static void +initialize_context(struct gl_context *ctx, gl_api api) +{ + initialize_context_to_defaults(ctx, api); + + /* GLSL 1.30 isn't fully supported, but we need to advertise 1.30 so that + * the built-in functions for 1.30 can be built. + */ + ctx->Const.GLSLVersion = 130; + + ctx->Const.MaxClipPlanes = 8; + ctx->Const.MaxDrawBuffers = 2; + + /* More than the 1.10 minimum to appease parser tests taken from + * apps that (hopefully) already checked the number of coords. + */ + ctx->Const.MaxTextureCoordUnits = 4; + + ctx->Driver.NewShader = _mesa_new_shader; +} + +/* Returned string will have 'ctx' as its ralloc owner. */ +static char * +load_text_file(void *ctx, const char *file_name) +{ + char *text = NULL; + size_t size; + size_t total_read = 0; + FILE *fp = fopen(file_name, "rb"); + + if (!fp) { + return NULL; + } + + fseek(fp, 0L, SEEK_END); + size = ftell(fp); + fseek(fp, 0L, SEEK_SET); + + text = (char *) ralloc_size(ctx, size + 1); + if (text != NULL) { + do { + size_t bytes = fread(text + total_read, + 1, size - total_read, fp); + if (bytes < size - total_read) { + free(text); + text = NULL; + break; + } + + if (bytes == 0) { + break; + } + + total_read += bytes; + } while (total_read < size); + + text[total_read] = '\0'; + } + + fclose(fp); + + return text; +} + +int glsl_es = 0; +int dump_ast = 0; +int dump_hir = 0; +int dump_lir = 0; +int do_link = 0; + +const struct option compiler_opts[] = { + { "glsl-es", 0, &glsl_es, 1 }, + { "dump-ast", 0, &dump_ast, 1 }, + { "dump-hir", 0, &dump_hir, 1 }, + { "dump-lir", 0, &dump_lir, 1 }, + { "link", 0, &do_link, 1 }, + { NULL, 0, NULL, 0 } +}; + +/** + * \brief Print proper usage and exit with failure. + */ +void +usage_fail(const char *name) +{ + + const char *header = + "usage: %s [options] \n" + "\n" + "Possible options are:\n"; + printf(header, name, name); + for (const struct option *o = compiler_opts; o->name != 0; ++o) { + printf(" --%s\n", o->name); + } + exit(EXIT_FAILURE); +} + + +void +compile_shader(struct gl_context *ctx, struct gl_shader *shader) +{ + struct _mesa_glsl_parse_state *state = + new(shader) _mesa_glsl_parse_state(ctx, shader->Type, shader); + + const char *source = shader->Source; + state->error = preprocess(state, &source, &state->info_log, + state->extensions, ctx->API) != 0; + + if (!state->error) { + _mesa_glsl_lexer_ctor(state, source); + _mesa_glsl_parse(state); + _mesa_glsl_lexer_dtor(state); + } + + if (dump_ast) { + foreach_list_const(n, &state->translation_unit) { + ast_node *ast = exec_node_data(ast_node, n, link); + ast->print(); + } + printf("\n\n"); + } + + shader->ir = new(shader) exec_list; + if (!state->error && !state->translation_unit.is_empty()) + _mesa_ast_to_hir(shader->ir, state); + + /* Print out the unoptimized IR. */ + if (!state->error && dump_hir) { + validate_ir_tree(shader->ir); + _mesa_print_ir(shader->ir, state); + } + + /* Optimization passes */ + if (!state->error && !shader->ir->is_empty()) { + bool progress; + do { + progress = do_common_optimization(shader->ir, false, 32); + } while (progress); + + validate_ir_tree(shader->ir); + } + + + /* Print out the resulting IR */ + if (!state->error && dump_lir) { + _mesa_print_ir(shader->ir, state); + } + + shader->symbols = state->symbols; + shader->CompileStatus = !state->error; + shader->Version = state->language_version; + memcpy(shader->builtins_to_link, state->builtins_to_link, + sizeof(shader->builtins_to_link[0]) * state->num_builtins_to_link); + shader->num_builtins_to_link = state->num_builtins_to_link; + + if (shader->InfoLog) + ralloc_free(shader->InfoLog); + + shader->InfoLog = state->info_log; + + /* Retain any live IR, but trash the rest. */ + reparent_ir(shader->ir, shader); + + ralloc_free(state); + + return; +} + +int +main(int argc, char **argv) +{ + int status = EXIT_SUCCESS; + struct gl_context local_ctx; + struct gl_context *ctx = &local_ctx; + + int c; + int idx = 0; + while ((c = getopt_long(argc, argv, "", compiler_opts, &idx)) != -1) + /* empty */ ; + + + if (argc <= optind) + usage_fail(argv[0]); + + initialize_context(ctx, (glsl_es) ? API_OPENGLES2 : API_OPENGL); + + struct gl_shader_program *whole_program; + + whole_program = rzalloc (NULL, struct gl_shader_program); + assert(whole_program != NULL); + whole_program->InfoLog = ralloc_strdup(whole_program, ""); + + for (/* empty */; argc > optind; optind++) { + whole_program->Shaders = + reralloc(whole_program, whole_program->Shaders, + struct gl_shader *, whole_program->NumShaders + 1); + assert(whole_program->Shaders != NULL); + + struct gl_shader *shader = rzalloc(whole_program, gl_shader); + + whole_program->Shaders[whole_program->NumShaders] = shader; + whole_program->NumShaders++; + + const unsigned len = strlen(argv[optind]); + if (len < 6) + usage_fail(argv[0]); + + const char *const ext = & argv[optind][len - 5]; + if (strncmp(".vert", ext, 5) == 0) + shader->Type = GL_VERTEX_SHADER; + else if (strncmp(".geom", ext, 5) == 0) + shader->Type = GL_GEOMETRY_SHADER; + else if (strncmp(".frag", ext, 5) == 0) + shader->Type = GL_FRAGMENT_SHADER; + else + usage_fail(argv[0]); + + shader->Source = load_text_file(whole_program, argv[optind]); + if (shader->Source == NULL) { + printf("File \"%s\" does not exist.\n", argv[optind]); + exit(EXIT_FAILURE); + } + + compile_shader(ctx, shader); + + if (!shader->CompileStatus) { + printf("Info log for %s:\n%s\n", argv[optind], shader->InfoLog); + status = EXIT_FAILURE; + break; + } + } + + if ((status == EXIT_SUCCESS) && do_link) { + link_shaders(ctx, whole_program); + status = (whole_program->LinkStatus) ? EXIT_SUCCESS : EXIT_FAILURE; + + if (strlen(whole_program->InfoLog) > 0) + printf("Info log for linking:\n%s\n", whole_program->InfoLog); + } + + for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) + ralloc_free(whole_program->_LinkedShaders[i]); + + ralloc_free(whole_program); + _mesa_glsl_release_types(); + _mesa_glsl_release_functions(); + + return status; +} diff --git a/3rdparty/glsl-optimizer/src/glsl/msvc/.gitignore b/3rdparty/glsl-optimizer/src/glsl/msvc/.gitignore new file mode 100644 index 000000000..38b542c10 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/msvc/.gitignore @@ -0,0 +1,4 @@ +*.ncb +*.user +*.suo +build \ No newline at end of file diff --git a/3rdparty/glsl-optimizer/src/glsl/msvc/mesaglsl2.sln b/3rdparty/glsl-optimizer/src/glsl/msvc/mesaglsl2.sln new file mode 100644 index 000000000..013674f4f --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/msvc/mesaglsl2.sln @@ -0,0 +1,29 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mesaglsl2", "mesaglsl2.vcproj", "{B475A403-9D9B-410D-8A93-BA49FC4DD811}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "glsl_optimizer_tests", "..\..\..\tests\glsl_optimizer_tests.vcproj", "{BB382242-6EBB-445F-989C-B9BA61D17965}" + ProjectSection(ProjectDependencies) = postProject + {B475A403-9D9B-410D-8A93-BA49FC4DD811} = {B475A403-9D9B-410D-8A93-BA49FC4DD811} + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B475A403-9D9B-410D-8A93-BA49FC4DD811}.Debug|Win32.ActiveCfg = Debug|Win32 + {B475A403-9D9B-410D-8A93-BA49FC4DD811}.Debug|Win32.Build.0 = Debug|Win32 + {B475A403-9D9B-410D-8A93-BA49FC4DD811}.Release|Win32.ActiveCfg = Release|Win32 + {B475A403-9D9B-410D-8A93-BA49FC4DD811}.Release|Win32.Build.0 = Release|Win32 + {BB382242-6EBB-445F-989C-B9BA61D17965}.Debug|Win32.ActiveCfg = Debug|Win32 + {BB382242-6EBB-445F-989C-B9BA61D17965}.Debug|Win32.Build.0 = Debug|Win32 + {BB382242-6EBB-445F-989C-B9BA61D17965}.Release|Win32.ActiveCfg = Release|Win32 + {BB382242-6EBB-445F-989C-B9BA61D17965}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/3rdparty/glsl-optimizer/src/glsl/msvc/mesaglsl2.vcproj b/3rdparty/glsl-optimizer/src/glsl/msvc/mesaglsl2.vcproj new file mode 100644 index 000000000..28bd2ad47 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/msvc/mesaglsl2.vcproj @@ -0,0 +1,773 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/3rdparty/glsl-optimizer/src/glsl/opt_algebraic.cpp b/3rdparty/glsl-optimizer/src/glsl/opt_algebraic.cpp new file mode 100644 index 000000000..252a1125e --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/opt_algebraic.cpp @@ -0,0 +1,429 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file opt_algebraic.cpp + * + * Takes advantage of association, commutivity, and other algebraic + * properties to simplify expressions. + */ + +#include "ir.h" +#include "ir_visitor.h" +#include "ir_rvalue_visitor.h" +#include "ir_optimization.h" +#include "glsl_types.h" + +/** + * Visitor class for replacing expressions with ir_constant values. + */ + +class ir_algebraic_visitor : public ir_rvalue_visitor { +public: + ir_algebraic_visitor() + { + this->progress = false; + this->mem_ctx = NULL; + } + + virtual ~ir_algebraic_visitor() + { + } + + ir_rvalue *handle_expression(ir_expression *ir); + void handle_rvalue(ir_rvalue **rvalue); + bool reassociate_constant(ir_expression *ir1, + int const_index, + ir_constant *constant, + ir_expression *ir2); + void reassociate_operands(ir_expression *ir1, + int op1, + ir_expression *ir2, + int op2); + ir_rvalue *swizzle_if_required(ir_expression *expr, + ir_rvalue *operand); + + void *mem_ctx; + + bool progress; +}; + +static inline bool +is_vec_zero(ir_constant *ir) +{ + return (ir == NULL) ? false : ir->is_zero(); +} + +static inline bool +is_vec_one(ir_constant *ir) +{ + return (ir == NULL) ? false : ir->is_one(); +} + +static void +update_type(ir_expression *ir) +{ + if (ir->operands[0]->type->is_vector()) + { + ir->type = ir->operands[0]->type; + ir->set_precision (ir->operands[0]->get_precision()); + } + else + { + ir->type = ir->operands[1]->type; + ir->set_precision (ir->operands[1]->get_precision()); + } +} + +void +ir_algebraic_visitor::reassociate_operands(ir_expression *ir1, + int op1, + ir_expression *ir2, + int op2) +{ + ir_rvalue *temp = ir2->operands[op2]; + ir2->operands[op2] = ir1->operands[op1]; + ir1->operands[op1] = temp; + + /* Update the type of ir2. The type of ir1 won't have changed -- + * base types matched, and at least one of the operands of the 2 + * binops is still a vector if any of them were. + */ + update_type(ir2); + + this->progress = true; +} + +/** + * Reassociates a constant down a tree of adds or multiplies. + * + * Consider (2 * (a * (b * 0.5))). We want to send up with a * b. + */ +bool +ir_algebraic_visitor::reassociate_constant(ir_expression *ir1, int const_index, + ir_constant *constant, + ir_expression *ir2) +{ + if (!ir2 || ir1->operation != ir2->operation) + return false; + + /* Don't want to even think about matrices. */ + if (ir1->operands[0]->type->is_matrix() || + ir1->operands[1]->type->is_matrix() || + ir2->operands[0]->type->is_matrix() || + ir2->operands[1]->type->is_matrix()) + return false; + + ir_constant *ir2_const[2]; + ir2_const[0] = ir2->operands[0]->constant_expression_value(); + ir2_const[1] = ir2->operands[1]->constant_expression_value(); + + if (ir2_const[0] && ir2_const[1]) + return false; + + if (ir2_const[0]) { + reassociate_operands(ir1, const_index, ir2, 1); + return true; + } else if (ir2_const[1]) { + reassociate_operands(ir1, const_index, ir2, 0); + return true; + } + + if (reassociate_constant(ir1, const_index, constant, + ir2->operands[0]->as_expression())) { + update_type(ir2); + return true; + } + + if (reassociate_constant(ir1, const_index, constant, + ir2->operands[1]->as_expression())) { + update_type(ir2); + return true; + } + + return false; +} + +/* When eliminating an expression and just returning one of its operands, + * we may need to swizzle that operand out to a vector if the expression was + * vector type. + */ +ir_rvalue * +ir_algebraic_visitor::swizzle_if_required(ir_expression *expr, + ir_rvalue *operand) +{ + if (expr->type->is_vector() && operand->type->is_scalar()) { + return new(mem_ctx) ir_swizzle(operand, 0, 0, 0, 0, + expr->type->vector_elements); + } else + return operand; +} + +ir_rvalue * +ir_algebraic_visitor::handle_expression(ir_expression *ir) +{ + ir_constant *op_const[2] = {NULL, NULL}; + ir_expression *op_expr[2] = {NULL, NULL}; + ir_expression *temp; + unsigned int i; + + assert(ir->get_num_operands() <= 2); + for (i = 0; i < ir->get_num_operands(); i++) { + if (ir->operands[i]->type->is_matrix()) + return ir; + + op_const[i] = ir->operands[i]->constant_expression_value(); + op_expr[i] = ir->operands[i]->as_expression(); + } + + if (this->mem_ctx == NULL) + this->mem_ctx = ralloc_parent(ir); + + switch (ir->operation) { + case ir_unop_logic_not: { + enum ir_expression_operation new_op = ir_unop_logic_not; + + if (op_expr[0] == NULL) + break; + + switch (op_expr[0]->operation) { + case ir_binop_less: new_op = ir_binop_gequal; break; + case ir_binop_greater: new_op = ir_binop_lequal; break; + case ir_binop_lequal: new_op = ir_binop_greater; break; + case ir_binop_gequal: new_op = ir_binop_less; break; + case ir_binop_equal: new_op = ir_binop_nequal; break; + case ir_binop_nequal: new_op = ir_binop_equal; break; + case ir_binop_all_equal: new_op = ir_binop_any_nequal; break; + case ir_binop_any_nequal: new_op = ir_binop_all_equal; break; + + default: + /* The default case handler is here to silence a warning from GCC. + */ + break; + } + + if (new_op != ir_unop_logic_not) { + this->progress = true; + return new(mem_ctx) ir_expression(new_op, + ir->type, + op_expr[0]->operands[0], + op_expr[0]->operands[1]); + } + + break; + } + + case ir_unop_neg: { + if (op_expr[0] && op_expr[0]->operation == ir_binop_sub) { + // -(A-B) => (B-A) + this->progress = true; + return new(mem_ctx) ir_expression(ir_binop_sub, + ir->type, + op_expr[0]->operands[1], + op_expr[0]->operands[0]); + } + break; + } + + case ir_binop_add: + if (is_vec_zero(op_const[0])) { + this->progress = true; + return swizzle_if_required(ir, ir->operands[1]); + } + if (is_vec_zero(op_const[1])) { + this->progress = true; + return swizzle_if_required(ir, ir->operands[0]); + } + + /* Reassociate addition of constants so that we can do constant + * folding. + */ + if (op_const[0] && !op_const[1]) + reassociate_constant(ir, 0, op_const[0], + ir->operands[1]->as_expression()); + if (op_const[1] && !op_const[0]) + reassociate_constant(ir, 1, op_const[1], + ir->operands[0]->as_expression()); + break; + + case ir_binop_sub: + if (is_vec_zero(op_const[0])) { + this->progress = true; + temp = new(mem_ctx) ir_expression(ir_unop_neg, + ir->operands[1]->type, + ir->operands[1], + NULL); + return swizzle_if_required(ir, temp); + } + if (is_vec_zero(op_const[1])) { + this->progress = true; + return swizzle_if_required(ir, ir->operands[0]); + } + break; + + case ir_binop_mul: + if (is_vec_one(op_const[0])) { + this->progress = true; + return swizzle_if_required(ir, ir->operands[1]); + } + if (is_vec_one(op_const[1])) { + this->progress = true; + return swizzle_if_required(ir, ir->operands[0]); + } + + if (is_vec_zero(op_const[0]) || is_vec_zero(op_const[1])) { + this->progress = true; + return ir_constant::zero(ir, ir->type); + } + + /* Reassociate multiplication of constants so that we can do + * constant folding. + */ + if (op_const[0] && !op_const[1]) + reassociate_constant(ir, 0, op_const[0], + ir->operands[1]->as_expression()); + if (op_const[1] && !op_const[0]) + reassociate_constant(ir, 1, op_const[1], + ir->operands[0]->as_expression()); + + break; + + case ir_binop_div: + if (is_vec_one(op_const[0]) && ir->type->base_type == GLSL_TYPE_FLOAT) { + this->progress = true; + temp = new(mem_ctx) ir_expression(ir_unop_rcp, + ir->operands[1]->type, + ir->operands[1], + NULL); + return swizzle_if_required(ir, temp); + } + if (is_vec_one(op_const[1])) { + this->progress = true; + return swizzle_if_required(ir, ir->operands[0]); + } + break; + + case ir_binop_logic_and: + /* FINISHME: Also simplify (a && a) to (a). */ + if (is_vec_one(op_const[0])) { + this->progress = true; + return ir->operands[1]; + } else if (is_vec_one(op_const[1])) { + this->progress = true; + return ir->operands[0]; + } else if (is_vec_zero(op_const[0]) || is_vec_zero(op_const[1])) { + this->progress = true; + return ir_constant::zero(mem_ctx, ir->type); + } + break; + + case ir_binop_logic_xor: + /* FINISHME: Also simplify (a ^^ a) to (false). */ + if (is_vec_zero(op_const[0])) { + this->progress = true; + return ir->operands[1]; + } else if (is_vec_zero(op_const[1])) { + this->progress = true; + return ir->operands[0]; + } else if (is_vec_one(op_const[0])) { + this->progress = true; + return new(mem_ctx) ir_expression(ir_unop_logic_not, ir->type, + ir->operands[1], NULL); + } else if (is_vec_one(op_const[1])) { + this->progress = true; + return new(mem_ctx) ir_expression(ir_unop_logic_not, ir->type, + ir->operands[0], NULL); + } + break; + + case ir_binop_logic_or: + /* FINISHME: Also simplify (a || a) to (a). */ + if (is_vec_zero(op_const[0])) { + this->progress = true; + return ir->operands[1]; + } else if (is_vec_zero(op_const[1])) { + this->progress = true; + return ir->operands[0]; + } else if (is_vec_one(op_const[0]) || is_vec_one(op_const[1])) { + ir_constant_data data; + + for (unsigned i = 0; i < 16; i++) + data.b[i] = true; + + this->progress = true; + return new(mem_ctx) ir_constant(ir->type, &data); + } + break; + + case ir_unop_rcp: + if (op_expr[0] && op_expr[0]->operation == ir_unop_rcp) { + this->progress = true; + return op_expr[0]->operands[0]; + } + + /* FINISHME: We should do rcp(rsq(x)) -> sqrt(x) for some + * backends, except that some backends will have done sqrt -> + * rcp(rsq(x)) and we don't want to undo it for them. + */ + + /* As far as we know, all backends are OK with rsq. */ + if (op_expr[0] && op_expr[0]->operation == ir_unop_sqrt) { + this->progress = true; + temp = new(mem_ctx) ir_expression(ir_unop_rsq, + op_expr[0]->operands[0]->type, + op_expr[0]->operands[0], + NULL); + return swizzle_if_required(ir, temp); + } + + break; + + default: + break; + } + + return ir; +} + +void +ir_algebraic_visitor::handle_rvalue(ir_rvalue **rvalue) +{ + if (!*rvalue) + return; + + ir_expression *expr = (*rvalue)->as_expression(); + if (!expr || expr->operation == ir_quadop_vector) + return; + + *rvalue = handle_expression(expr); +} + +bool +do_algebraic(exec_list *instructions) +{ + ir_algebraic_visitor v; + + visit_list_elements(&v, instructions); + + return v.progress; +} diff --git a/3rdparty/glsl-optimizer/src/glsl/opt_constant_folding.cpp b/3rdparty/glsl-optimizer/src/glsl/opt_constant_folding.cpp new file mode 100644 index 000000000..599b21525 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/opt_constant_folding.cpp @@ -0,0 +1,147 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file opt_constant_folding.cpp + * Replace constant-valued expressions with references to constant values. + */ + +#include "ir.h" +#include "ir_visitor.h" +#include "ir_rvalue_visitor.h" +#include "ir_optimization.h" +#include "glsl_types.h" + +/** + * Visitor class for replacing expressions with ir_constant values. + */ + +class ir_constant_folding_visitor : public ir_rvalue_visitor { +public: + ir_constant_folding_visitor() + { + this->progress = false; + } + + virtual ~ir_constant_folding_visitor() + { + /* empty */ + } + + virtual ir_visitor_status visit_enter(ir_assignment *ir); + virtual ir_visitor_status visit_enter(ir_call *ir); + + virtual void handle_rvalue(ir_rvalue **rvalue); + + bool progress; +}; + +void +ir_constant_folding_visitor::handle_rvalue(ir_rvalue **rvalue) +{ + if (*rvalue == NULL || (*rvalue)->ir_type == ir_type_constant) + return; + + /* Note that we do rvalue visitoring on leaving. So if an + * expression has a non-constant operand, no need to go looking + * down it to find if it's constant. This cuts the time of this + * pass down drastically. + */ + ir_expression *expr = (*rvalue)->as_expression(); + if (expr) { + for (unsigned int i = 0; i < expr->get_num_operands(); i++) { + if (!expr->operands[i]->as_constant()) + return; + } + } + + ir_constant *constant = (*rvalue)->constant_expression_value(); + if (constant) { + *rvalue = constant; + this->progress = true; + } else { + (*rvalue)->accept(this); + } +} + +ir_visitor_status +ir_constant_folding_visitor::visit_enter(ir_assignment *ir) +{ + ir->rhs->accept(this); + handle_rvalue(&ir->rhs); + + if (ir->condition) { + ir->condition->accept(this); + handle_rvalue(&ir->condition); + + ir_constant *const_val = ir->condition->as_constant(); + /* If the condition is constant, either remove the condition or + * remove the never-executed assignment. + */ + if (const_val) { + if (const_val->value.b[0]) + ir->condition = NULL; + else + ir->remove(); + this->progress = true; + } + } + + /* Don't descend into the LHS because we want it to stay as a + * variable dereference. FINISHME: We probably should to get array + * indices though. + */ + return visit_continue_with_parent; +} + +ir_visitor_status +ir_constant_folding_visitor::visit_enter(ir_call *ir) +{ + exec_list_iterator sig_iter = ir->get_callee()->parameters.iterator(); + foreach_iter(exec_list_iterator, iter, *ir) { + ir_rvalue *param_rval = (ir_rvalue *)iter.get(); + ir_variable *sig_param = (ir_variable *)sig_iter.get(); + + if (sig_param->mode == ir_var_in || sig_param->mode == ir_var_const_in) { + ir_rvalue *new_param = param_rval; + + handle_rvalue(&new_param); + if (new_param != param_rval) { + param_rval->replace_with(new_param); + } + } + sig_iter.next(); + } + + return visit_continue_with_parent; +} + +bool +do_constant_folding(exec_list *instructions) +{ + ir_constant_folding_visitor constant_folding; + + visit_list_elements(&constant_folding, instructions); + + return constant_folding.progress; +} diff --git a/3rdparty/glsl-optimizer/src/glsl/opt_constant_propagation.cpp b/3rdparty/glsl-optimizer/src/glsl/opt_constant_propagation.cpp new file mode 100644 index 000000000..9d7fd2231 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/opt_constant_propagation.cpp @@ -0,0 +1,448 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * constant of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, constant, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above constantright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR CONSTANTRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file opt_constant_propagation.cpp + * + * Tracks assignments of constants to channels of variables, and + * usage of those constant channels with direct usage of the constants. + * + * This can lead to constant folding and algebraic optimizations in + * those later expressions, while causing no increase in instruction + * count (due to constants being generally free to load from a + * constant push buffer or as instruction immediate values) and + * possibly reducing register pressure. + */ + +#include "ir.h" +#include "ir_visitor.h" +#include "ir_rvalue_visitor.h" +#include "ir_basic_block.h" +#include "ir_optimization.h" +#include "glsl_types.h" + +class acp_entry : public exec_node +{ +public: + acp_entry(ir_variable *var, unsigned write_mask, ir_constant *constant) + { + assert(var); + assert(constant); + this->var = var; + this->write_mask = write_mask; + this->constant = constant; + this->initial_values = write_mask; + } + + acp_entry(const acp_entry *src) + { + this->var = src->var; + this->write_mask = src->write_mask; + this->constant = src->constant; + this->initial_values = src->initial_values; + } + + ir_variable *var; + ir_constant *constant; + unsigned write_mask; + + /** Mask of values initially available in the constant. */ + unsigned initial_values; +}; + + +class kill_entry : public exec_node +{ +public: + kill_entry(ir_variable *var, unsigned write_mask) + { + assert(var); + this->var = var; + this->write_mask = write_mask; + } + + ir_variable *var; + unsigned write_mask; +}; + +class ir_constant_propagation_visitor : public ir_rvalue_visitor { +public: + ir_constant_propagation_visitor() + { + progress = false; + mem_ctx = ralloc_context(0); + this->acp = new(mem_ctx) exec_list; + this->kills = new(mem_ctx) exec_list; + } + ~ir_constant_propagation_visitor() + { + ralloc_free(mem_ctx); + } + + virtual ir_visitor_status visit_enter(class ir_loop *); + virtual ir_visitor_status visit_enter(class ir_function_signature *); + virtual ir_visitor_status visit_enter(class ir_function *); + virtual ir_visitor_status visit_leave(class ir_assignment *); + virtual ir_visitor_status visit_enter(class ir_call *); + virtual ir_visitor_status visit_enter(class ir_if *); + + void add_constant(ir_assignment *ir); + void kill(ir_variable *ir, unsigned write_mask); + void handle_if_block(exec_list *instructions); + void handle_rvalue(ir_rvalue **rvalue); + + /** List of acp_entry: The available constants to propagate */ + exec_list *acp; + + /** + * List of kill_entry: The masks of variables whose values were + * killed in this block. + */ + exec_list *kills; + + bool progress; + + bool killed_all; + + void *mem_ctx; +}; + + +void +ir_constant_propagation_visitor::handle_rvalue(ir_rvalue **rvalue) +{ + if (this->in_assignee || !*rvalue) + return; + + const glsl_type *type = (*rvalue)->type; + if (!type->is_scalar() && !type->is_vector()) + return; + + ir_swizzle *swiz = NULL; + ir_dereference_variable *deref = (*rvalue)->as_dereference_variable(); + if (!deref) { + swiz = (*rvalue)->as_swizzle(); + if (!swiz) + return; + + deref = swiz->val->as_dereference_variable(); + if (!deref) + return; + } + + ir_constant_data data; + memset(&data, 0, sizeof(data)); + + for (unsigned int i = 0; i < type->components(); i++) { + int channel; + acp_entry *found = NULL; + + if (swiz) { + switch (i) { + case 0: channel = swiz->mask.x; break; + case 1: channel = swiz->mask.y; break; + case 2: channel = swiz->mask.z; break; + case 3: channel = swiz->mask.w; break; + default: assert(!"shouldn't be reached"); channel = 0; break; + } + } else { + channel = i; + } + + foreach_iter(exec_list_iterator, iter, *this->acp) { + acp_entry *entry = (acp_entry *)iter.get(); + if (entry->var == deref->var && entry->write_mask & (1 << channel)) { + found = entry; + break; + } + } + + if (!found) + return; + + int rhs_channel = 0; + for (int j = 0; j < 4; j++) { + if (j == channel) + break; + if (found->initial_values & (1 << j)) + rhs_channel++; + } + + switch (type->base_type) { + case GLSL_TYPE_FLOAT: + data.f[i] = found->constant->value.f[rhs_channel]; + break; + case GLSL_TYPE_INT: + data.i[i] = found->constant->value.i[rhs_channel]; + break; + case GLSL_TYPE_UINT: + data.u[i] = found->constant->value.u[rhs_channel]; + break; + case GLSL_TYPE_BOOL: + data.b[i] = found->constant->value.b[rhs_channel]; + break; + default: + assert(!"not reached"); + break; + } + } + + *rvalue = new(ralloc_parent(deref)) ir_constant(type, &data); + this->progress = true; +} + +ir_visitor_status +ir_constant_propagation_visitor::visit_enter(ir_function_signature *ir) +{ + /* Treat entry into a function signature as a completely separate + * block. Any instructions at global scope will be shuffled into + * main() at link time, so they're irrelevant to us. + */ + exec_list *orig_acp = this->acp; + exec_list *orig_kills = this->kills; + bool orig_killed_all = this->killed_all; + + this->acp = new(mem_ctx) exec_list; + this->kills = new(mem_ctx) exec_list; + this->killed_all = false; + + visit_list_elements(this, &ir->body); + + this->kills = orig_kills; + this->acp = orig_acp; + this->killed_all = orig_killed_all; + + return visit_continue_with_parent; +} + +ir_visitor_status +ir_constant_propagation_visitor::visit_leave(ir_assignment *ir) +{ + if (this->in_assignee) + return visit_continue; + + kill(ir->lhs->variable_referenced(), ir->write_mask); + + add_constant(ir); + + return visit_continue; +} + +ir_visitor_status +ir_constant_propagation_visitor::visit_enter(ir_function *ir) +{ + (void) ir; + return visit_continue; +} + +ir_visitor_status +ir_constant_propagation_visitor::visit_enter(ir_call *ir) +{ + /* Do constant propagation on call parameters, but skip any out params */ + exec_list_iterator sig_param_iter = ir->get_callee()->parameters.iterator(); + foreach_iter(exec_list_iterator, iter, ir->actual_parameters) { + ir_variable *sig_param = (ir_variable *)sig_param_iter.get(); + ir_rvalue *param = (ir_rvalue *)iter.get(); + if (sig_param->mode != ir_var_out && sig_param->mode != ir_var_inout) { + ir_rvalue *new_param = param; + handle_rvalue(&new_param); + if (new_param != param) + param->replace_with(new_param); + else + param->accept(this); + } + sig_param_iter.next(); + } + + /* Since we're unlinked, we don't (necssarily) know the side effects of + * this call. So kill all copies. Except if it's a built-in; we know + * they are side effect free. + */ + if (!ir->get_callee()->is_builtin) { + acp->make_empty(); + this->killed_all = true; + } + + return visit_continue_with_parent; +} + +void +ir_constant_propagation_visitor::handle_if_block(exec_list *instructions) +{ + exec_list *orig_acp = this->acp; + exec_list *orig_kills = this->kills; + bool orig_killed_all = this->killed_all; + + this->acp = new(mem_ctx) exec_list; + this->kills = new(mem_ctx) exec_list; + this->killed_all = false; + + /* Populate the initial acp with a constant of the original */ + foreach_iter(exec_list_iterator, iter, *orig_acp) { + acp_entry *a = (acp_entry *)iter.get(); + this->acp->push_tail(new(this->mem_ctx) acp_entry(a)); + } + + visit_list_elements(this, instructions); + + if (this->killed_all) { + orig_acp->make_empty(); + } + + exec_list *new_kills = this->kills; + this->kills = orig_kills; + this->acp = orig_acp; + this->killed_all = this->killed_all || orig_killed_all; + + foreach_iter(exec_list_iterator, iter, *new_kills) { + kill_entry *k = (kill_entry *)iter.get(); + kill(k->var, k->write_mask); + } +} + +ir_visitor_status +ir_constant_propagation_visitor::visit_enter(ir_if *ir) +{ + ir->condition->accept(this); + handle_rvalue(&ir->condition); + + handle_if_block(&ir->then_instructions); + handle_if_block(&ir->else_instructions); + + /* handle_if_block() already descended into the children. */ + return visit_continue_with_parent; +} + +ir_visitor_status +ir_constant_propagation_visitor::visit_enter(ir_loop *ir) +{ + exec_list *orig_acp = this->acp; + exec_list *orig_kills = this->kills; + bool orig_killed_all = this->killed_all; + + /* FINISHME: For now, the initial acp for loops is totally empty. + * We could go through once, then go through again with the acp + * cloned minus the killed entries after the first run through. + */ + this->acp = new(mem_ctx) exec_list; + this->kills = new(mem_ctx) exec_list; + this->killed_all = false; + + visit_list_elements(this, &ir->body_instructions); + + if (this->killed_all) { + orig_acp->make_empty(); + } + + exec_list *new_kills = this->kills; + this->kills = orig_kills; + this->acp = orig_acp; + this->killed_all = this->killed_all || orig_killed_all; + + foreach_iter(exec_list_iterator, iter, *new_kills) { + kill_entry *k = (kill_entry *)iter.get(); + kill(k->var, k->write_mask); + } + + /* already descended into the children. */ + return visit_continue_with_parent; +} + +void +ir_constant_propagation_visitor::kill(ir_variable *var, unsigned write_mask) +{ + assert(var != NULL); + + /* We don't track non-vectors. */ + if (!var->type->is_vector() && !var->type->is_scalar()) + return; + + /* Remove any entries currently in the ACP for this kill. */ + foreach_iter(exec_list_iterator, iter, *this->acp) { + acp_entry *entry = (acp_entry *)iter.get(); + + if (entry->var == var) { + entry->write_mask &= ~write_mask; + if (entry->write_mask == 0) + entry->remove(); + } + } + + /* Add this writemask of the variable to the list of killed + * variables in this block. + */ + foreach_iter(exec_list_iterator, iter, *this->kills) { + kill_entry *entry = (kill_entry *)iter.get(); + + if (entry->var == var) { + entry->write_mask |= write_mask; + return; + } + } + /* Not already in the list. Make new entry. */ + this->kills->push_tail(new(this->mem_ctx) kill_entry(var, write_mask)); +} + +/** + * Adds an entry to the available constant list if it's a plain assignment + * of a variable to a variable. + */ +void +ir_constant_propagation_visitor::add_constant(ir_assignment *ir) +{ + acp_entry *entry; + + if (ir->condition) + return; + + if (!ir->write_mask) + return; + + ir_dereference_variable *deref = ir->lhs->as_dereference_variable(); + ir_constant *constant = ir->rhs->as_constant(); + + if (!deref || !constant) + return; + + /* Only do constant propagation on vectors. Constant matrices, + * arrays, or structures would require more work elsewhere. + */ + if (!deref->var->type->is_vector() && !deref->var->type->is_scalar()) + return; + + entry = new(this->mem_ctx) acp_entry(deref->var, ir->write_mask, constant); + this->acp->push_tail(entry); +} + +/** + * Does a constant propagation pass on the code present in the instruction stream. + */ +bool +do_constant_propagation(exec_list *instructions) +{ + ir_constant_propagation_visitor v; + + visit_list_elements(&v, instructions); + + return v.progress; +} diff --git a/3rdparty/glsl-optimizer/src/glsl/opt_constant_variable.cpp b/3rdparty/glsl-optimizer/src/glsl/opt_constant_variable.cpp new file mode 100644 index 000000000..3fa7c3bad --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/opt_constant_variable.cpp @@ -0,0 +1,195 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file opt_constant_variable.cpp + * + * Marks variables assigned a single constant value over the course + * of the program as constant. + * + * The goal here is to trigger further constant folding and then dead + * code elimination. This is common with vector/matrix constructors + * and calls to builtin functions. + */ + +#include "ir.h" +#include "ir_visitor.h" +#include "ir_optimization.h" +#include "glsl_types.h" + +struct assignment_entry { + exec_node link; + int assignment_count; + ir_variable *var; + ir_constant *constval; + bool our_scope; +}; + +class ir_constant_variable_visitor : public ir_hierarchical_visitor { +public: + virtual ir_visitor_status visit_enter(ir_dereference_variable *); + virtual ir_visitor_status visit(ir_variable *); + virtual ir_visitor_status visit_enter(ir_assignment *); + virtual ir_visitor_status visit_enter(ir_call *); + + exec_list list; +}; + +static struct assignment_entry * +get_assignment_entry(ir_variable *var, exec_list *list) +{ + struct assignment_entry *entry; + + foreach_list_typed(struct assignment_entry, entry, link, list) { + if (entry->var == var) + return entry; + } + + entry = (struct assignment_entry *)calloc(1, sizeof(*entry)); + entry->var = var; + list->push_head(&entry->link); + return entry; +} + +ir_visitor_status +ir_constant_variable_visitor::visit(ir_variable *ir) +{ + struct assignment_entry *entry = get_assignment_entry(ir, &this->list); + entry->our_scope = true; + return visit_continue; +} + +/* Skip derefs of variables so that we can detect declarations. */ +ir_visitor_status +ir_constant_variable_visitor::visit_enter(ir_dereference_variable *ir) +{ + (void)ir; + return visit_continue_with_parent; +} + +ir_visitor_status +ir_constant_variable_visitor::visit_enter(ir_assignment *ir) +{ + ir_constant *constval; + struct assignment_entry *entry; + + entry = get_assignment_entry(ir->lhs->variable_referenced(), &this->list); + assert(entry); + entry->assignment_count++; + + /* If it's already constant, don't do the work. */ + if (entry->var->constant_value) + return visit_continue; + + /* OK, now find if we actually have all the right conditions for + * this to be a constant value assigned to the var. + */ + if (ir->condition) + return visit_continue; + + ir_variable *var = ir->whole_variable_written(); + if (!var) + return visit_continue; + + constval = ir->rhs->constant_expression_value(); + if (!constval) + return visit_continue; + + /* Mark this entry as having a constant assignment (if the + * assignment count doesn't go >1). do_constant_variable will fix + * up the variable with the constant value later. + */ + entry->constval = constval; + + return visit_continue; +} + +ir_visitor_status +ir_constant_variable_visitor::visit_enter(ir_call *ir) +{ + exec_list_iterator sig_iter = ir->get_callee()->parameters.iterator(); + foreach_iter(exec_list_iterator, iter, *ir) { + ir_rvalue *param_rval = (ir_rvalue *)iter.get(); + ir_variable *param = (ir_variable *)sig_iter.get(); + + if (param->mode == ir_var_out || + param->mode == ir_var_inout) { + ir_variable *var = param_rval->variable_referenced(); + struct assignment_entry *entry; + + assert(var); + entry = get_assignment_entry(var, &this->list); + entry->assignment_count++; + } + sig_iter.next(); + } + return visit_continue; +} + +/** + * Does a copy propagation pass on the code present in the instruction stream. + */ +bool +do_constant_variable(exec_list *instructions) +{ + bool progress = false; + ir_constant_variable_visitor v; + + v.run(instructions); + + while (!v.list.is_empty()) { + + struct assignment_entry *entry; + entry = exec_node_data(struct assignment_entry, v.list.head, link); + + if (entry->assignment_count == 1 && entry->constval && entry->our_scope) { + entry->var->constant_value = entry->constval; + progress = true; + } + entry->link.remove(); + free(entry); + } + + return progress; +} + +bool +do_constant_variable_unlinked(exec_list *instructions) +{ + bool progress = false; + + foreach_iter(exec_list_iterator, iter, *instructions) { + ir_instruction *ir = (ir_instruction *)iter.get(); + ir_function *f = ir->as_function(); + if (f) { + foreach_iter(exec_list_iterator, sigiter, *f) { + ir_function_signature *sig = + (ir_function_signature *) sigiter.get(); + if (do_constant_variable(&sig->body)) + progress = true; + } + } + } + + return progress; +} diff --git a/3rdparty/glsl-optimizer/src/glsl/opt_copy_propagation.cpp b/3rdparty/glsl-optimizer/src/glsl/opt_copy_propagation.cpp new file mode 100644 index 000000000..3fad58547 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/opt_copy_propagation.cpp @@ -0,0 +1,350 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file opt_copy_propagation.cpp + * + * Moves usage of recently-copied variables to the previous copy of + * the variable. + * + * This should reduce the number of MOV instructions in the generated + * programs unless copy propagation is also done on the LIR, and may + * help anyway by triggering other optimizations that live in the HIR. + */ + +#include "ir.h" +#include "ir_visitor.h" +#include "ir_basic_block.h" +#include "ir_optimization.h" +#include "glsl_types.h" + +class acp_entry : public exec_node +{ +public: + acp_entry(ir_variable *lhs, ir_variable *rhs) + { + assert(lhs); + assert(rhs); + this->lhs = lhs; + this->rhs = rhs; + } + + ir_variable *lhs; + ir_variable *rhs; +}; + + +class kill_entry : public exec_node +{ +public: + kill_entry(ir_variable *var) + { + assert(var); + this->var = var; + } + + ir_variable *var; +}; + +class ir_copy_propagation_visitor : public ir_hierarchical_visitor { +public: + ir_copy_propagation_visitor() + { + progress = false; + mem_ctx = ralloc_context(0); + this->acp = new(mem_ctx) exec_list; + this->kills = new(mem_ctx) exec_list; + } + ~ir_copy_propagation_visitor() + { + ralloc_free(mem_ctx); + } + + virtual ir_visitor_status visit(class ir_dereference_variable *); + virtual ir_visitor_status visit_enter(class ir_loop *); + virtual ir_visitor_status visit_enter(class ir_function_signature *); + virtual ir_visitor_status visit_enter(class ir_function *); + virtual ir_visitor_status visit_leave(class ir_assignment *); + virtual ir_visitor_status visit_enter(class ir_call *); + virtual ir_visitor_status visit_enter(class ir_if *); + + void add_copy(ir_assignment *ir); + void kill(ir_variable *ir); + void handle_if_block(exec_list *instructions); + + /** List of acp_entry: The available copies to propagate */ + exec_list *acp; + /** + * List of kill_entry: The variables whose values were killed in this + * block. + */ + exec_list *kills; + + bool progress; + + bool killed_all; + + void *mem_ctx; +}; + +ir_visitor_status +ir_copy_propagation_visitor::visit_enter(ir_function_signature *ir) +{ + /* Treat entry into a function signature as a completely separate + * block. Any instructions at global scope will be shuffled into + * main() at link time, so they're irrelevant to us. + */ + exec_list *orig_acp = this->acp; + exec_list *orig_kills = this->kills; + bool orig_killed_all = this->killed_all; + + this->acp = new(mem_ctx) exec_list; + this->kills = new(mem_ctx) exec_list; + this->killed_all = false; + + visit_list_elements(this, &ir->body); + + this->kills = orig_kills; + this->acp = orig_acp; + this->killed_all = orig_killed_all; + + return visit_continue_with_parent; +} + +ir_visitor_status +ir_copy_propagation_visitor::visit_leave(ir_assignment *ir) +{ + kill(ir->lhs->variable_referenced()); + + add_copy(ir); + + return visit_continue; +} + +ir_visitor_status +ir_copy_propagation_visitor::visit_enter(ir_function *ir) +{ + (void) ir; + return visit_continue; +} + +/** + * Replaces dereferences of ACP RHS variables with ACP LHS variables. + * + * This is where the actual copy propagation occurs. Note that the + * rewriting of ir_dereference means that the ir_dereference instance + * must not be shared by multiple IR operations! + */ +ir_visitor_status +ir_copy_propagation_visitor::visit(ir_dereference_variable *ir) +{ + if (this->in_assignee) + return visit_continue; + + ir_variable *var = ir->var; + + foreach_iter(exec_list_iterator, iter, *this->acp) { + acp_entry *entry = (acp_entry *)iter.get(); + + if (var == entry->lhs) { + ir->var = entry->rhs; + this->progress = true; + break; + } + } + + return visit_continue; +} + + +ir_visitor_status +ir_copy_propagation_visitor::visit_enter(ir_call *ir) +{ + /* Do copy propagation on call parameters, but skip any out params */ + exec_list_iterator sig_param_iter = ir->get_callee()->parameters.iterator(); + foreach_iter(exec_list_iterator, iter, ir->actual_parameters) { + ir_variable *sig_param = (ir_variable *)sig_param_iter.get(); + ir_instruction *ir = (ir_instruction *)iter.get(); + if (sig_param->mode != ir_var_out && sig_param->mode != ir_var_inout) { + ir->accept(this); + } + sig_param_iter.next(); + } + + /* Since we're unlinked, we don't (necessarily) know the side effects of + * this call. So kill all copies. + * For any built-in functions, do not do this; they are side effect-free. + */ + if (!ir->get_callee()->is_builtin) { + acp->make_empty(); + this->killed_all = true; + } + + return visit_continue_with_parent; +} + +void +ir_copy_propagation_visitor::handle_if_block(exec_list *instructions) +{ + exec_list *orig_acp = this->acp; + exec_list *orig_kills = this->kills; + bool orig_killed_all = this->killed_all; + + this->acp = new(mem_ctx) exec_list; + this->kills = new(mem_ctx) exec_list; + this->killed_all = false; + + /* Populate the initial acp with a copy of the original */ + foreach_iter(exec_list_iterator, iter, *orig_acp) { + acp_entry *a = (acp_entry *)iter.get(); + this->acp->push_tail(new(this->mem_ctx) acp_entry(a->lhs, a->rhs)); + } + + visit_list_elements(this, instructions); + + if (this->killed_all) { + orig_acp->make_empty(); + } + + exec_list *new_kills = this->kills; + this->kills = orig_kills; + this->acp = orig_acp; + this->killed_all = this->killed_all || orig_killed_all; + + foreach_iter(exec_list_iterator, iter, *new_kills) { + kill_entry *k = (kill_entry *)iter.get(); + kill(k->var); + } +} + +ir_visitor_status +ir_copy_propagation_visitor::visit_enter(ir_if *ir) +{ + ir->condition->accept(this); + + handle_if_block(&ir->then_instructions); + handle_if_block(&ir->else_instructions); + + /* handle_if_block() already descended into the children. */ + return visit_continue_with_parent; +} + +ir_visitor_status +ir_copy_propagation_visitor::visit_enter(ir_loop *ir) +{ + exec_list *orig_acp = this->acp; + exec_list *orig_kills = this->kills; + bool orig_killed_all = this->killed_all; + + /* FINISHME: For now, the initial acp for loops is totally empty. + * We could go through once, then go through again with the acp + * cloned minus the killed entries after the first run through. + */ + this->acp = new(mem_ctx) exec_list; + this->kills = new(mem_ctx) exec_list; + this->killed_all = false; + + visit_list_elements(this, &ir->body_instructions); + + if (this->killed_all) { + orig_acp->make_empty(); + } + + exec_list *new_kills = this->kills; + this->kills = orig_kills; + this->acp = orig_acp; + this->killed_all = this->killed_all || orig_killed_all; + + foreach_iter(exec_list_iterator, iter, *new_kills) { + kill_entry *k = (kill_entry *)iter.get(); + kill(k->var); + } + + /* already descended into the children. */ + return visit_continue_with_parent; +} + +void +ir_copy_propagation_visitor::kill(ir_variable *var) +{ + assert(var != NULL); + + /* Remove any entries currently in the ACP for this kill. */ + foreach_iter(exec_list_iterator, iter, *acp) { + acp_entry *entry = (acp_entry *)iter.get(); + + if (entry->lhs == var || entry->rhs == var) { + entry->remove(); + } + } + + /* Add the LHS variable to the list of killed variables in this block. + */ + this->kills->push_tail(new(this->mem_ctx) kill_entry(var)); +} + +/** + * Adds an entry to the available copy list if it's a plain assignment + * of a variable to a variable. + */ +void +ir_copy_propagation_visitor::add_copy(ir_assignment *ir) +{ + acp_entry *entry; + + if (ir->condition) + return; + + ir_variable *lhs_var = ir->whole_variable_written(); + ir_variable *rhs_var = ir->rhs->whole_variable_referenced(); + + if ((lhs_var != NULL) && (rhs_var != NULL)) { + if (lhs_var == rhs_var) { + /* This is a dumb assignment, but we've conveniently noticed + * it here. Removing it now would mess up the loop iteration + * calling us. Just flag it to not execute, and someone else + * will clean up the mess. + */ + ir->condition = new(ralloc_parent(ir)) ir_constant(false); + this->progress = true; + } else { + if (lhs_var->precision == rhs_var->precision || lhs_var->precision==glsl_precision_undefined || rhs_var->precision==glsl_precision_undefined) { + entry = new(this->mem_ctx) acp_entry(lhs_var, rhs_var); + this->acp->push_tail(entry); + } + } + } +} + +/** + * Does a copy propagation pass on the code present in the instruction stream. + */ +bool +do_copy_propagation(exec_list *instructions) +{ + ir_copy_propagation_visitor v; + + visit_list_elements(&v, instructions); + + return v.progress; +} diff --git a/3rdparty/glsl-optimizer/src/glsl/opt_copy_propagation_elements.cpp b/3rdparty/glsl-optimizer/src/glsl/opt_copy_propagation_elements.cpp new file mode 100644 index 000000000..58e320d8d --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/opt_copy_propagation_elements.cpp @@ -0,0 +1,473 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file opt_copy_propagation_elements.cpp + * + * Replaces usage of recently-copied components of variables with the + * previous copy of the variable. + * + * This pass can be compared with opt_copy_propagation, which operands + * on arbitrary whole-variable copies. However, in order to handle + * the copy propagation of swizzled variables or writemasked writes, + * we want to track things on a channel-wise basis. I found that + * trying to mix the swizzled/writemasked support here with the + * whole-variable stuff in opt_copy_propagation.cpp just made a mess, + * so this is separate despite the ACP handling being somewhat + * similar. + * + * This should reduce the number of MOV instructions in the generated + * programs unless copy propagation is also done on the LIR, and may + * help anyway by triggering other optimizations that live in the HIR. + */ + +#include "ir.h" +#include "ir_rvalue_visitor.h" +#include "ir_basic_block.h" +#include "ir_optimization.h" +#include "glsl_types.h" + +static bool debug = false; + +class acp_entry : public exec_node +{ +public: + acp_entry(ir_variable *lhs, ir_variable *rhs, int write_mask, int swizzle[4]) + { + this->lhs = lhs; + this->rhs = rhs; + this->write_mask = write_mask; + memcpy(this->swizzle, swizzle, sizeof(this->swizzle)); + } + + acp_entry(acp_entry *a) + { + this->lhs = a->lhs; + this->rhs = a->rhs; + this->write_mask = a->write_mask; + memcpy(this->swizzle, a->swizzle, sizeof(this->swizzle)); + } + + ir_variable *lhs; + ir_variable *rhs; + unsigned int write_mask; + int swizzle[4]; +}; + + +class kill_entry : public exec_node +{ +public: + kill_entry(ir_variable *var, int write_mask) + { + this->var = var; + this->write_mask = write_mask; + } + + ir_variable *var; + unsigned int write_mask; +}; + +class ir_copy_propagation_elements_visitor : public ir_rvalue_visitor { +public: + ir_copy_propagation_elements_visitor() + { + this->progress = false; + this->mem_ctx = ralloc_context(NULL); + this->shader_mem_ctx = NULL; + this->acp = new(mem_ctx) exec_list; + this->kills = new(mem_ctx) exec_list; + } + ~ir_copy_propagation_elements_visitor() + { + ralloc_free(mem_ctx); + } + + virtual ir_visitor_status visit_enter(class ir_loop *); + virtual ir_visitor_status visit_enter(class ir_function_signature *); + virtual ir_visitor_status visit_leave(class ir_assignment *); + virtual ir_visitor_status visit_enter(class ir_call *); + virtual ir_visitor_status visit_enter(class ir_if *); + + void handle_rvalue(ir_rvalue **rvalue); + + void add_copy(ir_assignment *ir); + void kill(kill_entry *k); + void handle_if_block(exec_list *instructions); + + /** List of acp_entry: The available copies to propagate */ + exec_list *acp; + /** + * List of kill_entry: The variables whose values were killed in this + * block. + */ + exec_list *kills; + + bool progress; + + bool killed_all; + + /* Context for our local data structures. */ + void *mem_ctx; + /* Context for allocating new shader nodes. */ + void *shader_mem_ctx; +}; + +ir_visitor_status +ir_copy_propagation_elements_visitor::visit_enter(ir_function_signature *ir) +{ + /* Treat entry into a function signature as a completely separate + * block. Any instructions at global scope will be shuffled into + * main() at link time, so they're irrelevant to us. + */ + exec_list *orig_acp = this->acp; + exec_list *orig_kills = this->kills; + bool orig_killed_all = this->killed_all; + + this->acp = new(mem_ctx) exec_list; + this->kills = new(mem_ctx) exec_list; + this->killed_all = false; + + visit_list_elements(this, &ir->body); + + this->kills = orig_kills; + this->acp = orig_acp; + this->killed_all = orig_killed_all; + + return visit_continue_with_parent; +} + +ir_visitor_status +ir_copy_propagation_elements_visitor::visit_leave(ir_assignment *ir) +{ + ir_dereference_variable *lhs = ir->lhs->as_dereference_variable(); + ir_variable *var = ir->lhs->variable_referenced(); + + if (var->type->is_scalar() || var->type->is_vector()) { + kill_entry *k; + + if (lhs) + k = new(mem_ctx) kill_entry(var, ir->write_mask); + else + k = new(mem_ctx) kill_entry(var, ~0); + + kill(k); + } + + add_copy(ir); + + return visit_continue; +} + +/** + * Replaces dereferences of ACP RHS variables with ACP LHS variables. + * + * This is where the actual copy propagation occurs. Note that the + * rewriting of ir_dereference means that the ir_dereference instance + * must not be shared by multiple IR operations! + */ +void +ir_copy_propagation_elements_visitor::handle_rvalue(ir_rvalue **ir) +{ + int swizzle_chan[4]; + ir_dereference_variable *deref_var; + ir_variable *source[4] = {NULL, NULL, NULL, NULL}; + int source_chan[4]; + int chans; + + if (!*ir) + return; + + ir_swizzle *swizzle = (*ir)->as_swizzle(); + if (swizzle) { + deref_var = swizzle->val->as_dereference_variable(); + if (!deref_var) + return; + + swizzle_chan[0] = swizzle->mask.x; + swizzle_chan[1] = swizzle->mask.y; + swizzle_chan[2] = swizzle->mask.z; + swizzle_chan[3] = swizzle->mask.w; + chans = swizzle->type->vector_elements; + } else { + deref_var = (*ir)->as_dereference_variable(); + if (!deref_var) + return; + + swizzle_chan[0] = 0; + swizzle_chan[1] = 1; + swizzle_chan[2] = 2; + swizzle_chan[3] = 3; + chans = deref_var->type->vector_elements; + } + + if (this->in_assignee) + return; + + ir_variable *var = deref_var->var; + + /* Try to find ACP entries covering swizzle_chan[], hoping they're + * the same source variable. + */ + foreach_iter(exec_list_iterator, iter, *this->acp) { + acp_entry *entry = (acp_entry *)iter.get(); + + if (var == entry->lhs) { + for (int c = 0; c < chans; c++) { + if (entry->write_mask & (1 << swizzle_chan[c])) { + source[c] = entry->rhs; + source_chan[c] = entry->swizzle[swizzle_chan[c]]; + } + } + } + } + + /* Make sure all channels are copying from the same source variable. */ + if (!source[0]) + return; + for (int c = 1; c < chans; c++) { + if (source[c] != source[0]) + return; + } + + if (!shader_mem_ctx) + shader_mem_ctx = ralloc_parent(deref_var); + + if (debug) { + printf("Copy propagation from:\n"); + (*ir)->print(); + } + + deref_var = new(shader_mem_ctx) ir_dereference_variable(source[0]); + *ir = new(shader_mem_ctx) ir_swizzle(deref_var, + source_chan[0], + source_chan[1], + source_chan[2], + source_chan[3], + chans); + + if (debug) { + printf("to:\n"); + (*ir)->print(); + printf("\n"); + } +} + + +ir_visitor_status +ir_copy_propagation_elements_visitor::visit_enter(ir_call *ir) +{ + /* Do copy propagation on call parameters, but skip any out params */ + exec_list_iterator sig_param_iter = ir->get_callee()->parameters.iterator(); + foreach_iter(exec_list_iterator, iter, ir->actual_parameters) { + ir_variable *sig_param = (ir_variable *)sig_param_iter.get(); + ir_instruction *ir = (ir_instruction *)iter.get(); + if (sig_param->mode != ir_var_out && sig_param->mode != ir_var_inout) { + ir->accept(this); + } + sig_param_iter.next(); + } + + /* Since we're unlinked, we don't (necessarily) know the side effects of + * this call. So kill all copies. Except if it's a built-in; we know + * they are side effect free. + */ + if (!ir->get_callee()->is_builtin) { + acp->make_empty(); + this->killed_all = true; + } + + return visit_continue_with_parent; +} + +void +ir_copy_propagation_elements_visitor::handle_if_block(exec_list *instructions) +{ + exec_list *orig_acp = this->acp; + exec_list *orig_kills = this->kills; + bool orig_killed_all = this->killed_all; + + this->acp = new(mem_ctx) exec_list; + this->kills = new(mem_ctx) exec_list; + this->killed_all = false; + + /* Populate the initial acp with a copy of the original */ + foreach_iter(exec_list_iterator, iter, *orig_acp) { + acp_entry *a = (acp_entry *)iter.get(); + this->acp->push_tail(new(this->mem_ctx) acp_entry(a)); + } + + visit_list_elements(this, instructions); + + if (this->killed_all) { + orig_acp->make_empty(); + } + + exec_list *new_kills = this->kills; + this->kills = orig_kills; + this->acp = orig_acp; + this->killed_all = this->killed_all || orig_killed_all; + + /* Move the new kills into the parent block's list, removing them + * from the parent's ACP list in the process. + */ + foreach_list_safe(node, new_kills) { + kill_entry *k = (kill_entry *)node; + kill(k); + } +} + +ir_visitor_status +ir_copy_propagation_elements_visitor::visit_enter(ir_if *ir) +{ + ir->condition->accept(this); + + handle_if_block(&ir->then_instructions); + handle_if_block(&ir->else_instructions); + + /* handle_if_block() already descended into the children. */ + return visit_continue_with_parent; +} + +ir_visitor_status +ir_copy_propagation_elements_visitor::visit_enter(ir_loop *ir) +{ + exec_list *orig_acp = this->acp; + exec_list *orig_kills = this->kills; + bool orig_killed_all = this->killed_all; + + /* FINISHME: For now, the initial acp for loops is totally empty. + * We could go through once, then go through again with the acp + * cloned minus the killed entries after the first run through. + */ + this->acp = new(mem_ctx) exec_list; + this->kills = new(mem_ctx) exec_list; + this->killed_all = false; + + visit_list_elements(this, &ir->body_instructions); + + if (this->killed_all) { + orig_acp->make_empty(); + } + + exec_list *new_kills = this->kills; + this->kills = orig_kills; + this->acp = orig_acp; + this->killed_all = this->killed_all || orig_killed_all; + + foreach_list_safe(node, new_kills) { + kill_entry *k = (kill_entry *)node; + kill(k); + } + + /* already descended into the children. */ + return visit_continue_with_parent; +} + +/* Remove any entries currently in the ACP for this kill. */ +void +ir_copy_propagation_elements_visitor::kill(kill_entry *k) +{ + foreach_list_safe(node, acp) { + acp_entry *entry = (acp_entry *)node; + + if (entry->lhs == k->var) { + entry->write_mask = entry->write_mask & ~k->write_mask; + if (entry->write_mask == 0) { + entry->remove(); + continue; + } + } + if (entry->rhs == k->var) { + entry->remove(); + } + } + + /* If we were on a list, remove ourselves before inserting */ + if (k->next) + k->remove(); + + this->kills->push_tail(k); +} + +/** + * Adds directly-copied channels between vector variables to the available + * copy propagation list. + */ +void +ir_copy_propagation_elements_visitor::add_copy(ir_assignment *ir) +{ + acp_entry *entry; + int orig_swizzle[4] = {0, 1, 2, 3}; + int swizzle[4]; + + if (ir->condition) + return; + + ir_dereference_variable *lhs = ir->lhs->as_dereference_variable(); + if (!lhs || !(lhs->type->is_scalar() || lhs->type->is_vector())) + return; + + ir_dereference_variable *rhs = ir->rhs->as_dereference_variable(); + if (!rhs) { + ir_swizzle *swiz = ir->rhs->as_swizzle(); + if (!swiz) + return; + + rhs = swiz->val->as_dereference_variable(); + if (!rhs) + return; + + orig_swizzle[0] = swiz->mask.x; + orig_swizzle[1] = swiz->mask.y; + orig_swizzle[2] = swiz->mask.z; + orig_swizzle[3] = swiz->mask.w; + } + + /* Move the swizzle channels out to the positions they match in the + * destination. We don't want to have to rewrite the swizzle[] + * array every time we clear a bit of the write_mask. + */ + int j = 0; + for (int i = 0; i < 4; i++) { + if (ir->write_mask & (1 << i)) + swizzle[i] = orig_swizzle[j++]; + } + + if (lhs->var->precision != rhs->var->precision && lhs->var->precision!=glsl_precision_undefined && rhs->var->precision!=glsl_precision_undefined) + return; + + entry = new(this->mem_ctx) acp_entry(lhs->var, rhs->var, ir->write_mask, + swizzle); + this->acp->push_tail(entry); +} + +bool +do_copy_propagation_elements(exec_list *instructions) +{ + ir_copy_propagation_elements_visitor v; + + visit_list_elements(&v, instructions); + + return v.progress; +} diff --git a/3rdparty/glsl-optimizer/src/glsl/opt_dead_code.cpp b/3rdparty/glsl-optimizer/src/glsl/opt_dead_code.cpp new file mode 100644 index 000000000..4568ab087 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/opt_dead_code.cpp @@ -0,0 +1,142 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file opt_dead_code.cpp + * + * Eliminates dead assignments and variable declarations from the code. + */ + +#include "ir.h" +#include "ir_visitor.h" +#include "ir_variable_refcount.h" +#include "glsl_types.h" + +static bool debug = false; + +/** + * Do a dead code pass over instructions and everything that instructions + * references. + * + * Note that this will remove assignments to globals, so it is not suitable + * for usage on an unlinked instruction stream. + */ +bool +do_dead_code(exec_list *instructions) +{ + ir_variable_refcount_visitor v; + bool progress = false; + + v.run(instructions); + + foreach_iter(exec_list_iterator, iter, v.variable_list) { + variable_entry *entry = (variable_entry *)iter.get(); + + /* Since each assignment is a reference, the refereneced count must be + * greater than or equal to the assignment count. If they are equal, + * then all of the references are assignments, and the variable is + * dead. + * + * Note that if the variable is neither assigned nor referenced, both + * counts will be zero and will be caught by the equality test. + */ + assert(entry->referenced_count >= entry->assigned_count); + + if (debug) { + printf("%s@%p: %d refs, %d assigns, %sdeclared in our scope\n", + entry->var->name, (void *) entry->var, + entry->referenced_count, entry->assigned_count, + entry->declaration ? "" : "not "); + } + + if ((entry->referenced_count > entry->assigned_count) + || !entry->declaration) + continue; + + if (entry->assign) { + /* Remove a single dead assignment to the variable we found. + * Don't do so if it's a shader output, though. + */ + if (entry->var->mode != ir_var_out && + entry->var->mode != ir_var_inout && + !ir_has_call_skip_builtins(entry->assign)) { + entry->assign->remove(); + progress = true; + + if (debug) { + printf("Removed assignment to %s@%p\n", + entry->var->name, (void *) entry->var); + } + } + } else { + /* If there are no assignments or references to the variable left, + * then we can remove its declaration. + */ + + /* uniform initializers are precious, and could get used by another + * stage. + */ + if (entry->var->mode == ir_var_uniform && + entry->var->constant_value) + continue; + + entry->var->remove(); + progress = true; + + if (debug) { + printf("Removed declaration of %s@%p\n", + entry->var->name, (void *) entry->var); + } + } + } + + return progress; +} + +/** + * Does a dead code pass on the functions present in the instruction stream. + * + * This is suitable for use while the program is not linked, as it will + * ignore variable declarations (and the assignments to them) for variables + * with global scope. + */ +bool +do_dead_code_unlinked(exec_list *instructions) +{ + bool progress = false; + + foreach_iter(exec_list_iterator, iter, *instructions) { + ir_instruction *ir = (ir_instruction *)iter.get(); + ir_function *f = ir->as_function(); + if (f) { + foreach_iter(exec_list_iterator, sigiter, *f) { + ir_function_signature *sig = + (ir_function_signature *) sigiter.get(); + if (do_dead_code(&sig->body)) + progress = true; + } + } + } + + return progress; +} diff --git a/3rdparty/glsl-optimizer/src/glsl/opt_dead_code_local.cpp b/3rdparty/glsl-optimizer/src/glsl/opt_dead_code_local.cpp new file mode 100644 index 000000000..0a0b86804 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/opt_dead_code_local.cpp @@ -0,0 +1,223 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file opt_dead_code_local.cpp + * + * Eliminates local dead assignments from the code. + * + * This operates on basic blocks, tracking assignments and finding if + * they're used before the variable is completely reassigned. + * + * Compare this to ir_dead_code.cpp, which operates globally looking + * for assignments to variables that are never read. + */ + +#include "ir.h" +#include "ir_basic_block.h" +#include "ir_optimization.h" +#include "glsl_types.h" + +static bool debug = false; + +class assignment_entry : public exec_node +{ +public: + assignment_entry(ir_variable *lhs, ir_instruction *ir) + { + assert(lhs); + assert(ir); + this->lhs = lhs; + this->ir = ir; + } + + ir_variable *lhs; + ir_instruction *ir; +}; + +class kill_for_derefs_visitor : public ir_hierarchical_visitor { +public: + kill_for_derefs_visitor(exec_list *assignments) + { + this->assignments = assignments; + } + + virtual ir_visitor_status visit(ir_dereference_variable *ir) + { + ir_variable *const var = ir->variable_referenced(); + + foreach_iter(exec_list_iterator, iter, *this->assignments) { + assignment_entry *entry = (assignment_entry *)iter.get(); + + if (entry->lhs == var) { + if (debug) + printf("kill %s\n", entry->lhs->name); + entry->remove(); + } + } + + return visit_continue; + } + +private: + exec_list *assignments; +}; + +class array_index_visit : public ir_hierarchical_visitor { +public: + array_index_visit(ir_hierarchical_visitor *v) + { + this->visitor = v; + } + + virtual ir_visitor_status visit_enter(class ir_dereference_array *ir) + { + ir->array_index->accept(visitor); + return visit_continue; + } + + static void run(ir_instruction *ir, ir_hierarchical_visitor *v) + { + array_index_visit top_visit(v); + ir->accept(& top_visit); + } + + ir_hierarchical_visitor *visitor; +}; + + +/** + * Adds an entry to the available copy list if it's a plain assignment + * of a variable to a variable. + */ +static bool +process_assignment(void *ctx, ir_assignment *ir, exec_list *assignments) +{ + ir_variable *var = NULL; + bool progress = false; + kill_for_derefs_visitor v(assignments); + + /* Kill assignment entries for things used to produce this assignment. */ + ir->rhs->accept(&v); + if (ir->condition) { + ir->condition->accept(&v); + } + + /* Kill assignment enties used as array indices. + */ + array_index_visit::run(ir->lhs, &v); + var = ir->lhs->variable_referenced(); + assert(var); + + /* Now, check if we did a whole-variable assignment. */ + if (!ir->condition && (ir->whole_variable_written() != NULL)) { + /* We did a whole-variable assignment. So, any instruction in + * the assignment list with the same LHS is dead. + */ + if (debug) + printf("looking for %s to remove\n", var->name); + foreach_iter(exec_list_iterator, iter, *assignments) { + assignment_entry *entry = (assignment_entry *)iter.get(); + + if (entry->lhs == var) { + if (debug) + printf("removing %s\n", var->name); + entry->ir->remove(); + entry->remove(); + progress = true; + } + } + } + + /* Add this instruction to the assignment list available to be removed. + * But not if the assignment has other side effects. + * Skip any calls to built-in functions, cause they don't have side effects. + */ + if (ir_has_call_skip_builtins(ir)) + return progress; + + assignment_entry *entry = new(ctx) assignment_entry(var, ir); + assignments->push_tail(entry); + + if (debug) { + printf("add %s\n", var->name); + + printf("current entries\n"); + foreach_iter(exec_list_iterator, iter, *assignments) { + assignment_entry *entry = (assignment_entry *)iter.get(); + + printf(" %s\n", entry->lhs->name); + } + } + + return progress; +} + +static void +dead_code_local_basic_block(ir_instruction *first, + ir_instruction *last, + void *data) +{ + ir_instruction *ir, *ir_next; + /* List of avaialble_copy */ + exec_list assignments; + bool *out_progress = (bool *)data; + bool progress = false; + + void *ctx = ralloc_context(NULL); + /* Safe looping, since process_assignment */ + for (ir = first, ir_next = (ir_instruction *)first->next;; + ir = ir_next, ir_next = (ir_instruction *)ir->next) { + ir_assignment *ir_assign = ir->as_assignment(); + + if (debug) { + ir->print(); + printf("\n"); + } + + if (ir_assign) { + progress = process_assignment(ctx, ir_assign, &assignments) || progress; + } else { + kill_for_derefs_visitor kill(&assignments); + ir->accept(&kill); + } + + if (ir == last) + break; + } + *out_progress = progress; + ralloc_free(ctx); +} + +/** + * Does a copy propagation pass on the code present in the instruction stream. + */ +bool +do_dead_code_local(exec_list *instructions) +{ + bool progress = false; + + call_for_basic_blocks(instructions, dead_code_local_basic_block, &progress); + + return progress; +} diff --git a/3rdparty/glsl-optimizer/src/glsl/opt_dead_functions.cpp b/3rdparty/glsl-optimizer/src/glsl/opt_dead_functions.cpp new file mode 100644 index 000000000..51c77e3b9 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/opt_dead_functions.cpp @@ -0,0 +1,155 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file opt_dead_functions.cpp + * + * Eliminates unused functions from the linked program. + */ + +#include "ir.h" +#include "ir_visitor.h" +#include "ir_expression_flattening.h" +#include "glsl_types.h" + +class signature_entry : public exec_node +{ +public: + signature_entry(ir_function_signature *sig) + { + this->signature = sig; + this->used = false; + } + + ir_function_signature *signature; + bool used; +}; + +class ir_dead_functions_visitor : public ir_hierarchical_visitor { +public: + ir_dead_functions_visitor() + { + this->mem_ctx = ralloc_context(NULL); + } + + ~ir_dead_functions_visitor() + { + ralloc_free(this->mem_ctx); + } + + virtual ir_visitor_status visit_enter(ir_function_signature *); + virtual ir_visitor_status visit_enter(ir_call *); + + signature_entry *get_signature_entry(ir_function_signature *var); + + bool (*predicate)(ir_instruction *ir); + + /* List of signature_entry */ + exec_list signature_list; + void *mem_ctx; +}; + + +signature_entry * +ir_dead_functions_visitor::get_signature_entry(ir_function_signature *sig) +{ + foreach_iter(exec_list_iterator, iter, this->signature_list) { + signature_entry *entry = (signature_entry *)iter.get(); + if (entry->signature == sig) + return entry; + } + + signature_entry *entry = new(mem_ctx) signature_entry(sig); + this->signature_list.push_tail(entry); + return entry; +} + + +ir_visitor_status +ir_dead_functions_visitor::visit_enter(ir_function_signature *ir) +{ + signature_entry *entry = this->get_signature_entry(ir); + + if (strcmp(ir->function_name(), "main") == 0) { + entry->used = true; + } + + + + return visit_continue; +} + + +ir_visitor_status +ir_dead_functions_visitor::visit_enter(ir_call *ir) +{ + signature_entry *entry = this->get_signature_entry(ir->get_callee()); + + entry->used = true; + + return visit_continue; +} + +bool +do_dead_functions(exec_list *instructions) +{ + ir_dead_functions_visitor v; + bool progress = false; + + visit_list_elements(&v, instructions); + + /* Now that we've figured out which function signatures are used, remove + * the unused ones, and remove function definitions that have no more + * signatures. + */ + foreach_iter(exec_list_iterator, iter, v.signature_list) { + signature_entry *entry = (signature_entry *)iter.get(); + + if (!entry->used) { + entry->signature->remove(); + delete entry->signature; + progress = true; + } + delete(entry); + } + + /* We don't just do this above when we nuked a signature because of + * const pointers. + */ + foreach_iter(exec_list_iterator, iter, *instructions) { + ir_instruction *ir = (ir_instruction *)iter.get(); + ir_function *func = ir->as_function(); + + if (func && func->signatures.is_empty()) { + /* At this point (post-linking), the symbol table is no + * longer in use, so not removing the function from the + * symbol table should be OK. + */ + func->remove(); + delete func; + progress = true; + } + } + + return progress; +} diff --git a/3rdparty/glsl-optimizer/src/glsl/opt_discard_simplification.cpp b/3rdparty/glsl-optimizer/src/glsl/opt_discard_simplification.cpp new file mode 100644 index 000000000..a19947ddd --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/opt_discard_simplification.cpp @@ -0,0 +1,204 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file opt_discard_simplification.cpp + * + * This pass simplifies if-statements and loops containing unconditional + * discards. + * + * Case 1: Both branches contain unconditional discards: + * ----------------------------------------------------- + * + * if (cond) { + * s1; + * discard; + * s2; + * } else { + * s3; + * discard; + * s4; + * } + * + * becomes: + * + * discard + * + * Case 2: The "then" clause contains an unconditional discard: + * ------------------------------------------------------------ + * + * if (cond) { + * s1; + * discard; + * s2; + * } else { + * s3; + * } + * + * becomes: + * + * if (cond) { + * discard; + * } else { + * s3; + * } + * + * Case 3: The "else" clause contains an unconditional discard: + * ------------------------------------------------------------ + * + * if (cond) { + * s1; + * } else { + * s2; + * discard; + * s3; + * } + * + * becomes: + * + * if (cond) { + * s1; + * } else { + * discard; + * } + */ + +#include "glsl_types.h" +#include "ir.h" + +class discard_simplifier : public ir_hierarchical_visitor { +public: + discard_simplifier() + { + this->progress = false; + } + + ir_visitor_status visit_enter(ir_if *); + ir_visitor_status visit_enter(ir_loop *); + ir_visitor_status visit_enter(ir_assignment *); + + bool progress; +}; + +static ir_discard * +find_unconditional_discard(exec_list &instructions) +{ + foreach_list(n, &instructions) { + ir_instruction *ir = (ir_instruction *)n; + + if (ir->ir_type == ir_type_return || + ir->ir_type == ir_type_loop_jump) + return NULL; + + /* So far, this code doesn't know how to look inside of flow + * control to see if a discard later on at this level is + * unconditional. + */ + if (ir->ir_type == ir_type_if || + ir->ir_type == ir_type_loop) + return NULL; + + ir_discard *discard = ir->as_discard(); + if (discard != NULL && discard->condition == NULL) + return discard; + } + return NULL; +} + +static bool +is_only_instruction(ir_discard *discard) +{ + return (discard->prev->is_head_sentinel() && + discard->next->is_tail_sentinel()); +} + +/* We only care about the top level instructions, so don't descend + * into expressions. + */ +ir_visitor_status +discard_simplifier::visit_enter(ir_assignment *ir) +{ + return visit_continue_with_parent; +} + +ir_visitor_status +discard_simplifier::visit_enter(ir_if *ir) +{ + ir_discard *then_discard = find_unconditional_discard(ir->then_instructions); + ir_discard *else_discard = find_unconditional_discard(ir->else_instructions); + + if (then_discard == NULL && else_discard == NULL) + return visit_continue; + + /* If both branches result in discard, replace whole if with discard. */ + if (then_discard != NULL && else_discard != NULL) { + this->progress = true; + ir->replace_with(then_discard); + return visit_continue_with_parent; + } + + /* Otherwise, one branch has a discard. */ + if (then_discard != NULL && !is_only_instruction(then_discard)) { + this->progress = true; + ir->then_instructions.make_empty(); + ir->then_instructions.push_tail(then_discard); + } else if (else_discard != NULL && !is_only_instruction(else_discard)) { + this->progress = true; + ir->else_instructions.make_empty(); + ir->else_instructions.push_tail(else_discard); + } + + visit_list_elements(this, &ir->then_instructions); + return visit_continue_with_parent; +} + +ir_visitor_status +discard_simplifier::visit_enter(ir_loop *ir) +{ + ir_discard *discard = find_unconditional_discard(ir->body_instructions); + + if (discard) { + ir->replace_with(discard); + return visit_continue_with_parent; + } + + return visit_continue; +} + +bool +do_discard_simplification(exec_list *instructions) +{ + /* Look for a top-level unconditional discard */ + ir_discard *discard = find_unconditional_discard(*instructions); + if (discard != NULL) { + instructions->make_empty(); + instructions->push_tail(discard); + return true; + } + + discard_simplifier v; + + visit_list_elements(&v, instructions); + + return v.progress; +} diff --git a/3rdparty/glsl-optimizer/src/glsl/opt_function_inlining.cpp b/3rdparty/glsl-optimizer/src/glsl/opt_function_inlining.cpp new file mode 100644 index 000000000..b46a96911 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/opt_function_inlining.cpp @@ -0,0 +1,491 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file opt_function_inlining.cpp + * + * Replaces calls to functions with the body of the function. + */ + +#include +#include "ir.h" +#include "ir_visitor.h" +#include "ir_function_inlining.h" +#include "ir_expression_flattening.h" +#include "glsl_types.h" +#include "program/hash_table.h" + +static void +do_sampler_replacement(exec_list *instructions, + ir_variable *sampler, + ir_dereference *deref); + +class ir_function_inlining_visitor : public ir_hierarchical_visitor { +public: + ir_function_inlining_visitor() + { + progress = false; + current_function = NULL; + } + + virtual ~ir_function_inlining_visitor() + { + /* empty */ + } + + virtual ir_visitor_status visit_enter(ir_expression *); + virtual ir_visitor_status visit_enter(ir_call *); + virtual ir_visitor_status visit_enter(ir_assignment *); + virtual ir_visitor_status visit_enter(ir_return *); + virtual ir_visitor_status visit_enter(ir_texture *); + virtual ir_visitor_status visit_enter(ir_swizzle *); + + virtual ir_visitor_status visit_enter(ir_function_signature *sig) + { + this->current_function = sig; + return ir_hierarchical_visitor::visit_enter(sig); + } + virtual ir_visitor_status visit_leave(ir_function_signature *sig) + { + this->current_function = NULL; + return ir_hierarchical_visitor::visit_leave(sig); + } + + ir_function_signature* current_function; + bool progress; + +}; + + +bool +automatic_inlining_predicate(ir_instruction *ir) +{ + ir_call *call = ir->as_call(); + + if (call && can_inline(call)) + return true; + + return false; +} + +bool +do_function_inlining(exec_list *instructions) +{ + ir_function_inlining_visitor v; + + do_expression_flattening(instructions, automatic_inlining_predicate); + + v.run(instructions); + + return v.progress; +} + +static void +replace_return_with_assignment(ir_instruction *ir, void *data) +{ + void *ctx = ralloc_parent(ir); + ir_variable *retval = (ir_variable *)data; + ir_return *ret = ir->as_return(); + + if (ret) { + if (ret->value) { + ir_rvalue *lhs = new(ctx) ir_dereference_variable(retval); + ret->replace_with(new(ctx) ir_assignment(lhs, ret->value, NULL)); + } else { + /* un-valued return has to be the last return, or we shouldn't + * have reached here. (see can_inline()). + */ + assert(ret->next->is_tail_sentinel()); + ret->remove(); + } + } +} + +static void rename_inlined_variable (ir_instruction* new_ir, ir_function_signature* func) +{ + ir_variable *new_var = new_ir->as_variable(); + if (!new_var) + return; + + // go through callee, see if we have any variables that match this one + bool progress; + int counter = 0; + do + { + progress = false; + foreach_iter(exec_list_iterator, iter, func->parameters) + { + const ir_variable* var = (const ir_variable*) iter.get(); + if (!strcmp(var->name, new_var->name)) + { + progress = true; + ralloc_asprintf_append((char**)&new_var->name, "_i%d", counter++); + } + } + foreach_iter(exec_list_iterator, iter, func->body) + { + ir_instruction *ir = (ir_instruction*)iter.get(); + const ir_variable *var = ir->as_variable(); + if (!var) + continue; + if (!strcmp(var->name, new_var->name)) + { + progress = true; + ralloc_asprintf_append((char**)&new_var->name, "_i%d", counter++); + } + } + } + while (progress); +} + +ir_rvalue * +ir_call::generate_inline(ir_instruction *next_ir, ir_function_signature* parent) +{ + void *ctx = ralloc_parent(this); + ir_variable **parameters; + int num_parameters; + int i; + ir_variable *retval = NULL; + struct hash_table *ht; + + ht = hash_table_ctor(0, hash_table_pointer_hash, hash_table_pointer_compare); + + num_parameters = 0; + foreach_iter(exec_list_iterator, iter_sig, this->callee->parameters) + num_parameters++; + + parameters = new ir_variable *[num_parameters]; + + /* Generate storage for the return value. */ + if (!this->callee->return_type->is_void()) { + retval = new(ctx) ir_variable(this->callee->return_type, "_ret_val", + ir_var_temporary, this->callee->precision); + next_ir->insert_before(retval); + } + + /* Generate the declarations for the parameters to our inlined code, + * and set up the mapping of real function body variables to ours. + */ + i = 0; + exec_list_iterator sig_param_iter = this->callee->parameters.iterator(); + exec_list_iterator param_iter = this->actual_parameters.iterator(); + glsl_precision prec_params_max = glsl_precision_undefined; + for (i = 0; i < num_parameters; i++) { + ir_variable *sig_param = (ir_variable *) sig_param_iter.get(); + ir_rvalue *param = (ir_rvalue *) param_iter.get(); + + /* Generate a new variable for the parameter. */ + if (sig_param->type->base_type == GLSL_TYPE_SAMPLER) { + /* For samplers, we want the inlined sampler references + * referencing the passed in sampler variable, since that + * will have the location information, which an assignment of + * a sampler wouldn't. Fix it up below. + */ + parameters[i] = NULL; + } else { + parameters[i] = sig_param->clone(ctx, ht); + rename_inlined_variable (parameters[i], parent); + parameters[i]->mode = ir_var_auto; + + parameters[i]->precision = (glsl_precision)parameters[i]->precision; + if (parameters[i]->precision == glsl_precision_undefined) + parameters[i]->precision = param->get_precision(); + prec_params_max = higher_precision (prec_params_max, (glsl_precision)parameters[i]->precision); + + /* Remove the read-only decoration becuase we're going to write + * directly to this variable. If the cloned variable is left + * read-only and the inlined function is inside a loop, the loop + * analysis code will get confused. + */ + parameters[i]->read_only = false; + next_ir->insert_before(parameters[i]); + } + + /* Move the actual param into our param variable if it's an 'in' type. */ + if (parameters[i] && (sig_param->mode == ir_var_in || + sig_param->mode == ir_var_const_in || + sig_param->mode == ir_var_inout)) { + ir_assignment *assign; + + assign = new(ctx) ir_assignment(new(ctx) ir_dereference_variable(parameters[i]), + param, NULL); + next_ir->insert_before(assign); + } + + sig_param_iter.next(); + param_iter.next(); + } + + exec_list new_instructions; + + /* Generate the inlined body of the function to a new list */ + foreach_iter(exec_list_iterator, iter, callee->body) { + ir_instruction *ir = (ir_instruction *)iter.get(); + ir_instruction *new_ir = ir->clone(ctx, ht); + rename_inlined_variable (new_ir, parent); + + new_instructions.push_tail(new_ir); + visit_tree(new_ir, replace_return_with_assignment, retval); + } + + /* If any samplers were passed in, replace any deref of the sampler + * with a deref of the sampler argument. + */ + param_iter = this->actual_parameters.iterator(); + sig_param_iter = this->callee->parameters.iterator(); + for (i = 0; i < num_parameters; i++) { + ir_instruction *const param = (ir_instruction *) param_iter.get(); + ir_variable *sig_param = (ir_variable *) sig_param_iter.get(); + + if (sig_param->type->base_type == GLSL_TYPE_SAMPLER) { + ir_dereference *deref = param->as_dereference(); + + assert(deref); + do_sampler_replacement(&new_instructions, sig_param, deref); + } + param_iter.next(); + sig_param_iter.next(); + } + + /* Now push those new instructions in. */ + next_ir->insert_before(&new_instructions); + + /* Copy back the value of any 'out' parameters from the function body + * variables to our own. + */ + i = 0; + param_iter = this->actual_parameters.iterator(); + sig_param_iter = this->callee->parameters.iterator(); + for (i = 0; i < num_parameters; i++) { + ir_instruction *const param = (ir_instruction *) param_iter.get(); + const ir_variable *const sig_param = (ir_variable *) sig_param_iter.get(); + + /* Move our param variable into the actual param if it's an 'out' type. */ + if (parameters[i] && (sig_param->mode == ir_var_out || + sig_param->mode == ir_var_inout)) { + ir_assignment *assign; + + assign = new(ctx) ir_assignment(param->clone(ctx, NULL)->as_rvalue(), + new(ctx) ir_dereference_variable(parameters[i]), + NULL); + next_ir->insert_before(assign); + } + + param_iter.next(); + sig_param_iter.next(); + } + + delete [] parameters; + + hash_table_dtor(ht); + + if (retval) + return new(ctx) ir_dereference_variable(retval); + else + return NULL; +} + + +ir_visitor_status +ir_function_inlining_visitor::visit_enter(ir_expression *ir) +{ + (void) ir; + return visit_continue_with_parent; +} + + +ir_visitor_status +ir_function_inlining_visitor::visit_enter(ir_return *ir) +{ + (void) ir; + return visit_continue_with_parent; +} + + +ir_visitor_status +ir_function_inlining_visitor::visit_enter(ir_texture *ir) +{ + (void) ir; + return visit_continue_with_parent; +} + + +ir_visitor_status +ir_function_inlining_visitor::visit_enter(ir_swizzle *ir) +{ + (void) ir; + return visit_continue_with_parent; +} + + +ir_visitor_status +ir_function_inlining_visitor::visit_enter(ir_call *ir) +{ + if (can_inline(ir)) { + /* If the call was part of some tree, then it should have been + * flattened out or we shouldn't have seen it because of a + * visit_continue_with_parent in this visitor. + */ + assert(ir == base_ir); + + (void) ir->generate_inline(ir, this->current_function); + ir->remove(); + this->progress = true; + } + + return visit_continue; +} + + +ir_visitor_status +ir_function_inlining_visitor::visit_enter(ir_assignment *ir) +{ + ir_call *call = ir->rhs->as_call(); + if (!call || !can_inline(call)) + return visit_continue; + + /* generates the parameter setup, function body, and returns the return + * value of the function + */ + ir_rvalue *rhs = call->generate_inline(ir, this->current_function); + assert(rhs); + + // if function's return type had no precision specified, assign + // precision from lhs + if (rhs && rhs->get_precision() == glsl_precision_undefined) { + rhs->set_precision (ir->lhs->get_precision()); + ir_dereference_variable* deref = rhs->as_dereference_variable(); + if (deref) + deref->variable_referenced()->precision = ir->lhs->get_precision(); + } + + + ir->rhs = rhs; + this->progress = true; + + return visit_continue; +} + +/** + * Replaces references to the "sampler" variable with a clone of "deref." + * + * From the spec, samplers can appear in the tree as function + * (non-out) parameters and as the result of array indexing and + * structure field selection. In our builtin implementation, they + * also appear in the sampler field of an ir_tex instruction. + */ + +class ir_sampler_replacement_visitor : public ir_hierarchical_visitor { +public: + ir_sampler_replacement_visitor(ir_variable *sampler, ir_dereference *deref) + { + this->sampler = sampler; + this->deref = deref; + } + + virtual ~ir_sampler_replacement_visitor() + { + } + + virtual ir_visitor_status visit_leave(ir_call *); + virtual ir_visitor_status visit_leave(ir_dereference_array *); + virtual ir_visitor_status visit_leave(ir_dereference_record *); + virtual ir_visitor_status visit_leave(ir_texture *); + + void replace_deref(ir_dereference **deref); + void replace_rvalue(ir_rvalue **rvalue); + + ir_variable *sampler; + ir_dereference *deref; +}; + +void +ir_sampler_replacement_visitor::replace_deref(ir_dereference **deref) +{ + ir_dereference_variable *deref_var = (*deref)->as_dereference_variable(); + if (deref_var && deref_var->var == this->sampler) { + *deref = this->deref->clone(ralloc_parent(*deref), NULL); + } +} + +void +ir_sampler_replacement_visitor::replace_rvalue(ir_rvalue **rvalue) +{ + if (!*rvalue) + return; + + ir_dereference *deref = (*rvalue)->as_dereference(); + + if (!deref) + return; + + replace_deref(&deref); + *rvalue = deref; +} + +ir_visitor_status +ir_sampler_replacement_visitor::visit_leave(ir_texture *ir) +{ + replace_deref(&ir->sampler); + + return visit_continue; +} + +ir_visitor_status +ir_sampler_replacement_visitor::visit_leave(ir_dereference_array *ir) +{ + replace_rvalue(&ir->array); + return visit_continue; +} + +ir_visitor_status +ir_sampler_replacement_visitor::visit_leave(ir_dereference_record *ir) +{ + replace_rvalue(&ir->record); + return visit_continue; +} + +ir_visitor_status +ir_sampler_replacement_visitor::visit_leave(ir_call *ir) +{ + foreach_iter(exec_list_iterator, iter, *ir) { + ir_rvalue *param = (ir_rvalue *)iter.get(); + ir_rvalue *new_param = param; + replace_rvalue(&new_param); + + if (new_param != param) { + param->replace_with(new_param); + } + } + return visit_continue; +} + +static void +do_sampler_replacement(exec_list *instructions, + ir_variable *sampler, + ir_dereference *deref) +{ + ir_sampler_replacement_visitor v(sampler, deref); + + visit_list_elements(&v, instructions); +} diff --git a/3rdparty/glsl-optimizer/src/glsl/opt_if_simplification.cpp b/3rdparty/glsl-optimizer/src/glsl/opt_if_simplification.cpp new file mode 100644 index 000000000..29b1d18aa --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/opt_if_simplification.cpp @@ -0,0 +1,94 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file opt_if_simplification.cpp + * + * Moves constant branches of if statements out to the surrounding + * instruction stream. + */ + +#include "ir.h" + +class ir_if_simplification_visitor : public ir_hierarchical_visitor { +public: + ir_if_simplification_visitor() + { + this->made_progress = false; + } + + ir_visitor_status visit_leave(ir_if *); + ir_visitor_status visit_enter(ir_assignment *); + + bool made_progress; +}; + +/* We only care about the top level "if" instructions, so don't + * descend into expressions. + */ +ir_visitor_status +ir_if_simplification_visitor::visit_enter(ir_assignment *ir) +{ + return visit_continue_with_parent; +} + +bool +do_if_simplification(exec_list *instructions) +{ + ir_if_simplification_visitor v; + + v.run(instructions); + return v.made_progress; +} + + +ir_visitor_status +ir_if_simplification_visitor::visit_leave(ir_if *ir) +{ + /* FINISHME: Ideally there would be a way to note that the condition results + * FINISHME: in a constant before processing both of the other subtrees. + * FINISHME: This can probably be done with some flags, but it would take + * FINISHME: some work to get right. + */ + ir_constant *condition_constant = ir->condition->constant_expression_value(); + if (condition_constant) { + /* Move the contents of the one branch of the conditional + * that matters out. + */ + if (condition_constant->value.b[0]) { + foreach_iter(exec_list_iterator, then_iter, ir->then_instructions) { + ir_instruction *then_ir = (ir_instruction *)then_iter.get(); + ir->insert_before(then_ir); + } + } else { + foreach_iter(exec_list_iterator, else_iter, ir->else_instructions) { + ir_instruction *else_ir = (ir_instruction *)else_iter.get(); + ir->insert_before(else_ir); + } + } + ir->remove(); + this->made_progress = true; + } + + return visit_continue; +} diff --git a/3rdparty/glsl-optimizer/src/glsl/opt_noop_swizzle.cpp b/3rdparty/glsl-optimizer/src/glsl/opt_noop_swizzle.cpp new file mode 100644 index 000000000..0a906aaf1 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/opt_noop_swizzle.cpp @@ -0,0 +1,80 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file opt_noop_swizzle.cpp + * + * If a swizzle doesn't change the order or count of components, then + * remove the swizzle so that other optimization passes see the value + * behind it. + */ + +#include "ir.h" +#include "ir_visitor.h" +#include "ir_rvalue_visitor.h" +#include "ir_print_visitor.h" +#include "glsl_types.h" + +class ir_noop_swizzle_visitor : public ir_rvalue_visitor { +public: + ir_noop_swizzle_visitor() + { + this->progress = false; + } + + void handle_rvalue(ir_rvalue **rvalue); + bool progress; +}; + +void +ir_noop_swizzle_visitor::handle_rvalue(ir_rvalue **rvalue) +{ + if (!*rvalue) + return; + + ir_swizzle *swiz = (*rvalue)->as_swizzle(); + if (!swiz || swiz->type != swiz->val->type) + return; + + int elems = swiz->val->type->vector_elements; + if (swiz->mask.x != 0) + return; + if (elems >= 2 && swiz->mask.y != 1) + return; + if (elems >= 3 && swiz->mask.z != 2) + return; + if (elems >= 4 && swiz->mask.w != 3) + return; + + this->progress = true; + *rvalue = swiz->val; +} + +bool +do_noop_swizzle(exec_list *instructions) +{ + ir_noop_swizzle_visitor v; + visit_list_elements(&v, instructions); + + return v.progress; +} diff --git a/3rdparty/glsl-optimizer/src/glsl/opt_redundant_jumps.cpp b/3rdparty/glsl-optimizer/src/glsl/opt_redundant_jumps.cpp new file mode 100644 index 000000000..f350fa947 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/opt_redundant_jumps.cpp @@ -0,0 +1,120 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file opt_redundant_jumps.cpp + * Remove certain types of redundant jumps + */ + +#include "ir.h" + +class redundant_jumps_visitor : public ir_hierarchical_visitor { +public: + redundant_jumps_visitor() + { + this->progress = false; + } + + virtual ir_visitor_status visit_leave(ir_if *); + virtual ir_visitor_status visit_leave(ir_loop *); + virtual ir_visitor_status visit_enter(ir_assignment *); + + bool progress; +}; + +/* We only care about the top level instructions, so don't descend + * into expressions. + */ +ir_visitor_status +redundant_jumps_visitor::visit_enter(ir_assignment *ir) +{ + return visit_continue_with_parent; +} + +ir_visitor_status +redundant_jumps_visitor::visit_leave(ir_if *ir) +{ + /* If the last instruction in both branches is a 'break' or a 'continue', + * pull it out of the branches and insert it after the if-statment. Note + * that both must be the same type (either 'break' or 'continue'). + */ + ir_instruction *const last_then = + (ir_instruction *) ir->then_instructions.get_tail(); + ir_instruction *const last_else = + (ir_instruction *) ir->else_instructions.get_tail(); + + if ((last_then == NULL) || (last_else == NULL)) + return visit_continue; + + if ((last_then->ir_type != ir_type_loop_jump) + || (last_else->ir_type != ir_type_loop_jump)) + return visit_continue; + + ir_loop_jump *const then_jump = (ir_loop_jump *) last_then; + ir_loop_jump *const else_jump = (ir_loop_jump *) last_else; + + if (then_jump->mode != else_jump->mode) + return visit_continue; + + then_jump->remove(); + else_jump->remove(); + this->progress = true; + + ir->insert_after(then_jump); + + /* If both branchs of the if-statement are now empty, remove the + * if-statement. + */ + if (ir->then_instructions.is_empty() && ir->else_instructions.is_empty()) + ir->remove(); + + return visit_continue; +} + + +ir_visitor_status +redundant_jumps_visitor::visit_leave(ir_loop *ir) +{ + /* If the last instruction of a loop body is a 'continue', remove it. + */ + ir_instruction *const last = + (ir_instruction *) ir->body_instructions.get_tail(); + + if (last && (last->ir_type == ir_type_loop_jump) + && (((ir_loop_jump *) last)->mode == ir_loop_jump::jump_continue)) { + last->remove(); + this->progress = true; + } + + return visit_continue; +} + + +bool +optimize_redundant_jumps(exec_list *instructions) +{ + redundant_jumps_visitor v; + + v.run(instructions); + return v.progress; +} diff --git a/3rdparty/glsl-optimizer/src/glsl/opt_structure_splitting.cpp b/3rdparty/glsl-optimizer/src/glsl/opt_structure_splitting.cpp new file mode 100644 index 000000000..e7563fbc9 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/opt_structure_splitting.cpp @@ -0,0 +1,367 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file opt_structure_splitting.cpp + * + * If a structure is only ever referenced by its components, then + * split those components out to individual variables so they can be + * handled normally by other optimization passes. + * + * This skips structures like uniforms, which need to be accessible as + * structures for their access by the GL. + */ + +#include "ir.h" +#include "ir_visitor.h" +#include "ir_print_visitor.h" +#include "ir_rvalue_visitor.h" +#include "glsl_types.h" + +static bool debug = false; + +// XXX using variable_entry2 here to avoid collision (MSVC multiply-defined +// function) with the variable_entry class seen in ir_variable_refcount.h +// Perhaps we can use the one in ir_variable_refcount.h and make this class +// here go away? +class variable_entry2 : public exec_node +{ +public: + variable_entry2(ir_variable *var) + { + this->var = var; + this->whole_structure_access = 0; + this->declaration = false; + this->components = NULL; + this->mem_ctx = NULL; + } + + ir_variable *var; /* The key: the variable's pointer. */ + + /** Number of times the variable is referenced, including assignments. */ + unsigned whole_structure_access; + + bool declaration; /* If the variable had a decl in the instruction stream */ + + ir_variable **components; + + /** ralloc_parent(this->var) -- the shader's ralloc context. */ + void *mem_ctx; +}; + + +class ir_structure_reference_visitor : public ir_hierarchical_visitor { +public: + ir_structure_reference_visitor(void) + { + this->mem_ctx = ralloc_context(NULL); + this->variable_list.make_empty(); + } + + ~ir_structure_reference_visitor(void) + { + ralloc_free(mem_ctx); + } + + virtual ir_visitor_status visit(ir_variable *); + virtual ir_visitor_status visit(ir_dereference_variable *); + virtual ir_visitor_status visit_enter(ir_dereference_record *); + virtual ir_visitor_status visit_enter(ir_assignment *); + virtual ir_visitor_status visit_enter(ir_function_signature *); + + variable_entry2 *get_variable_entry2(ir_variable *var); + + /* List of split_var_entry */ + exec_list variable_list; + + void *mem_ctx; +}; + +variable_entry2 * +ir_structure_reference_visitor::get_variable_entry2(ir_variable *var) +{ + assert(var); + + if (!var->type->is_record() || var->mode == ir_var_uniform) + return NULL; + + foreach_iter(exec_list_iterator, iter, this->variable_list) { + variable_entry2 *entry = (variable_entry2 *)iter.get(); + if (entry->var == var) + return entry; + } + + variable_entry2 *entry = new(mem_ctx) variable_entry2(var); + this->variable_list.push_tail(entry); + return entry; +} + + +ir_visitor_status +ir_structure_reference_visitor::visit(ir_variable *ir) +{ + variable_entry2 *entry = this->get_variable_entry2(ir); + + if (entry) + entry->declaration = true; + + return visit_continue; +} + +ir_visitor_status +ir_structure_reference_visitor::visit(ir_dereference_variable *ir) +{ + ir_variable *const var = ir->variable_referenced(); + variable_entry2 *entry = this->get_variable_entry2(var); + + if (entry) + entry->whole_structure_access++; + + return visit_continue; +} + +ir_visitor_status +ir_structure_reference_visitor::visit_enter(ir_dereference_record *ir) +{ + (void) ir; + /* Don't descend into the ir_dereference_variable below. */ + return visit_continue_with_parent; +} + +ir_visitor_status +ir_structure_reference_visitor::visit_enter(ir_assignment *ir) +{ + /* If there are no structure references yet, no need to bother with + * processing the expression tree. + */ + if (this->variable_list.is_empty()) + return visit_continue_with_parent; + + if (ir->lhs->as_dereference_variable() && + ir->rhs->as_dereference_variable() && + !ir->condition) { + /* We'll split copies of a structure to copies of components, so don't + * descend to the ir_dereference_variables. + */ + return visit_continue_with_parent; + } + return visit_continue; +} + +ir_visitor_status +ir_structure_reference_visitor::visit_enter(ir_function_signature *ir) +{ + /* We don't want to descend into the function parameters and + * dead-code eliminate them, so just accept the body here. + */ + visit_list_elements(this, &ir->body); + return visit_continue_with_parent; +} + +class ir_structure_splitting_visitor : public ir_rvalue_visitor { +public: + ir_structure_splitting_visitor(exec_list *vars) + { + this->variable_list = vars; + } + + virtual ~ir_structure_splitting_visitor() + { + } + + virtual ir_visitor_status visit_leave(ir_assignment *); + + void split_deref(ir_dereference **deref); + void handle_rvalue(ir_rvalue **rvalue); + variable_entry2 *get_splitting_entry(ir_variable *var); + + exec_list *variable_list; + void *mem_ctx; +}; + +variable_entry2 * +ir_structure_splitting_visitor::get_splitting_entry(ir_variable *var) +{ + assert(var); + + if (!var->type->is_record()) + return NULL; + + foreach_iter(exec_list_iterator, iter, *this->variable_list) { + variable_entry2 *entry = (variable_entry2 *)iter.get(); + if (entry->var == var) { + return entry; + } + } + + return NULL; +} + +void +ir_structure_splitting_visitor::split_deref(ir_dereference **deref) +{ + if ((*deref)->ir_type != ir_type_dereference_record) + return; + + ir_dereference_record *deref_record = (ir_dereference_record *)*deref; + ir_dereference_variable *deref_var = deref_record->record->as_dereference_variable(); + if (!deref_var) + return; + + variable_entry2 *entry = get_splitting_entry(deref_var->var); + if (!entry) + return; + + unsigned int i; + for (i = 0; i < entry->var->type->length; i++) { + if (strcmp(deref_record->field, + entry->var->type->fields.structure[i].name) == 0) + break; + } + assert(i != entry->var->type->length); + + *deref = new(entry->mem_ctx) ir_dereference_variable(entry->components[i]); +} + +void +ir_structure_splitting_visitor::handle_rvalue(ir_rvalue **rvalue) +{ + if (!*rvalue) + return; + + ir_dereference *deref = (*rvalue)->as_dereference(); + + if (!deref) + return; + + split_deref(&deref); + *rvalue = deref; +} + +ir_visitor_status +ir_structure_splitting_visitor::visit_leave(ir_assignment *ir) +{ + ir_dereference_variable *lhs_deref = ir->lhs->as_dereference_variable(); + ir_dereference_variable *rhs_deref = ir->rhs->as_dereference_variable(); + variable_entry2 *lhs_entry = lhs_deref ? get_splitting_entry(lhs_deref->var) : NULL; + variable_entry2 *rhs_entry = rhs_deref ? get_splitting_entry(rhs_deref->var) : NULL; + const glsl_type *type = ir->rhs->type; + + if ((lhs_entry || rhs_entry) && !ir->condition) { + for (unsigned int i = 0; i < type->length; i++) { + ir_dereference *new_lhs, *new_rhs; + void *mem_ctx = lhs_entry ? lhs_entry->mem_ctx : rhs_entry->mem_ctx; + + if (lhs_entry) { + new_lhs = new(mem_ctx) ir_dereference_variable(lhs_entry->components[i]); + } else { + new_lhs = new(mem_ctx) + ir_dereference_record(ir->lhs->clone(mem_ctx, NULL), + type->fields.structure[i].name); + } + + if (rhs_entry) { + new_rhs = new(mem_ctx) ir_dereference_variable(rhs_entry->components[i]); + } else { + new_rhs = new(mem_ctx) + ir_dereference_record(ir->rhs->clone(mem_ctx, NULL), + type->fields.structure[i].name); + } + + ir->insert_before(new(mem_ctx) ir_assignment(new_lhs, + new_rhs, + NULL)); + } + ir->remove(); + } else { + handle_rvalue(&ir->rhs); + split_deref(&ir->lhs); + } + + handle_rvalue(&ir->condition); + + return visit_continue; +} + +bool +do_structure_splitting(exec_list *instructions) +{ + ir_structure_reference_visitor refs; + + visit_list_elements(&refs, instructions); + + /* Trim out variables we can't split. */ + foreach_iter(exec_list_iterator, iter, refs.variable_list) { + variable_entry2 *entry = (variable_entry2 *)iter.get(); + + if (debug) { + printf("structure %s@%p: decl %d, whole_access %d\n", + entry->var->name, (void *) entry->var, entry->declaration, + entry->whole_structure_access); + } + + if (!entry->declaration || entry->whole_structure_access) { + entry->remove(); + } + } + + if (refs.variable_list.is_empty()) + return false; + + void *mem_ctx = ralloc_context(NULL); + + /* Replace the decls of the structures to be split with their split + * components. + */ + foreach_iter(exec_list_iterator, iter, refs.variable_list) { + variable_entry2 *entry = (variable_entry2 *)iter.get(); + const struct glsl_type *type = entry->var->type; + + entry->mem_ctx = ralloc_parent(entry->var); + + entry->components = ralloc_array(mem_ctx, + ir_variable *, + type->length); + + for (unsigned int i = 0; i < entry->var->type->length; i++) { + const char *name = ralloc_asprintf(mem_ctx, "%s_%s", + entry->var->name, + type->fields.structure[i].name); + + entry->components[i] = + new(entry->mem_ctx) ir_variable(type->fields.structure[i].type, + name, + ir_var_temporary, type->fields.structure[i].precision); + entry->var->insert_before(entry->components[i]); + } + + entry->var->remove(); + } + + ir_structure_splitting_visitor split(&refs.variable_list); + visit_list_elements(&split, instructions); + + ralloc_free(mem_ctx); + + return true; +} diff --git a/3rdparty/glsl-optimizer/src/glsl/opt_swizzle_swizzle.cpp b/3rdparty/glsl-optimizer/src/glsl/opt_swizzle_swizzle.cpp new file mode 100644 index 000000000..bc442fa86 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/opt_swizzle_swizzle.cpp @@ -0,0 +1,93 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file opt_swizzle_swizzle.cpp + * + * Eliminates the second swizzle in a swizzle chain. + */ + +#include "ir.h" +#include "ir_visitor.h" +#include "ir_optimization.h" +#include "glsl_types.h" + +class ir_swizzle_swizzle_visitor : public ir_hierarchical_visitor { +public: + ir_swizzle_swizzle_visitor() + { + progress = false; + } + + virtual ir_visitor_status visit_enter(ir_swizzle *); + + bool progress; +}; + +ir_visitor_status +ir_swizzle_swizzle_visitor::visit_enter(ir_swizzle *ir) +{ + int mask2[4]; + + ir_swizzle *swiz2 = ir->val->as_swizzle(); + if (!swiz2) + return visit_continue; + + memset(&mask2, 0, sizeof(mask2)); + if (swiz2->mask.num_components >= 1) + mask2[0] = swiz2->mask.x; + if (swiz2->mask.num_components >= 2) + mask2[1] = swiz2->mask.y; + if (swiz2->mask.num_components >= 3) + mask2[2] = swiz2->mask.z; + if (swiz2->mask.num_components >= 4) + mask2[3] = swiz2->mask.w; + + if (ir->mask.num_components >= 1) + ir->mask.x = mask2[ir->mask.x]; + if (ir->mask.num_components >= 2) + ir->mask.y = mask2[ir->mask.y]; + if (ir->mask.num_components >= 3) + ir->mask.z = mask2[ir->mask.z]; + if (ir->mask.num_components >= 4) + ir->mask.w = mask2[ir->mask.w]; + + ir->val = swiz2->val; + + this->progress = true; + + return visit_continue; +} + +/** + * Does a copy propagation pass on the code present in the instruction stream. + */ +bool +do_swizzle_swizzle(exec_list *instructions) +{ + ir_swizzle_swizzle_visitor v; + + v.run(instructions); + + return v.progress; +} diff --git a/3rdparty/glsl-optimizer/src/glsl/opt_tree_grafting.cpp b/3rdparty/glsl-optimizer/src/glsl/opt_tree_grafting.cpp new file mode 100644 index 000000000..903b79e40 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/opt_tree_grafting.cpp @@ -0,0 +1,389 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file opt_tree_grafting.cpp + * + * Takes assignments to variables that are dereferenced only once and + * pastes the RHS expression into where the variable is dereferenced. + * + * In the process of various operations like function inlining and + * tertiary op handling, we'll end up with our expression trees having + * been chopped up into a series of assignments of short expressions + * to temps. Other passes like ir_algebraic.cpp would prefer to see + * the deepest expression trees they can to try to optimize them. + * + * This is a lot like copy propagaton. In comparison, copy + * propagation only acts on plain copies, not arbitrary expressions on + * the RHS. Generally, we wouldn't want to go pasting some + * complicated expression everywhere it got used, though, so we don't + * handle expressions in that pass. + * + * The hard part is making sure we don't move an expression across + * some other assignments that would change the value of the + * expression. So we split this into two passes: First, find the + * variables in our scope which are written to once and read once, and + * then go through basic blocks seeing if we find an opportunity to + * move those expressions safely. + */ + +#include "ir.h" +#include "ir_visitor.h" +#include "ir_variable_refcount.h" +#include "ir_basic_block.h" +#include "ir_optimization.h" +#include "glsl_types.h" + +static bool debug = false; + +class ir_tree_grafting_visitor : public ir_hierarchical_visitor { +public: + ir_tree_grafting_visitor(ir_assignment *graft_assign, + ir_variable *graft_var) + { + this->progress = false; + this->graft_assign = graft_assign; + this->graft_var = graft_var; + } + + virtual ir_visitor_status visit_leave(class ir_assignment *); + virtual ir_visitor_status visit_enter(class ir_assignment *); + virtual ir_visitor_status visit_enter(class ir_call *); + virtual ir_visitor_status visit_enter(class ir_expression *); + virtual ir_visitor_status visit_enter(class ir_function *); + virtual ir_visitor_status visit_enter(class ir_function_signature *); + virtual ir_visitor_status visit_enter(class ir_if *); + virtual ir_visitor_status visit_enter(class ir_loop *); + virtual ir_visitor_status visit_enter(class ir_swizzle *); + virtual ir_visitor_status visit_enter(class ir_texture *); + + bool do_graft(ir_rvalue **rvalue); + + bool progress; + ir_variable *graft_var; + ir_assignment *graft_assign; +}; + +struct find_deref_info { + ir_variable *var; + bool found; +}; + +void +dereferences_variable_callback(ir_instruction *ir, void *data) +{ + struct find_deref_info *info = (struct find_deref_info *)data; + ir_dereference_variable *deref = ir->as_dereference_variable(); + + if (deref && deref->var == info->var) + info->found = true; +} + +static bool +dereferences_variable(ir_instruction *ir, ir_variable *var) +{ + struct find_deref_info info; + + info.var = var; + info.found = false; + + visit_tree(ir, dereferences_variable_callback, &info); + + return info.found; +} + +bool +ir_tree_grafting_visitor::do_graft(ir_rvalue **rvalue) +{ + if (!*rvalue) + return false; + + ir_dereference_variable *deref = (*rvalue)->as_dereference_variable(); + + if (!deref || deref->var != this->graft_var) + return false; + + glsl_precision rvl_prec = deref->get_precision(); + glsl_precision rhs_prec = this->graft_assign->rhs->get_precision(); + if (rvl_prec != rhs_prec && rvl_prec != glsl_precision_undefined && rhs_prec != glsl_precision_undefined) + return false; + + if (debug) { + printf("GRAFTING:\n"); + this->graft_assign->print(); + printf("\n"); + printf("TO:\n"); + (*rvalue)->print(); + printf("\n"); + } + + this->graft_assign->remove(); + *rvalue = this->graft_assign->rhs; + + this->progress = true; + return true; +} + +ir_visitor_status +ir_tree_grafting_visitor::visit_enter(ir_loop *ir) +{ + (void)ir; + /* Do not traverse into the body of the loop since that is a + * different basic block. + */ + return visit_stop; +} + +ir_visitor_status +ir_tree_grafting_visitor::visit_leave(ir_assignment *ir) +{ + if (do_graft(&ir->rhs) || + do_graft(&ir->condition)) + return visit_stop; + + /* If this assignment updates a variable used in the assignment + * we're trying to graft, then we're done. + */ + if (dereferences_variable(this->graft_assign->rhs, + ir->lhs->variable_referenced())) { + if (debug) { + printf("graft killed by: "); + ir->print(); + printf("\n"); + } + return visit_stop; + } + + return visit_continue; +} + +ir_visitor_status +ir_tree_grafting_visitor::visit_enter(ir_assignment *ir) +{ + // if we're entering into assignment of different precision, leave now + if (ir->lhs->get_precision() != this->graft_var->precision && ir->lhs->get_precision() != glsl_precision_undefined && this->graft_var->precision != glsl_precision_undefined) + return visit_continue_with_parent; + return visit_continue; +} + + +ir_visitor_status +ir_tree_grafting_visitor::visit_enter(ir_function *ir) +{ + (void) ir; + return visit_continue_with_parent; +} + +ir_visitor_status +ir_tree_grafting_visitor::visit_enter(ir_function_signature *ir) +{ + (void)ir; + return visit_continue_with_parent; +} + +ir_visitor_status +ir_tree_grafting_visitor::visit_enter(ir_call *ir) +{ + exec_list_iterator sig_iter = ir->get_callee()->parameters.iterator(); + /* Reminder: iterating ir_call iterates its parameters. */ + foreach_iter(exec_list_iterator, iter, *ir) { + ir_variable *sig_param = (ir_variable *)sig_iter.get(); + ir_rvalue *ir = (ir_rvalue *)iter.get(); + ir_rvalue *new_ir = ir; + + if (sig_param->mode != ir_var_in && sig_param->mode != ir_var_const_in) + continue; + + if (do_graft(&new_ir)) { + ir->replace_with(new_ir); + return visit_stop; + } + sig_iter.next(); + } + + return visit_continue; +} + +ir_visitor_status +ir_tree_grafting_visitor::visit_enter(ir_expression *ir) +{ + for (unsigned int i = 0; i < ir->get_num_operands(); i++) { + if (do_graft(&ir->operands[i])) + return visit_stop; + } + + return visit_continue; +} + +ir_visitor_status +ir_tree_grafting_visitor::visit_enter(ir_if *ir) +{ + if (do_graft(&ir->condition)) + return visit_stop; + + /* Do not traverse into the body of the if-statement since that is a + * different basic block. + */ + return visit_continue_with_parent; +} + +ir_visitor_status +ir_tree_grafting_visitor::visit_enter(ir_swizzle *ir) +{ + if (do_graft(&ir->val)) + return visit_stop; + + return visit_continue; +} + +ir_visitor_status +ir_tree_grafting_visitor::visit_enter(ir_texture *ir) +{ + if (do_graft(&ir->coordinate) || + do_graft(&ir->projector) || + do_graft(&ir->offset) || + do_graft(&ir->shadow_comparitor)) + return visit_stop; + + switch (ir->op) { + case ir_tex: + break; + case ir_txb: + if (do_graft(&ir->lod_info.bias)) + return visit_stop; + break; + case ir_txf: + case ir_txl: + if (do_graft(&ir->lod_info.lod)) + return visit_stop; + break; + case ir_txd: + if (do_graft(&ir->lod_info.grad.dPdx) || + do_graft(&ir->lod_info.grad.dPdy)) + return visit_stop; + break; + } + + return visit_continue; +} + +struct tree_grafting_info { + ir_variable_refcount_visitor *refs; + bool progress; +}; + +static bool +try_tree_grafting(ir_assignment *start, + ir_variable *lhs_var, + ir_instruction *bb_last) +{ + ir_tree_grafting_visitor v(start, lhs_var); + + if (debug) { + printf("trying to graft: "); + lhs_var->print(); + printf("\n"); + } + + for (ir_instruction *ir = (ir_instruction *)start->next; + ir != bb_last->next; + ir = (ir_instruction *)ir->next) { + + if (debug) { + printf("- "); + ir->print(); + printf("\n"); + } + + ir_visitor_status s = ir->accept(&v); + if (s == visit_stop) + return v.progress; + } + + return false; +} + +static void +tree_grafting_basic_block(ir_instruction *bb_first, + ir_instruction *bb_last, + void *data) +{ + struct tree_grafting_info *info = (struct tree_grafting_info *)data; + ir_instruction *ir, *next; + + for (ir = bb_first, next = (ir_instruction *)ir->next; + ir != bb_last->next; + ir = next, next = (ir_instruction *)ir->next) { + ir_assignment *assign = ir->as_assignment(); + + if (!assign) + continue; + + ir_variable *lhs_var = assign->whole_variable_written(); + if (!lhs_var) + continue; + + if (lhs_var->mode == ir_var_out || + lhs_var->mode == ir_var_inout) + continue; + + variable_entry *entry = info->refs->get_variable_entry(lhs_var); + + if (!entry->declaration || + entry->assigned_count != 1 || + entry->referenced_count != 2) + continue; + + glsl_precision var_prec = (glsl_precision)lhs_var->precision; + glsl_precision rhs_prec = assign->rhs->get_precision(); + if (var_prec != rhs_prec && var_prec != glsl_precision_undefined && rhs_prec != glsl_precision_undefined) + continue; + + assert(assign == entry->assign); + + /* Found a possibly graftable assignment. Now, walk through the + * rest of the BB seeing if the deref is here, and if nothing interfered with + * pasting its expression's values in between. + */ + info->progress |= try_tree_grafting(assign, lhs_var, bb_last); + } +} + +/** + * Does a copy propagation pass on the code present in the instruction stream. + */ +bool +do_tree_grafting(exec_list *instructions) +{ + ir_variable_refcount_visitor refs; + struct tree_grafting_info info; + + info.progress = false; + info.refs = &refs; + + visit_list_elements(info.refs, instructions); + + call_for_basic_blocks(instructions, tree_grafting_basic_block, &info); + + return info.progress; +} diff --git a/3rdparty/glsl-optimizer/src/glsl/program.h b/3rdparty/glsl-optimizer/src/glsl/program.h new file mode 100644 index 000000000..437ca1462 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/program.h @@ -0,0 +1,35 @@ +/* + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (C) 2009 VMware, Inc. All Rights Reserved. + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include "main/core.h" + +extern void +link_shaders(struct gl_context *ctx, struct gl_shader_program *prog); + +extern void +linker_error(gl_shader_program *prog, const char *fmt, ...) + PRINTFLIKE(2, 3); + +extern void +linker_warning(gl_shader_program *prog, const char *fmt, ...) + PRINTFLIKE(2, 3); diff --git a/3rdparty/glsl-optimizer/src/glsl/ralloc.c b/3rdparty/glsl-optimizer/src/glsl/ralloc.c new file mode 100644 index 000000000..6a5eac6b9 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/ralloc.c @@ -0,0 +1,458 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include +#include +#include +#include +#include +#include + +#include "ralloc.h" + +#ifdef __GNUC__ +#define likely(x) __builtin_expect(!!(x),1) +#define unlikely(x) __builtin_expect(!!(x),0) +#else +#define likely(x) !!(x) +#define unlikely(x) !!(x) +#endif + +#ifndef va_copy +#ifdef __va_copy +#define va_copy(dest, src) __va_copy((dest), (src)) +#else +#define va_copy(dest, src) (dest) = (src) +#endif +#endif + +#define CANARY 0x5A1106 + +struct ralloc_header +{ + /* A canary value used to determine whether a pointer is ralloc'd. */ + unsigned canary; + + struct ralloc_header *parent; + + /* The first child (head of a linked list) */ + struct ralloc_header *child; + + /* Linked list of siblings */ + struct ralloc_header *prev; + struct ralloc_header *next; + + void (*destructor)(void *); +}; + +typedef struct ralloc_header ralloc_header; + +static void unlink_block(ralloc_header *info); +static void unsafe_free(ralloc_header *info); + +static ralloc_header * +get_header(const void *ptr) +{ + ralloc_header *info = (ralloc_header *) (((char *) ptr) - + sizeof(ralloc_header)); + assert(info->canary == CANARY); + return info; +} + +#define PTR_FROM_HEADER(info) (((char *) info) + sizeof(ralloc_header)) + +static void +add_child(ralloc_header *parent, ralloc_header *info) +{ + if (parent != NULL) { + info->parent = parent; + info->next = parent->child; + parent->child = info; + + if (info->next != NULL) + info->next->prev = info; + } +} + +void * +ralloc_context(const void *ctx) +{ + return ralloc_size(ctx, 0); +} + +void * +ralloc_size(const void *ctx, size_t size) +{ + void *block = calloc(1, size + sizeof(ralloc_header)); + + ralloc_header *info = (ralloc_header *) block; + ralloc_header *parent = ctx != NULL ? get_header(ctx) : NULL; + + add_child(parent, info); + + info->canary = CANARY; + + return PTR_FROM_HEADER(info); +} + +void * +rzalloc_size(const void *ctx, size_t size) +{ + void *ptr = ralloc_size(ctx, size); + if (likely(ptr != NULL)) + memset(ptr, 0, size); + return ptr; +} + +/* helper function - assumes ptr != NULL */ +static void * +resize(void *ptr, size_t size) +{ + ralloc_header *child, *old, *info; + + old = get_header(ptr); + info = realloc(old, size + sizeof(ralloc_header)); + + if (info == NULL) + return NULL; + + /* Update parent and sibling's links to the reallocated node. */ + if (info != old && info->parent != NULL) { + if (info->parent->child == old) + info->parent->child = info; + + if (info->prev != NULL) + info->prev->next = info; + + if (info->next != NULL) + info->next->prev = info; + } + + /* Update child->parent links for all children */ + for (child = info->child; child != NULL; child = child->next) + child->parent = info; + + return PTR_FROM_HEADER(info); +} + +void * +reralloc_size(const void *ctx, void *ptr, size_t size) +{ + if (unlikely(ptr == NULL)) + return ralloc_size(ctx, size); + + assert(ralloc_parent(ptr) == ctx); + return resize(ptr, size); +} + +void * +ralloc_array_size(const void *ctx, size_t size, unsigned count) +{ + if (count > SIZE_MAX/size) + return NULL; + + return ralloc_size(ctx, size * count); +} + +void * +rzalloc_array_size(const void *ctx, size_t size, unsigned count) +{ + if (count > SIZE_MAX/size) + return NULL; + + return rzalloc_size(ctx, size * count); +} + +void * +reralloc_array_size(const void *ctx, void *ptr, size_t size, unsigned count) +{ + if (count > SIZE_MAX/size) + return NULL; + + return reralloc_size(ctx, ptr, size * count); +} + +void +ralloc_free(void *ptr) +{ + ralloc_header *info; + + if (ptr == NULL) + return; + + info = get_header(ptr); + unlink_block(info); + unsafe_free(info); +} + +static void +unlink_block(ralloc_header *info) +{ + /* Unlink from parent & siblings */ + if (info->parent != NULL) { + if (info->parent->child == info) + info->parent->child = info->next; + + if (info->prev != NULL) + info->prev->next = info->next; + + if (info->next != NULL) + info->next->prev = info->prev; + } + info->parent = NULL; + info->prev = NULL; + info->next = NULL; +} + +static void +unsafe_free(ralloc_header *info) +{ + /* Recursively free any children...don't waste time unlinking them. */ + ralloc_header *temp; + while (info->child != NULL) { + temp = info->child; + info->child = temp->next; + unsafe_free(temp); + } + + /* Free the block itself. Call the destructor first, if any. */ + if (info->destructor != NULL) + info->destructor(PTR_FROM_HEADER(info)); + + free(info); +} + +void +ralloc_steal(const void *new_ctx, void *ptr) +{ + ralloc_header *info, *parent; + + if (unlikely(ptr == NULL)) + return; + + info = get_header(ptr); + parent = get_header(new_ctx); + + unlink_block(info); + + add_child(parent, info); +} + +void * +ralloc_parent(const void *ptr) +{ + ralloc_header *info; + + if (unlikely(ptr == NULL)) + return NULL; + + info = get_header(ptr); + return PTR_FROM_HEADER(info->parent); +} + +static void *autofree_context = NULL; + +static void +autofree(void) +{ + ralloc_free(autofree_context); +} + +void * +ralloc_autofree_context(void) +{ + if (unlikely(autofree_context == NULL)) { + autofree_context = ralloc_context(NULL); + atexit(autofree); + } + return autofree_context; +} + +void +ralloc_set_destructor(const void *ptr, void(*destructor)(void *)) +{ + ralloc_header *info = get_header(ptr); + info->destructor = destructor; +} + +char * +ralloc_strdup(const void *ctx, const char *str) +{ + size_t n; + char *ptr; + + if (unlikely(str == NULL)) + return NULL; + + n = strlen(str); + ptr = ralloc_array(ctx, char, n + 1); + memcpy(ptr, str, n); + ptr[n] = '\0'; + return ptr; +} + +char * +ralloc_strndup(const void *ctx, const char *str, size_t max) +{ + size_t n; + char *ptr; + + if (unlikely(str == NULL)) + return NULL; + + n = strlen(str); + if (n > max) + n = max; + + ptr = ralloc_array(ctx, char, n + 1); + memcpy(ptr, str, n); + ptr[n] = '\0'; + return ptr; +} + +/* helper routine for strcat/strncat - n is the exact amount to copy */ +static bool +cat(char **dest, const char *str, size_t n) +{ + char *both; + size_t existing_length; + assert(dest != NULL && *dest != NULL); + + existing_length = strlen(*dest); + both = resize(*dest, existing_length + n + 1); + if (unlikely(both == NULL)) + return false; + + memcpy(both + existing_length, str, n); + both[existing_length + n] = '\0'; + + *dest = both; + return true; +} + + +bool +ralloc_strcat(char **dest, const char *str) +{ + return cat(dest, str, strlen(str)); +} + +bool +ralloc_strncat(char **dest, const char *str, size_t n) +{ + /* Clamp n to the string length */ + size_t str_length = strlen(str); + if (str_length < n) + n = str_length; + + return cat(dest, str, n); +} + +char * +ralloc_asprintf(const void *ctx, const char *fmt, ...) +{ + char *ptr; + va_list args; + va_start(args, fmt); + ptr = ralloc_vasprintf(ctx, fmt, args); + va_end(args); + return ptr; +} + +/* Return the length of the string that would be generated by a printf-style + * format and argument list, not including the \0 byte. + */ +static size_t +printf_length(const char *fmt, va_list untouched_args) +{ + int size; + char junk; + + /* Make a copy of the va_list so the original caller can still use it */ + va_list args; + va_copy(args, untouched_args); + +#ifdef _MSC_VER + /* We need to use _vcsprintf to calculate the size as vsnprintf returns -1 + * if the number of characters to write is greater than count. + */ + size = _vscprintf(fmt, args); + (void)junk; +#else + size = vsnprintf(&junk, 1, fmt, args); +#endif + assert(size >= 0); + + va_end(args); + + return size; +} + +char * +ralloc_vasprintf(const void *ctx, const char *fmt, va_list args) +{ + size_t size = printf_length(fmt, args) + 1; + + char *ptr = ralloc_size(ctx, size); + if (ptr != NULL) + vsnprintf(ptr, size, fmt, args); + + return ptr; +} + +bool +ralloc_asprintf_append(char **str, const char *fmt, ...) +{ + bool success; + va_list args; + va_start(args, fmt); + success = ralloc_vasprintf_append(str, fmt, args); + va_end(args); + return success; +} + +bool +ralloc_vasprintf_append(char **str, const char *fmt, va_list args) +{ + size_t existing_length, new_length; + char *ptr; + + assert(str != NULL); + + if (unlikely(*str == NULL)) { + // Assuming a NULL context is probably bad, but it's expected behavior. + *str = ralloc_vasprintf(NULL, fmt, args); + return true; + } + + existing_length = strlen(*str); + new_length = printf_length(fmt, args); + + ptr = resize(*str, existing_length + new_length + 1); + if (unlikely(ptr == NULL)) + return false; + + vsnprintf(ptr + existing_length, new_length + 1, fmt, args); + *str = ptr; + return true; +} diff --git a/3rdparty/glsl-optimizer/src/glsl/ralloc.h b/3rdparty/glsl-optimizer/src/glsl/ralloc.h new file mode 100644 index 000000000..d5338152f --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/ralloc.h @@ -0,0 +1,345 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file ralloc.h + * + * ralloc: a recursive memory allocator + * + * The ralloc memory allocator creates a hierarchy of allocated + * objects. Every allocation is in reference to some parent, and + * every allocated object can in turn be used as the parent of a + * subsequent allocation. This allows for extremely convenient + * discarding of an entire tree/sub-tree of allocations by calling + * ralloc_free on any particular object to free it and all of its + * children. + * + * The conceptual working of ralloc was directly inspired by Andrew + * Tridgell's talloc, but ralloc is an independent implementation + * released under the MIT license and tuned for Mesa. + * + * The talloc implementation is available under the GNU Lesser + * General Public License (GNU LGPL), version 3 or later. It is + * more sophisticated than ralloc in that it includes reference + * counting and debugging features. See: http://talloc.samba.org/ + */ + +#ifndef RALLOC_H +#define RALLOC_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include + +/** + * \def ralloc(ctx, type) + * Allocate a new object chained off of the given context. + * + * This is equivalent to: + * \code + * ((type *) ralloc_size(ctx, sizeof(type)) + * \endcode + */ +#define ralloc(ctx, type) ((type *) ralloc_size(ctx, sizeof(type))) + +/** + * \def rzalloc(ctx, type) + * Allocate a new object out of the given context and initialize it to zero. + * + * This is equivalent to: + * \code + * ((type *) rzalloc_size(ctx, sizeof(type)) + * \endcode + */ +#define rzalloc(ctx, type) ((type *) rzalloc_size(ctx, sizeof(type))) + +/** + * Allocate a new ralloc context. + * + * While any ralloc'd pointer can be used as a context, sometimes it is useful + * to simply allocate a context with no associated memory. + * + * It is equivalent to: + * \code + * ((type *) ralloc_size(ctx, 0) + * \endcode + */ +void *ralloc_context(const void *ctx); + +/** + * Allocate memory chained off of the given context. + * + * This is the core allocation routine which is used by all others. It + * simply allocates storage for \p size bytes and returns the pointer, + * similar to \c malloc. + */ +void *ralloc_size(const void *ctx, size_t size); + +/** + * Allocate zero-initialized memory chained off of the given context. + * + * This is similar to \c calloc with a size of 1. + */ +void *rzalloc_size(const void *ctx, size_t size); + +/** + * Resize a piece of ralloc-managed memory, preserving data. + * + * Similar to \c realloc. Unlike C89, passing 0 for \p size does not free the + * memory. Instead, it resizes it to a 0-byte ralloc context, just like + * calling ralloc_size(ctx, 0). This is different from talloc. + * + * \param ctx The context to use for new allocation. If \p ptr != NULL, + * it must be the same as ralloc_parent(\p ptr). + * \param ptr Pointer to the memory to be resized. May be NULL. + * \param size The amount of memory to allocate, in bytes. + */ +void *reralloc_size(const void *ctx, void *ptr, size_t size); + +/// \defgroup array Array Allocators @{ + +/** + * \def ralloc_array(ctx, type, count) + * Allocate an array of objects chained off the given context. + * + * Similar to \c calloc, but does not initialize the memory to zero. + * + * More than a convenience function, this also checks for integer overflow when + * multiplying \c sizeof(type) and \p count. This is necessary for security. + * + * This is equivalent to: + * \code + * ((type *) ralloc_array_size(ctx, sizeof(type), count) + * \endcode + */ +#define ralloc_array(ctx, type, count) \ + ((type *) ralloc_array_size(ctx, sizeof(type), count)) + +/** + * \def rzalloc_array(ctx, type, count) + * Allocate a zero-initialized array chained off the given context. + * + * Similar to \c calloc. + * + * More than a convenience function, this also checks for integer overflow when + * multiplying \c sizeof(type) and \p count. This is necessary for security. + * + * This is equivalent to: + * \code + * ((type *) rzalloc_array_size(ctx, sizeof(type), count) + * \endcode + */ +#define rzalloc_array(ctx, type, count) \ + ((type *) rzalloc_array_size(ctx, sizeof(type), count)) + +/** + * \def reralloc(ctx, ptr, type, count) + * Resize a ralloc-managed array, preserving data. + * + * Similar to \c realloc. Unlike C89, passing 0 for \p size does not free the + * memory. Instead, it resizes it to a 0-byte ralloc context, just like + * calling ralloc_size(ctx, 0). This is different from talloc. + * + * More than a convenience function, this also checks for integer overflow when + * multiplying \c sizeof(type) and \p count. This is necessary for security. + * + * \param ctx The context to use for new allocation. If \p ptr != NULL, + * it must be the same as ralloc_parent(\p ptr). + * \param ptr Pointer to the array to be resized. May be NULL. + * \param type The element type. + * \param count The number of elements to allocate. + */ +#define reralloc(ctx, ptr, type, count) \ + ((type *) reralloc_array_size(ctx, ptr, sizeof(type), count)) + +/** + * Allocate memory for an array chained off the given context. + * + * Similar to \c calloc, but does not initialize the memory to zero. + * + * More than a convenience function, this also checks for integer overflow when + * multiplying \p size and \p count. This is necessary for security. + */ +void *ralloc_array_size(const void *ctx, size_t size, unsigned count); + +/** + * Allocate a zero-initialized array chained off the given context. + * + * Similar to \c calloc. + * + * More than a convenience function, this also checks for integer overflow when + * multiplying \p size and \p count. This is necessary for security. + */ +void *rzalloc_array_size(const void *ctx, size_t size, unsigned count); + +/** + * Resize a ralloc-managed array, preserving data. + * + * Similar to \c realloc. Unlike C89, passing 0 for \p size does not free the + * memory. Instead, it resizes it to a 0-byte ralloc context, just like + * calling ralloc_size(ctx, 0). This is different from talloc. + * + * More than a convenience function, this also checks for integer overflow when + * multiplying \c sizeof(type) and \p count. This is necessary for security. + * + * \param ctx The context to use for new allocation. If \p ptr != NULL, + * it must be the same as ralloc_parent(\p ptr). + * \param ptr Pointer to the array to be resized. May be NULL. + * \param size The size of an individual element. + * \param count The number of elements to allocate. + * + * \return True unless allocation failed. + */ +void *reralloc_array_size(const void *ctx, void *ptr, size_t size, + unsigned count); +/// @} + +/** + * Free a piece of ralloc-managed memory. + * + * This will also free the memory of any children allocated this context. + */ +void ralloc_free(void *ptr); + +/** + * "Steal" memory from one context, changing it to another. + * + * This changes \p ptr's context to \p new_ctx. This is quite useful if + * memory is allocated out of a temporary context. + */ +void ralloc_steal(const void *new_ctx, void *ptr); + +/** + * Return the given pointer's ralloc context. + */ +void *ralloc_parent(const void *ptr); + +/** + * Return a context whose memory will be automatically freed at program exit. + * + * The first call to this function creates a context and registers a handler + * to free it using \c atexit. This may cause trouble if used in a library + * loaded with \c dlopen. + */ +void *ralloc_autofree_context(void); + +/** + * Set a callback to occur just before an object is freed. + */ +void ralloc_set_destructor(const void *ptr, void(*destructor)(void *)); + +/// \defgroup array String Functions @{ +/** + * Duplicate a string, allocating the memory from the given context. + */ +char *ralloc_strdup(const void *ctx, const char *str); + +/** + * Duplicate a string, allocating the memory from the given context. + * + * Like \c strndup, at most \p n characters are copied. If \p str is longer + * than \p n characters, \p n are copied, and a termining \c '\0' byte is added. + */ +char *ralloc_strndup(const void *ctx, const char *str, size_t n); + +/** + * Concatenate two strings, allocating the necessary space. + * + * This appends \p str to \p *dest, similar to \c strcat, using ralloc_resize + * to expand \p *dest to the appropriate size. \p dest will be updated to the + * new pointer unless allocation fails. + * + * The result will always be null-terminated. + * + * \return True unless allocation failed. + */ +bool ralloc_strcat(char **dest, const char *str); + +/** + * Concatenate two strings, allocating the necessary space. + * + * This appends at most \p n bytes of \p str to \p *dest, using ralloc_resize + * to expand \p *dest to the appropriate size. \p dest will be updated to the + * new pointer unless allocation fails. + * + * The result will always be null-terminated; \p str does not need to be null + * terminated if it is longer than \p n. + * + * \return True unless allocation failed. + */ +bool ralloc_strncat(char **dest, const char *str, size_t n); + +/** + * Print to a string. + * + * This is analogous to \c sprintf, but allocates enough space (using \p ctx + * as the context) for the resulting string. + * + * \return The newly allocated string. + */ +char *ralloc_asprintf (const void *ctx, const char *fmt, ...); + +/** + * Print to a string, given a va_list. + * + * This is analogous to \c vsprintf, but allocates enough space (using \p ctx + * as the context) for the resulting string. + * + * \return The newly allocated string. + */ +char *ralloc_vasprintf(const void *ctx, const char *fmt, va_list args); + +/** + * Append formatted text to the supplied string. + * + * \sa ralloc_asprintf + * \sa ralloc_strcat + * + * \p str will be updated to the new pointer unless allocation fails. + * + * \return True unless allocation failed. + */ +bool ralloc_asprintf_append (char **str, const char *fmt, ...); + +/** + * Append formatted text to the supplied string, given a va_list. + * + * \sa ralloc_vasprintf + * \sa ralloc_strcat + * + * \p str will be updated to the new pointer unless allocation fails. + * + * \return True unless allocation failed. + */ +bool ralloc_vasprintf_append(char **str, const char *fmt, va_list args); +/// @} + +#ifdef __cplusplus +} /* end of extern "C" */ +#endif + +#endif diff --git a/3rdparty/glsl-optimizer/src/glsl/s_expression.cpp b/3rdparty/glsl-optimizer/src/glsl/s_expression.cpp new file mode 100644 index 000000000..e704a3be2 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/s_expression.cpp @@ -0,0 +1,211 @@ +/* -*- c++ -*- */ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include +#include "s_expression.h" + +s_symbol::s_symbol(const char *str, size_t n) +{ + /* Assume the given string is already nul-terminated and in memory that + * will live as long as this node. + */ + assert(str[n] == '\0'); + this->str = str; +} + +s_list::s_list() +{ +} + +static void +skip_whitespace(const char *&src, char *&symbol_buffer) +{ + size_t n = strspn(src, " \v\t\r\n"); + src += n; + symbol_buffer += n; + /* Also skip Scheme-style comments: semi-colon 'til end of line */ + if (src[0] == ';') { + n = strcspn(src, "\n"); + src += n; + symbol_buffer += n; + skip_whitespace(src, symbol_buffer); + } +} + +static s_expression * +read_atom(void *ctx, const char *&src, char *&symbol_buffer) +{ + s_expression *expr = NULL; + + skip_whitespace(src, symbol_buffer); + + size_t n = strcspn(src, "( \v\t\r\n);"); + if (n == 0) + return NULL; // no atom + + // Check if the atom is a number. + char *float_end = NULL; + double f = glsl_strtod(src, &float_end); + if (float_end != src) { + char *int_end = NULL; + int i = strtol(src, &int_end, 10); + // If strtod matched more characters, it must have a decimal part + if (float_end > int_end) + expr = new(ctx) s_float(f); + else + expr = new(ctx) s_int(i); + } else { + // Not a number; return a symbol. + symbol_buffer[n] = '\0'; + expr = new(ctx) s_symbol(symbol_buffer, n); + } + + src += n; + symbol_buffer += n; + + return expr; +} + +static s_expression * +__read_expression(void *ctx, const char *&src, char *&symbol_buffer) +{ + s_expression *atom = read_atom(ctx, src, symbol_buffer); + if (atom != NULL) + return atom; + + skip_whitespace(src, symbol_buffer); + if (src[0] == '(') { + ++src; + ++symbol_buffer; + + s_list *list = new(ctx) s_list; + s_expression *expr; + + while ((expr = __read_expression(ctx, src, symbol_buffer)) != NULL) { + list->subexpressions.push_tail(expr); + } + skip_whitespace(src, symbol_buffer); + if (src[0] != ')') { + printf("Unclosed expression (check your parenthesis).\n"); + return NULL; + } + ++src; + ++symbol_buffer; + return list; + } + return NULL; +} + +s_expression * +s_expression::read_expression(void *ctx, const char *&src) +{ + assert(src != NULL); + + /* When we encounter a Symbol, we need to save a nul-terminated copy of + * the string. However, ralloc_strndup'ing every individual Symbol is + * extremely expensive. We could avoid this by simply overwriting the + * next character (guaranteed to be whitespace, parens, or semicolon) with + * a nul-byte. But overwriting non-whitespace would mess up parsing. + * + * So, just copy the whole buffer ahead of time. Walk both, leaving the + * original source string unmodified, and altering the copy to contain the + * necessary nul-bytes whenever we encounter a symbol. + */ + char *symbol_buffer = ralloc_strdup(ctx, src); + return __read_expression(ctx, src, symbol_buffer); +} + +void s_int::print() +{ + printf("%d", this->val); +} + +void s_float::print() +{ + printf("%f", this->val); +} + +void s_symbol::print() +{ + printf("%s", this->str); +} + +void s_list::print() +{ + printf("("); + foreach_iter(exec_list_iterator, it, this->subexpressions) { + s_expression *expr = (s_expression*) it.get(); + expr->print(); + if (!expr->next->is_tail_sentinel()) + printf(" "); + } + printf(")"); +} + +// -------------------------------------------------- + +bool +s_pattern::match(s_expression *expr) +{ + switch (type) + { + case EXPR: *p_expr = expr; break; + case LIST: if (expr->is_list()) *p_list = (s_list *) expr; break; + case SYMBOL: if (expr->is_symbol()) *p_symbol = (s_symbol *) expr; break; + case NUMBER: if (expr->is_number()) *p_number = (s_number *) expr; break; + case INT: if (expr->is_int()) *p_int = (s_int *) expr; break; + case STRING: + s_symbol *sym = SX_AS_SYMBOL(expr); + if (sym != NULL && strcmp(sym->value(), literal) == 0) + return true; + return false; + }; + + return *p_expr == expr; +} + +bool +s_match(s_expression *top, unsigned n, s_pattern *pattern, bool partial) +{ + s_list *list = SX_AS_LIST(top); + if (list == NULL) + return false; + + unsigned i = 0; + foreach_iter(exec_list_iterator, it, list->subexpressions) { + if (i >= n) + return partial; /* More actual items than the pattern expected */ + + s_expression *expr = (s_expression *) it.get(); + if (expr == NULL || !pattern[i].match(expr)) + return false; + + i++; + } + + if (i < n) + return false; /* Less actual items than the pattern expected */ + + return true; +} diff --git a/3rdparty/glsl-optimizer/src/glsl/s_expression.h b/3rdparty/glsl-optimizer/src/glsl/s_expression.h new file mode 100644 index 000000000..642af19b4 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/s_expression.h @@ -0,0 +1,180 @@ +/* -*- c++ -*- */ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#pragma once +#ifndef S_EXPRESSION_H +#define S_EXPRESSION_H + +#include "main/core.h" /* for Elements */ +#include "strtod.h" +#include "list.h" + +/* Type-safe downcasting macros (also safe to pass NULL) */ +#define SX_AS_(t,x) ((x) && ((s_expression*) x)->is_##t()) ? ((s_##t*) (x)) \ + : NULL +#define SX_AS_LIST(x) SX_AS_(list, x) +#define SX_AS_SYMBOL(x) SX_AS_(symbol, x) +#define SX_AS_NUMBER(x) SX_AS_(number, x) +#define SX_AS_INT(x) SX_AS_(int, x) + +/* Pattern matching macros */ +#define MATCH(list, pat) s_match(list, Elements(pat), pat, false) +#define PARTIAL_MATCH(list, pat) s_match(list, Elements(pat), pat, true) + +/* For our purposes, S-Expressions are: + * - + * - + * - symbol + * - (expr1 expr2 ... exprN) where exprN is an S-Expression + * + * Unlike LISP/Scheme, we do not support (foo . bar) pairs. + */ +class s_expression : public exec_node +{ +public: + /** + * Read an S-Expression from the given string. + * Advances the supplied pointer to just after the expression read. + * + * Any allocation will be performed with 'ctx' as the ralloc owner. + */ + static s_expression *read_expression(void *ctx, const char *&src); + + /** + * Print out an S-Expression. Useful for debugging. + */ + virtual void print() = 0; + + virtual bool is_list() const { return false; } + virtual bool is_symbol() const { return false; } + virtual bool is_number() const { return false; } + virtual bool is_int() const { return false; } + +protected: + s_expression() { } +}; + +/* Atoms */ + +class s_number : public s_expression +{ +public: + bool is_number() const { return true; } + + virtual float fvalue() = 0; + +protected: + s_number() { } +}; + +class s_int : public s_number +{ +public: + s_int(int x) : val(x) { } + + bool is_int() const { return true; } + + float fvalue() { return float(this->val); } + int value() { return this->val; } + + void print(); + +private: + int val; +}; + +class s_float : public s_number +{ +public: + s_float(float x) : val(x) { } + + float fvalue() { return this->val; } + + void print(); + +private: + float val; +}; + +class s_symbol : public s_expression +{ +public: + s_symbol(const char *, size_t); + + bool is_symbol() const { return true; } + + const char *value() { return this->str; } + + void print(); + +private: + const char *str; +}; + +/* Lists of expressions: (expr1 ... exprN) */ +class s_list : public s_expression +{ +public: + s_list(); + + virtual bool is_list() const { return true; } + + void print(); + + exec_list subexpressions; +}; + +// ------------------------------------------------------------ + +/** + * Part of a pattern to match - essentially a record holding a pointer to the + * storage for the component to match, along with the appropriate type. + */ +class s_pattern { +public: + s_pattern(s_expression *&s) : p_expr(&s), type(EXPR) { } + s_pattern(s_list *&s) : p_list(&s), type(LIST) { } + s_pattern(s_symbol *&s) : p_symbol(&s), type(SYMBOL) { } + s_pattern(s_number *&s) : p_number(&s), type(NUMBER) { } + s_pattern(s_int *&s) : p_int(&s), type(INT) { } + s_pattern(const char *str) : literal(str), type(STRING) { } + + bool match(s_expression *expr); + +private: + union { + s_expression **p_expr; + s_list **p_list; + s_symbol **p_symbol; + s_number **p_number; + s_int **p_int; + const char *literal; + }; + enum { EXPR, LIST, SYMBOL, NUMBER, INT, STRING } type; +}; + +bool +s_match(s_expression *top, unsigned n, s_pattern *pattern, bool partial); + +#endif /* S_EXPRESSION_H */ diff --git a/3rdparty/glsl-optimizer/src/glsl/standalone_scaffolding.cpp b/3rdparty/glsl-optimizer/src/glsl/standalone_scaffolding.cpp new file mode 100644 index 000000000..696ea757e --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/standalone_scaffolding.cpp @@ -0,0 +1,91 @@ +/* + * Copyright © 2011 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/* This file declares stripped-down versions of functions that + * normally exist outside of the glsl folder, so that they can be used + * when running the GLSL compiler standalone (for unit testing or + * compiling builtins). + */ + +#include "standalone_scaffolding.h" + +#include +#include +#include "ralloc.h" + +void +_mesa_reference_shader(struct gl_context *ctx, struct gl_shader **ptr, + struct gl_shader *sh) +{ + *ptr = sh; +} + +struct gl_shader * +_mesa_new_shader(struct gl_context *ctx, GLuint name, GLenum type) +{ + struct gl_shader *shader; + + (void) ctx; + + assert(type == GL_FRAGMENT_SHADER || type == GL_VERTEX_SHADER); + shader = rzalloc(NULL, struct gl_shader); + if (shader) { + shader->Type = type; + shader->Name = name; + shader->RefCount = 1; + } + return shader; +} + +void initialize_context_to_defaults(struct gl_context *ctx, gl_api api) +{ + memset(ctx, 0, sizeof(*ctx)); + + ctx->API = api; + + ctx->Extensions.ARB_ES2_compatibility = true; + ctx->Extensions.ARB_draw_buffers = true; + ctx->Extensions.ARB_draw_instanced = true; + ctx->Extensions.ARB_fragment_coord_conventions = true; + ctx->Extensions.EXT_texture_array = true; + ctx->Extensions.NV_texture_rectangle = true; + ctx->Extensions.EXT_texture3D = true; + + ctx->Const.GLSLVersion = 120; + + /* 1.20 minimums. */ + ctx->Const.MaxLights = 8; + ctx->Const.MaxClipPlanes = 6; + ctx->Const.MaxTextureUnits = 2; + ctx->Const.MaxTextureCoordUnits = 2; + ctx->Const.VertexProgram.MaxAttribs = 16; + + ctx->Const.VertexProgram.MaxUniformComponents = 512; + ctx->Const.MaxVarying = 8; /* == gl_MaxVaryingFloats / 4 */ + ctx->Const.MaxVertexTextureImageUnits = 0; + ctx->Const.MaxCombinedTextureImageUnits = 2; + ctx->Const.MaxTextureImageUnits = 2; + ctx->Const.FragmentProgram.MaxUniformComponents = 64; + + ctx->Const.MaxDrawBuffers = 1; +} diff --git a/3rdparty/glsl-optimizer/src/glsl/standalone_scaffolding.h b/3rdparty/glsl-optimizer/src/glsl/standalone_scaffolding.h new file mode 100644 index 000000000..877332006 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/standalone_scaffolding.h @@ -0,0 +1,54 @@ +/* + * Copyright © 2011 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/* This file declares stripped-down versions of functions that + * normally exist outside of the glsl folder, so that they can be used + * when running the GLSL compiler standalone (for unit testing or + * compiling builtins). + */ + +#pragma once +#ifndef STANDALONE_SCAFFOLDING_H +#define STANDALONE_SCAFFOLDING_H + +#include "main/mtypes.h" + +extern "C" void +_mesa_reference_shader(struct gl_context *ctx, struct gl_shader **ptr, + struct gl_shader *sh); + +extern "C" struct gl_shader * +_mesa_new_shader(struct gl_context *ctx, GLuint name, GLenum type); + +/** + * Initialize the given gl_context structure to a reasonable set of + * defaults representing the minimum capabilities required by the + * OpenGL spec. + * + * This is used when compiling builtin functions and in testing, when + * we don't have a connection to an actual driver. + */ +void initialize_context_to_defaults(struct gl_context *ctx, gl_api api); + + +#endif /* STANDALONE_SCAFFOLDING_H */ diff --git a/3rdparty/glsl-optimizer/src/glsl/strtod.c b/3rdparty/glsl-optimizer/src/glsl/strtod.c new file mode 100644 index 000000000..ff3459148 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/strtod.c @@ -0,0 +1,56 @@ +/* + * Copyright 2010 VMware, Inc. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#include + +#ifdef _GNU_SOURCE +#include +#ifdef __APPLE__ +#include +#endif +#endif + +#include "strtod.h" + + + +/** + * Wrapper around strtod which uses the "C" locale so the decimal + * point is always '.' + */ +double +glsl_strtod(const char *s, char **end) +{ +#if defined(_GNU_SOURCE) && !defined(__CYGWIN__) && !defined(__FreeBSD__) + static locale_t loc = NULL; + if (!loc) { + loc = newlocale(LC_CTYPE_MASK, "C", NULL); + } + return strtod_l(s, end, loc); +#else + return strtod(s, end); +#endif +} diff --git a/3rdparty/glsl-optimizer/src/glsl/strtod.h b/3rdparty/glsl-optimizer/src/glsl/strtod.h new file mode 100644 index 000000000..0cf6409d4 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/strtod.h @@ -0,0 +1,43 @@ +/* + * Copyright 2010 VMware, Inc. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#ifndef STRTOD_H +#define STRTOD_H + +#ifdef __cplusplus +extern "C" { +#endif + +extern double +glsl_strtod(const char *s, char **end); + + +#ifdef __cplusplus +} +#endif + + +#endif diff --git a/3rdparty/glsl-optimizer/src/glsl/xcode/mesaglsl2.xcodeproj/project.pbxproj b/3rdparty/glsl-optimizer/src/glsl/xcode/mesaglsl2.xcodeproj/project.pbxproj new file mode 100644 index 000000000..d5f93f0bf --- /dev/null +++ b/3rdparty/glsl-optimizer/src/glsl/xcode/mesaglsl2.xcodeproj/project.pbxproj @@ -0,0 +1,961 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 45; + objects = { + +/* Begin PBXBuildFile section */ + 2B38545F1293BE5000F3E692 /* lower_if_to_cond_assign.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2B3854481293BE5000F3E692 /* lower_if_to_cond_assign.cpp */; }; + 2B3854601293BE5000F3E692 /* lower_jumps.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2B3854491293BE5000F3E692 /* lower_jumps.cpp */; }; + 2B3854611293BE5000F3E692 /* lower_mat_op_to_vec.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2B38544A1293BE5000F3E692 /* lower_mat_op_to_vec.cpp */; }; + 2B3854641293BE5000F3E692 /* lower_vec_index_to_cond_assign.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2B38544D1293BE5000F3E692 /* lower_vec_index_to_cond_assign.cpp */; }; + 2B3854651293BE5000F3E692 /* lower_vec_index_to_swizzle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2B38544E1293BE5000F3E692 /* lower_vec_index_to_swizzle.cpp */; }; + 2B3854661293BE5000F3E692 /* opt_algebraic.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2B38544F1293BE5000F3E692 /* opt_algebraic.cpp */; }; + 2B3854671293BE5000F3E692 /* opt_constant_folding.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2B3854501293BE5000F3E692 /* opt_constant_folding.cpp */; }; + 2B3854681293BE5000F3E692 /* opt_constant_propagation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2B3854511293BE5000F3E692 /* opt_constant_propagation.cpp */; }; + 2B3854691293BE5000F3E692 /* opt_constant_variable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2B3854521293BE5000F3E692 /* opt_constant_variable.cpp */; }; + 2B38546A1293BE5000F3E692 /* opt_copy_propagation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2B3854531293BE5000F3E692 /* opt_copy_propagation.cpp */; }; + 2B38546B1293BE5000F3E692 /* opt_dead_code_local.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2B3854541293BE5000F3E692 /* opt_dead_code_local.cpp */; }; + 2B38546C1293BE5000F3E692 /* opt_dead_code.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2B3854551293BE5000F3E692 /* opt_dead_code.cpp */; }; + 2B38546D1293BE5000F3E692 /* opt_dead_functions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2B3854561293BE5000F3E692 /* opt_dead_functions.cpp */; }; + 2B38546E1293BE5000F3E692 /* opt_function_inlining.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2B3854571293BE5000F3E692 /* opt_function_inlining.cpp */; }; + 2B38546F1293BE5000F3E692 /* opt_if_simplification.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2B3854581293BE5000F3E692 /* opt_if_simplification.cpp */; }; + 2B3854701293BE5000F3E692 /* opt_noop_swizzle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2B3854591293BE5000F3E692 /* opt_noop_swizzle.cpp */; }; + 2B3854711293BE5000F3E692 /* opt_structure_splitting.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2B38545A1293BE5000F3E692 /* opt_structure_splitting.cpp */; }; + 2B3854721293BE5000F3E692 /* opt_swizzle_swizzle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2B38545B1293BE5000F3E692 /* opt_swizzle_swizzle.cpp */; }; + 2B3854731293BE5000F3E692 /* opt_tree_grafting.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2B38545C1293BE5000F3E692 /* opt_tree_grafting.cpp */; }; + 2B47DA011209C87B00937F2C /* hash_table.c in Sources */ = {isa = PBXBuildFile; fileRef = 2B47D9FD1209C87B00937F2C /* hash_table.c */; }; + 2B47DA021209C87B00937F2C /* hash_table.h in Headers */ = {isa = PBXBuildFile; fileRef = 2B47D9FE1209C87B00937F2C /* hash_table.h */; }; + 2B47DA031209C87B00937F2C /* symbol_table.c in Sources */ = {isa = PBXBuildFile; fileRef = 2B47D9FF1209C87B00937F2C /* symbol_table.c */; }; + 2B47DA041209C87B00937F2C /* symbol_table.h in Headers */ = {isa = PBXBuildFile; fileRef = 2B47DA001209C87B00937F2C /* symbol_table.h */; }; + 2B62491112191339003F6EEE /* ir_rvalue_visitor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2B62490D12191339003F6EEE /* ir_rvalue_visitor.cpp */; }; + 2B62491212191339003F6EEE /* ir_rvalue_visitor.h in Headers */ = {isa = PBXBuildFile; fileRef = 2B62490E12191339003F6EEE /* ir_rvalue_visitor.h */; }; + 2B655A7213E0322E00B5278F /* ir_function_detect_recursion.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2B655A7113E0322E00B5278F /* ir_function_detect_recursion.cpp */; }; + 2B655A7313E0322E00B5278F /* ir_function_detect_recursion.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2B655A7113E0322E00B5278F /* ir_function_detect_recursion.cpp */; }; + 2B655A7813E0324F00B5278F /* standalone_scaffolding.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2B655A7613E0324F00B5278F /* standalone_scaffolding.cpp */; }; + 2B655A7913E0324F00B5278F /* standalone_scaffolding.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2B655A7613E0324F00B5278F /* standalone_scaffolding.cpp */; }; + 2B655A7A13E0324F00B5278F /* standalone_scaffolding.h in Headers */ = {isa = PBXBuildFile; fileRef = 2B655A7713E0324F00B5278F /* standalone_scaffolding.h */; }; + 2B6A99F41223B1670059FBED /* glcpp-lex.c in Sources */ = {isa = PBXBuildFile; fileRef = 2B6A99EC1223B1670059FBED /* glcpp-lex.c */; }; + 2B6A99F61223B1670059FBED /* glcpp-parse.c in Sources */ = {isa = PBXBuildFile; fileRef = 2B6A99EE1223B1670059FBED /* glcpp-parse.c */; }; + 2B6A99F71223B1670059FBED /* glcpp-parse.h in Headers */ = {isa = PBXBuildFile; fileRef = 2B6A99EF1223B1670059FBED /* glcpp-parse.h */; }; + 2B6A99FA1223B1670059FBED /* glcpp.h in Headers */ = {isa = PBXBuildFile; fileRef = 2B6A99F21223B1670059FBED /* glcpp.h */; }; + 2B6A99FB1223B1670059FBED /* pp.c in Sources */ = {isa = PBXBuildFile; fileRef = 2B6A99F31223B1670059FBED /* pp.c */; }; + 2BA07FAB1352E7BB00A1C074 /* ralloc.c in Sources */ = {isa = PBXBuildFile; fileRef = 2BA07FA91352E7BB00A1C074 /* ralloc.c */; }; + 2BA07FAC1352E7BB00A1C074 /* ralloc.h in Headers */ = {isa = PBXBuildFile; fileRef = 2BA07FAA1352E7BB00A1C074 /* ralloc.h */; }; + 2BA080421352EBB900A1C074 /* ast_expr.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BA55A511207FEA6002DC82D /* ast_expr.cpp */; }; + 2BA080431352EBB900A1C074 /* ast_function.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BA55A521207FEA6002DC82D /* ast_function.cpp */; }; + 2BA080441352EBB900A1C074 /* ast_to_hir.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BA55A531207FEA6002DC82D /* ast_to_hir.cpp */; }; + 2BA080451352EBB900A1C074 /* ast_type.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BA55A541207FEA6002DC82D /* ast_type.cpp */; }; + 2BA080471352EBB900A1C074 /* glsl_lexer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BA55A591207FEA6002DC82D /* glsl_lexer.cpp */; }; + 2BA080491352EBB900A1C074 /* glsl_parser_extras.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BA55A5D1207FEA6002DC82D /* glsl_parser_extras.cpp */; }; + 2BA0804A1352EBB900A1C074 /* glsl_parser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BA55A5F1207FEA6002DC82D /* glsl_parser.cpp */; }; + 2BA0804B1352EBB900A1C074 /* glsl_types.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BA55A631207FEA6002DC82D /* glsl_types.cpp */; }; + 2BA0804C1352EBB900A1C074 /* hir_field_selection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BA55A651207FEA6002DC82D /* hir_field_selection.cpp */; }; + 2BA0804D1352EBB900A1C074 /* ir_basic_block.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BA55A671207FEA6002DC82D /* ir_basic_block.cpp */; }; + 2BA0804E1352EBB900A1C074 /* ir_clone.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BA55A691207FEA6002DC82D /* ir_clone.cpp */; }; + 2BA0804F1352EBB900A1C074 /* ir_constant_expression.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BA55A6A1207FEA6002DC82D /* ir_constant_expression.cpp */; }; + 2BA080501352EBB900A1C074 /* ir_expression_flattening.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BA55A711207FEA6002DC82D /* ir_expression_flattening.cpp */; }; + 2BA080511352EBB900A1C074 /* ir_function_can_inline.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BA55A731207FEA6002DC82D /* ir_function_can_inline.cpp */; }; + 2BA080521352EBB900A1C074 /* ir_function.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BA55A761207FEA6002DC82D /* ir_function.cpp */; }; + 2BA080531352EBB900A1C074 /* ir_hierarchical_visitor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BA55A771207FEA6002DC82D /* ir_hierarchical_visitor.cpp */; }; + 2BA080541352EBB900A1C074 /* ir_hv_accept.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BA55A791207FEA6002DC82D /* ir_hv_accept.cpp */; }; + 2BA080551352EBB900A1C074 /* ir_import_prototypes.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BA55A7D1207FEA6002DC82D /* ir_import_prototypes.cpp */; }; + 2BA080561352EBB900A1C074 /* ir_print_glsl_visitor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BA55A811207FEA6002DC82D /* ir_print_glsl_visitor.cpp */; }; + 2BA080571352EBB900A1C074 /* ir_print_visitor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BA55A831207FEA6002DC82D /* ir_print_visitor.cpp */; }; + 2BA080581352EBB900A1C074 /* ir_reader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BA55A851207FEA6002DC82D /* ir_reader.cpp */; }; + 2BA080591352EBB900A1C074 /* ir_unused_structs.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BA55A8A1207FEA6002DC82D /* ir_unused_structs.cpp */; }; + 2BA0805A1352EBB900A1C074 /* ir_validate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BA55A8C1207FEA6002DC82D /* ir_validate.cpp */; }; + 2BA0805B1352EBB900A1C074 /* ir_variable_refcount.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BA55A8D1207FEA6002DC82D /* ir_variable_refcount.cpp */; }; + 2BA0805C1352EBB900A1C074 /* ir_variable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BA55A8F1207FEA6002DC82D /* ir_variable.cpp */; }; + 2BA0805D1352EBB900A1C074 /* ir.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BA55A931207FEA6002DC82D /* ir.cpp */; }; + 2BA0805E1352EBB900A1C074 /* link_functions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BA55A951207FEA6002DC82D /* link_functions.cpp */; }; + 2BA0805F1352EBB900A1C074 /* linker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BA55A961207FEA6002DC82D /* linker.cpp */; }; + 2BA080601352EBB900A1C074 /* s_expression.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BA55A9A1207FEA6002DC82D /* s_expression.cpp */; }; + 2BA080611352EBB900A1C074 /* hash_table.c in Sources */ = {isa = PBXBuildFile; fileRef = 2B47D9FD1209C87B00937F2C /* hash_table.c */; }; + 2BA080621352EBB900A1C074 /* symbol_table.c in Sources */ = {isa = PBXBuildFile; fileRef = 2B47D9FF1209C87B00937F2C /* symbol_table.c */; }; + 2BA080631352EBB900A1C074 /* ir_rvalue_visitor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2B62490D12191339003F6EEE /* ir_rvalue_visitor.cpp */; }; + 2BA080641352EBB900A1C074 /* glcpp-lex.c in Sources */ = {isa = PBXBuildFile; fileRef = 2B6A99EC1223B1670059FBED /* glcpp-lex.c */; }; + 2BA080651352EBB900A1C074 /* glcpp-parse.c in Sources */ = {isa = PBXBuildFile; fileRef = 2B6A99EE1223B1670059FBED /* glcpp-parse.c */; }; + 2BA080661352EBB900A1C074 /* pp.c in Sources */ = {isa = PBXBuildFile; fileRef = 2B6A99F31223B1670059FBED /* pp.c */; }; + 2BA080671352EBB900A1C074 /* glsl_symbol_table.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BBA491F1254706A00D42573 /* glsl_symbol_table.cpp */; }; + 2BA080681352EBB900A1C074 /* loop_analysis.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BBA49211254706A00D42573 /* loop_analysis.cpp */; }; + 2BA080691352EBB900A1C074 /* loop_controls.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BBA49231254706A00D42573 /* loop_controls.cpp */; }; + 2BA0806A1352EBB900A1C074 /* loop_unroll.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BBA49241254706A00D42573 /* loop_unroll.cpp */; }; + 2BA0806B1352EBB900A1C074 /* lower_noise.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BBA49251254706A00D42573 /* lower_noise.cpp */; }; + 2BA0806C1352EBB900A1C074 /* lower_variable_index_to_cond_assign.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BBA49261254706A00D42573 /* lower_variable_index_to_cond_assign.cpp */; }; + 2BA0806D1352EBB900A1C074 /* opt_redundant_jumps.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BBA49271254706A00D42573 /* opt_redundant_jumps.cpp */; }; + 2BA0806E1352EBB900A1C074 /* lower_if_to_cond_assign.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2B3854481293BE5000F3E692 /* lower_if_to_cond_assign.cpp */; }; + 2BA0806F1352EBB900A1C074 /* lower_jumps.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2B3854491293BE5000F3E692 /* lower_jumps.cpp */; }; + 2BA080701352EBB900A1C074 /* lower_mat_op_to_vec.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2B38544A1293BE5000F3E692 /* lower_mat_op_to_vec.cpp */; }; + 2BA080711352EBB900A1C074 /* lower_vec_index_to_cond_assign.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2B38544D1293BE5000F3E692 /* lower_vec_index_to_cond_assign.cpp */; }; + 2BA080721352EBB900A1C074 /* lower_vec_index_to_swizzle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2B38544E1293BE5000F3E692 /* lower_vec_index_to_swizzle.cpp */; }; + 2BA080731352EBB900A1C074 /* opt_algebraic.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2B38544F1293BE5000F3E692 /* opt_algebraic.cpp */; }; + 2BA080741352EBB900A1C074 /* opt_constant_folding.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2B3854501293BE5000F3E692 /* opt_constant_folding.cpp */; }; + 2BA080751352EBB900A1C074 /* opt_constant_propagation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2B3854511293BE5000F3E692 /* opt_constant_propagation.cpp */; }; + 2BA080761352EBB900A1C074 /* opt_constant_variable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2B3854521293BE5000F3E692 /* opt_constant_variable.cpp */; }; + 2BA080771352EBB900A1C074 /* opt_copy_propagation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2B3854531293BE5000F3E692 /* opt_copy_propagation.cpp */; }; + 2BA080781352EBB900A1C074 /* opt_dead_code_local.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2B3854541293BE5000F3E692 /* opt_dead_code_local.cpp */; }; + 2BA080791352EBB900A1C074 /* opt_dead_code.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2B3854551293BE5000F3E692 /* opt_dead_code.cpp */; }; + 2BA0807A1352EBB900A1C074 /* opt_dead_functions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2B3854561293BE5000F3E692 /* opt_dead_functions.cpp */; }; + 2BA0807B1352EBB900A1C074 /* opt_function_inlining.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2B3854571293BE5000F3E692 /* opt_function_inlining.cpp */; }; + 2BA0807C1352EBB900A1C074 /* opt_if_simplification.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2B3854581293BE5000F3E692 /* opt_if_simplification.cpp */; }; + 2BA0807D1352EBB900A1C074 /* opt_noop_swizzle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2B3854591293BE5000F3E692 /* opt_noop_swizzle.cpp */; }; + 2BA0807E1352EBB900A1C074 /* opt_structure_splitting.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2B38545A1293BE5000F3E692 /* opt_structure_splitting.cpp */; }; + 2BA0807F1352EBB900A1C074 /* opt_swizzle_swizzle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2B38545B1293BE5000F3E692 /* opt_swizzle_swizzle.cpp */; }; + 2BA080801352EBB900A1C074 /* opt_tree_grafting.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2B38545C1293BE5000F3E692 /* opt_tree_grafting.cpp */; }; + 2BA080811352EBB900A1C074 /* lower_discard.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BB2F5AA12B8F1580052C6B0 /* lower_discard.cpp */; }; + 2BA080821352EBB900A1C074 /* lower_instructions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BB2F5AB12B8F1580052C6B0 /* lower_instructions.cpp */; }; + 2BA080831352EBB900A1C074 /* lower_vector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BB2F5AC12B8F1580052C6B0 /* lower_vector.cpp */; }; + 2BA080841352EBB900A1C074 /* opt_discard_simplification.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BB2F5AD12B8F1580052C6B0 /* opt_discard_simplification.cpp */; }; + 2BA080851352EBB900A1C074 /* strtod.c in Sources */ = {isa = PBXBuildFile; fileRef = 2BB2F5AE12B8F1580052C6B0 /* strtod.c */; }; + 2BA080861352EBB900A1C074 /* ralloc.c in Sources */ = {isa = PBXBuildFile; fileRef = 2BA07FA91352E7BB00A1C074 /* ralloc.c */; }; + 2BA080871352EBD100A1C074 /* builtin_stubs.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BA080381352EB1A00A1C074 /* builtin_stubs.cpp */; }; + 2BA0808B1352EBFB00A1C074 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BA0808A1352EBFB00A1C074 /* main.cpp */; }; + 2BA55A9C1207FEA6002DC82D /* ast_expr.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BA55A511207FEA6002DC82D /* ast_expr.cpp */; }; + 2BA55A9D1207FEA6002DC82D /* ast_function.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BA55A521207FEA6002DC82D /* ast_function.cpp */; }; + 2BA55A9E1207FEA6002DC82D /* ast_to_hir.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BA55A531207FEA6002DC82D /* ast_to_hir.cpp */; }; + 2BA55A9F1207FEA6002DC82D /* ast_type.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BA55A541207FEA6002DC82D /* ast_type.cpp */; }; + 2BA55AA01207FEA6002DC82D /* ast.h in Headers */ = {isa = PBXBuildFile; fileRef = 2BA55A551207FEA6002DC82D /* ast.h */; }; + 2BA55AA11207FEA6002DC82D /* builtin_function.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BA55A561207FEA6002DC82D /* builtin_function.cpp */; }; + 2BA55AA21207FEA6002DC82D /* builtin_types.h in Headers */ = {isa = PBXBuildFile; fileRef = 2BA55A571207FEA6002DC82D /* builtin_types.h */; }; + 2BA55AA31207FEA6002DC82D /* builtin_variables.h in Headers */ = {isa = PBXBuildFile; fileRef = 2BA55A581207FEA6002DC82D /* builtin_variables.h */; }; + 2BA55AA41207FEA6002DC82D /* glsl_lexer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BA55A591207FEA6002DC82D /* glsl_lexer.cpp */; }; + 2BA55AA61207FEA6002DC82D /* glsl_optimizer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BA55A5B1207FEA6002DC82D /* glsl_optimizer.cpp */; }; + 2BA55AA71207FEA6002DC82D /* glsl_optimizer.h in Headers */ = {isa = PBXBuildFile; fileRef = 2BA55A5C1207FEA6002DC82D /* glsl_optimizer.h */; }; + 2BA55AA81207FEA6002DC82D /* glsl_parser_extras.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BA55A5D1207FEA6002DC82D /* glsl_parser_extras.cpp */; }; + 2BA55AA91207FEA6002DC82D /* glsl_parser_extras.h in Headers */ = {isa = PBXBuildFile; fileRef = 2BA55A5E1207FEA6002DC82D /* glsl_parser_extras.h */; }; + 2BA55AAA1207FEA6002DC82D /* glsl_parser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BA55A5F1207FEA6002DC82D /* glsl_parser.cpp */; }; + 2BA55AAB1207FEA6002DC82D /* glsl_parser.h in Headers */ = {isa = PBXBuildFile; fileRef = 2BA55A601207FEA6002DC82D /* glsl_parser.h */; }; + 2BA55AAD1207FEA6002DC82D /* glsl_symbol_table.h in Headers */ = {isa = PBXBuildFile; fileRef = 2BA55A621207FEA6002DC82D /* glsl_symbol_table.h */; }; + 2BA55AAE1207FEA6002DC82D /* glsl_types.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BA55A631207FEA6002DC82D /* glsl_types.cpp */; }; + 2BA55AAF1207FEA6002DC82D /* glsl_types.h in Headers */ = {isa = PBXBuildFile; fileRef = 2BA55A641207FEA6002DC82D /* glsl_types.h */; }; + 2BA55AB01207FEA6002DC82D /* hir_field_selection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BA55A651207FEA6002DC82D /* hir_field_selection.cpp */; }; + 2BA55AB21207FEA6002DC82D /* ir_basic_block.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BA55A671207FEA6002DC82D /* ir_basic_block.cpp */; }; + 2BA55AB31207FEA6002DC82D /* ir_basic_block.h in Headers */ = {isa = PBXBuildFile; fileRef = 2BA55A681207FEA6002DC82D /* ir_basic_block.h */; }; + 2BA55AB41207FEA6002DC82D /* ir_clone.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BA55A691207FEA6002DC82D /* ir_clone.cpp */; }; + 2BA55AB51207FEA6002DC82D /* ir_constant_expression.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BA55A6A1207FEA6002DC82D /* ir_constant_expression.cpp */; }; + 2BA55ABC1207FEA6002DC82D /* ir_expression_flattening.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BA55A711207FEA6002DC82D /* ir_expression_flattening.cpp */; }; + 2BA55ABD1207FEA6002DC82D /* ir_expression_flattening.h in Headers */ = {isa = PBXBuildFile; fileRef = 2BA55A721207FEA6002DC82D /* ir_expression_flattening.h */; }; + 2BA55ABE1207FEA6002DC82D /* ir_function_can_inline.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BA55A731207FEA6002DC82D /* ir_function_can_inline.cpp */; }; + 2BA55AC01207FEA6002DC82D /* ir_function_inlining.h in Headers */ = {isa = PBXBuildFile; fileRef = 2BA55A751207FEA6002DC82D /* ir_function_inlining.h */; }; + 2BA55AC11207FEA6002DC82D /* ir_function.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BA55A761207FEA6002DC82D /* ir_function.cpp */; }; + 2BA55AC21207FEA6002DC82D /* ir_hierarchical_visitor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BA55A771207FEA6002DC82D /* ir_hierarchical_visitor.cpp */; }; + 2BA55AC31207FEA6002DC82D /* ir_hierarchical_visitor.h in Headers */ = {isa = PBXBuildFile; fileRef = 2BA55A781207FEA6002DC82D /* ir_hierarchical_visitor.h */; }; + 2BA55AC41207FEA6002DC82D /* ir_hv_accept.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BA55A791207FEA6002DC82D /* ir_hv_accept.cpp */; }; + 2BA55AC81207FEA6002DC82D /* ir_import_prototypes.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BA55A7D1207FEA6002DC82D /* ir_import_prototypes.cpp */; }; + 2BA55ACB1207FEA6002DC82D /* ir_optimization.h in Headers */ = {isa = PBXBuildFile; fileRef = 2BA55A801207FEA6002DC82D /* ir_optimization.h */; }; + 2BA55ACC1207FEA6002DC82D /* ir_print_glsl_visitor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BA55A811207FEA6002DC82D /* ir_print_glsl_visitor.cpp */; }; + 2BA55ACD1207FEA6002DC82D /* ir_print_glsl_visitor.h in Headers */ = {isa = PBXBuildFile; fileRef = 2BA55A821207FEA6002DC82D /* ir_print_glsl_visitor.h */; }; + 2BA55ACE1207FEA6002DC82D /* ir_print_visitor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BA55A831207FEA6002DC82D /* ir_print_visitor.cpp */; }; + 2BA55ACF1207FEA6002DC82D /* ir_print_visitor.h in Headers */ = {isa = PBXBuildFile; fileRef = 2BA55A841207FEA6002DC82D /* ir_print_visitor.h */; }; + 2BA55AD01207FEA6002DC82D /* ir_reader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BA55A851207FEA6002DC82D /* ir_reader.cpp */; }; + 2BA55AD11207FEA6002DC82D /* ir_reader.h in Headers */ = {isa = PBXBuildFile; fileRef = 2BA55A861207FEA6002DC82D /* ir_reader.h */; }; + 2BA55AD51207FEA6002DC82D /* ir_unused_structs.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BA55A8A1207FEA6002DC82D /* ir_unused_structs.cpp */; }; + 2BA55AD61207FEA6002DC82D /* ir_unused_structs.h in Headers */ = {isa = PBXBuildFile; fileRef = 2BA55A8B1207FEA6002DC82D /* ir_unused_structs.h */; }; + 2BA55AD71207FEA6002DC82D /* ir_validate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BA55A8C1207FEA6002DC82D /* ir_validate.cpp */; }; + 2BA55AD81207FEA6002DC82D /* ir_variable_refcount.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BA55A8D1207FEA6002DC82D /* ir_variable_refcount.cpp */; }; + 2BA55AD91207FEA6002DC82D /* ir_variable_refcount.h in Headers */ = {isa = PBXBuildFile; fileRef = 2BA55A8E1207FEA6002DC82D /* ir_variable_refcount.h */; }; + 2BA55ADA1207FEA6002DC82D /* ir_variable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BA55A8F1207FEA6002DC82D /* ir_variable.cpp */; }; + 2BA55ADD1207FEA6002DC82D /* ir_visitor.h in Headers */ = {isa = PBXBuildFile; fileRef = 2BA55A921207FEA6002DC82D /* ir_visitor.h */; }; + 2BA55ADE1207FEA6002DC82D /* ir.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BA55A931207FEA6002DC82D /* ir.cpp */; }; + 2BA55ADF1207FEA6002DC82D /* ir.h in Headers */ = {isa = PBXBuildFile; fileRef = 2BA55A941207FEA6002DC82D /* ir.h */; }; + 2BA55AE01207FEA6002DC82D /* link_functions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BA55A951207FEA6002DC82D /* link_functions.cpp */; }; + 2BA55AE11207FEA6002DC82D /* linker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BA55A961207FEA6002DC82D /* linker.cpp */; }; + 2BA55AE21207FEA6002DC82D /* linker.h in Headers */ = {isa = PBXBuildFile; fileRef = 2BA55A971207FEA6002DC82D /* linker.h */; }; + 2BA55AE31207FEA6002DC82D /* list.h in Headers */ = {isa = PBXBuildFile; fileRef = 2BA55A981207FEA6002DC82D /* list.h */; }; + 2BA55AE41207FEA6002DC82D /* program.h in Headers */ = {isa = PBXBuildFile; fileRef = 2BA55A991207FEA6002DC82D /* program.h */; }; + 2BA55AE51207FEA6002DC82D /* s_expression.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BA55A9A1207FEA6002DC82D /* s_expression.cpp */; }; + 2BA55AE61207FEA6002DC82D /* s_expression.h in Headers */ = {isa = PBXBuildFile; fileRef = 2BA55A9B1207FEA6002DC82D /* s_expression.h */; }; + 2BB2F5B012B8F1580052C6B0 /* lower_discard.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BB2F5AA12B8F1580052C6B0 /* lower_discard.cpp */; }; + 2BB2F5B112B8F1580052C6B0 /* lower_instructions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BB2F5AB12B8F1580052C6B0 /* lower_instructions.cpp */; }; + 2BB2F5B212B8F1580052C6B0 /* lower_vector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BB2F5AC12B8F1580052C6B0 /* lower_vector.cpp */; }; + 2BB2F5B312B8F1580052C6B0 /* opt_discard_simplification.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BB2F5AD12B8F1580052C6B0 /* opt_discard_simplification.cpp */; }; + 2BB2F5B412B8F1580052C6B0 /* strtod.c in Sources */ = {isa = PBXBuildFile; fileRef = 2BB2F5AE12B8F1580052C6B0 /* strtod.c */; }; + 2BB2F5B512B8F1580052C6B0 /* strtod.h in Headers */ = {isa = PBXBuildFile; fileRef = 2BB2F5AF12B8F1580052C6B0 /* strtod.h */; }; + 2BB725A9135094BE0057D8B5 /* compiler.h in Headers */ = {isa = PBXBuildFile; fileRef = 2BB7259B135094BE0057D8B5 /* compiler.h */; }; + 2BB725AA135094BE0057D8B5 /* config.h in Headers */ = {isa = PBXBuildFile; fileRef = 2BB7259C135094BE0057D8B5 /* config.h */; }; + 2BB725AB135094BE0057D8B5 /* context.h in Headers */ = {isa = PBXBuildFile; fileRef = 2BB7259D135094BE0057D8B5 /* context.h */; }; + 2BB725AC135094BE0057D8B5 /* core.h in Headers */ = {isa = PBXBuildFile; fileRef = 2BB7259E135094BE0057D8B5 /* core.h */; }; + 2BB725AD135094BE0057D8B5 /* dd.h in Headers */ = {isa = PBXBuildFile; fileRef = 2BB7259F135094BE0057D8B5 /* dd.h */; }; + 2BB725AE135094BE0057D8B5 /* extensions.h in Headers */ = {isa = PBXBuildFile; fileRef = 2BB725A0135094BE0057D8B5 /* extensions.h */; }; + 2BB725AF135094BE0057D8B5 /* glheader.h in Headers */ = {isa = PBXBuildFile; fileRef = 2BB725A1135094BE0057D8B5 /* glheader.h */; }; + 2BB725B0135094BE0057D8B5 /* imports.h in Headers */ = {isa = PBXBuildFile; fileRef = 2BB725A2135094BE0057D8B5 /* imports.h */; }; + 2BB725B1135094BE0057D8B5 /* macros.h in Headers */ = {isa = PBXBuildFile; fileRef = 2BB725A3135094BE0057D8B5 /* macros.h */; }; + 2BB725B2135094BE0057D8B5 /* mfeatures.h in Headers */ = {isa = PBXBuildFile; fileRef = 2BB725A4135094BE0057D8B5 /* mfeatures.h */; }; + 2BB725B3135094BE0057D8B5 /* mtypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 2BB725A5135094BE0057D8B5 /* mtypes.h */; }; + 2BB725B4135094BE0057D8B5 /* shaderobj.h in Headers */ = {isa = PBXBuildFile; fileRef = 2BB725A6135094BE0057D8B5 /* shaderobj.h */; }; + 2BB725B5135094BE0057D8B5 /* simple_list.h in Headers */ = {isa = PBXBuildFile; fileRef = 2BB725A7135094BE0057D8B5 /* simple_list.h */; }; + 2BB725B6135094BE0057D8B5 /* version.h in Headers */ = {isa = PBXBuildFile; fileRef = 2BB725A8135094BE0057D8B5 /* version.h */; }; + 2BBA49281254706A00D42573 /* glsl_symbol_table.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BBA491F1254706A00D42573 /* glsl_symbol_table.cpp */; }; + 2BBA492A1254706A00D42573 /* loop_analysis.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BBA49211254706A00D42573 /* loop_analysis.cpp */; }; + 2BBA492B1254706A00D42573 /* loop_analysis.h in Headers */ = {isa = PBXBuildFile; fileRef = 2BBA49221254706A00D42573 /* loop_analysis.h */; }; + 2BBA492C1254706A00D42573 /* loop_controls.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BBA49231254706A00D42573 /* loop_controls.cpp */; }; + 2BBA492D1254706A00D42573 /* loop_unroll.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BBA49241254706A00D42573 /* loop_unroll.cpp */; }; + 2BBA492E1254706A00D42573 /* lower_noise.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BBA49251254706A00D42573 /* lower_noise.cpp */; }; + 2BBA492F1254706A00D42573 /* lower_variable_index_to_cond_assign.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BBA49261254706A00D42573 /* lower_variable_index_to_cond_assign.cpp */; }; + 2BBA49301254706A00D42573 /* opt_redundant_jumps.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BBA49271254706A00D42573 /* opt_redundant_jumps.cpp */; }; + 2BEC22EA1356E98300B5E301 /* opt_copy_propagation_elements.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BEC22CB1356E94E00B5E301 /* opt_copy_propagation_elements.cpp */; }; + 2BEC22EB1356E98500B5E301 /* opt_copy_propagation_elements.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BEC22CB1356E94E00B5E301 /* opt_copy_propagation_elements.cpp */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 2B3854481293BE5000F3E692 /* lower_if_to_cond_assign.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = lower_if_to_cond_assign.cpp; path = ../lower_if_to_cond_assign.cpp; sourceTree = SOURCE_ROOT; }; + 2B3854491293BE5000F3E692 /* lower_jumps.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = lower_jumps.cpp; path = ../lower_jumps.cpp; sourceTree = SOURCE_ROOT; }; + 2B38544A1293BE5000F3E692 /* lower_mat_op_to_vec.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = lower_mat_op_to_vec.cpp; path = ../lower_mat_op_to_vec.cpp; sourceTree = SOURCE_ROOT; }; + 2B38544D1293BE5000F3E692 /* lower_vec_index_to_cond_assign.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = lower_vec_index_to_cond_assign.cpp; path = ../lower_vec_index_to_cond_assign.cpp; sourceTree = SOURCE_ROOT; }; + 2B38544E1293BE5000F3E692 /* lower_vec_index_to_swizzle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = lower_vec_index_to_swizzle.cpp; path = ../lower_vec_index_to_swizzle.cpp; sourceTree = SOURCE_ROOT; }; + 2B38544F1293BE5000F3E692 /* opt_algebraic.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = opt_algebraic.cpp; path = ../opt_algebraic.cpp; sourceTree = SOURCE_ROOT; }; + 2B3854501293BE5000F3E692 /* opt_constant_folding.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = opt_constant_folding.cpp; path = ../opt_constant_folding.cpp; sourceTree = SOURCE_ROOT; }; + 2B3854511293BE5000F3E692 /* opt_constant_propagation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = opt_constant_propagation.cpp; path = ../opt_constant_propagation.cpp; sourceTree = SOURCE_ROOT; }; + 2B3854521293BE5000F3E692 /* opt_constant_variable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = opt_constant_variable.cpp; path = ../opt_constant_variable.cpp; sourceTree = SOURCE_ROOT; }; + 2B3854531293BE5000F3E692 /* opt_copy_propagation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = opt_copy_propagation.cpp; path = ../opt_copy_propagation.cpp; sourceTree = SOURCE_ROOT; }; + 2B3854541293BE5000F3E692 /* opt_dead_code_local.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = opt_dead_code_local.cpp; path = ../opt_dead_code_local.cpp; sourceTree = SOURCE_ROOT; }; + 2B3854551293BE5000F3E692 /* opt_dead_code.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = opt_dead_code.cpp; path = ../opt_dead_code.cpp; sourceTree = SOURCE_ROOT; }; + 2B3854561293BE5000F3E692 /* opt_dead_functions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = opt_dead_functions.cpp; path = ../opt_dead_functions.cpp; sourceTree = SOURCE_ROOT; }; + 2B3854571293BE5000F3E692 /* opt_function_inlining.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = opt_function_inlining.cpp; path = ../opt_function_inlining.cpp; sourceTree = SOURCE_ROOT; }; + 2B3854581293BE5000F3E692 /* opt_if_simplification.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = opt_if_simplification.cpp; path = ../opt_if_simplification.cpp; sourceTree = SOURCE_ROOT; }; + 2B3854591293BE5000F3E692 /* opt_noop_swizzle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = opt_noop_swizzle.cpp; path = ../opt_noop_swizzle.cpp; sourceTree = SOURCE_ROOT; }; + 2B38545A1293BE5000F3E692 /* opt_structure_splitting.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = opt_structure_splitting.cpp; path = ../opt_structure_splitting.cpp; sourceTree = SOURCE_ROOT; }; + 2B38545B1293BE5000F3E692 /* opt_swizzle_swizzle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = opt_swizzle_swizzle.cpp; path = ../opt_swizzle_swizzle.cpp; sourceTree = SOURCE_ROOT; }; + 2B38545C1293BE5000F3E692 /* opt_tree_grafting.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = opt_tree_grafting.cpp; path = ../opt_tree_grafting.cpp; sourceTree = SOURCE_ROOT; }; + 2B47D9FD1209C87B00937F2C /* hash_table.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = hash_table.c; path = ../../mesa/program/hash_table.c; sourceTree = SOURCE_ROOT; }; + 2B47D9FE1209C87B00937F2C /* hash_table.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = hash_table.h; path = ../../mesa/program/hash_table.h; sourceTree = SOURCE_ROOT; }; + 2B47D9FF1209C87B00937F2C /* symbol_table.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = symbol_table.c; path = ../../mesa/program/symbol_table.c; sourceTree = SOURCE_ROOT; }; + 2B47DA001209C87B00937F2C /* symbol_table.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = symbol_table.h; path = ../../mesa/program/symbol_table.h; sourceTree = SOURCE_ROOT; }; + 2B62490D12191339003F6EEE /* ir_rvalue_visitor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ir_rvalue_visitor.cpp; path = ../ir_rvalue_visitor.cpp; sourceTree = SOURCE_ROOT; }; + 2B62490E12191339003F6EEE /* ir_rvalue_visitor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ir_rvalue_visitor.h; path = ../ir_rvalue_visitor.h; sourceTree = SOURCE_ROOT; }; + 2B655A7113E0322E00B5278F /* ir_function_detect_recursion.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ir_function_detect_recursion.cpp; path = ../ir_function_detect_recursion.cpp; sourceTree = SOURCE_ROOT; }; + 2B655A7613E0324F00B5278F /* standalone_scaffolding.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = standalone_scaffolding.cpp; path = ../standalone_scaffolding.cpp; sourceTree = SOURCE_ROOT; }; + 2B655A7713E0324F00B5278F /* standalone_scaffolding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = standalone_scaffolding.h; path = ../standalone_scaffolding.h; sourceTree = SOURCE_ROOT; }; + 2B6A99EC1223B1670059FBED /* glcpp-lex.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = "glcpp-lex.c"; path = "../glcpp/glcpp-lex.c"; sourceTree = SOURCE_ROOT; }; + 2B6A99ED1223B1670059FBED /* glcpp-lex.l */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.lex; name = "glcpp-lex.l"; path = "../glcpp/glcpp-lex.l"; sourceTree = SOURCE_ROOT; }; + 2B6A99EE1223B1670059FBED /* glcpp-parse.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = "glcpp-parse.c"; path = "../glcpp/glcpp-parse.c"; sourceTree = SOURCE_ROOT; }; + 2B6A99EF1223B1670059FBED /* glcpp-parse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "glcpp-parse.h"; path = "../glcpp/glcpp-parse.h"; sourceTree = SOURCE_ROOT; }; + 2B6A99F01223B1670059FBED /* glcpp-parse.y */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.yacc; name = "glcpp-parse.y"; path = "../glcpp/glcpp-parse.y"; sourceTree = SOURCE_ROOT; }; + 2B6A99F11223B1670059FBED /* glcpp.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = glcpp.c; path = ../glcpp/glcpp.c; sourceTree = SOURCE_ROOT; }; + 2B6A99F21223B1670059FBED /* glcpp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = glcpp.h; path = ../glcpp/glcpp.h; sourceTree = SOURCE_ROOT; }; + 2B6A99F31223B1670059FBED /* pp.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = pp.c; path = ../glcpp/pp.c; sourceTree = SOURCE_ROOT; }; + 2BA07FA91352E7BB00A1C074 /* ralloc.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = ralloc.c; path = ../ralloc.c; sourceTree = SOURCE_ROOT; }; + 2BA07FAA1352E7BB00A1C074 /* ralloc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ralloc.h; path = ../ralloc.h; sourceTree = SOURCE_ROOT; }; + 2BA080381352EB1A00A1C074 /* builtin_stubs.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = builtin_stubs.cpp; path = ../builtin_stubs.cpp; sourceTree = SOURCE_ROOT; }; + 2BA0803D1352EB9300A1C074 /* builtin_compiler */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = builtin_compiler; sourceTree = BUILT_PRODUCTS_DIR; }; + 2BA0808A1352EBFB00A1C074 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = main.cpp; path = ../main.cpp; sourceTree = SOURCE_ROOT; }; + 2BA55A511207FEA6002DC82D /* ast_expr.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ast_expr.cpp; path = ../ast_expr.cpp; sourceTree = SOURCE_ROOT; }; + 2BA55A521207FEA6002DC82D /* ast_function.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ast_function.cpp; path = ../ast_function.cpp; sourceTree = SOURCE_ROOT; }; + 2BA55A531207FEA6002DC82D /* ast_to_hir.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ast_to_hir.cpp; path = ../ast_to_hir.cpp; sourceTree = SOURCE_ROOT; }; + 2BA55A541207FEA6002DC82D /* ast_type.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ast_type.cpp; path = ../ast_type.cpp; sourceTree = SOURCE_ROOT; }; + 2BA55A551207FEA6002DC82D /* ast.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ast.h; path = ../ast.h; sourceTree = SOURCE_ROOT; }; + 2BA55A561207FEA6002DC82D /* builtin_function.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = builtin_function.cpp; path = ../builtin_function.cpp; sourceTree = SOURCE_ROOT; }; + 2BA55A571207FEA6002DC82D /* builtin_types.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = builtin_types.h; path = ../builtin_types.h; sourceTree = SOURCE_ROOT; }; + 2BA55A581207FEA6002DC82D /* builtin_variables.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = builtin_variables.h; path = ../builtin_variables.h; sourceTree = SOURCE_ROOT; }; + 2BA55A591207FEA6002DC82D /* glsl_lexer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = glsl_lexer.cpp; path = ../glsl_lexer.cpp; sourceTree = SOURCE_ROOT; }; + 2BA55A5A1207FEA6002DC82D /* glsl_lexer.ll */ = {isa = PBXFileReference; explicitFileType = sourcecode.lex; fileEncoding = 4; name = glsl_lexer.ll; path = ../glsl_lexer.ll; sourceTree = SOURCE_ROOT; }; + 2BA55A5B1207FEA6002DC82D /* glsl_optimizer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = glsl_optimizer.cpp; path = ../glsl_optimizer.cpp; sourceTree = SOURCE_ROOT; }; + 2BA55A5C1207FEA6002DC82D /* glsl_optimizer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = glsl_optimizer.h; path = ../glsl_optimizer.h; sourceTree = SOURCE_ROOT; }; + 2BA55A5D1207FEA6002DC82D /* glsl_parser_extras.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = glsl_parser_extras.cpp; path = ../glsl_parser_extras.cpp; sourceTree = SOURCE_ROOT; }; + 2BA55A5E1207FEA6002DC82D /* glsl_parser_extras.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = glsl_parser_extras.h; path = ../glsl_parser_extras.h; sourceTree = SOURCE_ROOT; }; + 2BA55A5F1207FEA6002DC82D /* glsl_parser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = glsl_parser.cpp; path = ../glsl_parser.cpp; sourceTree = SOURCE_ROOT; }; + 2BA55A601207FEA6002DC82D /* glsl_parser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = glsl_parser.h; path = ../glsl_parser.h; sourceTree = SOURCE_ROOT; }; + 2BA55A611207FEA6002DC82D /* glsl_parser.yy */ = {isa = PBXFileReference; explicitFileType = sourcecode.yacc; fileEncoding = 4; name = glsl_parser.yy; path = ../glsl_parser.yy; sourceTree = SOURCE_ROOT; }; + 2BA55A621207FEA6002DC82D /* glsl_symbol_table.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = glsl_symbol_table.h; path = ../glsl_symbol_table.h; sourceTree = SOURCE_ROOT; }; + 2BA55A631207FEA6002DC82D /* glsl_types.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = glsl_types.cpp; path = ../glsl_types.cpp; sourceTree = SOURCE_ROOT; }; + 2BA55A641207FEA6002DC82D /* glsl_types.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = glsl_types.h; path = ../glsl_types.h; sourceTree = SOURCE_ROOT; }; + 2BA55A651207FEA6002DC82D /* hir_field_selection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = hir_field_selection.cpp; path = ../hir_field_selection.cpp; sourceTree = SOURCE_ROOT; }; + 2BA55A671207FEA6002DC82D /* ir_basic_block.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ir_basic_block.cpp; path = ../ir_basic_block.cpp; sourceTree = SOURCE_ROOT; }; + 2BA55A681207FEA6002DC82D /* ir_basic_block.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ir_basic_block.h; path = ../ir_basic_block.h; sourceTree = SOURCE_ROOT; }; + 2BA55A691207FEA6002DC82D /* ir_clone.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ir_clone.cpp; path = ../ir_clone.cpp; sourceTree = SOURCE_ROOT; }; + 2BA55A6A1207FEA6002DC82D /* ir_constant_expression.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ir_constant_expression.cpp; path = ../ir_constant_expression.cpp; sourceTree = SOURCE_ROOT; }; + 2BA55A711207FEA6002DC82D /* ir_expression_flattening.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ir_expression_flattening.cpp; path = ../ir_expression_flattening.cpp; sourceTree = SOURCE_ROOT; }; + 2BA55A721207FEA6002DC82D /* ir_expression_flattening.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ir_expression_flattening.h; path = ../ir_expression_flattening.h; sourceTree = SOURCE_ROOT; }; + 2BA55A731207FEA6002DC82D /* ir_function_can_inline.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ir_function_can_inline.cpp; path = ../ir_function_can_inline.cpp; sourceTree = SOURCE_ROOT; }; + 2BA55A751207FEA6002DC82D /* ir_function_inlining.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ir_function_inlining.h; path = ../ir_function_inlining.h; sourceTree = SOURCE_ROOT; }; + 2BA55A761207FEA6002DC82D /* ir_function.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ir_function.cpp; path = ../ir_function.cpp; sourceTree = SOURCE_ROOT; }; + 2BA55A771207FEA6002DC82D /* ir_hierarchical_visitor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ir_hierarchical_visitor.cpp; path = ../ir_hierarchical_visitor.cpp; sourceTree = SOURCE_ROOT; }; + 2BA55A781207FEA6002DC82D /* ir_hierarchical_visitor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ir_hierarchical_visitor.h; path = ../ir_hierarchical_visitor.h; sourceTree = SOURCE_ROOT; }; + 2BA55A791207FEA6002DC82D /* ir_hv_accept.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ir_hv_accept.cpp; path = ../ir_hv_accept.cpp; sourceTree = SOURCE_ROOT; }; + 2BA55A7D1207FEA6002DC82D /* ir_import_prototypes.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ir_import_prototypes.cpp; path = ../ir_import_prototypes.cpp; sourceTree = SOURCE_ROOT; }; + 2BA55A801207FEA6002DC82D /* ir_optimization.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ir_optimization.h; path = ../ir_optimization.h; sourceTree = SOURCE_ROOT; }; + 2BA55A811207FEA6002DC82D /* ir_print_glsl_visitor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ir_print_glsl_visitor.cpp; path = ../ir_print_glsl_visitor.cpp; sourceTree = SOURCE_ROOT; }; + 2BA55A821207FEA6002DC82D /* ir_print_glsl_visitor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ir_print_glsl_visitor.h; path = ../ir_print_glsl_visitor.h; sourceTree = SOURCE_ROOT; }; + 2BA55A831207FEA6002DC82D /* ir_print_visitor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ir_print_visitor.cpp; path = ../ir_print_visitor.cpp; sourceTree = SOURCE_ROOT; }; + 2BA55A841207FEA6002DC82D /* ir_print_visitor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ir_print_visitor.h; path = ../ir_print_visitor.h; sourceTree = SOURCE_ROOT; }; + 2BA55A851207FEA6002DC82D /* ir_reader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ir_reader.cpp; path = ../ir_reader.cpp; sourceTree = SOURCE_ROOT; }; + 2BA55A861207FEA6002DC82D /* ir_reader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ir_reader.h; path = ../ir_reader.h; sourceTree = SOURCE_ROOT; }; + 2BA55A8A1207FEA6002DC82D /* ir_unused_structs.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ir_unused_structs.cpp; path = ../ir_unused_structs.cpp; sourceTree = SOURCE_ROOT; }; + 2BA55A8B1207FEA6002DC82D /* ir_unused_structs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ir_unused_structs.h; path = ../ir_unused_structs.h; sourceTree = SOURCE_ROOT; }; + 2BA55A8C1207FEA6002DC82D /* ir_validate.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ir_validate.cpp; path = ../ir_validate.cpp; sourceTree = SOURCE_ROOT; }; + 2BA55A8D1207FEA6002DC82D /* ir_variable_refcount.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ir_variable_refcount.cpp; path = ../ir_variable_refcount.cpp; sourceTree = SOURCE_ROOT; }; + 2BA55A8E1207FEA6002DC82D /* ir_variable_refcount.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ir_variable_refcount.h; path = ../ir_variable_refcount.h; sourceTree = SOURCE_ROOT; }; + 2BA55A8F1207FEA6002DC82D /* ir_variable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ir_variable.cpp; path = ../ir_variable.cpp; sourceTree = SOURCE_ROOT; }; + 2BA55A921207FEA6002DC82D /* ir_visitor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ir_visitor.h; path = ../ir_visitor.h; sourceTree = SOURCE_ROOT; }; + 2BA55A931207FEA6002DC82D /* ir.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ir.cpp; path = ../ir.cpp; sourceTree = SOURCE_ROOT; }; + 2BA55A941207FEA6002DC82D /* ir.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ir.h; path = ../ir.h; sourceTree = SOURCE_ROOT; }; + 2BA55A951207FEA6002DC82D /* link_functions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = link_functions.cpp; path = ../link_functions.cpp; sourceTree = SOURCE_ROOT; }; + 2BA55A961207FEA6002DC82D /* linker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = linker.cpp; path = ../linker.cpp; sourceTree = SOURCE_ROOT; }; + 2BA55A971207FEA6002DC82D /* linker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = linker.h; path = ../linker.h; sourceTree = SOURCE_ROOT; }; + 2BA55A981207FEA6002DC82D /* list.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = list.h; path = ../list.h; sourceTree = SOURCE_ROOT; }; + 2BA55A991207FEA6002DC82D /* program.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = program.h; path = ../program.h; sourceTree = SOURCE_ROOT; }; + 2BA55A9A1207FEA6002DC82D /* s_expression.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = s_expression.cpp; path = ../s_expression.cpp; sourceTree = SOURCE_ROOT; }; + 2BA55A9B1207FEA6002DC82D /* s_expression.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = s_expression.h; path = ../s_expression.h; sourceTree = SOURCE_ROOT; }; + 2BB2F5AA12B8F1580052C6B0 /* lower_discard.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = lower_discard.cpp; path = ../lower_discard.cpp; sourceTree = SOURCE_ROOT; }; + 2BB2F5AB12B8F1580052C6B0 /* lower_instructions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = lower_instructions.cpp; path = ../lower_instructions.cpp; sourceTree = SOURCE_ROOT; }; + 2BB2F5AC12B8F1580052C6B0 /* lower_vector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = lower_vector.cpp; path = ../lower_vector.cpp; sourceTree = SOURCE_ROOT; }; + 2BB2F5AD12B8F1580052C6B0 /* opt_discard_simplification.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = opt_discard_simplification.cpp; path = ../opt_discard_simplification.cpp; sourceTree = SOURCE_ROOT; }; + 2BB2F5AE12B8F1580052C6B0 /* strtod.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = strtod.c; path = ../strtod.c; sourceTree = SOURCE_ROOT; }; + 2BB2F5AF12B8F1580052C6B0 /* strtod.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = strtod.h; path = ../strtod.h; sourceTree = SOURCE_ROOT; }; + 2BB7259B135094BE0057D8B5 /* compiler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = compiler.h; path = ../../mesa/main/compiler.h; sourceTree = SOURCE_ROOT; }; + 2BB7259C135094BE0057D8B5 /* config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = config.h; path = ../../mesa/main/config.h; sourceTree = SOURCE_ROOT; }; + 2BB7259D135094BE0057D8B5 /* context.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = context.h; path = ../../mesa/main/context.h; sourceTree = SOURCE_ROOT; }; + 2BB7259E135094BE0057D8B5 /* core.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = core.h; path = ../../mesa/main/core.h; sourceTree = SOURCE_ROOT; }; + 2BB7259F135094BE0057D8B5 /* dd.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = dd.h; path = ../../mesa/main/dd.h; sourceTree = SOURCE_ROOT; }; + 2BB725A0135094BE0057D8B5 /* extensions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = extensions.h; path = ../../mesa/main/extensions.h; sourceTree = SOURCE_ROOT; }; + 2BB725A1135094BE0057D8B5 /* glheader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = glheader.h; path = ../../mesa/main/glheader.h; sourceTree = SOURCE_ROOT; }; + 2BB725A2135094BE0057D8B5 /* imports.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imports.h; path = ../../mesa/main/imports.h; sourceTree = SOURCE_ROOT; }; + 2BB725A3135094BE0057D8B5 /* macros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = macros.h; path = ../../mesa/main/macros.h; sourceTree = SOURCE_ROOT; }; + 2BB725A4135094BE0057D8B5 /* mfeatures.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = mfeatures.h; path = ../../mesa/main/mfeatures.h; sourceTree = SOURCE_ROOT; }; + 2BB725A5135094BE0057D8B5 /* mtypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = mtypes.h; path = ../../mesa/main/mtypes.h; sourceTree = SOURCE_ROOT; }; + 2BB725A6135094BE0057D8B5 /* shaderobj.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = shaderobj.h; path = ../../mesa/main/shaderobj.h; sourceTree = SOURCE_ROOT; }; + 2BB725A7135094BE0057D8B5 /* simple_list.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = simple_list.h; path = ../../mesa/main/simple_list.h; sourceTree = SOURCE_ROOT; }; + 2BB725A8135094BE0057D8B5 /* version.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = version.h; path = ../../mesa/main/version.h; sourceTree = SOURCE_ROOT; }; + 2BBA491F1254706A00D42573 /* glsl_symbol_table.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = glsl_symbol_table.cpp; path = ../glsl_symbol_table.cpp; sourceTree = SOURCE_ROOT; }; + 2BBA49211254706A00D42573 /* loop_analysis.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = loop_analysis.cpp; path = ../loop_analysis.cpp; sourceTree = SOURCE_ROOT; }; + 2BBA49221254706A00D42573 /* loop_analysis.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = loop_analysis.h; path = ../loop_analysis.h; sourceTree = SOURCE_ROOT; }; + 2BBA49231254706A00D42573 /* loop_controls.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = loop_controls.cpp; path = ../loop_controls.cpp; sourceTree = SOURCE_ROOT; }; + 2BBA49241254706A00D42573 /* loop_unroll.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = loop_unroll.cpp; path = ../loop_unroll.cpp; sourceTree = SOURCE_ROOT; }; + 2BBA49251254706A00D42573 /* lower_noise.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = lower_noise.cpp; path = ../lower_noise.cpp; sourceTree = SOURCE_ROOT; }; + 2BBA49261254706A00D42573 /* lower_variable_index_to_cond_assign.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = lower_variable_index_to_cond_assign.cpp; path = ../lower_variable_index_to_cond_assign.cpp; sourceTree = SOURCE_ROOT; }; + 2BBA49271254706A00D42573 /* opt_redundant_jumps.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = opt_redundant_jumps.cpp; path = ../opt_redundant_jumps.cpp; sourceTree = SOURCE_ROOT; }; + 2BEC22CB1356E94E00B5E301 /* opt_copy_propagation_elements.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = opt_copy_propagation_elements.cpp; path = ../opt_copy_propagation_elements.cpp; sourceTree = SOURCE_ROOT; }; + D2AAC046055464E500DB518D /* libmesaglsl2.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libmesaglsl2.a; sourceTree = BUILT_PRODUCTS_DIR; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 2BA0803B1352EB9300A1C074 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + D289987405E68DCB004EDB86 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 08FB7794FE84155DC02AAC07 /* mesaglsl2 */ = { + isa = PBXGroup; + children = ( + 08FB7795FE84155DC02AAC07 /* Source */, + 1AB674ADFE9D54B511CA2CBB /* Products */, + ); + name = mesaglsl2; + sourceTree = ""; + }; + 08FB7795FE84155DC02AAC07 /* Source */ = { + isa = PBXGroup; + children = ( + 2BB7259A135094A60057D8B5 /* mesa */, + 2B47D9FC1209C85400937F2C /* program */, + 2BA55A501207FE41002DC82D /* glsl */, + ); + name = Source; + sourceTree = ""; + }; + 1AB674ADFE9D54B511CA2CBB /* Products */ = { + isa = PBXGroup; + children = ( + D2AAC046055464E500DB518D /* libmesaglsl2.a */, + 2BA0803D1352EB9300A1C074 /* builtin_compiler */, + ); + name = Products; + sourceTree = ""; + }; + 2B47D9FC1209C85400937F2C /* program */ = { + isa = PBXGroup; + children = ( + 2B47D9FD1209C87B00937F2C /* hash_table.c */, + 2B47D9FE1209C87B00937F2C /* hash_table.h */, + 2B47D9FF1209C87B00937F2C /* symbol_table.c */, + 2B47DA001209C87B00937F2C /* symbol_table.h */, + ); + name = program; + sourceTree = ""; + }; + 2B6A99EB1223B1460059FBED /* glcpp */ = { + isa = PBXGroup; + children = ( + 2B6A99EC1223B1670059FBED /* glcpp-lex.c */, + 2B6A99ED1223B1670059FBED /* glcpp-lex.l */, + 2B6A99EE1223B1670059FBED /* glcpp-parse.c */, + 2B6A99EF1223B1670059FBED /* glcpp-parse.h */, + 2B6A99F01223B1670059FBED /* glcpp-parse.y */, + 2B6A99F11223B1670059FBED /* glcpp.c */, + 2B6A99F21223B1670059FBED /* glcpp.h */, + 2B6A99F31223B1670059FBED /* pp.c */, + ); + name = glcpp; + sourceTree = ""; + }; + 2BA55A501207FE41002DC82D /* glsl */ = { + isa = PBXGroup; + children = ( + 2BA0808A1352EBFB00A1C074 /* main.cpp */, + 2BB2F5AA12B8F1580052C6B0 /* lower_discard.cpp */, + 2BB2F5AB12B8F1580052C6B0 /* lower_instructions.cpp */, + 2BB2F5AC12B8F1580052C6B0 /* lower_vector.cpp */, + 2BB2F5AD12B8F1580052C6B0 /* opt_discard_simplification.cpp */, + 2BB2F5AE12B8F1580052C6B0 /* strtod.c */, + 2BB2F5AF12B8F1580052C6B0 /* strtod.h */, + 2B6A99EB1223B1460059FBED /* glcpp */, + 2BA55A511207FEA6002DC82D /* ast_expr.cpp */, + 2BA55A521207FEA6002DC82D /* ast_function.cpp */, + 2BA55A531207FEA6002DC82D /* ast_to_hir.cpp */, + 2BA55A541207FEA6002DC82D /* ast_type.cpp */, + 2BA55A551207FEA6002DC82D /* ast.h */, + 2BA55A561207FEA6002DC82D /* builtin_function.cpp */, + 2BA080381352EB1A00A1C074 /* builtin_stubs.cpp */, + 2BA55A571207FEA6002DC82D /* builtin_types.h */, + 2BA55A581207FEA6002DC82D /* builtin_variables.h */, + 2BA55A591207FEA6002DC82D /* glsl_lexer.cpp */, + 2BA55A5A1207FEA6002DC82D /* glsl_lexer.ll */, + 2BA55A5B1207FEA6002DC82D /* glsl_optimizer.cpp */, + 2BA55A5C1207FEA6002DC82D /* glsl_optimizer.h */, + 2BA55A5D1207FEA6002DC82D /* glsl_parser_extras.cpp */, + 2BA55A5E1207FEA6002DC82D /* glsl_parser_extras.h */, + 2BA55A5F1207FEA6002DC82D /* glsl_parser.cpp */, + 2BA55A601207FEA6002DC82D /* glsl_parser.h */, + 2BA55A611207FEA6002DC82D /* glsl_parser.yy */, + 2BBA491F1254706A00D42573 /* glsl_symbol_table.cpp */, + 2BA55A621207FEA6002DC82D /* glsl_symbol_table.h */, + 2BA55A631207FEA6002DC82D /* glsl_types.cpp */, + 2BA55A641207FEA6002DC82D /* glsl_types.h */, + 2BA55A651207FEA6002DC82D /* hir_field_selection.cpp */, + 2BA55A671207FEA6002DC82D /* ir_basic_block.cpp */, + 2BA55A681207FEA6002DC82D /* ir_basic_block.h */, + 2BA55A691207FEA6002DC82D /* ir_clone.cpp */, + 2BA55A6A1207FEA6002DC82D /* ir_constant_expression.cpp */, + 2BA55A711207FEA6002DC82D /* ir_expression_flattening.cpp */, + 2BA55A721207FEA6002DC82D /* ir_expression_flattening.h */, + 2BA55A731207FEA6002DC82D /* ir_function_can_inline.cpp */, + 2B655A7113E0322E00B5278F /* ir_function_detect_recursion.cpp */, + 2BA55A751207FEA6002DC82D /* ir_function_inlining.h */, + 2BA55A761207FEA6002DC82D /* ir_function.cpp */, + 2BA55A771207FEA6002DC82D /* ir_hierarchical_visitor.cpp */, + 2BA55A781207FEA6002DC82D /* ir_hierarchical_visitor.h */, + 2BA55A791207FEA6002DC82D /* ir_hv_accept.cpp */, + 2BA55A7D1207FEA6002DC82D /* ir_import_prototypes.cpp */, + 2BA55A801207FEA6002DC82D /* ir_optimization.h */, + 2BA55A811207FEA6002DC82D /* ir_print_glsl_visitor.cpp */, + 2BA55A821207FEA6002DC82D /* ir_print_glsl_visitor.h */, + 2BA55A831207FEA6002DC82D /* ir_print_visitor.cpp */, + 2BA55A841207FEA6002DC82D /* ir_print_visitor.h */, + 2BA55A851207FEA6002DC82D /* ir_reader.cpp */, + 2BA55A861207FEA6002DC82D /* ir_reader.h */, + 2B62490D12191339003F6EEE /* ir_rvalue_visitor.cpp */, + 2B62490E12191339003F6EEE /* ir_rvalue_visitor.h */, + 2BA55A8A1207FEA6002DC82D /* ir_unused_structs.cpp */, + 2BA55A8B1207FEA6002DC82D /* ir_unused_structs.h */, + 2BA55A8C1207FEA6002DC82D /* ir_validate.cpp */, + 2BA55A8D1207FEA6002DC82D /* ir_variable_refcount.cpp */, + 2BA55A8E1207FEA6002DC82D /* ir_variable_refcount.h */, + 2BA55A8F1207FEA6002DC82D /* ir_variable.cpp */, + 2BA55A921207FEA6002DC82D /* ir_visitor.h */, + 2BA55A931207FEA6002DC82D /* ir.cpp */, + 2BA55A941207FEA6002DC82D /* ir.h */, + 2BA55A951207FEA6002DC82D /* link_functions.cpp */, + 2BA55A961207FEA6002DC82D /* linker.cpp */, + 2BA55A971207FEA6002DC82D /* linker.h */, + 2BA55A981207FEA6002DC82D /* list.h */, + 2BBA49211254706A00D42573 /* loop_analysis.cpp */, + 2BBA49221254706A00D42573 /* loop_analysis.h */, + 2BBA49231254706A00D42573 /* loop_controls.cpp */, + 2BBA49241254706A00D42573 /* loop_unroll.cpp */, + 2B3854481293BE5000F3E692 /* lower_if_to_cond_assign.cpp */, + 2B3854491293BE5000F3E692 /* lower_jumps.cpp */, + 2B38544A1293BE5000F3E692 /* lower_mat_op_to_vec.cpp */, + 2BBA49251254706A00D42573 /* lower_noise.cpp */, + 2BBA49261254706A00D42573 /* lower_variable_index_to_cond_assign.cpp */, + 2B38544D1293BE5000F3E692 /* lower_vec_index_to_cond_assign.cpp */, + 2B38544E1293BE5000F3E692 /* lower_vec_index_to_swizzle.cpp */, + 2B38544F1293BE5000F3E692 /* opt_algebraic.cpp */, + 2B3854501293BE5000F3E692 /* opt_constant_folding.cpp */, + 2B3854511293BE5000F3E692 /* opt_constant_propagation.cpp */, + 2B3854521293BE5000F3E692 /* opt_constant_variable.cpp */, + 2B3854531293BE5000F3E692 /* opt_copy_propagation.cpp */, + 2BEC22CB1356E94E00B5E301 /* opt_copy_propagation_elements.cpp */, + 2B3854541293BE5000F3E692 /* opt_dead_code_local.cpp */, + 2B3854551293BE5000F3E692 /* opt_dead_code.cpp */, + 2B3854561293BE5000F3E692 /* opt_dead_functions.cpp */, + 2B3854571293BE5000F3E692 /* opt_function_inlining.cpp */, + 2B3854581293BE5000F3E692 /* opt_if_simplification.cpp */, + 2B3854591293BE5000F3E692 /* opt_noop_swizzle.cpp */, + 2BBA49271254706A00D42573 /* opt_redundant_jumps.cpp */, + 2B38545A1293BE5000F3E692 /* opt_structure_splitting.cpp */, + 2B38545B1293BE5000F3E692 /* opt_swizzle_swizzle.cpp */, + 2B38545C1293BE5000F3E692 /* opt_tree_grafting.cpp */, + 2BA55A991207FEA6002DC82D /* program.h */, + 2BA07FA91352E7BB00A1C074 /* ralloc.c */, + 2BA07FAA1352E7BB00A1C074 /* ralloc.h */, + 2BA55A9A1207FEA6002DC82D /* s_expression.cpp */, + 2BA55A9B1207FEA6002DC82D /* s_expression.h */, + 2B655A7613E0324F00B5278F /* standalone_scaffolding.cpp */, + 2B655A7713E0324F00B5278F /* standalone_scaffolding.h */, + ); + name = glsl; + sourceTree = ""; + }; + 2BB7259A135094A60057D8B5 /* mesa */ = { + isa = PBXGroup; + children = ( + 2BB7259B135094BE0057D8B5 /* compiler.h */, + 2BB7259C135094BE0057D8B5 /* config.h */, + 2BB7259D135094BE0057D8B5 /* context.h */, + 2BB7259E135094BE0057D8B5 /* core.h */, + 2BB7259F135094BE0057D8B5 /* dd.h */, + 2BB725A0135094BE0057D8B5 /* extensions.h */, + 2BB725A1135094BE0057D8B5 /* glheader.h */, + 2BB725A2135094BE0057D8B5 /* imports.h */, + 2BB725A3135094BE0057D8B5 /* macros.h */, + 2BB725A4135094BE0057D8B5 /* mfeatures.h */, + 2BB725A5135094BE0057D8B5 /* mtypes.h */, + 2BB725A6135094BE0057D8B5 /* shaderobj.h */, + 2BB725A7135094BE0057D8B5 /* simple_list.h */, + 2BB725A8135094BE0057D8B5 /* version.h */, + ); + name = mesa; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXHeadersBuildPhase section */ + D2AAC043055464E500DB518D /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + 2BA55AA01207FEA6002DC82D /* ast.h in Headers */, + 2BA55AA21207FEA6002DC82D /* builtin_types.h in Headers */, + 2BA55AA31207FEA6002DC82D /* builtin_variables.h in Headers */, + 2BA55AA71207FEA6002DC82D /* glsl_optimizer.h in Headers */, + 2BA55AA91207FEA6002DC82D /* glsl_parser_extras.h in Headers */, + 2BA55AAB1207FEA6002DC82D /* glsl_parser.h in Headers */, + 2BA55AAD1207FEA6002DC82D /* glsl_symbol_table.h in Headers */, + 2BA55AAF1207FEA6002DC82D /* glsl_types.h in Headers */, + 2BA55AB31207FEA6002DC82D /* ir_basic_block.h in Headers */, + 2BA55ABD1207FEA6002DC82D /* ir_expression_flattening.h in Headers */, + 2BA55AC01207FEA6002DC82D /* ir_function_inlining.h in Headers */, + 2BA55AC31207FEA6002DC82D /* ir_hierarchical_visitor.h in Headers */, + 2BA55ACB1207FEA6002DC82D /* ir_optimization.h in Headers */, + 2BA55ACD1207FEA6002DC82D /* ir_print_glsl_visitor.h in Headers */, + 2BA55ACF1207FEA6002DC82D /* ir_print_visitor.h in Headers */, + 2BA55AD11207FEA6002DC82D /* ir_reader.h in Headers */, + 2BA55AD61207FEA6002DC82D /* ir_unused_structs.h in Headers */, + 2BA55AD91207FEA6002DC82D /* ir_variable_refcount.h in Headers */, + 2BA55ADD1207FEA6002DC82D /* ir_visitor.h in Headers */, + 2BA55ADF1207FEA6002DC82D /* ir.h in Headers */, + 2BA55AE21207FEA6002DC82D /* linker.h in Headers */, + 2BA55AE31207FEA6002DC82D /* list.h in Headers */, + 2BA55AE41207FEA6002DC82D /* program.h in Headers */, + 2BA55AE61207FEA6002DC82D /* s_expression.h in Headers */, + 2B47DA021209C87B00937F2C /* hash_table.h in Headers */, + 2B47DA041209C87B00937F2C /* symbol_table.h in Headers */, + 2B62491212191339003F6EEE /* ir_rvalue_visitor.h in Headers */, + 2B6A99F71223B1670059FBED /* glcpp-parse.h in Headers */, + 2B6A99FA1223B1670059FBED /* glcpp.h in Headers */, + 2BBA492B1254706A00D42573 /* loop_analysis.h in Headers */, + 2BB2F5B512B8F1580052C6B0 /* strtod.h in Headers */, + 2BB725A9135094BE0057D8B5 /* compiler.h in Headers */, + 2BB725AA135094BE0057D8B5 /* config.h in Headers */, + 2BB725AB135094BE0057D8B5 /* context.h in Headers */, + 2BB725AC135094BE0057D8B5 /* core.h in Headers */, + 2BB725AD135094BE0057D8B5 /* dd.h in Headers */, + 2BB725AE135094BE0057D8B5 /* extensions.h in Headers */, + 2BB725AF135094BE0057D8B5 /* glheader.h in Headers */, + 2BB725B0135094BE0057D8B5 /* imports.h in Headers */, + 2BB725B1135094BE0057D8B5 /* macros.h in Headers */, + 2BB725B2135094BE0057D8B5 /* mfeatures.h in Headers */, + 2BB725B3135094BE0057D8B5 /* mtypes.h in Headers */, + 2BB725B4135094BE0057D8B5 /* shaderobj.h in Headers */, + 2BB725B5135094BE0057D8B5 /* simple_list.h in Headers */, + 2BB725B6135094BE0057D8B5 /* version.h in Headers */, + 2BA07FAC1352E7BB00A1C074 /* ralloc.h in Headers */, + 2B655A7A13E0324F00B5278F /* standalone_scaffolding.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXHeadersBuildPhase section */ + +/* Begin PBXNativeTarget section */ + 2BA0803C1352EB9300A1C074 /* builtin_compiler */ = { + isa = PBXNativeTarget; + buildConfigurationList = 2BA080411352EBAB00A1C074 /* Build configuration list for PBXNativeTarget "builtin_compiler" */; + buildPhases = ( + 2BA0803A1352EB9300A1C074 /* Sources */, + 2BA0803B1352EB9300A1C074 /* Frameworks */, + 2BA080AA1352EE5500A1C074 /* ShellScript */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = builtin_compiler; + productName = builtin_compiler; + productReference = 2BA0803D1352EB9300A1C074 /* builtin_compiler */; + productType = "com.apple.product-type.tool"; + }; + D2AAC045055464E500DB518D /* mesaglsl2 */ = { + isa = PBXNativeTarget; + buildConfigurationList = 1DEB91EB08733DB70010E9CD /* Build configuration list for PBXNativeTarget "mesaglsl2" */; + buildPhases = ( + D2AAC043055464E500DB518D /* Headers */, + D2AAC044055464E500DB518D /* Sources */, + D289987405E68DCB004EDB86 /* Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = mesaglsl2; + productName = mesaglsl2; + productReference = D2AAC046055464E500DB518D /* libmesaglsl2.a */; + productType = "com.apple.product-type.library.static"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 08FB7793FE84155DC02AAC07 /* Project object */ = { + isa = PBXProject; + buildConfigurationList = 1DEB91EF08733DB70010E9CD /* Build configuration list for PBXProject "mesaglsl2" */; + compatibilityVersion = "Xcode 3.1"; + developmentRegion = English; + hasScannedForEncodings = 1; + knownRegions = ( + English, + Japanese, + French, + German, + ); + mainGroup = 08FB7794FE84155DC02AAC07 /* mesaglsl2 */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + D2AAC045055464E500DB518D /* mesaglsl2 */, + 2BA0803C1352EB9300A1C074 /* builtin_compiler */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXShellScriptBuildPhase section */ + 2BA080AA1352EE5500A1C074 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "echo \"Generating builtin functions...\"\ncd $BUILT_PRODUCTS_DIR\npython builtins/tools/generate_builtins.py ./builtin_compiler >builtin_function.cpp"; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 2BA0803A1352EB9300A1C074 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 2BA080421352EBB900A1C074 /* ast_expr.cpp in Sources */, + 2BA080431352EBB900A1C074 /* ast_function.cpp in Sources */, + 2BA080441352EBB900A1C074 /* ast_to_hir.cpp in Sources */, + 2BA080451352EBB900A1C074 /* ast_type.cpp in Sources */, + 2BA080471352EBB900A1C074 /* glsl_lexer.cpp in Sources */, + 2BA080491352EBB900A1C074 /* glsl_parser_extras.cpp in Sources */, + 2BA0804A1352EBB900A1C074 /* glsl_parser.cpp in Sources */, + 2BA0804B1352EBB900A1C074 /* glsl_types.cpp in Sources */, + 2BA0804C1352EBB900A1C074 /* hir_field_selection.cpp in Sources */, + 2BA0804D1352EBB900A1C074 /* ir_basic_block.cpp in Sources */, + 2BA0804E1352EBB900A1C074 /* ir_clone.cpp in Sources */, + 2BA0804F1352EBB900A1C074 /* ir_constant_expression.cpp in Sources */, + 2BA080501352EBB900A1C074 /* ir_expression_flattening.cpp in Sources */, + 2BA080511352EBB900A1C074 /* ir_function_can_inline.cpp in Sources */, + 2BA080521352EBB900A1C074 /* ir_function.cpp in Sources */, + 2BA080531352EBB900A1C074 /* ir_hierarchical_visitor.cpp in Sources */, + 2BA080541352EBB900A1C074 /* ir_hv_accept.cpp in Sources */, + 2BA080551352EBB900A1C074 /* ir_import_prototypes.cpp in Sources */, + 2BA080561352EBB900A1C074 /* ir_print_glsl_visitor.cpp in Sources */, + 2BA080571352EBB900A1C074 /* ir_print_visitor.cpp in Sources */, + 2BA080581352EBB900A1C074 /* ir_reader.cpp in Sources */, + 2BA080591352EBB900A1C074 /* ir_unused_structs.cpp in Sources */, + 2BA0805A1352EBB900A1C074 /* ir_validate.cpp in Sources */, + 2BA0805B1352EBB900A1C074 /* ir_variable_refcount.cpp in Sources */, + 2BA0805C1352EBB900A1C074 /* ir_variable.cpp in Sources */, + 2BA0805D1352EBB900A1C074 /* ir.cpp in Sources */, + 2BA0805E1352EBB900A1C074 /* link_functions.cpp in Sources */, + 2BA0805F1352EBB900A1C074 /* linker.cpp in Sources */, + 2BA080601352EBB900A1C074 /* s_expression.cpp in Sources */, + 2BA080611352EBB900A1C074 /* hash_table.c in Sources */, + 2BA080621352EBB900A1C074 /* symbol_table.c in Sources */, + 2BA080631352EBB900A1C074 /* ir_rvalue_visitor.cpp in Sources */, + 2BA080641352EBB900A1C074 /* glcpp-lex.c in Sources */, + 2BA080651352EBB900A1C074 /* glcpp-parse.c in Sources */, + 2BA080661352EBB900A1C074 /* pp.c in Sources */, + 2BA080671352EBB900A1C074 /* glsl_symbol_table.cpp in Sources */, + 2BA080681352EBB900A1C074 /* loop_analysis.cpp in Sources */, + 2BA080691352EBB900A1C074 /* loop_controls.cpp in Sources */, + 2BA0806A1352EBB900A1C074 /* loop_unroll.cpp in Sources */, + 2BA0806B1352EBB900A1C074 /* lower_noise.cpp in Sources */, + 2BA0806C1352EBB900A1C074 /* lower_variable_index_to_cond_assign.cpp in Sources */, + 2BA0806D1352EBB900A1C074 /* opt_redundant_jumps.cpp in Sources */, + 2BA0806E1352EBB900A1C074 /* lower_if_to_cond_assign.cpp in Sources */, + 2BA0806F1352EBB900A1C074 /* lower_jumps.cpp in Sources */, + 2BA080701352EBB900A1C074 /* lower_mat_op_to_vec.cpp in Sources */, + 2BA080711352EBB900A1C074 /* lower_vec_index_to_cond_assign.cpp in Sources */, + 2BA080721352EBB900A1C074 /* lower_vec_index_to_swizzle.cpp in Sources */, + 2BA080731352EBB900A1C074 /* opt_algebraic.cpp in Sources */, + 2BA080741352EBB900A1C074 /* opt_constant_folding.cpp in Sources */, + 2BA080751352EBB900A1C074 /* opt_constant_propagation.cpp in Sources */, + 2BA080761352EBB900A1C074 /* opt_constant_variable.cpp in Sources */, + 2BA080771352EBB900A1C074 /* opt_copy_propagation.cpp in Sources */, + 2BA080781352EBB900A1C074 /* opt_dead_code_local.cpp in Sources */, + 2BA080791352EBB900A1C074 /* opt_dead_code.cpp in Sources */, + 2BA0807A1352EBB900A1C074 /* opt_dead_functions.cpp in Sources */, + 2BA0807B1352EBB900A1C074 /* opt_function_inlining.cpp in Sources */, + 2BA0807C1352EBB900A1C074 /* opt_if_simplification.cpp in Sources */, + 2BA0807D1352EBB900A1C074 /* opt_noop_swizzle.cpp in Sources */, + 2BA0807E1352EBB900A1C074 /* opt_structure_splitting.cpp in Sources */, + 2BA0807F1352EBB900A1C074 /* opt_swizzle_swizzle.cpp in Sources */, + 2BA080801352EBB900A1C074 /* opt_tree_grafting.cpp in Sources */, + 2BA080811352EBB900A1C074 /* lower_discard.cpp in Sources */, + 2BA080821352EBB900A1C074 /* lower_instructions.cpp in Sources */, + 2BA080831352EBB900A1C074 /* lower_vector.cpp in Sources */, + 2BA080841352EBB900A1C074 /* opt_discard_simplification.cpp in Sources */, + 2BA080851352EBB900A1C074 /* strtod.c in Sources */, + 2BA080861352EBB900A1C074 /* ralloc.c in Sources */, + 2BA080871352EBD100A1C074 /* builtin_stubs.cpp in Sources */, + 2BA0808B1352EBFB00A1C074 /* main.cpp in Sources */, + 2BEC22EB1356E98500B5E301 /* opt_copy_propagation_elements.cpp in Sources */, + 2B655A7213E0322E00B5278F /* ir_function_detect_recursion.cpp in Sources */, + 2B655A7813E0324F00B5278F /* standalone_scaffolding.cpp in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + D2AAC044055464E500DB518D /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 2BA55A9C1207FEA6002DC82D /* ast_expr.cpp in Sources */, + 2BA55A9D1207FEA6002DC82D /* ast_function.cpp in Sources */, + 2BA55A9E1207FEA6002DC82D /* ast_to_hir.cpp in Sources */, + 2BA55A9F1207FEA6002DC82D /* ast_type.cpp in Sources */, + 2BA55AA11207FEA6002DC82D /* builtin_function.cpp in Sources */, + 2BA55AA41207FEA6002DC82D /* glsl_lexer.cpp in Sources */, + 2BA55AA61207FEA6002DC82D /* glsl_optimizer.cpp in Sources */, + 2BA55AA81207FEA6002DC82D /* glsl_parser_extras.cpp in Sources */, + 2BA55AAA1207FEA6002DC82D /* glsl_parser.cpp in Sources */, + 2BA55AAE1207FEA6002DC82D /* glsl_types.cpp in Sources */, + 2BA55AB01207FEA6002DC82D /* hir_field_selection.cpp in Sources */, + 2BA55AB21207FEA6002DC82D /* ir_basic_block.cpp in Sources */, + 2BA55AB41207FEA6002DC82D /* ir_clone.cpp in Sources */, + 2BA55AB51207FEA6002DC82D /* ir_constant_expression.cpp in Sources */, + 2BA55ABC1207FEA6002DC82D /* ir_expression_flattening.cpp in Sources */, + 2BA55ABE1207FEA6002DC82D /* ir_function_can_inline.cpp in Sources */, + 2BA55AC11207FEA6002DC82D /* ir_function.cpp in Sources */, + 2BA55AC21207FEA6002DC82D /* ir_hierarchical_visitor.cpp in Sources */, + 2BA55AC41207FEA6002DC82D /* ir_hv_accept.cpp in Sources */, + 2BA55AC81207FEA6002DC82D /* ir_import_prototypes.cpp in Sources */, + 2BA55ACC1207FEA6002DC82D /* ir_print_glsl_visitor.cpp in Sources */, + 2BA55ACE1207FEA6002DC82D /* ir_print_visitor.cpp in Sources */, + 2BA55AD01207FEA6002DC82D /* ir_reader.cpp in Sources */, + 2BA55AD51207FEA6002DC82D /* ir_unused_structs.cpp in Sources */, + 2BA55AD71207FEA6002DC82D /* ir_validate.cpp in Sources */, + 2BA55AD81207FEA6002DC82D /* ir_variable_refcount.cpp in Sources */, + 2BA55ADA1207FEA6002DC82D /* ir_variable.cpp in Sources */, + 2BA55ADE1207FEA6002DC82D /* ir.cpp in Sources */, + 2BA55AE01207FEA6002DC82D /* link_functions.cpp in Sources */, + 2BA55AE11207FEA6002DC82D /* linker.cpp in Sources */, + 2BA55AE51207FEA6002DC82D /* s_expression.cpp in Sources */, + 2B47DA011209C87B00937F2C /* hash_table.c in Sources */, + 2B47DA031209C87B00937F2C /* symbol_table.c in Sources */, + 2B62491112191339003F6EEE /* ir_rvalue_visitor.cpp in Sources */, + 2B6A99F41223B1670059FBED /* glcpp-lex.c in Sources */, + 2B6A99F61223B1670059FBED /* glcpp-parse.c in Sources */, + 2B6A99FB1223B1670059FBED /* pp.c in Sources */, + 2BBA49281254706A00D42573 /* glsl_symbol_table.cpp in Sources */, + 2BBA492A1254706A00D42573 /* loop_analysis.cpp in Sources */, + 2BBA492C1254706A00D42573 /* loop_controls.cpp in Sources */, + 2BBA492D1254706A00D42573 /* loop_unroll.cpp in Sources */, + 2BBA492E1254706A00D42573 /* lower_noise.cpp in Sources */, + 2BBA492F1254706A00D42573 /* lower_variable_index_to_cond_assign.cpp in Sources */, + 2BBA49301254706A00D42573 /* opt_redundant_jumps.cpp in Sources */, + 2B38545F1293BE5000F3E692 /* lower_if_to_cond_assign.cpp in Sources */, + 2B3854601293BE5000F3E692 /* lower_jumps.cpp in Sources */, + 2B3854611293BE5000F3E692 /* lower_mat_op_to_vec.cpp in Sources */, + 2B3854641293BE5000F3E692 /* lower_vec_index_to_cond_assign.cpp in Sources */, + 2B3854651293BE5000F3E692 /* lower_vec_index_to_swizzle.cpp in Sources */, + 2B3854661293BE5000F3E692 /* opt_algebraic.cpp in Sources */, + 2B3854671293BE5000F3E692 /* opt_constant_folding.cpp in Sources */, + 2B3854681293BE5000F3E692 /* opt_constant_propagation.cpp in Sources */, + 2B3854691293BE5000F3E692 /* opt_constant_variable.cpp in Sources */, + 2B38546A1293BE5000F3E692 /* opt_copy_propagation.cpp in Sources */, + 2B38546B1293BE5000F3E692 /* opt_dead_code_local.cpp in Sources */, + 2B38546C1293BE5000F3E692 /* opt_dead_code.cpp in Sources */, + 2B38546D1293BE5000F3E692 /* opt_dead_functions.cpp in Sources */, + 2B38546E1293BE5000F3E692 /* opt_function_inlining.cpp in Sources */, + 2B38546F1293BE5000F3E692 /* opt_if_simplification.cpp in Sources */, + 2B3854701293BE5000F3E692 /* opt_noop_swizzle.cpp in Sources */, + 2B3854711293BE5000F3E692 /* opt_structure_splitting.cpp in Sources */, + 2B3854721293BE5000F3E692 /* opt_swizzle_swizzle.cpp in Sources */, + 2B3854731293BE5000F3E692 /* opt_tree_grafting.cpp in Sources */, + 2BB2F5B012B8F1580052C6B0 /* lower_discard.cpp in Sources */, + 2BB2F5B112B8F1580052C6B0 /* lower_instructions.cpp in Sources */, + 2BB2F5B212B8F1580052C6B0 /* lower_vector.cpp in Sources */, + 2BB2F5B312B8F1580052C6B0 /* opt_discard_simplification.cpp in Sources */, + 2BB2F5B412B8F1580052C6B0 /* strtod.c in Sources */, + 2BA07FAB1352E7BB00A1C074 /* ralloc.c in Sources */, + 2BEC22EA1356E98300B5E301 /* opt_copy_propagation_elements.cpp in Sources */, + 2B655A7313E0322E00B5278F /* ir_function_detect_recursion.cpp in Sources */, + 2B655A7913E0324F00B5278F /* standalone_scaffolding.cpp in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 1DEB91EC08733DB70010E9CD /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + COPY_PHASE_STRIP = NO; + GCC_DYNAMIC_NO_PIC = NO; + GCC_ENABLE_FIX_AND_CONTINUE = YES; + GCC_MODEL_TUNING = G5; + GCC_OPTIMIZATION_LEVEL = 0; + INSTALL_PATH = /usr/local/lib; + PRODUCT_NAME = mesaglsl2; + }; + name = Debug; + }; + 1DEB91ED08733DB70010E9CD /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + GCC_MODEL_TUNING = G5; + INSTALL_PATH = /usr/local/lib; + PRODUCT_NAME = mesaglsl2; + }; + name = Release; + }; + 1DEB91F008733DB70010E9CD /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = i386; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_VERSION = 4.0; + GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = ( + ../../mapi, + ../../../include, + ../../mesa, + ); + ONLY_ACTIVE_ARCH = YES; + PREBINDING = NO; + SDKROOT = macosx10.4; + }; + name = Debug; + }; + 1DEB91F108733DB70010E9CD /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = i386; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_VERSION = 4.0; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = ( + ../../mapi, + ../../../include, + ../../mesa, + ); + PREBINDING = NO; + SDKROOT = macosx10.4; + }; + name = Release; + }; + 2BA0803F1352EB9400A1C074 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CONFIGURATION_BUILD_DIR = ..; + COPY_PHASE_STRIP = NO; + GCC_DYNAMIC_NO_PIC = NO; + GCC_ENABLE_FIX_AND_CONTINUE = YES; + GCC_MODEL_TUNING = G5; + GCC_OPTIMIZATION_LEVEL = 0; + INSTALL_PATH = /usr/local/bin; + PREBINDING = NO; + PRODUCT_NAME = builtin_compiler; + }; + name = Debug; + }; + 2BA080401352EB9400A1C074 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CONFIGURATION_BUILD_DIR = ..; + COPY_PHASE_STRIP = YES; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + GCC_ENABLE_FIX_AND_CONTINUE = NO; + GCC_MODEL_TUNING = G5; + INSTALL_PATH = /usr/local/bin; + PREBINDING = NO; + PRODUCT_NAME = builtin_compiler; + ZERO_LINK = NO; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 1DEB91EB08733DB70010E9CD /* Build configuration list for PBXNativeTarget "mesaglsl2" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 1DEB91EC08733DB70010E9CD /* Debug */, + 1DEB91ED08733DB70010E9CD /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 1DEB91EF08733DB70010E9CD /* Build configuration list for PBXProject "mesaglsl2" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 1DEB91F008733DB70010E9CD /* Debug */, + 1DEB91F108733DB70010E9CD /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 2BA080411352EBAB00A1C074 /* Build configuration list for PBXNativeTarget "builtin_compiler" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 2BA0803F1352EB9400A1C074 /* Debug */, + 2BA080401352EB9400A1C074 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 08FB7793FE84155DC02AAC07 /* Project object */; +} diff --git a/3rdparty/glsl-optimizer/src/mapi/glapi/.gitignore b/3rdparty/glsl-optimizer/src/mapi/glapi/.gitignore new file mode 100644 index 000000000..e706bc23c --- /dev/null +++ b/3rdparty/glsl-optimizer/src/mapi/glapi/.gitignore @@ -0,0 +1,11 @@ +.cvsignore +glX_proto_common.pyo +glX_proto_common.pyc +typeexpr.pyo +typeexpr.pyc +license.pyo +license.pyc +gl_XML.pyo +gl_XML.pyc +glX_XML.pyo +glX_XML.pyc diff --git a/3rdparty/glsl-optimizer/src/mapi/glapi/glapi.h b/3rdparty/glsl-optimizer/src/mapi/glapi/glapi.h new file mode 100644 index 000000000..35dffd757 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/mapi/glapi/glapi.h @@ -0,0 +1,181 @@ +/* + * Mesa 3-D graphics library + * Version: 7.1 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +/** + * \mainpage Mesa GL API Module + * + * \section GLAPIIntroduction Introduction + * + * The Mesa GL API module is responsible for dispatching all the + * gl*() functions. All GL functions are dispatched by jumping through + * the current dispatch table (basically a struct full of function + * pointers.) + * + * A per-thread current dispatch table and per-thread current context + * pointer are managed by this module too. + * + * This module is intended to be non-Mesa-specific so it can be used + * with the X/DRI libGL also. + */ + + +#ifndef _GLAPI_H +#define _GLAPI_H + + +#ifdef _GLAPI_NO_EXPORTS +# define _GLAPI_EXPORT +#else /* _GLAPI_NO_EXPORTS */ +# ifdef _WIN32 +# ifdef _GLAPI_DLL_EXPORTS +# define _GLAPI_EXPORT __declspec(dllexport) +# else +# define _GLAPI_EXPORT __declspec(dllimport) +# endif +# elif defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) +# define _GLAPI_EXPORT __attribute__((visibility("default"))) +# else +# define _GLAPI_EXPORT +# endif +#endif /* _GLAPI_NO_EXPORTS */ + + +/* Is this needed? It is incomplete anyway. */ +#ifdef USE_MGL_NAMESPACE +#define _glapi_set_dispatch _mglapi_set_dispatch +#define _glapi_get_dispatch _mglapi_get_dispatch +#define _glapi_set_context _mglapi_set_context +#define _glapi_get_context _mglapi_get_context +#define _glapi_Dispatch _mglapi_Dispatch +#define _glapi_Context _mglapi_Context +#endif + +#include "glapi/glthread.h" + +typedef void (*_glapi_proc)(void); +struct _glapi_table; + + +#if defined (GLX_USE_TLS) + +_GLAPI_EXPORT extern __thread struct _glapi_table * _glapi_tls_Dispatch + __attribute__((tls_model("initial-exec"))); + +_GLAPI_EXPORT extern __thread void * _glapi_tls_Context + __attribute__((tls_model("initial-exec"))); + +_GLAPI_EXPORT extern const struct _glapi_table *_glapi_Dispatch; +_GLAPI_EXPORT extern const void *_glapi_Context; + +# define GET_DISPATCH() _glapi_tls_Dispatch +# define GET_CURRENT_CONTEXT(C) struct gl_context *C = (struct gl_context *) _glapi_tls_Context + +#else + +_GLAPI_EXPORT extern struct _glapi_table *_glapi_Dispatch; +_GLAPI_EXPORT extern void *_glapi_Context; + +# ifdef THREADS + +# define GET_DISPATCH() \ + (likely(_glapi_Dispatch) ? _glapi_Dispatch : _glapi_get_dispatch()) + +# define GET_CURRENT_CONTEXT(C) struct gl_context *C = (struct gl_context *) \ + (likely(_glapi_Context) ? _glapi_Context : _glapi_get_context()) + +# else + +# define GET_DISPATCH() _glapi_Dispatch +# define GET_CURRENT_CONTEXT(C) struct gl_context *C = (struct gl_context *) _glapi_Context + +# endif + +#endif /* defined (GLX_USE_TLS) */ + + +void +_glapi_destroy_multithread(void); + + +_GLAPI_EXPORT void +_glapi_check_multithread(void); + + +_GLAPI_EXPORT void +_glapi_set_context(void *context); + + +_GLAPI_EXPORT void * +_glapi_get_context(void); + + +_GLAPI_EXPORT void +_glapi_set_dispatch(struct _glapi_table *dispatch); + + +_GLAPI_EXPORT struct _glapi_table * +_glapi_get_dispatch(void); + + +_GLAPI_EXPORT unsigned int +_glapi_get_dispatch_table_size(void); + + +_GLAPI_EXPORT int +_glapi_add_dispatch( const char * const * function_names, + const char * parameter_signature ); + +_GLAPI_EXPORT int +_glapi_get_proc_offset(const char *funcName); + + +_GLAPI_EXPORT _glapi_proc +_glapi_get_proc_address(const char *funcName); + + +_GLAPI_EXPORT const char * +_glapi_get_proc_name(unsigned int offset); + + +_GLAPI_EXPORT struct _glapi_table * +_glapi_create_table_from_handle(void *handle, const char *symbol_prefix); + + +_GLAPI_EXPORT unsigned long +_glthread_GetID(void); + + +/* + * These stubs are kept so that the old DRI drivers still load. + */ +_GLAPI_EXPORT void +_glapi_noop_enable_warnings(unsigned char enable); + + +_GLAPI_EXPORT void +_glapi_set_warning_func(_glapi_proc func); + + +#endif /* _GLAPI_H */ diff --git a/3rdparty/glsl-optimizer/src/mapi/glapi/glthread.h b/3rdparty/glsl-optimizer/src/mapi/glapi/glthread.h new file mode 100644 index 000000000..fc4ece7c3 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/mapi/glapi/glthread.h @@ -0,0 +1,20 @@ +#ifndef GLTHREAD_H +#define GLTHREAD_H + +#include "mapi/u_thread.h" + +#define _glthread_DECLARE_STATIC_MUTEX(name) u_mutex_declare_static(name) +#define _glthread_INIT_MUTEX(name) u_mutex_init(name) +#define _glthread_DESTROY_MUTEX(name) u_mutex_destroy(name) +#define _glthread_LOCK_MUTEX(name) u_mutex_lock(name) +#define _glthread_UNLOCK_MUTEX(name) u_mutex_unlock(name) + +#define _glthread_InitTSD(tsd) u_tsd_init(tsd); +#define _glthread_DestroyTSD(tsd) u_tsd_destroy(tsd); +#define _glthread_GetTSD(tsd) u_tsd_get(tsd); +#define _glthread_SetTSD(tsd, ptr) u_tsd_set(tsd, ptr); + +typedef struct u_tsd _glthread_TSD; +typedef u_mutex _glthread_Mutex; + +#endif /* GLTHREAD_H */ diff --git a/3rdparty/glsl-optimizer/src/mapi/mapi/u_compiler.h b/3rdparty/glsl-optimizer/src/mapi/mapi/u_compiler.h new file mode 100644 index 000000000..f1752d16f --- /dev/null +++ b/3rdparty/glsl-optimizer/src/mapi/mapi/u_compiler.h @@ -0,0 +1,48 @@ +#ifndef _U_COMPILER_H_ +#define _U_COMPILER_H_ + +/* Function inlining */ +#ifndef INLINE +# ifdef __cplusplus +# define INLINE inline +# elif defined(__GNUC__) +# define INLINE __inline__ +# elif defined(_MSC_VER) +# define INLINE __inline +# elif defined(__ICL) +# define INLINE __inline +# elif defined(__INTEL_COMPILER) +# define INLINE inline +# elif defined(__WATCOMC__) && (__WATCOMC__ >= 1100) +# define INLINE __inline +# elif defined(__SUNPRO_C) && defined(__C99FEATURES__) +# define INLINE inline +# elif (__STDC_VERSION__ >= 199901L) /* C99 */ +# define INLINE inline +# else +# define INLINE +# endif +#endif + +/* Function visibility */ +#ifndef PUBLIC +# if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) +# define PUBLIC __attribute__((visibility("default"))) +# elif defined(_MSC_VER) +# define PUBLIC __declspec(dllexport) +# else +# define PUBLIC +# endif +#endif + +#ifndef likely +# if defined(__GNUC__) +# define likely(x) __builtin_expect(!!(x), 1) +# define unlikely(x) __builtin_expect(!!(x), 0) +# else +# define likely(x) (x) +# define unlikely(x) (x) +# endif +#endif + +#endif /* _U_COMPILER_H_ */ diff --git a/3rdparty/glsl-optimizer/src/mapi/mapi/u_current.h b/3rdparty/glsl-optimizer/src/mapi/mapi/u_current.h new file mode 100644 index 000000000..f9cffd8c3 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/mapi/mapi/u_current.h @@ -0,0 +1,87 @@ +#ifndef _U_CURRENT_H_ +#define _U_CURRENT_H_ + +#if defined(MAPI_MODE_UTIL) || defined(MAPI_MODE_GLAPI) || \ + defined(MAPI_MODE_BRIDGE) + +#include "glapi/glapi.h" + +/* ugly renames to match glapi.h */ +#define mapi_table _glapi_table + +#ifdef GLX_USE_TLS +#define u_current_table _glapi_tls_Dispatch +#define u_current_user _glapi_tls_Context +#else +#define u_current_table _glapi_Dispatch +#define u_current_user _glapi_Context +#endif + +#define u_current_get_internal _glapi_get_dispatch +#define u_current_get_user_internal _glapi_get_context + +#define u_current_table_tsd _gl_DispatchTSD + +#else /* MAPI_MODE_UTIL || MAPI_MODE_GLAPI || MAPI_MODE_BRIDGE */ + +#include "u_compiler.h" + +struct mapi_table; + +#ifdef GLX_USE_TLS + +extern __thread struct mapi_table *u_current_table + __attribute__((tls_model("initial-exec"))); + +extern __thread void *u_current_user + __attribute__((tls_model("initial-exec"))); + +#else /* GLX_USE_TLS */ + +extern struct mapi_table *u_current_table; +extern void *u_current_user; + +#endif /* GLX_USE_TLS */ + +#endif /* MAPI_MODE_UTIL || MAPI_MODE_GLAPI || MAPI_MODE_BRIDGE */ + +void +u_current_init(void); + +void +u_current_destroy(void); + +void +u_current_set(const struct mapi_table *tbl); + +struct mapi_table * +u_current_get_internal(void); + +void +u_current_set_user(const void *ptr); + +void * +u_current_get_user_internal(void); + +static INLINE const struct mapi_table * +u_current_get(void) +{ +#ifdef GLX_USE_TLS + return u_current_table; +#else + return (likely(u_current_table) ? + u_current_table : u_current_get_internal()); +#endif +} + +static INLINE const void * +u_current_get_user(void) +{ +#ifdef GLX_USE_TLS + return u_current_user; +#else + return likely(u_current_user) ? u_current_user : u_current_get_user_internal(); +#endif +} + +#endif /* _U_CURRENT_H_ */ diff --git a/3rdparty/glsl-optimizer/src/mapi/mapi/u_thread.h b/3rdparty/glsl-optimizer/src/mapi/mapi/u_thread.h new file mode 100644 index 000000000..1cc8be3fa --- /dev/null +++ b/3rdparty/glsl-optimizer/src/mapi/mapi/u_thread.h @@ -0,0 +1,201 @@ +/* + * Mesa 3-D graphics library + * Version: 6.5.2 + * + * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +/* + * Thread support for gl dispatch. + * + * Initial version by John Stone (j.stone@acm.org) (johns@cs.umr.edu) + * and Christoph Poliwoda (poliwoda@volumegraphics.com) + * Revised by Keith Whitwell + * Adapted for new gl dispatcher by Brian Paul + * Modified for use in mapi by Chia-I Wu + */ + +/* + * If this file is accidentally included by a non-threaded build, + * it should not cause the build to fail, or otherwise cause problems. + * In general, it should only be included when needed however. + */ + +#ifndef _U_THREAD_H_ +#define _U_THREAD_H_ + +#include "u_compiler.h" + +#if defined(PTHREADS) || defined(WIN32) || defined(BEOS_THREADS) +#ifndef THREADS +#define THREADS +#endif +#endif + +/* + * POSIX threads. This should be your choice in the Unix world + * whenever possible. When building with POSIX threads, be sure + * to enable any compiler flags which will cause the MT-safe + * libc (if one exists) to be used when linking, as well as any + * header macros for MT-safe errno, etc. For Solaris, this is the -mt + * compiler flag. On Solaris with gcc, use -D_REENTRANT to enable + * proper compiling for MT-safe libc etc. + */ +#if defined(PTHREADS) +#include /* POSIX threads headers */ + +struct u_tsd { + pthread_key_t key; + int initMagic; +}; + +typedef pthread_mutex_t u_mutex; + +#define u_mutex_declare_static(name) \ + static u_mutex name = PTHREAD_MUTEX_INITIALIZER + +#define u_mutex_init(name) pthread_mutex_init(&(name), NULL) +#define u_mutex_destroy(name) pthread_mutex_destroy(&(name)) +#define u_mutex_lock(name) (void) pthread_mutex_lock(&(name)) +#define u_mutex_unlock(name) (void) pthread_mutex_unlock(&(name)) + +#endif /* PTHREADS */ + + +/* + * Windows threads. Should work with Windows NT and 95. + * IMPORTANT: Link with multithreaded runtime library when THREADS are + * used! + */ +#ifdef WIN32 +#include + +struct u_tsd { + DWORD key; + int initMagic; +}; + +typedef CRITICAL_SECTION u_mutex; + +/* http://locklessinc.com/articles/pthreads_on_windows/ */ +#define u_mutex_declare_static(name) \ + static u_mutex name = {(PCRITICAL_SECTION_DEBUG)-1, -1, 0, 0, 0, 0} + +#define u_mutex_init(name) InitializeCriticalSection(&name) +#define u_mutex_destroy(name) DeleteCriticalSection(&name) +#define u_mutex_lock(name) EnterCriticalSection(&name) +#define u_mutex_unlock(name) LeaveCriticalSection(&name) + +#endif /* WIN32 */ + + +/* + * BeOS threads. R5.x required. + */ +#ifdef BEOS_THREADS + +/* Problem with OS.h and this file on haiku */ +#ifndef __HAIKU__ +#include +#endif + +#include + +/* The only two typedefs required here + * this is cause of the OS.h problem + */ +#ifdef __HAIKU__ +typedef int32 thread_id; +typedef int32 sem_id; +#endif + +struct u_tsd { + int32 key; + int initMagic; +}; + +/* Use Benaphore, aka speeder semaphore */ +typedef struct { + int32 lock; + sem_id sem; +} benaphore; +typedef benaphore u_mutex; + +#define u_mutex_declare_static(name) \ + static u_mutex name = { 0, 0 } + +#define u_mutex_init(name) \ + name.sem = create_sem(0, #name"_benaphore"), \ + name.lock = 0 + +#define u_mutex_destroy(name) \ + delete_sem(name.sem), \ + name.lock = 0 + +#define u_mutex_lock(name) \ + if (name.sem == 0) \ + u_mutex_init(name); \ + if (atomic_add(&(name.lock), 1) >= 1) \ + acquire_sem(name.sem) + +#define u_mutex_unlock(name) \ + if (atomic_add(&(name.lock), -1) > 1) \ + release_sem(name.sem) + +#endif /* BEOS_THREADS */ + + +/* + * THREADS not defined + */ +#ifndef THREADS + +struct u_tsd { + int initMagic; +}; + +typedef unsigned u_mutex; + +#define u_mutex_declare_static(name) static u_mutex name = 0 +#define u_mutex_init(name) (void) name +#define u_mutex_destroy(name) (void) name +#define u_mutex_lock(name) (void) name +#define u_mutex_unlock(name) (void) name + +#endif /* THREADS */ + + +unsigned long +u_thread_self(void); + +void +u_tsd_init(struct u_tsd *tsd); + +void +u_tsd_destroy(struct u_tsd *tsd); /* WIN32 only */ + +void * +u_tsd_get(struct u_tsd *tsd); + +void +u_tsd_set(struct u_tsd *tsd, void *ptr); + +#endif /* _U_THREAD_H_ */ diff --git a/3rdparty/glsl-optimizer/src/mesa/.gitignore b/3rdparty/glsl-optimizer/src/mesa/.gitignore new file mode 100644 index 000000000..ce83eaf47 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/mesa/.gitignore @@ -0,0 +1,5 @@ +*/gen_matypes +*/matypes.h +depend.es* +depend.es* +objs-es* diff --git a/3rdparty/glsl-optimizer/src/mesa/main/.gitignore b/3rdparty/glsl-optimizer/src/mesa/main/.gitignore new file mode 100644 index 000000000..2575f44df --- /dev/null +++ b/3rdparty/glsl-optimizer/src/mesa/main/.gitignore @@ -0,0 +1,6 @@ +api_exec_es1.c +api_exec_es2.c +get_es1.c +get_es2.c +git_sha1.h +git_sha1.h.tmp diff --git a/3rdparty/glsl-optimizer/src/mesa/main/compiler.h b/3rdparty/glsl-optimizer/src/mesa/main/compiler.h new file mode 100644 index 000000000..8ed1c6fa6 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/mesa/main/compiler.h @@ -0,0 +1,493 @@ +/* + * Mesa 3-D graphics library + * Version: 7.5 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (C) 2009 VMware, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +/** + * \file compiler.h + * Compiler-related stuff. + */ + + +#ifndef COMPILER_H +#define COMPILER_H + + +#include +#include +#if defined(__alpha__) && defined(CCPML) +#include /* use Compaq's Fast Math Library on Alpha */ +#else +#include +#endif +#include +#include +#include +#include +#include +#include + + +#ifdef __cplusplus +extern "C" { +#endif + + +/** + * Get standard integer types + */ +#include + + +/** + * Sun compilers define __i386 instead of the gcc-style __i386__ + */ +#ifdef __SUNPRO_C +# if !defined(__i386__) && defined(__i386) +# define __i386__ +# elif !defined(__amd64__) && defined(__amd64) +# define __amd64__ +# elif !defined(__sparc__) && defined(__sparc) +# define __sparc__ +# endif +# if !defined(__volatile) +# define __volatile volatile +# endif +#endif + + +/** + * finite macro. + */ +#if defined(_MSC_VER) +# define finite _finite +#elif defined(__WATCOMC__) +# define finite _finite +#endif + + +/** + * Disable assorted warnings + */ +#if !defined(OPENSTEP) && (defined(__WIN32__) && !defined(__CYGWIN__)) && !defined(BUILD_FOR_SNAP) +# if !defined(__GNUC__) /* mingw environment */ +# pragma warning( disable : 4068 ) /* unknown pragma */ +# pragma warning( disable : 4710 ) /* function 'foo' not inlined */ +# pragma warning( disable : 4711 ) /* function 'foo' selected for automatic inline expansion */ +# pragma warning( disable : 4127 ) /* conditional expression is constant */ +# if defined(MESA_MINWARN) +# pragma warning( disable : 4244 ) /* '=' : conversion from 'const double ' to 'float ', possible loss of data */ +# pragma warning( disable : 4018 ) /* '<' : signed/unsigned mismatch */ +# pragma warning( disable : 4305 ) /* '=' : truncation from 'const double ' to 'float ' */ +# pragma warning( disable : 4550 ) /* 'function' undefined; assuming extern returning int */ +# pragma warning( disable : 4761 ) /* integral size mismatch in argument; conversion supplied */ +# endif +# endif +#endif +#if defined(__WATCOMC__) +# pragma disable_message(201) /* Disable unreachable code warnings */ +#endif + + + +/** + * Function inlining + */ +#ifndef INLINE +# if defined(__GNUC__) +# define INLINE __inline__ +# elif defined(__MSC__) +# define INLINE __inline +# elif defined(_MSC_VER) +# define INLINE __inline +# elif defined(__ICL) +# define INLINE __inline +# elif defined(__INTEL_COMPILER) +# define INLINE inline +# elif defined(__WATCOMC__) && (__WATCOMC__ >= 1100) +# define INLINE __inline +# elif defined(__SUNPRO_C) && defined(__C99FEATURES__) +# define INLINE inline +# define __inline inline +# define __inline__ inline +# elif (__STDC_VERSION__ >= 199901L) /* C99 */ +# define INLINE inline +# else +# define INLINE +# endif +#endif + + +/** + * PUBLIC/USED macros + * + * If we build the library with gcc's -fvisibility=hidden flag, we'll + * use the PUBLIC macro to mark functions that are to be exported. + * + * We also need to define a USED attribute, so the optimizer doesn't + * inline a static function that we later use in an alias. - ajax + */ +#ifndef PUBLIC +# if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) +# define PUBLIC __attribute__((visibility("default"))) +# define USED __attribute__((used)) +# else +# define PUBLIC +# define USED +# endif +#endif + + +/** + * Some compilers don't like some of Mesa's const usage. In those places use + * CONST instead of const. Pass -DNO_CONST to compilers where this matters. + */ +#ifdef NO_CONST +# define CONST +#else +# define CONST const +#endif + + +/** + * __builtin_expect macros + */ +#if !defined(__GNUC__) +# define __builtin_expect(x, y) (x) +#endif + +#ifndef likely +# ifdef __GNUC__ +# define likely(x) __builtin_expect(!!(x), 1) +# define unlikely(x) __builtin_expect(!!(x), 0) +# else +# define likely(x) (x) +# define unlikely(x) (x) +# endif +#endif + +/** + * The __FUNCTION__ gcc variable is generally only used for debugging. + * If we're not using gcc, define __FUNCTION__ as a cpp symbol here. + * Don't define it if using a newer Windows compiler. + */ +#ifndef __FUNCTION__ +# if defined(__VMS) +# define __FUNCTION__ "VMS$NL:" +# elif !defined(__GNUC__) && !defined(__xlC__) && \ + (!defined(_MSC_VER) || _MSC_VER < 1300) +# if (__STDC_VERSION__ >= 199901L) /* C99 */ || \ + (defined(__SUNPRO_C) && defined(__C99FEATURES__)) +# define __FUNCTION__ __func__ +# else +# define __FUNCTION__ "" +# endif +# endif +#endif +#ifndef __func__ +# if (__STDC_VERSION__ >= 199901L) || \ + (defined(__SUNPRO_C) && defined(__C99FEATURES__)) + /* __func__ is part of C99 */ +# elif defined(_MSC_VER) +# if _MSC_VER >= 1300 +# define __func__ __FUNCTION__ +# else +# define __func__ "" +# endif +# endif +#endif + + +/** + * Either define MESA_BIG_ENDIAN or MESA_LITTLE_ENDIAN, and CPU_TO_LE32. + * Do not use these unless absolutely necessary! + * Try to use a runtime test instead. + * For now, only used by some DRI hardware drivers for color/texel packing. + */ +#if defined(BYTE_ORDER) && defined(BIG_ENDIAN) && BYTE_ORDER == BIG_ENDIAN +#if defined(__linux__) +#include +#define CPU_TO_LE32( x ) bswap_32( x ) +#elif defined(__APPLE__) +#include +#define CPU_TO_LE32( x ) CFSwapInt32HostToLittle( x ) +#elif (defined(_AIX) || defined(__blrts)) +static INLINE GLuint CPU_TO_LE32(GLuint x) +{ + return (((x & 0x000000ff) << 24) | + ((x & 0x0000ff00) << 8) | + ((x & 0x00ff0000) >> 8) | + ((x & 0xff000000) >> 24)); +} +#else /*__linux__ */ +#include +#define CPU_TO_LE32( x ) bswap32( x ) +#endif /*__linux__*/ +#define MESA_BIG_ENDIAN 1 +#else +#define CPU_TO_LE32( x ) ( x ) +#define MESA_LITTLE_ENDIAN 1 +#endif +#define LE32_TO_CPU( x ) CPU_TO_LE32( x ) + + + +#if !defined(CAPI) && defined(WIN32) && !defined(BUILD_FOR_SNAP) +#define CAPI _cdecl +#endif + + +/** + * Create a macro so that asm functions can be linked into compilers other + * than GNU C + */ +#ifndef _ASMAPI +#if defined(WIN32) && !defined(BUILD_FOR_SNAP)/* was: !defined( __GNUC__ ) && !defined( VMS ) && !defined( __INTEL_COMPILER )*/ +#define _ASMAPI __cdecl +#else +#define _ASMAPI +#endif +#ifdef PTR_DECL_IN_FRONT +#define _ASMAPIP * _ASMAPI +#else +#define _ASMAPIP _ASMAPI * +#endif +#endif + +#ifdef USE_X86_ASM +#define _NORMAPI _ASMAPI +#define _NORMAPIP _ASMAPIP +#else +#define _NORMAPI +#define _NORMAPIP * +#endif + + +/* This is a macro on IRIX */ +#ifdef _P +#undef _P +#endif + + +/* Turn off macro checking systems used by other libraries */ +#ifdef CHECK +#undef CHECK +#endif + + +/** + * ASSERT macro + */ +#if !defined(_WIN32_WCE) +#if defined(BUILD_FOR_SNAP) && defined(CHECKED) +# define ASSERT(X) _CHECK(X) +#elif defined(DEBUG) +# define ASSERT(X) assert(X) +#else +# define ASSERT(X) +#endif +#endif + +#if (__GNUC__ >= 3) +#define PRINTFLIKE(f, a) __attribute__ ((format(__printf__, f, a))) +#else +#define PRINTFLIKE(f, a) +#endif + +#ifndef NULL +#define NULL 0 +#endif + + +/** + * LONGSTRING macro + * gcc -pedantic warns about long string literals, LONGSTRING silences that. + */ +#if !defined(__GNUC__) +# define LONGSTRING +#else +# define LONGSTRING __extension__ +#endif + + +#ifndef M_PI +#define M_PI (3.14159265358979323846) +#endif + +#ifndef M_E +#define M_E (2.7182818284590452354) +#endif + +#ifndef M_LOG2E +#define M_LOG2E (1.4426950408889634074) +#endif + +#ifndef ONE_DIV_SQRT_LN2 +#define ONE_DIV_SQRT_LN2 (1.201122408786449815) +#endif + +#ifndef FLT_MAX_EXP +#define FLT_MAX_EXP 128 +#endif + + +/** + * USE_IEEE: Determine if we're using IEEE floating point + */ +#if defined(__i386__) || defined(__386__) || defined(__sparc__) || \ + defined(__s390x__) || defined(__powerpc__) || \ + defined(__x86_64__) || \ + defined(ia64) || defined(__ia64__) || \ + defined(__hppa__) || defined(hpux) || \ + defined(__mips) || defined(_MIPS_ARCH) || \ + defined(__arm__) || \ + defined(__sh__) || defined(__m32r__) || \ + (defined(__sun) && defined(_IEEE_754)) || \ + (defined(__alpha__) && (defined(__IEEE_FLOAT) || !defined(VMS))) +#define USE_IEEE +#define IEEE_ONE 0x3f800000 +#endif + + +/** + * START/END_FAST_MATH macros: + * + * START_FAST_MATH: Set x86 FPU to faster, 32-bit precision mode (and save + * original mode to a temporary). + * END_FAST_MATH: Restore x86 FPU to original mode. + */ +#if defined(__GNUC__) && defined(__i386__) +/* + * Set the x86 FPU control word to guarentee only 32 bits of precision + * are stored in registers. Allowing the FPU to store more introduces + * differences between situations where numbers are pulled out of memory + * vs. situations where the compiler is able to optimize register usage. + * + * In the worst case, we force the compiler to use a memory access to + * truncate the float, by specifying the 'volatile' keyword. + */ +/* Hardware default: All exceptions masked, extended double precision, + * round to nearest (IEEE compliant): + */ +#define DEFAULT_X86_FPU 0x037f +/* All exceptions masked, single precision, round to nearest: + */ +#define FAST_X86_FPU 0x003f +/* The fldcw instruction will cause any pending FP exceptions to be + * raised prior to entering the block, and we clear any pending + * exceptions before exiting the block. Hence, asm code has free + * reign over the FPU while in the fast math block. + */ +#if defined(NO_FAST_MATH) +#define START_FAST_MATH(x) \ +do { \ + static GLuint mask = DEFAULT_X86_FPU; \ + __asm__ ( "fnstcw %0" : "=m" (*&(x)) ); \ + __asm__ ( "fldcw %0" : : "m" (mask) ); \ +} while (0) +#else +#define START_FAST_MATH(x) \ +do { \ + static GLuint mask = FAST_X86_FPU; \ + __asm__ ( "fnstcw %0" : "=m" (*&(x)) ); \ + __asm__ ( "fldcw %0" : : "m" (mask) ); \ +} while (0) +#endif +/* Restore original FPU mode, and clear any exceptions that may have + * occurred in the FAST_MATH block. + */ +#define END_FAST_MATH(x) \ +do { \ + __asm__ ( "fnclex ; fldcw %0" : : "m" (*&(x)) ); \ +} while (0) + +#elif defined(__WATCOMC__) && defined(__386__) +#define DEFAULT_X86_FPU 0x037f /* See GCC comments above */ +#define FAST_X86_FPU 0x003f /* See GCC comments above */ +void _watcom_start_fast_math(unsigned short *x,unsigned short *mask); +#pragma aux _watcom_start_fast_math = \ + "fnstcw word ptr [eax]" \ + "fldcw word ptr [ecx]" \ + parm [eax] [ecx] \ + modify exact []; +void _watcom_end_fast_math(unsigned short *x); +#pragma aux _watcom_end_fast_math = \ + "fnclex" \ + "fldcw word ptr [eax]" \ + parm [eax] \ + modify exact []; +#if defined(NO_FAST_MATH) +#define START_FAST_MATH(x) \ +do { \ + static GLushort mask = DEFAULT_X86_FPU; \ + _watcom_start_fast_math(&x,&mask); \ +} while (0) +#else +#define START_FAST_MATH(x) \ +do { \ + static GLushort mask = FAST_X86_FPU; \ + _watcom_start_fast_math(&x,&mask); \ +} while (0) +#endif +#define END_FAST_MATH(x) _watcom_end_fast_math(&x) + +#elif defined(_MSC_VER) && defined(_M_IX86) +#define DEFAULT_X86_FPU 0x037f /* See GCC comments above */ +#define FAST_X86_FPU 0x003f /* See GCC comments above */ +#if defined(NO_FAST_MATH) +#define START_FAST_MATH(x) do {\ + static GLuint mask = DEFAULT_X86_FPU;\ + __asm fnstcw word ptr [x]\ + __asm fldcw word ptr [mask]\ +} while(0) +#else +#define START_FAST_MATH(x) do {\ + static GLuint mask = FAST_X86_FPU;\ + __asm fnstcw word ptr [x]\ + __asm fldcw word ptr [mask]\ +} while(0) +#endif +#define END_FAST_MATH(x) do {\ + __asm fnclex\ + __asm fldcw word ptr [x]\ +} while(0) + +#else +#define START_FAST_MATH(x) x = 0 +#define END_FAST_MATH(x) (void)(x) +#endif + + +#ifndef Elements +#define Elements(x) (sizeof(x)/sizeof(*(x))) +#endif + + + +#ifdef __cplusplus +} +#endif + + +#endif /* COMPILER_H */ diff --git a/3rdparty/glsl-optimizer/src/mesa/main/config.h b/3rdparty/glsl-optimizer/src/mesa/main/config.h new file mode 100644 index 000000000..fffb1a7d2 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/mesa/main/config.h @@ -0,0 +1,358 @@ +/* + * Mesa 3-D graphics library + * Version: 7.5 + * + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. + * Copyright (C) 2008 VMware, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/** + * \file config.h + * Tunable configuration parameters. + */ + +#ifndef MESA_CONFIG_H_INCLUDED +#define MESA_CONFIG_H_INCLUDED + + +/** + * \name OpenGL implementation limits + */ +/*@{*/ + +/** Maximum modelview matrix stack depth */ +#define MAX_MODELVIEW_STACK_DEPTH 32 + +/** Maximum projection matrix stack depth */ +#define MAX_PROJECTION_STACK_DEPTH 32 + +/** Maximum texture matrix stack depth */ +#define MAX_TEXTURE_STACK_DEPTH 10 + +/** Maximum color matrix stack depth */ +#define MAX_COLOR_STACK_DEPTH 4 + +/** Maximum attribute stack depth */ +#define MAX_ATTRIB_STACK_DEPTH 16 + +/** Maximum client attribute stack depth */ +#define MAX_CLIENT_ATTRIB_STACK_DEPTH 16 + +/** Maximum recursion depth of display list calls */ +#define MAX_LIST_NESTING 64 + +/** Maximum number of lights */ +#define MAX_LIGHTS 8 + +/** Maximum user-defined clipping planes */ +#define MAX_CLIP_PLANES 6 + +/** Maximum pixel map lookup table size */ +#define MAX_PIXEL_MAP_TABLE 256 + +/** Maximum number of auxillary color buffers */ +#define MAX_AUX_BUFFERS 1 + +/** Maximum order (degree) of curves */ +#ifdef AMIGA +# define MAX_EVAL_ORDER 12 +#else +# define MAX_EVAL_ORDER 30 +#endif + +/** Maximum Name stack depth */ +#define MAX_NAME_STACK_DEPTH 64 + +/** Minimum point size */ +#define MIN_POINT_SIZE 1.0 +/** Maximum point size */ +#define MAX_POINT_SIZE 60.0 +/** Point size granularity */ +#define POINT_SIZE_GRANULARITY 0.1 + +/** Minimum line width */ +#define MIN_LINE_WIDTH 1.0 +/** Maximum line width */ +#define MAX_LINE_WIDTH 10.0 +/** Line width granularity */ +#define LINE_WIDTH_GRANULARITY 0.1 + +/** Max texture palette / color table size */ +#define MAX_COLOR_TABLE_SIZE 256 + +/** Max memory to allow for a single texture image (in megabytes) */ +#define MAX_TEXTURE_MBYTES 1024 + +/** Number of 1D/2D texture mipmap levels */ +#define MAX_TEXTURE_LEVELS 15 + +/** Number of 3D texture mipmap levels */ +#define MAX_3D_TEXTURE_LEVELS 15 + +/** Number of cube texture mipmap levels - GL_ARB_texture_cube_map */ +#define MAX_CUBE_TEXTURE_LEVELS 15 + +/** Maximum rectangular texture size - GL_NV_texture_rectangle */ +#define MAX_TEXTURE_RECT_SIZE 16384 + +/** Maximum number of layers in a 1D or 2D array texture - GL_MESA_texture_array */ +#define MAX_ARRAY_TEXTURE_LAYERS 64 + +/** + * Max number of texture coordinate units. This mainly just applies to + * the fixed-function vertex code. This will be difficult to raise above + * eight because of various vertex attribute bitvectors. + */ +#define MAX_TEXTURE_COORD_UNITS 8 + +/** + * Max number of texture image units. Also determines number of texture + * samplers in shaders. + */ +#define MAX_TEXTURE_IMAGE_UNITS 16 + +/** + * Larger of MAX_TEXTURE_COORD_UNITS and MAX_TEXTURE_IMAGE_UNITS. + * This value is only used for dimensioning arrays. + * Either MAX_TEXTURE_COORD_UNITS or MAX_TEXTURE_IMAGE_UNITS (or the + * corresponding ctx->Const.MaxTextureCoord/ImageUnits fields) should be + * used almost everywhere else. + */ +#define MAX_TEXTURE_UNITS ((MAX_TEXTURE_COORD_UNITS > MAX_TEXTURE_IMAGE_UNITS) ? MAX_TEXTURE_COORD_UNITS : MAX_TEXTURE_IMAGE_UNITS) + + +/** + * Maximum viewport/image width. Must accomodate all texture sizes too. + */ + +#ifndef MAX_WIDTH +# define MAX_WIDTH 16384 +#endif +/** Maximum viewport/image height */ +#ifndef MAX_HEIGHT +# define MAX_HEIGHT 16384 +#endif + +/* XXX: hack to prevent stack overflow on windows until all temporary arrays + * [MAX_WIDTH] are allocated from the heap */ +#ifdef WIN32 +#undef MAX_TEXTURE_LEVELS +#undef MAX_3D_TEXTURE_LEVELS +#undef MAX_CUBE_TEXTURE_LEVELS +#undef MAX_TEXTURE_RECT_SIZE +#undef MAX_WIDTH +#undef MAX_HEIGHT +#define MAX_TEXTURE_LEVELS 13 +#define MAX_3D_TEXTURE_LEVELS 9 +#define MAX_CUBE_TEXTURE_LEVELS 13 +#define MAX_TEXTURE_RECT_SIZE 4096 +#define MAX_WIDTH 4096 +#define MAX_HEIGHT 4096 +#endif + +/** Maxmimum size for CVA. May be overridden by the drivers. */ +#define MAX_ARRAY_LOCK_SIZE 3000 + +/** Subpixel precision for antialiasing, window coordinate snapping */ +#define SUB_PIXEL_BITS 4 + +/** Size of histogram tables */ +#define HISTOGRAM_TABLE_SIZE 256 + +/** Max convolution filter width */ +#define MAX_CONVOLUTION_WIDTH 9 +/** Max convolution filter height */ +#define MAX_CONVOLUTION_HEIGHT 9 + +/** For GL_ARB_texture_compression */ +#define MAX_COMPRESSED_TEXTURE_FORMATS 25 + +/** For GL_EXT_texture_filter_anisotropic */ +#define MAX_TEXTURE_MAX_ANISOTROPY 16.0 + +/** For GL_EXT_texture_lod_bias (typically MAX_TEXTURE_LEVELS - 1) */ +#define MAX_TEXTURE_LOD_BIAS 14.0 + +/** For any program target/extension */ +/*@{*/ +#define MAX_PROGRAM_INSTRUCTIONS (16 * 1024) + +/** + * Per-program constants (power of two) + * + * \c MAX_PROGRAM_LOCAL_PARAMS and \c MAX_UNIFORMS are just the assembly shader + * and GLSL shader names for the same thing. They should \b always have the + * same value. Each refers to the number of vec4 values supplied as + * per-program parameters. + */ +/*@{*/ +#define MAX_PROGRAM_LOCAL_PARAMS 1024 +#define MAX_UNIFORMS 1024 +/*@}*/ + +/** + * Per-context constants (power of two) + * + * \note + * This value should always be less than or equal to \c MAX_PROGRAM_LOCAL_PARAMS + * and \c MAX_VERTEX_PROGRAM_PARAMS. Otherwise some applications will make + * incorrect assumptions. + */ +#define MAX_PROGRAM_ENV_PARAMS 256 + +#define MAX_PROGRAM_MATRICES 8 +#define MAX_PROGRAM_MATRIX_STACK_DEPTH 4 +#define MAX_PROGRAM_CALL_DEPTH 8 +#define MAX_PROGRAM_TEMPS 256 +#define MAX_PROGRAM_ADDRESS_REGS 2 +#define MAX_VARYING 16 /**< number of float[4] vectors */ +#define MAX_SAMPLERS MAX_TEXTURE_IMAGE_UNITS +#define MAX_PROGRAM_INPUTS 32 +#define MAX_PROGRAM_OUTPUTS 64 +/*@}*/ + +/** For GL_ARB_vertex_program */ +/*@{*/ +#define MAX_VERTEX_PROGRAM_ADDRESS_REGS 1 +#define MAX_VERTEX_PROGRAM_PARAMS MAX_UNIFORMS +/*@}*/ + +/** For GL_ARB_fragment_program */ +/*@{*/ +#define MAX_FRAGMENT_PROGRAM_ADDRESS_REGS 0 +/*@}*/ + +/** For GL_NV_vertex_program */ +/*@{*/ +#define MAX_NV_VERTEX_PROGRAM_INSTRUCTIONS 128 +#define MAX_NV_VERTEX_PROGRAM_TEMPS 12 +#define MAX_NV_VERTEX_PROGRAM_PARAMS 96 +#define MAX_NV_VERTEX_PROGRAM_INPUTS 16 +#define MAX_NV_VERTEX_PROGRAM_OUTPUTS 15 +/*@}*/ + +/** For GL_NV_fragment_program */ +/*@{*/ +#define MAX_NV_FRAGMENT_PROGRAM_INSTRUCTIONS 1024 /* 72 for GL_ARB_f_p */ +#define MAX_NV_FRAGMENT_PROGRAM_TEMPS 96 +#define MAX_NV_FRAGMENT_PROGRAM_PARAMS 64 +#define MAX_NV_FRAGMENT_PROGRAM_INPUTS 12 +#define MAX_NV_FRAGMENT_PROGRAM_OUTPUTS 3 +#define MAX_NV_FRAGMENT_PROGRAM_WRITE_ONLYS 2 +/*@}*/ + + +/** For GL_ARB_vertex_shader */ +/*@{*/ +#define MAX_VERTEX_GENERIC_ATTRIBS 16 +#define MAX_VERTEX_TEXTURE_IMAGE_UNITS MAX_TEXTURE_IMAGE_UNITS +#define MAX_COMBINED_TEXTURE_IMAGE_UNITS (MAX_VERTEX_TEXTURE_IMAGE_UNITS + \ + MAX_TEXTURE_IMAGE_UNITS) +/*@}*/ + + +/** For GL_ARB_draw_buffers */ +/*@{*/ +#define MAX_DRAW_BUFFERS 8 +/*@}*/ + + +/** For GL_EXT_framebuffer_object */ +/*@{*/ +#define MAX_COLOR_ATTACHMENTS 8 +/*@}*/ + +/** For GL_ATI_envmap_bump - support bump mapping on first 8 units */ +#define SUPPORTED_ATI_BUMP_UNITS 0xff + +/** For GL_EXT_transform_feedback */ +#define MAX_FEEDBACK_ATTRIBS 32 + +/** For GL_ARB_geometry_shader4 */ +/*@{*/ +#define MAX_GEOMETRY_TEXTURE_IMAGE_UNITS 8 +#define MAX_GEOMETRY_VARYING_COMPONENTS 32 +#define MAX_VERTEX_VARYING_COMPONENTS 32 +#define MAX_GEOMETRY_UNIFORM_COMPONENTS 512 +#define MAX_GEOMETRY_OUTPUT_VERTICES 256 +#define MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS 1024 +/*@}*/ + + +/** + * \name Mesa-specific parameters + */ +/*@{*/ + + +/** + * If non-zero use GLdouble for walking triangle edges, for better accuracy. + */ +#define TRIANGLE_WALK_DOUBLE 0 + + +/** + * Bits per depth buffer value (max is 32). + */ +#ifndef DEFAULT_SOFTWARE_DEPTH_BITS +#define DEFAULT_SOFTWARE_DEPTH_BITS 16 +#endif +/** Depth buffer data type */ +#if DEFAULT_SOFTWARE_DEPTH_BITS <= 16 +#define DEFAULT_SOFTWARE_DEPTH_TYPE GLushort +#else +#define DEFAULT_SOFTWARE_DEPTH_TYPE GLuint +#endif + + +/** + * Bits per stencil value: 8 + */ +#define STENCIL_BITS 8 + + +/** + * Bits per color channel: 8, 16 or 32 + */ +#ifndef CHAN_BITS +#define CHAN_BITS 8 +#endif + + +/* + * Color channel component order + * + * \note Changes will almost certainly cause problems at this time. + */ +#define RCOMP 0 +#define GCOMP 1 +#define BCOMP 2 +#define ACOMP 3 + + +/** + * Maximum number of temporary vertices required for clipping. + * + * Used in array_cache and tnl modules. + */ +#define MAX_CLIPPED_VERTICES ((2 * (6 + MAX_CLIP_PLANES))+1) + + +#endif /* MESA_CONFIG_H_INCLUDED */ diff --git a/3rdparty/glsl-optimizer/src/mesa/main/context.h b/3rdparty/glsl-optimizer/src/mesa/main/context.h new file mode 100644 index 000000000..a4c7ba2c5 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/mesa/main/context.h @@ -0,0 +1,289 @@ +/* + * Mesa 3-D graphics library + * Version: 6.5.1 + * + * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +/** + * \file context.h + * Mesa context and visual-related functions. + * + * There are three large Mesa data types/classes which are meant to be + * used by device drivers: + * - struct gl_context: this contains the Mesa rendering state + * - struct gl_config: this describes the color buffer (RGB vs. ci), whether + * or not there's a depth buffer, stencil buffer, etc. + * - struct gl_framebuffer: contains pointers to the depth buffer, stencil + * buffer, accum buffer and alpha buffers. + * + * These types should be encapsulated by corresponding device driver + * data types. See xmesa.h and xmesaP.h for an example. + * + * In OOP terms, struct gl_context, struct gl_config, and struct gl_framebuffer + * are base classes which the device driver must derive from. + * + * The following functions create and destroy these data types. + */ + + +#ifndef CONTEXT_H +#define CONTEXT_H + + +#include "imports.h" +#include "mtypes.h" + + +struct _glapi_table; + + +/** \name Visual-related functions */ +/*@{*/ + +extern struct gl_config * +_mesa_create_visual( GLboolean dbFlag, + GLboolean stereoFlag, + GLint redBits, + GLint greenBits, + GLint blueBits, + GLint alphaBits, + GLint depthBits, + GLint stencilBits, + GLint accumRedBits, + GLint accumGreenBits, + GLint accumBlueBits, + GLint accumAlphaBits, + GLint numSamples ); + +extern GLboolean +_mesa_initialize_visual( struct gl_config *v, + GLboolean dbFlag, + GLboolean stereoFlag, + GLint redBits, + GLint greenBits, + GLint blueBits, + GLint alphaBits, + GLint depthBits, + GLint stencilBits, + GLint accumRedBits, + GLint accumGreenBits, + GLint accumBlueBits, + GLint accumAlphaBits, + GLint numSamples ); + +extern void +_mesa_destroy_visual( struct gl_config *vis ); + +/*@}*/ + + +/** \name Context-related functions */ +/*@{*/ + +extern GLboolean +_mesa_initialize_context( struct gl_context *ctx, + gl_api api, + const struct gl_config *visual, + struct gl_context *share_list, + const struct dd_function_table *driverFunctions, + void *driverContext ); + +extern struct gl_context * +_mesa_create_context(gl_api api, + const struct gl_config *visual, + struct gl_context *share_list, + const struct dd_function_table *driverFunctions, + void *driverContext); + +extern void +_mesa_free_context_data( struct gl_context *ctx ); + +extern void +_mesa_destroy_context( struct gl_context *ctx ); + + +extern void +_mesa_copy_context(const struct gl_context *src, struct gl_context *dst, GLuint mask); + + +extern void +_mesa_check_init_viewport(struct gl_context *ctx, GLuint width, GLuint height); + +extern GLboolean +_mesa_make_current( struct gl_context *ctx, struct gl_framebuffer *drawBuffer, + struct gl_framebuffer *readBuffer ); + +extern GLboolean +_mesa_share_state(struct gl_context *ctx, struct gl_context *ctxToShare); + +extern struct gl_context * +_mesa_get_current_context(void); + +/*@}*/ + +extern void +_mesa_init_get_hash(struct gl_context *ctx); + +extern void +_mesa_notifySwapBuffers(struct gl_context *gc); + + +extern struct _glapi_table * +_mesa_get_dispatch(struct gl_context *ctx); + + +void +_mesa_set_mvp_with_dp4( struct gl_context *ctx, + GLboolean flag ); + + +extern GLboolean +_mesa_valid_to_render(struct gl_context *ctx, const char *where); + + + +/** \name Miscellaneous */ +/*@{*/ + +extern void +_mesa_record_error( struct gl_context *ctx, GLenum error ); + + +extern void +_mesa_finish(struct gl_context *ctx); + +extern void +_mesa_flush(struct gl_context *ctx); + + +extern void GLAPIENTRY +_mesa_Finish( void ); + +extern void GLAPIENTRY +_mesa_Flush( void ); + +/*@}*/ + + +/** + * \name Macros for flushing buffered rendering commands before state changes, + * checking if inside glBegin/glEnd, etc. + */ +/*@{*/ + +/** + * Flush vertices. + * + * \param ctx GL context. + * \param newstate new state. + * + * Checks if dd_function_table::NeedFlush is marked to flush stored vertices, + * and calls dd_function_table::FlushVertices if so. Marks + * __struct gl_contextRec::NewState with \p newstate. + */ +#define FLUSH_VERTICES(ctx, newstate) \ +do { \ + if (MESA_VERBOSE & VERBOSE_STATE) \ + _mesa_debug(ctx, "FLUSH_VERTICES in %s\n", MESA_FUNCTION);\ + if (ctx->Driver.NeedFlush & FLUSH_STORED_VERTICES) \ + ctx->Driver.FlushVertices(ctx, FLUSH_STORED_VERTICES); \ + ctx->NewState |= newstate; \ +} while (0) + +/** + * Flush current state. + * + * \param ctx GL context. + * \param newstate new state. + * + * Checks if dd_function_table::NeedFlush is marked to flush current state, + * and calls dd_function_table::FlushVertices if so. Marks + * __struct gl_contextRec::NewState with \p newstate. + */ +#define FLUSH_CURRENT(ctx, newstate) \ +do { \ + if (MESA_VERBOSE & VERBOSE_STATE) \ + _mesa_debug(ctx, "FLUSH_CURRENT in %s\n", MESA_FUNCTION); \ + if (ctx->Driver.NeedFlush & FLUSH_UPDATE_CURRENT) \ + ctx->Driver.FlushVertices(ctx, FLUSH_UPDATE_CURRENT); \ + ctx->NewState |= newstate; \ +} while (0) + +/** + * Macro to assert that the API call was made outside the + * glBegin()/glEnd() pair, with return value. + * + * \param ctx GL context. + * \param retval value to return value in case the assertion fails. + */ +#define ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, retval) \ +do { \ + if (ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END) { \ + _mesa_error(ctx, GL_INVALID_OPERATION, "Inside glBegin/glEnd"); \ + return retval; \ + } \ +} while (0) + +/** + * Macro to assert that the API call was made outside the + * glBegin()/glEnd() pair. + * + * \param ctx GL context. + */ +#define ASSERT_OUTSIDE_BEGIN_END(ctx) \ +do { \ + if (ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END) { \ + _mesa_error(ctx, GL_INVALID_OPERATION, "Inside glBegin/glEnd"); \ + return; \ + } \ +} while (0) + +/** + * Macro to assert that the API call was made outside the + * glBegin()/glEnd() pair and flush the vertices. + * + * \param ctx GL context. + */ +#define ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx) \ +do { \ + ASSERT_OUTSIDE_BEGIN_END(ctx); \ + FLUSH_VERTICES(ctx, 0); \ +} while (0) + +/** + * Macro to assert that the API call was made outside the + * glBegin()/glEnd() pair and flush the vertices, with return value. + * + * \param ctx GL context. + * \param retval value to return value in case the assertion fails. + */ +#define ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx, retval) \ +do { \ + ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, retval); \ + FLUSH_VERTICES(ctx, 0); \ +} while (0) + +/*@}*/ + + + +#endif /* CONTEXT_H */ diff --git a/3rdparty/glsl-optimizer/src/mesa/main/core.h b/3rdparty/glsl-optimizer/src/mesa/main/core.h new file mode 100644 index 000000000..542d95b84 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/mesa/main/core.h @@ -0,0 +1,64 @@ +/* + * Mesa 3-D graphics library + * Version: 7.9 + * + * Copyright (C) 2010 LunarG Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Authors: + * Chia-I Wu + */ + + +/** + * \file core.h + * The public header of core mesa. + * + * This file is the (only) public header of core mesa. It is supposed to be + * used by GLX, WGL, and GLSL. It is important that headers directly or + * indirectly included here do not perform feature tests (#if FEATURE_xxx). + */ + + +#ifndef CORE_H +#define CORE_H + + +#include "main/glheader.h" +#include "main/compiler.h" +#include "main/imports.h" +#include "main/macros.h" + +#include "main/mtypes.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* for GLSL */ +#include "program/prog_parameter.h" +#include "program/prog_uniform.h" + +#ifdef __cplusplus +} +#endif + + +#endif /* CORE_H */ diff --git a/3rdparty/glsl-optimizer/src/mesa/main/dd.h b/3rdparty/glsl-optimizer/src/mesa/main/dd.h new file mode 100644 index 000000000..b5ed9a40c --- /dev/null +++ b/3rdparty/glsl-optimizer/src/mesa/main/dd.h @@ -0,0 +1,1160 @@ +/** + * \file dd.h + * Device driver interfaces. + */ + +/* + * Mesa 3-D graphics library + * Version: 6.5.2 + * + * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#ifndef DD_INCLUDED +#define DD_INCLUDED + +/* THIS FILE ONLY INCLUDED BY mtypes.h !!!!! */ + +#include "glheader.h" + +struct gl_buffer_object; +struct gl_context; +struct gl_display_list; +struct gl_framebuffer; +struct gl_pixelstore_attrib; +struct gl_program; +struct gl_renderbuffer; +struct gl_renderbuffer_attachment; +struct gl_shader; +struct gl_shader_program; +struct gl_texture_image; +struct gl_texture_object; + +/* GL_ARB_vertex_buffer_object */ +/* Modifies GL_MAP_UNSYNCHRONIZED_BIT to allow driver to fail (return + * NULL) if buffer is unavailable for immediate mapping. + * + * Does GL_MAP_INVALIDATE_RANGE_BIT do this? It seems so, but it + * would require more book-keeping in the driver than seems necessary + * at this point. + * + * Does GL_MAP_INVALDIATE_BUFFER_BIT do this? Not really -- we don't + * want to provoke the driver to throw away the old storage, we will + * respect the contents of already referenced data. + */ +#define MESA_MAP_NOWAIT_BIT 0x0040 + + +/** + * Device driver function table. + * Core Mesa uses these function pointers to call into device drivers. + * Most of these functions directly correspond to OpenGL state commands. + * Core Mesa will call these functions after error checking has been done + * so that the drivers don't have to worry about error testing. + * + * Vertex transformation/clipping/lighting is patched into the T&L module. + * Rasterization functions are patched into the swrast module. + * + * Note: when new functions are added here, the drivers/common/driverfuncs.c + * file should be updated too!!! + */ +struct dd_function_table { + /** + * Return a string as needed by glGetString(). + * Only the GL_RENDERER query must be implemented. Otherwise, NULL can be + * returned. + */ + const GLubyte * (*GetString)( struct gl_context *ctx, GLenum name ); + + /** + * Notify the driver after Mesa has made some internal state changes. + * + * This is in addition to any state change callbacks Mesa may already have + * made. + */ + void (*UpdateState)( struct gl_context *ctx, GLbitfield new_state ); + + /** + * Get the width and height of the named buffer/window. + * + * Mesa uses this to determine when the driver's window size has changed. + * XXX OBSOLETE: this function will be removed in the future. + */ + void (*GetBufferSize)( struct gl_framebuffer *buffer, + GLuint *width, GLuint *height ); + + /** + * Resize the given framebuffer to the given size. + * XXX OBSOLETE: this function will be removed in the future. + */ + void (*ResizeBuffers)( struct gl_context *ctx, struct gl_framebuffer *fb, + GLuint width, GLuint height); + + /** + * Called whenever an error is generated. + * __struct gl_contextRec::ErrorValue contains the error value. + */ + void (*Error)( struct gl_context *ctx ); + + /** + * This is called whenever glFinish() is called. + */ + void (*Finish)( struct gl_context *ctx ); + + /** + * This is called whenever glFlush() is called. + */ + void (*Flush)( struct gl_context *ctx ); + + /** + * Clear the color/depth/stencil/accum buffer(s). + * \param buffers a bitmask of BUFFER_BIT_* flags indicating which + * renderbuffers need to be cleared. + */ + void (*Clear)( struct gl_context *ctx, GLbitfield buffers ); + + /** + * Execute glAccum command. + */ + void (*Accum)( struct gl_context *ctx, GLenum op, GLfloat value ); + + + /** + * Execute glRasterPos, updating the ctx->Current.Raster fields + */ + void (*RasterPos)( struct gl_context *ctx, const GLfloat v[4] ); + + /** + * \name Image-related functions + */ + /*@{*/ + + /** + * Called by glDrawPixels(). + * \p unpack describes how to unpack the source image data. + */ + void (*DrawPixels)( struct gl_context *ctx, + GLint x, GLint y, GLsizei width, GLsizei height, + GLenum format, GLenum type, + const struct gl_pixelstore_attrib *unpack, + const GLvoid *pixels ); + + /** + * Called by glReadPixels(). + */ + void (*ReadPixels)( struct gl_context *ctx, + GLint x, GLint y, GLsizei width, GLsizei height, + GLenum format, GLenum type, + const struct gl_pixelstore_attrib *unpack, + GLvoid *dest ); + + /** + * Called by glCopyPixels(). + */ + void (*CopyPixels)( struct gl_context *ctx, GLint srcx, GLint srcy, + GLsizei width, GLsizei height, + GLint dstx, GLint dsty, GLenum type ); + + /** + * Called by glBitmap(). + */ + void (*Bitmap)( struct gl_context *ctx, + GLint x, GLint y, GLsizei width, GLsizei height, + const struct gl_pixelstore_attrib *unpack, + const GLubyte *bitmap ); + /*@}*/ + + + /** + * \name Texture image functions + */ + /*@{*/ + + /** + * Choose actual hardware texture format given the user-provided source + * image format and type and the desired internal format. In some + * cases, srcFormat and srcType can be GL_NONE. + * Called by glTexImage(), etc. + */ + gl_format (*ChooseTextureFormat)( struct gl_context *ctx, GLint internalFormat, + GLenum srcFormat, GLenum srcType ); + + /** + * Called by glTexImage1D(). Simply copy the source texture data into the + * destination texture memory. The gl_texture_image fields, etc. will be + * fully initialized. + * The parameters are the same as glTexImage1D(), plus: + * \param packing describes how to unpack the source data. + * \param texObj is the target texture object. + * \param texImage is the target texture image. + */ + void (*TexImage1D)( struct gl_context *ctx, GLenum target, GLint level, + GLint internalFormat, + GLint width, GLint border, + GLenum format, GLenum type, const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage ); + + /** + * Called by glTexImage2D(). + * + * \sa dd_function_table::TexImage1D. + */ + void (*TexImage2D)( struct gl_context *ctx, GLenum target, GLint level, + GLint internalFormat, + GLint width, GLint height, GLint border, + GLenum format, GLenum type, const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage ); + + /** + * Called by glTexImage3D(). + * + * \sa dd_function_table::TexImage1D. + */ + void (*TexImage3D)( struct gl_context *ctx, GLenum target, GLint level, + GLint internalFormat, + GLint width, GLint height, GLint depth, GLint border, + GLenum format, GLenum type, const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage ); + + /** + * Called by glTexSubImage1D(). Replace a subset of the target texture + * with new texel data. + * \sa dd_function_table::TexImage1D. + */ + void (*TexSubImage1D)( struct gl_context *ctx, GLenum target, GLint level, + GLint xoffset, GLsizei width, + GLenum format, GLenum type, + const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage ); + + /** + * Called by glTexSubImage2D(). + * + * \sa dd_function_table::TexSubImage1D. + */ + void (*TexSubImage2D)( struct gl_context *ctx, GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, + GLenum format, GLenum type, + const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage ); + + /** + * Called by glTexSubImage3D(). + * + * \sa dd_function_table::TexSubImage1D. + */ + void (*TexSubImage3D)( struct gl_context *ctx, GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLsizei width, GLsizei height, GLint depth, + GLenum format, GLenum type, + const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage ); + + /** + * Called by glGetTexImage(). + */ + void (*GetTexImage)( struct gl_context *ctx, GLenum target, GLint level, + GLenum format, GLenum type, GLvoid *pixels, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage ); + + /** + * Called by glCopyTexSubImage1D(). + * + * Drivers should use a fallback routine from texstore.c if needed. + */ + void (*CopyTexSubImage1D)( struct gl_context *ctx, GLenum target, GLint level, + GLint xoffset, + GLint x, GLint y, GLsizei width ); + /** + * Called by glCopyTexSubImage2D(). + * + * Drivers should use a fallback routine from texstore.c if needed. + */ + void (*CopyTexSubImage2D)( struct gl_context *ctx, GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLint x, GLint y, + GLsizei width, GLsizei height ); + /** + * Called by glCopyTexSubImage3D(). + * + * Drivers should use a fallback routine from texstore.c if needed. + */ + void (*CopyTexSubImage3D)( struct gl_context *ctx, GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLint x, GLint y, + GLsizei width, GLsizei height ); + + /** + * Called by glGenerateMipmap() or when GL_GENERATE_MIPMAP_SGIS is enabled. + */ + void (*GenerateMipmap)(struct gl_context *ctx, GLenum target, + struct gl_texture_object *texObj); + + /** + * Called by glTexImage[123]D when user specifies a proxy texture + * target. + * + * \return GL_TRUE if the proxy test passes, or GL_FALSE if the test fails. + */ + GLboolean (*TestProxyTexImage)(struct gl_context *ctx, GLenum target, + GLint level, GLint internalFormat, + GLenum format, GLenum type, + GLint width, GLint height, + GLint depth, GLint border); + /*@}*/ + + + /** + * \name Compressed texture functions + */ + /*@{*/ + + /** + * Called by glCompressedTexImage1D(). + * + * \param target user specified. + * \param format user specified. + * \param type user specified. + * \param pixels user specified. + * \param packing indicates the image packing of pixels. + * \param texObj is the target texture object. + * \param texImage is the target texture image. It will have the texture \p + * width, \p height, \p depth, \p border and \p internalFormat information. + * + * \a retainInternalCopy is returned by this function and indicates whether + * core Mesa should keep an internal copy of the texture image. + */ + void (*CompressedTexImage1D)( struct gl_context *ctx, GLenum target, + GLint level, GLint internalFormat, + GLsizei width, GLint border, + GLsizei imageSize, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage ); + /** + * Called by glCompressedTexImage2D(). + * + * \sa dd_function_table::CompressedTexImage1D. + */ + void (*CompressedTexImage2D)( struct gl_context *ctx, GLenum target, + GLint level, GLint internalFormat, + GLsizei width, GLsizei height, GLint border, + GLsizei imageSize, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage ); + /** + * Called by glCompressedTexImage3D(). + * + * \sa dd_function_table::CompressedTexImage3D. + */ + void (*CompressedTexImage3D)( struct gl_context *ctx, GLenum target, + GLint level, GLint internalFormat, + GLsizei width, GLsizei height, GLsizei depth, + GLint border, + GLsizei imageSize, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage ); + + /** + * Called by glCompressedTexSubImage1D(). + * + * \param target user specified. + * \param level user specified. + * \param xoffset user specified. + * \param yoffset user specified. + * \param zoffset user specified. + * \param width user specified. + * \param height user specified. + * \param depth user specified. + * \param imageSize user specified. + * \param data user specified. + * \param texObj is the target texture object. + * \param texImage is the target texture image. It will have the texture \p + * width, \p height, \p depth, \p border and \p internalFormat information. + */ + void (*CompressedTexSubImage1D)(struct gl_context *ctx, GLenum target, GLint level, + GLint xoffset, GLsizei width, + GLenum format, + GLsizei imageSize, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage); + /** + * Called by glCompressedTexSubImage2D(). + * + * \sa dd_function_table::CompressedTexImage3D. + */ + void (*CompressedTexSubImage2D)(struct gl_context *ctx, GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLsizei width, GLint height, + GLenum format, + GLsizei imageSize, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage); + /** + * Called by glCompressedTexSubImage3D(). + * + * \sa dd_function_table::CompressedTexImage3D. + */ + void (*CompressedTexSubImage3D)(struct gl_context *ctx, GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLsizei width, GLint height, GLint depth, + GLenum format, + GLsizei imageSize, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage); + + + /** + * Called by glGetCompressedTexImage. + */ + void (*GetCompressedTexImage)(struct gl_context *ctx, GLenum target, GLint level, + GLvoid *img, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage); + + /*@}*/ + + /** + * \name Texture object functions + */ + /*@{*/ + + /** + * Called by glBindTexture(). + */ + void (*BindTexture)( struct gl_context *ctx, GLenum target, + struct gl_texture_object *tObj ); + + /** + * Called to allocate a new texture object. + * A new gl_texture_object should be returned. The driver should + * attach to it any device-specific info it needs. + */ + struct gl_texture_object * (*NewTextureObject)( struct gl_context *ctx, GLuint name, + GLenum target ); + /** + * Called when a texture object is about to be deallocated. + * + * Driver should delete the gl_texture_object object and anything + * hanging off of it. + */ + void (*DeleteTexture)( struct gl_context *ctx, struct gl_texture_object *tObj ); + + /** + * Called to allocate a new texture image object. + */ + struct gl_texture_image * (*NewTextureImage)( struct gl_context *ctx ); + + /** + * Called to free tImage->Data. + */ + void (*FreeTexImageData)( struct gl_context *ctx, struct gl_texture_image *tImage ); + + /** Map texture image data into user space */ + void (*MapTexture)( struct gl_context *ctx, struct gl_texture_object *tObj ); + /** Unmap texture images from user space */ + void (*UnmapTexture)( struct gl_context *ctx, struct gl_texture_object *tObj ); + + /** + * Note: no context argument. This function doesn't initially look + * like it belongs here, except that the driver is the only entity + * that knows for sure how the texture memory is allocated - via + * the above callbacks. There is then an argument that the driver + * knows what memcpy paths might be fast. Typically this is invoked with + * + * to -- a pointer into texture memory allocated by NewTextureImage() above. + * from -- a pointer into client memory or a mesa temporary. + * sz -- nr bytes to copy. + */ + void* (*TextureMemCpy)( void *to, const void *from, size_t sz ); + + /** + * Called by glAreTextureResident(). + */ + GLboolean (*IsTextureResident)( struct gl_context *ctx, + struct gl_texture_object *t ); + + /** + * Called when the texture's color lookup table is changed. + * + * If \p tObj is NULL then the shared texture palette + * gl_texture_object::Palette is to be updated. + */ + void (*UpdateTexturePalette)( struct gl_context *ctx, + struct gl_texture_object *tObj ); + /*@}*/ + + + /** + * \name Imaging functionality + */ + /*@{*/ + void (*CopyColorTable)( struct gl_context *ctx, + GLenum target, GLenum internalformat, + GLint x, GLint y, GLsizei width ); + + void (*CopyColorSubTable)( struct gl_context *ctx, + GLenum target, GLsizei start, + GLint x, GLint y, GLsizei width ); + /*@}*/ + + + /** + * \name Vertex/fragment program functions + */ + /*@{*/ + /** Bind a vertex/fragment program */ + void (*BindProgram)(struct gl_context *ctx, GLenum target, struct gl_program *prog); + /** Allocate a new program */ + struct gl_program * (*NewProgram)(struct gl_context *ctx, GLenum target, GLuint id); + /** Delete a program */ + void (*DeleteProgram)(struct gl_context *ctx, struct gl_program *prog); + /** + * Notify driver that a program string (and GPU code) has been specified + * or modified. Return GL_TRUE or GL_FALSE to indicate if the program is + * supported by the driver. + */ + GLboolean (*ProgramStringNotify)(struct gl_context *ctx, GLenum target, + struct gl_program *prog); + + /** Query if program can be loaded onto hardware */ + GLboolean (*IsProgramNative)(struct gl_context *ctx, GLenum target, + struct gl_program *prog); + + /*@}*/ + + /** + * \name GLSL shader/program functions. + */ + /*@{*/ + /** + * Called when a shader program is linked. + * + * This gives drivers an opportunity to clone the IR and make their + * own transformations on it for the purposes of code generation. + */ + GLboolean (*LinkShader)(struct gl_context *ctx, struct gl_shader_program *shader); + /*@}*/ + + /** + * \name State-changing functions. + * + * \note drawing functions are above. + * + * These functions are called by their corresponding OpenGL API functions. + * They are \e also called by the gl_PopAttrib() function!!! + * May add more functions like these to the device driver in the future. + */ + /*@{*/ + /** Specify the alpha test function */ + void (*AlphaFunc)(struct gl_context *ctx, GLenum func, GLfloat ref); + /** Set the blend color */ + void (*BlendColor)(struct gl_context *ctx, const GLfloat color[4]); + /** Set the blend equation */ + void (*BlendEquationSeparate)(struct gl_context *ctx, GLenum modeRGB, GLenum modeA); + void (*BlendEquationSeparatei)(struct gl_context *ctx, GLuint buffer, + GLenum modeRGB, GLenum modeA); + /** Specify pixel arithmetic */ + void (*BlendFuncSeparate)(struct gl_context *ctx, + GLenum sfactorRGB, GLenum dfactorRGB, + GLenum sfactorA, GLenum dfactorA); + void (*BlendFuncSeparatei)(struct gl_context *ctx, GLuint buffer, + GLenum sfactorRGB, GLenum dfactorRGB, + GLenum sfactorA, GLenum dfactorA); + /** Specify clear values for the color buffers */ + void (*ClearColor)(struct gl_context *ctx, const GLfloat color[4]); + /** Specify the clear value for the depth buffer */ + void (*ClearDepth)(struct gl_context *ctx, GLclampd d); + /** Specify the clear value for the stencil buffer */ + void (*ClearStencil)(struct gl_context *ctx, GLint s); + /** Specify a plane against which all geometry is clipped */ + void (*ClipPlane)(struct gl_context *ctx, GLenum plane, const GLfloat *equation ); + /** Enable and disable writing of frame buffer color components */ + void (*ColorMask)(struct gl_context *ctx, GLboolean rmask, GLboolean gmask, + GLboolean bmask, GLboolean amask ); + void (*ColorMaskIndexed)(struct gl_context *ctx, GLuint buf, GLboolean rmask, + GLboolean gmask, GLboolean bmask, GLboolean amask); + /** Cause a material color to track the current color */ + void (*ColorMaterial)(struct gl_context *ctx, GLenum face, GLenum mode); + /** Specify whether front- or back-facing facets can be culled */ + void (*CullFace)(struct gl_context *ctx, GLenum mode); + /** Define front- and back-facing polygons */ + void (*FrontFace)(struct gl_context *ctx, GLenum mode); + /** Specify the value used for depth buffer comparisons */ + void (*DepthFunc)(struct gl_context *ctx, GLenum func); + /** Enable or disable writing into the depth buffer */ + void (*DepthMask)(struct gl_context *ctx, GLboolean flag); + /** Specify mapping of depth values from NDC to window coordinates */ + void (*DepthRange)(struct gl_context *ctx, GLclampd nearval, GLclampd farval); + /** Specify the current buffer for writing */ + void (*DrawBuffer)( struct gl_context *ctx, GLenum buffer ); + /** Specify the buffers for writing for fragment programs*/ + void (*DrawBuffers)( struct gl_context *ctx, GLsizei n, const GLenum *buffers ); + /** Enable or disable server-side gl capabilities */ + void (*Enable)(struct gl_context *ctx, GLenum cap, GLboolean state); + /** Specify fog parameters */ + void (*Fogfv)(struct gl_context *ctx, GLenum pname, const GLfloat *params); + /** Specify implementation-specific hints */ + void (*Hint)(struct gl_context *ctx, GLenum target, GLenum mode); + /** Set light source parameters. + * Note: for GL_POSITION and GL_SPOT_DIRECTION, params will have already + * been transformed to eye-space. + */ + void (*Lightfv)(struct gl_context *ctx, GLenum light, + GLenum pname, const GLfloat *params ); + /** Set the lighting model parameters */ + void (*LightModelfv)(struct gl_context *ctx, GLenum pname, const GLfloat *params); + /** Specify the line stipple pattern */ + void (*LineStipple)(struct gl_context *ctx, GLint factor, GLushort pattern ); + /** Specify the width of rasterized lines */ + void (*LineWidth)(struct gl_context *ctx, GLfloat width); + /** Specify a logical pixel operation for color index rendering */ + void (*LogicOpcode)(struct gl_context *ctx, GLenum opcode); + void (*PointParameterfv)(struct gl_context *ctx, GLenum pname, + const GLfloat *params); + /** Specify the diameter of rasterized points */ + void (*PointSize)(struct gl_context *ctx, GLfloat size); + /** Select a polygon rasterization mode */ + void (*PolygonMode)(struct gl_context *ctx, GLenum face, GLenum mode); + /** Set the scale and units used to calculate depth values */ + void (*PolygonOffset)(struct gl_context *ctx, GLfloat factor, GLfloat units); + /** Set the polygon stippling pattern */ + void (*PolygonStipple)(struct gl_context *ctx, const GLubyte *mask ); + /* Specifies the current buffer for reading */ + void (*ReadBuffer)( struct gl_context *ctx, GLenum buffer ); + /** Set rasterization mode */ + void (*RenderMode)(struct gl_context *ctx, GLenum mode ); + /** Define the scissor box */ + void (*Scissor)(struct gl_context *ctx, GLint x, GLint y, GLsizei w, GLsizei h); + /** Select flat or smooth shading */ + void (*ShadeModel)(struct gl_context *ctx, GLenum mode); + /** OpenGL 2.0 two-sided StencilFunc */ + void (*StencilFuncSeparate)(struct gl_context *ctx, GLenum face, GLenum func, + GLint ref, GLuint mask); + /** OpenGL 2.0 two-sided StencilMask */ + void (*StencilMaskSeparate)(struct gl_context *ctx, GLenum face, GLuint mask); + /** OpenGL 2.0 two-sided StencilOp */ + void (*StencilOpSeparate)(struct gl_context *ctx, GLenum face, GLenum fail, + GLenum zfail, GLenum zpass); + /** Control the generation of texture coordinates */ + void (*TexGen)(struct gl_context *ctx, GLenum coord, GLenum pname, + const GLfloat *params); + /** Set texture environment parameters */ + void (*TexEnv)(struct gl_context *ctx, GLenum target, GLenum pname, + const GLfloat *param); + /** Set texture parameters */ + void (*TexParameter)(struct gl_context *ctx, GLenum target, + struct gl_texture_object *texObj, + GLenum pname, const GLfloat *params); + /** Set the viewport */ + void (*Viewport)(struct gl_context *ctx, GLint x, GLint y, GLsizei w, GLsizei h); + /*@}*/ + + + /** + * \name Vertex/pixel buffer object functions + */ + /*@{*/ + void (*BindBuffer)( struct gl_context *ctx, GLenum target, + struct gl_buffer_object *obj ); + + struct gl_buffer_object * (*NewBufferObject)( struct gl_context *ctx, GLuint buffer, + GLenum target ); + + void (*DeleteBuffer)( struct gl_context *ctx, struct gl_buffer_object *obj ); + + GLboolean (*BufferData)( struct gl_context *ctx, GLenum target, GLsizeiptrARB size, + const GLvoid *data, GLenum usage, + struct gl_buffer_object *obj ); + + void (*BufferSubData)( struct gl_context *ctx, GLenum target, GLintptrARB offset, + GLsizeiptrARB size, const GLvoid *data, + struct gl_buffer_object *obj ); + + void (*GetBufferSubData)( struct gl_context *ctx, GLenum target, + GLintptrARB offset, GLsizeiptrARB size, + GLvoid *data, struct gl_buffer_object *obj ); + + void * (*MapBuffer)( struct gl_context *ctx, GLenum target, GLenum access, + struct gl_buffer_object *obj ); + + void (*CopyBufferSubData)( struct gl_context *ctx, + struct gl_buffer_object *src, + struct gl_buffer_object *dst, + GLintptr readOffset, GLintptr writeOffset, + GLsizeiptr size ); + + /* May return NULL if MESA_MAP_NOWAIT_BIT is set in access: + */ + void * (*MapBufferRange)( struct gl_context *ctx, GLenum target, GLintptr offset, + GLsizeiptr length, GLbitfield access, + struct gl_buffer_object *obj); + + void (*FlushMappedBufferRange)(struct gl_context *ctx, GLenum target, + GLintptr offset, GLsizeiptr length, + struct gl_buffer_object *obj); + + GLboolean (*UnmapBuffer)( struct gl_context *ctx, GLenum target, + struct gl_buffer_object *obj ); + /*@}*/ + + /** + * \name Functions for GL_APPLE_object_purgeable + */ + /*@{*/ + /* variations on ObjectPurgeable */ + GLenum (*BufferObjectPurgeable)( struct gl_context *ctx, struct gl_buffer_object *obj, GLenum option ); + GLenum (*RenderObjectPurgeable)( struct gl_context *ctx, struct gl_renderbuffer *obj, GLenum option ); + GLenum (*TextureObjectPurgeable)( struct gl_context *ctx, struct gl_texture_object *obj, GLenum option ); + + /* variations on ObjectUnpurgeable */ + GLenum (*BufferObjectUnpurgeable)( struct gl_context *ctx, struct gl_buffer_object *obj, GLenum option ); + GLenum (*RenderObjectUnpurgeable)( struct gl_context *ctx, struct gl_renderbuffer *obj, GLenum option ); + GLenum (*TextureObjectUnpurgeable)( struct gl_context *ctx, struct gl_texture_object *obj, GLenum option ); + /*@}*/ + + /** + * \name Functions for GL_EXT_framebuffer_{object,blit}. + */ + /*@{*/ + struct gl_framebuffer * (*NewFramebuffer)(struct gl_context *ctx, GLuint name); + struct gl_renderbuffer * (*NewRenderbuffer)(struct gl_context *ctx, GLuint name); + void (*BindFramebuffer)(struct gl_context *ctx, GLenum target, + struct gl_framebuffer *drawFb, + struct gl_framebuffer *readFb); + void (*FramebufferRenderbuffer)(struct gl_context *ctx, + struct gl_framebuffer *fb, + GLenum attachment, + struct gl_renderbuffer *rb); + void (*RenderTexture)(struct gl_context *ctx, + struct gl_framebuffer *fb, + struct gl_renderbuffer_attachment *att); + void (*FinishRenderTexture)(struct gl_context *ctx, + struct gl_renderbuffer_attachment *att); + void (*ValidateFramebuffer)(struct gl_context *ctx, + struct gl_framebuffer *fb); + /*@}*/ + void (*BlitFramebuffer)(struct gl_context *ctx, + GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, + GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, + GLbitfield mask, GLenum filter); + + /** + * \name Query objects + */ + /*@{*/ + struct gl_query_object * (*NewQueryObject)(struct gl_context *ctx, GLuint id); + void (*DeleteQuery)(struct gl_context *ctx, struct gl_query_object *q); + void (*BeginQuery)(struct gl_context *ctx, struct gl_query_object *q); + void (*EndQuery)(struct gl_context *ctx, struct gl_query_object *q); + void (*CheckQuery)(struct gl_context *ctx, struct gl_query_object *q); + void (*WaitQuery)(struct gl_context *ctx, struct gl_query_object *q); + /*@}*/ + + + /** + * \name Vertex Array objects + */ + /*@{*/ + struct gl_array_object * (*NewArrayObject)(struct gl_context *ctx, GLuint id); + void (*DeleteArrayObject)(struct gl_context *ctx, struct gl_array_object *obj); + void (*BindArrayObject)(struct gl_context *ctx, struct gl_array_object *obj); + /*@}*/ + + /** + * \name GLSL-related functions (ARB extensions and OpenGL 2.x) + */ + /*@{*/ + struct gl_shader *(*NewShader)(struct gl_context *ctx, GLuint name, GLenum type); + void (*DeleteShader)(struct gl_context *ctx, struct gl_shader *shader); + struct gl_shader_program *(*NewShaderProgram)(struct gl_context *ctx, GLuint name); + void (*DeleteShaderProgram)(struct gl_context *ctx, + struct gl_shader_program *shProg); + void (*UseProgram)(struct gl_context *ctx, struct gl_shader_program *shProg); + /*@}*/ + + + /** + * \name Support for multiple T&L engines + */ + /*@{*/ + + /** + * Bitmask of state changes that require the current T&L module to be + * validated, using ValidateTnlModule() below. + */ + GLuint NeedValidate; + + /** + * Validate the current T&L module. + * + * This is called directly after UpdateState() when a state change that has + * occurred matches the dd_function_table::NeedValidate bitmask above. This + * ensures all computed values are up to date, thus allowing the driver to + * decide if the current T&L module needs to be swapped out. + * + * This must be non-NULL if a driver installs a custom T&L module and sets + * the dd_function_table::NeedValidate bitmask, but may be NULL otherwise. + */ + void (*ValidateTnlModule)( struct gl_context *ctx, GLuint new_state ); + + /** + * Set by the driver-supplied T&L engine. + * + * Set to PRIM_OUTSIDE_BEGIN_END when outside glBegin()/glEnd(). + */ + GLuint CurrentExecPrimitive; + + /** + * Current state of an in-progress compilation. + * + * May take on any of the additional values PRIM_OUTSIDE_BEGIN_END, + * PRIM_INSIDE_UNKNOWN_PRIM or PRIM_UNKNOWN defined above. + */ + GLuint CurrentSavePrimitive; + + +#define FLUSH_STORED_VERTICES 0x1 +#define FLUSH_UPDATE_CURRENT 0x2 + /** + * Set by the driver-supplied T&L engine whenever vertices are buffered + * between glBegin()/glEnd() objects or __struct gl_contextRec::Current is not + * updated. + * + * The dd_function_table::FlushVertices call below may be used to resolve + * these conditions. + */ + GLuint NeedFlush; + GLuint SaveNeedFlush; + + + /* Called prior to any of the GLvertexformat functions being + * called. Paired with Driver.FlushVertices(). + */ + void (*BeginVertices)( struct gl_context *ctx ); + + /** + * If inside glBegin()/glEnd(), it should ASSERT(0). Otherwise, if + * FLUSH_STORED_VERTICES bit in \p flags is set flushes any buffered + * vertices, if FLUSH_UPDATE_CURRENT bit is set updates + * __struct gl_contextRec::Current and gl_light_attrib::Material + * + * Note that the default T&L engine never clears the + * FLUSH_UPDATE_CURRENT bit, even after performing the update. + */ + void (*FlushVertices)( struct gl_context *ctx, GLuint flags ); + void (*SaveFlushVertices)( struct gl_context *ctx ); + + /** + * Give the driver the opportunity to hook in its own vtxfmt for + * compiling optimized display lists. This is called on each valid + * glBegin() during list compilation. + */ + GLboolean (*NotifySaveBegin)( struct gl_context *ctx, GLenum mode ); + + /** + * Notify driver that the special derived value _NeedEyeCoords has + * changed. + */ + void (*LightingSpaceChange)( struct gl_context *ctx ); + + /** + * Called by glNewList(). + * + * Let the T&L component know what is going on with display lists + * in time to make changes to dispatch tables, etc. + */ + void (*NewList)( struct gl_context *ctx, GLuint list, GLenum mode ); + /** + * Called by glEndList(). + * + * \sa dd_function_table::NewList. + */ + void (*EndList)( struct gl_context *ctx ); + + /** + * Called by glCallList(s). + * + * Notify the T&L component before and after calling a display list. + */ + void (*BeginCallList)( struct gl_context *ctx, + struct gl_display_list *dlist ); + /** + * Called by glEndCallList(). + * + * \sa dd_function_table::BeginCallList. + */ + void (*EndCallList)( struct gl_context *ctx ); + + + /** + * \name GL_ARB_sync interfaces + */ + /*@{*/ + struct gl_sync_object * (*NewSyncObject)(struct gl_context *, GLenum); + void (*FenceSync)(struct gl_context *, struct gl_sync_object *, GLenum, GLbitfield); + void (*DeleteSyncObject)(struct gl_context *, struct gl_sync_object *); + void (*CheckSync)(struct gl_context *, struct gl_sync_object *); + void (*ClientWaitSync)(struct gl_context *, struct gl_sync_object *, + GLbitfield, GLuint64); + void (*ServerWaitSync)(struct gl_context *, struct gl_sync_object *, + GLbitfield, GLuint64); + /*@}*/ + + /** GL_NV_conditional_render */ + void (*BeginConditionalRender)(struct gl_context *ctx, struct gl_query_object *q, + GLenum mode); + void (*EndConditionalRender)(struct gl_context *ctx, struct gl_query_object *q); + + /** + * \name GL_OES_draw_texture interface + */ + /*@{*/ + void (*DrawTex)(struct gl_context *ctx, GLfloat x, GLfloat y, GLfloat z, + GLfloat width, GLfloat height); + /*@}*/ + + /** + * \name GL_OES_EGL_image interface + */ + void (*EGLImageTargetTexture2D)(struct gl_context *ctx, GLenum target, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage, + GLeglImageOES image_handle); + void (*EGLImageTargetRenderbufferStorage)(struct gl_context *ctx, + struct gl_renderbuffer *rb, + void *image_handle); + + /** + * \name GL_EXT_transform_feedback interface + */ + struct gl_transform_feedback_object * + (*NewTransformFeedback)(struct gl_context *ctx, GLuint name); + void (*DeleteTransformFeedback)(struct gl_context *ctx, + struct gl_transform_feedback_object *obj); + void (*BeginTransformFeedback)(struct gl_context *ctx, GLenum mode, + struct gl_transform_feedback_object *obj); + void (*EndTransformFeedback)(struct gl_context *ctx, + struct gl_transform_feedback_object *obj); + void (*PauseTransformFeedback)(struct gl_context *ctx, + struct gl_transform_feedback_object *obj); + void (*ResumeTransformFeedback)(struct gl_context *ctx, + struct gl_transform_feedback_object *obj); + void (*DrawTransformFeedback)(struct gl_context *ctx, GLenum mode, + struct gl_transform_feedback_object *obj); + + /** + * \name GL_NV_texture_barrier interface + */ + void (*TextureBarrier)(struct gl_context *ctx); + + /** + * \name GL_ARB_sampler_objects + */ + struct gl_sampler_object * (*NewSamplerObject)(struct gl_context *ctx, + GLuint name); + void (*DeleteSamplerObject)(struct gl_context *ctx, + struct gl_sampler_object *samp); +}; + + +/** + * Transform/Clip/Lighting interface + * + * Drivers present a reduced set of the functions possible in + * glBegin()/glEnd() objects. Core mesa provides translation stubs for the + * remaining functions to map down to these entry points. + * + * These are the initial values to be installed into dispatch by + * mesa. If the T&L driver wants to modify the dispatch table + * while installed, it must do so itself. It would be possible for + * the vertexformat to install its own initial values for these + * functions, but this way there is an obvious list of what is + * expected of the driver. + * + * If the driver wants to hook in entry points other than those + * listed, it must restore them to their original values in + * the disable() callback, below. + */ +typedef struct { + /** + * \name Vertex + */ + /*@{*/ + void (GLAPIENTRYP ArrayElement)( GLint ); + void (GLAPIENTRYP Color3f)( GLfloat, GLfloat, GLfloat ); + void (GLAPIENTRYP Color3fv)( const GLfloat * ); + void (GLAPIENTRYP Color4f)( GLfloat, GLfloat, GLfloat, GLfloat ); + void (GLAPIENTRYP Color4fv)( const GLfloat * ); + void (GLAPIENTRYP EdgeFlag)( GLboolean ); + void (GLAPIENTRYP EvalCoord1f)( GLfloat ); + void (GLAPIENTRYP EvalCoord1fv)( const GLfloat * ); + void (GLAPIENTRYP EvalCoord2f)( GLfloat, GLfloat ); + void (GLAPIENTRYP EvalCoord2fv)( const GLfloat * ); + void (GLAPIENTRYP EvalPoint1)( GLint ); + void (GLAPIENTRYP EvalPoint2)( GLint, GLint ); + void (GLAPIENTRYP FogCoordfEXT)( GLfloat ); + void (GLAPIENTRYP FogCoordfvEXT)( const GLfloat * ); + void (GLAPIENTRYP Indexf)( GLfloat ); + void (GLAPIENTRYP Indexfv)( const GLfloat * ); + void (GLAPIENTRYP Materialfv)( GLenum face, GLenum pname, const GLfloat * ); + void (GLAPIENTRYP MultiTexCoord1fARB)( GLenum, GLfloat ); + void (GLAPIENTRYP MultiTexCoord1fvARB)( GLenum, const GLfloat * ); + void (GLAPIENTRYP MultiTexCoord2fARB)( GLenum, GLfloat, GLfloat ); + void (GLAPIENTRYP MultiTexCoord2fvARB)( GLenum, const GLfloat * ); + void (GLAPIENTRYP MultiTexCoord3fARB)( GLenum, GLfloat, GLfloat, GLfloat ); + void (GLAPIENTRYP MultiTexCoord3fvARB)( GLenum, const GLfloat * ); + void (GLAPIENTRYP MultiTexCoord4fARB)( GLenum, GLfloat, GLfloat, GLfloat, GLfloat ); + void (GLAPIENTRYP MultiTexCoord4fvARB)( GLenum, const GLfloat * ); + void (GLAPIENTRYP Normal3f)( GLfloat, GLfloat, GLfloat ); + void (GLAPIENTRYP Normal3fv)( const GLfloat * ); + void (GLAPIENTRYP SecondaryColor3fEXT)( GLfloat, GLfloat, GLfloat ); + void (GLAPIENTRYP SecondaryColor3fvEXT)( const GLfloat * ); + void (GLAPIENTRYP TexCoord1f)( GLfloat ); + void (GLAPIENTRYP TexCoord1fv)( const GLfloat * ); + void (GLAPIENTRYP TexCoord2f)( GLfloat, GLfloat ); + void (GLAPIENTRYP TexCoord2fv)( const GLfloat * ); + void (GLAPIENTRYP TexCoord3f)( GLfloat, GLfloat, GLfloat ); + void (GLAPIENTRYP TexCoord3fv)( const GLfloat * ); + void (GLAPIENTRYP TexCoord4f)( GLfloat, GLfloat, GLfloat, GLfloat ); + void (GLAPIENTRYP TexCoord4fv)( const GLfloat * ); + void (GLAPIENTRYP Vertex2f)( GLfloat, GLfloat ); + void (GLAPIENTRYP Vertex2fv)( const GLfloat * ); + void (GLAPIENTRYP Vertex3f)( GLfloat, GLfloat, GLfloat ); + void (GLAPIENTRYP Vertex3fv)( const GLfloat * ); + void (GLAPIENTRYP Vertex4f)( GLfloat, GLfloat, GLfloat, GLfloat ); + void (GLAPIENTRYP Vertex4fv)( const GLfloat * ); + void (GLAPIENTRYP CallList)( GLuint ); + void (GLAPIENTRYP CallLists)( GLsizei, GLenum, const GLvoid * ); + void (GLAPIENTRYP Begin)( GLenum ); + void (GLAPIENTRYP End)( void ); + void (GLAPIENTRYP PrimitiveRestartNV)( void ); + /* GL_NV_vertex_program */ + void (GLAPIENTRYP VertexAttrib1fNV)( GLuint index, GLfloat x ); + void (GLAPIENTRYP VertexAttrib1fvNV)( GLuint index, const GLfloat *v ); + void (GLAPIENTRYP VertexAttrib2fNV)( GLuint index, GLfloat x, GLfloat y ); + void (GLAPIENTRYP VertexAttrib2fvNV)( GLuint index, const GLfloat *v ); + void (GLAPIENTRYP VertexAttrib3fNV)( GLuint index, GLfloat x, GLfloat y, GLfloat z ); + void (GLAPIENTRYP VertexAttrib3fvNV)( GLuint index, const GLfloat *v ); + void (GLAPIENTRYP VertexAttrib4fNV)( GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w ); + void (GLAPIENTRYP VertexAttrib4fvNV)( GLuint index, const GLfloat *v ); + /* GL_ARB_vertex_program */ + void (GLAPIENTRYP VertexAttrib1fARB)( GLuint index, GLfloat x ); + void (GLAPIENTRYP VertexAttrib1fvARB)( GLuint index, const GLfloat *v ); + void (GLAPIENTRYP VertexAttrib2fARB)( GLuint index, GLfloat x, GLfloat y ); + void (GLAPIENTRYP VertexAttrib2fvARB)( GLuint index, const GLfloat *v ); + void (GLAPIENTRYP VertexAttrib3fARB)( GLuint index, GLfloat x, GLfloat y, GLfloat z ); + void (GLAPIENTRYP VertexAttrib3fvARB)( GLuint index, const GLfloat *v ); + void (GLAPIENTRYP VertexAttrib4fARB)( GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w ); + void (GLAPIENTRYP VertexAttrib4fvARB)( GLuint index, const GLfloat *v ); + + /* GL_EXT_gpu_shader4 / GL 3.0 */ + void (GLAPIENTRYP VertexAttribI1i)( GLuint index, GLint x); + void (GLAPIENTRYP VertexAttribI2i)( GLuint index, GLint x, GLint y); + void (GLAPIENTRYP VertexAttribI3i)( GLuint index, GLint x, GLint y, GLint z); + void (GLAPIENTRYP VertexAttribI4i)( GLuint index, GLint x, GLint y, GLint z, GLint w); + void (GLAPIENTRYP VertexAttribI2iv)( GLuint index, const GLint *v); + void (GLAPIENTRYP VertexAttribI3iv)( GLuint index, const GLint *v); + void (GLAPIENTRYP VertexAttribI4iv)( GLuint index, const GLint *v); + + void (GLAPIENTRYP VertexAttribI1ui)( GLuint index, GLuint x); + void (GLAPIENTRYP VertexAttribI2ui)( GLuint index, GLuint x, GLuint y); + void (GLAPIENTRYP VertexAttribI3ui)( GLuint index, GLuint x, GLuint y, GLuint z); + void (GLAPIENTRYP VertexAttribI4ui)( GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); + void (GLAPIENTRYP VertexAttribI2uiv)( GLuint index, const GLuint *v); + void (GLAPIENTRYP VertexAttribI3uiv)( GLuint index, const GLuint *v); + void (GLAPIENTRYP VertexAttribI4uiv)( GLuint index, const GLuint *v); + + /*@}*/ + + void (GLAPIENTRYP Rectf)( GLfloat, GLfloat, GLfloat, GLfloat ); + + /** + * \name Array + */ + /*@{*/ + void (GLAPIENTRYP DrawArrays)( GLenum mode, GLint start, GLsizei count ); + void (GLAPIENTRYP DrawElements)( GLenum mode, GLsizei count, GLenum type, + const GLvoid *indices ); + void (GLAPIENTRYP DrawRangeElements)( GLenum mode, GLuint start, + GLuint end, GLsizei count, + GLenum type, const GLvoid *indices ); + void (GLAPIENTRYP MultiDrawElementsEXT)( GLenum mode, const GLsizei *count, + GLenum type, + const GLvoid **indices, + GLsizei primcount); + void (GLAPIENTRYP DrawElementsBaseVertex)( GLenum mode, GLsizei count, + GLenum type, + const GLvoid *indices, + GLint basevertex ); + void (GLAPIENTRYP DrawRangeElementsBaseVertex)( GLenum mode, GLuint start, + GLuint end, GLsizei count, + GLenum type, + const GLvoid *indices, + GLint basevertex); + void (GLAPIENTRYP MultiDrawElementsBaseVertex)( GLenum mode, + const GLsizei *count, + GLenum type, + const GLvoid **indices, + GLsizei primcount, + const GLint *basevertex); + void (GLAPIENTRYP DrawArraysInstanced)(GLenum mode, GLint first, + GLsizei count, GLsizei primcount); + void (GLAPIENTRYP DrawElementsInstanced)(GLenum mode, GLsizei count, + GLenum type, const GLvoid *indices, + GLsizei primcount); + void (GLAPIENTRYP DrawElementsInstancedBaseVertex)(GLenum mode, GLsizei count, + GLenum type, const GLvoid *indices, + GLsizei primcount, GLint basevertex); + /*@}*/ + + /** + * \name Eval + * + * If you don't support eval, fallback to the default vertex format + * on receiving an eval call and use the pipeline mechanism to + * provide partial T&L acceleration. + * + * Mesa will provide a set of helper functions to do eval within + * accelerated vertex formats, eventually... + */ + /*@{*/ + void (GLAPIENTRYP EvalMesh1)( GLenum mode, GLint i1, GLint i2 ); + void (GLAPIENTRYP EvalMesh2)( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 ); + /*@}*/ + +} GLvertexformat; + + +#endif /* DD_INCLUDED */ diff --git a/3rdparty/glsl-optimizer/src/mesa/main/extensions.h b/3rdparty/glsl-optimizer/src/mesa/main/extensions.h new file mode 100644 index 000000000..a9ed41f86 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/mesa/main/extensions.h @@ -0,0 +1,96 @@ +/** + * \file extensions.h + * Extension handling. + * + * \if subset + * (No-op) + * + * \endif + */ + +/* + * Mesa 3-D graphics library + * Version: 6.5.1 + * + * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#ifndef _EXTENSIONS_H_ +#define _EXTENSIONS_H_ + +#include "glheader.h" +#include "mfeatures.h" + +struct gl_context; + +#if _HAVE_FULL_GL + +extern void _mesa_enable_sw_extensions(struct gl_context *ctx); + +extern void _mesa_enable_imaging_extensions(struct gl_context *ctx); + +extern void _mesa_enable_1_3_extensions(struct gl_context *ctx); + +extern void _mesa_enable_1_4_extensions(struct gl_context *ctx); + +extern void _mesa_enable_1_5_extensions(struct gl_context *ctx); + +extern void _mesa_enable_2_0_extensions(struct gl_context *ctx); + +extern void _mesa_enable_2_1_extensions(struct gl_context *ctx); + +extern void _mesa_enable_extension(struct gl_context *ctx, const char *name); + +extern void _mesa_disable_extension(struct gl_context *ctx, const char *name); + +extern GLboolean _mesa_extension_is_enabled(struct gl_context *ctx, const char *name); + +extern void _mesa_init_extensions(struct gl_context *ctx); + +extern GLubyte *_mesa_make_extension_string(struct gl_context *ctx); + +extern GLuint +_mesa_get_extension_count(struct gl_context *ctx); + +extern const GLubyte * +_mesa_get_enabled_extension(struct gl_context *ctx, GLuint index); + + +#else + +/** No-op */ +#define _mesa_extensions_dtr( ctx ) ((void)0) + +/** No-op */ +#define _mesa_extensions_ctr( ctx ) ((void)0) + +/** No-op */ +#define _mesa_extensions_get_string( ctx ) "GL_EXT_texture_object" + +/** No-op */ +#define _mesa_enable_imaging_extensions( c ) ((void)0) + +/** No-op */ +#define _mesa_enable_extension( c, n ) ((void)0) + +#endif + +#endif diff --git a/3rdparty/glsl-optimizer/src/mesa/main/formats.h b/3rdparty/glsl-optimizer/src/mesa/main/formats.h new file mode 100644 index 000000000..5b8c01781 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/mesa/main/formats.h @@ -0,0 +1,270 @@ +/* + * Mesa 3-D graphics library + * Version: 7.7 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (c) 2008-2009 VMware, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/* + * Authors: + * Brian Paul + */ + + +#ifndef FORMATS_H +#define FORMATS_H + + +#include + +/* OpenGL doesn't have GL_UNSIGNED_BYTE_4_4, so we must define our own type + * for GL_LUMINANCE4_ALPHA4. */ +#define MESA_UNSIGNED_BYTE_4_4 (GL_UNSIGNED_BYTE<<1) + + +/** + * Mesa texture/renderbuffer image formats. + */ +typedef enum +{ + MESA_FORMAT_NONE = 0, + + /** + * \name Basic hardware formats + */ + /*@{*/ + /* msb <------ TEXEL BITS -----------> lsb */ + /* ---- ---- ---- ---- ---- ---- ---- ---- */ + MESA_FORMAT_RGBA8888, /* RRRR RRRR GGGG GGGG BBBB BBBB AAAA AAAA */ + MESA_FORMAT_RGBA8888_REV, /* AAAA AAAA BBBB BBBB GGGG GGGG RRRR RRRR */ + MESA_FORMAT_ARGB8888, /* AAAA AAAA RRRR RRRR GGGG GGGG BBBB BBBB */ + MESA_FORMAT_ARGB8888_REV, /* BBBB BBBB GGGG GGGG RRRR RRRR AAAA AAAA */ + MESA_FORMAT_XRGB8888, /* xxxx xxxx RRRR RRRR GGGG GGGG BBBB BBBB */ + MESA_FORMAT_XRGB8888_REV, /* BBBB BBBB GGGG GGGG RRRR RRRR xxxx xxxx */ + MESA_FORMAT_RGB888, /* RRRR RRRR GGGG GGGG BBBB BBBB */ + MESA_FORMAT_BGR888, /* BBBB BBBB GGGG GGGG RRRR RRRR */ + MESA_FORMAT_RGB565, /* RRRR RGGG GGGB BBBB */ + MESA_FORMAT_RGB565_REV, /* GGGB BBBB RRRR RGGG */ + MESA_FORMAT_ARGB4444, /* AAAA RRRR GGGG BBBB */ + MESA_FORMAT_ARGB4444_REV, /* GGGG BBBB AAAA RRRR */ + MESA_FORMAT_RGBA5551, /* RRRR RGGG GGBB BBBA */ + MESA_FORMAT_ARGB1555, /* ARRR RRGG GGGB BBBB */ + MESA_FORMAT_ARGB1555_REV, /* GGGB BBBB ARRR RRGG */ + MESA_FORMAT_AL44, /* AAAA LLLL */ + MESA_FORMAT_AL88, /* AAAA AAAA LLLL LLLL */ + MESA_FORMAT_AL88_REV, /* LLLL LLLL AAAA AAAA */ + MESA_FORMAT_AL1616, /* AAAA AAAA AAAA AAAA LLLL LLLL LLLL LLLL */ + MESA_FORMAT_AL1616_REV, /* LLLL LLLL LLLL LLLL AAAA AAAA AAAA AAAA */ + MESA_FORMAT_RGB332, /* RRRG GGBB */ + MESA_FORMAT_A8, /* AAAA AAAA */ + MESA_FORMAT_A16, /* AAAA AAAA AAAA AAAA */ + MESA_FORMAT_L8, /* LLLL LLLL */ + MESA_FORMAT_L16, /* LLLL LLLL LLLL LLLL */ + MESA_FORMAT_I8, /* IIII IIII */ + MESA_FORMAT_I16, /* IIII IIII IIII IIII */ + MESA_FORMAT_CI8, /* CCCC CCCC */ + MESA_FORMAT_YCBCR, /* YYYY YYYY UorV UorV */ + MESA_FORMAT_YCBCR_REV, /* UorV UorV YYYY YYYY */ + MESA_FORMAT_R8, /* RRRR RRRR */ + MESA_FORMAT_RG88, /* RRRR RRRR GGGG GGGG */ + MESA_FORMAT_RG88_REV, /* GGGG GGGG RRRR RRRR */ + MESA_FORMAT_R16, /* RRRR RRRR RRRR RRRR */ + MESA_FORMAT_RG1616, /* RRRR RRRR RRRR RRRR GGGG GGGG GGGG GGGG */ + MESA_FORMAT_RG1616_REV, /* GGGG GGGG GGGG GGGG RRRR RRRR RRRR RRRR */ + MESA_FORMAT_ARGB2101010, /* AARR RRRR RRRR GGGG GGGG GGBB BBBB BBBB */ + MESA_FORMAT_Z24_S8, /* ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ SSSS SSSS */ + MESA_FORMAT_S8_Z24, /* SSSS SSSS ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ */ + MESA_FORMAT_Z16, /* ZZZZ ZZZZ ZZZZ ZZZZ */ + MESA_FORMAT_X8_Z24, /* xxxx xxxx ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ */ + MESA_FORMAT_Z24_X8, /* ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ xxxx xxxx */ + MESA_FORMAT_Z32, /* ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ */ + MESA_FORMAT_S8, /* SSSS SSSS */ + /*@}*/ + + /** + * \name 8-bit/channel sRGB formats + */ + /*@{*/ + MESA_FORMAT_SRGB8, + MESA_FORMAT_SRGBA8, + MESA_FORMAT_SARGB8, + MESA_FORMAT_SL8, + MESA_FORMAT_SLA8, + MESA_FORMAT_SRGB_DXT1, + MESA_FORMAT_SRGBA_DXT1, + MESA_FORMAT_SRGBA_DXT3, + MESA_FORMAT_SRGBA_DXT5, + /*@}*/ + + /** + * \name Compressed texture formats. + */ + /*@{*/ + MESA_FORMAT_RGB_FXT1, + MESA_FORMAT_RGBA_FXT1, + MESA_FORMAT_RGB_DXT1, + MESA_FORMAT_RGBA_DXT1, + MESA_FORMAT_RGBA_DXT3, + MESA_FORMAT_RGBA_DXT5, + /*@}*/ + + /** + * \name Floating point texture formats. + */ + /*@{*/ + MESA_FORMAT_RGBA_FLOAT32, + MESA_FORMAT_RGBA_FLOAT16, + MESA_FORMAT_RGB_FLOAT32, + MESA_FORMAT_RGB_FLOAT16, + MESA_FORMAT_ALPHA_FLOAT32, + MESA_FORMAT_ALPHA_FLOAT16, + MESA_FORMAT_LUMINANCE_FLOAT32, + MESA_FORMAT_LUMINANCE_FLOAT16, + MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32, + MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16, + MESA_FORMAT_INTENSITY_FLOAT32, + MESA_FORMAT_INTENSITY_FLOAT16, + MESA_FORMAT_R_FLOAT32, + MESA_FORMAT_R_FLOAT16, + MESA_FORMAT_RG_FLOAT32, + MESA_FORMAT_RG_FLOAT16, + /*@}*/ + + /** + * \name Non-normalized signed integer formats. + * XXX Note: these are just stand-ins for some better hardware + * formats TBD such as BGRA or ARGB. + */ + MESA_FORMAT_RGBA_INT8, + MESA_FORMAT_RGBA_INT16, + MESA_FORMAT_RGBA_INT32, + + /** + * \name Non-normalized unsigned integer formats. + */ + MESA_FORMAT_RGBA_UINT8, + MESA_FORMAT_RGBA_UINT16, + MESA_FORMAT_RGBA_UINT32, + + /* msb <------ TEXEL BITS -----------> lsb */ + /* ---- ---- ---- ---- ---- ---- ---- ---- */ + /** + * \name Signed fixed point texture formats. + */ + /*@{*/ + MESA_FORMAT_DUDV8, /* DUDU DUDU DVDV DVDV */ + MESA_FORMAT_SIGNED_R8, /* RRRR RRRR */ + MESA_FORMAT_SIGNED_RG88_REV, /* GGGG GGGG RRRR RRRR */ + MESA_FORMAT_SIGNED_RGBX8888, /* RRRR RRRR GGGG GGGG BBBB BBBB xxxx xxxx */ + MESA_FORMAT_SIGNED_RGBA8888, /* RRRR RRRR GGGG GGGG BBBB BBBB AAAA AAAA */ + MESA_FORMAT_SIGNED_RGBA8888_REV,/*AAAA AAAA BBBB BBBB GGGG GGGG RRRR RRRR */ + MESA_FORMAT_SIGNED_R16, /* RRRR RRRR RRRR RRRR */ + MESA_FORMAT_SIGNED_GR1616, /* GGGG GGGG GGGG GGGG RRRR RRRR RRRR RRRR */ + MESA_FORMAT_SIGNED_RGB_16, /* ushort[0]=R, ushort[1]=G, ushort[2]=B */ + MESA_FORMAT_SIGNED_RGBA_16, /* ... */ + MESA_FORMAT_RGBA_16, /* ... */ + /*@}*/ + + /*@{*/ + MESA_FORMAT_RED_RGTC1, + MESA_FORMAT_SIGNED_RED_RGTC1, + MESA_FORMAT_RG_RGTC2, + MESA_FORMAT_SIGNED_RG_RGTC2, + /*@}*/ + + /*@{*/ + MESA_FORMAT_L_LATC1, + MESA_FORMAT_SIGNED_L_LATC1, + MESA_FORMAT_LA_LATC2, + MESA_FORMAT_SIGNED_LA_LATC2, + /*@}*/ + + MESA_FORMAT_SIGNED_A8, /* AAAA AAAA */ + MESA_FORMAT_SIGNED_L8, /* LLLL LLLL */ + MESA_FORMAT_SIGNED_AL88, /* AAAA AAAA LLLL LLLL */ + MESA_FORMAT_SIGNED_I8, /* IIII IIII */ + MESA_FORMAT_SIGNED_A16, /* AAAA AAAA AAAA AAAA */ + MESA_FORMAT_SIGNED_L16, /* LLLL LLLL LLLL LLLL */ + MESA_FORMAT_SIGNED_AL1616, /* AAAA AAAA AAAA AAAA LLLL LLLL LLLL LLLL */ + MESA_FORMAT_SIGNED_I16, /* IIII IIII IIII IIII */ + + MESA_FORMAT_RGB9_E5_FLOAT, + MESA_FORMAT_R11_G11_B10_FLOAT, + + MESA_FORMAT_Z32_FLOAT, + MESA_FORMAT_Z32_FLOAT_X24S8, + + MESA_FORMAT_COUNT +} gl_format; + + +extern const char * +_mesa_get_format_name(gl_format format); + +extern GLint +_mesa_get_format_bytes(gl_format format); + +extern GLint +_mesa_get_format_bits(gl_format format, GLenum pname); + +extern GLenum +_mesa_get_format_datatype(gl_format format); + +extern GLenum +_mesa_get_format_base_format(gl_format format); + +extern void +_mesa_get_format_block_size(gl_format format, GLuint *bw, GLuint *bh); + +extern GLboolean +_mesa_is_format_compressed(gl_format format); + +extern GLboolean +_mesa_is_format_packed_depth_stencil(gl_format format); + +extern GLboolean +_mesa_is_format_integer_color(gl_format format); + +extern GLenum +_mesa_get_format_color_encoding(gl_format format); + +extern GLuint +_mesa_format_image_size(gl_format format, GLsizei width, + GLsizei height, GLsizei depth); + +extern uint64_t +_mesa_format_image_size64(gl_format format, GLsizei width, + GLsizei height, GLsizei depth); + +extern GLint +_mesa_format_row_stride(gl_format format, GLsizei width); + +extern void +_mesa_format_to_type_and_comps(gl_format format, + GLenum *datatype, GLuint *comps); + +extern void +_mesa_test_formats(void); + +extern gl_format +_mesa_get_srgb_format_linear(gl_format format); + +#endif /* FORMATS_H */ diff --git a/3rdparty/glsl-optimizer/src/mesa/main/glheader.h b/3rdparty/glsl-optimizer/src/mesa/main/glheader.h new file mode 100644 index 000000000..0df811986 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/mesa/main/glheader.h @@ -0,0 +1,167 @@ +/* + * Mesa 3-D graphics library + * Version: 7.5 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +/** + * \file glheader.h + * Wrapper for GL/gl.h and GL/glext.h + */ + + +#ifndef GLHEADER_H +#define GLHEADER_H + + +#ifdef WGLAPI +#undef WGLAPI +#endif + + +#if !defined(OPENSTEP) && (defined(__WIN32__) && !defined(__CYGWIN__)) && !defined(BUILD_FOR_SNAP) +# if (defined(_MSC_VER) || defined(__MINGW32__)) && defined(BUILD_GL32) /* tag specify we're building mesa as a DLL */ +# define WGLAPI __declspec(dllexport) +# elif (defined(_MSC_VER) || defined(__MINGW32__)) && defined(_DLL) /* tag specifying we're building for DLL runtime support */ +# define WGLAPI __declspec(dllimport) +# else /* for use with static link lib build of Win32 edition only */ +# define WGLAPI __declspec(dllimport) +# endif /* _STATIC_MESA support */ +#endif /* WIN32 / CYGWIN bracket */ + + +#define GL_GLEXT_PROTOTYPES +#include "GL/gl.h" +#include "GL/glext.h" + + +/** + * GL_FIXED is defined in glext.h version 64 but these typedefs aren't (yet). + */ +typedef int GLfixed; +typedef int GLclampx; + + +#ifndef GL_OES_EGL_image +typedef void *GLeglImageOES; +#endif + + +#ifndef GL_OES_point_size_array +#define GL_POINT_SIZE_ARRAY_OES 0x8B9C +#define GL_POINT_SIZE_ARRAY_TYPE_OES 0x898A +#define GL_POINT_SIZE_ARRAY_STRIDE_OES 0x898B +#define GL_POINT_SIZE_ARRAY_POINTER_OES 0x898C +#define GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES 0x8B9F +#endif + + +#ifndef GL_OES_draw_texture +#define GL_TEXTURE_CROP_RECT_OES 0x8B9D +#endif + + +#ifndef GL_PROGRAM_BINARY_LENGTH_OES +#define GL_PROGRAM_BINARY_LENGTH_OES 0x8741 +#endif + +/* GLES 2.0 tokens */ +#ifndef GL_RGB565 +#define GL_RGB565 0x8D62 +#endif + +#ifndef GL_TEXTURE_GEN_STR_OES +#define GL_TEXTURE_GEN_STR_OES 0x8D60 +#endif + +#ifndef GL_OES_compressed_paletted_texture +#define GL_PALETTE4_RGB8_OES 0x8B90 +#define GL_PALETTE4_RGBA8_OES 0x8B91 +#define GL_PALETTE4_R5_G6_B5_OES 0x8B92 +#define GL_PALETTE4_RGBA4_OES 0x8B93 +#define GL_PALETTE4_RGB5_A1_OES 0x8B94 +#define GL_PALETTE8_RGB8_OES 0x8B95 +#define GL_PALETTE8_RGBA8_OES 0x8B96 +#define GL_PALETTE8_R5_G6_B5_OES 0x8B97 +#define GL_PALETTE8_RGBA4_OES 0x8B98 +#define GL_PALETTE8_RGB5_A1_OES 0x8B99 +#endif + +#ifndef GL_OES_matrix_get +#define GL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS_OES 0x898D +#define GL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS_OES 0x898E +#define GL_TEXTURE_MATRIX_FLOAT_AS_INT_BITS_OES 0x898F +#endif + +#ifndef GL_ES_VERSION_2_0 +#define GL_SHADER_BINARY_FORMATS 0x8DF8 +#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 +#define GL_SHADER_COMPILER 0x8DFA +#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB +#define GL_MAX_VARYING_VECTORS 0x8DFC +#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD +#endif + +#ifndef GL_ATI_texture_compression_3dc +#define GL_ATI_texture_compression_3dc 1 +#define GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI 0x8837 +#endif + + +/** + * Internal token to represent a GLSL shader program (a collection of + * one or more shaders that get linked together). Note that GLSL + * shaders and shader programs share one name space (one hash table) + * so we need a value that's different from any of the + * GL_VERTEX/FRAGMENT/GEOMETRY_PROGRAM tokens. + */ +#define GL_SHADER_PROGRAM_MESA 0x9999 + + +/** + * Internal token for geometry programs. + * Use the value for GL_GEOMETRY_PROGRAM_NV for now. + */ +#define MESA_GEOMETRY_PROGRAM 0x8c26 + +/* Several fields of struct gl_config can take these as values. Since + * GLX header files may not be available everywhere they need to be used, + * redefine them here. + */ +#define GLX_NONE 0x8000 +#define GLX_SLOW_CONFIG 0x8001 +#define GLX_TRUE_COLOR 0x8002 +#define GLX_DIRECT_COLOR 0x8003 +#define GLX_PSEUDO_COLOR 0x8004 +#define GLX_STATIC_COLOR 0x8005 +#define GLX_GRAY_SCALE 0x8006 +#define GLX_STATIC_GRAY 0x8007 +#define GLX_TRANSPARENT_RGB 0x8008 +#define GLX_TRANSPARENT_INDEX 0x8009 +#define GLX_NON_CONFORMANT_CONFIG 0x800D +#define GLX_SWAP_EXCHANGE_OML 0x8061 +#define GLX_SWAP_COPY_OML 0x8062 +#define GLX_SWAP_UNDEFINED_OML 0x8063 + +#define GLX_DONT_CARE 0xFFFFFFFF + +#endif /* GLHEADER_H */ diff --git a/3rdparty/glsl-optimizer/src/mesa/main/imports.h b/3rdparty/glsl-optimizer/src/mesa/main/imports.h new file mode 100644 index 000000000..3fa1db02a --- /dev/null +++ b/3rdparty/glsl-optimizer/src/mesa/main/imports.h @@ -0,0 +1,642 @@ +/* + * Mesa 3-D graphics library + * Version: 7.5 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +/** + * \file imports.h + * Standard C library function wrappers. + * + * This file provides wrappers for all the standard C library functions + * like malloc(), free(), printf(), getenv(), etc. + */ + + +#ifndef IMPORTS_H +#define IMPORTS_H + + +#include "compiler.h" +#include "glheader.h" + + +#ifdef __cplusplus +extern "C" { +#endif + + +/**********************************************************************/ +/** Memory macros */ +/*@{*/ + +/** Allocate \p BYTES bytes */ +#define MALLOC(BYTES) malloc(BYTES) +/** Allocate and zero \p BYTES bytes */ +#define CALLOC(BYTES) calloc(1, BYTES) +/** Allocate a structure of type \p T */ +#define MALLOC_STRUCT(T) (struct T *) malloc(sizeof(struct T)) +/** Allocate and zero a structure of type \p T */ +#define CALLOC_STRUCT(T) (struct T *) calloc(1, sizeof(struct T)) +/** Free memory */ +#define FREE(PTR) free(PTR) + +/*@}*/ + + +/* + * For GL_ARB_vertex_buffer_object we need to treat vertex array pointers + * as offsets into buffer stores. Since the vertex array pointer and + * buffer store pointer are both pointers and we need to add them, we use + * this macro. + * Both pointers/offsets are expressed in bytes. + */ +#define ADD_POINTERS(A, B) ( (GLubyte *) (A) + (uintptr_t) (B) ) + + +/** + * Sometimes we treat GLfloats as GLints. On x86 systems, moving a float + * as a int (thereby using integer registers instead of FP registers) is + * a performance win. Typically, this can be done with ordinary casts. + * But with gcc's -fstrict-aliasing flag (which defaults to on in gcc 3.0) + * these casts generate warnings. + * The following union typedef is used to solve that. + */ +typedef union { GLfloat f; GLint i; } fi_type; + + + +/********************************************************************** + * Math macros + */ + +#define MAX_GLUSHORT 0xffff +#define MAX_GLUINT 0xffffffff + +/* Degrees to radians conversion: */ +#define DEG2RAD (M_PI/180.0) + + +/*** + *** SQRTF: single-precision square root + ***/ +#if 0 /* _mesa_sqrtf() not accurate enough - temporarily disabled */ +# define SQRTF(X) _mesa_sqrtf(X) +#else +# define SQRTF(X) (float) sqrt((float) (X)) +#endif + + +/*** + *** INV_SQRTF: single-precision inverse square root + ***/ +#if 0 +#define INV_SQRTF(X) _mesa_inv_sqrt(X) +#else +#define INV_SQRTF(X) (1.0F / SQRTF(X)) /* this is faster on a P4 */ +#endif + + +/** + * \name Work-arounds for platforms that lack C99 math functions + */ +/*@{*/ +#if (!defined(_XOPEN_SOURCE) || (_XOPEN_SOURCE < 600)) && !defined(_ISOC99_SOURCE) \ + && (!defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L)) \ + && (!defined(_MSC_VER) || (_MSC_VER < 1400)) +#define acosf(f) ((float) acos(f)) +#define asinf(f) ((float) asin(f)) +#define atan2f(x,y) ((float) atan2(x,y)) +#define atanf(f) ((float) atan(f)) +#define cielf(f) ((float) ciel(f)) +#define cosf(f) ((float) cos(f)) +#define coshf(f) ((float) cosh(f)) +#define expf(f) ((float) exp(f)) +#define exp2f(f) ((float) exp2(f)) +#define floorf(f) ((float) floor(f)) +#define logf(f) ((float) log(f)) +#define log2f(f) ((float) log2(f)) +#define powf(x,y) ((float) pow(x,y)) +#define sinf(f) ((float) sin(f)) +#define sinhf(f) ((float) sinh(f)) +#define sqrtf(f) ((float) sqrt(f)) +#define tanf(f) ((float) tan(f)) +#define tanhf(f) ((float) tanh(f)) +#define acoshf(f) ((float) acosh(f)) +#define asinhf(f) ((float) asinh(f)) +#define atanhf(f) ((float) atanh(f)) +#endif + +#if defined(_MSC_VER) +static INLINE float truncf(float x) { return x < 0.0f ? ceilf(x) : floorf(x); } +static INLINE float exp2f(float x) { return powf(2.0f, x); } +static INLINE float log2f(float x) { return logf(x) * 1.442695041f; } +static INLINE float asinhf(float x) { return logf(x + sqrtf(x * x + 1.0f)); } +static INLINE float acoshf(float x) { return logf(x + sqrtf(x * x - 1.0f)); } +static INLINE float atanhf(float x) { return (logf(1.0f + x) - logf(1.0f - x)) / 2.0f; } +static INLINE int isblank(int ch) { return ch == ' ' || ch == '\t'; } +#define strtoll(p, e, b) _strtoi64(p, e, b) +#endif +/*@}*/ + +/*** + *** LOG2: Log base 2 of float + ***/ +#ifdef USE_IEEE +#if 0 +/* This is pretty fast, but not accurate enough (only 2 fractional bits). + * Based on code from http://www.stereopsis.com/log2.html + */ +static INLINE GLfloat LOG2(GLfloat x) +{ + const GLfloat y = x * x * x * x; + const GLuint ix = *((GLuint *) &y); + const GLuint exp = (ix >> 23) & 0xFF; + const GLint log2 = ((GLint) exp) - 127; + return (GLfloat) log2 * (1.0 / 4.0); /* 4, because of x^4 above */ +} +#endif +/* Pretty fast, and accurate. + * Based on code from http://www.flipcode.com/totd/ + */ +static INLINE GLfloat LOG2(GLfloat val) +{ + fi_type num; + GLint log_2; + num.f = val; + log_2 = ((num.i >> 23) & 255) - 128; + num.i &= ~(255 << 23); + num.i += 127 << 23; + num.f = ((-1.0f/3) * num.f + 2) * num.f - 2.0f/3; + return num.f + log_2; +} +#else +/* + * NOTE: log_base_2(x) = log(x) / log(2) + * NOTE: 1.442695 = 1/log(2). + */ +#define LOG2(x) ((GLfloat) (log(x) * 1.442695F)) +#endif + + +/*** + *** IS_INF_OR_NAN: test if float is infinite or NaN + ***/ +#ifdef USE_IEEE +static INLINE int IS_INF_OR_NAN( float x ) +{ + fi_type tmp; + tmp.f = x; + return !(int)((unsigned int)((tmp.i & 0x7fffffff)-0x7f800000) >> 31); +} +#elif defined(isfinite) +#define IS_INF_OR_NAN(x) (!isfinite(x)) +#elif defined(finite) +#define IS_INF_OR_NAN(x) (!finite(x)) +#elif defined(__VMS) +#define IS_INF_OR_NAN(x) (!finite(x)) +#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L +#define IS_INF_OR_NAN(x) (!isfinite(x)) +#else +#define IS_INF_OR_NAN(x) (!finite(x)) +#endif + + +/*** + *** IS_NEGATIVE: test if float is negative + ***/ +#if defined(USE_IEEE) +static INLINE int GET_FLOAT_BITS( float x ) +{ + fi_type fi; + fi.f = x; + return fi.i; +} +#define IS_NEGATIVE(x) (GET_FLOAT_BITS(x) < 0) +#else +#define IS_NEGATIVE(x) (x < 0.0F) +#endif + + +/*** + *** DIFFERENT_SIGNS: test if two floats have opposite signs + ***/ +#if defined(USE_IEEE) +#define DIFFERENT_SIGNS(x,y) ((GET_FLOAT_BITS(x) ^ GET_FLOAT_BITS(y)) & (1<<31)) +#else +/* Could just use (x*y<0) except for the flatshading requirements. + * Maybe there's a better way? + */ +#define DIFFERENT_SIGNS(x,y) ((x) * (y) <= 0.0F && (x) - (y) != 0.0F) +#endif + + +/*** + *** CEILF: ceiling of float + *** FLOORF: floor of float + *** FABSF: absolute value of float + *** LOGF: the natural logarithm (base e) of the value + *** EXPF: raise e to the value + *** LDEXPF: multiply value by an integral power of two + *** FREXPF: extract mantissa and exponent from value + ***/ +#if defined(__gnu_linux__) +/* C99 functions */ +#define CEILF(x) ceilf(x) +#define FLOORF(x) floorf(x) +#define FABSF(x) fabsf(x) +#define LOGF(x) logf(x) +#define EXPF(x) expf(x) +#define LDEXPF(x,y) ldexpf(x,y) +#define FREXPF(x,y) frexpf(x,y) +#else +#define CEILF(x) ((GLfloat) ceil(x)) +#define FLOORF(x) ((GLfloat) floor(x)) +#define FABSF(x) ((GLfloat) fabs(x)) +#define LOGF(x) ((GLfloat) log(x)) +#define EXPF(x) ((GLfloat) exp(x)) +#define LDEXPF(x,y) ((GLfloat) ldexp(x,y)) +#define FREXPF(x,y) ((GLfloat) frexp(x,y)) +#endif + + +/*** + *** IROUND: return (as an integer) float rounded to nearest integer + ***/ +#if defined(USE_X86_ASM) && defined(__GNUC__) && defined(__i386__) +static INLINE int iround(float f) +{ + int r; + __asm__ ("fistpl %0" : "=m" (r) : "t" (f) : "st"); + return r; +} +#define IROUND(x) iround(x) +#elif defined(USE_X86_ASM) && defined(_MSC_VER) +static INLINE int iround(float f) +{ + int r; + _asm { + fld f + fistp r + } + return r; +} +#define IROUND(x) iround(x) +#elif defined(__WATCOMC__) && defined(__386__) +long iround(float f); +#pragma aux iround = \ + "push eax" \ + "fistp dword ptr [esp]" \ + "pop eax" \ + parm [8087] \ + value [eax] \ + modify exact [eax]; +#define IROUND(x) iround(x) +#else +#define IROUND(f) ((int) (((f) >= 0.0F) ? ((f) + 0.5F) : ((f) - 0.5F))) +#endif + +#define IROUND64(f) ((GLint64) (((f) >= 0.0F) ? ((f) + 0.5F) : ((f) - 0.5F))) + +/*** + *** IROUND_POS: return (as an integer) positive float rounded to nearest int + ***/ +#ifdef DEBUG +#define IROUND_POS(f) (assert((f) >= 0.0F), IROUND(f)) +#else +#define IROUND_POS(f) (IROUND(f)) +#endif + + +/*** + *** IFLOOR: return (as an integer) floor of float + ***/ +#if defined(USE_X86_ASM) && defined(__GNUC__) && defined(__i386__) +/* + * IEEE floor for computers that round to nearest or even. + * 'f' must be between -4194304 and 4194303. + * This floor operation is done by "(iround(f + .5) + iround(f - .5)) >> 1", + * but uses some IEEE specific tricks for better speed. + * Contributed by Josh Vanderhoof + */ +static INLINE int ifloor(float f) +{ + int ai, bi; + double af, bf; + af = (3 << 22) + 0.5 + (double)f; + bf = (3 << 22) + 0.5 - (double)f; + /* GCC generates an extra fstp/fld without this. */ + __asm__ ("fstps %0" : "=m" (ai) : "t" (af) : "st"); + __asm__ ("fstps %0" : "=m" (bi) : "t" (bf) : "st"); + return (ai - bi) >> 1; +} +#define IFLOOR(x) ifloor(x) +#elif defined(USE_IEEE) +static INLINE int ifloor(float f) +{ + int ai, bi; + double af, bf; + fi_type u; + + af = (3 << 22) + 0.5 + (double)f; + bf = (3 << 22) + 0.5 - (double)f; + u.f = (float) af; ai = u.i; + u.f = (float) bf; bi = u.i; + return (ai - bi) >> 1; +} +#define IFLOOR(x) ifloor(x) +#else +static INLINE int ifloor(float f) +{ + int i = IROUND(f); + return (i > f) ? i - 1 : i; +} +#define IFLOOR(x) ifloor(x) +#endif + + +/*** + *** ICEIL: return (as an integer) ceiling of float + ***/ +#if defined(USE_X86_ASM) && defined(__GNUC__) && defined(__i386__) +/* + * IEEE ceil for computers that round to nearest or even. + * 'f' must be between -4194304 and 4194303. + * This ceil operation is done by "(iround(f + .5) + iround(f - .5) + 1) >> 1", + * but uses some IEEE specific tricks for better speed. + * Contributed by Josh Vanderhoof + */ +static INLINE int iceil(float f) +{ + int ai, bi; + double af, bf; + af = (3 << 22) + 0.5 + (double)f; + bf = (3 << 22) + 0.5 - (double)f; + /* GCC generates an extra fstp/fld without this. */ + __asm__ ("fstps %0" : "=m" (ai) : "t" (af) : "st"); + __asm__ ("fstps %0" : "=m" (bi) : "t" (bf) : "st"); + return (ai - bi + 1) >> 1; +} +#define ICEIL(x) iceil(x) +#elif defined(USE_IEEE) +static INLINE int iceil(float f) +{ + int ai, bi; + double af, bf; + fi_type u; + af = (3 << 22) + 0.5 + (double)f; + bf = (3 << 22) + 0.5 - (double)f; + u.f = (float) af; ai = u.i; + u.f = (float) bf; bi = u.i; + return (ai - bi + 1) >> 1; +} +#define ICEIL(x) iceil(x) +#else +static INLINE int iceil(float f) +{ + int i = IROUND(f); + return (i < f) ? i + 1 : i; +} +#define ICEIL(x) iceil(x) +#endif + + +/** + * Is x a power of two? + */ +static INLINE int +_mesa_is_pow_two(int x) +{ + return !(x & (x - 1)); +} + +/** + * Round given integer to next higer power of two + * If X is zero result is undefined. + * + * Source for the fallback implementation is + * Sean Eron Anderson's webpage "Bit Twiddling Hacks" + * http://graphics.stanford.edu/~seander/bithacks.html + * + * When using builtin function have to do some work + * for case when passed values 1 to prevent hiting + * undefined result from __builtin_clz. Undefined + * results would be different depending on optimization + * level used for build. + */ +static INLINE int32_t +_mesa_next_pow_two_32(uint32_t x) +{ +#if defined(__GNUC__) && \ + ((__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || __GNUC__ >= 4) + uint32_t y = (x != 1); + return (1 + y) << ((__builtin_clz(x - y) ^ 31) ); +#else + x--; + x |= x >> 1; + x |= x >> 2; + x |= x >> 4; + x |= x >> 8; + x |= x >> 16; + x++; + return x; +#endif +} + +static INLINE int64_t +_mesa_next_pow_two_64(uint64_t x) +{ +#if defined(__GNUC__) && \ + ((__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || __GNUC__ >= 4) + uint64_t y = (x != 1); + if (sizeof(x) == sizeof(long)) + return (1 + y) << ((__builtin_clzl(x - y) ^ 63)); + else + return (1 + y) << ((__builtin_clzll(x - y) ^ 63)); +#else + x--; + x |= x >> 1; + x |= x >> 2; + x |= x >> 4; + x |= x >> 8; + x |= x >> 16; + x |= x >> 32; + x++; + return x; +#endif +} + + +/* + * Returns the floor form of binary logarithm for a 32-bit integer. + */ +static INLINE GLuint +_mesa_logbase2(GLuint n) +{ +#if defined(__GNUC__) && \ + ((__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || __GNUC__ >= 4) + return (31 - __builtin_clz(n | 1)); +#else + GLuint pos = 0; + if (n >= 1<<16) { n >>= 16; pos += 16; } + if (n >= 1<< 8) { n >>= 8; pos += 8; } + if (n >= 1<< 4) { n >>= 4; pos += 4; } + if (n >= 1<< 2) { n >>= 2; pos += 2; } + if (n >= 1<< 1) { pos += 1; } + return pos; +#endif +} + + +/** + * Return 1 if this is a little endian machine, 0 if big endian. + */ +static INLINE GLboolean +_mesa_little_endian(void) +{ + const GLuint ui = 1; /* intentionally not static */ + return *((const GLubyte *) &ui); +} + + + +/********************************************************************** + * Functions + */ + +extern void * +_mesa_align_malloc( size_t bytes, unsigned long alignment ); + +extern void * +_mesa_align_calloc( size_t bytes, unsigned long alignment ); + +extern void +_mesa_align_free( void *ptr ); + +extern void * +_mesa_align_realloc(void *oldBuffer, size_t oldSize, size_t newSize, + unsigned long alignment); + +extern void * +_mesa_exec_malloc( GLuint size ); + +extern void +_mesa_exec_free( void *addr ); + +extern void * +_mesa_realloc( void *oldBuffer, size_t oldSize, size_t newSize ); + +extern void +_mesa_memset16( unsigned short *dst, unsigned short val, size_t n ); + +extern double +_mesa_sqrtd(double x); + +extern float +_mesa_sqrtf(float x); + +extern float +_mesa_inv_sqrtf(float x); + +extern void +_mesa_init_sqrt_table(void); + +#ifdef __GNUC__ + +#ifdef __MINGW32__ +#define ffs __builtin_ffs +#define ffsll __builtin_ffsll +#endif + +#define _mesa_ffs(i) ffs(i) +#define _mesa_ffsll(i) ffsll(i) + +#if ((_GNUC__ == 3 && __GNUC_MINOR__ >= 4) || __GNUC__ >= 4) +#define _mesa_bitcount(i) __builtin_popcount(i) +#else +extern unsigned int +_mesa_bitcount(unsigned int n); +#endif + +#else +extern int +_mesa_ffs(int32_t i); + +extern int +_mesa_ffsll(int64_t i); + +extern unsigned int +_mesa_bitcount(unsigned int n); +#endif + +extern GLhalfARB +_mesa_float_to_half(float f); + +extern float +_mesa_half_to_float(GLhalfARB h); + + +extern void * +_mesa_bsearch( const void *key, const void *base, size_t nmemb, size_t size, + int (*compar)(const void *, const void *) ); + +extern char * +_mesa_getenv( const char *var ); + +extern char * +_mesa_strdup( const char *s ); + +extern float +_mesa_strtof( const char *s, char **end ); + +extern unsigned int +_mesa_str_checksum(const char *str); + +extern int +_mesa_snprintf( char *str, size_t size, const char *fmt, ... ) PRINTFLIKE(3, 4); + +struct gl_context; + +extern void +_mesa_warning( struct gl_context *gc, const char *fmtString, ... ) PRINTFLIKE(2, 3); + +extern void +_mesa_problem( const struct gl_context *ctx, const char *fmtString, ... ) PRINTFLIKE(2, 3); + +extern void +_mesa_error( struct gl_context *ctx, GLenum error, const char *fmtString, ... ) PRINTFLIKE(3, 4); + +extern void +_mesa_debug( const struct gl_context *ctx, const char *fmtString, ... ) PRINTFLIKE(2, 3); + + +#if defined(_MSC_VER) && !defined(snprintf) +#define snprintf _snprintf +#endif + + +#ifdef __cplusplus +} +#endif + + +#endif /* IMPORTS_H */ diff --git a/3rdparty/glsl-optimizer/src/mesa/main/macros.h b/3rdparty/glsl-optimizer/src/mesa/main/macros.h new file mode 100644 index 000000000..01e4d20af --- /dev/null +++ b/3rdparty/glsl-optimizer/src/mesa/main/macros.h @@ -0,0 +1,725 @@ +/** + * \file macros.h + * A collection of useful macros. + */ + +/* + * Mesa 3-D graphics library + * Version: 6.5.2 + * + * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#ifndef MACROS_H +#define MACROS_H + +#include "imports.h" + + +/** + * \name Integer / float conversion for colors, normals, etc. + */ +/*@{*/ + +/** Convert GLubyte in [0,255] to GLfloat in [0.0,1.0] */ +extern GLfloat _mesa_ubyte_to_float_color_tab[256]; +#define UBYTE_TO_FLOAT(u) _mesa_ubyte_to_float_color_tab[(unsigned int)(u)] + +/** Convert GLfloat in [0.0,1.0] to GLubyte in [0,255] */ +#define FLOAT_TO_UBYTE(X) ((GLubyte) (GLint) ((X) * 255.0F)) + + +/** Convert GLbyte in [-128,127] to GLfloat in [-1.0,1.0] */ +#define BYTE_TO_FLOAT(B) ((2.0F * (B) + 1.0F) * (1.0F/255.0F)) + +/** Convert GLfloat in [-1.0,1.0] to GLbyte in [-128,127] */ +#define FLOAT_TO_BYTE(X) ( (((GLint) (255.0F * (X))) - 1) / 2 ) + + +/** Convert GLbyte in [-128,127] to GLfloat in [-1.0,1.0], texture/fb data */ +#define BYTE_TO_FLOAT_TEX(B) ((B) == -128 ? -1.0F : (B) * (1.0F/127.0F)) + +/** Convert GLfloat in [-1.0,1.0] to GLbyte in [-128,127], texture/fb data */ +#define FLOAT_TO_BYTE_TEX(X) CLAMP( (GLint) (127.0F * (X)), -128, 127 ) + +/** Convert GLushort in [0,65535] to GLfloat in [0.0,1.0] */ +#define USHORT_TO_FLOAT(S) ((GLfloat) (S) * (1.0F / 65535.0F)) + +/** Convert GLfloat in [0.0,1.0] to GLushort in [0, 65535] */ +#define FLOAT_TO_USHORT(X) ((GLuint) ((X) * 65535.0F)) + + +/** Convert GLshort in [-32768,32767] to GLfloat in [-1.0,1.0] */ +#define SHORT_TO_FLOAT(S) ((2.0F * (S) + 1.0F) * (1.0F/65535.0F)) + +/** Convert GLfloat in [-1.0,1.0] to GLshort in [-32768,32767] */ +#define FLOAT_TO_SHORT(X) ( (((GLint) (65535.0F * (X))) - 1) / 2 ) + + +/** Convert GLshort in [-32768,32767] to GLfloat in [-1.0,1.0], texture/fb data */ +#define SHORT_TO_FLOAT_TEX(S) ((S) == -32768 ? -1.0F : (S) * (1.0F/32767.0F)) + +/** Convert GLfloat in [-1.0,1.0] to GLshort in [-32768,32767], texture/fb data */ +#define FLOAT_TO_SHORT_TEX(X) ( (GLint) (32767.0F * (X)) ) + + +/** Convert GLuint in [0,4294967295] to GLfloat in [0.0,1.0] */ +#define UINT_TO_FLOAT(U) ((GLfloat) ((U) * (1.0F / 4294967295.0))) + +/** Convert GLfloat in [0.0,1.0] to GLuint in [0,4294967295] */ +#define FLOAT_TO_UINT(X) ((GLuint) ((X) * 4294967295.0)) + + +/** Convert GLint in [-2147483648,2147483647] to GLfloat in [-1.0,1.0] */ +#define INT_TO_FLOAT(I) ((GLfloat) ((2.0F * (I) + 1.0F) * (1.0F/4294967294.0))) + +/** Convert GLfloat in [-1.0,1.0] to GLint in [-2147483648,2147483647] */ +/* causes overflow: +#define FLOAT_TO_INT(X) ( (((GLint) (4294967294.0 * (X))) - 1) / 2 ) +*/ +/* a close approximation: */ +#define FLOAT_TO_INT(X) ( (GLint) (2147483647.0 * (X)) ) + +/** Convert GLfloat in [-1.0,1.0] to GLint64 in [-(1<<63),(1 << 63) -1] */ +#define FLOAT_TO_INT64(X) ( (GLint64) (9223372036854775807.0 * (double)(X)) ) + + +/** Convert GLint in [-2147483648,2147483647] to GLfloat in [-1.0,1.0], texture/fb data */ +#define INT_TO_FLOAT_TEX(I) ((I) == -2147483648 ? -1.0F : (I) * (1.0F/2147483647.0)) + +/** Convert GLfloat in [-1.0,1.0] to GLint in [-2147483648,2147483647], texture/fb data */ +#define FLOAT_TO_INT_TEX(X) ( (GLint) (2147483647.0 * (X)) ) + + +#define BYTE_TO_UBYTE(b) ((GLubyte) ((b) < 0 ? 0 : (GLubyte) (b))) +#define SHORT_TO_UBYTE(s) ((GLubyte) ((s) < 0 ? 0 : (GLubyte) ((s) >> 7))) +#define USHORT_TO_UBYTE(s) ((GLubyte) ((s) >> 8)) +#define INT_TO_UBYTE(i) ((GLubyte) ((i) < 0 ? 0 : (GLubyte) ((i) >> 23))) +#define UINT_TO_UBYTE(i) ((GLubyte) ((i) >> 24)) + + +#define BYTE_TO_USHORT(b) ((b) < 0 ? 0 : ((GLushort) (((b) * 65535) / 255))) +#define UBYTE_TO_USHORT(b) (((GLushort) (b) << 8) | (GLushort) (b)) +#define SHORT_TO_USHORT(s) ((s) < 0 ? 0 : ((GLushort) (((s) * 65535 / 32767)))) +#define INT_TO_USHORT(i) ((i) < 0 ? 0 : ((GLushort) ((i) >> 15))) +#define UINT_TO_USHORT(i) ((i) < 0 ? 0 : ((GLushort) ((i) >> 16))) +#define UNCLAMPED_FLOAT_TO_USHORT(us, f) \ + us = ( (GLushort) IROUND( CLAMP((f), 0.0F, 1.0F) * 65535.0F) ) +#define CLAMPED_FLOAT_TO_USHORT(us, f) \ + us = ( (GLushort) IROUND( (f) * 65535.0F) ) + +#define UNCLAMPED_FLOAT_TO_SHORT(s, f) \ + s = ( (GLshort) IROUND( CLAMP((f), -1.0F, 1.0F) * 32767.0F) ) + +/*** + *** UNCLAMPED_FLOAT_TO_UBYTE: clamp float to [0,1] and map to ubyte in [0,255] + *** CLAMPED_FLOAT_TO_UBYTE: map float known to be in [0,1] to ubyte in [0,255] + ***/ +#if defined(USE_IEEE) && !defined(DEBUG) +#define IEEE_0996 0x3f7f0000 /* 0.996 or so */ +/* This function/macro is sensitive to precision. Test very carefully + * if you change it! + */ +#define UNCLAMPED_FLOAT_TO_UBYTE(UB, F) \ + do { \ + fi_type __tmp; \ + __tmp.f = (F); \ + if (__tmp.i < 0) \ + UB = (GLubyte) 0; \ + else if (__tmp.i >= IEEE_0996) \ + UB = (GLubyte) 255; \ + else { \ + __tmp.f = __tmp.f * (255.0F/256.0F) + 32768.0F; \ + UB = (GLubyte) __tmp.i; \ + } \ + } while (0) +#define CLAMPED_FLOAT_TO_UBYTE(UB, F) \ + do { \ + fi_type __tmp; \ + __tmp.f = (F) * (255.0F/256.0F) + 32768.0F; \ + UB = (GLubyte) __tmp.i; \ + } while (0) +#else +#define UNCLAMPED_FLOAT_TO_UBYTE(ub, f) \ + ub = ((GLubyte) IROUND(CLAMP((f), 0.0F, 1.0F) * 255.0F)) +#define CLAMPED_FLOAT_TO_UBYTE(ub, f) \ + ub = ((GLubyte) IROUND((f) * 255.0F)) +#endif + +/*@}*/ + + +/** Stepping a GLfloat pointer by a byte stride */ +#define STRIDE_F(p, i) (p = (GLfloat *)((GLubyte *)p + i)) +/** Stepping a GLuint pointer by a byte stride */ +#define STRIDE_UI(p, i) (p = (GLuint *)((GLubyte *)p + i)) +/** Stepping a GLubyte[4] pointer by a byte stride */ +#define STRIDE_4UB(p, i) (p = (GLubyte (*)[4])((GLubyte *)p + i)) +/** Stepping a GLfloat[4] pointer by a byte stride */ +#define STRIDE_4F(p, i) (p = (GLfloat (*)[4])((GLubyte *)p + i)) +/** Stepping a GLchan[4] pointer by a byte stride */ +#define STRIDE_4CHAN(p, i) (p = (GLchan (*)[4])((GLubyte *)p + i)) +/** Stepping a GLchan pointer by a byte stride */ +#define STRIDE_CHAN(p, i) (p = (GLchan *)((GLubyte *)p + i)) +/** Stepping a \p t pointer by a byte stride */ +#define STRIDE_T(p, t, i) (p = (t)((GLubyte *)p + i)) + + +/**********************************************************************/ +/** \name 4-element vector operations */ +/*@{*/ + +/** Zero */ +#define ZERO_4V( DST ) (DST)[0] = (DST)[1] = (DST)[2] = (DST)[3] = 0 + +/** Test for equality */ +#define TEST_EQ_4V(a,b) ((a)[0] == (b)[0] && \ + (a)[1] == (b)[1] && \ + (a)[2] == (b)[2] && \ + (a)[3] == (b)[3]) + +/** Test for equality (unsigned bytes) */ +#if defined(__i386__) +#define TEST_EQ_4UBV(DST, SRC) *((GLuint*)(DST)) == *((GLuint*)(SRC)) +#else +#define TEST_EQ_4UBV(DST, SRC) TEST_EQ_4V(DST, SRC) +#endif + +/** Copy a 4-element vector */ +#define COPY_4V( DST, SRC ) \ +do { \ + (DST)[0] = (SRC)[0]; \ + (DST)[1] = (SRC)[1]; \ + (DST)[2] = (SRC)[2]; \ + (DST)[3] = (SRC)[3]; \ +} while (0) + +/** Copy a 4-element vector with cast */ +#define COPY_4V_CAST( DST, SRC, CAST ) \ +do { \ + (DST)[0] = (CAST)(SRC)[0]; \ + (DST)[1] = (CAST)(SRC)[1]; \ + (DST)[2] = (CAST)(SRC)[2]; \ + (DST)[3] = (CAST)(SRC)[3]; \ +} while (0) + +/** Copy a 4-element unsigned byte vector */ +#if defined(__i386__) +#define COPY_4UBV(DST, SRC) \ +do { \ + *((GLuint*)(DST)) = *((GLuint*)(SRC)); \ +} while (0) +#else +/* The GLuint cast might fail if DST or SRC are not dword-aligned (RISC) */ +#define COPY_4UBV(DST, SRC) \ +do { \ + (DST)[0] = (SRC)[0]; \ + (DST)[1] = (SRC)[1]; \ + (DST)[2] = (SRC)[2]; \ + (DST)[3] = (SRC)[3]; \ +} while (0) +#endif + +/** + * Copy a 4-element float vector + * memcpy seems to be most efficient + */ +#define COPY_4FV( DST, SRC ) \ +do { \ + memcpy(DST, SRC, sizeof(GLfloat) * 4); \ +} while (0) + +/** Copy \p SZ elements into a 4-element vector */ +#define COPY_SZ_4V(DST, SZ, SRC) \ +do { \ + switch (SZ) { \ + case 4: (DST)[3] = (SRC)[3]; \ + case 3: (DST)[2] = (SRC)[2]; \ + case 2: (DST)[1] = (SRC)[1]; \ + case 1: (DST)[0] = (SRC)[0]; \ + } \ +} while(0) + +/** Copy \p SZ elements into a homegeneous (4-element) vector, giving + * default values to the remaining */ +#define COPY_CLEAN_4V(DST, SZ, SRC) \ +do { \ + ASSIGN_4V( DST, 0, 0, 0, 1 ); \ + COPY_SZ_4V( DST, SZ, SRC ); \ +} while (0) + +/** Subtraction */ +#define SUB_4V( DST, SRCA, SRCB ) \ +do { \ + (DST)[0] = (SRCA)[0] - (SRCB)[0]; \ + (DST)[1] = (SRCA)[1] - (SRCB)[1]; \ + (DST)[2] = (SRCA)[2] - (SRCB)[2]; \ + (DST)[3] = (SRCA)[3] - (SRCB)[3]; \ +} while (0) + +/** Addition */ +#define ADD_4V( DST, SRCA, SRCB ) \ +do { \ + (DST)[0] = (SRCA)[0] + (SRCB)[0]; \ + (DST)[1] = (SRCA)[1] + (SRCB)[1]; \ + (DST)[2] = (SRCA)[2] + (SRCB)[2]; \ + (DST)[3] = (SRCA)[3] + (SRCB)[3]; \ +} while (0) + +/** Element-wise multiplication */ +#define SCALE_4V( DST, SRCA, SRCB ) \ +do { \ + (DST)[0] = (SRCA)[0] * (SRCB)[0]; \ + (DST)[1] = (SRCA)[1] * (SRCB)[1]; \ + (DST)[2] = (SRCA)[2] * (SRCB)[2]; \ + (DST)[3] = (SRCA)[3] * (SRCB)[3]; \ +} while (0) + +/** In-place addition */ +#define ACC_4V( DST, SRC ) \ +do { \ + (DST)[0] += (SRC)[0]; \ + (DST)[1] += (SRC)[1]; \ + (DST)[2] += (SRC)[2]; \ + (DST)[3] += (SRC)[3]; \ +} while (0) + +/** Element-wise multiplication and addition */ +#define ACC_SCALE_4V( DST, SRCA, SRCB ) \ +do { \ + (DST)[0] += (SRCA)[0] * (SRCB)[0]; \ + (DST)[1] += (SRCA)[1] * (SRCB)[1]; \ + (DST)[2] += (SRCA)[2] * (SRCB)[2]; \ + (DST)[3] += (SRCA)[3] * (SRCB)[3]; \ +} while (0) + +/** In-place scalar multiplication and addition */ +#define ACC_SCALE_SCALAR_4V( DST, S, SRCB ) \ +do { \ + (DST)[0] += S * (SRCB)[0]; \ + (DST)[1] += S * (SRCB)[1]; \ + (DST)[2] += S * (SRCB)[2]; \ + (DST)[3] += S * (SRCB)[3]; \ +} while (0) + +/** Scalar multiplication */ +#define SCALE_SCALAR_4V( DST, S, SRCB ) \ +do { \ + (DST)[0] = S * (SRCB)[0]; \ + (DST)[1] = S * (SRCB)[1]; \ + (DST)[2] = S * (SRCB)[2]; \ + (DST)[3] = S * (SRCB)[3]; \ +} while (0) + +/** In-place scalar multiplication */ +#define SELF_SCALE_SCALAR_4V( DST, S ) \ +do { \ + (DST)[0] *= S; \ + (DST)[1] *= S; \ + (DST)[2] *= S; \ + (DST)[3] *= S; \ +} while (0) + +/** Assignment */ +#define ASSIGN_4V( V, V0, V1, V2, V3 ) \ +do { \ + V[0] = V0; \ + V[1] = V1; \ + V[2] = V2; \ + V[3] = V3; \ +} while(0) + +/*@}*/ + + +/**********************************************************************/ +/** \name 3-element vector operations*/ +/*@{*/ + +/** Zero */ +#define ZERO_3V( DST ) (DST)[0] = (DST)[1] = (DST)[2] = 0 + +/** Test for equality */ +#define TEST_EQ_3V(a,b) \ + ((a)[0] == (b)[0] && \ + (a)[1] == (b)[1] && \ + (a)[2] == (b)[2]) + +/** Copy a 3-element vector */ +#define COPY_3V( DST, SRC ) \ +do { \ + (DST)[0] = (SRC)[0]; \ + (DST)[1] = (SRC)[1]; \ + (DST)[2] = (SRC)[2]; \ +} while (0) + +/** Copy a 3-element vector with cast */ +#define COPY_3V_CAST( DST, SRC, CAST ) \ +do { \ + (DST)[0] = (CAST)(SRC)[0]; \ + (DST)[1] = (CAST)(SRC)[1]; \ + (DST)[2] = (CAST)(SRC)[2]; \ +} while (0) + +/** Copy a 3-element float vector */ +#define COPY_3FV( DST, SRC ) \ +do { \ + const GLfloat *_tmp = (SRC); \ + (DST)[0] = _tmp[0]; \ + (DST)[1] = _tmp[1]; \ + (DST)[2] = _tmp[2]; \ +} while (0) + +/** Subtraction */ +#define SUB_3V( DST, SRCA, SRCB ) \ +do { \ + (DST)[0] = (SRCA)[0] - (SRCB)[0]; \ + (DST)[1] = (SRCA)[1] - (SRCB)[1]; \ + (DST)[2] = (SRCA)[2] - (SRCB)[2]; \ +} while (0) + +/** Addition */ +#define ADD_3V( DST, SRCA, SRCB ) \ +do { \ + (DST)[0] = (SRCA)[0] + (SRCB)[0]; \ + (DST)[1] = (SRCA)[1] + (SRCB)[1]; \ + (DST)[2] = (SRCA)[2] + (SRCB)[2]; \ +} while (0) + +/** In-place scalar multiplication */ +#define SCALE_3V( DST, SRCA, SRCB ) \ +do { \ + (DST)[0] = (SRCA)[0] * (SRCB)[0]; \ + (DST)[1] = (SRCA)[1] * (SRCB)[1]; \ + (DST)[2] = (SRCA)[2] * (SRCB)[2]; \ +} while (0) + +/** In-place element-wise multiplication */ +#define SELF_SCALE_3V( DST, SRC ) \ +do { \ + (DST)[0] *= (SRC)[0]; \ + (DST)[1] *= (SRC)[1]; \ + (DST)[2] *= (SRC)[2]; \ +} while (0) + +/** In-place addition */ +#define ACC_3V( DST, SRC ) \ +do { \ + (DST)[0] += (SRC)[0]; \ + (DST)[1] += (SRC)[1]; \ + (DST)[2] += (SRC)[2]; \ +} while (0) + +/** Element-wise multiplication and addition */ +#define ACC_SCALE_3V( DST, SRCA, SRCB ) \ +do { \ + (DST)[0] += (SRCA)[0] * (SRCB)[0]; \ + (DST)[1] += (SRCA)[1] * (SRCB)[1]; \ + (DST)[2] += (SRCA)[2] * (SRCB)[2]; \ +} while (0) + +/** Scalar multiplication */ +#define SCALE_SCALAR_3V( DST, S, SRCB ) \ +do { \ + (DST)[0] = S * (SRCB)[0]; \ + (DST)[1] = S * (SRCB)[1]; \ + (DST)[2] = S * (SRCB)[2]; \ +} while (0) + +/** In-place scalar multiplication and addition */ +#define ACC_SCALE_SCALAR_3V( DST, S, SRCB ) \ +do { \ + (DST)[0] += S * (SRCB)[0]; \ + (DST)[1] += S * (SRCB)[1]; \ + (DST)[2] += S * (SRCB)[2]; \ +} while (0) + +/** In-place scalar multiplication */ +#define SELF_SCALE_SCALAR_3V( DST, S ) \ +do { \ + (DST)[0] *= S; \ + (DST)[1] *= S; \ + (DST)[2] *= S; \ +} while (0) + +/** In-place scalar addition */ +#define ACC_SCALAR_3V( DST, S ) \ +do { \ + (DST)[0] += S; \ + (DST)[1] += S; \ + (DST)[2] += S; \ +} while (0) + +/** Assignment */ +#define ASSIGN_3V( V, V0, V1, V2 ) \ +do { \ + V[0] = V0; \ + V[1] = V1; \ + V[2] = V2; \ +} while(0) + +/*@}*/ + + +/**********************************************************************/ +/** \name 2-element vector operations*/ +/*@{*/ + +/** Zero */ +#define ZERO_2V( DST ) (DST)[0] = (DST)[1] = 0 + +/** Copy a 2-element vector */ +#define COPY_2V( DST, SRC ) \ +do { \ + (DST)[0] = (SRC)[0]; \ + (DST)[1] = (SRC)[1]; \ +} while (0) + +/** Copy a 2-element vector with cast */ +#define COPY_2V_CAST( DST, SRC, CAST ) \ +do { \ + (DST)[0] = (CAST)(SRC)[0]; \ + (DST)[1] = (CAST)(SRC)[1]; \ +} while (0) + +/** Copy a 2-element float vector */ +#define COPY_2FV( DST, SRC ) \ +do { \ + const GLfloat *_tmp = (SRC); \ + (DST)[0] = _tmp[0]; \ + (DST)[1] = _tmp[1]; \ +} while (0) + +/** Subtraction */ +#define SUB_2V( DST, SRCA, SRCB ) \ +do { \ + (DST)[0] = (SRCA)[0] - (SRCB)[0]; \ + (DST)[1] = (SRCA)[1] - (SRCB)[1]; \ +} while (0) + +/** Addition */ +#define ADD_2V( DST, SRCA, SRCB ) \ +do { \ + (DST)[0] = (SRCA)[0] + (SRCB)[0]; \ + (DST)[1] = (SRCA)[1] + (SRCB)[1]; \ +} while (0) + +/** In-place scalar multiplication */ +#define SCALE_2V( DST, SRCA, SRCB ) \ +do { \ + (DST)[0] = (SRCA)[0] * (SRCB)[0]; \ + (DST)[1] = (SRCA)[1] * (SRCB)[1]; \ +} while (0) + +/** In-place addition */ +#define ACC_2V( DST, SRC ) \ +do { \ + (DST)[0] += (SRC)[0]; \ + (DST)[1] += (SRC)[1]; \ +} while (0) + +/** Element-wise multiplication and addition */ +#define ACC_SCALE_2V( DST, SRCA, SRCB ) \ +do { \ + (DST)[0] += (SRCA)[0] * (SRCB)[0]; \ + (DST)[1] += (SRCA)[1] * (SRCB)[1]; \ +} while (0) + +/** Scalar multiplication */ +#define SCALE_SCALAR_2V( DST, S, SRCB ) \ +do { \ + (DST)[0] = S * (SRCB)[0]; \ + (DST)[1] = S * (SRCB)[1]; \ +} while (0) + +/** In-place scalar multiplication and addition */ +#define ACC_SCALE_SCALAR_2V( DST, S, SRCB ) \ +do { \ + (DST)[0] += S * (SRCB)[0]; \ + (DST)[1] += S * (SRCB)[1]; \ +} while (0) + +/** In-place scalar multiplication */ +#define SELF_SCALE_SCALAR_2V( DST, S ) \ +do { \ + (DST)[0] *= S; \ + (DST)[1] *= S; \ +} while (0) + +/** In-place scalar addition */ +#define ACC_SCALAR_2V( DST, S ) \ +do { \ + (DST)[0] += S; \ + (DST)[1] += S; \ +} while (0) + +/** Assign scalers to short vectors */ +#define ASSIGN_2V( V, V0, V1 ) \ +do { \ + V[0] = V0; \ + V[1] = V1; \ +} while(0) + +/*@}*/ + + +/** \name Linear interpolation macros */ +/*@{*/ + +/** + * Linear interpolation + * + * \note \p OUT argument is evaluated twice! + * \note Be wary of using *coord++ as an argument to any of these macros! + */ +#define LINTERP(T, OUT, IN) ((OUT) + (T) * ((IN) - (OUT))) + +/* Can do better with integer math + */ +#define INTERP_UB( t, dstub, outub, inub ) \ +do { \ + GLfloat inf = UBYTE_TO_FLOAT( inub ); \ + GLfloat outf = UBYTE_TO_FLOAT( outub ); \ + GLfloat dstf = LINTERP( t, outf, inf ); \ + UNCLAMPED_FLOAT_TO_UBYTE( dstub, dstf ); \ +} while (0) + +#define INTERP_CHAN( t, dstc, outc, inc ) \ +do { \ + GLfloat inf = CHAN_TO_FLOAT( inc ); \ + GLfloat outf = CHAN_TO_FLOAT( outc ); \ + GLfloat dstf = LINTERP( t, outf, inf ); \ + UNCLAMPED_FLOAT_TO_CHAN( dstc, dstf ); \ +} while (0) + +#define INTERP_UI( t, dstui, outui, inui ) \ + dstui = (GLuint) (GLint) LINTERP( (t), (GLfloat) (outui), (GLfloat) (inui) ) + +#define INTERP_F( t, dstf, outf, inf ) \ + dstf = LINTERP( t, outf, inf ) + +#define INTERP_4F( t, dst, out, in ) \ +do { \ + dst[0] = LINTERP( (t), (out)[0], (in)[0] ); \ + dst[1] = LINTERP( (t), (out)[1], (in)[1] ); \ + dst[2] = LINTERP( (t), (out)[2], (in)[2] ); \ + dst[3] = LINTERP( (t), (out)[3], (in)[3] ); \ +} while (0) + +#define INTERP_3F( t, dst, out, in ) \ +do { \ + dst[0] = LINTERP( (t), (out)[0], (in)[0] ); \ + dst[1] = LINTERP( (t), (out)[1], (in)[1] ); \ + dst[2] = LINTERP( (t), (out)[2], (in)[2] ); \ +} while (0) + +#define INTERP_4CHAN( t, dst, out, in ) \ +do { \ + INTERP_CHAN( (t), (dst)[0], (out)[0], (in)[0] ); \ + INTERP_CHAN( (t), (dst)[1], (out)[1], (in)[1] ); \ + INTERP_CHAN( (t), (dst)[2], (out)[2], (in)[2] ); \ + INTERP_CHAN( (t), (dst)[3], (out)[3], (in)[3] ); \ +} while (0) + +#define INTERP_3CHAN( t, dst, out, in ) \ +do { \ + INTERP_CHAN( (t), (dst)[0], (out)[0], (in)[0] ); \ + INTERP_CHAN( (t), (dst)[1], (out)[1], (in)[1] ); \ + INTERP_CHAN( (t), (dst)[2], (out)[2], (in)[2] ); \ +} while (0) + +#define INTERP_SZ( t, vec, to, out, in, sz ) \ +do { \ + switch (sz) { \ + case 4: vec[to][3] = LINTERP( (t), (vec)[out][3], (vec)[in][3] ); \ + case 3: vec[to][2] = LINTERP( (t), (vec)[out][2], (vec)[in][2] ); \ + case 2: vec[to][1] = LINTERP( (t), (vec)[out][1], (vec)[in][1] ); \ + case 1: vec[to][0] = LINTERP( (t), (vec)[out][0], (vec)[in][0] ); \ + } \ +} while(0) + +/*@}*/ + + + +/** Clamp X to [MIN,MAX] */ +#define CLAMP( X, MIN, MAX ) ( (X)<(MIN) ? (MIN) : ((X)>(MAX) ? (MAX) : (X)) ) + +/** Minimum of two values: */ +#define MIN2( A, B ) ( (A)<(B) ? (A) : (B) ) + +/** Maximum of two values: */ +#define MAX2( A, B ) ( (A)>(B) ? (A) : (B) ) + +/** Minimum and maximum of three values: */ +#define MIN3( A, B, C ) ((A) < (B) ? MIN2(A, C) : MIN2(B, C)) +#define MAX3( A, B, C ) ((A) > (B) ? MAX2(A, C) : MAX2(B, C)) + +/** Dot product of two 2-element vectors */ +#define DOT2( a, b ) ( (a)[0]*(b)[0] + (a)[1]*(b)[1] ) + +/** Dot product of two 3-element vectors */ +#define DOT3( a, b ) ( (a)[0]*(b)[0] + (a)[1]*(b)[1] + (a)[2]*(b)[2] ) + +/** Dot product of two 4-element vectors */ +#define DOT4( a, b ) ( (a)[0]*(b)[0] + (a)[1]*(b)[1] + \ + (a)[2]*(b)[2] + (a)[3]*(b)[3] ) + +/** Dot product of two 4-element vectors */ +#define DOT4V(v,a,b,c,d) (v[0]*(a) + v[1]*(b) + v[2]*(c) + v[3]*(d)) + + +/** Cross product of two 3-element vectors */ +#define CROSS3(n, u, v) \ +do { \ + (n)[0] = (u)[1]*(v)[2] - (u)[2]*(v)[1]; \ + (n)[1] = (u)[2]*(v)[0] - (u)[0]*(v)[2]; \ + (n)[2] = (u)[0]*(v)[1] - (u)[1]*(v)[0]; \ +} while (0) + + +/* Normalize a 3-element vector to unit length. */ +#define NORMALIZE_3FV( V ) \ +do { \ + GLfloat len = (GLfloat) LEN_SQUARED_3FV(V); \ + if (len) { \ + len = INV_SQRTF(len); \ + (V)[0] = (GLfloat) ((V)[0] * len); \ + (V)[1] = (GLfloat) ((V)[1] * len); \ + (V)[2] = (GLfloat) ((V)[2] * len); \ + } \ +} while(0) + +#define LEN_3FV( V ) (SQRTF((V)[0]*(V)[0]+(V)[1]*(V)[1]+(V)[2]*(V)[2])) +#define LEN_2FV( V ) (SQRTF((V)[0]*(V)[0]+(V)[1]*(V)[1])) + +#define LEN_SQUARED_3FV( V ) ((V)[0]*(V)[0]+(V)[1]*(V)[1]+(V)[2]*(V)[2]) +#define LEN_SQUARED_2FV( V ) ((V)[0]*(V)[0]+(V)[1]*(V)[1]) + + +/** casts to silence warnings with some compilers */ +#define ENUM_TO_INT(E) ((GLint)(E)) +#define ENUM_TO_FLOAT(E) ((GLfloat)(GLint)(E)) +#define ENUM_TO_DOUBLE(E) ((GLdouble)(GLint)(E)) +#define ENUM_TO_BOOLEAN(E) ((E) ? GL_TRUE : GL_FALSE) + + +#endif diff --git a/3rdparty/glsl-optimizer/src/mesa/main/mfeatures.h b/3rdparty/glsl-optimizer/src/mesa/main/mfeatures.h new file mode 100644 index 000000000..33db50814 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/mesa/main/mfeatures.h @@ -0,0 +1,146 @@ +/* + * Mesa 3-D graphics library + * Version: 7.1 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +/** + * \file mfeatures.h + * Flags to enable/disable specific parts of the API. + */ + +#ifndef FEATURES_H +#define FEATURES_H + + +#ifndef _HAVE_FULL_GL +#define _HAVE_FULL_GL 1 +#endif + +/* assert that a feature is disabled and should never be used */ +#define ASSERT_NO_FEATURE() ASSERT(0) + +/** + * A feature can be anything. But most of them share certain characteristics. + * + * When a feature defines vtxfmt entries, they can be initialized and + * installed by + * _MESA_INIT__VTXFMT + * _mesa_install__vtxfmt + * + * When a feature defines dispatch entries, they are initialized by + * _mesa_init__dispatch + * + * When a feature has states, they are initialized and freed by + * _mesa_init_ + * _mesa_free__data + * + * Except for states, the others compile to no-op when a feature is disabled. + * + * The GLAPIENTRYs and helper functions defined by a feature should also + * compile to no-op when it is disabled. But to save typings and to catch + * bugs, some of them may be unavailable, or compile to ASSERT_NO_FEATURE() + * when the feature is disabled. + * + * A feature following the conventions may be used without knowing if it is + * enabled or not. + */ + +#ifndef FEATURE_ES1 +#define FEATURE_ES1 0 +#endif +#ifndef FEATURE_ES2 +#define FEATURE_ES2 0 +#endif + +#define FEATURE_ES (FEATURE_ES1 || FEATURE_ES2) + +#ifndef FEATURE_GL +#define FEATURE_GL !FEATURE_ES +#endif + +#if defined(IN_DRI_DRIVER) || (FEATURE_GL + FEATURE_ES1 + FEATURE_ES2 > 1) +#define FEATURE_remap_table 1 +#else +#define FEATURE_remap_table 0 +#endif + +#define FEATURE_dispatch 1 +#define FEATURE_texgen 1 +#define FEATURE_userclip 1 + +#define FEATURE_accum FEATURE_GL +#define FEATURE_arrayelt FEATURE_GL +#define FEATURE_attrib_stack FEATURE_GL +/* this disables vtxfmt, api_loopback, and api_noop completely */ +#define FEATURE_beginend FEATURE_GL +#define FEATURE_colortable FEATURE_GL +#define FEATURE_convolve FEATURE_GL +#define FEATURE_dlist (FEATURE_GL && FEATURE_arrayelt && FEATURE_beginend) +#define FEATURE_draw_read_buffer FEATURE_GL +#define FEATURE_drawpix FEATURE_GL +#define FEATURE_evaluators FEATURE_GL +#define FEATURE_feedback FEATURE_GL +#define FEATURE_pixel_transfer FEATURE_GL +#define FEATURE_queryobj FEATURE_GL +#define FEATURE_rastpos FEATURE_GL +#define FEATURE_texture_fxt1 FEATURE_GL +#define FEATURE_texture_s3tc FEATURE_GL + +#define FEATURE_extra_context_init FEATURE_ES +#define FEATURE_point_size_array FEATURE_ES + +#define FEATURE_es2_glsl FEATURE_ES2 + +#define FEATURE_ARB_fragment_program 1 +#define FEATURE_ARB_vertex_program 1 +#define FEATURE_ARB_vertex_shader 1 +#define FEATURE_ARB_fragment_shader 1 +#define FEATURE_ARB_shader_objects (FEATURE_ARB_vertex_shader || FEATURE_ARB_fragment_shader) +#define FEATURE_ARB_shading_language_100 FEATURE_ARB_shader_objects +#define FEATURE_ARB_geometry_shader4 FEATURE_ARB_shader_objects + +#define FEATURE_ARB_framebuffer_object (FEATURE_GL && FEATURE_EXT_framebuffer_object) +#define FEATURE_ARB_map_buffer_range FEATURE_GL +#define FEATURE_ARB_pixel_buffer_object (FEATURE_GL && FEATURE_EXT_pixel_buffer_object) +#define FEATURE_ARB_sampler_objects FEATURE_GL +#define FEATURE_ARB_sync FEATURE_GL +#define FEATURE_ARB_vertex_buffer_object 1 + +#define FEATURE_EXT_framebuffer_blit FEATURE_GL +#define FEATURE_EXT_framebuffer_object 1 +#define FEATURE_EXT_pixel_buffer_object 1 +#define FEATURE_EXT_texture_sRGB FEATURE_GL +#define FEATURE_EXT_transform_feedback FEATURE_GL + +#define FEATURE_APPLE_object_purgeable FEATURE_GL +#define FEATURE_ATI_fragment_shader FEATURE_GL +#define FEATURE_NV_fence FEATURE_GL +#define FEATURE_NV_fragment_program FEATURE_GL +#define FEATURE_NV_vertex_program FEATURE_GL + +#define FEATURE_OES_EGL_image 1 +#define FEATURE_OES_draw_texture FEATURE_ES1 +#define FEATURE_OES_framebuffer_object FEATURE_ES +#define FEATURE_OES_mapbuffer FEATURE_ES + +#endif /* FEATURES_H */ diff --git a/3rdparty/glsl-optimizer/src/mesa/main/mtypes.h b/3rdparty/glsl-optimizer/src/mesa/main/mtypes.h new file mode 100644 index 000000000..2d5f44c1e --- /dev/null +++ b/3rdparty/glsl-optimizer/src/mesa/main/mtypes.h @@ -0,0 +1,3421 @@ +/* + * Mesa 3-D graphics library + * Version: 7.7 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (C) 2009 VMware, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/** + * \file mtypes.h + * Main Mesa data structures. + * + * Please try to mark derived values with a leading underscore ('_'). + */ + +#ifndef MTYPES_H +#define MTYPES_H + + +#include "main/glheader.h" +#include "main/config.h" +#include "main/mfeatures.h" +#include "glapi/glapi.h" +#include "math/m_matrix.h" /* GLmatrix */ +#include "main/simple_list.h" /* struct simple_node */ +#include "main/formats.h" /* MESA_FORMAT_COUNT */ + + +/** + * Color channel data type. + */ +#if CHAN_BITS == 8 + typedef GLubyte GLchan; +#define CHAN_MAX 255 +#define CHAN_MAXF 255.0F +#define CHAN_TYPE GL_UNSIGNED_BYTE +#elif CHAN_BITS == 16 + typedef GLushort GLchan; +#define CHAN_MAX 65535 +#define CHAN_MAXF 65535.0F +#define CHAN_TYPE GL_UNSIGNED_SHORT +#elif CHAN_BITS == 32 + typedef GLfloat GLchan; +#define CHAN_MAX 1.0 +#define CHAN_MAXF 1.0F +#define CHAN_TYPE GL_FLOAT +#else +#error "illegal number of color channel bits" +#endif + + +/** + * Stencil buffer data type. + */ +#if STENCIL_BITS==8 + typedef GLubyte GLstencil; +#elif STENCIL_BITS==16 + typedef GLushort GLstencil; +#else +# error "illegal number of stencil bits" +#endif + + +/** + * \name 64-bit extension of GLbitfield. + */ +/*@{*/ +typedef GLuint64 GLbitfield64; + +/** Set a single bit */ +#define BITFIELD64_BIT(b) ((GLbitfield64)1 << (b)) + + +/** + * \name Some forward type declarations + */ +/*@{*/ +struct _mesa_HashTable; +struct gl_attrib_node; +struct gl_list_extensions; +struct gl_meta_state; +struct gl_pixelstore_attrib; +struct gl_program_cache; +struct gl_texture_format; +struct gl_texture_image; +struct gl_texture_object; +struct gl_context; +struct st_context; +/*@}*/ + + +/** Extra draw modes beyond GL_POINTS, GL_TRIANGLE_FAN, etc */ +#define PRIM_OUTSIDE_BEGIN_END (GL_POLYGON+1) +#define PRIM_INSIDE_UNKNOWN_PRIM (GL_POLYGON+2) +#define PRIM_UNKNOWN (GL_POLYGON+3) + + +/** + * Shader stages. Note that these will become 5 with tessellation. + * These MUST have the same values as gallium's PIPE_SHADER_* + */ +typedef enum +{ + MESA_SHADER_VERTEX = 0, + MESA_SHADER_FRAGMENT = 1, + MESA_SHADER_GEOMETRY = 2, + MESA_SHADER_TYPES = 3 +} gl_shader_type; + + + +/** + * Indexes for vertex program attributes. + * GL_NV_vertex_program aliases generic attributes over the conventional + * attributes. In GL_ARB_vertex_program shader the aliasing is optional. + * In GL_ARB_vertex_shader / OpenGL 2.0 the aliasing is disallowed (the + * generic attributes are distinct/separate). + */ +typedef enum +{ + VERT_ATTRIB_POS = 0, + VERT_ATTRIB_WEIGHT = 1, + VERT_ATTRIB_NORMAL = 2, + VERT_ATTRIB_COLOR0 = 3, + VERT_ATTRIB_COLOR1 = 4, + VERT_ATTRIB_FOG = 5, + VERT_ATTRIB_COLOR_INDEX = 6, + VERT_ATTRIB_POINT_SIZE = 6, /*alias*/ + VERT_ATTRIB_EDGEFLAG = 7, + VERT_ATTRIB_TEX0 = 8, + VERT_ATTRIB_TEX1 = 9, + VERT_ATTRIB_TEX2 = 10, + VERT_ATTRIB_TEX3 = 11, + VERT_ATTRIB_TEX4 = 12, + VERT_ATTRIB_TEX5 = 13, + VERT_ATTRIB_TEX6 = 14, + VERT_ATTRIB_TEX7 = 15, + VERT_ATTRIB_GENERIC0 = 16, + VERT_ATTRIB_GENERIC1 = 17, + VERT_ATTRIB_GENERIC2 = 18, + VERT_ATTRIB_GENERIC3 = 19, + VERT_ATTRIB_GENERIC4 = 20, + VERT_ATTRIB_GENERIC5 = 21, + VERT_ATTRIB_GENERIC6 = 22, + VERT_ATTRIB_GENERIC7 = 23, + VERT_ATTRIB_GENERIC8 = 24, + VERT_ATTRIB_GENERIC9 = 25, + VERT_ATTRIB_GENERIC10 = 26, + VERT_ATTRIB_GENERIC11 = 27, + VERT_ATTRIB_GENERIC12 = 28, + VERT_ATTRIB_GENERIC13 = 29, + VERT_ATTRIB_GENERIC14 = 30, + VERT_ATTRIB_GENERIC15 = 31, + VERT_ATTRIB_MAX = 32 +} gl_vert_attrib; + +/** + * Bitflags for vertex attributes. + * These are used in bitfields in many places. + */ +/*@{*/ +#define VERT_BIT_POS (1 << VERT_ATTRIB_POS) +#define VERT_BIT_WEIGHT (1 << VERT_ATTRIB_WEIGHT) +#define VERT_BIT_NORMAL (1 << VERT_ATTRIB_NORMAL) +#define VERT_BIT_COLOR0 (1 << VERT_ATTRIB_COLOR0) +#define VERT_BIT_COLOR1 (1 << VERT_ATTRIB_COLOR1) +#define VERT_BIT_FOG (1 << VERT_ATTRIB_FOG) +#define VERT_BIT_COLOR_INDEX (1 << VERT_ATTRIB_COLOR_INDEX) +#define VERT_BIT_EDGEFLAG (1 << VERT_ATTRIB_EDGEFLAG) +#define VERT_BIT_TEX0 (1 << VERT_ATTRIB_TEX0) +#define VERT_BIT_TEX1 (1 << VERT_ATTRIB_TEX1) +#define VERT_BIT_TEX2 (1 << VERT_ATTRIB_TEX2) +#define VERT_BIT_TEX3 (1 << VERT_ATTRIB_TEX3) +#define VERT_BIT_TEX4 (1 << VERT_ATTRIB_TEX4) +#define VERT_BIT_TEX5 (1 << VERT_ATTRIB_TEX5) +#define VERT_BIT_TEX6 (1 << VERT_ATTRIB_TEX6) +#define VERT_BIT_TEX7 (1 << VERT_ATTRIB_TEX7) +#define VERT_BIT_GENERIC0 (1 << VERT_ATTRIB_GENERIC0) +#define VERT_BIT_GENERIC1 (1 << VERT_ATTRIB_GENERIC1) +#define VERT_BIT_GENERIC2 (1 << VERT_ATTRIB_GENERIC2) +#define VERT_BIT_GENERIC3 (1 << VERT_ATTRIB_GENERIC3) +#define VERT_BIT_GENERIC4 (1 << VERT_ATTRIB_GENERIC4) +#define VERT_BIT_GENERIC5 (1 << VERT_ATTRIB_GENERIC5) +#define VERT_BIT_GENERIC6 (1 << VERT_ATTRIB_GENERIC6) +#define VERT_BIT_GENERIC7 (1 << VERT_ATTRIB_GENERIC7) +#define VERT_BIT_GENERIC8 (1 << VERT_ATTRIB_GENERIC8) +#define VERT_BIT_GENERIC9 (1 << VERT_ATTRIB_GENERIC9) +#define VERT_BIT_GENERIC10 (1 << VERT_ATTRIB_GENERIC10) +#define VERT_BIT_GENERIC11 (1 << VERT_ATTRIB_GENERIC11) +#define VERT_BIT_GENERIC12 (1 << VERT_ATTRIB_GENERIC12) +#define VERT_BIT_GENERIC13 (1 << VERT_ATTRIB_GENERIC13) +#define VERT_BIT_GENERIC14 (1 << VERT_ATTRIB_GENERIC14) +#define VERT_BIT_GENERIC15 (1 << VERT_ATTRIB_GENERIC15) + +#define VERT_BIT_TEX(u) (1 << (VERT_ATTRIB_TEX0 + (u))) +#define VERT_BIT_GENERIC(g) (1 << (VERT_ATTRIB_GENERIC0 + (g))) +/*@}*/ + + +/** + * Indexes for vertex program result attributes + */ +typedef enum +{ + VERT_RESULT_HPOS = 0, + VERT_RESULT_COL0 = 1, + VERT_RESULT_COL1 = 2, + VERT_RESULT_FOGC = 3, + VERT_RESULT_TEX0 = 4, + VERT_RESULT_TEX1 = 5, + VERT_RESULT_TEX2 = 6, + VERT_RESULT_TEX3 = 7, + VERT_RESULT_TEX4 = 8, + VERT_RESULT_TEX5 = 9, + VERT_RESULT_TEX6 = 10, + VERT_RESULT_TEX7 = 11, + VERT_RESULT_PSIZ = 12, + VERT_RESULT_BFC0 = 13, + VERT_RESULT_BFC1 = 14, + VERT_RESULT_EDGE = 15, + VERT_RESULT_VAR0 = 16, /**< shader varying */ + VERT_RESULT_MAX = (VERT_RESULT_VAR0 + MAX_VARYING) +} gl_vert_result; + + +/*********************************************/ + +/** + * Indexes for geometry program attributes. + */ +typedef enum +{ + GEOM_ATTRIB_POSITION = 0, + GEOM_ATTRIB_COLOR0 = 1, + GEOM_ATTRIB_COLOR1 = 2, + GEOM_ATTRIB_SECONDARY_COLOR0 = 3, + GEOM_ATTRIB_SECONDARY_COLOR1 = 4, + GEOM_ATTRIB_FOG_FRAG_COORD = 5, + GEOM_ATTRIB_POINT_SIZE = 6, + GEOM_ATTRIB_CLIP_VERTEX = 7, + GEOM_ATTRIB_PRIMITIVE_ID = 8, + GEOM_ATTRIB_TEX_COORD = 9, + + GEOM_ATTRIB_VAR0 = 16, + GEOM_ATTRIB_MAX = (GEOM_ATTRIB_VAR0 + MAX_VARYING) +} gl_geom_attrib; + +/** + * Bitflags for geometry attributes. + * These are used in bitfields in many places. + */ +/*@{*/ +#define GEOM_BIT_COLOR0 (1 << GEOM_ATTRIB_COLOR0) +#define GEOM_BIT_COLOR1 (1 << GEOM_ATTRIB_COLOR1) +#define GEOM_BIT_SCOLOR0 (1 << GEOM_ATTRIB_SECONDARY_COLOR0) +#define GEOM_BIT_SCOLOR1 (1 << GEOM_ATTRIB_SECONDARY_COLOR1) +#define GEOM_BIT_TEX_COORD (1 << GEOM_ATTRIB_TEX_COORD) +#define GEOM_BIT_FOG_COORD (1 << GEOM_ATTRIB_FOG_FRAG_COORD) +#define GEOM_BIT_POSITION (1 << GEOM_ATTRIB_POSITION) +#define GEOM_BIT_POINT_SIDE (1 << GEOM_ATTRIB_POINT_SIZE) +#define GEOM_BIT_CLIP_VERTEX (1 << GEOM_ATTRIB_CLIP_VERTEX) +#define GEOM_BIT_PRIM_ID (1 << GEOM_ATTRIB_PRIMITIVE_ID) +#define GEOM_BIT_VAR0 (1 << GEOM_ATTRIB_VAR0) + +#define GEOM_BIT_VAR(g) (1 << (GEOM_BIT_VAR0 + (g))) +/*@}*/ + + +/** + * Indexes for geometry program result attributes + */ +typedef enum +{ + GEOM_RESULT_POS = 0, + GEOM_RESULT_COL0 = 1, + GEOM_RESULT_COL1 = 2, + GEOM_RESULT_SCOL0 = 3, + GEOM_RESULT_SCOL1 = 4, + GEOM_RESULT_FOGC = 5, + GEOM_RESULT_TEX0 = 6, + GEOM_RESULT_TEX1 = 7, + GEOM_RESULT_TEX2 = 8, + GEOM_RESULT_TEX3 = 9, + GEOM_RESULT_TEX4 = 10, + GEOM_RESULT_TEX5 = 11, + GEOM_RESULT_TEX6 = 12, + GEOM_RESULT_TEX7 = 13, + GEOM_RESULT_PSIZ = 14, + GEOM_RESULT_CLPV = 15, + GEOM_RESULT_PRID = 16, + GEOM_RESULT_LAYR = 17, + GEOM_RESULT_VAR0 = 18, /**< shader varying, should really be 16 */ + /* ### we need to -2 because var0 is 18 instead 16 like in the others */ + GEOM_RESULT_MAX = (GEOM_RESULT_VAR0 + MAX_VARYING - 2) +} gl_geom_result; + + +/** + * Indexes for fragment program input attributes. + */ +typedef enum +{ + FRAG_ATTRIB_WPOS = 0, + FRAG_ATTRIB_COL0 = 1, + FRAG_ATTRIB_COL1 = 2, + FRAG_ATTRIB_FOGC = 3, + FRAG_ATTRIB_TEX0 = 4, + FRAG_ATTRIB_TEX1 = 5, + FRAG_ATTRIB_TEX2 = 6, + FRAG_ATTRIB_TEX3 = 7, + FRAG_ATTRIB_TEX4 = 8, + FRAG_ATTRIB_TEX5 = 9, + FRAG_ATTRIB_TEX6 = 10, + FRAG_ATTRIB_TEX7 = 11, + FRAG_ATTRIB_FACE = 12, /**< front/back face */ + FRAG_ATTRIB_PNTC = 13, /**< sprite/point coord */ + FRAG_ATTRIB_VAR0 = 14, /**< shader varying */ + FRAG_ATTRIB_MAX = (FRAG_ATTRIB_VAR0 + MAX_VARYING) +} gl_frag_attrib; + +/** + * Bitflags for fragment program input attributes. + */ +/*@{*/ +#define FRAG_BIT_WPOS (1 << FRAG_ATTRIB_WPOS) +#define FRAG_BIT_COL0 (1 << FRAG_ATTRIB_COL0) +#define FRAG_BIT_COL1 (1 << FRAG_ATTRIB_COL1) +#define FRAG_BIT_FOGC (1 << FRAG_ATTRIB_FOGC) +#define FRAG_BIT_FACE (1 << FRAG_ATTRIB_FACE) +#define FRAG_BIT_PNTC (1 << FRAG_ATTRIB_PNTC) +#define FRAG_BIT_TEX0 (1 << FRAG_ATTRIB_TEX0) +#define FRAG_BIT_TEX1 (1 << FRAG_ATTRIB_TEX1) +#define FRAG_BIT_TEX2 (1 << FRAG_ATTRIB_TEX2) +#define FRAG_BIT_TEX3 (1 << FRAG_ATTRIB_TEX3) +#define FRAG_BIT_TEX4 (1 << FRAG_ATTRIB_TEX4) +#define FRAG_BIT_TEX5 (1 << FRAG_ATTRIB_TEX5) +#define FRAG_BIT_TEX6 (1 << FRAG_ATTRIB_TEX6) +#define FRAG_BIT_TEX7 (1 << FRAG_ATTRIB_TEX7) +#define FRAG_BIT_VAR0 (1 << FRAG_ATTRIB_VAR0) + +#define FRAG_BIT_TEX(U) (FRAG_BIT_TEX0 << (U)) +#define FRAG_BIT_VAR(V) (FRAG_BIT_VAR0 << (V)) + +#define FRAG_BITS_TEX_ANY (FRAG_BIT_TEX0| \ + FRAG_BIT_TEX1| \ + FRAG_BIT_TEX2| \ + FRAG_BIT_TEX3| \ + FRAG_BIT_TEX4| \ + FRAG_BIT_TEX5| \ + FRAG_BIT_TEX6| \ + FRAG_BIT_TEX7) +/*@}*/ + + +/** + * Fragment program results + */ +typedef enum +{ + FRAG_RESULT_DEPTH = 0, + FRAG_RESULT_STENCIL = 1, + /* If a single color should be written to all render targets, this + * register is written. No FRAG_RESULT_DATAn will be written. + */ + FRAG_RESULT_COLOR = 2, + + /* FRAG_RESULT_DATAn are the per-render-target (GLSL gl_FragData[n] + * or ARB_fragment_program fragment.color[n]) color results. If + * any are written, FRAG_RESULT_COLOR will not be written. + */ + FRAG_RESULT_DATA0 = 3, + FRAG_RESULT_MAX = (FRAG_RESULT_DATA0 + MAX_DRAW_BUFFERS) +} gl_frag_result; + + +/** + * Indexes for all renderbuffers + */ +typedef enum +{ + /* the four standard color buffers */ + BUFFER_FRONT_LEFT, + BUFFER_BACK_LEFT, + BUFFER_FRONT_RIGHT, + BUFFER_BACK_RIGHT, + BUFFER_DEPTH, + BUFFER_STENCIL, + BUFFER_ACCUM, + /* optional aux buffer */ + BUFFER_AUX0, + /* generic renderbuffers */ + BUFFER_COLOR0, + BUFFER_COLOR1, + BUFFER_COLOR2, + BUFFER_COLOR3, + BUFFER_COLOR4, + BUFFER_COLOR5, + BUFFER_COLOR6, + BUFFER_COLOR7, + BUFFER_COUNT +} gl_buffer_index; + +/** + * Bit flags for all renderbuffers + */ +#define BUFFER_BIT_FRONT_LEFT (1 << BUFFER_FRONT_LEFT) +#define BUFFER_BIT_BACK_LEFT (1 << BUFFER_BACK_LEFT) +#define BUFFER_BIT_FRONT_RIGHT (1 << BUFFER_FRONT_RIGHT) +#define BUFFER_BIT_BACK_RIGHT (1 << BUFFER_BACK_RIGHT) +#define BUFFER_BIT_AUX0 (1 << BUFFER_AUX0) +#define BUFFER_BIT_AUX1 (1 << BUFFER_AUX1) +#define BUFFER_BIT_AUX2 (1 << BUFFER_AUX2) +#define BUFFER_BIT_AUX3 (1 << BUFFER_AUX3) +#define BUFFER_BIT_DEPTH (1 << BUFFER_DEPTH) +#define BUFFER_BIT_STENCIL (1 << BUFFER_STENCIL) +#define BUFFER_BIT_ACCUM (1 << BUFFER_ACCUM) +#define BUFFER_BIT_COLOR0 (1 << BUFFER_COLOR0) +#define BUFFER_BIT_COLOR1 (1 << BUFFER_COLOR1) +#define BUFFER_BIT_COLOR2 (1 << BUFFER_COLOR2) +#define BUFFER_BIT_COLOR3 (1 << BUFFER_COLOR3) +#define BUFFER_BIT_COLOR4 (1 << BUFFER_COLOR4) +#define BUFFER_BIT_COLOR5 (1 << BUFFER_COLOR5) +#define BUFFER_BIT_COLOR6 (1 << BUFFER_COLOR6) +#define BUFFER_BIT_COLOR7 (1 << BUFFER_COLOR7) + +/** + * Mask of all the color buffer bits (but not accum). + */ +#define BUFFER_BITS_COLOR (BUFFER_BIT_FRONT_LEFT | \ + BUFFER_BIT_BACK_LEFT | \ + BUFFER_BIT_FRONT_RIGHT | \ + BUFFER_BIT_BACK_RIGHT | \ + BUFFER_BIT_AUX0 | \ + BUFFER_BIT_COLOR0 | \ + BUFFER_BIT_COLOR1 | \ + BUFFER_BIT_COLOR2 | \ + BUFFER_BIT_COLOR3 | \ + BUFFER_BIT_COLOR4 | \ + BUFFER_BIT_COLOR5 | \ + BUFFER_BIT_COLOR6 | \ + BUFFER_BIT_COLOR7) + + +/** + * Framebuffer configuration (aka visual / pixelformat) + * Note: some of these fields should be boolean, but it appears that + * code in drivers/dri/common/util.c requires int-sized fields. + */ +struct gl_config +{ + GLboolean rgbMode; + GLboolean floatMode; + GLboolean colorIndexMode; /* XXX is this used anywhere? */ + GLuint doubleBufferMode; + GLuint stereoMode; + + GLboolean haveAccumBuffer; + GLboolean haveDepthBuffer; + GLboolean haveStencilBuffer; + + GLint redBits, greenBits, blueBits, alphaBits; /* bits per comp */ + GLuint redMask, greenMask, blueMask, alphaMask; + GLint rgbBits; /* total bits for rgb */ + GLint indexBits; /* total bits for colorindex */ + + GLint accumRedBits, accumGreenBits, accumBlueBits, accumAlphaBits; + GLint depthBits; + GLint stencilBits; + + GLint numAuxBuffers; + + GLint level; + + /* EXT_visual_rating / GLX 1.2 */ + GLint visualRating; + + /* EXT_visual_info / GLX 1.2 */ + GLint transparentPixel; + /* colors are floats scaled to ints */ + GLint transparentRed, transparentGreen, transparentBlue, transparentAlpha; + GLint transparentIndex; + + /* ARB_multisample / SGIS_multisample */ + GLint sampleBuffers; + GLint samples; + + /* SGIX_pbuffer / GLX 1.3 */ + GLint maxPbufferWidth; + GLint maxPbufferHeight; + GLint maxPbufferPixels; + GLint optimalPbufferWidth; /* Only for SGIX_pbuffer. */ + GLint optimalPbufferHeight; /* Only for SGIX_pbuffer. */ + + /* OML_swap_method */ + GLint swapMethod; + + /* EXT_texture_from_pixmap */ + GLint bindToTextureRgb; + GLint bindToTextureRgba; + GLint bindToMipmapTexture; + GLint bindToTextureTargets; + GLint yInverted; + + /* EXT_framebuffer_sRGB */ + GLint sRGBCapable; +}; + + +/** + * Data structure for color tables + */ +struct gl_color_table +{ + GLenum InternalFormat; /**< The user-specified format */ + GLenum _BaseFormat; /**< GL_ALPHA, GL_RGBA, GL_RGB, etc */ + GLuint Size; /**< number of entries in table */ + GLfloat *TableF; /**< Color table, floating point values */ + GLubyte *TableUB; /**< Color table, ubyte values */ + GLubyte RedSize; + GLubyte GreenSize; + GLubyte BlueSize; + GLubyte AlphaSize; + GLubyte LuminanceSize; + GLubyte IntensitySize; +}; + + +/** + * \name Bit flags used for updating material values. + */ +/*@{*/ +#define MAT_ATTRIB_FRONT_AMBIENT 0 +#define MAT_ATTRIB_BACK_AMBIENT 1 +#define MAT_ATTRIB_FRONT_DIFFUSE 2 +#define MAT_ATTRIB_BACK_DIFFUSE 3 +#define MAT_ATTRIB_FRONT_SPECULAR 4 +#define MAT_ATTRIB_BACK_SPECULAR 5 +#define MAT_ATTRIB_FRONT_EMISSION 6 +#define MAT_ATTRIB_BACK_EMISSION 7 +#define MAT_ATTRIB_FRONT_SHININESS 8 +#define MAT_ATTRIB_BACK_SHININESS 9 +#define MAT_ATTRIB_FRONT_INDEXES 10 +#define MAT_ATTRIB_BACK_INDEXES 11 +#define MAT_ATTRIB_MAX 12 + +#define MAT_ATTRIB_AMBIENT(f) (MAT_ATTRIB_FRONT_AMBIENT+(f)) +#define MAT_ATTRIB_DIFFUSE(f) (MAT_ATTRIB_FRONT_DIFFUSE+(f)) +#define MAT_ATTRIB_SPECULAR(f) (MAT_ATTRIB_FRONT_SPECULAR+(f)) +#define MAT_ATTRIB_EMISSION(f) (MAT_ATTRIB_FRONT_EMISSION+(f)) +#define MAT_ATTRIB_SHININESS(f)(MAT_ATTRIB_FRONT_SHININESS+(f)) +#define MAT_ATTRIB_INDEXES(f) (MAT_ATTRIB_FRONT_INDEXES+(f)) + +#define MAT_INDEX_AMBIENT 0 +#define MAT_INDEX_DIFFUSE 1 +#define MAT_INDEX_SPECULAR 2 + +#define MAT_BIT_FRONT_AMBIENT (1< ) */ + GLfloat _NormSpotDirection[4]; /**< normalized spotlight direction */ + GLfloat _VP_inf_spot_attenuation; + + GLfloat _SpotExpTable[EXP_TABLE_SIZE][2]; /**< to replace a pow() call */ + GLfloat _MatAmbient[2][3]; /**< material ambient * light ambient */ + GLfloat _MatDiffuse[2][3]; /**< material diffuse * light diffuse */ + GLfloat _MatSpecular[2][3]; /**< material spec * light specular */ + GLfloat _dli; /**< CI diffuse light intensity */ + GLfloat _sli; /**< CI specular light intensity */ + /*@}*/ +}; + + +/** + * Light model state. + */ +struct gl_lightmodel +{ + GLfloat Ambient[4]; /**< ambient color */ + GLboolean LocalViewer; /**< Local (or infinite) view point? */ + GLboolean TwoSide; /**< Two (or one) sided lighting? */ + GLenum ColorControl; /**< either GL_SINGLE_COLOR + * or GL_SEPARATE_SPECULAR_COLOR */ +}; + + +/** + * Material state. + */ +struct gl_material +{ + GLfloat Attrib[MAT_ATTRIB_MAX][4]; +}; + + +/** + * Accumulation buffer attribute group (GL_ACCUM_BUFFER_BIT) + */ +struct gl_accum_attrib +{ + GLfloat ClearColor[4]; /**< Accumulation buffer clear color */ +}; + + +/** + * Color buffer attribute group (GL_COLOR_BUFFER_BIT). + */ +struct gl_colorbuffer_attrib +{ + GLuint ClearIndex; /**< Index to use for glClear */ + GLfloat ClearColorUnclamped[4]; /**< Color to use for glClear*/ + GLclampf ClearColor[4]; /**< Color to use for glClear */ + + GLuint IndexMask; /**< Color index write mask */ + GLubyte ColorMask[MAX_DRAW_BUFFERS][4];/**< Each flag is 0xff or 0x0 */ + + GLenum DrawBuffer[MAX_DRAW_BUFFERS]; /**< Which buffer to draw into */ + + /** + * \name alpha testing + */ + /*@{*/ + GLboolean AlphaEnabled; /**< Alpha test enabled flag */ + GLenum AlphaFunc; /**< Alpha test function */ + GLfloat AlphaRefUnclamped; + GLclampf AlphaRef; /**< Alpha reference value */ + /*@}*/ + + /** + * \name Blending + */ + /*@{*/ + GLbitfield BlendEnabled; /**< Per-buffer blend enable flags */ + + /* NOTE: this does _not_ depend on fragment clamping or any other clamping control, + * only on the fixed-pointness of the render target. + * The query does however depend on fragment color clamping. + */ + GLfloat BlendColorUnclamped[4]; /**< Blending color */ + GLfloat BlendColor[4]; /**< Blending color */ + + struct + { + GLenum SrcRGB; /**< RGB blend source term */ + GLenum DstRGB; /**< RGB blend dest term */ + GLenum SrcA; /**< Alpha blend source term */ + GLenum DstA; /**< Alpha blend dest term */ + GLenum EquationRGB; /**< GL_ADD, GL_SUBTRACT, etc. */ + GLenum EquationA; /**< GL_ADD, GL_SUBTRACT, etc. */ + } Blend[MAX_DRAW_BUFFERS]; + /** Are the blend func terms currently different for each buffer/target? */ + GLboolean _BlendFuncPerBuffer; + /** Are the blend equations currently different for each buffer/target? */ + GLboolean _BlendEquationPerBuffer; + /*@}*/ + + /** + * \name Logic op + */ + /*@{*/ + GLenum LogicOp; /**< Logic operator */ + GLboolean IndexLogicOpEnabled; /**< Color index logic op enabled flag */ + GLboolean ColorLogicOpEnabled; /**< RGBA logic op enabled flag */ + GLboolean _LogicOpEnabled; /**< RGBA logic op + EXT_blend_logic_op enabled flag */ + /*@}*/ + + GLboolean DitherFlag; /**< Dither enable flag */ + + GLenum ClampFragmentColor; /**< GL_TRUE, GL_FALSE or GL_FIXED_ONLY_ARB */ + GLboolean _ClampFragmentColor; /** < with GL_FIXED_ONLY_ARB resolved */ + GLenum ClampReadColor; /**< GL_TRUE, GL_FALSE or GL_FIXED_ONLY_ARB */ + GLboolean _ClampReadColor; /** < with GL_FIXED_ONLY_ARB resolved */ + + GLboolean sRGBEnabled; /**< Framebuffer sRGB blending/updating requested */ +}; + + +/** + * Current attribute group (GL_CURRENT_BIT). + */ +struct gl_current_attrib +{ + /** + * \name Current vertex attributes. + * \note Values are valid only after FLUSH_VERTICES has been called. + * \note Index and Edgeflag current values are stored as floats in the + * SIX and SEVEN attribute slots. + */ + GLfloat Attrib[VERT_ATTRIB_MAX][4]; /**< Position, color, texcoords, etc */ + + /** + * \name Current raster position attributes (always valid). + * \note This set of attributes is very similar to the SWvertex struct. + */ + /*@{*/ + GLfloat RasterPos[4]; + GLfloat RasterDistance; + GLfloat RasterColor[4]; + GLfloat RasterSecondaryColor[4]; + GLfloat RasterTexCoords[MAX_TEXTURE_COORD_UNITS][4]; + GLboolean RasterPosValid; + /*@}*/ +}; + + +/** + * Depth buffer attribute group (GL_DEPTH_BUFFER_BIT). + */ +struct gl_depthbuffer_attrib +{ + GLenum Func; /**< Function for depth buffer compare */ + GLclampd Clear; /**< Value to clear depth buffer to */ + GLboolean Test; /**< Depth buffering enabled flag */ + GLboolean Mask; /**< Depth buffer writable? */ + GLboolean BoundsTest; /**< GL_EXT_depth_bounds_test */ + GLfloat BoundsMin, BoundsMax;/**< GL_EXT_depth_bounds_test */ +}; + + +/** + * Evaluator attribute group (GL_EVAL_BIT). + */ +struct gl_eval_attrib +{ + /** + * \name Enable bits + */ + /*@{*/ + GLboolean Map1Color4; + GLboolean Map1Index; + GLboolean Map1Normal; + GLboolean Map1TextureCoord1; + GLboolean Map1TextureCoord2; + GLboolean Map1TextureCoord3; + GLboolean Map1TextureCoord4; + GLboolean Map1Vertex3; + GLboolean Map1Vertex4; + GLboolean Map1Attrib[16]; /* GL_NV_vertex_program */ + GLboolean Map2Color4; + GLboolean Map2Index; + GLboolean Map2Normal; + GLboolean Map2TextureCoord1; + GLboolean Map2TextureCoord2; + GLboolean Map2TextureCoord3; + GLboolean Map2TextureCoord4; + GLboolean Map2Vertex3; + GLboolean Map2Vertex4; + GLboolean Map2Attrib[16]; /* GL_NV_vertex_program */ + GLboolean AutoNormal; + /*@}*/ + + /** + * \name Map Grid endpoints and divisions and calculated du values + */ + /*@{*/ + GLint MapGrid1un; + GLfloat MapGrid1u1, MapGrid1u2, MapGrid1du; + GLint MapGrid2un, MapGrid2vn; + GLfloat MapGrid2u1, MapGrid2u2, MapGrid2du; + GLfloat MapGrid2v1, MapGrid2v2, MapGrid2dv; + /*@}*/ +}; + + +/** + * Fog attribute group (GL_FOG_BIT). + */ +struct gl_fog_attrib +{ + GLboolean Enabled; /**< Fog enabled flag */ + GLfloat ColorUnclamped[4]; /**< Fog color */ + GLfloat Color[4]; /**< Fog color */ + GLfloat Density; /**< Density >= 0.0 */ + GLfloat Start; /**< Start distance in eye coords */ + GLfloat End; /**< End distance in eye coords */ + GLfloat Index; /**< Fog index */ + GLenum Mode; /**< Fog mode */ + GLboolean ColorSumEnabled; + GLenum FogCoordinateSource; /**< GL_EXT_fog_coord */ + GLfloat _Scale; /**< (End == Start) ? 1.0 : 1.0 / (End - Start) */ +}; + + +/** + * \brief Layout qualifiers for gl_FragDepth. + * + * Extension AMD_conservative_depth allows gl_FragDepth to be redeclared with + * a layout qualifier. + * + * \see enum ir_depth_layout + */ +enum gl_frag_depth_layout { + FRAG_DEPTH_LAYOUT_NONE, /**< No layout is specified. */ + FRAG_DEPTH_LAYOUT_ANY, + FRAG_DEPTH_LAYOUT_GREATER, + FRAG_DEPTH_LAYOUT_LESS, + FRAG_DEPTH_LAYOUT_UNCHANGED +}; + + +/** + * Hint attribute group (GL_HINT_BIT). + * + * Values are always one of GL_FASTEST, GL_NICEST, or GL_DONT_CARE. + */ +struct gl_hint_attrib +{ + GLenum PerspectiveCorrection; + GLenum PointSmooth; + GLenum LineSmooth; + GLenum PolygonSmooth; + GLenum Fog; + GLenum ClipVolumeClipping; /**< GL_EXT_clip_volume_hint */ + GLenum TextureCompression; /**< GL_ARB_texture_compression */ + GLenum GenerateMipmap; /**< GL_SGIS_generate_mipmap */ + GLenum FragmentShaderDerivative; /**< GL_ARB_fragment_shader */ +}; + +/** + * Light state flags. + */ +/*@{*/ +#define LIGHT_SPOT 0x1 +#define LIGHT_LOCAL_VIEWER 0x2 +#define LIGHT_POSITIONAL 0x4 +#define LIGHT_NEED_VERTICES (LIGHT_POSITIONAL|LIGHT_LOCAL_VIEWER) +/*@}*/ + + +/** + * Lighting attribute group (GL_LIGHT_BIT). + */ +struct gl_light_attrib +{ + struct gl_light Light[MAX_LIGHTS]; /**< Array of light sources */ + struct gl_lightmodel Model; /**< Lighting model */ + + /** + * Must flush FLUSH_VERTICES before referencing: + */ + /*@{*/ + struct gl_material Material; /**< Includes front & back values */ + /*@}*/ + + GLboolean Enabled; /**< Lighting enabled flag */ + GLenum ShadeModel; /**< GL_FLAT or GL_SMOOTH */ + GLenum ProvokingVertex; /**< GL_EXT_provoking_vertex */ + GLenum ColorMaterialFace; /**< GL_FRONT, BACK or FRONT_AND_BACK */ + GLenum ColorMaterialMode; /**< GL_AMBIENT, GL_DIFFUSE, etc */ + GLbitfield ColorMaterialBitmask; /**< bitmask formed from Face and Mode */ + GLboolean ColorMaterialEnabled; + GLenum ClampVertexColor; + GLboolean _ClampVertexColor; + + struct gl_light EnabledList; /**< List sentinel */ + + /** + * Derived state for optimizations: + */ + /*@{*/ + GLboolean _NeedEyeCoords; + GLboolean _NeedVertices; /**< Use fast shader? */ + GLbitfield _Flags; /**< LIGHT_* flags, see above */ + GLfloat _BaseColor[2][3]; + /*@}*/ +}; + + +/** + * Line attribute group (GL_LINE_BIT). + */ +struct gl_line_attrib +{ + GLboolean SmoothFlag; /**< GL_LINE_SMOOTH enabled? */ + GLboolean StippleFlag; /**< GL_LINE_STIPPLE enabled? */ + GLushort StipplePattern; /**< Stipple pattern */ + GLint StippleFactor; /**< Stipple repeat factor */ + GLfloat Width; /**< Line width */ +}; + + +/** + * Display list attribute group (GL_LIST_BIT). + */ +struct gl_list_attrib +{ + GLuint ListBase; +}; + + +/** + * Multisample attribute group (GL_MULTISAMPLE_BIT). + */ +struct gl_multisample_attrib +{ + GLboolean Enabled; + GLboolean _Enabled; /**< true if Enabled and multisample buffer */ + GLboolean SampleAlphaToCoverage; + GLboolean SampleAlphaToOne; + GLboolean SampleCoverage; + GLfloat SampleCoverageValue; + GLboolean SampleCoverageInvert; +}; + + +/** + * A pixelmap (see glPixelMap) + */ +struct gl_pixelmap +{ + GLint Size; + GLfloat Map[MAX_PIXEL_MAP_TABLE]; + GLubyte Map8[MAX_PIXEL_MAP_TABLE]; /**< converted to 8-bit color */ +}; + + +/** + * Collection of all pixelmaps + */ +struct gl_pixelmaps +{ + struct gl_pixelmap RtoR; /**< i.e. GL_PIXEL_MAP_R_TO_R */ + struct gl_pixelmap GtoG; + struct gl_pixelmap BtoB; + struct gl_pixelmap AtoA; + struct gl_pixelmap ItoR; + struct gl_pixelmap ItoG; + struct gl_pixelmap ItoB; + struct gl_pixelmap ItoA; + struct gl_pixelmap ItoI; + struct gl_pixelmap StoS; +}; + + +/** + * Pixel attribute group (GL_PIXEL_MODE_BIT). + */ +struct gl_pixel_attrib +{ + GLenum ReadBuffer; /**< source buffer for glRead/CopyPixels() */ + + /*--- Begin Pixel Transfer State ---*/ + /* Fields are in the order in which they're applied... */ + + /** Scale & Bias (index shift, offset) */ + /*@{*/ + GLfloat RedBias, RedScale; + GLfloat GreenBias, GreenScale; + GLfloat BlueBias, BlueScale; + GLfloat AlphaBias, AlphaScale; + GLfloat DepthBias, DepthScale; + GLint IndexShift, IndexOffset; + /*@}*/ + + /* Pixel Maps */ + /* Note: actual pixel maps are not part of this attrib group */ + GLboolean MapColorFlag; + GLboolean MapStencilFlag; + + /*--- End Pixel Transfer State ---*/ + + /** glPixelZoom */ + GLfloat ZoomX, ZoomY; +}; + + +/** + * Point attribute group (GL_POINT_BIT). + */ +struct gl_point_attrib +{ + GLboolean SmoothFlag; /**< True if GL_POINT_SMOOTH is enabled */ + GLfloat Size; /**< User-specified point size */ + GLfloat Params[3]; /**< GL_EXT_point_parameters */ + GLfloat MinSize, MaxSize; /**< GL_EXT_point_parameters */ + GLfloat Threshold; /**< GL_EXT_point_parameters */ + GLboolean _Attenuated; /**< True if Params != [1, 0, 0] */ + GLboolean PointSprite; /**< GL_NV/ARB_point_sprite */ + GLboolean CoordReplace[MAX_TEXTURE_COORD_UNITS]; /**< GL_ARB_point_sprite*/ + GLenum SpriteRMode; /**< GL_NV_point_sprite (only!) */ + GLenum SpriteOrigin; /**< GL_ARB_point_sprite */ +}; + + +/** + * Polygon attribute group (GL_POLYGON_BIT). + */ +struct gl_polygon_attrib +{ + GLenum FrontFace; /**< Either GL_CW or GL_CCW */ + GLenum FrontMode; /**< Either GL_POINT, GL_LINE or GL_FILL */ + GLenum BackMode; /**< Either GL_POINT, GL_LINE or GL_FILL */ + GLboolean _FrontBit; /**< 0=GL_CCW, 1=GL_CW */ + GLboolean CullFlag; /**< Culling on/off flag */ + GLboolean SmoothFlag; /**< True if GL_POLYGON_SMOOTH is enabled */ + GLboolean StippleFlag; /**< True if GL_POLYGON_STIPPLE is enabled */ + GLenum CullFaceMode; /**< Culling mode GL_FRONT or GL_BACK */ + GLfloat OffsetFactor; /**< Polygon offset factor, from user */ + GLfloat OffsetUnits; /**< Polygon offset units, from user */ + GLboolean OffsetPoint; /**< Offset in GL_POINT mode */ + GLboolean OffsetLine; /**< Offset in GL_LINE mode */ + GLboolean OffsetFill; /**< Offset in GL_FILL mode */ +}; + + +/** + * Scissor attributes (GL_SCISSOR_BIT). + */ +struct gl_scissor_attrib +{ + GLboolean Enabled; /**< Scissor test enabled? */ + GLint X, Y; /**< Lower left corner of box */ + GLsizei Width, Height; /**< Size of box */ +}; + + +/** + * Stencil attribute group (GL_STENCIL_BUFFER_BIT). + * + * Three sets of stencil data are tracked so that OpenGL 2.0, + * GL_EXT_stencil_two_side, and GL_ATI_separate_stencil can all be supported + * simultaneously. In each of the stencil state arrays, element 0 corresponds + * to GL_FRONT. Element 1 corresponds to the OpenGL 2.0 / + * GL_ATI_separate_stencil GL_BACK state. Element 2 corresponds to the + * GL_EXT_stencil_two_side GL_BACK state. + * + * The derived value \c _BackFace is either 1 or 2 depending on whether or + * not GL_STENCIL_TEST_TWO_SIDE_EXT is enabled. + * + * The derived value \c _TestTwoSide is set when the front-face and back-face + * stencil state are different. + */ +struct gl_stencil_attrib +{ + GLboolean Enabled; /**< Enabled flag */ + GLboolean TestTwoSide; /**< GL_EXT_stencil_two_side */ + GLubyte ActiveFace; /**< GL_EXT_stencil_two_side (0 or 2) */ + GLboolean _Enabled; /**< Enabled and stencil buffer present */ + GLboolean _TestTwoSide; + GLubyte _BackFace; /**< Current back stencil state (1 or 2) */ + GLenum Function[3]; /**< Stencil function */ + GLenum FailFunc[3]; /**< Fail function */ + GLenum ZPassFunc[3]; /**< Depth buffer pass function */ + GLenum ZFailFunc[3]; /**< Depth buffer fail function */ + GLint Ref[3]; /**< Reference value */ + GLuint ValueMask[3]; /**< Value mask */ + GLuint WriteMask[3]; /**< Write mask */ + GLuint Clear; /**< Clear value */ +}; + + +/** + * An index for each type of texture object. These correspond to the GL + * texture target enums, such as GL_TEXTURE_2D, GL_TEXTURE_CUBE_MAP, etc. + * Note: the order is from highest priority to lowest priority. + */ +typedef enum +{ + TEXTURE_BUFFER_INDEX, + TEXTURE_2D_ARRAY_INDEX, + TEXTURE_1D_ARRAY_INDEX, + TEXTURE_CUBE_INDEX, + TEXTURE_3D_INDEX, + TEXTURE_RECT_INDEX, + TEXTURE_2D_INDEX, + TEXTURE_1D_INDEX, + NUM_TEXTURE_TARGETS +} gl_texture_index; + + +/** + * Bit flags for each type of texture object + * Used for Texture.Unit[]._ReallyEnabled flags. + */ +/*@{*/ +#define TEXTURE_BUFFER_BIT (1 << TEXTURE_BUFFER_INDEX) +#define TEXTURE_2D_ARRAY_BIT (1 << TEXTURE_2D_ARRAY_INDEX) +#define TEXTURE_1D_ARRAY_BIT (1 << TEXTURE_1D_ARRAY_INDEX) +#define TEXTURE_CUBE_BIT (1 << TEXTURE_CUBE_INDEX) +#define TEXTURE_3D_BIT (1 << TEXTURE_3D_INDEX) +#define TEXTURE_RECT_BIT (1 << TEXTURE_RECT_INDEX) +#define TEXTURE_2D_BIT (1 << TEXTURE_2D_INDEX) +#define TEXTURE_1D_BIT (1 << TEXTURE_1D_INDEX) +/*@}*/ + + +/** + * TexGenEnabled flags. + */ +/*@{*/ +#define S_BIT 1 +#define T_BIT 2 +#define R_BIT 4 +#define Q_BIT 8 +#define STR_BITS (S_BIT | T_BIT | R_BIT) +/*@}*/ + + +/** + * Bit flag versions of the corresponding GL_ constants. + */ +/*@{*/ +#define TEXGEN_SPHERE_MAP 0x1 +#define TEXGEN_OBJ_LINEAR 0x2 +#define TEXGEN_EYE_LINEAR 0x4 +#define TEXGEN_REFLECTION_MAP_NV 0x8 +#define TEXGEN_NORMAL_MAP_NV 0x10 + +#define TEXGEN_NEED_NORMALS (TEXGEN_SPHERE_MAP | \ + TEXGEN_REFLECTION_MAP_NV | \ + TEXGEN_NORMAL_MAP_NV) +#define TEXGEN_NEED_EYE_COORD (TEXGEN_SPHERE_MAP | \ + TEXGEN_REFLECTION_MAP_NV | \ + TEXGEN_NORMAL_MAP_NV | \ + TEXGEN_EYE_LINEAR) +/*@}*/ + + + +/** Tex-gen enabled for texture unit? */ +#define ENABLE_TEXGEN(unit) (1 << (unit)) + +/** Non-identity texture matrix for texture unit? */ +#define ENABLE_TEXMAT(unit) (1 << (unit)) + + +/** + * Texel fetch function prototype. We use texel fetch functions to + * extract RGBA, color indexes and depth components out of 1D, 2D and 3D + * texture images. These functions help to isolate us from the gritty + * details of all the various texture image encodings. + * + * \param texImage texture image. + * \param col texel column. + * \param row texel row. + * \param img texel image level/layer. + * \param texelOut output texel (up to 4 GLchans) + */ +typedef void (*FetchTexelFuncC)( const struct gl_texture_image *texImage, + GLint col, GLint row, GLint img, + GLchan *texelOut ); + +/** + * As above, but returns floats. + * Used for depth component images and for upcoming signed/float + * texture images. + */ +typedef void (*FetchTexelFuncF)( const struct gl_texture_image *texImage, + GLint col, GLint row, GLint img, + GLfloat *texelOut ); + + +typedef void (*StoreTexelFunc)(struct gl_texture_image *texImage, + GLint col, GLint row, GLint img, + const void *texel); + + +/** + * Texture image state. Describes the dimensions of a texture image, + * the texel format and pointers to Texel Fetch functions. + */ +struct gl_texture_image +{ + GLint InternalFormat; /**< Internal format as given by the user */ + GLenum _BaseFormat; /**< Either GL_RGB, GL_RGBA, GL_ALPHA, + * GL_LUMINANCE, GL_LUMINANCE_ALPHA, + * GL_INTENSITY, GL_COLOR_INDEX, + * GL_DEPTH_COMPONENT or GL_DEPTH_STENCIL_EXT + * only. Used for choosing TexEnv arithmetic. + */ + gl_format TexFormat; /**< The actual texture memory format */ + + GLuint Border; /**< 0 or 1 */ + GLuint Width; /**< = 2^WidthLog2 + 2*Border */ + GLuint Height; /**< = 2^HeightLog2 + 2*Border */ + GLuint Depth; /**< = 2^DepthLog2 + 2*Border */ + GLuint Width2; /**< = Width - 2*Border */ + GLuint Height2; /**< = Height - 2*Border */ + GLuint Depth2; /**< = Depth - 2*Border */ + GLuint WidthLog2; /**< = log2(Width2) */ + GLuint HeightLog2; /**< = log2(Height2) */ + GLuint DepthLog2; /**< = log2(Depth2) */ + GLuint MaxLog2; /**< = MAX(WidthLog2, HeightLog2) */ + GLfloat WidthScale; /**< used for mipmap LOD computation */ + GLfloat HeightScale; /**< used for mipmap LOD computation */ + GLfloat DepthScale; /**< used for mipmap LOD computation */ + GLboolean IsClientData; /**< Data owned by client? */ + GLboolean _IsPowerOfTwo; /**< Are all dimensions powers of two? */ + + struct gl_texture_object *TexObject; /**< Pointer back to parent object */ + + FetchTexelFuncC FetchTexelc; /**< GLchan texel fetch function pointer */ + FetchTexelFuncF FetchTexelf; /**< Float texel fetch function pointer */ + + GLuint RowStride; /**< Padded width in units of texels */ + GLuint *ImageOffsets; /**< if 3D texture: array [Depth] of offsets to + each 2D slice in 'Data', in texels */ + GLvoid *Data; /**< Image data, accessed via FetchTexel() */ + + /** + * \name For device driver: + */ + /*@{*/ + void *DriverData; /**< Arbitrary device driver data */ + /*@}*/ +}; + + +/** + * Indexes for cube map faces. + */ +typedef enum +{ + FACE_POS_X = 0, + FACE_NEG_X = 1, + FACE_POS_Y = 2, + FACE_NEG_Y = 3, + FACE_POS_Z = 4, + FACE_NEG_Z = 5, + MAX_FACES = 6 +} gl_face_index; + + +/** + * Sampler object state. These objects are new with GL_ARB_sampler_objects + * and OpenGL 3.3. Legacy texture objects also contain a sampler object. + */ +struct gl_sampler_object +{ + GLuint Name; + GLint RefCount; + + GLenum WrapS; /**< S-axis texture image wrap mode */ + GLenum WrapT; /**< T-axis texture image wrap mode */ + GLenum WrapR; /**< R-axis texture image wrap mode */ + GLenum MinFilter; /**< minification filter */ + GLenum MagFilter; /**< magnification filter */ + union { + GLfloat f[4]; + GLuint ui[4]; + GLint i[4]; + } BorderColor; /**< Interpreted according to texture format */ + GLfloat MinLod; /**< min lambda, OpenGL 1.2 */ + GLfloat MaxLod; /**< max lambda, OpenGL 1.2 */ + GLfloat LodBias; /**< OpenGL 1.4 */ + GLfloat MaxAnisotropy; /**< GL_EXT_texture_filter_anisotropic */ + GLenum CompareMode; /**< GL_ARB_shadow */ + GLenum CompareFunc; /**< GL_ARB_shadow */ + GLfloat CompareFailValue; /**< GL_ARB_shadow_ambient */ + GLenum sRGBDecode; /**< GL_DECODE_EXT or GL_SKIP_DECODE_EXT */ + GLboolean CubeMapSeamless; /**< GL_AMD_seamless_cubemap_per_texture */ + + /* deprecated sampler state */ + GLenum DepthMode; /**< GL_ARB_depth_texture */ + + /** Is the texture object complete with respect to this sampler? */ + GLboolean _CompleteTexture; +}; + + +/** + * Texture object state. Contains the array of mipmap images, border color, + * wrap modes, filter modes, shadow/texcompare state, and the per-texture + * color palette. + */ +struct gl_texture_object +{ + _glthread_Mutex Mutex; /**< for thread safety */ + GLint RefCount; /**< reference count */ + GLuint Name; /**< the user-visible texture object ID */ + GLenum Target; /**< GL_TEXTURE_1D, GL_TEXTURE_2D, etc. */ + + struct gl_sampler_object Sampler; + + GLfloat Priority; /**< in [0,1] */ + GLint BaseLevel; /**< min mipmap level, OpenGL 1.2 */ + GLint MaxLevel; /**< max mipmap level, OpenGL 1.2 */ + GLint _MaxLevel; /**< actual max mipmap level (q in the spec) */ + GLfloat _MaxLambda; /**< = _MaxLevel - BaseLevel (q - b in spec) */ + GLint CropRect[4]; /**< GL_OES_draw_texture */ + GLenum Swizzle[4]; /**< GL_EXT_texture_swizzle */ + GLuint _Swizzle; /**< same as Swizzle, but SWIZZLE_* format */ + GLboolean GenerateMipmap; /**< GL_SGIS_generate_mipmap */ + GLboolean _Complete; /**< Is texture object complete? */ + GLboolean _RenderToTexture; /**< Any rendering to this texture? */ + GLboolean Purgeable; /**< Is the buffer purgeable under memory pressure? */ + + /** Actual texture images, indexed by [cube face] and [mipmap level] */ + struct gl_texture_image *Image[MAX_FACES][MAX_TEXTURE_LEVELS]; + + /** GL_ARB_texture_buffer_object */ + struct gl_buffer_object *BufferObject; + GLenum BufferObjectFormat; + + /** GL_EXT_paletted_texture */ + struct gl_color_table Palette; + + /** + * \name For device driver. + * Note: instead of attaching driver data to this pointer, it's preferable + * to instead use this struct as a base class for your own texture object + * class. Driver->NewTextureObject() can be used to implement the + * allocation. + */ + void *DriverData; /**< Arbitrary device driver data */ +}; + + +/** Up to four combiner sources are possible with GL_NV_texture_env_combine4 */ +#define MAX_COMBINER_TERMS 4 + + +/** + * Texture combine environment state. + */ +struct gl_tex_env_combine_state +{ + GLenum ModeRGB; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */ + GLenum ModeA; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */ + /** Source terms: GL_PRIMARY_COLOR, GL_TEXTURE, etc */ + GLenum SourceRGB[MAX_COMBINER_TERMS]; + GLenum SourceA[MAX_COMBINER_TERMS]; + /** Source operands: GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR, etc */ + GLenum OperandRGB[MAX_COMBINER_TERMS]; + GLenum OperandA[MAX_COMBINER_TERMS]; + GLuint ScaleShiftRGB; /**< 0, 1 or 2 */ + GLuint ScaleShiftA; /**< 0, 1 or 2 */ + GLuint _NumArgsRGB; /**< Number of inputs used for the RGB combiner */ + GLuint _NumArgsA; /**< Number of inputs used for the A combiner */ +}; + + +/** + * Texture coord generation state. + */ +struct gl_texgen +{ + GLenum Mode; /**< GL_EYE_LINEAR, GL_SPHERE_MAP, etc */ + GLbitfield _ModeBit; /**< TEXGEN_x bit corresponding to Mode */ + GLfloat ObjectPlane[4]; + GLfloat EyePlane[4]; +}; + + +/** + * Texture unit state. Contains enable flags, texture environment/function/ + * combiners, texgen state, and pointers to current texture objects. + */ +struct gl_texture_unit +{ + GLbitfield Enabled; /**< bitmask of TEXTURE_*_BIT flags */ + GLbitfield _ReallyEnabled; /**< 0 or exactly one of TEXTURE_*_BIT flags */ + + GLenum EnvMode; /**< GL_MODULATE, GL_DECAL, GL_BLEND, etc. */ + GLclampf EnvColor[4]; + GLfloat EnvColorUnclamped[4]; + + struct gl_texgen GenS; + struct gl_texgen GenT; + struct gl_texgen GenR; + struct gl_texgen GenQ; + GLbitfield TexGenEnabled; /**< Bitwise-OR of [STRQ]_BIT values */ + GLbitfield _GenFlags; /**< Bitwise-OR of Gen[STRQ]._ModeBit */ + + GLfloat LodBias; /**< for biasing mipmap levels */ + GLenum BumpTarget; + GLfloat RotMatrix[4]; /* 2x2 matrix */ + + /** Current sampler object (GL_ARB_sampler_objects) */ + struct gl_sampler_object *Sampler; + + /** + * \name GL_EXT_texture_env_combine + */ + struct gl_tex_env_combine_state Combine; + + /** + * Derived state based on \c EnvMode and the \c BaseFormat of the + * currently enabled texture. + */ + struct gl_tex_env_combine_state _EnvMode; + + /** + * Currently enabled combiner state. This will point to either + * \c Combine or \c _EnvMode. + */ + struct gl_tex_env_combine_state *_CurrentCombine; + + /** Current texture object pointers */ + struct gl_texture_object *CurrentTex[NUM_TEXTURE_TARGETS]; + + /** Points to highest priority, complete and enabled texture object */ + struct gl_texture_object *_Current; +}; + + +/** + * Texture attribute group (GL_TEXTURE_BIT). + */ +struct gl_texture_attrib +{ + GLuint CurrentUnit; /**< GL_ACTIVE_TEXTURE */ + struct gl_texture_unit Unit[MAX_COMBINED_TEXTURE_IMAGE_UNITS]; + + struct gl_texture_object *ProxyTex[NUM_TEXTURE_TARGETS]; + + /** GL_ARB_texture_buffer_object */ + struct gl_buffer_object *BufferObject; + + /** GL_ARB_seamless_cubemap */ + GLboolean CubeMapSeamless; + + /** GL_EXT_shared_texture_palette */ + GLboolean SharedPalette; + struct gl_color_table Palette; + + /** Texture units/samplers used by vertex or fragment texturing */ + GLbitfield _EnabledUnits; + + /** Texture coord units/sets used for fragment texturing */ + GLbitfield _EnabledCoordUnits; + + /** Texture coord units that have texgen enabled */ + GLbitfield _TexGenEnabled; + + /** Texture coord units that have non-identity matrices */ + GLbitfield _TexMatEnabled; + + /** Bitwise-OR of all Texture.Unit[i]._GenFlags */ + GLbitfield _GenFlags; +}; + + +/** + * Transformation attribute group (GL_TRANSFORM_BIT). + */ +struct gl_transform_attrib +{ + GLenum MatrixMode; /**< Matrix mode */ + GLfloat EyeUserPlane[MAX_CLIP_PLANES][4]; /**< User clip planes */ + GLfloat _ClipUserPlane[MAX_CLIP_PLANES][4]; /**< derived */ + GLbitfield ClipPlanesEnabled; /**< on/off bitmask */ + GLboolean Normalize; /**< Normalize all normals? */ + GLboolean RescaleNormals; /**< GL_EXT_rescale_normal */ + GLboolean RasterPositionUnclipped; /**< GL_IBM_rasterpos_clip */ + GLboolean DepthClamp; /**< GL_ARB_depth_clamp */ + + GLfloat CullEyePos[4]; + GLfloat CullObjPos[4]; +}; + + +/** + * Viewport attribute group (GL_VIEWPORT_BIT). + */ +struct gl_viewport_attrib +{ + GLint X, Y; /**< position */ + GLsizei Width, Height; /**< size */ + GLfloat Near, Far; /**< Depth buffer range */ + GLmatrix _WindowMap; /**< Mapping transformation as a matrix. */ +}; + + +/** + * GL_ARB_vertex/pixel_buffer_object buffer object + */ +struct gl_buffer_object +{ + _glthread_Mutex Mutex; + GLint RefCount; + GLuint Name; + GLenum Usage; /**< GL_STREAM_DRAW_ARB, GL_STREAM_READ_ARB, etc. */ + GLsizeiptrARB Size; /**< Size of buffer storage in bytes */ + GLubyte *Data; /**< Location of storage either in RAM or VRAM. */ + /** Fields describing a mapped buffer */ + /*@{*/ + GLbitfield AccessFlags; /**< Mask of GL_MAP_x_BIT flags */ + GLvoid *Pointer; /**< User-space address of mapping */ + GLintptr Offset; /**< Mapped offset */ + GLsizeiptr Length; /**< Mapped length */ + /*@}*/ + GLboolean Written; /**< Ever written to? (for debugging) */ + GLboolean Purgeable; /**< Is the buffer purgeable under memory pressure? */ +}; + + +/** + * Client pixel packing/unpacking attributes + */ +struct gl_pixelstore_attrib +{ + GLint Alignment; + GLint RowLength; + GLint SkipPixels; + GLint SkipRows; + GLint ImageHeight; + GLint SkipImages; + GLboolean SwapBytes; + GLboolean LsbFirst; + GLboolean ClientStorage; /**< GL_APPLE_client_storage */ + GLboolean Invert; /**< GL_MESA_pack_invert */ + struct gl_buffer_object *BufferObj; /**< GL_ARB_pixel_buffer_object */ +}; + + +/** + * Client vertex array attributes + */ +struct gl_client_array +{ + GLint Size; /**< components per element (1,2,3,4) */ + GLenum Type; /**< datatype: GL_FLOAT, GL_INT, etc */ + GLenum Format; /**< default: GL_RGBA, but may be GL_BGRA */ + GLsizei Stride; /**< user-specified stride */ + GLsizei StrideB; /**< actual stride in bytes */ + const GLubyte *Ptr; /**< Points to array data */ + GLboolean Enabled; /**< Enabled flag is a boolean */ + GLboolean Normalized; /**< GL_ARB_vertex_program */ + GLboolean Integer; /**< Integer-valued? */ + GLuint InstanceDivisor; /**< GL_ARB_instanced_arrays */ + GLuint _ElementSize; /**< size of each element in bytes */ + + struct gl_buffer_object *BufferObj;/**< GL_ARB_vertex_buffer_object */ + GLuint _MaxElement; /**< max element index into array buffer + 1 */ +}; + + +/** + * Collection of vertex arrays. Defined by the GL_APPLE_vertex_array_object + * extension, but a nice encapsulation in any case. + */ +struct gl_array_object +{ + /** Name of the array object as received from glGenVertexArrayAPPLE. */ + GLuint Name; + + GLint RefCount; + _glthread_Mutex Mutex; + GLboolean VBOonly; /**< require all arrays to live in VBOs? */ + + /** Conventional vertex arrays */ + /*@{*/ + struct gl_client_array Vertex; + struct gl_client_array Weight; + struct gl_client_array Normal; + struct gl_client_array Color; + struct gl_client_array SecondaryColor; + struct gl_client_array FogCoord; + struct gl_client_array Index; + struct gl_client_array EdgeFlag; + struct gl_client_array TexCoord[MAX_TEXTURE_COORD_UNITS]; + struct gl_client_array PointSize; + /*@}*/ + + /** + * Generic arrays for vertex programs/shaders. + * For NV vertex programs, these attributes alias and take priority + * over the conventional attribs above. For ARB vertex programs and + * GLSL vertex shaders, these attributes are separate. + */ + struct gl_client_array VertexAttrib[MAX_VERTEX_GENERIC_ATTRIBS]; + + /** Mask of _NEW_ARRAY_* values indicating which arrays are enabled */ + GLbitfield _Enabled; + + /** + * Min of all enabled arrays' _MaxElement. When arrays reside inside VBOs + * we can determine the max legal (in bounds) glDrawElements array index. + */ + GLuint _MaxElement; +}; + + +/** + * Vertex array state + */ +struct gl_array_attrib +{ + /** Currently bound array object. See _mesa_BindVertexArrayAPPLE() */ + struct gl_array_object *ArrayObj; + + /** The default vertex array object */ + struct gl_array_object *DefaultArrayObj; + + /** Array objects (GL_ARB/APPLE_vertex_array_object) */ + struct _mesa_HashTable *Objects; + + GLint ActiveTexture; /**< Client Active Texture */ + GLuint LockFirst; /**< GL_EXT_compiled_vertex_array */ + GLuint LockCount; /**< GL_EXT_compiled_vertex_array */ + + /** GL 3.1 (slightly different from GL_NV_primitive_restart) */ + GLboolean PrimitiveRestart; + GLuint RestartIndex; + + GLbitfield NewState; /**< mask of _NEW_ARRAY_* values */ + GLboolean RebindArrays; /**< whether the VBO module should rebind arrays */ + + /* GL_ARB_vertex_buffer_object */ + struct gl_buffer_object *ArrayBufferObj; + struct gl_buffer_object *ElementArrayBufferObj; +}; + + +/** + * Feedback buffer state + */ +struct gl_feedback +{ + GLenum Type; + GLbitfield _Mask; /**< FB_* bits */ + GLfloat *Buffer; + GLuint BufferSize; + GLuint Count; +}; + + +/** + * Selection buffer state + */ +struct gl_selection +{ + GLuint *Buffer; /**< selection buffer */ + GLuint BufferSize; /**< size of the selection buffer */ + GLuint BufferCount; /**< number of values in the selection buffer */ + GLuint Hits; /**< number of records in the selection buffer */ + GLuint NameStackDepth; /**< name stack depth */ + GLuint NameStack[MAX_NAME_STACK_DEPTH]; /**< name stack */ + GLboolean HitFlag; /**< hit flag */ + GLfloat HitMinZ; /**< minimum hit depth */ + GLfloat HitMaxZ; /**< maximum hit depth */ +}; + + +/** + * 1-D Evaluator control points + */ +struct gl_1d_map +{ + GLuint Order; /**< Number of control points */ + GLfloat u1, u2, du; /**< u1, u2, 1.0/(u2-u1) */ + GLfloat *Points; /**< Points to contiguous control points */ +}; + + +/** + * 2-D Evaluator control points + */ +struct gl_2d_map +{ + GLuint Uorder; /**< Number of control points in U dimension */ + GLuint Vorder; /**< Number of control points in V dimension */ + GLfloat u1, u2, du; + GLfloat v1, v2, dv; + GLfloat *Points; /**< Points to contiguous control points */ +}; + + +/** + * All evaluator control point state + */ +struct gl_evaluators +{ + /** + * \name 1-D maps + */ + /*@{*/ + struct gl_1d_map Map1Vertex3; + struct gl_1d_map Map1Vertex4; + struct gl_1d_map Map1Index; + struct gl_1d_map Map1Color4; + struct gl_1d_map Map1Normal; + struct gl_1d_map Map1Texture1; + struct gl_1d_map Map1Texture2; + struct gl_1d_map Map1Texture3; + struct gl_1d_map Map1Texture4; + struct gl_1d_map Map1Attrib[16]; /**< GL_NV_vertex_program */ + /*@}*/ + + /** + * \name 2-D maps + */ + /*@{*/ + struct gl_2d_map Map2Vertex3; + struct gl_2d_map Map2Vertex4; + struct gl_2d_map Map2Index; + struct gl_2d_map Map2Color4; + struct gl_2d_map Map2Normal; + struct gl_2d_map Map2Texture1; + struct gl_2d_map Map2Texture2; + struct gl_2d_map Map2Texture3; + struct gl_2d_map Map2Texture4; + struct gl_2d_map Map2Attrib[16]; /**< GL_NV_vertex_program */ + /*@}*/ +}; + + +/** + * Names of the various vertex/fragment program register files, etc. + * + * NOTE: first four tokens must fit into 2 bits (see t_vb_arbprogram.c) + * All values should fit in a 4-bit field. + * + * NOTE: PROGRAM_ENV_PARAM, PROGRAM_STATE_VAR, PROGRAM_NAMED_PARAM, + * PROGRAM_CONSTANT, and PROGRAM_UNIFORM can all be considered to + * be "uniform" variables since they can only be set outside glBegin/End. + * They're also all stored in the same Parameters array. + */ +typedef enum +{ + PROGRAM_TEMPORARY, /**< machine->Temporary[] */ + PROGRAM_INPUT, /**< machine->Inputs[] */ + PROGRAM_OUTPUT, /**< machine->Outputs[] */ + PROGRAM_VARYING, /**< machine->Inputs[]/Outputs[] */ + PROGRAM_LOCAL_PARAM, /**< gl_program->LocalParams[] */ + PROGRAM_ENV_PARAM, /**< gl_program->Parameters[] */ + PROGRAM_STATE_VAR, /**< gl_program->Parameters[] */ + PROGRAM_NAMED_PARAM, /**< gl_program->Parameters[] */ + PROGRAM_CONSTANT, /**< gl_program->Parameters[] */ + PROGRAM_UNIFORM, /**< gl_program->Parameters[] */ + PROGRAM_WRITE_ONLY, /**< A dummy, write-only register */ + PROGRAM_ADDRESS, /**< machine->AddressReg */ + PROGRAM_SAMPLER, /**< for shader samplers, compile-time only */ + PROGRAM_SYSTEM_VALUE,/**< InstanceId, PrimitiveID, etc. */ + PROGRAM_UNDEFINED, /**< Invalid/TBD value */ + PROGRAM_FILE_MAX +} gl_register_file; + + +/** + * If the register file is PROGRAM_SYSTEM_VALUE, the register index will be + * one of these values. + */ +typedef enum +{ + SYSTEM_VALUE_FRONT_FACE, /**< Fragment shader only (not done yet) */ + SYSTEM_VALUE_INSTANCE_ID, /**< Vertex shader only */ + SYSTEM_VALUE_MAX /**< Number of values */ +} gl_system_value; + + +/** Vertex and fragment instructions */ +struct prog_instruction; +struct gl_program_parameter_list; +struct gl_uniform_list; + + +/** + * Base class for any kind of program object + */ +struct gl_program +{ + GLuint Id; + GLubyte *String; /**< Null-terminated program text */ + GLint RefCount; + GLenum Target; /**< GL_VERTEX/FRAGMENT_PROGRAM_ARB, GL_FRAGMENT_PROGRAM_NV */ + GLenum Format; /**< String encoding format */ + GLboolean Resident; + + struct prog_instruction *Instructions; + + GLbitfield InputsRead; /**< Bitmask of which input regs are read */ + GLbitfield64 OutputsWritten; /**< Bitmask of which output regs are written */ + GLbitfield SystemValuesRead; /**< Bitmask of SYSTEM_VALUE_x inputs used */ + GLbitfield InputFlags[MAX_PROGRAM_INPUTS]; /**< PROG_PARAM_BIT_x flags */ + GLbitfield OutputFlags[MAX_PROGRAM_OUTPUTS]; /**< PROG_PARAM_BIT_x flags */ + GLbitfield TexturesUsed[MAX_COMBINED_TEXTURE_IMAGE_UNITS]; /**< TEXTURE_x_BIT bitmask */ + GLbitfield SamplersUsed; /**< Bitfield of which samplers are used */ + GLbitfield ShadowSamplers; /**< Texture units used for shadow sampling. */ + + + /** Named parameters, constants, etc. from program text */ + struct gl_program_parameter_list *Parameters; + /** Numbered local parameters */ + GLfloat LocalParams[MAX_PROGRAM_LOCAL_PARAMS][4]; + + /** Vertex/fragment shader varying vars */ + struct gl_program_parameter_list *Varying; + /** Vertex program user-defined attributes */ + struct gl_program_parameter_list *Attributes; + + /** Map from sampler unit to texture unit (set by glUniform1i()) */ + GLubyte SamplerUnits[MAX_SAMPLERS]; + /** Which texture target is being sampled (TEXTURE_1D/2D/3D/etc_INDEX) */ + gl_texture_index SamplerTargets[MAX_SAMPLERS]; + + /** Bitmask of which register files are read/written with indirect + * addressing. Mask of (1 << PROGRAM_x) bits. + */ + GLbitfield IndirectRegisterFiles; + + /** Logical counts */ + /*@{*/ + GLuint NumInstructions; + GLuint NumTemporaries; + GLuint NumParameters; + GLuint NumAttributes; + GLuint NumAddressRegs; + GLuint NumAluInstructions; + GLuint NumTexInstructions; + GLuint NumTexIndirections; + /*@}*/ + /** Native, actual h/w counts */ + /*@{*/ + GLuint NumNativeInstructions; + GLuint NumNativeTemporaries; + GLuint NumNativeParameters; + GLuint NumNativeAttributes; + GLuint NumNativeAddressRegs; + GLuint NumNativeAluInstructions; + GLuint NumNativeTexInstructions; + GLuint NumNativeTexIndirections; + /*@}*/ +}; + + +/** Vertex program object */ +struct gl_vertex_program +{ + struct gl_program Base; /**< base class */ + GLboolean IsNVProgram; /**< is this a GL_NV_vertex_program program? */ + GLboolean IsPositionInvariant; +}; + + +/** Geometry program object */ +struct gl_geometry_program +{ + struct gl_program Base; /**< base class */ + + GLint VerticesOut; + GLenum InputType; /**< GL_POINTS, GL_LINES, GL_LINES_ADJACENCY_ARB, + GL_TRIANGLES, or GL_TRIANGLES_ADJACENCY_ARB */ + GLenum OutputType; /**< GL_POINTS, GL_LINE_STRIP or GL_TRIANGLE_STRIP */ +}; + + +/** Fragment program object */ +struct gl_fragment_program +{ + struct gl_program Base; /**< base class */ + GLboolean UsesKill; /**< shader uses KIL instruction */ + GLboolean OriginUpperLeft; + GLboolean PixelCenterInteger; + enum gl_frag_depth_layout FragDepthLayout; +}; + + +/** + * State common to vertex and fragment programs. + */ +struct gl_program_state +{ + GLint ErrorPos; /* GL_PROGRAM_ERROR_POSITION_ARB/NV */ + const char *ErrorString; /* GL_PROGRAM_ERROR_STRING_ARB/NV */ +}; + + +/** + * Context state for vertex programs. + */ +struct gl_vertex_program_state +{ + GLboolean Enabled; /**< User-set GL_VERTEX_PROGRAM_ARB/NV flag */ + GLboolean _Enabled; /**< Enabled and _valid_ user program? */ + GLboolean PointSizeEnabled; /**< GL_VERTEX_PROGRAM_POINT_SIZE_ARB/NV */ + GLboolean TwoSideEnabled; /**< GL_VERTEX_PROGRAM_TWO_SIDE_ARB/NV */ + struct gl_vertex_program *Current; /**< User-bound vertex program */ + + /** Currently enabled and valid vertex program (including internal + * programs, user-defined vertex programs and GLSL vertex shaders). + * This is the program we must use when rendering. + */ + struct gl_vertex_program *_Current; + + GLfloat Parameters[MAX_PROGRAM_ENV_PARAMS][4]; /**< Env params */ + + /* For GL_NV_vertex_program only: */ + GLenum TrackMatrix[MAX_PROGRAM_ENV_PARAMS / 4]; + GLenum TrackMatrixTransform[MAX_PROGRAM_ENV_PARAMS / 4]; + + /** Should fixed-function T&L be implemented with a vertex prog? */ + GLboolean _MaintainTnlProgram; + + /** Program to emulate fixed-function T&L (see above) */ + struct gl_vertex_program *_TnlProgram; + + /** Cache of fixed-function programs */ + struct gl_program_cache *Cache; + + GLboolean _Overriden; +}; + + +/** + * Context state for geometry programs. + */ +struct gl_geometry_program_state +{ + GLboolean Enabled; /**< GL_ARB_GEOMETRY_SHADER4 */ + GLboolean _Enabled; /**< Enabled and valid program? */ + struct gl_geometry_program *Current; /**< user-bound geometry program */ + + /** Currently enabled and valid program (including internal programs + * and compiled shader programs). + */ + struct gl_geometry_program *_Current; + + GLfloat Parameters[MAX_PROGRAM_ENV_PARAMS][4]; /**< Env params */ + + /** Cache of fixed-function programs */ + struct gl_program_cache *Cache; +}; + +/** + * Context state for fragment programs. + */ +struct gl_fragment_program_state +{ + GLboolean Enabled; /**< User-set fragment program enable flag */ + GLboolean _Enabled; /**< Enabled and _valid_ user program? */ + struct gl_fragment_program *Current; /**< User-bound fragment program */ + + /** Currently enabled and valid fragment program (including internal + * programs, user-defined fragment programs and GLSL fragment shaders). + * This is the program we must use when rendering. + */ + struct gl_fragment_program *_Current; + + GLfloat Parameters[MAX_PROGRAM_ENV_PARAMS][4]; /**< Env params */ + + /** Should fixed-function texturing be implemented with a fragment prog? */ + GLboolean _MaintainTexEnvProgram; + + /** Program to emulate fixed-function texture env/combine (see above) */ + struct gl_fragment_program *_TexEnvProgram; + + /** Cache of fixed-function programs */ + struct gl_program_cache *Cache; +}; + + +/** + * ATI_fragment_shader runtime state + */ +#define ATI_FS_INPUT_PRIMARY 0 +#define ATI_FS_INPUT_SECONDARY 1 + +struct atifs_instruction; +struct atifs_setupinst; + +/** + * ATI fragment shader + */ +struct ati_fragment_shader +{ + GLuint Id; + GLint RefCount; + struct atifs_instruction *Instructions[2]; + struct atifs_setupinst *SetupInst[2]; + GLfloat Constants[8][4]; + GLbitfield LocalConstDef; /**< Indicates which constants have been set */ + GLubyte numArithInstr[2]; + GLubyte regsAssigned[2]; + GLubyte NumPasses; /**< 1 or 2 */ + GLubyte cur_pass; + GLubyte last_optype; + GLboolean interpinp1; + GLboolean isValid; + GLuint swizzlerq; +}; + +/** + * Context state for GL_ATI_fragment_shader + */ +struct gl_ati_fragment_shader_state +{ + GLboolean Enabled; + GLboolean _Enabled; /**< enabled and valid shader? */ + GLboolean Compiling; + GLfloat GlobalConstants[8][4]; + struct ati_fragment_shader *Current; +}; + + +/** + * Occlusion/timer query object. + */ +struct gl_query_object +{ + GLenum Target; /**< The query target, when active */ + GLuint Id; /**< hash table ID/name */ + GLuint64EXT Result; /**< the counter */ + GLboolean Active; /**< inside Begin/EndQuery */ + GLboolean Ready; /**< result is ready? */ +}; + + +/** + * Context state for query objects. + */ +struct gl_query_state +{ + struct _mesa_HashTable *QueryObjects; + struct gl_query_object *CurrentOcclusionObject; /* GL_ARB_occlusion_query */ + struct gl_query_object *CurrentTimerObject; /* GL_EXT_timer_query */ + + /** GL_NV_conditional_render */ + struct gl_query_object *CondRenderQuery; + + /** GL_EXT_transform_feedback */ + struct gl_query_object *PrimitivesGenerated; + struct gl_query_object *PrimitivesWritten; + + /** GL_ARB_timer_query */ + struct gl_query_object *TimeElapsed; + + GLenum CondRenderMode; +}; + + +/** Sync object state */ +struct gl_sync_object { + struct simple_node link; + GLenum Type; /**< GL_SYNC_FENCE */ + GLuint Name; /**< Fence name */ + GLint RefCount; /**< Reference count */ + GLboolean DeletePending; /**< Object was deleted while there were still + * live references (e.g., sync not yet finished) + */ + GLenum SyncCondition; + GLbitfield Flags; /**< Flags passed to glFenceSync */ + GLuint StatusFlag:1; /**< Has the sync object been signaled? */ +}; + + +/** Set by #pragma directives */ +struct gl_sl_pragmas +{ + GLboolean IgnoreOptimize; /**< ignore #pragma optimize(on/off) ? */ + GLboolean IgnoreDebug; /**< ignore #pragma debug(on/off) ? */ + GLboolean Optimize; /**< defaults on */ + GLboolean Debug; /**< defaults off */ +}; + + +/** + * A GLSL vertex or fragment shader object. + */ +struct gl_shader +{ + GLenum Type; /**< GL_FRAGMENT_SHADER || GL_VERTEX_SHADER || GL_GEOMETRY_SHADER_ARB (first field!) */ + GLuint Name; /**< AKA the handle */ + GLint RefCount; /**< Reference count */ + GLboolean DeletePending; + GLboolean CompileStatus; + const GLchar *Source; /**< Source code string */ + GLuint SourceChecksum; /**< for debug/logging purposes */ + struct gl_program *Program; /**< Post-compile assembly code */ + GLchar *InfoLog; + struct gl_sl_pragmas Pragmas; + + unsigned Version; /**< GLSL version used for linking */ + + struct exec_list *ir; + struct glsl_symbol_table *symbols; + + /** Shaders containing built-in functions that are used for linking. */ + struct gl_shader *builtins_to_link[16]; + unsigned num_builtins_to_link; +}; + + +/** + * A GLSL program object. + * Basically a linked collection of vertex and fragment shaders. + */ +struct gl_shader_program +{ + GLenum Type; /**< Always GL_SHADER_PROGRAM (internal token) */ + GLuint Name; /**< aka handle or ID */ + GLint RefCount; /**< Reference count */ + GLboolean DeletePending; + + GLuint NumShaders; /**< number of attached shaders */ + struct gl_shader **Shaders; /**< List of attached the shaders */ + + /** User-defined attribute bindings (glBindAttribLocation) */ + struct gl_program_parameter_list *Attributes; + + /** Transform feedback varyings */ + struct { + GLenum BufferMode; + GLuint NumVarying; + GLchar **VaryingNames; /**< Array [NumVarying] of char * */ + } TransformFeedback; + + /** Geometry shader state - copied into gl_geometry_program at link time */ + struct { + GLint VerticesOut; + GLenum InputType; /**< GL_POINTS, GL_LINES, GL_LINES_ADJACENCY_ARB, + GL_TRIANGLES, or GL_TRIANGLES_ADJACENCY_ARB */ + GLenum OutputType; /**< GL_POINTS, GL_LINE_STRIP or GL_TRIANGLE_STRIP */ + } Geom; + + /* post-link info: */ + struct gl_vertex_program *VertexProgram; /**< Linked vertex program */ + struct gl_fragment_program *FragmentProgram; /**< Linked fragment prog */ + struct gl_geometry_program *GeometryProgram; /**< Linked geometry prog */ + struct gl_uniform_list *Uniforms; + struct gl_program_parameter_list *Varying; + GLboolean LinkStatus; /**< GL_LINK_STATUS */ + GLboolean Validated; + GLboolean _Used; /**< Ever used for drawing? */ + GLchar *InfoLog; + + unsigned Version; /**< GLSL version used for linking */ + + /** + * Per-stage shaders resulting from the first stage of linking. + * + * Set of linked shaders for this program. The array is accessed using the + * \c MESA_SHADER_* defines. Entries for non-existent stages will be + * \c NULL. + */ + struct gl_shader *_LinkedShaders[MESA_SHADER_TYPES]; +}; + + +#define GLSL_DUMP 0x1 /**< Dump shaders to stdout */ +#define GLSL_LOG 0x2 /**< Write shaders to files */ +#define GLSL_OPT 0x4 /**< Force optimizations (override pragmas) */ +#define GLSL_NO_OPT 0x8 /**< Force no optimizations (override pragmas) */ +#define GLSL_UNIFORMS 0x10 /**< Print glUniform calls */ +#define GLSL_NOP_VERT 0x20 /**< Force no-op vertex shaders */ +#define GLSL_NOP_FRAG 0x40 /**< Force no-op fragment shaders */ +#define GLSL_USE_PROG 0x80 /**< Log glUseProgram calls */ + + +/** + * Context state for GLSL vertex/fragment shaders. + */ +struct gl_shader_state +{ + /** + * Programs used for rendering + * + * There is a separate program set for each shader stage. If + * GL_EXT_separate_shader_objects is not supported, each of these must point + * to \c NULL or to the same program. + */ + struct gl_shader_program *CurrentVertexProgram; + struct gl_shader_program *CurrentGeometryProgram; + struct gl_shader_program *CurrentFragmentProgram; + + /** + * Program used by glUniform calls. + * + * Explicitly set by \c glUseProgram and \c glActiveProgramEXT. + */ + struct gl_shader_program *ActiveProgram; + + GLbitfield Flags; /**< Mask of GLSL_x flags */ +}; + +/** + * Compiler options for a single GLSL shaders type + */ +struct gl_shader_compiler_options +{ + /** Driver-selectable options: */ + GLboolean EmitCondCodes; /**< Use condition codes? */ + GLboolean EmitNVTempInitialization; /**< 0-fill NV temp registers */ + /** + * Attempts to flatten all ir_if (OPCODE_IF) for GPUs that can't + * support control flow. + */ + GLboolean EmitNoIfs; + GLboolean EmitNoLoops; + GLboolean EmitNoFunctions; + GLboolean EmitNoCont; /**< Emit CONT opcode? */ + GLboolean EmitNoMainReturn; /**< Emit CONT/RET opcodes? */ + GLboolean EmitNoNoise; /**< Emit NOISE opcodes? */ + GLboolean EmitNoPow; /**< Emit POW opcodes? */ + + /** + * \name Forms of indirect addressing the driver cannot do. + */ + /*@{*/ + GLboolean EmitNoIndirectInput; /**< No indirect addressing of inputs */ + GLboolean EmitNoIndirectOutput; /**< No indirect addressing of outputs */ + GLboolean EmitNoIndirectTemp; /**< No indirect addressing of temps */ + GLboolean EmitNoIndirectUniform; /**< No indirect addressing of constants */ + /*@}*/ + + GLuint MaxUnrollIterations; + + struct gl_sl_pragmas DefaultPragmas; /**< Default #pragma settings */ +}; + +/** + * Transform feedback object state + */ +struct gl_transform_feedback_object +{ + GLuint Name; /**< AKA the object ID */ + GLint RefCount; + GLboolean Active; /**< Is transform feedback enabled? */ + GLboolean Paused; /**< Is transform feedback paused? */ + + /** The feedback buffers */ + GLuint BufferNames[MAX_FEEDBACK_ATTRIBS]; + struct gl_buffer_object *Buffers[MAX_FEEDBACK_ATTRIBS]; + + /** Start of feedback data in dest buffer */ + GLintptr Offset[MAX_FEEDBACK_ATTRIBS]; + /** Max data to put into dest buffer (in bytes) */ + GLsizeiptr Size[MAX_FEEDBACK_ATTRIBS]; +}; + + +/** + * Context state for transform feedback. + */ +struct gl_transform_feedback +{ + GLenum Mode; /**< GL_POINTS, GL_LINES or GL_TRIANGLES */ + + GLboolean RasterDiscard; /**< GL_RASTERIZER_DISCARD */ + + /** The general binding point (GL_TRANSFORM_FEEDBACK_BUFFER) */ + struct gl_buffer_object *CurrentBuffer; + + /** The table of all transform feedback objects */ + struct _mesa_HashTable *Objects; + + /** The current xform-fb object (GL_TRANSFORM_FEEDBACK_BINDING) */ + struct gl_transform_feedback_object *CurrentObject; + + /** The default xform-fb object (Name==0) */ + struct gl_transform_feedback_object *DefaultObject; +}; + + + +/** + * State which can be shared by multiple contexts: + */ +struct gl_shared_state +{ + _glthread_Mutex Mutex; /**< for thread safety */ + GLint RefCount; /**< Reference count */ + struct _mesa_HashTable *DisplayList; /**< Display lists hash table */ + struct _mesa_HashTable *TexObjects; /**< Texture objects hash table */ + + /** Default texture objects (shared by all texture units) */ + struct gl_texture_object *DefaultTex[NUM_TEXTURE_TARGETS]; + + /** Fallback texture used when a bound texture is incomplete */ + struct gl_texture_object *FallbackTex; + + /** + * \name Thread safety and statechange notification for texture + * objects. + * + * \todo Improve the granularity of locking. + */ + /*@{*/ + _glthread_Mutex TexMutex; /**< texobj thread safety */ + GLuint TextureStateStamp; /**< state notification for shared tex */ + /*@}*/ + + /** Default buffer object for vertex arrays that aren't in VBOs */ + struct gl_buffer_object *NullBufferObj; + + /** + * \name Vertex/geometry/fragment programs + */ + /*@{*/ + struct _mesa_HashTable *Programs; /**< All vertex/fragment programs */ + struct gl_vertex_program *DefaultVertexProgram; + struct gl_fragment_program *DefaultFragmentProgram; + struct gl_geometry_program *DefaultGeometryProgram; + /*@}*/ + + /* GL_ATI_fragment_shader */ + struct _mesa_HashTable *ATIShaders; + struct ati_fragment_shader *DefaultFragmentShader; + + struct _mesa_HashTable *BufferObjects; + + /** Table of both gl_shader and gl_shader_program objects */ + struct _mesa_HashTable *ShaderObjects; + + /* GL_EXT_framebuffer_object */ + struct _mesa_HashTable *RenderBuffers; + struct _mesa_HashTable *FrameBuffers; + + /* GL_ARB_sync */ + struct simple_node SyncObjects; + + /** GL_ARB_sampler_objects */ + struct _mesa_HashTable *SamplerObjects; + + void *DriverData; /**< Device driver shared state */ +}; + + + + +/** + * A renderbuffer stores colors or depth values or stencil values. + * A framebuffer object will have a collection of these. + * Data are read/written to the buffer with a handful of Get/Put functions. + * + * Instances of this object are allocated with the Driver's NewRenderbuffer + * hook. Drivers will likely wrap this class inside a driver-specific + * class to simulate inheritance. + */ +struct gl_renderbuffer +{ + _glthread_Mutex Mutex; /**< for thread safety */ + GLuint ClassID; /**< Useful for drivers */ + GLuint Name; + GLint RefCount; + GLuint Width, Height; + GLint RowStride; /**< Padded width in units of pixels */ + GLboolean Purgeable; /**< Is the buffer purgeable under memory pressure? */ + + GLboolean AttachedAnytime; /**< TRUE if it was attached to a framebuffer */ + + GLubyte NumSamples; + + GLenum InternalFormat; /**< The user-specified format */ + GLenum _BaseFormat; /**< Either GL_RGB, GL_RGBA, GL_DEPTH_COMPONENT or + GL_STENCIL_INDEX. */ + gl_format Format; /**< The actual renderbuffer memory format */ + + GLenum DataType; /**< Type of values passed to the Get/Put functions */ + GLvoid *Data; /**< This may not be used by some kinds of RBs */ + + /* Used to wrap one renderbuffer around another: */ + struct gl_renderbuffer *Wrapped; + + /* Delete this renderbuffer */ + void (*Delete)(struct gl_renderbuffer *rb); + + /* Allocate new storage for this renderbuffer */ + GLboolean (*AllocStorage)(struct gl_context *ctx, struct gl_renderbuffer *rb, + GLenum internalFormat, + GLuint width, GLuint height); + + /* Lock/Unlock are called before/after calling the Get/Put functions. + * Not sure this is the right place for these yet. + void (*Lock)(struct gl_context *ctx, struct gl_renderbuffer *rb); + void (*Unlock)(struct gl_context *ctx, struct gl_renderbuffer *rb); + */ + + /* Return a pointer to the element/pixel at (x,y). + * Should return NULL if the buffer memory can't be directly addressed. + */ + void *(*GetPointer)(struct gl_context *ctx, struct gl_renderbuffer *rb, + GLint x, GLint y); + + /* Get/Read a row of values. + * The values will be of format _BaseFormat and type DataType. + */ + void (*GetRow)(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, void *values); + + /* Get/Read values at arbitrary locations. + * The values will be of format _BaseFormat and type DataType. + */ + void (*GetValues)(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + const GLint x[], const GLint y[], void *values); + + /* Put/Write a row of values. + * The values will be of format _BaseFormat and type DataType. + */ + void (*PutRow)(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, const void *values, const GLubyte *mask); + + /* Put/Write a row of RGB values. This is a special-case routine that's + * only used for RGBA renderbuffers when the source data is GL_RGB. That's + * a common case for glDrawPixels and some triangle routines. + * The values will be of format GL_RGB and type DataType. + */ + void (*PutRowRGB)(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, const void *values, const GLubyte *mask); + + + /* Put/Write a row of identical values. + * The values will be of format _BaseFormat and type DataType. + */ + void (*PutMonoRow)(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, const void *value, const GLubyte *mask); + + /* Put/Write values at arbitrary locations. + * The values will be of format _BaseFormat and type DataType. + */ + void (*PutValues)(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + const GLint x[], const GLint y[], const void *values, + const GLubyte *mask); + /* Put/Write identical values at arbitrary locations. + * The values will be of format _BaseFormat and type DataType. + */ + void (*PutMonoValues)(struct gl_context *ctx, struct gl_renderbuffer *rb, + GLuint count, const GLint x[], const GLint y[], + const void *value, const GLubyte *mask); +}; + + +/** + * A renderbuffer attachment points to either a texture object (and specifies + * a mipmap level, cube face or 3D texture slice) or points to a renderbuffer. + */ +struct gl_renderbuffer_attachment +{ + GLenum Type; /**< \c GL_NONE or \c GL_TEXTURE or \c GL_RENDERBUFFER_EXT */ + GLboolean Complete; + + /** + * If \c Type is \c GL_RENDERBUFFER_EXT, this stores a pointer to the + * application supplied renderbuffer object. + */ + struct gl_renderbuffer *Renderbuffer; + + /** + * If \c Type is \c GL_TEXTURE, this stores a pointer to the application + * supplied texture object. + */ + struct gl_texture_object *Texture; + GLuint TextureLevel; /**< Attached mipmap level. */ + GLuint CubeMapFace; /**< 0 .. 5, for cube map textures. */ + GLuint Zoffset; /**< Slice for 3D textures, or layer for both 1D + * and 2D array textures */ +}; + + +/** + * A framebuffer is a collection of renderbuffers (color, depth, stencil, etc). + * In C++ terms, think of this as a base class from which device drivers + * will make derived classes. + */ +struct gl_framebuffer +{ + _glthread_Mutex Mutex; /**< for thread safety */ + /** + * If zero, this is a window system framebuffer. If non-zero, this + * is a FBO framebuffer; note that for some devices (i.e. those with + * a natural pixel coordinate system for FBOs that differs from the + * OpenGL/Mesa coordinate system), this means that the viewport, + * polygon face orientation, and polygon stipple will have to be inverted. + */ + GLuint Name; + + GLint RefCount; + GLboolean DeletePending; + + /** + * The framebuffer's visual. Immutable if this is a window system buffer. + * Computed from attachments if user-made FBO. + */ + struct gl_config Visual; + + GLboolean Initialized; + + GLuint Width, Height; /**< size of frame buffer in pixels */ + + /** \name Drawing bounds (Intersection of buffer size and scissor box) */ + /*@{*/ + GLint _Xmin, _Xmax; /**< inclusive */ + GLint _Ymin, _Ymax; /**< exclusive */ + /*@}*/ + + /** \name Derived Z buffer stuff */ + /*@{*/ + GLuint _DepthMax; /**< Max depth buffer value */ + GLfloat _DepthMaxF; /**< Float max depth buffer value */ + GLfloat _MRD; /**< minimum resolvable difference in Z values */ + /*@}*/ + + /** One of the GL_FRAMEBUFFER_(IN)COMPLETE_* tokens */ + GLenum _Status; + + /** Integer color values */ + GLboolean _IntegerColor; + + /** Array of all renderbuffer attachments, indexed by BUFFER_* tokens. */ + struct gl_renderbuffer_attachment Attachment[BUFFER_COUNT]; + + /* In unextended OpenGL these vars are part of the GL_COLOR_BUFFER + * attribute group and GL_PIXEL attribute group, respectively. + */ + GLenum ColorDrawBuffer[MAX_DRAW_BUFFERS]; + GLenum ColorReadBuffer; + + /** Computed from ColorDraw/ReadBuffer above */ + GLuint _NumColorDrawBuffers; + GLint _ColorDrawBufferIndexes[MAX_DRAW_BUFFERS]; /**< BUFFER_x or -1 */ + GLint _ColorReadBufferIndex; /* -1 = None */ + struct gl_renderbuffer *_ColorDrawBuffers[MAX_DRAW_BUFFERS]; + struct gl_renderbuffer *_ColorReadBuffer; + + /** The Actual depth/stencil buffers to use. May be wrappers around the + * depth/stencil buffers attached above. */ + struct gl_renderbuffer *_DepthBuffer; + struct gl_renderbuffer *_StencilBuffer; + + /** Delete this framebuffer */ + void (*Delete)(struct gl_framebuffer *fb); +}; + + +/** + * Precision info for shader datatypes. See glGetShaderPrecisionFormat(). + */ +struct gl_precision +{ + GLushort RangeMin; /**< min value exponent */ + GLushort RangeMax; /**< max value exponent */ + GLushort Precision; /**< number of mantissa bits */ +}; + + +/** + * Limits for vertex, geometry and fragment programs/shaders. + */ +struct gl_program_constants +{ + /* logical limits */ + GLuint MaxInstructions; + GLuint MaxAluInstructions; + GLuint MaxTexInstructions; + GLuint MaxTexIndirections; + GLuint MaxAttribs; + GLuint MaxTemps; + GLuint MaxAddressRegs; + GLuint MaxAddressOffset; /**< [-MaxAddressOffset, MaxAddressOffset-1] */ + GLuint MaxParameters; + GLuint MaxLocalParams; + GLuint MaxEnvParams; + /* native/hardware limits */ + GLuint MaxNativeInstructions; + GLuint MaxNativeAluInstructions; + GLuint MaxNativeTexInstructions; + GLuint MaxNativeTexIndirections; + GLuint MaxNativeAttribs; + GLuint MaxNativeTemps; + GLuint MaxNativeAddressRegs; + GLuint MaxNativeParameters; + /* For shaders */ + GLuint MaxUniformComponents; /**< Usually == MaxParameters * 4 */ + /* ES 2.0 and GL_ARB_ES2_compatibility */ + struct gl_precision LowFloat, MediumFloat, HighFloat; + struct gl_precision LowInt, MediumInt, HighInt; +}; + + +/** + * Constants which may be overridden by device driver during context creation + * but are never changed after that. + */ +struct gl_constants +{ + GLint MaxTextureMbytes; /**< Max memory per image, in MB */ + GLint MaxTextureLevels; /**< Max mipmap levels. */ + GLint Max3DTextureLevels; /**< Max mipmap levels for 3D textures */ + GLint MaxCubeTextureLevels; /**< Max mipmap levels for cube textures */ + GLint MaxArrayTextureLayers; /**< Max layers in array textures */ + GLint MaxTextureRectSize; /**< Max rectangle texture size, in pixes */ + GLuint MaxTextureCoordUnits; + GLuint MaxTextureImageUnits; + GLuint MaxVertexTextureImageUnits; + GLuint MaxCombinedTextureImageUnits; + GLuint MaxGeometryTextureImageUnits; + GLuint MaxTextureUnits; /**< = MIN(CoordUnits, ImageUnits) */ + GLfloat MaxTextureMaxAnisotropy; /**< GL_EXT_texture_filter_anisotropic */ + GLfloat MaxTextureLodBias; /**< GL_EXT_texture_lod_bias */ + GLuint MaxTextureBufferSize; /**< GL_ARB_texture_buffer_object */ + + GLuint MaxArrayLockSize; + + GLint SubPixelBits; + + GLfloat MinPointSize, MaxPointSize; /**< aliased */ + GLfloat MinPointSizeAA, MaxPointSizeAA; /**< antialiased */ + GLfloat PointSizeGranularity; + GLfloat MinLineWidth, MaxLineWidth; /**< aliased */ + GLfloat MinLineWidthAA, MaxLineWidthAA; /**< antialiased */ + GLfloat LineWidthGranularity; + + GLuint MaxColorTableSize; + + GLuint MaxClipPlanes; + GLuint MaxLights; + GLfloat MaxShininess; /**< GL_NV_light_max_exponent */ + GLfloat MaxSpotExponent; /**< GL_NV_light_max_exponent */ + + GLuint MaxViewportWidth, MaxViewportHeight; + + struct gl_program_constants VertexProgram; /**< GL_ARB_vertex_program */ + struct gl_program_constants FragmentProgram; /**< GL_ARB_fragment_program */ + struct gl_program_constants GeometryProgram; /**< GL_ARB_geometry_shader4 */ + GLuint MaxProgramMatrices; + GLuint MaxProgramMatrixStackDepth; + + /** vertex array / buffer object bounds checking */ + GLboolean CheckArrayBounds; + + GLuint MaxDrawBuffers; /**< GL_ARB_draw_buffers */ + + GLuint MaxColorAttachments; /**< GL_EXT_framebuffer_object */ + GLuint MaxRenderbufferSize; /**< GL_EXT_framebuffer_object */ + GLuint MaxSamples; /**< GL_ARB_framebuffer_object */ + + /** Number of varying vectors between vertex and fragment shaders */ + GLuint MaxVarying; + GLuint MaxVertexVaryingComponents; /**< Between vert and geom shader */ + GLuint MaxGeometryVaryingComponents; /**< Between geom and frag shader */ + + /** GL_ARB_geometry_shader4 */ + GLuint MaxGeometryOutputVertices; + GLuint MaxGeometryTotalOutputComponents; + + GLuint GLSLVersion; /**< GLSL version supported (ex: 120 = 1.20) */ + + /** Which texture units support GL_ATI_envmap_bumpmap as targets */ + GLbitfield SupportedBumpUnits; + + /** + * Maximum amount of time, measured in nanseconds, that the server can wait. + */ + GLuint64 MaxServerWaitTimeout; + + /** GL_EXT_provoking_vertex */ + GLboolean QuadsFollowProvokingVertexConvention; + + /** OpenGL version 3.0 */ + GLbitfield ContextFlags; /**< Ex: GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT */ + + /** OpenGL version 3.2 */ + GLbitfield ProfileMask; /**< Mask of CONTEXT_x_PROFILE_BIT */ + + /** GL_EXT_transform_feedback */ + GLuint MaxTransformFeedbackSeparateAttribs; + GLuint MaxTransformFeedbackSeparateComponents; + GLuint MaxTransformFeedbackInterleavedComponents; + + /** GL_EXT_gpu_shader4 */ + GLint MinProgramTexelOffset, MaxProgramTexelOffset; + + /* GL_EXT_framebuffer_sRGB */ + GLboolean sRGBCapable; /* can enable sRGB blend/update on FBOs */ + + /* GL_ARB_robustness */ + GLenum ResetStrategy; +}; + + +/** + * Enable flag for each OpenGL extension. Different device drivers will + * enable different extensions at runtime. + */ +struct gl_extensions +{ + GLboolean dummy; /* don't remove this! */ + GLboolean dummy_true; /* Set true by _mesa_init_extensions(). */ + GLboolean dummy_false; /* Set false by _mesa_init_extensions(). */ + GLboolean ARB_ES2_compatibility; + GLboolean ARB_blend_func_extended; + GLboolean ARB_color_buffer_float; + GLboolean ARB_copy_buffer; + GLboolean ARB_depth_buffer_float; + GLboolean ARB_depth_clamp; + GLboolean ARB_depth_texture; + GLboolean ARB_draw_buffers; + GLboolean ARB_draw_buffers_blend; + GLboolean ARB_draw_elements_base_vertex; + GLboolean ARB_draw_instanced; + GLboolean ARB_fragment_coord_conventions; + GLboolean ARB_fragment_program; + GLboolean ARB_fragment_program_shadow; + GLboolean ARB_fragment_shader; + GLboolean ARB_framebuffer_object; + GLboolean ARB_explicit_attrib_location; + GLboolean ARB_geometry_shader4; + GLboolean ARB_half_float_pixel; + GLboolean ARB_half_float_vertex; + GLboolean ARB_instanced_arrays; + GLboolean ARB_map_buffer_range; + GLboolean ARB_multisample; + GLboolean ARB_multitexture; + GLboolean ARB_occlusion_query; + GLboolean ARB_occlusion_query2; + GLboolean ARB_point_sprite; + GLboolean ARB_sampler_objects; + GLboolean ARB_seamless_cube_map; + GLboolean ARB_shader_objects; + GLboolean ARB_shader_stencil_export; + GLboolean ARB_shader_texture_lod; + GLboolean ARB_shading_language_100; + GLboolean ARB_shadow; + GLboolean ARB_shadow_ambient; + GLboolean ARB_sync; + GLboolean ARB_texture_border_clamp; + GLboolean ARB_texture_buffer_object; + GLboolean ARB_texture_compression; + GLboolean ARB_texture_compression_rgtc; + GLboolean ARB_texture_cube_map; + GLboolean ARB_texture_env_combine; + GLboolean ARB_texture_env_crossbar; + GLboolean ARB_texture_env_dot3; + GLboolean ARB_texture_float; + GLboolean ARB_texture_mirrored_repeat; + GLboolean ARB_texture_multisample; + GLboolean ARB_texture_non_power_of_two; + GLboolean ARB_texture_rg; + GLboolean ARB_texture_rgb10_a2ui; + GLboolean ARB_timer_query; + GLboolean ARB_transform_feedback2; + GLboolean ARB_transpose_matrix; + GLboolean ARB_uniform_buffer_object; + GLboolean ARB_vertex_array_object; + GLboolean ARB_vertex_buffer_object; + GLboolean ARB_vertex_program; + GLboolean ARB_vertex_shader; + GLboolean ARB_vertex_type_2_10_10_10_rev; + GLboolean ARB_window_pos; + GLboolean EXT_abgr; + GLboolean EXT_bgra; + GLboolean EXT_blend_color; + GLboolean EXT_blend_equation_separate; + GLboolean EXT_blend_func_separate; + GLboolean EXT_blend_logic_op; + GLboolean EXT_blend_minmax; + GLboolean EXT_blend_subtract; + GLboolean EXT_clip_volume_hint; + GLboolean EXT_compiled_vertex_array; + GLboolean EXT_copy_texture; + GLboolean EXT_depth_bounds_test; + GLboolean EXT_draw_buffers2; + GLboolean EXT_draw_range_elements; + GLboolean EXT_fog_coord; + GLboolean EXT_framebuffer_blit; + GLboolean EXT_framebuffer_multisample; + GLboolean EXT_framebuffer_object; + GLboolean EXT_framebuffer_sRGB; + GLboolean EXT_gpu_program_parameters; + GLboolean EXT_gpu_shader4; + GLboolean EXT_multi_draw_arrays; + GLboolean EXT_paletted_texture; + GLboolean EXT_packed_depth_stencil; + GLboolean EXT_packed_float; + GLboolean EXT_packed_pixels; + GLboolean EXT_pixel_buffer_object; + GLboolean EXT_point_parameters; + GLboolean EXT_polygon_offset; + GLboolean EXT_provoking_vertex; + GLboolean EXT_rescale_normal; + GLboolean EXT_shadow_funcs; + GLboolean EXT_secondary_color; + GLboolean EXT_separate_shader_objects; + GLboolean EXT_separate_specular_color; + GLboolean EXT_shared_texture_palette; + GLboolean EXT_stencil_wrap; + GLboolean EXT_stencil_two_side; + GLboolean EXT_subtexture; + GLboolean EXT_texture; + GLboolean EXT_texture_object; + GLboolean EXT_texture3D; + GLboolean EXT_texture_array; + GLboolean EXT_texture_compression_latc; + GLboolean EXT_texture_compression_s3tc; + GLboolean EXT_texture_env_add; + GLboolean EXT_texture_env_combine; + GLboolean EXT_texture_env_dot3; + GLboolean EXT_texture_filter_anisotropic; + GLboolean EXT_texture_integer; + GLboolean EXT_texture_lod_bias; + GLboolean EXT_texture_mirror_clamp; + GLboolean EXT_texture_shared_exponent; + GLboolean EXT_texture_snorm; + GLboolean EXT_texture_sRGB; + GLboolean EXT_texture_sRGB_decode; + GLboolean EXT_texture_swizzle; + GLboolean EXT_transform_feedback; + GLboolean EXT_timer_query; + GLboolean EXT_vertex_array; + GLboolean EXT_vertex_array_bgra; + GLboolean EXT_vertex_array_set; + GLboolean OES_standard_derivatives; + /* vendor extensions */ + GLboolean AMD_conservative_depth; + GLboolean AMD_seamless_cubemap_per_texture; + GLboolean APPLE_client_storage; + GLboolean APPLE_packed_pixels; + GLboolean APPLE_vertex_array_object; + GLboolean APPLE_object_purgeable; + GLboolean ATI_envmap_bumpmap; + GLboolean ATI_texture_compression_3dc; + GLboolean ATI_texture_mirror_once; + GLboolean ATI_texture_env_combine3; + GLboolean ATI_fragment_shader; + GLboolean ATI_separate_stencil; + GLboolean IBM_rasterpos_clip; + GLboolean IBM_multimode_draw_arrays; + GLboolean MESA_pack_invert; + GLboolean MESA_resize_buffers; + GLboolean MESA_ycbcr_texture; + GLboolean MESA_texture_array; + GLboolean NV_blend_square; + GLboolean NV_conditional_render; + GLboolean NV_fragment_program; + GLboolean NV_fragment_program_option; + GLboolean NV_light_max_exponent; + GLboolean NV_point_sprite; + GLboolean NV_primitive_restart; + GLboolean NV_texture_barrier; + GLboolean NV_texgen_reflection; + GLboolean NV_texture_env_combine4; + GLboolean NV_texture_rectangle; + GLboolean NV_vertex_program; + GLboolean NV_vertex_program1_1; + GLboolean OES_read_format; + GLboolean SGIS_generate_mipmap; + GLboolean SGIS_texture_edge_clamp; + GLboolean SGIS_texture_lod; + GLboolean TDFX_texture_compression_FXT1; + GLboolean S3_s3tc; + GLboolean OES_EGL_image; + GLboolean OES_draw_texture; + GLboolean EXT_texture_format_BGRA8888; + GLboolean extension_sentinel; + /** The extension string */ + const GLubyte *String; + /** Number of supported extensions */ + GLuint Count; +}; + + +/** + * A stack of matrices (projection, modelview, color, texture, etc). + */ +struct gl_matrix_stack +{ + GLmatrix *Top; /**< points into Stack */ + GLmatrix *Stack; /**< array [MaxDepth] of GLmatrix */ + GLuint Depth; /**< 0 <= Depth < MaxDepth */ + GLuint MaxDepth; /**< size of Stack[] array */ + GLuint DirtyFlag; /**< _NEW_MODELVIEW or _NEW_PROJECTION, for example */ +}; + + +/** + * \name Bits for image transfer operations + * \sa __struct gl_contextRec::ImageTransferState. + */ +/*@{*/ +#define IMAGE_SCALE_BIAS_BIT 0x1 +#define IMAGE_SHIFT_OFFSET_BIT 0x2 +#define IMAGE_MAP_COLOR_BIT 0x4 +#define IMAGE_CLAMP_BIT 0x800 + + +/** Pixel Transfer ops */ +#define IMAGE_BITS (IMAGE_SCALE_BIAS_BIT | \ + IMAGE_SHIFT_OFFSET_BIT | \ + IMAGE_MAP_COLOR_BIT) + +/** + * \name Bits to indicate what state has changed. + */ +/*@{*/ +#define _NEW_MODELVIEW (1 << 0) /**< gl_context::ModelView */ +#define _NEW_PROJECTION (1 << 1) /**< gl_context::Projection */ +#define _NEW_TEXTURE_MATRIX (1 << 2) /**< gl_context::TextureMatrix */ +#define _NEW_COLOR (1 << 3) /**< gl_context::Color */ +#define _NEW_DEPTH (1 << 4) /**< gl_context::Depth */ +#define _NEW_EVAL (1 << 5) /**< gl_context::Eval, EvalMap */ +#define _NEW_FOG (1 << 6) /**< gl_context::Fog */ +#define _NEW_HINT (1 << 7) /**< gl_context::Hint */ +#define _NEW_LIGHT (1 << 8) /**< gl_context::Light */ +#define _NEW_LINE (1 << 9) /**< gl_context::Line */ +#define _NEW_PIXEL (1 << 10) /**< gl_context::Pixel */ +#define _NEW_POINT (1 << 11) /**< gl_context::Point */ +#define _NEW_POLYGON (1 << 12) /**< gl_context::Polygon */ +#define _NEW_POLYGONSTIPPLE (1 << 13) /**< gl_context::PolygonStipple */ +#define _NEW_SCISSOR (1 << 14) /**< gl_context::Scissor */ +#define _NEW_STENCIL (1 << 15) /**< gl_context::Stencil */ +#define _NEW_TEXTURE (1 << 16) /**< gl_context::Texture */ +#define _NEW_TRANSFORM (1 << 17) /**< gl_context::Transform */ +#define _NEW_VIEWPORT (1 << 18) /**< gl_context::Viewport */ +#define _NEW_PACKUNPACK (1 << 19) /**< gl_context::Pack, Unpack */ +#define _NEW_ARRAY (1 << 20) /**< gl_context::Array */ +#define _NEW_RENDERMODE (1 << 21) /**< gl_context::RenderMode, etc */ +#define _NEW_BUFFERS (1 << 22) /**< gl_context::Visual, DrawBuffer, */ +#define _NEW_CURRENT_ATTRIB (1 << 23) /**< gl_context::Current */ +#define _NEW_MULTISAMPLE (1 << 24) /**< gl_context::Multisample */ +#define _NEW_TRACK_MATRIX (1 << 25) /**< gl_context::VertexProgram */ +#define _NEW_PROGRAM (1 << 26) /**< New program/shader state */ +#define _NEW_PROGRAM_CONSTANTS (1 << 27) +#define _NEW_BUFFER_OBJECT (1 << 28) +#define _NEW_FRAG_CLAMP (1 << 29) +#define _NEW_ALL ~0 +/*@}*/ + + +/** + * \name Bits to track array state changes + * + * Also used to summarize array enabled. + */ +/*@{*/ +#define _NEW_ARRAY_VERTEX VERT_BIT_POS +#define _NEW_ARRAY_WEIGHT VERT_BIT_WEIGHT +#define _NEW_ARRAY_NORMAL VERT_BIT_NORMAL +#define _NEW_ARRAY_COLOR0 VERT_BIT_COLOR0 +#define _NEW_ARRAY_COLOR1 VERT_BIT_COLOR1 +#define _NEW_ARRAY_FOGCOORD VERT_BIT_FOG +#define _NEW_ARRAY_INDEX VERT_BIT_COLOR_INDEX +#define _NEW_ARRAY_EDGEFLAG VERT_BIT_EDGEFLAG +#define _NEW_ARRAY_POINT_SIZE VERT_BIT_COLOR_INDEX /* aliased */ +#define _NEW_ARRAY_TEXCOORD_0 VERT_BIT_TEX0 +#define _NEW_ARRAY_TEXCOORD_1 VERT_BIT_TEX1 +#define _NEW_ARRAY_TEXCOORD_2 VERT_BIT_TEX2 +#define _NEW_ARRAY_TEXCOORD_3 VERT_BIT_TEX3 +#define _NEW_ARRAY_TEXCOORD_4 VERT_BIT_TEX4 +#define _NEW_ARRAY_TEXCOORD_5 VERT_BIT_TEX5 +#define _NEW_ARRAY_TEXCOORD_6 VERT_BIT_TEX6 +#define _NEW_ARRAY_TEXCOORD_7 VERT_BIT_TEX7 +#define _NEW_ARRAY_ATTRIB_0 VERT_BIT_GENERIC0 /* start at bit 16 */ +#define _NEW_ARRAY_ALL 0xffffffff + + +#define _NEW_ARRAY_TEXCOORD(i) (_NEW_ARRAY_TEXCOORD_0 << (i)) +#define _NEW_ARRAY_ATTRIB(i) (_NEW_ARRAY_ATTRIB_0 << (i)) +/*@}*/ + + + +/** + * \name A bunch of flags that we think might be useful to drivers. + * + * Set in the __struct gl_contextRec::_TriangleCaps bitfield. + */ +/*@{*/ +#define DD_FLATSHADE 0x1 +#define DD_SEPARATE_SPECULAR 0x2 +#define DD_TRI_CULL_FRONT_BACK 0x4 /* special case on some hw */ +#define DD_TRI_LIGHT_TWOSIDE 0x8 +#define DD_TRI_UNFILLED 0x10 +#define DD_TRI_SMOOTH 0x20 +#define DD_TRI_STIPPLE 0x40 +#define DD_TRI_OFFSET 0x80 +#define DD_LINE_SMOOTH 0x100 +#define DD_LINE_STIPPLE 0x200 +#define DD_POINT_SMOOTH 0x400 +#define DD_POINT_ATTEN 0x800 +#define DD_TRI_TWOSTENCIL 0x1000 +/*@}*/ + + +/** + * \name Define the state changes under which each of these bits might change + */ +/*@{*/ +#define _DD_NEW_FLATSHADE _NEW_LIGHT +#define _DD_NEW_SEPARATE_SPECULAR (_NEW_LIGHT | _NEW_FOG | _NEW_PROGRAM) +#define _DD_NEW_TRI_CULL_FRONT_BACK _NEW_POLYGON +#define _DD_NEW_TRI_LIGHT_TWOSIDE _NEW_LIGHT +#define _DD_NEW_TRI_UNFILLED _NEW_POLYGON +#define _DD_NEW_TRI_SMOOTH _NEW_POLYGON +#define _DD_NEW_TRI_STIPPLE _NEW_POLYGON +#define _DD_NEW_TRI_OFFSET _NEW_POLYGON +#define _DD_NEW_LINE_SMOOTH _NEW_LINE +#define _DD_NEW_LINE_STIPPLE _NEW_LINE +#define _DD_NEW_LINE_WIDTH _NEW_LINE +#define _DD_NEW_POINT_SMOOTH _NEW_POINT +#define _DD_NEW_POINT_SIZE _NEW_POINT +#define _DD_NEW_POINT_ATTEN _NEW_POINT +/*@}*/ + + +/** + * Composite state flags + */ +/*@{*/ +#define _MESA_NEW_NEED_EYE_COORDS (_NEW_LIGHT | \ + _NEW_TEXTURE | \ + _NEW_POINT | \ + _NEW_PROGRAM | \ + _NEW_MODELVIEW) +/*@}*/ + + + + +/* This has to be included here. */ +#include "dd.h" + + +/** + * Display list flags. + * Strictly this is a tnl-private concept, but it doesn't seem + * worthwhile adding a tnl private structure just to hold this one bit + * of information: + */ +#define DLIST_DANGLING_REFS 0x1 + + +/** Opaque declaration of display list payload data type */ +union gl_dlist_node; + + +/** + * Provide a location where information about a display list can be + * collected. Could be extended with driverPrivate structures, + * etc. in the future. + */ +struct gl_display_list +{ + GLuint Name; + GLbitfield Flags; /**< DLIST_x flags */ + /** The dlist commands are in a linked list of nodes */ + union gl_dlist_node *Head; +}; + + +/** + * State used during display list compilation and execution. + */ +struct gl_dlist_state +{ + GLuint CallDepth; /**< Current recursion calling depth */ + + struct gl_display_list *CurrentList; /**< List currently being compiled */ + union gl_dlist_node *CurrentBlock; /**< Pointer to current block of nodes */ + GLuint CurrentPos; /**< Index into current block of nodes */ + + GLvertexformat ListVtxfmt; + + GLubyte ActiveAttribSize[VERT_ATTRIB_MAX]; + GLfloat CurrentAttrib[VERT_ATTRIB_MAX][4]; + + GLubyte ActiveMaterialSize[MAT_ATTRIB_MAX]; + GLfloat CurrentMaterial[MAT_ATTRIB_MAX][4]; + + GLubyte ActiveIndex; + GLfloat CurrentIndex; + + GLubyte ActiveEdgeFlag; + GLboolean CurrentEdgeFlag; + + struct { + /* State known to have been set by the currently-compiling display + * list. Used to eliminate some redundant state changes. + */ + GLenum ShadeModel; + } Current; +}; + + +/** + * Enum for the OpenGL APIs we know about and may support. + */ +typedef enum +{ + API_OPENGL, + API_OPENGLES, + API_OPENGLES2 +} gl_api; + + +/** + * Mesa rendering context. + * + * This is the central context data structure for Mesa. Almost all + * OpenGL state is contained in this structure. + * Think of this as a base class from which device drivers will derive + * sub classes. + * + * The struct gl_context typedef names this structure. + */ +struct gl_context +{ + /** State possibly shared with other contexts in the address space */ + struct gl_shared_state *Shared; + + /** \name API function pointer tables */ + /*@{*/ + gl_api API; + struct _glapi_table *Save; /**< Display list save functions */ + struct _glapi_table *Exec; /**< Execute functions */ + struct _glapi_table *CurrentDispatch; /**< == Save or Exec !! */ + /*@}*/ + + struct gl_config Visual; + struct gl_framebuffer *DrawBuffer; /**< buffer for writing */ + struct gl_framebuffer *ReadBuffer; /**< buffer for reading */ + struct gl_framebuffer *WinSysDrawBuffer; /**< set with MakeCurrent */ + struct gl_framebuffer *WinSysReadBuffer; /**< set with MakeCurrent */ + + /** + * Device driver function pointer table + */ + struct dd_function_table Driver; + + void *DriverCtx; /**< Points to device driver context/state */ + + /** Core/Driver constants */ + struct gl_constants Const; + + /** \name The various 4x4 matrix stacks */ + /*@{*/ + struct gl_matrix_stack ModelviewMatrixStack; + struct gl_matrix_stack ProjectionMatrixStack; + struct gl_matrix_stack TextureMatrixStack[MAX_TEXTURE_UNITS]; + struct gl_matrix_stack ProgramMatrixStack[MAX_PROGRAM_MATRICES]; + struct gl_matrix_stack *CurrentStack; /**< Points to one of the above stacks */ + /*@}*/ + + /** Combined modelview and projection matrix */ + GLmatrix _ModelProjectMatrix; + + /** \name Display lists */ + struct gl_dlist_state ListState; + + GLboolean ExecuteFlag; /**< Execute GL commands? */ + GLboolean CompileFlag; /**< Compile GL commands into display list? */ + + /** Extension information */ + struct gl_extensions Extensions; + + /** Version info */ + GLuint VersionMajor, VersionMinor; + char *VersionString; + + /** \name State attribute stack (for glPush/PopAttrib) */ + /*@{*/ + GLuint AttribStackDepth; + struct gl_attrib_node *AttribStack[MAX_ATTRIB_STACK_DEPTH]; + /*@}*/ + + /** \name Renderer attribute groups + * + * We define a struct for each attribute group to make pushing and popping + * attributes easy. Also it's a good organization. + */ + /*@{*/ + struct gl_accum_attrib Accum; /**< Accum buffer attributes */ + struct gl_colorbuffer_attrib Color; /**< Color buffer attributes */ + struct gl_current_attrib Current; /**< Current attributes */ + struct gl_depthbuffer_attrib Depth; /**< Depth buffer attributes */ + struct gl_eval_attrib Eval; /**< Eval attributes */ + struct gl_fog_attrib Fog; /**< Fog attributes */ + struct gl_hint_attrib Hint; /**< Hint attributes */ + struct gl_light_attrib Light; /**< Light attributes */ + struct gl_line_attrib Line; /**< Line attributes */ + struct gl_list_attrib List; /**< List attributes */ + struct gl_multisample_attrib Multisample; + struct gl_pixel_attrib Pixel; /**< Pixel attributes */ + struct gl_point_attrib Point; /**< Point attributes */ + struct gl_polygon_attrib Polygon; /**< Polygon attributes */ + GLuint PolygonStipple[32]; /**< Polygon stipple */ + struct gl_scissor_attrib Scissor; /**< Scissor attributes */ + struct gl_stencil_attrib Stencil; /**< Stencil buffer attributes */ + struct gl_texture_attrib Texture; /**< Texture attributes */ + struct gl_transform_attrib Transform; /**< Transformation attributes */ + struct gl_viewport_attrib Viewport; /**< Viewport attributes */ + /*@}*/ + + /** \name Client attribute stack */ + /*@{*/ + GLuint ClientAttribStackDepth; + struct gl_attrib_node *ClientAttribStack[MAX_CLIENT_ATTRIB_STACK_DEPTH]; + /*@}*/ + + /** \name Client attribute groups */ + /*@{*/ + struct gl_array_attrib Array; /**< Vertex arrays */ + struct gl_pixelstore_attrib Pack; /**< Pixel packing */ + struct gl_pixelstore_attrib Unpack; /**< Pixel unpacking */ + struct gl_pixelstore_attrib DefaultPacking; /**< Default params */ + /*@}*/ + + /** \name Other assorted state (not pushed/popped on attribute stack) */ + /*@{*/ + struct gl_pixelmaps PixelMaps; + + struct gl_evaluators EvalMap; /**< All evaluators */ + struct gl_feedback Feedback; /**< Feedback */ + struct gl_selection Select; /**< Selection */ + + struct gl_program_state Program; /**< general program state */ + struct gl_vertex_program_state VertexProgram; + struct gl_fragment_program_state FragmentProgram; + struct gl_geometry_program_state GeometryProgram; + struct gl_ati_fragment_shader_state ATIFragmentShader; + + struct gl_shader_state Shader; /**< GLSL shader object state */ + struct gl_shader_compiler_options ShaderCompilerOptions[MESA_SHADER_TYPES]; + + struct gl_query_state Query; /**< occlusion, timer queries */ + + struct gl_transform_feedback TransformFeedback; + + struct gl_buffer_object *CopyReadBuffer; /**< GL_ARB_copy_buffer */ + struct gl_buffer_object *CopyWriteBuffer; /**< GL_ARB_copy_buffer */ + /*@}*/ + + struct gl_meta_state *Meta; /**< for "meta" operations */ + + /* GL_EXT_framebuffer_object */ + struct gl_renderbuffer *CurrentRenderbuffer; + + GLenum ErrorValue; /**< Last error code */ + + /* GL_ARB_robustness */ + GLenum ResetStatus; + + /** + * Recognize and silence repeated error debug messages in buggy apps. + */ + const char *ErrorDebugFmtString; + GLuint ErrorDebugCount; + + GLenum RenderMode; /**< either GL_RENDER, GL_SELECT, GL_FEEDBACK */ + GLbitfield NewState; /**< bitwise-or of _NEW_* flags */ + + GLboolean ViewportInitialized; /**< has viewport size been initialized? */ + + GLbitfield varying_vp_inputs; /**< mask of VERT_BIT_* flags */ + + /** \name Derived state */ + /*@{*/ + /** Bitwise-or of DD_* flags. Note that this bitfield may be used before + * state validation so they need to always be current. + */ + GLbitfield _TriangleCaps; + GLbitfield _ImageTransferState;/**< bitwise-or of IMAGE_*_BIT flags */ + GLfloat _EyeZDir[3]; + GLfloat _ModelViewInvScale; + GLboolean _NeedEyeCoords; + GLboolean _ForceEyeCoords; + + GLuint TextureStateTimestamp; /**< detect changes to shared state */ + + struct gl_shine_tab *_ShineTable[2]; /**< Active shine tables */ + struct gl_shine_tab *_ShineTabList; /**< MRU list of inactive shine tables */ + /**@}*/ + + struct gl_list_extensions *ListExt; /**< driver dlist extensions */ + + /** \name For debugging/development only */ + /*@{*/ + GLboolean FirstTimeCurrent; + /*@}*/ + + /** software compression/decompression supported or not */ + GLboolean Mesa_DXTn; + + GLboolean TextureFormatSupported[MESA_FORMAT_COUNT]; + + /** + * Use dp4 (rather than mul/mad) instructions for position + * transformation? + */ + GLboolean mvp_with_dp4; + + /** + * \name Hooks for module contexts. + * + * These will eventually live in the driver or elsewhere. + */ + /*@{*/ + void *swrast_context; + void *swsetup_context; + void *swtnl_context; + void *swtnl_im; + struct st_context *st; + void *aelt_context; + /*@}*/ +}; + + +#ifdef DEBUG +extern int MESA_VERBOSE; +extern int MESA_DEBUG_FLAGS; +# define MESA_FUNCTION __FUNCTION__ +#else +# define MESA_VERBOSE 0 +# define MESA_DEBUG_FLAGS 0 +# define MESA_FUNCTION "a function" +# ifndef NDEBUG +# define NDEBUG +# endif +#endif + + +/** The MESA_VERBOSE var is a bitmask of these flags */ +enum _verbose +{ + VERBOSE_VARRAY = 0x0001, + VERBOSE_TEXTURE = 0x0002, + VERBOSE_MATERIAL = 0x0004, + VERBOSE_PIPELINE = 0x0008, + VERBOSE_DRIVER = 0x0010, + VERBOSE_STATE = 0x0020, + VERBOSE_API = 0x0040, + VERBOSE_DISPLAY_LIST = 0x0100, + VERBOSE_LIGHTING = 0x0200, + VERBOSE_PRIMS = 0x0400, + VERBOSE_VERTS = 0x0800, + VERBOSE_DISASSEM = 0x1000, + VERBOSE_DRAW = 0x2000, + VERBOSE_SWAPBUFFERS = 0x4000 +}; + + +/** The MESA_DEBUG_FLAGS var is a bitmask of these flags */ +enum _debug +{ + DEBUG_ALWAYS_FLUSH = 0x1 +}; + + + +#endif /* MTYPES_H */ diff --git a/3rdparty/glsl-optimizer/src/mesa/main/shaderobj.h b/3rdparty/glsl-optimizer/src/mesa/main/shaderobj.h new file mode 100644 index 000000000..de7c998cf --- /dev/null +++ b/3rdparty/glsl-optimizer/src/mesa/main/shaderobj.h @@ -0,0 +1,137 @@ +/* + * Mesa 3-D graphics library + * Version: 6.5.3 + * + * Copyright (C) 2004-2007 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#ifndef SHADEROBJ_H +#define SHADEROBJ_H + + +#include "main/compiler.h" +#include "main/glheader.h" +#include "main/mtypes.h" +#include "program/ir_to_mesa.h" + +#ifdef __cplusplus +extern "C" { +#endif +/** + * Internal functions + */ + +extern void +_mesa_init_shader_state(struct gl_context * ctx); + +extern void +_mesa_free_shader_state(struct gl_context *ctx); + + +extern void +_mesa_reference_shader(struct gl_context *ctx, struct gl_shader **ptr, + struct gl_shader *sh); + +extern struct gl_shader * +_mesa_lookup_shader(struct gl_context *ctx, GLuint name); + +extern struct gl_shader * +_mesa_lookup_shader_err(struct gl_context *ctx, GLuint name, const char *caller); + + + +extern void +_mesa_reference_shader_program(struct gl_context *ctx, + struct gl_shader_program **ptr, + struct gl_shader_program *shProg); +extern void +_mesa_init_shader(struct gl_context *ctx, struct gl_shader *shader); + +extern struct gl_shader * +_mesa_new_shader(struct gl_context *ctx, GLuint name, GLenum type); + +extern void +_mesa_init_shader_program(struct gl_context *ctx, struct gl_shader_program *prog); + +extern struct gl_shader_program * +_mesa_lookup_shader_program(struct gl_context *ctx, GLuint name); + +extern struct gl_shader_program * +_mesa_lookup_shader_program_err(struct gl_context *ctx, GLuint name, + const char *caller); + +extern void +_mesa_clear_shader_program_data(struct gl_context *ctx, + struct gl_shader_program *shProg); + +extern void +_mesa_free_shader_program_data(struct gl_context *ctx, + struct gl_shader_program *shProg); + + + +extern void +_mesa_init_shader_object_functions(struct dd_function_table *driver); + +extern void +_mesa_init_shader_state(struct gl_context *ctx); + +extern void +_mesa_free_shader_state(struct gl_context *ctx); + + +static INLINE gl_shader_type +_mesa_shader_type_to_index(GLenum v) +{ + switch (v) { + case GL_VERTEX_SHADER: + return MESA_SHADER_VERTEX; + case GL_FRAGMENT_SHADER: + return MESA_SHADER_FRAGMENT; + case GL_GEOMETRY_SHADER: + return MESA_SHADER_GEOMETRY; + default: + ASSERT(0 && "bad value in _mesa_shader_type_to_index()"); + return MESA_SHADER_TYPES; + } +} + + +static INLINE GLenum +_mesa_shader_index_to_type(GLuint i) +{ + static const GLenum enums[MESA_SHADER_TYPES] = { + GL_VERTEX_SHADER, + GL_FRAGMENT_SHADER, + GL_GEOMETRY_SHADER , + }; + if (i >= MESA_SHADER_TYPES) + return 0; + else + return enums[i]; +} + + +#ifdef __cplusplus +} +#endif + +#endif /* SHADEROBJ_H */ diff --git a/3rdparty/glsl-optimizer/src/mesa/main/simple_list.h b/3rdparty/glsl-optimizer/src/mesa/main/simple_list.h new file mode 100644 index 000000000..ff7f88823 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/mesa/main/simple_list.h @@ -0,0 +1,202 @@ +/** + * \file simple_list.h + * Simple macros for type-safe, intrusive lists. + * + * Intended to work with a list sentinal which is created as an empty + * list. Insert & delete are O(1). + * + * \author + * (C) 1997, Keith Whitwell + */ + +/* + * Mesa 3-D graphics library + * Version: 3.5 + * + * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#ifndef _SIMPLE_LIST_H +#define _SIMPLE_LIST_H + +struct simple_node { + struct simple_node *next; + struct simple_node *prev; +}; + +/** + * Remove an element from list. + * + * \param elem element to remove. + */ +#define remove_from_list(elem) \ +do { \ + (elem)->next->prev = (elem)->prev; \ + (elem)->prev->next = (elem)->next; \ +} while (0) + +/** + * Insert an element to the list head. + * + * \param list list. + * \param elem element to insert. + */ +#define insert_at_head(list, elem) \ +do { \ + (elem)->prev = list; \ + (elem)->next = (list)->next; \ + (list)->next->prev = elem; \ + (list)->next = elem; \ +} while(0) + +/** + * Insert an element to the list tail. + * + * \param list list. + * \param elem element to insert. + */ +#define insert_at_tail(list, elem) \ +do { \ + (elem)->next = list; \ + (elem)->prev = (list)->prev; \ + (list)->prev->next = elem; \ + (list)->prev = elem; \ +} while(0) + +/** + * Move an element to the list head. + * + * \param list list. + * \param elem element to move. + */ +#define move_to_head(list, elem) \ +do { \ + remove_from_list(elem); \ + insert_at_head(list, elem); \ +} while (0) + +/** + * Move an element to the list tail. + * + * \param list list. + * \param elem element to move. + */ +#define move_to_tail(list, elem) \ +do { \ + remove_from_list(elem); \ + insert_at_tail(list, elem); \ +} while (0) + +/** + * Make a empty list empty. + * + * \param sentinal list (sentinal element). + */ +#define make_empty_list(sentinal) \ +do { \ + (sentinal)->next = sentinal; \ + (sentinal)->prev = sentinal; \ +} while (0) + +/** + * Get list first element. + * + * \param list list. + * + * \return pointer to first element. + */ +#define first_elem(list) ((list)->next) + +/** + * Get list last element. + * + * \param list list. + * + * \return pointer to last element. + */ +#define last_elem(list) ((list)->prev) + +/** + * Get next element. + * + * \param elem element. + * + * \return pointer to next element. + */ +#define next_elem(elem) ((elem)->next) + +/** + * Get previous element. + * + * \param elem element. + * + * \return pointer to previous element. + */ +#define prev_elem(elem) ((elem)->prev) + +/** + * Test whether element is at end of the list. + * + * \param list list. + * \param elem element. + * + * \return non-zero if element is at end of list, or zero otherwise. + */ +#define at_end(list, elem) ((elem) == (list)) + +/** + * Test if a list is empty. + * + * \param list list. + * + * \return non-zero if list empty, or zero otherwise. + */ +#define is_empty_list(list) ((list)->next == (list)) + +/** + * Walk through the elements of a list. + * + * \param ptr pointer to the current element. + * \param list list. + * + * \note It should be followed by a { } block or a single statement, as in a \c + * for loop. + */ +#define foreach(ptr, list) \ + for( ptr=(list)->next ; ptr!=list ; ptr=(ptr)->next ) + +/** + * Walk through the elements of a list. + * + * Same as #foreach but lets you unlink the current value during a list + * traversal. Useful for freeing a list, element by element. + * + * \param ptr pointer to the current element. + * \param t temporary pointer. + * \param list list. + * + * \note It should be followed by a { } block or a single statement, as in a \c + * for loop. + */ +#define foreach_s(ptr, t, list) \ + for(ptr=(list)->next,t=(ptr)->next; list != ptr; ptr=t, t=(t)->next) + +#endif diff --git a/3rdparty/glsl-optimizer/src/mesa/main/uniforms.h b/3rdparty/glsl-optimizer/src/mesa/main/uniforms.h new file mode 100644 index 000000000..b024cb30b --- /dev/null +++ b/3rdparty/glsl-optimizer/src/mesa/main/uniforms.h @@ -0,0 +1,208 @@ +/* + * Mesa 3-D graphics library + * + * Copyright (C) 2010 VMware, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#ifndef UNIFORMS_H +#define UNIFORMS_H + +#include "glheader.h" +#include "program/prog_parameter.h" + +struct gl_program; +struct _glapi_table; + +extern void GLAPIENTRY +_mesa_Uniform1fARB(GLint, GLfloat); + +extern void GLAPIENTRY +_mesa_Uniform2fARB(GLint, GLfloat, GLfloat); + +extern void GLAPIENTRY +_mesa_Uniform3fARB(GLint, GLfloat, GLfloat, GLfloat); + +extern void GLAPIENTRY +_mesa_Uniform4fARB(GLint, GLfloat, GLfloat, GLfloat, GLfloat); + +extern void GLAPIENTRY +_mesa_Uniform1iARB(GLint, GLint); + +extern void GLAPIENTRY +_mesa_Uniform2iARB(GLint, GLint, GLint); + +extern void GLAPIENTRY +_mesa_Uniform3iARB(GLint, GLint, GLint, GLint); + +extern void GLAPIENTRY +_mesa_Uniform4iARB(GLint, GLint, GLint, GLint, GLint); + +extern void GLAPIENTRY +_mesa_Uniform1fvARB(GLint, GLsizei, const GLfloat *); + +extern void GLAPIENTRY +_mesa_Uniform2fvARB(GLint, GLsizei, const GLfloat *); + +extern void GLAPIENTRY +_mesa_Uniform3fvARB(GLint, GLsizei, const GLfloat *); + +extern void GLAPIENTRY +_mesa_Uniform4fvARB(GLint, GLsizei, const GLfloat *); + +extern void GLAPIENTRY +_mesa_Uniform1ivARB(GLint, GLsizei, const GLint *); + +extern void GLAPIENTRY +_mesa_Uniform2ivARB(GLint, GLsizei, const GLint *); + +extern void GLAPIENTRY +_mesa_Uniform3ivARB(GLint, GLsizei, const GLint *); + +extern void GLAPIENTRY +_mesa_Uniform4ivARB(GLint, GLsizei, const GLint *); + +extern void GLAPIENTRY +_mesa_Uniform1ui(GLint location, GLuint v0); + +extern void GLAPIENTRY +_mesa_Uniform2ui(GLint location, GLuint v0, GLuint v1); + +extern void GLAPIENTRY +_mesa_Uniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2); + +extern void GLAPIENTRY +_mesa_Uniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); + +extern void GLAPIENTRY +_mesa_Uniform1uiv(GLint location, GLsizei count, const GLuint *value); + +extern void GLAPIENTRY +_mesa_Uniform2uiv(GLint location, GLsizei count, const GLuint *value); + +extern void GLAPIENTRY +_mesa_Uniform3uiv(GLint location, GLsizei count, const GLuint *value); + +extern void GLAPIENTRY +_mesa_Uniform4uiv(GLint location, GLsizei count, const GLuint *value); + + +extern void GLAPIENTRY +_mesa_UniformMatrix2fvARB(GLint, GLsizei, GLboolean, const GLfloat *); + +extern void GLAPIENTRY +_mesa_UniformMatrix3fvARB(GLint, GLsizei, GLboolean, const GLfloat *); + +extern void GLAPIENTRY +_mesa_UniformMatrix4fvARB(GLint, GLsizei, GLboolean, const GLfloat *); + +extern void GLAPIENTRY +_mesa_UniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, + const GLfloat *value); + +extern void GLAPIENTRY +_mesa_UniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, + const GLfloat *value); + +extern void GLAPIENTRY +_mesa_UniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, + const GLfloat *value); + +extern void GLAPIENTRY +_mesa_UniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, + const GLfloat *value); + +extern void GLAPIENTRY +_mesa_UniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, + const GLfloat *value); + +extern void GLAPIENTRY +_mesa_UniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, + const GLfloat *value); + + +extern void GLAPIENTRY +_mesa_GetActiveUniformARB(GLhandleARB, GLuint, GLsizei, GLsizei *, + GLint *, GLenum *, GLcharARB *); + +extern void GLAPIENTRY +_mesa_GetUniformfvARB(GLhandleARB, GLint, GLfloat *); + +extern void GLAPIENTRY +_mesa_GetnUniformfvARB(GLhandleARB, GLint, GLsizei, GLfloat *); + +extern void GLAPIENTRY +_mesa_GetUniformivARB(GLhandleARB, GLint, GLint *); + +extern void GLAPIENTRY +_mesa_GetnUniformivARB(GLhandleARB, GLint, GLsizei, GLint *); + +extern void GLAPIENTRY +_mesa_GetUniformuiv(GLhandleARB, GLint, GLuint *); + +extern void GLAPIENTRY +_mesa_GetnUniformuivARB(GLhandleARB, GLint, GLsizei, GLuint *); + +extern void GLAPIENTRY +_mesa_GetUniformdv(GLhandleARB, GLint, GLdouble *); + +extern void GLAPIENTRY +_mesa_GetnUniformdvARB(GLhandleARB, GLint, GLsizei, GLdouble *); + +extern GLint GLAPIENTRY +_mesa_GetUniformLocationARB(GLhandleARB, const GLcharARB *); + +GLint +_mesa_get_uniform_location(struct gl_context *ctx, struct gl_shader_program *shProg, + const GLchar *name); + +void +_mesa_uniform(struct gl_context *ctx, struct gl_shader_program *shader_program, + GLint location, GLsizei count, + const GLvoid *values, GLenum type); + +void +_mesa_uniform_matrix(struct gl_context *ctx, struct gl_shader_program *shProg, + GLint cols, GLint rows, + GLint location, GLsizei count, + GLboolean transpose, const GLfloat *values); + +extern void +_mesa_update_shader_textures_used(struct gl_program *prog); + + +extern void +_mesa_init_shader_uniform_dispatch(struct _glapi_table *exec); + +struct gl_builtin_uniform_element { + const char *field; + int tokens[STATE_LENGTH]; + int swizzle; +}; + +struct gl_builtin_uniform_desc { + const char *name; + struct gl_builtin_uniform_element *elements; + unsigned int num_elements; +}; + +extern const struct gl_builtin_uniform_desc _mesa_builtin_uniform_desc[]; + +#endif /* UNIFORMS_H */ diff --git a/3rdparty/glsl-optimizer/src/mesa/main/version.h b/3rdparty/glsl-optimizer/src/mesa/main/version.h new file mode 100644 index 000000000..0a0512c33 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/mesa/main/version.h @@ -0,0 +1,60 @@ +/* + * Mesa 3-D graphics library + * Version: 7.11 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (C) 2009 VMware, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#ifndef VERSION_H +#define VERSION_H + + +struct gl_context; + + +/* Mesa version */ +#define MESA_MAJOR 7 +#define MESA_MINOR 12 +#define MESA_PATCH 0 +#define MESA_VERSION_STRING "7.12-devel" + +/* To make version comparison easy */ +#define MESA_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) +#define MESA_VERSION_CODE MESA_VERSION(MESA_MAJOR, MESA_MINOR, MESA_PATCH) + + +/* OpenGL API version */ +#define OPENGL_MAJOR 2 +#define OPENGL_MINOR 1 +#define OPENGL_PATCH 0 +#define OPENGL_VERSION_STRING "2.1" + +/* To make version comparison easy */ +#define OPENGL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) +#define OPENGL_VERSION_CODE OPENGL_VERSION(OPENGL_MAJOR, OPENGL_MINOR, OPENGL_PATCH) + + +extern void +_mesa_compute_version(struct gl_context *ctx); + + +#endif /* VERSION_H */ diff --git a/3rdparty/glsl-optimizer/src/mesa/math/m_matrix.h b/3rdparty/glsl-optimizer/src/mesa/math/m_matrix.h new file mode 100644 index 000000000..a69afb858 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/mesa/math/m_matrix.h @@ -0,0 +1,212 @@ +/* + * Mesa 3-D graphics library + * Version: 6.3 + * + * Copyright (C) 1999-2005 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +/** + * \file math/m_matrix.h + * Defines basic structures for matrix-handling. + */ + +#ifndef _M_MATRIX_H +#define _M_MATRIX_H + + +#include "main/glheader.h" + + +/** + * \name Symbolic names to some of the entries in the matrix + * + * These are handy for the viewport mapping, which is expressed as a matrix. + */ +/*@{*/ +#define MAT_SX 0 +#define MAT_SY 5 +#define MAT_SZ 10 +#define MAT_TX 12 +#define MAT_TY 13 +#define MAT_TZ 14 +/*@}*/ + + +/** + * Different kinds of 4x4 transformation matrices. + * We use these to select specific optimized vertex transformation routines. + */ +enum GLmatrixtype { + MATRIX_GENERAL, /**< general 4x4 matrix */ + MATRIX_IDENTITY, /**< identity matrix */ + MATRIX_3D_NO_ROT, /**< orthogonal projection and others... */ + MATRIX_PERSPECTIVE, /**< perspective projection matrix */ + MATRIX_2D, /**< 2-D transformation */ + MATRIX_2D_NO_ROT, /**< 2-D scale & translate only */ + MATRIX_3D /**< 3-D transformation */ +} ; + +/** + * Matrix type to represent 4x4 transformation matrices. + */ +typedef struct { + GLfloat *m; /**< 16 matrix elements (16-byte aligned) */ + GLfloat *inv; /**< optional 16-element inverse (16-byte aligned) */ + GLuint flags; /**< possible values determined by (of \link + * MatFlags MAT_FLAG_* flags\endlink) + */ + enum GLmatrixtype type; +} GLmatrix; + + + + +extern void +_math_matrix_ctr( GLmatrix *m ); + +extern void +_math_matrix_dtr( GLmatrix *m ); + +extern void +_math_matrix_alloc_inv( GLmatrix *m ); + +extern void +_math_matrix_mul_matrix( GLmatrix *dest, const GLmatrix *a, const GLmatrix *b ); + +extern void +_math_matrix_mul_floats( GLmatrix *dest, const GLfloat *b ); + +extern void +_math_matrix_loadf( GLmatrix *mat, const GLfloat *m ); + +extern void +_math_matrix_translate( GLmatrix *mat, GLfloat x, GLfloat y, GLfloat z ); + +extern void +_math_matrix_rotate( GLmatrix *m, GLfloat angle, + GLfloat x, GLfloat y, GLfloat z ); + +extern void +_math_matrix_scale( GLmatrix *mat, GLfloat x, GLfloat y, GLfloat z ); + +extern void +_math_matrix_ortho( GLmatrix *mat, + GLfloat left, GLfloat right, + GLfloat bottom, GLfloat top, + GLfloat nearval, GLfloat farval ); + +extern void +_math_matrix_frustum( GLmatrix *mat, + GLfloat left, GLfloat right, + GLfloat bottom, GLfloat top, + GLfloat nearval, GLfloat farval ); + +extern void +_math_matrix_viewport(GLmatrix *m, GLint x, GLint y, GLint width, GLint height, + GLfloat zNear, GLfloat zFar, GLfloat depthMax); + +extern void +_math_matrix_set_identity( GLmatrix *dest ); + +extern void +_math_matrix_copy( GLmatrix *to, const GLmatrix *from ); + +extern void +_math_matrix_analyse( GLmatrix *mat ); + +extern void +_math_matrix_print( const GLmatrix *m ); + +extern GLboolean +_math_matrix_is_length_preserving( const GLmatrix *m ); + +extern GLboolean +_math_matrix_has_rotation( const GLmatrix *m ); + +extern GLboolean +_math_matrix_is_general_scale( const GLmatrix *m ); + +extern GLboolean +_math_matrix_is_dirty( const GLmatrix *m ); + + +/** + * \name Related functions that don't actually operate on GLmatrix structs + */ +/*@{*/ + +extern void +_math_transposef( GLfloat to[16], const GLfloat from[16] ); + +extern void +_math_transposed( GLdouble to[16], const GLdouble from[16] ); + +extern void +_math_transposefd( GLfloat to[16], const GLdouble from[16] ); + + +/* + * Transform a point (column vector) by a matrix: Q = M * P + */ +#define TRANSFORM_POINT( Q, M, P ) \ + Q[0] = M[0] * P[0] + M[4] * P[1] + M[8] * P[2] + M[12] * P[3]; \ + Q[1] = M[1] * P[0] + M[5] * P[1] + M[9] * P[2] + M[13] * P[3]; \ + Q[2] = M[2] * P[0] + M[6] * P[1] + M[10] * P[2] + M[14] * P[3]; \ + Q[3] = M[3] * P[0] + M[7] * P[1] + M[11] * P[2] + M[15] * P[3]; + + +#define TRANSFORM_POINT3( Q, M, P ) \ + Q[0] = M[0] * P[0] + M[4] * P[1] + M[8] * P[2] + M[12]; \ + Q[1] = M[1] * P[0] + M[5] * P[1] + M[9] * P[2] + M[13]; \ + Q[2] = M[2] * P[0] + M[6] * P[1] + M[10] * P[2] + M[14]; \ + Q[3] = M[3] * P[0] + M[7] * P[1] + M[11] * P[2] + M[15]; + + +/* + * Transform a normal (row vector) by a matrix: [NX NY NZ] = N * MAT + */ +#define TRANSFORM_NORMAL( TO, N, MAT ) \ +do { \ + TO[0] = N[0] * MAT[0] + N[1] * MAT[1] + N[2] * MAT[2]; \ + TO[1] = N[0] * MAT[4] + N[1] * MAT[5] + N[2] * MAT[6]; \ + TO[2] = N[0] * MAT[8] + N[1] * MAT[9] + N[2] * MAT[10]; \ +} while (0) + + +/** + * Transform a direction by a matrix. + */ +#define TRANSFORM_DIRECTION( TO, DIR, MAT ) \ +do { \ + TO[0] = DIR[0] * MAT[0] + DIR[1] * MAT[4] + DIR[2] * MAT[8]; \ + TO[1] = DIR[0] * MAT[1] + DIR[1] * MAT[5] + DIR[2] * MAT[9]; \ + TO[2] = DIR[0] * MAT[2] + DIR[1] * MAT[6] + DIR[2] * MAT[10];\ +} while (0) + + +extern void +_mesa_transform_vector(GLfloat u[4], const GLfloat v[4], const GLfloat m[16]); + + +/*@}*/ + + +#endif diff --git a/3rdparty/glsl-optimizer/src/mesa/program/.gitignore b/3rdparty/glsl-optimizer/src/mesa/program/.gitignore new file mode 100644 index 000000000..4c20872e1 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/mesa/program/.gitignore @@ -0,0 +1,4 @@ +program_parse.output +lex.yy.c +program_parse.tab.c +program_parse.tab.h diff --git a/3rdparty/glsl-optimizer/src/mesa/program/hash_table.c b/3rdparty/glsl-optimizer/src/mesa/program/hash_table.c new file mode 100644 index 000000000..877a9e2ff --- /dev/null +++ b/3rdparty/glsl-optimizer/src/mesa/program/hash_table.c @@ -0,0 +1,209 @@ +/* + * Copyright © 2008 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file hash_table.c + * \brief Implementation of a generic, opaque hash table data type. + * + * \author Ian Romanick + */ + +#include "main/imports.h" +#include "main/simple_list.h" +#include "hash_table.h" + +struct node { + struct node *next; + struct node *prev; +}; + +struct hash_table { + hash_func_t hash; + hash_compare_func_t compare; + + unsigned num_buckets; + struct node buckets[1]; +}; + + +struct hash_node { + struct node link; + const void *key; + void *data; +}; + + +struct hash_table * +hash_table_ctor(unsigned num_buckets, hash_func_t hash, + hash_compare_func_t compare) +{ + struct hash_table *ht; + unsigned i; + + + if (num_buckets < 16) { + num_buckets = 16; + } + + ht = malloc(sizeof(*ht) + ((num_buckets - 1) + * sizeof(ht->buckets[0]))); + if (ht != NULL) { + ht->hash = hash; + ht->compare = compare; + ht->num_buckets = num_buckets; + + for (i = 0; i < num_buckets; i++) { + make_empty_list(& ht->buckets[i]); + } + } + + return ht; +} + + +void +hash_table_dtor(struct hash_table *ht) +{ + hash_table_clear(ht); + free(ht); +} + + +void +hash_table_clear(struct hash_table *ht) +{ + struct node *node; + struct node *temp; + unsigned i; + + + for (i = 0; i < ht->num_buckets; i++) { + foreach_s(node, temp, & ht->buckets[i]) { + remove_from_list(node); + free(node); + } + + assert(is_empty_list(& ht->buckets[i])); + } +} + + +void * +hash_table_find(struct hash_table *ht, const void *key) +{ + const unsigned hash_value = (*ht->hash)(key); + const unsigned bucket = hash_value % ht->num_buckets; + struct node *node; + + foreach(node, & ht->buckets[bucket]) { + struct hash_node *hn = (struct hash_node *) node; + + if ((*ht->compare)(hn->key, key) == 0) { + return hn->data; + } + } + + return NULL; +} + + +void +hash_table_insert(struct hash_table *ht, void *data, const void *key) +{ + const unsigned hash_value = (*ht->hash)(key); + const unsigned bucket = hash_value % ht->num_buckets; + struct hash_node *node; + + node = calloc(1, sizeof(*node)); + + node->data = data; + node->key = key; + + insert_at_head(& ht->buckets[bucket], & node->link); +} + +void +hash_table_remove(struct hash_table *ht, const void *key) +{ + const unsigned hash_value = (*ht->hash)(key); + const unsigned bucket = hash_value % ht->num_buckets; + struct node *node; + + foreach(node, & ht->buckets[bucket]) { + struct hash_node *hn = (struct hash_node *) node; + + if ((*ht->compare)(hn->key, key) == 0) { + remove_from_list(node); + free(node); + return; + } + } +} + +void +hash_table_call_foreach(struct hash_table *ht, + void (*callback)(const void *key, + void *data, + void *closure), + void *closure) +{ + int bucket; + + for (bucket = 0; bucket < ht->num_buckets; bucket++) { + struct node *node, *temp; + foreach_s(node, temp, &ht->buckets[bucket]) { + struct hash_node *hn = (struct hash_node *) node; + + callback(hn->key, hn->data, closure); + } + } +} + +unsigned +hash_table_string_hash(const void *key) +{ + const char *str = (const char *) key; + unsigned hash = 5381; + + + while (*str != '\0') { + hash = (hash * 33) + *str; + str++; + } + + return hash; +} + + +unsigned +hash_table_pointer_hash(const void *key) +{ + return (unsigned)((uintptr_t) key / sizeof(void *)); +} + + +int +hash_table_pointer_compare(const void *key1, const void *key2) +{ + return key1 == key2 ? 0 : 1; +} diff --git a/3rdparty/glsl-optimizer/src/mesa/program/hash_table.h b/3rdparty/glsl-optimizer/src/mesa/program/hash_table.h new file mode 100644 index 000000000..e715bb1cc --- /dev/null +++ b/3rdparty/glsl-optimizer/src/mesa/program/hash_table.h @@ -0,0 +1,157 @@ +/* + * Copyright © 2008 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file hash_table.h + * \brief Implementation of a generic, opaque hash table data type. + * + * \author Ian Romanick + */ + +#ifndef HASH_TABLE_H +#define HASH_TABLE_H + +struct hash_table; + +typedef unsigned (*hash_func_t)(const void *key); +typedef int (*hash_compare_func_t)(const void *key1, const void *key2); + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Hash table constructor + * + * Creates a hash table with the specified number of buckets. The supplied + * \c hash and \c compare routines are used when adding elements to the table + * and when searching for elements in the table. + * + * \param num_buckets Number of buckets (bins) in the hash table. + * \param hash Function used to compute hash value of input keys. + * \param compare Function used to compare keys. + */ +extern struct hash_table *hash_table_ctor(unsigned num_buckets, + hash_func_t hash, hash_compare_func_t compare); + + +/** + * Release all memory associated with a hash table + * + * \warning + * This function cannot release memory occupied either by keys or data. + */ +extern void hash_table_dtor(struct hash_table *ht); + + +/** + * Flush all entries from a hash table + * + * \param ht Table to be cleared of its entries. + */ +extern void hash_table_clear(struct hash_table *ht); + + +/** + * Search a hash table for a specific element + * + * \param ht Table to be searched + * \param key Key of the desired element + * + * \return + * The \c data value supplied to \c hash_table_insert when the element with + * the matching key was added. If no matching key exists in the table, + * \c NULL is returned. + */ +extern void *hash_table_find(struct hash_table *ht, const void *key); + + +/** + * Add an element to a hash table + */ +extern void hash_table_insert(struct hash_table *ht, void *data, + const void *key); + +/** + * Remove a specific element from a hash table. + */ +extern void hash_table_remove(struct hash_table *ht, const void *key); + +/** + * Compute hash value of a string + * + * Computes the hash value of a string using the DJB2 algorithm developed by + * Professor Daniel J. Bernstein. It was published on comp.lang.c once upon + * a time. I was unable to find the original posting in the archives. + * + * \param key Pointer to a NUL terminated string to be hashed. + * + * \sa hash_table_string_compare + */ +extern unsigned hash_table_string_hash(const void *key); + + +/** + * Compare two strings used as keys + * + * This is just a macro wrapper around \c strcmp. + * + * \sa hash_table_string_hash + */ +#define hash_table_string_compare ((hash_compare_func_t) strcmp) + + +/** + * Compute hash value of a pointer + * + * \param key Pointer to be used as a hash key + * + * \note + * The memory pointed to by \c key is \b never accessed. The value of \c key + * itself is used as the hash key + * + * \sa hash_table_pointer_compare + */ +unsigned +hash_table_pointer_hash(const void *key); + + +/** + * Compare two pointers used as keys + * + * \sa hash_table_pointer_hash + */ +int +hash_table_pointer_compare(const void *key1, const void *key2); + +void +hash_table_call_foreach(struct hash_table *ht, + void (*callback)(const void *key, + void *data, + void *closure), + void *closure); + +#ifdef __cplusplus +} +#endif +#endif /* HASH_TABLE_H */ diff --git a/3rdparty/glsl-optimizer/src/mesa/program/ir_to_mesa.h b/3rdparty/glsl-optimizer/src/mesa/program/ir_to_mesa.h new file mode 100644 index 000000000..7410e1497 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/mesa/program/ir_to_mesa.h @@ -0,0 +1,41 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "main/glheader.h" + +struct gl_context; +struct gl_shader; +struct gl_shader_program; + +void _mesa_glsl_compile_shader(struct gl_context *ctx, struct gl_shader *sh); +void _mesa_glsl_link_shader(struct gl_context *ctx, struct gl_shader_program *prog); +GLboolean _mesa_ir_compile_shader(struct gl_context *ctx, struct gl_shader *shader); +GLboolean _mesa_ir_link_shader(struct gl_context *ctx, struct gl_shader_program *prog); + +#ifdef __cplusplus +} +#endif diff --git a/3rdparty/glsl-optimizer/src/mesa/program/prog_instruction.h b/3rdparty/glsl-optimizer/src/mesa/program/prog_instruction.h new file mode 100644 index 000000000..db2b594e7 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/mesa/program/prog_instruction.h @@ -0,0 +1,454 @@ +/* + * Mesa 3-D graphics library + * Version: 7.3 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +/** + * \file prog_instruction.h + * + * Vertex/fragment program instruction datatypes and constants. + * + * \author Brian Paul + * \author Keith Whitwell + * \author Ian Romanick + */ + + +#ifndef PROG_INSTRUCTION_H +#define PROG_INSTRUCTION_H + + +#include "main/glheader.h" + + +/** + * Swizzle indexes. + * Do not change! + */ +/*@{*/ +#define SWIZZLE_X 0 +#define SWIZZLE_Y 1 +#define SWIZZLE_Z 2 +#define SWIZZLE_W 3 +#define SWIZZLE_ZERO 4 /**< For SWZ instruction only */ +#define SWIZZLE_ONE 5 /**< For SWZ instruction only */ +#define SWIZZLE_NIL 7 /**< used during shader code gen (undefined value) */ +/*@}*/ + +#define MAKE_SWIZZLE4(a,b,c,d) (((a)<<0) | ((b)<<3) | ((c)<<6) | ((d)<<9)) +#define SWIZZLE_NOOP MAKE_SWIZZLE4(0,1,2,3) +#define GET_SWZ(swz, idx) (((swz) >> ((idx)*3)) & 0x7) +#define GET_BIT(msk, idx) (((msk) >> (idx)) & 0x1) + +#define SWIZZLE_XYZW MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_W) +#define SWIZZLE_XXXX MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_X, SWIZZLE_X, SWIZZLE_X) +#define SWIZZLE_YYYY MAKE_SWIZZLE4(SWIZZLE_Y, SWIZZLE_Y, SWIZZLE_Y, SWIZZLE_Y) +#define SWIZZLE_ZZZZ MAKE_SWIZZLE4(SWIZZLE_Z, SWIZZLE_Z, SWIZZLE_Z, SWIZZLE_Z) +#define SWIZZLE_WWWW MAKE_SWIZZLE4(SWIZZLE_W, SWIZZLE_W, SWIZZLE_W, SWIZZLE_W) + + +/** + * Writemask values, 1 bit per component. + */ +/*@{*/ +#define WRITEMASK_X 0x1 +#define WRITEMASK_Y 0x2 +#define WRITEMASK_XY 0x3 +#define WRITEMASK_Z 0x4 +#define WRITEMASK_XZ 0x5 +#define WRITEMASK_YZ 0x6 +#define WRITEMASK_XYZ 0x7 +#define WRITEMASK_W 0x8 +#define WRITEMASK_XW 0x9 +#define WRITEMASK_YW 0xa +#define WRITEMASK_XYW 0xb +#define WRITEMASK_ZW 0xc +#define WRITEMASK_XZW 0xd +#define WRITEMASK_YZW 0xe +#define WRITEMASK_XYZW 0xf +/*@}*/ + + +/** + * Condition codes + */ +/*@{*/ +#define COND_GT 1 /**< greater than zero */ +#define COND_EQ 2 /**< equal to zero */ +#define COND_LT 3 /**< less than zero */ +#define COND_UN 4 /**< unordered (NaN) */ +#define COND_GE 5 /**< greater than or equal to zero */ +#define COND_LE 6 /**< less than or equal to zero */ +#define COND_NE 7 /**< not equal to zero */ +#define COND_TR 8 /**< always true */ +#define COND_FL 9 /**< always false */ +/*@}*/ + + +/** + * Instruction precision for GL_NV_fragment_program + */ +/*@{*/ +#define FLOAT32 0x1 +#define FLOAT16 0x2 +#define FIXED12 0x4 +/*@}*/ + + +/** + * Saturation modes when storing values. + */ +/*@{*/ +#define SATURATE_OFF 0 +#define SATURATE_ZERO_ONE 1 +/*@}*/ + + +/** + * Per-component negation masks + */ +/*@{*/ +#define NEGATE_X 0x1 +#define NEGATE_Y 0x2 +#define NEGATE_Z 0x4 +#define NEGATE_W 0x8 +#define NEGATE_XYZ 0x7 +#define NEGATE_XYZW 0xf +#define NEGATE_NONE 0x0 +/*@}*/ + + +/** + * Program instruction opcodes for vertex, fragment and geometry programs. + */ +typedef enum prog_opcode { + /* ARB_vp ARB_fp NV_vp NV_fp GLSL */ + /*------------------------------------------*/ + OPCODE_NOP = 0, /* X */ + OPCODE_ABS, /* X X 1.1 X */ + OPCODE_ADD, /* X X X X X */ + OPCODE_AND, /* */ + OPCODE_ARA, /* 2 */ + OPCODE_ARL, /* X X X */ + OPCODE_ARL_NV, /* 2 */ + OPCODE_ARR, /* 2 */ + OPCODE_BGNLOOP, /* opt */ + OPCODE_BGNSUB, /* opt */ + OPCODE_BRA, /* 2 */ + OPCODE_BRK, /* 2 opt */ + OPCODE_CAL, /* 2 2 opt */ + OPCODE_CMP, /* X X */ + OPCODE_CONT, /* opt */ + OPCODE_COS, /* X 2 X X */ + OPCODE_DDX, /* X X */ + OPCODE_DDY, /* X X */ + OPCODE_DP2, /* 2 X */ + OPCODE_DP2A, /* 2 */ + OPCODE_DP3, /* X X X X X */ + OPCODE_DP4, /* X X X X X */ + OPCODE_DPH, /* X X 1.1 */ + OPCODE_DST, /* X X X X */ + OPCODE_ELSE, /* opt */ + OPCODE_EMIT_VERTEX,/* X */ + OPCODE_END, /* X X X X opt */ + OPCODE_END_PRIMITIVE,/* X */ + OPCODE_ENDIF, /* opt */ + OPCODE_ENDLOOP, /* opt */ + OPCODE_ENDSUB, /* opt */ + OPCODE_EX2, /* X X 2 X X */ + OPCODE_EXP, /* X X */ + OPCODE_FLR, /* X X 2 X X */ + OPCODE_FRC, /* X X 2 X X */ + OPCODE_IF, /* opt */ + OPCODE_KIL, /* X X */ + OPCODE_KIL_NV, /* X X */ + OPCODE_LG2, /* X X 2 X X */ + OPCODE_LIT, /* X X X X */ + OPCODE_LOG, /* X X */ + OPCODE_LRP, /* X X */ + OPCODE_MAD, /* X X X X X */ + OPCODE_MAX, /* X X X X X */ + OPCODE_MIN, /* X X X X X */ + OPCODE_MOV, /* X X X X X */ + OPCODE_MUL, /* X X X X X */ + OPCODE_NOISE1, /* X */ + OPCODE_NOISE2, /* X */ + OPCODE_NOISE3, /* X */ + OPCODE_NOISE4, /* X */ + OPCODE_NOT, /* */ + OPCODE_NRM3, /* */ + OPCODE_NRM4, /* */ + OPCODE_OR, /* */ + OPCODE_PK2H, /* X */ + OPCODE_PK2US, /* X */ + OPCODE_PK4B, /* X */ + OPCODE_PK4UB, /* X */ + OPCODE_POW, /* X X X X */ + OPCODE_POPA, /* 3 */ + OPCODE_PRINT, /* X X */ + OPCODE_PUSHA, /* 3 */ + OPCODE_RCC, /* 1.1 */ + OPCODE_RCP, /* X X X X X */ + OPCODE_RET, /* 2 2 opt */ + OPCODE_RFL, /* X X */ + OPCODE_RSQ, /* X X X X X */ + OPCODE_SCS, /* X X */ + OPCODE_SEQ, /* 2 X X */ + OPCODE_SFL, /* 2 X */ + OPCODE_SGE, /* X X X X X */ + OPCODE_SGT, /* 2 X X */ + OPCODE_SIN, /* X 2 X X */ + OPCODE_SLE, /* 2 X X */ + OPCODE_SLT, /* X X X X X */ + OPCODE_SNE, /* 2 X X */ + OPCODE_SSG, /* 2 X */ + OPCODE_STR, /* 2 X */ + OPCODE_SUB, /* X X 1.1 X X */ + OPCODE_SWZ, /* X X X */ + OPCODE_TEX, /* X 3 X X */ + OPCODE_TXB, /* X 3 X */ + OPCODE_TXD, /* X X */ + OPCODE_TXL, /* 3 2 X */ + OPCODE_TXP, /* X X */ + OPCODE_TXP_NV, /* 3 X */ + OPCODE_TRUNC, /* X */ + OPCODE_UP2H, /* X */ + OPCODE_UP2US, /* X */ + OPCODE_UP4B, /* X */ + OPCODE_UP4UB, /* X */ + OPCODE_X2D, /* X */ + OPCODE_XOR, /* */ + OPCODE_XPD, /* X X */ + MAX_OPCODE +} gl_inst_opcode; + + +/** + * Number of bits for the src/dst register Index field. + * This limits the size of temp/uniform register files. + */ +#define INST_INDEX_BITS 12 + + +/** + * Instruction source register. + */ +struct prog_src_register +{ + GLuint File:4; /**< One of the PROGRAM_* register file values. */ + GLint Index:(INST_INDEX_BITS+1); /**< Extra bit here for sign bit. + * May be negative for relative addressing. + */ + GLuint Swizzle:12; + GLuint RelAddr:1; + + /** Take the component-wise absolute value */ + GLuint Abs:1; + + /** + * Post-Abs negation. + * This will either be NEGATE_NONE or NEGATE_XYZW, except for the SWZ + * instruction which allows per-component negation. + */ + GLuint Negate:4; + + /** + * Is the register two-dimensional. + * Two dimensional registers are of the + * REGISTER[index][index2] format. + * They are used by the geometry shaders where + * the first index is the index within an array + * and the second index is the semantic of the + * array, e.g. gl_PositionIn[index] would become + * INPUT[index][gl_PositionIn] + */ + GLuint HasIndex2:1; + GLuint RelAddr2:1; + GLint Index2:(INST_INDEX_BITS+1); /**< Extra bit here for sign bit. + * May be negative for relative + * addressing. */ +}; + + +/** + * Instruction destination register. + */ +struct prog_dst_register +{ + GLuint File:4; /**< One of the PROGRAM_* register file values */ + GLuint Index:INST_INDEX_BITS; /**< Unsigned, never negative */ + GLuint WriteMask:4; + GLuint RelAddr:1; + + /** + * \name Conditional destination update control. + * + * \since + * NV_fragment_program, NV_fragment_program_option, NV_vertex_program2, + * NV_vertex_program2_option. + */ + /*@{*/ + /** + * Takes one of the 9 possible condition values (EQ, FL, GT, GE, LE, LT, + * NE, TR, or UN). Dest reg is only written to if the matching + * (swizzled) condition code value passes. When a conditional update mask + * is not specified, this will be \c COND_TR. + */ + GLuint CondMask:4; + + /** + * Condition code swizzle value. + */ + GLuint CondSwizzle:12; + + /** + * Selects the condition code register to use for conditional destination + * update masking. In NV_fragmnet_program or NV_vertex_program2 mode, only + * condition code register 0 is available. In NV_vertex_program3 mode, + * condition code registers 0 and 1 are available. + */ + GLuint CondSrc:1; + /*@}*/ +}; + + +/** + * Vertex/fragment program instruction. + */ +struct prog_instruction +{ + gl_inst_opcode Opcode; + struct prog_src_register SrcReg[3]; + struct prog_dst_register DstReg; + + /** + * Indicates that the instruction should update the condition code + * register. + * + * \since + * NV_fragment_program, NV_fragment_program_option, NV_vertex_program2, + * NV_vertex_program2_option. + */ + GLuint CondUpdate:1; + + /** + * If prog_instruction::CondUpdate is \c GL_TRUE, this value selects the + * condition code register that is to be updated. + * + * In GL_NV_fragment_program or GL_NV_vertex_program2 mode, only condition + * code register 0 is available. In GL_NV_vertex_program3 mode, condition + * code registers 0 and 1 are available. + * + * \since + * NV_fragment_program, NV_fragment_program_option, NV_vertex_program2, + * NV_vertex_program2_option. + */ + GLuint CondDst:1; + + /** + * Saturate each value of the vectored result to the range [0,1] or the + * range [-1,1]. \c SSAT mode (i.e., saturation to the range [-1,1]) is + * only available in NV_fragment_program2 mode. + * Value is one of the SATURATE_* tokens. + * + * \since + * NV_fragment_program, NV_fragment_program_option, NV_vertex_program3. + */ + GLuint SaturateMode:2; + + /** + * Per-instruction selectable precision: FLOAT32, FLOAT16, FIXED12. + * + * \since + * NV_fragment_program, NV_fragment_program_option. + */ + GLuint Precision:3; + + /** + * \name Extra fields for TEX, TXB, TXD, TXL, TXP instructions. + */ + /*@{*/ + /** Source texture unit. */ + GLuint TexSrcUnit:5; + + /** Source texture target, one of TEXTURE_{1D,2D,3D,CUBE,RECT}_INDEX */ + GLuint TexSrcTarget:3; + + /** True if tex instruction should do shadow comparison */ + GLuint TexShadow:1; + /*@}*/ + + /** + * For BRA and CAL instructions, the location to jump to. + * For BGNLOOP, points to ENDLOOP (and vice-versa). + * For BRK, points to ENDLOOP + * For IF, points to ELSE or ENDIF. + * For ELSE, points to ENDIF. + */ + GLint BranchTarget; + + /** for debugging purposes */ + const char *Comment; + + /** Arbitrary data. Used for OPCODE_PRINT and some drivers */ + void *Data; + + /** for driver use (try to remove someday) */ + GLint Aux; +}; + + +extern void +_mesa_init_instructions(struct prog_instruction *inst, GLuint count); + +extern struct prog_instruction * +_mesa_alloc_instructions(GLuint numInst); + +extern struct prog_instruction * +_mesa_realloc_instructions(struct prog_instruction *oldInst, + GLuint numOldInst, GLuint numNewInst); + +extern struct prog_instruction * +_mesa_copy_instructions(struct prog_instruction *dest, + const struct prog_instruction *src, GLuint n); + +extern void +_mesa_free_instructions(struct prog_instruction *inst, GLuint count); + +extern GLuint +_mesa_num_inst_src_regs(gl_inst_opcode opcode); + +extern GLuint +_mesa_num_inst_dst_regs(gl_inst_opcode opcode); + +extern GLboolean +_mesa_is_tex_instruction(gl_inst_opcode opcode); + +extern GLboolean +_mesa_check_soa_dependencies(const struct prog_instruction *inst); + +extern const char * +_mesa_opcode_string(gl_inst_opcode opcode); + + +#endif /* PROG_INSTRUCTION_H */ diff --git a/3rdparty/glsl-optimizer/src/mesa/program/prog_parameter.h b/3rdparty/glsl-optimizer/src/mesa/program/prog_parameter.h new file mode 100644 index 000000000..1a5ed3439 --- /dev/null +++ b/3rdparty/glsl-optimizer/src/mesa/program/prog_parameter.h @@ -0,0 +1,185 @@ +/* + * Mesa 3-D graphics library + * Version: 7.3 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/** + * \file prog_parameter.c + * Program parameter lists and functions. + * \author Brian Paul + */ + +#ifndef PROG_PARAMETER_H +#define PROG_PARAMETER_H + +#include "main/mtypes.h" +#include "prog_statevars.h" + + +/** + * Program parameter flags + */ +/*@{*/ +#define PROG_PARAM_BIT_CENTROID 0x1 /**< for varying vars (GLSL 1.20) */ +#define PROG_PARAM_BIT_INVARIANT 0x2 /**< for varying vars (GLSL 1.20) */ +#define PROG_PARAM_BIT_FLAT 0x4 /**< for varying vars (GLSL 1.30) */ +#define PROG_PARAM_BIT_LINEAR 0x8 /**< for varying vars (GLSL 1.30) */ +#define PROG_PARAM_BIT_CYL_WRAP 0x10 /**< XXX gallium debug */ +/*@}*/ + + +/** + * Actual data for constant values of parameters. + */ +typedef union gl_constant_value +{ + GLfloat f; + GLboolean b; + GLint i; + GLuint u; +} gl_constant_value; + + +/** + * Program parameter. + * Used by shaders/programs for uniforms, constants, varying vars, etc. + */ +struct gl_program_parameter +{ + const char *Name; /**< Null-terminated string */ + gl_register_file Type; /**< PROGRAM_NAMED_PARAM, CONSTANT or STATE_VAR */ + GLenum DataType; /**< GL_FLOAT, GL_FLOAT_VEC2, etc */ + /** + * Number of components (1..4), or more. + * If the number of components is greater than 4, + * this parameter is part of a larger uniform like a GLSL matrix or array. + * The next program parameter's Size will be Size-4 of this parameter. + */ + GLuint Size; + GLboolean Initialized; /**< debug: Has the ParameterValue[] been set? */ + GLbitfield Flags; /**< Bitmask of PROG_PARAM_*_BIT */ + /** + * A sequence of STATE_* tokens and integers to identify GL state. + */ + gl_state_index StateIndexes[STATE_LENGTH]; +}; + + +/** + * List of gl_program_parameter instances. + */ +struct gl_program_parameter_list +{ + GLuint Size; /**< allocated size of Parameters, ParameterValues */ + GLuint NumParameters; /**< number of parameters in arrays */ + struct gl_program_parameter *Parameters; /**< Array [Size] */ + gl_constant_value (*ParameterValues)[4]; /**< Array [Size] of constant[4] */ + GLbitfield StateFlags; /**< _NEW_* flags indicating which state changes + might invalidate ParameterValues[] */ +}; + + +extern struct gl_program_parameter_list * +_mesa_new_parameter_list(void); + +extern struct gl_program_parameter_list * +_mesa_new_parameter_list_sized(unsigned size); + +extern void +_mesa_free_parameter_list(struct gl_program_parameter_list *paramList); + +extern struct gl_program_parameter_list * +_mesa_clone_parameter_list(const struct gl_program_parameter_list *list); + +extern struct gl_program_parameter_list * +_mesa_combine_parameter_lists(const struct gl_program_parameter_list *a, + const struct gl_program_parameter_list *b); + +static INLINE GLuint +_mesa_num_parameters(const struct gl_program_parameter_list *list) +{ + return list ? list->NumParameters : 0; +} + +extern GLint +_mesa_add_parameter(struct gl_program_parameter_list *paramList, + gl_register_file type, const char *name, + GLuint size, GLenum datatype, + const gl_constant_value *values, + const gl_state_index state[STATE_LENGTH], + GLbitfield flags); + +extern GLint +_mesa_add_named_parameter(struct gl_program_parameter_list *paramList, + const char *name, const gl_constant_value values[4]); + +extern GLint +_mesa_add_named_constant(struct gl_program_parameter_list *paramList, + const char *name, const gl_constant_value values[4], + GLuint size); + +extern GLint +_mesa_add_typed_unnamed_constant(struct gl_program_parameter_list *paramList, + const gl_constant_value values[4], GLuint size, + GLenum datatype, GLuint *swizzleOut); + +extern GLint +_mesa_add_unnamed_constant(struct gl_program_parameter_list *paramList, + const gl_constant_value values[4], GLuint size, + GLuint *swizzleOut); + +extern GLint +_mesa_add_varying(struct gl_program_parameter_list *paramList, + const char *name, GLuint size, GLenum datatype, + GLbitfield flags); + +extern GLint +_mesa_add_attribute(struct gl_program_parameter_list *paramList, + const char *name, GLint size, GLenum datatype, GLint attrib); + +extern GLint +_mesa_add_state_reference(struct gl_program_parameter_list *paramList, + const gl_state_index stateTokens[STATE_LENGTH]); + +extern gl_constant_value * +_mesa_lookup_parameter_value(const struct gl_program_parameter_list *paramList, + GLsizei nameLen, const char *name); + +extern GLint +_mesa_lookup_parameter_index(const struct gl_program_parameter_list *paramList, + GLsizei nameLen, const char *name); + +extern GLboolean +_mesa_lookup_parameter_constant(const struct gl_program_parameter_list *list, + const gl_constant_value v[], GLuint vSize, + GLint *posOut, GLuint *swizzleOut); + +extern GLuint +_mesa_longest_parameter_name(const struct gl_program_parameter_list *list, + gl_register_file type); + +extern GLuint +_mesa_num_parameters_of_type(const struct gl_program_parameter_list *list, + gl_register_file type); + + +#endif /* PROG_PARAMETER_H */ diff --git a/3rdparty/glsl-optimizer/src/mesa/program/prog_statevars.h b/3rdparty/glsl-optimizer/src/mesa/program/prog_statevars.h new file mode 100644 index 000000000..04af3f4cf --- /dev/null +++ b/3rdparty/glsl-optimizer/src/mesa/program/prog_statevars.h @@ -0,0 +1,148 @@ +/* + * Mesa 3-D graphics library + * Version: 7.1 + * + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef PROG_STATEVARS_H +#define PROG_STATEVARS_H + +#include "main/glheader.h" + +struct gl_context; +struct gl_program_parameter_list; + +/** + * Number of STATE_* values we need to address any GL state. + * Used to dimension arrays. + */ +#define STATE_LENGTH 5 + + +/** + * Used for describing GL state referenced from inside ARB vertex and + * fragment programs. + * A string such as "state.light[0].ambient" gets translated into a + * sequence of tokens such as [ STATE_LIGHT, 0, STATE_AMBIENT ]. + * + * For state that's an array, like STATE_CLIPPLANE, the 2nd token [1] should + * always be the array index. + */ +typedef enum gl_state_index_ { + STATE_MATERIAL = 100, /* start at 100 so small ints are seen as ints */ + + STATE_LIGHT, + STATE_LIGHTMODEL_AMBIENT, + STATE_LIGHTMODEL_SCENECOLOR, + STATE_LIGHTPROD, + + STATE_TEXGEN, + + STATE_FOG_COLOR, + STATE_FOG_PARAMS, + + STATE_CLIPPLANE, + + STATE_POINT_SIZE, + STATE_POINT_ATTENUATION, + + STATE_MODELVIEW_MATRIX, + STATE_PROJECTION_MATRIX, + STATE_MVP_MATRIX, + STATE_TEXTURE_MATRIX, + STATE_PROGRAM_MATRIX, + STATE_MATRIX_INVERSE, + STATE_MATRIX_TRANSPOSE, + STATE_MATRIX_INVTRANS, + + STATE_AMBIENT, + STATE_DIFFUSE, + STATE_SPECULAR, + STATE_EMISSION, + STATE_SHININESS, + STATE_HALF_VECTOR, + + STATE_POSITION, /**< xyzw = position */ + STATE_ATTENUATION, /**< xyz = attenuation, w = spot exponent */ + STATE_SPOT_DIRECTION, /**< xyz = direction, w = cos(cutoff) */ + STATE_SPOT_CUTOFF, /**< x = cutoff, yzw = undefined */ + + STATE_TEXGEN_EYE_S, + STATE_TEXGEN_EYE_T, + STATE_TEXGEN_EYE_R, + STATE_TEXGEN_EYE_Q, + STATE_TEXGEN_OBJECT_S, + STATE_TEXGEN_OBJECT_T, + STATE_TEXGEN_OBJECT_R, + STATE_TEXGEN_OBJECT_Q, + + STATE_TEXENV_COLOR, + + STATE_DEPTH_RANGE, + + STATE_VERTEX_PROGRAM, + STATE_FRAGMENT_PROGRAM, + + STATE_ENV, + STATE_LOCAL, + + STATE_INTERNAL, /* Mesa additions */ + STATE_CURRENT_ATTRIB, /* ctx->Current vertex attrib value */ + STATE_CURRENT_ATTRIB_MAYBE_VP_CLAMPED, /* ctx->Current vertex attrib value after passthrough vertex processing */ + STATE_NORMAL_SCALE, + STATE_TEXRECT_SCALE, + STATE_FOG_PARAMS_OPTIMIZED, /* for faster fog calc */ + STATE_POINT_SIZE_CLAMPED, /* includes implementation dependent size clamp */ + STATE_POINT_SIZE_IMPL_CLAMP, /* for implementation clamp only in vs */ + STATE_LIGHT_SPOT_DIR_NORMALIZED, /* pre-normalized spot dir */ + STATE_LIGHT_POSITION, /* object vs eye space */ + STATE_LIGHT_POSITION_NORMALIZED, /* object vs eye space */ + STATE_LIGHT_HALF_VECTOR, /* object vs eye space */ + STATE_PT_SCALE, /**< Pixel transfer RGBA scale */ + STATE_PT_BIAS, /**< Pixel transfer RGBA bias */ + STATE_SHADOW_AMBIENT, /**< ARB_shadow_ambient fail value; token[2] is texture unit index */ + STATE_FB_SIZE, /**< (width-1, height-1, 0, 0) */ + STATE_FB_WPOS_Y_TRANSFORM, /**< (1, 0, -1, height) if a FBO is bound, (-1, height, 1, 0) otherwise */ + STATE_ROT_MATRIX_0, /**< ATI_envmap_bumpmap, rot matrix row 0 */ + STATE_ROT_MATRIX_1, /**< ATI_envmap_bumpmap, rot matrix row 1 */ + STATE_INTERNAL_DRIVER /* first available state index for drivers (must be last) */ +} gl_state_index; + + + +extern void +_mesa_load_state_parameters(struct gl_context *ctx, + struct gl_program_parameter_list *paramList); + + +extern GLbitfield +_mesa_program_state_flags(const gl_state_index state[STATE_LENGTH]); + + +extern char * +_mesa_program_state_string(const gl_state_index state[STATE_LENGTH]); + + +extern void +_mesa_load_tracked_matrices(struct gl_context *ctx); + + +#endif /* PROG_STATEVARS_H */ diff --git a/3rdparty/glsl-optimizer/src/mesa/program/prog_uniform.h b/3rdparty/glsl-optimizer/src/mesa/program/prog_uniform.h new file mode 100644 index 000000000..67f78006e --- /dev/null +++ b/3rdparty/glsl-optimizer/src/mesa/program/prog_uniform.h @@ -0,0 +1,89 @@ +/* + * Mesa 3-D graphics library + * Version: 7.1 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/** + * \file prog_uniform.c + * Shader uniform functions. + * \author Brian Paul + */ + +#ifndef PROG_UNIFORM_H +#define PROG_UNIFORM_H + +#include "main/glheader.h" + + +/** + * Shader program uniform variable. + * The glGetUniformLocation() and glUniform() commands will use this + * information. + * Note that a uniform such as "binormal" might be used in both the + * vertex shader and the fragment shader. When glUniform() is called to + * set the uniform's value, it must be updated in both the vertex and + * fragment shaders. The uniform may be in different locations in the + * two shaders so we keep track of that here. + */ +struct gl_uniform +{ + const char *Name; /**< Null-terminated string */ + GLint VertPos; + GLint FragPos; + GLint GeomPos; + GLboolean Initialized; /**< For debug. Has this uniform been set? */ + const struct glsl_type *Type; +}; + + +/** + * List of gl_uniforms + */ +struct gl_uniform_list +{ + GLuint Size; /**< allocated size of Uniforms array */ + GLuint NumUniforms; /**< number of uniforms in the array */ + struct gl_uniform *Uniforms; /**< Array [Size] */ +}; + + +extern struct gl_uniform_list * +_mesa_new_uniform_list(void); + +extern void +_mesa_free_uniform_list(struct gl_uniform_list *list); + +extern struct gl_uniform * +_mesa_append_uniform(struct gl_uniform_list *list, + const char *name, GLenum target, GLuint progPos); + +extern GLint +_mesa_lookup_uniform(const struct gl_uniform_list *list, const char *name); + +extern GLint +_mesa_longest_uniform_name(const struct gl_uniform_list *list); + +extern void +_mesa_print_uniforms(const struct gl_uniform_list *list); + + +#endif /* PROG_UNIFORM_H */ diff --git a/3rdparty/glsl-optimizer/src/mesa/program/symbol_table.c b/3rdparty/glsl-optimizer/src/mesa/program/symbol_table.c new file mode 100644 index 000000000..004f1f8fa --- /dev/null +++ b/3rdparty/glsl-optimizer/src/mesa/program/symbol_table.c @@ -0,0 +1,488 @@ +/* + * Copyright © 2008 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include "main/imports.h" +#include "symbol_table.h" +#include "hash_table.h" + +struct symbol { + /** + * Link to the next symbol in the table with the same name + * + * The linked list of symbols with the same name is ordered by scope + * from inner-most to outer-most. + */ + struct symbol *next_with_same_name; + + + /** + * Link to the next symbol in the table with the same scope + * + * The linked list of symbols with the same scope is unordered. Symbols + * in this list my have unique names. + */ + struct symbol *next_with_same_scope; + + + /** + * Header information for the list of symbols with the same name. + */ + struct symbol_header *hdr; + + + /** + * Name space of the symbol + * + * Name space are arbitrary user assigned integers. No two symbols can + * exist in the same name space at the same scope level. + */ + int name_space; + + /** Scope depth where this symbol was defined. */ + unsigned depth; + + /** + * Arbitrary user supplied data. + */ + void *data; +}; + + +/** + */ +struct symbol_header { + /** Linkage in list of all headers in a given symbol table. */ + struct symbol_header *next; + + /** Symbol name. */ + char *name; + + /** Linked list of symbols with the same name. */ + struct symbol *symbols; +}; + + +/** + * Element of the scope stack. + */ +struct scope_level { + /** Link to next (inner) scope level. */ + struct scope_level *next; + + /** Linked list of symbols with the same scope. */ + struct symbol *symbols; +}; + + +/** + * + */ +struct _mesa_symbol_table { + /** Hash table containing all symbols in the symbol table. */ + struct hash_table *ht; + + /** Top of scope stack. */ + struct scope_level *current_scope; + + /** List of all symbol headers in the table. */ + struct symbol_header *hdr; + + /** Current scope depth. */ + unsigned depth; +}; + + +struct _mesa_symbol_table_iterator { + /** + * Name space of symbols returned by this iterator. + */ + int name_space; + + + /** + * Currently iterated symbol + * + * The next call to \c _mesa_symbol_table_iterator_get will return this + * value. It will also update this value to the value that should be + * returned by the next call. + */ + struct symbol *curr; +}; + + +static void +check_symbol_table(struct _mesa_symbol_table *table) +{ +#if 1 + struct scope_level *scope; + + for (scope = table->current_scope; scope != NULL; scope = scope->next) { + struct symbol *sym; + + for (sym = scope->symbols + ; sym != NULL + ; sym = sym->next_with_same_name) { + const struct symbol_header *const hdr = sym->hdr; + struct symbol *sym2; + + for (sym2 = hdr->symbols + ; sym2 != NULL + ; sym2 = sym2->next_with_same_name) { + assert(sym2->hdr == hdr); + } + } + } +#endif +} + +void +_mesa_symbol_table_pop_scope(struct _mesa_symbol_table *table) +{ + struct scope_level *const scope = table->current_scope; + struct symbol *sym = scope->symbols; + + table->current_scope = scope->next; + table->depth--; + + free(scope); + + while (sym != NULL) { + struct symbol *const next = sym->next_with_same_scope; + struct symbol_header *const hdr = sym->hdr; + + assert(hdr->symbols == sym); + + hdr->symbols = sym->next_with_same_name; + + free(sym); + + sym = next; + } + + check_symbol_table(table); +} + + +void +_mesa_symbol_table_push_scope(struct _mesa_symbol_table *table) +{ + struct scope_level *const scope = calloc(1, sizeof(*scope)); + + scope->next = table->current_scope; + table->current_scope = scope; + table->depth++; +} + + +static struct symbol_header * +find_symbol(struct _mesa_symbol_table *table, const char *name) +{ + return (struct symbol_header *) hash_table_find(table->ht, name); +} + + +struct _mesa_symbol_table_iterator * +_mesa_symbol_table_iterator_ctor(struct _mesa_symbol_table *table, + int name_space, const char *name) +{ + struct _mesa_symbol_table_iterator *iter = calloc(1, sizeof(*iter)); + struct symbol_header *const hdr = find_symbol(table, name); + + iter->name_space = name_space; + + if (hdr != NULL) { + struct symbol *sym; + + for (sym = hdr->symbols; sym != NULL; sym = sym->next_with_same_name) { + assert(sym->hdr == hdr); + + if ((name_space == -1) || (sym->name_space == name_space)) { + iter->curr = sym; + break; + } + } + } + + return iter; +} + + +void +_mesa_symbol_table_iterator_dtor(struct _mesa_symbol_table_iterator *iter) +{ + free(iter); +} + + +void * +_mesa_symbol_table_iterator_get(struct _mesa_symbol_table_iterator *iter) +{ + return (iter->curr == NULL) ? NULL : iter->curr->data; +} + + +int +_mesa_symbol_table_iterator_next(struct _mesa_symbol_table_iterator *iter) +{ + struct symbol_header *hdr; + + if (iter->curr == NULL) { + return 0; + } + + hdr = iter->curr->hdr; + iter->curr = iter->curr->next_with_same_name; + + while (iter->curr != NULL) { + assert(iter->curr->hdr == hdr); + + if ((iter->name_space == -1) + || (iter->curr->name_space == iter->name_space)) { + return 1; + } + + iter->curr = iter->curr->next_with_same_name; + } + + return 0; +} + + +/** + * Determine the scope "distance" of a symbol from the current scope + * + * \return + * A non-negative number for the number of scopes between the current scope + * and the scope where a symbol was defined. A value of zero means the current + * scope. A negative number if the symbol does not exist. + */ +int +_mesa_symbol_table_symbol_scope(struct _mesa_symbol_table *table, + int name_space, const char *name) +{ + struct symbol_header *const hdr = find_symbol(table, name); + struct symbol *sym; + + if (hdr != NULL) { + for (sym = hdr->symbols; sym != NULL; sym = sym->next_with_same_name) { + assert(sym->hdr == hdr); + + if ((name_space == -1) || (sym->name_space == name_space)) { + assert(sym->depth <= table->depth); + return sym->depth - table->depth; + } + } + } + + return -1; +} + + +void * +_mesa_symbol_table_find_symbol(struct _mesa_symbol_table *table, + int name_space, const char *name) +{ + struct symbol_header *const hdr = find_symbol(table, name); + + if (hdr != NULL) { + struct symbol *sym; + + + for (sym = hdr->symbols; sym != NULL; sym = sym->next_with_same_name) { + assert(sym->hdr == hdr); + + if ((name_space == -1) || (sym->name_space == name_space)) { + return sym->data; + } + } + } + + return NULL; +} + + +int +_mesa_symbol_table_add_symbol(struct _mesa_symbol_table *table, + int name_space, const char *name, + void *declaration) +{ + struct symbol_header *hdr; + struct symbol *sym; + + check_symbol_table(table); + + hdr = find_symbol(table, name); + + check_symbol_table(table); + + if (hdr == NULL) { + hdr = calloc(1, sizeof(*hdr)); + hdr->name = strdup(name); + + hash_table_insert(table->ht, hdr, hdr->name); + hdr->next = table->hdr; + table->hdr = hdr; + } + + check_symbol_table(table); + + /* If the symbol already exists in this namespace at this scope, it cannot + * be added to the table. + */ + for (sym = hdr->symbols + ; (sym != NULL) && (sym->name_space != name_space) + ; sym = sym->next_with_same_name) { + /* empty */ + } + + if (sym && (sym->depth == table->depth)) + return -1; + + sym = calloc(1, sizeof(*sym)); + sym->next_with_same_name = hdr->symbols; + sym->next_with_same_scope = table->current_scope->symbols; + sym->hdr = hdr; + sym->name_space = name_space; + sym->data = declaration; + sym->depth = table->depth; + + assert(sym->hdr == hdr); + + hdr->symbols = sym; + table->current_scope->symbols = sym; + + check_symbol_table(table); + return 0; +} + + +int +_mesa_symbol_table_add_global_symbol(struct _mesa_symbol_table *table, + int name_space, const char *name, + void *declaration) +{ + struct symbol_header *hdr; + struct symbol *sym; + struct symbol *curr; + struct scope_level *top_scope; + + check_symbol_table(table); + + hdr = find_symbol(table, name); + + check_symbol_table(table); + + if (hdr == NULL) { + hdr = calloc(1, sizeof(*hdr)); + hdr->name = strdup(name); + + hash_table_insert(table->ht, hdr, hdr->name); + hdr->next = table->hdr; + table->hdr = hdr; + } + + check_symbol_table(table); + + /* If the symbol already exists in this namespace at this scope, it cannot + * be added to the table. + */ + for (sym = hdr->symbols + ; (sym != NULL) && (sym->name_space != name_space) + ; sym = sym->next_with_same_name) { + /* empty */ + } + + if (sym && sym->depth == 0) + return -1; + + /* Find the top-level scope */ + for (top_scope = table->current_scope + ; top_scope->next != NULL + ; top_scope = top_scope->next) { + /* empty */ + } + + sym = calloc(1, sizeof(*sym)); + sym->next_with_same_scope = top_scope->symbols; + sym->hdr = hdr; + sym->name_space = name_space; + sym->data = declaration; + + assert(sym->hdr == hdr); + + /* Since next_with_same_name is ordered by scope, we need to append the + * new symbol to the _end_ of the list. + */ + if (hdr->symbols == NULL) { + hdr->symbols = sym; + } else { + for (curr = hdr->symbols + ; curr->next_with_same_name != NULL + ; curr = curr->next_with_same_name) { + /* empty */ + } + curr->next_with_same_name = sym; + } + top_scope->symbols = sym; + + check_symbol_table(table); + return 0; +} + + + +struct _mesa_symbol_table * +_mesa_symbol_table_ctor(void) +{ + struct _mesa_symbol_table *table = calloc(1, sizeof(*table)); + + if (table != NULL) { + table->ht = hash_table_ctor(32, hash_table_string_hash, + hash_table_string_compare); + + _mesa_symbol_table_push_scope(table); + } + + return table; +} + + +void +_mesa_symbol_table_dtor(struct _mesa_symbol_table *table) +{ + struct symbol_header *hdr; + struct symbol_header *next; + + while (table->current_scope != NULL) { + _mesa_symbol_table_pop_scope(table); + } + + for (hdr = table->hdr; hdr != NULL; hdr = next) { + next = hdr->next; + free(hdr->name); + free(hdr); + } + + hash_table_dtor(table->ht); + free(table); +} diff --git a/3rdparty/glsl-optimizer/src/mesa/program/symbol_table.h b/3rdparty/glsl-optimizer/src/mesa/program/symbol_table.h new file mode 100644 index 000000000..f9d91649b --- /dev/null +++ b/3rdparty/glsl-optimizer/src/mesa/program/symbol_table.h @@ -0,0 +1,62 @@ +/* + * Copyright © 2008 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +#ifndef MESA_SYMBOL_TABLE_H +#define MESA_SYMBOL_TABLE_H + +struct _mesa_symbol_table; +struct _mesa_symbol_table_iterator; + +extern void _mesa_symbol_table_push_scope(struct _mesa_symbol_table *table); + +extern void _mesa_symbol_table_pop_scope(struct _mesa_symbol_table *table); + +extern int _mesa_symbol_table_add_symbol(struct _mesa_symbol_table *symtab, + int name_space, const char *name, void *declaration); + +extern int _mesa_symbol_table_add_global_symbol( + struct _mesa_symbol_table *symtab, int name_space, const char *name, + void *declaration); + +extern int _mesa_symbol_table_symbol_scope(struct _mesa_symbol_table *table, + int name_space, const char *name); + +extern void *_mesa_symbol_table_find_symbol( + struct _mesa_symbol_table *symtab, int name_space, const char *name); + +extern struct _mesa_symbol_table *_mesa_symbol_table_ctor(void); + +extern void _mesa_symbol_table_dtor(struct _mesa_symbol_table *); + +extern struct _mesa_symbol_table_iterator *_mesa_symbol_table_iterator_ctor( + struct _mesa_symbol_table *table, int name_space, const char *name); + +extern void _mesa_symbol_table_iterator_dtor( + struct _mesa_symbol_table_iterator *); + +extern void *_mesa_symbol_table_iterator_get( + struct _mesa_symbol_table_iterator *iter); + +extern int _mesa_symbol_table_iterator_next( + struct _mesa_symbol_table_iterator *iter); + +#endif /* MESA_SYMBOL_TABLE_H */ diff --git a/3rdparty/glsl-optimizer/tests/fragment/array-const-in.txt b/3rdparty/glsl-optimizer/tests/fragment/array-const-in.txt new file mode 100644 index 000000000..56dccb65b --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/array-const-in.txt @@ -0,0 +1,24 @@ +vec4 xlat_main( ); +vec4 xlat_main( ) { + vec2 poisson[8]; + poisson[0] = vec2( 0.000000, 0.000000); + poisson[1] = vec2( 0.527837, -0.0858680); + poisson[2] = vec2( -0.0400880, 0.536087); + poisson[3] = vec2( -0.670445, -0.179949); + poisson[4] = vec2( -0.419418, -0.616039); + poisson[5] = vec2( 0.440453, -0.639399); + poisson[6] = vec2( -0.757088, 0.349334); + poisson[7] = vec2( 0.574619, 0.685879); + vec4 c; + int i = 0; + c = vec4( 0.000000); + for ( ; (i < 8); ( ++i )) { + c.xy += poisson[ i ]; + } + return c; +} +void main() { + vec4 xl_retval; + xl_retval = xlat_main( ); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/array-const-inES.txt b/3rdparty/glsl-optimizer/tests/fragment/array-const-inES.txt new file mode 100644 index 000000000..7a903b0e7 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/array-const-inES.txt @@ -0,0 +1,24 @@ +mediump vec4 xlat_main( ); +mediump vec4 xlat_main( ) { + highp vec2 poisson[8]; + poisson[0] = vec2( 0.000000, 0.000000); + poisson[1] = vec2( 0.527837, -0.0858680); + poisson[2] = vec2( -0.0400880, 0.536087); + poisson[3] = vec2( -0.670445, -0.179949); + poisson[4] = vec2( -0.419418, -0.616039); + poisson[5] = vec2( 0.440453, -0.639399); + poisson[6] = vec2( -0.757088, 0.349334); + poisson[7] = vec2( 0.574619, 0.685879); + mediump vec4 c; + highp int i = 0; + c = vec4( 0.000000); + for ( ; (i < 8); ( ++i )) { + c.xy += poisson[ i ]; + } + return c; +} +void main() { + mediump vec4 xl_retval; + xl_retval = xlat_main( ); + gl_FragData[0] = mediump vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/array-const-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/array-const-ir.txt new file mode 100644 index 000000000..feec7c2bc --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/array-const-ir.txt @@ -0,0 +1,64 @@ +vec4 xlat_main () +{ + int i; + vec4 c; + vec2 poisson[8]; + vec2 tmpvar_1; + tmpvar_1 = vec2(0.0, 0.0); + poisson[0] = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = vec2(0.527837, -0.085868); + poisson[1] = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = vec2(-0.040088, 0.536087); + poisson[2] = tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = vec2(-0.670445, -0.179949); + poisson[3] = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5 = vec2(-0.419418, -0.616039); + poisson[4] = tmpvar_5; + vec2 tmpvar_6; + tmpvar_6 = vec2(0.440453, -0.639399); + poisson[5] = tmpvar_6; + vec2 tmpvar_7; + tmpvar_7 = vec2(-0.757088, 0.349334); + poisson[6] = tmpvar_7; + vec2 tmpvar_8; + tmpvar_8 = vec2(0.574619, 0.685879); + poisson[7] = tmpvar_8; + int tmpvar_9; + tmpvar_9 = 0; + i = tmpvar_9; + vec4 tmpvar_10; + tmpvar_10 = vec4(0.0, 0.0, 0.0, 0.0); + c = tmpvar_10; + while (true) { + if (!((i < 8))) { + break; + }; + vec2 tmpvar_11; + tmpvar_11 = (c.xy + poisson[i]); + c.xy = tmpvar_11.xy.xy; + int tmpvar_12; + tmpvar_12 = (i + 1); + i = tmpvar_12; + }; + return c; +} + +void main () +{ + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = xlat_main (); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xl_retval = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = xl_retval.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + gl_FragData[0] = tmpvar_4; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/array-const-irES.txt b/3rdparty/glsl-optimizer/tests/fragment/array-const-irES.txt new file mode 100644 index 000000000..1fe6f6f9a --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/array-const-irES.txt @@ -0,0 +1,64 @@ +mediump vec4 xlat_main () +{ + int i; + mediump vec4 c; + highp vec2 poisson[8]; + vec2 tmpvar_1; + tmpvar_1 = vec2(0.0, 0.0); + poisson[0] = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = vec2(0.527837, -0.085868); + poisson[1] = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = vec2(-0.040088, 0.536087); + poisson[2] = tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = vec2(-0.670445, -0.179949); + poisson[3] = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5 = vec2(-0.419418, -0.616039); + poisson[4] = tmpvar_5; + vec2 tmpvar_6; + tmpvar_6 = vec2(0.440453, -0.639399); + poisson[5] = tmpvar_6; + vec2 tmpvar_7; + tmpvar_7 = vec2(-0.757088, 0.349334); + poisson[6] = tmpvar_7; + vec2 tmpvar_8; + tmpvar_8 = vec2(0.574619, 0.685879); + poisson[7] = tmpvar_8; + int tmpvar_9; + tmpvar_9 = 0; + i = tmpvar_9; + vec4 tmpvar_10; + tmpvar_10 = vec4(0.0, 0.0, 0.0, 0.0); + c = tmpvar_10; + while (true) { + if (!((i < 8))) { + break; + }; + highp vec2 tmpvar_11; + tmpvar_11 = (c.xy + poisson[i]); + c.xy = tmpvar_11.xy.xy; + int tmpvar_12; + tmpvar_12 = (i + 1); + i = tmpvar_12; + }; + return c; +} + +void main () +{ + mediump vec4 xl_retval; + mediump vec4 tmpvar_1; + tmpvar_1 = xlat_main (); + mediump vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xl_retval = tmpvar_2; + mediump vec4 tmpvar_3; + tmpvar_3 = xl_retval.xyzw; + mediump vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + gl_FragData[0] = tmpvar_4; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/array-const-out.txt b/3rdparty/glsl-optimizer/tests/fragment/array-const-out.txt new file mode 100644 index 000000000..a27dfea03 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/array-const-out.txt @@ -0,0 +1,24 @@ +void main () +{ + vec4 c; + vec2 poisson[8]; + poisson[0] = vec2(0.0, 0.0); + poisson[1] = vec2(0.527837, -0.085868); + poisson[2] = vec2(-0.040088, 0.536087); + poisson[3] = vec2(-0.670445, -0.179949); + poisson[4] = vec2(-0.419418, -0.616039); + poisson[5] = vec2(0.440453, -0.639399); + poisson[6] = vec2(-0.757088, 0.349334); + poisson[7] = vec2(0.574619, 0.685879); + c = vec4(0.0, 0.0, 0.0, 0.0); + c.xy = poisson[0]; + c.xy = (c.xy + poisson[1]); + c.xy = (c.xy + poisson[2]); + c.xy = (c.xy + poisson[3]); + c.xy = (c.xy + poisson[4]); + c.xy = (c.xy + poisson[5]); + c.xy = (c.xy + poisson[6]); + c.xy = (c.xy + poisson[7]); + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/array-const-outES.txt b/3rdparty/glsl-optimizer/tests/fragment/array-const-outES.txt new file mode 100644 index 000000000..84c2f7f67 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/array-const-outES.txt @@ -0,0 +1,40 @@ +void main () +{ + mediump vec4 c; + highp vec2 poisson[8]; + poisson[0] = vec2(0.0, 0.0); + poisson[1] = vec2(0.527837, -0.085868); + poisson[2] = vec2(-0.040088, 0.536087); + poisson[3] = vec2(-0.670445, -0.179949); + poisson[4] = vec2(-0.419418, -0.616039); + poisson[5] = vec2(0.440453, -0.639399); + poisson[6] = vec2(-0.757088, 0.349334); + poisson[7] = vec2(0.574619, 0.685879); + c = vec4(0.0, 0.0, 0.0, 0.0); + highp vec2 tmpvar_1; + tmpvar_1 = poisson[0]; + c.xy = tmpvar_1; + highp vec2 tmpvar_2; + tmpvar_2 = (c.xy + poisson[1]); + c.xy = tmpvar_2; + highp vec2 tmpvar_3; + tmpvar_3 = (c.xy + poisson[2]); + c.xy = tmpvar_3; + highp vec2 tmpvar_4; + tmpvar_4 = (c.xy + poisson[3]); + c.xy = tmpvar_4; + highp vec2 tmpvar_5; + tmpvar_5 = (c.xy + poisson[4]); + c.xy = tmpvar_5; + highp vec2 tmpvar_6; + tmpvar_6 = (c.xy + poisson[5]); + c.xy = tmpvar_6; + highp vec2 tmpvar_7; + tmpvar_7 = (c.xy + poisson[6]); + c.xy = tmpvar_7; + highp vec2 tmpvar_8; + tmpvar_8 = (c.xy + poisson[7]); + c.xy = tmpvar_8; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/array-constconst-in.txt b/3rdparty/glsl-optimizer/tests/fragment/array-constconst-in.txt new file mode 100644 index 000000000..56dccb65b --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/array-constconst-in.txt @@ -0,0 +1,24 @@ +vec4 xlat_main( ); +vec4 xlat_main( ) { + vec2 poisson[8]; + poisson[0] = vec2( 0.000000, 0.000000); + poisson[1] = vec2( 0.527837, -0.0858680); + poisson[2] = vec2( -0.0400880, 0.536087); + poisson[3] = vec2( -0.670445, -0.179949); + poisson[4] = vec2( -0.419418, -0.616039); + poisson[5] = vec2( 0.440453, -0.639399); + poisson[6] = vec2( -0.757088, 0.349334); + poisson[7] = vec2( 0.574619, 0.685879); + vec4 c; + int i = 0; + c = vec4( 0.000000); + for ( ; (i < 8); ( ++i )) { + c.xy += poisson[ i ]; + } + return c; +} +void main() { + vec4 xl_retval; + xl_retval = xlat_main( ); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/array-constconst-inES.txt b/3rdparty/glsl-optimizer/tests/fragment/array-constconst-inES.txt new file mode 100644 index 000000000..7a903b0e7 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/array-constconst-inES.txt @@ -0,0 +1,24 @@ +mediump vec4 xlat_main( ); +mediump vec4 xlat_main( ) { + highp vec2 poisson[8]; + poisson[0] = vec2( 0.000000, 0.000000); + poisson[1] = vec2( 0.527837, -0.0858680); + poisson[2] = vec2( -0.0400880, 0.536087); + poisson[3] = vec2( -0.670445, -0.179949); + poisson[4] = vec2( -0.419418, -0.616039); + poisson[5] = vec2( 0.440453, -0.639399); + poisson[6] = vec2( -0.757088, 0.349334); + poisson[7] = vec2( 0.574619, 0.685879); + mediump vec4 c; + highp int i = 0; + c = vec4( 0.000000); + for ( ; (i < 8); ( ++i )) { + c.xy += poisson[ i ]; + } + return c; +} +void main() { + mediump vec4 xl_retval; + xl_retval = xlat_main( ); + gl_FragData[0] = mediump vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/array-constconst-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/array-constconst-ir.txt new file mode 100644 index 000000000..feec7c2bc --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/array-constconst-ir.txt @@ -0,0 +1,64 @@ +vec4 xlat_main () +{ + int i; + vec4 c; + vec2 poisson[8]; + vec2 tmpvar_1; + tmpvar_1 = vec2(0.0, 0.0); + poisson[0] = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = vec2(0.527837, -0.085868); + poisson[1] = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = vec2(-0.040088, 0.536087); + poisson[2] = tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = vec2(-0.670445, -0.179949); + poisson[3] = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5 = vec2(-0.419418, -0.616039); + poisson[4] = tmpvar_5; + vec2 tmpvar_6; + tmpvar_6 = vec2(0.440453, -0.639399); + poisson[5] = tmpvar_6; + vec2 tmpvar_7; + tmpvar_7 = vec2(-0.757088, 0.349334); + poisson[6] = tmpvar_7; + vec2 tmpvar_8; + tmpvar_8 = vec2(0.574619, 0.685879); + poisson[7] = tmpvar_8; + int tmpvar_9; + tmpvar_9 = 0; + i = tmpvar_9; + vec4 tmpvar_10; + tmpvar_10 = vec4(0.0, 0.0, 0.0, 0.0); + c = tmpvar_10; + while (true) { + if (!((i < 8))) { + break; + }; + vec2 tmpvar_11; + tmpvar_11 = (c.xy + poisson[i]); + c.xy = tmpvar_11.xy.xy; + int tmpvar_12; + tmpvar_12 = (i + 1); + i = tmpvar_12; + }; + return c; +} + +void main () +{ + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = xlat_main (); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xl_retval = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = xl_retval.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + gl_FragData[0] = tmpvar_4; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/array-constconst-irES.txt b/3rdparty/glsl-optimizer/tests/fragment/array-constconst-irES.txt new file mode 100644 index 000000000..1fe6f6f9a --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/array-constconst-irES.txt @@ -0,0 +1,64 @@ +mediump vec4 xlat_main () +{ + int i; + mediump vec4 c; + highp vec2 poisson[8]; + vec2 tmpvar_1; + tmpvar_1 = vec2(0.0, 0.0); + poisson[0] = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = vec2(0.527837, -0.085868); + poisson[1] = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = vec2(-0.040088, 0.536087); + poisson[2] = tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = vec2(-0.670445, -0.179949); + poisson[3] = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5 = vec2(-0.419418, -0.616039); + poisson[4] = tmpvar_5; + vec2 tmpvar_6; + tmpvar_6 = vec2(0.440453, -0.639399); + poisson[5] = tmpvar_6; + vec2 tmpvar_7; + tmpvar_7 = vec2(-0.757088, 0.349334); + poisson[6] = tmpvar_7; + vec2 tmpvar_8; + tmpvar_8 = vec2(0.574619, 0.685879); + poisson[7] = tmpvar_8; + int tmpvar_9; + tmpvar_9 = 0; + i = tmpvar_9; + vec4 tmpvar_10; + tmpvar_10 = vec4(0.0, 0.0, 0.0, 0.0); + c = tmpvar_10; + while (true) { + if (!((i < 8))) { + break; + }; + highp vec2 tmpvar_11; + tmpvar_11 = (c.xy + poisson[i]); + c.xy = tmpvar_11.xy.xy; + int tmpvar_12; + tmpvar_12 = (i + 1); + i = tmpvar_12; + }; + return c; +} + +void main () +{ + mediump vec4 xl_retval; + mediump vec4 tmpvar_1; + tmpvar_1 = xlat_main (); + mediump vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xl_retval = tmpvar_2; + mediump vec4 tmpvar_3; + tmpvar_3 = xl_retval.xyzw; + mediump vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + gl_FragData[0] = tmpvar_4; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/array-constconst-out.txt b/3rdparty/glsl-optimizer/tests/fragment/array-constconst-out.txt new file mode 100644 index 000000000..a27dfea03 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/array-constconst-out.txt @@ -0,0 +1,24 @@ +void main () +{ + vec4 c; + vec2 poisson[8]; + poisson[0] = vec2(0.0, 0.0); + poisson[1] = vec2(0.527837, -0.085868); + poisson[2] = vec2(-0.040088, 0.536087); + poisson[3] = vec2(-0.670445, -0.179949); + poisson[4] = vec2(-0.419418, -0.616039); + poisson[5] = vec2(0.440453, -0.639399); + poisson[6] = vec2(-0.757088, 0.349334); + poisson[7] = vec2(0.574619, 0.685879); + c = vec4(0.0, 0.0, 0.0, 0.0); + c.xy = poisson[0]; + c.xy = (c.xy + poisson[1]); + c.xy = (c.xy + poisson[2]); + c.xy = (c.xy + poisson[3]); + c.xy = (c.xy + poisson[4]); + c.xy = (c.xy + poisson[5]); + c.xy = (c.xy + poisson[6]); + c.xy = (c.xy + poisson[7]); + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/array-constconst-outES.txt b/3rdparty/glsl-optimizer/tests/fragment/array-constconst-outES.txt new file mode 100644 index 000000000..84c2f7f67 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/array-constconst-outES.txt @@ -0,0 +1,40 @@ +void main () +{ + mediump vec4 c; + highp vec2 poisson[8]; + poisson[0] = vec2(0.0, 0.0); + poisson[1] = vec2(0.527837, -0.085868); + poisson[2] = vec2(-0.040088, 0.536087); + poisson[3] = vec2(-0.670445, -0.179949); + poisson[4] = vec2(-0.419418, -0.616039); + poisson[5] = vec2(0.440453, -0.639399); + poisson[6] = vec2(-0.757088, 0.349334); + poisson[7] = vec2(0.574619, 0.685879); + c = vec4(0.0, 0.0, 0.0, 0.0); + highp vec2 tmpvar_1; + tmpvar_1 = poisson[0]; + c.xy = tmpvar_1; + highp vec2 tmpvar_2; + tmpvar_2 = (c.xy + poisson[1]); + c.xy = tmpvar_2; + highp vec2 tmpvar_3; + tmpvar_3 = (c.xy + poisson[2]); + c.xy = tmpvar_3; + highp vec2 tmpvar_4; + tmpvar_4 = (c.xy + poisson[3]); + c.xy = tmpvar_4; + highp vec2 tmpvar_5; + tmpvar_5 = (c.xy + poisson[4]); + c.xy = tmpvar_5; + highp vec2 tmpvar_6; + tmpvar_6 = (c.xy + poisson[5]); + c.xy = tmpvar_6; + highp vec2 tmpvar_7; + tmpvar_7 = (c.xy + poisson[6]); + c.xy = tmpvar_7; + highp vec2 tmpvar_8; + tmpvar_8 = (c.xy + poisson[7]); + c.xy = tmpvar_8; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/ast-in.txt b/3rdparty/glsl-optimizer/tests/fragment/ast-in.txt new file mode 100644 index 000000000..42ca76a67 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/ast-in.txt @@ -0,0 +1,23 @@ +void main() { + if (gl_FragCoord.x==1.0) + discard; + float a; + if (2==3) + a = 2.0; + if (3==4) + a = 3.0; + else + a = 4.0; + for (int i = 0; i < 10; ++i) + a += 1.0; + do { + a += 2.0; + } while (0==1); + a += 1.0; + a *= a; + a = -a; + --a; + a = sqrt(a); + a = 1.0 / a; + gl_FragColor = vec4(a); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/ast-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/ast-ir.txt new file mode 100644 index 000000000..f0a929a4b --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/ast-ir.txt @@ -0,0 +1,70 @@ +void main () +{ + int i; + float a; + if ((gl_FragCoord.x == 1.0)) { + discard; + }; + if ((2 == 3)) { + float tmpvar_1; + tmpvar_1 = 2.0; + a = tmpvar_1; + }; + if ((3 == 4)) { + float tmpvar_2; + tmpvar_2 = 3.0; + a = tmpvar_2; + } else { + float tmpvar_3; + tmpvar_3 = 4.0; + a = tmpvar_3; + }; + int tmpvar_4; + tmpvar_4 = 0; + i = tmpvar_4; + while (true) { + if (!((i < 10))) { + break; + }; + float tmpvar_5; + tmpvar_5 = (a + 1.0); + a = tmpvar_5; + int tmpvar_6; + tmpvar_6 = (i + 1); + i = tmpvar_6; + }; + while (true) { + float tmpvar_7; + tmpvar_7 = (a + 2.0); + a = tmpvar_7; + if (!((0 == 1))) { + break; + }; + }; + float tmpvar_8; + tmpvar_8 = (a + 1.0); + a = tmpvar_8; + float tmpvar_9; + tmpvar_9 = (a * a); + a = tmpvar_9; + float tmpvar_10; + tmpvar_10 = -(a); + a = tmpvar_10; + float tmpvar_11; + tmpvar_11 = (a - 1.0); + a = tmpvar_11; + float tmpvar_12; + tmpvar_12 = sqrt (a); + float tmpvar_13; + tmpvar_13 = tmpvar_12; + a = tmpvar_13; + float tmpvar_14; + tmpvar_14 = (1.0 / a); + a = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = vec4(a); + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_FragColor = tmpvar_16; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/ast-out.txt b/3rdparty/glsl-optimizer/tests/fragment/ast-out.txt new file mode 100644 index 000000000..86327ef11 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/ast-out.txt @@ -0,0 +1,25 @@ +void main () +{ + int i; + float a; + if ((gl_FragCoord.x == 1.0)) { + discard; + }; + a = 4.0; + i = 0; + for (int i = 0; i < 10; ) { + a = (a + 1.0); + i = (i + 1); + }; + while (true) { + a = (a + 2.0); + break; + }; + float tmpvar_1; + tmpvar_1 = (a + 1.0); + float tmpvar_2; + tmpvar_2 = (1.0/(sqrt ((-((tmpvar_1 * tmpvar_1)) - 1.0)))); + a = tmpvar_2; + gl_FragColor = vec4(tmpvar_2); +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/basic-in.txt b/3rdparty/glsl-optimizer/tests/fragment/basic-in.txt new file mode 100644 index 000000000..8526483fa --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/basic-in.txt @@ -0,0 +1,9 @@ +vec4 xlat_main( ); +vec4 xlat_main( ) { + return vec4( 1.00000); +} +void main() { + vec4 xl_retval; + xl_retval = xlat_main( ); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/basic-inES.txt b/3rdparty/glsl-optimizer/tests/fragment/basic-inES.txt new file mode 100644 index 000000000..fb7cd4e03 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/basic-inES.txt @@ -0,0 +1,9 @@ +mediump vec4 xlat_main( ); +mediump vec4 xlat_main( ) { + return vec4( 1.00000); +} +void main() { + mediump vec4 xl_retval; + xl_retval = xlat_main( ); + gl_FragData[0] = mediump vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/basic-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/basic-ir.txt new file mode 100644 index 000000000..c1fbea114 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/basic-ir.txt @@ -0,0 +1,20 @@ +vec4 xlat_main () +{ + return vec4(1.0, 1.0, 1.0, 1.0); +} + +void main () +{ + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = xlat_main (); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xl_retval = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = xl_retval.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + gl_FragData[0] = tmpvar_4; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/basic-irES.txt b/3rdparty/glsl-optimizer/tests/fragment/basic-irES.txt new file mode 100644 index 000000000..636fe9d20 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/basic-irES.txt @@ -0,0 +1,20 @@ +mediump vec4 xlat_main () +{ + return vec4(1.0, 1.0, 1.0, 1.0); +} + +void main () +{ + mediump vec4 xl_retval; + mediump vec4 tmpvar_1; + tmpvar_1 = xlat_main (); + mediump vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xl_retval = tmpvar_2; + mediump vec4 tmpvar_3; + tmpvar_3 = xl_retval.xyzw; + mediump vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + gl_FragData[0] = tmpvar_4; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/basic-out.txt b/3rdparty/glsl-optimizer/tests/fragment/basic-out.txt new file mode 100644 index 000000000..c41789ad6 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/basic-out.txt @@ -0,0 +1,5 @@ +void main () +{ + gl_FragData[0] = vec4(1.0, 1.0, 1.0, 1.0); +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/basic-outES.txt b/3rdparty/glsl-optimizer/tests/fragment/basic-outES.txt new file mode 100644 index 000000000..c41789ad6 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/basic-outES.txt @@ -0,0 +1,5 @@ +void main () +{ + gl_FragData[0] = vec4(1.0, 1.0, 1.0, 1.0); +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/bug-global-init-in.txt b/3rdparty/glsl-optimizer/tests/fragment/bug-global-init-in.txt new file mode 100644 index 000000000..010d4ee29 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/bug-global-init-in.txt @@ -0,0 +1,6 @@ +uniform float value; +float otherValue = log(value); +void main() +{ + gl_FragColor = vec4(otherValue); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/bug-global-init-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/bug-global-init-ir.txt new file mode 100644 index 000000000..c46e53029 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/bug-global-init-ir.txt @@ -0,0 +1,19 @@ +float otherValue; +uniform float value; +float tmpvar_1; +//; +float tmpvar_2; +//; +//; +void main () +{ +tmpvar_1 = log (value); +tmpvar_2 = tmpvar_1; +otherValue = tmpvar_2; + vec4 tmpvar_1; + tmpvar_1 = vec4(otherValue); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + gl_FragColor = tmpvar_2; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/bug-global-init-out.txt b/3rdparty/glsl-optimizer/tests/fragment/bug-global-init-out.txt new file mode 100644 index 000000000..10d07ae6a --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/bug-global-init-out.txt @@ -0,0 +1,9 @@ +float otherValue; +uniform float value; +//; +void main () +{ +otherValue = log (value); + gl_FragColor = vec4(otherValue); +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/bug-loop-null-from-in.txt b/3rdparty/glsl-optimizer/tests/fragment/bug-loop-null-from-in.txt new file mode 100644 index 000000000..3a38c8a78 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/bug-loop-null-from-in.txt @@ -0,0 +1,9 @@ +void main() { + float a = 0.0; + int k = 0; + for (int i = 0; i < 3; ++i) + a += 1.0; + for ( ; k < 3; ++k) + a += 3.0; + gl_FragColor = vec4(a); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/bug-loop-null-from-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/bug-loop-null-from-ir.txt new file mode 100644 index 000000000..0766427ae --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/bug-loop-null-from-ir.txt @@ -0,0 +1,43 @@ +void main () +{ + int i; + int k; + float a; + float tmpvar_1; + tmpvar_1 = 0.0; + a = tmpvar_1; + int tmpvar_2; + tmpvar_2 = 0; + k = tmpvar_2; + int tmpvar_3; + tmpvar_3 = 0; + i = tmpvar_3; + while (true) { + if (!((i < 3))) { + break; + }; + float tmpvar_4; + tmpvar_4 = (a + 1.0); + a = tmpvar_4; + int tmpvar_5; + tmpvar_5 = (i + 1); + i = tmpvar_5; + }; + while (true) { + if (!((k < 3))) { + break; + }; + float tmpvar_6; + tmpvar_6 = (a + 3.0); + a = tmpvar_6; + int tmpvar_7; + tmpvar_7 = (k + 1); + k = tmpvar_7; + }; + vec4 tmpvar_8; + tmpvar_8 = vec4(a); + vec4 tmpvar_9; + tmpvar_9 = tmpvar_8; + gl_FragColor = tmpvar_9; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/bug-loop-null-from-out.txt b/3rdparty/glsl-optimizer/tests/fragment/bug-loop-null-from-out.txt new file mode 100644 index 000000000..2ea5bec87 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/bug-loop-null-from-out.txt @@ -0,0 +1,5 @@ +void main () +{ + gl_FragColor = vec4(12.0, 12.0, 12.0, 12.0); +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/bug-op-parens-in.txt b/3rdparty/glsl-optimizer/tests/fragment/bug-op-parens-in.txt new file mode 100644 index 000000000..390b2907b --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/bug-op-parens-in.txt @@ -0,0 +1,8 @@ +uniform float value; +uniform float otherValue; +void main() +{ + float invValue = 1.0 / value; + float result = otherValue / invValue; + gl_FragColor = vec4(result); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/bug-op-parens-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/bug-op-parens-ir.txt new file mode 100644 index 000000000..f763f4bac --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/bug-op-parens-ir.txt @@ -0,0 +1,19 @@ +uniform float otherValue; +uniform float value; +void main () +{ + float result; + float invValue; + float tmpvar_1; + tmpvar_1 = (1.0 / value); + invValue = tmpvar_1; + float tmpvar_2; + tmpvar_2 = (otherValue / invValue); + result = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = vec4(result); + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + gl_FragColor = tmpvar_4; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/bug-op-parens-out.txt b/3rdparty/glsl-optimizer/tests/fragment/bug-op-parens-out.txt new file mode 100644 index 000000000..dff0ea386 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/bug-op-parens-out.txt @@ -0,0 +1,7 @@ +uniform float otherValue; +uniform float value; +void main () +{ + gl_FragColor = vec4((otherValue / (1.0/(value)))); +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/complex-alphabumpspec-in.txt b/3rdparty/glsl-optimizer/tests/fragment/complex-alphabumpspec-in.txt new file mode 100644 index 000000000..16755a7bf --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/complex-alphabumpspec-in.txt @@ -0,0 +1,111 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 viewDir; + vec3 lightDir; + vec3 vlight; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform sampler2D _BumpMap; +uniform vec4 _Color; +uniform vec4 _LightColor0; +uniform sampler2D _MainTex; +uniform float _Shininess; +uniform vec4 _SpecColor; +vec4 UnpackNormal( in vec4 packednormal ); +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingBlinnPhong( in SurfaceOutput s, in vec3 lightDir, in vec3 viewDir, in float atten ); +vec4 frag_surf( in v2f_surf IN ); +vec4 UnpackNormal( in vec4 packednormal ) { + vec4 normal; + normal.xy = ((packednormal.wy * 2.00000) - 1.00000); + normal.z = sqrt( ((1.00000 - (normal.x * normal.x )) - (normal.y * normal.y )) ); + return normal; +} +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 tex; + tex = texture2D( _MainTex, IN.uv_MainTex); + o.Albedo = (tex.xyz * _Color.xyz ); + o.Gloss = tex.w ; + o.Alpha = (tex.w * _Color.w ); + o.Specular = _Shininess; + o.Normal = vec3( UnpackNormal( texture2D( _BumpMap, IN.uv_BumpMap))); +} +vec4 LightingBlinnPhong( in SurfaceOutput s, in vec3 lightDir, in vec3 viewDir, in float atten ) { + vec3 h; + float diff; + float nh; + float spec; + vec4 c; + h = normalize( (lightDir + viewDir) ); + diff = max( 0.000000, dot( s.Normal, lightDir)); + nh = max( 0.000000, dot( s.Normal, h)); + spec = (pow( nh, (s.Specular * 128.000)) * s.Gloss); + c.xyz = ((((s.Albedo * _LightColor0.xyz ) * diff) + ((_LightColor0.xyz * _SpecColor.xyz ) * spec)) * (atten * 2.00000)); + c.w = (s.Alpha + (((_LightColor0.w * _SpecColor.w ) * spec) * atten)); + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + float atten = 1.00000; + vec4 c; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + surfIN.uv_BumpMap = IN.hip_pack0.zw ; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + surf( surfIN, o); + c = LightingBlinnPhong( o, IN.lightDir, normalize( vec3( IN.viewDir) ), atten); + c.xyz += (o.Albedo * IN.vlight); + c.w = o.Alpha; + return c; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec4( gl_TexCoord[0]); + xlt_IN.viewDir = vec3( gl_TexCoord[1]); + xlt_IN.lightDir = vec3( gl_TexCoord[2]); + xlt_IN.vlight = vec3( gl_TexCoord[3]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/complex-alphabumpspec-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/complex-alphabumpspec-ir.txt new file mode 100644 index 000000000..b80274de3 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/complex-alphabumpspec-ir.txt @@ -0,0 +1,215 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 viewDir; + vec3 lightDir; + vec3 vlight; +}; +varying vec4 xlv_FOG; +uniform vec4 _SpecColor; +uniform float _Shininess; +uniform sampler2D _MainTex; +uniform vec4 _LightColor0; +uniform vec4 _Color; +uniform sampler2D _BumpMap; +vec4 UnpackNormal ( + in vec4 packednormal +) +{ + vec4 normal; + vec2 tmpvar_1; + tmpvar_1 = ((packednormal.wy * 2.0) - 1.0); + normal.xy = tmpvar_1.xy.xy; + float tmpvar_2; + tmpvar_2 = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + normal.z = vec3(tmpvar_3).z; + return normal; +} + +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 tex; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + tex = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = (tex.xyz * _Color.xyz); + o.Albedo = tmpvar_3; + float tmpvar_4; + tmpvar_4 = tex.w; + o.Gloss = tmpvar_4; + float tmpvar_5; + tmpvar_5 = (tex.w * _Color.w); + o.Alpha = tmpvar_5; + float tmpvar_6; + tmpvar_6 = _Shininess; + o.Specular = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = texture2D (_BumpMap, IN.uv_BumpMap); + vec4 tmpvar_8; + tmpvar_8 = UnpackNormal (tmpvar_7); + vec3 tmpvar_9; + tmpvar_9 = tmpvar_8.xyz; + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + o.Normal = tmpvar_10; +} + +vec4 LightingBlinnPhong ( + in SurfaceOutput s, + in vec3 lightDir, + in vec3 viewDir, + in float atten +) +{ + vec4 c; + float spec; + float nh; + float diff; + vec3 h; + vec3 tmpvar_1; + tmpvar_1 = normalize ((lightDir + viewDir)); + vec3 tmpvar_2; + tmpvar_2 = tmpvar_1; + h = tmpvar_2; + float tmpvar_3; + tmpvar_3 = dot (s.Normal, lightDir); + float tmpvar_4; + tmpvar_4 = max (0.0, tmpvar_3); + float tmpvar_5; + tmpvar_5 = tmpvar_4; + diff = tmpvar_5; + float tmpvar_6; + tmpvar_6 = dot (s.Normal, h); + float tmpvar_7; + tmpvar_7 = max (0.0, tmpvar_6); + float tmpvar_8; + tmpvar_8 = tmpvar_7; + nh = tmpvar_8; + float tmpvar_9; + tmpvar_9 = pow (nh, (s.Specular * 128.0)); + float tmpvar_10; + tmpvar_10 = (tmpvar_9 * s.Gloss); + spec = tmpvar_10; + vec3 tmpvar_11; + tmpvar_11 = ((((s.Albedo * _LightColor0.xyz) * diff) + ((_LightColor0.xyz * _SpecColor.xyz) * spec)) * (atten * 2.0)); + c.xyz = tmpvar_11.xyz.xyz; + float tmpvar_12; + tmpvar_12 = (s.Alpha + (((_LightColor0.w * _SpecColor.w) * spec) * atten)); + c.w = vec4(tmpvar_12).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 c; + float atten; + SurfaceOutput o; + Input surfIN; + float tmpvar_1; + tmpvar_1 = 1.0; + atten = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = IN.hip_pack0.zw; + surfIN.uv_BumpMap = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Specular = tmpvar_6; + float tmpvar_7; + tmpvar_7 = 0.0; + o.Alpha = tmpvar_7; + float tmpvar_8; + tmpvar_8 = 0.0; + o.Gloss = tmpvar_8; + surf (surfIN, o); + vec3 tmpvar_9; + tmpvar_9 = IN.viewDir.xyz; + vec3 tmpvar_10; + tmpvar_10 = normalize (tmpvar_9); + vec4 tmpvar_11; + tmpvar_11 = LightingBlinnPhong (o, IN.lightDir, tmpvar_10, atten); + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + c = tmpvar_12; + vec3 tmpvar_13; + tmpvar_13 = (c.xyz + (o.Albedo * IN.vlight)); + c.xyz = tmpvar_13.xyz.xyz; + float tmpvar_14; + tmpvar_14 = o.Alpha; + c.w = vec4(tmpvar_14).w; + return c; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.viewDir = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.lightDir = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = gl_TexCoord[3].xyz; + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_IN.vlight = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = frag_surf (xlt_IN); + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xl_retval = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = xl_retval.xyzw; + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + gl_FragData[0] = tmpvar_14; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/complex-alphabumpspec-out.txt b/3rdparty/glsl-optimizer/tests/fragment/complex-alphabumpspec-out.txt new file mode 100644 index 000000000..827ae6291 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/complex-alphabumpspec-out.txt @@ -0,0 +1,35 @@ +uniform vec4 _SpecColor; +uniform float _Shininess; +uniform sampler2D _MainTex; +uniform vec4 _LightColor0; +uniform vec4 _Color; +uniform sampler2D _BumpMap; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = gl_TexCoord[0]; + vec3 tmpvar_2; + tmpvar_2 = gl_TexCoord[2].xyz; + vec4 c; + vec4 tmpvar_3; + tmpvar_3 = texture2D (_MainTex, tmpvar_1.xy); + vec3 tmpvar_4; + tmpvar_4 = (tmpvar_3.xyz * _Color.xyz); + float tmpvar_5; + tmpvar_5 = (tmpvar_3.w * _Color.w); + vec4 normal; + normal.xy = ((texture2D (_BumpMap, tmpvar_1.zw).wy * 2.0) - 1.0); + normal.z = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + vec3 tmpvar_6; + tmpvar_6 = normal.xyz; + vec4 c_i0; + float tmpvar_7; + tmpvar_7 = (pow (max (0.0, dot (tmpvar_6, normalize ((tmpvar_2 + normalize (gl_TexCoord[1].xyz))))), (_Shininess * 128.0)) * tmpvar_3.w); + c_i0.xyz = ((((tmpvar_4 * _LightColor0.xyz) * max (0.0, dot (tmpvar_6, tmpvar_2))) + ((_LightColor0.xyz * _SpecColor.xyz) * tmpvar_7)) * 2.0); + c_i0.w = (tmpvar_5 + ((_LightColor0.w * _SpecColor.w) * tmpvar_7)); + c = c_i0; + c.xyz = (c_i0.xyz + (tmpvar_4 * gl_TexCoord[3].xyz)); + c.w = tmpvar_5; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/complex-collectshadows-in.txt b/3rdparty/glsl-optimizer/tests/fragment/complex-collectshadows-in.txt new file mode 100644 index 000000000..e45ab823c --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/complex-collectshadows-in.txt @@ -0,0 +1,77 @@ +struct v2f { + vec4 pos; + vec2 uv; + vec3 ray; +}; +uniform sampler2D _CameraDepthTexture; +uniform vec4 _LightShadowData; +uniform vec4 _LightSplitsFar; +uniform vec4 _LightSplitsNear; +uniform sampler2D _ShadowMapTexture; +uniform mat4 _View2Shadow; +uniform mat4 _View2Shadow1; +uniform mat4 _View2Shadow2; +uniform mat4 _View2Shadow3; +uniform vec4 _ZBufferParams; +float unitySampleShadow( in vec4 eyePos ); +float Linear01Depth( in float z ); +vec2 EncodeFloatRG( in float v ); +vec4 xlat_main( in v2f i ); +float unitySampleShadow( in vec4 eyePos ) { + vec3 sc0; + vec3 sc1; + vec3 sc2; + vec3 sc3; + float z; + vec4 near; + vec4 far; + vec4 weights; + vec4 coord; + float shadow; + sc0 = ( _View2Shadow * eyePos ).xyz ; + sc1 = ( _View2Shadow1 * eyePos ).xyz ; + sc2 = ( _View2Shadow2 * eyePos ).xyz ; + sc3 = ( _View2Shadow3 * eyePos ).xyz ; + z = eyePos.z ; + near = vec4( greaterThanEqual( vec4( z ), _LightSplitsNear) ); + far = vec4( lessThan( vec4( z ), _LightSplitsFar) ); + weights = (near * far); + coord = vec4( ((((sc0 * weights.x ) + (sc1 * weights.y )) + (sc2 * weights.z )) + (sc3 * weights.w )), 1.00000); + shadow = ( (texture2D( _ShadowMapTexture, coord.xy ).x < coord.z ) ) ? ( _LightShadowData.x ) : ( 1.00000 ); + return shadow; +} +float Linear01Depth( in float z ) { + return (1.00000 / ((_ZBufferParams.x * z) + _ZBufferParams.y )); +} +vec2 EncodeFloatRG( in float v ) { + vec2 kEncodeMul = vec2( 1.00000, 255.000); + float kEncodeBit = 0.00392157; + vec2 enc; + enc = (kEncodeMul * v); + enc = fract( enc ); + enc.x -= (enc.y * kEncodeBit); + return enc; +} +vec4 xlat_main( in v2f i ) { + float depth; + vec4 vpos; + float shadow; + vec4 res; + depth = texture2D( _CameraDepthTexture, i.uv).x ; + depth = Linear01Depth( depth); + vpos = vec4( (i.ray * depth), 1.00000); + shadow = unitySampleShadow( vpos); + res.x = shadow; + res.y = 1.00000; + res.zw = EncodeFloatRG( (1.00000 - depth)); + return res; +} +void main() { + vec4 xl_retval; + v2f xlt_i; + xlt_i.pos = vec4(0.0); + xlt_i.uv = vec2( gl_TexCoord[0]); + xlt_i.ray = vec3( gl_TexCoord[1]); + xl_retval = xlat_main( xlt_i); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/complex-collectshadows-inES.txt b/3rdparty/glsl-optimizer/tests/fragment/complex-collectshadows-inES.txt new file mode 100644 index 000000000..a9da4c652 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/complex-collectshadows-inES.txt @@ -0,0 +1,79 @@ +struct v2f { + highp vec4 pos; + highp vec2 uv; + highp vec3 ray; +}; +uniform sampler2D _CameraDepthTexture; +uniform highp vec4 _LightShadowData; +uniform highp vec4 _LightSplitsFar; +uniform highp vec4 _LightSplitsNear; +uniform sampler2D _ShadowMapTexture; +uniform highp mat4 _View2Shadow; +uniform highp mat4 _View2Shadow1; +uniform highp mat4 _View2Shadow2; +uniform highp mat4 _View2Shadow3; +uniform highp vec4 _ZBufferParams; +mediump float unitySampleShadow( in highp vec4 eyePos ); +highp float Linear01Depth( in highp float z ); +highp vec2 EncodeFloatRG( in highp float v ); +mediump vec4 xlat_main( in v2f i ); +mediump float unitySampleShadow( in highp vec4 eyePos ) { + highp vec3 sc0; + highp vec3 sc1; + highp vec3 sc2; + highp vec3 sc3; + highp float z; + highp vec4 near; + highp vec4 far; + highp vec4 weights; + highp vec4 coord; + mediump float shadow; + sc0 = ( _View2Shadow * eyePos ).xyz ; + sc1 = ( _View2Shadow1 * eyePos ).xyz ; + sc2 = ( _View2Shadow2 * eyePos ).xyz ; + sc3 = ( _View2Shadow3 * eyePos ).xyz ; + z = eyePos.z ; + near = vec4( greaterThanEqual( vec4( z ), _LightSplitsNear) ); + far = vec4( lessThan( vec4( z ), _LightSplitsFar) ); + weights = (near * far); + coord = vec4( ((((sc0 * weights.x ) + (sc1 * weights.y )) + (sc2 * weights.z )) + (sc3 * weights.w )), 1.00000); + shadow = ( (texture2D( _ShadowMapTexture, coord.xy ).x < coord.z ) ) ? ( _LightShadowData.x ) : ( 1.00000 ); + return shadow; +} +highp float Linear01Depth( in highp float z ) { + return (1.00000 / ((_ZBufferParams.x * z) + _ZBufferParams.y )); +} +highp vec2 EncodeFloatRG( in highp float v ) { + highp vec2 kEncodeMul = vec2( 1.00000, 255.000); + highp float kEncodeBit = 0.00392157; + highp vec2 enc; + enc = (kEncodeMul * v); + enc = fract( enc ); + enc.x -= (enc.y * kEncodeBit); + return enc; +} +mediump vec4 xlat_main( in v2f i ) { + highp float depth; + highp vec4 vpos; + mediump float shadow; + highp vec4 res; + depth = texture2D( _CameraDepthTexture, i.uv).x ; + depth = Linear01Depth( depth); + vpos = vec4( (i.ray * depth), 1.00000); + shadow = unitySampleShadow( vpos); + res.x = shadow; + res.y = 1.00000; + res.zw = EncodeFloatRG( (1.00000 - depth)); + return res; +} +varying highp vec2 xlv_TEXCOORD0; +varying highp vec3 xlv_TEXCOORD1; +void main() { + mediump vec4 xl_retval; + v2f xlt_i; + xlt_i.pos = highp vec4(0.0); + xlt_i.uv = highp vec2( xlv_TEXCOORD0); + xlt_i.ray = highp vec3( xlv_TEXCOORD1); + xl_retval = xlat_main( xlt_i); + gl_FragData[0] = mediump vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/complex-collectshadows-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/complex-collectshadows-ir.txt new file mode 100644 index 000000000..618f61203 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/complex-collectshadows-ir.txt @@ -0,0 +1,191 @@ +struct v2f { + vec4 pos; + vec2 uv; + vec3 ray; +}; +uniform vec4 _ZBufferParams; +uniform mat4 _View2Shadow3; +uniform mat4 _View2Shadow2; +uniform mat4 _View2Shadow1; +uniform mat4 _View2Shadow; +uniform sampler2D _ShadowMapTexture; +uniform vec4 _LightSplitsNear; +uniform vec4 _LightSplitsFar; +uniform vec4 _LightShadowData; +uniform sampler2D _CameraDepthTexture; +float unitySampleShadow ( + in vec4 eyePos +) +{ + float shadow; + vec4 coord; + vec4 weights; + vec4 far; + vec4 near; + float z; + vec3 sc3; + vec3 sc2; + vec3 sc1; + vec3 sc0; + vec3 tmpvar_1; + tmpvar_1 = (_View2Shadow * eyePos).xyz; + sc0 = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = (_View2Shadow1 * eyePos).xyz; + sc1 = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = (_View2Shadow2 * eyePos).xyz; + sc2 = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = (_View2Shadow3 * eyePos).xyz; + sc3 = tmpvar_4; + float tmpvar_5; + tmpvar_5 = eyePos.z; + z = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = vec4(z); + bvec4 tmpvar_7; + tmpvar_7 = greaterThanEqual (tmpvar_6, _LightSplitsNear); + vec4 tmpvar_8; + tmpvar_8 = vec4(tmpvar_7).xyzw; + vec4 tmpvar_9; + tmpvar_9 = tmpvar_8; + near = tmpvar_9; + vec4 tmpvar_10; + tmpvar_10 = vec4(z); + bvec4 tmpvar_11; + tmpvar_11 = lessThan (tmpvar_10, _LightSplitsFar); + vec4 tmpvar_12; + tmpvar_12 = vec4(tmpvar_11).xyzw; + vec4 tmpvar_13; + tmpvar_13 = tmpvar_12; + far = tmpvar_13; + vec4 tmpvar_14; + tmpvar_14 = (near * far); + weights = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15.w = 1.0; + tmpvar_15.xyz = ((((sc0 * weights.x) + (sc1 * weights.y)) + (sc2 * weights.z)) + (sc3 * weights.w)).xyz; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + coord = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17 = texture2D (_ShadowMapTexture, coord.xy); + float tmpvar_18; + if ((tmpvar_17.x < coord.z)) { + tmpvar_18 = _LightShadowData.x; + } else { + tmpvar_18 = 1.0; + }; + float tmpvar_19; + tmpvar_19 = tmpvar_18; + shadow = tmpvar_19; + return shadow; +} + +float Linear01Depth ( + in float z +) +{ + return (1.0 / ((_ZBufferParams.x * z) + _ZBufferParams.y)); +} + +vec2 EncodeFloatRG ( + in float v +) +{ + vec2 enc; + float kEncodeBit; + vec2 kEncodeMul; + vec2 tmpvar_1; + tmpvar_1 = vec2(1.0, 255.0); + kEncodeMul = tmpvar_1; + float tmpvar_2; + tmpvar_2 = 0.00392157; + kEncodeBit = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = (kEncodeMul * v); + enc = tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = fract (enc); + vec2 tmpvar_5; + tmpvar_5 = tmpvar_4; + enc = tmpvar_5; + float tmpvar_6; + tmpvar_6 = (enc.x - (enc.y * kEncodeBit)); + enc.x = tmpvar_6; + return enc; +} + +vec4 xlat_main ( + in v2f i +) +{ + vec4 res; + float shadow; + vec4 vpos; + float depth; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_CameraDepthTexture, i.uv); + float tmpvar_2; + tmpvar_2 = tmpvar_1.x; + depth = tmpvar_2; + float tmpvar_3; + tmpvar_3 = Linear01Depth (depth); + float tmpvar_4; + tmpvar_4 = tmpvar_3; + depth = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5.w = 1.0; + tmpvar_5.xyz = (i.ray * depth).xyz; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_5; + vpos = tmpvar_6; + float tmpvar_7; + tmpvar_7 = unitySampleShadow (vpos); + float tmpvar_8; + tmpvar_8 = tmpvar_7; + shadow = tmpvar_8; + float tmpvar_9; + tmpvar_9 = shadow; + res.x = tmpvar_9; + float tmpvar_10; + tmpvar_10 = 1.0; + res.y = vec2(tmpvar_10).y; + vec2 tmpvar_11; + tmpvar_11 = EncodeFloatRG ((1.0 - depth)); + vec2 tmpvar_12; + tmpvar_12 = tmpvar_11; + res.zw = tmpvar_12.xxxy.zw; + return res; +} + +void main () +{ + v2f xlt_i; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_i.pos = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = gl_TexCoord[0].xy; + vec2 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_i.uv = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = gl_TexCoord[1].xyz; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_4; + xlt_i.ray = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = xlat_main (xlt_i); + vec4 tmpvar_7; + tmpvar_7 = tmpvar_6; + xl_retval = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = xl_retval.xyzw; + vec4 tmpvar_9; + tmpvar_9 = tmpvar_8; + gl_FragData[0] = tmpvar_9; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/complex-collectshadows-irES.txt b/3rdparty/glsl-optimizer/tests/fragment/complex-collectshadows-irES.txt new file mode 100644 index 000000000..56963b8a4 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/complex-collectshadows-irES.txt @@ -0,0 +1,193 @@ +struct v2f { + highp vec4 pos; + highp vec2 uv; + highp vec3 ray; +}; +varying highp vec3 xlv_TEXCOORD1; +varying highp vec2 xlv_TEXCOORD0; +uniform highp vec4 _ZBufferParams; +uniform highp mat4 _View2Shadow3; +uniform highp mat4 _View2Shadow2; +uniform highp mat4 _View2Shadow1; +uniform highp mat4 _View2Shadow; +uniform sampler2D _ShadowMapTexture; +uniform highp vec4 _LightSplitsNear; +uniform highp vec4 _LightSplitsFar; +uniform highp vec4 _LightShadowData; +uniform sampler2D _CameraDepthTexture; +mediump float unitySampleShadow ( + in highp vec4 eyePos +) +{ + mediump float shadow; + highp vec4 coord; + highp vec4 weights; + highp vec4 far; + highp vec4 near; + highp float z; + highp vec3 sc3; + highp vec3 sc2; + highp vec3 sc1; + highp vec3 sc0; + highp vec3 tmpvar_1; + tmpvar_1 = (_View2Shadow * eyePos).xyz; + sc0 = tmpvar_1; + highp vec3 tmpvar_2; + tmpvar_2 = (_View2Shadow1 * eyePos).xyz; + sc1 = tmpvar_2; + highp vec3 tmpvar_3; + tmpvar_3 = (_View2Shadow2 * eyePos).xyz; + sc2 = tmpvar_3; + highp vec3 tmpvar_4; + tmpvar_4 = (_View2Shadow3 * eyePos).xyz; + sc3 = tmpvar_4; + highp float tmpvar_5; + tmpvar_5 = eyePos.z; + z = tmpvar_5; + highp vec4 tmpvar_6; + tmpvar_6 = vec4(z); + bvec4 tmpvar_7; + tmpvar_7 = greaterThanEqual (tmpvar_6, _LightSplitsNear); + lowp vec4 tmpvar_8; + tmpvar_8 = vec4(tmpvar_7).xyzw; + lowp vec4 tmpvar_9; + tmpvar_9 = tmpvar_8; + near = tmpvar_9; + highp vec4 tmpvar_10; + tmpvar_10 = vec4(z); + bvec4 tmpvar_11; + tmpvar_11 = lessThan (tmpvar_10, _LightSplitsFar); + lowp vec4 tmpvar_12; + tmpvar_12 = vec4(tmpvar_11).xyzw; + lowp vec4 tmpvar_13; + tmpvar_13 = tmpvar_12; + far = tmpvar_13; + highp vec4 tmpvar_14; + tmpvar_14 = (near * far); + weights = tmpvar_14; + highp vec4 tmpvar_15; + tmpvar_15.w = 1.0; + tmpvar_15.xyz = ((((sc0 * weights.x) + (sc1 * weights.y)) + (sc2 * weights.z)) + (sc3 * weights.w)).xyz; + highp vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + coord = tmpvar_16; + lowp vec4 tmpvar_17; + tmpvar_17 = texture2D (_ShadowMapTexture, coord.xy); + highp float tmpvar_18; + if ((tmpvar_17.x < coord.z)) { + tmpvar_18 = _LightShadowData.x; + } else { + tmpvar_18 = 1.0; + }; + highp float tmpvar_19; + tmpvar_19 = tmpvar_18; + shadow = tmpvar_19; + return shadow; +} + +float Linear01Depth ( + in highp float z +) +{ + return (1.0 / ((_ZBufferParams.x * z) + _ZBufferParams.y)); +} + +vec2 EncodeFloatRG ( + in highp float v +) +{ + highp vec2 enc; + highp float kEncodeBit; + highp vec2 kEncodeMul; + vec2 tmpvar_1; + tmpvar_1 = vec2(1.0, 255.0); + kEncodeMul = tmpvar_1; + float tmpvar_2; + tmpvar_2 = 0.00392157; + kEncodeBit = tmpvar_2; + highp vec2 tmpvar_3; + tmpvar_3 = (kEncodeMul * v); + enc = tmpvar_3; + highp vec2 tmpvar_4; + tmpvar_4 = fract (enc); + highp vec2 tmpvar_5; + tmpvar_5 = tmpvar_4; + enc = tmpvar_5; + highp float tmpvar_6; + tmpvar_6 = (enc.x - (enc.y * kEncodeBit)); + enc.x = tmpvar_6; + return enc; +} + +mediump vec4 xlat_main ( + in v2f i +) +{ + highp vec4 res; + mediump float shadow; + highp vec4 vpos; + highp float depth; + lowp vec4 tmpvar_1; + tmpvar_1 = texture2D (_CameraDepthTexture, i.uv); + lowp float tmpvar_2; + tmpvar_2 = tmpvar_1.x; + depth = tmpvar_2; + highp float tmpvar_3; + tmpvar_3 = Linear01Depth (depth); + highp float tmpvar_4; + tmpvar_4 = tmpvar_3; + depth = tmpvar_4; + highp vec4 tmpvar_5; + tmpvar_5.w = 1.0; + tmpvar_5.xyz = (i.ray * depth).xyz; + highp vec4 tmpvar_6; + tmpvar_6 = tmpvar_5; + vpos = tmpvar_6; + mediump float tmpvar_7; + tmpvar_7 = unitySampleShadow (vpos); + mediump float tmpvar_8; + tmpvar_8 = tmpvar_7; + shadow = tmpvar_8; + mediump float tmpvar_9; + tmpvar_9 = shadow; + res.x = tmpvar_9; + float tmpvar_10; + tmpvar_10 = 1.0; + res.y = vec2(tmpvar_10).y; + highp vec2 tmpvar_11; + tmpvar_11 = EncodeFloatRG ((1.0 - depth)); + highp vec2 tmpvar_12; + tmpvar_12 = tmpvar_11; + res.zw = tmpvar_12.xxxy.zw; + return res; +} + +void main () +{ + v2f xlt_i; + mediump vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_i.pos = tmpvar_1; + highp vec2 tmpvar_2; + tmpvar_2 = xlv_TEXCOORD0.xy; + highp vec2 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_i.uv = tmpvar_3; + highp vec3 tmpvar_4; + tmpvar_4 = xlv_TEXCOORD1.xyz; + highp vec3 tmpvar_5; + tmpvar_5 = tmpvar_4; + xlt_i.ray = tmpvar_5; + mediump vec4 tmpvar_6; + tmpvar_6 = xlat_main (xlt_i); + mediump vec4 tmpvar_7; + tmpvar_7 = tmpvar_6; + xl_retval = tmpvar_7; + mediump vec4 tmpvar_8; + tmpvar_8 = xl_retval.xyzw; + mediump vec4 tmpvar_9; + tmpvar_9 = tmpvar_8; + gl_FragData[0] = tmpvar_9; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/complex-collectshadows-out.txt b/3rdparty/glsl-optimizer/tests/fragment/complex-collectshadows-out.txt new file mode 100644 index 000000000..cf05b5448 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/complex-collectshadows-out.txt @@ -0,0 +1,42 @@ +uniform vec4 _ZBufferParams; +uniform mat4 _View2Shadow3; +uniform mat4 _View2Shadow2; +uniform mat4 _View2Shadow1; +uniform mat4 _View2Shadow; +uniform sampler2D _ShadowMapTexture; +uniform vec4 _LightSplitsNear; +uniform vec4 _LightSplitsFar; +uniform vec4 _LightShadowData; +uniform sampler2D _CameraDepthTexture; +void main () +{ + vec4 res; + float tmpvar_1; + tmpvar_1 = (1.0/(((_ZBufferParams.x * texture2D (_CameraDepthTexture, gl_TexCoord[0].xy).x) + _ZBufferParams.y))); + vec4 tmpvar_2; + tmpvar_2.w = 1.0; + tmpvar_2.xyz = (gl_TexCoord[1].xyz * tmpvar_1); + vec4 tmpvar_3; + tmpvar_3 = (vec4(greaterThanEqual (tmpvar_2.zzzz, _LightSplitsNear)) * vec4(lessThan (tmpvar_2.zzzz, _LightSplitsFar))); + vec4 tmpvar_4; + tmpvar_4.w = 1.0; + tmpvar_4.xyz = (((((_View2Shadow * tmpvar_2).xyz * tmpvar_3.x) + ((_View2Shadow1 * tmpvar_2).xyz * tmpvar_3.y)) + ((_View2Shadow2 * tmpvar_2).xyz * tmpvar_3.z)) + ((_View2Shadow3 * tmpvar_2).xyz * tmpvar_3.w)); + vec4 tmpvar_5; + tmpvar_5 = texture2D (_ShadowMapTexture, tmpvar_4.xy); + float tmpvar_6; + if ((tmpvar_5.x < tmpvar_4.z)) { + tmpvar_6 = _LightShadowData.x; + } else { + tmpvar_6 = 1.0; + }; + res.x = tmpvar_6; + res.y = 1.0; + vec2 enc; + vec2 tmpvar_7; + tmpvar_7 = fract ((vec2(1.0, 255.0) * (1.0 - tmpvar_1))); + enc = tmpvar_7; + enc.x = (tmpvar_7.x - (tmpvar_7.y * 0.00392157)); + res.zw = enc; + gl_FragData[0] = res; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/complex-collectshadows-outES.txt b/3rdparty/glsl-optimizer/tests/fragment/complex-collectshadows-outES.txt new file mode 100644 index 000000000..2137898f1 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/complex-collectshadows-outES.txt @@ -0,0 +1,65 @@ +varying highp vec3 xlv_TEXCOORD1; +varying highp vec2 xlv_TEXCOORD0; +uniform highp vec4 _ZBufferParams; +uniform highp mat4 _View2Shadow3; +uniform highp mat4 _View2Shadow2; +uniform highp mat4 _View2Shadow1; +uniform highp mat4 _View2Shadow; +uniform sampler2D _ShadowMapTexture; +uniform highp vec4 _LightSplitsNear; +uniform highp vec4 _LightSplitsFar; +uniform highp vec4 _LightShadowData; +uniform sampler2D _CameraDepthTexture; +void main () +{ + mediump vec4 tmpvar_1; + highp vec4 res; + highp float depth; + lowp float tmpvar_2; + tmpvar_2 = texture2D (_CameraDepthTexture, xlv_TEXCOORD0).x; + depth = tmpvar_2; + highp float tmpvar_3; + tmpvar_3 = (1.0/(((_ZBufferParams.x * depth) + _ZBufferParams.y))); + depth = tmpvar_3; + highp vec4 tmpvar_4; + tmpvar_4.w = 1.0; + tmpvar_4.xyz = (xlv_TEXCOORD1 * tmpvar_3); + mediump float shadow_i0; + highp vec4 far; + highp vec4 near; + highp vec4 tmpvar_5; + tmpvar_5 = tmpvar_4.zzzz; + lowp vec4 tmpvar_6; + tmpvar_6 = vec4(greaterThanEqual (tmpvar_5, _LightSplitsNear)); + near = tmpvar_6; + highp vec4 tmpvar_7; + tmpvar_7 = tmpvar_4.zzzz; + lowp vec4 tmpvar_8; + tmpvar_8 = vec4(lessThan (tmpvar_7, _LightSplitsFar)); + far = tmpvar_8; + highp vec4 tmpvar_9; + tmpvar_9 = (near * far); + highp vec4 tmpvar_10; + tmpvar_10.w = 1.0; + tmpvar_10.xyz = (((((_View2Shadow * tmpvar_4).xyz * tmpvar_9.x) + ((_View2Shadow1 * tmpvar_4).xyz * tmpvar_9.y)) + ((_View2Shadow2 * tmpvar_4).xyz * tmpvar_9.z)) + ((_View2Shadow3 * tmpvar_4).xyz * tmpvar_9.w)); + lowp vec4 tmpvar_11; + tmpvar_11 = texture2D (_ShadowMapTexture, tmpvar_10.xy); + highp float tmpvar_12; + if ((tmpvar_11.x < tmpvar_10.z)) { + tmpvar_12 = _LightShadowData.x; + } else { + tmpvar_12 = 1.0; + }; + shadow_i0 = tmpvar_12; + res.x = shadow_i0; + res.y = 1.0; + highp vec2 enc; + highp vec2 tmpvar_13; + tmpvar_13 = fract ((vec2(1.0, 255.0) * (1.0 - tmpvar_3))); + enc = tmpvar_13; + enc.x = (tmpvar_13.x - (tmpvar_13.y * 0.00392157)); + res.zw = enc; + tmpvar_1 = res; + gl_FragData[0] = tmpvar_1; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/complex-flare-in.txt b/3rdparty/glsl-optimizer/tests/fragment/complex-flare-in.txt new file mode 100644 index 000000000..0791a597a --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/complex-flare-in.txt @@ -0,0 +1,23 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +uniform sampler2D _FlareTexture; +vec4 xlat_main( in vec4 color, in vec2 texcoord ); +vec4 xlat_main( in vec4 color, in vec2 texcoord ) { + return (texture2D( _FlareTexture, texcoord) * color); +} +void main() { + vec4 xl_retval; + xl_retval = xlat_main( vec4(gl_Color), vec2(gl_TexCoord[0])); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/complex-flare-inES.txt b/3rdparty/glsl-optimizer/tests/fragment/complex-flare-inES.txt new file mode 100644 index 000000000..44e39e73f --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/complex-flare-inES.txt @@ -0,0 +1,11 @@ +uniform sampler2D _FlareTexture; +lowp vec4 xlat_main( in lowp vec4 color, in highp vec2 texcoord ) { + return (texture2D( _FlareTexture, texcoord) * color); +} +varying lowp vec4 xlv_COLOR; +varying highp vec2 xlv_TEXCOORD0; +void main() { + lowp vec4 xl_retval; + xl_retval = xlat_main( vec4(xlv_COLOR), vec2(xlv_TEXCOORD0)); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/complex-flare-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/complex-flare-ir.txt new file mode 100644 index 000000000..235f7f730 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/complex-flare-ir.txt @@ -0,0 +1,30 @@ +uniform sampler2D _FlareTexture; +vec4 xlat_main ( + in vec4 color, + in vec2 texcoord +) +{ + vec4 tmpvar_1; + tmpvar_1 = texture2D (_FlareTexture, texcoord); + return (tmpvar_1 * color); +} + +void main () +{ + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Color.xyzw; + vec2 tmpvar_2; + tmpvar_2 = gl_TexCoord[0].xy; + vec4 tmpvar_3; + tmpvar_3 = xlat_main (tmpvar_1, tmpvar_2); + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xl_retval = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = xl_retval.xyzw; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_5; + gl_FragData[0] = tmpvar_6; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/complex-flare-irES.txt b/3rdparty/glsl-optimizer/tests/fragment/complex-flare-irES.txt new file mode 100644 index 000000000..35ec449a3 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/complex-flare-irES.txt @@ -0,0 +1,32 @@ +varying highp vec2 xlv_TEXCOORD0; +varying lowp vec4 xlv_COLOR; +uniform sampler2D _FlareTexture; +lowp vec4 xlat_main ( + in lowp vec4 color, + in highp vec2 texcoord +) +{ + lowp vec4 tmpvar_1; + tmpvar_1 = texture2D (_FlareTexture, texcoord); + return (tmpvar_1 * color); +} + +void main () +{ + lowp vec4 xl_retval; + lowp vec4 tmpvar_1; + tmpvar_1 = xlv_COLOR.xyzw; + highp vec2 tmpvar_2; + tmpvar_2 = xlv_TEXCOORD0.xy; + lowp vec4 tmpvar_3; + tmpvar_3 = xlat_main (tmpvar_1, tmpvar_2); + lowp vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xl_retval = tmpvar_4; + lowp vec4 tmpvar_5; + tmpvar_5 = xl_retval.xyzw; + lowp vec4 tmpvar_6; + tmpvar_6 = tmpvar_5; + gl_FragData[0] = tmpvar_6; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/complex-flare-out.txt b/3rdparty/glsl-optimizer/tests/fragment/complex-flare-out.txt new file mode 100644 index 000000000..0e864f605 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/complex-flare-out.txt @@ -0,0 +1,6 @@ +uniform sampler2D _FlareTexture; +void main () +{ + gl_FragData[0] = (texture2D (_FlareTexture, gl_TexCoord[0].xy) * gl_Color); +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/complex-flare-outES.txt b/3rdparty/glsl-optimizer/tests/fragment/complex-flare-outES.txt new file mode 100644 index 000000000..9f5ac17df --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/complex-flare-outES.txt @@ -0,0 +1,8 @@ +varying highp vec2 xlv_TEXCOORD0; +varying lowp vec4 xlv_COLOR; +uniform sampler2D _FlareTexture; +void main () +{ + gl_FragData[0] = (texture2D (_FlareTexture, xlv_TEXCOORD0) * xlv_COLOR); +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/complex-fxaa-preset1-in.txt b/3rdparty/glsl-optimizer/tests/fragment/complex-fxaa-preset1-in.txt new file mode 100644 index 000000000..4a81caf9c --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/complex-fxaa-preset1-in.txt @@ -0,0 +1,188 @@ +#extension GL_ARB_shader_texture_lod : require +vec4 xll_tex2Dlod(sampler2D s, vec4 coord) { + return texture2DLod( s, coord.xy, coord.w); +} +vec4 xll_tex2Dgrad(sampler2D s, vec2 coord, vec2 ddx, vec2 ddy) { + return texture2DGradARB( s, coord, ddx, ddy); +} +uniform sampler2D _MainTex; +uniform vec4 _MainTex_TexelSize; +vec4 FxaaTexOff( in sampler2D tex, in vec2 pos, in vec2 off, in vec2 rcpFrame ); +vec4 FxaaTexLod0( in sampler2D tex, in vec2 pos ); +vec4 FxaaTexGrad( in sampler2D tex, in vec2 pos, in vec2 grad ); +float FxaaLuma( in vec3 rgb ); +vec3 FxaaLerp3( in vec3 a, in vec3 b, in float amountOfA ); +vec3 FxaaFilterReturn( in vec3 rgb ); +vec3 FxaaPixelShader( in vec2 pos, in sampler2D tex, in vec2 rcpFrame ); +vec4 xlat_main( in vec2 uv ); +vec4 FxaaTexOff( in sampler2D tex, in vec2 pos, in vec2 off, in vec2 rcpFrame ) { + return xll_tex2Dlod( tex, vec4( (pos.xy + (off * rcpFrame)), 0.00000, 0.00000)); +} +vec4 FxaaTexLod0( in sampler2D tex, in vec2 pos ) { + return xll_tex2Dlod( tex, vec4( pos.xy , 0.00000, 0.00000)); +} +vec4 FxaaTexGrad( in sampler2D tex, in vec2 pos, in vec2 grad ) { + return xll_tex2Dgrad( tex, pos.xy , grad, grad); +} +float FxaaLuma( in vec3 rgb ) { + return ((rgb.y * 1.96321) + rgb.x ); +} +vec3 FxaaLerp3( in vec3 a, in vec3 b, in float amountOfA ) { + return ((vec3( ( -amountOfA ), ( -amountOfA ), ( -amountOfA )) * b) + ((a * vec3( amountOfA, amountOfA, amountOfA)) + b)); +} +vec3 FxaaFilterReturn( in vec3 rgb ) { + return rgb; +} +vec3 FxaaPixelShader( in vec2 pos, in sampler2D tex, in vec2 rcpFrame ) { + vec3 rgbN; + vec3 rgbW; + vec3 rgbM; + vec3 rgbE; + vec3 rgbS; + float lumaN; + float lumaW; + float lumaM; + float lumaE; + float lumaS; + float rangeMin; + float rangeMax; + float range; + vec3 rgbL; + float lumaL; + float rangeL; + float blendL; + vec3 rgbNW; + vec3 rgbNE; + vec3 rgbSW; + vec3 rgbSE; + float lumaNW; + float lumaNE; + float lumaSW; + float lumaSE; + float edgeVert; + float edgeHorz; + bool horzSpan; + float lengthSign; + float gradientN; + float gradientS; + bool pairN; + vec2 posN; + vec2 posP; + vec2 offNP; + float lumaEndN; + float lumaEndP; + bool doneN = false; + bool doneP = false; + int i = 0; + float dstN; + float dstP; + bool directionN; + float spanLength; + float subPixelOffset; + vec3 rgbF; + rgbN = FxaaTexOff( tex, pos.xy , vec2( 0.00000, -1.00000), rcpFrame).xyz ; + rgbW = FxaaTexOff( tex, pos.xy , vec2( -1.00000, 0.00000), rcpFrame).xyz ; + rgbM = FxaaTexOff( tex, pos.xy , vec2( 0.00000, 0.00000), rcpFrame).xyz ; + rgbE = FxaaTexOff( tex, pos.xy , vec2( 1.00000, 0.00000), rcpFrame).xyz ; + rgbS = FxaaTexOff( tex, pos.xy , vec2( 0.00000, 1.00000), rcpFrame).xyz ; + lumaN = FxaaLuma( rgbN); + lumaW = FxaaLuma( rgbW); + lumaM = FxaaLuma( rgbM); + lumaE = FxaaLuma( rgbE); + lumaS = FxaaLuma( rgbS); + rangeMin = min( lumaM, min( min( lumaN, lumaW), min( lumaS, lumaE))); + rangeMax = max( lumaM, max( max( lumaN, lumaW), max( lumaS, lumaE))); + range = (rangeMax - rangeMin); + if ( (range < max( 0.0625000, (rangeMax * 0.125000))) ){ + return FxaaFilterReturn( rgbM); + } + rgbL = ((((rgbN + rgbW) + rgbM) + rgbE) + rgbS); + lumaL = ((((lumaN + lumaW) + lumaE) + lumaS) * 0.250000); + rangeL = abs( (lumaL - lumaM) ); + blendL = (max( 0.00000, ((rangeL / range) - 0.250000)) * 1.33333); + blendL = min( 0.750000, blendL); + rgbNW = FxaaTexOff( tex, pos.xy , vec2( -1.00000, -1.00000), rcpFrame).xyz ; + rgbNE = FxaaTexOff( tex, pos.xy , vec2( 1.00000, -1.00000), rcpFrame).xyz ; + rgbSW = FxaaTexOff( tex, pos.xy , vec2( -1.00000, 1.00000), rcpFrame).xyz ; + rgbSE = FxaaTexOff( tex, pos.xy , vec2( 1.00000, 1.00000), rcpFrame).xyz ; + rgbL += (((rgbNW + rgbNE) + rgbSW) + rgbSE); + rgbL *= vec3( 0.111111, 0.111111, 0.111111); + lumaNW = FxaaLuma( rgbNW); + lumaNE = FxaaLuma( rgbNE); + lumaSW = FxaaLuma( rgbSW); + lumaSE = FxaaLuma( rgbSE); + edgeVert = ((abs( (((0.250000 * lumaNW) + (-0.500000 * lumaN)) + (0.250000 * lumaNE)) ) + abs( (((0.500000 * lumaW) + (-1.00000 * lumaM)) + (0.500000 * lumaE)) )) + abs( (((0.250000 * lumaSW) + (-0.500000 * lumaS)) + (0.250000 * lumaSE)) )); + edgeHorz = ((abs( (((0.250000 * lumaNW) + (-0.500000 * lumaW)) + (0.250000 * lumaSW)) ) + abs( (((0.500000 * lumaN) + (-1.00000 * lumaM)) + (0.500000 * lumaS)) )) + abs( (((0.250000 * lumaNE) + (-0.500000 * lumaE)) + (0.250000 * lumaSE)) )); + horzSpan = (edgeHorz >= edgeVert); + lengthSign = (( horzSpan ) ? ( ( -rcpFrame.y ) ) : ( ( -rcpFrame.x ) )); + if ( ( !horzSpan ) ){ + lumaN = lumaW; + } + if ( ( !horzSpan ) ){ + lumaS = lumaE; + } + gradientN = abs( (lumaN - lumaM) ); + gradientS = abs( (lumaS - lumaM) ); + lumaN = ((lumaN + lumaM) * 0.500000); + lumaS = ((lumaS + lumaM) * 0.500000); + pairN = (gradientN >= gradientS); + if ( ( !pairN ) ){ + lumaN = lumaS; + } + if ( ( !pairN ) ){ + gradientN = gradientS; + } + if ( ( !pairN ) ){ + lengthSign *= -1.00000; + } + posN.x = (pos.x + (( horzSpan ) ? ( 0.00000 ) : ( (lengthSign * 0.500000) ))); + posN.y = (pos.y + (( horzSpan ) ? ( (lengthSign * 0.500000) ) : ( 0.00000 ))); + gradientN *= 0.250000; + posP = posN; + offNP = (( horzSpan ) ? ( vec2( rcpFrame.x , 0.00000) ) : ( vec2( 0.00000, rcpFrame.y ) )); + lumaEndN = lumaN; + lumaEndP = lumaN; + posN += (offNP * vec2( -2.00000, -2.00000)); + posP += (offNP * vec2( 2.00000, 2.00000)); + offNP *= vec2( 3.00000, 3.00000); + for ( ; (i < 4); ( i++ )) { + if ( ( !doneN ) ){ + lumaEndN = FxaaLuma( FxaaTexGrad( tex, posN.xy , offNP).xyz ); + } + if ( ( !doneP ) ){ + lumaEndP = FxaaLuma( FxaaTexGrad( tex, posP.xy , offNP).xyz ); + } + doneN = (doneN || (abs( (lumaEndN - lumaN) ) >= gradientN)); + doneP = (doneP || (abs( (lumaEndP - lumaN) ) >= gradientN)); + if ( (doneN && doneP) ){ + break; + } + if ( ( !doneN ) ){ + posN -= offNP; + } + if ( ( !doneP ) ){ + posP += offNP; + } + } + dstN = (( horzSpan ) ? ( (pos.x - posN.x ) ) : ( (pos.y - posN.y ) )); + dstP = (( horzSpan ) ? ( (posP.x - pos.x ) ) : ( (posP.y - pos.y ) )); + directionN = (dstN < dstP); + lumaEndN = (( directionN ) ? ( lumaEndN ) : ( lumaEndP )); + if ( (((lumaM - lumaN) < 0.00000) == ((lumaEndN - lumaN) < 0.00000)) ){ + lengthSign = 0.00000; + } + spanLength = (dstP + dstN); + dstN = (( directionN ) ? ( dstN ) : ( dstP )); + subPixelOffset = ((0.500000 + (dstN * (-1.00000 / spanLength))) * lengthSign); + rgbF = FxaaTexLod0( tex, vec2( (pos.x + (( horzSpan ) ? ( 0.00000 ) : ( subPixelOffset ))), (pos.y + (( horzSpan ) ? ( subPixelOffset ) : ( 0.00000 ))))).xyz ; + return FxaaFilterReturn( FxaaLerp3( rgbL, rgbF, blendL)); +} +vec4 xlat_main( in vec2 uv ) { + return vec4( FxaaPixelShader( uv.xy , _MainTex, _MainTex_TexelSize.xy ).xyz , 0.00000); +} +varying vec2 xlv_TEXCOORD0; +void main() { + vec4 xl_retval; + xl_retval = xlat_main( vec2(xlv_TEXCOORD0)); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/complex-fxaa-preset1-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/complex-fxaa-preset1-ir.txt new file mode 100644 index 000000000..06280544b --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/complex-fxaa-preset1-ir.txt @@ -0,0 +1,609 @@ +#extension GL_ARB_shader_texture_lod : enable +varying vec2 xlv_TEXCOORD0; +uniform vec4 _MainTex_TexelSize; +uniform sampler2D _MainTex; +vec4 xll_tex2Dlod ( + in sampler2D s, + in vec4 coord +) +{ + vec4 tmpvar_1; + tmpvar_1 = texture2DLod (s, coord.xy, coord.w); + return tmpvar_1; +} + +vec4 xll_tex2Dgrad ( + in sampler2D s, + in vec2 coord, + in vec2 ddx, + in vec2 ddy +) +{ + vec4 tmpvar_1; + tmpvar_1 = texture2DGradARB (s, coord, ddx, ddy); + return tmpvar_1; +} + +vec4 FxaaTexOff ( + in sampler2D tex, + in vec2 pos, + in vec2 off, + in vec2 rcpFrame +) +{ + vec4 tmpvar_1; + tmpvar_1.zw = vec2(0.0, 0.0); + tmpvar_1.xy = (pos.xy + (off * rcpFrame)).xy; + vec4 tmpvar_2; + tmpvar_2 = xll_tex2Dlod (tex, tmpvar_1); + return tmpvar_2; +} + +vec4 FxaaTexLod0 ( + in sampler2D tex, + in vec2 pos +) +{ + vec4 tmpvar_1; + tmpvar_1.zw = vec2(0.0, 0.0); + tmpvar_1.xy = pos.xy.xy; + vec4 tmpvar_2; + tmpvar_2 = xll_tex2Dlod (tex, tmpvar_1); + return tmpvar_2; +} + +vec4 FxaaTexGrad ( + in sampler2D tex, + in vec2 pos, + in vec2 grad +) +{ + vec4 tmpvar_1; + tmpvar_1 = xll_tex2Dgrad (tex, pos.xy, grad, grad); + return tmpvar_1; +} + +float FxaaLuma ( + in vec3 rgb +) +{ + return ((rgb.y * 1.96321) + rgb.x); +} + +vec3 FxaaLerp3 ( + in vec3 a, + in vec3 b, + in float amountOfA +) +{ + vec3 tmpvar_1; + tmpvar_1.x = -(amountOfA); + tmpvar_1.y = -(amountOfA); + tmpvar_1.z = -(amountOfA); + vec3 tmpvar_2; + tmpvar_2.x = amountOfA; + tmpvar_2.y = amountOfA; + tmpvar_2.z = amountOfA; + return ((tmpvar_1 * b) + ((a * tmpvar_2) + b)); +} + +vec3 FxaaFilterReturn ( + in vec3 rgb +) +{ + return rgb; +} + +vec3 FxaaPixelShader ( + in vec2 pos, + in sampler2D tex, + in vec2 rcpFrame +) +{ + vec3 rgbF; + float subPixelOffset; + float spanLength; + bool directionN; + float dstP; + float dstN; + int i; + bool doneP; + bool doneN; + float lumaEndP; + float lumaEndN; + vec2 offNP; + vec2 posP; + vec2 posN; + bool pairN; + float gradientS; + float gradientN; + float lengthSign; + bool horzSpan; + float edgeHorz; + float edgeVert; + float lumaSE; + float lumaSW; + float lumaNE; + float lumaNW; + vec3 rgbSE; + vec3 rgbSW; + vec3 rgbNE; + vec3 rgbNW; + float blendL; + float rangeL; + float lumaL; + vec3 rgbL; + float range; + float rangeMax; + float rangeMin; + float lumaS; + float lumaE; + float lumaM; + float lumaW; + float lumaN; + vec3 rgbS; + vec3 rgbE; + vec3 rgbM; + vec3 rgbW; + vec3 rgbN; + bool tmpvar_1; + tmpvar_1 = bool(0); + doneN = tmpvar_1; + bool tmpvar_2; + tmpvar_2 = bool(0); + doneP = tmpvar_2; + int tmpvar_3; + tmpvar_3 = 0; + i = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = FxaaTexOff (tex, pos.xy, vec2(0.0, -1.0), rcpFrame); + vec3 tmpvar_5; + tmpvar_5 = tmpvar_4.xyz; + rgbN = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = FxaaTexOff (tex, pos.xy, vec2(-1.0, 0.0), rcpFrame); + vec3 tmpvar_7; + tmpvar_7 = tmpvar_6.xyz; + rgbW = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = FxaaTexOff (tex, pos.xy, vec2(0.0, 0.0), rcpFrame); + vec3 tmpvar_9; + tmpvar_9 = tmpvar_8.xyz; + rgbM = tmpvar_9; + vec4 tmpvar_10; + tmpvar_10 = FxaaTexOff (tex, pos.xy, vec2(1.0, 0.0), rcpFrame); + vec3 tmpvar_11; + tmpvar_11 = tmpvar_10.xyz; + rgbE = tmpvar_11; + vec4 tmpvar_12; + tmpvar_12 = FxaaTexOff (tex, pos.xy, vec2(0.0, 1.0), rcpFrame); + vec3 tmpvar_13; + tmpvar_13 = tmpvar_12.xyz; + rgbS = tmpvar_13; + float tmpvar_14; + tmpvar_14 = FxaaLuma (rgbN); + float tmpvar_15; + tmpvar_15 = tmpvar_14; + lumaN = tmpvar_15; + float tmpvar_16; + tmpvar_16 = FxaaLuma (rgbW); + float tmpvar_17; + tmpvar_17 = tmpvar_16; + lumaW = tmpvar_17; + float tmpvar_18; + tmpvar_18 = FxaaLuma (rgbM); + float tmpvar_19; + tmpvar_19 = tmpvar_18; + lumaM = tmpvar_19; + float tmpvar_20; + tmpvar_20 = FxaaLuma (rgbE); + float tmpvar_21; + tmpvar_21 = tmpvar_20; + lumaE = tmpvar_21; + float tmpvar_22; + tmpvar_22 = FxaaLuma (rgbS); + float tmpvar_23; + tmpvar_23 = tmpvar_22; + lumaS = tmpvar_23; + float tmpvar_24; + tmpvar_24 = min (lumaN, lumaW); + float tmpvar_25; + tmpvar_25 = min (lumaS, lumaE); + float tmpvar_26; + tmpvar_26 = min (tmpvar_24, tmpvar_25); + float tmpvar_27; + tmpvar_27 = min (lumaM, tmpvar_26); + float tmpvar_28; + tmpvar_28 = tmpvar_27; + rangeMin = tmpvar_28; + float tmpvar_29; + tmpvar_29 = max (lumaN, lumaW); + float tmpvar_30; + tmpvar_30 = max (lumaS, lumaE); + float tmpvar_31; + tmpvar_31 = max (tmpvar_29, tmpvar_30); + float tmpvar_32; + tmpvar_32 = max (lumaM, tmpvar_31); + float tmpvar_33; + tmpvar_33 = tmpvar_32; + rangeMax = tmpvar_33; + float tmpvar_34; + tmpvar_34 = (rangeMax - rangeMin); + range = tmpvar_34; + float tmpvar_35; + tmpvar_35 = max (0.0625, (rangeMax * 0.125)); + if ((range < tmpvar_35)) { + vec3 tmpvar_36; + tmpvar_36 = FxaaFilterReturn (rgbM); + return tmpvar_36; + }; + vec3 tmpvar_37; + tmpvar_37 = ((((rgbN + rgbW) + rgbM) + rgbE) + rgbS); + rgbL = tmpvar_37; + float tmpvar_38; + tmpvar_38 = ((((lumaN + lumaW) + lumaE) + lumaS) * 0.25); + lumaL = tmpvar_38; + float tmpvar_39; + tmpvar_39 = abs ((lumaL - lumaM)); + float tmpvar_40; + tmpvar_40 = tmpvar_39; + rangeL = tmpvar_40; + float tmpvar_41; + tmpvar_41 = max (0.0, ((rangeL / range) - 0.25)); + float tmpvar_42; + tmpvar_42 = (tmpvar_41 * 1.33333); + blendL = tmpvar_42; + float tmpvar_43; + tmpvar_43 = min (0.75, blendL); + float tmpvar_44; + tmpvar_44 = tmpvar_43; + blendL = tmpvar_44; + vec4 tmpvar_45; + tmpvar_45 = FxaaTexOff (tex, pos.xy, vec2(-1.0, -1.0), rcpFrame); + vec3 tmpvar_46; + tmpvar_46 = tmpvar_45.xyz; + rgbNW = tmpvar_46; + vec4 tmpvar_47; + tmpvar_47 = FxaaTexOff (tex, pos.xy, vec2(1.0, -1.0), rcpFrame); + vec3 tmpvar_48; + tmpvar_48 = tmpvar_47.xyz; + rgbNE = tmpvar_48; + vec4 tmpvar_49; + tmpvar_49 = FxaaTexOff (tex, pos.xy, vec2(-1.0, 1.0), rcpFrame); + vec3 tmpvar_50; + tmpvar_50 = tmpvar_49.xyz; + rgbSW = tmpvar_50; + vec4 tmpvar_51; + tmpvar_51 = FxaaTexOff (tex, pos.xy, vec2(1.0, 1.0), rcpFrame); + vec3 tmpvar_52; + tmpvar_52 = tmpvar_51.xyz; + rgbSE = tmpvar_52; + vec3 tmpvar_53; + tmpvar_53 = (rgbL + (((rgbNW + rgbNE) + rgbSW) + rgbSE)); + rgbL = tmpvar_53; + vec3 tmpvar_54; + tmpvar_54 = (rgbL * vec3(0.111111, 0.111111, 0.111111)); + rgbL = tmpvar_54; + float tmpvar_55; + tmpvar_55 = FxaaLuma (rgbNW); + float tmpvar_56; + tmpvar_56 = tmpvar_55; + lumaNW = tmpvar_56; + float tmpvar_57; + tmpvar_57 = FxaaLuma (rgbNE); + float tmpvar_58; + tmpvar_58 = tmpvar_57; + lumaNE = tmpvar_58; + float tmpvar_59; + tmpvar_59 = FxaaLuma (rgbSW); + float tmpvar_60; + tmpvar_60 = tmpvar_59; + lumaSW = tmpvar_60; + float tmpvar_61; + tmpvar_61 = FxaaLuma (rgbSE); + float tmpvar_62; + tmpvar_62 = tmpvar_61; + lumaSE = tmpvar_62; + float tmpvar_63; + tmpvar_63 = abs ((((0.25 * lumaNW) + (-(0.5) * lumaN)) + (0.25 * lumaNE))); + float tmpvar_64; + tmpvar_64 = abs ((((0.5 * lumaW) + (-(1.0) * lumaM)) + (0.5 * lumaE))); + float tmpvar_65; + tmpvar_65 = abs ((((0.25 * lumaSW) + (-(0.5) * lumaS)) + (0.25 * lumaSE))); + float tmpvar_66; + tmpvar_66 = ((tmpvar_63 + tmpvar_64) + tmpvar_65); + edgeVert = tmpvar_66; + float tmpvar_67; + tmpvar_67 = abs ((((0.25 * lumaNW) + (-(0.5) * lumaW)) + (0.25 * lumaSW))); + float tmpvar_68; + tmpvar_68 = abs ((((0.5 * lumaN) + (-(1.0) * lumaM)) + (0.5 * lumaS))); + float tmpvar_69; + tmpvar_69 = abs ((((0.25 * lumaNE) + (-(0.5) * lumaE)) + (0.25 * lumaSE))); + float tmpvar_70; + tmpvar_70 = ((tmpvar_67 + tmpvar_68) + tmpvar_69); + edgeHorz = tmpvar_70; + bool tmpvar_71; + tmpvar_71 = (edgeHorz >= edgeVert); + horzSpan = tmpvar_71; + float tmpvar_72; + if (horzSpan) { + tmpvar_72 = -(rcpFrame.y); + } else { + tmpvar_72 = -(rcpFrame.x); + }; + float tmpvar_73; + tmpvar_73 = tmpvar_72; + lengthSign = tmpvar_73; + if (!(horzSpan)) { + float tmpvar_74; + tmpvar_74 = lumaW; + lumaN = tmpvar_74; + }; + if (!(horzSpan)) { + float tmpvar_75; + tmpvar_75 = lumaE; + lumaS = tmpvar_75; + }; + float tmpvar_76; + tmpvar_76 = abs ((lumaN - lumaM)); + float tmpvar_77; + tmpvar_77 = tmpvar_76; + gradientN = tmpvar_77; + float tmpvar_78; + tmpvar_78 = abs ((lumaS - lumaM)); + float tmpvar_79; + tmpvar_79 = tmpvar_78; + gradientS = tmpvar_79; + float tmpvar_80; + tmpvar_80 = ((lumaN + lumaM) * 0.5); + lumaN = tmpvar_80; + float tmpvar_81; + tmpvar_81 = ((lumaS + lumaM) * 0.5); + lumaS = tmpvar_81; + bool tmpvar_82; + tmpvar_82 = (gradientN >= gradientS); + pairN = tmpvar_82; + if (!(pairN)) { + float tmpvar_83; + tmpvar_83 = lumaS; + lumaN = tmpvar_83; + }; + if (!(pairN)) { + float tmpvar_84; + tmpvar_84 = gradientS; + gradientN = tmpvar_84; + }; + if (!(pairN)) { + float tmpvar_85; + tmpvar_85 = (lengthSign * -(1.0)); + lengthSign = tmpvar_85; + }; + float tmpvar_86; + if (horzSpan) { + tmpvar_86 = 0.0; + } else { + tmpvar_86 = (lengthSign * 0.5); + }; + float tmpvar_87; + tmpvar_87 = (pos.x + tmpvar_86); + posN.x = tmpvar_87; + float tmpvar_88; + if (horzSpan) { + tmpvar_88 = (lengthSign * 0.5); + } else { + tmpvar_88 = 0.0; + }; + float tmpvar_89; + tmpvar_89 = (pos.y + tmpvar_88); + posN.y = vec2(tmpvar_89).y; + float tmpvar_90; + tmpvar_90 = (gradientN * 0.25); + gradientN = tmpvar_90; + vec2 tmpvar_91; + tmpvar_91 = posN; + posP = tmpvar_91; + vec2 tmpvar_92; + if (horzSpan) { + vec2 tmpvar_93; + tmpvar_93.y = 0.0; + tmpvar_93.x = rcpFrame.x; + tmpvar_92 = tmpvar_93; + } else { + vec2 tmpvar_94; + tmpvar_94.x = 0.0; + tmpvar_94.y = rcpFrame.y; + tmpvar_92 = tmpvar_94; + }; + vec2 tmpvar_95; + tmpvar_95 = tmpvar_92; + offNP = tmpvar_95; + float tmpvar_96; + tmpvar_96 = lumaN; + lumaEndN = tmpvar_96; + float tmpvar_97; + tmpvar_97 = lumaN; + lumaEndP = tmpvar_97; + vec2 tmpvar_98; + tmpvar_98 = (posN + (offNP * vec2(-2.0, -2.0))); + posN = tmpvar_98; + vec2 tmpvar_99; + tmpvar_99 = (posP + (offNP * vec2(2.0, 2.0))); + posP = tmpvar_99; + vec2 tmpvar_100; + tmpvar_100 = (offNP * vec2(3.0, 3.0)); + offNP = tmpvar_100; + while (true) { + if (!((i < 4))) { + break; + }; + if (!(doneN)) { + vec4 tmpvar_101; + tmpvar_101 = FxaaTexGrad (tex, posN.xy, offNP); + float tmpvar_102; + tmpvar_102 = FxaaLuma (tmpvar_101.xyz); + float tmpvar_103; + tmpvar_103 = tmpvar_102; + lumaEndN = tmpvar_103; + }; + if (!(doneP)) { + vec4 tmpvar_104; + tmpvar_104 = FxaaTexGrad (tex, posP.xy, offNP); + float tmpvar_105; + tmpvar_105 = FxaaLuma (tmpvar_104.xyz); + float tmpvar_106; + tmpvar_106 = tmpvar_105; + lumaEndP = tmpvar_106; + }; + bool tmpvar_107; + if (doneN) { + tmpvar_107 = bool(1); + } else { + float tmpvar_108; + tmpvar_108 = abs ((lumaEndN - lumaN)); + tmpvar_107 = (tmpvar_108 >= gradientN); + }; + bool tmpvar_109; + tmpvar_109 = tmpvar_107; + doneN = tmpvar_109; + bool tmpvar_110; + if (doneP) { + tmpvar_110 = bool(1); + } else { + float tmpvar_111; + tmpvar_111 = abs ((lumaEndP - lumaN)); + tmpvar_110 = (tmpvar_111 >= gradientN); + }; + bool tmpvar_112; + tmpvar_112 = tmpvar_110; + doneP = tmpvar_112; + bool tmpvar_113; + if (doneN) { + tmpvar_113 = doneP; + } else { + tmpvar_113 = bool(0); + }; + if (tmpvar_113) { + break; + }; + if (!(doneN)) { + vec2 tmpvar_114; + tmpvar_114 = (posN - offNP); + posN = tmpvar_114; + }; + if (!(doneP)) { + vec2 tmpvar_115; + tmpvar_115 = (posP + offNP); + posP = tmpvar_115; + }; + int _post_incdec_tmp; + _post_incdec_tmp = i; + int tmpvar_116; + tmpvar_116 = (i + 1); + i = tmpvar_116; + }; + float tmpvar_117; + if (horzSpan) { + tmpvar_117 = (pos.x - posN.x); + } else { + tmpvar_117 = (pos.y - posN.y); + }; + float tmpvar_118; + tmpvar_118 = tmpvar_117; + dstN = tmpvar_118; + float tmpvar_119; + if (horzSpan) { + tmpvar_119 = (posP.x - pos.x); + } else { + tmpvar_119 = (posP.y - pos.y); + }; + float tmpvar_120; + tmpvar_120 = tmpvar_119; + dstP = tmpvar_120; + bool tmpvar_121; + tmpvar_121 = (dstN < dstP); + directionN = tmpvar_121; + float tmpvar_122; + if (directionN) { + tmpvar_122 = lumaEndN; + } else { + tmpvar_122 = lumaEndP; + }; + float tmpvar_123; + tmpvar_123 = tmpvar_122; + lumaEndN = tmpvar_123; + if ((((lumaM - lumaN) < 0.0) == ((lumaEndN - lumaN) < 0.0))) { + float tmpvar_124; + tmpvar_124 = 0.0; + lengthSign = tmpvar_124; + }; + float tmpvar_125; + tmpvar_125 = (dstP + dstN); + spanLength = tmpvar_125; + float tmpvar_126; + if (directionN) { + tmpvar_126 = dstN; + } else { + tmpvar_126 = dstP; + }; + float tmpvar_127; + tmpvar_127 = tmpvar_126; + dstN = tmpvar_127; + float tmpvar_128; + tmpvar_128 = ((0.5 + (dstN * (-(1.0) / spanLength))) * lengthSign); + subPixelOffset = tmpvar_128; + float tmpvar_129; + if (horzSpan) { + tmpvar_129 = 0.0; + } else { + tmpvar_129 = subPixelOffset; + }; + float tmpvar_130; + if (horzSpan) { + tmpvar_130 = subPixelOffset; + } else { + tmpvar_130 = 0.0; + }; + vec2 tmpvar_131; + tmpvar_131.x = (pos.x + tmpvar_129); + tmpvar_131.y = (pos.y + tmpvar_130); + vec4 tmpvar_132; + tmpvar_132 = FxaaTexLod0 (tex, tmpvar_131); + vec3 tmpvar_133; + tmpvar_133 = tmpvar_132.xyz; + rgbF = tmpvar_133; + vec3 tmpvar_134; + tmpvar_134 = FxaaLerp3 (rgbL, rgbF, blendL); + vec3 tmpvar_135; + tmpvar_135 = FxaaFilterReturn (tmpvar_134); + return tmpvar_135; +} + +vec4 xlat_main ( + in vec2 uv +) +{ + vec3 tmpvar_1; + tmpvar_1 = FxaaPixelShader (uv.xy, _MainTex, _MainTex_TexelSize.xy); + vec4 tmpvar_2; + tmpvar_2.w = 0.0; + tmpvar_2.xyz = tmpvar_1.xyz.xyz; + return tmpvar_2; +} + +void main () +{ + vec4 xl_retval; + vec2 tmpvar_1; + tmpvar_1 = xlv_TEXCOORD0.xy; + vec4 tmpvar_2; + tmpvar_2 = xlat_main (tmpvar_1); + vec4 tmpvar_3; + tmpvar_3 = tmpvar_2; + xl_retval = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = xl_retval.xyzw; + vec4 tmpvar_5; + tmpvar_5 = tmpvar_4; + gl_FragData[0] = tmpvar_5; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/complex-fxaa-preset1-out.txt b/3rdparty/glsl-optimizer/tests/fragment/complex-fxaa-preset1-out.txt new file mode 100644 index 000000000..8b21a4443 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/complex-fxaa-preset1-out.txt @@ -0,0 +1,279 @@ +#extension GL_ARB_shader_texture_lod : enable +varying vec2 xlv_TEXCOORD0; +uniform vec4 _MainTex_TexelSize; +uniform sampler2D _MainTex; +void main () +{ + vec3 tmpvar_1; + int i; + bool doneP; + bool doneN; + float lumaEndP; + float lumaEndN; + vec2 offNP; + vec2 posP; + vec2 posN; + float gradientN; + float lengthSign; + float lumaS; + float lumaN; + doneN = bool(0); + doneP = bool(0); + i = 0; + vec4 tmpvar_2; + tmpvar_2.zw = vec2(0.0, 0.0); + tmpvar_2.xy = (xlv_TEXCOORD0 + (vec2(0.0, -1.0) * _MainTex_TexelSize.xy)); + vec4 tmpvar_3; + tmpvar_3 = texture2DLod (_MainTex, tmpvar_2.xy, 0.0); + vec4 tmpvar_4; + tmpvar_4.zw = vec2(0.0, 0.0); + tmpvar_4.xy = (xlv_TEXCOORD0 + (vec2(-1.0, 0.0) * _MainTex_TexelSize.xy)); + vec4 tmpvar_5; + tmpvar_5 = texture2DLod (_MainTex, tmpvar_4.xy, 0.0); + vec4 tmpvar_6; + tmpvar_6.zw = vec2(0.0, 0.0); + tmpvar_6.xy = xlv_TEXCOORD0; + vec4 tmpvar_7; + tmpvar_7 = texture2DLod (_MainTex, tmpvar_6.xy, 0.0); + vec4 tmpvar_8; + tmpvar_8.zw = vec2(0.0, 0.0); + tmpvar_8.xy = (xlv_TEXCOORD0 + (vec2(1.0, 0.0) * _MainTex_TexelSize.xy)); + vec4 tmpvar_9; + tmpvar_9 = texture2DLod (_MainTex, tmpvar_8.xy, 0.0); + vec4 tmpvar_10; + tmpvar_10.zw = vec2(0.0, 0.0); + tmpvar_10.xy = (xlv_TEXCOORD0 + (vec2(0.0, 1.0) * _MainTex_TexelSize.xy)); + vec4 tmpvar_11; + tmpvar_11 = texture2DLod (_MainTex, tmpvar_10.xy, 0.0); + float tmpvar_12; + tmpvar_12 = ((tmpvar_3.y * 1.96321) + tmpvar_3.x); + lumaN = tmpvar_12; + float tmpvar_13; + tmpvar_13 = ((tmpvar_5.y * 1.96321) + tmpvar_5.x); + float tmpvar_14; + tmpvar_14 = ((tmpvar_7.y * 1.96321) + tmpvar_7.x); + float tmpvar_15; + tmpvar_15 = ((tmpvar_9.y * 1.96321) + tmpvar_9.x); + float tmpvar_16; + tmpvar_16 = ((tmpvar_11.y * 1.96321) + tmpvar_11.x); + lumaS = tmpvar_16; + float tmpvar_17; + tmpvar_17 = max (tmpvar_14, max (max (tmpvar_12, tmpvar_13), max (tmpvar_16, tmpvar_15))); + float tmpvar_18; + tmpvar_18 = (tmpvar_17 - min (tmpvar_14, min (min (tmpvar_12, tmpvar_13), min (tmpvar_16, tmpvar_15)))); + float tmpvar_19; + tmpvar_19 = max (0.0625, (tmpvar_17 * 0.125)); + if ((tmpvar_18 < tmpvar_19)) { + tmpvar_1 = tmpvar_7.xyz; + } else { + float tmpvar_20; + tmpvar_20 = min (0.75, (max (0.0, ((abs ((((((tmpvar_12 + tmpvar_13) + tmpvar_15) + tmpvar_16) * 0.25) - tmpvar_14)) / tmpvar_18) - 0.25)) * 1.33333)); + vec4 tmpvar_21; + tmpvar_21.zw = vec2(0.0, 0.0); + tmpvar_21.xy = (xlv_TEXCOORD0 + (vec2(-1.0, -1.0) * _MainTex_TexelSize.xy)); + vec4 tmpvar_22; + tmpvar_22 = texture2DLod (_MainTex, tmpvar_21.xy, 0.0); + vec4 tmpvar_23; + tmpvar_23.zw = vec2(0.0, 0.0); + tmpvar_23.xy = (xlv_TEXCOORD0 + (vec2(1.0, -1.0) * _MainTex_TexelSize.xy)); + vec4 tmpvar_24; + tmpvar_24 = texture2DLod (_MainTex, tmpvar_23.xy, 0.0); + vec4 tmpvar_25; + tmpvar_25.zw = vec2(0.0, 0.0); + tmpvar_25.xy = (xlv_TEXCOORD0 + (vec2(-1.0, 1.0) * _MainTex_TexelSize.xy)); + vec4 tmpvar_26; + tmpvar_26 = texture2DLod (_MainTex, tmpvar_25.xy, 0.0); + vec4 tmpvar_27; + tmpvar_27.zw = vec2(0.0, 0.0); + tmpvar_27.xy = (xlv_TEXCOORD0 + _MainTex_TexelSize.xy); + vec4 tmpvar_28; + tmpvar_28 = texture2DLod (_MainTex, tmpvar_27.xy, 0.0); + vec3 tmpvar_29; + tmpvar_29 = ((((((tmpvar_3.xyz + tmpvar_5.xyz) + tmpvar_7.xyz) + tmpvar_9.xyz) + tmpvar_11.xyz) + (((tmpvar_22.xyz + tmpvar_24.xyz) + tmpvar_26.xyz) + tmpvar_28.xyz)) * vec3(0.111111, 0.111111, 0.111111)); + float tmpvar_30; + tmpvar_30 = ((tmpvar_22.y * 1.96321) + tmpvar_22.x); + float tmpvar_31; + tmpvar_31 = ((tmpvar_24.y * 1.96321) + tmpvar_24.x); + float tmpvar_32; + tmpvar_32 = ((tmpvar_26.y * 1.96321) + tmpvar_26.x); + float tmpvar_33; + tmpvar_33 = ((tmpvar_28.y * 1.96321) + tmpvar_28.x); + bool tmpvar_34; + tmpvar_34 = (((abs ((((0.25 * tmpvar_30) + (-(0.5) * tmpvar_13)) + (0.25 * tmpvar_32))) + abs ((((0.5 * tmpvar_12) + (-(1.0) * tmpvar_14)) + (0.5 * tmpvar_16)))) + abs ((((0.25 * tmpvar_31) + (-(0.5) * tmpvar_15)) + (0.25 * tmpvar_33)))) >= ((abs ((((0.25 * tmpvar_30) + (-(0.5) * tmpvar_12)) + (0.25 * tmpvar_31))) + abs ((((0.5 * tmpvar_13) + (-(1.0) * tmpvar_14)) + (0.5 * tmpvar_15)))) + abs ((((0.25 * tmpvar_32) + (-(0.5) * tmpvar_16)) + (0.25 * tmpvar_33))))); + float tmpvar_35; + if (tmpvar_34) { + tmpvar_35 = -(_MainTex_TexelSize.y); + } else { + tmpvar_35 = -(_MainTex_TexelSize.x); + }; + lengthSign = tmpvar_35; + if (!(tmpvar_34)) { + lumaN = tmpvar_13; + }; + if (!(tmpvar_34)) { + lumaS = tmpvar_15; + }; + float tmpvar_36; + tmpvar_36 = abs ((lumaN - tmpvar_14)); + gradientN = tmpvar_36; + float tmpvar_37; + tmpvar_37 = abs ((lumaS - tmpvar_14)); + lumaN = ((lumaN + tmpvar_14) * 0.5); + float tmpvar_38; + tmpvar_38 = ((lumaS + tmpvar_14) * 0.5); + lumaS = tmpvar_38; + bool tmpvar_39; + tmpvar_39 = (tmpvar_36 >= tmpvar_37); + if (!(tmpvar_39)) { + lumaN = tmpvar_38; + }; + if (!(tmpvar_39)) { + gradientN = tmpvar_37; + }; + if (!(tmpvar_39)) { + lengthSign = (tmpvar_35 * -1.0); + }; + float tmpvar_40; + if (tmpvar_34) { + tmpvar_40 = 0.0; + } else { + tmpvar_40 = (lengthSign * 0.5); + }; + posN.x = (xlv_TEXCOORD0.x + tmpvar_40); + float tmpvar_41; + if (tmpvar_34) { + tmpvar_41 = (lengthSign * 0.5); + } else { + tmpvar_41 = 0.0; + }; + posN.y = (xlv_TEXCOORD0.y + tmpvar_41); + gradientN = (gradientN * 0.25); + posP = posN; + vec2 tmpvar_42; + if (tmpvar_34) { + vec2 tmpvar_43; + tmpvar_43.y = 0.0; + tmpvar_43.x = _MainTex_TexelSize.x; + tmpvar_42 = tmpvar_43; + } else { + vec2 tmpvar_44; + tmpvar_44.x = 0.0; + tmpvar_44.y = _MainTex_TexelSize.y; + tmpvar_42 = tmpvar_44; + }; + lumaEndN = lumaN; + lumaEndP = lumaN; + posN = (posN + (tmpvar_42 * vec2(-2.0, -2.0))); + posP = (posP + (tmpvar_42 * vec2(2.0, 2.0))); + offNP = (tmpvar_42 * vec2(3.0, 3.0)); + while (true) { + if ((i >= 4)) { + break; + }; + if (!(doneN)) { + vec4 tmpvar_45; + tmpvar_45 = texture2DGradARB (_MainTex, posN, offNP, offNP); + lumaEndN = ((tmpvar_45.y * 1.96321) + tmpvar_45.x); + }; + if (!(doneP)) { + vec4 tmpvar_46; + tmpvar_46 = texture2DGradARB (_MainTex, posP, offNP, offNP); + lumaEndP = ((tmpvar_46.y * 1.96321) + tmpvar_46.x); + }; + bool tmpvar_47; + if (doneN) { + tmpvar_47 = bool(1); + } else { + tmpvar_47 = (abs ((lumaEndN - lumaN)) >= gradientN); + }; + doneN = tmpvar_47; + bool tmpvar_48; + if (doneP) { + tmpvar_48 = bool(1); + } else { + tmpvar_48 = (abs ((lumaEndP - lumaN)) >= gradientN); + }; + doneP = tmpvar_48; + bool tmpvar_49; + if (tmpvar_47) { + tmpvar_49 = tmpvar_48; + } else { + tmpvar_49 = bool(0); + }; + if (tmpvar_49) { + break; + }; + if (!(tmpvar_47)) { + posN = (posN - offNP); + }; + if (!(tmpvar_48)) { + posP = (posP + offNP); + }; + i = (i + 1); + }; + float tmpvar_50; + if (tmpvar_34) { + tmpvar_50 = (xlv_TEXCOORD0.x - posN.x); + } else { + tmpvar_50 = (xlv_TEXCOORD0.y - posN.y); + }; + float tmpvar_51; + if (tmpvar_34) { + tmpvar_51 = (posP.x - xlv_TEXCOORD0.x); + } else { + tmpvar_51 = (posP.y - xlv_TEXCOORD0.y); + }; + bool tmpvar_52; + tmpvar_52 = (tmpvar_50 < tmpvar_51); + float tmpvar_53; + if (tmpvar_52) { + tmpvar_53 = lumaEndN; + } else { + tmpvar_53 = lumaEndP; + }; + lumaEndN = tmpvar_53; + if ((((tmpvar_14 - lumaN) < 0.0) == ((tmpvar_53 - lumaN) < 0.0))) { + lengthSign = 0.0; + }; + float tmpvar_54; + tmpvar_54 = (tmpvar_51 + tmpvar_50); + float tmpvar_55; + if (tmpvar_52) { + tmpvar_55 = tmpvar_50; + } else { + tmpvar_55 = tmpvar_51; + }; + float tmpvar_56; + tmpvar_56 = ((0.5 + (tmpvar_55 * (-1.0 / tmpvar_54))) * lengthSign); + float tmpvar_57; + if (tmpvar_34) { + tmpvar_57 = 0.0; + } else { + tmpvar_57 = tmpvar_56; + }; + float tmpvar_58; + if (tmpvar_34) { + tmpvar_58 = tmpvar_56; + } else { + tmpvar_58 = 0.0; + }; + vec2 tmpvar_59; + tmpvar_59.x = (xlv_TEXCOORD0.x + tmpvar_57); + tmpvar_59.y = (xlv_TEXCOORD0.y + tmpvar_58); + vec4 tmpvar_60; + tmpvar_60.zw = vec2(0.0, 0.0); + tmpvar_60.xy = tmpvar_59; + vec4 tmpvar_61; + tmpvar_61 = texture2DLod (_MainTex, tmpvar_60.xy, 0.0); + vec3 tmpvar_62; + tmpvar_62.x = -(tmpvar_20); + tmpvar_62.y = -(tmpvar_20); + tmpvar_62.z = -(tmpvar_20); + tmpvar_1 = ((tmpvar_62 * tmpvar_61.xyz) + ((tmpvar_29 * vec3(tmpvar_20)) + tmpvar_61.xyz)); + }; + vec4 tmpvar_63; + tmpvar_63.w = 0.0; + tmpvar_63.xyz = tmpvar_1; + gl_FragData[0] = tmpvar_63; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/complex-fxaa-preset3-in.txt b/3rdparty/glsl-optimizer/tests/fragment/complex-fxaa-preset3-in.txt new file mode 100644 index 000000000..ed582b5d0 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/complex-fxaa-preset3-in.txt @@ -0,0 +1,180 @@ +#extension GL_ARB_shader_texture_lod : require +vec4 xll_tex2Dlod(sampler2D s, vec4 coord) { + return texture2DLod( s, coord.xy, coord.w); +} +uniform sampler2D _MainTex; +uniform vec4 _MainTex_TexelSize; +vec4 FxaaTexOff( in sampler2D tex, in vec2 pos, in vec2 off, in vec2 rcpFrame ); +vec4 FxaaTexLod0( in sampler2D tex, in vec2 pos ); +float FxaaLuma( in vec3 rgb ); +vec3 FxaaLerp3( in vec3 a, in vec3 b, in float amountOfA ); +vec3 FxaaFilterReturn( in vec3 rgb ); +vec3 FxaaPixelShader( in vec2 pos, in sampler2D tex, in vec2 rcpFrame ); +vec4 xlat_main( in vec2 uv ); +vec4 FxaaTexOff( in sampler2D tex, in vec2 pos, in vec2 off, in vec2 rcpFrame ) { + return xll_tex2Dlod( tex, vec4( (pos.xy + (off * rcpFrame)), 0.00000, 0.00000)); +} +vec4 FxaaTexLod0( in sampler2D tex, in vec2 pos ) { + return xll_tex2Dlod( tex, vec4( pos.xy , 0.00000, 0.00000)); +} +float FxaaLuma( in vec3 rgb ) { + return ((rgb.y * 1.96321) + rgb.x ); +} +vec3 FxaaLerp3( in vec3 a, in vec3 b, in float amountOfA ) { + return ((vec3( ( -amountOfA ), ( -amountOfA ), ( -amountOfA )) * b) + ((a * vec3( amountOfA, amountOfA, amountOfA)) + b)); +} +vec3 FxaaFilterReturn( in vec3 rgb ) { + return rgb; +} +vec3 FxaaPixelShader( in vec2 pos, in sampler2D tex, in vec2 rcpFrame ) { + vec3 rgbN; + vec3 rgbW; + vec3 rgbM; + vec3 rgbE; + vec3 rgbS; + float lumaN; + float lumaW; + float lumaM; + float lumaE; + float lumaS; + float rangeMin; + float rangeMax; + float range; + vec3 rgbL; + float lumaL; + float rangeL; + float blendL; + vec3 rgbNW; + vec3 rgbNE; + vec3 rgbSW; + vec3 rgbSE; + float lumaNW; + float lumaNE; + float lumaSW; + float lumaSE; + float edgeVert; + float edgeHorz; + bool horzSpan; + float lengthSign; + float gradientN; + float gradientS; + bool pairN; + vec2 posN; + vec2 posP; + vec2 offNP; + float lumaEndN; + float lumaEndP; + bool doneN = false; + bool doneP = false; + int i = 0; + float dstN; + float dstP; + bool directionN; + float spanLength; + float subPixelOffset; + vec3 rgbF; + rgbN = FxaaTexOff( tex, pos.xy , vec2( 0.00000, -1.00000), rcpFrame).xyz ; + rgbW = FxaaTexOff( tex, pos.xy , vec2( -1.00000, 0.00000), rcpFrame).xyz ; + rgbM = FxaaTexOff( tex, pos.xy , vec2( 0.00000, 0.00000), rcpFrame).xyz ; + rgbE = FxaaTexOff( tex, pos.xy , vec2( 1.00000, 0.00000), rcpFrame).xyz ; + rgbS = FxaaTexOff( tex, pos.xy , vec2( 0.00000, 1.00000), rcpFrame).xyz ; + lumaN = FxaaLuma( rgbN); + lumaW = FxaaLuma( rgbW); + lumaM = FxaaLuma( rgbM); + lumaE = FxaaLuma( rgbE); + lumaS = FxaaLuma( rgbS); + rangeMin = min( lumaM, min( min( lumaN, lumaW), min( lumaS, lumaE))); + rangeMax = max( lumaM, max( max( lumaN, lumaW), max( lumaS, lumaE))); + range = (rangeMax - rangeMin); + if ( (range < max( 0.0416667, (rangeMax * 0.125000))) ){ + return FxaaFilterReturn( rgbM); + } + rgbL = ((((rgbN + rgbW) + rgbM) + rgbE) + rgbS); + lumaL = ((((lumaN + lumaW) + lumaE) + lumaS) * 0.250000); + rangeL = abs( (lumaL - lumaM) ); + blendL = (max( 0.00000, ((rangeL / range) - 0.250000)) * 1.33333); + blendL = min( 0.750000, blendL); + rgbNW = FxaaTexOff( tex, pos.xy , vec2( -1.00000, -1.00000), rcpFrame).xyz ; + rgbNE = FxaaTexOff( tex, pos.xy , vec2( 1.00000, -1.00000), rcpFrame).xyz ; + rgbSW = FxaaTexOff( tex, pos.xy , vec2( -1.00000, 1.00000), rcpFrame).xyz ; + rgbSE = FxaaTexOff( tex, pos.xy , vec2( 1.00000, 1.00000), rcpFrame).xyz ; + rgbL += (((rgbNW + rgbNE) + rgbSW) + rgbSE); + rgbL *= vec3( 0.111111, 0.111111, 0.111111); + lumaNW = FxaaLuma( rgbNW); + lumaNE = FxaaLuma( rgbNE); + lumaSW = FxaaLuma( rgbSW); + lumaSE = FxaaLuma( rgbSE); + edgeVert = ((abs( (((0.250000 * lumaNW) + (-0.500000 * lumaN)) + (0.250000 * lumaNE)) ) + abs( (((0.500000 * lumaW) + (-1.00000 * lumaM)) + (0.500000 * lumaE)) )) + abs( (((0.250000 * lumaSW) + (-0.500000 * lumaS)) + (0.250000 * lumaSE)) )); + edgeHorz = ((abs( (((0.250000 * lumaNW) + (-0.500000 * lumaW)) + (0.250000 * lumaSW)) ) + abs( (((0.500000 * lumaN) + (-1.00000 * lumaM)) + (0.500000 * lumaS)) )) + abs( (((0.250000 * lumaNE) + (-0.500000 * lumaE)) + (0.250000 * lumaSE)) )); + horzSpan = (edgeHorz >= edgeVert); + lengthSign = (( horzSpan ) ? ( ( -rcpFrame.y ) ) : ( ( -rcpFrame.x ) )); + if ( ( !horzSpan ) ){ + lumaN = lumaW; + } + if ( ( !horzSpan ) ){ + lumaS = lumaE; + } + gradientN = abs( (lumaN - lumaM) ); + gradientS = abs( (lumaS - lumaM) ); + lumaN = ((lumaN + lumaM) * 0.500000); + lumaS = ((lumaS + lumaM) * 0.500000); + pairN = (gradientN >= gradientS); + if ( ( !pairN ) ){ + lumaN = lumaS; + } + if ( ( !pairN ) ){ + gradientN = gradientS; + } + if ( ( !pairN ) ){ + lengthSign *= -1.00000; + } + posN.x = (pos.x + (( horzSpan ) ? ( 0.00000 ) : ( (lengthSign * 0.500000) ))); + posN.y = (pos.y + (( horzSpan ) ? ( (lengthSign * 0.500000) ) : ( 0.00000 ))); + gradientN *= 0.250000; + posP = posN; + offNP = (( horzSpan ) ? ( vec2( rcpFrame.x , 0.00000) ) : ( vec2( 0.00000, rcpFrame.y ) )); + lumaEndN = lumaN; + lumaEndP = lumaN; + posN += (offNP * vec2( -1.00000, -1.00000)); + posP += (offNP * vec2( 1.00000, 1.00000)); + for ( ; (i < 16); ( i++ )) { + if ( ( !doneN ) ){ + lumaEndN = FxaaLuma( FxaaTexLod0( tex, posN.xy ).xyz ); + } + if ( ( !doneP ) ){ + lumaEndP = FxaaLuma( FxaaTexLod0( tex, posP.xy ).xyz ); + } + doneN = (doneN || (abs( (lumaEndN - lumaN) ) >= gradientN)); + doneP = (doneP || (abs( (lumaEndP - lumaN) ) >= gradientN)); + if ( (doneN && doneP) ){ + break; + } + if ( ( !doneN ) ){ + posN -= offNP; + } + if ( ( !doneP ) ){ + posP += offNP; + } + } + dstN = (( horzSpan ) ? ( (pos.x - posN.x ) ) : ( (pos.y - posN.y ) )); + dstP = (( horzSpan ) ? ( (posP.x - pos.x ) ) : ( (posP.y - pos.y ) )); + directionN = (dstN < dstP); + lumaEndN = (( directionN ) ? ( lumaEndN ) : ( lumaEndP )); + if ( (((lumaM - lumaN) < 0.00000) == ((lumaEndN - lumaN) < 0.00000)) ){ + lengthSign = 0.00000; + } + spanLength = (dstP + dstN); + dstN = (( directionN ) ? ( dstN ) : ( dstP )); + subPixelOffset = ((0.500000 + (dstN * (-1.00000 / spanLength))) * lengthSign); + rgbF = FxaaTexLod0( tex, vec2( (pos.x + (( horzSpan ) ? ( 0.00000 ) : ( subPixelOffset ))), (pos.y + (( horzSpan ) ? ( subPixelOffset ) : ( 0.00000 ))))).xyz ; + return FxaaFilterReturn( FxaaLerp3( rgbL, rgbF, blendL)); +} +vec4 xlat_main( in vec2 uv ) { + return vec4( FxaaPixelShader( uv.xy , _MainTex, _MainTex_TexelSize.xy ).xyz , 0.00000); +} +varying vec2 xlv_TEXCOORD0; +void main() { + vec4 xl_retval; + xl_retval = xlat_main( vec2(xlv_TEXCOORD0)); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/complex-fxaa-preset3-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/complex-fxaa-preset3-ir.txt new file mode 100644 index 000000000..be6d808ab --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/complex-fxaa-preset3-ir.txt @@ -0,0 +1,583 @@ +#extension GL_ARB_shader_texture_lod : enable +varying vec2 xlv_TEXCOORD0; +uniform vec4 _MainTex_TexelSize; +uniform sampler2D _MainTex; +vec4 xll_tex2Dlod ( + in sampler2D s, + in vec4 coord +) +{ + vec4 tmpvar_1; + tmpvar_1 = texture2DLod (s, coord.xy, coord.w); + return tmpvar_1; +} + +vec4 FxaaTexOff ( + in sampler2D tex, + in vec2 pos, + in vec2 off, + in vec2 rcpFrame +) +{ + vec4 tmpvar_1; + tmpvar_1.zw = vec2(0.0, 0.0); + tmpvar_1.xy = (pos.xy + (off * rcpFrame)).xy; + vec4 tmpvar_2; + tmpvar_2 = xll_tex2Dlod (tex, tmpvar_1); + return tmpvar_2; +} + +vec4 FxaaTexLod0 ( + in sampler2D tex, + in vec2 pos +) +{ + vec4 tmpvar_1; + tmpvar_1.zw = vec2(0.0, 0.0); + tmpvar_1.xy = pos.xy.xy; + vec4 tmpvar_2; + tmpvar_2 = xll_tex2Dlod (tex, tmpvar_1); + return tmpvar_2; +} + +float FxaaLuma ( + in vec3 rgb +) +{ + return ((rgb.y * 1.96321) + rgb.x); +} + +vec3 FxaaLerp3 ( + in vec3 a, + in vec3 b, + in float amountOfA +) +{ + vec3 tmpvar_1; + tmpvar_1.x = -(amountOfA); + tmpvar_1.y = -(amountOfA); + tmpvar_1.z = -(amountOfA); + vec3 tmpvar_2; + tmpvar_2.x = amountOfA; + tmpvar_2.y = amountOfA; + tmpvar_2.z = amountOfA; + return ((tmpvar_1 * b) + ((a * tmpvar_2) + b)); +} + +vec3 FxaaFilterReturn ( + in vec3 rgb +) +{ + return rgb; +} + +vec3 FxaaPixelShader ( + in vec2 pos, + in sampler2D tex, + in vec2 rcpFrame +) +{ + vec3 rgbF; + float subPixelOffset; + float spanLength; + bool directionN; + float dstP; + float dstN; + int i; + bool doneP; + bool doneN; + float lumaEndP; + float lumaEndN; + vec2 offNP; + vec2 posP; + vec2 posN; + bool pairN; + float gradientS; + float gradientN; + float lengthSign; + bool horzSpan; + float edgeHorz; + float edgeVert; + float lumaSE; + float lumaSW; + float lumaNE; + float lumaNW; + vec3 rgbSE; + vec3 rgbSW; + vec3 rgbNE; + vec3 rgbNW; + float blendL; + float rangeL; + float lumaL; + vec3 rgbL; + float range; + float rangeMax; + float rangeMin; + float lumaS; + float lumaE; + float lumaM; + float lumaW; + float lumaN; + vec3 rgbS; + vec3 rgbE; + vec3 rgbM; + vec3 rgbW; + vec3 rgbN; + bool tmpvar_1; + tmpvar_1 = bool(0); + doneN = tmpvar_1; + bool tmpvar_2; + tmpvar_2 = bool(0); + doneP = tmpvar_2; + int tmpvar_3; + tmpvar_3 = 0; + i = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = FxaaTexOff (tex, pos.xy, vec2(0.0, -1.0), rcpFrame); + vec3 tmpvar_5; + tmpvar_5 = tmpvar_4.xyz; + rgbN = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = FxaaTexOff (tex, pos.xy, vec2(-1.0, 0.0), rcpFrame); + vec3 tmpvar_7; + tmpvar_7 = tmpvar_6.xyz; + rgbW = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = FxaaTexOff (tex, pos.xy, vec2(0.0, 0.0), rcpFrame); + vec3 tmpvar_9; + tmpvar_9 = tmpvar_8.xyz; + rgbM = tmpvar_9; + vec4 tmpvar_10; + tmpvar_10 = FxaaTexOff (tex, pos.xy, vec2(1.0, 0.0), rcpFrame); + vec3 tmpvar_11; + tmpvar_11 = tmpvar_10.xyz; + rgbE = tmpvar_11; + vec4 tmpvar_12; + tmpvar_12 = FxaaTexOff (tex, pos.xy, vec2(0.0, 1.0), rcpFrame); + vec3 tmpvar_13; + tmpvar_13 = tmpvar_12.xyz; + rgbS = tmpvar_13; + float tmpvar_14; + tmpvar_14 = FxaaLuma (rgbN); + float tmpvar_15; + tmpvar_15 = tmpvar_14; + lumaN = tmpvar_15; + float tmpvar_16; + tmpvar_16 = FxaaLuma (rgbW); + float tmpvar_17; + tmpvar_17 = tmpvar_16; + lumaW = tmpvar_17; + float tmpvar_18; + tmpvar_18 = FxaaLuma (rgbM); + float tmpvar_19; + tmpvar_19 = tmpvar_18; + lumaM = tmpvar_19; + float tmpvar_20; + tmpvar_20 = FxaaLuma (rgbE); + float tmpvar_21; + tmpvar_21 = tmpvar_20; + lumaE = tmpvar_21; + float tmpvar_22; + tmpvar_22 = FxaaLuma (rgbS); + float tmpvar_23; + tmpvar_23 = tmpvar_22; + lumaS = tmpvar_23; + float tmpvar_24; + tmpvar_24 = min (lumaN, lumaW); + float tmpvar_25; + tmpvar_25 = min (lumaS, lumaE); + float tmpvar_26; + tmpvar_26 = min (tmpvar_24, tmpvar_25); + float tmpvar_27; + tmpvar_27 = min (lumaM, tmpvar_26); + float tmpvar_28; + tmpvar_28 = tmpvar_27; + rangeMin = tmpvar_28; + float tmpvar_29; + tmpvar_29 = max (lumaN, lumaW); + float tmpvar_30; + tmpvar_30 = max (lumaS, lumaE); + float tmpvar_31; + tmpvar_31 = max (tmpvar_29, tmpvar_30); + float tmpvar_32; + tmpvar_32 = max (lumaM, tmpvar_31); + float tmpvar_33; + tmpvar_33 = tmpvar_32; + rangeMax = tmpvar_33; + float tmpvar_34; + tmpvar_34 = (rangeMax - rangeMin); + range = tmpvar_34; + float tmpvar_35; + tmpvar_35 = max (0.0416667, (rangeMax * 0.125)); + if ((range < tmpvar_35)) { + vec3 tmpvar_36; + tmpvar_36 = FxaaFilterReturn (rgbM); + return tmpvar_36; + }; + vec3 tmpvar_37; + tmpvar_37 = ((((rgbN + rgbW) + rgbM) + rgbE) + rgbS); + rgbL = tmpvar_37; + float tmpvar_38; + tmpvar_38 = ((((lumaN + lumaW) + lumaE) + lumaS) * 0.25); + lumaL = tmpvar_38; + float tmpvar_39; + tmpvar_39 = abs ((lumaL - lumaM)); + float tmpvar_40; + tmpvar_40 = tmpvar_39; + rangeL = tmpvar_40; + float tmpvar_41; + tmpvar_41 = max (0.0, ((rangeL / range) - 0.25)); + float tmpvar_42; + tmpvar_42 = (tmpvar_41 * 1.33333); + blendL = tmpvar_42; + float tmpvar_43; + tmpvar_43 = min (0.75, blendL); + float tmpvar_44; + tmpvar_44 = tmpvar_43; + blendL = tmpvar_44; + vec4 tmpvar_45; + tmpvar_45 = FxaaTexOff (tex, pos.xy, vec2(-1.0, -1.0), rcpFrame); + vec3 tmpvar_46; + tmpvar_46 = tmpvar_45.xyz; + rgbNW = tmpvar_46; + vec4 tmpvar_47; + tmpvar_47 = FxaaTexOff (tex, pos.xy, vec2(1.0, -1.0), rcpFrame); + vec3 tmpvar_48; + tmpvar_48 = tmpvar_47.xyz; + rgbNE = tmpvar_48; + vec4 tmpvar_49; + tmpvar_49 = FxaaTexOff (tex, pos.xy, vec2(-1.0, 1.0), rcpFrame); + vec3 tmpvar_50; + tmpvar_50 = tmpvar_49.xyz; + rgbSW = tmpvar_50; + vec4 tmpvar_51; + tmpvar_51 = FxaaTexOff (tex, pos.xy, vec2(1.0, 1.0), rcpFrame); + vec3 tmpvar_52; + tmpvar_52 = tmpvar_51.xyz; + rgbSE = tmpvar_52; + vec3 tmpvar_53; + tmpvar_53 = (rgbL + (((rgbNW + rgbNE) + rgbSW) + rgbSE)); + rgbL = tmpvar_53; + vec3 tmpvar_54; + tmpvar_54 = (rgbL * vec3(0.111111, 0.111111, 0.111111)); + rgbL = tmpvar_54; + float tmpvar_55; + tmpvar_55 = FxaaLuma (rgbNW); + float tmpvar_56; + tmpvar_56 = tmpvar_55; + lumaNW = tmpvar_56; + float tmpvar_57; + tmpvar_57 = FxaaLuma (rgbNE); + float tmpvar_58; + tmpvar_58 = tmpvar_57; + lumaNE = tmpvar_58; + float tmpvar_59; + tmpvar_59 = FxaaLuma (rgbSW); + float tmpvar_60; + tmpvar_60 = tmpvar_59; + lumaSW = tmpvar_60; + float tmpvar_61; + tmpvar_61 = FxaaLuma (rgbSE); + float tmpvar_62; + tmpvar_62 = tmpvar_61; + lumaSE = tmpvar_62; + float tmpvar_63; + tmpvar_63 = abs ((((0.25 * lumaNW) + (-(0.5) * lumaN)) + (0.25 * lumaNE))); + float tmpvar_64; + tmpvar_64 = abs ((((0.5 * lumaW) + (-(1.0) * lumaM)) + (0.5 * lumaE))); + float tmpvar_65; + tmpvar_65 = abs ((((0.25 * lumaSW) + (-(0.5) * lumaS)) + (0.25 * lumaSE))); + float tmpvar_66; + tmpvar_66 = ((tmpvar_63 + tmpvar_64) + tmpvar_65); + edgeVert = tmpvar_66; + float tmpvar_67; + tmpvar_67 = abs ((((0.25 * lumaNW) + (-(0.5) * lumaW)) + (0.25 * lumaSW))); + float tmpvar_68; + tmpvar_68 = abs ((((0.5 * lumaN) + (-(1.0) * lumaM)) + (0.5 * lumaS))); + float tmpvar_69; + tmpvar_69 = abs ((((0.25 * lumaNE) + (-(0.5) * lumaE)) + (0.25 * lumaSE))); + float tmpvar_70; + tmpvar_70 = ((tmpvar_67 + tmpvar_68) + tmpvar_69); + edgeHorz = tmpvar_70; + bool tmpvar_71; + tmpvar_71 = (edgeHorz >= edgeVert); + horzSpan = tmpvar_71; + float tmpvar_72; + if (horzSpan) { + tmpvar_72 = -(rcpFrame.y); + } else { + tmpvar_72 = -(rcpFrame.x); + }; + float tmpvar_73; + tmpvar_73 = tmpvar_72; + lengthSign = tmpvar_73; + if (!(horzSpan)) { + float tmpvar_74; + tmpvar_74 = lumaW; + lumaN = tmpvar_74; + }; + if (!(horzSpan)) { + float tmpvar_75; + tmpvar_75 = lumaE; + lumaS = tmpvar_75; + }; + float tmpvar_76; + tmpvar_76 = abs ((lumaN - lumaM)); + float tmpvar_77; + tmpvar_77 = tmpvar_76; + gradientN = tmpvar_77; + float tmpvar_78; + tmpvar_78 = abs ((lumaS - lumaM)); + float tmpvar_79; + tmpvar_79 = tmpvar_78; + gradientS = tmpvar_79; + float tmpvar_80; + tmpvar_80 = ((lumaN + lumaM) * 0.5); + lumaN = tmpvar_80; + float tmpvar_81; + tmpvar_81 = ((lumaS + lumaM) * 0.5); + lumaS = tmpvar_81; + bool tmpvar_82; + tmpvar_82 = (gradientN >= gradientS); + pairN = tmpvar_82; + if (!(pairN)) { + float tmpvar_83; + tmpvar_83 = lumaS; + lumaN = tmpvar_83; + }; + if (!(pairN)) { + float tmpvar_84; + tmpvar_84 = gradientS; + gradientN = tmpvar_84; + }; + if (!(pairN)) { + float tmpvar_85; + tmpvar_85 = (lengthSign * -(1.0)); + lengthSign = tmpvar_85; + }; + float tmpvar_86; + if (horzSpan) { + tmpvar_86 = 0.0; + } else { + tmpvar_86 = (lengthSign * 0.5); + }; + float tmpvar_87; + tmpvar_87 = (pos.x + tmpvar_86); + posN.x = tmpvar_87; + float tmpvar_88; + if (horzSpan) { + tmpvar_88 = (lengthSign * 0.5); + } else { + tmpvar_88 = 0.0; + }; + float tmpvar_89; + tmpvar_89 = (pos.y + tmpvar_88); + posN.y = vec2(tmpvar_89).y; + float tmpvar_90; + tmpvar_90 = (gradientN * 0.25); + gradientN = tmpvar_90; + vec2 tmpvar_91; + tmpvar_91 = posN; + posP = tmpvar_91; + vec2 tmpvar_92; + if (horzSpan) { + vec2 tmpvar_93; + tmpvar_93.y = 0.0; + tmpvar_93.x = rcpFrame.x; + tmpvar_92 = tmpvar_93; + } else { + vec2 tmpvar_94; + tmpvar_94.x = 0.0; + tmpvar_94.y = rcpFrame.y; + tmpvar_92 = tmpvar_94; + }; + vec2 tmpvar_95; + tmpvar_95 = tmpvar_92; + offNP = tmpvar_95; + float tmpvar_96; + tmpvar_96 = lumaN; + lumaEndN = tmpvar_96; + float tmpvar_97; + tmpvar_97 = lumaN; + lumaEndP = tmpvar_97; + vec2 tmpvar_98; + tmpvar_98 = (posN + (offNP * vec2(-1.0, -1.0))); + posN = tmpvar_98; + vec2 tmpvar_99; + tmpvar_99 = (posP + (offNP * vec2(1.0, 1.0))); + posP = tmpvar_99; + while (true) { + if (!((i < 16))) { + break; + }; + if (!(doneN)) { + vec4 tmpvar_100; + tmpvar_100 = FxaaTexLod0 (tex, posN.xy); + float tmpvar_101; + tmpvar_101 = FxaaLuma (tmpvar_100.xyz); + float tmpvar_102; + tmpvar_102 = tmpvar_101; + lumaEndN = tmpvar_102; + }; + if (!(doneP)) { + vec4 tmpvar_103; + tmpvar_103 = FxaaTexLod0 (tex, posP.xy); + float tmpvar_104; + tmpvar_104 = FxaaLuma (tmpvar_103.xyz); + float tmpvar_105; + tmpvar_105 = tmpvar_104; + lumaEndP = tmpvar_105; + }; + bool tmpvar_106; + if (doneN) { + tmpvar_106 = bool(1); + } else { + float tmpvar_107; + tmpvar_107 = abs ((lumaEndN - lumaN)); + tmpvar_106 = (tmpvar_107 >= gradientN); + }; + bool tmpvar_108; + tmpvar_108 = tmpvar_106; + doneN = tmpvar_108; + bool tmpvar_109; + if (doneP) { + tmpvar_109 = bool(1); + } else { + float tmpvar_110; + tmpvar_110 = abs ((lumaEndP - lumaN)); + tmpvar_109 = (tmpvar_110 >= gradientN); + }; + bool tmpvar_111; + tmpvar_111 = tmpvar_109; + doneP = tmpvar_111; + bool tmpvar_112; + if (doneN) { + tmpvar_112 = doneP; + } else { + tmpvar_112 = bool(0); + }; + if (tmpvar_112) { + break; + }; + if (!(doneN)) { + vec2 tmpvar_113; + tmpvar_113 = (posN - offNP); + posN = tmpvar_113; + }; + if (!(doneP)) { + vec2 tmpvar_114; + tmpvar_114 = (posP + offNP); + posP = tmpvar_114; + }; + int _post_incdec_tmp; + _post_incdec_tmp = i; + int tmpvar_115; + tmpvar_115 = (i + 1); + i = tmpvar_115; + }; + float tmpvar_116; + if (horzSpan) { + tmpvar_116 = (pos.x - posN.x); + } else { + tmpvar_116 = (pos.y - posN.y); + }; + float tmpvar_117; + tmpvar_117 = tmpvar_116; + dstN = tmpvar_117; + float tmpvar_118; + if (horzSpan) { + tmpvar_118 = (posP.x - pos.x); + } else { + tmpvar_118 = (posP.y - pos.y); + }; + float tmpvar_119; + tmpvar_119 = tmpvar_118; + dstP = tmpvar_119; + bool tmpvar_120; + tmpvar_120 = (dstN < dstP); + directionN = tmpvar_120; + float tmpvar_121; + if (directionN) { + tmpvar_121 = lumaEndN; + } else { + tmpvar_121 = lumaEndP; + }; + float tmpvar_122; + tmpvar_122 = tmpvar_121; + lumaEndN = tmpvar_122; + if ((((lumaM - lumaN) < 0.0) == ((lumaEndN - lumaN) < 0.0))) { + float tmpvar_123; + tmpvar_123 = 0.0; + lengthSign = tmpvar_123; + }; + float tmpvar_124; + tmpvar_124 = (dstP + dstN); + spanLength = tmpvar_124; + float tmpvar_125; + if (directionN) { + tmpvar_125 = dstN; + } else { + tmpvar_125 = dstP; + }; + float tmpvar_126; + tmpvar_126 = tmpvar_125; + dstN = tmpvar_126; + float tmpvar_127; + tmpvar_127 = ((0.5 + (dstN * (-(1.0) / spanLength))) * lengthSign); + subPixelOffset = tmpvar_127; + float tmpvar_128; + if (horzSpan) { + tmpvar_128 = 0.0; + } else { + tmpvar_128 = subPixelOffset; + }; + float tmpvar_129; + if (horzSpan) { + tmpvar_129 = subPixelOffset; + } else { + tmpvar_129 = 0.0; + }; + vec2 tmpvar_130; + tmpvar_130.x = (pos.x + tmpvar_128); + tmpvar_130.y = (pos.y + tmpvar_129); + vec4 tmpvar_131; + tmpvar_131 = FxaaTexLod0 (tex, tmpvar_130); + vec3 tmpvar_132; + tmpvar_132 = tmpvar_131.xyz; + rgbF = tmpvar_132; + vec3 tmpvar_133; + tmpvar_133 = FxaaLerp3 (rgbL, rgbF, blendL); + vec3 tmpvar_134; + tmpvar_134 = FxaaFilterReturn (tmpvar_133); + return tmpvar_134; +} + +vec4 xlat_main ( + in vec2 uv +) +{ + vec3 tmpvar_1; + tmpvar_1 = FxaaPixelShader (uv.xy, _MainTex, _MainTex_TexelSize.xy); + vec4 tmpvar_2; + tmpvar_2.w = 0.0; + tmpvar_2.xyz = tmpvar_1.xyz.xyz; + return tmpvar_2; +} + +void main () +{ + vec4 xl_retval; + vec2 tmpvar_1; + tmpvar_1 = xlv_TEXCOORD0.xy; + vec4 tmpvar_2; + tmpvar_2 = xlat_main (tmpvar_1); + vec4 tmpvar_3; + tmpvar_3 = tmpvar_2; + xl_retval = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = xl_retval.xyzw; + vec4 tmpvar_5; + tmpvar_5 = tmpvar_4; + gl_FragData[0] = tmpvar_5; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/complex-fxaa-preset3-out.txt b/3rdparty/glsl-optimizer/tests/fragment/complex-fxaa-preset3-out.txt new file mode 100644 index 000000000..faedf4fb7 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/complex-fxaa-preset3-out.txt @@ -0,0 +1,285 @@ +#extension GL_ARB_shader_texture_lod : enable +varying vec2 xlv_TEXCOORD0; +uniform vec4 _MainTex_TexelSize; +uniform sampler2D _MainTex; +void main () +{ + vec3 tmpvar_1; + int i; + bool doneP; + bool doneN; + float lumaEndP; + float lumaEndN; + vec2 offNP; + vec2 posP; + vec2 posN; + float gradientN; + float lengthSign; + float lumaS; + float lumaN; + doneN = bool(0); + doneP = bool(0); + i = 0; + vec4 tmpvar_2; + tmpvar_2.zw = vec2(0.0, 0.0); + tmpvar_2.xy = (xlv_TEXCOORD0 + (vec2(0.0, -1.0) * _MainTex_TexelSize.xy)); + vec4 tmpvar_3; + tmpvar_3 = texture2DLod (_MainTex, tmpvar_2.xy, 0.0); + vec4 tmpvar_4; + tmpvar_4.zw = vec2(0.0, 0.0); + tmpvar_4.xy = (xlv_TEXCOORD0 + (vec2(-1.0, 0.0) * _MainTex_TexelSize.xy)); + vec4 tmpvar_5; + tmpvar_5 = texture2DLod (_MainTex, tmpvar_4.xy, 0.0); + vec4 tmpvar_6; + tmpvar_6.zw = vec2(0.0, 0.0); + tmpvar_6.xy = xlv_TEXCOORD0; + vec4 tmpvar_7; + tmpvar_7 = texture2DLod (_MainTex, tmpvar_6.xy, 0.0); + vec4 tmpvar_8; + tmpvar_8.zw = vec2(0.0, 0.0); + tmpvar_8.xy = (xlv_TEXCOORD0 + (vec2(1.0, 0.0) * _MainTex_TexelSize.xy)); + vec4 tmpvar_9; + tmpvar_9 = texture2DLod (_MainTex, tmpvar_8.xy, 0.0); + vec4 tmpvar_10; + tmpvar_10.zw = vec2(0.0, 0.0); + tmpvar_10.xy = (xlv_TEXCOORD0 + (vec2(0.0, 1.0) * _MainTex_TexelSize.xy)); + vec4 tmpvar_11; + tmpvar_11 = texture2DLod (_MainTex, tmpvar_10.xy, 0.0); + float tmpvar_12; + tmpvar_12 = ((tmpvar_3.y * 1.96321) + tmpvar_3.x); + lumaN = tmpvar_12; + float tmpvar_13; + tmpvar_13 = ((tmpvar_5.y * 1.96321) + tmpvar_5.x); + float tmpvar_14; + tmpvar_14 = ((tmpvar_7.y * 1.96321) + tmpvar_7.x); + float tmpvar_15; + tmpvar_15 = ((tmpvar_9.y * 1.96321) + tmpvar_9.x); + float tmpvar_16; + tmpvar_16 = ((tmpvar_11.y * 1.96321) + tmpvar_11.x); + lumaS = tmpvar_16; + float tmpvar_17; + tmpvar_17 = max (tmpvar_14, max (max (tmpvar_12, tmpvar_13), max (tmpvar_16, tmpvar_15))); + float tmpvar_18; + tmpvar_18 = (tmpvar_17 - min (tmpvar_14, min (min (tmpvar_12, tmpvar_13), min (tmpvar_16, tmpvar_15)))); + float tmpvar_19; + tmpvar_19 = max (0.0416667, (tmpvar_17 * 0.125)); + if ((tmpvar_18 < tmpvar_19)) { + tmpvar_1 = tmpvar_7.xyz; + } else { + float tmpvar_20; + tmpvar_20 = min (0.75, (max (0.0, ((abs ((((((tmpvar_12 + tmpvar_13) + tmpvar_15) + tmpvar_16) * 0.25) - tmpvar_14)) / tmpvar_18) - 0.25)) * 1.33333)); + vec4 tmpvar_21; + tmpvar_21.zw = vec2(0.0, 0.0); + tmpvar_21.xy = (xlv_TEXCOORD0 + (vec2(-1.0, -1.0) * _MainTex_TexelSize.xy)); + vec4 tmpvar_22; + tmpvar_22 = texture2DLod (_MainTex, tmpvar_21.xy, 0.0); + vec4 tmpvar_23; + tmpvar_23.zw = vec2(0.0, 0.0); + tmpvar_23.xy = (xlv_TEXCOORD0 + (vec2(1.0, -1.0) * _MainTex_TexelSize.xy)); + vec4 tmpvar_24; + tmpvar_24 = texture2DLod (_MainTex, tmpvar_23.xy, 0.0); + vec4 tmpvar_25; + tmpvar_25.zw = vec2(0.0, 0.0); + tmpvar_25.xy = (xlv_TEXCOORD0 + (vec2(-1.0, 1.0) * _MainTex_TexelSize.xy)); + vec4 tmpvar_26; + tmpvar_26 = texture2DLod (_MainTex, tmpvar_25.xy, 0.0); + vec4 tmpvar_27; + tmpvar_27.zw = vec2(0.0, 0.0); + tmpvar_27.xy = (xlv_TEXCOORD0 + _MainTex_TexelSize.xy); + vec4 tmpvar_28; + tmpvar_28 = texture2DLod (_MainTex, tmpvar_27.xy, 0.0); + vec3 tmpvar_29; + tmpvar_29 = ((((((tmpvar_3.xyz + tmpvar_5.xyz) + tmpvar_7.xyz) + tmpvar_9.xyz) + tmpvar_11.xyz) + (((tmpvar_22.xyz + tmpvar_24.xyz) + tmpvar_26.xyz) + tmpvar_28.xyz)) * vec3(0.111111, 0.111111, 0.111111)); + float tmpvar_30; + tmpvar_30 = ((tmpvar_22.y * 1.96321) + tmpvar_22.x); + float tmpvar_31; + tmpvar_31 = ((tmpvar_24.y * 1.96321) + tmpvar_24.x); + float tmpvar_32; + tmpvar_32 = ((tmpvar_26.y * 1.96321) + tmpvar_26.x); + float tmpvar_33; + tmpvar_33 = ((tmpvar_28.y * 1.96321) + tmpvar_28.x); + bool tmpvar_34; + tmpvar_34 = (((abs ((((0.25 * tmpvar_30) + (-(0.5) * tmpvar_13)) + (0.25 * tmpvar_32))) + abs ((((0.5 * tmpvar_12) + (-(1.0) * tmpvar_14)) + (0.5 * tmpvar_16)))) + abs ((((0.25 * tmpvar_31) + (-(0.5) * tmpvar_15)) + (0.25 * tmpvar_33)))) >= ((abs ((((0.25 * tmpvar_30) + (-(0.5) * tmpvar_12)) + (0.25 * tmpvar_31))) + abs ((((0.5 * tmpvar_13) + (-(1.0) * tmpvar_14)) + (0.5 * tmpvar_15)))) + abs ((((0.25 * tmpvar_32) + (-(0.5) * tmpvar_16)) + (0.25 * tmpvar_33))))); + float tmpvar_35; + if (tmpvar_34) { + tmpvar_35 = -(_MainTex_TexelSize.y); + } else { + tmpvar_35 = -(_MainTex_TexelSize.x); + }; + lengthSign = tmpvar_35; + if (!(tmpvar_34)) { + lumaN = tmpvar_13; + }; + if (!(tmpvar_34)) { + lumaS = tmpvar_15; + }; + float tmpvar_36; + tmpvar_36 = abs ((lumaN - tmpvar_14)); + gradientN = tmpvar_36; + float tmpvar_37; + tmpvar_37 = abs ((lumaS - tmpvar_14)); + lumaN = ((lumaN + tmpvar_14) * 0.5); + float tmpvar_38; + tmpvar_38 = ((lumaS + tmpvar_14) * 0.5); + lumaS = tmpvar_38; + bool tmpvar_39; + tmpvar_39 = (tmpvar_36 >= tmpvar_37); + if (!(tmpvar_39)) { + lumaN = tmpvar_38; + }; + if (!(tmpvar_39)) { + gradientN = tmpvar_37; + }; + if (!(tmpvar_39)) { + lengthSign = (tmpvar_35 * -1.0); + }; + float tmpvar_40; + if (tmpvar_34) { + tmpvar_40 = 0.0; + } else { + tmpvar_40 = (lengthSign * 0.5); + }; + posN.x = (xlv_TEXCOORD0.x + tmpvar_40); + float tmpvar_41; + if (tmpvar_34) { + tmpvar_41 = (lengthSign * 0.5); + } else { + tmpvar_41 = 0.0; + }; + posN.y = (xlv_TEXCOORD0.y + tmpvar_41); + gradientN = (gradientN * 0.25); + posP = posN; + vec2 tmpvar_42; + if (tmpvar_34) { + vec2 tmpvar_43; + tmpvar_43.y = 0.0; + tmpvar_43.x = _MainTex_TexelSize.x; + tmpvar_42 = tmpvar_43; + } else { + vec2 tmpvar_44; + tmpvar_44.x = 0.0; + tmpvar_44.y = _MainTex_TexelSize.y; + tmpvar_42 = tmpvar_44; + }; + offNP = tmpvar_42; + lumaEndN = lumaN; + lumaEndP = lumaN; + posN = (posN + (tmpvar_42 * vec2(-1.0, -1.0))); + posP = (posP + tmpvar_42); + while (true) { + if ((i >= 16)) { + break; + }; + if (!(doneN)) { + vec4 tmpvar_45; + tmpvar_45.zw = vec2(0.0, 0.0); + tmpvar_45.xy = posN; + vec4 tmpvar_46; + tmpvar_46 = texture2DLod (_MainTex, tmpvar_45.xy, 0.0); + lumaEndN = ((tmpvar_46.y * 1.96321) + tmpvar_46.x); + }; + if (!(doneP)) { + vec4 tmpvar_47; + tmpvar_47.zw = vec2(0.0, 0.0); + tmpvar_47.xy = posP; + vec4 tmpvar_48; + tmpvar_48 = texture2DLod (_MainTex, tmpvar_47.xy, 0.0); + lumaEndP = ((tmpvar_48.y * 1.96321) + tmpvar_48.x); + }; + bool tmpvar_49; + if (doneN) { + tmpvar_49 = bool(1); + } else { + tmpvar_49 = (abs ((lumaEndN - lumaN)) >= gradientN); + }; + doneN = tmpvar_49; + bool tmpvar_50; + if (doneP) { + tmpvar_50 = bool(1); + } else { + tmpvar_50 = (abs ((lumaEndP - lumaN)) >= gradientN); + }; + doneP = tmpvar_50; + bool tmpvar_51; + if (tmpvar_49) { + tmpvar_51 = tmpvar_50; + } else { + tmpvar_51 = bool(0); + }; + if (tmpvar_51) { + break; + }; + if (!(tmpvar_49)) { + posN = (posN - offNP); + }; + if (!(tmpvar_50)) { + posP = (posP + offNP); + }; + i = (i + 1); + }; + float tmpvar_52; + if (tmpvar_34) { + tmpvar_52 = (xlv_TEXCOORD0.x - posN.x); + } else { + tmpvar_52 = (xlv_TEXCOORD0.y - posN.y); + }; + float tmpvar_53; + if (tmpvar_34) { + tmpvar_53 = (posP.x - xlv_TEXCOORD0.x); + } else { + tmpvar_53 = (posP.y - xlv_TEXCOORD0.y); + }; + bool tmpvar_54; + tmpvar_54 = (tmpvar_52 < tmpvar_53); + float tmpvar_55; + if (tmpvar_54) { + tmpvar_55 = lumaEndN; + } else { + tmpvar_55 = lumaEndP; + }; + lumaEndN = tmpvar_55; + if ((((tmpvar_14 - lumaN) < 0.0) == ((tmpvar_55 - lumaN) < 0.0))) { + lengthSign = 0.0; + }; + float tmpvar_56; + tmpvar_56 = (tmpvar_53 + tmpvar_52); + float tmpvar_57; + if (tmpvar_54) { + tmpvar_57 = tmpvar_52; + } else { + tmpvar_57 = tmpvar_53; + }; + float tmpvar_58; + tmpvar_58 = ((0.5 + (tmpvar_57 * (-1.0 / tmpvar_56))) * lengthSign); + float tmpvar_59; + if (tmpvar_34) { + tmpvar_59 = 0.0; + } else { + tmpvar_59 = tmpvar_58; + }; + float tmpvar_60; + if (tmpvar_34) { + tmpvar_60 = tmpvar_58; + } else { + tmpvar_60 = 0.0; + }; + vec2 tmpvar_61; + tmpvar_61.x = (xlv_TEXCOORD0.x + tmpvar_59); + tmpvar_61.y = (xlv_TEXCOORD0.y + tmpvar_60); + vec4 tmpvar_62; + tmpvar_62.zw = vec2(0.0, 0.0); + tmpvar_62.xy = tmpvar_61; + vec4 tmpvar_63; + tmpvar_63 = texture2DLod (_MainTex, tmpvar_62.xy, 0.0); + vec3 tmpvar_64; + tmpvar_64.x = -(tmpvar_20); + tmpvar_64.y = -(tmpvar_20); + tmpvar_64.z = -(tmpvar_20); + tmpvar_1 = ((tmpvar_64 * tmpvar_63.xyz) + ((tmpvar_29 * vec3(tmpvar_20)) + tmpvar_63.xyz)); + }; + vec4 tmpvar_65; + tmpvar_65.w = 0.0; + tmpvar_65.xyz = tmpvar_1; + gl_FragData[0] = tmpvar_65; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/complex-fxaa3-11-consolepc-in.txt b/3rdparty/glsl-optimizer/tests/fragment/complex-fxaa3-11-consolepc-in.txt new file mode 100644 index 000000000..2cfc7a413 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/complex-fxaa3-11-consolepc-in.txt @@ -0,0 +1,107 @@ +#ifdef GL_ES +#define texture2DLod texture2DLodEXT +#endif +#extension GL_ARB_shader_texture_lod : require +vec4 xll_tex2Dlod(sampler2D s, vec4 coord) { + return texture2DLod( s, coord.xy, coord.w); +} +struct v2f { + vec4 pos; + vec2 uv; + vec4 uvPosPos; +}; +uniform sampler2D _MainTex; +uniform vec4 _MainTex_TexelSize; +float FxaaLuma( in vec4 rgba ); +vec4 FxaaPixelShader( in vec2 pos, in vec4 fxaaConsolePosPos, in sampler2D tex, in sampler2D fxaaConsole360TexExpBiasNegOne, in sampler2D fxaaConsole360TexExpBiasNegTwo, in vec2 fxaaQualityRcpFrame, in vec4 fxaaConsoleRcpFrameOpt, in vec4 fxaaConsoleRcpFrameOpt2, in vec4 fxaaConsole360RcpFrameOpt2, in float fxaaQualitySubpix, in float fxaaQualityEdgeThreshold, in float fxaaQualityEdgeThresholdMin, in float fxaaConsoleEdgeSharpness, in float fxaaConsoleEdgeThreshold, in float fxaaConsoleEdgeThresholdMin, in vec4 fxaaConsole360ConstDir ); +vec4 xlat_main( in v2f i ); +float FxaaLuma( in vec4 rgba ) { + return rgba.y ; +} +vec4 FxaaPixelShader( in vec2 pos, in vec4 fxaaConsolePosPos, in sampler2D tex, in sampler2D fxaaConsole360TexExpBiasNegOne, in sampler2D fxaaConsole360TexExpBiasNegTwo, in vec2 fxaaQualityRcpFrame, in vec4 fxaaConsoleRcpFrameOpt, in vec4 fxaaConsoleRcpFrameOpt2, in vec4 fxaaConsole360RcpFrameOpt2, in float fxaaQualitySubpix, in float fxaaQualityEdgeThreshold, in float fxaaQualityEdgeThresholdMin, in float fxaaConsoleEdgeSharpness, in float fxaaConsoleEdgeThreshold, in float fxaaConsoleEdgeThresholdMin, in vec4 fxaaConsole360ConstDir ) { + float lumaNw; + float lumaSw; + float lumaNe; + float lumaSe; + vec4 rgbyM; + float lumaM; + float lumaMaxNwSw; + float lumaMinNwSw; + float lumaMaxNeSe; + float lumaMinNeSe; + float lumaMax; + float lumaMin; + float lumaMaxScaled; + float lumaMinM; + float lumaMaxScaledClamped; + float lumaMaxM; + float dirSwMinusNe; + float lumaMaxSubMinM; + float dirSeMinusNw; + vec2 dir; + vec2 dir1; + vec4 rgbyN1; + vec4 rgbyP1; + float dirAbsMinTimesC; + vec2 dir2; + vec4 rgbyN2; + vec4 rgbyP2; + vec4 rgbyA; + vec4 rgbyB; + bool twoTap; + lumaNw = FxaaLuma( xll_tex2Dlod( tex, vec4( fxaaConsolePosPos.xy , 0.00000, 0.00000))); + lumaSw = FxaaLuma( xll_tex2Dlod( tex, vec4( fxaaConsolePosPos.xw , 0.00000, 0.00000))); + lumaNe = FxaaLuma( xll_tex2Dlod( tex, vec4( fxaaConsolePosPos.zy , 0.00000, 0.00000))); + lumaSe = FxaaLuma( xll_tex2Dlod( tex, vec4( fxaaConsolePosPos.zw , 0.00000, 0.00000))); + rgbyM = xll_tex2Dlod( tex, vec4( pos.xy , 0.00000, 0.00000)); + lumaM = rgbyM.y ; + lumaMaxNwSw = max( lumaNw, lumaSw); + lumaNe += 0.00260417; + lumaMinNwSw = min( lumaNw, lumaSw); + lumaMaxNeSe = max( lumaNe, lumaSe); + lumaMinNeSe = min( lumaNe, lumaSe); + lumaMax = max( lumaMaxNeSe, lumaMaxNwSw); + lumaMin = min( lumaMinNeSe, lumaMinNwSw); + lumaMaxScaled = (lumaMax * fxaaConsoleEdgeThreshold); + lumaMinM = min( lumaMin, lumaM); + lumaMaxScaledClamped = max( fxaaConsoleEdgeThresholdMin, lumaMaxScaled); + lumaMaxM = max( lumaMax, lumaM); + dirSwMinusNe = (lumaSw - lumaNe); + lumaMaxSubMinM = (lumaMaxM - lumaMinM); + dirSeMinusNw = (lumaSe - lumaNw); + if ( (lumaMaxSubMinM < lumaMaxScaledClamped) ){ + return rgbyM; + } + dir.x = (dirSwMinusNe + dirSeMinusNw); + dir.y = (dirSwMinusNe - dirSeMinusNw); + dir1 = normalize( dir.xy ); + rgbyN1 = xll_tex2Dlod( tex, vec4( (pos.xy - (dir1 * fxaaConsoleRcpFrameOpt.zw )), 0.00000, 0.00000)); + rgbyP1 = xll_tex2Dlod( tex, vec4( (pos.xy + (dir1 * fxaaConsoleRcpFrameOpt.zw )), 0.00000, 0.00000)); + dirAbsMinTimesC = (min( abs( dir1.x ), abs( dir1.y )) * fxaaConsoleEdgeSharpness); + dir2 = clamp( (dir1.xy / dirAbsMinTimesC), vec2( -2.00000), vec2( 2.00000)); + rgbyN2 = xll_tex2Dlod( tex, vec4( (pos.xy - (dir2 * fxaaConsoleRcpFrameOpt2.zw )), 0.00000, 0.00000)); + rgbyP2 = xll_tex2Dlod( tex, vec4( (pos.xy + (dir2 * fxaaConsoleRcpFrameOpt2.zw )), 0.00000, 0.00000)); + rgbyA = (rgbyN1 + rgbyP1); + rgbyB = (((rgbyN2 + rgbyP2) * 0.250000) + (rgbyA * 0.250000)); + twoTap = ((rgbyB.y < lumaMin) || (rgbyB.y > lumaMax)); + if ( twoTap ){ + rgbyB.xyz = (rgbyA.xyz * 0.500000); + } + return rgbyB; +} +vec4 xlat_main( in v2f i ) { + float fxaaN = 0.500000; + return FxaaPixelShader( i.uv, i.uvPosPos, _MainTex, _MainTex, _MainTex, _MainTex_TexelSize.xy , (_MainTex_TexelSize.xyxy * vec4( ( -fxaaN ), ( -fxaaN ), fxaaN, fxaaN)), (_MainTex_TexelSize.xyxy * vec4( -2.00000, -2.00000, 2.00000, 2.00000)), (_MainTex_TexelSize.xyxy * vec4( 8.00000, 8.00000, -4.00000, -4.00000)), 0.750000, 0.166000, 0.0833000, 8.00000, 0.125000, 0.0500000, vec4( 1.00000, -1.00000, 0.250000, -0.250000)); +} +varying vec4 xlv_SV_POSITION; +varying vec2 xlv_TEXCOORD0; +varying vec4 xlv_TEXCOORD1; +void main() { + vec4 xl_retval; + v2f xlt_i; + xlt_i.pos = vec4( xlv_SV_POSITION); + xlt_i.uv = vec2( xlv_TEXCOORD0); + xlt_i.uvPosPos = vec4( xlv_TEXCOORD1); + xl_retval = xlat_main( xlt_i); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/complex-fxaa3-11-consolepc-inES.txt b/3rdparty/glsl-optimizer/tests/fragment/complex-fxaa3-11-consolepc-inES.txt new file mode 100644 index 000000000..95bc7142c --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/complex-fxaa3-11-consolepc-inES.txt @@ -0,0 +1,106 @@ +#ifdef GL_ES +#define texture2DLod texture2DLodEXT +#endif +#extension GL_EXT_shader_texture_lod : require +vec4 xll_tex2Dlod(sampler2D s, vec4 coord) { + return texture2DLod( s, coord.xy, coord.w); +} +struct v2f { + highp vec4 pos; + highp vec2 uv; + highp vec4 uvPosPos; +}; +uniform sampler2D _MainTex; +uniform highp vec4 _MainTex_TexelSize; +highp float FxaaLuma( in lowp vec4 rgba ); +lowp vec4 FxaaPixelShader( in highp vec2 pos, in highp vec4 fxaaConsolePosPos, in sampler2D tex, in sampler2D fxaaConsole360TexExpBiasNegOne, in sampler2D fxaaConsole360TexExpBiasNegTwo, in highp vec2 fxaaQualityRcpFrame, in highp vec4 fxaaConsoleRcpFrameOpt, in highp vec4 fxaaConsoleRcpFrameOpt2, in highp vec4 fxaaConsole360RcpFrameOpt2, in highp float fxaaQualitySubpix, in highp float fxaaQualityEdgeThreshold, in highp float fxaaQualityEdgeThresholdMin, in highp float fxaaConsoleEdgeSharpness, in highp float fxaaConsoleEdgeThreshold, in highp float fxaaConsoleEdgeThresholdMin, in highp vec4 fxaaConsole360ConstDir ); +lowp vec4 xlat_main( in v2f i ); +highp float FxaaLuma( in lowp vec4 rgba ) { + return rgba.y ; +} +lowp vec4 FxaaPixelShader( in highp vec2 pos, in highp vec4 fxaaConsolePosPos, in sampler2D tex, in sampler2D fxaaConsole360TexExpBiasNegOne, in sampler2D fxaaConsole360TexExpBiasNegTwo, in highp vec2 fxaaQualityRcpFrame, in highp vec4 fxaaConsoleRcpFrameOpt, in highp vec4 fxaaConsoleRcpFrameOpt2, in highp vec4 fxaaConsole360RcpFrameOpt2, in highp float fxaaQualitySubpix, in highp float fxaaQualityEdgeThreshold, in highp float fxaaQualityEdgeThresholdMin, in highp float fxaaConsoleEdgeSharpness, in highp float fxaaConsoleEdgeThreshold, in highp float fxaaConsoleEdgeThresholdMin, in highp vec4 fxaaConsole360ConstDir ) { + highp float lumaNw; + highp float lumaSw; + highp float lumaNe; + highp float lumaSe; + lowp vec4 rgbyM; + highp float lumaM; + highp float lumaMaxNwSw; + highp float lumaMinNwSw; + highp float lumaMaxNeSe; + highp float lumaMinNeSe; + highp float lumaMax; + highp float lumaMin; + highp float lumaMaxScaled; + highp float lumaMinM; + highp float lumaMaxScaledClamped; + highp float lumaMaxM; + highp float dirSwMinusNe; + highp float lumaMaxSubMinM; + highp float dirSeMinusNw; + highp vec2 dir; + highp vec2 dir1; + lowp vec4 rgbyN1; + lowp vec4 rgbyP1; + highp float dirAbsMinTimesC; + highp vec2 dir2; + lowp vec4 rgbyN2; + lowp vec4 rgbyP2; + lowp vec4 rgbyA; + lowp vec4 rgbyB; + bool twoTap; + lumaNw = FxaaLuma( xll_tex2Dlod( tex, vec4( fxaaConsolePosPos.xy , 0.00000, 0.00000))); + lumaSw = FxaaLuma( xll_tex2Dlod( tex, vec4( fxaaConsolePosPos.xw , 0.00000, 0.00000))); + lumaNe = FxaaLuma( xll_tex2Dlod( tex, vec4( fxaaConsolePosPos.zy , 0.00000, 0.00000))); + lumaSe = FxaaLuma( xll_tex2Dlod( tex, vec4( fxaaConsolePosPos.zw , 0.00000, 0.00000))); + rgbyM = xll_tex2Dlod( tex, vec4( pos.xy , 0.00000, 0.00000)); + lumaM = rgbyM.y ; + lumaMaxNwSw = max( lumaNw, lumaSw); + lumaNe += 0.00260417; + lumaMinNwSw = min( lumaNw, lumaSw); + lumaMaxNeSe = max( lumaNe, lumaSe); + lumaMinNeSe = min( lumaNe, lumaSe); + lumaMax = max( lumaMaxNeSe, lumaMaxNwSw); + lumaMin = min( lumaMinNeSe, lumaMinNwSw); + lumaMaxScaled = (lumaMax * fxaaConsoleEdgeThreshold); + lumaMinM = min( lumaMin, lumaM); + lumaMaxScaledClamped = max( fxaaConsoleEdgeThresholdMin, lumaMaxScaled); + lumaMaxM = max( lumaMax, lumaM); + dirSwMinusNe = (lumaSw - lumaNe); + lumaMaxSubMinM = (lumaMaxM - lumaMinM); + dirSeMinusNw = (lumaSe - lumaNw); + if ( (lumaMaxSubMinM < lumaMaxScaledClamped) ){ + return rgbyM; + } + dir.x = (dirSwMinusNe + dirSeMinusNw); + dir.y = (dirSwMinusNe - dirSeMinusNw); + dir1 = normalize( dir.xy ); + rgbyN1 = xll_tex2Dlod( tex, vec4( (pos.xy - (dir1 * fxaaConsoleRcpFrameOpt.zw )), 0.00000, 0.00000)); + rgbyP1 = xll_tex2Dlod( tex, vec4( (pos.xy + (dir1 * fxaaConsoleRcpFrameOpt.zw )), 0.00000, 0.00000)); + dirAbsMinTimesC = (min( abs( dir1.x ), abs( dir1.y )) * fxaaConsoleEdgeSharpness); + dir2 = clamp( (dir1.xy / dirAbsMinTimesC), vec2( -2.00000), vec2( 2.00000)); + rgbyN2 = xll_tex2Dlod( tex, vec4( (pos.xy - (dir2 * fxaaConsoleRcpFrameOpt2.zw )), 0.00000, 0.00000)); + rgbyP2 = xll_tex2Dlod( tex, vec4( (pos.xy + (dir2 * fxaaConsoleRcpFrameOpt2.zw )), 0.00000, 0.00000)); + rgbyA = (rgbyN1 + rgbyP1); + rgbyB = (((rgbyN2 + rgbyP2) * 0.250000) + (rgbyA * 0.250000)); + twoTap = ((rgbyB.y < lumaMin) || (rgbyB.y > lumaMax)); + if ( twoTap ){ + rgbyB.xyz = (rgbyA.xyz * 0.500000); + } + return rgbyB; +} +lowp vec4 xlat_main( in v2f i ) { + highp float fxaaN = 0.500000; + return FxaaPixelShader( i.uv, i.uvPosPos, _MainTex, _MainTex, _MainTex, _MainTex_TexelSize.xy , (_MainTex_TexelSize.xyxy * vec4( ( -fxaaN ), ( -fxaaN ), fxaaN, fxaaN)), (_MainTex_TexelSize.xyxy * vec4( -2.00000, -2.00000, 2.00000, 2.00000)), (_MainTex_TexelSize.xyxy * vec4( 8.00000, 8.00000, -4.00000, -4.00000)), 0.750000, 0.166000, 0.0833000, 8.00000, 0.125000, 0.0500000, vec4( 1.00000, -1.00000, 0.250000, -0.250000)); +} +varying highp vec2 xlv_TEXCOORD0; +varying highp vec4 xlv_TEXCOORD1; +void main() { + lowp vec4 xl_retval; + v2f xlt_i; + xlt_i.pos = vec4(0.0); + xlt_i.uv = vec2( xlv_TEXCOORD0); + xlt_i.uvPosPos = vec4( xlv_TEXCOORD1); + xl_retval = xlat_main( xlt_i); + gl_FragData[0] = vec4( xl_retval); +} \ No newline at end of file diff --git a/3rdparty/glsl-optimizer/tests/fragment/complex-fxaa3-11-consolepc-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/complex-fxaa3-11-consolepc-ir.txt new file mode 100644 index 000000000..8fd3b4940 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/complex-fxaa3-11-consolepc-ir.txt @@ -0,0 +1,320 @@ +#extension GL_ARB_shader_texture_lod : enable +struct v2f { + vec4 pos; + vec2 uv; + vec4 uvPosPos; +}; +varying vec4 xlv_TEXCOORD1; +varying vec2 xlv_TEXCOORD0; +varying vec4 xlv_SV_POSITION; +uniform vec4 _MainTex_TexelSize; +uniform sampler2D _MainTex; +vec4 xll_tex2Dlod ( + in sampler2D s, + in vec4 coord +) +{ + vec4 tmpvar_1; + tmpvar_1 = texture2DLod (s, coord.xy, coord.w); + return tmpvar_1; +} + +float FxaaLuma ( + in vec4 rgba +) +{ + return rgba.y; +} + +vec4 FxaaPixelShader ( + in vec2 pos, + in vec4 fxaaConsolePosPos, + in sampler2D tex, + in sampler2D fxaaConsole360TexExpBiasNegOne, + in sampler2D fxaaConsole360TexExpBiasNegTwo, + in vec2 fxaaQualityRcpFrame, + in vec4 fxaaConsoleRcpFrameOpt, + in vec4 fxaaConsoleRcpFrameOpt2, + in vec4 fxaaConsole360RcpFrameOpt2, + in float fxaaQualitySubpix, + in float fxaaQualityEdgeThreshold, + in float fxaaQualityEdgeThresholdMin, + in float fxaaConsoleEdgeSharpness, + in float fxaaConsoleEdgeThreshold, + in float fxaaConsoleEdgeThresholdMin, + in vec4 fxaaConsole360ConstDir +) +{ + bool twoTap; + vec4 rgbyB; + vec4 rgbyA; + vec4 rgbyP2; + vec4 rgbyN2; + vec2 dir2; + float dirAbsMinTimesC; + vec4 rgbyP1; + vec4 rgbyN1; + vec2 dir1; + vec2 dir; + float dirSeMinusNw; + float lumaMaxSubMinM; + float dirSwMinusNe; + float lumaMaxM; + float lumaMaxScaledClamped; + float lumaMinM; + float lumaMaxScaled; + float lumaMin; + float lumaMax; + float lumaMinNeSe; + float lumaMaxNeSe; + float lumaMinNwSw; + float lumaMaxNwSw; + float lumaM; + vec4 rgbyM; + float lumaSe; + float lumaNe; + float lumaSw; + float lumaNw; + vec4 tmpvar_1; + tmpvar_1.zw = vec2(0.0, 0.0); + tmpvar_1.xy = fxaaConsolePosPos.xy.xy; + vec4 tmpvar_2; + tmpvar_2 = xll_tex2Dlod (tex, tmpvar_1); + float tmpvar_3; + tmpvar_3 = FxaaLuma (tmpvar_2); + float tmpvar_4; + tmpvar_4 = tmpvar_3; + lumaNw = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5.zw = vec2(0.0, 0.0); + tmpvar_5.xy = fxaaConsolePosPos.xw.xy; + vec4 tmpvar_6; + tmpvar_6 = xll_tex2Dlod (tex, tmpvar_5); + float tmpvar_7; + tmpvar_7 = FxaaLuma (tmpvar_6); + float tmpvar_8; + tmpvar_8 = tmpvar_7; + lumaSw = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9.zw = vec2(0.0, 0.0); + tmpvar_9.xy = fxaaConsolePosPos.zy.xy; + vec4 tmpvar_10; + tmpvar_10 = xll_tex2Dlod (tex, tmpvar_9); + float tmpvar_11; + tmpvar_11 = FxaaLuma (tmpvar_10); + float tmpvar_12; + tmpvar_12 = tmpvar_11; + lumaNe = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13.zw = vec2(0.0, 0.0); + tmpvar_13.xy = fxaaConsolePosPos.zw.xy; + vec4 tmpvar_14; + tmpvar_14 = xll_tex2Dlod (tex, tmpvar_13); + float tmpvar_15; + tmpvar_15 = FxaaLuma (tmpvar_14); + float tmpvar_16; + tmpvar_16 = tmpvar_15; + lumaSe = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.zw = vec2(0.0, 0.0); + tmpvar_17.xy = pos.xy.xy; + vec4 tmpvar_18; + tmpvar_18 = xll_tex2Dlod (tex, tmpvar_17); + vec4 tmpvar_19; + tmpvar_19 = tmpvar_18; + rgbyM = tmpvar_19; + float tmpvar_20; + tmpvar_20 = rgbyM.y; + lumaM = tmpvar_20; + float tmpvar_21; + tmpvar_21 = max (lumaNw, lumaSw); + float tmpvar_22; + tmpvar_22 = tmpvar_21; + lumaMaxNwSw = tmpvar_22; + float tmpvar_23; + tmpvar_23 = (lumaNe + 0.00260417); + lumaNe = tmpvar_23; + float tmpvar_24; + tmpvar_24 = min (lumaNw, lumaSw); + float tmpvar_25; + tmpvar_25 = tmpvar_24; + lumaMinNwSw = tmpvar_25; + float tmpvar_26; + tmpvar_26 = max (lumaNe, lumaSe); + float tmpvar_27; + tmpvar_27 = tmpvar_26; + lumaMaxNeSe = tmpvar_27; + float tmpvar_28; + tmpvar_28 = min (lumaNe, lumaSe); + float tmpvar_29; + tmpvar_29 = tmpvar_28; + lumaMinNeSe = tmpvar_29; + float tmpvar_30; + tmpvar_30 = max (lumaMaxNeSe, lumaMaxNwSw); + float tmpvar_31; + tmpvar_31 = tmpvar_30; + lumaMax = tmpvar_31; + float tmpvar_32; + tmpvar_32 = min (lumaMinNeSe, lumaMinNwSw); + float tmpvar_33; + tmpvar_33 = tmpvar_32; + lumaMin = tmpvar_33; + float tmpvar_34; + tmpvar_34 = (lumaMax * fxaaConsoleEdgeThreshold); + lumaMaxScaled = tmpvar_34; + float tmpvar_35; + tmpvar_35 = min (lumaMin, lumaM); + float tmpvar_36; + tmpvar_36 = tmpvar_35; + lumaMinM = tmpvar_36; + float tmpvar_37; + tmpvar_37 = max (fxaaConsoleEdgeThresholdMin, lumaMaxScaled); + float tmpvar_38; + tmpvar_38 = tmpvar_37; + lumaMaxScaledClamped = tmpvar_38; + float tmpvar_39; + tmpvar_39 = max (lumaMax, lumaM); + float tmpvar_40; + tmpvar_40 = tmpvar_39; + lumaMaxM = tmpvar_40; + float tmpvar_41; + tmpvar_41 = (lumaSw - lumaNe); + dirSwMinusNe = tmpvar_41; + float tmpvar_42; + tmpvar_42 = (lumaMaxM - lumaMinM); + lumaMaxSubMinM = tmpvar_42; + float tmpvar_43; + tmpvar_43 = (lumaSe - lumaNw); + dirSeMinusNw = tmpvar_43; + if ((lumaMaxSubMinM < lumaMaxScaledClamped)) { + return rgbyM; + }; + float tmpvar_44; + tmpvar_44 = (dirSwMinusNe + dirSeMinusNw); + dir.x = tmpvar_44; + float tmpvar_45; + tmpvar_45 = (dirSwMinusNe - dirSeMinusNw); + dir.y = vec2(tmpvar_45).y; + vec2 tmpvar_46; + tmpvar_46 = normalize (dir.xy); + vec2 tmpvar_47; + tmpvar_47 = tmpvar_46; + dir1 = tmpvar_47; + vec4 tmpvar_48; + tmpvar_48.zw = vec2(0.0, 0.0); + tmpvar_48.xy = (pos.xy - (dir1 * fxaaConsoleRcpFrameOpt.zw)).xy; + vec4 tmpvar_49; + tmpvar_49 = xll_tex2Dlod (tex, tmpvar_48); + vec4 tmpvar_50; + tmpvar_50 = tmpvar_49; + rgbyN1 = tmpvar_50; + vec4 tmpvar_51; + tmpvar_51.zw = vec2(0.0, 0.0); + tmpvar_51.xy = (pos.xy + (dir1 * fxaaConsoleRcpFrameOpt.zw)).xy; + vec4 tmpvar_52; + tmpvar_52 = xll_tex2Dlod (tex, tmpvar_51); + vec4 tmpvar_53; + tmpvar_53 = tmpvar_52; + rgbyP1 = tmpvar_53; + float tmpvar_54; + tmpvar_54 = abs (dir1.x); + float tmpvar_55; + tmpvar_55 = abs (dir1.y); + float tmpvar_56; + tmpvar_56 = min (tmpvar_54, tmpvar_55); + float tmpvar_57; + tmpvar_57 = (tmpvar_56 * fxaaConsoleEdgeSharpness); + dirAbsMinTimesC = tmpvar_57; + vec2 tmpvar_58; + tmpvar_58 = clamp ((dir1.xy / dirAbsMinTimesC), vec2(-2.0, -2.0), vec2(2.0, 2.0)); + vec2 tmpvar_59; + tmpvar_59 = tmpvar_58; + dir2 = tmpvar_59; + vec4 tmpvar_60; + tmpvar_60.zw = vec2(0.0, 0.0); + tmpvar_60.xy = (pos.xy - (dir2 * fxaaConsoleRcpFrameOpt2.zw)).xy; + vec4 tmpvar_61; + tmpvar_61 = xll_tex2Dlod (tex, tmpvar_60); + vec4 tmpvar_62; + tmpvar_62 = tmpvar_61; + rgbyN2 = tmpvar_62; + vec4 tmpvar_63; + tmpvar_63.zw = vec2(0.0, 0.0); + tmpvar_63.xy = (pos.xy + (dir2 * fxaaConsoleRcpFrameOpt2.zw)).xy; + vec4 tmpvar_64; + tmpvar_64 = xll_tex2Dlod (tex, tmpvar_63); + vec4 tmpvar_65; + tmpvar_65 = tmpvar_64; + rgbyP2 = tmpvar_65; + vec4 tmpvar_66; + tmpvar_66 = (rgbyN1 + rgbyP1); + rgbyA = tmpvar_66; + vec4 tmpvar_67; + tmpvar_67 = (((rgbyN2 + rgbyP2) * 0.25) + (rgbyA * 0.25)); + rgbyB = tmpvar_67; + bool tmpvar_68; + if ((rgbyB.y < lumaMin)) { + tmpvar_68 = bool(1); + } else { + tmpvar_68 = (rgbyB.y > lumaMax); + }; + bool tmpvar_69; + tmpvar_69 = tmpvar_68; + twoTap = tmpvar_69; + if (twoTap) { + vec3 tmpvar_70; + tmpvar_70 = (rgbyA.xyz * 0.5); + rgbyB.xyz = tmpvar_70.xyz.xyz; + }; + return rgbyB; +} + +vec4 xlat_main ( + in v2f i +) +{ + float fxaaN; + float tmpvar_1; + tmpvar_1 = 0.5; + fxaaN = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2.x = -(fxaaN); + tmpvar_2.y = -(fxaaN); + tmpvar_2.z = fxaaN; + tmpvar_2.w = fxaaN; + vec4 tmpvar_3; + tmpvar_3 = FxaaPixelShader (i.uv, i.uvPosPos, _MainTex, _MainTex, _MainTex, _MainTex_TexelSize.xy, (_MainTex_TexelSize.xyxy * tmpvar_2), (_MainTex_TexelSize.xyxy * vec4(-2.0, -2.0, 2.0, 2.0)), (_MainTex_TexelSize.xyxy * vec4(8.0, 8.0, -4.0, -4.0)), 0.75, 0.166, 0.0833, 8.0, 0.125, 0.05, vec4(1.0, -1.0, 0.25, -0.25)); + return tmpvar_3; +} + +void main () +{ + v2f xlt_i; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = xlv_SV_POSITION.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_i.pos = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = xlv_TEXCOORD0.xy; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_i.uv = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = xlv_TEXCOORD1.xyzw; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_i.uvPosPos = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = xlat_main (xlt_i); + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xl_retval = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = xl_retval.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + gl_FragData[0] = tmpvar_10; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/complex-fxaa3-11-consolepc-irES.txt b/3rdparty/glsl-optimizer/tests/fragment/complex-fxaa3-11-consolepc-irES.txt new file mode 100644 index 000000000..717c960e4 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/complex-fxaa3-11-consolepc-irES.txt @@ -0,0 +1,317 @@ +#extension GL_EXT_shader_texture_lod : enable +struct v2f { + highp vec4 pos; + highp vec2 uv; + highp vec4 uvPosPos; +}; +varying highp vec4 xlv_TEXCOORD1; +varying highp vec2 xlv_TEXCOORD0; +uniform highp vec4 _MainTex_TexelSize; +uniform sampler2D _MainTex; +vec4 xll_tex2Dlod ( + in sampler2D s, + in vec4 coord +) +{ + lowp vec4 tmpvar_1; + tmpvar_1 = texture2DLodEXT (s, coord.xy, coord.w); + return tmpvar_1; +} + +float FxaaLuma ( + in lowp vec4 rgba +) +{ + return rgba.y; +} + +lowp vec4 FxaaPixelShader ( + in highp vec2 pos, + in highp vec4 fxaaConsolePosPos, + in sampler2D tex, + in sampler2D fxaaConsole360TexExpBiasNegOne, + in sampler2D fxaaConsole360TexExpBiasNegTwo, + in highp vec2 fxaaQualityRcpFrame, + in highp vec4 fxaaConsoleRcpFrameOpt, + in highp vec4 fxaaConsoleRcpFrameOpt2, + in highp vec4 fxaaConsole360RcpFrameOpt2, + in highp float fxaaQualitySubpix, + in highp float fxaaQualityEdgeThreshold, + in highp float fxaaQualityEdgeThresholdMin, + in highp float fxaaConsoleEdgeSharpness, + in highp float fxaaConsoleEdgeThreshold, + in highp float fxaaConsoleEdgeThresholdMin, + in highp vec4 fxaaConsole360ConstDir +) +{ + bool twoTap; + lowp vec4 rgbyB; + lowp vec4 rgbyA; + lowp vec4 rgbyP2; + lowp vec4 rgbyN2; + highp vec2 dir2; + highp float dirAbsMinTimesC; + lowp vec4 rgbyP1; + lowp vec4 rgbyN1; + highp vec2 dir1; + highp vec2 dir; + highp float dirSeMinusNw; + highp float lumaMaxSubMinM; + highp float dirSwMinusNe; + highp float lumaMaxM; + highp float lumaMaxScaledClamped; + highp float lumaMinM; + highp float lumaMaxScaled; + highp float lumaMin; + highp float lumaMax; + highp float lumaMinNeSe; + highp float lumaMaxNeSe; + highp float lumaMinNwSw; + highp float lumaMaxNwSw; + highp float lumaM; + lowp vec4 rgbyM; + highp float lumaSe; + highp float lumaNe; + highp float lumaSw; + highp float lumaNw; + highp vec4 tmpvar_1; + tmpvar_1.zw = vec2(0.0, 0.0); + tmpvar_1.xy = fxaaConsolePosPos.xy.xy; + vec4 tmpvar_2; + tmpvar_2 = xll_tex2Dlod (tex, tmpvar_1); + highp float tmpvar_3; + tmpvar_3 = FxaaLuma (tmpvar_2); + highp float tmpvar_4; + tmpvar_4 = tmpvar_3; + lumaNw = tmpvar_4; + highp vec4 tmpvar_5; + tmpvar_5.zw = vec2(0.0, 0.0); + tmpvar_5.xy = fxaaConsolePosPos.xw.xy; + vec4 tmpvar_6; + tmpvar_6 = xll_tex2Dlod (tex, tmpvar_5); + highp float tmpvar_7; + tmpvar_7 = FxaaLuma (tmpvar_6); + highp float tmpvar_8; + tmpvar_8 = tmpvar_7; + lumaSw = tmpvar_8; + highp vec4 tmpvar_9; + tmpvar_9.zw = vec2(0.0, 0.0); + tmpvar_9.xy = fxaaConsolePosPos.zy.xy; + vec4 tmpvar_10; + tmpvar_10 = xll_tex2Dlod (tex, tmpvar_9); + highp float tmpvar_11; + tmpvar_11 = FxaaLuma (tmpvar_10); + highp float tmpvar_12; + tmpvar_12 = tmpvar_11; + lumaNe = tmpvar_12; + highp vec4 tmpvar_13; + tmpvar_13.zw = vec2(0.0, 0.0); + tmpvar_13.xy = fxaaConsolePosPos.zw.xy; + vec4 tmpvar_14; + tmpvar_14 = xll_tex2Dlod (tex, tmpvar_13); + highp float tmpvar_15; + tmpvar_15 = FxaaLuma (tmpvar_14); + highp float tmpvar_16; + tmpvar_16 = tmpvar_15; + lumaSe = tmpvar_16; + highp vec4 tmpvar_17; + tmpvar_17.zw = vec2(0.0, 0.0); + tmpvar_17.xy = pos.xy.xy; + vec4 tmpvar_18; + tmpvar_18 = xll_tex2Dlod (tex, tmpvar_17); + vec4 tmpvar_19; + tmpvar_19 = tmpvar_18; + rgbyM = tmpvar_19; + lowp float tmpvar_20; + tmpvar_20 = rgbyM.y; + lumaM = tmpvar_20; + highp float tmpvar_21; + tmpvar_21 = max (lumaNw, lumaSw); + highp float tmpvar_22; + tmpvar_22 = tmpvar_21; + lumaMaxNwSw = tmpvar_22; + highp float tmpvar_23; + tmpvar_23 = (lumaNe + 0.00260417); + lumaNe = tmpvar_23; + highp float tmpvar_24; + tmpvar_24 = min (lumaNw, lumaSw); + highp float tmpvar_25; + tmpvar_25 = tmpvar_24; + lumaMinNwSw = tmpvar_25; + highp float tmpvar_26; + tmpvar_26 = max (lumaNe, lumaSe); + highp float tmpvar_27; + tmpvar_27 = tmpvar_26; + lumaMaxNeSe = tmpvar_27; + highp float tmpvar_28; + tmpvar_28 = min (lumaNe, lumaSe); + highp float tmpvar_29; + tmpvar_29 = tmpvar_28; + lumaMinNeSe = tmpvar_29; + highp float tmpvar_30; + tmpvar_30 = max (lumaMaxNeSe, lumaMaxNwSw); + highp float tmpvar_31; + tmpvar_31 = tmpvar_30; + lumaMax = tmpvar_31; + highp float tmpvar_32; + tmpvar_32 = min (lumaMinNeSe, lumaMinNwSw); + highp float tmpvar_33; + tmpvar_33 = tmpvar_32; + lumaMin = tmpvar_33; + highp float tmpvar_34; + tmpvar_34 = (lumaMax * fxaaConsoleEdgeThreshold); + lumaMaxScaled = tmpvar_34; + highp float tmpvar_35; + tmpvar_35 = min (lumaMin, lumaM); + highp float tmpvar_36; + tmpvar_36 = tmpvar_35; + lumaMinM = tmpvar_36; + highp float tmpvar_37; + tmpvar_37 = max (fxaaConsoleEdgeThresholdMin, lumaMaxScaled); + highp float tmpvar_38; + tmpvar_38 = tmpvar_37; + lumaMaxScaledClamped = tmpvar_38; + highp float tmpvar_39; + tmpvar_39 = max (lumaMax, lumaM); + highp float tmpvar_40; + tmpvar_40 = tmpvar_39; + lumaMaxM = tmpvar_40; + highp float tmpvar_41; + tmpvar_41 = (lumaSw - lumaNe); + dirSwMinusNe = tmpvar_41; + highp float tmpvar_42; + tmpvar_42 = (lumaMaxM - lumaMinM); + lumaMaxSubMinM = tmpvar_42; + highp float tmpvar_43; + tmpvar_43 = (lumaSe - lumaNw); + dirSeMinusNw = tmpvar_43; + if ((lumaMaxSubMinM < lumaMaxScaledClamped)) { + return rgbyM; + }; + highp float tmpvar_44; + tmpvar_44 = (dirSwMinusNe + dirSeMinusNw); + dir.x = tmpvar_44; + highp float tmpvar_45; + tmpvar_45 = (dirSwMinusNe - dirSeMinusNw); + dir.y = vec2(tmpvar_45).y; + highp vec2 tmpvar_46; + tmpvar_46 = normalize (dir.xy); + highp vec2 tmpvar_47; + tmpvar_47 = tmpvar_46; + dir1 = tmpvar_47; + highp vec4 tmpvar_48; + tmpvar_48.zw = vec2(0.0, 0.0); + tmpvar_48.xy = (pos.xy - (dir1 * fxaaConsoleRcpFrameOpt.zw)).xy; + vec4 tmpvar_49; + tmpvar_49 = xll_tex2Dlod (tex, tmpvar_48); + vec4 tmpvar_50; + tmpvar_50 = tmpvar_49; + rgbyN1 = tmpvar_50; + highp vec4 tmpvar_51; + tmpvar_51.zw = vec2(0.0, 0.0); + tmpvar_51.xy = (pos.xy + (dir1 * fxaaConsoleRcpFrameOpt.zw)).xy; + vec4 tmpvar_52; + tmpvar_52 = xll_tex2Dlod (tex, tmpvar_51); + vec4 tmpvar_53; + tmpvar_53 = tmpvar_52; + rgbyP1 = tmpvar_53; + highp float tmpvar_54; + tmpvar_54 = abs (dir1.x); + highp float tmpvar_55; + tmpvar_55 = abs (dir1.y); + highp float tmpvar_56; + tmpvar_56 = min (tmpvar_54, tmpvar_55); + highp float tmpvar_57; + tmpvar_57 = (tmpvar_56 * fxaaConsoleEdgeSharpness); + dirAbsMinTimesC = tmpvar_57; + highp vec2 tmpvar_58; + tmpvar_58 = clamp ((dir1.xy / dirAbsMinTimesC), vec2(-2.0, -2.0), vec2(2.0, 2.0)); + highp vec2 tmpvar_59; + tmpvar_59 = tmpvar_58; + dir2 = tmpvar_59; + highp vec4 tmpvar_60; + tmpvar_60.zw = vec2(0.0, 0.0); + tmpvar_60.xy = (pos.xy - (dir2 * fxaaConsoleRcpFrameOpt2.zw)).xy; + vec4 tmpvar_61; + tmpvar_61 = xll_tex2Dlod (tex, tmpvar_60); + vec4 tmpvar_62; + tmpvar_62 = tmpvar_61; + rgbyN2 = tmpvar_62; + highp vec4 tmpvar_63; + tmpvar_63.zw = vec2(0.0, 0.0); + tmpvar_63.xy = (pos.xy + (dir2 * fxaaConsoleRcpFrameOpt2.zw)).xy; + vec4 tmpvar_64; + tmpvar_64 = xll_tex2Dlod (tex, tmpvar_63); + vec4 tmpvar_65; + tmpvar_65 = tmpvar_64; + rgbyP2 = tmpvar_65; + lowp vec4 tmpvar_66; + tmpvar_66 = (rgbyN1 + rgbyP1); + rgbyA = tmpvar_66; + lowp vec4 tmpvar_67; + tmpvar_67 = (((rgbyN2 + rgbyP2) * 0.25) + (rgbyA * 0.25)); + rgbyB = tmpvar_67; + bool tmpvar_68; + if ((rgbyB.y < lumaMin)) { + tmpvar_68 = bool(1); + } else { + tmpvar_68 = (rgbyB.y > lumaMax); + }; + bool tmpvar_69; + tmpvar_69 = tmpvar_68; + twoTap = tmpvar_69; + if (twoTap) { + lowp vec3 tmpvar_70; + tmpvar_70 = (rgbyA.xyz * 0.5); + rgbyB.xyz = tmpvar_70.xyz.xyz; + }; + return rgbyB; +} + +lowp vec4 xlat_main ( + in v2f i +) +{ + highp float fxaaN; + float tmpvar_1; + tmpvar_1 = 0.5; + fxaaN = tmpvar_1; + highp vec4 tmpvar_2; + tmpvar_2.x = -(fxaaN); + tmpvar_2.y = -(fxaaN); + tmpvar_2.z = fxaaN; + tmpvar_2.w = fxaaN; + lowp vec4 tmpvar_3; + tmpvar_3 = FxaaPixelShader (i.uv, i.uvPosPos, _MainTex, _MainTex, _MainTex, _MainTex_TexelSize.xy, (_MainTex_TexelSize.xyxy * tmpvar_2), (_MainTex_TexelSize.xyxy * vec4(-2.0, -2.0, 2.0, 2.0)), (_MainTex_TexelSize.xyxy * vec4(8.0, 8.0, -4.0, -4.0)), 0.75, 0.166, 0.0833, 8.0, 0.125, 0.05, vec4(1.0, -1.0, 0.25, -0.25)); + return tmpvar_3; +} + +void main () +{ + v2f xlt_i; + lowp vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_i.pos = tmpvar_1; + highp vec2 tmpvar_2; + tmpvar_2 = xlv_TEXCOORD0.xy; + highp vec2 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_i.uv = tmpvar_3; + highp vec4 tmpvar_4; + tmpvar_4 = xlv_TEXCOORD1.xyzw; + highp vec4 tmpvar_5; + tmpvar_5 = tmpvar_4; + xlt_i.uvPosPos = tmpvar_5; + lowp vec4 tmpvar_6; + tmpvar_6 = xlat_main (xlt_i); + lowp vec4 tmpvar_7; + tmpvar_7 = tmpvar_6; + xl_retval = tmpvar_7; + lowp vec4 tmpvar_8; + tmpvar_8 = xl_retval.xyzw; + lowp vec4 tmpvar_9; + tmpvar_9 = tmpvar_8; + gl_FragData[0] = tmpvar_9; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/complex-fxaa3-11-consolepc-out.txt b/3rdparty/glsl-optimizer/tests/fragment/complex-fxaa3-11-consolepc-out.txt new file mode 100644 index 000000000..be697283f --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/complex-fxaa3-11-consolepc-out.txt @@ -0,0 +1,99 @@ +#extension GL_ARB_shader_texture_lod : enable +varying vec4 xlv_TEXCOORD1; +varying vec2 xlv_TEXCOORD0; +uniform vec4 _MainTex_TexelSize; +uniform sampler2D _MainTex; +void main () +{ + vec4 fxaaConsoleRcpFrameOpt; + fxaaConsoleRcpFrameOpt = (_MainTex_TexelSize.xyxy * vec4(-0.5, -0.5, 0.5, 0.5)); + vec4 fxaaConsoleRcpFrameOpt2; + fxaaConsoleRcpFrameOpt2 = (_MainTex_TexelSize.xyxy * vec4(-2.0, -2.0, 2.0, 2.0)); + vec4 tmpvar_1; + vec4 rgbyB; + vec2 dir; + vec4 tmpvar_2; + tmpvar_2.zw = vec2(0.0, 0.0); + tmpvar_2.xy = xlv_TEXCOORD1.xy; + vec4 tmpvar_3; + tmpvar_3 = texture2DLod (_MainTex, tmpvar_2.xy, 0.0); + float tmpvar_4; + tmpvar_4 = tmpvar_3.y; + vec4 tmpvar_5; + tmpvar_5.zw = vec2(0.0, 0.0); + tmpvar_5.xy = xlv_TEXCOORD1.xw; + vec4 tmpvar_6; + tmpvar_6 = texture2DLod (_MainTex, tmpvar_5.xy, 0.0); + float tmpvar_7; + tmpvar_7 = tmpvar_6.y; + vec4 tmpvar_8; + tmpvar_8.zw = vec2(0.0, 0.0); + tmpvar_8.xy = xlv_TEXCOORD1.zy; + vec4 tmpvar_9; + tmpvar_9.zw = vec2(0.0, 0.0); + tmpvar_9.xy = xlv_TEXCOORD1.zw; + vec4 tmpvar_10; + tmpvar_10 = texture2DLod (_MainTex, tmpvar_9.xy, 0.0); + float tmpvar_11; + tmpvar_11 = tmpvar_10.y; + vec4 tmpvar_12; + tmpvar_12.zw = vec2(0.0, 0.0); + tmpvar_12.xy = xlv_TEXCOORD0; + vec4 tmpvar_13; + tmpvar_13 = texture2DLod (_MainTex, tmpvar_12.xy, 0.0); + float tmpvar_14; + tmpvar_14 = tmpvar_13.y; + float tmpvar_15; + tmpvar_15 = (texture2DLod (_MainTex, tmpvar_8.xy, 0.0).y + 0.00260417); + float tmpvar_16; + tmpvar_16 = max (max (tmpvar_15, tmpvar_11), max (tmpvar_4, tmpvar_7)); + float tmpvar_17; + tmpvar_17 = min (min (tmpvar_15, tmpvar_11), min (tmpvar_4, tmpvar_7)); + float tmpvar_18; + tmpvar_18 = max (0.05, (tmpvar_16 * 0.125)); + float tmpvar_19; + tmpvar_19 = (tmpvar_6.y - tmpvar_15); + float tmpvar_20; + tmpvar_20 = (max (tmpvar_16, tmpvar_14) - min (tmpvar_17, tmpvar_14)); + float tmpvar_21; + tmpvar_21 = (tmpvar_10.y - tmpvar_3.y); + if ((tmpvar_20 < tmpvar_18)) { + tmpvar_1 = tmpvar_13; + } else { + dir.x = (tmpvar_19 + tmpvar_21); + dir.y = (tmpvar_19 - tmpvar_21); + vec2 tmpvar_22; + tmpvar_22 = normalize (dir); + vec4 tmpvar_23; + tmpvar_23.zw = vec2(0.0, 0.0); + tmpvar_23.xy = (xlv_TEXCOORD0 - (tmpvar_22 * fxaaConsoleRcpFrameOpt.zw)); + vec4 tmpvar_24; + tmpvar_24.zw = vec2(0.0, 0.0); + tmpvar_24.xy = (xlv_TEXCOORD0 + (tmpvar_22 * fxaaConsoleRcpFrameOpt.zw)); + vec2 tmpvar_25; + tmpvar_25 = clamp ((tmpvar_22 / (min (abs (tmpvar_22.x), abs (tmpvar_22.y)) * 8.0)), vec2(-2.0, -2.0), vec2(2.0, 2.0)); + vec4 tmpvar_26; + tmpvar_26.zw = vec2(0.0, 0.0); + tmpvar_26.xy = (xlv_TEXCOORD0 - (tmpvar_25 * fxaaConsoleRcpFrameOpt2.zw)); + vec4 tmpvar_27; + tmpvar_27.zw = vec2(0.0, 0.0); + tmpvar_27.xy = (xlv_TEXCOORD0 + (tmpvar_25 * fxaaConsoleRcpFrameOpt2.zw)); + vec4 tmpvar_28; + tmpvar_28 = (texture2DLod (_MainTex, tmpvar_23.xy, 0.0) + texture2DLod (_MainTex, tmpvar_24.xy, 0.0)); + vec4 tmpvar_29; + tmpvar_29 = (((texture2DLod (_MainTex, tmpvar_26.xy, 0.0) + texture2DLod (_MainTex, tmpvar_27.xy, 0.0)) * 0.25) + (tmpvar_28 * 0.25)); + rgbyB = tmpvar_29; + bool tmpvar_30; + if ((tmpvar_29.y < tmpvar_17)) { + tmpvar_30 = bool(1); + } else { + tmpvar_30 = (tmpvar_29.y > tmpvar_16); + }; + if (tmpvar_30) { + rgbyB.xyz = (tmpvar_28.xyz * 0.5); + }; + tmpvar_1 = rgbyB; + }; + gl_FragData[0] = tmpvar_1; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/complex-fxaa3-11-consolepc-outES.txt b/3rdparty/glsl-optimizer/tests/fragment/complex-fxaa3-11-consolepc-outES.txt new file mode 100644 index 000000000..1e4bbd687 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/complex-fxaa3-11-consolepc-outES.txt @@ -0,0 +1,105 @@ +#extension GL_EXT_shader_texture_lod : enable +varying highp vec4 xlv_TEXCOORD1; +varying highp vec2 xlv_TEXCOORD0; +uniform highp vec4 _MainTex_TexelSize; +uniform sampler2D _MainTex; +void main () +{ + highp vec4 fxaaConsoleRcpFrameOpt; + fxaaConsoleRcpFrameOpt = (_MainTex_TexelSize.xyxy * vec4(-0.5, -0.5, 0.5, 0.5)); + highp vec4 fxaaConsoleRcpFrameOpt2; + fxaaConsoleRcpFrameOpt2 = (_MainTex_TexelSize.xyxy * vec4(-2.0, -2.0, 2.0, 2.0)); + lowp vec4 tmpvar_1; + lowp vec4 rgbyB; + highp vec2 dir; + highp float lumaM; + highp vec4 tmpvar_2; + tmpvar_2.zw = vec2(0.0, 0.0); + tmpvar_2.xy = xlv_TEXCOORD1.xy; + lowp vec4 tmpvar_3; + tmpvar_3 = texture2DLodEXT (_MainTex, tmpvar_2.xy, 0.0); + highp float tmpvar_4; + tmpvar_4 = tmpvar_3.y; + highp vec4 tmpvar_5; + tmpvar_5.zw = vec2(0.0, 0.0); + tmpvar_5.xy = xlv_TEXCOORD1.xw; + lowp vec4 tmpvar_6; + tmpvar_6 = texture2DLodEXT (_MainTex, tmpvar_5.xy, 0.0); + highp float tmpvar_7; + tmpvar_7 = tmpvar_6.y; + highp vec4 tmpvar_8; + tmpvar_8.zw = vec2(0.0, 0.0); + tmpvar_8.xy = xlv_TEXCOORD1.zy; + lowp vec4 tmpvar_9; + tmpvar_9 = texture2DLodEXT (_MainTex, tmpvar_8.xy, 0.0); + highp float tmpvar_10; + tmpvar_10 = tmpvar_9.y; + highp vec4 tmpvar_11; + tmpvar_11.zw = vec2(0.0, 0.0); + tmpvar_11.xy = xlv_TEXCOORD1.zw; + lowp vec4 tmpvar_12; + tmpvar_12 = texture2DLodEXT (_MainTex, tmpvar_11.xy, 0.0); + highp float tmpvar_13; + tmpvar_13 = tmpvar_12.y; + highp vec4 tmpvar_14; + tmpvar_14.zw = vec2(0.0, 0.0); + tmpvar_14.xy = xlv_TEXCOORD0; + lowp vec4 tmpvar_15; + tmpvar_15 = texture2DLodEXT (_MainTex, tmpvar_14.xy, 0.0); + lowp float tmpvar_16; + tmpvar_16 = tmpvar_15.y; + lumaM = tmpvar_16; + highp float tmpvar_17; + tmpvar_17 = (tmpvar_10 + 0.00260417); + highp float tmpvar_18; + tmpvar_18 = max (max (tmpvar_17, tmpvar_13), max (tmpvar_4, tmpvar_7)); + highp float tmpvar_19; + tmpvar_19 = min (min (tmpvar_17, tmpvar_13), min (tmpvar_4, tmpvar_7)); + highp float tmpvar_20; + tmpvar_20 = max (0.05, (tmpvar_18 * 0.125)); + highp float tmpvar_21; + tmpvar_21 = (tmpvar_7 - tmpvar_17); + highp float tmpvar_22; + tmpvar_22 = (max (tmpvar_18, lumaM) - min (tmpvar_19, lumaM)); + highp float tmpvar_23; + tmpvar_23 = (tmpvar_13 - tmpvar_4); + if ((tmpvar_22 < tmpvar_20)) { + tmpvar_1 = tmpvar_15; + } else { + dir.x = (tmpvar_21 + tmpvar_23); + dir.y = (tmpvar_21 - tmpvar_23); + highp vec2 tmpvar_24; + tmpvar_24 = normalize (dir); + highp vec4 tmpvar_25; + tmpvar_25.zw = vec2(0.0, 0.0); + tmpvar_25.xy = (xlv_TEXCOORD0 - (tmpvar_24 * fxaaConsoleRcpFrameOpt.zw)); + highp vec4 tmpvar_26; + tmpvar_26.zw = vec2(0.0, 0.0); + tmpvar_26.xy = (xlv_TEXCOORD0 + (tmpvar_24 * fxaaConsoleRcpFrameOpt.zw)); + highp vec2 tmpvar_27; + tmpvar_27 = clamp ((tmpvar_24 / (min (abs (tmpvar_24.x), abs (tmpvar_24.y)) * 8.0)), vec2(-2.0, -2.0), vec2(2.0, 2.0)); + highp vec4 tmpvar_28; + tmpvar_28.zw = vec2(0.0, 0.0); + tmpvar_28.xy = (xlv_TEXCOORD0 - (tmpvar_27 * fxaaConsoleRcpFrameOpt2.zw)); + highp vec4 tmpvar_29; + tmpvar_29.zw = vec2(0.0, 0.0); + tmpvar_29.xy = (xlv_TEXCOORD0 + (tmpvar_27 * fxaaConsoleRcpFrameOpt2.zw)); + lowp vec4 tmpvar_30; + tmpvar_30 = (texture2DLodEXT (_MainTex, tmpvar_25.xy, 0.0) + texture2DLodEXT (_MainTex, tmpvar_26.xy, 0.0)); + lowp vec4 tmpvar_31; + tmpvar_31 = (((texture2DLodEXT (_MainTex, tmpvar_28.xy, 0.0) + texture2DLodEXT (_MainTex, tmpvar_29.xy, 0.0)) * 0.25) + (tmpvar_30 * 0.25)); + rgbyB = tmpvar_31; + bool tmpvar_32; + if ((tmpvar_31.y < tmpvar_19)) { + tmpvar_32 = bool(1); + } else { + tmpvar_32 = (tmpvar_31.y > tmpvar_18); + }; + if (tmpvar_32) { + rgbyB.xyz = (tmpvar_30.xyz * 0.5); + }; + tmpvar_1 = rgbyB; + }; + gl_FragData[0] = tmpvar_1; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/complex-fxaa3-11-pc39-in.txt b/3rdparty/glsl-optimizer/tests/fragment/complex-fxaa3-11-pc39-in.txt new file mode 100644 index 000000000..eef6faa52 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/complex-fxaa3-11-pc39-in.txt @@ -0,0 +1,567 @@ +#ifdef GL_ES +#define texture2DLod texture2DLodEXT +#endif +#extension GL_ARB_shader_texture_lod : require +vec4 xll_tex2Dlod(sampler2D s, vec4 coord) { + return texture2DLod( s, coord.xy, coord.w); +} +float xll_saturate( float x) { + return clamp( x, 0.0, 1.0); +} +vec2 xll_saturate( vec2 x) { + return clamp( x, 0.0, 1.0); +} +vec3 xll_saturate( vec3 x) { + return clamp( x, 0.0, 1.0); +} +vec4 xll_saturate( vec4 x) { + return clamp( x, 0.0, 1.0); +} +mat2 xll_saturate(mat2 m) { + return mat2( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0)); +} +mat3 xll_saturate(mat3 m) { + return mat3( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0), clamp(m[2], 0.0, 1.0)); +} +mat4 xll_saturate(mat4 m) { + return mat4( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0), clamp(m[2], 0.0, 1.0), clamp(m[3], 0.0, 1.0)); +} +struct v2f { + vec4 pos; + vec2 uv; + vec4 uvPosPos; +}; +uniform sampler2D _MainTex; +uniform vec4 _MainTex_TexelSize; +float FxaaLuma( in vec4 rgba ); +vec4 FxaaPixelShader( in vec2 pos, in vec4 fxaaConsolePosPos, in sampler2D tex, in sampler2D fxaaConsole360TexExpBiasNegOne, in sampler2D fxaaConsole360TexExpBiasNegTwo, in vec2 fxaaQualityRcpFrame, in vec4 fxaaConsoleRcpFrameOpt, in vec4 fxaaConsoleRcpFrameOpt2, in vec4 fxaaConsole360RcpFrameOpt2, in float fxaaQualitySubpix, in float fxaaQualityEdgeThreshold, in float fxaaQualityEdgeThresholdMin, in float fxaaConsoleEdgeSharpness, in float fxaaConsoleEdgeThreshold, in float fxaaConsoleEdgeThresholdMin, in vec4 fxaaConsole360ConstDir ); +vec4 xlat_main( in v2f i ); +float FxaaLuma( in vec4 rgba ) { + return rgba.w ; +} +vec4 FxaaPixelShader( in vec2 pos, in vec4 fxaaConsolePosPos, in sampler2D tex, in sampler2D fxaaConsole360TexExpBiasNegOne, in sampler2D fxaaConsole360TexExpBiasNegTwo, in vec2 fxaaQualityRcpFrame, in vec4 fxaaConsoleRcpFrameOpt, in vec4 fxaaConsoleRcpFrameOpt2, in vec4 fxaaConsole360RcpFrameOpt2, in float fxaaQualitySubpix, in float fxaaQualityEdgeThreshold, in float fxaaQualityEdgeThresholdMin, in float fxaaConsoleEdgeSharpness, in float fxaaConsoleEdgeThreshold, in float fxaaConsoleEdgeThresholdMin, in vec4 fxaaConsole360ConstDir ) { + vec2 posM; + vec4 rgbyM; + float lumaS; + float lumaE; + float lumaN; + float lumaW; + float maxSM; + float minSM; + float maxESM; + float minESM; + float maxWN; + float minWN; + float rangeMax; + float rangeMin; + float rangeMaxScaled; + float range; + float rangeMaxClamped; + bool earlyExit; + float lumaNW; + float lumaSE; + float lumaNE; + float lumaSW; + float lumaNS; + float lumaWE; + float subpixRcpRange; + float subpixNSWE; + float edgeHorz1; + float edgeVert1; + float lumaNESE; + float lumaNWNE; + float edgeHorz2; + float edgeVert2; + float lumaNWSW; + float lumaSWSE; + float edgeHorz4; + float edgeVert4; + float edgeHorz3; + float edgeVert3; + float edgeHorz; + float edgeVert; + float subpixNWSWNESE; + float lengthSign; + bool horzSpan; + float subpixA; + float subpixB; + float gradientN; + float gradientS; + float lumaNN; + float lumaSS; + bool pairN; + float gradient; + float subpixC; + vec2 posB; + vec2 offNP; + vec2 posN; + vec2 posP; + float subpixD; + float lumaEndN; + float subpixE; + float lumaEndP; + float gradientScaled; + float lumaMM; + float subpixF; + bool lumaMLTZero; + bool doneN; + bool doneP; + bool doneNP; + float dstN; + float dstP; + bool goodSpanN; + float spanLength; + bool goodSpanP; + float spanLengthRcp; + bool directionN; + float dst; + bool goodSpan; + float subpixG; + float pixelOffset; + float subpixH; + float pixelOffsetGood; + float pixelOffsetSubpix; + posM.x = pos.x ; + posM.y = pos.y ; + rgbyM = xll_tex2Dlod( tex, vec4( posM, 0.00000, 0.00000)); + lumaS = FxaaLuma( xll_tex2Dlod( tex, vec4( (posM + (vec2( 0.00000, 1.00000) * fxaaQualityRcpFrame.xy )), 0.00000, 0.00000))); + lumaE = FxaaLuma( xll_tex2Dlod( tex, vec4( (posM + (vec2( 1.00000, 0.00000) * fxaaQualityRcpFrame.xy )), 0.00000, 0.00000))); + lumaN = FxaaLuma( xll_tex2Dlod( tex, vec4( (posM + (vec2( 0.00000, -1.00000) * fxaaQualityRcpFrame.xy )), 0.00000, 0.00000))); + lumaW = FxaaLuma( xll_tex2Dlod( tex, vec4( (posM + (vec2( -1.00000, 0.00000) * fxaaQualityRcpFrame.xy )), 0.00000, 0.00000))); + maxSM = max( lumaS, rgbyM.w ); + minSM = min( lumaS, rgbyM.w ); + maxESM = max( lumaE, maxSM); + minESM = min( lumaE, minSM); + maxWN = max( lumaN, lumaW); + minWN = min( lumaN, lumaW); + rangeMax = max( maxWN, maxESM); + rangeMin = min( minWN, minESM); + rangeMaxScaled = (rangeMax * fxaaQualityEdgeThreshold); + range = (rangeMax - rangeMin); + rangeMaxClamped = max( fxaaQualityEdgeThresholdMin, rangeMaxScaled); + earlyExit = (range < rangeMaxClamped); + if ( earlyExit ){ + return rgbyM; + } + lumaNW = FxaaLuma( xll_tex2Dlod( tex, vec4( (posM + (vec2( -1.00000, -1.00000) * fxaaQualityRcpFrame.xy )), 0.00000, 0.00000))); + lumaSE = FxaaLuma( xll_tex2Dlod( tex, vec4( (posM + (vec2( 1.00000, 1.00000) * fxaaQualityRcpFrame.xy )), 0.00000, 0.00000))); + lumaNE = FxaaLuma( xll_tex2Dlod( tex, vec4( (posM + (vec2( 1.00000, -1.00000) * fxaaQualityRcpFrame.xy )), 0.00000, 0.00000))); + lumaSW = FxaaLuma( xll_tex2Dlod( tex, vec4( (posM + (vec2( -1.00000, 1.00000) * fxaaQualityRcpFrame.xy )), 0.00000, 0.00000))); + lumaNS = (lumaN + lumaS); + lumaWE = (lumaW + lumaE); + subpixRcpRange = (1.00000 / range); + subpixNSWE = (lumaNS + lumaWE); + edgeHorz1 = ((-2.00000 * rgbyM.w ) + lumaNS); + edgeVert1 = ((-2.00000 * rgbyM.w ) + lumaWE); + lumaNESE = (lumaNE + lumaSE); + lumaNWNE = (lumaNW + lumaNE); + edgeHorz2 = ((-2.00000 * lumaE) + lumaNESE); + edgeVert2 = ((-2.00000 * lumaN) + lumaNWNE); + lumaNWSW = (lumaNW + lumaSW); + lumaSWSE = (lumaSW + lumaSE); + edgeHorz4 = ((abs( edgeHorz1 ) * 2.00000) + abs( edgeHorz2 )); + edgeVert4 = ((abs( edgeVert1 ) * 2.00000) + abs( edgeVert2 )); + edgeHorz3 = ((-2.00000 * lumaW) + lumaNWSW); + edgeVert3 = ((-2.00000 * lumaS) + lumaSWSE); + edgeHorz = (abs( edgeHorz3 ) + edgeHorz4); + edgeVert = (abs( edgeVert3 ) + edgeVert4); + subpixNWSWNESE = (lumaNWSW + lumaNESE); + lengthSign = fxaaQualityRcpFrame.x ; + horzSpan = (edgeHorz >= edgeVert); + subpixA = ((subpixNSWE * 2.00000) + subpixNWSWNESE); + if ( ( !horzSpan ) ){ + lumaN = lumaW; + } + if ( ( !horzSpan ) ){ + lumaS = lumaE; + } + if ( horzSpan ){ + lengthSign = fxaaQualityRcpFrame.y ; + } + subpixB = ((subpixA * 0.0833333) - rgbyM.w ); + gradientN = (lumaN - rgbyM.w ); + gradientS = (lumaS - rgbyM.w ); + lumaNN = (lumaN + rgbyM.w ); + lumaSS = (lumaS + rgbyM.w ); + pairN = (abs( gradientN ) >= abs( gradientS )); + gradient = max( abs( gradientN ), abs( gradientS )); + if ( pairN ){ + lengthSign = ( -lengthSign ); + } + subpixC = xll_saturate( (abs( subpixB ) * subpixRcpRange) ); + posB.x = posM.x ; + posB.y = posM.y ; + offNP.x = (( ( !horzSpan ) ) ? ( 0.00000 ) : ( fxaaQualityRcpFrame.x )); + offNP.y = (( horzSpan ) ? ( 0.00000 ) : ( fxaaQualityRcpFrame.y )); + if ( ( !horzSpan ) ){ + posB.x += (lengthSign * 0.500000); + } + if ( horzSpan ){ + posB.y += (lengthSign * 0.500000); + } + posN.x = (posB.x - (offNP.x * 1.00000)); + posN.y = (posB.y - (offNP.y * 1.00000)); + posP.x = (posB.x + (offNP.x * 1.00000)); + posP.y = (posB.y + (offNP.y * 1.00000)); + subpixD = ((-2.00000 * subpixC) + 3.00000); + lumaEndN = FxaaLuma( xll_tex2Dlod( tex, vec4( posN, 0.00000, 0.00000))); + subpixE = (subpixC * subpixC); + lumaEndP = FxaaLuma( xll_tex2Dlod( tex, vec4( posP, 0.00000, 0.00000))); + if ( ( !pairN ) ){ + lumaNN = lumaSS; + } + gradientScaled = ((gradient * 1.00000) / 4.00000); + lumaMM = (rgbyM.w - (lumaNN * 0.500000)); + subpixF = (subpixD * subpixE); + lumaMLTZero = (lumaMM < 0.00000); + lumaEndN -= (lumaNN * 0.500000); + lumaEndP -= (lumaNN * 0.500000); + doneN = (abs( lumaEndN ) >= gradientScaled); + doneP = (abs( lumaEndP ) >= gradientScaled); + if ( ( !doneN ) ){ + posN.x -= (offNP.x * 1.00000); + } + if ( ( !doneN ) ){ + posN.y -= (offNP.y * 1.00000); + } + doneNP = (( !doneN ) || ( !doneP )); + if ( ( !doneP ) ){ + posP.x += (offNP.x * 1.00000); + } + if ( ( !doneP ) ){ + posP.y += (offNP.y * 1.00000); + } + if ( doneNP ){ + if ( ( !doneN ) ){ + lumaEndN = FxaaLuma( xll_tex2Dlod( tex, vec4( posN.xy , 0.00000, 0.00000))); + } + if ( ( !doneP ) ){ + lumaEndP = FxaaLuma( xll_tex2Dlod( tex, vec4( posP.xy , 0.00000, 0.00000))); + } + if ( ( !doneN ) ){ + lumaEndN = (lumaEndN - (lumaNN * 0.500000)); + } + if ( ( !doneP ) ){ + lumaEndP = (lumaEndP - (lumaNN * 0.500000)); + } + doneN = (abs( lumaEndN ) >= gradientScaled); + doneP = (abs( lumaEndP ) >= gradientScaled); + if ( ( !doneN ) ){ + posN.x -= (offNP.x * 1.00000); + } + if ( ( !doneN ) ){ + posN.y -= (offNP.y * 1.00000); + } + doneNP = (( !doneN ) || ( !doneP )); + if ( ( !doneP ) ){ + posP.x += (offNP.x * 1.00000); + } + if ( ( !doneP ) ){ + posP.y += (offNP.y * 1.00000); + } + if ( doneNP ){ + if ( ( !doneN ) ){ + lumaEndN = FxaaLuma( xll_tex2Dlod( tex, vec4( posN.xy , 0.00000, 0.00000))); + } + if ( ( !doneP ) ){ + lumaEndP = FxaaLuma( xll_tex2Dlod( tex, vec4( posP.xy , 0.00000, 0.00000))); + } + if ( ( !doneN ) ){ + lumaEndN = (lumaEndN - (lumaNN * 0.500000)); + } + if ( ( !doneP ) ){ + lumaEndP = (lumaEndP - (lumaNN * 0.500000)); + } + doneN = (abs( lumaEndN ) >= gradientScaled); + doneP = (abs( lumaEndP ) >= gradientScaled); + if ( ( !doneN ) ){ + posN.x -= (offNP.x * 1.00000); + } + if ( ( !doneN ) ){ + posN.y -= (offNP.y * 1.00000); + } + doneNP = (( !doneN ) || ( !doneP )); + if ( ( !doneP ) ){ + posP.x += (offNP.x * 1.00000); + } + if ( ( !doneP ) ){ + posP.y += (offNP.y * 1.00000); + } + if ( doneNP ){ + if ( ( !doneN ) ){ + lumaEndN = FxaaLuma( xll_tex2Dlod( tex, vec4( posN.xy , 0.00000, 0.00000))); + } + if ( ( !doneP ) ){ + lumaEndP = FxaaLuma( xll_tex2Dlod( tex, vec4( posP.xy , 0.00000, 0.00000))); + } + if ( ( !doneN ) ){ + lumaEndN = (lumaEndN - (lumaNN * 0.500000)); + } + if ( ( !doneP ) ){ + lumaEndP = (lumaEndP - (lumaNN * 0.500000)); + } + doneN = (abs( lumaEndN ) >= gradientScaled); + doneP = (abs( lumaEndP ) >= gradientScaled); + if ( ( !doneN ) ){ + posN.x -= (offNP.x * 1.00000); + } + if ( ( !doneN ) ){ + posN.y -= (offNP.y * 1.00000); + } + doneNP = (( !doneN ) || ( !doneP )); + if ( ( !doneP ) ){ + posP.x += (offNP.x * 1.00000); + } + if ( ( !doneP ) ){ + posP.y += (offNP.y * 1.00000); + } + if ( doneNP ){ + if ( ( !doneN ) ){ + lumaEndN = FxaaLuma( xll_tex2Dlod( tex, vec4( posN.xy , 0.00000, 0.00000))); + } + if ( ( !doneP ) ){ + lumaEndP = FxaaLuma( xll_tex2Dlod( tex, vec4( posP.xy , 0.00000, 0.00000))); + } + if ( ( !doneN ) ){ + lumaEndN = (lumaEndN - (lumaNN * 0.500000)); + } + if ( ( !doneP ) ){ + lumaEndP = (lumaEndP - (lumaNN * 0.500000)); + } + doneN = (abs( lumaEndN ) >= gradientScaled); + doneP = (abs( lumaEndP ) >= gradientScaled); + if ( ( !doneN ) ){ + posN.x -= (offNP.x * 1.50000); + } + if ( ( !doneN ) ){ + posN.y -= (offNP.y * 1.50000); + } + doneNP = (( !doneN ) || ( !doneP )); + if ( ( !doneP ) ){ + posP.x += (offNP.x * 1.50000); + } + if ( ( !doneP ) ){ + posP.y += (offNP.y * 1.50000); + } + if ( doneNP ){ + if ( ( !doneN ) ){ + lumaEndN = FxaaLuma( xll_tex2Dlod( tex, vec4( posN.xy , 0.00000, 0.00000))); + } + if ( ( !doneP ) ){ + lumaEndP = FxaaLuma( xll_tex2Dlod( tex, vec4( posP.xy , 0.00000, 0.00000))); + } + if ( ( !doneN ) ){ + lumaEndN = (lumaEndN - (lumaNN * 0.500000)); + } + if ( ( !doneP ) ){ + lumaEndP = (lumaEndP - (lumaNN * 0.500000)); + } + doneN = (abs( lumaEndN ) >= gradientScaled); + doneP = (abs( lumaEndP ) >= gradientScaled); + if ( ( !doneN ) ){ + posN.x -= (offNP.x * 2.00000); + } + if ( ( !doneN ) ){ + posN.y -= (offNP.y * 2.00000); + } + doneNP = (( !doneN ) || ( !doneP )); + if ( ( !doneP ) ){ + posP.x += (offNP.x * 2.00000); + } + if ( ( !doneP ) ){ + posP.y += (offNP.y * 2.00000); + } + if ( doneNP ){ + if ( ( !doneN ) ){ + lumaEndN = FxaaLuma( xll_tex2Dlod( tex, vec4( posN.xy , 0.00000, 0.00000))); + } + if ( ( !doneP ) ){ + lumaEndP = FxaaLuma( xll_tex2Dlod( tex, vec4( posP.xy , 0.00000, 0.00000))); + } + if ( ( !doneN ) ){ + lumaEndN = (lumaEndN - (lumaNN * 0.500000)); + } + if ( ( !doneP ) ){ + lumaEndP = (lumaEndP - (lumaNN * 0.500000)); + } + doneN = (abs( lumaEndN ) >= gradientScaled); + doneP = (abs( lumaEndP ) >= gradientScaled); + if ( ( !doneN ) ){ + posN.x -= (offNP.x * 2.00000); + } + if ( ( !doneN ) ){ + posN.y -= (offNP.y * 2.00000); + } + doneNP = (( !doneN ) || ( !doneP )); + if ( ( !doneP ) ){ + posP.x += (offNP.x * 2.00000); + } + if ( ( !doneP ) ){ + posP.y += (offNP.y * 2.00000); + } + if ( doneNP ){ + if ( ( !doneN ) ){ + lumaEndN = FxaaLuma( xll_tex2Dlod( tex, vec4( posN.xy , 0.00000, 0.00000))); + } + if ( ( !doneP ) ){ + lumaEndP = FxaaLuma( xll_tex2Dlod( tex, vec4( posP.xy , 0.00000, 0.00000))); + } + if ( ( !doneN ) ){ + lumaEndN = (lumaEndN - (lumaNN * 0.500000)); + } + if ( ( !doneP ) ){ + lumaEndP = (lumaEndP - (lumaNN * 0.500000)); + } + doneN = (abs( lumaEndN ) >= gradientScaled); + doneP = (abs( lumaEndP ) >= gradientScaled); + if ( ( !doneN ) ){ + posN.x -= (offNP.x * 2.00000); + } + if ( ( !doneN ) ){ + posN.y -= (offNP.y * 2.00000); + } + doneNP = (( !doneN ) || ( !doneP )); + if ( ( !doneP ) ){ + posP.x += (offNP.x * 2.00000); + } + if ( ( !doneP ) ){ + posP.y += (offNP.y * 2.00000); + } + if ( doneNP ){ + if ( ( !doneN ) ){ + lumaEndN = FxaaLuma( xll_tex2Dlod( tex, vec4( posN.xy , 0.00000, 0.00000))); + } + if ( ( !doneP ) ){ + lumaEndP = FxaaLuma( xll_tex2Dlod( tex, vec4( posP.xy , 0.00000, 0.00000))); + } + if ( ( !doneN ) ){ + lumaEndN = (lumaEndN - (lumaNN * 0.500000)); + } + if ( ( !doneP ) ){ + lumaEndP = (lumaEndP - (lumaNN * 0.500000)); + } + doneN = (abs( lumaEndN ) >= gradientScaled); + doneP = (abs( lumaEndP ) >= gradientScaled); + if ( ( !doneN ) ){ + posN.x -= (offNP.x * 2.00000); + } + if ( ( !doneN ) ){ + posN.y -= (offNP.y * 2.00000); + } + doneNP = (( !doneN ) || ( !doneP )); + if ( ( !doneP ) ){ + posP.x += (offNP.x * 2.00000); + } + if ( ( !doneP ) ){ + posP.y += (offNP.y * 2.00000); + } + if ( doneNP ){ + if ( ( !doneN ) ){ + lumaEndN = FxaaLuma( xll_tex2Dlod( tex, vec4( posN.xy , 0.00000, 0.00000))); + } + if ( ( !doneP ) ){ + lumaEndP = FxaaLuma( xll_tex2Dlod( tex, vec4( posP.xy , 0.00000, 0.00000))); + } + if ( ( !doneN ) ){ + lumaEndN = (lumaEndN - (lumaNN * 0.500000)); + } + if ( ( !doneP ) ){ + lumaEndP = (lumaEndP - (lumaNN * 0.500000)); + } + doneN = (abs( lumaEndN ) >= gradientScaled); + doneP = (abs( lumaEndP ) >= gradientScaled); + if ( ( !doneN ) ){ + posN.x -= (offNP.x * 4.00000); + } + if ( ( !doneN ) ){ + posN.y -= (offNP.y * 4.00000); + } + doneNP = (( !doneN ) || ( !doneP )); + if ( ( !doneP ) ){ + posP.x += (offNP.x * 4.00000); + } + if ( ( !doneP ) ){ + posP.y += (offNP.y * 4.00000); + } + if ( doneNP ){ + if ( ( !doneN ) ){ + lumaEndN = FxaaLuma( xll_tex2Dlod( tex, vec4( posN.xy , 0.00000, 0.00000))); + } + if ( ( !doneP ) ){ + lumaEndP = FxaaLuma( xll_tex2Dlod( tex, vec4( posP.xy , 0.00000, 0.00000))); + } + if ( ( !doneN ) ){ + lumaEndN = (lumaEndN - (lumaNN * 0.500000)); + } + if ( ( !doneP ) ){ + lumaEndP = (lumaEndP - (lumaNN * 0.500000)); + } + doneN = (abs( lumaEndN ) >= gradientScaled); + doneP = (abs( lumaEndP ) >= gradientScaled); + if ( ( !doneN ) ){ + posN.x -= (offNP.x * 8.00000); + } + if ( ( !doneN ) ){ + posN.y -= (offNP.y * 8.00000); + } + doneNP = (( !doneN ) || ( !doneP )); + if ( ( !doneP ) ){ + posP.x += (offNP.x * 8.00000); + } + if ( ( !doneP ) ){ + posP.y += (offNP.y * 8.00000); + } + } + } + } + } + } + } + } + } + } + } + dstN = (posM.x - posN.x ); + dstP = (posP.x - posM.x ); + if ( ( !horzSpan ) ){ + dstN = (posM.y - posN.y ); + } + if ( ( !horzSpan ) ){ + dstP = (posP.y - posM.y ); + } + goodSpanN = ((lumaEndN < 0.00000) != lumaMLTZero); + spanLength = (dstP + dstN); + goodSpanP = ((lumaEndP < 0.00000) != lumaMLTZero); + spanLengthRcp = (1.00000 / spanLength); + directionN = (dstN < dstP); + dst = min( dstN, dstP); + goodSpan = (( directionN ) ? ( goodSpanN ) : ( goodSpanP )); + subpixG = (subpixF * subpixF); + pixelOffset = ((dst * ( -spanLengthRcp )) + 0.500000); + subpixH = (subpixG * fxaaQualitySubpix); + pixelOffsetGood = (( goodSpan ) ? ( pixelOffset ) : ( 0.00000 )); + pixelOffsetSubpix = max( pixelOffsetGood, subpixH); + if ( ( !horzSpan ) ){ + posM.x += (pixelOffsetSubpix * lengthSign); + } + if ( horzSpan ){ + posM.y += (pixelOffsetSubpix * lengthSign); + } + return vec4( xll_tex2Dlod( tex, vec4( posM, 0.00000, 0.00000)).xyz , rgbyM.w ); +} +vec4 xlat_main( in v2f i ) { + float fxaaN = 0.500000; + return FxaaPixelShader( i.uv, i.uvPosPos, _MainTex, _MainTex, _MainTex, _MainTex_TexelSize.xy , (_MainTex_TexelSize.xyxy * vec4( ( -fxaaN ), ( -fxaaN ), fxaaN, fxaaN)), (_MainTex_TexelSize.xyxy * vec4( -2.00000, -2.00000, 2.00000, 2.00000)), (_MainTex_TexelSize.xyxy * vec4( 8.00000, 8.00000, -4.00000, -4.00000)), 0.750000, 0.166000, 0.0833000, 8.00000, 0.125000, 0.0500000, vec4( 1.00000, -1.00000, 0.250000, -0.250000)); +} +varying vec4 xlv_SV_POSITION; +varying vec2 xlv_TEXCOORD0; +varying vec4 xlv_TEXCOORD1; +void main() { + vec4 xl_retval; + v2f xlt_i; + xlt_i.pos = vec4( xlv_SV_POSITION); + xlt_i.uv = vec2( xlv_TEXCOORD0); + xlt_i.uvPosPos = vec4( xlv_TEXCOORD1); + xl_retval = xlat_main( xlt_i); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/complex-fxaa3-11-pc39-inES.txt b/3rdparty/glsl-optimizer/tests/fragment/complex-fxaa3-11-pc39-inES.txt new file mode 100644 index 000000000..bade4bfc7 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/complex-fxaa3-11-pc39-inES.txt @@ -0,0 +1,567 @@ +#ifdef GL_ES +#define texture2DLod texture2DLodEXT +#endif +#extension GL_EXT_shader_texture_lod : require +vec4 xll_tex2Dlod(sampler2D s, vec4 coord) { + return texture2DLod( s, coord.xy, coord.w); +} +float xll_saturate( float x) { + return clamp( x, 0.0, 1.0); +} +vec2 xll_saturate( vec2 x) { + return clamp( x, 0.0, 1.0); +} +vec3 xll_saturate( vec3 x) { + return clamp( x, 0.0, 1.0); +} +vec4 xll_saturate( vec4 x) { + return clamp( x, 0.0, 1.0); +} +mat2 xll_saturate(mat2 m) { + return mat2( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0)); +} +mat3 xll_saturate(mat3 m) { + return mat3( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0), clamp(m[2], 0.0, 1.0)); +} +mat4 xll_saturate(mat4 m) { + return mat4( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0), clamp(m[2], 0.0, 1.0), clamp(m[3], 0.0, 1.0)); +} +struct v2f { + highp vec4 pos; + highp vec2 uv; + highp vec4 uvPosPos; +}; +uniform sampler2D _MainTex; +uniform highp vec4 _MainTex_TexelSize; +highp float FxaaLuma( in highp vec4 rgba ); +highp vec4 FxaaPixelShader( in highp vec2 pos, in highp vec4 fxaaConsolePosPos, in sampler2D tex, in sampler2D fxaaConsole360TexExpBiasNegOne, in sampler2D fxaaConsole360TexExpBiasNegTwo, in highp vec2 fxaaQualityRcpFrame, in highp vec4 fxaaConsoleRcpFrameOpt, in highp vec4 fxaaConsoleRcpFrameOpt2, in highp vec4 fxaaConsole360RcpFrameOpt2, in highp float fxaaQualitySubpix, in highp float fxaaQualityEdgeThreshold, in highp float fxaaQualityEdgeThresholdMin, in highp float fxaaConsoleEdgeSharpness, in highp float fxaaConsoleEdgeThreshold, in highp float fxaaConsoleEdgeThresholdMin, in highp vec4 fxaaConsole360ConstDir ); +highp vec4 xlat_main( in v2f i ); +highp float FxaaLuma( in highp vec4 rgba ) { + return rgba.w ; +} +highp vec4 FxaaPixelShader( in highp vec2 pos, in highp vec4 fxaaConsolePosPos, in sampler2D tex, in sampler2D fxaaConsole360TexExpBiasNegOne, in sampler2D fxaaConsole360TexExpBiasNegTwo, in highp vec2 fxaaQualityRcpFrame, in highp vec4 fxaaConsoleRcpFrameOpt, in highp vec4 fxaaConsoleRcpFrameOpt2, in highp vec4 fxaaConsole360RcpFrameOpt2, in highp float fxaaQualitySubpix, in highp float fxaaQualityEdgeThreshold, in highp float fxaaQualityEdgeThresholdMin, in highp float fxaaConsoleEdgeSharpness, in highp float fxaaConsoleEdgeThreshold, in highp float fxaaConsoleEdgeThresholdMin, in highp vec4 fxaaConsole360ConstDir ) { + highp vec2 posM; + highp vec4 rgbyM; + highp float lumaS; + highp float lumaE; + highp float lumaN; + highp float lumaW; + highp float maxSM; + highp float minSM; + highp float maxESM; + highp float minESM; + highp float maxWN; + highp float minWN; + highp float rangeMax; + highp float rangeMin; + highp float rangeMaxScaled; + highp float range; + highp float rangeMaxClamped; + bool earlyExit; + highp float lumaNW; + highp float lumaSE; + highp float lumaNE; + highp float lumaSW; + highp float lumaNS; + highp float lumaWE; + highp float subpixRcpRange; + highp float subpixNSWE; + highp float edgeHorz1; + highp float edgeVert1; + highp float lumaNESE; + highp float lumaNWNE; + highp float edgeHorz2; + highp float edgeVert2; + highp float lumaNWSW; + highp float lumaSWSE; + highp float edgeHorz4; + highp float edgeVert4; + highp float edgeHorz3; + highp float edgeVert3; + highp float edgeHorz; + highp float edgeVert; + highp float subpixNWSWNESE; + highp float lengthSign; + bool horzSpan; + highp float subpixA; + highp float subpixB; + highp float gradientN; + highp float gradientS; + highp float lumaNN; + highp float lumaSS; + bool pairN; + highp float gradient; + highp float subpixC; + highp vec2 posB; + highp vec2 offNP; + highp vec2 posN; + highp vec2 posP; + highp float subpixD; + highp float lumaEndN; + highp float subpixE; + highp float lumaEndP; + highp float gradientScaled; + highp float lumaMM; + highp float subpixF; + bool lumaMLTZero; + bool doneN; + bool doneP; + bool doneNP; + highp float dstN; + highp float dstP; + bool goodSpanN; + highp float spanLength; + bool goodSpanP; + highp float spanLengthRcp; + bool directionN; + highp float dst; + bool goodSpan; + highp float subpixG; + highp float pixelOffset; + highp float subpixH; + highp float pixelOffsetGood; + highp float pixelOffsetSubpix; + posM.x = pos.x ; + posM.y = pos.y ; + rgbyM = xll_tex2Dlod( tex, vec4( posM, 0.00000, 0.00000)); + lumaS = FxaaLuma( xll_tex2Dlod( tex, vec4( (posM + (vec2( 0.00000, 1.00000) * fxaaQualityRcpFrame.xy )), 0.00000, 0.00000))); + lumaE = FxaaLuma( xll_tex2Dlod( tex, vec4( (posM + (vec2( 1.00000, 0.00000) * fxaaQualityRcpFrame.xy )), 0.00000, 0.00000))); + lumaN = FxaaLuma( xll_tex2Dlod( tex, vec4( (posM + (vec2( 0.00000, -1.00000) * fxaaQualityRcpFrame.xy )), 0.00000, 0.00000))); + lumaW = FxaaLuma( xll_tex2Dlod( tex, vec4( (posM + (vec2( -1.00000, 0.00000) * fxaaQualityRcpFrame.xy )), 0.00000, 0.00000))); + maxSM = max( lumaS, rgbyM.w ); + minSM = min( lumaS, rgbyM.w ); + maxESM = max( lumaE, maxSM); + minESM = min( lumaE, minSM); + maxWN = max( lumaN, lumaW); + minWN = min( lumaN, lumaW); + rangeMax = max( maxWN, maxESM); + rangeMin = min( minWN, minESM); + rangeMaxScaled = (rangeMax * fxaaQualityEdgeThreshold); + range = (rangeMax - rangeMin); + rangeMaxClamped = max( fxaaQualityEdgeThresholdMin, rangeMaxScaled); + earlyExit = (range < rangeMaxClamped); + if ( earlyExit ){ + return rgbyM; + } + lumaNW = FxaaLuma( xll_tex2Dlod( tex, vec4( (posM + (vec2( -1.00000, -1.00000) * fxaaQualityRcpFrame.xy )), 0.00000, 0.00000))); + lumaSE = FxaaLuma( xll_tex2Dlod( tex, vec4( (posM + (vec2( 1.00000, 1.00000) * fxaaQualityRcpFrame.xy )), 0.00000, 0.00000))); + lumaNE = FxaaLuma( xll_tex2Dlod( tex, vec4( (posM + (vec2( 1.00000, -1.00000) * fxaaQualityRcpFrame.xy )), 0.00000, 0.00000))); + lumaSW = FxaaLuma( xll_tex2Dlod( tex, vec4( (posM + (vec2( -1.00000, 1.00000) * fxaaQualityRcpFrame.xy )), 0.00000, 0.00000))); + lumaNS = (lumaN + lumaS); + lumaWE = (lumaW + lumaE); + subpixRcpRange = (1.00000 / range); + subpixNSWE = (lumaNS + lumaWE); + edgeHorz1 = ((-2.00000 * rgbyM.w ) + lumaNS); + edgeVert1 = ((-2.00000 * rgbyM.w ) + lumaWE); + lumaNESE = (lumaNE + lumaSE); + lumaNWNE = (lumaNW + lumaNE); + edgeHorz2 = ((-2.00000 * lumaE) + lumaNESE); + edgeVert2 = ((-2.00000 * lumaN) + lumaNWNE); + lumaNWSW = (lumaNW + lumaSW); + lumaSWSE = (lumaSW + lumaSE); + edgeHorz4 = ((abs( edgeHorz1 ) * 2.00000) + abs( edgeHorz2 )); + edgeVert4 = ((abs( edgeVert1 ) * 2.00000) + abs( edgeVert2 )); + edgeHorz3 = ((-2.00000 * lumaW) + lumaNWSW); + edgeVert3 = ((-2.00000 * lumaS) + lumaSWSE); + edgeHorz = (abs( edgeHorz3 ) + edgeHorz4); + edgeVert = (abs( edgeVert3 ) + edgeVert4); + subpixNWSWNESE = (lumaNWSW + lumaNESE); + lengthSign = fxaaQualityRcpFrame.x ; + horzSpan = (edgeHorz >= edgeVert); + subpixA = ((subpixNSWE * 2.00000) + subpixNWSWNESE); + if ( ( !horzSpan ) ){ + lumaN = lumaW; + } + if ( ( !horzSpan ) ){ + lumaS = lumaE; + } + if ( horzSpan ){ + lengthSign = fxaaQualityRcpFrame.y ; + } + subpixB = ((subpixA * 0.0833333) - rgbyM.w ); + gradientN = (lumaN - rgbyM.w ); + gradientS = (lumaS - rgbyM.w ); + lumaNN = (lumaN + rgbyM.w ); + lumaSS = (lumaS + rgbyM.w ); + pairN = (abs( gradientN ) >= abs( gradientS )); + gradient = max( abs( gradientN ), abs( gradientS )); + if ( pairN ){ + lengthSign = ( -lengthSign ); + } + subpixC = xll_saturate( (abs( subpixB ) * subpixRcpRange) ); + posB.x = posM.x ; + posB.y = posM.y ; + offNP.x = (( ( !horzSpan ) ) ? ( 0.00000 ) : ( fxaaQualityRcpFrame.x )); + offNP.y = (( horzSpan ) ? ( 0.00000 ) : ( fxaaQualityRcpFrame.y )); + if ( ( !horzSpan ) ){ + posB.x += (lengthSign * 0.500000); + } + if ( horzSpan ){ + posB.y += (lengthSign * 0.500000); + } + posN.x = (posB.x - (offNP.x * 1.00000)); + posN.y = (posB.y - (offNP.y * 1.00000)); + posP.x = (posB.x + (offNP.x * 1.00000)); + posP.y = (posB.y + (offNP.y * 1.00000)); + subpixD = ((-2.00000 * subpixC) + 3.00000); + lumaEndN = FxaaLuma( xll_tex2Dlod( tex, vec4( posN, 0.00000, 0.00000))); + subpixE = (subpixC * subpixC); + lumaEndP = FxaaLuma( xll_tex2Dlod( tex, vec4( posP, 0.00000, 0.00000))); + if ( ( !pairN ) ){ + lumaNN = lumaSS; + } + gradientScaled = ((gradient * 1.00000) / 4.00000); + lumaMM = (rgbyM.w - (lumaNN * 0.500000)); + subpixF = (subpixD * subpixE); + lumaMLTZero = (lumaMM < 0.00000); + lumaEndN -= (lumaNN * 0.500000); + lumaEndP -= (lumaNN * 0.500000); + doneN = (abs( lumaEndN ) >= gradientScaled); + doneP = (abs( lumaEndP ) >= gradientScaled); + if ( ( !doneN ) ){ + posN.x -= (offNP.x * 1.00000); + } + if ( ( !doneN ) ){ + posN.y -= (offNP.y * 1.00000); + } + doneNP = (( !doneN ) || ( !doneP )); + if ( ( !doneP ) ){ + posP.x += (offNP.x * 1.00000); + } + if ( ( !doneP ) ){ + posP.y += (offNP.y * 1.00000); + } + if ( doneNP ){ + if ( ( !doneN ) ){ + lumaEndN = FxaaLuma( xll_tex2Dlod( tex, vec4( posN.xy , 0.00000, 0.00000))); + } + if ( ( !doneP ) ){ + lumaEndP = FxaaLuma( xll_tex2Dlod( tex, vec4( posP.xy , 0.00000, 0.00000))); + } + if ( ( !doneN ) ){ + lumaEndN = (lumaEndN - (lumaNN * 0.500000)); + } + if ( ( !doneP ) ){ + lumaEndP = (lumaEndP - (lumaNN * 0.500000)); + } + doneN = (abs( lumaEndN ) >= gradientScaled); + doneP = (abs( lumaEndP ) >= gradientScaled); + if ( ( !doneN ) ){ + posN.x -= (offNP.x * 1.00000); + } + if ( ( !doneN ) ){ + posN.y -= (offNP.y * 1.00000); + } + doneNP = (( !doneN ) || ( !doneP )); + if ( ( !doneP ) ){ + posP.x += (offNP.x * 1.00000); + } + if ( ( !doneP ) ){ + posP.y += (offNP.y * 1.00000); + } + if ( doneNP ){ + if ( ( !doneN ) ){ + lumaEndN = FxaaLuma( xll_tex2Dlod( tex, vec4( posN.xy , 0.00000, 0.00000))); + } + if ( ( !doneP ) ){ + lumaEndP = FxaaLuma( xll_tex2Dlod( tex, vec4( posP.xy , 0.00000, 0.00000))); + } + if ( ( !doneN ) ){ + lumaEndN = (lumaEndN - (lumaNN * 0.500000)); + } + if ( ( !doneP ) ){ + lumaEndP = (lumaEndP - (lumaNN * 0.500000)); + } + doneN = (abs( lumaEndN ) >= gradientScaled); + doneP = (abs( lumaEndP ) >= gradientScaled); + if ( ( !doneN ) ){ + posN.x -= (offNP.x * 1.00000); + } + if ( ( !doneN ) ){ + posN.y -= (offNP.y * 1.00000); + } + doneNP = (( !doneN ) || ( !doneP )); + if ( ( !doneP ) ){ + posP.x += (offNP.x * 1.00000); + } + if ( ( !doneP ) ){ + posP.y += (offNP.y * 1.00000); + } + if ( doneNP ){ + if ( ( !doneN ) ){ + lumaEndN = FxaaLuma( xll_tex2Dlod( tex, vec4( posN.xy , 0.00000, 0.00000))); + } + if ( ( !doneP ) ){ + lumaEndP = FxaaLuma( xll_tex2Dlod( tex, vec4( posP.xy , 0.00000, 0.00000))); + } + if ( ( !doneN ) ){ + lumaEndN = (lumaEndN - (lumaNN * 0.500000)); + } + if ( ( !doneP ) ){ + lumaEndP = (lumaEndP - (lumaNN * 0.500000)); + } + doneN = (abs( lumaEndN ) >= gradientScaled); + doneP = (abs( lumaEndP ) >= gradientScaled); + if ( ( !doneN ) ){ + posN.x -= (offNP.x * 1.00000); + } + if ( ( !doneN ) ){ + posN.y -= (offNP.y * 1.00000); + } + doneNP = (( !doneN ) || ( !doneP )); + if ( ( !doneP ) ){ + posP.x += (offNP.x * 1.00000); + } + if ( ( !doneP ) ){ + posP.y += (offNP.y * 1.00000); + } + if ( doneNP ){ + if ( ( !doneN ) ){ + lumaEndN = FxaaLuma( xll_tex2Dlod( tex, vec4( posN.xy , 0.00000, 0.00000))); + } + if ( ( !doneP ) ){ + lumaEndP = FxaaLuma( xll_tex2Dlod( tex, vec4( posP.xy , 0.00000, 0.00000))); + } + if ( ( !doneN ) ){ + lumaEndN = (lumaEndN - (lumaNN * 0.500000)); + } + if ( ( !doneP ) ){ + lumaEndP = (lumaEndP - (lumaNN * 0.500000)); + } + doneN = (abs( lumaEndN ) >= gradientScaled); + doneP = (abs( lumaEndP ) >= gradientScaled); + if ( ( !doneN ) ){ + posN.x -= (offNP.x * 1.50000); + } + if ( ( !doneN ) ){ + posN.y -= (offNP.y * 1.50000); + } + doneNP = (( !doneN ) || ( !doneP )); + if ( ( !doneP ) ){ + posP.x += (offNP.x * 1.50000); + } + if ( ( !doneP ) ){ + posP.y += (offNP.y * 1.50000); + } + if ( doneNP ){ + if ( ( !doneN ) ){ + lumaEndN = FxaaLuma( xll_tex2Dlod( tex, vec4( posN.xy , 0.00000, 0.00000))); + } + if ( ( !doneP ) ){ + lumaEndP = FxaaLuma( xll_tex2Dlod( tex, vec4( posP.xy , 0.00000, 0.00000))); + } + if ( ( !doneN ) ){ + lumaEndN = (lumaEndN - (lumaNN * 0.500000)); + } + if ( ( !doneP ) ){ + lumaEndP = (lumaEndP - (lumaNN * 0.500000)); + } + doneN = (abs( lumaEndN ) >= gradientScaled); + doneP = (abs( lumaEndP ) >= gradientScaled); + if ( ( !doneN ) ){ + posN.x -= (offNP.x * 2.00000); + } + if ( ( !doneN ) ){ + posN.y -= (offNP.y * 2.00000); + } + doneNP = (( !doneN ) || ( !doneP )); + if ( ( !doneP ) ){ + posP.x += (offNP.x * 2.00000); + } + if ( ( !doneP ) ){ + posP.y += (offNP.y * 2.00000); + } + if ( doneNP ){ + if ( ( !doneN ) ){ + lumaEndN = FxaaLuma( xll_tex2Dlod( tex, vec4( posN.xy , 0.00000, 0.00000))); + } + if ( ( !doneP ) ){ + lumaEndP = FxaaLuma( xll_tex2Dlod( tex, vec4( posP.xy , 0.00000, 0.00000))); + } + if ( ( !doneN ) ){ + lumaEndN = (lumaEndN - (lumaNN * 0.500000)); + } + if ( ( !doneP ) ){ + lumaEndP = (lumaEndP - (lumaNN * 0.500000)); + } + doneN = (abs( lumaEndN ) >= gradientScaled); + doneP = (abs( lumaEndP ) >= gradientScaled); + if ( ( !doneN ) ){ + posN.x -= (offNP.x * 2.00000); + } + if ( ( !doneN ) ){ + posN.y -= (offNP.y * 2.00000); + } + doneNP = (( !doneN ) || ( !doneP )); + if ( ( !doneP ) ){ + posP.x += (offNP.x * 2.00000); + } + if ( ( !doneP ) ){ + posP.y += (offNP.y * 2.00000); + } + if ( doneNP ){ + if ( ( !doneN ) ){ + lumaEndN = FxaaLuma( xll_tex2Dlod( tex, vec4( posN.xy , 0.00000, 0.00000))); + } + if ( ( !doneP ) ){ + lumaEndP = FxaaLuma( xll_tex2Dlod( tex, vec4( posP.xy , 0.00000, 0.00000))); + } + if ( ( !doneN ) ){ + lumaEndN = (lumaEndN - (lumaNN * 0.500000)); + } + if ( ( !doneP ) ){ + lumaEndP = (lumaEndP - (lumaNN * 0.500000)); + } + doneN = (abs( lumaEndN ) >= gradientScaled); + doneP = (abs( lumaEndP ) >= gradientScaled); + if ( ( !doneN ) ){ + posN.x -= (offNP.x * 2.00000); + } + if ( ( !doneN ) ){ + posN.y -= (offNP.y * 2.00000); + } + doneNP = (( !doneN ) || ( !doneP )); + if ( ( !doneP ) ){ + posP.x += (offNP.x * 2.00000); + } + if ( ( !doneP ) ){ + posP.y += (offNP.y * 2.00000); + } + if ( doneNP ){ + if ( ( !doneN ) ){ + lumaEndN = FxaaLuma( xll_tex2Dlod( tex, vec4( posN.xy , 0.00000, 0.00000))); + } + if ( ( !doneP ) ){ + lumaEndP = FxaaLuma( xll_tex2Dlod( tex, vec4( posP.xy , 0.00000, 0.00000))); + } + if ( ( !doneN ) ){ + lumaEndN = (lumaEndN - (lumaNN * 0.500000)); + } + if ( ( !doneP ) ){ + lumaEndP = (lumaEndP - (lumaNN * 0.500000)); + } + doneN = (abs( lumaEndN ) >= gradientScaled); + doneP = (abs( lumaEndP ) >= gradientScaled); + if ( ( !doneN ) ){ + posN.x -= (offNP.x * 2.00000); + } + if ( ( !doneN ) ){ + posN.y -= (offNP.y * 2.00000); + } + doneNP = (( !doneN ) || ( !doneP )); + if ( ( !doneP ) ){ + posP.x += (offNP.x * 2.00000); + } + if ( ( !doneP ) ){ + posP.y += (offNP.y * 2.00000); + } + if ( doneNP ){ + if ( ( !doneN ) ){ + lumaEndN = FxaaLuma( xll_tex2Dlod( tex, vec4( posN.xy , 0.00000, 0.00000))); + } + if ( ( !doneP ) ){ + lumaEndP = FxaaLuma( xll_tex2Dlod( tex, vec4( posP.xy , 0.00000, 0.00000))); + } + if ( ( !doneN ) ){ + lumaEndN = (lumaEndN - (lumaNN * 0.500000)); + } + if ( ( !doneP ) ){ + lumaEndP = (lumaEndP - (lumaNN * 0.500000)); + } + doneN = (abs( lumaEndN ) >= gradientScaled); + doneP = (abs( lumaEndP ) >= gradientScaled); + if ( ( !doneN ) ){ + posN.x -= (offNP.x * 4.00000); + } + if ( ( !doneN ) ){ + posN.y -= (offNP.y * 4.00000); + } + doneNP = (( !doneN ) || ( !doneP )); + if ( ( !doneP ) ){ + posP.x += (offNP.x * 4.00000); + } + if ( ( !doneP ) ){ + posP.y += (offNP.y * 4.00000); + } + if ( doneNP ){ + if ( ( !doneN ) ){ + lumaEndN = FxaaLuma( xll_tex2Dlod( tex, vec4( posN.xy , 0.00000, 0.00000))); + } + if ( ( !doneP ) ){ + lumaEndP = FxaaLuma( xll_tex2Dlod( tex, vec4( posP.xy , 0.00000, 0.00000))); + } + if ( ( !doneN ) ){ + lumaEndN = (lumaEndN - (lumaNN * 0.500000)); + } + if ( ( !doneP ) ){ + lumaEndP = (lumaEndP - (lumaNN * 0.500000)); + } + doneN = (abs( lumaEndN ) >= gradientScaled); + doneP = (abs( lumaEndP ) >= gradientScaled); + if ( ( !doneN ) ){ + posN.x -= (offNP.x * 8.00000); + } + if ( ( !doneN ) ){ + posN.y -= (offNP.y * 8.00000); + } + doneNP = (( !doneN ) || ( !doneP )); + if ( ( !doneP ) ){ + posP.x += (offNP.x * 8.00000); + } + if ( ( !doneP ) ){ + posP.y += (offNP.y * 8.00000); + } + } + } + } + } + } + } + } + } + } + } + dstN = (posM.x - posN.x ); + dstP = (posP.x - posM.x ); + if ( ( !horzSpan ) ){ + dstN = (posM.y - posN.y ); + } + if ( ( !horzSpan ) ){ + dstP = (posP.y - posM.y ); + } + goodSpanN = ((lumaEndN < 0.00000) != lumaMLTZero); + spanLength = (dstP + dstN); + goodSpanP = ((lumaEndP < 0.00000) != lumaMLTZero); + spanLengthRcp = (1.00000 / spanLength); + directionN = (dstN < dstP); + dst = min( dstN, dstP); + goodSpan = (( directionN ) ? ( goodSpanN ) : ( goodSpanP )); + subpixG = (subpixF * subpixF); + pixelOffset = ((dst * ( -spanLengthRcp )) + 0.500000); + subpixH = (subpixG * fxaaQualitySubpix); + pixelOffsetGood = (( goodSpan ) ? ( pixelOffset ) : ( 0.00000 )); + pixelOffsetSubpix = max( pixelOffsetGood, subpixH); + if ( ( !horzSpan ) ){ + posM.x += (pixelOffsetSubpix * lengthSign); + } + if ( horzSpan ){ + posM.y += (pixelOffsetSubpix * lengthSign); + } + return vec4( xll_tex2Dlod( tex, vec4( posM, 0.00000, 0.00000)).xyz , rgbyM.w ); +} +highp vec4 xlat_main( in v2f i ) { + highp float fxaaN = 0.500000; + return FxaaPixelShader( i.uv, i.uvPosPos, _MainTex, _MainTex, _MainTex, _MainTex_TexelSize.xy , (_MainTex_TexelSize.xyxy * vec4( ( -fxaaN ), ( -fxaaN ), fxaaN, fxaaN)), (_MainTex_TexelSize.xyxy * vec4( -2.00000, -2.00000, 2.00000, 2.00000)), (_MainTex_TexelSize.xyxy * vec4( 8.00000, 8.00000, -4.00000, -4.00000)), 0.750000, 0.166000, 0.0833000, 8.00000, 0.125000, 0.0500000, vec4( 1.00000, -1.00000, 0.250000, -0.250000)); +} +varying highp vec4 xlv_SV_POSITION; +varying highp vec2 xlv_TEXCOORD0; +varying highp vec4 xlv_TEXCOORD1; +void main() { + highp vec4 xl_retval; + v2f xlt_i; + xlt_i.pos = vec4( xlv_SV_POSITION); + xlt_i.uv = vec2( xlv_TEXCOORD0); + xlt_i.uvPosPos = vec4( xlv_TEXCOORD1); + xl_retval = xlat_main( xlt_i); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/complex-fxaa3-11-pc39-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/complex-fxaa3-11-pc39-ir.txt new file mode 100644 index 000000000..a79231e10 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/complex-fxaa3-11-pc39-ir.txt @@ -0,0 +1,1542 @@ +#extension GL_ARB_shader_texture_lod : enable +struct v2f { + vec4 pos; + vec2 uv; + vec4 uvPosPos; +}; +varying vec4 xlv_TEXCOORD1; +varying vec2 xlv_TEXCOORD0; +varying vec4 xlv_SV_POSITION; +uniform vec4 _MainTex_TexelSize; +uniform sampler2D _MainTex; +vec4 xll_tex2Dlod ( + in sampler2D s, + in vec4 coord +) +{ + vec4 tmpvar_1; + tmpvar_1 = texture2DLod (s, coord.xy, coord.w); + return tmpvar_1; +} + +float xll_saturate ( + in float x +) +{ + float tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec2 xll_saturate ( + in vec2 x +) +{ + vec2 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec3 xll_saturate ( + in vec3 x +) +{ + vec3 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec4 xll_saturate ( + in vec4 x +) +{ + vec4 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +mat2 xll_saturate ( + in mat2 m +) +{ + vec2 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec2 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + mat2 tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_1; + tmpvar_3[0] = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5 = tmpvar_2; + tmpvar_3[1] = tmpvar_5; + return tmpvar_3; +} + +mat3 xll_saturate ( + in mat3 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec3 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + vec3 tmpvar_3; + tmpvar_3 = clamp (m[2], 0.0, 1.0); + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +mat4 xll_saturate ( + in mat4 m +) +{ + vec4 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec4 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + vec4 tmpvar_3; + tmpvar_3 = clamp (m[2], 0.0, 1.0); + vec4 tmpvar_4; + tmpvar_4 = clamp (m[3], 0.0, 1.0); + mat4 tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_1; + tmpvar_5[0] = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = tmpvar_2; + tmpvar_5[1] = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_3; + tmpvar_5[2] = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = tmpvar_4; + tmpvar_5[3] = tmpvar_9; + return tmpvar_5; +} + +float FxaaLuma ( + in vec4 rgba +) +{ + return rgba.w; +} + +vec4 FxaaPixelShader ( + in vec2 pos, + in vec4 fxaaConsolePosPos, + in sampler2D tex, + in sampler2D fxaaConsole360TexExpBiasNegOne, + in sampler2D fxaaConsole360TexExpBiasNegTwo, + in vec2 fxaaQualityRcpFrame, + in vec4 fxaaConsoleRcpFrameOpt, + in vec4 fxaaConsoleRcpFrameOpt2, + in vec4 fxaaConsole360RcpFrameOpt2, + in float fxaaQualitySubpix, + in float fxaaQualityEdgeThreshold, + in float fxaaQualityEdgeThresholdMin, + in float fxaaConsoleEdgeSharpness, + in float fxaaConsoleEdgeThreshold, + in float fxaaConsoleEdgeThresholdMin, + in vec4 fxaaConsole360ConstDir +) +{ + float pixelOffsetSubpix; + float pixelOffsetGood; + float subpixH; + float pixelOffset; + float subpixG; + bool goodSpan; + float dst; + bool directionN; + float spanLengthRcp; + bool goodSpanP; + float spanLength; + bool goodSpanN; + float dstP; + float dstN; + bool doneNP; + bool doneP; + bool doneN; + bool lumaMLTZero; + float subpixF; + float lumaMM; + float gradientScaled; + float lumaEndP; + float subpixE; + float lumaEndN; + float subpixD; + vec2 posP; + vec2 posN; + vec2 offNP; + vec2 posB; + float subpixC; + float gradient; + bool pairN; + float lumaSS; + float lumaNN; + float gradientS; + float gradientN; + float subpixB; + float subpixA; + bool horzSpan; + float lengthSign; + float subpixNWSWNESE; + float edgeVert; + float edgeHorz; + float edgeVert3; + float edgeHorz3; + float edgeVert4; + float edgeHorz4; + float lumaSWSE; + float lumaNWSW; + float edgeVert2; + float edgeHorz2; + float lumaNWNE; + float lumaNESE; + float edgeVert1; + float edgeHorz1; + float subpixNSWE; + float subpixRcpRange; + float lumaWE; + float lumaNS; + float lumaSW; + float lumaNE; + float lumaSE; + float lumaNW; + bool earlyExit; + float rangeMaxClamped; + float range; + float rangeMaxScaled; + float rangeMin; + float rangeMax; + float minWN; + float maxWN; + float minESM; + float maxESM; + float minSM; + float maxSM; + float lumaW; + float lumaN; + float lumaE; + float lumaS; + vec4 rgbyM; + vec2 posM; + float tmpvar_1; + tmpvar_1 = pos.x; + posM.x = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.y; + posM.y = vec2(tmpvar_2).y; + vec4 tmpvar_3; + tmpvar_3.zw = vec2(0.0, 0.0); + tmpvar_3.xy = posM.xy; + vec4 tmpvar_4; + tmpvar_4 = xll_tex2Dlod (tex, tmpvar_3); + vec4 tmpvar_5; + tmpvar_5 = tmpvar_4; + rgbyM = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6.zw = vec2(0.0, 0.0); + tmpvar_6.xy = (posM + (vec2(0.0, 1.0) * fxaaQualityRcpFrame.xy)).xy; + vec4 tmpvar_7; + tmpvar_7 = xll_tex2Dlod (tex, tmpvar_6); + float tmpvar_8; + tmpvar_8 = FxaaLuma (tmpvar_7); + float tmpvar_9; + tmpvar_9 = tmpvar_8; + lumaS = tmpvar_9; + vec4 tmpvar_10; + tmpvar_10.zw = vec2(0.0, 0.0); + tmpvar_10.xy = (posM + (vec2(1.0, 0.0) * fxaaQualityRcpFrame.xy)).xy; + vec4 tmpvar_11; + tmpvar_11 = xll_tex2Dlod (tex, tmpvar_10); + float tmpvar_12; + tmpvar_12 = FxaaLuma (tmpvar_11); + float tmpvar_13; + tmpvar_13 = tmpvar_12; + lumaE = tmpvar_13; + vec4 tmpvar_14; + tmpvar_14.zw = vec2(0.0, 0.0); + tmpvar_14.xy = (posM + (vec2(0.0, -1.0) * fxaaQualityRcpFrame.xy)).xy; + vec4 tmpvar_15; + tmpvar_15 = xll_tex2Dlod (tex, tmpvar_14); + float tmpvar_16; + tmpvar_16 = FxaaLuma (tmpvar_15); + float tmpvar_17; + tmpvar_17 = tmpvar_16; + lumaN = tmpvar_17; + vec4 tmpvar_18; + tmpvar_18.zw = vec2(0.0, 0.0); + tmpvar_18.xy = (posM + (vec2(-1.0, 0.0) * fxaaQualityRcpFrame.xy)).xy; + vec4 tmpvar_19; + tmpvar_19 = xll_tex2Dlod (tex, tmpvar_18); + float tmpvar_20; + tmpvar_20 = FxaaLuma (tmpvar_19); + float tmpvar_21; + tmpvar_21 = tmpvar_20; + lumaW = tmpvar_21; + float tmpvar_22; + tmpvar_22 = max (lumaS, rgbyM.w); + float tmpvar_23; + tmpvar_23 = tmpvar_22; + maxSM = tmpvar_23; + float tmpvar_24; + tmpvar_24 = min (lumaS, rgbyM.w); + float tmpvar_25; + tmpvar_25 = tmpvar_24; + minSM = tmpvar_25; + float tmpvar_26; + tmpvar_26 = max (lumaE, maxSM); + float tmpvar_27; + tmpvar_27 = tmpvar_26; + maxESM = tmpvar_27; + float tmpvar_28; + tmpvar_28 = min (lumaE, minSM); + float tmpvar_29; + tmpvar_29 = tmpvar_28; + minESM = tmpvar_29; + float tmpvar_30; + tmpvar_30 = max (lumaN, lumaW); + float tmpvar_31; + tmpvar_31 = tmpvar_30; + maxWN = tmpvar_31; + float tmpvar_32; + tmpvar_32 = min (lumaN, lumaW); + float tmpvar_33; + tmpvar_33 = tmpvar_32; + minWN = tmpvar_33; + float tmpvar_34; + tmpvar_34 = max (maxWN, maxESM); + float tmpvar_35; + tmpvar_35 = tmpvar_34; + rangeMax = tmpvar_35; + float tmpvar_36; + tmpvar_36 = min (minWN, minESM); + float tmpvar_37; + tmpvar_37 = tmpvar_36; + rangeMin = tmpvar_37; + float tmpvar_38; + tmpvar_38 = (rangeMax * fxaaQualityEdgeThreshold); + rangeMaxScaled = tmpvar_38; + float tmpvar_39; + tmpvar_39 = (rangeMax - rangeMin); + range = tmpvar_39; + float tmpvar_40; + tmpvar_40 = max (fxaaQualityEdgeThresholdMin, rangeMaxScaled); + float tmpvar_41; + tmpvar_41 = tmpvar_40; + rangeMaxClamped = tmpvar_41; + bool tmpvar_42; + tmpvar_42 = (range < rangeMaxClamped); + earlyExit = tmpvar_42; + if (earlyExit) { + return rgbyM; + }; + vec4 tmpvar_43; + tmpvar_43.zw = vec2(0.0, 0.0); + tmpvar_43.xy = (posM + (vec2(-1.0, -1.0) * fxaaQualityRcpFrame.xy)).xy; + vec4 tmpvar_44; + tmpvar_44 = xll_tex2Dlod (tex, tmpvar_43); + float tmpvar_45; + tmpvar_45 = FxaaLuma (tmpvar_44); + float tmpvar_46; + tmpvar_46 = tmpvar_45; + lumaNW = tmpvar_46; + vec4 tmpvar_47; + tmpvar_47.zw = vec2(0.0, 0.0); + tmpvar_47.xy = (posM + (vec2(1.0, 1.0) * fxaaQualityRcpFrame.xy)).xy; + vec4 tmpvar_48; + tmpvar_48 = xll_tex2Dlod (tex, tmpvar_47); + float tmpvar_49; + tmpvar_49 = FxaaLuma (tmpvar_48); + float tmpvar_50; + tmpvar_50 = tmpvar_49; + lumaSE = tmpvar_50; + vec4 tmpvar_51; + tmpvar_51.zw = vec2(0.0, 0.0); + tmpvar_51.xy = (posM + (vec2(1.0, -1.0) * fxaaQualityRcpFrame.xy)).xy; + vec4 tmpvar_52; + tmpvar_52 = xll_tex2Dlod (tex, tmpvar_51); + float tmpvar_53; + tmpvar_53 = FxaaLuma (tmpvar_52); + float tmpvar_54; + tmpvar_54 = tmpvar_53; + lumaNE = tmpvar_54; + vec4 tmpvar_55; + tmpvar_55.zw = vec2(0.0, 0.0); + tmpvar_55.xy = (posM + (vec2(-1.0, 1.0) * fxaaQualityRcpFrame.xy)).xy; + vec4 tmpvar_56; + tmpvar_56 = xll_tex2Dlod (tex, tmpvar_55); + float tmpvar_57; + tmpvar_57 = FxaaLuma (tmpvar_56); + float tmpvar_58; + tmpvar_58 = tmpvar_57; + lumaSW = tmpvar_58; + float tmpvar_59; + tmpvar_59 = (lumaN + lumaS); + lumaNS = tmpvar_59; + float tmpvar_60; + tmpvar_60 = (lumaW + lumaE); + lumaWE = tmpvar_60; + float tmpvar_61; + tmpvar_61 = (1.0 / range); + subpixRcpRange = tmpvar_61; + float tmpvar_62; + tmpvar_62 = (lumaNS + lumaWE); + subpixNSWE = tmpvar_62; + float tmpvar_63; + tmpvar_63 = ((-(2.0) * rgbyM.w) + lumaNS); + edgeHorz1 = tmpvar_63; + float tmpvar_64; + tmpvar_64 = ((-(2.0) * rgbyM.w) + lumaWE); + edgeVert1 = tmpvar_64; + float tmpvar_65; + tmpvar_65 = (lumaNE + lumaSE); + lumaNESE = tmpvar_65; + float tmpvar_66; + tmpvar_66 = (lumaNW + lumaNE); + lumaNWNE = tmpvar_66; + float tmpvar_67; + tmpvar_67 = ((-(2.0) * lumaE) + lumaNESE); + edgeHorz2 = tmpvar_67; + float tmpvar_68; + tmpvar_68 = ((-(2.0) * lumaN) + lumaNWNE); + edgeVert2 = tmpvar_68; + float tmpvar_69; + tmpvar_69 = (lumaNW + lumaSW); + lumaNWSW = tmpvar_69; + float tmpvar_70; + tmpvar_70 = (lumaSW + lumaSE); + lumaSWSE = tmpvar_70; + float tmpvar_71; + tmpvar_71 = abs (edgeHorz1); + float tmpvar_72; + tmpvar_72 = abs (edgeHorz2); + float tmpvar_73; + tmpvar_73 = ((tmpvar_71 * 2.0) + tmpvar_72); + edgeHorz4 = tmpvar_73; + float tmpvar_74; + tmpvar_74 = abs (edgeVert1); + float tmpvar_75; + tmpvar_75 = abs (edgeVert2); + float tmpvar_76; + tmpvar_76 = ((tmpvar_74 * 2.0) + tmpvar_75); + edgeVert4 = tmpvar_76; + float tmpvar_77; + tmpvar_77 = ((-(2.0) * lumaW) + lumaNWSW); + edgeHorz3 = tmpvar_77; + float tmpvar_78; + tmpvar_78 = ((-(2.0) * lumaS) + lumaSWSE); + edgeVert3 = tmpvar_78; + float tmpvar_79; + tmpvar_79 = abs (edgeHorz3); + float tmpvar_80; + tmpvar_80 = (tmpvar_79 + edgeHorz4); + edgeHorz = tmpvar_80; + float tmpvar_81; + tmpvar_81 = abs (edgeVert3); + float tmpvar_82; + tmpvar_82 = (tmpvar_81 + edgeVert4); + edgeVert = tmpvar_82; + float tmpvar_83; + tmpvar_83 = (lumaNWSW + lumaNESE); + subpixNWSWNESE = tmpvar_83; + float tmpvar_84; + tmpvar_84 = fxaaQualityRcpFrame.x; + lengthSign = tmpvar_84; + bool tmpvar_85; + tmpvar_85 = (edgeHorz >= edgeVert); + horzSpan = tmpvar_85; + float tmpvar_86; + tmpvar_86 = ((subpixNSWE * 2.0) + subpixNWSWNESE); + subpixA = tmpvar_86; + if (!(horzSpan)) { + float tmpvar_87; + tmpvar_87 = lumaW; + lumaN = tmpvar_87; + }; + if (!(horzSpan)) { + float tmpvar_88; + tmpvar_88 = lumaE; + lumaS = tmpvar_88; + }; + if (horzSpan) { + float tmpvar_89; + tmpvar_89 = fxaaQualityRcpFrame.y; + lengthSign = tmpvar_89; + }; + float tmpvar_90; + tmpvar_90 = ((subpixA * 0.0833333) - rgbyM.w); + subpixB = tmpvar_90; + float tmpvar_91; + tmpvar_91 = (lumaN - rgbyM.w); + gradientN = tmpvar_91; + float tmpvar_92; + tmpvar_92 = (lumaS - rgbyM.w); + gradientS = tmpvar_92; + float tmpvar_93; + tmpvar_93 = (lumaN + rgbyM.w); + lumaNN = tmpvar_93; + float tmpvar_94; + tmpvar_94 = (lumaS + rgbyM.w); + lumaSS = tmpvar_94; + float tmpvar_95; + tmpvar_95 = abs (gradientN); + float tmpvar_96; + tmpvar_96 = abs (gradientS); + bool tmpvar_97; + tmpvar_97 = (tmpvar_95 >= tmpvar_96); + pairN = tmpvar_97; + float tmpvar_98; + tmpvar_98 = abs (gradientN); + float tmpvar_99; + tmpvar_99 = abs (gradientS); + float tmpvar_100; + tmpvar_100 = max (tmpvar_98, tmpvar_99); + float tmpvar_101; + tmpvar_101 = tmpvar_100; + gradient = tmpvar_101; + if (pairN) { + float tmpvar_102; + tmpvar_102 = -(lengthSign); + lengthSign = tmpvar_102; + }; + float tmpvar_103; + tmpvar_103 = abs (subpixB); + float tmpvar_104; + tmpvar_104 = xll_saturate ((tmpvar_103 * subpixRcpRange)); + float tmpvar_105; + tmpvar_105 = tmpvar_104; + subpixC = tmpvar_105; + float tmpvar_106; + tmpvar_106 = posM.x; + posB.x = tmpvar_106; + float tmpvar_107; + tmpvar_107 = posM.y; + posB.y = vec2(tmpvar_107).y; + float tmpvar_108; + if (!(horzSpan)) { + tmpvar_108 = 0.0; + } else { + tmpvar_108 = fxaaQualityRcpFrame.x; + }; + float tmpvar_109; + tmpvar_109 = tmpvar_108; + offNP.x = tmpvar_109; + float tmpvar_110; + if (horzSpan) { + tmpvar_110 = 0.0; + } else { + tmpvar_110 = fxaaQualityRcpFrame.y; + }; + float tmpvar_111; + tmpvar_111 = tmpvar_110; + offNP.y = vec2(tmpvar_111).y; + if (!(horzSpan)) { + float tmpvar_112; + tmpvar_112 = (posB.x + (lengthSign * 0.5)); + posB.x = tmpvar_112; + }; + if (horzSpan) { + float tmpvar_113; + tmpvar_113 = (posB.y + (lengthSign * 0.5)); + posB.y = vec2(tmpvar_113).y; + }; + float tmpvar_114; + tmpvar_114 = (posB.x - (offNP.x * 1.0)); + posN.x = tmpvar_114; + float tmpvar_115; + tmpvar_115 = (posB.y - (offNP.y * 1.0)); + posN.y = vec2(tmpvar_115).y; + float tmpvar_116; + tmpvar_116 = (posB.x + (offNP.x * 1.0)); + posP.x = tmpvar_116; + float tmpvar_117; + tmpvar_117 = (posB.y + (offNP.y * 1.0)); + posP.y = vec2(tmpvar_117).y; + float tmpvar_118; + tmpvar_118 = ((-(2.0) * subpixC) + 3.0); + subpixD = tmpvar_118; + vec4 tmpvar_119; + tmpvar_119.zw = vec2(0.0, 0.0); + tmpvar_119.xy = posN.xy; + vec4 tmpvar_120; + tmpvar_120 = xll_tex2Dlod (tex, tmpvar_119); + float tmpvar_121; + tmpvar_121 = FxaaLuma (tmpvar_120); + float tmpvar_122; + tmpvar_122 = tmpvar_121; + lumaEndN = tmpvar_122; + float tmpvar_123; + tmpvar_123 = (subpixC * subpixC); + subpixE = tmpvar_123; + vec4 tmpvar_124; + tmpvar_124.zw = vec2(0.0, 0.0); + tmpvar_124.xy = posP.xy; + vec4 tmpvar_125; + tmpvar_125 = xll_tex2Dlod (tex, tmpvar_124); + float tmpvar_126; + tmpvar_126 = FxaaLuma (tmpvar_125); + float tmpvar_127; + tmpvar_127 = tmpvar_126; + lumaEndP = tmpvar_127; + if (!(pairN)) { + float tmpvar_128; + tmpvar_128 = lumaSS; + lumaNN = tmpvar_128; + }; + float tmpvar_129; + tmpvar_129 = ((gradient * 1.0) / 4.0); + gradientScaled = tmpvar_129; + float tmpvar_130; + tmpvar_130 = (rgbyM.w - (lumaNN * 0.5)); + lumaMM = tmpvar_130; + float tmpvar_131; + tmpvar_131 = (subpixD * subpixE); + subpixF = tmpvar_131; + bool tmpvar_132; + tmpvar_132 = (lumaMM < 0.0); + lumaMLTZero = tmpvar_132; + float tmpvar_133; + tmpvar_133 = (lumaEndN - (lumaNN * 0.5)); + lumaEndN = tmpvar_133; + float tmpvar_134; + tmpvar_134 = (lumaEndP - (lumaNN * 0.5)); + lumaEndP = tmpvar_134; + float tmpvar_135; + tmpvar_135 = abs (lumaEndN); + bool tmpvar_136; + tmpvar_136 = (tmpvar_135 >= gradientScaled); + doneN = tmpvar_136; + float tmpvar_137; + tmpvar_137 = abs (lumaEndP); + bool tmpvar_138; + tmpvar_138 = (tmpvar_137 >= gradientScaled); + doneP = tmpvar_138; + if (!(doneN)) { + float tmpvar_139; + tmpvar_139 = (posN.x - (offNP.x * 1.0)); + posN.x = tmpvar_139; + }; + if (!(doneN)) { + float tmpvar_140; + tmpvar_140 = (posN.y - (offNP.y * 1.0)); + posN.y = vec2(tmpvar_140).y; + }; + bool tmpvar_141; + if (!(doneN)) { + tmpvar_141 = bool(1); + } else { + tmpvar_141 = !(doneP); + }; + bool tmpvar_142; + tmpvar_142 = tmpvar_141; + doneNP = tmpvar_142; + if (!(doneP)) { + float tmpvar_143; + tmpvar_143 = (posP.x + (offNP.x * 1.0)); + posP.x = tmpvar_143; + }; + if (!(doneP)) { + float tmpvar_144; + tmpvar_144 = (posP.y + (offNP.y * 1.0)); + posP.y = vec2(tmpvar_144).y; + }; + if (doneNP) { + if (!(doneN)) { + vec4 tmpvar_145; + tmpvar_145.zw = vec2(0.0, 0.0); + tmpvar_145.xy = posN.xy.xy; + vec4 tmpvar_146; + tmpvar_146 = xll_tex2Dlod (tex, tmpvar_145); + float tmpvar_147; + tmpvar_147 = FxaaLuma (tmpvar_146); + float tmpvar_148; + tmpvar_148 = tmpvar_147; + lumaEndN = tmpvar_148; + }; + if (!(doneP)) { + vec4 tmpvar_149; + tmpvar_149.zw = vec2(0.0, 0.0); + tmpvar_149.xy = posP.xy.xy; + vec4 tmpvar_150; + tmpvar_150 = xll_tex2Dlod (tex, tmpvar_149); + float tmpvar_151; + tmpvar_151 = FxaaLuma (tmpvar_150); + float tmpvar_152; + tmpvar_152 = tmpvar_151; + lumaEndP = tmpvar_152; + }; + if (!(doneN)) { + float tmpvar_153; + tmpvar_153 = (lumaEndN - (lumaNN * 0.5)); + lumaEndN = tmpvar_153; + }; + if (!(doneP)) { + float tmpvar_154; + tmpvar_154 = (lumaEndP - (lumaNN * 0.5)); + lumaEndP = tmpvar_154; + }; + float tmpvar_155; + tmpvar_155 = abs (lumaEndN); + bool tmpvar_156; + tmpvar_156 = (tmpvar_155 >= gradientScaled); + doneN = tmpvar_156; + float tmpvar_157; + tmpvar_157 = abs (lumaEndP); + bool tmpvar_158; + tmpvar_158 = (tmpvar_157 >= gradientScaled); + doneP = tmpvar_158; + if (!(doneN)) { + float tmpvar_159; + tmpvar_159 = (posN.x - (offNP.x * 1.0)); + posN.x = tmpvar_159; + }; + if (!(doneN)) { + float tmpvar_160; + tmpvar_160 = (posN.y - (offNP.y * 1.0)); + posN.y = vec2(tmpvar_160).y; + }; + bool tmpvar_161; + if (!(doneN)) { + tmpvar_161 = bool(1); + } else { + tmpvar_161 = !(doneP); + }; + bool tmpvar_162; + tmpvar_162 = tmpvar_161; + doneNP = tmpvar_162; + if (!(doneP)) { + float tmpvar_163; + tmpvar_163 = (posP.x + (offNP.x * 1.0)); + posP.x = tmpvar_163; + }; + if (!(doneP)) { + float tmpvar_164; + tmpvar_164 = (posP.y + (offNP.y * 1.0)); + posP.y = vec2(tmpvar_164).y; + }; + if (doneNP) { + if (!(doneN)) { + vec4 tmpvar_165; + tmpvar_165.zw = vec2(0.0, 0.0); + tmpvar_165.xy = posN.xy.xy; + vec4 tmpvar_166; + tmpvar_166 = xll_tex2Dlod (tex, tmpvar_165); + float tmpvar_167; + tmpvar_167 = FxaaLuma (tmpvar_166); + float tmpvar_168; + tmpvar_168 = tmpvar_167; + lumaEndN = tmpvar_168; + }; + if (!(doneP)) { + vec4 tmpvar_169; + tmpvar_169.zw = vec2(0.0, 0.0); + tmpvar_169.xy = posP.xy.xy; + vec4 tmpvar_170; + tmpvar_170 = xll_tex2Dlod (tex, tmpvar_169); + float tmpvar_171; + tmpvar_171 = FxaaLuma (tmpvar_170); + float tmpvar_172; + tmpvar_172 = tmpvar_171; + lumaEndP = tmpvar_172; + }; + if (!(doneN)) { + float tmpvar_173; + tmpvar_173 = (lumaEndN - (lumaNN * 0.5)); + lumaEndN = tmpvar_173; + }; + if (!(doneP)) { + float tmpvar_174; + tmpvar_174 = (lumaEndP - (lumaNN * 0.5)); + lumaEndP = tmpvar_174; + }; + float tmpvar_175; + tmpvar_175 = abs (lumaEndN); + bool tmpvar_176; + tmpvar_176 = (tmpvar_175 >= gradientScaled); + doneN = tmpvar_176; + float tmpvar_177; + tmpvar_177 = abs (lumaEndP); + bool tmpvar_178; + tmpvar_178 = (tmpvar_177 >= gradientScaled); + doneP = tmpvar_178; + if (!(doneN)) { + float tmpvar_179; + tmpvar_179 = (posN.x - (offNP.x * 1.0)); + posN.x = tmpvar_179; + }; + if (!(doneN)) { + float tmpvar_180; + tmpvar_180 = (posN.y - (offNP.y * 1.0)); + posN.y = vec2(tmpvar_180).y; + }; + bool tmpvar_181; + if (!(doneN)) { + tmpvar_181 = bool(1); + } else { + tmpvar_181 = !(doneP); + }; + bool tmpvar_182; + tmpvar_182 = tmpvar_181; + doneNP = tmpvar_182; + if (!(doneP)) { + float tmpvar_183; + tmpvar_183 = (posP.x + (offNP.x * 1.0)); + posP.x = tmpvar_183; + }; + if (!(doneP)) { + float tmpvar_184; + tmpvar_184 = (posP.y + (offNP.y * 1.0)); + posP.y = vec2(tmpvar_184).y; + }; + if (doneNP) { + if (!(doneN)) { + vec4 tmpvar_185; + tmpvar_185.zw = vec2(0.0, 0.0); + tmpvar_185.xy = posN.xy.xy; + vec4 tmpvar_186; + tmpvar_186 = xll_tex2Dlod (tex, tmpvar_185); + float tmpvar_187; + tmpvar_187 = FxaaLuma (tmpvar_186); + float tmpvar_188; + tmpvar_188 = tmpvar_187; + lumaEndN = tmpvar_188; + }; + if (!(doneP)) { + vec4 tmpvar_189; + tmpvar_189.zw = vec2(0.0, 0.0); + tmpvar_189.xy = posP.xy.xy; + vec4 tmpvar_190; + tmpvar_190 = xll_tex2Dlod (tex, tmpvar_189); + float tmpvar_191; + tmpvar_191 = FxaaLuma (tmpvar_190); + float tmpvar_192; + tmpvar_192 = tmpvar_191; + lumaEndP = tmpvar_192; + }; + if (!(doneN)) { + float tmpvar_193; + tmpvar_193 = (lumaEndN - (lumaNN * 0.5)); + lumaEndN = tmpvar_193; + }; + if (!(doneP)) { + float tmpvar_194; + tmpvar_194 = (lumaEndP - (lumaNN * 0.5)); + lumaEndP = tmpvar_194; + }; + float tmpvar_195; + tmpvar_195 = abs (lumaEndN); + bool tmpvar_196; + tmpvar_196 = (tmpvar_195 >= gradientScaled); + doneN = tmpvar_196; + float tmpvar_197; + tmpvar_197 = abs (lumaEndP); + bool tmpvar_198; + tmpvar_198 = (tmpvar_197 >= gradientScaled); + doneP = tmpvar_198; + if (!(doneN)) { + float tmpvar_199; + tmpvar_199 = (posN.x - (offNP.x * 1.0)); + posN.x = tmpvar_199; + }; + if (!(doneN)) { + float tmpvar_200; + tmpvar_200 = (posN.y - (offNP.y * 1.0)); + posN.y = vec2(tmpvar_200).y; + }; + bool tmpvar_201; + if (!(doneN)) { + tmpvar_201 = bool(1); + } else { + tmpvar_201 = !(doneP); + }; + bool tmpvar_202; + tmpvar_202 = tmpvar_201; + doneNP = tmpvar_202; + if (!(doneP)) { + float tmpvar_203; + tmpvar_203 = (posP.x + (offNP.x * 1.0)); + posP.x = tmpvar_203; + }; + if (!(doneP)) { + float tmpvar_204; + tmpvar_204 = (posP.y + (offNP.y * 1.0)); + posP.y = vec2(tmpvar_204).y; + }; + if (doneNP) { + if (!(doneN)) { + vec4 tmpvar_205; + tmpvar_205.zw = vec2(0.0, 0.0); + tmpvar_205.xy = posN.xy.xy; + vec4 tmpvar_206; + tmpvar_206 = xll_tex2Dlod (tex, tmpvar_205); + float tmpvar_207; + tmpvar_207 = FxaaLuma (tmpvar_206); + float tmpvar_208; + tmpvar_208 = tmpvar_207; + lumaEndN = tmpvar_208; + }; + if (!(doneP)) { + vec4 tmpvar_209; + tmpvar_209.zw = vec2(0.0, 0.0); + tmpvar_209.xy = posP.xy.xy; + vec4 tmpvar_210; + tmpvar_210 = xll_tex2Dlod (tex, tmpvar_209); + float tmpvar_211; + tmpvar_211 = FxaaLuma (tmpvar_210); + float tmpvar_212; + tmpvar_212 = tmpvar_211; + lumaEndP = tmpvar_212; + }; + if (!(doneN)) { + float tmpvar_213; + tmpvar_213 = (lumaEndN - (lumaNN * 0.5)); + lumaEndN = tmpvar_213; + }; + if (!(doneP)) { + float tmpvar_214; + tmpvar_214 = (lumaEndP - (lumaNN * 0.5)); + lumaEndP = tmpvar_214; + }; + float tmpvar_215; + tmpvar_215 = abs (lumaEndN); + bool tmpvar_216; + tmpvar_216 = (tmpvar_215 >= gradientScaled); + doneN = tmpvar_216; + float tmpvar_217; + tmpvar_217 = abs (lumaEndP); + bool tmpvar_218; + tmpvar_218 = (tmpvar_217 >= gradientScaled); + doneP = tmpvar_218; + if (!(doneN)) { + float tmpvar_219; + tmpvar_219 = (posN.x - (offNP.x * 1.5)); + posN.x = tmpvar_219; + }; + if (!(doneN)) { + float tmpvar_220; + tmpvar_220 = (posN.y - (offNP.y * 1.5)); + posN.y = vec2(tmpvar_220).y; + }; + bool tmpvar_221; + if (!(doneN)) { + tmpvar_221 = bool(1); + } else { + tmpvar_221 = !(doneP); + }; + bool tmpvar_222; + tmpvar_222 = tmpvar_221; + doneNP = tmpvar_222; + if (!(doneP)) { + float tmpvar_223; + tmpvar_223 = (posP.x + (offNP.x * 1.5)); + posP.x = tmpvar_223; + }; + if (!(doneP)) { + float tmpvar_224; + tmpvar_224 = (posP.y + (offNP.y * 1.5)); + posP.y = vec2(tmpvar_224).y; + }; + if (doneNP) { + if (!(doneN)) { + vec4 tmpvar_225; + tmpvar_225.zw = vec2(0.0, 0.0); + tmpvar_225.xy = posN.xy.xy; + vec4 tmpvar_226; + tmpvar_226 = xll_tex2Dlod (tex, tmpvar_225); + float tmpvar_227; + tmpvar_227 = FxaaLuma (tmpvar_226); + float tmpvar_228; + tmpvar_228 = tmpvar_227; + lumaEndN = tmpvar_228; + }; + if (!(doneP)) { + vec4 tmpvar_229; + tmpvar_229.zw = vec2(0.0, 0.0); + tmpvar_229.xy = posP.xy.xy; + vec4 tmpvar_230; + tmpvar_230 = xll_tex2Dlod (tex, tmpvar_229); + float tmpvar_231; + tmpvar_231 = FxaaLuma (tmpvar_230); + float tmpvar_232; + tmpvar_232 = tmpvar_231; + lumaEndP = tmpvar_232; + }; + if (!(doneN)) { + float tmpvar_233; + tmpvar_233 = (lumaEndN - (lumaNN * 0.5)); + lumaEndN = tmpvar_233; + }; + if (!(doneP)) { + float tmpvar_234; + tmpvar_234 = (lumaEndP - (lumaNN * 0.5)); + lumaEndP = tmpvar_234; + }; + float tmpvar_235; + tmpvar_235 = abs (lumaEndN); + bool tmpvar_236; + tmpvar_236 = (tmpvar_235 >= gradientScaled); + doneN = tmpvar_236; + float tmpvar_237; + tmpvar_237 = abs (lumaEndP); + bool tmpvar_238; + tmpvar_238 = (tmpvar_237 >= gradientScaled); + doneP = tmpvar_238; + if (!(doneN)) { + float tmpvar_239; + tmpvar_239 = (posN.x - (offNP.x * 2.0)); + posN.x = tmpvar_239; + }; + if (!(doneN)) { + float tmpvar_240; + tmpvar_240 = (posN.y - (offNP.y * 2.0)); + posN.y = vec2(tmpvar_240).y; + }; + bool tmpvar_241; + if (!(doneN)) { + tmpvar_241 = bool(1); + } else { + tmpvar_241 = !(doneP); + }; + bool tmpvar_242; + tmpvar_242 = tmpvar_241; + doneNP = tmpvar_242; + if (!(doneP)) { + float tmpvar_243; + tmpvar_243 = (posP.x + (offNP.x * 2.0)); + posP.x = tmpvar_243; + }; + if (!(doneP)) { + float tmpvar_244; + tmpvar_244 = (posP.y + (offNP.y * 2.0)); + posP.y = vec2(tmpvar_244).y; + }; + if (doneNP) { + if (!(doneN)) { + vec4 tmpvar_245; + tmpvar_245.zw = vec2(0.0, 0.0); + tmpvar_245.xy = posN.xy.xy; + vec4 tmpvar_246; + tmpvar_246 = xll_tex2Dlod (tex, tmpvar_245); + float tmpvar_247; + tmpvar_247 = FxaaLuma (tmpvar_246); + float tmpvar_248; + tmpvar_248 = tmpvar_247; + lumaEndN = tmpvar_248; + }; + if (!(doneP)) { + vec4 tmpvar_249; + tmpvar_249.zw = vec2(0.0, 0.0); + tmpvar_249.xy = posP.xy.xy; + vec4 tmpvar_250; + tmpvar_250 = xll_tex2Dlod (tex, tmpvar_249); + float tmpvar_251; + tmpvar_251 = FxaaLuma (tmpvar_250); + float tmpvar_252; + tmpvar_252 = tmpvar_251; + lumaEndP = tmpvar_252; + }; + if (!(doneN)) { + float tmpvar_253; + tmpvar_253 = (lumaEndN - (lumaNN * 0.5)); + lumaEndN = tmpvar_253; + }; + if (!(doneP)) { + float tmpvar_254; + tmpvar_254 = (lumaEndP - (lumaNN * 0.5)); + lumaEndP = tmpvar_254; + }; + float tmpvar_255; + tmpvar_255 = abs (lumaEndN); + bool tmpvar_256; + tmpvar_256 = (tmpvar_255 >= gradientScaled); + doneN = tmpvar_256; + float tmpvar_257; + tmpvar_257 = abs (lumaEndP); + bool tmpvar_258; + tmpvar_258 = (tmpvar_257 >= gradientScaled); + doneP = tmpvar_258; + if (!(doneN)) { + float tmpvar_259; + tmpvar_259 = (posN.x - (offNP.x * 2.0)); + posN.x = tmpvar_259; + }; + if (!(doneN)) { + float tmpvar_260; + tmpvar_260 = (posN.y - (offNP.y * 2.0)); + posN.y = vec2(tmpvar_260).y; + }; + bool tmpvar_261; + if (!(doneN)) { + tmpvar_261 = bool(1); + } else { + tmpvar_261 = !(doneP); + }; + bool tmpvar_262; + tmpvar_262 = tmpvar_261; + doneNP = tmpvar_262; + if (!(doneP)) { + float tmpvar_263; + tmpvar_263 = (posP.x + (offNP.x * 2.0)); + posP.x = tmpvar_263; + }; + if (!(doneP)) { + float tmpvar_264; + tmpvar_264 = (posP.y + (offNP.y * 2.0)); + posP.y = vec2(tmpvar_264).y; + }; + if (doneNP) { + if (!(doneN)) { + vec4 tmpvar_265; + tmpvar_265.zw = vec2(0.0, 0.0); + tmpvar_265.xy = posN.xy.xy; + vec4 tmpvar_266; + tmpvar_266 = xll_tex2Dlod (tex, tmpvar_265); + float tmpvar_267; + tmpvar_267 = FxaaLuma (tmpvar_266); + float tmpvar_268; + tmpvar_268 = tmpvar_267; + lumaEndN = tmpvar_268; + }; + if (!(doneP)) { + vec4 tmpvar_269; + tmpvar_269.zw = vec2(0.0, 0.0); + tmpvar_269.xy = posP.xy.xy; + vec4 tmpvar_270; + tmpvar_270 = xll_tex2Dlod (tex, tmpvar_269); + float tmpvar_271; + tmpvar_271 = FxaaLuma (tmpvar_270); + float tmpvar_272; + tmpvar_272 = tmpvar_271; + lumaEndP = tmpvar_272; + }; + if (!(doneN)) { + float tmpvar_273; + tmpvar_273 = (lumaEndN - (lumaNN * 0.5)); + lumaEndN = tmpvar_273; + }; + if (!(doneP)) { + float tmpvar_274; + tmpvar_274 = (lumaEndP - (lumaNN * 0.5)); + lumaEndP = tmpvar_274; + }; + float tmpvar_275; + tmpvar_275 = abs (lumaEndN); + bool tmpvar_276; + tmpvar_276 = (tmpvar_275 >= gradientScaled); + doneN = tmpvar_276; + float tmpvar_277; + tmpvar_277 = abs (lumaEndP); + bool tmpvar_278; + tmpvar_278 = (tmpvar_277 >= gradientScaled); + doneP = tmpvar_278; + if (!(doneN)) { + float tmpvar_279; + tmpvar_279 = (posN.x - (offNP.x * 2.0)); + posN.x = tmpvar_279; + }; + if (!(doneN)) { + float tmpvar_280; + tmpvar_280 = (posN.y - (offNP.y * 2.0)); + posN.y = vec2(tmpvar_280).y; + }; + bool tmpvar_281; + if (!(doneN)) { + tmpvar_281 = bool(1); + } else { + tmpvar_281 = !(doneP); + }; + bool tmpvar_282; + tmpvar_282 = tmpvar_281; + doneNP = tmpvar_282; + if (!(doneP)) { + float tmpvar_283; + tmpvar_283 = (posP.x + (offNP.x * 2.0)); + posP.x = tmpvar_283; + }; + if (!(doneP)) { + float tmpvar_284; + tmpvar_284 = (posP.y + (offNP.y * 2.0)); + posP.y = vec2(tmpvar_284).y; + }; + if (doneNP) { + if (!(doneN)) { + vec4 tmpvar_285; + tmpvar_285.zw = vec2(0.0, 0.0); + tmpvar_285.xy = posN.xy.xy; + vec4 tmpvar_286; + tmpvar_286 = xll_tex2Dlod (tex, tmpvar_285); + float tmpvar_287; + tmpvar_287 = FxaaLuma (tmpvar_286); + float tmpvar_288; + tmpvar_288 = tmpvar_287; + lumaEndN = tmpvar_288; + }; + if (!(doneP)) { + vec4 tmpvar_289; + tmpvar_289.zw = vec2(0.0, 0.0); + tmpvar_289.xy = posP.xy.xy; + vec4 tmpvar_290; + tmpvar_290 = xll_tex2Dlod (tex, tmpvar_289); + float tmpvar_291; + tmpvar_291 = FxaaLuma (tmpvar_290); + float tmpvar_292; + tmpvar_292 = tmpvar_291; + lumaEndP = tmpvar_292; + }; + if (!(doneN)) { + float tmpvar_293; + tmpvar_293 = (lumaEndN - (lumaNN * 0.5)); + lumaEndN = tmpvar_293; + }; + if (!(doneP)) { + float tmpvar_294; + tmpvar_294 = (lumaEndP - (lumaNN * 0.5)); + lumaEndP = tmpvar_294; + }; + float tmpvar_295; + tmpvar_295 = abs (lumaEndN); + bool tmpvar_296; + tmpvar_296 = (tmpvar_295 >= gradientScaled); + doneN = tmpvar_296; + float tmpvar_297; + tmpvar_297 = abs (lumaEndP); + bool tmpvar_298; + tmpvar_298 = (tmpvar_297 >= gradientScaled); + doneP = tmpvar_298; + if (!(doneN)) { + float tmpvar_299; + tmpvar_299 = (posN.x - (offNP.x * 2.0)); + posN.x = tmpvar_299; + }; + if (!(doneN)) { + float tmpvar_300; + tmpvar_300 = (posN.y - (offNP.y * 2.0)); + posN.y = vec2(tmpvar_300).y; + }; + bool tmpvar_301; + if (!(doneN)) { + tmpvar_301 = bool(1); + } else { + tmpvar_301 = !(doneP); + }; + bool tmpvar_302; + tmpvar_302 = tmpvar_301; + doneNP = tmpvar_302; + if (!(doneP)) { + float tmpvar_303; + tmpvar_303 = (posP.x + (offNP.x * 2.0)); + posP.x = tmpvar_303; + }; + if (!(doneP)) { + float tmpvar_304; + tmpvar_304 = (posP.y + (offNP.y * 2.0)); + posP.y = vec2(tmpvar_304).y; + }; + if (doneNP) { + if (!(doneN)) { + vec4 tmpvar_305; + tmpvar_305.zw = vec2(0.0, 0.0); + tmpvar_305.xy = posN.xy.xy; + vec4 tmpvar_306; + tmpvar_306 = xll_tex2Dlod (tex, tmpvar_305); + float tmpvar_307; + tmpvar_307 = FxaaLuma (tmpvar_306); + float tmpvar_308; + tmpvar_308 = tmpvar_307; + lumaEndN = tmpvar_308; + }; + if (!(doneP)) { + vec4 tmpvar_309; + tmpvar_309.zw = vec2(0.0, 0.0); + tmpvar_309.xy = posP.xy.xy; + vec4 tmpvar_310; + tmpvar_310 = xll_tex2Dlod (tex, tmpvar_309); + float tmpvar_311; + tmpvar_311 = FxaaLuma (tmpvar_310); + float tmpvar_312; + tmpvar_312 = tmpvar_311; + lumaEndP = tmpvar_312; + }; + if (!(doneN)) { + float tmpvar_313; + tmpvar_313 = (lumaEndN - (lumaNN * 0.5)); + lumaEndN = tmpvar_313; + }; + if (!(doneP)) { + float tmpvar_314; + tmpvar_314 = (lumaEndP - (lumaNN * 0.5)); + lumaEndP = tmpvar_314; + }; + float tmpvar_315; + tmpvar_315 = abs (lumaEndN); + bool tmpvar_316; + tmpvar_316 = (tmpvar_315 >= gradientScaled); + doneN = tmpvar_316; + float tmpvar_317; + tmpvar_317 = abs (lumaEndP); + bool tmpvar_318; + tmpvar_318 = (tmpvar_317 >= gradientScaled); + doneP = tmpvar_318; + if (!(doneN)) { + float tmpvar_319; + tmpvar_319 = (posN.x - (offNP.x * 4.0)); + posN.x = tmpvar_319; + }; + if (!(doneN)) { + float tmpvar_320; + tmpvar_320 = (posN.y - (offNP.y * 4.0)); + posN.y = vec2(tmpvar_320).y; + }; + bool tmpvar_321; + if (!(doneN)) { + tmpvar_321 = bool(1); + } else { + tmpvar_321 = !(doneP); + }; + bool tmpvar_322; + tmpvar_322 = tmpvar_321; + doneNP = tmpvar_322; + if (!(doneP)) { + float tmpvar_323; + tmpvar_323 = (posP.x + (offNP.x * 4.0)); + posP.x = tmpvar_323; + }; + if (!(doneP)) { + float tmpvar_324; + tmpvar_324 = (posP.y + (offNP.y * 4.0)); + posP.y = vec2(tmpvar_324).y; + }; + if (doneNP) { + if (!(doneN)) { + vec4 tmpvar_325; + tmpvar_325.zw = vec2(0.0, 0.0); + tmpvar_325.xy = posN.xy.xy; + vec4 tmpvar_326; + tmpvar_326 = xll_tex2Dlod (tex, tmpvar_325); + float tmpvar_327; + tmpvar_327 = FxaaLuma (tmpvar_326); + float tmpvar_328; + tmpvar_328 = tmpvar_327; + lumaEndN = tmpvar_328; + }; + if (!(doneP)) { + vec4 tmpvar_329; + tmpvar_329.zw = vec2(0.0, 0.0); + tmpvar_329.xy = posP.xy.xy; + vec4 tmpvar_330; + tmpvar_330 = xll_tex2Dlod (tex, tmpvar_329); + float tmpvar_331; + tmpvar_331 = FxaaLuma (tmpvar_330); + float tmpvar_332; + tmpvar_332 = tmpvar_331; + lumaEndP = tmpvar_332; + }; + if (!(doneN)) { + float tmpvar_333; + tmpvar_333 = (lumaEndN - (lumaNN * 0.5)); + lumaEndN = tmpvar_333; + }; + if (!(doneP)) { + float tmpvar_334; + tmpvar_334 = (lumaEndP - (lumaNN * 0.5)); + lumaEndP = tmpvar_334; + }; + float tmpvar_335; + tmpvar_335 = abs (lumaEndN); + bool tmpvar_336; + tmpvar_336 = (tmpvar_335 >= gradientScaled); + doneN = tmpvar_336; + float tmpvar_337; + tmpvar_337 = abs (lumaEndP); + bool tmpvar_338; + tmpvar_338 = (tmpvar_337 >= gradientScaled); + doneP = tmpvar_338; + if (!(doneN)) { + float tmpvar_339; + tmpvar_339 = (posN.x - (offNP.x * 8.0)); + posN.x = tmpvar_339; + }; + if (!(doneN)) { + float tmpvar_340; + tmpvar_340 = (posN.y - (offNP.y * 8.0)); + posN.y = vec2(tmpvar_340).y; + }; + bool tmpvar_341; + if (!(doneN)) { + tmpvar_341 = bool(1); + } else { + tmpvar_341 = !(doneP); + }; + bool tmpvar_342; + tmpvar_342 = tmpvar_341; + doneNP = tmpvar_342; + if (!(doneP)) { + float tmpvar_343; + tmpvar_343 = (posP.x + (offNP.x * 8.0)); + posP.x = tmpvar_343; + }; + if (!(doneP)) { + float tmpvar_344; + tmpvar_344 = (posP.y + (offNP.y * 8.0)); + posP.y = vec2(tmpvar_344).y; + }; + }; + }; + }; + }; + }; + }; + }; + }; + }; + }; + float tmpvar_345; + tmpvar_345 = (posM.x - posN.x); + dstN = tmpvar_345; + float tmpvar_346; + tmpvar_346 = (posP.x - posM.x); + dstP = tmpvar_346; + if (!(horzSpan)) { + float tmpvar_347; + tmpvar_347 = (posM.y - posN.y); + dstN = tmpvar_347; + }; + if (!(horzSpan)) { + float tmpvar_348; + tmpvar_348 = (posP.y - posM.y); + dstP = tmpvar_348; + }; + bool tmpvar_349; + tmpvar_349 = ((lumaEndN < 0.0) != lumaMLTZero); + goodSpanN = tmpvar_349; + float tmpvar_350; + tmpvar_350 = (dstP + dstN); + spanLength = tmpvar_350; + bool tmpvar_351; + tmpvar_351 = ((lumaEndP < 0.0) != lumaMLTZero); + goodSpanP = tmpvar_351; + float tmpvar_352; + tmpvar_352 = (1.0 / spanLength); + spanLengthRcp = tmpvar_352; + bool tmpvar_353; + tmpvar_353 = (dstN < dstP); + directionN = tmpvar_353; + float tmpvar_354; + tmpvar_354 = min (dstN, dstP); + float tmpvar_355; + tmpvar_355 = tmpvar_354; + dst = tmpvar_355; + bool tmpvar_356; + if (directionN) { + tmpvar_356 = goodSpanN; + } else { + tmpvar_356 = goodSpanP; + }; + bool tmpvar_357; + tmpvar_357 = tmpvar_356; + goodSpan = tmpvar_357; + float tmpvar_358; + tmpvar_358 = (subpixF * subpixF); + subpixG = tmpvar_358; + float tmpvar_359; + tmpvar_359 = ((dst * -(spanLengthRcp)) + 0.5); + pixelOffset = tmpvar_359; + float tmpvar_360; + tmpvar_360 = (subpixG * fxaaQualitySubpix); + subpixH = tmpvar_360; + float tmpvar_361; + if (goodSpan) { + tmpvar_361 = pixelOffset; + } else { + tmpvar_361 = 0.0; + }; + float tmpvar_362; + tmpvar_362 = tmpvar_361; + pixelOffsetGood = tmpvar_362; + float tmpvar_363; + tmpvar_363 = max (pixelOffsetGood, subpixH); + float tmpvar_364; + tmpvar_364 = tmpvar_363; + pixelOffsetSubpix = tmpvar_364; + if (!(horzSpan)) { + float tmpvar_365; + tmpvar_365 = (posM.x + (pixelOffsetSubpix * lengthSign)); + posM.x = tmpvar_365; + }; + if (horzSpan) { + float tmpvar_366; + tmpvar_366 = (posM.y + (pixelOffsetSubpix * lengthSign)); + posM.y = vec2(tmpvar_366).y; + }; + vec4 tmpvar_367; + tmpvar_367.zw = vec2(0.0, 0.0); + tmpvar_367.xy = posM.xy; + vec4 tmpvar_368; + tmpvar_368 = xll_tex2Dlod (tex, tmpvar_367); + vec4 tmpvar_369; + tmpvar_369.xyz = tmpvar_368.xyz.xyz; + tmpvar_369.w = rgbyM.w; + return tmpvar_369; +} + +vec4 xlat_main ( + in v2f i +) +{ + float fxaaN; + float tmpvar_1; + tmpvar_1 = 0.5; + fxaaN = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2.x = -(fxaaN); + tmpvar_2.y = -(fxaaN); + tmpvar_2.z = fxaaN; + tmpvar_2.w = fxaaN; + vec4 tmpvar_3; + tmpvar_3 = FxaaPixelShader (i.uv, i.uvPosPos, _MainTex, _MainTex, _MainTex, _MainTex_TexelSize.xy, (_MainTex_TexelSize.xyxy * tmpvar_2), (_MainTex_TexelSize.xyxy * vec4(-2.0, -2.0, 2.0, 2.0)), (_MainTex_TexelSize.xyxy * vec4(8.0, 8.0, -4.0, -4.0)), 0.75, 0.166, 0.0833, 8.0, 0.125, 0.05, vec4(1.0, -1.0, 0.25, -0.25)); + return tmpvar_3; +} + +void main () +{ + v2f xlt_i; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = xlv_SV_POSITION.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_i.pos = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = xlv_TEXCOORD0.xy; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_i.uv = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = xlv_TEXCOORD1.xyzw; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_i.uvPosPos = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = xlat_main (xlt_i); + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xl_retval = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = xl_retval.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + gl_FragData[0] = tmpvar_10; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/complex-fxaa3-11-pc39-irES.txt b/3rdparty/glsl-optimizer/tests/fragment/complex-fxaa3-11-pc39-irES.txt new file mode 100644 index 000000000..0fd857dd4 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/complex-fxaa3-11-pc39-irES.txt @@ -0,0 +1,1542 @@ +#extension GL_EXT_shader_texture_lod : enable +struct v2f { + highp vec4 pos; + highp vec2 uv; + highp vec4 uvPosPos; +}; +varying highp vec4 xlv_TEXCOORD1; +varying highp vec2 xlv_TEXCOORD0; +varying highp vec4 xlv_SV_POSITION; +uniform highp vec4 _MainTex_TexelSize; +uniform sampler2D _MainTex; +vec4 xll_tex2Dlod ( + in sampler2D s, + in vec4 coord +) +{ + lowp vec4 tmpvar_1; + tmpvar_1 = texture2DLodEXT (s, coord.xy, coord.w); + return tmpvar_1; +} + +float xll_saturate ( + in float x +) +{ + float tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec2 xll_saturate ( + in vec2 x +) +{ + vec2 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec3 xll_saturate ( + in vec3 x +) +{ + vec3 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec4 xll_saturate ( + in vec4 x +) +{ + vec4 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +mat2 xll_saturate ( + in mat2 m +) +{ + vec2 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec2 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + mat2 tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_1; + tmpvar_3[0] = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5 = tmpvar_2; + tmpvar_3[1] = tmpvar_5; + return tmpvar_3; +} + +mat3 xll_saturate ( + in mat3 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec3 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + vec3 tmpvar_3; + tmpvar_3 = clamp (m[2], 0.0, 1.0); + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +mat4 xll_saturate ( + in mat4 m +) +{ + vec4 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec4 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + vec4 tmpvar_3; + tmpvar_3 = clamp (m[2], 0.0, 1.0); + vec4 tmpvar_4; + tmpvar_4 = clamp (m[3], 0.0, 1.0); + mat4 tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_1; + tmpvar_5[0] = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = tmpvar_2; + tmpvar_5[1] = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_3; + tmpvar_5[2] = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = tmpvar_4; + tmpvar_5[3] = tmpvar_9; + return tmpvar_5; +} + +float FxaaLuma ( + in highp vec4 rgba +) +{ + return rgba.w; +} + +vec4 FxaaPixelShader ( + in highp vec2 pos, + in highp vec4 fxaaConsolePosPos, + in sampler2D tex, + in sampler2D fxaaConsole360TexExpBiasNegOne, + in sampler2D fxaaConsole360TexExpBiasNegTwo, + in highp vec2 fxaaQualityRcpFrame, + in highp vec4 fxaaConsoleRcpFrameOpt, + in highp vec4 fxaaConsoleRcpFrameOpt2, + in highp vec4 fxaaConsole360RcpFrameOpt2, + in highp float fxaaQualitySubpix, + in highp float fxaaQualityEdgeThreshold, + in highp float fxaaQualityEdgeThresholdMin, + in highp float fxaaConsoleEdgeSharpness, + in highp float fxaaConsoleEdgeThreshold, + in highp float fxaaConsoleEdgeThresholdMin, + in highp vec4 fxaaConsole360ConstDir +) +{ + highp float pixelOffsetSubpix; + highp float pixelOffsetGood; + highp float subpixH; + highp float pixelOffset; + highp float subpixG; + bool goodSpan; + highp float dst; + bool directionN; + highp float spanLengthRcp; + bool goodSpanP; + highp float spanLength; + bool goodSpanN; + highp float dstP; + highp float dstN; + bool doneNP; + bool doneP; + bool doneN; + bool lumaMLTZero; + highp float subpixF; + highp float lumaMM; + highp float gradientScaled; + highp float lumaEndP; + highp float subpixE; + highp float lumaEndN; + highp float subpixD; + highp vec2 posP; + highp vec2 posN; + highp vec2 offNP; + highp vec2 posB; + highp float subpixC; + highp float gradient; + bool pairN; + highp float lumaSS; + highp float lumaNN; + highp float gradientS; + highp float gradientN; + highp float subpixB; + highp float subpixA; + bool horzSpan; + highp float lengthSign; + highp float subpixNWSWNESE; + highp float edgeVert; + highp float edgeHorz; + highp float edgeVert3; + highp float edgeHorz3; + highp float edgeVert4; + highp float edgeHorz4; + highp float lumaSWSE; + highp float lumaNWSW; + highp float edgeVert2; + highp float edgeHorz2; + highp float lumaNWNE; + highp float lumaNESE; + highp float edgeVert1; + highp float edgeHorz1; + highp float subpixNSWE; + highp float subpixRcpRange; + highp float lumaWE; + highp float lumaNS; + highp float lumaSW; + highp float lumaNE; + highp float lumaSE; + highp float lumaNW; + bool earlyExit; + highp float rangeMaxClamped; + highp float range; + highp float rangeMaxScaled; + highp float rangeMin; + highp float rangeMax; + highp float minWN; + highp float maxWN; + highp float minESM; + highp float maxESM; + highp float minSM; + highp float maxSM; + highp float lumaW; + highp float lumaN; + highp float lumaE; + highp float lumaS; + highp vec4 rgbyM; + highp vec2 posM; + highp float tmpvar_1; + tmpvar_1 = pos.x; + posM.x = tmpvar_1; + highp float tmpvar_2; + tmpvar_2 = pos.y; + posM.y = vec2(tmpvar_2).y; + highp vec4 tmpvar_3; + tmpvar_3.zw = vec2(0.0, 0.0); + tmpvar_3.xy = posM.xy; + vec4 tmpvar_4; + tmpvar_4 = xll_tex2Dlod (tex, tmpvar_3); + vec4 tmpvar_5; + tmpvar_5 = tmpvar_4; + rgbyM = tmpvar_5; + highp vec4 tmpvar_6; + tmpvar_6.zw = vec2(0.0, 0.0); + tmpvar_6.xy = (posM + (vec2(0.0, 1.0) * fxaaQualityRcpFrame.xy)).xy; + vec4 tmpvar_7; + tmpvar_7 = xll_tex2Dlod (tex, tmpvar_6); + highp float tmpvar_8; + tmpvar_8 = FxaaLuma (tmpvar_7); + highp float tmpvar_9; + tmpvar_9 = tmpvar_8; + lumaS = tmpvar_9; + highp vec4 tmpvar_10; + tmpvar_10.zw = vec2(0.0, 0.0); + tmpvar_10.xy = (posM + (vec2(1.0, 0.0) * fxaaQualityRcpFrame.xy)).xy; + vec4 tmpvar_11; + tmpvar_11 = xll_tex2Dlod (tex, tmpvar_10); + highp float tmpvar_12; + tmpvar_12 = FxaaLuma (tmpvar_11); + highp float tmpvar_13; + tmpvar_13 = tmpvar_12; + lumaE = tmpvar_13; + highp vec4 tmpvar_14; + tmpvar_14.zw = vec2(0.0, 0.0); + tmpvar_14.xy = (posM + (vec2(0.0, -1.0) * fxaaQualityRcpFrame.xy)).xy; + vec4 tmpvar_15; + tmpvar_15 = xll_tex2Dlod (tex, tmpvar_14); + highp float tmpvar_16; + tmpvar_16 = FxaaLuma (tmpvar_15); + highp float tmpvar_17; + tmpvar_17 = tmpvar_16; + lumaN = tmpvar_17; + highp vec4 tmpvar_18; + tmpvar_18.zw = vec2(0.0, 0.0); + tmpvar_18.xy = (posM + (vec2(-1.0, 0.0) * fxaaQualityRcpFrame.xy)).xy; + vec4 tmpvar_19; + tmpvar_19 = xll_tex2Dlod (tex, tmpvar_18); + highp float tmpvar_20; + tmpvar_20 = FxaaLuma (tmpvar_19); + highp float tmpvar_21; + tmpvar_21 = tmpvar_20; + lumaW = tmpvar_21; + highp float tmpvar_22; + tmpvar_22 = max (lumaS, rgbyM.w); + highp float tmpvar_23; + tmpvar_23 = tmpvar_22; + maxSM = tmpvar_23; + highp float tmpvar_24; + tmpvar_24 = min (lumaS, rgbyM.w); + highp float tmpvar_25; + tmpvar_25 = tmpvar_24; + minSM = tmpvar_25; + highp float tmpvar_26; + tmpvar_26 = max (lumaE, maxSM); + highp float tmpvar_27; + tmpvar_27 = tmpvar_26; + maxESM = tmpvar_27; + highp float tmpvar_28; + tmpvar_28 = min (lumaE, minSM); + highp float tmpvar_29; + tmpvar_29 = tmpvar_28; + minESM = tmpvar_29; + highp float tmpvar_30; + tmpvar_30 = max (lumaN, lumaW); + highp float tmpvar_31; + tmpvar_31 = tmpvar_30; + maxWN = tmpvar_31; + highp float tmpvar_32; + tmpvar_32 = min (lumaN, lumaW); + highp float tmpvar_33; + tmpvar_33 = tmpvar_32; + minWN = tmpvar_33; + highp float tmpvar_34; + tmpvar_34 = max (maxWN, maxESM); + highp float tmpvar_35; + tmpvar_35 = tmpvar_34; + rangeMax = tmpvar_35; + highp float tmpvar_36; + tmpvar_36 = min (minWN, minESM); + highp float tmpvar_37; + tmpvar_37 = tmpvar_36; + rangeMin = tmpvar_37; + highp float tmpvar_38; + tmpvar_38 = (rangeMax * fxaaQualityEdgeThreshold); + rangeMaxScaled = tmpvar_38; + highp float tmpvar_39; + tmpvar_39 = (rangeMax - rangeMin); + range = tmpvar_39; + highp float tmpvar_40; + tmpvar_40 = max (fxaaQualityEdgeThresholdMin, rangeMaxScaled); + highp float tmpvar_41; + tmpvar_41 = tmpvar_40; + rangeMaxClamped = tmpvar_41; + bool tmpvar_42; + tmpvar_42 = (range < rangeMaxClamped); + earlyExit = tmpvar_42; + if (earlyExit) { + return rgbyM; + }; + highp vec4 tmpvar_43; + tmpvar_43.zw = vec2(0.0, 0.0); + tmpvar_43.xy = (posM + (vec2(-1.0, -1.0) * fxaaQualityRcpFrame.xy)).xy; + vec4 tmpvar_44; + tmpvar_44 = xll_tex2Dlod (tex, tmpvar_43); + highp float tmpvar_45; + tmpvar_45 = FxaaLuma (tmpvar_44); + highp float tmpvar_46; + tmpvar_46 = tmpvar_45; + lumaNW = tmpvar_46; + highp vec4 tmpvar_47; + tmpvar_47.zw = vec2(0.0, 0.0); + tmpvar_47.xy = (posM + (vec2(1.0, 1.0) * fxaaQualityRcpFrame.xy)).xy; + vec4 tmpvar_48; + tmpvar_48 = xll_tex2Dlod (tex, tmpvar_47); + highp float tmpvar_49; + tmpvar_49 = FxaaLuma (tmpvar_48); + highp float tmpvar_50; + tmpvar_50 = tmpvar_49; + lumaSE = tmpvar_50; + highp vec4 tmpvar_51; + tmpvar_51.zw = vec2(0.0, 0.0); + tmpvar_51.xy = (posM + (vec2(1.0, -1.0) * fxaaQualityRcpFrame.xy)).xy; + vec4 tmpvar_52; + tmpvar_52 = xll_tex2Dlod (tex, tmpvar_51); + highp float tmpvar_53; + tmpvar_53 = FxaaLuma (tmpvar_52); + highp float tmpvar_54; + tmpvar_54 = tmpvar_53; + lumaNE = tmpvar_54; + highp vec4 tmpvar_55; + tmpvar_55.zw = vec2(0.0, 0.0); + tmpvar_55.xy = (posM + (vec2(-1.0, 1.0) * fxaaQualityRcpFrame.xy)).xy; + vec4 tmpvar_56; + tmpvar_56 = xll_tex2Dlod (tex, tmpvar_55); + highp float tmpvar_57; + tmpvar_57 = FxaaLuma (tmpvar_56); + highp float tmpvar_58; + tmpvar_58 = tmpvar_57; + lumaSW = tmpvar_58; + highp float tmpvar_59; + tmpvar_59 = (lumaN + lumaS); + lumaNS = tmpvar_59; + highp float tmpvar_60; + tmpvar_60 = (lumaW + lumaE); + lumaWE = tmpvar_60; + highp float tmpvar_61; + tmpvar_61 = (1.0 / range); + subpixRcpRange = tmpvar_61; + highp float tmpvar_62; + tmpvar_62 = (lumaNS + lumaWE); + subpixNSWE = tmpvar_62; + highp float tmpvar_63; + tmpvar_63 = ((-(2.0) * rgbyM.w) + lumaNS); + edgeHorz1 = tmpvar_63; + highp float tmpvar_64; + tmpvar_64 = ((-(2.0) * rgbyM.w) + lumaWE); + edgeVert1 = tmpvar_64; + highp float tmpvar_65; + tmpvar_65 = (lumaNE + lumaSE); + lumaNESE = tmpvar_65; + highp float tmpvar_66; + tmpvar_66 = (lumaNW + lumaNE); + lumaNWNE = tmpvar_66; + highp float tmpvar_67; + tmpvar_67 = ((-(2.0) * lumaE) + lumaNESE); + edgeHorz2 = tmpvar_67; + highp float tmpvar_68; + tmpvar_68 = ((-(2.0) * lumaN) + lumaNWNE); + edgeVert2 = tmpvar_68; + highp float tmpvar_69; + tmpvar_69 = (lumaNW + lumaSW); + lumaNWSW = tmpvar_69; + highp float tmpvar_70; + tmpvar_70 = (lumaSW + lumaSE); + lumaSWSE = tmpvar_70; + highp float tmpvar_71; + tmpvar_71 = abs (edgeHorz1); + highp float tmpvar_72; + tmpvar_72 = abs (edgeHorz2); + highp float tmpvar_73; + tmpvar_73 = ((tmpvar_71 * 2.0) + tmpvar_72); + edgeHorz4 = tmpvar_73; + highp float tmpvar_74; + tmpvar_74 = abs (edgeVert1); + highp float tmpvar_75; + tmpvar_75 = abs (edgeVert2); + highp float tmpvar_76; + tmpvar_76 = ((tmpvar_74 * 2.0) + tmpvar_75); + edgeVert4 = tmpvar_76; + highp float tmpvar_77; + tmpvar_77 = ((-(2.0) * lumaW) + lumaNWSW); + edgeHorz3 = tmpvar_77; + highp float tmpvar_78; + tmpvar_78 = ((-(2.0) * lumaS) + lumaSWSE); + edgeVert3 = tmpvar_78; + highp float tmpvar_79; + tmpvar_79 = abs (edgeHorz3); + highp float tmpvar_80; + tmpvar_80 = (tmpvar_79 + edgeHorz4); + edgeHorz = tmpvar_80; + highp float tmpvar_81; + tmpvar_81 = abs (edgeVert3); + highp float tmpvar_82; + tmpvar_82 = (tmpvar_81 + edgeVert4); + edgeVert = tmpvar_82; + highp float tmpvar_83; + tmpvar_83 = (lumaNWSW + lumaNESE); + subpixNWSWNESE = tmpvar_83; + highp float tmpvar_84; + tmpvar_84 = fxaaQualityRcpFrame.x; + lengthSign = tmpvar_84; + bool tmpvar_85; + tmpvar_85 = (edgeHorz >= edgeVert); + horzSpan = tmpvar_85; + highp float tmpvar_86; + tmpvar_86 = ((subpixNSWE * 2.0) + subpixNWSWNESE); + subpixA = tmpvar_86; + if (!(horzSpan)) { + highp float tmpvar_87; + tmpvar_87 = lumaW; + lumaN = tmpvar_87; + }; + if (!(horzSpan)) { + highp float tmpvar_88; + tmpvar_88 = lumaE; + lumaS = tmpvar_88; + }; + if (horzSpan) { + highp float tmpvar_89; + tmpvar_89 = fxaaQualityRcpFrame.y; + lengthSign = tmpvar_89; + }; + highp float tmpvar_90; + tmpvar_90 = ((subpixA * 0.0833333) - rgbyM.w); + subpixB = tmpvar_90; + highp float tmpvar_91; + tmpvar_91 = (lumaN - rgbyM.w); + gradientN = tmpvar_91; + highp float tmpvar_92; + tmpvar_92 = (lumaS - rgbyM.w); + gradientS = tmpvar_92; + highp float tmpvar_93; + tmpvar_93 = (lumaN + rgbyM.w); + lumaNN = tmpvar_93; + highp float tmpvar_94; + tmpvar_94 = (lumaS + rgbyM.w); + lumaSS = tmpvar_94; + highp float tmpvar_95; + tmpvar_95 = abs (gradientN); + highp float tmpvar_96; + tmpvar_96 = abs (gradientS); + bool tmpvar_97; + tmpvar_97 = (tmpvar_95 >= tmpvar_96); + pairN = tmpvar_97; + highp float tmpvar_98; + tmpvar_98 = abs (gradientN); + highp float tmpvar_99; + tmpvar_99 = abs (gradientS); + highp float tmpvar_100; + tmpvar_100 = max (tmpvar_98, tmpvar_99); + highp float tmpvar_101; + tmpvar_101 = tmpvar_100; + gradient = tmpvar_101; + if (pairN) { + highp float tmpvar_102; + tmpvar_102 = -(lengthSign); + lengthSign = tmpvar_102; + }; + highp float tmpvar_103; + tmpvar_103 = abs (subpixB); + float tmpvar_104; + tmpvar_104 = xll_saturate ((tmpvar_103 * subpixRcpRange)); + float tmpvar_105; + tmpvar_105 = tmpvar_104; + subpixC = tmpvar_105; + highp float tmpvar_106; + tmpvar_106 = posM.x; + posB.x = tmpvar_106; + highp float tmpvar_107; + tmpvar_107 = posM.y; + posB.y = vec2(tmpvar_107).y; + highp float tmpvar_108; + if (!(horzSpan)) { + tmpvar_108 = 0.0; + } else { + tmpvar_108 = fxaaQualityRcpFrame.x; + }; + highp float tmpvar_109; + tmpvar_109 = tmpvar_108; + offNP.x = tmpvar_109; + highp float tmpvar_110; + if (horzSpan) { + tmpvar_110 = 0.0; + } else { + tmpvar_110 = fxaaQualityRcpFrame.y; + }; + highp float tmpvar_111; + tmpvar_111 = tmpvar_110; + offNP.y = vec2(tmpvar_111).y; + if (!(horzSpan)) { + highp float tmpvar_112; + tmpvar_112 = (posB.x + (lengthSign * 0.5)); + posB.x = tmpvar_112; + }; + if (horzSpan) { + highp float tmpvar_113; + tmpvar_113 = (posB.y + (lengthSign * 0.5)); + posB.y = vec2(tmpvar_113).y; + }; + highp float tmpvar_114; + tmpvar_114 = (posB.x - (offNP.x * 1.0)); + posN.x = tmpvar_114; + highp float tmpvar_115; + tmpvar_115 = (posB.y - (offNP.y * 1.0)); + posN.y = vec2(tmpvar_115).y; + highp float tmpvar_116; + tmpvar_116 = (posB.x + (offNP.x * 1.0)); + posP.x = tmpvar_116; + highp float tmpvar_117; + tmpvar_117 = (posB.y + (offNP.y * 1.0)); + posP.y = vec2(tmpvar_117).y; + highp float tmpvar_118; + tmpvar_118 = ((-(2.0) * subpixC) + 3.0); + subpixD = tmpvar_118; + highp vec4 tmpvar_119; + tmpvar_119.zw = vec2(0.0, 0.0); + tmpvar_119.xy = posN.xy; + vec4 tmpvar_120; + tmpvar_120 = xll_tex2Dlod (tex, tmpvar_119); + highp float tmpvar_121; + tmpvar_121 = FxaaLuma (tmpvar_120); + highp float tmpvar_122; + tmpvar_122 = tmpvar_121; + lumaEndN = tmpvar_122; + highp float tmpvar_123; + tmpvar_123 = (subpixC * subpixC); + subpixE = tmpvar_123; + highp vec4 tmpvar_124; + tmpvar_124.zw = vec2(0.0, 0.0); + tmpvar_124.xy = posP.xy; + vec4 tmpvar_125; + tmpvar_125 = xll_tex2Dlod (tex, tmpvar_124); + highp float tmpvar_126; + tmpvar_126 = FxaaLuma (tmpvar_125); + highp float tmpvar_127; + tmpvar_127 = tmpvar_126; + lumaEndP = tmpvar_127; + if (!(pairN)) { + highp float tmpvar_128; + tmpvar_128 = lumaSS; + lumaNN = tmpvar_128; + }; + highp float tmpvar_129; + tmpvar_129 = ((gradient * 1.0) / 4.0); + gradientScaled = tmpvar_129; + highp float tmpvar_130; + tmpvar_130 = (rgbyM.w - (lumaNN * 0.5)); + lumaMM = tmpvar_130; + highp float tmpvar_131; + tmpvar_131 = (subpixD * subpixE); + subpixF = tmpvar_131; + bool tmpvar_132; + tmpvar_132 = (lumaMM < 0.0); + lumaMLTZero = tmpvar_132; + highp float tmpvar_133; + tmpvar_133 = (lumaEndN - (lumaNN * 0.5)); + lumaEndN = tmpvar_133; + highp float tmpvar_134; + tmpvar_134 = (lumaEndP - (lumaNN * 0.5)); + lumaEndP = tmpvar_134; + highp float tmpvar_135; + tmpvar_135 = abs (lumaEndN); + bool tmpvar_136; + tmpvar_136 = (tmpvar_135 >= gradientScaled); + doneN = tmpvar_136; + highp float tmpvar_137; + tmpvar_137 = abs (lumaEndP); + bool tmpvar_138; + tmpvar_138 = (tmpvar_137 >= gradientScaled); + doneP = tmpvar_138; + if (!(doneN)) { + highp float tmpvar_139; + tmpvar_139 = (posN.x - (offNP.x * 1.0)); + posN.x = tmpvar_139; + }; + if (!(doneN)) { + highp float tmpvar_140; + tmpvar_140 = (posN.y - (offNP.y * 1.0)); + posN.y = vec2(tmpvar_140).y; + }; + bool tmpvar_141; + if (!(doneN)) { + tmpvar_141 = bool(1); + } else { + tmpvar_141 = !(doneP); + }; + bool tmpvar_142; + tmpvar_142 = tmpvar_141; + doneNP = tmpvar_142; + if (!(doneP)) { + highp float tmpvar_143; + tmpvar_143 = (posP.x + (offNP.x * 1.0)); + posP.x = tmpvar_143; + }; + if (!(doneP)) { + highp float tmpvar_144; + tmpvar_144 = (posP.y + (offNP.y * 1.0)); + posP.y = vec2(tmpvar_144).y; + }; + if (doneNP) { + if (!(doneN)) { + highp vec4 tmpvar_145; + tmpvar_145.zw = vec2(0.0, 0.0); + tmpvar_145.xy = posN.xy.xy; + vec4 tmpvar_146; + tmpvar_146 = xll_tex2Dlod (tex, tmpvar_145); + highp float tmpvar_147; + tmpvar_147 = FxaaLuma (tmpvar_146); + highp float tmpvar_148; + tmpvar_148 = tmpvar_147; + lumaEndN = tmpvar_148; + }; + if (!(doneP)) { + highp vec4 tmpvar_149; + tmpvar_149.zw = vec2(0.0, 0.0); + tmpvar_149.xy = posP.xy.xy; + vec4 tmpvar_150; + tmpvar_150 = xll_tex2Dlod (tex, tmpvar_149); + highp float tmpvar_151; + tmpvar_151 = FxaaLuma (tmpvar_150); + highp float tmpvar_152; + tmpvar_152 = tmpvar_151; + lumaEndP = tmpvar_152; + }; + if (!(doneN)) { + highp float tmpvar_153; + tmpvar_153 = (lumaEndN - (lumaNN * 0.5)); + lumaEndN = tmpvar_153; + }; + if (!(doneP)) { + highp float tmpvar_154; + tmpvar_154 = (lumaEndP - (lumaNN * 0.5)); + lumaEndP = tmpvar_154; + }; + highp float tmpvar_155; + tmpvar_155 = abs (lumaEndN); + bool tmpvar_156; + tmpvar_156 = (tmpvar_155 >= gradientScaled); + doneN = tmpvar_156; + highp float tmpvar_157; + tmpvar_157 = abs (lumaEndP); + bool tmpvar_158; + tmpvar_158 = (tmpvar_157 >= gradientScaled); + doneP = tmpvar_158; + if (!(doneN)) { + highp float tmpvar_159; + tmpvar_159 = (posN.x - (offNP.x * 1.0)); + posN.x = tmpvar_159; + }; + if (!(doneN)) { + highp float tmpvar_160; + tmpvar_160 = (posN.y - (offNP.y * 1.0)); + posN.y = vec2(tmpvar_160).y; + }; + bool tmpvar_161; + if (!(doneN)) { + tmpvar_161 = bool(1); + } else { + tmpvar_161 = !(doneP); + }; + bool tmpvar_162; + tmpvar_162 = tmpvar_161; + doneNP = tmpvar_162; + if (!(doneP)) { + highp float tmpvar_163; + tmpvar_163 = (posP.x + (offNP.x * 1.0)); + posP.x = tmpvar_163; + }; + if (!(doneP)) { + highp float tmpvar_164; + tmpvar_164 = (posP.y + (offNP.y * 1.0)); + posP.y = vec2(tmpvar_164).y; + }; + if (doneNP) { + if (!(doneN)) { + highp vec4 tmpvar_165; + tmpvar_165.zw = vec2(0.0, 0.0); + tmpvar_165.xy = posN.xy.xy; + vec4 tmpvar_166; + tmpvar_166 = xll_tex2Dlod (tex, tmpvar_165); + highp float tmpvar_167; + tmpvar_167 = FxaaLuma (tmpvar_166); + highp float tmpvar_168; + tmpvar_168 = tmpvar_167; + lumaEndN = tmpvar_168; + }; + if (!(doneP)) { + highp vec4 tmpvar_169; + tmpvar_169.zw = vec2(0.0, 0.0); + tmpvar_169.xy = posP.xy.xy; + vec4 tmpvar_170; + tmpvar_170 = xll_tex2Dlod (tex, tmpvar_169); + highp float tmpvar_171; + tmpvar_171 = FxaaLuma (tmpvar_170); + highp float tmpvar_172; + tmpvar_172 = tmpvar_171; + lumaEndP = tmpvar_172; + }; + if (!(doneN)) { + highp float tmpvar_173; + tmpvar_173 = (lumaEndN - (lumaNN * 0.5)); + lumaEndN = tmpvar_173; + }; + if (!(doneP)) { + highp float tmpvar_174; + tmpvar_174 = (lumaEndP - (lumaNN * 0.5)); + lumaEndP = tmpvar_174; + }; + highp float tmpvar_175; + tmpvar_175 = abs (lumaEndN); + bool tmpvar_176; + tmpvar_176 = (tmpvar_175 >= gradientScaled); + doneN = tmpvar_176; + highp float tmpvar_177; + tmpvar_177 = abs (lumaEndP); + bool tmpvar_178; + tmpvar_178 = (tmpvar_177 >= gradientScaled); + doneP = tmpvar_178; + if (!(doneN)) { + highp float tmpvar_179; + tmpvar_179 = (posN.x - (offNP.x * 1.0)); + posN.x = tmpvar_179; + }; + if (!(doneN)) { + highp float tmpvar_180; + tmpvar_180 = (posN.y - (offNP.y * 1.0)); + posN.y = vec2(tmpvar_180).y; + }; + bool tmpvar_181; + if (!(doneN)) { + tmpvar_181 = bool(1); + } else { + tmpvar_181 = !(doneP); + }; + bool tmpvar_182; + tmpvar_182 = tmpvar_181; + doneNP = tmpvar_182; + if (!(doneP)) { + highp float tmpvar_183; + tmpvar_183 = (posP.x + (offNP.x * 1.0)); + posP.x = tmpvar_183; + }; + if (!(doneP)) { + highp float tmpvar_184; + tmpvar_184 = (posP.y + (offNP.y * 1.0)); + posP.y = vec2(tmpvar_184).y; + }; + if (doneNP) { + if (!(doneN)) { + highp vec4 tmpvar_185; + tmpvar_185.zw = vec2(0.0, 0.0); + tmpvar_185.xy = posN.xy.xy; + vec4 tmpvar_186; + tmpvar_186 = xll_tex2Dlod (tex, tmpvar_185); + highp float tmpvar_187; + tmpvar_187 = FxaaLuma (tmpvar_186); + highp float tmpvar_188; + tmpvar_188 = tmpvar_187; + lumaEndN = tmpvar_188; + }; + if (!(doneP)) { + highp vec4 tmpvar_189; + tmpvar_189.zw = vec2(0.0, 0.0); + tmpvar_189.xy = posP.xy.xy; + vec4 tmpvar_190; + tmpvar_190 = xll_tex2Dlod (tex, tmpvar_189); + highp float tmpvar_191; + tmpvar_191 = FxaaLuma (tmpvar_190); + highp float tmpvar_192; + tmpvar_192 = tmpvar_191; + lumaEndP = tmpvar_192; + }; + if (!(doneN)) { + highp float tmpvar_193; + tmpvar_193 = (lumaEndN - (lumaNN * 0.5)); + lumaEndN = tmpvar_193; + }; + if (!(doneP)) { + highp float tmpvar_194; + tmpvar_194 = (lumaEndP - (lumaNN * 0.5)); + lumaEndP = tmpvar_194; + }; + highp float tmpvar_195; + tmpvar_195 = abs (lumaEndN); + bool tmpvar_196; + tmpvar_196 = (tmpvar_195 >= gradientScaled); + doneN = tmpvar_196; + highp float tmpvar_197; + tmpvar_197 = abs (lumaEndP); + bool tmpvar_198; + tmpvar_198 = (tmpvar_197 >= gradientScaled); + doneP = tmpvar_198; + if (!(doneN)) { + highp float tmpvar_199; + tmpvar_199 = (posN.x - (offNP.x * 1.0)); + posN.x = tmpvar_199; + }; + if (!(doneN)) { + highp float tmpvar_200; + tmpvar_200 = (posN.y - (offNP.y * 1.0)); + posN.y = vec2(tmpvar_200).y; + }; + bool tmpvar_201; + if (!(doneN)) { + tmpvar_201 = bool(1); + } else { + tmpvar_201 = !(doneP); + }; + bool tmpvar_202; + tmpvar_202 = tmpvar_201; + doneNP = tmpvar_202; + if (!(doneP)) { + highp float tmpvar_203; + tmpvar_203 = (posP.x + (offNP.x * 1.0)); + posP.x = tmpvar_203; + }; + if (!(doneP)) { + highp float tmpvar_204; + tmpvar_204 = (posP.y + (offNP.y * 1.0)); + posP.y = vec2(tmpvar_204).y; + }; + if (doneNP) { + if (!(doneN)) { + highp vec4 tmpvar_205; + tmpvar_205.zw = vec2(0.0, 0.0); + tmpvar_205.xy = posN.xy.xy; + vec4 tmpvar_206; + tmpvar_206 = xll_tex2Dlod (tex, tmpvar_205); + highp float tmpvar_207; + tmpvar_207 = FxaaLuma (tmpvar_206); + highp float tmpvar_208; + tmpvar_208 = tmpvar_207; + lumaEndN = tmpvar_208; + }; + if (!(doneP)) { + highp vec4 tmpvar_209; + tmpvar_209.zw = vec2(0.0, 0.0); + tmpvar_209.xy = posP.xy.xy; + vec4 tmpvar_210; + tmpvar_210 = xll_tex2Dlod (tex, tmpvar_209); + highp float tmpvar_211; + tmpvar_211 = FxaaLuma (tmpvar_210); + highp float tmpvar_212; + tmpvar_212 = tmpvar_211; + lumaEndP = tmpvar_212; + }; + if (!(doneN)) { + highp float tmpvar_213; + tmpvar_213 = (lumaEndN - (lumaNN * 0.5)); + lumaEndN = tmpvar_213; + }; + if (!(doneP)) { + highp float tmpvar_214; + tmpvar_214 = (lumaEndP - (lumaNN * 0.5)); + lumaEndP = tmpvar_214; + }; + highp float tmpvar_215; + tmpvar_215 = abs (lumaEndN); + bool tmpvar_216; + tmpvar_216 = (tmpvar_215 >= gradientScaled); + doneN = tmpvar_216; + highp float tmpvar_217; + tmpvar_217 = abs (lumaEndP); + bool tmpvar_218; + tmpvar_218 = (tmpvar_217 >= gradientScaled); + doneP = tmpvar_218; + if (!(doneN)) { + highp float tmpvar_219; + tmpvar_219 = (posN.x - (offNP.x * 1.5)); + posN.x = tmpvar_219; + }; + if (!(doneN)) { + highp float tmpvar_220; + tmpvar_220 = (posN.y - (offNP.y * 1.5)); + posN.y = vec2(tmpvar_220).y; + }; + bool tmpvar_221; + if (!(doneN)) { + tmpvar_221 = bool(1); + } else { + tmpvar_221 = !(doneP); + }; + bool tmpvar_222; + tmpvar_222 = tmpvar_221; + doneNP = tmpvar_222; + if (!(doneP)) { + highp float tmpvar_223; + tmpvar_223 = (posP.x + (offNP.x * 1.5)); + posP.x = tmpvar_223; + }; + if (!(doneP)) { + highp float tmpvar_224; + tmpvar_224 = (posP.y + (offNP.y * 1.5)); + posP.y = vec2(tmpvar_224).y; + }; + if (doneNP) { + if (!(doneN)) { + highp vec4 tmpvar_225; + tmpvar_225.zw = vec2(0.0, 0.0); + tmpvar_225.xy = posN.xy.xy; + vec4 tmpvar_226; + tmpvar_226 = xll_tex2Dlod (tex, tmpvar_225); + highp float tmpvar_227; + tmpvar_227 = FxaaLuma (tmpvar_226); + highp float tmpvar_228; + tmpvar_228 = tmpvar_227; + lumaEndN = tmpvar_228; + }; + if (!(doneP)) { + highp vec4 tmpvar_229; + tmpvar_229.zw = vec2(0.0, 0.0); + tmpvar_229.xy = posP.xy.xy; + vec4 tmpvar_230; + tmpvar_230 = xll_tex2Dlod (tex, tmpvar_229); + highp float tmpvar_231; + tmpvar_231 = FxaaLuma (tmpvar_230); + highp float tmpvar_232; + tmpvar_232 = tmpvar_231; + lumaEndP = tmpvar_232; + }; + if (!(doneN)) { + highp float tmpvar_233; + tmpvar_233 = (lumaEndN - (lumaNN * 0.5)); + lumaEndN = tmpvar_233; + }; + if (!(doneP)) { + highp float tmpvar_234; + tmpvar_234 = (lumaEndP - (lumaNN * 0.5)); + lumaEndP = tmpvar_234; + }; + highp float tmpvar_235; + tmpvar_235 = abs (lumaEndN); + bool tmpvar_236; + tmpvar_236 = (tmpvar_235 >= gradientScaled); + doneN = tmpvar_236; + highp float tmpvar_237; + tmpvar_237 = abs (lumaEndP); + bool tmpvar_238; + tmpvar_238 = (tmpvar_237 >= gradientScaled); + doneP = tmpvar_238; + if (!(doneN)) { + highp float tmpvar_239; + tmpvar_239 = (posN.x - (offNP.x * 2.0)); + posN.x = tmpvar_239; + }; + if (!(doneN)) { + highp float tmpvar_240; + tmpvar_240 = (posN.y - (offNP.y * 2.0)); + posN.y = vec2(tmpvar_240).y; + }; + bool tmpvar_241; + if (!(doneN)) { + tmpvar_241 = bool(1); + } else { + tmpvar_241 = !(doneP); + }; + bool tmpvar_242; + tmpvar_242 = tmpvar_241; + doneNP = tmpvar_242; + if (!(doneP)) { + highp float tmpvar_243; + tmpvar_243 = (posP.x + (offNP.x * 2.0)); + posP.x = tmpvar_243; + }; + if (!(doneP)) { + highp float tmpvar_244; + tmpvar_244 = (posP.y + (offNP.y * 2.0)); + posP.y = vec2(tmpvar_244).y; + }; + if (doneNP) { + if (!(doneN)) { + highp vec4 tmpvar_245; + tmpvar_245.zw = vec2(0.0, 0.0); + tmpvar_245.xy = posN.xy.xy; + vec4 tmpvar_246; + tmpvar_246 = xll_tex2Dlod (tex, tmpvar_245); + highp float tmpvar_247; + tmpvar_247 = FxaaLuma (tmpvar_246); + highp float tmpvar_248; + tmpvar_248 = tmpvar_247; + lumaEndN = tmpvar_248; + }; + if (!(doneP)) { + highp vec4 tmpvar_249; + tmpvar_249.zw = vec2(0.0, 0.0); + tmpvar_249.xy = posP.xy.xy; + vec4 tmpvar_250; + tmpvar_250 = xll_tex2Dlod (tex, tmpvar_249); + highp float tmpvar_251; + tmpvar_251 = FxaaLuma (tmpvar_250); + highp float tmpvar_252; + tmpvar_252 = tmpvar_251; + lumaEndP = tmpvar_252; + }; + if (!(doneN)) { + highp float tmpvar_253; + tmpvar_253 = (lumaEndN - (lumaNN * 0.5)); + lumaEndN = tmpvar_253; + }; + if (!(doneP)) { + highp float tmpvar_254; + tmpvar_254 = (lumaEndP - (lumaNN * 0.5)); + lumaEndP = tmpvar_254; + }; + highp float tmpvar_255; + tmpvar_255 = abs (lumaEndN); + bool tmpvar_256; + tmpvar_256 = (tmpvar_255 >= gradientScaled); + doneN = tmpvar_256; + highp float tmpvar_257; + tmpvar_257 = abs (lumaEndP); + bool tmpvar_258; + tmpvar_258 = (tmpvar_257 >= gradientScaled); + doneP = tmpvar_258; + if (!(doneN)) { + highp float tmpvar_259; + tmpvar_259 = (posN.x - (offNP.x * 2.0)); + posN.x = tmpvar_259; + }; + if (!(doneN)) { + highp float tmpvar_260; + tmpvar_260 = (posN.y - (offNP.y * 2.0)); + posN.y = vec2(tmpvar_260).y; + }; + bool tmpvar_261; + if (!(doneN)) { + tmpvar_261 = bool(1); + } else { + tmpvar_261 = !(doneP); + }; + bool tmpvar_262; + tmpvar_262 = tmpvar_261; + doneNP = tmpvar_262; + if (!(doneP)) { + highp float tmpvar_263; + tmpvar_263 = (posP.x + (offNP.x * 2.0)); + posP.x = tmpvar_263; + }; + if (!(doneP)) { + highp float tmpvar_264; + tmpvar_264 = (posP.y + (offNP.y * 2.0)); + posP.y = vec2(tmpvar_264).y; + }; + if (doneNP) { + if (!(doneN)) { + highp vec4 tmpvar_265; + tmpvar_265.zw = vec2(0.0, 0.0); + tmpvar_265.xy = posN.xy.xy; + vec4 tmpvar_266; + tmpvar_266 = xll_tex2Dlod (tex, tmpvar_265); + highp float tmpvar_267; + tmpvar_267 = FxaaLuma (tmpvar_266); + highp float tmpvar_268; + tmpvar_268 = tmpvar_267; + lumaEndN = tmpvar_268; + }; + if (!(doneP)) { + highp vec4 tmpvar_269; + tmpvar_269.zw = vec2(0.0, 0.0); + tmpvar_269.xy = posP.xy.xy; + vec4 tmpvar_270; + tmpvar_270 = xll_tex2Dlod (tex, tmpvar_269); + highp float tmpvar_271; + tmpvar_271 = FxaaLuma (tmpvar_270); + highp float tmpvar_272; + tmpvar_272 = tmpvar_271; + lumaEndP = tmpvar_272; + }; + if (!(doneN)) { + highp float tmpvar_273; + tmpvar_273 = (lumaEndN - (lumaNN * 0.5)); + lumaEndN = tmpvar_273; + }; + if (!(doneP)) { + highp float tmpvar_274; + tmpvar_274 = (lumaEndP - (lumaNN * 0.5)); + lumaEndP = tmpvar_274; + }; + highp float tmpvar_275; + tmpvar_275 = abs (lumaEndN); + bool tmpvar_276; + tmpvar_276 = (tmpvar_275 >= gradientScaled); + doneN = tmpvar_276; + highp float tmpvar_277; + tmpvar_277 = abs (lumaEndP); + bool tmpvar_278; + tmpvar_278 = (tmpvar_277 >= gradientScaled); + doneP = tmpvar_278; + if (!(doneN)) { + highp float tmpvar_279; + tmpvar_279 = (posN.x - (offNP.x * 2.0)); + posN.x = tmpvar_279; + }; + if (!(doneN)) { + highp float tmpvar_280; + tmpvar_280 = (posN.y - (offNP.y * 2.0)); + posN.y = vec2(tmpvar_280).y; + }; + bool tmpvar_281; + if (!(doneN)) { + tmpvar_281 = bool(1); + } else { + tmpvar_281 = !(doneP); + }; + bool tmpvar_282; + tmpvar_282 = tmpvar_281; + doneNP = tmpvar_282; + if (!(doneP)) { + highp float tmpvar_283; + tmpvar_283 = (posP.x + (offNP.x * 2.0)); + posP.x = tmpvar_283; + }; + if (!(doneP)) { + highp float tmpvar_284; + tmpvar_284 = (posP.y + (offNP.y * 2.0)); + posP.y = vec2(tmpvar_284).y; + }; + if (doneNP) { + if (!(doneN)) { + highp vec4 tmpvar_285; + tmpvar_285.zw = vec2(0.0, 0.0); + tmpvar_285.xy = posN.xy.xy; + vec4 tmpvar_286; + tmpvar_286 = xll_tex2Dlod (tex, tmpvar_285); + highp float tmpvar_287; + tmpvar_287 = FxaaLuma (tmpvar_286); + highp float tmpvar_288; + tmpvar_288 = tmpvar_287; + lumaEndN = tmpvar_288; + }; + if (!(doneP)) { + highp vec4 tmpvar_289; + tmpvar_289.zw = vec2(0.0, 0.0); + tmpvar_289.xy = posP.xy.xy; + vec4 tmpvar_290; + tmpvar_290 = xll_tex2Dlod (tex, tmpvar_289); + highp float tmpvar_291; + tmpvar_291 = FxaaLuma (tmpvar_290); + highp float tmpvar_292; + tmpvar_292 = tmpvar_291; + lumaEndP = tmpvar_292; + }; + if (!(doneN)) { + highp float tmpvar_293; + tmpvar_293 = (lumaEndN - (lumaNN * 0.5)); + lumaEndN = tmpvar_293; + }; + if (!(doneP)) { + highp float tmpvar_294; + tmpvar_294 = (lumaEndP - (lumaNN * 0.5)); + lumaEndP = tmpvar_294; + }; + highp float tmpvar_295; + tmpvar_295 = abs (lumaEndN); + bool tmpvar_296; + tmpvar_296 = (tmpvar_295 >= gradientScaled); + doneN = tmpvar_296; + highp float tmpvar_297; + tmpvar_297 = abs (lumaEndP); + bool tmpvar_298; + tmpvar_298 = (tmpvar_297 >= gradientScaled); + doneP = tmpvar_298; + if (!(doneN)) { + highp float tmpvar_299; + tmpvar_299 = (posN.x - (offNP.x * 2.0)); + posN.x = tmpvar_299; + }; + if (!(doneN)) { + highp float tmpvar_300; + tmpvar_300 = (posN.y - (offNP.y * 2.0)); + posN.y = vec2(tmpvar_300).y; + }; + bool tmpvar_301; + if (!(doneN)) { + tmpvar_301 = bool(1); + } else { + tmpvar_301 = !(doneP); + }; + bool tmpvar_302; + tmpvar_302 = tmpvar_301; + doneNP = tmpvar_302; + if (!(doneP)) { + highp float tmpvar_303; + tmpvar_303 = (posP.x + (offNP.x * 2.0)); + posP.x = tmpvar_303; + }; + if (!(doneP)) { + highp float tmpvar_304; + tmpvar_304 = (posP.y + (offNP.y * 2.0)); + posP.y = vec2(tmpvar_304).y; + }; + if (doneNP) { + if (!(doneN)) { + highp vec4 tmpvar_305; + tmpvar_305.zw = vec2(0.0, 0.0); + tmpvar_305.xy = posN.xy.xy; + vec4 tmpvar_306; + tmpvar_306 = xll_tex2Dlod (tex, tmpvar_305); + highp float tmpvar_307; + tmpvar_307 = FxaaLuma (tmpvar_306); + highp float tmpvar_308; + tmpvar_308 = tmpvar_307; + lumaEndN = tmpvar_308; + }; + if (!(doneP)) { + highp vec4 tmpvar_309; + tmpvar_309.zw = vec2(0.0, 0.0); + tmpvar_309.xy = posP.xy.xy; + vec4 tmpvar_310; + tmpvar_310 = xll_tex2Dlod (tex, tmpvar_309); + highp float tmpvar_311; + tmpvar_311 = FxaaLuma (tmpvar_310); + highp float tmpvar_312; + tmpvar_312 = tmpvar_311; + lumaEndP = tmpvar_312; + }; + if (!(doneN)) { + highp float tmpvar_313; + tmpvar_313 = (lumaEndN - (lumaNN * 0.5)); + lumaEndN = tmpvar_313; + }; + if (!(doneP)) { + highp float tmpvar_314; + tmpvar_314 = (lumaEndP - (lumaNN * 0.5)); + lumaEndP = tmpvar_314; + }; + highp float tmpvar_315; + tmpvar_315 = abs (lumaEndN); + bool tmpvar_316; + tmpvar_316 = (tmpvar_315 >= gradientScaled); + doneN = tmpvar_316; + highp float tmpvar_317; + tmpvar_317 = abs (lumaEndP); + bool tmpvar_318; + tmpvar_318 = (tmpvar_317 >= gradientScaled); + doneP = tmpvar_318; + if (!(doneN)) { + highp float tmpvar_319; + tmpvar_319 = (posN.x - (offNP.x * 4.0)); + posN.x = tmpvar_319; + }; + if (!(doneN)) { + highp float tmpvar_320; + tmpvar_320 = (posN.y - (offNP.y * 4.0)); + posN.y = vec2(tmpvar_320).y; + }; + bool tmpvar_321; + if (!(doneN)) { + tmpvar_321 = bool(1); + } else { + tmpvar_321 = !(doneP); + }; + bool tmpvar_322; + tmpvar_322 = tmpvar_321; + doneNP = tmpvar_322; + if (!(doneP)) { + highp float tmpvar_323; + tmpvar_323 = (posP.x + (offNP.x * 4.0)); + posP.x = tmpvar_323; + }; + if (!(doneP)) { + highp float tmpvar_324; + tmpvar_324 = (posP.y + (offNP.y * 4.0)); + posP.y = vec2(tmpvar_324).y; + }; + if (doneNP) { + if (!(doneN)) { + highp vec4 tmpvar_325; + tmpvar_325.zw = vec2(0.0, 0.0); + tmpvar_325.xy = posN.xy.xy; + vec4 tmpvar_326; + tmpvar_326 = xll_tex2Dlod (tex, tmpvar_325); + highp float tmpvar_327; + tmpvar_327 = FxaaLuma (tmpvar_326); + highp float tmpvar_328; + tmpvar_328 = tmpvar_327; + lumaEndN = tmpvar_328; + }; + if (!(doneP)) { + highp vec4 tmpvar_329; + tmpvar_329.zw = vec2(0.0, 0.0); + tmpvar_329.xy = posP.xy.xy; + vec4 tmpvar_330; + tmpvar_330 = xll_tex2Dlod (tex, tmpvar_329); + highp float tmpvar_331; + tmpvar_331 = FxaaLuma (tmpvar_330); + highp float tmpvar_332; + tmpvar_332 = tmpvar_331; + lumaEndP = tmpvar_332; + }; + if (!(doneN)) { + highp float tmpvar_333; + tmpvar_333 = (lumaEndN - (lumaNN * 0.5)); + lumaEndN = tmpvar_333; + }; + if (!(doneP)) { + highp float tmpvar_334; + tmpvar_334 = (lumaEndP - (lumaNN * 0.5)); + lumaEndP = tmpvar_334; + }; + highp float tmpvar_335; + tmpvar_335 = abs (lumaEndN); + bool tmpvar_336; + tmpvar_336 = (tmpvar_335 >= gradientScaled); + doneN = tmpvar_336; + highp float tmpvar_337; + tmpvar_337 = abs (lumaEndP); + bool tmpvar_338; + tmpvar_338 = (tmpvar_337 >= gradientScaled); + doneP = tmpvar_338; + if (!(doneN)) { + highp float tmpvar_339; + tmpvar_339 = (posN.x - (offNP.x * 8.0)); + posN.x = tmpvar_339; + }; + if (!(doneN)) { + highp float tmpvar_340; + tmpvar_340 = (posN.y - (offNP.y * 8.0)); + posN.y = vec2(tmpvar_340).y; + }; + bool tmpvar_341; + if (!(doneN)) { + tmpvar_341 = bool(1); + } else { + tmpvar_341 = !(doneP); + }; + bool tmpvar_342; + tmpvar_342 = tmpvar_341; + doneNP = tmpvar_342; + if (!(doneP)) { + highp float tmpvar_343; + tmpvar_343 = (posP.x + (offNP.x * 8.0)); + posP.x = tmpvar_343; + }; + if (!(doneP)) { + highp float tmpvar_344; + tmpvar_344 = (posP.y + (offNP.y * 8.0)); + posP.y = vec2(tmpvar_344).y; + }; + }; + }; + }; + }; + }; + }; + }; + }; + }; + }; + highp float tmpvar_345; + tmpvar_345 = (posM.x - posN.x); + dstN = tmpvar_345; + highp float tmpvar_346; + tmpvar_346 = (posP.x - posM.x); + dstP = tmpvar_346; + if (!(horzSpan)) { + highp float tmpvar_347; + tmpvar_347 = (posM.y - posN.y); + dstN = tmpvar_347; + }; + if (!(horzSpan)) { + highp float tmpvar_348; + tmpvar_348 = (posP.y - posM.y); + dstP = tmpvar_348; + }; + bool tmpvar_349; + tmpvar_349 = ((lumaEndN < 0.0) != lumaMLTZero); + goodSpanN = tmpvar_349; + highp float tmpvar_350; + tmpvar_350 = (dstP + dstN); + spanLength = tmpvar_350; + bool tmpvar_351; + tmpvar_351 = ((lumaEndP < 0.0) != lumaMLTZero); + goodSpanP = tmpvar_351; + highp float tmpvar_352; + tmpvar_352 = (1.0 / spanLength); + spanLengthRcp = tmpvar_352; + bool tmpvar_353; + tmpvar_353 = (dstN < dstP); + directionN = tmpvar_353; + highp float tmpvar_354; + tmpvar_354 = min (dstN, dstP); + highp float tmpvar_355; + tmpvar_355 = tmpvar_354; + dst = tmpvar_355; + bool tmpvar_356; + if (directionN) { + tmpvar_356 = goodSpanN; + } else { + tmpvar_356 = goodSpanP; + }; + bool tmpvar_357; + tmpvar_357 = tmpvar_356; + goodSpan = tmpvar_357; + highp float tmpvar_358; + tmpvar_358 = (subpixF * subpixF); + subpixG = tmpvar_358; + highp float tmpvar_359; + tmpvar_359 = ((dst * -(spanLengthRcp)) + 0.5); + pixelOffset = tmpvar_359; + highp float tmpvar_360; + tmpvar_360 = (subpixG * fxaaQualitySubpix); + subpixH = tmpvar_360; + highp float tmpvar_361; + if (goodSpan) { + tmpvar_361 = pixelOffset; + } else { + tmpvar_361 = 0.0; + }; + highp float tmpvar_362; + tmpvar_362 = tmpvar_361; + pixelOffsetGood = tmpvar_362; + highp float tmpvar_363; + tmpvar_363 = max (pixelOffsetGood, subpixH); + highp float tmpvar_364; + tmpvar_364 = tmpvar_363; + pixelOffsetSubpix = tmpvar_364; + if (!(horzSpan)) { + highp float tmpvar_365; + tmpvar_365 = (posM.x + (pixelOffsetSubpix * lengthSign)); + posM.x = tmpvar_365; + }; + if (horzSpan) { + highp float tmpvar_366; + tmpvar_366 = (posM.y + (pixelOffsetSubpix * lengthSign)); + posM.y = vec2(tmpvar_366).y; + }; + highp vec4 tmpvar_367; + tmpvar_367.zw = vec2(0.0, 0.0); + tmpvar_367.xy = posM.xy; + vec4 tmpvar_368; + tmpvar_368 = xll_tex2Dlod (tex, tmpvar_367); + highp vec4 tmpvar_369; + tmpvar_369.xyz = tmpvar_368.xyz.xyz; + tmpvar_369.w = rgbyM.w; + return tmpvar_369; +} + +vec4 xlat_main ( + in v2f i +) +{ + highp float fxaaN; + float tmpvar_1; + tmpvar_1 = 0.5; + fxaaN = tmpvar_1; + highp vec4 tmpvar_2; + tmpvar_2.x = -(fxaaN); + tmpvar_2.y = -(fxaaN); + tmpvar_2.z = fxaaN; + tmpvar_2.w = fxaaN; + highp vec4 tmpvar_3; + tmpvar_3 = FxaaPixelShader (i.uv, i.uvPosPos, _MainTex, _MainTex, _MainTex, _MainTex_TexelSize.xy, (_MainTex_TexelSize.xyxy * tmpvar_2), (_MainTex_TexelSize.xyxy * vec4(-2.0, -2.0, 2.0, 2.0)), (_MainTex_TexelSize.xyxy * vec4(8.0, 8.0, -4.0, -4.0)), 0.75, 0.166, 0.0833, 8.0, 0.125, 0.05, vec4(1.0, -1.0, 0.25, -0.25)); + return tmpvar_3; +} + +void main () +{ + v2f xlt_i; + highp vec4 xl_retval; + highp vec4 tmpvar_1; + tmpvar_1 = xlv_SV_POSITION.xyzw; + highp vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_i.pos = tmpvar_2; + highp vec2 tmpvar_3; + tmpvar_3 = xlv_TEXCOORD0.xy; + highp vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_i.uv = tmpvar_4; + highp vec4 tmpvar_5; + tmpvar_5 = xlv_TEXCOORD1.xyzw; + highp vec4 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_i.uvPosPos = tmpvar_6; + highp vec4 tmpvar_7; + tmpvar_7 = xlat_main (xlt_i); + highp vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xl_retval = tmpvar_8; + highp vec4 tmpvar_9; + tmpvar_9 = xl_retval.xyzw; + highp vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + gl_FragData[0] = tmpvar_10; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/complex-fxaa3-11-pc39-out.txt b/3rdparty/glsl-optimizer/tests/fragment/complex-fxaa3-11-pc39-out.txt new file mode 100644 index 000000000..19d2f3130 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/complex-fxaa3-11-pc39-out.txt @@ -0,0 +1,669 @@ +#extension GL_ARB_shader_texture_lod : enable +varying vec2 xlv_TEXCOORD0; +uniform vec4 _MainTex_TexelSize; +uniform sampler2D _MainTex; +void main () +{ + vec4 tmpvar_1; + float dstP; + float dstN; + float lumaEndP; + float lumaEndN; + vec2 posP; + vec2 posN; + vec2 posB; + float lumaNN; + float lengthSign; + float lumaN; + float lumaS; + vec2 posM; + posM.x = xlv_TEXCOORD0.x; + posM.y = xlv_TEXCOORD0.y; + vec4 tmpvar_2; + tmpvar_2.zw = vec2(0.0, 0.0); + tmpvar_2.xy = posM; + vec4 tmpvar_3; + tmpvar_3 = texture2DLod (_MainTex, tmpvar_2.xy, 0.0); + vec4 tmpvar_4; + tmpvar_4.zw = vec2(0.0, 0.0); + tmpvar_4.xy = (xlv_TEXCOORD0 + (vec2(0.0, 1.0) * _MainTex_TexelSize.xy)); + vec4 tmpvar_5; + tmpvar_5 = texture2DLod (_MainTex, tmpvar_4.xy, 0.0); + float tmpvar_6; + tmpvar_6 = tmpvar_5.w; + lumaS = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7.zw = vec2(0.0, 0.0); + tmpvar_7.xy = (xlv_TEXCOORD0 + (vec2(1.0, 0.0) * _MainTex_TexelSize.xy)); + vec4 tmpvar_8; + tmpvar_8 = texture2DLod (_MainTex, tmpvar_7.xy, 0.0); + float tmpvar_9; + tmpvar_9 = tmpvar_8.w; + vec4 tmpvar_10; + tmpvar_10.zw = vec2(0.0, 0.0); + tmpvar_10.xy = (xlv_TEXCOORD0 + (vec2(0.0, -1.0) * _MainTex_TexelSize.xy)); + vec4 tmpvar_11; + tmpvar_11 = texture2DLod (_MainTex, tmpvar_10.xy, 0.0); + float tmpvar_12; + tmpvar_12 = tmpvar_11.w; + lumaN = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13.zw = vec2(0.0, 0.0); + tmpvar_13.xy = (xlv_TEXCOORD0 + (vec2(-1.0, 0.0) * _MainTex_TexelSize.xy)); + vec4 tmpvar_14; + tmpvar_14 = texture2DLod (_MainTex, tmpvar_13.xy, 0.0); + float tmpvar_15; + tmpvar_15 = tmpvar_14.w; + float tmpvar_16; + tmpvar_16 = max (max (tmpvar_12, tmpvar_15), max (tmpvar_9, max (tmpvar_6, tmpvar_3.w))); + float tmpvar_17; + tmpvar_17 = (tmpvar_16 - min (min (tmpvar_12, tmpvar_15), min (tmpvar_9, min (tmpvar_6, tmpvar_3.w)))); + if ((tmpvar_17 < max (0.0833, (tmpvar_16 * 0.166)))) { + tmpvar_1 = tmpvar_3; + } else { + vec4 tmpvar_18; + tmpvar_18.zw = vec2(0.0, 0.0); + tmpvar_18.xy = (xlv_TEXCOORD0 + (vec2(-1.0, -1.0) * _MainTex_TexelSize.xy)); + vec4 tmpvar_19; + tmpvar_19 = texture2DLod (_MainTex, tmpvar_18.xy, 0.0); + vec4 tmpvar_20; + tmpvar_20.zw = vec2(0.0, 0.0); + tmpvar_20.xy = (xlv_TEXCOORD0 + _MainTex_TexelSize.xy); + vec4 tmpvar_21; + tmpvar_21 = texture2DLod (_MainTex, tmpvar_20.xy, 0.0); + vec4 tmpvar_22; + tmpvar_22.zw = vec2(0.0, 0.0); + tmpvar_22.xy = (xlv_TEXCOORD0 + (vec2(1.0, -1.0) * _MainTex_TexelSize.xy)); + vec4 tmpvar_23; + tmpvar_23 = texture2DLod (_MainTex, tmpvar_22.xy, 0.0); + vec4 tmpvar_24; + tmpvar_24.zw = vec2(0.0, 0.0); + tmpvar_24.xy = (xlv_TEXCOORD0 + (vec2(-1.0, 1.0) * _MainTex_TexelSize.xy)); + vec4 tmpvar_25; + tmpvar_25 = texture2DLod (_MainTex, tmpvar_24.xy, 0.0); + float tmpvar_26; + tmpvar_26 = (tmpvar_11.w + tmpvar_5.w); + float tmpvar_27; + tmpvar_27 = (tmpvar_14.w + tmpvar_8.w); + float tmpvar_28; + tmpvar_28 = (1.0/(tmpvar_17)); + float tmpvar_29; + tmpvar_29 = (tmpvar_23.w + tmpvar_21.w); + float tmpvar_30; + tmpvar_30 = (tmpvar_19.w + tmpvar_25.w); + lengthSign = _MainTex_TexelSize.x; + bool tmpvar_31; + tmpvar_31 = ((abs (((-(2.0) * tmpvar_14.w) + tmpvar_30)) + ((abs (((-(2.0) * tmpvar_3.w) + tmpvar_26)) * 2.0) + abs (((-(2.0) * tmpvar_8.w) + tmpvar_29)))) >= (abs (((-(2.0) * tmpvar_5.w) + (tmpvar_25.w + tmpvar_21.w))) + ((abs (((-(2.0) * tmpvar_3.w) + tmpvar_27)) * 2.0) + abs (((-(2.0) * tmpvar_11.w) + (tmpvar_19.w + tmpvar_23.w)))))); + float tmpvar_32; + tmpvar_32 = (((tmpvar_26 + tmpvar_27) * 2.0) + (tmpvar_30 + tmpvar_29)); + if (!(tmpvar_31)) { + lumaN = tmpvar_15; + }; + if (!(tmpvar_31)) { + lumaS = tmpvar_9; + }; + if (tmpvar_31) { + lengthSign = _MainTex_TexelSize.y; + }; + float tmpvar_33; + tmpvar_33 = ((tmpvar_32 * 0.0833333) - tmpvar_3.w); + float tmpvar_34; + tmpvar_34 = (lumaN - tmpvar_3.w); + float tmpvar_35; + tmpvar_35 = (lumaS - tmpvar_3.w); + lumaNN = (lumaN + tmpvar_3.w); + float tmpvar_36; + tmpvar_36 = (lumaS + tmpvar_3.w); + bool tmpvar_37; + tmpvar_37 = (abs (tmpvar_34) >= abs (tmpvar_35)); + float tmpvar_38; + tmpvar_38 = max (abs (tmpvar_34), abs (tmpvar_35)); + if (tmpvar_37) { + lengthSign = -(lengthSign); + }; + float tmpvar_39; + tmpvar_39 = clamp ((abs (tmpvar_33) * tmpvar_28), 0.0, 1.0); + posB.x = xlv_TEXCOORD0.x; + posB.y = xlv_TEXCOORD0.y; + float tmpvar_40; + if (!(tmpvar_31)) { + tmpvar_40 = 0.0; + } else { + tmpvar_40 = _MainTex_TexelSize.x; + }; + float tmpvar_41; + if (tmpvar_31) { + tmpvar_41 = 0.0; + } else { + tmpvar_41 = _MainTex_TexelSize.y; + }; + if (!(tmpvar_31)) { + posB.x = (xlv_TEXCOORD0.x + (lengthSign * 0.5)); + }; + if (tmpvar_31) { + posB.y = (xlv_TEXCOORD0.y + (lengthSign * 0.5)); + }; + posN.x = (posB.x - tmpvar_40); + posN.y = (posB.y - tmpvar_41); + posP.x = (posB.x + tmpvar_40); + posP.y = (posB.y + tmpvar_41); + float tmpvar_42; + tmpvar_42 = ((-2.0 * tmpvar_39) + 3.0); + vec4 tmpvar_43; + tmpvar_43.zw = vec2(0.0, 0.0); + tmpvar_43.xy = posN; + vec4 tmpvar_44; + tmpvar_44 = texture2DLod (_MainTex, tmpvar_43.xy, 0.0); + lumaEndN = tmpvar_44.w; + float tmpvar_45; + tmpvar_45 = (tmpvar_39 * tmpvar_39); + vec4 tmpvar_46; + tmpvar_46.zw = vec2(0.0, 0.0); + tmpvar_46.xy = posP; + vec4 tmpvar_47; + tmpvar_47 = texture2DLod (_MainTex, tmpvar_46.xy, 0.0); + lumaEndP = tmpvar_47.w; + if (!(tmpvar_37)) { + lumaNN = tmpvar_36; + }; + float tmpvar_48; + tmpvar_48 = (tmpvar_38 / 4.0); + float tmpvar_49; + tmpvar_49 = (tmpvar_42 * tmpvar_45); + bool tmpvar_50; + tmpvar_50 = ((tmpvar_3.w - (lumaNN * 0.5)) < 0.0); + float tmpvar_51; + tmpvar_51 = (tmpvar_44.w - (lumaNN * 0.5)); + lumaEndN = tmpvar_51; + float tmpvar_52; + tmpvar_52 = (tmpvar_47.w - (lumaNN * 0.5)); + lumaEndP = tmpvar_52; + bool tmpvar_53; + tmpvar_53 = (abs (tmpvar_51) >= tmpvar_48); + bool tmpvar_54; + tmpvar_54 = (abs (tmpvar_52) >= tmpvar_48); + if (!(tmpvar_53)) { + posN.x = (posN.x - tmpvar_40); + }; + if (!(tmpvar_53)) { + posN.y = (posN.y - tmpvar_41); + }; + bool tmpvar_55; + if (!(tmpvar_53)) { + tmpvar_55 = bool(1); + } else { + tmpvar_55 = !(tmpvar_54); + }; + if (!(tmpvar_54)) { + posP.x = (posP.x + tmpvar_40); + }; + if (!(tmpvar_54)) { + posP.y = (posP.y + tmpvar_41); + }; + if (tmpvar_55) { + if (!(tmpvar_53)) { + vec4 tmpvar_56; + tmpvar_56.zw = vec2(0.0, 0.0); + tmpvar_56.xy = posN; + lumaEndN = texture2DLod (_MainTex, tmpvar_56.xy, 0.0).w; + }; + if (!(tmpvar_54)) { + vec4 tmpvar_57; + tmpvar_57.zw = vec2(0.0, 0.0); + tmpvar_57.xy = posP; + lumaEndP = texture2DLod (_MainTex, tmpvar_57.xy, 0.0).w; + }; + if (!(tmpvar_53)) { + lumaEndN = (lumaEndN - (lumaNN * 0.5)); + }; + if (!(tmpvar_54)) { + lumaEndP = (lumaEndP - (lumaNN * 0.5)); + }; + bool tmpvar_58; + tmpvar_58 = (abs (lumaEndN) >= tmpvar_48); + bool tmpvar_59; + tmpvar_59 = (abs (lumaEndP) >= tmpvar_48); + if (!(tmpvar_58)) { + posN.x = (posN.x - tmpvar_40); + }; + if (!(tmpvar_58)) { + posN.y = (posN.y - tmpvar_41); + }; + bool tmpvar_60; + if (!(tmpvar_58)) { + tmpvar_60 = bool(1); + } else { + tmpvar_60 = !(tmpvar_59); + }; + if (!(tmpvar_59)) { + posP.x = (posP.x + tmpvar_40); + }; + if (!(tmpvar_59)) { + posP.y = (posP.y + tmpvar_41); + }; + if (tmpvar_60) { + if (!(tmpvar_58)) { + vec4 tmpvar_61; + tmpvar_61.zw = vec2(0.0, 0.0); + tmpvar_61.xy = posN; + lumaEndN = texture2DLod (_MainTex, tmpvar_61.xy, 0.0).w; + }; + if (!(tmpvar_59)) { + vec4 tmpvar_62; + tmpvar_62.zw = vec2(0.0, 0.0); + tmpvar_62.xy = posP; + lumaEndP = texture2DLod (_MainTex, tmpvar_62.xy, 0.0).w; + }; + if (!(tmpvar_58)) { + lumaEndN = (lumaEndN - (lumaNN * 0.5)); + }; + if (!(tmpvar_59)) { + lumaEndP = (lumaEndP - (lumaNN * 0.5)); + }; + bool tmpvar_63; + tmpvar_63 = (abs (lumaEndN) >= tmpvar_48); + bool tmpvar_64; + tmpvar_64 = (abs (lumaEndP) >= tmpvar_48); + if (!(tmpvar_63)) { + posN.x = (posN.x - tmpvar_40); + }; + if (!(tmpvar_63)) { + posN.y = (posN.y - tmpvar_41); + }; + bool tmpvar_65; + if (!(tmpvar_63)) { + tmpvar_65 = bool(1); + } else { + tmpvar_65 = !(tmpvar_64); + }; + if (!(tmpvar_64)) { + posP.x = (posP.x + tmpvar_40); + }; + if (!(tmpvar_64)) { + posP.y = (posP.y + tmpvar_41); + }; + if (tmpvar_65) { + if (!(tmpvar_63)) { + vec4 tmpvar_66; + tmpvar_66.zw = vec2(0.0, 0.0); + tmpvar_66.xy = posN; + lumaEndN = texture2DLod (_MainTex, tmpvar_66.xy, 0.0).w; + }; + if (!(tmpvar_64)) { + vec4 tmpvar_67; + tmpvar_67.zw = vec2(0.0, 0.0); + tmpvar_67.xy = posP; + lumaEndP = texture2DLod (_MainTex, tmpvar_67.xy, 0.0).w; + }; + if (!(tmpvar_63)) { + lumaEndN = (lumaEndN - (lumaNN * 0.5)); + }; + if (!(tmpvar_64)) { + lumaEndP = (lumaEndP - (lumaNN * 0.5)); + }; + bool tmpvar_68; + tmpvar_68 = (abs (lumaEndN) >= tmpvar_48); + bool tmpvar_69; + tmpvar_69 = (abs (lumaEndP) >= tmpvar_48); + if (!(tmpvar_68)) { + posN.x = (posN.x - tmpvar_40); + }; + if (!(tmpvar_68)) { + posN.y = (posN.y - tmpvar_41); + }; + bool tmpvar_70; + if (!(tmpvar_68)) { + tmpvar_70 = bool(1); + } else { + tmpvar_70 = !(tmpvar_69); + }; + if (!(tmpvar_69)) { + posP.x = (posP.x + tmpvar_40); + }; + if (!(tmpvar_69)) { + posP.y = (posP.y + tmpvar_41); + }; + if (tmpvar_70) { + if (!(tmpvar_68)) { + vec4 tmpvar_71; + tmpvar_71.zw = vec2(0.0, 0.0); + tmpvar_71.xy = posN; + lumaEndN = texture2DLod (_MainTex, tmpvar_71.xy, 0.0).w; + }; + if (!(tmpvar_69)) { + vec4 tmpvar_72; + tmpvar_72.zw = vec2(0.0, 0.0); + tmpvar_72.xy = posP; + lumaEndP = texture2DLod (_MainTex, tmpvar_72.xy, 0.0).w; + }; + if (!(tmpvar_68)) { + lumaEndN = (lumaEndN - (lumaNN * 0.5)); + }; + if (!(tmpvar_69)) { + lumaEndP = (lumaEndP - (lumaNN * 0.5)); + }; + bool tmpvar_73; + tmpvar_73 = (abs (lumaEndN) >= tmpvar_48); + bool tmpvar_74; + tmpvar_74 = (abs (lumaEndP) >= tmpvar_48); + if (!(tmpvar_73)) { + posN.x = (posN.x - (tmpvar_40 * 1.5)); + }; + if (!(tmpvar_73)) { + posN.y = (posN.y - (tmpvar_41 * 1.5)); + }; + bool tmpvar_75; + if (!(tmpvar_73)) { + tmpvar_75 = bool(1); + } else { + tmpvar_75 = !(tmpvar_74); + }; + if (!(tmpvar_74)) { + posP.x = (posP.x + (tmpvar_40 * 1.5)); + }; + if (!(tmpvar_74)) { + posP.y = (posP.y + (tmpvar_41 * 1.5)); + }; + if (tmpvar_75) { + if (!(tmpvar_73)) { + vec4 tmpvar_76; + tmpvar_76.zw = vec2(0.0, 0.0); + tmpvar_76.xy = posN; + lumaEndN = texture2DLod (_MainTex, tmpvar_76.xy, 0.0).w; + }; + if (!(tmpvar_74)) { + vec4 tmpvar_77; + tmpvar_77.zw = vec2(0.0, 0.0); + tmpvar_77.xy = posP; + lumaEndP = texture2DLod (_MainTex, tmpvar_77.xy, 0.0).w; + }; + if (!(tmpvar_73)) { + lumaEndN = (lumaEndN - (lumaNN * 0.5)); + }; + if (!(tmpvar_74)) { + lumaEndP = (lumaEndP - (lumaNN * 0.5)); + }; + bool tmpvar_78; + tmpvar_78 = (abs (lumaEndN) >= tmpvar_48); + bool tmpvar_79; + tmpvar_79 = (abs (lumaEndP) >= tmpvar_48); + if (!(tmpvar_78)) { + posN.x = (posN.x - (tmpvar_40 * 2.0)); + }; + if (!(tmpvar_78)) { + posN.y = (posN.y - (tmpvar_41 * 2.0)); + }; + bool tmpvar_80; + if (!(tmpvar_78)) { + tmpvar_80 = bool(1); + } else { + tmpvar_80 = !(tmpvar_79); + }; + if (!(tmpvar_79)) { + posP.x = (posP.x + (tmpvar_40 * 2.0)); + }; + if (!(tmpvar_79)) { + posP.y = (posP.y + (tmpvar_41 * 2.0)); + }; + if (tmpvar_80) { + if (!(tmpvar_78)) { + vec4 tmpvar_81; + tmpvar_81.zw = vec2(0.0, 0.0); + tmpvar_81.xy = posN; + lumaEndN = texture2DLod (_MainTex, tmpvar_81.xy, 0.0).w; + }; + if (!(tmpvar_79)) { + vec4 tmpvar_82; + tmpvar_82.zw = vec2(0.0, 0.0); + tmpvar_82.xy = posP; + lumaEndP = texture2DLod (_MainTex, tmpvar_82.xy, 0.0).w; + }; + if (!(tmpvar_78)) { + lumaEndN = (lumaEndN - (lumaNN * 0.5)); + }; + if (!(tmpvar_79)) { + lumaEndP = (lumaEndP - (lumaNN * 0.5)); + }; + bool tmpvar_83; + tmpvar_83 = (abs (lumaEndN) >= tmpvar_48); + bool tmpvar_84; + tmpvar_84 = (abs (lumaEndP) >= tmpvar_48); + if (!(tmpvar_83)) { + posN.x = (posN.x - (tmpvar_40 * 2.0)); + }; + if (!(tmpvar_83)) { + posN.y = (posN.y - (tmpvar_41 * 2.0)); + }; + bool tmpvar_85; + if (!(tmpvar_83)) { + tmpvar_85 = bool(1); + } else { + tmpvar_85 = !(tmpvar_84); + }; + if (!(tmpvar_84)) { + posP.x = (posP.x + (tmpvar_40 * 2.0)); + }; + if (!(tmpvar_84)) { + posP.y = (posP.y + (tmpvar_41 * 2.0)); + }; + if (tmpvar_85) { + if (!(tmpvar_83)) { + vec4 tmpvar_86; + tmpvar_86.zw = vec2(0.0, 0.0); + tmpvar_86.xy = posN; + lumaEndN = texture2DLod (_MainTex, tmpvar_86.xy, 0.0).w; + }; + if (!(tmpvar_84)) { + vec4 tmpvar_87; + tmpvar_87.zw = vec2(0.0, 0.0); + tmpvar_87.xy = posP; + lumaEndP = texture2DLod (_MainTex, tmpvar_87.xy, 0.0).w; + }; + if (!(tmpvar_83)) { + lumaEndN = (lumaEndN - (lumaNN * 0.5)); + }; + if (!(tmpvar_84)) { + lumaEndP = (lumaEndP - (lumaNN * 0.5)); + }; + bool tmpvar_88; + tmpvar_88 = (abs (lumaEndN) >= tmpvar_48); + bool tmpvar_89; + tmpvar_89 = (abs (lumaEndP) >= tmpvar_48); + if (!(tmpvar_88)) { + posN.x = (posN.x - (tmpvar_40 * 2.0)); + }; + if (!(tmpvar_88)) { + posN.y = (posN.y - (tmpvar_41 * 2.0)); + }; + bool tmpvar_90; + if (!(tmpvar_88)) { + tmpvar_90 = bool(1); + } else { + tmpvar_90 = !(tmpvar_89); + }; + if (!(tmpvar_89)) { + posP.x = (posP.x + (tmpvar_40 * 2.0)); + }; + if (!(tmpvar_89)) { + posP.y = (posP.y + (tmpvar_41 * 2.0)); + }; + if (tmpvar_90) { + if (!(tmpvar_88)) { + vec4 tmpvar_91; + tmpvar_91.zw = vec2(0.0, 0.0); + tmpvar_91.xy = posN; + lumaEndN = texture2DLod (_MainTex, tmpvar_91.xy, 0.0).w; + }; + if (!(tmpvar_89)) { + vec4 tmpvar_92; + tmpvar_92.zw = vec2(0.0, 0.0); + tmpvar_92.xy = posP; + lumaEndP = texture2DLod (_MainTex, tmpvar_92.xy, 0.0).w; + }; + if (!(tmpvar_88)) { + lumaEndN = (lumaEndN - (lumaNN * 0.5)); + }; + if (!(tmpvar_89)) { + lumaEndP = (lumaEndP - (lumaNN * 0.5)); + }; + bool tmpvar_93; + tmpvar_93 = (abs (lumaEndN) >= tmpvar_48); + bool tmpvar_94; + tmpvar_94 = (abs (lumaEndP) >= tmpvar_48); + if (!(tmpvar_93)) { + posN.x = (posN.x - (tmpvar_40 * 2.0)); + }; + if (!(tmpvar_93)) { + posN.y = (posN.y - (tmpvar_41 * 2.0)); + }; + bool tmpvar_95; + if (!(tmpvar_93)) { + tmpvar_95 = bool(1); + } else { + tmpvar_95 = !(tmpvar_94); + }; + if (!(tmpvar_94)) { + posP.x = (posP.x + (tmpvar_40 * 2.0)); + }; + if (!(tmpvar_94)) { + posP.y = (posP.y + (tmpvar_41 * 2.0)); + }; + if (tmpvar_95) { + if (!(tmpvar_93)) { + vec4 tmpvar_96; + tmpvar_96.zw = vec2(0.0, 0.0); + tmpvar_96.xy = posN; + lumaEndN = texture2DLod (_MainTex, tmpvar_96.xy, 0.0).w; + }; + if (!(tmpvar_94)) { + vec4 tmpvar_97; + tmpvar_97.zw = vec2(0.0, 0.0); + tmpvar_97.xy = posP; + lumaEndP = texture2DLod (_MainTex, tmpvar_97.xy, 0.0).w; + }; + if (!(tmpvar_93)) { + lumaEndN = (lumaEndN - (lumaNN * 0.5)); + }; + if (!(tmpvar_94)) { + lumaEndP = (lumaEndP - (lumaNN * 0.5)); + }; + bool tmpvar_98; + tmpvar_98 = (abs (lumaEndN) >= tmpvar_48); + bool tmpvar_99; + tmpvar_99 = (abs (lumaEndP) >= tmpvar_48); + if (!(tmpvar_98)) { + posN.x = (posN.x - (tmpvar_40 * 4.0)); + }; + if (!(tmpvar_98)) { + posN.y = (posN.y - (tmpvar_41 * 4.0)); + }; + bool tmpvar_100; + if (!(tmpvar_98)) { + tmpvar_100 = bool(1); + } else { + tmpvar_100 = !(tmpvar_99); + }; + if (!(tmpvar_99)) { + posP.x = (posP.x + (tmpvar_40 * 4.0)); + }; + if (!(tmpvar_99)) { + posP.y = (posP.y + (tmpvar_41 * 4.0)); + }; + if (tmpvar_100) { + if (!(tmpvar_98)) { + vec4 tmpvar_101; + tmpvar_101.zw = vec2(0.0, 0.0); + tmpvar_101.xy = posN; + lumaEndN = texture2DLod (_MainTex, tmpvar_101.xy, 0.0).w; + }; + if (!(tmpvar_99)) { + vec4 tmpvar_102; + tmpvar_102.zw = vec2(0.0, 0.0); + tmpvar_102.xy = posP; + lumaEndP = texture2DLod (_MainTex, tmpvar_102.xy, 0.0).w; + }; + if (!(tmpvar_98)) { + lumaEndN = (lumaEndN - (lumaNN * 0.5)); + }; + if (!(tmpvar_99)) { + lumaEndP = (lumaEndP - (lumaNN * 0.5)); + }; + bool tmpvar_103; + tmpvar_103 = (abs (lumaEndN) >= tmpvar_48); + bool tmpvar_104; + tmpvar_104 = (abs (lumaEndP) >= tmpvar_48); + if (!(tmpvar_103)) { + posN.x = (posN.x - (tmpvar_40 * 8.0)); + }; + if (!(tmpvar_103)) { + posN.y = (posN.y - (tmpvar_41 * 8.0)); + }; + if (!(tmpvar_103)) { + }; + if (!(tmpvar_104)) { + posP.x = (posP.x + (tmpvar_40 * 8.0)); + }; + if (!(tmpvar_104)) { + posP.y = (posP.y + (tmpvar_41 * 8.0)); + }; + }; + }; + }; + }; + }; + }; + }; + }; + }; + }; + dstN = (xlv_TEXCOORD0.x - posN.x); + dstP = (posP.x - xlv_TEXCOORD0.x); + if (!(tmpvar_31)) { + dstN = (xlv_TEXCOORD0.y - posN.y); + }; + if (!(tmpvar_31)) { + dstP = (posP.y - xlv_TEXCOORD0.y); + }; + bool tmpvar_105; + tmpvar_105 = ((lumaEndN < 0.0) != tmpvar_50); + bool tmpvar_106; + tmpvar_106 = ((lumaEndP < 0.0) != tmpvar_50); + float tmpvar_107; + tmpvar_107 = (1.0/((dstP + dstN))); + float tmpvar_108; + tmpvar_108 = min (dstN, dstP); + bool tmpvar_109; + if ((dstN < dstP)) { + tmpvar_109 = tmpvar_105; + } else { + tmpvar_109 = tmpvar_106; + }; + float tmpvar_110; + tmpvar_110 = ((tmpvar_108 * -(tmpvar_107)) + 0.5); + float tmpvar_111; + tmpvar_111 = ((tmpvar_49 * tmpvar_49) * 0.75); + float tmpvar_112; + if (tmpvar_109) { + tmpvar_112 = tmpvar_110; + } else { + tmpvar_112 = 0.0; + }; + float tmpvar_113; + tmpvar_113 = max (tmpvar_112, tmpvar_111); + if (!(tmpvar_31)) { + posM.x = (xlv_TEXCOORD0.x + (tmpvar_113 * lengthSign)); + }; + if (tmpvar_31) { + posM.y = (xlv_TEXCOORD0.y + (tmpvar_113 * lengthSign)); + }; + vec4 tmpvar_114; + tmpvar_114.zw = vec2(0.0, 0.0); + tmpvar_114.xy = posM; + vec4 tmpvar_115; + tmpvar_115.xyz = texture2DLod (_MainTex, tmpvar_114.xy, 0.0).xyz; + tmpvar_115.w = tmpvar_3.w; + tmpvar_1 = tmpvar_115; + }; + gl_FragData[0] = tmpvar_1; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/complex-fxaa3-11-pc39-outES.txt b/3rdparty/glsl-optimizer/tests/fragment/complex-fxaa3-11-pc39-outES.txt new file mode 100644 index 000000000..564ff4ec1 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/complex-fxaa3-11-pc39-outES.txt @@ -0,0 +1,773 @@ +#extension GL_EXT_shader_texture_lod : enable +varying highp vec2 xlv_TEXCOORD0; +uniform highp vec4 _MainTex_TexelSize; +uniform sampler2D _MainTex; +void main () +{ + highp vec4 tmpvar_1; + highp float dstP; + highp float dstN; + highp float lumaEndP; + highp float lumaEndN; + highp vec2 posP; + highp vec2 posN; + highp vec2 posB; + highp float lumaNN; + highp float lengthSign; + highp float lumaN; + highp float lumaS; + highp vec4 rgbyM; + highp vec2 posM; + posM.x = xlv_TEXCOORD0.x; + posM.y = xlv_TEXCOORD0.y; + highp vec4 tmpvar_2; + tmpvar_2.zw = vec2(0.0, 0.0); + tmpvar_2.xy = posM; + lowp vec4 tmpvar_3; + tmpvar_3 = texture2DLodEXT (_MainTex, tmpvar_2.xy, 0.0); + rgbyM = tmpvar_3; + highp vec4 tmpvar_4; + tmpvar_4.zw = vec2(0.0, 0.0); + tmpvar_4.xy = (xlv_TEXCOORD0 + (vec2(0.0, 1.0) * _MainTex_TexelSize.xy)); + lowp vec4 tmpvar_5; + tmpvar_5 = texture2DLodEXT (_MainTex, tmpvar_4.xy, 0.0); + highp float tmpvar_6; + highp vec4 rgba; + rgba = tmpvar_5; + tmpvar_6 = rgba.w; + lumaS = tmpvar_6; + highp vec4 tmpvar_7; + tmpvar_7.zw = vec2(0.0, 0.0); + tmpvar_7.xy = (xlv_TEXCOORD0 + (vec2(1.0, 0.0) * _MainTex_TexelSize.xy)); + lowp vec4 tmpvar_8; + tmpvar_8 = texture2DLodEXT (_MainTex, tmpvar_7.xy, 0.0); + highp float tmpvar_9; + highp vec4 rgba_i0; + rgba_i0 = tmpvar_8; + tmpvar_9 = rgba_i0.w; + highp vec4 tmpvar_10; + tmpvar_10.zw = vec2(0.0, 0.0); + tmpvar_10.xy = (xlv_TEXCOORD0 + (vec2(0.0, -1.0) * _MainTex_TexelSize.xy)); + lowp vec4 tmpvar_11; + tmpvar_11 = texture2DLodEXT (_MainTex, tmpvar_10.xy, 0.0); + highp float tmpvar_12; + highp vec4 rgba_i0_i1; + rgba_i0_i1 = tmpvar_11; + tmpvar_12 = rgba_i0_i1.w; + lumaN = tmpvar_12; + highp vec4 tmpvar_13; + tmpvar_13.zw = vec2(0.0, 0.0); + tmpvar_13.xy = (xlv_TEXCOORD0 + (vec2(-1.0, 0.0) * _MainTex_TexelSize.xy)); + lowp vec4 tmpvar_14; + tmpvar_14 = texture2DLodEXT (_MainTex, tmpvar_13.xy, 0.0); + highp float tmpvar_15; + highp vec4 rgba_i0_i1_i2; + rgba_i0_i1_i2 = tmpvar_14; + tmpvar_15 = rgba_i0_i1_i2.w; + highp float tmpvar_16; + tmpvar_16 = max (max (tmpvar_12, tmpvar_15), max (tmpvar_9, max (tmpvar_6, rgbyM.w))); + highp float tmpvar_17; + tmpvar_17 = (tmpvar_16 - min (min (tmpvar_12, tmpvar_15), min (tmpvar_9, min (tmpvar_6, rgbyM.w)))); + if ((tmpvar_17 < max (0.0833, (tmpvar_16 * 0.166)))) { + tmpvar_1 = rgbyM; + } else { + highp vec4 tmpvar_18; + tmpvar_18.zw = vec2(0.0, 0.0); + tmpvar_18.xy = (xlv_TEXCOORD0 + (vec2(-1.0, -1.0) * _MainTex_TexelSize.xy)); + lowp vec4 tmpvar_19; + tmpvar_19 = texture2DLodEXT (_MainTex, tmpvar_18.xy, 0.0); + highp vec4 rgba_i0_i1_i2_i3; + rgba_i0_i1_i2_i3 = tmpvar_19; + highp vec4 tmpvar_20; + tmpvar_20.zw = vec2(0.0, 0.0); + tmpvar_20.xy = (xlv_TEXCOORD0 + _MainTex_TexelSize.xy); + lowp vec4 tmpvar_21; + tmpvar_21 = texture2DLodEXT (_MainTex, tmpvar_20.xy, 0.0); + highp vec4 rgba_i0_i1_i2_i3_i4; + rgba_i0_i1_i2_i3_i4 = tmpvar_21; + highp vec4 tmpvar_22; + tmpvar_22.zw = vec2(0.0, 0.0); + tmpvar_22.xy = (xlv_TEXCOORD0 + (vec2(1.0, -1.0) * _MainTex_TexelSize.xy)); + lowp vec4 tmpvar_23; + tmpvar_23 = texture2DLodEXT (_MainTex, tmpvar_22.xy, 0.0); + highp vec4 rgba_i0_i1_i2_i3_i4_i5; + rgba_i0_i1_i2_i3_i4_i5 = tmpvar_23; + highp vec4 tmpvar_24; + tmpvar_24.zw = vec2(0.0, 0.0); + tmpvar_24.xy = (xlv_TEXCOORD0 + (vec2(-1.0, 1.0) * _MainTex_TexelSize.xy)); + lowp vec4 tmpvar_25; + tmpvar_25 = texture2DLodEXT (_MainTex, tmpvar_24.xy, 0.0); + highp vec4 rgba_i0_i1_i2_i3_i4_i5_i6; + rgba_i0_i1_i2_i3_i4_i5_i6 = tmpvar_25; + highp float tmpvar_26; + tmpvar_26 = (rgba_i0_i1.w + rgba.w); + highp float tmpvar_27; + tmpvar_27 = (rgba_i0_i1_i2.w + rgba_i0.w); + highp float tmpvar_28; + tmpvar_28 = (1.0/(tmpvar_17)); + highp float tmpvar_29; + tmpvar_29 = (rgba_i0_i1_i2_i3_i4_i5.w + rgba_i0_i1_i2_i3_i4.w); + highp float tmpvar_30; + tmpvar_30 = (rgba_i0_i1_i2_i3.w + rgba_i0_i1_i2_i3_i4_i5_i6.w); + lengthSign = _MainTex_TexelSize.x; + bool tmpvar_31; + tmpvar_31 = ((abs (((-(2.0) * rgba_i0_i1_i2.w) + tmpvar_30)) + ((abs (((-(2.0) * rgbyM.w) + tmpvar_26)) * 2.0) + abs (((-(2.0) * rgba_i0.w) + tmpvar_29)))) >= (abs (((-(2.0) * rgba.w) + (rgba_i0_i1_i2_i3_i4_i5_i6.w + rgba_i0_i1_i2_i3_i4.w))) + ((abs (((-(2.0) * rgbyM.w) + tmpvar_27)) * 2.0) + abs (((-(2.0) * rgba_i0_i1.w) + (rgba_i0_i1_i2_i3.w + rgba_i0_i1_i2_i3_i4_i5.w)))))); + highp float tmpvar_32; + tmpvar_32 = (((tmpvar_26 + tmpvar_27) * 2.0) + (tmpvar_30 + tmpvar_29)); + if (!(tmpvar_31)) { + lumaN = tmpvar_15; + }; + if (!(tmpvar_31)) { + lumaS = tmpvar_9; + }; + if (tmpvar_31) { + lengthSign = _MainTex_TexelSize.y; + }; + highp float tmpvar_33; + tmpvar_33 = ((tmpvar_32 * 0.0833333) - rgbyM.w); + highp float tmpvar_34; + tmpvar_34 = (lumaN - rgbyM.w); + highp float tmpvar_35; + tmpvar_35 = (lumaS - rgbyM.w); + lumaNN = (lumaN + rgbyM.w); + highp float tmpvar_36; + tmpvar_36 = (lumaS + rgbyM.w); + bool tmpvar_37; + tmpvar_37 = (abs (tmpvar_34) >= abs (tmpvar_35)); + highp float tmpvar_38; + tmpvar_38 = max (abs (tmpvar_34), abs (tmpvar_35)); + if (tmpvar_37) { + lengthSign = -(lengthSign); + }; + highp float tmpvar_39; + tmpvar_39 = clamp ((abs (tmpvar_33) * tmpvar_28), 0.0, 1.0); + posB.x = xlv_TEXCOORD0.x; + posB.y = xlv_TEXCOORD0.y; + highp float tmpvar_40; + if (!(tmpvar_31)) { + tmpvar_40 = 0.0; + } else { + tmpvar_40 = _MainTex_TexelSize.x; + }; + highp float tmpvar_41; + if (tmpvar_31) { + tmpvar_41 = 0.0; + } else { + tmpvar_41 = _MainTex_TexelSize.y; + }; + if (!(tmpvar_31)) { + posB.x = (xlv_TEXCOORD0.x + (lengthSign * 0.5)); + }; + if (tmpvar_31) { + posB.y = (xlv_TEXCOORD0.y + (lengthSign * 0.5)); + }; + posN.x = (posB.x - tmpvar_40); + posN.y = (posB.y - tmpvar_41); + posP.x = (posB.x + tmpvar_40); + posP.y = (posB.y + tmpvar_41); + highp float tmpvar_42; + tmpvar_42 = ((-2.0 * tmpvar_39) + 3.0); + highp vec4 tmpvar_43; + tmpvar_43.zw = vec2(0.0, 0.0); + tmpvar_43.xy = posN; + lowp vec4 tmpvar_44; + tmpvar_44 = texture2DLodEXT (_MainTex, tmpvar_43.xy, 0.0); + highp vec4 rgba_i0_i1_i2_i3_i4_i5_i6_i7; + rgba_i0_i1_i2_i3_i4_i5_i6_i7 = tmpvar_44; + lumaEndN = rgba_i0_i1_i2_i3_i4_i5_i6_i7.w; + highp float tmpvar_45; + tmpvar_45 = (tmpvar_39 * tmpvar_39); + highp vec4 tmpvar_46; + tmpvar_46.zw = vec2(0.0, 0.0); + tmpvar_46.xy = posP; + lowp vec4 tmpvar_47; + tmpvar_47 = texture2DLodEXT (_MainTex, tmpvar_46.xy, 0.0); + highp vec4 rgba_i0_i1_i2_i3_i4_i5_i6_i7_i8; + rgba_i0_i1_i2_i3_i4_i5_i6_i7_i8 = tmpvar_47; + lumaEndP = rgba_i0_i1_i2_i3_i4_i5_i6_i7_i8.w; + if (!(tmpvar_37)) { + lumaNN = tmpvar_36; + }; + highp float tmpvar_48; + tmpvar_48 = (tmpvar_38 / 4.0); + highp float tmpvar_49; + tmpvar_49 = (tmpvar_42 * tmpvar_45); + bool tmpvar_50; + tmpvar_50 = ((rgbyM.w - (lumaNN * 0.5)) < 0.0); + highp float tmpvar_51; + tmpvar_51 = (rgba_i0_i1_i2_i3_i4_i5_i6_i7.w - (lumaNN * 0.5)); + lumaEndN = tmpvar_51; + highp float tmpvar_52; + tmpvar_52 = (rgba_i0_i1_i2_i3_i4_i5_i6_i7_i8.w - (lumaNN * 0.5)); + lumaEndP = tmpvar_52; + bool tmpvar_53; + tmpvar_53 = (abs (tmpvar_51) >= tmpvar_48); + bool tmpvar_54; + tmpvar_54 = (abs (tmpvar_52) >= tmpvar_48); + if (!(tmpvar_53)) { + posN.x = (posN.x - tmpvar_40); + }; + if (!(tmpvar_53)) { + posN.y = (posN.y - tmpvar_41); + }; + bool tmpvar_55; + if (!(tmpvar_53)) { + tmpvar_55 = bool(1); + } else { + tmpvar_55 = !(tmpvar_54); + }; + if (!(tmpvar_54)) { + posP.x = (posP.x + tmpvar_40); + }; + if (!(tmpvar_54)) { + posP.y = (posP.y + tmpvar_41); + }; + if (tmpvar_55) { + if (!(tmpvar_53)) { + highp vec4 tmpvar_56; + tmpvar_56.zw = vec2(0.0, 0.0); + tmpvar_56.xy = posN; + lowp vec4 tmpvar_57; + tmpvar_57 = texture2DLodEXT (_MainTex, tmpvar_56.xy, 0.0); + highp vec4 rgba_i0_i1_i2_i3_i4_i5_i6_i7_i8_i9; + rgba_i0_i1_i2_i3_i4_i5_i6_i7_i8_i9 = tmpvar_57; + lumaEndN = rgba_i0_i1_i2_i3_i4_i5_i6_i7_i8_i9.w; + }; + if (!(tmpvar_54)) { + highp vec4 tmpvar_58; + tmpvar_58.zw = vec2(0.0, 0.0); + tmpvar_58.xy = posP; + lowp vec4 tmpvar_59; + tmpvar_59 = texture2DLodEXT (_MainTex, tmpvar_58.xy, 0.0); + highp vec4 rgba_i0_i1_i2_i3_i4_i5_i6_i7_i8_i9; + rgba_i0_i1_i2_i3_i4_i5_i6_i7_i8_i9 = tmpvar_59; + lumaEndP = rgba_i0_i1_i2_i3_i4_i5_i6_i7_i8_i9.w; + }; + if (!(tmpvar_53)) { + lumaEndN = (lumaEndN - (lumaNN * 0.5)); + }; + if (!(tmpvar_54)) { + lumaEndP = (lumaEndP - (lumaNN * 0.5)); + }; + bool tmpvar_60; + tmpvar_60 = (abs (lumaEndN) >= tmpvar_48); + bool tmpvar_61; + tmpvar_61 = (abs (lumaEndP) >= tmpvar_48); + if (!(tmpvar_60)) { + posN.x = (posN.x - tmpvar_40); + }; + if (!(tmpvar_60)) { + posN.y = (posN.y - tmpvar_41); + }; + bool tmpvar_62; + if (!(tmpvar_60)) { + tmpvar_62 = bool(1); + } else { + tmpvar_62 = !(tmpvar_61); + }; + if (!(tmpvar_61)) { + posP.x = (posP.x + tmpvar_40); + }; + if (!(tmpvar_61)) { + posP.y = (posP.y + tmpvar_41); + }; + if (tmpvar_62) { + if (!(tmpvar_60)) { + highp vec4 tmpvar_63; + tmpvar_63.zw = vec2(0.0, 0.0); + tmpvar_63.xy = posN; + lowp vec4 tmpvar_64; + tmpvar_64 = texture2DLodEXT (_MainTex, tmpvar_63.xy, 0.0); + highp vec4 rgba_i0_i1_i2_i3_i4_i5_i6_i7_i8_i9; + rgba_i0_i1_i2_i3_i4_i5_i6_i7_i8_i9 = tmpvar_64; + lumaEndN = rgba_i0_i1_i2_i3_i4_i5_i6_i7_i8_i9.w; + }; + if (!(tmpvar_61)) { + highp vec4 tmpvar_65; + tmpvar_65.zw = vec2(0.0, 0.0); + tmpvar_65.xy = posP; + lowp vec4 tmpvar_66; + tmpvar_66 = texture2DLodEXT (_MainTex, tmpvar_65.xy, 0.0); + highp vec4 rgba_i0_i1_i2_i3_i4_i5_i6_i7_i8_i9; + rgba_i0_i1_i2_i3_i4_i5_i6_i7_i8_i9 = tmpvar_66; + lumaEndP = rgba_i0_i1_i2_i3_i4_i5_i6_i7_i8_i9.w; + }; + if (!(tmpvar_60)) { + lumaEndN = (lumaEndN - (lumaNN * 0.5)); + }; + if (!(tmpvar_61)) { + lumaEndP = (lumaEndP - (lumaNN * 0.5)); + }; + bool tmpvar_67; + tmpvar_67 = (abs (lumaEndN) >= tmpvar_48); + bool tmpvar_68; + tmpvar_68 = (abs (lumaEndP) >= tmpvar_48); + if (!(tmpvar_67)) { + posN.x = (posN.x - tmpvar_40); + }; + if (!(tmpvar_67)) { + posN.y = (posN.y - tmpvar_41); + }; + bool tmpvar_69; + if (!(tmpvar_67)) { + tmpvar_69 = bool(1); + } else { + tmpvar_69 = !(tmpvar_68); + }; + if (!(tmpvar_68)) { + posP.x = (posP.x + tmpvar_40); + }; + if (!(tmpvar_68)) { + posP.y = (posP.y + tmpvar_41); + }; + if (tmpvar_69) { + if (!(tmpvar_67)) { + highp vec4 tmpvar_70; + tmpvar_70.zw = vec2(0.0, 0.0); + tmpvar_70.xy = posN; + lowp vec4 tmpvar_71; + tmpvar_71 = texture2DLodEXT (_MainTex, tmpvar_70.xy, 0.0); + highp vec4 rgba_i0_i1_i2_i3_i4_i5_i6_i7_i8_i9; + rgba_i0_i1_i2_i3_i4_i5_i6_i7_i8_i9 = tmpvar_71; + lumaEndN = rgba_i0_i1_i2_i3_i4_i5_i6_i7_i8_i9.w; + }; + if (!(tmpvar_68)) { + highp vec4 tmpvar_72; + tmpvar_72.zw = vec2(0.0, 0.0); + tmpvar_72.xy = posP; + lowp vec4 tmpvar_73; + tmpvar_73 = texture2DLodEXT (_MainTex, tmpvar_72.xy, 0.0); + highp vec4 rgba_i0_i1_i2_i3_i4_i5_i6_i7_i8_i9; + rgba_i0_i1_i2_i3_i4_i5_i6_i7_i8_i9 = tmpvar_73; + lumaEndP = rgba_i0_i1_i2_i3_i4_i5_i6_i7_i8_i9.w; + }; + if (!(tmpvar_67)) { + lumaEndN = (lumaEndN - (lumaNN * 0.5)); + }; + if (!(tmpvar_68)) { + lumaEndP = (lumaEndP - (lumaNN * 0.5)); + }; + bool tmpvar_74; + tmpvar_74 = (abs (lumaEndN) >= tmpvar_48); + bool tmpvar_75; + tmpvar_75 = (abs (lumaEndP) >= tmpvar_48); + if (!(tmpvar_74)) { + posN.x = (posN.x - tmpvar_40); + }; + if (!(tmpvar_74)) { + posN.y = (posN.y - tmpvar_41); + }; + bool tmpvar_76; + if (!(tmpvar_74)) { + tmpvar_76 = bool(1); + } else { + tmpvar_76 = !(tmpvar_75); + }; + if (!(tmpvar_75)) { + posP.x = (posP.x + tmpvar_40); + }; + if (!(tmpvar_75)) { + posP.y = (posP.y + tmpvar_41); + }; + if (tmpvar_76) { + if (!(tmpvar_74)) { + highp vec4 tmpvar_77; + tmpvar_77.zw = vec2(0.0, 0.0); + tmpvar_77.xy = posN; + lowp vec4 tmpvar_78; + tmpvar_78 = texture2DLodEXT (_MainTex, tmpvar_77.xy, 0.0); + highp vec4 rgba_i0_i1_i2_i3_i4_i5_i6_i7_i8_i9; + rgba_i0_i1_i2_i3_i4_i5_i6_i7_i8_i9 = tmpvar_78; + lumaEndN = rgba_i0_i1_i2_i3_i4_i5_i6_i7_i8_i9.w; + }; + if (!(tmpvar_75)) { + highp vec4 tmpvar_79; + tmpvar_79.zw = vec2(0.0, 0.0); + tmpvar_79.xy = posP; + lowp vec4 tmpvar_80; + tmpvar_80 = texture2DLodEXT (_MainTex, tmpvar_79.xy, 0.0); + highp vec4 rgba_i0_i1_i2_i3_i4_i5_i6_i7_i8_i9; + rgba_i0_i1_i2_i3_i4_i5_i6_i7_i8_i9 = tmpvar_80; + lumaEndP = rgba_i0_i1_i2_i3_i4_i5_i6_i7_i8_i9.w; + }; + if (!(tmpvar_74)) { + lumaEndN = (lumaEndN - (lumaNN * 0.5)); + }; + if (!(tmpvar_75)) { + lumaEndP = (lumaEndP - (lumaNN * 0.5)); + }; + bool tmpvar_81; + tmpvar_81 = (abs (lumaEndN) >= tmpvar_48); + bool tmpvar_82; + tmpvar_82 = (abs (lumaEndP) >= tmpvar_48); + if (!(tmpvar_81)) { + posN.x = (posN.x - (tmpvar_40 * 1.5)); + }; + if (!(tmpvar_81)) { + posN.y = (posN.y - (tmpvar_41 * 1.5)); + }; + bool tmpvar_83; + if (!(tmpvar_81)) { + tmpvar_83 = bool(1); + } else { + tmpvar_83 = !(tmpvar_82); + }; + if (!(tmpvar_82)) { + posP.x = (posP.x + (tmpvar_40 * 1.5)); + }; + if (!(tmpvar_82)) { + posP.y = (posP.y + (tmpvar_41 * 1.5)); + }; + if (tmpvar_83) { + if (!(tmpvar_81)) { + highp vec4 tmpvar_84; + tmpvar_84.zw = vec2(0.0, 0.0); + tmpvar_84.xy = posN; + lowp vec4 tmpvar_85; + tmpvar_85 = texture2DLodEXT (_MainTex, tmpvar_84.xy, 0.0); + highp vec4 rgba_i0_i1_i2_i3_i4_i5_i6_i7_i8_i9; + rgba_i0_i1_i2_i3_i4_i5_i6_i7_i8_i9 = tmpvar_85; + lumaEndN = rgba_i0_i1_i2_i3_i4_i5_i6_i7_i8_i9.w; + }; + if (!(tmpvar_82)) { + highp vec4 tmpvar_86; + tmpvar_86.zw = vec2(0.0, 0.0); + tmpvar_86.xy = posP; + lowp vec4 tmpvar_87; + tmpvar_87 = texture2DLodEXT (_MainTex, tmpvar_86.xy, 0.0); + highp vec4 rgba_i0_i1_i2_i3_i4_i5_i6_i7_i8_i9; + rgba_i0_i1_i2_i3_i4_i5_i6_i7_i8_i9 = tmpvar_87; + lumaEndP = rgba_i0_i1_i2_i3_i4_i5_i6_i7_i8_i9.w; + }; + if (!(tmpvar_81)) { + lumaEndN = (lumaEndN - (lumaNN * 0.5)); + }; + if (!(tmpvar_82)) { + lumaEndP = (lumaEndP - (lumaNN * 0.5)); + }; + bool tmpvar_88; + tmpvar_88 = (abs (lumaEndN) >= tmpvar_48); + bool tmpvar_89; + tmpvar_89 = (abs (lumaEndP) >= tmpvar_48); + if (!(tmpvar_88)) { + posN.x = (posN.x - (tmpvar_40 * 2.0)); + }; + if (!(tmpvar_88)) { + posN.y = (posN.y - (tmpvar_41 * 2.0)); + }; + bool tmpvar_90; + if (!(tmpvar_88)) { + tmpvar_90 = bool(1); + } else { + tmpvar_90 = !(tmpvar_89); + }; + if (!(tmpvar_89)) { + posP.x = (posP.x + (tmpvar_40 * 2.0)); + }; + if (!(tmpvar_89)) { + posP.y = (posP.y + (tmpvar_41 * 2.0)); + }; + if (tmpvar_90) { + if (!(tmpvar_88)) { + highp vec4 tmpvar_91; + tmpvar_91.zw = vec2(0.0, 0.0); + tmpvar_91.xy = posN; + lowp vec4 tmpvar_92; + tmpvar_92 = texture2DLodEXT (_MainTex, tmpvar_91.xy, 0.0); + highp vec4 rgba_i0_i1_i2_i3_i4_i5_i6_i7_i8_i9; + rgba_i0_i1_i2_i3_i4_i5_i6_i7_i8_i9 = tmpvar_92; + lumaEndN = rgba_i0_i1_i2_i3_i4_i5_i6_i7_i8_i9.w; + }; + if (!(tmpvar_89)) { + highp vec4 tmpvar_93; + tmpvar_93.zw = vec2(0.0, 0.0); + tmpvar_93.xy = posP; + lowp vec4 tmpvar_94; + tmpvar_94 = texture2DLodEXT (_MainTex, tmpvar_93.xy, 0.0); + highp vec4 rgba_i0_i1_i2_i3_i4_i5_i6_i7_i8_i9; + rgba_i0_i1_i2_i3_i4_i5_i6_i7_i8_i9 = tmpvar_94; + lumaEndP = rgba_i0_i1_i2_i3_i4_i5_i6_i7_i8_i9.w; + }; + if (!(tmpvar_88)) { + lumaEndN = (lumaEndN - (lumaNN * 0.5)); + }; + if (!(tmpvar_89)) { + lumaEndP = (lumaEndP - (lumaNN * 0.5)); + }; + bool tmpvar_95; + tmpvar_95 = (abs (lumaEndN) >= tmpvar_48); + bool tmpvar_96; + tmpvar_96 = (abs (lumaEndP) >= tmpvar_48); + if (!(tmpvar_95)) { + posN.x = (posN.x - (tmpvar_40 * 2.0)); + }; + if (!(tmpvar_95)) { + posN.y = (posN.y - (tmpvar_41 * 2.0)); + }; + bool tmpvar_97; + if (!(tmpvar_95)) { + tmpvar_97 = bool(1); + } else { + tmpvar_97 = !(tmpvar_96); + }; + if (!(tmpvar_96)) { + posP.x = (posP.x + (tmpvar_40 * 2.0)); + }; + if (!(tmpvar_96)) { + posP.y = (posP.y + (tmpvar_41 * 2.0)); + }; + if (tmpvar_97) { + if (!(tmpvar_95)) { + highp vec4 tmpvar_98; + tmpvar_98.zw = vec2(0.0, 0.0); + tmpvar_98.xy = posN; + lowp vec4 tmpvar_99; + tmpvar_99 = texture2DLodEXT (_MainTex, tmpvar_98.xy, 0.0); + highp vec4 rgba_i0_i1_i2_i3_i4_i5_i6_i7_i8_i9; + rgba_i0_i1_i2_i3_i4_i5_i6_i7_i8_i9 = tmpvar_99; + lumaEndN = rgba_i0_i1_i2_i3_i4_i5_i6_i7_i8_i9.w; + }; + if (!(tmpvar_96)) { + highp vec4 tmpvar_100; + tmpvar_100.zw = vec2(0.0, 0.0); + tmpvar_100.xy = posP; + lowp vec4 tmpvar_101; + tmpvar_101 = texture2DLodEXT (_MainTex, tmpvar_100.xy, 0.0); + highp vec4 rgba_i0_i1_i2_i3_i4_i5_i6_i7_i8_i9; + rgba_i0_i1_i2_i3_i4_i5_i6_i7_i8_i9 = tmpvar_101; + lumaEndP = rgba_i0_i1_i2_i3_i4_i5_i6_i7_i8_i9.w; + }; + if (!(tmpvar_95)) { + lumaEndN = (lumaEndN - (lumaNN * 0.5)); + }; + if (!(tmpvar_96)) { + lumaEndP = (lumaEndP - (lumaNN * 0.5)); + }; + bool tmpvar_102; + tmpvar_102 = (abs (lumaEndN) >= tmpvar_48); + bool tmpvar_103; + tmpvar_103 = (abs (lumaEndP) >= tmpvar_48); + if (!(tmpvar_102)) { + posN.x = (posN.x - (tmpvar_40 * 2.0)); + }; + if (!(tmpvar_102)) { + posN.y = (posN.y - (tmpvar_41 * 2.0)); + }; + bool tmpvar_104; + if (!(tmpvar_102)) { + tmpvar_104 = bool(1); + } else { + tmpvar_104 = !(tmpvar_103); + }; + if (!(tmpvar_103)) { + posP.x = (posP.x + (tmpvar_40 * 2.0)); + }; + if (!(tmpvar_103)) { + posP.y = (posP.y + (tmpvar_41 * 2.0)); + }; + if (tmpvar_104) { + if (!(tmpvar_102)) { + highp vec4 tmpvar_105; + tmpvar_105.zw = vec2(0.0, 0.0); + tmpvar_105.xy = posN; + lowp vec4 tmpvar_106; + tmpvar_106 = texture2DLodEXT (_MainTex, tmpvar_105.xy, 0.0); + highp vec4 rgba_i0_i1_i2_i3_i4_i5_i6_i7_i8_i9; + rgba_i0_i1_i2_i3_i4_i5_i6_i7_i8_i9 = tmpvar_106; + lumaEndN = rgba_i0_i1_i2_i3_i4_i5_i6_i7_i8_i9.w; + }; + if (!(tmpvar_103)) { + highp vec4 tmpvar_107; + tmpvar_107.zw = vec2(0.0, 0.0); + tmpvar_107.xy = posP; + lowp vec4 tmpvar_108; + tmpvar_108 = texture2DLodEXT (_MainTex, tmpvar_107.xy, 0.0); + highp vec4 rgba_i0_i1_i2_i3_i4_i5_i6_i7_i8_i9; + rgba_i0_i1_i2_i3_i4_i5_i6_i7_i8_i9 = tmpvar_108; + lumaEndP = rgba_i0_i1_i2_i3_i4_i5_i6_i7_i8_i9.w; + }; + if (!(tmpvar_102)) { + lumaEndN = (lumaEndN - (lumaNN * 0.5)); + }; + if (!(tmpvar_103)) { + lumaEndP = (lumaEndP - (lumaNN * 0.5)); + }; + bool tmpvar_109; + tmpvar_109 = (abs (lumaEndN) >= tmpvar_48); + bool tmpvar_110; + tmpvar_110 = (abs (lumaEndP) >= tmpvar_48); + if (!(tmpvar_109)) { + posN.x = (posN.x - (tmpvar_40 * 2.0)); + }; + if (!(tmpvar_109)) { + posN.y = (posN.y - (tmpvar_41 * 2.0)); + }; + bool tmpvar_111; + if (!(tmpvar_109)) { + tmpvar_111 = bool(1); + } else { + tmpvar_111 = !(tmpvar_110); + }; + if (!(tmpvar_110)) { + posP.x = (posP.x + (tmpvar_40 * 2.0)); + }; + if (!(tmpvar_110)) { + posP.y = (posP.y + (tmpvar_41 * 2.0)); + }; + if (tmpvar_111) { + if (!(tmpvar_109)) { + highp vec4 tmpvar_112; + tmpvar_112.zw = vec2(0.0, 0.0); + tmpvar_112.xy = posN; + lowp vec4 tmpvar_113; + tmpvar_113 = texture2DLodEXT (_MainTex, tmpvar_112.xy, 0.0); + highp vec4 rgba_i0_i1_i2_i3_i4_i5_i6_i7_i8_i9; + rgba_i0_i1_i2_i3_i4_i5_i6_i7_i8_i9 = tmpvar_113; + lumaEndN = rgba_i0_i1_i2_i3_i4_i5_i6_i7_i8_i9.w; + }; + if (!(tmpvar_110)) { + highp vec4 tmpvar_114; + tmpvar_114.zw = vec2(0.0, 0.0); + tmpvar_114.xy = posP; + lowp vec4 tmpvar_115; + tmpvar_115 = texture2DLodEXT (_MainTex, tmpvar_114.xy, 0.0); + highp vec4 rgba_i0_i1_i2_i3_i4_i5_i6_i7_i8_i9; + rgba_i0_i1_i2_i3_i4_i5_i6_i7_i8_i9 = tmpvar_115; + lumaEndP = rgba_i0_i1_i2_i3_i4_i5_i6_i7_i8_i9.w; + }; + if (!(tmpvar_109)) { + lumaEndN = (lumaEndN - (lumaNN * 0.5)); + }; + if (!(tmpvar_110)) { + lumaEndP = (lumaEndP - (lumaNN * 0.5)); + }; + bool tmpvar_116; + tmpvar_116 = (abs (lumaEndN) >= tmpvar_48); + bool tmpvar_117; + tmpvar_117 = (abs (lumaEndP) >= tmpvar_48); + if (!(tmpvar_116)) { + posN.x = (posN.x - (tmpvar_40 * 4.0)); + }; + if (!(tmpvar_116)) { + posN.y = (posN.y - (tmpvar_41 * 4.0)); + }; + bool tmpvar_118; + if (!(tmpvar_116)) { + tmpvar_118 = bool(1); + } else { + tmpvar_118 = !(tmpvar_117); + }; + if (!(tmpvar_117)) { + posP.x = (posP.x + (tmpvar_40 * 4.0)); + }; + if (!(tmpvar_117)) { + posP.y = (posP.y + (tmpvar_41 * 4.0)); + }; + if (tmpvar_118) { + if (!(tmpvar_116)) { + highp vec4 tmpvar_119; + tmpvar_119.zw = vec2(0.0, 0.0); + tmpvar_119.xy = posN; + lowp vec4 tmpvar_120; + tmpvar_120 = texture2DLodEXT (_MainTex, tmpvar_119.xy, 0.0); + highp vec4 rgba_i0_i1_i2_i3_i4_i5_i6_i7_i8_i9; + rgba_i0_i1_i2_i3_i4_i5_i6_i7_i8_i9 = tmpvar_120; + lumaEndN = rgba_i0_i1_i2_i3_i4_i5_i6_i7_i8_i9.w; + }; + if (!(tmpvar_117)) { + highp vec4 tmpvar_121; + tmpvar_121.zw = vec2(0.0, 0.0); + tmpvar_121.xy = posP; + lowp vec4 tmpvar_122; + tmpvar_122 = texture2DLodEXT (_MainTex, tmpvar_121.xy, 0.0); + highp vec4 rgba_i0_i1_i2_i3_i4_i5_i6_i7_i8_i9; + rgba_i0_i1_i2_i3_i4_i5_i6_i7_i8_i9 = tmpvar_122; + lumaEndP = rgba_i0_i1_i2_i3_i4_i5_i6_i7_i8_i9.w; + }; + if (!(tmpvar_116)) { + lumaEndN = (lumaEndN - (lumaNN * 0.5)); + }; + if (!(tmpvar_117)) { + lumaEndP = (lumaEndP - (lumaNN * 0.5)); + }; + bool tmpvar_123; + tmpvar_123 = (abs (lumaEndN) >= tmpvar_48); + bool tmpvar_124; + tmpvar_124 = (abs (lumaEndP) >= tmpvar_48); + if (!(tmpvar_123)) { + posN.x = (posN.x - (tmpvar_40 * 8.0)); + }; + if (!(tmpvar_123)) { + posN.y = (posN.y - (tmpvar_41 * 8.0)); + }; + if (!(tmpvar_123)) { + }; + if (!(tmpvar_124)) { + posP.x = (posP.x + (tmpvar_40 * 8.0)); + }; + if (!(tmpvar_124)) { + posP.y = (posP.y + (tmpvar_41 * 8.0)); + }; + }; + }; + }; + }; + }; + }; + }; + }; + }; + }; + dstN = (xlv_TEXCOORD0.x - posN.x); + dstP = (posP.x - xlv_TEXCOORD0.x); + if (!(tmpvar_31)) { + dstN = (xlv_TEXCOORD0.y - posN.y); + }; + if (!(tmpvar_31)) { + dstP = (posP.y - xlv_TEXCOORD0.y); + }; + bool tmpvar_125; + tmpvar_125 = ((lumaEndN < 0.0) != tmpvar_50); + bool tmpvar_126; + tmpvar_126 = ((lumaEndP < 0.0) != tmpvar_50); + highp float tmpvar_127; + tmpvar_127 = (1.0/((dstP + dstN))); + highp float tmpvar_128; + tmpvar_128 = min (dstN, dstP); + bool tmpvar_129; + if ((dstN < dstP)) { + tmpvar_129 = tmpvar_125; + } else { + tmpvar_129 = tmpvar_126; + }; + highp float tmpvar_130; + tmpvar_130 = ((tmpvar_128 * -(tmpvar_127)) + 0.5); + highp float tmpvar_131; + tmpvar_131 = ((tmpvar_49 * tmpvar_49) * 0.75); + highp float tmpvar_132; + if (tmpvar_129) { + tmpvar_132 = tmpvar_130; + } else { + tmpvar_132 = 0.0; + }; + highp float tmpvar_133; + tmpvar_133 = max (tmpvar_132, tmpvar_131); + if (!(tmpvar_31)) { + posM.x = (xlv_TEXCOORD0.x + (tmpvar_133 * lengthSign)); + }; + if (tmpvar_31) { + posM.y = (xlv_TEXCOORD0.y + (tmpvar_133 * lengthSign)); + }; + highp vec4 tmpvar_134; + tmpvar_134.zw = vec2(0.0, 0.0); + tmpvar_134.xy = posM; + lowp vec4 tmpvar_135; + tmpvar_135 = texture2DLodEXT (_MainTex, tmpvar_134.xy, 0.0); + highp vec4 tmpvar_136; + tmpvar_136.xyz = tmpvar_135.xyz; + tmpvar_136.w = rgbyM.w; + tmpvar_1 = tmpvar_136; + }; + gl_FragData[0] = tmpvar_1; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/complex-particle-in.txt b/3rdparty/glsl-optimizer/tests/fragment/complex-particle-in.txt new file mode 100644 index 000000000..ce406bb8d --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/complex-particle-in.txt @@ -0,0 +1,21 @@ +struct v2f { + vec4 vertex; + vec4 color; + vec2 texcoord; +}; +uniform sampler2D _MainTex; +vec4 xlat_main( in v2f i ); +vec4 xlat_main( in v2f i ) { + return (i.color * texture2D( _MainTex, i.texcoord)); +} +varying vec4 xlv_COLOR; +varying vec2 xlv_TEXCOORD0; +void main() { + vec4 xl_retval; + v2f xlt_i; + xlt_i.vertex = vec4(0.0); + xlt_i.color = vec4( xlv_COLOR); + xlt_i.texcoord = vec2( xlv_TEXCOORD0); + xl_retval = xlat_main( xlt_i); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/complex-particle-inES.txt b/3rdparty/glsl-optimizer/tests/fragment/complex-particle-inES.txt new file mode 100644 index 000000000..8ecedcf4d --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/complex-particle-inES.txt @@ -0,0 +1,20 @@ +struct v2f { + highp vec4 vertex; + lowp vec4 color; + mediump vec2 texcoord; +}; +uniform sampler2D _MainTex; +lowp vec4 xlat_main( in v2f i ) { + return (i.color * texture2D( _MainTex, i.texcoord)); +} +varying lowp vec4 xlv_COLOR; +varying mediump vec2 xlv_TEXCOORD0; +void main() { + lowp vec4 xl_retval; + v2f xlt_i; + xlt_i.vertex = vec4(0.0); + xlt_i.color = vec4( xlv_COLOR); + xlt_i.texcoord = vec2( xlv_TEXCOORD0); + xl_retval = xlat_main( xlt_i); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/complex-particle-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/complex-particle-ir.txt new file mode 100644 index 000000000..33df9300a --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/complex-particle-ir.txt @@ -0,0 +1,46 @@ +struct v2f { + vec4 vertex; + vec4 color; + vec2 texcoord; +}; +varying vec2 xlv_TEXCOORD0; +varying vec4 xlv_COLOR; +uniform sampler2D _MainTex; +vec4 xlat_main ( + in v2f i +) +{ + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, i.texcoord); + return (i.color * tmpvar_1); +} + +void main () +{ + v2f xlt_i; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_i.vertex = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = xlv_COLOR.xyzw; + vec4 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_i.color = tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = xlv_TEXCOORD0.xy; + vec2 tmpvar_5; + tmpvar_5 = tmpvar_4; + xlt_i.texcoord = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = xlat_main (xlt_i); + vec4 tmpvar_7; + tmpvar_7 = tmpvar_6; + xl_retval = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = xl_retval.xyzw; + vec4 tmpvar_9; + tmpvar_9 = tmpvar_8; + gl_FragData[0] = tmpvar_9; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/complex-particle-irES.txt b/3rdparty/glsl-optimizer/tests/fragment/complex-particle-irES.txt new file mode 100644 index 000000000..da93bdd0e --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/complex-particle-irES.txt @@ -0,0 +1,46 @@ +struct v2f { + highp vec4 vertex; + lowp vec4 color; + mediump vec2 texcoord; +}; +varying mediump vec2 xlv_TEXCOORD0; +varying lowp vec4 xlv_COLOR; +uniform sampler2D _MainTex; +lowp vec4 xlat_main ( + in v2f i +) +{ + lowp vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, i.texcoord); + return (i.color * tmpvar_1); +} + +void main () +{ + v2f xlt_i; + lowp vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_i.vertex = tmpvar_1; + lowp vec4 tmpvar_2; + tmpvar_2 = xlv_COLOR.xyzw; + lowp vec4 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_i.color = tmpvar_3; + mediump vec2 tmpvar_4; + tmpvar_4 = xlv_TEXCOORD0.xy; + mediump vec2 tmpvar_5; + tmpvar_5 = tmpvar_4; + xlt_i.texcoord = tmpvar_5; + lowp vec4 tmpvar_6; + tmpvar_6 = xlat_main (xlt_i); + lowp vec4 tmpvar_7; + tmpvar_7 = tmpvar_6; + xl_retval = tmpvar_7; + lowp vec4 tmpvar_8; + tmpvar_8 = xl_retval.xyzw; + lowp vec4 tmpvar_9; + tmpvar_9 = tmpvar_8; + gl_FragData[0] = tmpvar_9; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/complex-particle-out.txt b/3rdparty/glsl-optimizer/tests/fragment/complex-particle-out.txt new file mode 100644 index 000000000..ea8caea49 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/complex-particle-out.txt @@ -0,0 +1,8 @@ +varying vec2 xlv_TEXCOORD0; +varying vec4 xlv_COLOR; +uniform sampler2D _MainTex; +void main () +{ + gl_FragData[0] = (xlv_COLOR * texture2D (_MainTex, xlv_TEXCOORD0)); +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/complex-particle-outES.txt b/3rdparty/glsl-optimizer/tests/fragment/complex-particle-outES.txt new file mode 100644 index 000000000..629618c39 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/complex-particle-outES.txt @@ -0,0 +1,8 @@ +varying mediump vec2 xlv_TEXCOORD0; +varying lowp vec4 xlv_COLOR; +uniform sampler2D _MainTex; +void main () +{ + gl_FragData[0] = (xlv_COLOR * texture2D (_MainTex, xlv_TEXCOORD0)); +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/complex-prepasslight-in.txt b/3rdparty/glsl-optimizer/tests/fragment/complex-prepasslight-in.txt new file mode 100644 index 000000000..bdc511fc9 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/complex-prepasslight-in.txt @@ -0,0 +1,145 @@ +float xll_saturate( float x) { + return clamp( x, 0.0, 1.0); +} +vec2 xll_saturate( vec2 x) { + return clamp( x, 0.0, 1.0); +} +vec3 xll_saturate( vec3 x) { + return clamp( x, 0.0, 1.0); +} +vec4 xll_saturate( vec4 x) { + return clamp( x, 0.0, 1.0); +} +mat2 xll_saturate(mat2 m) { + return mat2( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0)); +} +mat3 xll_saturate(mat3 m) { + return mat3( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0), clamp(m[2], 0.0, 1.0)); +} +mat4 xll_saturate(mat4 m) { + return mat4( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0), clamp(m[2], 0.0, 1.0), clamp(m[3], 0.0, 1.0)); +} +vec2 xll_vecTSel (bvec2 a, vec2 b, vec2 c) { + return vec2 (a.x ? b.x : c.x, a.y ? b.y : c.y); +} +vec3 xll_vecTSel (bvec3 a, vec3 b, vec3 c) { + return vec3 (a.x ? b.x : c.x, a.y ? b.y : c.y, a.z ? b.z : c.z); +} +vec4 xll_vecTSel (bvec4 a, vec4 b, vec4 c) { + return vec4 (a.x ? b.x : c.x, a.y ? b.y : c.y, a.z ? b.z : c.z, a.w ? b.w : c.w); +} +struct v2f { + vec4 pos; + vec4 uv; + vec3 ray; +}; +uniform sampler2D _CameraDepthTexture; +uniform sampler2D _CameraNormalsTexture; +uniform mat4 _CameraToWorld; +uniform vec4 _LightColor; +uniform mat4 _LightMatrix0; +uniform vec4 _LightPos; +uniform vec4 _LightPositionRange; +uniform vec4 _LightShadowData; +uniform samplerCube _LightTexture0; +uniform sampler2D _LightTextureB0; +uniform vec4 _ProjectionParams; +uniform samplerCube _ShadowMapTexture; +uniform vec3 _WorldSpaceCameraPos; +uniform vec4 _ZBufferParams; +uniform vec4 unity_LightmapFade; +float Luminance( in vec3 c ); +float Linear01Depth( in float z ); +float DecodeFloatRGBA( in vec4 enc ); +float SampleCubeDistance( in vec3 vec ); +float unitySampleShadow( in vec3 vec, in float mydist ); +float ComputeShadow( in vec3 vec, in float z, in vec2 uv ); +vec4 xlat_main( in v2f i ); +float Luminance( in vec3 c ) { + return dot( c, vec3( 0.220000, 0.707000, 0.0710000)); +} +float Linear01Depth( in float z ) { + return (1.00000 / ((_ZBufferParams.x * z) + _ZBufferParams.y )); +} +float DecodeFloatRGBA( in vec4 enc ) { + vec4 kDecodeDot = vec4( 1.00000, 0.00392157, 1.53787e-005, 6.22737e-009); + return dot( enc, kDecodeDot); +} +float SampleCubeDistance( in vec3 vec ) { + vec4 packDist; + packDist = textureCube( _ShadowMapTexture, vec); + return DecodeFloatRGBA( packDist); +} +float unitySampleShadow( in vec3 vec, in float mydist ) { + float z = 0.00781250; + vec4 shadowVals; + vec4 shadows; + shadowVals.x = SampleCubeDistance( (vec + vec3( z, z, z))); + shadowVals.y = SampleCubeDistance( (vec + vec3( ( -z ), ( -z ), z))); + shadowVals.z = SampleCubeDistance( (vec + vec3( ( -z ), z, ( -z )))); + shadowVals.w = SampleCubeDistance( (vec + vec3( z, ( -z ), ( -z )))); + shadows = xll_vecTSel (lessThan( shadowVals, vec4( vec4( mydist) )), vec4( _LightShadowData.xxxx ), vec4( 1.00000)); + return dot( shadows, vec4( 0.250000)); +} +float ComputeShadow( in vec3 vec, in float z, in vec2 uv ) { + float fade; + float mydist; + fade = ((z * _LightShadowData.z ) + _LightShadowData.w ); + fade = xll_saturate( fade ); + mydist = (length( vec ) * _LightPositionRange.w ); + mydist *= 0.970000; + return unitySampleShadow( vec, mydist); + return 1.00000; +} +vec4 xlat_main( in v2f i ) { + vec2 uv; + vec4 nspec; + vec3 normal; + float depth; + vec4 vpos; + vec3 wpos; + vec3 tolight; + vec3 lightDir; + float att; + float atten; + float diff; + vec3 h; + float spec; + vec4 res; + float fade; + i.ray = (i.ray * (_ProjectionParams.z / i.ray.z )); + uv = (i.uv.xy / i.uv.w ); + nspec = texture2D( _CameraNormalsTexture, uv); + normal = ((nspec.xyz * 2.00000) - 1.00000); + normal = normalize( normal ); + depth = texture2D( _CameraDepthTexture, uv).x ; + depth = Linear01Depth( depth); + vpos = vec4( (i.ray * depth), 1.00000); + wpos = ( _CameraToWorld * vpos ).xyz ; + tolight = (wpos - _LightPos.xyz ); + lightDir = ( -normalize( tolight ) ); + att = (dot( tolight, tolight) * _LightPos.w ); + atten = texture2D( _LightTextureB0, vec2( vec2( att))).w ; + atten *= ComputeShadow( tolight, vpos.z , uv); + atten *= textureCube( _LightTexture0, ( _LightMatrix0 * vec4( wpos, 1.00000) ).xyz ).w ; + diff = max( 0.000000, dot( lightDir, normal)); + h = normalize( (lightDir - normalize( (wpos - _WorldSpaceCameraPos) )) ); + spec = pow( max( 0.000000, dot( h, normal)), (nspec.w * 128.000)); + spec *= xll_saturate( atten ); + res.xyz = (_LightColor.xyz * (diff * atten)); + res.w = (spec * Luminance( _LightColor.xyz )); + fade = ((vpos.z * unity_LightmapFade.z ) + unity_LightmapFade.w ); + res *= xll_saturate( (1.00000 - fade) ); + return exp2( ( -res ) ); +} +varying vec4 xlv_TEXCOORD0; +varying vec3 xlv_TEXCOORD1; +void main() { + vec4 xl_retval; + v2f xlt_i; + xlt_i.pos = vec4(0.0); + xlt_i.uv = vec4( xlv_TEXCOORD0); + xlt_i.ray = vec3( xlv_TEXCOORD1); + xl_retval = xlat_main( xlt_i); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/complex-prepasslight-inES.txt b/3rdparty/glsl-optimizer/tests/fragment/complex-prepasslight-inES.txt new file mode 100644 index 000000000..f0bd8867c --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/complex-prepasslight-inES.txt @@ -0,0 +1,145 @@ +float xll_saturate( float x) { + return clamp( x, 0.0, 1.0); +} +vec2 xll_saturate( vec2 x) { + return clamp( x, 0.0, 1.0); +} +vec3 xll_saturate( vec3 x) { + return clamp( x, 0.0, 1.0); +} +vec4 xll_saturate( vec4 x) { + return clamp( x, 0.0, 1.0); +} +mat2 xll_saturate(mat2 m) { + return mat2( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0)); +} +mat3 xll_saturate(mat3 m) { + return mat3( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0), clamp(m[2], 0.0, 1.0)); +} +mat4 xll_saturate(mat4 m) { + return mat4( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0), clamp(m[2], 0.0, 1.0), clamp(m[3], 0.0, 1.0)); +} +vec2 xll_vecTSel (bvec2 a, vec2 b, vec2 c) { + return vec2 (a.x ? b.x : c.x, a.y ? b.y : c.y); +} +vec3 xll_vecTSel (bvec3 a, vec3 b, vec3 c) { + return vec3 (a.x ? b.x : c.x, a.y ? b.y : c.y, a.z ? b.z : c.z); +} +vec4 xll_vecTSel (bvec4 a, vec4 b, vec4 c) { + return vec4 (a.x ? b.x : c.x, a.y ? b.y : c.y, a.z ? b.z : c.z, a.w ? b.w : c.w); +} +struct v2f { + highp vec4 pos; + highp vec4 uv; + highp vec3 ray; +}; +uniform sampler2D _CameraDepthTexture; +uniform sampler2D _CameraNormalsTexture; +uniform highp mat4 _CameraToWorld; +uniform highp vec4 _LightColor; +uniform highp mat4 _LightMatrix0; +uniform highp vec4 _LightPos; +uniform highp vec4 _LightPositionRange; +uniform highp vec4 _LightShadowData; +uniform samplerCube _LightTexture0; +uniform sampler2D _LightTextureB0; +uniform highp vec4 _ProjectionParams; +uniform samplerCube _ShadowMapTexture; +uniform highp vec3 _WorldSpaceCameraPos; +uniform highp vec4 _ZBufferParams; +uniform highp vec4 unity_LightmapFade; +mediump float Luminance( in mediump vec3 c ); +highp float Linear01Depth( in highp float z ); +highp float DecodeFloatRGBA( in highp vec4 enc ); +highp float SampleCubeDistance( in highp vec3 vec ); +mediump float unitySampleShadow( in highp vec3 vec, in highp float mydist ); +mediump float ComputeShadow( in highp vec3 vec, in highp float z, in highp vec2 uv ); +mediump vec4 xlat_main( in v2f i ); +mediump float Luminance( in mediump vec3 c ) { + return dot( c, mediump vec3( 0.220000, 0.707000, 0.0710000)); +} +highp float Linear01Depth( in highp float z ) { + return (1.00000 / ((_ZBufferParams.x * z) + _ZBufferParams.y )); +} +highp float DecodeFloatRGBA( in highp vec4 enc ) { + highp vec4 kDecodeDot = vec4( 1.00000, 0.00392157, 1.53787e-005, 6.22737e-009); + return dot( enc, kDecodeDot); +} +highp float SampleCubeDistance( in highp vec3 vec ) { + highp vec4 packDist; + packDist = textureCube( _ShadowMapTexture, vec); + return DecodeFloatRGBA( packDist); +} +mediump float unitySampleShadow( in highp vec3 vec, in highp float mydist ) { + highp float z = 0.00781250; + highp vec4 shadowVals; + mediump vec4 shadows; + shadowVals.x = SampleCubeDistance( (vec + vec3( z, z, z))); + shadowVals.y = SampleCubeDistance( (vec + vec3( ( -z ), ( -z ), z))); + shadowVals.z = SampleCubeDistance( (vec + vec3( ( -z ), z, ( -z )))); + shadowVals.w = SampleCubeDistance( (vec + vec3( z, ( -z ), ( -z )))); + shadows = xll_vecTSel (lessThan( shadowVals, vec4( vec4( mydist) )), vec4( _LightShadowData.xxxx ), vec4( 1.00000)); + return dot( shadows, vec4( 0.250000)); +} +mediump float ComputeShadow( in highp vec3 vec, in highp float z, in highp vec2 uv ) { + highp float fade; + highp float mydist; + fade = ((z * _LightShadowData.z ) + _LightShadowData.w ); + fade = xll_saturate( fade ); + mydist = (length( vec ) * _LightPositionRange.w ); + mydist *= 0.970000; + return unitySampleShadow( vec, mydist); + return 1.00000; +} +mediump vec4 xlat_main( in v2f i ) { + highp vec2 uv; + mediump vec4 nspec; + mediump vec3 normal; + highp float depth; + highp vec4 vpos; + highp vec3 wpos; + highp vec3 tolight; + mediump vec3 lightDir; + highp float att; + highp float atten; + mediump float diff; + mediump vec3 h; + highp float spec; + mediump vec4 res; + highp float fade; + i.ray = (i.ray * (_ProjectionParams.z / i.ray.z )); + uv = (i.uv.xy / i.uv.w ); + nspec = texture2D( _CameraNormalsTexture, uv); + normal = ((nspec.xyz * 2.00000) - 1.00000); + normal = normalize( normal ); + depth = texture2D( _CameraDepthTexture, uv).x ; + depth = Linear01Depth( depth); + vpos = vec4( (i.ray * depth), 1.00000); + wpos = ( _CameraToWorld * vpos ).xyz ; + tolight = (wpos - _LightPos.xyz ); + lightDir = ( -normalize( tolight ) ); + att = (dot( tolight, tolight) * _LightPos.w ); + atten = texture2D( _LightTextureB0, vec2( vec2( att))).w ; + atten *= ComputeShadow( tolight, vpos.z , uv); + atten *= textureCube( _LightTexture0, ( _LightMatrix0 * vec4( wpos, 1.00000) ).xyz ).w ; + diff = max( 0.000000, dot( lightDir, normal)); + h = normalize( (lightDir - normalize( (wpos - _WorldSpaceCameraPos) )) ); + spec = pow( max( 0.000000, dot( h, normal)), (nspec.w * 128.000)); + spec *= xll_saturate( atten ); + res.xyz = (_LightColor.xyz * (diff * atten)); + res.w = (spec * Luminance( _LightColor.xyz )); + fade = ((vpos.z * unity_LightmapFade.z ) + unity_LightmapFade.w ); + res *= xll_saturate( (1.00000 - fade) ); + return exp2( ( -res ) ); +} +varying highp vec4 xlv_TEXCOORD0; +varying highp vec3 xlv_TEXCOORD1; +void main() { + mediump vec4 xl_retval; + v2f xlt_i; + xlt_i.pos = highp vec4(0.0); + xlt_i.uv = highp vec4( xlv_TEXCOORD0); + xlt_i.ray = highp vec3( xlv_TEXCOORD1); + xl_retval = xlat_main( xlt_i); + gl_FragData[0] = mediump vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/complex-prepasslight-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/complex-prepasslight-ir.txt new file mode 100644 index 000000000..65832a637 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/complex-prepasslight-ir.txt @@ -0,0 +1,529 @@ +struct v2f { + vec4 pos; + vec4 uv; + vec3 ray; +}; +varying vec3 xlv_TEXCOORD1; +varying vec4 xlv_TEXCOORD0; +uniform vec4 unity_LightmapFade; +uniform vec4 _ZBufferParams; +uniform vec3 _WorldSpaceCameraPos; +uniform samplerCube _ShadowMapTexture; +uniform vec4 _ProjectionParams; +uniform sampler2D _LightTextureB0; +uniform samplerCube _LightTexture0; +uniform vec4 _LightShadowData; +uniform vec4 _LightPositionRange; +uniform vec4 _LightPos; +uniform mat4 _LightMatrix0; +uniform vec4 _LightColor; +uniform mat4 _CameraToWorld; +uniform sampler2D _CameraNormalsTexture; +uniform sampler2D _CameraDepthTexture; +float xll_saturate ( + in float x +) +{ + float tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec2 xll_saturate ( + in vec2 x +) +{ + vec2 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec3 xll_saturate ( + in vec3 x +) +{ + vec3 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec4 xll_saturate ( + in vec4 x +) +{ + vec4 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +mat2 xll_saturate ( + in mat2 m +) +{ + vec2 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec2 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + mat2 tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_1; + tmpvar_3[0] = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5 = tmpvar_2; + tmpvar_3[1] = tmpvar_5; + return tmpvar_3; +} + +mat3 xll_saturate ( + in mat3 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec3 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + vec3 tmpvar_3; + tmpvar_3 = clamp (m[2], 0.0, 1.0); + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +mat4 xll_saturate ( + in mat4 m +) +{ + vec4 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec4 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + vec4 tmpvar_3; + tmpvar_3 = clamp (m[2], 0.0, 1.0); + vec4 tmpvar_4; + tmpvar_4 = clamp (m[3], 0.0, 1.0); + mat4 tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_1; + tmpvar_5[0] = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = tmpvar_2; + tmpvar_5[1] = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_3; + tmpvar_5[2] = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = tmpvar_4; + tmpvar_5[3] = tmpvar_9; + return tmpvar_5; +} + +vec2 xll_vecTSel ( + in bvec2 a, + in vec2 b, + in vec2 c +) +{ + float tmpvar_1; + if (a.x) { + tmpvar_1 = b.x; + } else { + tmpvar_1 = c.x; + }; + float tmpvar_2; + if (a.y) { + tmpvar_2 = b.y; + } else { + tmpvar_2 = c.y; + }; + vec2 tmpvar_3; + tmpvar_3.x = tmpvar_1; + tmpvar_3.y = tmpvar_2; + return tmpvar_3; +} + +vec3 xll_vecTSel ( + in bvec3 a, + in vec3 b, + in vec3 c +) +{ + float tmpvar_1; + if (a.x) { + tmpvar_1 = b.x; + } else { + tmpvar_1 = c.x; + }; + float tmpvar_2; + if (a.y) { + tmpvar_2 = b.y; + } else { + tmpvar_2 = c.y; + }; + float tmpvar_3; + if (a.z) { + tmpvar_3 = b.z; + } else { + tmpvar_3 = c.z; + }; + vec3 tmpvar_4; + tmpvar_4.x = tmpvar_1; + tmpvar_4.y = tmpvar_2; + tmpvar_4.z = tmpvar_3; + return tmpvar_4; +} + +vec4 xll_vecTSel ( + in bvec4 a, + in vec4 b, + in vec4 c +) +{ + float tmpvar_1; + if (a.x) { + tmpvar_1 = b.x; + } else { + tmpvar_1 = c.x; + }; + float tmpvar_2; + if (a.y) { + tmpvar_2 = b.y; + } else { + tmpvar_2 = c.y; + }; + float tmpvar_3; + if (a.z) { + tmpvar_3 = b.z; + } else { + tmpvar_3 = c.z; + }; + float tmpvar_4; + if (a.w) { + tmpvar_4 = b.w; + } else { + tmpvar_4 = c.w; + }; + vec4 tmpvar_5; + tmpvar_5.x = tmpvar_1; + tmpvar_5.y = tmpvar_2; + tmpvar_5.z = tmpvar_3; + tmpvar_5.w = tmpvar_4; + return tmpvar_5; +} + +float Luminance ( + in vec3 c +) +{ + float tmpvar_1; + tmpvar_1 = dot (c, vec3(0.22, 0.707, 0.071)); + return tmpvar_1; +} + +float Linear01Depth ( + in float z +) +{ + return (1.0 / ((_ZBufferParams.x * z) + _ZBufferParams.y)); +} + +float DecodeFloatRGBA ( + in vec4 enc +) +{ + vec4 kDecodeDot; + vec4 tmpvar_1; + tmpvar_1 = vec4(1.0, 0.00392157, 1.53787e-05, 0.0); + kDecodeDot = tmpvar_1; + float tmpvar_2; + tmpvar_2 = dot (enc, kDecodeDot); + return tmpvar_2; +} + +float SampleCubeDistance ( + in vec3 vec +) +{ + vec4 packDist; + vec4 tmpvar_1; + tmpvar_1 = textureCube (_ShadowMapTexture, vec); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + packDist = tmpvar_2; + float tmpvar_3; + tmpvar_3 = DecodeFloatRGBA (packDist); + return tmpvar_3; +} + +float unitySampleShadow ( + in vec3 vec, + in float mydist +) +{ + vec4 shadows; + vec4 shadowVals; + float z; + float tmpvar_1; + tmpvar_1 = 0.0078125; + z = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2.x = z; + tmpvar_2.y = z; + tmpvar_2.z = z; + float tmpvar_3; + tmpvar_3 = SampleCubeDistance ((vec + tmpvar_2)); + float tmpvar_4; + tmpvar_4 = tmpvar_3; + shadowVals.x = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5.x = -(z); + tmpvar_5.y = -(z); + tmpvar_5.z = z; + float tmpvar_6; + tmpvar_6 = SampleCubeDistance ((vec + tmpvar_5)); + float tmpvar_7; + tmpvar_7 = tmpvar_6; + shadowVals.y = vec2(tmpvar_7).y; + vec3 tmpvar_8; + tmpvar_8.x = -(z); + tmpvar_8.y = z; + tmpvar_8.z = -(z); + float tmpvar_9; + tmpvar_9 = SampleCubeDistance ((vec + tmpvar_8)); + float tmpvar_10; + tmpvar_10 = tmpvar_9; + shadowVals.z = vec3(tmpvar_10).z; + vec3 tmpvar_11; + tmpvar_11.x = z; + tmpvar_11.y = -(z); + tmpvar_11.z = -(z); + float tmpvar_12; + tmpvar_12 = SampleCubeDistance ((vec + tmpvar_11)); + float tmpvar_13; + tmpvar_13 = tmpvar_12; + shadowVals.w = vec4(tmpvar_13).w; + vec4 tmpvar_14; + tmpvar_14 = vec4(mydist); + vec4 tmpvar_15; + tmpvar_15 = tmpvar_14.xyzw; + bvec4 tmpvar_16; + tmpvar_16 = lessThan (shadowVals, tmpvar_15); + vec4 tmpvar_17; + tmpvar_17 = _LightShadowData.xxxx.xyzw; + vec4 tmpvar_18; + tmpvar_18 = xll_vecTSel (tmpvar_16, tmpvar_17, vec4(1.0, 1.0, 1.0, 1.0)); + vec4 tmpvar_19; + tmpvar_19 = tmpvar_18; + shadows = tmpvar_19; + float tmpvar_20; + tmpvar_20 = dot (shadows, vec4(0.25, 0.25, 0.25, 0.25)); + return tmpvar_20; +} + +float ComputeShadow ( + in vec3 vec, + in float z, + in vec2 uv +) +{ + float mydist; + float fade; + float tmpvar_1; + tmpvar_1 = ((z * _LightShadowData.z) + _LightShadowData.w); + fade = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xll_saturate (fade); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + fade = tmpvar_3; + float tmpvar_4; + tmpvar_4 = length (vec); + float tmpvar_5; + tmpvar_5 = (tmpvar_4 * _LightPositionRange.w); + mydist = tmpvar_5; + float tmpvar_6; + tmpvar_6 = (mydist * 0.97); + mydist = tmpvar_6; + float tmpvar_7; + tmpvar_7 = unitySampleShadow (vec, mydist); + return tmpvar_7; + return 1.0; +} + +vec4 xlat_main ( + in v2f i +) +{ + float fade; + vec4 res; + float spec; + vec3 h; + float diff; + float atten; + float att; + vec3 lightDir; + vec3 tolight; + vec3 wpos; + vec4 vpos; + float depth; + vec3 normal; + vec4 nspec; + vec2 uv; + vec3 tmpvar_1; + tmpvar_1 = (i.ray * (_ProjectionParams.z / i.ray.z)); + i.ray = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = (i.uv.xy / i.uv.w); + uv = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = texture2D (_CameraNormalsTexture, uv); + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + nspec = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = ((nspec.xyz * 2.0) - 1.0); + normal = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = normalize (normal); + vec3 tmpvar_7; + tmpvar_7 = tmpvar_6; + normal = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = texture2D (_CameraDepthTexture, uv); + float tmpvar_9; + tmpvar_9 = tmpvar_8.x; + depth = tmpvar_9; + float tmpvar_10; + tmpvar_10 = Linear01Depth (depth); + float tmpvar_11; + tmpvar_11 = tmpvar_10; + depth = tmpvar_11; + vec4 tmpvar_12; + tmpvar_12.w = 1.0; + tmpvar_12.xyz = (i.ray * depth).xyz; + vec4 tmpvar_13; + tmpvar_13 = tmpvar_12; + vpos = tmpvar_13; + vec3 tmpvar_14; + tmpvar_14 = (_CameraToWorld * vpos).xyz; + wpos = tmpvar_14; + vec3 tmpvar_15; + tmpvar_15 = (wpos - _LightPos.xyz); + tolight = tmpvar_15; + vec3 tmpvar_16; + tmpvar_16 = normalize (tolight); + vec3 tmpvar_17; + tmpvar_17 = -(tmpvar_16); + lightDir = tmpvar_17; + float tmpvar_18; + tmpvar_18 = dot (tolight, tolight); + float tmpvar_19; + tmpvar_19 = (tmpvar_18 * _LightPos.w); + att = tmpvar_19; + vec2 tmpvar_20; + tmpvar_20 = vec2(att); + vec2 tmpvar_21; + tmpvar_21 = tmpvar_20.xy; + vec4 tmpvar_22; + tmpvar_22 = texture2D (_LightTextureB0, tmpvar_21); + float tmpvar_23; + tmpvar_23 = tmpvar_22.w; + atten = tmpvar_23; + float tmpvar_24; + tmpvar_24 = ComputeShadow (tolight, vpos.z, uv); + float tmpvar_25; + tmpvar_25 = (atten * tmpvar_24); + atten = tmpvar_25; + vec4 tmpvar_26; + tmpvar_26.w = 1.0; + tmpvar_26.xyz = wpos.xyz; + vec4 tmpvar_27; + tmpvar_27 = textureCube (_LightTexture0, (_LightMatrix0 * tmpvar_26).xyz); + float tmpvar_28; + tmpvar_28 = (atten * tmpvar_27.w); + atten = tmpvar_28; + float tmpvar_29; + tmpvar_29 = dot (lightDir, normal); + float tmpvar_30; + tmpvar_30 = max (0.0, tmpvar_29); + float tmpvar_31; + tmpvar_31 = tmpvar_30; + diff = tmpvar_31; + vec3 tmpvar_32; + tmpvar_32 = normalize ((wpos - _WorldSpaceCameraPos)); + vec3 tmpvar_33; + tmpvar_33 = normalize ((lightDir - tmpvar_32)); + vec3 tmpvar_34; + tmpvar_34 = tmpvar_33; + h = tmpvar_34; + float tmpvar_35; + tmpvar_35 = dot (h, normal); + float tmpvar_36; + tmpvar_36 = max (0.0, tmpvar_35); + float tmpvar_37; + tmpvar_37 = pow (tmpvar_36, (nspec.w * 128.0)); + float tmpvar_38; + tmpvar_38 = tmpvar_37; + spec = tmpvar_38; + float tmpvar_39; + tmpvar_39 = xll_saturate (atten); + float tmpvar_40; + tmpvar_40 = (spec * tmpvar_39); + spec = tmpvar_40; + vec3 tmpvar_41; + tmpvar_41 = (_LightColor.xyz * (diff * atten)); + res.xyz = tmpvar_41.xyz.xyz; + float tmpvar_42; + tmpvar_42 = Luminance (_LightColor.xyz); + float tmpvar_43; + tmpvar_43 = (spec * tmpvar_42); + res.w = vec4(tmpvar_43).w; + float tmpvar_44; + tmpvar_44 = ((vpos.z * unity_LightmapFade.z) + unity_LightmapFade.w); + fade = tmpvar_44; + float tmpvar_45; + tmpvar_45 = xll_saturate ((1.0 - fade)); + vec4 tmpvar_46; + tmpvar_46 = (res * tmpvar_45); + res = tmpvar_46; + vec4 tmpvar_47; + tmpvar_47 = exp2 (-(res)); + return tmpvar_47; +} + +void main () +{ + v2f xlt_i; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_i.pos = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = xlv_TEXCOORD0.xyzw; + vec4 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_i.uv = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = xlv_TEXCOORD1.xyz; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_4; + xlt_i.ray = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = xlat_main (xlt_i); + vec4 tmpvar_7; + tmpvar_7 = tmpvar_6; + xl_retval = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = xl_retval.xyzw; + vec4 tmpvar_9; + tmpvar_9 = tmpvar_8; + gl_FragData[0] = tmpvar_9; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/complex-prepasslight-irES.txt b/3rdparty/glsl-optimizer/tests/fragment/complex-prepasslight-irES.txt new file mode 100644 index 000000000..5bc41c459 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/complex-prepasslight-irES.txt @@ -0,0 +1,529 @@ +struct v2f { + highp vec4 pos; + highp vec4 uv; + highp vec3 ray; +}; +varying highp vec3 xlv_TEXCOORD1; +varying highp vec4 xlv_TEXCOORD0; +uniform highp vec4 unity_LightmapFade; +uniform highp vec4 _ZBufferParams; +uniform highp vec3 _WorldSpaceCameraPos; +uniform samplerCube _ShadowMapTexture; +uniform highp vec4 _ProjectionParams; +uniform sampler2D _LightTextureB0; +uniform samplerCube _LightTexture0; +uniform highp vec4 _LightShadowData; +uniform highp vec4 _LightPositionRange; +uniform highp vec4 _LightPos; +uniform highp mat4 _LightMatrix0; +uniform highp vec4 _LightColor; +uniform highp mat4 _CameraToWorld; +uniform sampler2D _CameraNormalsTexture; +uniform sampler2D _CameraDepthTexture; +float xll_saturate ( + in float x +) +{ + float tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec2 xll_saturate ( + in vec2 x +) +{ + vec2 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec3 xll_saturate ( + in vec3 x +) +{ + vec3 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec4 xll_saturate ( + in vec4 x +) +{ + vec4 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +mat2 xll_saturate ( + in mat2 m +) +{ + vec2 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec2 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + mat2 tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_1; + tmpvar_3[0] = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5 = tmpvar_2; + tmpvar_3[1] = tmpvar_5; + return tmpvar_3; +} + +mat3 xll_saturate ( + in mat3 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec3 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + vec3 tmpvar_3; + tmpvar_3 = clamp (m[2], 0.0, 1.0); + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +mat4 xll_saturate ( + in mat4 m +) +{ + vec4 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec4 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + vec4 tmpvar_3; + tmpvar_3 = clamp (m[2], 0.0, 1.0); + vec4 tmpvar_4; + tmpvar_4 = clamp (m[3], 0.0, 1.0); + mat4 tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_1; + tmpvar_5[0] = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = tmpvar_2; + tmpvar_5[1] = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_3; + tmpvar_5[2] = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = tmpvar_4; + tmpvar_5[3] = tmpvar_9; + return tmpvar_5; +} + +vec2 xll_vecTSel ( + in bvec2 a, + in vec2 b, + in vec2 c +) +{ + float tmpvar_1; + if (a.x) { + tmpvar_1 = b.x; + } else { + tmpvar_1 = c.x; + }; + float tmpvar_2; + if (a.y) { + tmpvar_2 = b.y; + } else { + tmpvar_2 = c.y; + }; + vec2 tmpvar_3; + tmpvar_3.x = tmpvar_1; + tmpvar_3.y = tmpvar_2; + return tmpvar_3; +} + +vec3 xll_vecTSel ( + in bvec3 a, + in vec3 b, + in vec3 c +) +{ + float tmpvar_1; + if (a.x) { + tmpvar_1 = b.x; + } else { + tmpvar_1 = c.x; + }; + float tmpvar_2; + if (a.y) { + tmpvar_2 = b.y; + } else { + tmpvar_2 = c.y; + }; + float tmpvar_3; + if (a.z) { + tmpvar_3 = b.z; + } else { + tmpvar_3 = c.z; + }; + vec3 tmpvar_4; + tmpvar_4.x = tmpvar_1; + tmpvar_4.y = tmpvar_2; + tmpvar_4.z = tmpvar_3; + return tmpvar_4; +} + +vec4 xll_vecTSel ( + in bvec4 a, + in vec4 b, + in vec4 c +) +{ + float tmpvar_1; + if (a.x) { + tmpvar_1 = b.x; + } else { + tmpvar_1 = c.x; + }; + float tmpvar_2; + if (a.y) { + tmpvar_2 = b.y; + } else { + tmpvar_2 = c.y; + }; + float tmpvar_3; + if (a.z) { + tmpvar_3 = b.z; + } else { + tmpvar_3 = c.z; + }; + float tmpvar_4; + if (a.w) { + tmpvar_4 = b.w; + } else { + tmpvar_4 = c.w; + }; + vec4 tmpvar_5; + tmpvar_5.x = tmpvar_1; + tmpvar_5.y = tmpvar_2; + tmpvar_5.z = tmpvar_3; + tmpvar_5.w = tmpvar_4; + return tmpvar_5; +} + +mediump float Luminance ( + in mediump vec3 c +) +{ + mediump float tmpvar_1; + tmpvar_1 = dot (c, vec3(0.22, 0.707, 0.071)); + return tmpvar_1; +} + +float Linear01Depth ( + in highp float z +) +{ + return (1.0 / ((_ZBufferParams.x * z) + _ZBufferParams.y)); +} + +float DecodeFloatRGBA ( + in highp vec4 enc +) +{ + highp vec4 kDecodeDot; + vec4 tmpvar_1; + tmpvar_1 = vec4(1.0, 0.00392157, 1.53787e-05, 0.0); + kDecodeDot = tmpvar_1; + highp float tmpvar_2; + tmpvar_2 = dot (enc, kDecodeDot); + return tmpvar_2; +} + +float SampleCubeDistance ( + in highp vec3 vec +) +{ + highp vec4 packDist; + lowp vec4 tmpvar_1; + tmpvar_1 = textureCube (_ShadowMapTexture, vec); + lowp vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + packDist = tmpvar_2; + highp float tmpvar_3; + tmpvar_3 = DecodeFloatRGBA (packDist); + return tmpvar_3; +} + +mediump float unitySampleShadow ( + in highp vec3 vec, + in highp float mydist +) +{ + mediump vec4 shadows; + highp vec4 shadowVals; + highp float z; + float tmpvar_1; + tmpvar_1 = 0.0078125; + z = tmpvar_1; + highp vec3 tmpvar_2; + tmpvar_2.x = z; + tmpvar_2.y = z; + tmpvar_2.z = z; + highp float tmpvar_3; + tmpvar_3 = SampleCubeDistance ((vec + tmpvar_2)); + highp float tmpvar_4; + tmpvar_4 = tmpvar_3; + shadowVals.x = tmpvar_4; + highp vec3 tmpvar_5; + tmpvar_5.x = -(z); + tmpvar_5.y = -(z); + tmpvar_5.z = z; + highp float tmpvar_6; + tmpvar_6 = SampleCubeDistance ((vec + tmpvar_5)); + highp float tmpvar_7; + tmpvar_7 = tmpvar_6; + shadowVals.y = vec2(tmpvar_7).y; + highp vec3 tmpvar_8; + tmpvar_8.x = -(z); + tmpvar_8.y = z; + tmpvar_8.z = -(z); + highp float tmpvar_9; + tmpvar_9 = SampleCubeDistance ((vec + tmpvar_8)); + highp float tmpvar_10; + tmpvar_10 = tmpvar_9; + shadowVals.z = vec3(tmpvar_10).z; + highp vec3 tmpvar_11; + tmpvar_11.x = z; + tmpvar_11.y = -(z); + tmpvar_11.z = -(z); + highp float tmpvar_12; + tmpvar_12 = SampleCubeDistance ((vec + tmpvar_11)); + highp float tmpvar_13; + tmpvar_13 = tmpvar_12; + shadowVals.w = vec4(tmpvar_13).w; + highp vec4 tmpvar_14; + tmpvar_14 = vec4(mydist); + highp vec4 tmpvar_15; + tmpvar_15 = tmpvar_14.xyzw; + bvec4 tmpvar_16; + tmpvar_16 = lessThan (shadowVals, tmpvar_15); + highp vec4 tmpvar_17; + tmpvar_17 = _LightShadowData.xxxx.xyzw; + vec4 tmpvar_18; + tmpvar_18 = xll_vecTSel (tmpvar_16, tmpvar_17, vec4(1.0, 1.0, 1.0, 1.0)); + vec4 tmpvar_19; + tmpvar_19 = tmpvar_18; + shadows = tmpvar_19; + mediump float tmpvar_20; + tmpvar_20 = dot (shadows, vec4(0.25, 0.25, 0.25, 0.25)); + return tmpvar_20; +} + +mediump float ComputeShadow ( + in highp vec3 vec, + in highp float z, + in highp vec2 uv +) +{ + highp float mydist; + highp float fade; + highp float tmpvar_1; + tmpvar_1 = ((z * _LightShadowData.z) + _LightShadowData.w); + fade = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xll_saturate (fade); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + fade = tmpvar_3; + highp float tmpvar_4; + tmpvar_4 = length (vec); + highp float tmpvar_5; + tmpvar_5 = (tmpvar_4 * _LightPositionRange.w); + mydist = tmpvar_5; + highp float tmpvar_6; + tmpvar_6 = (mydist * 0.97); + mydist = tmpvar_6; + mediump float tmpvar_7; + tmpvar_7 = unitySampleShadow (vec, mydist); + return tmpvar_7; + return 1.0; +} + +mediump vec4 xlat_main ( + in v2f i +) +{ + highp float fade; + mediump vec4 res; + highp float spec; + mediump vec3 h; + mediump float diff; + highp float atten; + highp float att; + mediump vec3 lightDir; + highp vec3 tolight; + highp vec3 wpos; + highp vec4 vpos; + highp float depth; + mediump vec3 normal; + mediump vec4 nspec; + highp vec2 uv; + highp vec3 tmpvar_1; + tmpvar_1 = (i.ray * (_ProjectionParams.z / i.ray.z)); + i.ray = tmpvar_1; + highp vec2 tmpvar_2; + tmpvar_2 = (i.uv.xy / i.uv.w); + uv = tmpvar_2; + lowp vec4 tmpvar_3; + tmpvar_3 = texture2D (_CameraNormalsTexture, uv); + lowp vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + nspec = tmpvar_4; + mediump vec3 tmpvar_5; + tmpvar_5 = ((nspec.xyz * 2.0) - 1.0); + normal = tmpvar_5; + mediump vec3 tmpvar_6; + tmpvar_6 = normalize (normal); + mediump vec3 tmpvar_7; + tmpvar_7 = tmpvar_6; + normal = tmpvar_7; + lowp vec4 tmpvar_8; + tmpvar_8 = texture2D (_CameraDepthTexture, uv); + lowp float tmpvar_9; + tmpvar_9 = tmpvar_8.x; + depth = tmpvar_9; + highp float tmpvar_10; + tmpvar_10 = Linear01Depth (depth); + highp float tmpvar_11; + tmpvar_11 = tmpvar_10; + depth = tmpvar_11; + highp vec4 tmpvar_12; + tmpvar_12.w = 1.0; + tmpvar_12.xyz = (i.ray * depth).xyz; + highp vec4 tmpvar_13; + tmpvar_13 = tmpvar_12; + vpos = tmpvar_13; + highp vec3 tmpvar_14; + tmpvar_14 = (_CameraToWorld * vpos).xyz; + wpos = tmpvar_14; + highp vec3 tmpvar_15; + tmpvar_15 = (wpos - _LightPos.xyz); + tolight = tmpvar_15; + highp vec3 tmpvar_16; + tmpvar_16 = normalize (tolight); + highp vec3 tmpvar_17; + tmpvar_17 = -(tmpvar_16); + lightDir = tmpvar_17; + highp float tmpvar_18; + tmpvar_18 = dot (tolight, tolight); + highp float tmpvar_19; + tmpvar_19 = (tmpvar_18 * _LightPos.w); + att = tmpvar_19; + highp vec2 tmpvar_20; + tmpvar_20 = vec2(att); + highp vec2 tmpvar_21; + tmpvar_21 = tmpvar_20.xy; + lowp vec4 tmpvar_22; + tmpvar_22 = texture2D (_LightTextureB0, tmpvar_21); + lowp float tmpvar_23; + tmpvar_23 = tmpvar_22.w; + atten = tmpvar_23; + mediump float tmpvar_24; + tmpvar_24 = ComputeShadow (tolight, vpos.z, uv); + highp float tmpvar_25; + tmpvar_25 = (atten * tmpvar_24); + atten = tmpvar_25; + highp vec4 tmpvar_26; + tmpvar_26.w = 1.0; + tmpvar_26.xyz = wpos.xyz; + lowp vec4 tmpvar_27; + tmpvar_27 = textureCube (_LightTexture0, (_LightMatrix0 * tmpvar_26).xyz); + highp float tmpvar_28; + tmpvar_28 = (atten * tmpvar_27.w); + atten = tmpvar_28; + mediump float tmpvar_29; + tmpvar_29 = dot (lightDir, normal); + mediump float tmpvar_30; + tmpvar_30 = max (0.0, tmpvar_29); + mediump float tmpvar_31; + tmpvar_31 = tmpvar_30; + diff = tmpvar_31; + highp vec3 tmpvar_32; + tmpvar_32 = normalize ((wpos - _WorldSpaceCameraPos)); + highp vec3 tmpvar_33; + tmpvar_33 = normalize ((lightDir - tmpvar_32)); + highp vec3 tmpvar_34; + tmpvar_34 = tmpvar_33; + h = tmpvar_34; + mediump float tmpvar_35; + tmpvar_35 = dot (h, normal); + mediump float tmpvar_36; + tmpvar_36 = max (0.0, tmpvar_35); + mediump float tmpvar_37; + tmpvar_37 = pow (tmpvar_36, (nspec.w * 128.0)); + mediump float tmpvar_38; + tmpvar_38 = tmpvar_37; + spec = tmpvar_38; + float tmpvar_39; + tmpvar_39 = xll_saturate (atten); + highp float tmpvar_40; + tmpvar_40 = (spec * tmpvar_39); + spec = tmpvar_40; + highp vec3 tmpvar_41; + tmpvar_41 = (_LightColor.xyz * (diff * atten)); + res.xyz = tmpvar_41.xyz.xyz; + mediump float tmpvar_42; + tmpvar_42 = Luminance (_LightColor.xyz); + highp float tmpvar_43; + tmpvar_43 = (spec * tmpvar_42); + res.w = vec4(tmpvar_43).w; + highp float tmpvar_44; + tmpvar_44 = ((vpos.z * unity_LightmapFade.z) + unity_LightmapFade.w); + fade = tmpvar_44; + float tmpvar_45; + tmpvar_45 = xll_saturate ((1.0 - fade)); + mediump vec4 tmpvar_46; + tmpvar_46 = (res * tmpvar_45); + res = tmpvar_46; + mediump vec4 tmpvar_47; + tmpvar_47 = exp2 (-(res)); + return tmpvar_47; +} + +void main () +{ + v2f xlt_i; + mediump vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_i.pos = tmpvar_1; + highp vec4 tmpvar_2; + tmpvar_2 = xlv_TEXCOORD0.xyzw; + highp vec4 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_i.uv = tmpvar_3; + highp vec3 tmpvar_4; + tmpvar_4 = xlv_TEXCOORD1.xyz; + highp vec3 tmpvar_5; + tmpvar_5 = tmpvar_4; + xlt_i.ray = tmpvar_5; + mediump vec4 tmpvar_6; + tmpvar_6 = xlat_main (xlt_i); + mediump vec4 tmpvar_7; + tmpvar_7 = tmpvar_6; + xl_retval = tmpvar_7; + mediump vec4 tmpvar_8; + tmpvar_8 = xl_retval.xyzw; + mediump vec4 tmpvar_9; + tmpvar_9 = tmpvar_8; + gl_FragData[0] = tmpvar_9; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/complex-prepasslight-out.txt b/3rdparty/glsl-optimizer/tests/fragment/complex-prepasslight-out.txt new file mode 100644 index 000000000..f20436a67 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/complex-prepasslight-out.txt @@ -0,0 +1,87 @@ +varying vec3 xlv_TEXCOORD1; +varying vec4 xlv_TEXCOORD0; +uniform vec4 unity_LightmapFade; +uniform vec4 _ZBufferParams; +uniform vec3 _WorldSpaceCameraPos; +uniform samplerCube _ShadowMapTexture; +uniform vec4 _ProjectionParams; +uniform sampler2D _LightTextureB0; +uniform samplerCube _LightTexture0; +uniform vec4 _LightShadowData; +uniform vec4 _LightPositionRange; +uniform vec4 _LightPos; +uniform mat4 _LightMatrix0; +uniform vec4 _LightColor; +uniform mat4 _CameraToWorld; +uniform sampler2D _CameraNormalsTexture; +uniform sampler2D _CameraDepthTexture; +void main () +{ + vec4 res; + float atten; + vec3 lightDir; + vec3 normal; + vec2 tmpvar_1; + tmpvar_1 = (xlv_TEXCOORD0.xy / xlv_TEXCOORD0.w); + vec4 tmpvar_2; + tmpvar_2 = texture2D (_CameraNormalsTexture, tmpvar_1); + normal = normalize (((tmpvar_2.xyz * 2.0) - 1.0)); + vec4 tmpvar_3; + tmpvar_3.w = 1.0; + tmpvar_3.xyz = ((xlv_TEXCOORD1 * (_ProjectionParams.z / xlv_TEXCOORD1.z)) * (1.0/(((_ZBufferParams.x * texture2D (_CameraDepthTexture, tmpvar_1).x) + _ZBufferParams.y)))); + vec3 tmpvar_4; + tmpvar_4 = (_CameraToWorld * tmpvar_3).xyz; + vec3 tmpvar_5; + tmpvar_5 = (tmpvar_4 - _LightPos.xyz); + lightDir = -(normalize (tmpvar_5)); + atten = texture2D (_LightTextureB0, vec2((dot (tmpvar_5, tmpvar_5) * _LightPos.w))).w; + vec4 shadowVals; + shadowVals.x = dot (textureCube (_ShadowMapTexture, (tmpvar_5 + vec3(0.0078125))), vec4(1.0, 0.00392157, 1.53787e-05, 0.0)); + shadowVals.y = dot (textureCube (_ShadowMapTexture, (tmpvar_5 + vec3(-0.0078125, -0.0078125, 0.0078125))), vec4(1.0, 0.00392157, 1.53787e-05, 0.0)); + shadowVals.z = dot (textureCube (_ShadowMapTexture, (tmpvar_5 + vec3(-0.0078125, 0.0078125, -0.0078125))), vec4(1.0, 0.00392157, 1.53787e-05, 0.0)); + shadowVals.w = dot (textureCube (_ShadowMapTexture, (tmpvar_5 + vec3(0.0078125, -0.0078125, -0.0078125))), vec4(1.0, 0.00392157, 1.53787e-05, 0.0)); + bvec4 tmpvar_6; + tmpvar_6 = lessThan (shadowVals, vec4(((length (tmpvar_5) * _LightPositionRange.w) * 0.97))); + float tmpvar_7; + if (tmpvar_6.x) { + tmpvar_7 = _LightShadowData.x; + } else { + tmpvar_7 = 1.0; + }; + float tmpvar_8; + if (tmpvar_6.y) { + tmpvar_8 = _LightShadowData.x; + } else { + tmpvar_8 = 1.0; + }; + float tmpvar_9; + if (tmpvar_6.z) { + tmpvar_9 = _LightShadowData.x; + } else { + tmpvar_9 = 1.0; + }; + float tmpvar_10; + if (tmpvar_6.w) { + tmpvar_10 = _LightShadowData.x; + } else { + tmpvar_10 = 1.0; + }; + vec4 tmpvar_11; + tmpvar_11.x = tmpvar_7; + tmpvar_11.y = tmpvar_8; + tmpvar_11.z = tmpvar_9; + tmpvar_11.w = tmpvar_10; + vec4 tmpvar_12; + tmpvar_12.w = 1.0; + tmpvar_12.xyz = tmpvar_4; + float tmpvar_13; + tmpvar_13 = ((atten * dot (tmpvar_11, vec4(0.25, 0.25, 0.25, 0.25))) * textureCube (_LightTexture0, (_LightMatrix0 * tmpvar_12).xyz).w); + atten = tmpvar_13; + res.xyz = (_LightColor.xyz * (max (0.0, dot (lightDir, normal)) * tmpvar_13)); + res.w = ((pow (max (0.0, dot (normalize ((lightDir - normalize ((tmpvar_4 - _WorldSpaceCameraPos)))), normal)), (tmpvar_2.w * 128.0)) * clamp (tmpvar_13, 0.0, 1.0)) * dot (_LightColor.xyz, vec3(0.22, 0.707, 0.071))); + vec4 tmpvar_14; + tmpvar_14 = (res * clamp ((1.0 - ((tmpvar_3.z * unity_LightmapFade.z) + unity_LightmapFade.w)), 0.0, 1.0)); + res = tmpvar_14; + gl_FragData[0] = exp2 (-(tmpvar_14)); +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/complex-prepasslight-outES.txt b/3rdparty/glsl-optimizer/tests/fragment/complex-prepasslight-outES.txt new file mode 100644 index 000000000..f18ed730e --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/complex-prepasslight-outES.txt @@ -0,0 +1,157 @@ +varying highp vec3 xlv_TEXCOORD1; +varying highp vec4 xlv_TEXCOORD0; +uniform highp vec4 unity_LightmapFade; +uniform highp vec4 _ZBufferParams; +uniform highp vec3 _WorldSpaceCameraPos; +uniform samplerCube _ShadowMapTexture; +uniform highp vec4 _ProjectionParams; +uniform sampler2D _LightTextureB0; +uniform samplerCube _LightTexture0; +uniform highp vec4 _LightShadowData; +uniform highp vec4 _LightPositionRange; +uniform highp vec4 _LightPos; +uniform highp mat4 _LightMatrix0; +uniform highp vec4 _LightColor; +uniform highp mat4 _CameraToWorld; +uniform sampler2D _CameraNormalsTexture; +uniform sampler2D _CameraDepthTexture; +void main () +{ + mediump vec4 res; + highp float spec; + mediump vec3 h; + highp float atten; + mediump vec3 lightDir; + highp float depth; + mediump vec3 normal; + mediump vec4 nspec; + highp vec2 tmpvar_1; + tmpvar_1 = (xlv_TEXCOORD0.xy / xlv_TEXCOORD0.w); + lowp vec4 tmpvar_2; + tmpvar_2 = texture2D (_CameraNormalsTexture, tmpvar_1); + nspec = tmpvar_2; + normal = normalize (((nspec.xyz * 2.0) - 1.0)); + lowp float tmpvar_3; + tmpvar_3 = texture2D (_CameraDepthTexture, tmpvar_1).x; + depth = tmpvar_3; + highp float tmpvar_4; + tmpvar_4 = (1.0/(((_ZBufferParams.x * depth) + _ZBufferParams.y))); + depth = tmpvar_4; + highp vec4 tmpvar_5; + tmpvar_5.w = 1.0; + tmpvar_5.xyz = ((xlv_TEXCOORD1 * (_ProjectionParams.z / xlv_TEXCOORD1.z)) * tmpvar_4); + highp vec3 tmpvar_6; + tmpvar_6 = (_CameraToWorld * tmpvar_5).xyz; + highp vec3 tmpvar_7; + tmpvar_7 = (tmpvar_6 - _LightPos.xyz); + highp vec3 tmpvar_8; + tmpvar_8 = -(normalize (tmpvar_7)); + lightDir = tmpvar_8; + highp vec2 tmpvar_9; + tmpvar_9 = vec2((dot (tmpvar_7, tmpvar_7) * _LightPos.w)); + lowp float tmpvar_10; + tmpvar_10 = texture2D (_LightTextureB0, tmpvar_9).w; + atten = tmpvar_10; + mediump vec4 shadows; + highp vec4 shadowVals; + highp vec3 vec_i0_i0; + vec_i0_i0 = (tmpvar_7 + vec3(0.0078125, 0.0078125, 0.0078125)); + highp vec4 packDist; + lowp vec4 tmpvar_11; + tmpvar_11 = textureCube (_ShadowMapTexture, vec_i0_i0); + packDist = tmpvar_11; + shadowVals.x = dot (packDist, vec4(1.0, 0.00392157, 1.53787e-05, 0.0)); + highp vec3 vec_i0_i1; + vec_i0_i1 = (tmpvar_7 + vec3(-0.0078125, -0.0078125, 0.0078125)); + highp vec4 packDist_i0; + lowp vec4 tmpvar_12; + tmpvar_12 = textureCube (_ShadowMapTexture, vec_i0_i1); + packDist_i0 = tmpvar_12; + shadowVals.y = dot (packDist_i0, vec4(1.0, 0.00392157, 1.53787e-05, 0.0)); + highp vec3 vec_i0_i1_i2; + vec_i0_i1_i2 = (tmpvar_7 + vec3(-0.0078125, 0.0078125, -0.0078125)); + highp vec4 packDist_i0_i1; + lowp vec4 tmpvar_13; + tmpvar_13 = textureCube (_ShadowMapTexture, vec_i0_i1_i2); + packDist_i0_i1 = tmpvar_13; + shadowVals.z = dot (packDist_i0_i1, vec4(1.0, 0.00392157, 1.53787e-05, 0.0)); + highp vec3 vec_i0_i1_i2_i3; + vec_i0_i1_i2_i3 = (tmpvar_7 + vec3(0.0078125, -0.0078125, -0.0078125)); + highp vec4 packDist_i0_i1_i2; + lowp vec4 tmpvar_14; + tmpvar_14 = textureCube (_ShadowMapTexture, vec_i0_i1_i2_i3); + packDist_i0_i1_i2 = tmpvar_14; + shadowVals.w = dot (packDist_i0_i1_i2, vec4(1.0, 0.00392157, 1.53787e-05, 0.0)); + highp vec4 tmpvar_15; + tmpvar_15 = vec4(((length (tmpvar_7) * _LightPositionRange.w) * 0.97)); + bvec4 tmpvar_16; + tmpvar_16 = lessThan (shadowVals, tmpvar_15); + highp float tmpvar_17; + if (tmpvar_16.x) { + tmpvar_17 = _LightShadowData.x; + } else { + tmpvar_17 = 1.0; + }; + highp float tmpvar_18; + if (tmpvar_16.y) { + tmpvar_18 = _LightShadowData.x; + } else { + tmpvar_18 = 1.0; + }; + highp float tmpvar_19; + if (tmpvar_16.z) { + tmpvar_19 = _LightShadowData.x; + } else { + tmpvar_19 = 1.0; + }; + highp float tmpvar_20; + if (tmpvar_16.w) { + tmpvar_20 = _LightShadowData.x; + } else { + tmpvar_20 = 1.0; + }; + highp vec4 tmpvar_21; + tmpvar_21.x = tmpvar_17; + tmpvar_21.y = tmpvar_18; + tmpvar_21.z = tmpvar_19; + tmpvar_21.w = tmpvar_20; + shadows = tmpvar_21; + mediump float tmpvar_22; + tmpvar_22 = dot (shadows, vec4(0.25, 0.25, 0.25, 0.25)); + highp vec4 tmpvar_23; + tmpvar_23.w = 1.0; + tmpvar_23.xyz = tmpvar_6; + lowp vec4 tmpvar_24; + tmpvar_24 = textureCube (_LightTexture0, (_LightMatrix0 * tmpvar_23).xyz); + highp float tmpvar_25; + tmpvar_25 = ((atten * tmpvar_22) * tmpvar_24.w); + atten = tmpvar_25; + mediump float tmpvar_26; + tmpvar_26 = max (0.0, dot (lightDir, normal)); + highp vec3 tmpvar_27; + tmpvar_27 = normalize ((lightDir - normalize ((tmpvar_6 - _WorldSpaceCameraPos)))); + h = tmpvar_27; + mediump float tmpvar_28; + tmpvar_28 = pow (max (0.0, dot (h, normal)), (nspec.w * 128.0)); + spec = tmpvar_28; + highp float tmpvar_29; + tmpvar_29 = (spec * clamp (tmpvar_25, 0.0, 1.0)); + spec = tmpvar_29; + highp vec3 tmpvar_30; + tmpvar_30 = (_LightColor.xyz * (tmpvar_26 * tmpvar_25)); + res.xyz = tmpvar_30; + mediump vec3 c; + c = _LightColor.xyz; + mediump float tmpvar_31; + tmpvar_31 = dot (c, vec3(0.22, 0.707, 0.071)); + highp float tmpvar_32; + tmpvar_32 = (tmpvar_29 * tmpvar_31); + res.w = tmpvar_32; + highp float tmpvar_33; + tmpvar_33 = clamp ((1.0 - ((tmpvar_5.z * unity_LightmapFade.z) + unity_LightmapFade.w)), 0.0, 1.0); + mediump vec4 tmpvar_34; + tmpvar_34 = (res * tmpvar_33); + res = tmpvar_34; + gl_FragData[0] = exp2 (-(tmpvar_34)); +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/complex-treeleaf-in.txt b/3rdparty/glsl-optimizer/tests/fragment/complex-treeleaf-in.txt new file mode 100644 index 000000000..f48ba9e59 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/complex-treeleaf-in.txt @@ -0,0 +1,137 @@ +void xll_clip(float x) { + if ( x<0.0 ) discard; +} +float xll_saturate( float x) { + return clamp( x, 0.0, 1.0); +} +vec2 xll_saturate( vec2 x) { + return clamp( x, 0.0, 1.0); +} +vec3 xll_saturate( vec3 x) { + return clamp( x, 0.0, 1.0); +} +vec4 xll_saturate( vec4 x) { + return clamp( x, 0.0, 1.0); +} +mat2 xll_saturate(mat2 m) { + return mat2( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0)); +} +mat3 xll_saturate(mat3 m) { + return mat3( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0), clamp(m[2], 0.0, 1.0)); +} +mat4 xll_saturate(mat4 m) { + return mat4( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0), clamp(m[2], 0.0, 1.0), clamp(m[3], 0.0, 1.0)); +} +struct LeafSurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Translucency; + float ShadowOffset; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec4 color; +}; +struct v2f_surf { + vec4 pos; + vec2 hip_pack0; + vec4 lop_color; + vec3 lightDir; + vec3 viewDir; + vec2 _LightCoord; +}; +uniform sampler2D _BumpSpecMap; +uniform vec4 _Color; +uniform float _Cutoff; +uniform vec4 _LightColor0; +uniform sampler2D _LightTexture0; +uniform sampler2D _MainTex; +uniform float _ShadowStrength; +uniform vec3 _TranslucencyColor; +uniform sampler2D _TranslucencyMap; +uniform float _TranslucencyViewDependency; +vec4 UnpackNormal( in vec4 packednormal ); +void surf( in Input IN, inout LeafSurfaceOutput o ); +vec4 LightingTreeLeaf( in LeafSurfaceOutput s, in vec3 lightDir, in vec3 viewDir, in float atten ); +vec4 xlat_main( in v2f_surf IN ); +vec4 UnpackNormal( in vec4 packednormal ) { + vec4 normal; + normal.xy = ((packednormal.wy * 2.00000) - 1.00000); + normal.z = sqrt( ((1.00000 - (normal.x * normal.x )) - (normal.y * normal.y )) ); + return normal; +} +void surf( in Input IN, inout LeafSurfaceOutput o ) { + vec4 c; + vec4 trngls; + vec4 norspc; + c = texture2D( _MainTex, IN.uv_MainTex); + o.Albedo = ((c.xyz * _Color.xyz ) * IN.color.w ); + trngls = texture2D( _TranslucencyMap, IN.uv_MainTex); + o.Translucency = trngls.z ; + o.Gloss = (trngls.w * _Color.x ); + o.Alpha = c.w ; + norspc = texture2D( _BumpSpecMap, IN.uv_MainTex); + o.Specular = norspc.x ; + o.ShadowOffset = norspc.z ; + o.Normal = vec3( UnpackNormal( norspc)); +} +vec4 LightingTreeLeaf( in LeafSurfaceOutput s, in vec3 lightDir, in vec3 viewDir, in float atten ) { + vec3 h; + float nl; + float nh; + float spec; + float backContrib; + vec3 translucencyColor; + vec4 c; + h = normalize( (lightDir + viewDir) ); + nl = dot( s.Normal, lightDir); + nh = max( 0.000000, dot( s.Normal, h)); + spec = (pow( nh, (s.Specular * 128.000)) * s.Gloss); + backContrib = xll_saturate( dot( viewDir, ( -lightDir )) ); + backContrib = mix( xll_saturate( ( -nl ) ), backContrib, _TranslucencyViewDependency); + translucencyColor = ((backContrib * s.Translucency) * _TranslucencyColor); + nl = max( 0.000000, ((nl * 0.600000) + 0.400000)); + c.xyz = (s.Albedo * ((translucencyColor * 2.00000) + nl)); + c.xyz = ((c.xyz * _LightColor0.xyz ) + spec); + c.xyz *= mix( 2.00000, (atten * 2.00000), _ShadowStrength); + return c; +} +vec4 xlat_main( in v2f_surf IN ) { + Input surfIN; + LeafSurfaceOutput o; + vec3 lightDir; + vec4 c; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + surfIN.color = IN.lop_color; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + surf( surfIN, o); + xll_clip( (o.Alpha - _Cutoff) ); + lightDir = IN.lightDir; + c = LightingTreeLeaf( o, lightDir, normalize( vec3( IN.viewDir) ), (texture2D( _LightTexture0, IN._LightCoord).w * 1.00000)); + c.w = o.Alpha; + return c; +} +varying vec2 xlv_TEXCOORD0; +varying vec4 xlv_COLOR0; +varying vec3 xlv_TEXCOORD1; +varying vec3 xlv_TEXCOORD2; +varying vec2 xlv_TEXCOORD3; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.hip_pack0 = vec2( xlv_TEXCOORD0); + xlt_IN.lop_color = vec4( xlv_COLOR0); + xlt_IN.lightDir = vec3( xlv_TEXCOORD1); + xlt_IN.viewDir = vec3( xlv_TEXCOORD2); + xlt_IN._LightCoord = vec2( xlv_TEXCOORD3); + xl_retval = xlat_main( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/complex-treeleaf-inES.txt b/3rdparty/glsl-optimizer/tests/fragment/complex-treeleaf-inES.txt new file mode 100644 index 000000000..09154477a --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/complex-treeleaf-inES.txt @@ -0,0 +1,137 @@ +void xll_clip(float x) { + if ( x<0.0 ) discard; +} +float xll_saturate( float x) { + return clamp( x, 0.0, 1.0); +} +vec2 xll_saturate( vec2 x) { + return clamp( x, 0.0, 1.0); +} +vec3 xll_saturate( vec3 x) { + return clamp( x, 0.0, 1.0); +} +vec4 xll_saturate( vec4 x) { + return clamp( x, 0.0, 1.0); +} +mat2 xll_saturate(mat2 m) { + return mat2( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0)); +} +mat3 xll_saturate(mat3 m) { + return mat3( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0), clamp(m[2], 0.0, 1.0)); +} +mat4 xll_saturate(mat4 m) { + return mat4( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0), clamp(m[2], 0.0, 1.0), clamp(m[3], 0.0, 1.0)); +} +struct LeafSurfaceOutput { + mediump vec3 Albedo; + mediump vec3 Normal; + mediump vec3 Emission; + mediump float Translucency; + mediump float ShadowOffset; + mediump float Specular; + mediump float Gloss; + mediump float Alpha; +}; +struct Input { + highp vec2 uv_MainTex; + highp vec4 color; +}; +struct v2f_surf { + highp vec4 pos; + highp vec2 hip_pack0; + highp vec4 lop_color; + highp vec3 lightDir; + highp vec3 viewDir; + highp vec2 _LightCoord; +}; +uniform sampler2D _BumpSpecMap; +uniform highp vec4 _Color; +uniform highp float _Cutoff; +uniform highp vec4 _LightColor0; +uniform sampler2D _LightTexture0; +uniform sampler2D _MainTex; +uniform mediump float _ShadowStrength; +uniform mediump vec3 _TranslucencyColor; +uniform sampler2D _TranslucencyMap; +uniform mediump float _TranslucencyViewDependency; +mediump vec4 UnpackNormal( in mediump vec4 packednormal ); +void surf( in Input IN, inout LeafSurfaceOutput o ); +mediump vec4 LightingTreeLeaf( in LeafSurfaceOutput s, in mediump vec3 lightDir, in mediump vec3 viewDir, in mediump float atten ); +mediump vec4 xlat_main( in v2f_surf IN ); +mediump vec4 UnpackNormal( in mediump vec4 packednormal ) { + mediump vec4 normal; + normal.xy = ((packednormal.wy * 2.00000) - 1.00000); + normal.z = sqrt( ((1.00000 - (normal.x * normal.x )) - (normal.y * normal.y )) ); + return normal; +} +void surf( in Input IN, inout LeafSurfaceOutput o ) { + mediump vec4 c; + mediump vec4 trngls; + mediump vec4 norspc; + c = texture2D( _MainTex, IN.uv_MainTex); + o.Albedo = ((c.xyz * _Color.xyz ) * IN.color.w ); + trngls = texture2D( _TranslucencyMap, IN.uv_MainTex); + o.Translucency = trngls.z ; + o.Gloss = (trngls.w * _Color.x ); + o.Alpha = c.w ; + norspc = texture2D( _BumpSpecMap, IN.uv_MainTex); + o.Specular = norspc.x ; + o.ShadowOffset = norspc.z ; + o.Normal = vec3( UnpackNormal( norspc)); +} +mediump vec4 LightingTreeLeaf( in LeafSurfaceOutput s, in mediump vec3 lightDir, in mediump vec3 viewDir, in mediump float atten ) { + mediump vec3 h; + mediump float nl; + mediump float nh; + mediump float spec; + mediump float backContrib; + mediump vec3 translucencyColor; + mediump vec4 c; + h = normalize( (lightDir + viewDir) ); + nl = dot( s.Normal, lightDir); + nh = max( 0.000000, dot( s.Normal, h)); + spec = (pow( nh, (s.Specular * 128.000)) * s.Gloss); + backContrib = xll_saturate( dot( viewDir, ( -lightDir )) ); + backContrib = mix( xll_saturate( ( -nl ) ), backContrib, _TranslucencyViewDependency); + translucencyColor = ((backContrib * s.Translucency) * _TranslucencyColor); + nl = max( 0.000000, ((nl * 0.600000) + 0.400000)); + c.xyz = (s.Albedo * ((translucencyColor * 2.00000) + nl)); + c.xyz = ((c.xyz * _LightColor0.xyz ) + spec); + c.xyz *= mix( 2.00000, (atten * 2.00000), _ShadowStrength); + return c; +} +mediump vec4 xlat_main( in v2f_surf IN ) { + Input surfIN; + LeafSurfaceOutput o; + mediump vec3 lightDir; + mediump vec4 c; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + surfIN.color = IN.lop_color; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + surf( surfIN, o); + xll_clip( (o.Alpha - _Cutoff) ); + lightDir = IN.lightDir; + c = LightingTreeLeaf( o, lightDir, normalize( vec3( IN.viewDir) ), (texture2D( _LightTexture0, IN._LightCoord).w * 1.00000)); + c.w = o.Alpha; + return c; +} +varying highp vec2 xlv_TEXCOORD0; +varying highp vec4 xlv_COLOR0; +varying highp vec3 xlv_TEXCOORD1; +varying highp vec3 xlv_TEXCOORD2; +varying highp vec2 xlv_TEXCOORD3; +void main() { + mediump vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = highp vec4(0.0); + xlt_IN.hip_pack0 = highp vec2( xlv_TEXCOORD0); + xlt_IN.lop_color = highp vec4( xlv_COLOR0); + xlt_IN.lightDir = highp vec3( xlv_TEXCOORD1); + xlt_IN.viewDir = highp vec3( xlv_TEXCOORD2); + xlt_IN._LightCoord = highp vec2( xlv_TEXCOORD3); + xl_retval = xlat_main( xlt_IN); + gl_FragData[0] = mediump vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/complex-treeleaf-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/complex-treeleaf-ir.txt new file mode 100644 index 000000000..74d29cf5f --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/complex-treeleaf-ir.txt @@ -0,0 +1,381 @@ +struct LeafSurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Translucency; + float ShadowOffset; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec4 color; +}; +struct v2f_surf { + vec4 pos; + vec2 hip_pack0; + vec4 lop_color; + vec3 lightDir; + vec3 viewDir; + vec2 _LightCoord; +}; +varying vec2 xlv_TEXCOORD3; +varying vec3 xlv_TEXCOORD2; +varying vec3 xlv_TEXCOORD1; +varying vec4 xlv_COLOR0; +varying vec2 xlv_TEXCOORD0; +uniform float _TranslucencyViewDependency; +uniform sampler2D _TranslucencyMap; +uniform vec3 _TranslucencyColor; +uniform float _ShadowStrength; +uniform sampler2D _MainTex; +uniform sampler2D _LightTexture0; +uniform vec4 _LightColor0; +uniform float _Cutoff; +uniform vec4 _Color; +uniform sampler2D _BumpSpecMap; +void xll_clip ( + in float x +) +{ + if ((x < 0.0)) { + discard; + }; +} + +float xll_saturate ( + in float x +) +{ + float tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec2 xll_saturate ( + in vec2 x +) +{ + vec2 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec3 xll_saturate ( + in vec3 x +) +{ + vec3 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec4 xll_saturate ( + in vec4 x +) +{ + vec4 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +mat2 xll_saturate ( + in mat2 m +) +{ + vec2 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec2 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + mat2 tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_1; + tmpvar_3[0] = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5 = tmpvar_2; + tmpvar_3[1] = tmpvar_5; + return tmpvar_3; +} + +mat3 xll_saturate ( + in mat3 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec3 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + vec3 tmpvar_3; + tmpvar_3 = clamp (m[2], 0.0, 1.0); + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +mat4 xll_saturate ( + in mat4 m +) +{ + vec4 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec4 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + vec4 tmpvar_3; + tmpvar_3 = clamp (m[2], 0.0, 1.0); + vec4 tmpvar_4; + tmpvar_4 = clamp (m[3], 0.0, 1.0); + mat4 tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_1; + tmpvar_5[0] = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = tmpvar_2; + tmpvar_5[1] = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_3; + tmpvar_5[2] = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = tmpvar_4; + tmpvar_5[3] = tmpvar_9; + return tmpvar_5; +} + +vec4 UnpackNormal ( + in vec4 packednormal +) +{ + vec4 normal; + vec2 tmpvar_1; + tmpvar_1 = ((packednormal.wy * 2.0) - 1.0); + normal.xy = tmpvar_1.xy.xy; + float tmpvar_2; + tmpvar_2 = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + normal.z = vec3(tmpvar_3).z; + return normal; +} + +void surf ( + in Input IN, + inout LeafSurfaceOutput o +) +{ + vec4 norspc; + vec4 trngls; + vec4 c; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + c = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = ((c.xyz * _Color.xyz) * IN.color.w); + o.Albedo = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = texture2D (_TranslucencyMap, IN.uv_MainTex); + vec4 tmpvar_5; + tmpvar_5 = tmpvar_4; + trngls = tmpvar_5; + float tmpvar_6; + tmpvar_6 = trngls.z; + o.Translucency = tmpvar_6; + float tmpvar_7; + tmpvar_7 = (trngls.w * _Color.x); + o.Gloss = tmpvar_7; + float tmpvar_8; + tmpvar_8 = c.w; + o.Alpha = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = texture2D (_BumpSpecMap, IN.uv_MainTex); + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + norspc = tmpvar_10; + float tmpvar_11; + tmpvar_11 = norspc.x; + o.Specular = tmpvar_11; + float tmpvar_12; + tmpvar_12 = norspc.z; + o.ShadowOffset = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = UnpackNormal (norspc); + vec3 tmpvar_14; + tmpvar_14 = tmpvar_13.xyz; + vec3 tmpvar_15; + tmpvar_15 = tmpvar_14; + o.Normal = tmpvar_15; +} + +vec4 LightingTreeLeaf ( + in LeafSurfaceOutput s, + in vec3 lightDir, + in vec3 viewDir, + in float atten +) +{ + vec4 c; + vec3 translucencyColor; + float backContrib; + float spec; + float nh; + float nl; + vec3 h; + vec3 tmpvar_1; + tmpvar_1 = normalize ((lightDir + viewDir)); + vec3 tmpvar_2; + tmpvar_2 = tmpvar_1; + h = tmpvar_2; + float tmpvar_3; + tmpvar_3 = dot (s.Normal, lightDir); + float tmpvar_4; + tmpvar_4 = tmpvar_3; + nl = tmpvar_4; + float tmpvar_5; + tmpvar_5 = dot (s.Normal, h); + float tmpvar_6; + tmpvar_6 = max (0.0, tmpvar_5); + float tmpvar_7; + tmpvar_7 = tmpvar_6; + nh = tmpvar_7; + float tmpvar_8; + tmpvar_8 = pow (nh, (s.Specular * 128.0)); + float tmpvar_9; + tmpvar_9 = (tmpvar_8 * s.Gloss); + spec = tmpvar_9; + float tmpvar_10; + tmpvar_10 = dot (viewDir, -(lightDir)); + float tmpvar_11; + tmpvar_11 = xll_saturate (tmpvar_10); + float tmpvar_12; + tmpvar_12 = tmpvar_11; + backContrib = tmpvar_12; + float tmpvar_13; + tmpvar_13 = xll_saturate (-(nl)); + float tmpvar_14; + tmpvar_14 = mix (tmpvar_13, backContrib, _TranslucencyViewDependency); + float tmpvar_15; + tmpvar_15 = tmpvar_14; + backContrib = tmpvar_15; + vec3 tmpvar_16; + tmpvar_16 = ((backContrib * s.Translucency) * _TranslucencyColor); + translucencyColor = tmpvar_16; + float tmpvar_17; + tmpvar_17 = max (0.0, ((nl * 0.6) + 0.4)); + float tmpvar_18; + tmpvar_18 = tmpvar_17; + nl = tmpvar_18; + vec3 tmpvar_19; + tmpvar_19 = (s.Albedo * ((translucencyColor * 2.0) + nl)); + c.xyz = tmpvar_19.xyz.xyz; + vec3 tmpvar_20; + tmpvar_20 = ((c.xyz * _LightColor0.xyz) + spec); + c.xyz = tmpvar_20.xyz.xyz; + float tmpvar_21; + tmpvar_21 = mix (2.0, (atten * 2.0), _ShadowStrength); + vec3 tmpvar_22; + tmpvar_22 = (c.xyz * tmpvar_21); + c.xyz = tmpvar_22.xyz.xyz; + return c; +} + +vec4 xlat_main ( + in v2f_surf IN +) +{ + vec4 c; + vec3 lightDir; + LeafSurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = IN.lop_color; + surfIN.color = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Specular = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Alpha = tmpvar_6; + surf (surfIN, o); + xll_clip ((o.Alpha - _Cutoff)); + vec3 tmpvar_7; + tmpvar_7 = IN.lightDir; + lightDir = tmpvar_7; + vec3 tmpvar_8; + tmpvar_8 = IN.viewDir.xyz; + vec3 tmpvar_9; + tmpvar_9 = normalize (tmpvar_8); + vec4 tmpvar_10; + tmpvar_10 = texture2D (_LightTexture0, IN._LightCoord); + vec4 tmpvar_11; + tmpvar_11 = LightingTreeLeaf (o, lightDir, tmpvar_9, (tmpvar_10.w * 1.0)); + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + c = tmpvar_12; + float tmpvar_13; + tmpvar_13 = o.Alpha; + c.w = vec4(tmpvar_13).w; + return c; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = xlv_TEXCOORD0.xy; + vec2 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_IN.hip_pack0 = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = xlv_COLOR0.xyzw; + vec4 tmpvar_5; + tmpvar_5 = tmpvar_4; + xlt_IN.lop_color = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = xlv_TEXCOORD1.xyz; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_6; + xlt_IN.lightDir = tmpvar_7; + vec3 tmpvar_8; + tmpvar_8 = xlv_TEXCOORD2.xyz; + vec3 tmpvar_9; + tmpvar_9 = tmpvar_8; + xlt_IN.viewDir = tmpvar_9; + vec2 tmpvar_10; + tmpvar_10 = xlv_TEXCOORD3.xy; + vec2 tmpvar_11; + tmpvar_11 = tmpvar_10; + xlt_IN._LightCoord = tmpvar_11; + vec4 tmpvar_12; + tmpvar_12 = xlat_main (xlt_IN); + vec4 tmpvar_13; + tmpvar_13 = tmpvar_12; + xl_retval = tmpvar_13; + vec4 tmpvar_14; + tmpvar_14 = xl_retval.xyzw; + vec4 tmpvar_15; + tmpvar_15 = tmpvar_14; + gl_FragData[0] = tmpvar_15; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/complex-treeleaf-irES.txt b/3rdparty/glsl-optimizer/tests/fragment/complex-treeleaf-irES.txt new file mode 100644 index 000000000..e2365c05e --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/complex-treeleaf-irES.txt @@ -0,0 +1,381 @@ +struct LeafSurfaceOutput { + mediump vec3 Albedo; + mediump vec3 Normal; + mediump vec3 Emission; + mediump float Translucency; + mediump float ShadowOffset; + mediump float Specular; + mediump float Gloss; + mediump float Alpha; +}; +struct Input { + highp vec2 uv_MainTex; + highp vec4 color; +}; +struct v2f_surf { + highp vec4 pos; + highp vec2 hip_pack0; + highp vec4 lop_color; + highp vec3 lightDir; + highp vec3 viewDir; + highp vec2 _LightCoord; +}; +varying highp vec2 xlv_TEXCOORD3; +varying highp vec3 xlv_TEXCOORD2; +varying highp vec3 xlv_TEXCOORD1; +varying highp vec4 xlv_COLOR0; +varying highp vec2 xlv_TEXCOORD0; +uniform mediump float _TranslucencyViewDependency; +uniform sampler2D _TranslucencyMap; +uniform mediump vec3 _TranslucencyColor; +uniform mediump float _ShadowStrength; +uniform sampler2D _MainTex; +uniform sampler2D _LightTexture0; +uniform highp vec4 _LightColor0; +uniform highp float _Cutoff; +uniform highp vec4 _Color; +uniform sampler2D _BumpSpecMap; +void xll_clip ( + in float x +) +{ + if ((x < 0.0)) { + discard; + }; +} + +float xll_saturate ( + in float x +) +{ + float tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec2 xll_saturate ( + in vec2 x +) +{ + vec2 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec3 xll_saturate ( + in vec3 x +) +{ + vec3 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec4 xll_saturate ( + in vec4 x +) +{ + vec4 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +mat2 xll_saturate ( + in mat2 m +) +{ + vec2 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec2 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + mat2 tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_1; + tmpvar_3[0] = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5 = tmpvar_2; + tmpvar_3[1] = tmpvar_5; + return tmpvar_3; +} + +mat3 xll_saturate ( + in mat3 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec3 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + vec3 tmpvar_3; + tmpvar_3 = clamp (m[2], 0.0, 1.0); + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +mat4 xll_saturate ( + in mat4 m +) +{ + vec4 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec4 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + vec4 tmpvar_3; + tmpvar_3 = clamp (m[2], 0.0, 1.0); + vec4 tmpvar_4; + tmpvar_4 = clamp (m[3], 0.0, 1.0); + mat4 tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_1; + tmpvar_5[0] = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = tmpvar_2; + tmpvar_5[1] = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_3; + tmpvar_5[2] = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = tmpvar_4; + tmpvar_5[3] = tmpvar_9; + return tmpvar_5; +} + +mediump vec4 UnpackNormal ( + in mediump vec4 packednormal +) +{ + mediump vec4 normal; + mediump vec2 tmpvar_1; + tmpvar_1 = ((packednormal.wy * 2.0) - 1.0); + normal.xy = tmpvar_1.xy.xy; + mediump float tmpvar_2; + tmpvar_2 = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + mediump float tmpvar_3; + tmpvar_3 = tmpvar_2; + normal.z = vec3(tmpvar_3).z; + return normal; +} + +void surf ( + in Input IN, + inout LeafSurfaceOutput o +) +{ + mediump vec4 norspc; + mediump vec4 trngls; + mediump vec4 c; + lowp vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + lowp vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + c = tmpvar_2; + highp vec3 tmpvar_3; + tmpvar_3 = ((c.xyz * _Color.xyz) * IN.color.w); + o.Albedo = tmpvar_3; + lowp vec4 tmpvar_4; + tmpvar_4 = texture2D (_TranslucencyMap, IN.uv_MainTex); + lowp vec4 tmpvar_5; + tmpvar_5 = tmpvar_4; + trngls = tmpvar_5; + mediump float tmpvar_6; + tmpvar_6 = trngls.z; + o.Translucency = tmpvar_6; + highp float tmpvar_7; + tmpvar_7 = (trngls.w * _Color.x); + o.Gloss = tmpvar_7; + mediump float tmpvar_8; + tmpvar_8 = c.w; + o.Alpha = tmpvar_8; + lowp vec4 tmpvar_9; + tmpvar_9 = texture2D (_BumpSpecMap, IN.uv_MainTex); + lowp vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + norspc = tmpvar_10; + mediump float tmpvar_11; + tmpvar_11 = norspc.x; + o.Specular = tmpvar_11; + mediump float tmpvar_12; + tmpvar_12 = norspc.z; + o.ShadowOffset = tmpvar_12; + mediump vec4 tmpvar_13; + tmpvar_13 = UnpackNormal (norspc); + mediump vec3 tmpvar_14; + tmpvar_14 = tmpvar_13.xyz; + mediump vec3 tmpvar_15; + tmpvar_15 = tmpvar_14; + o.Normal = tmpvar_15; +} + +mediump vec4 LightingTreeLeaf ( + in LeafSurfaceOutput s, + in mediump vec3 lightDir, + in mediump vec3 viewDir, + in mediump float atten +) +{ + mediump vec4 c; + mediump vec3 translucencyColor; + mediump float backContrib; + mediump float spec; + mediump float nh; + mediump float nl; + mediump vec3 h; + mediump vec3 tmpvar_1; + tmpvar_1 = normalize ((lightDir + viewDir)); + mediump vec3 tmpvar_2; + tmpvar_2 = tmpvar_1; + h = tmpvar_2; + mediump float tmpvar_3; + tmpvar_3 = dot (s.Normal, lightDir); + mediump float tmpvar_4; + tmpvar_4 = tmpvar_3; + nl = tmpvar_4; + mediump float tmpvar_5; + tmpvar_5 = dot (s.Normal, h); + mediump float tmpvar_6; + tmpvar_6 = max (0.0, tmpvar_5); + mediump float tmpvar_7; + tmpvar_7 = tmpvar_6; + nh = tmpvar_7; + mediump float tmpvar_8; + tmpvar_8 = pow (nh, (s.Specular * 128.0)); + mediump float tmpvar_9; + tmpvar_9 = (tmpvar_8 * s.Gloss); + spec = tmpvar_9; + mediump float tmpvar_10; + tmpvar_10 = dot (viewDir, -(lightDir)); + float tmpvar_11; + tmpvar_11 = xll_saturate (tmpvar_10); + float tmpvar_12; + tmpvar_12 = tmpvar_11; + backContrib = tmpvar_12; + float tmpvar_13; + tmpvar_13 = xll_saturate (-(nl)); + mediump float tmpvar_14; + tmpvar_14 = mix (tmpvar_13, backContrib, _TranslucencyViewDependency); + mediump float tmpvar_15; + tmpvar_15 = tmpvar_14; + backContrib = tmpvar_15; + mediump vec3 tmpvar_16; + tmpvar_16 = ((backContrib * s.Translucency) * _TranslucencyColor); + translucencyColor = tmpvar_16; + mediump float tmpvar_17; + tmpvar_17 = max (0.0, ((nl * 0.6) + 0.4)); + mediump float tmpvar_18; + tmpvar_18 = tmpvar_17; + nl = tmpvar_18; + mediump vec3 tmpvar_19; + tmpvar_19 = (s.Albedo * ((translucencyColor * 2.0) + nl)); + c.xyz = tmpvar_19.xyz.xyz; + highp vec3 tmpvar_20; + tmpvar_20 = ((c.xyz * _LightColor0.xyz) + spec); + c.xyz = tmpvar_20.xyz.xyz; + mediump float tmpvar_21; + tmpvar_21 = mix (2.0, (atten * 2.0), _ShadowStrength); + mediump vec3 tmpvar_22; + tmpvar_22 = (c.xyz * tmpvar_21); + c.xyz = tmpvar_22.xyz.xyz; + return c; +} + +mediump vec4 xlat_main ( + in v2f_surf IN +) +{ + mediump vec4 c; + mediump vec3 lightDir; + LeafSurfaceOutput o; + Input surfIN; + highp vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + highp vec4 tmpvar_2; + tmpvar_2 = IN.lop_color; + surfIN.color = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Specular = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Alpha = tmpvar_6; + surf (surfIN, o); + xll_clip ((o.Alpha - _Cutoff)); + highp vec3 tmpvar_7; + tmpvar_7 = IN.lightDir; + lightDir = tmpvar_7; + highp vec3 tmpvar_8; + tmpvar_8 = IN.viewDir.xyz; + highp vec3 tmpvar_9; + tmpvar_9 = normalize (tmpvar_8); + lowp vec4 tmpvar_10; + tmpvar_10 = texture2D (_LightTexture0, IN._LightCoord); + mediump vec4 tmpvar_11; + tmpvar_11 = LightingTreeLeaf (o, lightDir, tmpvar_9, (tmpvar_10.w * 1.0)); + mediump vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + c = tmpvar_12; + mediump float tmpvar_13; + tmpvar_13 = o.Alpha; + c.w = vec4(tmpvar_13).w; + return c; +} + +void main () +{ + v2f_surf xlt_IN; + mediump vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + highp vec2 tmpvar_2; + tmpvar_2 = xlv_TEXCOORD0.xy; + highp vec2 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_IN.hip_pack0 = tmpvar_3; + highp vec4 tmpvar_4; + tmpvar_4 = xlv_COLOR0.xyzw; + highp vec4 tmpvar_5; + tmpvar_5 = tmpvar_4; + xlt_IN.lop_color = tmpvar_5; + highp vec3 tmpvar_6; + tmpvar_6 = xlv_TEXCOORD1.xyz; + highp vec3 tmpvar_7; + tmpvar_7 = tmpvar_6; + xlt_IN.lightDir = tmpvar_7; + highp vec3 tmpvar_8; + tmpvar_8 = xlv_TEXCOORD2.xyz; + highp vec3 tmpvar_9; + tmpvar_9 = tmpvar_8; + xlt_IN.viewDir = tmpvar_9; + highp vec2 tmpvar_10; + tmpvar_10 = xlv_TEXCOORD3.xy; + highp vec2 tmpvar_11; + tmpvar_11 = tmpvar_10; + xlt_IN._LightCoord = tmpvar_11; + mediump vec4 tmpvar_12; + tmpvar_12 = xlat_main (xlt_IN); + mediump vec4 tmpvar_13; + tmpvar_13 = tmpvar_12; + xl_retval = tmpvar_13; + mediump vec4 tmpvar_14; + tmpvar_14 = xl_retval.xyzw; + mediump vec4 tmpvar_15; + tmpvar_15 = tmpvar_14; + gl_FragData[0] = tmpvar_15; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/complex-treeleaf-out.txt b/3rdparty/glsl-optimizer/tests/fragment/complex-treeleaf-out.txt new file mode 100644 index 000000000..b4a71a944 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/complex-treeleaf-out.txt @@ -0,0 +1,51 @@ +varying vec2 xlv_TEXCOORD3; +varying vec3 xlv_TEXCOORD2; +varying vec3 xlv_TEXCOORD1; +varying vec4 xlv_COLOR0; +varying vec2 xlv_TEXCOORD0; +uniform float _TranslucencyViewDependency; +uniform sampler2D _TranslucencyMap; +uniform vec3 _TranslucencyColor; +uniform float _ShadowStrength; +uniform sampler2D _MainTex; +uniform sampler2D _LightTexture0; +uniform vec4 _LightColor0; +uniform float _Cutoff; +uniform vec4 _Color; +uniform sampler2D _BumpSpecMap; +void main () +{ + vec4 c; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, xlv_TEXCOORD0); + vec3 tmpvar_2; + tmpvar_2 = ((tmpvar_1.xyz * _Color.xyz) * xlv_COLOR0.w); + vec4 tmpvar_3; + tmpvar_3 = texture2D (_TranslucencyMap, xlv_TEXCOORD0); + float tmpvar_4; + tmpvar_4 = (tmpvar_3.w * _Color.x); + vec4 tmpvar_5; + tmpvar_5 = texture2D (_BumpSpecMap, xlv_TEXCOORD0); + vec4 normal; + normal.xy = ((tmpvar_5.wy * 2.0) - 1.0); + normal.z = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + vec3 tmpvar_6; + tmpvar_6 = normal.xyz; + float x; + x = (tmpvar_1.w - _Cutoff); + if ((x < 0.0)) { + discard; + }; + vec3 tmpvar_7; + tmpvar_7 = normalize (xlv_TEXCOORD2); + vec4 c_i0_i1; + float tmpvar_8; + tmpvar_8 = dot (tmpvar_6, xlv_TEXCOORD1); + c_i0_i1.xyz = (tmpvar_2 * ((((mix (clamp (-(tmpvar_8), 0.0, 1.0), clamp (dot (tmpvar_7, -(xlv_TEXCOORD1)), 0.0, 1.0), _TranslucencyViewDependency) * tmpvar_3.z) * _TranslucencyColor) * 2.0) + max (0.0, ((tmpvar_8 * 0.6) + 0.4)))); + c_i0_i1.xyz = ((c_i0_i1.xyz * _LightColor0.xyz) + (pow (max (0.0, dot (tmpvar_6, normalize ((xlv_TEXCOORD1 + tmpvar_7)))), (tmpvar_5.x * 128.0)) * tmpvar_4)); + c_i0_i1.xyz = (c_i0_i1.xyz * mix (2.0, (texture2D (_LightTexture0, xlv_TEXCOORD3).w * 2.0), _ShadowStrength)); + c = c_i0_i1; + c.w = tmpvar_1.w; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/complex-treeleaf-outES.txt b/3rdparty/glsl-optimizer/tests/fragment/complex-treeleaf-outES.txt new file mode 100644 index 000000000..19d7c7461 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/complex-treeleaf-outES.txt @@ -0,0 +1,73 @@ +varying highp vec2 xlv_TEXCOORD3; +varying highp vec3 xlv_TEXCOORD2; +varying highp vec3 xlv_TEXCOORD1; +varying highp vec4 xlv_COLOR0; +varying highp vec2 xlv_TEXCOORD0; +uniform mediump float _TranslucencyViewDependency; +uniform sampler2D _TranslucencyMap; +uniform mediump vec3 _TranslucencyColor; +uniform mediump float _ShadowStrength; +uniform sampler2D _MainTex; +uniform sampler2D _LightTexture0; +uniform highp vec4 _LightColor0; +uniform highp float _Cutoff; +uniform highp vec4 _Color; +uniform sampler2D _BumpSpecMap; +void main () +{ + mediump vec4 c; + mediump vec3 lightDir; + mediump vec3 tmpvar_1; + mediump float tmpvar_2; + mediump vec4 norspc; + mediump vec4 trngls; + mediump vec4 c_i0; + lowp vec4 tmpvar_3; + tmpvar_3 = texture2D (_MainTex, xlv_TEXCOORD0); + c_i0 = tmpvar_3; + highp vec3 tmpvar_4; + tmpvar_4 = ((c_i0.xyz * _Color.xyz) * xlv_COLOR0.w); + tmpvar_1 = tmpvar_4; + lowp vec4 tmpvar_5; + tmpvar_5 = texture2D (_TranslucencyMap, xlv_TEXCOORD0); + trngls = tmpvar_5; + highp float tmpvar_6; + tmpvar_6 = (trngls.w * _Color.x); + tmpvar_2 = tmpvar_6; + lowp vec4 tmpvar_7; + tmpvar_7 = texture2D (_BumpSpecMap, xlv_TEXCOORD0); + norspc = tmpvar_7; + mediump vec4 normal; + normal.xy = ((norspc.wy * 2.0) - 1.0); + normal.z = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + mediump vec3 tmpvar_8; + tmpvar_8 = normal.xyz; + highp float x; + x = (c_i0.w - _Cutoff); + if ((x < 0.0)) { + discard; + }; + lightDir = xlv_TEXCOORD1; + highp vec3 tmpvar_9; + tmpvar_9 = normalize (xlv_TEXCOORD2); + lowp vec4 tmpvar_10; + tmpvar_10 = texture2D (_LightTexture0, xlv_TEXCOORD3); + mediump vec3 viewDir; + viewDir = tmpvar_9; + mediump float atten; + atten = tmpvar_10.w; + mediump vec4 c_i0_i1; + mediump float tmpvar_11; + tmpvar_11 = dot (tmpvar_8, lightDir); + mediump float tmpvar_12; + tmpvar_12 = (pow (max (0.0, dot (tmpvar_8, normalize ((lightDir + viewDir)))), (norspc.x * 128.0)) * tmpvar_2); + c_i0_i1.xyz = (tmpvar_1 * ((((mix (clamp (-(tmpvar_11), 0.0, 1.0), clamp (dot (viewDir, -(lightDir)), 0.0, 1.0), _TranslucencyViewDependency) * trngls.z) * _TranslucencyColor) * 2.0) + max (0.0, ((tmpvar_11 * 0.6) + 0.4)))); + highp vec3 tmpvar_13; + tmpvar_13 = ((c_i0_i1.xyz * _LightColor0.xyz) + tmpvar_12); + c_i0_i1.xyz = tmpvar_13; + c_i0_i1.xyz = (c_i0_i1.xyz * mix (2.0, (atten * 2.0), _ShadowStrength)); + c = c_i0_i1; + c.w = c_i0.w; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/derivatives-in.txt b/3rdparty/glsl-optimizer/tests/fragment/derivatives-in.txt new file mode 100644 index 000000000..49fd071d7 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/derivatives-in.txt @@ -0,0 +1,59 @@ +float xll_dFdx(float f) { + return dFdx(f); +} +vec2 xll_dFdx(vec2 v) { + return dFdx(v); +} +vec3 xll_dFdx(vec3 v) { + return dFdx(v); +} +vec4 xll_dFdx(vec4 v) { + return dFdx(v); +} +mat2 xll_dFdx(mat2 m) { + return mat2( dFdx(m[0]), dFdx(m[1])); +} +mat3 xll_dFdx(mat3 m) { + return mat3( dFdx(m[0]), dFdx(m[1]), dFdx(m[2])); +} +mat4 xll_dFdx(mat4 m) { + return mat4( dFdx(m[0]), dFdx(m[1]), dFdx(m[2]), dFdx(m[3])); +} +float xll_fwidth(float f) { + return fwidth(f); +} +vec2 xll_fwidth(vec2 v) { + return fwidth(v); +} +vec3 xll_fwidth(vec3 v) { + return fwidth(v); +} +vec4 xll_fwidth(vec4 v) { + return fwidth(v); +} +mat2 xll_fwidth(mat2 m) { + return mat2( fwidth(m[0]), fwidth(m[1])); +} +mat3 xll_fwidth(mat3 m) { + return mat3( fwidth(m[0]), fwidth(m[1]), fwidth(m[2])); +} +mat4 xll_fwidth(mat4 m) { + return mat4( fwidth(m[0]), fwidth(m[1]), fwidth(m[2]), fwidth(m[3])); +} +vec4 xlat_main( in vec4 uv ); +#line 1 +vec4 xlat_main( in vec4 uv ) { + vec4 res; + #line 3 + res.x = xll_dFdx(uv.x); + res.y = xll_dFdx(uv.y); + res.zw = xll_fwidth(uv.xy); + #line 7 + return res; +} +varying vec4 xlv_TEXCOORD0; +void main() { + vec4 xl_retval; + xl_retval = xlat_main( vec4(xlv_TEXCOORD0)); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/derivatives-inES.txt b/3rdparty/glsl-optimizer/tests/fragment/derivatives-inES.txt new file mode 100644 index 000000000..5f32e46d1 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/derivatives-inES.txt @@ -0,0 +1,61 @@ +#extension GL_OES_standard_derivatives : require +float xll_dFdx(float f) { + return dFdx(f); +} +vec2 xll_dFdx(vec2 v) { + return dFdx(v); +} +vec3 xll_dFdx(vec3 v) { + return dFdx(v); +} +vec4 xll_dFdx(vec4 v) { + return dFdx(v); +} +mat2 xll_dFdx(mat2 m) { + return mat2( dFdx(m[0]), dFdx(m[1])); +} +mat3 xll_dFdx(mat3 m) { + return mat3( dFdx(m[0]), dFdx(m[1]), dFdx(m[2])); +} +mat4 xll_dFdx(mat4 m) { + return mat4( dFdx(m[0]), dFdx(m[1]), dFdx(m[2]), dFdx(m[3])); +} +float xll_fwidth(float f) { + return fwidth(f); +} +vec2 xll_fwidth(vec2 v) { + return fwidth(v); +} +vec3 xll_fwidth(vec3 v) { + return fwidth(v); +} +vec4 xll_fwidth(vec4 v) { + return fwidth(v); +} +mat2 xll_fwidth(mat2 m) { + return mat2( fwidth(m[0]), fwidth(m[1])); +} +mat3 xll_fwidth(mat3 m) { + return mat3( fwidth(m[0]), fwidth(m[1]), fwidth(m[2])); +} +mat4 xll_fwidth(mat4 m) { + return mat4( fwidth(m[0]), fwidth(m[1]), fwidth(m[2]), fwidth(m[3])); +} +mediump vec4 xlat_main( in highp vec4 uv ); +#line 1 +mediump vec4 xlat_main( in highp vec4 uv ) { + lowp vec4 res; + #line 3 + res.x = xll_dFdx( uv.x ); + res.y = xll_dFdx( uv.y ); + res.z = xll_fwidth( uv.z ); + res.w = 1.00000; + #line 7 + return res; +} +varying highp vec4 xlv_TEXCOORD0; +void main() { + mediump vec4 xl_retval; + xl_retval = xlat_main( vec4(xlv_TEXCOORD0)); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/derivatives-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/derivatives-ir.txt new file mode 100644 index 000000000..8d819e1e9 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/derivatives-ir.txt @@ -0,0 +1,251 @@ +varying vec4 xlv_TEXCOORD0; +float xll_dFdx ( + in float f +) +{ + float tmpvar_1; + tmpvar_1 = dFdx (f); + return tmpvar_1; +} + +vec2 xll_dFdx ( + in vec2 v +) +{ + vec2 tmpvar_1; + tmpvar_1 = dFdx (v); + return tmpvar_1; +} + +vec3 xll_dFdx ( + in vec3 v +) +{ + vec3 tmpvar_1; + tmpvar_1 = dFdx (v); + return tmpvar_1; +} + +vec4 xll_dFdx ( + in vec4 v +) +{ + vec4 tmpvar_1; + tmpvar_1 = dFdx (v); + return tmpvar_1; +} + +mat2 xll_dFdx ( + in mat2 m +) +{ + vec2 tmpvar_1; + tmpvar_1 = dFdx (m[0]); + vec2 tmpvar_2; + tmpvar_2 = dFdx (m[1]); + mat2 tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_1; + tmpvar_3[0] = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5 = tmpvar_2; + tmpvar_3[1] = tmpvar_5; + return tmpvar_3; +} + +mat3 xll_dFdx ( + in mat3 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = dFdx (m[0]); + vec3 tmpvar_2; + tmpvar_2 = dFdx (m[1]); + vec3 tmpvar_3; + tmpvar_3 = dFdx (m[2]); + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +mat4 xll_dFdx ( + in mat4 m +) +{ + vec4 tmpvar_1; + tmpvar_1 = dFdx (m[0]); + vec4 tmpvar_2; + tmpvar_2 = dFdx (m[1]); + vec4 tmpvar_3; + tmpvar_3 = dFdx (m[2]); + vec4 tmpvar_4; + tmpvar_4 = dFdx (m[3]); + mat4 tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_1; + tmpvar_5[0] = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = tmpvar_2; + tmpvar_5[1] = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_3; + tmpvar_5[2] = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = tmpvar_4; + tmpvar_5[3] = tmpvar_9; + return tmpvar_5; +} + +float xll_fwidth ( + in float f +) +{ + float tmpvar_1; + tmpvar_1 = fwidth (f); + return tmpvar_1; +} + +vec2 xll_fwidth ( + in vec2 v +) +{ + vec2 tmpvar_1; + tmpvar_1 = fwidth (v); + return tmpvar_1; +} + +vec3 xll_fwidth ( + in vec3 v +) +{ + vec3 tmpvar_1; + tmpvar_1 = fwidth (v); + return tmpvar_1; +} + +vec4 xll_fwidth ( + in vec4 v +) +{ + vec4 tmpvar_1; + tmpvar_1 = fwidth (v); + return tmpvar_1; +} + +mat2 xll_fwidth ( + in mat2 m +) +{ + vec2 tmpvar_1; + tmpvar_1 = fwidth (m[0]); + vec2 tmpvar_2; + tmpvar_2 = fwidth (m[1]); + mat2 tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_1; + tmpvar_3[0] = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5 = tmpvar_2; + tmpvar_3[1] = tmpvar_5; + return tmpvar_3; +} + +mat3 xll_fwidth ( + in mat3 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = fwidth (m[0]); + vec3 tmpvar_2; + tmpvar_2 = fwidth (m[1]); + vec3 tmpvar_3; + tmpvar_3 = fwidth (m[2]); + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +mat4 xll_fwidth ( + in mat4 m +) +{ + vec4 tmpvar_1; + tmpvar_1 = fwidth (m[0]); + vec4 tmpvar_2; + tmpvar_2 = fwidth (m[1]); + vec4 tmpvar_3; + tmpvar_3 = fwidth (m[2]); + vec4 tmpvar_4; + tmpvar_4 = fwidth (m[3]); + mat4 tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_1; + tmpvar_5[0] = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = tmpvar_2; + tmpvar_5[1] = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_3; + tmpvar_5[2] = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = tmpvar_4; + tmpvar_5[3] = tmpvar_9; + return tmpvar_5; +} + +vec4 xlat_main ( + in vec4 uv +) +{ + vec4 res; + float tmpvar_1; + tmpvar_1 = xll_dFdx (uv.x); + float tmpvar_2; + tmpvar_2 = tmpvar_1; + res.x = tmpvar_2; + float tmpvar_3; + tmpvar_3 = xll_dFdx (uv.y); + float tmpvar_4; + tmpvar_4 = tmpvar_3; + res.y = vec2(tmpvar_4).y; + vec2 tmpvar_5; + tmpvar_5 = xll_fwidth (uv.xy); + vec2 tmpvar_6; + tmpvar_6 = tmpvar_5; + res.zw = tmpvar_6.xxxy.zw; + return res; +} + +void main () +{ + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = xlv_TEXCOORD0.xyzw; + vec4 tmpvar_2; + tmpvar_2 = xlat_main (tmpvar_1); + vec4 tmpvar_3; + tmpvar_3 = tmpvar_2; + xl_retval = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = xl_retval.xyzw; + vec4 tmpvar_5; + tmpvar_5 = tmpvar_4; + gl_FragData[0] = tmpvar_5; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/derivatives-irES.txt b/3rdparty/glsl-optimizer/tests/fragment/derivatives-irES.txt new file mode 100644 index 000000000..dc24c99ec --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/derivatives-irES.txt @@ -0,0 +1,255 @@ +#extension GL_OES_standard_derivatives : enable +varying highp vec4 xlv_TEXCOORD0; +float xll_dFdx ( + in float f +) +{ + float tmpvar_1; + tmpvar_1 = dFdx (f); + return tmpvar_1; +} + +vec2 xll_dFdx ( + in vec2 v +) +{ + vec2 tmpvar_1; + tmpvar_1 = dFdx (v); + return tmpvar_1; +} + +vec3 xll_dFdx ( + in vec3 v +) +{ + vec3 tmpvar_1; + tmpvar_1 = dFdx (v); + return tmpvar_1; +} + +vec4 xll_dFdx ( + in vec4 v +) +{ + vec4 tmpvar_1; + tmpvar_1 = dFdx (v); + return tmpvar_1; +} + +mat2 xll_dFdx ( + in mat2 m +) +{ + vec2 tmpvar_1; + tmpvar_1 = dFdx (m[0]); + vec2 tmpvar_2; + tmpvar_2 = dFdx (m[1]); + mat2 tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_1; + tmpvar_3[0] = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5 = tmpvar_2; + tmpvar_3[1] = tmpvar_5; + return tmpvar_3; +} + +mat3 xll_dFdx ( + in mat3 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = dFdx (m[0]); + vec3 tmpvar_2; + tmpvar_2 = dFdx (m[1]); + vec3 tmpvar_3; + tmpvar_3 = dFdx (m[2]); + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +mat4 xll_dFdx ( + in mat4 m +) +{ + vec4 tmpvar_1; + tmpvar_1 = dFdx (m[0]); + vec4 tmpvar_2; + tmpvar_2 = dFdx (m[1]); + vec4 tmpvar_3; + tmpvar_3 = dFdx (m[2]); + vec4 tmpvar_4; + tmpvar_4 = dFdx (m[3]); + mat4 tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_1; + tmpvar_5[0] = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = tmpvar_2; + tmpvar_5[1] = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_3; + tmpvar_5[2] = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = tmpvar_4; + tmpvar_5[3] = tmpvar_9; + return tmpvar_5; +} + +float xll_fwidth ( + in float f +) +{ + float tmpvar_1; + tmpvar_1 = fwidth (f); + return tmpvar_1; +} + +vec2 xll_fwidth ( + in vec2 v +) +{ + vec2 tmpvar_1; + tmpvar_1 = fwidth (v); + return tmpvar_1; +} + +vec3 xll_fwidth ( + in vec3 v +) +{ + vec3 tmpvar_1; + tmpvar_1 = fwidth (v); + return tmpvar_1; +} + +vec4 xll_fwidth ( + in vec4 v +) +{ + vec4 tmpvar_1; + tmpvar_1 = fwidth (v); + return tmpvar_1; +} + +mat2 xll_fwidth ( + in mat2 m +) +{ + vec2 tmpvar_1; + tmpvar_1 = fwidth (m[0]); + vec2 tmpvar_2; + tmpvar_2 = fwidth (m[1]); + mat2 tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_1; + tmpvar_3[0] = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5 = tmpvar_2; + tmpvar_3[1] = tmpvar_5; + return tmpvar_3; +} + +mat3 xll_fwidth ( + in mat3 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = fwidth (m[0]); + vec3 tmpvar_2; + tmpvar_2 = fwidth (m[1]); + vec3 tmpvar_3; + tmpvar_3 = fwidth (m[2]); + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +mat4 xll_fwidth ( + in mat4 m +) +{ + vec4 tmpvar_1; + tmpvar_1 = fwidth (m[0]); + vec4 tmpvar_2; + tmpvar_2 = fwidth (m[1]); + vec4 tmpvar_3; + tmpvar_3 = fwidth (m[2]); + vec4 tmpvar_4; + tmpvar_4 = fwidth (m[3]); + mat4 tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_1; + tmpvar_5[0] = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = tmpvar_2; + tmpvar_5[1] = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_3; + tmpvar_5[2] = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = tmpvar_4; + tmpvar_5[3] = tmpvar_9; + return tmpvar_5; +} + +mediump vec4 xlat_main ( + in highp vec4 uv +) +{ + lowp vec4 res; + float tmpvar_1; + tmpvar_1 = xll_dFdx (uv.x); + float tmpvar_2; + tmpvar_2 = tmpvar_1; + res.x = tmpvar_2; + float tmpvar_3; + tmpvar_3 = xll_dFdx (uv.y); + float tmpvar_4; + tmpvar_4 = tmpvar_3; + res.y = vec2(tmpvar_4).y; + float tmpvar_5; + tmpvar_5 = xll_fwidth (uv.z); + float tmpvar_6; + tmpvar_6 = tmpvar_5; + res.z = vec3(tmpvar_6).z; + float tmpvar_7; + tmpvar_7 = 1.0; + res.w = vec4(tmpvar_7).w; + return res; +} + +void main () +{ + mediump vec4 xl_retval; + highp vec4 tmpvar_1; + tmpvar_1 = xlv_TEXCOORD0.xyzw; + mediump vec4 tmpvar_2; + tmpvar_2 = xlat_main (tmpvar_1); + mediump vec4 tmpvar_3; + tmpvar_3 = tmpvar_2; + xl_retval = tmpvar_3; + mediump vec4 tmpvar_4; + tmpvar_4 = xl_retval.xyzw; + mediump vec4 tmpvar_5; + tmpvar_5 = tmpvar_4; + gl_FragData[0] = tmpvar_5; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/derivatives-out.txt b/3rdparty/glsl-optimizer/tests/fragment/derivatives-out.txt new file mode 100644 index 000000000..873a91a1c --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/derivatives-out.txt @@ -0,0 +1,10 @@ +varying vec4 xlv_TEXCOORD0; +void main () +{ + vec4 res; + res.x = dFdx (xlv_TEXCOORD0.x); + res.y = dFdx (xlv_TEXCOORD0.y); + res.zw = fwidth (xlv_TEXCOORD0.xy); + gl_FragData[0] = res; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/derivatives-outES.txt b/3rdparty/glsl-optimizer/tests/fragment/derivatives-outES.txt new file mode 100644 index 000000000..ef0eff769 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/derivatives-outES.txt @@ -0,0 +1,20 @@ +#extension GL_OES_standard_derivatives : enable +varying highp vec4 xlv_TEXCOORD0; +void main () +{ + mediump vec4 tmpvar_1; + lowp vec4 res; + highp float tmpvar_2; + tmpvar_2 = dFdx (xlv_TEXCOORD0.x); + res.x = tmpvar_2; + highp float tmpvar_3; + tmpvar_3 = dFdx (xlv_TEXCOORD0.y); + res.y = tmpvar_3; + highp float tmpvar_4; + tmpvar_4 = fwidth (xlv_TEXCOORD0.z); + res.z = tmpvar_4; + res.w = 1.0; + tmpvar_1 = res; + gl_FragData[0] = tmpvar_1; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/estest1-in.txt b/3rdparty/glsl-optimizer/tests/fragment/estest1-in.txt new file mode 100644 index 000000000..9b13af189 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/estest1-in.txt @@ -0,0 +1,26 @@ +struct v2f { + vec4 pos; + vec2 uv0; + vec2 uv1; +}; + +uniform vec4 _Color; +uniform sampler2D _Detail; +uniform sampler2D _MainTex; +vec4 frag( in v2f i ); +vec4 frag( in v2f i ) { + vec4 c; + c = (_Color * texture2D( _MainTex, i.uv0)); + c = ((c * texture2D( _Detail, i.uv1)) * 2.00000); + return c; +} +varying vec4 xlv_TEXCOORD0; +varying vec4 xlv_TEXCOORD1; +void main() { + vec4 xl_retval; + v2f xlt_i; + xlt_i.uv0 = vec2( xlv_TEXCOORD0); + xlt_i.uv1 = vec2( xlv_TEXCOORD1); + xl_retval = frag( xlt_i); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/estest1-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/estest1-ir.txt new file mode 100644 index 000000000..14838950e --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/estest1-ir.txt @@ -0,0 +1,54 @@ +struct v2f { + vec4 pos; + vec2 uv0; + vec2 uv1; +}; +varying vec4 xlv_TEXCOORD1; +varying vec4 xlv_TEXCOORD0; +uniform sampler2D _MainTex; +uniform sampler2D _Detail; +uniform vec4 _Color; +vec4 frag ( + in v2f i +) +{ + vec4 c; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, i.uv0); + vec4 tmpvar_2; + tmpvar_2 = (_Color * tmpvar_1); + c = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = texture2D (_Detail, i.uv1); + vec4 tmpvar_4; + tmpvar_4 = ((c * tmpvar_3) * 2.0); + c = tmpvar_4; + return c; +} + +void main () +{ + v2f xlt_i; + vec4 xl_retval; + vec2 tmpvar_1; + tmpvar_1 = xlv_TEXCOORD0.xy; + vec2 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_i.uv0 = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = xlv_TEXCOORD1.xy; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_i.uv1 = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = frag (xlt_i); + vec4 tmpvar_6; + tmpvar_6 = tmpvar_5; + xl_retval = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = xl_retval.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + gl_FragData[0] = tmpvar_8; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/estest1-out.txt b/3rdparty/glsl-optimizer/tests/fragment/estest1-out.txt new file mode 100644 index 000000000..269e6c9f5 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/estest1-out.txt @@ -0,0 +1,10 @@ +varying vec4 xlv_TEXCOORD1; +varying vec4 xlv_TEXCOORD0; +uniform sampler2D _MainTex; +uniform sampler2D _Detail; +uniform vec4 _Color; +void main () +{ + gl_FragData[0] = (((_Color * texture2D (_MainTex, xlv_TEXCOORD0.xy)) * texture2D (_Detail, xlv_TEXCOORD1.xy)) * 2.0); +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/in-struct-ret-vals-in.txt b/3rdparty/glsl-optimizer/tests/fragment/in-struct-ret-vals-in.txt new file mode 100644 index 000000000..e0909a228 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/in-struct-ret-vals-in.txt @@ -0,0 +1,21 @@ +struct v2f { + vec4 pos; + vec2 uv; + vec4 color; +}; +vec4 xlat_main( in v2f i ); +vec4 xlat_main( in v2f i ) { + vec4 c; + c = i.color; + c.xy += i.uv; + return c; +} +void main() { + vec4 xl_retval; + v2f xlt_i; + xlt_i.pos = vec4(0.0); + xlt_i.uv = vec2( gl_TexCoord[0]); + xlt_i.color = vec4( gl_Color); + xl_retval = xlat_main( xlt_i); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/in-struct-ret-vals-inES.txt b/3rdparty/glsl-optimizer/tests/fragment/in-struct-ret-vals-inES.txt new file mode 100644 index 000000000..4817d90d6 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/in-struct-ret-vals-inES.txt @@ -0,0 +1,23 @@ +struct v2f { + highp vec4 pos; + highp vec2 uv; + highp vec4 color; +}; +mediump vec4 xlat_main( in v2f i ); +mediump vec4 xlat_main( in v2f i ) { + mediump vec4 c; + c = i.color; + c.xy += i.uv; + return c; +} +varying highp vec2 xlv_TEXCOORD0; +varying highp vec4 xlv_COLOR; +void main() { + mediump vec4 xl_retval; + v2f xlt_i; + xlt_i.pos = highp vec4(0.0); + xlt_i.uv = highp vec2( xlv_TEXCOORD0); + xlt_i.color = highp vec4( xlv_COLOR); + xl_retval = xlat_main( xlt_i); + gl_FragData[0] = mediump vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/in-struct-ret-vals-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/in-struct-ret-vals-ir.txt new file mode 100644 index 000000000..c0e0e010e --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/in-struct-ret-vals-ir.txt @@ -0,0 +1,48 @@ +struct v2f { + vec4 pos; + vec2 uv; + vec4 color; +}; +vec4 xlat_main ( + in v2f i +) +{ + vec4 c; + vec4 tmpvar_1; + tmpvar_1 = i.color; + c = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = (c.xy + i.uv); + c.xy = tmpvar_2.xy.xy; + return c; +} + +void main () +{ + v2f xlt_i; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_i.pos = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = gl_TexCoord[0].xy; + vec2 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_i.uv = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = gl_Color.xyzw; + vec4 tmpvar_5; + tmpvar_5 = tmpvar_4; + xlt_i.color = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = xlat_main (xlt_i); + vec4 tmpvar_7; + tmpvar_7 = tmpvar_6; + xl_retval = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = xl_retval.xyzw; + vec4 tmpvar_9; + tmpvar_9 = tmpvar_8; + gl_FragData[0] = tmpvar_9; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/in-struct-ret-vals-irES.txt b/3rdparty/glsl-optimizer/tests/fragment/in-struct-ret-vals-irES.txt new file mode 100644 index 000000000..797151917 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/in-struct-ret-vals-irES.txt @@ -0,0 +1,50 @@ +struct v2f { + highp vec4 pos; + highp vec2 uv; + highp vec4 color; +}; +varying highp vec4 xlv_COLOR; +varying highp vec2 xlv_TEXCOORD0; +mediump vec4 xlat_main ( + in v2f i +) +{ + mediump vec4 c; + highp vec4 tmpvar_1; + tmpvar_1 = i.color; + c = tmpvar_1; + highp vec2 tmpvar_2; + tmpvar_2 = (c.xy + i.uv); + c.xy = tmpvar_2.xy.xy; + return c; +} + +void main () +{ + v2f xlt_i; + mediump vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_i.pos = tmpvar_1; + highp vec2 tmpvar_2; + tmpvar_2 = xlv_TEXCOORD0.xy; + highp vec2 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_i.uv = tmpvar_3; + highp vec4 tmpvar_4; + tmpvar_4 = xlv_COLOR.xyzw; + highp vec4 tmpvar_5; + tmpvar_5 = tmpvar_4; + xlt_i.color = tmpvar_5; + mediump vec4 tmpvar_6; + tmpvar_6 = xlat_main (xlt_i); + mediump vec4 tmpvar_7; + tmpvar_7 = tmpvar_6; + xl_retval = tmpvar_7; + mediump vec4 tmpvar_8; + tmpvar_8 = xl_retval.xyzw; + mediump vec4 tmpvar_9; + tmpvar_9 = tmpvar_8; + gl_FragData[0] = tmpvar_9; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/in-struct-ret-vals-out.txt b/3rdparty/glsl-optimizer/tests/fragment/in-struct-ret-vals-out.txt new file mode 100644 index 000000000..24e4470f1 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/in-struct-ret-vals-out.txt @@ -0,0 +1,8 @@ +void main () +{ + vec4 c; + c = gl_Color; + c.xy = (gl_Color.xy + gl_TexCoord[0].xy); + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/in-struct-ret-vals-outES.txt b/3rdparty/glsl-optimizer/tests/fragment/in-struct-ret-vals-outES.txt new file mode 100644 index 000000000..6ae677127 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/in-struct-ret-vals-outES.txt @@ -0,0 +1,12 @@ +varying highp vec4 xlv_COLOR; +varying highp vec2 xlv_TEXCOORD0; +void main () +{ + mediump vec4 c; + c = xlv_COLOR; + highp vec2 tmpvar_1; + tmpvar_1 = (c.xy + xlv_TEXCOORD0); + c.xy = tmpvar_1; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/in-vals-ret-vals-inES.txt b/3rdparty/glsl-optimizer/tests/fragment/in-vals-ret-vals-inES.txt new file mode 100644 index 000000000..11e133519 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/in-vals-ret-vals-inES.txt @@ -0,0 +1,14 @@ +mediump vec4 xlat_main( in highp vec2 uv, in highp vec4 color ); +mediump vec4 xlat_main( in highp vec2 uv, in highp vec4 color ) { + mediump vec4 c; + c = color; + c.xy += uv; + return c; +} +varying highp vec2 xlv_TEXCOORD0; +varying highp vec4 xlv_COLOR; +void main() { + mediump vec4 xl_retval; + xl_retval = xlat_main( highp vec2(xlv_TEXCOORD0), highp vec4(xlv_COLOR)); + gl_FragData[0] = mediump vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/in-vals-ret-vals-irES.txt b/3rdparty/glsl-optimizer/tests/fragment/in-vals-ret-vals-irES.txt new file mode 100644 index 000000000..362b5c034 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/in-vals-ret-vals-irES.txt @@ -0,0 +1,36 @@ +varying highp vec4 xlv_COLOR; +varying highp vec2 xlv_TEXCOORD0; +mediump vec4 xlat_main ( + in highp vec2 uv, + in highp vec4 color +) +{ + mediump vec4 c; + highp vec4 tmpvar_1; + tmpvar_1 = color; + c = tmpvar_1; + highp vec2 tmpvar_2; + tmpvar_2 = (c.xy + uv); + c.xy = tmpvar_2.xy.xy; + return c; +} + +void main () +{ + mediump vec4 xl_retval; + highp vec2 tmpvar_1; + tmpvar_1 = xlv_TEXCOORD0.xy; + highp vec4 tmpvar_2; + tmpvar_2 = xlv_COLOR.xyzw; + mediump vec4 tmpvar_3; + tmpvar_3 = xlat_main (tmpvar_1, tmpvar_2); + mediump vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xl_retval = tmpvar_4; + mediump vec4 tmpvar_5; + tmpvar_5 = xl_retval.xyzw; + mediump vec4 tmpvar_6; + tmpvar_6 = tmpvar_5; + gl_FragData[0] = tmpvar_6; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/in-vals-ret-vals-outES.txt b/3rdparty/glsl-optimizer/tests/fragment/in-vals-ret-vals-outES.txt new file mode 100644 index 000000000..6ae677127 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/in-vals-ret-vals-outES.txt @@ -0,0 +1,12 @@ +varying highp vec4 xlv_COLOR; +varying highp vec2 xlv_TEXCOORD0; +void main () +{ + mediump vec4 c; + c = xlv_COLOR; + highp vec2 tmpvar_1; + tmpvar_1 = (c.xy + xlv_TEXCOORD0); + c.xy = tmpvar_1; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/intrinsics-in.txt b/3rdparty/glsl-optimizer/tests/fragment/intrinsics-in.txt new file mode 100644 index 000000000..c612ba689 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/intrinsics-in.txt @@ -0,0 +1,77 @@ +float xll_mod( float x, float y ) { + float d = x / y; + float f = fract (abs(d)) * y; + return d >= 0.0 ? f : -f; +} +vec2 xll_mod( vec2 x, vec2 y ) { + vec2 d = x / y; + vec2 f = fract (abs(d)) * y; + return vec2 (d.x >= 0.0 ? f.x : -f.x, d.y >= 0.0 ? f.y : -f.y); +} +vec3 xll_mod( vec3 x, vec3 y ) { + vec3 d = x / y; + vec3 f = fract (abs(d)) * y; + return vec3 (d.x >= 0.0 ? f.x : -f.x, d.y >= 0.0 ? f.y : -f.y, d.z >= 0.0 ? f.z : -f.z); +} +vec4 xll_mod( vec4 x, vec4 y ) { + vec4 d = x / y; + vec4 f = fract (abs(d)) * y; + return vec4 (d.x >= 0.0 ? f.x : -f.x, d.y >= 0.0 ? f.y : -f.y, d.z >= 0.0 ? f.z : -f.z, d.w >= 0.0 ? f.w : -f.w); +} +float xll_modf( float x, out int ip) { + ip = int (x); + return x-float(ip); +} +float xll_modf( float x, out float ip) { + int i = int (x); + ip = float(i); + return x-ip; +} +vec2 xll_modf( vec2 x, out ivec2 ip) { + ip = ivec2 (x); + return x-vec2(ip); +} +vec2 xll_modf( vec2 x, out vec2 ip) { + ivec2 i = ivec2 (x); + ip = vec2(i); + return x-ip; +} +vec3 xll_modf( vec3 x, out ivec3 ip) { + ip = ivec3 (x); + return x-vec3(ip); +} +vec3 xll_modf( vec3 x, out vec3 ip) { + ivec3 i = ivec3 (x); + ip = vec3(i); + return x-ip; +} +vec4 xll_modf( vec4 x, out ivec4 ip) { + ip = ivec4 (x); + return x-vec4(ip); +} +vec4 xll_modf( vec4 x, out vec4 ip) { + ivec4 i = ivec4 (x); + ip = vec4(i); + return x-ip; +} +vec4 xlat_main( in vec4 uv ); +vec4 xlat_main( in vec4 uv ) { + vec4 c; + vec4 d; + c = vec4( 0.000000); + c.x += xll_mod( uv.x , 2.00000); + c.xy += xll_mod( uv.xy , vec2( 2.00000)); + c.xyz += xll_mod( uv.xyz , vec3( 2.00000)); + c.xyzw += xll_mod( uv.xyzw , vec4( 2.00000)); + c.x += xll_modf( uv.x , d.x ); + c.xy += xll_modf( uv.xy , d.xy ); + c.xyz += xll_modf( uv.xyz , d.xyz ); + c.xyzw += xll_modf( uv.xyzw , d.xyzw ); + return c; +} +varying vec4 xlv_TEXCOORD0; +void main() { + vec4 xl_retval; + xl_retval = xlat_main( vec4(xlv_TEXCOORD0)); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/intrinsics-inES.txt b/3rdparty/glsl-optimizer/tests/fragment/intrinsics-inES.txt new file mode 100644 index 000000000..2462470cf --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/intrinsics-inES.txt @@ -0,0 +1,77 @@ +float xll_mod( float x, float y ) { + float d = x / y; + float f = fract (abs(d)) * y; + return d >= 0.0 ? f : -f; +} +vec2 xll_mod( vec2 x, vec2 y ) { + vec2 d = x / y; + vec2 f = fract (abs(d)) * y; + return vec2 (d.x >= 0.0 ? f.x : -f.x, d.y >= 0.0 ? f.y : -f.y); +} +vec3 xll_mod( vec3 x, vec3 y ) { + vec3 d = x / y; + vec3 f = fract (abs(d)) * y; + return vec3 (d.x >= 0.0 ? f.x : -f.x, d.y >= 0.0 ? f.y : -f.y, d.z >= 0.0 ? f.z : -f.z); +} +vec4 xll_mod( vec4 x, vec4 y ) { + vec4 d = x / y; + vec4 f = fract (abs(d)) * y; + return vec4 (d.x >= 0.0 ? f.x : -f.x, d.y >= 0.0 ? f.y : -f.y, d.z >= 0.0 ? f.z : -f.z, d.w >= 0.0 ? f.w : -f.w); +} +float xll_modf( float x, out int ip) { + ip = int (x); + return x-float(ip); +} +float xll_modf( float x, out float ip) { + int i = int (x); + ip = float(i); + return x-ip; +} +vec2 xll_modf( vec2 x, out ivec2 ip) { + ip = ivec2 (x); + return x-vec2(ip); +} +vec2 xll_modf( vec2 x, out vec2 ip) { + ivec2 i = ivec2 (x); + ip = vec2(i); + return x-ip; +} +vec3 xll_modf( vec3 x, out ivec3 ip) { + ip = ivec3 (x); + return x-vec3(ip); +} +vec3 xll_modf( vec3 x, out vec3 ip) { + ivec3 i = ivec3 (x); + ip = vec3(i); + return x-ip; +} +vec4 xll_modf( vec4 x, out ivec4 ip) { + ip = ivec4 (x); + return x-vec4(ip); +} +vec4 xll_modf( vec4 x, out vec4 ip) { + ivec4 i = ivec4 (x); + ip = vec4(i); + return x-ip; +} +mediump vec4 xlat_main( in highp vec4 uv ); +mediump vec4 xlat_main( in highp vec4 uv ) { + mediump vec4 c; + mediump vec4 d; + c = vec4( 0.000000); + c.x += xll_mod( uv.x , 2.00000); + c.xy += xll_mod( uv.xy , vec2( 2.00000)); + c.xyz += xll_mod( uv.xyz , vec3( 2.00000)); + c.xyzw += xll_mod( uv.xyzw , vec4( 2.00000)); + c.x += xll_modf( uv.x , d.x ); + c.xy += xll_modf( uv.xy , d.xy ); + c.xyz += xll_modf( uv.xyz , d.xyz ); + c.xyzw += xll_modf( uv.xyzw , d.xyzw ); + return c; +} +varying highp vec4 xlv_TEXCOORD0; +void main() { + mediump vec4 xl_retval; + xl_retval = xlat_main( highp vec4(xlv_TEXCOORD0)); + gl_FragData[0] = mediump vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/intrinsics-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/intrinsics-ir.txt new file mode 100644 index 000000000..10684968f --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/intrinsics-ir.txt @@ -0,0 +1,350 @@ +varying vec4 xlv_TEXCOORD0; +float xll_mod ( + in float x, + in float y +) +{ + float f; + float d; + float tmpvar_1; + tmpvar_1 = (x / y); + d = tmpvar_1; + float tmpvar_2; + tmpvar_2 = abs (d); + float tmpvar_3; + tmpvar_3 = fract (tmpvar_2); + float tmpvar_4; + tmpvar_4 = (tmpvar_3 * y); + f = tmpvar_4; + float tmpvar_5; + if ((d >= 0.0)) { + tmpvar_5 = f; + } else { + tmpvar_5 = -(f); + }; + return tmpvar_5; +} + +vec2 xll_mod ( + in vec2 x, + in vec2 y +) +{ + vec2 f; + vec2 d; + vec2 tmpvar_1; + tmpvar_1 = (x / y); + d = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = abs (d); + vec2 tmpvar_3; + tmpvar_3 = fract (tmpvar_2); + vec2 tmpvar_4; + tmpvar_4 = (tmpvar_3 * y); + f = tmpvar_4; + float tmpvar_5; + if ((d.x >= 0.0)) { + tmpvar_5 = f.x; + } else { + tmpvar_5 = -(f.x); + }; + float tmpvar_6; + if ((d.y >= 0.0)) { + tmpvar_6 = f.y; + } else { + tmpvar_6 = -(f.y); + }; + vec2 tmpvar_7; + tmpvar_7.x = tmpvar_5; + tmpvar_7.y = tmpvar_6; + return tmpvar_7; +} + +vec3 xll_mod ( + in vec3 x, + in vec3 y +) +{ + vec3 f; + vec3 d; + vec3 tmpvar_1; + tmpvar_1 = (x / y); + d = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = abs (d); + vec3 tmpvar_3; + tmpvar_3 = fract (tmpvar_2); + vec3 tmpvar_4; + tmpvar_4 = (tmpvar_3 * y); + f = tmpvar_4; + float tmpvar_5; + if ((d.x >= 0.0)) { + tmpvar_5 = f.x; + } else { + tmpvar_5 = -(f.x); + }; + float tmpvar_6; + if ((d.y >= 0.0)) { + tmpvar_6 = f.y; + } else { + tmpvar_6 = -(f.y); + }; + float tmpvar_7; + if ((d.z >= 0.0)) { + tmpvar_7 = f.z; + } else { + tmpvar_7 = -(f.z); + }; + vec3 tmpvar_8; + tmpvar_8.x = tmpvar_5; + tmpvar_8.y = tmpvar_6; + tmpvar_8.z = tmpvar_7; + return tmpvar_8; +} + +vec4 xll_mod ( + in vec4 x, + in vec4 y +) +{ + vec4 f; + vec4 d; + vec4 tmpvar_1; + tmpvar_1 = (x / y); + d = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = abs (d); + vec4 tmpvar_3; + tmpvar_3 = fract (tmpvar_2); + vec4 tmpvar_4; + tmpvar_4 = (tmpvar_3 * y); + f = tmpvar_4; + float tmpvar_5; + if ((d.x >= 0.0)) { + tmpvar_5 = f.x; + } else { + tmpvar_5 = -(f.x); + }; + float tmpvar_6; + if ((d.y >= 0.0)) { + tmpvar_6 = f.y; + } else { + tmpvar_6 = -(f.y); + }; + float tmpvar_7; + if ((d.z >= 0.0)) { + tmpvar_7 = f.z; + } else { + tmpvar_7 = -(f.z); + }; + float tmpvar_8; + if ((d.w >= 0.0)) { + tmpvar_8 = f.w; + } else { + tmpvar_8 = -(f.w); + }; + vec4 tmpvar_9; + tmpvar_9.x = tmpvar_5; + tmpvar_9.y = tmpvar_6; + tmpvar_9.z = tmpvar_7; + tmpvar_9.w = tmpvar_8; + return tmpvar_9; +} + +float xll_modf ( + in float x, + out int ip +) +{ + int tmpvar_1; + tmpvar_1 = int(x); + ip = tmpvar_1; + return (x - float(ip)); +} + +float xll_modf ( + in float x, + out float ip +) +{ + int i; + int tmpvar_1; + tmpvar_1 = int(x); + i = tmpvar_1; + float tmpvar_2; + tmpvar_2 = float(i); + ip = tmpvar_2; + return (x - ip); +} + +vec2 xll_modf ( + in vec2 x, + out ivec2 ip +) +{ + ivec2 tmpvar_1; + tmpvar_1 = ivec2(x).xy; + ivec2 tmpvar_2; + tmpvar_2 = tmpvar_1; + ip = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = vec2(ip).xy; + return (x - tmpvar_3); +} + +vec2 xll_modf ( + in vec2 x, + out vec2 ip +) +{ + ivec2 i; + ivec2 tmpvar_1; + tmpvar_1 = ivec2(x).xy; + ivec2 tmpvar_2; + tmpvar_2 = tmpvar_1; + i = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = vec2(i).xy; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + ip = tmpvar_4; + return (x - ip); +} + +vec3 xll_modf ( + in vec3 x, + out ivec3 ip +) +{ + ivec3 tmpvar_1; + tmpvar_1 = ivec3(x).xyz; + ivec3 tmpvar_2; + tmpvar_2 = tmpvar_1; + ip = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(ip).xyz; + return (x - tmpvar_3); +} + +vec3 xll_modf ( + in vec3 x, + out vec3 ip +) +{ + ivec3 i; + ivec3 tmpvar_1; + tmpvar_1 = ivec3(x).xyz; + ivec3 tmpvar_2; + tmpvar_2 = tmpvar_1; + i = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(i).xyz; + vec3 tmpvar_4; + tmpvar_4 = tmpvar_3; + ip = tmpvar_4; + return (x - ip); +} + +vec4 xll_modf ( + in vec4 x, + out ivec4 ip +) +{ + ivec4 tmpvar_1; + tmpvar_1 = ivec4(x).xyzw; + ivec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + ip = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = vec4(ip).xyzw; + return (x - tmpvar_3); +} + +vec4 xll_modf ( + in vec4 x, + out vec4 ip +) +{ + ivec4 i; + ivec4 tmpvar_1; + tmpvar_1 = ivec4(x).xyzw; + ivec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + i = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = vec4(i).xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + ip = tmpvar_4; + return (x - ip); +} + +vec4 xlat_main ( + in vec4 uv +) +{ + vec4 d; + vec4 c; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + c = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xll_mod (uv.x, 2.0); + float tmpvar_3; + tmpvar_3 = (c.x + tmpvar_2); + c.x = tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = xll_mod (uv.xy, vec2(2.0, 2.0)); + vec2 tmpvar_5; + tmpvar_5 = (c.xy + tmpvar_4); + c.xy = tmpvar_5.xy.xy; + vec3 tmpvar_6; + tmpvar_6 = xll_mod (uv.xyz, vec3(2.0, 2.0, 2.0)); + vec3 tmpvar_7; + tmpvar_7 = (c.xyz + tmpvar_6); + c.xyz = tmpvar_7.xyz.xyz; + vec4 tmpvar_8; + tmpvar_8 = xll_mod (uv.xyzw, vec4(2.0, 2.0, 2.0, 2.0)); + vec4 tmpvar_9; + tmpvar_9 = (c.xyzw + tmpvar_8); + c = tmpvar_9.xyzw.xyzw; + float tmpvar_10; + tmpvar_10 = xll_modf (uv.x, d.x); + float tmpvar_11; + tmpvar_11 = (c.x + tmpvar_10); + c.x = tmpvar_11; + vec2 tmpvar_12; + tmpvar_12 = xll_modf (uv.xy, d.xy); + vec2 tmpvar_13; + tmpvar_13 = (c.xy + tmpvar_12); + c.xy = tmpvar_13.xy.xy; + vec3 tmpvar_14; + tmpvar_14 = xll_modf (uv.xyz, d.xyz); + vec3 tmpvar_15; + tmpvar_15 = (c.xyz + tmpvar_14); + c.xyz = tmpvar_15.xyz.xyz; + vec4 tmpvar_16; + tmpvar_16 = xll_modf (uv.xyzw, d.xyzw); + vec4 tmpvar_17; + tmpvar_17 = (c.xyzw + tmpvar_16); + c = tmpvar_17.xyzw.xyzw; + return c; +} + +void main () +{ + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = xlv_TEXCOORD0.xyzw; + vec4 tmpvar_2; + tmpvar_2 = xlat_main (tmpvar_1); + vec4 tmpvar_3; + tmpvar_3 = tmpvar_2; + xl_retval = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = xl_retval.xyzw; + vec4 tmpvar_5; + tmpvar_5 = tmpvar_4; + gl_FragData[0] = tmpvar_5; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/intrinsics-irES.txt b/3rdparty/glsl-optimizer/tests/fragment/intrinsics-irES.txt new file mode 100644 index 000000000..c22f272eb --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/intrinsics-irES.txt @@ -0,0 +1,350 @@ +varying highp vec4 xlv_TEXCOORD0; +float xll_mod ( + in float x, + in float y +) +{ + float f; + float d; + float tmpvar_1; + tmpvar_1 = (x / y); + d = tmpvar_1; + float tmpvar_2; + tmpvar_2 = abs (d); + float tmpvar_3; + tmpvar_3 = fract (tmpvar_2); + float tmpvar_4; + tmpvar_4 = (tmpvar_3 * y); + f = tmpvar_4; + float tmpvar_5; + if ((d >= 0.0)) { + tmpvar_5 = f; + } else { + tmpvar_5 = -(f); + }; + return tmpvar_5; +} + +vec2 xll_mod ( + in vec2 x, + in vec2 y +) +{ + vec2 f; + vec2 d; + vec2 tmpvar_1; + tmpvar_1 = (x / y); + d = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = abs (d); + vec2 tmpvar_3; + tmpvar_3 = fract (tmpvar_2); + vec2 tmpvar_4; + tmpvar_4 = (tmpvar_3 * y); + f = tmpvar_4; + float tmpvar_5; + if ((d.x >= 0.0)) { + tmpvar_5 = f.x; + } else { + tmpvar_5 = -(f.x); + }; + float tmpvar_6; + if ((d.y >= 0.0)) { + tmpvar_6 = f.y; + } else { + tmpvar_6 = -(f.y); + }; + vec2 tmpvar_7; + tmpvar_7.x = tmpvar_5; + tmpvar_7.y = tmpvar_6; + return tmpvar_7; +} + +vec3 xll_mod ( + in vec3 x, + in vec3 y +) +{ + vec3 f; + vec3 d; + vec3 tmpvar_1; + tmpvar_1 = (x / y); + d = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = abs (d); + vec3 tmpvar_3; + tmpvar_3 = fract (tmpvar_2); + vec3 tmpvar_4; + tmpvar_4 = (tmpvar_3 * y); + f = tmpvar_4; + float tmpvar_5; + if ((d.x >= 0.0)) { + tmpvar_5 = f.x; + } else { + tmpvar_5 = -(f.x); + }; + float tmpvar_6; + if ((d.y >= 0.0)) { + tmpvar_6 = f.y; + } else { + tmpvar_6 = -(f.y); + }; + float tmpvar_7; + if ((d.z >= 0.0)) { + tmpvar_7 = f.z; + } else { + tmpvar_7 = -(f.z); + }; + vec3 tmpvar_8; + tmpvar_8.x = tmpvar_5; + tmpvar_8.y = tmpvar_6; + tmpvar_8.z = tmpvar_7; + return tmpvar_8; +} + +vec4 xll_mod ( + in vec4 x, + in vec4 y +) +{ + vec4 f; + vec4 d; + vec4 tmpvar_1; + tmpvar_1 = (x / y); + d = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = abs (d); + vec4 tmpvar_3; + tmpvar_3 = fract (tmpvar_2); + vec4 tmpvar_4; + tmpvar_4 = (tmpvar_3 * y); + f = tmpvar_4; + float tmpvar_5; + if ((d.x >= 0.0)) { + tmpvar_5 = f.x; + } else { + tmpvar_5 = -(f.x); + }; + float tmpvar_6; + if ((d.y >= 0.0)) { + tmpvar_6 = f.y; + } else { + tmpvar_6 = -(f.y); + }; + float tmpvar_7; + if ((d.z >= 0.0)) { + tmpvar_7 = f.z; + } else { + tmpvar_7 = -(f.z); + }; + float tmpvar_8; + if ((d.w >= 0.0)) { + tmpvar_8 = f.w; + } else { + tmpvar_8 = -(f.w); + }; + vec4 tmpvar_9; + tmpvar_9.x = tmpvar_5; + tmpvar_9.y = tmpvar_6; + tmpvar_9.z = tmpvar_7; + tmpvar_9.w = tmpvar_8; + return tmpvar_9; +} + +float xll_modf ( + in float x, + out int ip +) +{ + int tmpvar_1; + tmpvar_1 = int(x); + ip = tmpvar_1; + return (x - float(ip)); +} + +float xll_modf ( + in float x, + out float ip +) +{ + int i; + int tmpvar_1; + tmpvar_1 = int(x); + i = tmpvar_1; + float tmpvar_2; + tmpvar_2 = float(i); + ip = tmpvar_2; + return (x - ip); +} + +vec2 xll_modf ( + in vec2 x, + out ivec2 ip +) +{ + ivec2 tmpvar_1; + tmpvar_1 = ivec2(x).xy; + ivec2 tmpvar_2; + tmpvar_2 = tmpvar_1; + ip = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = vec2(ip).xy; + return (x - tmpvar_3); +} + +vec2 xll_modf ( + in vec2 x, + out vec2 ip +) +{ + ivec2 i; + ivec2 tmpvar_1; + tmpvar_1 = ivec2(x).xy; + ivec2 tmpvar_2; + tmpvar_2 = tmpvar_1; + i = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = vec2(i).xy; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + ip = tmpvar_4; + return (x - ip); +} + +vec3 xll_modf ( + in vec3 x, + out ivec3 ip +) +{ + ivec3 tmpvar_1; + tmpvar_1 = ivec3(x).xyz; + ivec3 tmpvar_2; + tmpvar_2 = tmpvar_1; + ip = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(ip).xyz; + return (x - tmpvar_3); +} + +vec3 xll_modf ( + in vec3 x, + out vec3 ip +) +{ + ivec3 i; + ivec3 tmpvar_1; + tmpvar_1 = ivec3(x).xyz; + ivec3 tmpvar_2; + tmpvar_2 = tmpvar_1; + i = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(i).xyz; + vec3 tmpvar_4; + tmpvar_4 = tmpvar_3; + ip = tmpvar_4; + return (x - ip); +} + +vec4 xll_modf ( + in vec4 x, + out ivec4 ip +) +{ + ivec4 tmpvar_1; + tmpvar_1 = ivec4(x).xyzw; + ivec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + ip = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = vec4(ip).xyzw; + return (x - tmpvar_3); +} + +vec4 xll_modf ( + in vec4 x, + out vec4 ip +) +{ + ivec4 i; + ivec4 tmpvar_1; + tmpvar_1 = ivec4(x).xyzw; + ivec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + i = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = vec4(i).xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + ip = tmpvar_4; + return (x - ip); +} + +mediump vec4 xlat_main ( + in highp vec4 uv +) +{ + mediump vec4 d; + mediump vec4 c; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + c = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xll_mod (uv.x, 2.0); + mediump float tmpvar_3; + tmpvar_3 = (c.x + tmpvar_2); + c.x = tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = xll_mod (uv.xy, vec2(2.0, 2.0)); + mediump vec2 tmpvar_5; + tmpvar_5 = (c.xy + tmpvar_4); + c.xy = tmpvar_5.xy.xy; + vec3 tmpvar_6; + tmpvar_6 = xll_mod (uv.xyz, vec3(2.0, 2.0, 2.0)); + mediump vec3 tmpvar_7; + tmpvar_7 = (c.xyz + tmpvar_6); + c.xyz = tmpvar_7.xyz.xyz; + vec4 tmpvar_8; + tmpvar_8 = xll_mod (uv.xyzw, vec4(2.0, 2.0, 2.0, 2.0)); + mediump vec4 tmpvar_9; + tmpvar_9 = (c.xyzw + tmpvar_8); + c = tmpvar_9.xyzw.xyzw; + float tmpvar_10; + tmpvar_10 = xll_modf (uv.x, d.x); + mediump float tmpvar_11; + tmpvar_11 = (c.x + tmpvar_10); + c.x = tmpvar_11; + vec2 tmpvar_12; + tmpvar_12 = xll_modf (uv.xy, d.xy); + mediump vec2 tmpvar_13; + tmpvar_13 = (c.xy + tmpvar_12); + c.xy = tmpvar_13.xy.xy; + vec3 tmpvar_14; + tmpvar_14 = xll_modf (uv.xyz, d.xyz); + mediump vec3 tmpvar_15; + tmpvar_15 = (c.xyz + tmpvar_14); + c.xyz = tmpvar_15.xyz.xyz; + vec4 tmpvar_16; + tmpvar_16 = xll_modf (uv.xyzw, d.xyzw); + mediump vec4 tmpvar_17; + tmpvar_17 = (c.xyzw + tmpvar_16); + c = tmpvar_17.xyzw.xyzw; + return c; +} + +void main () +{ + mediump vec4 xl_retval; + highp vec4 tmpvar_1; + tmpvar_1 = xlv_TEXCOORD0.xyzw; + mediump vec4 tmpvar_2; + tmpvar_2 = xlat_main (tmpvar_1); + mediump vec4 tmpvar_3; + tmpvar_3 = tmpvar_2; + xl_retval = tmpvar_3; + mediump vec4 tmpvar_4; + tmpvar_4 = xl_retval.xyzw; + mediump vec4 tmpvar_5; + tmpvar_5 = tmpvar_4; + gl_FragData[0] = tmpvar_5; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/intrinsics-out.txt b/3rdparty/glsl-optimizer/tests/fragment/intrinsics-out.txt new file mode 100644 index 000000000..37687485f --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/intrinsics-out.txt @@ -0,0 +1,104 @@ +varying vec4 xlv_TEXCOORD0; +void main () +{ + vec4 c; + c = vec4(0.0, 0.0, 0.0, 0.0); + float tmpvar_1; + tmpvar_1 = (xlv_TEXCOORD0.x / 2.0); + float tmpvar_2; + tmpvar_2 = (fract (abs (tmpvar_1)) * 2.0); + float tmpvar_3; + if ((tmpvar_1 >= 0.0)) { + tmpvar_3 = tmpvar_2; + } else { + tmpvar_3 = -(tmpvar_2); + }; + c.x = tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = (xlv_TEXCOORD0.xy / vec2(2.0, 2.0)); + vec2 tmpvar_5; + tmpvar_5 = (fract (abs (tmpvar_4)) * vec2(2.0, 2.0)); + float tmpvar_6; + if ((tmpvar_4.x >= 0.0)) { + tmpvar_6 = tmpvar_5.x; + } else { + tmpvar_6 = -(tmpvar_5.x); + }; + float tmpvar_7; + if ((tmpvar_4.y >= 0.0)) { + tmpvar_7 = tmpvar_5.y; + } else { + tmpvar_7 = -(tmpvar_5.y); + }; + vec2 tmpvar_8; + tmpvar_8.x = tmpvar_6; + tmpvar_8.y = tmpvar_7; + c.xy = (c.xy + tmpvar_8); + vec3 tmpvar_9; + tmpvar_9 = (xlv_TEXCOORD0.xyz / vec3(2.0, 2.0, 2.0)); + vec3 tmpvar_10; + tmpvar_10 = (fract (abs (tmpvar_9)) * vec3(2.0, 2.0, 2.0)); + float tmpvar_11; + if ((tmpvar_9.x >= 0.0)) { + tmpvar_11 = tmpvar_10.x; + } else { + tmpvar_11 = -(tmpvar_10.x); + }; + float tmpvar_12; + if ((tmpvar_9.y >= 0.0)) { + tmpvar_12 = tmpvar_10.y; + } else { + tmpvar_12 = -(tmpvar_10.y); + }; + float tmpvar_13; + if ((tmpvar_9.z >= 0.0)) { + tmpvar_13 = tmpvar_10.z; + } else { + tmpvar_13 = -(tmpvar_10.z); + }; + vec3 tmpvar_14; + tmpvar_14.x = tmpvar_11; + tmpvar_14.y = tmpvar_12; + tmpvar_14.z = tmpvar_13; + c.xyz = (c.xyz + tmpvar_14); + vec4 tmpvar_15; + tmpvar_15 = (xlv_TEXCOORD0 / vec4(2.0, 2.0, 2.0, 2.0)); + vec4 tmpvar_16; + tmpvar_16 = (fract (abs (tmpvar_15)) * vec4(2.0, 2.0, 2.0, 2.0)); + float tmpvar_17; + if ((tmpvar_15.x >= 0.0)) { + tmpvar_17 = tmpvar_16.x; + } else { + tmpvar_17 = -(tmpvar_16.x); + }; + float tmpvar_18; + if ((tmpvar_15.y >= 0.0)) { + tmpvar_18 = tmpvar_16.y; + } else { + tmpvar_18 = -(tmpvar_16.y); + }; + float tmpvar_19; + if ((tmpvar_15.z >= 0.0)) { + tmpvar_19 = tmpvar_16.z; + } else { + tmpvar_19 = -(tmpvar_16.z); + }; + float tmpvar_20; + if ((tmpvar_15.w >= 0.0)) { + tmpvar_20 = tmpvar_16.w; + } else { + tmpvar_20 = -(tmpvar_16.w); + }; + vec4 tmpvar_21; + tmpvar_21.x = tmpvar_17; + tmpvar_21.y = tmpvar_18; + tmpvar_21.z = tmpvar_19; + tmpvar_21.w = tmpvar_20; + c = (c + tmpvar_21); + c.x = (c.x + (xlv_TEXCOORD0.x - float(int(xlv_TEXCOORD0.x)))); + c.xy = (c.xy + (xlv_TEXCOORD0.xy - vec2(ivec2(xlv_TEXCOORD0.xy)))); + c.xyz = (c.xyz + (xlv_TEXCOORD0.xyz - vec3(ivec3(xlv_TEXCOORD0.xyz)))); + c = (c + (xlv_TEXCOORD0 - vec4(ivec4(xlv_TEXCOORD0)))); + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/intrinsics-outES.txt b/3rdparty/glsl-optimizer/tests/fragment/intrinsics-outES.txt new file mode 100644 index 000000000..14d638f6e --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/intrinsics-outES.txt @@ -0,0 +1,104 @@ +varying highp vec4 xlv_TEXCOORD0; +void main () +{ + mediump vec4 c; + c = vec4(0.0, 0.0, 0.0, 0.0); + float tmpvar_1; + tmpvar_1 = (xlv_TEXCOORD0.x / 2.0); + float tmpvar_2; + tmpvar_2 = (fract (abs (tmpvar_1)) * 2.0); + float tmpvar_3; + if ((tmpvar_1 >= 0.0)) { + tmpvar_3 = tmpvar_2; + } else { + tmpvar_3 = -(tmpvar_2); + }; + c.x = tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = (xlv_TEXCOORD0.xy / vec2(2.0, 2.0)); + vec2 tmpvar_5; + tmpvar_5 = (fract (abs (tmpvar_4)) * vec2(2.0, 2.0)); + float tmpvar_6; + if ((tmpvar_4.x >= 0.0)) { + tmpvar_6 = tmpvar_5.x; + } else { + tmpvar_6 = -(tmpvar_5.x); + }; + float tmpvar_7; + if ((tmpvar_4.y >= 0.0)) { + tmpvar_7 = tmpvar_5.y; + } else { + tmpvar_7 = -(tmpvar_5.y); + }; + vec2 tmpvar_8; + tmpvar_8.x = tmpvar_6; + tmpvar_8.y = tmpvar_7; + c.xy = (c.xy + tmpvar_8); + vec3 tmpvar_9; + tmpvar_9 = (xlv_TEXCOORD0.xyz / vec3(2.0, 2.0, 2.0)); + vec3 tmpvar_10; + tmpvar_10 = (fract (abs (tmpvar_9)) * vec3(2.0, 2.0, 2.0)); + float tmpvar_11; + if ((tmpvar_9.x >= 0.0)) { + tmpvar_11 = tmpvar_10.x; + } else { + tmpvar_11 = -(tmpvar_10.x); + }; + float tmpvar_12; + if ((tmpvar_9.y >= 0.0)) { + tmpvar_12 = tmpvar_10.y; + } else { + tmpvar_12 = -(tmpvar_10.y); + }; + float tmpvar_13; + if ((tmpvar_9.z >= 0.0)) { + tmpvar_13 = tmpvar_10.z; + } else { + tmpvar_13 = -(tmpvar_10.z); + }; + vec3 tmpvar_14; + tmpvar_14.x = tmpvar_11; + tmpvar_14.y = tmpvar_12; + tmpvar_14.z = tmpvar_13; + c.xyz = (c.xyz + tmpvar_14); + vec4 tmpvar_15; + tmpvar_15 = (xlv_TEXCOORD0 / vec4(2.0, 2.0, 2.0, 2.0)); + vec4 tmpvar_16; + tmpvar_16 = (fract (abs (tmpvar_15)) * vec4(2.0, 2.0, 2.0, 2.0)); + float tmpvar_17; + if ((tmpvar_15.x >= 0.0)) { + tmpvar_17 = tmpvar_16.x; + } else { + tmpvar_17 = -(tmpvar_16.x); + }; + float tmpvar_18; + if ((tmpvar_15.y >= 0.0)) { + tmpvar_18 = tmpvar_16.y; + } else { + tmpvar_18 = -(tmpvar_16.y); + }; + float tmpvar_19; + if ((tmpvar_15.z >= 0.0)) { + tmpvar_19 = tmpvar_16.z; + } else { + tmpvar_19 = -(tmpvar_16.z); + }; + float tmpvar_20; + if ((tmpvar_15.w >= 0.0)) { + tmpvar_20 = tmpvar_16.w; + } else { + tmpvar_20 = -(tmpvar_16.w); + }; + vec4 tmpvar_21; + tmpvar_21.x = tmpvar_17; + tmpvar_21.y = tmpvar_18; + tmpvar_21.z = tmpvar_19; + tmpvar_21.w = tmpvar_20; + c = (c + tmpvar_21); + c.x = (c.x + (xlv_TEXCOORD0.x - float(int(xlv_TEXCOORD0.x)))); + c.xy = (c.xy + (xlv_TEXCOORD0.xy - vec2(ivec2(xlv_TEXCOORD0.xy)))); + c.xyz = (c.xyz + (xlv_TEXCOORD0.xyz - vec3(ivec3(xlv_TEXCOORD0.xyz)))); + c = (c + (xlv_TEXCOORD0 - vec4(ivec4(xlv_TEXCOORD0)))); + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/opt-copyprop-struct-in.txt b/3rdparty/glsl-optimizer/tests/fragment/opt-copyprop-struct-in.txt new file mode 100644 index 000000000..1739b9039 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/opt-copyprop-struct-in.txt @@ -0,0 +1,10 @@ +struct v2f { + float f; +}; +varying float var; +void main() { + v2f i; + i.f = var; + v2f i2 = i; + gl_FragColor = vec4(abs(i2.f)); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/opt-copyprop-struct-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/opt-copyprop-struct-ir.txt new file mode 100644 index 000000000..3d084720f --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/opt-copyprop-struct-ir.txt @@ -0,0 +1,23 @@ +struct v2f { + float f; +}; +varying float var; +void main () +{ + v2f i2; + v2f i; + float tmpvar_1; + tmpvar_1 = var; + i.f = tmpvar_1; + v2f tmpvar_2; + tmpvar_2 = i; + i2 = tmpvar_2; + float tmpvar_3; + tmpvar_3 = abs (i2.f); + vec4 tmpvar_4; + tmpvar_4 = vec4(tmpvar_3); + vec4 tmpvar_5; + tmpvar_5 = tmpvar_4; + gl_FragColor = tmpvar_5; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/opt-copyprop-struct-out.txt b/3rdparty/glsl-optimizer/tests/fragment/opt-copyprop-struct-out.txt new file mode 100644 index 000000000..44176a2da --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/opt-copyprop-struct-out.txt @@ -0,0 +1,6 @@ +varying float var; +void main () +{ + gl_FragColor = vec4(abs (var)); +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/opt-copypropelems-swizzle-in.txt b/3rdparty/glsl-optimizer/tests/fragment/opt-copypropelems-swizzle-in.txt new file mode 100644 index 000000000..9ef290bcf --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/opt-copypropelems-swizzle-in.txt @@ -0,0 +1,8 @@ +varying vec2 uv; +uniform sampler2D tex; +void main() { + vec4 v = texture2D (tex, uv); + v.xy = v.yx; + v.x = -v.x; + gl_FragColor = v; +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/opt-copypropelems-swizzle-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/opt-copypropelems-swizzle-ir.txt new file mode 100644 index 000000000..2940c9494 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/opt-copypropelems-swizzle-ir.txt @@ -0,0 +1,21 @@ +uniform sampler2D tex; +varying vec2 uv; +void main () +{ + vec4 v; + vec4 tmpvar_1; + tmpvar_1 = texture2D (tex, uv); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + v = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = v.yx; + v.xy = tmpvar_3.xy.xy; + float tmpvar_4; + tmpvar_4 = -(v.x); + v.x = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = v; + gl_FragColor = tmpvar_5; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/opt-copypropelems-swizzle-out.txt b/3rdparty/glsl-optimizer/tests/fragment/opt-copypropelems-swizzle-out.txt new file mode 100644 index 000000000..077db1b0d --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/opt-copypropelems-swizzle-out.txt @@ -0,0 +1,13 @@ +uniform sampler2D tex; +varying vec2 uv; +void main () +{ + vec4 v; + vec4 tmpvar_1; + tmpvar_1 = texture2D (tex, uv); + v = tmpvar_1; + v.xy = tmpvar_1.yx; + v.x = -(tmpvar_1.y); + gl_FragColor = v; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/opt-deadcode-in.txt b/3rdparty/glsl-optimizer/tests/fragment/opt-deadcode-in.txt new file mode 100644 index 000000000..1c968d66d --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/opt-deadcode-in.txt @@ -0,0 +1,24 @@ +struct v2f { + vec4 pos; + float unusedmember; +}; +void main() { + float f = gl_FragCoord.x; + + v2f sused; + sused.pos = vec4(f); + sused.unusedmember = f*6.0; + v2f sunused; + sunused.pos = vec4(f); + sunused.unusedmember = f*7.0; + + float fused = f*2.0; + float funused = f*3.0; + + float arrused[3]; + arrused[0] = f*4.0; + float arrunused[3]; + arrunused[0] = f*5.0; + + gl_FragColor = vec4(fused+sused.pos.x+arrused[0]); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/opt-deadcode-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/opt-deadcode-ir.txt new file mode 100644 index 000000000..19ef8bad0 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/opt-deadcode-ir.txt @@ -0,0 +1,51 @@ +struct v2f { + vec4 pos; + float unusedmember; +}; +void main () +{ + float arrunused[3]; + float arrused[3]; + float funused; + float fused; + v2f sunused; + v2f sused; + float f; + float tmpvar_1; + tmpvar_1 = gl_FragCoord.x; + f = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = vec4(f); + vec4 tmpvar_3; + tmpvar_3 = tmpvar_2; + sused.pos = tmpvar_3; + float tmpvar_4; + tmpvar_4 = (f * 6.0); + sused.unusedmember = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = vec4(f); + vec4 tmpvar_6; + tmpvar_6 = tmpvar_5; + sunused.pos = tmpvar_6; + float tmpvar_7; + tmpvar_7 = (f * 7.0); + sunused.unusedmember = tmpvar_7; + float tmpvar_8; + tmpvar_8 = (f * 2.0); + fused = tmpvar_8; + float tmpvar_9; + tmpvar_9 = (f * 3.0); + funused = tmpvar_9; + float tmpvar_10; + tmpvar_10 = (f * 4.0); + arrused[0] = tmpvar_10; + float tmpvar_11; + tmpvar_11 = (f * 5.0); + arrunused[0] = tmpvar_11; + vec4 tmpvar_12; + tmpvar_12 = vec4(((fused + sused.pos.x) + arrused[0])); + vec4 tmpvar_13; + tmpvar_13 = tmpvar_12; + gl_FragColor = tmpvar_13; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/opt-deadcode-out.txt b/3rdparty/glsl-optimizer/tests/fragment/opt-deadcode-out.txt new file mode 100644 index 000000000..ed5ce9f25 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/opt-deadcode-out.txt @@ -0,0 +1,7 @@ +void main () +{ + float arrused[3]; + arrused[0] = (gl_FragCoord.x * 4.0); + gl_FragColor = vec4((((gl_FragCoord.x * 2.0) + gl_FragCoord.x) + arrused[0])); +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/opt-deadcodestruct-in.txt b/3rdparty/glsl-optimizer/tests/fragment/opt-deadcodestruct-in.txt new file mode 100644 index 000000000..a2afa10e0 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/opt-deadcodestruct-in.txt @@ -0,0 +1,11 @@ +struct foo { + float used; + float unused; +}; +void main() { + float f = 1.0; + foo s; + s.used = f; + s.unused = f; + gl_FragColor = vec4(s.used); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/opt-deadcodestruct-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/opt-deadcodestruct-ir.txt new file mode 100644 index 000000000..6e200dc4b --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/opt-deadcodestruct-ir.txt @@ -0,0 +1,24 @@ +struct foo { + float used; + float unused; +}; +void main () +{ + foo s; + float f; + float tmpvar_1; + tmpvar_1 = 1.0; + f = tmpvar_1; + float tmpvar_2; + tmpvar_2 = f; + s.used = tmpvar_2; + float tmpvar_3; + tmpvar_3 = f; + s.unused = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = vec4(s.used); + vec4 tmpvar_5; + tmpvar_5 = tmpvar_4; + gl_FragColor = tmpvar_5; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/opt-deadcodestruct-out.txt b/3rdparty/glsl-optimizer/tests/fragment/opt-deadcodestruct-out.txt new file mode 100644 index 000000000..8c6cc4992 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/opt-deadcodestruct-out.txt @@ -0,0 +1,5 @@ +void main () +{ + gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0); +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/opt-grafting-precision-inES.txt b/3rdparty/glsl-optimizer/tests/fragment/opt-grafting-precision-inES.txt new file mode 100644 index 000000000..3a7a3ee33 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/opt-grafting-precision-inES.txt @@ -0,0 +1,13 @@ +varying lowp vec3 normal; +varying lowp vec3 halfDir; +uniform mediump float specPower; + +void main() +{ + lowp float nh = dot (normal, halfDir); + mediump float spec = pow (nh, specPower); + + lowp vec4 c; + c = vec4(spec); + gl_FragColor = c; +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/opt-grafting-precision-irES.txt b/3rdparty/glsl-optimizer/tests/fragment/opt-grafting-precision-irES.txt new file mode 100644 index 000000000..f4fa98964 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/opt-grafting-precision-irES.txt @@ -0,0 +1,28 @@ +uniform mediump float specPower; +varying lowp vec3 halfDir; +varying lowp vec3 normal; +void main () +{ + lowp vec4 c; + mediump float spec; + lowp float nh; + lowp float tmpvar_1; + tmpvar_1 = dot (normal, halfDir); + lowp float tmpvar_2; + tmpvar_2 = tmpvar_1; + nh = tmpvar_2; + mediump float tmpvar_3; + tmpvar_3 = pow (nh, specPower); + mediump float tmpvar_4; + tmpvar_4 = tmpvar_3; + spec = tmpvar_4; + mediump vec4 tmpvar_5; + tmpvar_5 = vec4(spec); + mediump vec4 tmpvar_6; + tmpvar_6 = tmpvar_5; + c = tmpvar_6; + lowp vec4 tmpvar_7; + tmpvar_7 = c; + gl_FragColor = tmpvar_7; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/opt-grafting-precision-outES.txt b/3rdparty/glsl-optimizer/tests/fragment/opt-grafting-precision-outES.txt new file mode 100644 index 000000000..a4a8dbd3a --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/opt-grafting-precision-outES.txt @@ -0,0 +1,14 @@ +uniform mediump float specPower; +varying lowp vec3 halfDir; +varying lowp vec3 normal; +void main () +{ + lowp vec4 c; + lowp float tmpvar_1; + tmpvar_1 = dot (normal, halfDir); + mediump vec4 tmpvar_2; + tmpvar_2 = vec4(pow (tmpvar_1, specPower)); + c = tmpvar_2; + gl_FragColor = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/opt-inline-inoutstruct-in.txt b/3rdparty/glsl-optimizer/tests/fragment/opt-inline-inoutstruct-in.txt new file mode 100644 index 000000000..eff6bfbd9 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/opt-inline-inoutstruct-in.txt @@ -0,0 +1,11 @@ +struct SurfaceOutput { + vec4 color; +}; +void surf(inout SurfaceOutput o) { + o.color = vec4(1); +} +void main() { + SurfaceOutput o; + surf(o); + gl_FragColor = o.color; +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/opt-inline-inoutstruct-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/opt-inline-inoutstruct-ir.txt new file mode 100644 index 000000000..f8c5755c4 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/opt-inline-inoutstruct-ir.txt @@ -0,0 +1,21 @@ +struct SurfaceOutput { + vec4 color; +}; +void surf ( + inout SurfaceOutput o +) +{ + vec4 tmpvar_1; + tmpvar_1 = vec4(1.0, 1.0, 1.0, 1.0); + o.color = tmpvar_1; +} + +void main () +{ + SurfaceOutput o; + surf (o); + vec4 tmpvar_1; + tmpvar_1 = o.color; + gl_FragColor = tmpvar_1; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/opt-inline-inoutstruct-out.txt b/3rdparty/glsl-optimizer/tests/fragment/opt-inline-inoutstruct-out.txt new file mode 100644 index 000000000..8c6cc4992 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/opt-inline-inoutstruct-out.txt @@ -0,0 +1,5 @@ +void main () +{ + gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0); +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/opt-vec-var-index-in.txt b/3rdparty/glsl-optimizer/tests/fragment/opt-vec-var-index-in.txt new file mode 100644 index 000000000..d443d2d04 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/opt-vec-var-index-in.txt @@ -0,0 +1,7 @@ +void main() { + vec2 c = vec2(0.0); + for (int j = 0; j < 2; ++j) { + c += abs (vec2(vec2(0.0)[j])); + } + gl_FragColor = vec4(c,0.0,0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/opt-vec-var-index-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/opt-vec-var-index-ir.txt new file mode 100644 index 000000000..90cfb8c6c --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/opt-vec-var-index-ir.txt @@ -0,0 +1,33 @@ +void main () +{ + int j; + vec2 c; + vec2 tmpvar_1; + tmpvar_1 = vec2(0.0, 0.0); + c = tmpvar_1; + int tmpvar_2; + tmpvar_2 = 0; + j = tmpvar_2; + while (true) { + if (!((j < 2))) { + break; + }; + vec2 tmpvar_3; + tmpvar_3 = vec2(vec2(0.0, 0.0)[j]); + vec2 tmpvar_4; + tmpvar_4 = abs (tmpvar_3); + vec2 tmpvar_5; + tmpvar_5 = (c + tmpvar_4); + c = tmpvar_5; + int tmpvar_6; + tmpvar_6 = (j + 1); + j = tmpvar_6; + }; + vec4 tmpvar_7; + tmpvar_7.zw = vec2(0.0, 0.0); + tmpvar_7.xy = c.xy; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + gl_FragColor = tmpvar_8; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/opt-vec-var-index-out.txt b/3rdparty/glsl-optimizer/tests/fragment/opt-vec-var-index-out.txt new file mode 100644 index 000000000..a87465638 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/opt-vec-var-index-out.txt @@ -0,0 +1,8 @@ +void main () +{ + vec4 tmpvar_1; + tmpvar_1.zw = vec2(0.0, 0.0); + tmpvar_1.xy = vec2(0.0, 0.0); + gl_FragColor = tmpvar_1; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/pp-basic-in.txt b/3rdparty/glsl-optimizer/tests/fragment/pp-basic-in.txt new file mode 100644 index 000000000..975ea8da1 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/pp-basic-in.txt @@ -0,0 +1,17 @@ +#define FRAGMENT + +#ifdef VERTEX +foo bar baz +#endif + +#ifdef FRAGMENT +vec4 xlat_main () { + return vec4(1.0); +} +#endif + +void main() { + vec4 xl_retval; + xl_retval = xlat_main(); + gl_FragData[0] = vec4(xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/pp-basic-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/pp-basic-ir.txt new file mode 100644 index 000000000..c1fbea114 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/pp-basic-ir.txt @@ -0,0 +1,20 @@ +vec4 xlat_main () +{ + return vec4(1.0, 1.0, 1.0, 1.0); +} + +void main () +{ + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = xlat_main (); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xl_retval = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = xl_retval.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + gl_FragData[0] = tmpvar_4; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/pp-basic-out.txt b/3rdparty/glsl-optimizer/tests/fragment/pp-basic-out.txt new file mode 100644 index 000000000..c41789ad6 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/pp-basic-out.txt @@ -0,0 +1,5 @@ +void main () +{ + gl_FragData[0] = vec4(1.0, 1.0, 1.0, 1.0); +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/prec-inlineexpr1-inES.txt b/3rdparty/glsl-optimizer/tests/fragment/prec-inlineexpr1-inES.txt new file mode 100644 index 000000000..423f9bd6a --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/prec-inlineexpr1-inES.txt @@ -0,0 +1,21 @@ +float xll_saturate(float x) { + return clamp(x, 0.0, 1.0); +} +vec3 xll_saturate(vec3 x) { + return clamp(x, 0.0, 1.0); +} +uniform sampler2D _MainTex; +uniform sampler2D _BurntTex; +uniform mediump float _EmberFadeEnd; +uniform mediump float _EmberFadeStart; +lowp vec4 frag (mediump vec2 uv) { + lowp vec3 base = texture2D(_MainTex, uv).xyz; + lowp vec3 burn = texture2D(_BurntTex, uv).xyz; + lowp float t; + t = xll_saturate( ((_EmberFadeStart - 0.05) / (_EmberFadeStart - _EmberFadeEnd)) ); + return vec4(mix(base, burn, vec3(t)), 1.0); +} +varying mediump vec2 xlv_TEXCOORD0; +void main() { + gl_FragColor = frag(xlv_TEXCOORD0); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/prec-inlineexpr1-irES.txt b/3rdparty/glsl-optimizer/tests/fragment/prec-inlineexpr1-irES.txt new file mode 100644 index 000000000..3660e17ab --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/prec-inlineexpr1-irES.txt @@ -0,0 +1,64 @@ +varying mediump vec2 xlv_TEXCOORD0; +uniform mediump float _EmberFadeStart; +uniform mediump float _EmberFadeEnd; +uniform sampler2D _BurntTex; +uniform sampler2D _MainTex; +float xll_saturate ( + in float x +) +{ + float tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec3 xll_saturate ( + in vec3 x +) +{ + vec3 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +lowp vec4 frag ( + in mediump vec2 uv +) +{ + lowp float t; + lowp vec3 burn; + lowp vec3 base; + lowp vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, uv); + lowp vec3 tmpvar_2; + tmpvar_2 = tmpvar_1.xyz; + base = tmpvar_2; + lowp vec4 tmpvar_3; + tmpvar_3 = texture2D (_BurntTex, uv); + lowp vec3 tmpvar_4; + tmpvar_4 = tmpvar_3.xyz; + burn = tmpvar_4; + float tmpvar_5; + tmpvar_5 = xll_saturate (((_EmberFadeStart - 0.05) / (_EmberFadeStart - _EmberFadeEnd))); + float tmpvar_6; + tmpvar_6 = tmpvar_5; + t = tmpvar_6; + lowp vec3 tmpvar_7; + tmpvar_7 = vec3(t); + lowp vec3 tmpvar_8; + tmpvar_8 = mix (base, burn, tmpvar_7); + lowp vec4 tmpvar_9; + tmpvar_9.w = 1.0; + tmpvar_9.xyz = tmpvar_8.xyz; + return tmpvar_9; +} + +void main () +{ + lowp vec4 tmpvar_1; + tmpvar_1 = frag (xlv_TEXCOORD0); + lowp vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + gl_FragColor = tmpvar_2; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/prec-inlineexpr1-outES.txt b/3rdparty/glsl-optimizer/tests/fragment/prec-inlineexpr1-outES.txt new file mode 100644 index 000000000..59cc75b0f --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/prec-inlineexpr1-outES.txt @@ -0,0 +1,17 @@ +varying mediump vec2 xlv_TEXCOORD0; +uniform mediump float _EmberFadeStart; +uniform mediump float _EmberFadeEnd; +uniform sampler2D _BurntTex; +uniform sampler2D _MainTex; +void main () +{ + lowp float t; + mediump float tmpvar_1; + tmpvar_1 = clamp (((_EmberFadeStart - 0.05) / (_EmberFadeStart - _EmberFadeEnd)), 0.0, 1.0); + t = tmpvar_1; + lowp vec4 tmpvar_2; + tmpvar_2.w = 1.0; + tmpvar_2.xyz = mix (texture2D (_MainTex, xlv_TEXCOORD0).xyz, texture2D (_BurntTex, xlv_TEXCOORD0).xyz, vec3(t)); + gl_FragColor = tmpvar_2; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/prec-inlineexpr2-inES.txt b/3rdparty/glsl-optimizer/tests/fragment/prec-inlineexpr2-inES.txt new file mode 100644 index 000000000..5edf9d2da --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/prec-inlineexpr2-inES.txt @@ -0,0 +1,21 @@ +float xll_saturate(float x) { + return clamp(x, 0.0, 1.0); +} +vec3 xll_saturate(vec3 x) { + return clamp(x, 0.0, 1.0); +} +uniform sampler2D _MainTex; +uniform sampler2D _BurntTex; +uniform mediump float _EmberFadeEnd; +uniform mediump float _EmberFadeStart; +lowp vec4 frag (mediump vec2 uv) { + lowp vec3 base = texture2D(_MainTex, uv).xyz; + lowp vec3 burn = texture2D(_BurntTex, uv).xyz; + lowp vec3 t; + t = vec3( xll_saturate( ((_EmberFadeStart - 0.05) / (_EmberFadeStart - _EmberFadeEnd)) ) ); + return vec4(mix(base, burn, t), 1.0); +} +varying mediump vec2 xlv_TEXCOORD0; +void main() { + gl_FragColor = frag(xlv_TEXCOORD0); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/prec-inlineexpr2-irES.txt b/3rdparty/glsl-optimizer/tests/fragment/prec-inlineexpr2-irES.txt new file mode 100644 index 000000000..050ae72bb --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/prec-inlineexpr2-irES.txt @@ -0,0 +1,64 @@ +varying mediump vec2 xlv_TEXCOORD0; +uniform mediump float _EmberFadeStart; +uniform mediump float _EmberFadeEnd; +uniform sampler2D _BurntTex; +uniform sampler2D _MainTex; +float xll_saturate ( + in float x +) +{ + float tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec3 xll_saturate ( + in vec3 x +) +{ + vec3 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +lowp vec4 frag ( + in mediump vec2 uv +) +{ + lowp vec3 t; + lowp vec3 burn; + lowp vec3 base; + lowp vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, uv); + lowp vec3 tmpvar_2; + tmpvar_2 = tmpvar_1.xyz; + base = tmpvar_2; + lowp vec4 tmpvar_3; + tmpvar_3 = texture2D (_BurntTex, uv); + lowp vec3 tmpvar_4; + tmpvar_4 = tmpvar_3.xyz; + burn = tmpvar_4; + float tmpvar_5; + tmpvar_5 = xll_saturate (((_EmberFadeStart - 0.05) / (_EmberFadeStart - _EmberFadeEnd))); + vec3 tmpvar_6; + tmpvar_6 = vec3(tmpvar_5); + vec3 tmpvar_7; + tmpvar_7 = tmpvar_6; + t = tmpvar_7; + lowp vec3 tmpvar_8; + tmpvar_8 = mix (base, burn, t); + lowp vec4 tmpvar_9; + tmpvar_9.w = 1.0; + tmpvar_9.xyz = tmpvar_8.xyz; + return tmpvar_9; +} + +void main () +{ + lowp vec4 tmpvar_1; + tmpvar_1 = frag (xlv_TEXCOORD0); + lowp vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + gl_FragColor = tmpvar_2; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/prec-inlineexpr2-outES.txt b/3rdparty/glsl-optimizer/tests/fragment/prec-inlineexpr2-outES.txt new file mode 100644 index 000000000..e919368b5 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/prec-inlineexpr2-outES.txt @@ -0,0 +1,17 @@ +varying mediump vec2 xlv_TEXCOORD0; +uniform mediump float _EmberFadeStart; +uniform mediump float _EmberFadeEnd; +uniform sampler2D _BurntTex; +uniform sampler2D _MainTex; +void main () +{ + lowp vec3 t; + mediump vec3 tmpvar_1; + tmpvar_1 = vec3(clamp (((_EmberFadeStart - 0.05) / (_EmberFadeStart - _EmberFadeEnd)), 0.0, 1.0)); + t = tmpvar_1; + lowp vec4 tmpvar_2; + tmpvar_2.w = 1.0; + tmpvar_2.xyz = mix (texture2D (_MainTex, xlv_TEXCOORD0).xyz, texture2D (_BurntTex, xlv_TEXCOORD0).xyz, t); + gl_FragColor = tmpvar_2; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/prec-temps-inES.txt b/3rdparty/glsl-optimizer/tests/fragment/prec-temps-inES.txt new file mode 100644 index 000000000..5e3a5fba3 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/prec-temps-inES.txt @@ -0,0 +1,42 @@ +struct v2f_surf { + highp vec4 pos; + lowp vec2 pack0; + lowp vec3 halfDir; + lowp vec3 lightDir; + lowp vec3 vlight; +}; +uniform sampler2D _BumpMap; +uniform lowp vec4 _LightColor0; +uniform sampler2D _MainTex; +uniform lowp float _Shininess; +lowp vec4 frag_surf (in v2f_surf IN) { + lowp vec4 tex; + lowp vec3 Normal; + lowp float diff; + lowp float nh; + lowp float spec; + lowp vec4 c; + tex = texture2D (_MainTex, IN.pack0); + Normal = (texture2D( _BumpMap, IN.pack0).xyz * 2.0) - 1.0; + diff = max (0.0, dot(Normal, IN.lightDir)); + nh = max (0.0, dot(Normal, IN.halfDir)); + spec = pow(nh, _Shininess) * tex.w; + c.xyz = ((vec3(tex) * ((_LightColor0.xyz * diff) + IN.vlight)) + (_LightColor0.xyz * spec)); + c.w = 0.00000; + return c; +} +varying lowp vec2 xlv_TEXCOORD0; +varying lowp vec3 xlv_TEXCOORD1; +varying lowp vec3 xlv_TEXCOORD2; +varying lowp vec3 xlv_TEXCOORD3; +void main() { + lowp vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.pack0 = vec2(xlv_TEXCOORD0); + xlt_IN.halfDir = vec3(xlv_TEXCOORD1); + xlt_IN.lightDir = vec3(xlv_TEXCOORD2); + xlt_IN.vlight = vec3(xlv_TEXCOORD3); + xl_retval = frag_surf(xlt_IN); + gl_FragData[0] = vec4(xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/prec-temps-irES.txt b/3rdparty/glsl-optimizer/tests/fragment/prec-temps-irES.txt new file mode 100644 index 000000000..752e7b99e --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/prec-temps-irES.txt @@ -0,0 +1,104 @@ +struct v2f_surf { + highp vec4 pos; + lowp vec2 pack0; + lowp vec3 halfDir; + lowp vec3 lightDir; + lowp vec3 vlight; +}; +varying lowp vec3 xlv_TEXCOORD3; +varying lowp vec3 xlv_TEXCOORD2; +varying lowp vec3 xlv_TEXCOORD1; +varying lowp vec2 xlv_TEXCOORD0; +uniform lowp float _Shininess; +uniform sampler2D _MainTex; +uniform lowp vec4 _LightColor0; +uniform sampler2D _BumpMap; +lowp vec4 frag_surf ( + in v2f_surf IN +) +{ + lowp vec4 c; + lowp float spec; + lowp float nh; + lowp float diff; + lowp vec3 Normal; + lowp vec4 tex; + lowp vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.pack0); + lowp vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + tex = tmpvar_2; + lowp vec4 tmpvar_3; + tmpvar_3 = texture2D (_BumpMap, IN.pack0); + lowp vec3 tmpvar_4; + tmpvar_4 = ((tmpvar_3.xyz * 2.0) - 1.0); + Normal = tmpvar_4; + lowp float tmpvar_5; + tmpvar_5 = dot (Normal, IN.lightDir); + lowp float tmpvar_6; + tmpvar_6 = max (0.0, tmpvar_5); + lowp float tmpvar_7; + tmpvar_7 = tmpvar_6; + diff = tmpvar_7; + lowp float tmpvar_8; + tmpvar_8 = dot (Normal, IN.halfDir); + lowp float tmpvar_9; + tmpvar_9 = max (0.0, tmpvar_8); + lowp float tmpvar_10; + tmpvar_10 = tmpvar_9; + nh = tmpvar_10; + lowp float tmpvar_11; + tmpvar_11 = pow (nh, _Shininess); + lowp float tmpvar_12; + tmpvar_12 = (tmpvar_11 * tex.w); + spec = tmpvar_12; + lowp vec3 tmpvar_13; + tmpvar_13 = tex.xyz; + lowp vec3 tmpvar_14; + tmpvar_14 = ((tmpvar_13 * ((_LightColor0.xyz * diff) + IN.vlight)) + (_LightColor0.xyz * spec)); + c.xyz = tmpvar_14.xyz.xyz; + float tmpvar_15; + tmpvar_15 = 0.0; + c.w = vec4(tmpvar_15).w; + return c; +} + +void main () +{ + v2f_surf xlt_IN; + lowp vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + lowp vec2 tmpvar_2; + tmpvar_2 = xlv_TEXCOORD0.xy; + lowp vec2 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_IN.pack0 = tmpvar_3; + lowp vec3 tmpvar_4; + tmpvar_4 = xlv_TEXCOORD1.xyz; + lowp vec3 tmpvar_5; + tmpvar_5 = tmpvar_4; + xlt_IN.halfDir = tmpvar_5; + lowp vec3 tmpvar_6; + tmpvar_6 = xlv_TEXCOORD2.xyz; + lowp vec3 tmpvar_7; + tmpvar_7 = tmpvar_6; + xlt_IN.lightDir = tmpvar_7; + lowp vec3 tmpvar_8; + tmpvar_8 = xlv_TEXCOORD3.xyz; + lowp vec3 tmpvar_9; + tmpvar_9 = tmpvar_8; + xlt_IN.vlight = tmpvar_9; + lowp vec4 tmpvar_10; + tmpvar_10 = frag_surf (xlt_IN); + lowp vec4 tmpvar_11; + tmpvar_11 = tmpvar_10; + xl_retval = tmpvar_11; + lowp vec4 tmpvar_12; + tmpvar_12 = xl_retval.xyzw; + lowp vec4 tmpvar_13; + tmpvar_13 = tmpvar_12; + gl_FragData[0] = tmpvar_13; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/prec-temps-outES.txt b/3rdparty/glsl-optimizer/tests/fragment/prec-temps-outES.txt new file mode 100644 index 000000000..dade24c6b --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/prec-temps-outES.txt @@ -0,0 +1,20 @@ +varying lowp vec3 xlv_TEXCOORD3; +varying lowp vec3 xlv_TEXCOORD2; +varying lowp vec3 xlv_TEXCOORD1; +varying lowp vec2 xlv_TEXCOORD0; +uniform lowp float _Shininess; +uniform sampler2D _MainTex; +uniform lowp vec4 _LightColor0; +uniform sampler2D _BumpMap; +void main () +{ + lowp vec4 c; + lowp vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, xlv_TEXCOORD0); + lowp vec3 tmpvar_2; + tmpvar_2 = ((texture2D (_BumpMap, xlv_TEXCOORD0).xyz * 2.0) - 1.0); + c.xyz = ((tmpvar_1.xyz * ((_LightColor0.xyz * max (0.0, dot (tmpvar_2, xlv_TEXCOORD2))) + xlv_TEXCOORD3)) + (_LightColor0.xyz * (pow (max (0.0, dot (tmpvar_2, xlv_TEXCOORD1)), _Shininess) * tmpvar_1.w))); + c.w = 0.0; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/prec-tempssimple-inES.txt b/3rdparty/glsl-optimizer/tests/fragment/prec-tempssimple-inES.txt new file mode 100644 index 000000000..b52e1fc4b --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/prec-tempssimple-inES.txt @@ -0,0 +1,21 @@ +uniform sampler2D tex_def; +uniform lowp sampler2D tex_lowp; +uniform highp sampler2D tex_highp; +varying lowp vec2 var_lowp; +varying mediump vec2 var_mediump; +void main() +{ + lowp vec4 c1; + c1 = texture2D (tex_def, var_lowp) * 2.0; + lowp vec4 c2; + c2 = texture2D (tex_def, var_mediump) * 2.0; + lowp vec4 c3; + c3 = texture2D (tex_highp, var_mediump) * 2.0; + lowp vec4 c4; + c4 = texture2D (tex_lowp, var_mediump) * 2.0; + + lowp vec4 a1; + a1 = abs(var_lowp.xxxx); + + gl_FragColor = c1 + c2 + c3 + c4 + a1; +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/prec-tempssimple-irES.txt b/3rdparty/glsl-optimizer/tests/fragment/prec-tempssimple-irES.txt new file mode 100644 index 000000000..f89e964c0 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/prec-tempssimple-irES.txt @@ -0,0 +1,42 @@ +varying mediump vec2 var_mediump; +varying lowp vec2 var_lowp; +uniform sampler2D tex_highp; +uniform sampler2D tex_lowp; +uniform sampler2D tex_def; +void main () +{ + lowp vec4 a1; + lowp vec4 c4; + lowp vec4 c3; + lowp vec4 c2; + lowp vec4 c1; + lowp vec4 tmpvar_1; + tmpvar_1 = texture2D (tex_def, var_lowp); + lowp vec4 tmpvar_2; + tmpvar_2 = (tmpvar_1 * 2.0); + c1 = tmpvar_2; + lowp vec4 tmpvar_3; + tmpvar_3 = texture2D (tex_def, var_mediump); + lowp vec4 tmpvar_4; + tmpvar_4 = (tmpvar_3 * 2.0); + c2 = tmpvar_4; + highp vec4 tmpvar_5; + tmpvar_5 = texture2D (tex_highp, var_mediump); + highp vec4 tmpvar_6; + tmpvar_6 = (tmpvar_5 * 2.0); + c3 = tmpvar_6; + lowp vec4 tmpvar_7; + tmpvar_7 = texture2D (tex_lowp, var_mediump); + lowp vec4 tmpvar_8; + tmpvar_8 = (tmpvar_7 * 2.0); + c4 = tmpvar_8; + lowp vec4 tmpvar_9; + tmpvar_9 = abs (var_lowp.xxxx); + lowp vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + a1 = tmpvar_10; + lowp vec4 tmpvar_11; + tmpvar_11 = ((((c1 + c2) + c3) + c4) + a1); + gl_FragColor = tmpvar_11; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/prec-tempssimple-outES.txt b/3rdparty/glsl-optimizer/tests/fragment/prec-tempssimple-outES.txt new file mode 100644 index 000000000..48acf3849 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/prec-tempssimple-outES.txt @@ -0,0 +1,14 @@ +varying mediump vec2 var_mediump; +varying lowp vec2 var_lowp; +uniform sampler2D tex_highp; +uniform sampler2D tex_lowp; +uniform sampler2D tex_def; +void main () +{ + lowp vec4 c3; + highp vec4 tmpvar_1; + tmpvar_1 = (texture2D (tex_highp, var_mediump) * 2.0); + c3 = tmpvar_1; + gl_FragColor = (((((texture2D (tex_def, var_lowp) * 2.0) + (texture2D (tex_def, var_mediump) * 2.0)) + c3) + (texture2D (tex_lowp, var_mediump) * 2.0)) + abs (var_lowp.xxxx)); +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/struct-array-var-index-in.txt b/3rdparty/glsl-optimizer/tests/fragment/struct-array-var-index-in.txt new file mode 100644 index 000000000..3925ecd1d --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/struct-array-var-index-in.txt @@ -0,0 +1,9 @@ +struct str { + float params[3]; +}; +void main() { + str s; + for (int i = 0; i < 3; ++i) + s.params[i] = 1.0; + gl_FragColor = vec4(0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/struct-array-var-index-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/struct-array-var-index-ir.txt new file mode 100644 index 000000000..1d2736ed5 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/struct-array-var-index-ir.txt @@ -0,0 +1,26 @@ +struct str { + float params[3]; +}; +void main () +{ + int i; + str s; + int tmpvar_1; + tmpvar_1 = 0; + i = tmpvar_1; + while (true) { + if (!((i < 3))) { + break; + }; + float tmpvar_2; + tmpvar_2 = 1.0; + s.params[i] = tmpvar_2; + int tmpvar_3; + tmpvar_3 = (i + 1); + i = tmpvar_3; + }; + vec4 tmpvar_4; + tmpvar_4 = vec4(0.0, 0.0, 0.0, 0.0); + gl_FragColor = tmpvar_4; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/struct-array-var-index-out.txt b/3rdparty/glsl-optimizer/tests/fragment/struct-array-var-index-out.txt new file mode 100644 index 000000000..78deab76f --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/struct-array-var-index-out.txt @@ -0,0 +1,5 @@ +void main () +{ + gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0); +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/struct-unused-in.txt b/3rdparty/glsl-optimizer/tests/fragment/struct-unused-in.txt new file mode 100644 index 000000000..bc6ffdc1e --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/struct-unused-in.txt @@ -0,0 +1,7 @@ +struct SurfaceOutput { + vec4 color; +}; +void main() { + SurfaceOutput o; + gl_FragColor = vec4(0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/struct-unused-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/struct-unused-ir.txt new file mode 100644 index 000000000..2dd30148c --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/struct-unused-ir.txt @@ -0,0 +1,11 @@ +struct SurfaceOutput { + vec4 color; +}; +void main () +{ + SurfaceOutput o; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + gl_FragColor = tmpvar_1; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/struct-unused-out.txt b/3rdparty/glsl-optimizer/tests/fragment/struct-unused-out.txt new file mode 100644 index 000000000..78deab76f --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/struct-unused-out.txt @@ -0,0 +1,5 @@ +void main () +{ + gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0); +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/swizzle-writemask-in.txt b/3rdparty/glsl-optimizer/tests/fragment/swizzle-writemask-in.txt new file mode 100644 index 000000000..22638a2ca --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/swizzle-writemask-in.txt @@ -0,0 +1,6 @@ +void main () { + vec4 c; + c.x = dot (gl_FragCoord.xyz, vec3(1.0, 2.0, 3.0)); + c.yzw = vec3(4.0,5.0,6.0); + gl_FragColor = c; +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/swizzle-writemask-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/swizzle-writemask-ir.txt new file mode 100644 index 000000000..c5c9a301c --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/swizzle-writemask-ir.txt @@ -0,0 +1,16 @@ +void main () +{ + vec4 c; + float tmpvar_1; + tmpvar_1 = dot (gl_FragCoord.xyz, vec3(1.0, 2.0, 3.0)); + float tmpvar_2; + tmpvar_2 = tmpvar_1; + c.x = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(4.0, 5.0, 6.0); + c.yzw = tmpvar_3.xxyz.yzw; + vec4 tmpvar_4; + tmpvar_4 = c; + gl_FragColor = tmpvar_4; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/swizzle-writemask-out.txt b/3rdparty/glsl-optimizer/tests/fragment/swizzle-writemask-out.txt new file mode 100644 index 000000000..471605a4f --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/swizzle-writemask-out.txt @@ -0,0 +1,8 @@ +void main () +{ + vec4 c; + c.x = dot (gl_FragCoord.xyz, vec3(1.0, 2.0, 3.0)); + c.yzw = vec3(4.0, 5.0, 6.0); + gl_FragColor = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/syntax-inES.txt b/3rdparty/glsl-optimizer/tests/fragment/syntax-inES.txt new file mode 100644 index 000000000..21852db5c --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/syntax-inES.txt @@ -0,0 +1,15 @@ +mediump vec4 xlat_main( ); +mediump vec4 xlat_main( ) { + highp float foo = 1.00000; + foo += 1.00000; + foo += 100000.; + foo += -0.00100000; + foo += 2.00000; + foo += 3.00000; + return vec4( foo); +} +void main() { + mediump vec4 xl_retval; + xl_retval = xlat_main( ); + gl_FragData[0] = mediump vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/syntax-irES.txt b/3rdparty/glsl-optimizer/tests/fragment/syntax-irES.txt new file mode 100644 index 000000000..78376583c --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/syntax-irES.txt @@ -0,0 +1,41 @@ +mediump vec4 xlat_main () +{ + highp float foo; + float tmpvar_1; + tmpvar_1 = 1.0; + foo = tmpvar_1; + highp float tmpvar_2; + tmpvar_2 = (foo + 1.0); + foo = tmpvar_2; + highp float tmpvar_3; + tmpvar_3 = (foo + 100000.0); + foo = tmpvar_3; + highp float tmpvar_4; + tmpvar_4 = (foo + -(0.001)); + foo = tmpvar_4; + highp float tmpvar_5; + tmpvar_5 = (foo + 2.0); + foo = tmpvar_5; + highp float tmpvar_6; + tmpvar_6 = (foo + 3.0); + foo = tmpvar_6; + highp vec4 tmpvar_7; + tmpvar_7 = vec4(foo); + return tmpvar_7; +} + +void main () +{ + mediump vec4 xl_retval; + mediump vec4 tmpvar_1; + tmpvar_1 = xlat_main (); + mediump vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xl_retval = tmpvar_2; + mediump vec4 tmpvar_3; + tmpvar_3 = xl_retval.xyzw; + mediump vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + gl_FragData[0] = tmpvar_4; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/syntax-outES.txt b/3rdparty/glsl-optimizer/tests/fragment/syntax-outES.txt new file mode 100644 index 000000000..ee9713d03 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/syntax-outES.txt @@ -0,0 +1,5 @@ +void main () +{ + gl_FragData[0] = vec4(100007.0, 100007.0, 100007.0, 100007.0); +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/ternary-in.txt b/3rdparty/glsl-optimizer/tests/fragment/ternary-in.txt new file mode 100644 index 000000000..4befc28c4 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/ternary-in.txt @@ -0,0 +1,17 @@ +vec4 xlat_main( in vec4 uv ); +vec4 xlat_main( in vec4 uv ) { + vec4 c; + c = vec4( 0.000000); + c += ( (uv.x > 0.500000) ) ? ( 0.900000 ) : ( 0.100000 ); + c += ( (uv.x > 0.500000) ) ? ( vec4( 0.900000, 0.900000, 0.900000, 0.900000) ) : ( vec4( 0.100000, 0.100000, 0.100000, 0.100000) ); + c.xyz += ( (uv.x > 0.500000) ) ? ( vec3( 0.900000, 0.900000, 0.900000) ) : ( vec3( 0.100000, 0.100000, 0.100000) ); + c.xy += ( (uv.x > 0.500000) ) ? ( vec2( 0.900000, 0.900000) ) : ( vec2( 0.100000, 0.100000) ); + c.x += ( bool( fract( uv.x ) ) ) ? ( 0.900000 ) : ( 0.100000 ); + return c; +} +varying vec4 xlv_TEXCOORD0; +void main() { + vec4 xl_retval; + xl_retval = xlat_main( vec4(xlv_TEXCOORD0)); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/ternary-inES.txt b/3rdparty/glsl-optimizer/tests/fragment/ternary-inES.txt new file mode 100644 index 000000000..1e8e8ad72 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/ternary-inES.txt @@ -0,0 +1,17 @@ +mediump vec4 xlat_main( in highp vec4 uv ); +mediump vec4 xlat_main( in highp vec4 uv ) { + mediump vec4 c; + c = vec4( 0.000000); + c += ( (uv.x > 0.500000) ) ? ( 0.900000 ) : ( 0.100000 ); + c += ( (uv.x > 0.500000) ) ? ( highp vec4( 0.900000, 0.900000, 0.900000, 0.900000) ) : ( highp vec4( 0.100000, 0.100000, 0.100000, 0.100000) ); + c.xyz += ( (uv.x > 0.500000) ) ? ( highp vec3( 0.900000, 0.900000, 0.900000) ) : ( highp vec3( 0.100000, 0.100000, 0.100000) ); + c.xy += ( (uv.x > 0.500000) ) ? ( highp vec2( 0.900000, 0.900000) ) : ( highp vec2( 0.100000, 0.100000) ); + c.x += ( bool( fract( uv.x ) ) ) ? ( 0.900000 ) : ( 0.100000 ); + return c; +} +varying highp vec4 xlv_TEXCOORD0; +void main() { + mediump vec4 xl_retval; + xl_retval = xlat_main( highp vec4(xlv_TEXCOORD0)); + gl_FragData[0] = mediump vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/ternary-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/ternary-ir.txt new file mode 100644 index 000000000..fbfb3e879 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/ternary-ir.txt @@ -0,0 +1,76 @@ +varying vec4 xlv_TEXCOORD0; +vec4 xlat_main ( + in vec4 uv +) +{ + vec4 c; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + c = tmpvar_1; + float tmpvar_2; + if ((uv.x > 0.5)) { + tmpvar_2 = 0.9; + } else { + tmpvar_2 = 0.1; + }; + vec4 tmpvar_3; + tmpvar_3 = (c + tmpvar_2); + c = tmpvar_3; + vec4 tmpvar_4; + if ((uv.x > 0.5)) { + tmpvar_4 = vec4(0.9, 0.9, 0.9, 0.9); + } else { + tmpvar_4 = vec4(0.1, 0.1, 0.1, 0.1); + }; + vec4 tmpvar_5; + tmpvar_5 = (c + tmpvar_4); + c = tmpvar_5; + vec3 tmpvar_6; + if ((uv.x > 0.5)) { + tmpvar_6 = vec3(0.9, 0.9, 0.9); + } else { + tmpvar_6 = vec3(0.1, 0.1, 0.1); + }; + vec3 tmpvar_7; + tmpvar_7 = (c.xyz + tmpvar_6); + c.xyz = tmpvar_7.xyz.xyz; + vec2 tmpvar_8; + if ((uv.x > 0.5)) { + tmpvar_8 = vec2(0.9, 0.9); + } else { + tmpvar_8 = vec2(0.1, 0.1); + }; + vec2 tmpvar_9; + tmpvar_9 = (c.xy + tmpvar_8); + c.xy = tmpvar_9.xy.xy; + float tmpvar_10; + tmpvar_10 = fract (uv.x); + float tmpvar_11; + if (bool(tmpvar_10)) { + tmpvar_11 = 0.9; + } else { + tmpvar_11 = 0.1; + }; + float tmpvar_12; + tmpvar_12 = (c.x + tmpvar_11); + c.x = tmpvar_12; + return c; +} + +void main () +{ + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = xlv_TEXCOORD0.xyzw; + vec4 tmpvar_2; + tmpvar_2 = xlat_main (tmpvar_1); + vec4 tmpvar_3; + tmpvar_3 = tmpvar_2; + xl_retval = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = xl_retval.xyzw; + vec4 tmpvar_5; + tmpvar_5 = tmpvar_4; + gl_FragData[0] = tmpvar_5; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/ternary-irES.txt b/3rdparty/glsl-optimizer/tests/fragment/ternary-irES.txt new file mode 100644 index 000000000..866e054cb --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/ternary-irES.txt @@ -0,0 +1,76 @@ +varying highp vec4 xlv_TEXCOORD0; +mediump vec4 xlat_main ( + in highp vec4 uv +) +{ + mediump vec4 c; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + c = tmpvar_1; + float tmpvar_2; + if ((uv.x > 0.5)) { + tmpvar_2 = 0.9; + } else { + tmpvar_2 = 0.1; + }; + mediump vec4 tmpvar_3; + tmpvar_3 = (c + tmpvar_2); + c = tmpvar_3; + vec4 tmpvar_4; + if ((uv.x > 0.5)) { + tmpvar_4 = vec4(0.9, 0.9, 0.9, 0.9); + } else { + tmpvar_4 = vec4(0.1, 0.1, 0.1, 0.1); + }; + mediump vec4 tmpvar_5; + tmpvar_5 = (c + tmpvar_4); + c = tmpvar_5; + vec3 tmpvar_6; + if ((uv.x > 0.5)) { + tmpvar_6 = vec3(0.9, 0.9, 0.9); + } else { + tmpvar_6 = vec3(0.1, 0.1, 0.1); + }; + mediump vec3 tmpvar_7; + tmpvar_7 = (c.xyz + tmpvar_6); + c.xyz = tmpvar_7.xyz.xyz; + vec2 tmpvar_8; + if ((uv.x > 0.5)) { + tmpvar_8 = vec2(0.9, 0.9); + } else { + tmpvar_8 = vec2(0.1, 0.1); + }; + mediump vec2 tmpvar_9; + tmpvar_9 = (c.xy + tmpvar_8); + c.xy = tmpvar_9.xy.xy; + highp float tmpvar_10; + tmpvar_10 = fract (uv.x); + float tmpvar_11; + if (bool(tmpvar_10)) { + tmpvar_11 = 0.9; + } else { + tmpvar_11 = 0.1; + }; + mediump float tmpvar_12; + tmpvar_12 = (c.x + tmpvar_11); + c.x = tmpvar_12; + return c; +} + +void main () +{ + mediump vec4 xl_retval; + highp vec4 tmpvar_1; + tmpvar_1 = xlv_TEXCOORD0.xyzw; + mediump vec4 tmpvar_2; + tmpvar_2 = xlat_main (tmpvar_1); + mediump vec4 tmpvar_3; + tmpvar_3 = tmpvar_2; + xl_retval = tmpvar_3; + mediump vec4 tmpvar_4; + tmpvar_4 = xl_retval.xyzw; + mediump vec4 tmpvar_5; + tmpvar_5 = tmpvar_4; + gl_FragData[0] = tmpvar_5; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/ternary-out.txt b/3rdparty/glsl-optimizer/tests/fragment/ternary-out.txt new file mode 100644 index 000000000..978042768 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/ternary-out.txt @@ -0,0 +1,47 @@ +varying vec4 xlv_TEXCOORD0; +void main () +{ + vec4 c; + c = vec4(0.0, 0.0, 0.0, 0.0); + float tmpvar_1; + if ((xlv_TEXCOORD0.x > 0.5)) { + tmpvar_1 = 0.9; + } else { + tmpvar_1 = 0.1; + }; + c = vec4(tmpvar_1); + vec4 tmpvar_2; + if ((xlv_TEXCOORD0.x > 0.5)) { + tmpvar_2 = vec4(0.9, 0.9, 0.9, 0.9); + } else { + tmpvar_2 = vec4(0.1, 0.1, 0.1, 0.1); + }; + vec4 tmpvar_3; + tmpvar_3 = (vec4(tmpvar_1) + tmpvar_2); + c = tmpvar_3; + vec3 tmpvar_4; + if ((xlv_TEXCOORD0.x > 0.5)) { + tmpvar_4 = vec3(0.9, 0.9, 0.9); + } else { + tmpvar_4 = vec3(0.1, 0.1, 0.1); + }; + c.xyz = (tmpvar_3.xyz + tmpvar_4); + vec2 tmpvar_5; + if ((xlv_TEXCOORD0.x > 0.5)) { + tmpvar_5 = vec2(0.9, 0.9); + } else { + tmpvar_5 = vec2(0.1, 0.1); + }; + c.xy = (c.xy + tmpvar_5); + float tmpvar_6; + tmpvar_6 = fract (xlv_TEXCOORD0.x); + float tmpvar_7; + if (bool(tmpvar_6)) { + tmpvar_7 = 0.9; + } else { + tmpvar_7 = 0.1; + }; + c.x = (c.x + tmpvar_7); + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/ternary-outES.txt b/3rdparty/glsl-optimizer/tests/fragment/ternary-outES.txt new file mode 100644 index 000000000..a0efb0a9f --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/ternary-outES.txt @@ -0,0 +1,47 @@ +varying highp vec4 xlv_TEXCOORD0; +void main () +{ + mediump vec4 c; + c = vec4(0.0, 0.0, 0.0, 0.0); + float tmpvar_1; + if ((xlv_TEXCOORD0.x > 0.5)) { + tmpvar_1 = 0.9; + } else { + tmpvar_1 = 0.1; + }; + c = vec4(tmpvar_1); + vec4 tmpvar_2; + if ((xlv_TEXCOORD0.x > 0.5)) { + tmpvar_2 = vec4(0.9, 0.9, 0.9, 0.9); + } else { + tmpvar_2 = vec4(0.1, 0.1, 0.1, 0.1); + }; + mediump vec4 tmpvar_3; + tmpvar_3 = (vec4(tmpvar_1) + tmpvar_2); + c = tmpvar_3; + vec3 tmpvar_4; + if ((xlv_TEXCOORD0.x > 0.5)) { + tmpvar_4 = vec3(0.9, 0.9, 0.9); + } else { + tmpvar_4 = vec3(0.1, 0.1, 0.1); + }; + c.xyz = (tmpvar_3.xyz + tmpvar_4); + vec2 tmpvar_5; + if ((xlv_TEXCOORD0.x > 0.5)) { + tmpvar_5 = vec2(0.9, 0.9); + } else { + tmpvar_5 = vec2(0.1, 0.1); + }; + c.xy = (c.xy + tmpvar_5); + highp float tmpvar_6; + tmpvar_6 = fract (xlv_TEXCOORD0.x); + float tmpvar_7; + if (bool(tmpvar_6)) { + tmpvar_7 = 0.9; + } else { + tmpvar_7 = 0.1; + }; + c.x = (c.x + tmpvar_7); + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/ternary-vec4-in.txt b/3rdparty/glsl-optimizer/tests/fragment/ternary-vec4-in.txt new file mode 100644 index 000000000..38616b648 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/ternary-vec4-in.txt @@ -0,0 +1,26 @@ +vec2 xll_vecTSel (bvec2 a, vec2 b, vec2 c) { + return vec2 (a.x ? b.x : c.x, a.y ? b.y : c.y); +} +vec3 xll_vecTSel (bvec3 a, vec3 b, vec3 c) { + return vec3 (a.x ? b.x : c.x, a.y ? b.y : c.y, a.z ? b.z : c.z); +} +vec4 xll_vecTSel (bvec4 a, vec4 b, vec4 c) { + return vec4 (a.x ? b.x : c.x, a.y ? b.y : c.y, a.z ? b.z : c.z, a.w ? b.w : c.w); +} +vec4 xlat_main( in vec4 uv ); +vec4 xlat_main( in vec4 uv ) { + vec4 a; + a = vec4( 0.000000); + a += xll_vecTSel (greaterThan( uv, vec4( 0.500000 )), vec4( 1.00000, 2.00000, 3.00000, 4.00000), vec4( 5.00000, 6.00000, 7.00000, 8.00000)); + a += xll_vecTSel (greaterThan( uv, vec4( 0.500000, 0.500000, 0.500000, 0.500000)), vec4( 1.00000, 2.00000, 3.00000, 4.00000), vec4( 5.00000, 6.00000, 7.00000, 8.00000)); + a += xll_vecTSel (greaterThan( uv, vec4( 0.500000 )), vec4( 1.00000, 1.00000, 1.00000, 1.00000), vec4( 2.00000, 2.00000, 2.00000, 2.00000)); + a += xll_vecTSel (greaterThan( uv, vec4( 0.500000 )), vec4( 1), vec4( 2)); + a += xll_vecTSel (bvec4( fract( uv ) ), vec4( 1.00000, 1.00000, 1.00000, 1.00000), vec4( 2.00000, 2.00000, 2.00000, 2.00000)); + return a; +} +varying vec4 xlv_TEXCOORD0; +void main() { + vec4 xl_retval; + xl_retval = xlat_main( vec4(xlv_TEXCOORD0)); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/ternary-vec4-inES.txt b/3rdparty/glsl-optimizer/tests/fragment/ternary-vec4-inES.txt new file mode 100644 index 000000000..a777b2a4b --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/ternary-vec4-inES.txt @@ -0,0 +1,26 @@ +vec2 xll_vecTSel (bvec2 a, vec2 b, vec2 c) { + return vec2 (a.x ? b.x : c.x, a.y ? b.y : c.y); +} +vec3 xll_vecTSel (bvec3 a, vec3 b, vec3 c) { + return vec3 (a.x ? b.x : c.x, a.y ? b.y : c.y, a.z ? b.z : c.z); +} +vec4 xll_vecTSel (bvec4 a, vec4 b, vec4 c) { + return vec4 (a.x ? b.x : c.x, a.y ? b.y : c.y, a.z ? b.z : c.z, a.w ? b.w : c.w); +} +mediump vec4 xlat_main( in highp vec4 uv ); +mediump vec4 xlat_main( in highp vec4 uv ) { + highp vec4 a; + a = vec4( 0.000000); + a += xll_vecTSel (greaterThan( uv, vec4( 0.500000 )), highp vec4( 1.00000, 2.00000, 3.00000, 4.00000), highp vec4( 5.00000, 6.00000, 7.00000, 8.00000)); + a += xll_vecTSel (greaterThan( uv, highp vec4( 0.500000, 0.500000, 0.500000, 0.500000)), highp vec4( 1.00000, 2.00000, 3.00000, 4.00000), highp vec4( 5.00000, 6.00000, 7.00000, 8.00000)); + a += xll_vecTSel (greaterThan( uv, vec4( 0.500000 )), highp vec4( 1.00000, 1.00000, 1.00000, 1.00000), highp vec4( 2.00000, 2.00000, 2.00000, 2.00000)); + a += xll_vecTSel (greaterThan( uv, vec4( 0.500000 )), vec4( 1), vec4( 2)); + a += xll_vecTSel (bvec4( fract( uv ) ), highp vec4( 1.00000, 1.00000, 1.00000, 1.00000), highp vec4( 2.00000, 2.00000, 2.00000, 2.00000)); + return a; +} +varying highp vec4 xlv_TEXCOORD0; +void main() { + mediump vec4 xl_retval; + xl_retval = xlat_main( highp vec4(xlv_TEXCOORD0)); + gl_FragData[0] = mediump vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/ternary-vec4-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/ternary-vec4-ir.txt new file mode 100644 index 000000000..6d376c719 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/ternary-vec4-ir.txt @@ -0,0 +1,159 @@ +varying vec4 xlv_TEXCOORD0; +vec2 xll_vecTSel ( + in bvec2 a, + in vec2 b, + in vec2 c +) +{ + float tmpvar_1; + if (a.x) { + tmpvar_1 = b.x; + } else { + tmpvar_1 = c.x; + }; + float tmpvar_2; + if (a.y) { + tmpvar_2 = b.y; + } else { + tmpvar_2 = c.y; + }; + vec2 tmpvar_3; + tmpvar_3.x = tmpvar_1; + tmpvar_3.y = tmpvar_2; + return tmpvar_3; +} + +vec3 xll_vecTSel ( + in bvec3 a, + in vec3 b, + in vec3 c +) +{ + float tmpvar_1; + if (a.x) { + tmpvar_1 = b.x; + } else { + tmpvar_1 = c.x; + }; + float tmpvar_2; + if (a.y) { + tmpvar_2 = b.y; + } else { + tmpvar_2 = c.y; + }; + float tmpvar_3; + if (a.z) { + tmpvar_3 = b.z; + } else { + tmpvar_3 = c.z; + }; + vec3 tmpvar_4; + tmpvar_4.x = tmpvar_1; + tmpvar_4.y = tmpvar_2; + tmpvar_4.z = tmpvar_3; + return tmpvar_4; +} + +vec4 xll_vecTSel ( + in bvec4 a, + in vec4 b, + in vec4 c +) +{ + float tmpvar_1; + if (a.x) { + tmpvar_1 = b.x; + } else { + tmpvar_1 = c.x; + }; + float tmpvar_2; + if (a.y) { + tmpvar_2 = b.y; + } else { + tmpvar_2 = c.y; + }; + float tmpvar_3; + if (a.z) { + tmpvar_3 = b.z; + } else { + tmpvar_3 = c.z; + }; + float tmpvar_4; + if (a.w) { + tmpvar_4 = b.w; + } else { + tmpvar_4 = c.w; + }; + vec4 tmpvar_5; + tmpvar_5.x = tmpvar_1; + tmpvar_5.y = tmpvar_2; + tmpvar_5.z = tmpvar_3; + tmpvar_5.w = tmpvar_4; + return tmpvar_5; +} + +vec4 xlat_main ( + in vec4 uv +) +{ + vec4 a; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + a = tmpvar_1; + bvec4 tmpvar_2; + tmpvar_2 = greaterThan (uv, vec4(0.5, 0.5, 0.5, 0.5)); + vec4 tmpvar_3; + tmpvar_3 = xll_vecTSel (tmpvar_2, vec4(1.0, 2.0, 3.0, 4.0), vec4(5.0, 6.0, 7.0, 8.0)); + vec4 tmpvar_4; + tmpvar_4 = (a + tmpvar_3); + a = tmpvar_4; + bvec4 tmpvar_5; + tmpvar_5 = greaterThan (uv, vec4(0.5, 0.5, 0.5, 0.5)); + vec4 tmpvar_6; + tmpvar_6 = xll_vecTSel (tmpvar_5, vec4(1.0, 2.0, 3.0, 4.0), vec4(5.0, 6.0, 7.0, 8.0)); + vec4 tmpvar_7; + tmpvar_7 = (a + tmpvar_6); + a = tmpvar_7; + bvec4 tmpvar_8; + tmpvar_8 = greaterThan (uv, vec4(0.5, 0.5, 0.5, 0.5)); + vec4 tmpvar_9; + tmpvar_9 = xll_vecTSel (tmpvar_8, vec4(1.0, 1.0, 1.0, 1.0), vec4(2.0, 2.0, 2.0, 2.0)); + vec4 tmpvar_10; + tmpvar_10 = (a + tmpvar_9); + a = tmpvar_10; + bvec4 tmpvar_11; + tmpvar_11 = greaterThan (uv, vec4(0.5, 0.5, 0.5, 0.5)); + vec4 tmpvar_12; + tmpvar_12 = xll_vecTSel (tmpvar_11, vec4(1.0, 1.0, 1.0, 1.0), vec4(2.0, 2.0, 2.0, 2.0)); + vec4 tmpvar_13; + tmpvar_13 = (a + tmpvar_12); + a = tmpvar_13; + vec4 tmpvar_14; + tmpvar_14 = fract (uv); + bvec4 tmpvar_15; + tmpvar_15 = bvec4(tmpvar_14).xyzw; + vec4 tmpvar_16; + tmpvar_16 = xll_vecTSel (tmpvar_15, vec4(1.0, 1.0, 1.0, 1.0), vec4(2.0, 2.0, 2.0, 2.0)); + vec4 tmpvar_17; + tmpvar_17 = (a + tmpvar_16); + a = tmpvar_17; + return a; +} + +void main () +{ + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = xlv_TEXCOORD0.xyzw; + vec4 tmpvar_2; + tmpvar_2 = xlat_main (tmpvar_1); + vec4 tmpvar_3; + tmpvar_3 = tmpvar_2; + xl_retval = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = xl_retval.xyzw; + vec4 tmpvar_5; + tmpvar_5 = tmpvar_4; + gl_FragData[0] = tmpvar_5; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/ternary-vec4-irES.txt b/3rdparty/glsl-optimizer/tests/fragment/ternary-vec4-irES.txt new file mode 100644 index 000000000..caf0718de --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/ternary-vec4-irES.txt @@ -0,0 +1,159 @@ +varying highp vec4 xlv_TEXCOORD0; +vec2 xll_vecTSel ( + in bvec2 a, + in vec2 b, + in vec2 c +) +{ + float tmpvar_1; + if (a.x) { + tmpvar_1 = b.x; + } else { + tmpvar_1 = c.x; + }; + float tmpvar_2; + if (a.y) { + tmpvar_2 = b.y; + } else { + tmpvar_2 = c.y; + }; + vec2 tmpvar_3; + tmpvar_3.x = tmpvar_1; + tmpvar_3.y = tmpvar_2; + return tmpvar_3; +} + +vec3 xll_vecTSel ( + in bvec3 a, + in vec3 b, + in vec3 c +) +{ + float tmpvar_1; + if (a.x) { + tmpvar_1 = b.x; + } else { + tmpvar_1 = c.x; + }; + float tmpvar_2; + if (a.y) { + tmpvar_2 = b.y; + } else { + tmpvar_2 = c.y; + }; + float tmpvar_3; + if (a.z) { + tmpvar_3 = b.z; + } else { + tmpvar_3 = c.z; + }; + vec3 tmpvar_4; + tmpvar_4.x = tmpvar_1; + tmpvar_4.y = tmpvar_2; + tmpvar_4.z = tmpvar_3; + return tmpvar_4; +} + +vec4 xll_vecTSel ( + in bvec4 a, + in vec4 b, + in vec4 c +) +{ + float tmpvar_1; + if (a.x) { + tmpvar_1 = b.x; + } else { + tmpvar_1 = c.x; + }; + float tmpvar_2; + if (a.y) { + tmpvar_2 = b.y; + } else { + tmpvar_2 = c.y; + }; + float tmpvar_3; + if (a.z) { + tmpvar_3 = b.z; + } else { + tmpvar_3 = c.z; + }; + float tmpvar_4; + if (a.w) { + tmpvar_4 = b.w; + } else { + tmpvar_4 = c.w; + }; + vec4 tmpvar_5; + tmpvar_5.x = tmpvar_1; + tmpvar_5.y = tmpvar_2; + tmpvar_5.z = tmpvar_3; + tmpvar_5.w = tmpvar_4; + return tmpvar_5; +} + +mediump vec4 xlat_main ( + in highp vec4 uv +) +{ + highp vec4 a; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + a = tmpvar_1; + bvec4 tmpvar_2; + tmpvar_2 = greaterThan (uv, vec4(0.5, 0.5, 0.5, 0.5)); + vec4 tmpvar_3; + tmpvar_3 = xll_vecTSel (tmpvar_2, vec4(1.0, 2.0, 3.0, 4.0), vec4(5.0, 6.0, 7.0, 8.0)); + highp vec4 tmpvar_4; + tmpvar_4 = (a + tmpvar_3); + a = tmpvar_4; + bvec4 tmpvar_5; + tmpvar_5 = greaterThan (uv, vec4(0.5, 0.5, 0.5, 0.5)); + vec4 tmpvar_6; + tmpvar_6 = xll_vecTSel (tmpvar_5, vec4(1.0, 2.0, 3.0, 4.0), vec4(5.0, 6.0, 7.0, 8.0)); + highp vec4 tmpvar_7; + tmpvar_7 = (a + tmpvar_6); + a = tmpvar_7; + bvec4 tmpvar_8; + tmpvar_8 = greaterThan (uv, vec4(0.5, 0.5, 0.5, 0.5)); + vec4 tmpvar_9; + tmpvar_9 = xll_vecTSel (tmpvar_8, vec4(1.0, 1.0, 1.0, 1.0), vec4(2.0, 2.0, 2.0, 2.0)); + highp vec4 tmpvar_10; + tmpvar_10 = (a + tmpvar_9); + a = tmpvar_10; + bvec4 tmpvar_11; + tmpvar_11 = greaterThan (uv, vec4(0.5, 0.5, 0.5, 0.5)); + vec4 tmpvar_12; + tmpvar_12 = xll_vecTSel (tmpvar_11, vec4(1.0, 1.0, 1.0, 1.0), vec4(2.0, 2.0, 2.0, 2.0)); + highp vec4 tmpvar_13; + tmpvar_13 = (a + tmpvar_12); + a = tmpvar_13; + highp vec4 tmpvar_14; + tmpvar_14 = fract (uv); + bvec4 tmpvar_15; + tmpvar_15 = bvec4(tmpvar_14).xyzw; + vec4 tmpvar_16; + tmpvar_16 = xll_vecTSel (tmpvar_15, vec4(1.0, 1.0, 1.0, 1.0), vec4(2.0, 2.0, 2.0, 2.0)); + highp vec4 tmpvar_17; + tmpvar_17 = (a + tmpvar_16); + a = tmpvar_17; + return a; +} + +void main () +{ + mediump vec4 xl_retval; + highp vec4 tmpvar_1; + tmpvar_1 = xlv_TEXCOORD0.xyzw; + mediump vec4 tmpvar_2; + tmpvar_2 = xlat_main (tmpvar_1); + mediump vec4 tmpvar_3; + tmpvar_3 = tmpvar_2; + xl_retval = tmpvar_3; + mediump vec4 tmpvar_4; + tmpvar_4 = xl_retval.xyzw; + mediump vec4 tmpvar_5; + tmpvar_5 = tmpvar_4; + gl_FragData[0] = tmpvar_5; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/ternary-vec4-out.txt b/3rdparty/glsl-optimizer/tests/fragment/ternary-vec4-out.txt new file mode 100644 index 000000000..6906f5e63 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/ternary-vec4-out.txt @@ -0,0 +1,167 @@ +varying vec4 xlv_TEXCOORD0; +void main () +{ + bvec4 tmpvar_1; + tmpvar_1 = greaterThan (xlv_TEXCOORD0, vec4(0.5, 0.5, 0.5, 0.5)); + float tmpvar_2; + if (tmpvar_1.x) { + tmpvar_2 = 1.0; + } else { + tmpvar_2 = 5.0; + }; + float tmpvar_3; + if (tmpvar_1.y) { + tmpvar_3 = 2.0; + } else { + tmpvar_3 = 6.0; + }; + float tmpvar_4; + if (tmpvar_1.z) { + tmpvar_4 = 3.0; + } else { + tmpvar_4 = 7.0; + }; + float tmpvar_5; + if (tmpvar_1.w) { + tmpvar_5 = 4.0; + } else { + tmpvar_5 = 8.0; + }; + vec4 tmpvar_6; + tmpvar_6.x = tmpvar_2; + tmpvar_6.y = tmpvar_3; + tmpvar_6.z = tmpvar_4; + tmpvar_6.w = tmpvar_5; + bvec4 tmpvar_7; + tmpvar_7 = greaterThan (xlv_TEXCOORD0, vec4(0.5, 0.5, 0.5, 0.5)); + float tmpvar_8; + if (tmpvar_7.x) { + tmpvar_8 = 1.0; + } else { + tmpvar_8 = 5.0; + }; + float tmpvar_9; + if (tmpvar_7.y) { + tmpvar_9 = 2.0; + } else { + tmpvar_9 = 6.0; + }; + float tmpvar_10; + if (tmpvar_7.z) { + tmpvar_10 = 3.0; + } else { + tmpvar_10 = 7.0; + }; + float tmpvar_11; + if (tmpvar_7.w) { + tmpvar_11 = 4.0; + } else { + tmpvar_11 = 8.0; + }; + vec4 tmpvar_12; + tmpvar_12.x = tmpvar_8; + tmpvar_12.y = tmpvar_9; + tmpvar_12.z = tmpvar_10; + tmpvar_12.w = tmpvar_11; + vec4 tmpvar_13; + tmpvar_13 = (tmpvar_6 + tmpvar_12); + bvec4 tmpvar_14; + tmpvar_14 = greaterThan (xlv_TEXCOORD0, vec4(0.5, 0.5, 0.5, 0.5)); + float tmpvar_15; + if (tmpvar_14.x) { + tmpvar_15 = 1.0; + } else { + tmpvar_15 = 2.0; + }; + float tmpvar_16; + if (tmpvar_14.y) { + tmpvar_16 = 1.0; + } else { + tmpvar_16 = 2.0; + }; + float tmpvar_17; + if (tmpvar_14.z) { + tmpvar_17 = 1.0; + } else { + tmpvar_17 = 2.0; + }; + float tmpvar_18; + if (tmpvar_14.w) { + tmpvar_18 = 1.0; + } else { + tmpvar_18 = 2.0; + }; + vec4 tmpvar_19; + tmpvar_19.x = tmpvar_15; + tmpvar_19.y = tmpvar_16; + tmpvar_19.z = tmpvar_17; + tmpvar_19.w = tmpvar_18; + vec4 tmpvar_20; + tmpvar_20 = (tmpvar_13 + tmpvar_19); + bvec4 tmpvar_21; + tmpvar_21 = greaterThan (xlv_TEXCOORD0, vec4(0.5, 0.5, 0.5, 0.5)); + float tmpvar_22; + if (tmpvar_21.x) { + tmpvar_22 = 1.0; + } else { + tmpvar_22 = 2.0; + }; + float tmpvar_23; + if (tmpvar_21.y) { + tmpvar_23 = 1.0; + } else { + tmpvar_23 = 2.0; + }; + float tmpvar_24; + if (tmpvar_21.z) { + tmpvar_24 = 1.0; + } else { + tmpvar_24 = 2.0; + }; + float tmpvar_25; + if (tmpvar_21.w) { + tmpvar_25 = 1.0; + } else { + tmpvar_25 = 2.0; + }; + vec4 tmpvar_26; + tmpvar_26.x = tmpvar_22; + tmpvar_26.y = tmpvar_23; + tmpvar_26.z = tmpvar_24; + tmpvar_26.w = tmpvar_25; + vec4 tmpvar_27; + tmpvar_27 = (tmpvar_20 + tmpvar_26); + bvec4 tmpvar_28; + tmpvar_28 = bvec4(fract (xlv_TEXCOORD0)); + float tmpvar_29; + if (tmpvar_28.x) { + tmpvar_29 = 1.0; + } else { + tmpvar_29 = 2.0; + }; + float tmpvar_30; + if (tmpvar_28.y) { + tmpvar_30 = 1.0; + } else { + tmpvar_30 = 2.0; + }; + float tmpvar_31; + if (tmpvar_28.z) { + tmpvar_31 = 1.0; + } else { + tmpvar_31 = 2.0; + }; + float tmpvar_32; + if (tmpvar_28.w) { + tmpvar_32 = 1.0; + } else { + tmpvar_32 = 2.0; + }; + vec4 tmpvar_33; + tmpvar_33.x = tmpvar_29; + tmpvar_33.y = tmpvar_30; + tmpvar_33.z = tmpvar_31; + tmpvar_33.w = tmpvar_32; + gl_FragData[0] = (tmpvar_27 + tmpvar_33); +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/ternary-vec4-outES.txt b/3rdparty/glsl-optimizer/tests/fragment/ternary-vec4-outES.txt new file mode 100644 index 000000000..04a33ea6e --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/ternary-vec4-outES.txt @@ -0,0 +1,171 @@ +varying highp vec4 xlv_TEXCOORD0; +void main () +{ + mediump vec4 tmpvar_1; + bvec4 tmpvar_2; + tmpvar_2 = greaterThan (xlv_TEXCOORD0, vec4(0.5, 0.5, 0.5, 0.5)); + float tmpvar_3; + if (tmpvar_2.x) { + tmpvar_3 = 1.0; + } else { + tmpvar_3 = 5.0; + }; + float tmpvar_4; + if (tmpvar_2.y) { + tmpvar_4 = 2.0; + } else { + tmpvar_4 = 6.0; + }; + float tmpvar_5; + if (tmpvar_2.z) { + tmpvar_5 = 3.0; + } else { + tmpvar_5 = 7.0; + }; + float tmpvar_6; + if (tmpvar_2.w) { + tmpvar_6 = 4.0; + } else { + tmpvar_6 = 8.0; + }; + vec4 tmpvar_7; + tmpvar_7.x = tmpvar_3; + tmpvar_7.y = tmpvar_4; + tmpvar_7.z = tmpvar_5; + tmpvar_7.w = tmpvar_6; + bvec4 tmpvar_8; + tmpvar_8 = greaterThan (xlv_TEXCOORD0, vec4(0.5, 0.5, 0.5, 0.5)); + float tmpvar_9; + if (tmpvar_8.x) { + tmpvar_9 = 1.0; + } else { + tmpvar_9 = 5.0; + }; + float tmpvar_10; + if (tmpvar_8.y) { + tmpvar_10 = 2.0; + } else { + tmpvar_10 = 6.0; + }; + float tmpvar_11; + if (tmpvar_8.z) { + tmpvar_11 = 3.0; + } else { + tmpvar_11 = 7.0; + }; + float tmpvar_12; + if (tmpvar_8.w) { + tmpvar_12 = 4.0; + } else { + tmpvar_12 = 8.0; + }; + vec4 tmpvar_13; + tmpvar_13.x = tmpvar_9; + tmpvar_13.y = tmpvar_10; + tmpvar_13.z = tmpvar_11; + tmpvar_13.w = tmpvar_12; + highp vec4 tmpvar_14; + tmpvar_14 = (tmpvar_7 + tmpvar_13); + bvec4 tmpvar_15; + tmpvar_15 = greaterThan (xlv_TEXCOORD0, vec4(0.5, 0.5, 0.5, 0.5)); + float tmpvar_16; + if (tmpvar_15.x) { + tmpvar_16 = 1.0; + } else { + tmpvar_16 = 2.0; + }; + float tmpvar_17; + if (tmpvar_15.y) { + tmpvar_17 = 1.0; + } else { + tmpvar_17 = 2.0; + }; + float tmpvar_18; + if (tmpvar_15.z) { + tmpvar_18 = 1.0; + } else { + tmpvar_18 = 2.0; + }; + float tmpvar_19; + if (tmpvar_15.w) { + tmpvar_19 = 1.0; + } else { + tmpvar_19 = 2.0; + }; + vec4 tmpvar_20; + tmpvar_20.x = tmpvar_16; + tmpvar_20.y = tmpvar_17; + tmpvar_20.z = tmpvar_18; + tmpvar_20.w = tmpvar_19; + highp vec4 tmpvar_21; + tmpvar_21 = (tmpvar_14 + tmpvar_20); + bvec4 tmpvar_22; + tmpvar_22 = greaterThan (xlv_TEXCOORD0, vec4(0.5, 0.5, 0.5, 0.5)); + float tmpvar_23; + if (tmpvar_22.x) { + tmpvar_23 = 1.0; + } else { + tmpvar_23 = 2.0; + }; + float tmpvar_24; + if (tmpvar_22.y) { + tmpvar_24 = 1.0; + } else { + tmpvar_24 = 2.0; + }; + float tmpvar_25; + if (tmpvar_22.z) { + tmpvar_25 = 1.0; + } else { + tmpvar_25 = 2.0; + }; + float tmpvar_26; + if (tmpvar_22.w) { + tmpvar_26 = 1.0; + } else { + tmpvar_26 = 2.0; + }; + vec4 tmpvar_27; + tmpvar_27.x = tmpvar_23; + tmpvar_27.y = tmpvar_24; + tmpvar_27.z = tmpvar_25; + tmpvar_27.w = tmpvar_26; + highp vec4 tmpvar_28; + tmpvar_28 = (tmpvar_21 + tmpvar_27); + bvec4 tmpvar_29; + tmpvar_29 = bvec4(fract (xlv_TEXCOORD0)); + float tmpvar_30; + if (tmpvar_29.x) { + tmpvar_30 = 1.0; + } else { + tmpvar_30 = 2.0; + }; + float tmpvar_31; + if (tmpvar_29.y) { + tmpvar_31 = 1.0; + } else { + tmpvar_31 = 2.0; + }; + float tmpvar_32; + if (tmpvar_29.z) { + tmpvar_32 = 1.0; + } else { + tmpvar_32 = 2.0; + }; + float tmpvar_33; + if (tmpvar_29.w) { + tmpvar_33 = 1.0; + } else { + tmpvar_33 = 2.0; + }; + vec4 tmpvar_34; + tmpvar_34.x = tmpvar_30; + tmpvar_34.y = tmpvar_31; + tmpvar_34.z = tmpvar_32; + tmpvar_34.w = tmpvar_33; + highp vec4 tmpvar_35; + tmpvar_35 = (tmpvar_28 + tmpvar_34); + tmpvar_1 = tmpvar_35; + gl_FragData[0] = tmpvar_1; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/tex2dlod-in.txt b/3rdparty/glsl-optimizer/tests/fragment/tex2dlod-in.txt new file mode 100644 index 000000000..e283775f8 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/tex2dlod-in.txt @@ -0,0 +1,15 @@ +#extension GL_ARB_shader_texture_lod : require +vec4 xll_tex2Dlod(sampler2D s, vec4 coord) { + return texture2DLod( s, coord.xy, coord.w); +} +uniform sampler2D tex; +vec4 xlat_main( in vec4 uv ); +vec4 xlat_main( in vec4 uv ) { + return xll_tex2Dlod( tex, vec4( uv.xy , 0.0, 0.0)); +} +varying vec4 xlv_TEXCOORD0; +void main() { + vec4 xl_retval; + xl_retval = xlat_main( vec4(xlv_TEXCOORD0)); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/tex2dlod-inES.txt b/3rdparty/glsl-optimizer/tests/fragment/tex2dlod-inES.txt new file mode 100644 index 000000000..f878eeef2 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/tex2dlod-inES.txt @@ -0,0 +1,15 @@ +#extension GL_ARB_shader_texture_lod : require +vec4 xll_tex2Dlod(sampler2D s, vec4 coord) { + return texture2DLod( s, coord.xy, coord.w); +} +uniform sampler2D tex; +mediump vec4 xlat_main( in highp vec4 uv ); +mediump vec4 xlat_main( in highp vec4 uv ) { + return xll_tex2Dlod( tex, vec4( uv.xy , 0.0, 0.0)); +} +varying highp vec4 xlv_TEXCOORD0; +void main() { + mediump vec4 xl_retval; + xl_retval = xlat_main( vec4(xlv_TEXCOORD0)); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/tex2dlod-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/tex2dlod-ir.txt new file mode 100644 index 000000000..dc6623468 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/tex2dlod-ir.txt @@ -0,0 +1,42 @@ +#extension GL_ARB_shader_texture_lod : enable +varying vec4 xlv_TEXCOORD0; +uniform sampler2D tex; +vec4 xll_tex2Dlod ( + in sampler2D s, + in vec4 coord +) +{ + vec4 tmpvar_1; + tmpvar_1 = texture2DLod (s, coord.xy, coord.w); + return tmpvar_1; +} + +vec4 xlat_main ( + in vec4 uv +) +{ + vec4 tmpvar_1; + tmpvar_1.zw = vec2(0.0, 0.0); + tmpvar_1.xy = uv.xy.xy; + vec4 tmpvar_2; + tmpvar_2 = xll_tex2Dlod (tex, tmpvar_1); + return tmpvar_2; +} + +void main () +{ + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = xlv_TEXCOORD0.xyzw; + vec4 tmpvar_2; + tmpvar_2 = xlat_main (tmpvar_1); + vec4 tmpvar_3; + tmpvar_3 = tmpvar_2; + xl_retval = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = xl_retval.xyzw; + vec4 tmpvar_5; + tmpvar_5 = tmpvar_4; + gl_FragData[0] = tmpvar_5; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/tex2dlod-irES.txt b/3rdparty/glsl-optimizer/tests/fragment/tex2dlod-irES.txt new file mode 100644 index 000000000..283b29366 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/tex2dlod-irES.txt @@ -0,0 +1,42 @@ +#extension GL_ARB_shader_texture_lod : enable +varying highp vec4 xlv_TEXCOORD0; +uniform sampler2D tex; +vec4 xll_tex2Dlod ( + in sampler2D s, + in vec4 coord +) +{ + lowp vec4 tmpvar_1; + tmpvar_1 = texture2DLod (s, coord.xy, coord.w); + return tmpvar_1; +} + +mediump vec4 xlat_main ( + in highp vec4 uv +) +{ + highp vec4 tmpvar_1; + tmpvar_1.zw = vec2(0.0, 0.0); + tmpvar_1.xy = uv.xy.xy; + vec4 tmpvar_2; + tmpvar_2 = xll_tex2Dlod (tex, tmpvar_1); + return tmpvar_2; +} + +void main () +{ + mediump vec4 xl_retval; + highp vec4 tmpvar_1; + tmpvar_1 = xlv_TEXCOORD0.xyzw; + mediump vec4 tmpvar_2; + tmpvar_2 = xlat_main (tmpvar_1); + mediump vec4 tmpvar_3; + tmpvar_3 = tmpvar_2; + xl_retval = tmpvar_3; + mediump vec4 tmpvar_4; + tmpvar_4 = xl_retval.xyzw; + mediump vec4 tmpvar_5; + tmpvar_5 = tmpvar_4; + gl_FragData[0] = tmpvar_5; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/tex2dlod-out.txt b/3rdparty/glsl-optimizer/tests/fragment/tex2dlod-out.txt new file mode 100644 index 000000000..bbee8adf1 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/tex2dlod-out.txt @@ -0,0 +1,11 @@ +#extension GL_ARB_shader_texture_lod : enable +varying vec4 xlv_TEXCOORD0; +uniform sampler2D tex; +void main () +{ + vec4 tmpvar_1; + tmpvar_1.zw = vec2(0.0, 0.0); + tmpvar_1.xy = xlv_TEXCOORD0.xy; + gl_FragData[0] = texture2DLod (tex, tmpvar_1.xy, 0.0); +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/tex2dlod-outES.txt b/3rdparty/glsl-optimizer/tests/fragment/tex2dlod-outES.txt new file mode 100644 index 000000000..f5d60f890 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/tex2dlod-outES.txt @@ -0,0 +1,15 @@ +#extension GL_ARB_shader_texture_lod : enable +varying highp vec4 xlv_TEXCOORD0; +uniform sampler2D tex; +void main () +{ + mediump vec4 tmpvar_1; + highp vec4 tmpvar_2; + tmpvar_2.zw = vec2(0.0, 0.0); + tmpvar_2.xy = xlv_TEXCOORD0.xy; + lowp vec4 tmpvar_3; + tmpvar_3 = texture2DLod (tex, tmpvar_2.xy, 0.0); + tmpvar_1 = tmpvar_3; + gl_FragData[0] = tmpvar_1; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/types-writemask-in.txt b/3rdparty/glsl-optimizer/tests/fragment/types-writemask-in.txt new file mode 100644 index 000000000..ec426f50e --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/types-writemask-in.txt @@ -0,0 +1,6 @@ +void main () { + vec4 c; + c.x = gl_FragCoord.y; + c.yzw = vec3(4.0,5.0,6.0); + gl_FragColor = c; +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/types-writemask-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/types-writemask-ir.txt new file mode 100644 index 000000000..20a7ebf15 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/types-writemask-ir.txt @@ -0,0 +1,14 @@ +void main () +{ + vec4 c; + float tmpvar_1; + tmpvar_1 = gl_FragCoord.y; + c.x = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = vec3(4.0, 5.0, 6.0); + c.yzw = tmpvar_2.xxyz.yzw; + vec4 tmpvar_3; + tmpvar_3 = c; + gl_FragColor = tmpvar_3; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/types-writemask-out.txt b/3rdparty/glsl-optimizer/tests/fragment/types-writemask-out.txt new file mode 100644 index 000000000..4c9eacc11 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/types-writemask-out.txt @@ -0,0 +1,8 @@ +void main () +{ + vec4 c; + c.x = gl_FragCoord.y; + c.yzw = vec3(4.0, 5.0, 6.0); + gl_FragColor = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Bumped_Diffuse-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Bumped_Diffuse-in.txt new file mode 100644 index 000000000..f24c69199 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Bumped_Diffuse-in.txt @@ -0,0 +1,90 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; +}; +struct v2f_surf { + vec4 pos; + vec2 hip_pack0; + vec3 TtoV0; + vec3 TtoV1; + vec3 TtoV2; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform sampler2D _BumpMap; +uniform vec4 _Color; +uniform sampler2D _MainTex; +vec4 UnpackNormal( in vec4 packednormal ); +void surf( in Input IN, inout SurfaceOutput o ); +vec4 frag_surf( in v2f_surf IN ); +vec4 UnpackNormal( in vec4 packednormal ) { + vec4 normal; + normal.xy = ((packednormal.wy * 2.00000) - 1.00000); + normal.z = sqrt( ((1.00000 - (normal.x * normal.x )) - (normal.y * normal.y )) ); + return normal; +} +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 c; + c = (texture2D( _MainTex, IN.uv_MainTex) * _Color); + o.Albedo = c.xyz ; + o.Alpha = c.w ; + o.Normal = vec3( UnpackNormal( texture2D( _BumpMap, IN.uv_BumpMap))); +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec3 viewN; + vec4 res; + surfIN.uv_BumpMap = IN.hip_pack0.xy ; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + surf( surfIN, o); + viewN.x = dot( IN.TtoV0, o.Normal); + viewN.y = dot( IN.TtoV1, o.Normal); + viewN.z = dot( IN.TtoV2, o.Normal); + o.Normal = viewN; + res.xyz = ((o.Normal * vec3( 0.500000, 0.500000, -0.500000)) + 0.500000); + res.w = o.Specular; + return res; +} +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.hip_pack0 = vec2( gl_TexCoord[0]); + xlt_IN.TtoV0 = vec3( gl_TexCoord[1]); + xlt_IN.TtoV1 = vec3( gl_TexCoord[2]); + xlt_IN.TtoV2 = vec3( gl_TexCoord[3]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Bumped_Diffuse-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Bumped_Diffuse-ir.txt new file mode 100644 index 000000000..00189f203 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Bumped_Diffuse-ir.txt @@ -0,0 +1,159 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; +}; +struct v2f_surf { + vec4 pos; + vec2 hip_pack0; + vec3 TtoV0; + vec3 TtoV1; + vec3 TtoV2; +}; +uniform sampler2D _MainTex; +uniform vec4 _Color; +uniform sampler2D _BumpMap; +vec4 UnpackNormal ( + in vec4 packednormal +) +{ + vec4 normal; + vec2 tmpvar_1; + tmpvar_1 = ((packednormal.wy * 2.0) - 1.0); + normal.xy = tmpvar_1.xy.xy; + float tmpvar_2; + tmpvar_2 = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + normal.z = vec3(tmpvar_3).z; + return normal; +} + +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 c; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = (tmpvar_1 * _Color); + c = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = c.xyz; + o.Albedo = tmpvar_3; + float tmpvar_4; + tmpvar_4 = c.w; + o.Alpha = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = texture2D (_BumpMap, IN.uv_BumpMap); + vec4 tmpvar_6; + tmpvar_6 = UnpackNormal (tmpvar_5); + vec3 tmpvar_7; + tmpvar_7 = tmpvar_6.xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + o.Normal = tmpvar_8; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 res; + vec3 viewN; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_BumpMap = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_3; + float tmpvar_4; + tmpvar_4 = 0.0; + o.Specular = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Alpha = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Gloss = tmpvar_6; + surf (surfIN, o); + float tmpvar_7; + tmpvar_7 = dot (IN.TtoV0, o.Normal); + float tmpvar_8; + tmpvar_8 = tmpvar_7; + viewN.x = tmpvar_8; + float tmpvar_9; + tmpvar_9 = dot (IN.TtoV1, o.Normal); + float tmpvar_10; + tmpvar_10 = tmpvar_9; + viewN.y = vec2(tmpvar_10).y; + float tmpvar_11; + tmpvar_11 = dot (IN.TtoV2, o.Normal); + float tmpvar_12; + tmpvar_12 = tmpvar_11; + viewN.z = vec3(tmpvar_12).z; + vec3 tmpvar_13; + tmpvar_13 = viewN; + o.Normal = tmpvar_13; + vec3 tmpvar_14; + tmpvar_14 = ((o.Normal * vec3(0.5, 0.5, -0.5)) + 0.5); + res.xyz = tmpvar_14.xyz.xyz; + float tmpvar_15; + tmpvar_15 = o.Specular; + res.w = vec4(tmpvar_15).w; + return res; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = gl_TexCoord[0].xy; + vec2 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_IN.hip_pack0 = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = gl_TexCoord[1].xyz; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_4; + xlt_IN.TtoV0 = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = gl_TexCoord[2].xyz; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_6; + xlt_IN.TtoV1 = tmpvar_7; + vec3 tmpvar_8; + tmpvar_8 = gl_TexCoord[3].xyz; + vec3 tmpvar_9; + tmpvar_9 = tmpvar_8; + xlt_IN.TtoV2 = tmpvar_9; + vec4 tmpvar_10; + tmpvar_10 = frag_surf (xlt_IN); + vec4 tmpvar_11; + tmpvar_11 = tmpvar_10; + xl_retval = tmpvar_11; + vec4 tmpvar_12; + tmpvar_12 = xl_retval.xyzw; + vec4 tmpvar_13; + tmpvar_13 = tmpvar_12; + gl_FragData[0] = tmpvar_13; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Bumped_Diffuse-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Bumped_Diffuse-out.txt new file mode 100644 index 000000000..3c1dec354 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Bumped_Diffuse-out.txt @@ -0,0 +1,18 @@ +uniform sampler2D _BumpMap; +void main () +{ + vec4 res; + vec3 viewN; + vec4 normal; + normal.xy = ((texture2D (_BumpMap, gl_TexCoord[0].xy).wy * 2.0) - 1.0); + normal.z = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + vec3 tmpvar_1; + tmpvar_1 = normal.xyz; + viewN.x = dot (gl_TexCoord[1].xyz, tmpvar_1); + viewN.y = dot (gl_TexCoord[2].xyz, tmpvar_1); + viewN.z = dot (gl_TexCoord[3].xyz, tmpvar_1); + res.xyz = ((viewN * vec3(0.5, 0.5, -0.5)) + 0.5); + res.w = 0.0; + gl_FragData[0] = res; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Bumped_Diffuse1-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Bumped_Diffuse1-in.txt new file mode 100644 index 000000000..93bf021ef --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Bumped_Diffuse1-in.txt @@ -0,0 +1,96 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 hip_screen; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform sampler2D _BumpMap; +uniform vec4 _Color; +uniform sampler2D _LightBuffer; +uniform sampler2D _MainTex; +uniform vec4 unity_Ambient; +vec4 UnpackNormal( in vec4 packednormal ); +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingLambert_PrePass( in SurfaceOutput s, in vec4 light ); +vec4 frag_surf( in v2f_surf IN ); +vec4 UnpackNormal( in vec4 packednormal ) { + vec4 normal; + normal.xy = ((packednormal.wy * 2.00000) - 1.00000); + normal.z = sqrt( ((1.00000 - (normal.x * normal.x )) - (normal.y * normal.y )) ); + return normal; +} +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 c; + c = (texture2D( _MainTex, IN.uv_MainTex) * _Color); + o.Albedo = c.xyz ; + o.Alpha = c.w ; + o.Normal = vec3( UnpackNormal( texture2D( _BumpMap, IN.uv_BumpMap))); +} +vec4 LightingLambert_PrePass( in SurfaceOutput s, in vec4 light ) { + vec4 c; + c.xyz = (s.Albedo * light.xyz ); + c.w = s.Alpha; + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec4 light; + vec4 col; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + surf( surfIN, o); + light = texture2DProj( _LightBuffer, IN.hip_screen); + light = ( -log2( light ) ); + light.xyz += unity_Ambient.xyz ; + col = LightingLambert_PrePass( o, light); + return col; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec2( gl_TexCoord[0]); + xlt_IN.hip_screen = vec4( gl_TexCoord[1]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Bumped_Diffuse1-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Bumped_Diffuse1-ir.txt new file mode 100644 index 000000000..ed5b5cdf3 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Bumped_Diffuse1-ir.txt @@ -0,0 +1,163 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 hip_screen; +}; +varying vec4 xlv_FOG; +uniform vec4 unity_Ambient; +uniform sampler2D _MainTex; +uniform sampler2D _LightBuffer; +uniform vec4 _Color; +uniform sampler2D _BumpMap; +vec4 UnpackNormal ( + in vec4 packednormal +) +{ + vec4 normal; + vec2 tmpvar_1; + tmpvar_1 = ((packednormal.wy * 2.0) - 1.0); + normal.xy = tmpvar_1.xy.xy; + float tmpvar_2; + tmpvar_2 = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + normal.z = vec3(tmpvar_3).z; + return normal; +} + +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 c; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = (tmpvar_1 * _Color); + c = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = c.xyz; + o.Albedo = tmpvar_3; + float tmpvar_4; + tmpvar_4 = c.w; + o.Alpha = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = texture2D (_BumpMap, IN.uv_BumpMap); + vec4 tmpvar_6; + tmpvar_6 = UnpackNormal (tmpvar_5); + vec3 tmpvar_7; + tmpvar_7 = tmpvar_6.xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + o.Normal = tmpvar_8; +} + +vec4 LightingLambert_PrePass ( + in SurfaceOutput s, + in vec4 light +) +{ + vec4 c; + vec3 tmpvar_1; + tmpvar_1 = (s.Albedo * light.xyz); + c.xyz = tmpvar_1.xyz.xyz; + float tmpvar_2; + tmpvar_2 = s.Alpha; + c.w = vec4(tmpvar_2).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 col; + vec4 light; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_3; + float tmpvar_4; + tmpvar_4 = 0.0; + o.Specular = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Alpha = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Gloss = tmpvar_6; + surf (surfIN, o); + vec4 tmpvar_7; + tmpvar_7 = texture2DProj (_LightBuffer, IN.hip_screen); + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + light = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = log2 (light); + vec4 tmpvar_10; + tmpvar_10 = -(tmpvar_9); + light = tmpvar_10; + vec3 tmpvar_11; + tmpvar_11 = (light.xyz + unity_Ambient.xyz); + light.xyz = tmpvar_11.xyz.xyz; + vec4 tmpvar_12; + tmpvar_12 = LightingLambert_PrePass (o, light); + vec4 tmpvar_13; + tmpvar_13 = tmpvar_12; + col = tmpvar_13; + return col; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xy; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyzw; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.hip_screen = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = frag_surf (xlt_IN); + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xl_retval = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = xl_retval.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + gl_FragData[0] = tmpvar_10; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Bumped_Diffuse1-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Bumped_Diffuse1-out.txt new file mode 100644 index 000000000..43ddd4de4 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Bumped_Diffuse1-out.txt @@ -0,0 +1,24 @@ +uniform vec4 unity_Ambient; +uniform sampler2D _MainTex; +uniform sampler2D _LightBuffer; +uniform vec4 _Color; +uniform sampler2D _BumpMap; +void main () +{ + vec4 light; + vec2 tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = (texture2D (_MainTex, gl_TexCoord[0].xy) * _Color); + vec4 normal; + normal.xy = ((texture2D (_BumpMap, tmpvar_1).wy * 2.0) - 1.0); + normal.z = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + vec4 tmpvar_3; + tmpvar_3 = -(log2 (texture2DProj (_LightBuffer, gl_TexCoord[1]))); + light = tmpvar_3; + light.xyz = (tmpvar_3.xyz + unity_Ambient.xyz); + vec4 c_i0; + c_i0.xyz = (tmpvar_2.xyz * light.xyz); + c_i0.w = tmpvar_2.w; + gl_FragData[0] = c_i0; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Bumped_Specular-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Bumped_Specular-in.txt new file mode 100644 index 000000000..d05216ad5 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Bumped_Specular-in.txt @@ -0,0 +1,120 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 viewDir; + vec3 lightDir; + vec3 vlight; + vec4 _ShadowCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform sampler2D _BumpMap; +uniform vec4 _Color; +uniform vec4 _LightColor0; +uniform sampler2D _MainTex; +uniform sampler2D _ShadowMapTexture; +uniform float _Shininess; +uniform vec4 _SpecColor; +float unitySampleShadow( in vec4 shadowCoord ); +vec4 UnpackNormal( in vec4 packednormal ); +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingBlinnPhong( in SurfaceOutput s, in vec3 lightDir, in vec3 viewDir, in float atten ); +vec4 frag_surf( in v2f_surf IN ); +float unitySampleShadow( in vec4 shadowCoord ) { + float shadow; + shadow = texture2DProj( _ShadowMapTexture, shadowCoord).x ; + return shadow; +} +vec4 UnpackNormal( in vec4 packednormal ) { + vec4 normal; + normal.xy = ((packednormal.wy * 2.00000) - 1.00000); + normal.z = sqrt( ((1.00000 - (normal.x * normal.x )) - (normal.y * normal.y )) ); + return normal; +} +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 tex; + tex = texture2D( _MainTex, IN.uv_MainTex); + o.Albedo = (tex.xyz * _Color.xyz ); + o.Gloss = tex.w ; + o.Alpha = (tex.w * _Color.w ); + o.Specular = _Shininess; + o.Normal = vec3( UnpackNormal( texture2D( _BumpMap, IN.uv_BumpMap))); +} +vec4 LightingBlinnPhong( in SurfaceOutput s, in vec3 lightDir, in vec3 viewDir, in float atten ) { + vec3 h; + float diff; + float nh; + float spec; + vec4 c; + h = normalize( (lightDir + viewDir) ); + diff = max( 0.000000, dot( s.Normal, lightDir)); + nh = max( 0.000000, dot( s.Normal, h)); + spec = (pow( nh, (s.Specular * 128.000)) * s.Gloss); + c.xyz = ((((s.Albedo * _LightColor0.xyz ) * diff) + ((_LightColor0.xyz * _SpecColor.xyz ) * spec)) * (atten * 2.00000)); + c.w = (s.Alpha + (((_LightColor0.w * _SpecColor.w ) * spec) * atten)); + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + float atten; + vec4 c; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + surfIN.uv_BumpMap = IN.hip_pack0.zw ; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + surf( surfIN, o); + atten = unitySampleShadow( IN._ShadowCoord); + c = LightingBlinnPhong( o, IN.lightDir, normalize( vec3( IN.viewDir) ), atten); + c.xyz += (o.Albedo * IN.vlight); + return c; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec4( gl_TexCoord[0]); + xlt_IN.viewDir = vec3( gl_TexCoord[1]); + xlt_IN.lightDir = vec3( gl_TexCoord[2]); + xlt_IN.vlight = vec3( gl_TexCoord[3]); + xlt_IN._ShadowCoord = vec4( gl_TexCoord[4]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Bumped_Specular-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Bumped_Specular-ir.txt new file mode 100644 index 000000000..ceacd3fca --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Bumped_Specular-ir.txt @@ -0,0 +1,234 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 viewDir; + vec3 lightDir; + vec3 vlight; + vec4 _ShadowCoord; +}; +varying vec4 xlv_FOG; +uniform vec4 _SpecColor; +uniform float _Shininess; +uniform sampler2D _ShadowMapTexture; +uniform sampler2D _MainTex; +uniform vec4 _LightColor0; +uniform vec4 _Color; +uniform sampler2D _BumpMap; +float unitySampleShadow ( + in vec4 shadowCoord +) +{ + float shadow; + vec4 tmpvar_1; + tmpvar_1 = texture2DProj (_ShadowMapTexture, shadowCoord); + float tmpvar_2; + tmpvar_2 = tmpvar_1.x; + shadow = tmpvar_2; + return shadow; +} + +vec4 UnpackNormal ( + in vec4 packednormal +) +{ + vec4 normal; + vec2 tmpvar_1; + tmpvar_1 = ((packednormal.wy * 2.0) - 1.0); + normal.xy = tmpvar_1.xy.xy; + float tmpvar_2; + tmpvar_2 = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + normal.z = vec3(tmpvar_3).z; + return normal; +} + +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 tex; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + tex = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = (tex.xyz * _Color.xyz); + o.Albedo = tmpvar_3; + float tmpvar_4; + tmpvar_4 = tex.w; + o.Gloss = tmpvar_4; + float tmpvar_5; + tmpvar_5 = (tex.w * _Color.w); + o.Alpha = tmpvar_5; + float tmpvar_6; + tmpvar_6 = _Shininess; + o.Specular = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = texture2D (_BumpMap, IN.uv_BumpMap); + vec4 tmpvar_8; + tmpvar_8 = UnpackNormal (tmpvar_7); + vec3 tmpvar_9; + tmpvar_9 = tmpvar_8.xyz; + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + o.Normal = tmpvar_10; +} + +vec4 LightingBlinnPhong ( + in SurfaceOutput s, + in vec3 lightDir, + in vec3 viewDir, + in float atten +) +{ + vec4 c; + float spec; + float nh; + float diff; + vec3 h; + vec3 tmpvar_1; + tmpvar_1 = normalize ((lightDir + viewDir)); + vec3 tmpvar_2; + tmpvar_2 = tmpvar_1; + h = tmpvar_2; + float tmpvar_3; + tmpvar_3 = dot (s.Normal, lightDir); + float tmpvar_4; + tmpvar_4 = max (0.0, tmpvar_3); + float tmpvar_5; + tmpvar_5 = tmpvar_4; + diff = tmpvar_5; + float tmpvar_6; + tmpvar_6 = dot (s.Normal, h); + float tmpvar_7; + tmpvar_7 = max (0.0, tmpvar_6); + float tmpvar_8; + tmpvar_8 = tmpvar_7; + nh = tmpvar_8; + float tmpvar_9; + tmpvar_9 = pow (nh, (s.Specular * 128.0)); + float tmpvar_10; + tmpvar_10 = (tmpvar_9 * s.Gloss); + spec = tmpvar_10; + vec3 tmpvar_11; + tmpvar_11 = ((((s.Albedo * _LightColor0.xyz) * diff) + ((_LightColor0.xyz * _SpecColor.xyz) * spec)) * (atten * 2.0)); + c.xyz = tmpvar_11.xyz.xyz; + float tmpvar_12; + tmpvar_12 = (s.Alpha + (((_LightColor0.w * _SpecColor.w) * spec) * atten)); + c.w = vec4(tmpvar_12).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 c; + float atten; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = IN.hip_pack0.zw; + surfIN.uv_BumpMap = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Specular = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Alpha = tmpvar_6; + float tmpvar_7; + tmpvar_7 = 0.0; + o.Gloss = tmpvar_7; + surf (surfIN, o); + float tmpvar_8; + tmpvar_8 = unitySampleShadow (IN._ShadowCoord); + float tmpvar_9; + tmpvar_9 = tmpvar_8; + atten = tmpvar_9; + vec3 tmpvar_10; + tmpvar_10 = IN.viewDir.xyz; + vec3 tmpvar_11; + tmpvar_11 = normalize (tmpvar_10); + vec4 tmpvar_12; + tmpvar_12 = LightingBlinnPhong (o, IN.lightDir, tmpvar_11, atten); + vec4 tmpvar_13; + tmpvar_13 = tmpvar_12; + c = tmpvar_13; + vec3 tmpvar_14; + tmpvar_14 = (c.xyz + (o.Albedo * IN.vlight)); + c.xyz = tmpvar_14.xyz.xyz; + return c; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.viewDir = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.lightDir = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = gl_TexCoord[3].xyz; + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_IN.vlight = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_TexCoord[4].xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_IN._ShadowCoord = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = frag_surf (xlt_IN); + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_FragData[0] = tmpvar_16; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Bumped_Specular-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Bumped_Specular-out.txt new file mode 100644 index 000000000..7251aaf95 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Bumped_Specular-out.txt @@ -0,0 +1,35 @@ +uniform vec4 _SpecColor; +uniform float _Shininess; +uniform sampler2D _ShadowMapTexture; +uniform sampler2D _MainTex; +uniform vec4 _LightColor0; +uniform vec4 _Color; +uniform sampler2D _BumpMap; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = gl_TexCoord[0]; + vec3 tmpvar_2; + tmpvar_2 = gl_TexCoord[2].xyz; + vec4 c; + vec4 tmpvar_3; + tmpvar_3 = texture2D (_MainTex, tmpvar_1.xy); + vec3 tmpvar_4; + tmpvar_4 = (tmpvar_3.xyz * _Color.xyz); + vec4 normal; + normal.xy = ((texture2D (_BumpMap, tmpvar_1.zw).wy * 2.0) - 1.0); + normal.z = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + vec3 tmpvar_5; + tmpvar_5 = normal.xyz; + vec4 tmpvar_6; + tmpvar_6 = texture2DProj (_ShadowMapTexture, gl_TexCoord[4]); + vec4 c_i0; + float tmpvar_7; + tmpvar_7 = (pow (max (0.0, dot (tmpvar_5, normalize ((tmpvar_2 + normalize (gl_TexCoord[1].xyz))))), (_Shininess * 128.0)) * tmpvar_3.w); + c_i0.xyz = ((((tmpvar_4 * _LightColor0.xyz) * max (0.0, dot (tmpvar_5, tmpvar_2))) + ((_LightColor0.xyz * _SpecColor.xyz) * tmpvar_7)) * (tmpvar_6.x * 2.0)); + c_i0.w = ((tmpvar_3.w * _Color.w) + (((_LightColor0.w * _SpecColor.w) * tmpvar_7) * tmpvar_6.x)); + c = c_i0; + c.xyz = (c_i0.xyz + (tmpvar_4 * gl_TexCoord[3].xyz)); + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Bumped_Specular1-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Bumped_Specular1-in.txt new file mode 100644 index 000000000..a0abf0162 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Bumped_Specular1-in.txt @@ -0,0 +1,112 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 lightDir; + vec3 viewDir; + vec2 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform sampler2D _BumpMap; +uniform vec4 _Color; +uniform vec4 _LightColor0; +uniform sampler2D _LightTexture0; +uniform sampler2D _MainTex; +uniform float _Shininess; +uniform vec4 _SpecColor; +vec4 UnpackNormal( in vec4 packednormal ); +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingBlinnPhong( in SurfaceOutput s, in vec3 lightDir, in vec3 viewDir, in float atten ); +vec4 frag_surf( in v2f_surf IN ); +vec4 UnpackNormal( in vec4 packednormal ) { + vec4 normal; + normal.xy = ((packednormal.wy * 2.00000) - 1.00000); + normal.z = sqrt( ((1.00000 - (normal.x * normal.x )) - (normal.y * normal.y )) ); + return normal; +} +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 tex; + tex = texture2D( _MainTex, IN.uv_MainTex); + o.Albedo = (tex.xyz * _Color.xyz ); + o.Gloss = tex.w ; + o.Alpha = (tex.w * _Color.w ); + o.Specular = _Shininess; + o.Normal = vec3( UnpackNormal( texture2D( _BumpMap, IN.uv_BumpMap))); +} +vec4 LightingBlinnPhong( in SurfaceOutput s, in vec3 lightDir, in vec3 viewDir, in float atten ) { + vec3 h; + float diff; + float nh; + float spec; + vec4 c; + h = normalize( (lightDir + viewDir) ); + diff = max( 0.000000, dot( s.Normal, lightDir)); + nh = max( 0.000000, dot( s.Normal, h)); + spec = (pow( nh, (s.Specular * 128.000)) * s.Gloss); + c.xyz = ((((s.Albedo * _LightColor0.xyz ) * diff) + ((_LightColor0.xyz * _SpecColor.xyz ) * spec)) * (atten * 2.00000)); + c.w = (s.Alpha + (((_LightColor0.w * _SpecColor.w ) * spec) * atten)); + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec3 lightDir; + vec4 c; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + surfIN.uv_BumpMap = IN.hip_pack0.zw ; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + surf( surfIN, o); + lightDir = IN.lightDir; + c = LightingBlinnPhong( o, lightDir, normalize( vec3( IN.viewDir) ), (texture2D( _LightTexture0, IN._LightCoord).w * 1.00000)); + c.w = 0.000000; + return c; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec4( gl_TexCoord[0]); + xlt_IN.lightDir = vec3( gl_TexCoord[1]); + xlt_IN.viewDir = vec3( gl_TexCoord[2]); + xlt_IN._LightCoord = vec2( gl_TexCoord[3]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Bumped_Specular1-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Bumped_Specular1-ir.txt new file mode 100644 index 000000000..7c3e615ea --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Bumped_Specular1-ir.txt @@ -0,0 +1,215 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 lightDir; + vec3 viewDir; + vec2 _LightCoord; +}; +varying vec4 xlv_FOG; +uniform vec4 _SpecColor; +uniform float _Shininess; +uniform sampler2D _MainTex; +uniform sampler2D _LightTexture0; +uniform vec4 _LightColor0; +uniform vec4 _Color; +uniform sampler2D _BumpMap; +vec4 UnpackNormal ( + in vec4 packednormal +) +{ + vec4 normal; + vec2 tmpvar_1; + tmpvar_1 = ((packednormal.wy * 2.0) - 1.0); + normal.xy = tmpvar_1.xy.xy; + float tmpvar_2; + tmpvar_2 = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + normal.z = vec3(tmpvar_3).z; + return normal; +} + +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 tex; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + tex = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = (tex.xyz * _Color.xyz); + o.Albedo = tmpvar_3; + float tmpvar_4; + tmpvar_4 = tex.w; + o.Gloss = tmpvar_4; + float tmpvar_5; + tmpvar_5 = (tex.w * _Color.w); + o.Alpha = tmpvar_5; + float tmpvar_6; + tmpvar_6 = _Shininess; + o.Specular = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = texture2D (_BumpMap, IN.uv_BumpMap); + vec4 tmpvar_8; + tmpvar_8 = UnpackNormal (tmpvar_7); + vec3 tmpvar_9; + tmpvar_9 = tmpvar_8.xyz; + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + o.Normal = tmpvar_10; +} + +vec4 LightingBlinnPhong ( + in SurfaceOutput s, + in vec3 lightDir, + in vec3 viewDir, + in float atten +) +{ + vec4 c; + float spec; + float nh; + float diff; + vec3 h; + vec3 tmpvar_1; + tmpvar_1 = normalize ((lightDir + viewDir)); + vec3 tmpvar_2; + tmpvar_2 = tmpvar_1; + h = tmpvar_2; + float tmpvar_3; + tmpvar_3 = dot (s.Normal, lightDir); + float tmpvar_4; + tmpvar_4 = max (0.0, tmpvar_3); + float tmpvar_5; + tmpvar_5 = tmpvar_4; + diff = tmpvar_5; + float tmpvar_6; + tmpvar_6 = dot (s.Normal, h); + float tmpvar_7; + tmpvar_7 = max (0.0, tmpvar_6); + float tmpvar_8; + tmpvar_8 = tmpvar_7; + nh = tmpvar_8; + float tmpvar_9; + tmpvar_9 = pow (nh, (s.Specular * 128.0)); + float tmpvar_10; + tmpvar_10 = (tmpvar_9 * s.Gloss); + spec = tmpvar_10; + vec3 tmpvar_11; + tmpvar_11 = ((((s.Albedo * _LightColor0.xyz) * diff) + ((_LightColor0.xyz * _SpecColor.xyz) * spec)) * (atten * 2.0)); + c.xyz = tmpvar_11.xyz.xyz; + float tmpvar_12; + tmpvar_12 = (s.Alpha + (((_LightColor0.w * _SpecColor.w) * spec) * atten)); + c.w = vec4(tmpvar_12).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 c; + vec3 lightDir; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = IN.hip_pack0.zw; + surfIN.uv_BumpMap = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Specular = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Alpha = tmpvar_6; + float tmpvar_7; + tmpvar_7 = 0.0; + o.Gloss = tmpvar_7; + surf (surfIN, o); + vec3 tmpvar_8; + tmpvar_8 = IN.lightDir; + lightDir = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = IN.viewDir.xyz; + vec3 tmpvar_10; + tmpvar_10 = normalize (tmpvar_9); + vec4 tmpvar_11; + tmpvar_11 = texture2D (_LightTexture0, IN._LightCoord); + vec4 tmpvar_12; + tmpvar_12 = LightingBlinnPhong (o, lightDir, tmpvar_10, (tmpvar_11.w * 1.0)); + vec4 tmpvar_13; + tmpvar_13 = tmpvar_12; + c = tmpvar_13; + float tmpvar_14; + tmpvar_14 = 0.0; + c.w = vec4(tmpvar_14).w; + return c; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.lightDir = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.viewDir = tmpvar_8; + vec2 tmpvar_9; + tmpvar_9 = gl_TexCoord[3].xy; + vec2 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_IN._LightCoord = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = frag_surf (xlt_IN); + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xl_retval = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = xl_retval.xyzw; + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + gl_FragData[0] = tmpvar_14; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Bumped_Specular1-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Bumped_Specular1-out.txt new file mode 100644 index 000000000..3336332ef --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Bumped_Specular1-out.txt @@ -0,0 +1,33 @@ +uniform vec4 _SpecColor; +uniform float _Shininess; +uniform sampler2D _MainTex; +uniform sampler2D _LightTexture0; +uniform vec4 _LightColor0; +uniform vec4 _Color; +uniform sampler2D _BumpMap; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = gl_TexCoord[0]; + vec3 tmpvar_2; + tmpvar_2 = gl_TexCoord[1].xyz; + vec4 c; + vec4 tmpvar_3; + tmpvar_3 = texture2D (_MainTex, tmpvar_1.xy); + vec4 normal; + normal.xy = ((texture2D (_BumpMap, tmpvar_1.zw).wy * 2.0) - 1.0); + normal.z = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + vec3 tmpvar_4; + tmpvar_4 = normal.xyz; + float atten; + atten = texture2D (_LightTexture0, gl_TexCoord[3].xy).w; + vec4 c_i0; + float tmpvar_5; + tmpvar_5 = (pow (max (0.0, dot (tmpvar_4, normalize ((tmpvar_2 + normalize (gl_TexCoord[2].xyz))))), (_Shininess * 128.0)) * tmpvar_3.w); + c_i0.xyz = (((((tmpvar_3.xyz * _Color.xyz) * _LightColor0.xyz) * max (0.0, dot (tmpvar_4, tmpvar_2))) + ((_LightColor0.xyz * _SpecColor.xyz) * tmpvar_5)) * (atten * 2.0)); + c_i0.w = ((tmpvar_3.w * _Color.w) + (((_LightColor0.w * _SpecColor.w) * tmpvar_5) * atten)); + c = c_i0; + c.w = 0.0; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Bumped_Specular2-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Bumped_Specular2-in.txt new file mode 100644 index 000000000..07ca232a4 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Bumped_Specular2-in.txt @@ -0,0 +1,136 @@ +float xll_saturate( float x) { + return clamp( x, 0.0, 1.0); +} +vec2 xll_saturate( vec2 x) { + return clamp( x, 0.0, 1.0); +} +vec3 xll_saturate( vec3 x) { + return clamp( x, 0.0, 1.0); +} +vec4 xll_saturate( vec4 x) { + return clamp( x, 0.0, 1.0); +} +mat2 xll_saturate(mat2 m) { + return mat2( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0)); +} +mat3 xll_saturate(mat3 m) { + return mat3( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0), clamp(m[2], 0.0, 1.0)); +} +mat4 xll_saturate(mat4 m) { + return mat4( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0), clamp(m[2], 0.0, 1.0), clamp(m[3], 0.0, 1.0)); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 hip_screen; + vec3 hip_lmapFade; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform sampler2D _BumpMap; +uniform vec4 _Color; +uniform sampler2D _LightBuffer; +uniform sampler2D _MainTex; +uniform float _Shininess; +uniform vec4 _SpecColor; +uniform sampler2D unity_Lightmap; +uniform sampler2D unity_LightmapInd; +vec4 UnpackNormal( in vec4 packednormal ); +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingBlinnPhong_PrePass( in SurfaceOutput s, in vec4 light ); +vec3 DecodeLightmap( in vec4 color ); +vec4 frag_surf( in v2f_surf IN ); +vec4 UnpackNormal( in vec4 packednormal ) { + vec4 normal; + normal.xy = ((packednormal.wy * 2.00000) - 1.00000); + normal.z = sqrt( ((1.00000 - (normal.x * normal.x )) - (normal.y * normal.y )) ); + return normal; +} +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 tex; + tex = texture2D( _MainTex, IN.uv_MainTex); + o.Albedo = (tex.xyz * _Color.xyz ); + o.Gloss = tex.w ; + o.Alpha = (tex.w * _Color.w ); + o.Specular = _Shininess; + o.Normal = vec3( UnpackNormal( texture2D( _BumpMap, IN.uv_BumpMap))); +} +vec4 LightingBlinnPhong_PrePass( in SurfaceOutput s, in vec4 light ) { + float spec; + vec4 c; + spec = (light.w * s.Gloss); + c.xyz = ((s.Albedo * light.xyz ) + ((light.xyz * _SpecColor.xyz ) * spec)); + c.w = (s.Alpha + (spec * _SpecColor.w )); + return c; +} +vec3 DecodeLightmap( in vec4 color ) { + return (2.00000 * color.xyz ); +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec4 light; + vec3 lmFull; + vec3 lmIndirect; + vec3 lm; + vec4 col; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + surf( surfIN, o); + light = texture2DProj( _LightBuffer, IN.hip_screen); + light = ( -log2( light ) ); + lmFull = DecodeLightmap( texture2D( unity_Lightmap, IN.hip_lmapFade.xy )); + lmIndirect = DecodeLightmap( texture2D( unity_LightmapInd, IN.hip_lmapFade.xy )); + lm = mix( lmIndirect, lmFull, vec3( xll_saturate( IN.hip_lmapFade.z ))); + light.xyz += lm; + col = LightingBlinnPhong_PrePass( o, light); + return col; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec2( gl_TexCoord[0]); + xlt_IN.hip_screen = vec4( gl_TexCoord[1]); + xlt_IN.hip_lmapFade = vec3( gl_TexCoord[2]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Bumped_Specular2-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Bumped_Specular2-ir.txt new file mode 100644 index 000000000..6dad1fa3b --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Bumped_Specular2-ir.txt @@ -0,0 +1,320 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 hip_screen; + vec3 hip_lmapFade; +}; +varying vec4 xlv_FOG; +uniform sampler2D unity_LightmapInd; +uniform sampler2D unity_Lightmap; +uniform vec4 _SpecColor; +uniform float _Shininess; +uniform sampler2D _MainTex; +uniform sampler2D _LightBuffer; +uniform vec4 _Color; +uniform sampler2D _BumpMap; +float xll_saturate ( + in float x +) +{ + float tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec2 xll_saturate ( + in vec2 x +) +{ + vec2 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec3 xll_saturate ( + in vec3 x +) +{ + vec3 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec4 xll_saturate ( + in vec4 x +) +{ + vec4 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +mat2 xll_saturate ( + in mat2 m +) +{ + vec2 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec2 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + mat2 tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_1; + tmpvar_3[0] = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5 = tmpvar_2; + tmpvar_3[1] = tmpvar_5; + return tmpvar_3; +} + +mat3 xll_saturate ( + in mat3 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec3 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + vec3 tmpvar_3; + tmpvar_3 = clamp (m[2], 0.0, 1.0); + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +mat4 xll_saturate ( + in mat4 m +) +{ + vec4 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec4 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + vec4 tmpvar_3; + tmpvar_3 = clamp (m[2], 0.0, 1.0); + vec4 tmpvar_4; + tmpvar_4 = clamp (m[3], 0.0, 1.0); + mat4 tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_1; + tmpvar_5[0] = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = tmpvar_2; + tmpvar_5[1] = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_3; + tmpvar_5[2] = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = tmpvar_4; + tmpvar_5[3] = tmpvar_9; + return tmpvar_5; +} + +vec4 UnpackNormal ( + in vec4 packednormal +) +{ + vec4 normal; + vec2 tmpvar_1; + tmpvar_1 = ((packednormal.wy * 2.0) - 1.0); + normal.xy = tmpvar_1.xy.xy; + float tmpvar_2; + tmpvar_2 = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + normal.z = vec3(tmpvar_3).z; + return normal; +} + +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 tex; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + tex = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = (tex.xyz * _Color.xyz); + o.Albedo = tmpvar_3; + float tmpvar_4; + tmpvar_4 = tex.w; + o.Gloss = tmpvar_4; + float tmpvar_5; + tmpvar_5 = (tex.w * _Color.w); + o.Alpha = tmpvar_5; + float tmpvar_6; + tmpvar_6 = _Shininess; + o.Specular = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = texture2D (_BumpMap, IN.uv_BumpMap); + vec4 tmpvar_8; + tmpvar_8 = UnpackNormal (tmpvar_7); + vec3 tmpvar_9; + tmpvar_9 = tmpvar_8.xyz; + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + o.Normal = tmpvar_10; +} + +vec4 LightingBlinnPhong_PrePass ( + in SurfaceOutput s, + in vec4 light +) +{ + vec4 c; + float spec; + float tmpvar_1; + tmpvar_1 = (light.w * s.Gloss); + spec = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = ((s.Albedo * light.xyz) + ((light.xyz * _SpecColor.xyz) * spec)); + c.xyz = tmpvar_2.xyz.xyz; + float tmpvar_3; + tmpvar_3 = (s.Alpha + (spec * _SpecColor.w)); + c.w = vec4(tmpvar_3).w; + return c; +} + +vec3 DecodeLightmap ( + in vec4 color +) +{ + return (2.0 * color.xyz); +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 col; + vec3 lm; + vec3 lmIndirect; + vec3 lmFull; + vec4 light; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_3; + float tmpvar_4; + tmpvar_4 = 0.0; + o.Specular = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Alpha = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Gloss = tmpvar_6; + surf (surfIN, o); + vec4 tmpvar_7; + tmpvar_7 = texture2DProj (_LightBuffer, IN.hip_screen); + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + light = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = log2 (light); + vec4 tmpvar_10; + tmpvar_10 = -(tmpvar_9); + light = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = texture2D (unity_Lightmap, IN.hip_lmapFade.xy); + vec3 tmpvar_12; + tmpvar_12 = DecodeLightmap (tmpvar_11); + vec3 tmpvar_13; + tmpvar_13 = tmpvar_12; + lmFull = tmpvar_13; + vec4 tmpvar_14; + tmpvar_14 = texture2D (unity_LightmapInd, IN.hip_lmapFade.xy); + vec3 tmpvar_15; + tmpvar_15 = DecodeLightmap (tmpvar_14); + vec3 tmpvar_16; + tmpvar_16 = tmpvar_15; + lmIndirect = tmpvar_16; + float tmpvar_17; + tmpvar_17 = xll_saturate (IN.hip_lmapFade.z); + vec3 tmpvar_18; + tmpvar_18 = vec3(tmpvar_17); + vec3 tmpvar_19; + tmpvar_19 = mix (lmIndirect, lmFull, tmpvar_18); + vec3 tmpvar_20; + tmpvar_20 = tmpvar_19; + lm = tmpvar_20; + vec3 tmpvar_21; + tmpvar_21 = (light.xyz + lm); + light.xyz = tmpvar_21.xyz.xyz; + vec4 tmpvar_22; + tmpvar_22 = LightingBlinnPhong_PrePass (o, light); + vec4 tmpvar_23; + tmpvar_23 = tmpvar_22; + col = tmpvar_23; + return col; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xy; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyzw; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.hip_screen = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.hip_lmapFade = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = frag_surf (xlt_IN); + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xl_retval = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = xl_retval.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + gl_FragData[0] = tmpvar_12; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Bumped_Specular2-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Bumped_Specular2-out.txt new file mode 100644 index 000000000..167aba285 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Bumped_Specular2-out.txt @@ -0,0 +1,30 @@ +uniform sampler2D unity_LightmapInd; +uniform sampler2D unity_Lightmap; +uniform vec4 _SpecColor; +uniform sampler2D _MainTex; +uniform sampler2D _LightBuffer; +uniform vec4 _Color; +uniform sampler2D _BumpMap; +void main () +{ + vec3 tmpvar_1; + tmpvar_1 = gl_TexCoord[2].xyz; + vec4 light; + vec2 tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = texture2D (_MainTex, gl_TexCoord[0].xy); + vec4 normal; + normal.xy = ((texture2D (_BumpMap, tmpvar_2).wy * 2.0) - 1.0); + normal.z = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + vec4 tmpvar_4; + tmpvar_4 = -(log2 (texture2DProj (_LightBuffer, gl_TexCoord[1]))); + light = tmpvar_4; + light.xyz = (tmpvar_4.xyz + mix ((2.0 * texture2D (unity_LightmapInd, tmpvar_1.xy).xyz), (2.0 * texture2D (unity_Lightmap, tmpvar_1.xy).xyz), vec3(clamp (tmpvar_1.z, 0.0, 1.0)))); + vec4 c; + float tmpvar_5; + tmpvar_5 = (tmpvar_4.w * tmpvar_3.w); + c.xyz = (((tmpvar_3.xyz * _Color.xyz) * light.xyz) + ((light.xyz * _SpecColor.xyz) * tmpvar_5)); + c.w = ((tmpvar_3.w * _Color.w) + (tmpvar_5 * _SpecColor.w)); + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Decal-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Decal-in.txt new file mode 100644 index 000000000..cebc6e2ac --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Decal-in.txt @@ -0,0 +1,96 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_DecalTex; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 normal; + vec3 lightDir; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _Color; +uniform sampler2D _DecalTex; +uniform vec4 _LightColor0; +uniform sampler2D _MainTex; +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ); +vec4 frag_surf( in v2f_surf IN ); +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 c; + vec4 decal; + c = texture2D( _MainTex, IN.uv_MainTex); + decal = texture2D( _DecalTex, IN.uv_DecalTex); + c.xyz = mix( c.xyz , decal.xyz , vec3( decal.w )); + c *= _Color; + o.Albedo = c.xyz ; + o.Alpha = c.w ; +} +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ) { + float diff; + vec4 c; + diff = max( 0.000000, dot( s.Normal, lightDir)); + c.xyz = ((s.Albedo * _LightColor0.xyz ) * ((diff * atten) * 2.00000)); + c.w = s.Alpha; + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec3 lightDir; + vec4 c; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + surfIN.uv_DecalTex = IN.hip_pack0.zw ; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + o.Normal = IN.normal; + surf( surfIN, o); + lightDir = IN.lightDir; + c = LightingLambert( o, lightDir, 1.00000); + c.w = 0.000000; + return c; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec4( gl_TexCoord[0]); + xlt_IN.normal = vec3( gl_TexCoord[1]); + xlt_IN.lightDir = vec3( gl_TexCoord[2]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Decal-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Decal-ir.txt new file mode 100644 index 000000000..fb8a69493 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Decal-ir.txt @@ -0,0 +1,167 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_DecalTex; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 normal; + vec3 lightDir; +}; +varying vec4 xlv_FOG; +uniform sampler2D _MainTex; +uniform vec4 _LightColor0; +uniform sampler2D _DecalTex; +uniform vec4 _Color; +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 decal; + vec4 c; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + c = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = texture2D (_DecalTex, IN.uv_DecalTex); + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + decal = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = vec3(decal.w); + vec3 tmpvar_6; + tmpvar_6 = mix (c.xyz, decal.xyz, tmpvar_5); + vec3 tmpvar_7; + tmpvar_7 = tmpvar_6; + c.xyz = tmpvar_7.xyz.xyz; + vec4 tmpvar_8; + tmpvar_8 = (c * _Color); + c = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = c.xyz; + o.Albedo = tmpvar_9; + float tmpvar_10; + tmpvar_10 = c.w; + o.Alpha = tmpvar_10; +} + +vec4 LightingLambert ( + in SurfaceOutput s, + in vec3 lightDir, + in float atten +) +{ + vec4 c; + float diff; + float tmpvar_1; + tmpvar_1 = dot (s.Normal, lightDir); + float tmpvar_2; + tmpvar_2 = max (0.0, tmpvar_1); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + diff = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = ((s.Albedo * _LightColor0.xyz) * ((diff * atten) * 2.0)); + c.xyz = tmpvar_4.xyz.xyz; + float tmpvar_5; + tmpvar_5 = s.Alpha; + c.w = vec4(tmpvar_5).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 c; + vec3 lightDir; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = IN.hip_pack0.zw; + surfIN.uv_DecalTex = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Specular = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Alpha = tmpvar_6; + float tmpvar_7; + tmpvar_7 = 0.0; + o.Gloss = tmpvar_7; + vec3 tmpvar_8; + tmpvar_8 = IN.normal; + o.Normal = tmpvar_8; + surf (surfIN, o); + vec3 tmpvar_9; + tmpvar_9 = IN.lightDir; + lightDir = tmpvar_9; + vec4 tmpvar_10; + tmpvar_10 = LightingLambert (o, lightDir, 1.0); + vec4 tmpvar_11; + tmpvar_11 = tmpvar_10; + c = tmpvar_11; + float tmpvar_12; + tmpvar_12 = 0.0; + c.w = vec4(tmpvar_12).w; + return c; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.normal = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.lightDir = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = frag_surf (xlt_IN); + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xl_retval = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = xl_retval.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + gl_FragData[0] = tmpvar_12; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Decal-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Decal-out.txt new file mode 100644 index 000000000..f114f3ad6 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Decal-out.txt @@ -0,0 +1,27 @@ +uniform sampler2D _MainTex; +uniform vec4 _LightColor0; +uniform sampler2D _DecalTex; +uniform vec4 _Color; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = gl_TexCoord[0]; + vec4 c; + vec4 c_i0; + vec4 tmpvar_2; + tmpvar_2 = texture2D (_MainTex, tmpvar_1.xy); + c_i0 = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = texture2D (_DecalTex, tmpvar_1.zw); + c_i0.xyz = mix (tmpvar_2.xyz, tmpvar_3.xyz, tmpvar_3.www); + vec4 tmpvar_4; + tmpvar_4 = (c_i0 * _Color); + c_i0 = tmpvar_4; + vec4 c_i0_i1; + c_i0_i1.xyz = ((tmpvar_4.xyz * _LightColor0.xyz) * (max (0.0, dot (gl_TexCoord[1].xyz, gl_TexCoord[2].xyz)) * 2.0)); + c_i0_i1.w = tmpvar_4.w; + c = c_i0_i1; + c.w = 0.0; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Decal1-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Decal1-in.txt new file mode 100644 index 000000000..fd86cf928 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Decal1-in.txt @@ -0,0 +1,99 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_DecalTex; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 normal; + vec3 lightDir; + vec2 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _Color; +uniform sampler2D _DecalTex; +uniform vec4 _LightColor0; +uniform sampler2D _LightTexture0; +uniform sampler2D _MainTex; +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ); +vec4 frag_surf( in v2f_surf IN ); +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 c; + vec4 decal; + c = texture2D( _MainTex, IN.uv_MainTex); + decal = texture2D( _DecalTex, IN.uv_DecalTex); + c.xyz = mix( c.xyz , decal.xyz , vec3( decal.w )); + c *= _Color; + o.Albedo = c.xyz ; + o.Alpha = c.w ; +} +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ) { + float diff; + vec4 c; + diff = max( 0.000000, dot( s.Normal, lightDir)); + c.xyz = ((s.Albedo * _LightColor0.xyz ) * ((diff * atten) * 2.00000)); + c.w = s.Alpha; + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec3 lightDir; + vec4 c; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + surfIN.uv_DecalTex = IN.hip_pack0.zw ; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + o.Normal = IN.normal; + surf( surfIN, o); + lightDir = IN.lightDir; + c = LightingLambert( o, lightDir, (texture2D( _LightTexture0, IN._LightCoord).w * 1.00000)); + c.w = 0.000000; + return c; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec4( gl_TexCoord[0]); + xlt_IN.normal = vec3( gl_TexCoord[1]); + xlt_IN.lightDir = vec3( gl_TexCoord[2]); + xlt_IN._LightCoord = vec2( gl_TexCoord[3]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Decal1-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Decal1-ir.txt new file mode 100644 index 000000000..3b1341ddc --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Decal1-ir.txt @@ -0,0 +1,176 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_DecalTex; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 normal; + vec3 lightDir; + vec2 _LightCoord; +}; +varying vec4 xlv_FOG; +uniform sampler2D _MainTex; +uniform sampler2D _LightTexture0; +uniform vec4 _LightColor0; +uniform sampler2D _DecalTex; +uniform vec4 _Color; +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 decal; + vec4 c; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + c = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = texture2D (_DecalTex, IN.uv_DecalTex); + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + decal = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = vec3(decal.w); + vec3 tmpvar_6; + tmpvar_6 = mix (c.xyz, decal.xyz, tmpvar_5); + vec3 tmpvar_7; + tmpvar_7 = tmpvar_6; + c.xyz = tmpvar_7.xyz.xyz; + vec4 tmpvar_8; + tmpvar_8 = (c * _Color); + c = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = c.xyz; + o.Albedo = tmpvar_9; + float tmpvar_10; + tmpvar_10 = c.w; + o.Alpha = tmpvar_10; +} + +vec4 LightingLambert ( + in SurfaceOutput s, + in vec3 lightDir, + in float atten +) +{ + vec4 c; + float diff; + float tmpvar_1; + tmpvar_1 = dot (s.Normal, lightDir); + float tmpvar_2; + tmpvar_2 = max (0.0, tmpvar_1); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + diff = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = ((s.Albedo * _LightColor0.xyz) * ((diff * atten) * 2.0)); + c.xyz = tmpvar_4.xyz.xyz; + float tmpvar_5; + tmpvar_5 = s.Alpha; + c.w = vec4(tmpvar_5).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 c; + vec3 lightDir; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = IN.hip_pack0.zw; + surfIN.uv_DecalTex = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Specular = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Alpha = tmpvar_6; + float tmpvar_7; + tmpvar_7 = 0.0; + o.Gloss = tmpvar_7; + vec3 tmpvar_8; + tmpvar_8 = IN.normal; + o.Normal = tmpvar_8; + surf (surfIN, o); + vec3 tmpvar_9; + tmpvar_9 = IN.lightDir; + lightDir = tmpvar_9; + vec4 tmpvar_10; + tmpvar_10 = texture2D (_LightTexture0, IN._LightCoord); + vec4 tmpvar_11; + tmpvar_11 = LightingLambert (o, lightDir, (tmpvar_10.w * 1.0)); + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + c = tmpvar_12; + float tmpvar_13; + tmpvar_13 = 0.0; + c.w = vec4(tmpvar_13).w; + return c; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.normal = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.lightDir = tmpvar_8; + vec2 tmpvar_9; + tmpvar_9 = gl_TexCoord[3].xy; + vec2 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_IN._LightCoord = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = frag_surf (xlt_IN); + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xl_retval = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = xl_retval.xyzw; + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + gl_FragData[0] = tmpvar_14; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Decal1-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Decal1-out.txt new file mode 100644 index 000000000..0c1629729 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Decal1-out.txt @@ -0,0 +1,28 @@ +uniform sampler2D _MainTex; +uniform sampler2D _LightTexture0; +uniform vec4 _LightColor0; +uniform sampler2D _DecalTex; +uniform vec4 _Color; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = gl_TexCoord[0]; + vec4 c; + vec4 c_i0; + vec4 tmpvar_2; + tmpvar_2 = texture2D (_MainTex, tmpvar_1.xy); + c_i0 = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = texture2D (_DecalTex, tmpvar_1.zw); + c_i0.xyz = mix (tmpvar_2.xyz, tmpvar_3.xyz, tmpvar_3.www); + vec4 tmpvar_4; + tmpvar_4 = (c_i0 * _Color); + c_i0 = tmpvar_4; + vec4 c_i0_i1; + c_i0_i1.xyz = ((tmpvar_4.xyz * _LightColor0.xyz) * ((max (0.0, dot (gl_TexCoord[1].xyz, gl_TexCoord[2].xyz)) * texture2D (_LightTexture0, gl_TexCoord[3].xy).w) * 2.0)); + c_i0_i1.w = tmpvar_4.w; + c = c_i0_i1; + c.w = 0.0; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Decal2-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Decal2-in.txt new file mode 100644 index 000000000..0e0e728e6 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Decal2-in.txt @@ -0,0 +1,93 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_DecalTex; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec4 hip_screen; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _Color; +uniform sampler2D _DecalTex; +uniform sampler2D _LightBuffer; +uniform sampler2D _MainTex; +uniform vec4 unity_Ambient; +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingLambert_PrePass( in SurfaceOutput s, in vec4 light ); +vec4 frag_surf( in v2f_surf IN ); +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 c; + vec4 decal; + c = texture2D( _MainTex, IN.uv_MainTex); + decal = texture2D( _DecalTex, IN.uv_DecalTex); + c.xyz = mix( c.xyz , decal.xyz , vec3( decal.w )); + c *= _Color; + o.Albedo = c.xyz ; + o.Alpha = c.w ; +} +vec4 LightingLambert_PrePass( in SurfaceOutput s, in vec4 light ) { + vec4 c; + c.xyz = (s.Albedo * light.xyz ); + c.w = s.Alpha; + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec4 light; + vec4 col; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + surfIN.uv_DecalTex = IN.hip_pack0.zw ; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + surf( surfIN, o); + light = texture2DProj( _LightBuffer, IN.hip_screen); + light = ( -log2( light ) ); + light.xyz += unity_Ambient.xyz ; + col = LightingLambert_PrePass( o, light); + return col; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec4( gl_TexCoord[0]); + xlt_IN.hip_screen = vec4( gl_TexCoord[1]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Decal2-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Decal2-ir.txt new file mode 100644 index 000000000..bdae95dea --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Decal2-ir.txt @@ -0,0 +1,157 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_DecalTex; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec4 hip_screen; +}; +varying vec4 xlv_FOG; +uniform vec4 unity_Ambient; +uniform sampler2D _MainTex; +uniform sampler2D _LightBuffer; +uniform sampler2D _DecalTex; +uniform vec4 _Color; +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 decal; + vec4 c; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + c = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = texture2D (_DecalTex, IN.uv_DecalTex); + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + decal = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = vec3(decal.w); + vec3 tmpvar_6; + tmpvar_6 = mix (c.xyz, decal.xyz, tmpvar_5); + vec3 tmpvar_7; + tmpvar_7 = tmpvar_6; + c.xyz = tmpvar_7.xyz.xyz; + vec4 tmpvar_8; + tmpvar_8 = (c * _Color); + c = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = c.xyz; + o.Albedo = tmpvar_9; + float tmpvar_10; + tmpvar_10 = c.w; + o.Alpha = tmpvar_10; +} + +vec4 LightingLambert_PrePass ( + in SurfaceOutput s, + in vec4 light +) +{ + vec4 c; + vec3 tmpvar_1; + tmpvar_1 = (s.Albedo * light.xyz); + c.xyz = tmpvar_1.xyz.xyz; + float tmpvar_2; + tmpvar_2 = s.Alpha; + c.w = vec4(tmpvar_2).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 col; + vec4 light; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = IN.hip_pack0.zw; + surfIN.uv_DecalTex = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Specular = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Alpha = tmpvar_6; + float tmpvar_7; + tmpvar_7 = 0.0; + o.Gloss = tmpvar_7; + surf (surfIN, o); + vec4 tmpvar_8; + tmpvar_8 = texture2DProj (_LightBuffer, IN.hip_screen); + vec4 tmpvar_9; + tmpvar_9 = tmpvar_8; + light = tmpvar_9; + vec4 tmpvar_10; + tmpvar_10 = log2 (light); + vec4 tmpvar_11; + tmpvar_11 = -(tmpvar_10); + light = tmpvar_11; + vec3 tmpvar_12; + tmpvar_12 = (light.xyz + unity_Ambient.xyz); + light.xyz = tmpvar_12.xyz.xyz; + vec4 tmpvar_13; + tmpvar_13 = LightingLambert_PrePass (o, light); + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + col = tmpvar_14; + return col; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyzw; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.hip_screen = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = frag_surf (xlt_IN); + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xl_retval = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = xl_retval.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + gl_FragData[0] = tmpvar_10; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Decal2-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Decal2-out.txt new file mode 100644 index 000000000..99b5c8b3b --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Decal2-out.txt @@ -0,0 +1,30 @@ +uniform vec4 unity_Ambient; +uniform sampler2D _MainTex; +uniform sampler2D _LightBuffer; +uniform sampler2D _DecalTex; +uniform vec4 _Color; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = gl_TexCoord[0]; + vec4 light; + vec4 c; + vec4 tmpvar_2; + tmpvar_2 = texture2D (_MainTex, tmpvar_1.xy); + c = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = texture2D (_DecalTex, tmpvar_1.zw); + c.xyz = mix (tmpvar_2.xyz, tmpvar_3.xyz, tmpvar_3.www); + vec4 tmpvar_4; + tmpvar_4 = (c * _Color); + c = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = -(log2 (texture2DProj (_LightBuffer, gl_TexCoord[1]))); + light = tmpvar_5; + light.xyz = (tmpvar_5.xyz + unity_Ambient.xyz); + vec4 c_i0; + c_i0.xyz = (tmpvar_4.xyz * light.xyz); + c_i0.w = tmpvar_4.w; + gl_FragData[0] = c_i0; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Diffuse-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Diffuse-in.txt new file mode 100644 index 000000000..a93398545 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Diffuse-in.txt @@ -0,0 +1,93 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 normal; + vec3 lightDir; + vec3 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _Color; +uniform vec4 _LightColor0; +uniform sampler2D _LightTexture0; +uniform sampler2D _MainTex; +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ); +vec4 frag_surf( in v2f_surf IN ); +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 c; + c = (texture2D( _MainTex, IN.uv_MainTex) * _Color); + o.Albedo = c.xyz ; + o.Alpha = c.w ; +} +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ) { + float diff; + vec4 c; + diff = max( 0.000000, dot( s.Normal, lightDir)); + c.xyz = ((s.Albedo * _LightColor0.xyz ) * ((diff * atten) * 2.00000)); + c.w = s.Alpha; + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec3 lightDir; + vec4 c; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + o.Normal = IN.normal; + surf( surfIN, o); + lightDir = IN.lightDir; + lightDir = normalize( lightDir ); + c = LightingLambert( o, lightDir, texture2D( _LightTexture0, vec2( vec2( dot( IN._LightCoord, IN._LightCoord)))).w ); + c.w = 0.000000; + return c; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec2( gl_TexCoord[0]); + xlt_IN.normal = vec3( gl_TexCoord[1]); + xlt_IN.lightDir = vec3( gl_TexCoord[2]); + xlt_IN._LightCoord = vec3( gl_TexCoord[3]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Diffuse-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Diffuse-ir.txt new file mode 100644 index 000000000..beb3c35dd --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Diffuse-ir.txt @@ -0,0 +1,166 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 normal; + vec3 lightDir; + vec3 _LightCoord; +}; +varying vec4 xlv_FOG; +uniform sampler2D _MainTex; +uniform sampler2D _LightTexture0; +uniform vec4 _LightColor0; +uniform vec4 _Color; +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 c; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = (tmpvar_1 * _Color); + c = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = c.xyz; + o.Albedo = tmpvar_3; + float tmpvar_4; + tmpvar_4 = c.w; + o.Alpha = tmpvar_4; +} + +vec4 LightingLambert ( + in SurfaceOutput s, + in vec3 lightDir, + in float atten +) +{ + vec4 c; + float diff; + float tmpvar_1; + tmpvar_1 = dot (s.Normal, lightDir); + float tmpvar_2; + tmpvar_2 = max (0.0, tmpvar_1); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + diff = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = ((s.Albedo * _LightColor0.xyz) * ((diff * atten) * 2.0)); + c.xyz = tmpvar_4.xyz.xyz; + float tmpvar_5; + tmpvar_5 = s.Alpha; + c.w = vec4(tmpvar_5).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 c; + vec3 lightDir; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_3; + float tmpvar_4; + tmpvar_4 = 0.0; + o.Specular = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Alpha = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Gloss = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = IN.normal; + o.Normal = tmpvar_7; + surf (surfIN, o); + vec3 tmpvar_8; + tmpvar_8 = IN.lightDir; + lightDir = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = normalize (lightDir); + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + lightDir = tmpvar_10; + float tmpvar_11; + tmpvar_11 = dot (IN._LightCoord, IN._LightCoord); + vec2 tmpvar_12; + tmpvar_12 = vec2(tmpvar_11); + vec2 tmpvar_13; + tmpvar_13 = tmpvar_12.xy; + vec4 tmpvar_14; + tmpvar_14 = texture2D (_LightTexture0, tmpvar_13); + vec4 tmpvar_15; + tmpvar_15 = LightingLambert (o, lightDir, tmpvar_14.w); + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + c = tmpvar_16; + float tmpvar_17; + tmpvar_17 = 0.0; + c.w = vec4(tmpvar_17).w; + return c; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xy; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.normal = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.lightDir = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = gl_TexCoord[3].xyz; + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_IN._LightCoord = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = frag_surf (xlt_IN); + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xl_retval = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = xl_retval.xyzw; + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + gl_FragData[0] = tmpvar_14; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Diffuse-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Diffuse-out.txt new file mode 100644 index 000000000..eda730dda --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Diffuse-out.txt @@ -0,0 +1,19 @@ +uniform sampler2D _MainTex; +uniform sampler2D _LightTexture0; +uniform vec4 _LightColor0; +uniform vec4 _Color; +void main () +{ + vec3 tmpvar_1; + tmpvar_1 = gl_TexCoord[3].xyz; + vec4 c; + vec4 tmpvar_2; + tmpvar_2 = (texture2D (_MainTex, gl_TexCoord[0].xy) * _Color); + vec4 c_i0_i1; + c_i0_i1.xyz = ((tmpvar_2.xyz * _LightColor0.xyz) * ((max (0.0, dot (gl_TexCoord[1].xyz, normalize (gl_TexCoord[2].xyz))) * texture2D (_LightTexture0, vec2(dot (tmpvar_1, tmpvar_1))).w) * 2.0)); + c_i0_i1.w = tmpvar_2.w; + c = c_i0_i1; + c.w = 0.0; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Diffuse1-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Diffuse1-in.txt new file mode 100644 index 000000000..a6b94bf7a --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Diffuse1-in.txt @@ -0,0 +1,69 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; +}; +struct v2f_surf { + vec4 pos; + vec3 normal; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _Color; +uniform sampler2D _MainTex; +void surf( in Input IN, inout SurfaceOutput o ); +vec4 frag_surf( in v2f_surf IN ); +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 c; + c = (texture2D( _MainTex, IN.uv_MainTex) * _Color); + o.Albedo = c.xyz ; + o.Alpha = c.w ; +} +vec4 frag_surf( in v2f_surf IN ) { + SurfaceOutput o; + Input surfIN; + vec4 res; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + o.Normal = IN.normal; + surf( surfIN, o); + res.xyz = ((o.Normal * vec3( 0.500000, 0.500000, -0.500000)) + 0.500000); + res.w = o.Specular; + return res; +} +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.normal = vec3( gl_TexCoord[0]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Diffuse1-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Diffuse1-ir.txt new file mode 100644 index 000000000..6527e10b7 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Diffuse1-ir.txt @@ -0,0 +1,95 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; +}; +struct v2f_surf { + vec4 pos; + vec3 normal; +}; +uniform sampler2D _MainTex; +uniform vec4 _Color; +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 c; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = (tmpvar_1 * _Color); + c = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = c.xyz; + o.Albedo = tmpvar_3; + float tmpvar_4; + tmpvar_4 = c.w; + o.Alpha = tmpvar_4; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 res; + Input surfIN; + SurfaceOutput o; + vec3 tmpvar_1; + tmpvar_1 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_2; + float tmpvar_3; + tmpvar_3 = 0.0; + o.Specular = tmpvar_3; + float tmpvar_4; + tmpvar_4 = 0.0; + o.Alpha = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Gloss = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = IN.normal; + o.Normal = tmpvar_6; + surf (surfIN, o); + vec3 tmpvar_7; + tmpvar_7 = ((o.Normal * vec3(0.5, 0.5, -0.5)) + 0.5); + res.xyz = tmpvar_7.xyz.xyz; + float tmpvar_8; + tmpvar_8 = o.Specular; + res.w = vec4(tmpvar_8).w; + return res; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = gl_TexCoord[0].xyz; + vec3 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_IN.normal = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = frag_surf (xlt_IN); + vec4 tmpvar_5; + tmpvar_5 = tmpvar_4; + xl_retval = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = xl_retval.xyzw; + vec4 tmpvar_7; + tmpvar_7 = tmpvar_6; + gl_FragData[0] = tmpvar_7; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Diffuse1-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Diffuse1-out.txt new file mode 100644 index 000000000..2a4e65f10 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Diffuse1-out.txt @@ -0,0 +1,8 @@ +void main () +{ + vec4 res; + res.xyz = ((gl_TexCoord[0].xyz * vec3(0.5, 0.5, -0.5)) + 0.5); + res.w = 0.0; + gl_FragData[0] = res; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Diffuse2-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Diffuse2-in.txt new file mode 100644 index 000000000..b7401d4b6 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Diffuse2-in.txt @@ -0,0 +1,120 @@ +float xll_saturate( float x) { + return clamp( x, 0.0, 1.0); +} +vec2 xll_saturate( vec2 x) { + return clamp( x, 0.0, 1.0); +} +vec3 xll_saturate( vec3 x) { + return clamp( x, 0.0, 1.0); +} +vec4 xll_saturate( vec4 x) { + return clamp( x, 0.0, 1.0); +} +mat2 xll_saturate(mat2 m) { + return mat2( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0)); +} +mat3 xll_saturate(mat3 m) { + return mat3( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0), clamp(m[2], 0.0, 1.0)); +} +mat4 xll_saturate(mat4 m) { + return mat4( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0), clamp(m[2], 0.0, 1.0), clamp(m[3], 0.0, 1.0)); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 hip_screen; + vec3 hip_lmapFade; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _Color; +uniform sampler2D _LightBuffer; +uniform sampler2D _MainTex; +uniform sampler2D unity_Lightmap; +uniform sampler2D unity_LightmapInd; +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingLambert_PrePass( in SurfaceOutput s, in vec4 light ); +vec3 DecodeLightmap( in vec4 color ); +vec4 frag_surf( in v2f_surf IN ); +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 c; + c = (texture2D( _MainTex, IN.uv_MainTex) * _Color); + o.Albedo = c.xyz ; + o.Alpha = c.w ; +} +vec4 LightingLambert_PrePass( in SurfaceOutput s, in vec4 light ) { + vec4 c; + c.xyz = (s.Albedo * light.xyz ); + c.w = s.Alpha; + return c; +} +vec3 DecodeLightmap( in vec4 color ) { + return (2.00000 * color.xyz ); +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec4 light; + vec3 lmFull; + vec3 lmIndirect; + vec3 lm; + vec4 col; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + surf( surfIN, o); + light = texture2DProj( _LightBuffer, IN.hip_screen); + light = ( -log2( light ) ); + lmFull = DecodeLightmap( texture2D( unity_Lightmap, IN.hip_lmapFade.xy )); + lmIndirect = DecodeLightmap( texture2D( unity_LightmapInd, IN.hip_lmapFade.xy )); + lm = mix( lmIndirect, lmFull, vec3( xll_saturate( IN.hip_lmapFade.z ))); + light.xyz += lm; + col = LightingLambert_PrePass( o, light); + return col; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec2( gl_TexCoord[0]); + xlt_IN.hip_screen = vec4( gl_TexCoord[1]); + xlt_IN.hip_lmapFade = vec3( gl_TexCoord[2]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Diffuse2-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Diffuse2-ir.txt new file mode 100644 index 000000000..aec3aac01 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Diffuse2-ir.txt @@ -0,0 +1,281 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 hip_screen; + vec3 hip_lmapFade; +}; +varying vec4 xlv_FOG; +uniform sampler2D unity_LightmapInd; +uniform sampler2D unity_Lightmap; +uniform sampler2D _MainTex; +uniform sampler2D _LightBuffer; +uniform vec4 _Color; +float xll_saturate ( + in float x +) +{ + float tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec2 xll_saturate ( + in vec2 x +) +{ + vec2 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec3 xll_saturate ( + in vec3 x +) +{ + vec3 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec4 xll_saturate ( + in vec4 x +) +{ + vec4 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +mat2 xll_saturate ( + in mat2 m +) +{ + vec2 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec2 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + mat2 tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_1; + tmpvar_3[0] = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5 = tmpvar_2; + tmpvar_3[1] = tmpvar_5; + return tmpvar_3; +} + +mat3 xll_saturate ( + in mat3 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec3 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + vec3 tmpvar_3; + tmpvar_3 = clamp (m[2], 0.0, 1.0); + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +mat4 xll_saturate ( + in mat4 m +) +{ + vec4 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec4 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + vec4 tmpvar_3; + tmpvar_3 = clamp (m[2], 0.0, 1.0); + vec4 tmpvar_4; + tmpvar_4 = clamp (m[3], 0.0, 1.0); + mat4 tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_1; + tmpvar_5[0] = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = tmpvar_2; + tmpvar_5[1] = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_3; + tmpvar_5[2] = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = tmpvar_4; + tmpvar_5[3] = tmpvar_9; + return tmpvar_5; +} + +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 c; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = (tmpvar_1 * _Color); + c = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = c.xyz; + o.Albedo = tmpvar_3; + float tmpvar_4; + tmpvar_4 = c.w; + o.Alpha = tmpvar_4; +} + +vec4 LightingLambert_PrePass ( + in SurfaceOutput s, + in vec4 light +) +{ + vec4 c; + vec3 tmpvar_1; + tmpvar_1 = (s.Albedo * light.xyz); + c.xyz = tmpvar_1.xyz.xyz; + float tmpvar_2; + tmpvar_2 = s.Alpha; + c.w = vec4(tmpvar_2).w; + return c; +} + +vec3 DecodeLightmap ( + in vec4 color +) +{ + return (2.0 * color.xyz); +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 col; + vec3 lm; + vec3 lmIndirect; + vec3 lmFull; + vec4 light; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_3; + float tmpvar_4; + tmpvar_4 = 0.0; + o.Specular = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Alpha = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Gloss = tmpvar_6; + surf (surfIN, o); + vec4 tmpvar_7; + tmpvar_7 = texture2DProj (_LightBuffer, IN.hip_screen); + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + light = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = log2 (light); + vec4 tmpvar_10; + tmpvar_10 = -(tmpvar_9); + light = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = texture2D (unity_Lightmap, IN.hip_lmapFade.xy); + vec3 tmpvar_12; + tmpvar_12 = DecodeLightmap (tmpvar_11); + vec3 tmpvar_13; + tmpvar_13 = tmpvar_12; + lmFull = tmpvar_13; + vec4 tmpvar_14; + tmpvar_14 = texture2D (unity_LightmapInd, IN.hip_lmapFade.xy); + vec3 tmpvar_15; + tmpvar_15 = DecodeLightmap (tmpvar_14); + vec3 tmpvar_16; + tmpvar_16 = tmpvar_15; + lmIndirect = tmpvar_16; + float tmpvar_17; + tmpvar_17 = xll_saturate (IN.hip_lmapFade.z); + vec3 tmpvar_18; + tmpvar_18 = vec3(tmpvar_17); + vec3 tmpvar_19; + tmpvar_19 = mix (lmIndirect, lmFull, tmpvar_18); + vec3 tmpvar_20; + tmpvar_20 = tmpvar_19; + lm = tmpvar_20; + vec3 tmpvar_21; + tmpvar_21 = (light.xyz + lm); + light.xyz = tmpvar_21.xyz.xyz; + vec4 tmpvar_22; + tmpvar_22 = LightingLambert_PrePass (o, light); + vec4 tmpvar_23; + tmpvar_23 = tmpvar_22; + col = tmpvar_23; + return col; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xy; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyzw; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.hip_screen = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.hip_lmapFade = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = frag_surf (xlt_IN); + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xl_retval = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = xl_retval.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + gl_FragData[0] = tmpvar_12; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Diffuse2-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Diffuse2-out.txt new file mode 100644 index 000000000..258a9b7ee --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Diffuse2-out.txt @@ -0,0 +1,22 @@ +uniform sampler2D unity_LightmapInd; +uniform sampler2D unity_Lightmap; +uniform sampler2D _MainTex; +uniform sampler2D _LightBuffer; +uniform vec4 _Color; +void main () +{ + vec3 tmpvar_1; + tmpvar_1 = gl_TexCoord[2].xyz; + vec4 light; + vec4 tmpvar_2; + tmpvar_2 = (texture2D (_MainTex, gl_TexCoord[0].xy) * _Color); + vec4 tmpvar_3; + tmpvar_3 = -(log2 (texture2DProj (_LightBuffer, gl_TexCoord[1]))); + light = tmpvar_3; + light.xyz = (tmpvar_3.xyz + mix ((2.0 * texture2D (unity_LightmapInd, tmpvar_1.xy).xyz), (2.0 * texture2D (unity_Lightmap, tmpvar_1.xy).xyz), vec3(clamp (tmpvar_1.z, 0.0, 1.0)))); + vec4 c_i0; + c_i0.xyz = (tmpvar_2.xyz * light.xyz); + c_i0.w = tmpvar_2.w; + gl_FragData[0] = c_i0; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Diffuse_Alpha_Shadowed_ZWrite-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Diffuse_Alpha_Shadowed_ZWrite-in.txt new file mode 100644 index 000000000..b15d52de8 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Diffuse_Alpha_Shadowed_ZWrite-in.txt @@ -0,0 +1,90 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 normal; + vec3 vlight; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _Color; +uniform vec4 _LightColor0; +uniform sampler2D _MainTex; +uniform vec4 _WorldSpaceLightPos0; +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ); +vec4 frag_surf( in v2f_surf IN ); +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 c; + c = (texture2D( _MainTex, IN.uv_MainTex) * _Color); + o.Albedo = c.xyz ; + o.Alpha = c.w ; +} +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ) { + float diff; + vec4 c; + diff = max( 0.000000, dot( s.Normal, lightDir)); + c.xyz = ((s.Albedo * _LightColor0.xyz ) * ((diff * atten) * 2.00000)); + c.w = s.Alpha; + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + float atten = 1.00000; + vec4 c; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + o.Normal = IN.normal; + surf( surfIN, o); + c = LightingLambert( o, _WorldSpaceLightPos0.xyz , atten); + c.xyz += (o.Albedo * IN.vlight); + c.w = o.Alpha; + return c; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec2( gl_TexCoord[0]); + xlt_IN.normal = vec3( gl_TexCoord[1]); + xlt_IN.vlight = vec3( gl_TexCoord[2]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Diffuse_Alpha_Shadowed_ZWrite-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Diffuse_Alpha_Shadowed_ZWrite-ir.txt new file mode 100644 index 000000000..a3b35ccd6 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Diffuse_Alpha_Shadowed_ZWrite-ir.txt @@ -0,0 +1,150 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 normal; + vec3 vlight; +}; +varying vec4 xlv_FOG; +uniform vec4 _WorldSpaceLightPos0; +uniform sampler2D _MainTex; +uniform vec4 _LightColor0; +uniform vec4 _Color; +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 c; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = (tmpvar_1 * _Color); + c = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = c.xyz; + o.Albedo = tmpvar_3; + float tmpvar_4; + tmpvar_4 = c.w; + o.Alpha = tmpvar_4; +} + +vec4 LightingLambert ( + in SurfaceOutput s, + in vec3 lightDir, + in float atten +) +{ + vec4 c; + float diff; + float tmpvar_1; + tmpvar_1 = dot (s.Normal, lightDir); + float tmpvar_2; + tmpvar_2 = max (0.0, tmpvar_1); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + diff = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = ((s.Albedo * _LightColor0.xyz) * ((diff * atten) * 2.0)); + c.xyz = tmpvar_4.xyz.xyz; + float tmpvar_5; + tmpvar_5 = s.Alpha; + c.w = vec4(tmpvar_5).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 c; + float atten; + SurfaceOutput o; + Input surfIN; + float tmpvar_1; + tmpvar_1 = 1.0; + atten = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Specular = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Alpha = tmpvar_6; + float tmpvar_7; + tmpvar_7 = 0.0; + o.Gloss = tmpvar_7; + vec3 tmpvar_8; + tmpvar_8 = IN.normal; + o.Normal = tmpvar_8; + surf (surfIN, o); + vec4 tmpvar_9; + tmpvar_9 = LightingLambert (o, _WorldSpaceLightPos0.xyz, atten); + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + c = tmpvar_10; + vec3 tmpvar_11; + tmpvar_11 = (c.xyz + (o.Albedo * IN.vlight)); + c.xyz = tmpvar_11.xyz.xyz; + float tmpvar_12; + tmpvar_12 = o.Alpha; + c.w = vec4(tmpvar_12).w; + return c; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xy; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.normal = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.vlight = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = frag_surf (xlt_IN); + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xl_retval = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = xl_retval.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + gl_FragData[0] = tmpvar_12; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Diffuse_Alpha_Shadowed_ZWrite-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Diffuse_Alpha_Shadowed_ZWrite-out.txt new file mode 100644 index 000000000..bbb3a5a16 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Diffuse_Alpha_Shadowed_ZWrite-out.txt @@ -0,0 +1,18 @@ +uniform vec4 _WorldSpaceLightPos0; +uniform sampler2D _MainTex; +uniform vec4 _LightColor0; +uniform vec4 _Color; +void main () +{ + vec4 c; + vec4 tmpvar_1; + tmpvar_1 = (texture2D (_MainTex, gl_TexCoord[0].xy) * _Color); + vec4 c_i0_i1; + c_i0_i1.xyz = ((tmpvar_1.xyz * _LightColor0.xyz) * (max (0.0, dot (gl_TexCoord[1].xyz, _WorldSpaceLightPos0.xyz)) * 2.0)); + c_i0_i1.w = tmpvar_1.w; + c = c_i0_i1; + c.xyz = (c_i0_i1.xyz + (tmpvar_1.xyz * gl_TexCoord[2].xyz)); + c.w = tmpvar_1.w; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Diffuse_Detail-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Diffuse_Detail-in.txt new file mode 100644 index 000000000..6eecd245c --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Diffuse_Detail-in.txt @@ -0,0 +1,106 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_Detail; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 normal; + vec3 lightDir; + vec4 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _Color; +uniform sampler2D _Detail; +uniform vec4 _LightColor0; +uniform sampler2D _LightTexture0; +uniform sampler2D _LightTextureB0; +uniform sampler2D _MainTex; +void surf( in Input IN, inout SurfaceOutput o ); +float UnitySpotCookie( in vec4 LightCoord ); +float UnitySpotAttenuate( in vec3 LightCoord ); +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ); +vec4 frag_surf( in v2f_surf IN ); +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 c; + c = (texture2D( _MainTex, IN.uv_MainTex) * _Color); + c.xyz *= (texture2D( _Detail, IN.uv_Detail).xyz * 2.00000); + o.Albedo = c.xyz ; + o.Alpha = c.w ; +} +float UnitySpotCookie( in vec4 LightCoord ) { + return texture2D( _LightTexture0, ((LightCoord.xy / LightCoord.w ) + 0.500000)).w ; +} +float UnitySpotAttenuate( in vec3 LightCoord ) { + return texture2D( _LightTextureB0, vec2( vec2( dot( LightCoord, LightCoord)))).w ; +} +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ) { + float diff; + vec4 c; + diff = max( 0.000000, dot( s.Normal, lightDir)); + c.xyz = ((s.Albedo * _LightColor0.xyz ) * ((diff * atten) * 2.00000)); + c.w = s.Alpha; + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec3 lightDir; + vec4 c; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + surfIN.uv_Detail = IN.hip_pack0.zw ; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + o.Normal = IN.normal; + surf( surfIN, o); + lightDir = IN.lightDir; + lightDir = normalize( lightDir ); + c = LightingLambert( o, lightDir, ((float( (IN._LightCoord.z > 0.000000) ) * UnitySpotCookie( IN._LightCoord)) * UnitySpotAttenuate( IN._LightCoord.xyz ))); + c.w = 0.000000; + return c; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec4( gl_TexCoord[0]); + xlt_IN.normal = vec3( gl_TexCoord[1]); + xlt_IN.lightDir = vec3( gl_TexCoord[2]); + xlt_IN._LightCoord = vec4( gl_TexCoord[3]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Diffuse_Detail-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Diffuse_Detail-ir.txt new file mode 100644 index 000000000..0423c7150 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Diffuse_Detail-ir.txt @@ -0,0 +1,197 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_Detail; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 normal; + vec3 lightDir; + vec4 _LightCoord; +}; +varying vec4 xlv_FOG; +uniform sampler2D _MainTex; +uniform sampler2D _LightTextureB0; +uniform sampler2D _LightTexture0; +uniform vec4 _LightColor0; +uniform sampler2D _Detail; +uniform vec4 _Color; +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 c; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = (tmpvar_1 * _Color); + c = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = texture2D (_Detail, IN.uv_Detail); + vec3 tmpvar_4; + tmpvar_4 = (c.xyz * (tmpvar_3.xyz * 2.0)); + c.xyz = tmpvar_4.xyz.xyz; + vec3 tmpvar_5; + tmpvar_5 = c.xyz; + o.Albedo = tmpvar_5; + float tmpvar_6; + tmpvar_6 = c.w; + o.Alpha = tmpvar_6; +} + +float UnitySpotCookie ( + in vec4 LightCoord +) +{ + vec4 tmpvar_1; + tmpvar_1 = texture2D (_LightTexture0, ((LightCoord.xy / LightCoord.w) + 0.5)); + return tmpvar_1.w; +} + +float UnitySpotAttenuate ( + in vec3 LightCoord +) +{ + float tmpvar_1; + tmpvar_1 = dot (LightCoord, LightCoord); + vec2 tmpvar_2; + tmpvar_2 = vec2(tmpvar_1); + vec2 tmpvar_3; + tmpvar_3 = tmpvar_2.xy; + vec4 tmpvar_4; + tmpvar_4 = texture2D (_LightTextureB0, tmpvar_3); + return tmpvar_4.w; +} + +vec4 LightingLambert ( + in SurfaceOutput s, + in vec3 lightDir, + in float atten +) +{ + vec4 c; + float diff; + float tmpvar_1; + tmpvar_1 = dot (s.Normal, lightDir); + float tmpvar_2; + tmpvar_2 = max (0.0, tmpvar_1); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + diff = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = ((s.Albedo * _LightColor0.xyz) * ((diff * atten) * 2.0)); + c.xyz = tmpvar_4.xyz.xyz; + float tmpvar_5; + tmpvar_5 = s.Alpha; + c.w = vec4(tmpvar_5).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 c; + vec3 lightDir; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = IN.hip_pack0.zw; + surfIN.uv_Detail = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Specular = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Alpha = tmpvar_6; + float tmpvar_7; + tmpvar_7 = 0.0; + o.Gloss = tmpvar_7; + vec3 tmpvar_8; + tmpvar_8 = IN.normal; + o.Normal = tmpvar_8; + surf (surfIN, o); + vec3 tmpvar_9; + tmpvar_9 = IN.lightDir; + lightDir = tmpvar_9; + vec3 tmpvar_10; + tmpvar_10 = normalize (lightDir); + vec3 tmpvar_11; + tmpvar_11 = tmpvar_10; + lightDir = tmpvar_11; + float tmpvar_12; + tmpvar_12 = UnitySpotCookie (IN._LightCoord); + float tmpvar_13; + tmpvar_13 = UnitySpotAttenuate (IN._LightCoord.xyz); + vec4 tmpvar_14; + tmpvar_14 = LightingLambert (o, lightDir, ((float((IN._LightCoord.z > 0.0)) * tmpvar_12) * tmpvar_13)); + vec4 tmpvar_15; + tmpvar_15 = tmpvar_14; + c = tmpvar_15; + float tmpvar_16; + tmpvar_16 = 0.0; + c.w = vec4(tmpvar_16).w; + return c; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.normal = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.lightDir = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_TexCoord[3].xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_IN._LightCoord = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = frag_surf (xlt_IN); + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xl_retval = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = xl_retval.xyzw; + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + gl_FragData[0] = tmpvar_14; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Diffuse_Detail-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Diffuse_Detail-out.txt new file mode 100644 index 000000000..dcf872fc8 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Diffuse_Detail-out.txt @@ -0,0 +1,28 @@ +uniform sampler2D _MainTex; +uniform sampler2D _LightTextureB0; +uniform sampler2D _LightTexture0; +uniform vec4 _LightColor0; +uniform sampler2D _Detail; +uniform vec4 _Color; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = gl_TexCoord[0]; + vec4 tmpvar_2; + tmpvar_2 = gl_TexCoord[3]; + vec4 c; + vec4 c_i0; + vec4 tmpvar_3; + tmpvar_3 = (texture2D (_MainTex, tmpvar_1.xy) * _Color); + c_i0 = tmpvar_3; + c_i0.xyz = (tmpvar_3.xyz * (texture2D (_Detail, tmpvar_1.zw).xyz * 2.0)); + vec3 LightCoord_i0; + LightCoord_i0 = tmpvar_2.xyz; + vec4 c_i0_i1; + c_i0_i1.xyz = ((c_i0.xyz * _LightColor0.xyz) * ((max (0.0, dot (gl_TexCoord[1].xyz, normalize (gl_TexCoord[2].xyz))) * ((float((tmpvar_2.z > 0.0)) * texture2D (_LightTexture0, ((tmpvar_2.xy / tmpvar_2.w) + 0.5)).w) * texture2D (_LightTextureB0, vec2(dot (LightCoord_i0, LightCoord_i0))).w)) * 2.0)); + c_i0_i1.w = c_i0.w; + c = c_i0_i1; + c.w = 0.0; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Diffuse_Detail1-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Diffuse_Detail1-in.txt new file mode 100644 index 000000000..1376c889a --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Diffuse_Detail1-in.txt @@ -0,0 +1,72 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_Detail; +}; +struct v2f_surf { + vec4 pos; + vec3 normal; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _Color; +uniform sampler2D _Detail; +uniform sampler2D _MainTex; +void surf( in Input IN, inout SurfaceOutput o ); +vec4 frag_surf( in v2f_surf IN ); +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 c; + c = (texture2D( _MainTex, IN.uv_MainTex) * _Color); + c.xyz *= (texture2D( _Detail, IN.uv_Detail).xyz * 2.00000); + o.Albedo = c.xyz ; + o.Alpha = c.w ; +} +vec4 frag_surf( in v2f_surf IN ) { + SurfaceOutput o; + Input surfIN; + vec4 res; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + o.Normal = IN.normal; + surf( surfIN, o); + res.xyz = ((o.Normal * vec3( 0.500000, 0.500000, -0.500000)) + 0.500000); + res.w = o.Specular; + return res; +} +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.normal = vec3( gl_TexCoord[0]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Diffuse_Detail1-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Diffuse_Detail1-ir.txt new file mode 100644 index 000000000..95e6be307 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Diffuse_Detail1-ir.txt @@ -0,0 +1,102 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_Detail; +}; +struct v2f_surf { + vec4 pos; + vec3 normal; +}; +uniform sampler2D _MainTex; +uniform sampler2D _Detail; +uniform vec4 _Color; +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 c; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = (tmpvar_1 * _Color); + c = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = texture2D (_Detail, IN.uv_Detail); + vec3 tmpvar_4; + tmpvar_4 = (c.xyz * (tmpvar_3.xyz * 2.0)); + c.xyz = tmpvar_4.xyz.xyz; + vec3 tmpvar_5; + tmpvar_5 = c.xyz; + o.Albedo = tmpvar_5; + float tmpvar_6; + tmpvar_6 = c.w; + o.Alpha = tmpvar_6; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 res; + Input surfIN; + SurfaceOutput o; + vec3 tmpvar_1; + tmpvar_1 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_2; + float tmpvar_3; + tmpvar_3 = 0.0; + o.Specular = tmpvar_3; + float tmpvar_4; + tmpvar_4 = 0.0; + o.Alpha = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Gloss = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = IN.normal; + o.Normal = tmpvar_6; + surf (surfIN, o); + vec3 tmpvar_7; + tmpvar_7 = ((o.Normal * vec3(0.5, 0.5, -0.5)) + 0.5); + res.xyz = tmpvar_7.xyz.xyz; + float tmpvar_8; + tmpvar_8 = o.Specular; + res.w = vec4(tmpvar_8).w; + return res; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = gl_TexCoord[0].xyz; + vec3 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_IN.normal = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = frag_surf (xlt_IN); + vec4 tmpvar_5; + tmpvar_5 = tmpvar_4; + xl_retval = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = xl_retval.xyzw; + vec4 tmpvar_7; + tmpvar_7 = tmpvar_6; + gl_FragData[0] = tmpvar_7; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Diffuse_Detail1-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Diffuse_Detail1-out.txt new file mode 100644 index 000000000..2a4e65f10 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Diffuse_Detail1-out.txt @@ -0,0 +1,8 @@ +void main () +{ + vec4 res; + res.xyz = ((gl_TexCoord[0].xyz * vec3(0.5, 0.5, -0.5)) + 0.5); + res.w = 0.0; + gl_FragData[0] = res; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-FX_Glass_Stained_BumpDistort-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-FX_Glass_Stained_BumpDistort-in.txt new file mode 100644 index 000000000..e7b7f54d4 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-FX_Glass_Stained_BumpDistort-in.txt @@ -0,0 +1,58 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct v2f { + vec4 vertex; + vec4 uvgrab; + vec2 uvbump; + vec2 uvmain; +}; +struct appdata_t { + vec4 vertex; + vec2 texcoord; +}; +uniform float _BumpAmt; +uniform sampler2D _BumpMap; +uniform sampler2D _GrabTexture; +uniform vec4 _GrabTexture_TexelSize; +uniform sampler2D _MainTex; +vec4 UnpackNormal( in vec4 packednormal ); +vec4 frag( in v2f i ); +vec4 UnpackNormal( in vec4 packednormal ) { + vec4 normal; + normal.xy = ((packednormal.wy * 2.00000) - 1.00000); + normal.z = sqrt( ((1.00000 - (normal.x * normal.x )) - (normal.y * normal.y )) ); + return normal; +} +vec4 frag( in v2f i ) { + vec2 bump; + vec2 offset; + vec4 col; + vec4 tint; + bump = UnpackNormal( texture2D( _BumpMap, i.uvbump)).xy ; + offset = ((bump * _BumpAmt) * _GrabTexture_TexelSize.xy ); + i.uvgrab.xy = ((offset * i.uvgrab.z ) + i.uvgrab.xy ); + col = texture2DProj( _GrabTexture, i.uvgrab); + tint = texture2D( _MainTex, i.uvmain); + return (col * tint); +} +void main() { + vec4 xl_retval; + v2f xlt_i; + xlt_i.vertex = vec4(0.0); + xlt_i.uvgrab = vec4( gl_TexCoord[0]); + xlt_i.uvbump = vec2( gl_TexCoord[1]); + xlt_i.uvmain = vec2( gl_TexCoord[2]); + xl_retval = frag( xlt_i); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-FX_Glass_Stained_BumpDistort-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-FX_Glass_Stained_BumpDistort-ir.txt new file mode 100644 index 000000000..25674b82c --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-FX_Glass_Stained_BumpDistort-ir.txt @@ -0,0 +1,95 @@ +struct v2f { + vec4 vertex; + vec4 uvgrab; + vec2 uvbump; + vec2 uvmain; +}; +uniform sampler2D _MainTex; +uniform vec4 _GrabTexture_TexelSize; +uniform sampler2D _GrabTexture; +uniform sampler2D _BumpMap; +uniform float _BumpAmt; +vec4 UnpackNormal ( + in vec4 packednormal +) +{ + vec4 normal; + vec2 tmpvar_1; + tmpvar_1 = ((packednormal.wy * 2.0) - 1.0); + normal.xy = tmpvar_1.xy.xy; + float tmpvar_2; + tmpvar_2 = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + normal.z = vec3(tmpvar_3).z; + return normal; +} + +vec4 frag ( + in v2f i +) +{ + vec4 tint; + vec4 col; + vec2 offset; + vec2 bump; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_BumpMap, i.uvbump); + vec4 tmpvar_2; + tmpvar_2 = UnpackNormal (tmpvar_1); + vec2 tmpvar_3; + tmpvar_3 = tmpvar_2.xy; + bump = tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = ((bump * _BumpAmt) * _GrabTexture_TexelSize.xy); + offset = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5 = ((offset * i.uvgrab.z) + i.uvgrab.xy); + i.uvgrab.xy = tmpvar_5.xy.xy; + vec4 tmpvar_6; + tmpvar_6 = texture2DProj (_GrabTexture, i.uvgrab); + vec4 tmpvar_7; + tmpvar_7 = tmpvar_6; + col = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = texture2D (_MainTex, i.uvmain); + vec4 tmpvar_9; + tmpvar_9 = tmpvar_8; + tint = tmpvar_9; + return (col * tint); +} + +void main () +{ + v2f xlt_i; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_i.vertex = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = gl_TexCoord[0].xyzw; + vec4 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_i.uvgrab = tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = gl_TexCoord[1].xy; + vec2 tmpvar_5; + tmpvar_5 = tmpvar_4; + xlt_i.uvbump = tmpvar_5; + vec2 tmpvar_6; + tmpvar_6 = gl_TexCoord[2].xy; + vec2 tmpvar_7; + tmpvar_7 = tmpvar_6; + xlt_i.uvmain = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = frag (xlt_i); + vec4 tmpvar_9; + tmpvar_9 = tmpvar_8; + xl_retval = tmpvar_9; + vec4 tmpvar_10; + tmpvar_10 = xl_retval.xyzw; + vec4 tmpvar_11; + tmpvar_11 = tmpvar_10; + gl_FragData[0] = tmpvar_11; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-FX_Glass_Stained_BumpDistort-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-FX_Glass_Stained_BumpDistort-out.txt new file mode 100644 index 000000000..c0e67b2d4 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-FX_Glass_Stained_BumpDistort-out.txt @@ -0,0 +1,18 @@ +uniform sampler2D _MainTex; +uniform vec4 _GrabTexture_TexelSize; +uniform sampler2D _GrabTexture; +uniform sampler2D _BumpMap; +uniform float _BumpAmt; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = gl_TexCoord[0]; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + vec4 normal; + normal.xy = ((texture2D (_BumpMap, gl_TexCoord[1].xy).wy * 2.0) - 1.0); + normal.z = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + tmpvar_2.xy = ((((normal.xy * _BumpAmt) * _GrabTexture_TexelSize.xy) * tmpvar_1.z) + tmpvar_1.xy); + gl_FragData[0] = (texture2DProj (_GrabTexture, tmpvar_2) * texture2D (_MainTex, gl_TexCoord[2].xy)); +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-FX_Water_(simple)-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-FX_Water_(simple)-in.txt new file mode 100644 index 000000000..e5cf0fd63 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-FX_Water_(simple)-in.txt @@ -0,0 +1,62 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct v2f { + vec4 pos; + float fog; + vec2 bumpuv[2]; + vec3 viewDir; +}; +struct appdata { + vec4 vertex; + vec3 normal; +}; +uniform sampler2D _BumpMap; +uniform sampler2D _ColorControl; +uniform vec4 _horizonColor; +vec4 UnpackNormal( in vec4 packednormal ); +vec4 frag( in v2f i ); +vec4 UnpackNormal( in vec4 packednormal ) { + vec4 normal; + normal.xy = ((packednormal.wy * 2.00000) - 1.00000); + normal.z = sqrt( ((1.00000 - (normal.x * normal.x )) - (normal.y * normal.y )) ); + return normal; +} +vec4 frag( in v2f i ) { + vec3 bump1; + vec3 bump2; + vec3 bump; + float fresnel; + vec4 water; + vec4 col; + bump1 = UnpackNormal( texture2D( _BumpMap, i.bumpuv[ 0 ])).xyz ; + bump2 = UnpackNormal( texture2D( _BumpMap, i.bumpuv[ 1 ])).xyz ; + bump = ((bump1 + bump2) * 0.500000); + fresnel = dot( i.viewDir, bump); + water = texture2D( _ColorControl, vec2( fresnel, fresnel)); + col.xyz = mix( water.xyz , _horizonColor.xyz , vec3( water.w )); + col.w = _horizonColor.w ; + return col; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f xlt_i; + xlt_i.pos = vec4(0.0); + xlt_i.fog = float( xlv_FOG); + xlt_i.bumpuv[0] = vec2( gl_TexCoord[0]); + xlt_i.bumpuv[1] = vec2( gl_TexCoord[1]); + xlt_i.viewDir = vec3( gl_TexCoord[2]); + xl_retval = frag( xlt_i); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-FX_Water_(simple)-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-FX_Water_(simple)-ir.txt new file mode 100644 index 000000000..de3202664 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-FX_Water_(simple)-ir.txt @@ -0,0 +1,116 @@ +struct v2f { + vec4 pos; + float fog; + vec2 bumpuv[2]; + vec3 viewDir; +}; +varying vec4 xlv_FOG; +uniform vec4 _horizonColor; +uniform sampler2D _ColorControl; +uniform sampler2D _BumpMap; +vec4 UnpackNormal ( + in vec4 packednormal +) +{ + vec4 normal; + vec2 tmpvar_1; + tmpvar_1 = ((packednormal.wy * 2.0) - 1.0); + normal.xy = tmpvar_1.xy.xy; + float tmpvar_2; + tmpvar_2 = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + normal.z = vec3(tmpvar_3).z; + return normal; +} + +vec4 frag ( + in v2f i +) +{ + vec4 col; + vec4 water; + float fresnel; + vec3 bump; + vec3 bump2; + vec3 bump1; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_BumpMap, i.bumpuv[0]); + vec4 tmpvar_2; + tmpvar_2 = UnpackNormal (tmpvar_1); + vec3 tmpvar_3; + tmpvar_3 = tmpvar_2.xyz; + bump1 = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = texture2D (_BumpMap, i.bumpuv[1]); + vec4 tmpvar_5; + tmpvar_5 = UnpackNormal (tmpvar_4); + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5.xyz; + bump2 = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = ((bump1 + bump2) * 0.5); + bump = tmpvar_7; + float tmpvar_8; + tmpvar_8 = dot (i.viewDir, bump); + float tmpvar_9; + tmpvar_9 = tmpvar_8; + fresnel = tmpvar_9; + vec2 tmpvar_10; + tmpvar_10.x = fresnel; + tmpvar_10.y = fresnel; + vec4 tmpvar_11; + tmpvar_11 = texture2D (_ColorControl, tmpvar_10); + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + water = tmpvar_12; + vec3 tmpvar_13; + tmpvar_13 = vec3(water.w); + vec3 tmpvar_14; + tmpvar_14 = mix (water.xyz, _horizonColor.xyz, tmpvar_13); + vec3 tmpvar_15; + tmpvar_15 = tmpvar_14; + col.xyz = tmpvar_15.xyz.xyz; + float tmpvar_16; + tmpvar_16 = _horizonColor.w; + col.w = vec4(tmpvar_16).w; + return col; +} + +void main () +{ + v2f xlt_i; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_i.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_i.fog = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xy; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_i.bumpuv[0] = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xy; + vec2 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_i.bumpuv[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_i.viewDir = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = frag (xlt_i); + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xl_retval = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = xl_retval.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + gl_FragData[0] = tmpvar_12; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-FX_Water_(simple)-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-FX_Water_(simple)-out.txt new file mode 100644 index 000000000..0f89e80b7 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-FX_Water_(simple)-out.txt @@ -0,0 +1,27 @@ +uniform vec4 _horizonColor; +uniform sampler2D _ColorControl; +uniform sampler2D _BumpMap; +void main () +{ + vec2 tmpvar_1[2]; + tmpvar_1[0] = gl_TexCoord[0].xy; + tmpvar_1[1] = gl_TexCoord[1].xy; + vec4 col; + vec4 normal; + normal.xy = ((texture2D (_BumpMap, tmpvar_1[0]).wy * 2.0) - 1.0); + normal.z = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + vec4 normal_i0; + normal_i0.xy = ((texture2D (_BumpMap, tmpvar_1[1]).wy * 2.0) - 1.0); + normal_i0.z = sqrt (((1.0 - (normal_i0.x * normal_i0.x)) - (normal_i0.y * normal_i0.y))); + float tmpvar_2; + tmpvar_2 = dot (gl_TexCoord[2].xyz, ((normal.xyz + normal_i0.xyz) * 0.5)); + vec2 tmpvar_3; + tmpvar_3.x = tmpvar_2; + tmpvar_3.y = tmpvar_2; + vec4 tmpvar_4; + tmpvar_4 = texture2D (_ColorControl, tmpvar_3); + col.xyz = mix (tmpvar_4.xyz, _horizonColor.xyz, tmpvar_4.www); + col.w = _horizonColor.w; + gl_FragData[0] = col; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Grab_Invert-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Grab_Invert-in.txt new file mode 100644 index 000000000..222092285 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Grab_Invert-in.txt @@ -0,0 +1,30 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct v2f { + vec4 vertex; + vec4 uv; +}; +uniform sampler2D _GrabTexture; +vec4 frag( in v2f i ); +vec4 frag( in v2f i ) { + return (1.00000 - texture2DProj( _GrabTexture, i.uv)); +} +void main() { + vec4 xl_retval; + v2f xlt_i; + xlt_i.vertex = vec4(0.0); + xlt_i.uv = vec4( gl_TexCoord[0]); + xl_retval = frag( xlt_i); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Grab_Invert-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Grab_Invert-ir.txt new file mode 100644 index 000000000..c500aef58 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Grab_Invert-ir.txt @@ -0,0 +1,38 @@ +struct v2f { + vec4 vertex; + vec4 uv; +}; +uniform sampler2D _GrabTexture; +vec4 frag ( + in v2f i +) +{ + vec4 tmpvar_1; + tmpvar_1 = texture2DProj (_GrabTexture, i.uv); + return (1.0 - tmpvar_1); +} + +void main () +{ + v2f xlt_i; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_i.vertex = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = gl_TexCoord[0].xyzw; + vec4 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_i.uv = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = frag (xlt_i); + vec4 tmpvar_5; + tmpvar_5 = tmpvar_4; + xl_retval = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = xl_retval.xyzw; + vec4 tmpvar_7; + tmpvar_7 = tmpvar_6; + gl_FragData[0] = tmpvar_7; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Grab_Invert-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Grab_Invert-out.txt new file mode 100644 index 000000000..c4590c1e4 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Grab_Invert-out.txt @@ -0,0 +1,6 @@ +uniform sampler2D _GrabTexture; +void main () +{ + gl_FragData[0] = (1.0 - texture2DProj (_GrabTexture, gl_TexCoord[0])); +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Camera-DepthNormalTexture-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Camera-DepthNormalTexture-in.txt new file mode 100644 index 000000000..0832f3d96 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Camera-DepthNormalTexture-in.txt @@ -0,0 +1,71 @@ +void xll_clip(float x) { + if ( x<0.0 ) discard; +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct v2f { + vec4 pos; + vec2 uv; + vec4 nz; +}; +struct appdata { + vec4 vertex; + vec3 normal; + vec4 color; + vec4 texcoord; +}; +uniform float _Cutoff; +uniform sampler2D _MainTex; +vec2 EncodeViewNormalStereo( in vec3 n ); +vec2 EncodeFloatRG( in float v ); +vec4 EncodeDepthNormal( in float depth, in vec3 normal ); +vec4 frag( in v2f i ); +vec2 EncodeViewNormalStereo( in vec3 n ) { + float kScale = 1.77770; + vec2 enc; + enc = (n.xy / (n.z + 1.00000)); + enc /= kScale; + enc = ((enc * 0.500000) + 0.500000); + return enc; +} +vec2 EncodeFloatRG( in float v ) { + vec2 kEncodeMul = vec2( 1.00000, 255.000); + float kEncodeBit = 0.00392157; + vec2 enc; + enc = (kEncodeMul * v); + enc = fract( enc ); + enc.x -= (enc.y * kEncodeBit); + return enc; +} +vec4 EncodeDepthNormal( in float depth, in vec3 normal ) { + vec4 enc; + enc.xy = EncodeViewNormalStereo( normal); + enc.zw = EncodeFloatRG( depth); + return enc; +} +vec4 frag( in v2f i ) { + vec4 texcol; + texcol = texture2D( _MainTex, i.uv); + xll_clip( (texcol.w - _Cutoff) ); + return EncodeDepthNormal( i.nz.w , i.nz.xyz ); +} +void main() { + vec4 xl_retval; + v2f xlt_i; + xlt_i.pos = vec4(0.0); + xlt_i.uv = vec2( gl_TexCoord[0]); + xlt_i.nz = vec4( gl_TexCoord[1]); + xl_retval = frag( xlt_i); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Camera-DepthNormalTexture-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Camera-DepthNormalTexture-ir.txt new file mode 100644 index 000000000..5bc54c861 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Camera-DepthNormalTexture-ir.txt @@ -0,0 +1,128 @@ +struct v2f { + vec4 pos; + vec2 uv; + vec4 nz; +}; +uniform sampler2D _MainTex; +uniform float _Cutoff; +void xll_clip ( + in float x +) +{ + if ((x < 0.0)) { + discard; + }; +} + +vec2 EncodeViewNormalStereo ( + in vec3 n +) +{ + vec2 enc; + float kScale; + float tmpvar_1; + tmpvar_1 = 1.7777; + kScale = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = (n.xy / (n.z + 1.0)); + enc = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = (enc / kScale); + enc = tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = ((enc * 0.5) + 0.5); + enc = tmpvar_4; + return enc; +} + +vec2 EncodeFloatRG ( + in float v +) +{ + vec2 enc; + float kEncodeBit; + vec2 kEncodeMul; + vec2 tmpvar_1; + tmpvar_1 = vec2(1.0, 255.0); + kEncodeMul = tmpvar_1; + float tmpvar_2; + tmpvar_2 = 0.00392157; + kEncodeBit = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = (kEncodeMul * v); + enc = tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = fract (enc); + vec2 tmpvar_5; + tmpvar_5 = tmpvar_4; + enc = tmpvar_5; + float tmpvar_6; + tmpvar_6 = (enc.x - (enc.y * kEncodeBit)); + enc.x = tmpvar_6; + return enc; +} + +vec4 EncodeDepthNormal ( + in float depth, + in vec3 normal +) +{ + vec4 enc; + vec2 tmpvar_1; + tmpvar_1 = EncodeViewNormalStereo (normal); + vec2 tmpvar_2; + tmpvar_2 = tmpvar_1; + enc.xy = tmpvar_2.xy.xy; + vec2 tmpvar_3; + tmpvar_3 = EncodeFloatRG (depth); + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + enc.zw = tmpvar_4.xxxy.zw; + return enc; +} + +vec4 frag ( + in v2f i +) +{ + vec4 texcol; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, i.uv); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + texcol = tmpvar_2; + xll_clip ((texcol.w - _Cutoff)); + vec4 tmpvar_3; + tmpvar_3 = EncodeDepthNormal (i.nz.w, i.nz.xyz); + return tmpvar_3; +} + +void main () +{ + v2f xlt_i; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_i.pos = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = gl_TexCoord[0].xy; + vec2 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_i.uv = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = gl_TexCoord[1].xyzw; + vec4 tmpvar_5; + tmpvar_5 = tmpvar_4; + xlt_i.nz = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = frag (xlt_i); + vec4 tmpvar_7; + tmpvar_7 = tmpvar_6; + xl_retval = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = xl_retval.xyzw; + vec4 tmpvar_9; + tmpvar_9 = tmpvar_8; + gl_FragData[0] = tmpvar_9; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Camera-DepthNormalTexture-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Camera-DepthNormalTexture-out.txt new file mode 100644 index 000000000..0d7f18884 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Camera-DepthNormalTexture-out.txt @@ -0,0 +1,22 @@ +uniform sampler2D _MainTex; +uniform float _Cutoff; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = gl_TexCoord[1]; + float x; + x = (texture2D (_MainTex, gl_TexCoord[0].xy).w - _Cutoff); + if ((x < 0.0)) { + discard; + }; + vec4 enc; + enc.xy = ((((tmpvar_1.xy / (tmpvar_1.z + 1.0)) / 1.7777) * 0.5) + 0.5); + vec2 enc_i0_i1; + vec2 tmpvar_2; + tmpvar_2 = fract ((vec2(1.0, 255.0) * tmpvar_1.w)); + enc_i0_i1 = tmpvar_2; + enc_i0_i1.x = (tmpvar_2.x - (tmpvar_2.y * 0.00392157)); + enc.zw = enc_i0_i1; + gl_FragData[0] = enc; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Camera-DepthNormalTexture1-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Camera-DepthNormalTexture1-in.txt new file mode 100644 index 000000000..72b929561 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Camera-DepthNormalTexture1-in.txt @@ -0,0 +1,72 @@ +void xll_clip(float x) { + if ( x<0.0 ) discard; +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct v2f { + vec4 pos; + vec2 uv; + vec4 nz; +}; +struct appdata_grass { + vec4 vertex; + vec4 tangent; + vec4 color; + vec4 texcoord; + vec4 texcoord1; +}; +uniform float _Cutoff; +uniform sampler2D _MainTex; +vec2 EncodeViewNormalStereo( in vec3 n ); +vec2 EncodeFloatRG( in float v ); +vec4 EncodeDepthNormal( in float depth, in vec3 normal ); +vec4 frag( in v2f i ); +vec2 EncodeViewNormalStereo( in vec3 n ) { + float kScale = 1.77770; + vec2 enc; + enc = (n.xy / (n.z + 1.00000)); + enc /= kScale; + enc = ((enc * 0.500000) + 0.500000); + return enc; +} +vec2 EncodeFloatRG( in float v ) { + vec2 kEncodeMul = vec2( 1.00000, 255.000); + float kEncodeBit = 0.00392157; + vec2 enc; + enc = (kEncodeMul * v); + enc = fract( enc ); + enc.x -= (enc.y * kEncodeBit); + return enc; +} +vec4 EncodeDepthNormal( in float depth, in vec3 normal ) { + vec4 enc; + enc.xy = EncodeViewNormalStereo( normal); + enc.zw = EncodeFloatRG( depth); + return enc; +} +vec4 frag( in v2f i ) { + vec4 texcol; + texcol = texture2D( _MainTex, i.uv); + xll_clip( (texcol.w - _Cutoff) ); + return EncodeDepthNormal( i.nz.w , i.nz.xyz ); +} +void main() { + vec4 xl_retval; + v2f xlt_i; + xlt_i.pos = vec4(0.0); + xlt_i.uv = vec2( gl_TexCoord[0]); + xlt_i.nz = vec4( gl_TexCoord[1]); + xl_retval = frag( xlt_i); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Camera-DepthNormalTexture1-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Camera-DepthNormalTexture1-ir.txt new file mode 100644 index 000000000..5bc54c861 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Camera-DepthNormalTexture1-ir.txt @@ -0,0 +1,128 @@ +struct v2f { + vec4 pos; + vec2 uv; + vec4 nz; +}; +uniform sampler2D _MainTex; +uniform float _Cutoff; +void xll_clip ( + in float x +) +{ + if ((x < 0.0)) { + discard; + }; +} + +vec2 EncodeViewNormalStereo ( + in vec3 n +) +{ + vec2 enc; + float kScale; + float tmpvar_1; + tmpvar_1 = 1.7777; + kScale = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = (n.xy / (n.z + 1.0)); + enc = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = (enc / kScale); + enc = tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = ((enc * 0.5) + 0.5); + enc = tmpvar_4; + return enc; +} + +vec2 EncodeFloatRG ( + in float v +) +{ + vec2 enc; + float kEncodeBit; + vec2 kEncodeMul; + vec2 tmpvar_1; + tmpvar_1 = vec2(1.0, 255.0); + kEncodeMul = tmpvar_1; + float tmpvar_2; + tmpvar_2 = 0.00392157; + kEncodeBit = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = (kEncodeMul * v); + enc = tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = fract (enc); + vec2 tmpvar_5; + tmpvar_5 = tmpvar_4; + enc = tmpvar_5; + float tmpvar_6; + tmpvar_6 = (enc.x - (enc.y * kEncodeBit)); + enc.x = tmpvar_6; + return enc; +} + +vec4 EncodeDepthNormal ( + in float depth, + in vec3 normal +) +{ + vec4 enc; + vec2 tmpvar_1; + tmpvar_1 = EncodeViewNormalStereo (normal); + vec2 tmpvar_2; + tmpvar_2 = tmpvar_1; + enc.xy = tmpvar_2.xy.xy; + vec2 tmpvar_3; + tmpvar_3 = EncodeFloatRG (depth); + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + enc.zw = tmpvar_4.xxxy.zw; + return enc; +} + +vec4 frag ( + in v2f i +) +{ + vec4 texcol; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, i.uv); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + texcol = tmpvar_2; + xll_clip ((texcol.w - _Cutoff)); + vec4 tmpvar_3; + tmpvar_3 = EncodeDepthNormal (i.nz.w, i.nz.xyz); + return tmpvar_3; +} + +void main () +{ + v2f xlt_i; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_i.pos = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = gl_TexCoord[0].xy; + vec2 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_i.uv = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = gl_TexCoord[1].xyzw; + vec4 tmpvar_5; + tmpvar_5 = tmpvar_4; + xlt_i.nz = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = frag (xlt_i); + vec4 tmpvar_7; + tmpvar_7 = tmpvar_6; + xl_retval = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = xl_retval.xyzw; + vec4 tmpvar_9; + tmpvar_9 = tmpvar_8; + gl_FragData[0] = tmpvar_9; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Camera-DepthNormalTexture1-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Camera-DepthNormalTexture1-out.txt new file mode 100644 index 000000000..0d7f18884 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Camera-DepthNormalTexture1-out.txt @@ -0,0 +1,22 @@ +uniform sampler2D _MainTex; +uniform float _Cutoff; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = gl_TexCoord[1]; + float x; + x = (texture2D (_MainTex, gl_TexCoord[0].xy).w - _Cutoff); + if ((x < 0.0)) { + discard; + }; + vec4 enc; + enc.xy = ((((tmpvar_1.xy / (tmpvar_1.z + 1.0)) / 1.7777) * 0.5) + 0.5); + vec2 enc_i0_i1; + vec2 tmpvar_2; + tmpvar_2 = fract ((vec2(1.0, 255.0) * tmpvar_1.w)); + enc_i0_i1 = tmpvar_2; + enc_i0_i1.x = (tmpvar_2.x - (tmpvar_2.y * 0.00392157)); + enc.zw = enc_i0_i1; + gl_FragData[0] = enc; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Camera-DepthTexture-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Camera-DepthTexture-in.txt new file mode 100644 index 000000000..efda7df49 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Camera-DepthTexture-in.txt @@ -0,0 +1,42 @@ +void xll_clip(float x) { + if ( x<0.0 ) discard; +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct v2f { + vec4 pos; + vec2 uv; +}; +struct appdata_tree_billboard { + vec4 vertex; + vec4 color; + vec4 texcoord; + vec2 texcoord1; +}; +uniform sampler2D _MainTex; +vec4 frag( in v2f i ); +vec4 frag( in v2f i ) { + vec4 texcol; + texcol = texture2D( _MainTex, i.uv); + xll_clip( (texcol.w - 0.00100000) ); + return vec4( 0.000000); +} +void main() { + vec4 xl_retval; + v2f xlt_i; + xlt_i.pos = vec4(0.0); + xlt_i.uv = vec2( gl_TexCoord[0]); + xl_retval = frag( xlt_i); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Camera-DepthTexture-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Camera-DepthTexture-ir.txt new file mode 100644 index 000000000..33fcaec66 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Camera-DepthTexture-ir.txt @@ -0,0 +1,52 @@ +struct v2f { + vec4 pos; + vec2 uv; +}; +uniform sampler2D _MainTex; +void xll_clip ( + in float x +) +{ + if ((x < 0.0)) { + discard; + }; +} + +vec4 frag ( + in v2f i +) +{ + vec4 texcol; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, i.uv); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + texcol = tmpvar_2; + xll_clip ((texcol.w - 0.001)); + return vec4(0.0, 0.0, 0.0, 0.0); +} + +void main () +{ + v2f xlt_i; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_i.pos = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = gl_TexCoord[0].xy; + vec2 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_i.uv = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = frag (xlt_i); + vec4 tmpvar_5; + tmpvar_5 = tmpvar_4; + xl_retval = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = xl_retval.xyzw; + vec4 tmpvar_7; + tmpvar_7 = tmpvar_6; + gl_FragData[0] = tmpvar_7; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Camera-DepthTexture-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Camera-DepthTexture-out.txt new file mode 100644 index 000000000..8cf9dafbe --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Camera-DepthTexture-out.txt @@ -0,0 +1,11 @@ +uniform sampler2D _MainTex; +void main () +{ + float x; + x = (texture2D (_MainTex, gl_TexCoord[0].xy).w - 0.001); + if ((x < 0.0)) { + discard; + }; + gl_FragData[0] = vec4(0.0, 0.0, 0.0, 0.0); +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Color_Correction_Effect-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Color_Correction_Effect-in.txt new file mode 100644 index 000000000..eb6e51d66 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Color_Correction_Effect-in.txt @@ -0,0 +1,37 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +uniform sampler2D _MainTex; +uniform sampler2D _RampTex; +vec4 frag( in v2f_img i ); +vec4 frag( in v2f_img i ) { + vec4 orig; + float rr; + float gg; + float bb; + vec4 color; + orig = texture2D( _MainTex, i.uv); + rr = (texture2D( _RampTex, orig.xx ).x + 1.00000e-005); + gg = (texture2D( _RampTex, orig.yy ).y + 2.00000e-005); + bb = (texture2D( _RampTex, orig.zz ).z + 3.00000e-005); + color = vec4( rr, gg, bb, orig.w ); + return color; +} +void main() { + vec4 xl_retval; + v2f_img xlt_i; + xlt_i.pos = vec4(0.0); + xlt_i.uv = vec2( gl_TexCoord[0]); + xl_retval = frag( xlt_i); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Color_Correction_Effect-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Color_Correction_Effect-ir.txt new file mode 100644 index 000000000..e08ef4f65 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Color_Correction_Effect-ir.txt @@ -0,0 +1,70 @@ +struct v2f_img { + vec4 pos; + vec2 uv; +}; +uniform sampler2D _RampTex; +uniform sampler2D _MainTex; +vec4 frag ( + in v2f_img i +) +{ + vec4 color; + float bb; + float gg; + float rr; + vec4 orig; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, i.uv); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + orig = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = texture2D (_RampTex, orig.xx); + float tmpvar_4; + tmpvar_4 = (tmpvar_3.x + 1e-05); + rr = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = texture2D (_RampTex, orig.yy); + float tmpvar_6; + tmpvar_6 = (tmpvar_5.y + 2e-05); + gg = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = texture2D (_RampTex, orig.zz); + float tmpvar_8; + tmpvar_8 = (tmpvar_7.z + 3e-05); + bb = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9.x = rr; + tmpvar_9.y = gg; + tmpvar_9.z = bb; + tmpvar_9.w = orig.w; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + color = tmpvar_10; + return color; +} + +void main () +{ + v2f_img xlt_i; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_i.pos = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = gl_TexCoord[0].xy; + vec2 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_i.uv = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = frag (xlt_i); + vec4 tmpvar_5; + tmpvar_5 = tmpvar_4; + xl_retval = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = xl_retval.xyzw; + vec4 tmpvar_7; + tmpvar_7 = tmpvar_6; + gl_FragData[0] = tmpvar_7; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Color_Correction_Effect-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Color_Correction_Effect-out.txt new file mode 100644 index 000000000..be855f505 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Color_Correction_Effect-out.txt @@ -0,0 +1,14 @@ +uniform sampler2D _RampTex; +uniform sampler2D _MainTex; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, gl_TexCoord[0].xy); + vec4 tmpvar_2; + tmpvar_2.x = (texture2D (_RampTex, tmpvar_1.xx).x + 1e-05); + tmpvar_2.y = (texture2D (_RampTex, tmpvar_1.yy).y + 2e-05); + tmpvar_2.z = (texture2D (_RampTex, tmpvar_1.zz).z + 3e-05); + tmpvar_2.w = tmpvar_1.w; + gl_FragData[0] = tmpvar_2; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Edge_Detect_X-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Edge_Detect_X-in.txt new file mode 100644 index 000000000..9c181355c --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Edge_Detect_X-in.txt @@ -0,0 +1,48 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct v2f { + vec4 pos; + vec2 uv[3]; +}; +uniform sampler2D _MainTex; +uniform float _Treshold; +vec4 frag( in v2f i ); +vec4 frag( in v2f i ) { + vec4 original; + vec3 p1; + vec3 p2; + vec3 p3; + vec3 diff; + float len; + original = texture2D( _MainTex, i.uv[ 0 ]); + p1 = original.xyz ; + p2 = texture2D( _MainTex, i.uv[ 1 ]).xyz ; + p3 = texture2D( _MainTex, i.uv[ 2 ]).xyz ; + diff = (((p1 * 2.00000) - p2) - p3); + len = dot( diff, diff); + if ( (len >= _Treshold) ){ + original.xyz = vec3( 0.000000); + } + return original; +} +void main() { + vec4 xl_retval; + v2f xlt_i; + xlt_i.pos = vec4(0.0); + xlt_i.uv[0] = vec2( gl_TexCoord[0]); + xlt_i.uv[1] = vec2( gl_TexCoord[1]); + xlt_i.uv[2] = vec2( gl_TexCoord[2]); + xl_retval = frag( xlt_i); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Edge_Detect_X-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Edge_Detect_X-ir.txt new file mode 100644 index 000000000..58de22155 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Edge_Detect_X-ir.txt @@ -0,0 +1,84 @@ +struct v2f { + vec4 pos; + vec2 uv[3]; +}; +uniform float _Treshold; +uniform sampler2D _MainTex; +vec4 frag ( + in v2f i +) +{ + float len; + vec3 diff; + vec3 p3; + vec3 p2; + vec3 p1; + vec4 original; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, i.uv[0]); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + original = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = original.xyz; + p1 = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = texture2D (_MainTex, i.uv[1]); + vec3 tmpvar_5; + tmpvar_5 = tmpvar_4.xyz; + p2 = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = texture2D (_MainTex, i.uv[2]); + vec3 tmpvar_7; + tmpvar_7 = tmpvar_6.xyz; + p3 = tmpvar_7; + vec3 tmpvar_8; + tmpvar_8 = (((p1 * 2.0) - p2) - p3); + diff = tmpvar_8; + float tmpvar_9; + tmpvar_9 = dot (diff, diff); + float tmpvar_10; + tmpvar_10 = tmpvar_9; + len = tmpvar_10; + if ((len >= _Treshold)) { + vec3 tmpvar_11; + tmpvar_11 = vec3(0.0, 0.0, 0.0); + original.xyz = tmpvar_11.xyz.xyz; + }; + return original; +} + +void main () +{ + v2f xlt_i; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_i.pos = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = gl_TexCoord[0].xy; + vec2 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_i.uv[0] = tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = gl_TexCoord[1].xy; + vec2 tmpvar_5; + tmpvar_5 = tmpvar_4; + xlt_i.uv[1] = tmpvar_5; + vec2 tmpvar_6; + tmpvar_6 = gl_TexCoord[2].xy; + vec2 tmpvar_7; + tmpvar_7 = tmpvar_6; + xlt_i.uv[2] = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = frag (xlt_i); + vec4 tmpvar_9; + tmpvar_9 = tmpvar_8; + xl_retval = tmpvar_9; + vec4 tmpvar_10; + tmpvar_10 = xl_retval.xyzw; + vec4 tmpvar_11; + tmpvar_11 = tmpvar_10; + gl_FragData[0] = tmpvar_11; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Edge_Detect_X-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Edge_Detect_X-out.txt new file mode 100644 index 000000000..76cd800a4 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Edge_Detect_X-out.txt @@ -0,0 +1,22 @@ +uniform float _Treshold; +uniform sampler2D _MainTex; +void main () +{ + vec2 tmpvar_1[3]; + tmpvar_1[0] = gl_TexCoord[0].xy; + tmpvar_1[1] = gl_TexCoord[1].xy; + tmpvar_1[2] = gl_TexCoord[2].xy; + vec4 original; + vec4 tmpvar_2; + tmpvar_2 = texture2D (_MainTex, tmpvar_1[0]); + original = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = (((tmpvar_2.xyz * 2.0) - texture2D (_MainTex, tmpvar_1[1]).xyz) - texture2D (_MainTex, tmpvar_1[2]).xyz); + float tmpvar_4; + tmpvar_4 = dot (tmpvar_3, tmpvar_3); + if ((tmpvar_4 >= _Treshold)) { + original.xyz = vec3(0.0, 0.0, 0.0); + }; + gl_FragData[0] = original; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_GlowConeTap-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_GlowConeTap-in.txt new file mode 100644 index 000000000..68cc42c56 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_GlowConeTap-in.txt @@ -0,0 +1,38 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct v2f { + vec4 pos; + vec4 uv[2]; +}; +uniform vec4 _Color; +uniform sampler2D _MainTex; +vec4 frag( in v2f i ); +vec4 frag( in v2f i ) { + vec4 c; + c = texture2D( _MainTex, i.uv[ 0 ].xy ); + c += texture2D( _MainTex, i.uv[ 0 ].zw ); + c += texture2D( _MainTex, i.uv[ 1 ].xy ); + c += texture2D( _MainTex, i.uv[ 1 ].zw ); + c.xyz *= _Color.xyz ; + return (c * _Color.w ); +} +void main() { + vec4 xl_retval; + v2f xlt_i; + xlt_i.pos = vec4(0.0); + xlt_i.uv[0] = vec4( gl_TexCoord[0]); + xlt_i.uv[1] = vec4( gl_TexCoord[1]); + xl_retval = frag( xlt_i); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_GlowConeTap-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_GlowConeTap-ir.txt new file mode 100644 index 000000000..5e8bd5fe9 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_GlowConeTap-ir.txt @@ -0,0 +1,66 @@ +struct v2f { + vec4 pos; + vec4 uv[2]; +}; +uniform sampler2D _MainTex; +uniform vec4 _Color; +vec4 frag ( + in v2f i +) +{ + vec4 c; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, i.uv[0].xy); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + c = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = texture2D (_MainTex, i.uv[0].zw); + vec4 tmpvar_4; + tmpvar_4 = (c + tmpvar_3); + c = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = texture2D (_MainTex, i.uv[1].xy); + vec4 tmpvar_6; + tmpvar_6 = (c + tmpvar_5); + c = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = texture2D (_MainTex, i.uv[1].zw); + vec4 tmpvar_8; + tmpvar_8 = (c + tmpvar_7); + c = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = (c.xyz * _Color.xyz); + c.xyz = tmpvar_9.xyz.xyz; + return (c * _Color.w); +} + +void main () +{ + v2f xlt_i; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_i.pos = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = gl_TexCoord[0].xyzw; + vec4 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_i.uv[0] = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = gl_TexCoord[1].xyzw; + vec4 tmpvar_5; + tmpvar_5 = tmpvar_4; + xlt_i.uv[1] = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = frag (xlt_i); + vec4 tmpvar_7; + tmpvar_7 = tmpvar_6; + xl_retval = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = xl_retval.xyzw; + vec4 tmpvar_9; + tmpvar_9 = tmpvar_8; + gl_FragData[0] = tmpvar_9; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_GlowConeTap-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_GlowConeTap-out.txt new file mode 100644 index 000000000..286ab7904 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_GlowConeTap-out.txt @@ -0,0 +1,15 @@ +uniform sampler2D _MainTex; +uniform vec4 _Color; +void main () +{ + vec4 tmpvar_1[2]; + tmpvar_1[0] = gl_TexCoord[0]; + tmpvar_1[1] = gl_TexCoord[1]; + vec4 c; + vec4 tmpvar_2; + tmpvar_2 = (((texture2D (_MainTex, tmpvar_1[0].xy) + texture2D (_MainTex, tmpvar_1[0].zw)) + texture2D (_MainTex, tmpvar_1[1].xy)) + texture2D (_MainTex, tmpvar_1[1].zw)); + c = tmpvar_2; + c.xyz = (tmpvar_2.xyz * _Color.xyz); + gl_FragData[0] = (c * _Color.w); +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Glow_Downsample-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Glow_Downsample-in.txt new file mode 100644 index 000000000..bafe69eac --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Glow_Downsample-in.txt @@ -0,0 +1,43 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct v2f { + vec4 pos; + vec4 uv[4]; +}; +uniform vec4 _Color; +uniform sampler2D _MainTex; +vec4 frag( in v2f i ); +vec4 frag( in v2f i ) { + vec4 c; + c = texture2D( _MainTex, i.uv[ 0 ].xy ); + c += texture2D( _MainTex, i.uv[ 1 ].xy ); + c += texture2D( _MainTex, i.uv[ 2 ].xy ); + c += texture2D( _MainTex, i.uv[ 3 ].xy ); + c /= 4.00000; + c.xyz *= _Color.xyz ; + c.xyz *= (c.w + _Color.w ); + c.w = 0.000000; + return c; +} +void main() { + vec4 xl_retval; + v2f xlt_i; + xlt_i.pos = vec4(0.0); + xlt_i.uv[0] = vec4( gl_TexCoord[0]); + xlt_i.uv[1] = vec4( gl_TexCoord[1]); + xlt_i.uv[2] = vec4( gl_TexCoord[2]); + xlt_i.uv[3] = vec4( gl_TexCoord[3]); + xl_retval = frag( xlt_i); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Glow_Downsample-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Glow_Downsample-ir.txt new file mode 100644 index 000000000..ba3fc4ed3 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Glow_Downsample-ir.txt @@ -0,0 +1,85 @@ +struct v2f { + vec4 pos; + vec4 uv[4]; +}; +uniform sampler2D _MainTex; +uniform vec4 _Color; +vec4 frag ( + in v2f i +) +{ + vec4 c; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, i.uv[0].xy); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + c = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = texture2D (_MainTex, i.uv[1].xy); + vec4 tmpvar_4; + tmpvar_4 = (c + tmpvar_3); + c = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = texture2D (_MainTex, i.uv[2].xy); + vec4 tmpvar_6; + tmpvar_6 = (c + tmpvar_5); + c = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = texture2D (_MainTex, i.uv[3].xy); + vec4 tmpvar_8; + tmpvar_8 = (c + tmpvar_7); + c = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = (c / 4.0); + c = tmpvar_9; + vec3 tmpvar_10; + tmpvar_10 = (c.xyz * _Color.xyz); + c.xyz = tmpvar_10.xyz.xyz; + vec3 tmpvar_11; + tmpvar_11 = (c.xyz * (c.w + _Color.w)); + c.xyz = tmpvar_11.xyz.xyz; + float tmpvar_12; + tmpvar_12 = 0.0; + c.w = vec4(tmpvar_12).w; + return c; +} + +void main () +{ + v2f xlt_i; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_i.pos = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = gl_TexCoord[0].xyzw; + vec4 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_i.uv[0] = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = gl_TexCoord[1].xyzw; + vec4 tmpvar_5; + tmpvar_5 = tmpvar_4; + xlt_i.uv[1] = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = gl_TexCoord[2].xyzw; + vec4 tmpvar_7; + tmpvar_7 = tmpvar_6; + xlt_i.uv[2] = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = gl_TexCoord[3].xyzw; + vec4 tmpvar_9; + tmpvar_9 = tmpvar_8; + xlt_i.uv[3] = tmpvar_9; + vec4 tmpvar_10; + tmpvar_10 = frag (xlt_i); + vec4 tmpvar_11; + tmpvar_11 = tmpvar_10; + xl_retval = tmpvar_11; + vec4 tmpvar_12; + tmpvar_12 = xl_retval.xyzw; + vec4 tmpvar_13; + tmpvar_13 = tmpvar_12; + gl_FragData[0] = tmpvar_13; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Glow_Downsample-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Glow_Downsample-out.txt new file mode 100644 index 000000000..4435d2203 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Glow_Downsample-out.txt @@ -0,0 +1,19 @@ +uniform sampler2D _MainTex; +uniform vec4 _Color; +void main () +{ + vec4 tmpvar_1[4]; + tmpvar_1[0] = gl_TexCoord[0]; + tmpvar_1[1] = gl_TexCoord[1]; + tmpvar_1[2] = gl_TexCoord[2]; + tmpvar_1[3] = gl_TexCoord[3]; + vec4 c; + vec4 tmpvar_2; + tmpvar_2 = ((((texture2D (_MainTex, tmpvar_1[0].xy) + texture2D (_MainTex, tmpvar_1[1].xy)) + texture2D (_MainTex, tmpvar_1[2].xy)) + texture2D (_MainTex, tmpvar_1[3].xy)) / 4.0); + c = tmpvar_2; + c.xyz = (tmpvar_2.xyz * _Color.xyz); + c.xyz = (c.xyz * (tmpvar_2.w + _Color.w)); + c.w = 0.0; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Grayscale_Effect-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Grayscale_Effect-in.txt new file mode 100644 index 000000000..c20e3ef04 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Grayscale_Effect-in.txt @@ -0,0 +1,41 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +uniform sampler2D _MainTex; +uniform float _RampOffset; +uniform sampler2D _RampTex; +float Luminance( in vec3 c ); +vec4 frag( in v2f_img i ); +float Luminance( in vec3 c ) { + return dot( c, vec3( 0.220000, 0.707000, 0.0710000)); +} +vec4 frag( in v2f_img i ) { + vec4 original; + float grayscale; + vec2 remap; + vec4 xlat_var_output; + original = texture2D( _MainTex, i.uv); + grayscale = Luminance( original.xyz ); + remap = vec2( (grayscale + _RampOffset), 0.500000); + xlat_var_output = texture2D( _RampTex, remap); + xlat_var_output.w = original.w ; + return xlat_var_output; +} +void main() { + vec4 xl_retval; + v2f_img xlt_i; + xlt_i.pos = vec4(0.0); + xlt_i.uv = vec2( gl_TexCoord[0]); + xl_retval = frag( xlt_i); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Grayscale_Effect-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Grayscale_Effect-ir.txt new file mode 100644 index 000000000..0f6889c5b --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Grayscale_Effect-ir.txt @@ -0,0 +1,75 @@ +struct v2f_img { + vec4 pos; + vec2 uv; +}; +uniform sampler2D _RampTex; +uniform float _RampOffset; +uniform sampler2D _MainTex; +float Luminance ( + in vec3 c +) +{ + float tmpvar_1; + tmpvar_1 = dot (c, vec3(0.22, 0.707, 0.071)); + return tmpvar_1; +} + +vec4 frag ( + in v2f_img i +) +{ + vec4 xlat_var_output; + vec2 remap; + float grayscale; + vec4 original; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, i.uv); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + original = tmpvar_2; + float tmpvar_3; + tmpvar_3 = Luminance (original.xyz); + float tmpvar_4; + tmpvar_4 = tmpvar_3; + grayscale = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5.y = 0.5; + tmpvar_5.x = (grayscale + _RampOffset); + vec2 tmpvar_6; + tmpvar_6 = tmpvar_5; + remap = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = texture2D (_RampTex, remap); + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlat_var_output = tmpvar_8; + float tmpvar_9; + tmpvar_9 = original.w; + xlat_var_output.w = vec4(tmpvar_9).w; + return xlat_var_output; +} + +void main () +{ + v2f_img xlt_i; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_i.pos = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = gl_TexCoord[0].xy; + vec2 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_i.uv = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = frag (xlt_i); + vec4 tmpvar_5; + tmpvar_5 = tmpvar_4; + xl_retval = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = xl_retval.xyzw; + vec4 tmpvar_7; + tmpvar_7 = tmpvar_6; + gl_FragData[0] = tmpvar_7; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Grayscale_Effect-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Grayscale_Effect-out.txt new file mode 100644 index 000000000..6411213c7 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Grayscale_Effect-out.txt @@ -0,0 +1,16 @@ +uniform sampler2D _RampTex; +uniform float _RampOffset; +uniform sampler2D _MainTex; +void main () +{ + vec4 xlat_var_output; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, gl_TexCoord[0].xy); + vec2 tmpvar_2; + tmpvar_2.y = 0.5; + tmpvar_2.x = (dot (tmpvar_1.xyz, vec3(0.22, 0.707, 0.071)) + _RampOffset); + xlat_var_output = texture2D (_RampTex, tmpvar_2); + xlat_var_output.w = tmpvar_1.w; + gl_FragData[0] = xlat_var_output; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Internal-CombineDepthNormals-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Internal-CombineDepthNormals-in.txt new file mode 100644 index 000000000..5a981d7f7 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Internal-CombineDepthNormals-in.txt @@ -0,0 +1,73 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct v2f { + vec4 pos; + vec2 uv; +}; +struct appdata { + vec4 vertex; + vec2 texcoord; +}; +uniform sampler2D _CameraDepthTexture; +uniform sampler2D _CameraNormalsTexture; +uniform vec4 _ZBufferParams; +float Linear01Depth( in float z ); +vec2 EncodeViewNormalStereo( in vec3 n ); +vec2 EncodeFloatRG( in float v ); +vec4 EncodeDepthNormal( in float depth, in vec3 normal ); +vec4 frag( in v2f i ); +float Linear01Depth( in float z ) { + return (1.00000 / ((_ZBufferParams.x * z) + _ZBufferParams.y )); +} +vec2 EncodeViewNormalStereo( in vec3 n ) { + float kScale = 1.77770; + vec2 enc; + enc = (n.xy / (n.z + 1.00000)); + enc /= kScale; + enc = ((enc * 0.500000) + 0.500000); + return enc; +} +vec2 EncodeFloatRG( in float v ) { + vec2 kEncodeMul = vec2( 1.00000, 255.000); + float kEncodeBit = 0.00392157; + vec2 enc; + enc = (kEncodeMul * v); + enc = fract( enc ); + enc.x -= (enc.y * kEncodeBit); + return enc; +} +vec4 EncodeDepthNormal( in float depth, in vec3 normal ) { + vec4 enc; + enc.xy = EncodeViewNormalStereo( normal); + enc.zw = EncodeFloatRG( depth); + return enc; +} +vec4 frag( in v2f i ) { + float d; + vec4 n; + d = texture2D( _CameraDepthTexture, i.uv).x ; + n = texture2D( _CameraNormalsTexture, i.uv); + d = Linear01Depth( d); + n.xyz = ((n.xyz * 2.00000) - 1.00000); + n.z = ( -n.z ); + return ( (d < 0.999985) ) ? ( EncodeDepthNormal( d, n.xyz ) ) : ( vec4( 0.500000, 0.500000, 1.00000, 1.00000) ); +} +void main() { + vec4 xl_retval; + v2f xlt_i; + xlt_i.pos = vec4(0.0); + xlt_i.uv = vec2( gl_TexCoord[0]); + xl_retval = frag( xlt_i); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Internal-CombineDepthNormals-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Internal-CombineDepthNormals-ir.txt new file mode 100644 index 000000000..bb20a3aa3 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Internal-CombineDepthNormals-ir.txt @@ -0,0 +1,143 @@ +struct v2f { + vec4 pos; + vec2 uv; +}; +uniform vec4 _ZBufferParams; +uniform sampler2D _CameraNormalsTexture; +uniform sampler2D _CameraDepthTexture; +float Linear01Depth ( + in float z +) +{ + return (1.0 / ((_ZBufferParams.x * z) + _ZBufferParams.y)); +} + +vec2 EncodeViewNormalStereo ( + in vec3 n +) +{ + vec2 enc; + float kScale; + float tmpvar_1; + tmpvar_1 = 1.7777; + kScale = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = (n.xy / (n.z + 1.0)); + enc = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = (enc / kScale); + enc = tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = ((enc * 0.5) + 0.5); + enc = tmpvar_4; + return enc; +} + +vec2 EncodeFloatRG ( + in float v +) +{ + vec2 enc; + float kEncodeBit; + vec2 kEncodeMul; + vec2 tmpvar_1; + tmpvar_1 = vec2(1.0, 255.0); + kEncodeMul = tmpvar_1; + float tmpvar_2; + tmpvar_2 = 0.00392157; + kEncodeBit = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = (kEncodeMul * v); + enc = tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = fract (enc); + vec2 tmpvar_5; + tmpvar_5 = tmpvar_4; + enc = tmpvar_5; + float tmpvar_6; + tmpvar_6 = (enc.x - (enc.y * kEncodeBit)); + enc.x = tmpvar_6; + return enc; +} + +vec4 EncodeDepthNormal ( + in float depth, + in vec3 normal +) +{ + vec4 enc; + vec2 tmpvar_1; + tmpvar_1 = EncodeViewNormalStereo (normal); + vec2 tmpvar_2; + tmpvar_2 = tmpvar_1; + enc.xy = tmpvar_2.xy.xy; + vec2 tmpvar_3; + tmpvar_3 = EncodeFloatRG (depth); + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + enc.zw = tmpvar_4.xxxy.zw; + return enc; +} + +vec4 frag ( + in v2f i +) +{ + vec4 n; + float d; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_CameraDepthTexture, i.uv); + float tmpvar_2; + tmpvar_2 = tmpvar_1.x; + d = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = texture2D (_CameraNormalsTexture, i.uv); + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + n = tmpvar_4; + float tmpvar_5; + tmpvar_5 = Linear01Depth (d); + float tmpvar_6; + tmpvar_6 = tmpvar_5; + d = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = ((n.xyz * 2.0) - 1.0); + n.xyz = tmpvar_7.xyz.xyz; + float tmpvar_8; + tmpvar_8 = -(n.z); + n.z = vec3(tmpvar_8).z; + vec4 tmpvar_9; + if ((d < 0.999985)) { + vec4 tmpvar_10; + tmpvar_10 = EncodeDepthNormal (d, n.xyz); + tmpvar_9 = tmpvar_10; + } else { + tmpvar_9 = vec4(0.5, 0.5, 1.0, 1.0); + }; + return tmpvar_9; +} + +void main () +{ + v2f xlt_i; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_i.pos = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = gl_TexCoord[0].xy; + vec2 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_i.uv = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = frag (xlt_i); + vec4 tmpvar_5; + tmpvar_5 = tmpvar_4; + xl_retval = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = xl_retval.xyzw; + vec4 tmpvar_7; + tmpvar_7 = tmpvar_6; + gl_FragData[0] = tmpvar_7; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Internal-CombineDepthNormals-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Internal-CombineDepthNormals-out.txt new file mode 100644 index 000000000..764b4c9f1 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Internal-CombineDepthNormals-out.txt @@ -0,0 +1,32 @@ +uniform vec4 _ZBufferParams; +uniform sampler2D _CameraNormalsTexture; +uniform sampler2D _CameraDepthTexture; +void main () +{ + vec2 tmpvar_1; + tmpvar_1 = gl_TexCoord[0].xy; + vec4 n; + vec4 tmpvar_2; + tmpvar_2 = texture2D (_CameraNormalsTexture, tmpvar_1); + n = tmpvar_2; + float tmpvar_3; + tmpvar_3 = (1.0/(((_ZBufferParams.x * texture2D (_CameraDepthTexture, tmpvar_1).x) + _ZBufferParams.y))); + n.xyz = ((tmpvar_2.xyz * 2.0) - 1.0); + n.z = -(n.z); + vec4 tmpvar_4; + if ((tmpvar_3 < 0.999985)) { + vec4 enc; + enc.xy = ((((n.xy / (n.z + 1.0)) / 1.7777) * 0.5) + 0.5); + vec2 enc_i0_i1; + vec2 tmpvar_5; + tmpvar_5 = fract ((vec2(1.0, 255.0) * tmpvar_3)); + enc_i0_i1 = tmpvar_5; + enc_i0_i1.x = (tmpvar_5.x - (tmpvar_5.y * 0.00392157)); + enc.zw = enc_i0_i1; + tmpvar_4 = enc; + } else { + tmpvar_4 = vec4(0.5, 0.5, 1.0, 1.0); + }; + gl_FragData[0] = tmpvar_4; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Internal-GUITextureBlit-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Internal-GUITextureBlit-in.txt new file mode 100644 index 000000000..f157ad534 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Internal-GUITextureBlit-in.txt @@ -0,0 +1,43 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct v2f { + vec4 vertex; + vec4 color; + vec2 texcoord; + vec2 texgencoord; +}; +struct appdata_t { + vec4 vertex; + vec4 color; + vec2 texcoord; +}; +uniform sampler2D _GUIClipTexture; +uniform sampler2D _MainTex; +vec4 frag( in v2f i ); +vec4 frag( in v2f i ) { + vec4 col; + col.xyz = (texture2D( _MainTex, i.texcoord).xyz * i.color.xyz ); + col.w = (i.color.w * texture2D( _GUIClipTexture, i.texgencoord).w ); + return col; +} +void main() { + vec4 xl_retval; + v2f xlt_i; + xlt_i.vertex = vec4(0.0); + xlt_i.color = vec4( gl_Color); + xlt_i.texcoord = vec2( gl_TexCoord[0]); + xlt_i.texgencoord = vec2( gl_TexCoord[1]); + xl_retval = frag( xlt_i); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Internal-GUITextureBlit-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Internal-GUITextureBlit-ir.txt new file mode 100644 index 000000000..d4ffecc1e --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Internal-GUITextureBlit-ir.txt @@ -0,0 +1,60 @@ +struct v2f { + vec4 vertex; + vec4 color; + vec2 texcoord; + vec2 texgencoord; +}; +uniform sampler2D _MainTex; +uniform sampler2D _GUIClipTexture; +vec4 frag ( + in v2f i +) +{ + vec4 col; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, i.texcoord); + vec3 tmpvar_2; + tmpvar_2 = (tmpvar_1.xyz * i.color.xyz); + col.xyz = tmpvar_2.xyz.xyz; + vec4 tmpvar_3; + tmpvar_3 = texture2D (_GUIClipTexture, i.texgencoord); + float tmpvar_4; + tmpvar_4 = (i.color.w * tmpvar_3.w); + col.w = vec4(tmpvar_4).w; + return col; +} + +void main () +{ + v2f xlt_i; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_i.vertex = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = gl_Color.xyzw; + vec4 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_i.color = tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = gl_TexCoord[0].xy; + vec2 tmpvar_5; + tmpvar_5 = tmpvar_4; + xlt_i.texcoord = tmpvar_5; + vec2 tmpvar_6; + tmpvar_6 = gl_TexCoord[1].xy; + vec2 tmpvar_7; + tmpvar_7 = tmpvar_6; + xlt_i.texgencoord = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = frag (xlt_i); + vec4 tmpvar_9; + tmpvar_9 = tmpvar_8; + xl_retval = tmpvar_9; + vec4 tmpvar_10; + tmpvar_10 = xl_retval.xyzw; + vec4 tmpvar_11; + tmpvar_11 = tmpvar_10; + gl_FragData[0] = tmpvar_11; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Internal-GUITextureBlit-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Internal-GUITextureBlit-out.txt new file mode 100644 index 000000000..5dcfd9214 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Internal-GUITextureBlit-out.txt @@ -0,0 +1,10 @@ +uniform sampler2D _MainTex; +uniform sampler2D _GUIClipTexture; +void main () +{ + vec4 col; + col.xyz = (texture2D (_MainTex, gl_TexCoord[0].xy).xyz * gl_Color.xyz); + col.w = (gl_Color.w * texture2D (_GUIClipTexture, gl_TexCoord[1].xy).w); + gl_FragData[0] = col; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Internal-GUITextureClip-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Internal-GUITextureClip-in.txt new file mode 100644 index 000000000..8ac7505ce --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Internal-GUITextureClip-in.txt @@ -0,0 +1,43 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct v2f { + vec4 vertex; + vec4 color; + vec2 texcoord; + vec2 texgencoord; +}; +struct appdata_t { + vec4 vertex; + vec4 color; + vec2 texcoord; +}; +uniform sampler2D _GUIClipTexture; +uniform sampler2D _MainTex; +vec4 frag( in v2f i ); +vec4 frag( in v2f i ) { + vec4 col; + col = (texture2D( _MainTex, i.texcoord) * i.color); + col.w *= texture2D( _GUIClipTexture, i.texgencoord).w ; + return col; +} +void main() { + vec4 xl_retval; + v2f xlt_i; + xlt_i.vertex = vec4(0.0); + xlt_i.color = vec4( gl_Color); + xlt_i.texcoord = vec2( gl_TexCoord[0]); + xlt_i.texgencoord = vec2( gl_TexCoord[1]); + xl_retval = frag( xlt_i); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Internal-GUITextureClip-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Internal-GUITextureClip-ir.txt new file mode 100644 index 000000000..4432e95ea --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Internal-GUITextureClip-ir.txt @@ -0,0 +1,60 @@ +struct v2f { + vec4 vertex; + vec4 color; + vec2 texcoord; + vec2 texgencoord; +}; +uniform sampler2D _MainTex; +uniform sampler2D _GUIClipTexture; +vec4 frag ( + in v2f i +) +{ + vec4 col; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, i.texcoord); + vec4 tmpvar_2; + tmpvar_2 = (tmpvar_1 * i.color); + col = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = texture2D (_GUIClipTexture, i.texgencoord); + float tmpvar_4; + tmpvar_4 = (col.w * tmpvar_3.w); + col.w = vec4(tmpvar_4).w; + return col; +} + +void main () +{ + v2f xlt_i; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_i.vertex = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = gl_Color.xyzw; + vec4 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_i.color = tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = gl_TexCoord[0].xy; + vec2 tmpvar_5; + tmpvar_5 = tmpvar_4; + xlt_i.texcoord = tmpvar_5; + vec2 tmpvar_6; + tmpvar_6 = gl_TexCoord[1].xy; + vec2 tmpvar_7; + tmpvar_7 = tmpvar_6; + xlt_i.texgencoord = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = frag (xlt_i); + vec4 tmpvar_9; + tmpvar_9 = tmpvar_8; + xl_retval = tmpvar_9; + vec4 tmpvar_10; + tmpvar_10 = xl_retval.xyzw; + vec4 tmpvar_11; + tmpvar_11 = tmpvar_10; + gl_FragData[0] = tmpvar_11; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Internal-GUITextureClip-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Internal-GUITextureClip-out.txt new file mode 100644 index 000000000..1f4741aa5 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Internal-GUITextureClip-out.txt @@ -0,0 +1,12 @@ +uniform sampler2D _MainTex; +uniform sampler2D _GUIClipTexture; +void main () +{ + vec4 col; + vec4 tmpvar_1; + tmpvar_1 = (texture2D (_MainTex, gl_TexCoord[0].xy) * gl_Color); + col = tmpvar_1; + col.w = (tmpvar_1.w * texture2D (_GUIClipTexture, gl_TexCoord[1].xy).w); + gl_FragData[0] = col; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Internal-Halo-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Internal-Halo-in.txt new file mode 100644 index 000000000..06728776c --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Internal-Halo-in.txt @@ -0,0 +1,39 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct v2f { + vec4 vertex; + vec4 color; + vec2 texcoord; +}; +struct appdata_t { + vec4 vertex; + vec4 color; + vec2 texcoord; +}; +uniform sampler2D _HaloFalloff; +vec4 frag( in v2f i ); +vec4 frag( in v2f i ) { + float a; + a = texture2D( _HaloFalloff, i.texcoord).w ; + return vec4( (i.color.xyz * a), a); +} +void main() { + vec4 xl_retval; + v2f xlt_i; + xlt_i.vertex = vec4(0.0); + xlt_i.color = vec4( gl_Color); + xlt_i.texcoord = vec2( gl_TexCoord[0]); + xl_retval = frag( xlt_i); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Internal-Halo-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Internal-Halo-ir.txt new file mode 100644 index 000000000..535bd2f7d --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Internal-Halo-ir.txt @@ -0,0 +1,51 @@ +struct v2f { + vec4 vertex; + vec4 color; + vec2 texcoord; +}; +uniform sampler2D _HaloFalloff; +vec4 frag ( + in v2f i +) +{ + float a; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_HaloFalloff, i.texcoord); + float tmpvar_2; + tmpvar_2 = tmpvar_1.w; + a = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3.xyz = (i.color.xyz * a).xyz; + tmpvar_3.w = a; + return tmpvar_3; +} + +void main () +{ + v2f xlt_i; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_i.vertex = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = gl_Color.xyzw; + vec4 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_i.color = tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = gl_TexCoord[0].xy; + vec2 tmpvar_5; + tmpvar_5 = tmpvar_4; + xlt_i.texcoord = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = frag (xlt_i); + vec4 tmpvar_7; + tmpvar_7 = tmpvar_6; + xl_retval = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = xl_retval.xyzw; + vec4 tmpvar_9; + tmpvar_9 = tmpvar_8; + gl_FragData[0] = tmpvar_9; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Internal-Halo-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Internal-Halo-out.txt new file mode 100644 index 000000000..dbb65dee0 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Internal-Halo-out.txt @@ -0,0 +1,11 @@ +uniform sampler2D _HaloFalloff; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = texture2D (_HaloFalloff, gl_TexCoord[0].xy); + vec4 tmpvar_2; + tmpvar_2.xyz = (gl_Color.xyz * tmpvar_1.w); + tmpvar_2.w = tmpvar_1.w; + gl_FragData[0] = tmpvar_2; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Internal-PrePassCollectShadows-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Internal-PrePassCollectShadows-in.txt new file mode 100644 index 000000000..2e8a50b1f --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Internal-PrePassCollectShadows-in.txt @@ -0,0 +1,95 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct v2f { + vec4 pos; + vec2 uv; + vec3 ray; +}; +struct appdata { + vec4 vertex; + vec2 texcoord; + vec3 texcoord1; +}; +uniform sampler2D _CameraDepthTexture; +uniform vec4 _LightShadowData; +uniform vec4 _LightSplitsFar; +uniform vec4 _LightSplitsNear; +uniform sampler2D _ShadowMapTexture; +uniform mat4 _View2Shadow; +uniform mat4 _View2Shadow1; +uniform mat4 _View2Shadow2; +uniform mat4 _View2Shadow3; +uniform vec4 _ZBufferParams; +float unitySampleShadow( in vec4 eyePos ); +float Linear01Depth( in float z ); +vec2 EncodeFloatRG( in float v ); +vec4 frag( in v2f i ); +float unitySampleShadow( in vec4 eyePos ) { + vec3 sc0; + vec3 sc1; + vec3 sc2; + vec3 sc3; + float z; + vec4 near; + vec4 far; + vec4 weights; + vec4 coord; + float shadow; + sc0 = ( _View2Shadow * eyePos ).xyz ; + sc1 = ( _View2Shadow1 * eyePos ).xyz ; + sc2 = ( _View2Shadow2 * eyePos ).xyz ; + sc3 = ( _View2Shadow3 * eyePos ).xyz ; + z = eyePos.z ; + near = vec4( greaterThanEqual( vec4( z ), _LightSplitsNear) ); + far = vec4( lessThan( vec4( z ), _LightSplitsFar) ); + weights = (near * far); + coord = vec4( ((((sc0 * weights.x ) + (sc1 * weights.y )) + (sc2 * weights.z )) + (sc3 * weights.w )), 1.00000); + shadow = ( (texture2D( _ShadowMapTexture, coord.xy ).x < coord.z ) ) ? ( _LightShadowData.x ) : ( 1.00000 ); + return shadow; +} +float Linear01Depth( in float z ) { + return (1.00000 / ((_ZBufferParams.x * z) + _ZBufferParams.y )); +} +vec2 EncodeFloatRG( in float v ) { + vec2 kEncodeMul = vec2( 1.00000, 255.000); + float kEncodeBit = 0.00392157; + vec2 enc; + enc = (kEncodeMul * v); + enc = fract( enc ); + enc.x -= (enc.y * kEncodeBit); + return enc; +} +vec4 frag( in v2f i ) { + float depth; + vec4 vpos; + float shadow; + vec4 res; + depth = texture2D( _CameraDepthTexture, i.uv).x ; + depth = Linear01Depth( depth); + vpos = vec4( (i.ray * depth), 1.00000); + shadow = unitySampleShadow( vpos); + res.x = shadow; + res.y = 1.00000; + res.zw = EncodeFloatRG( (1.00000 - depth)); + return res; +} +void main() { + vec4 xl_retval; + v2f xlt_i; + xlt_i.pos = vec4(0.0); + xlt_i.uv = vec2( gl_TexCoord[0]); + xlt_i.ray = vec3( gl_TexCoord[1]); + xl_retval = frag( xlt_i); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Internal-PrePassCollectShadows-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Internal-PrePassCollectShadows-ir.txt new file mode 100644 index 000000000..b5e79db6d --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Internal-PrePassCollectShadows-ir.txt @@ -0,0 +1,191 @@ +struct v2f { + vec4 pos; + vec2 uv; + vec3 ray; +}; +uniform vec4 _ZBufferParams; +uniform mat4 _View2Shadow3; +uniform mat4 _View2Shadow2; +uniform mat4 _View2Shadow1; +uniform mat4 _View2Shadow; +uniform sampler2D _ShadowMapTexture; +uniform vec4 _LightSplitsNear; +uniform vec4 _LightSplitsFar; +uniform vec4 _LightShadowData; +uniform sampler2D _CameraDepthTexture; +float unitySampleShadow ( + in vec4 eyePos +) +{ + float shadow; + vec4 coord; + vec4 weights; + vec4 far; + vec4 near; + float z; + vec3 sc3; + vec3 sc2; + vec3 sc1; + vec3 sc0; + vec3 tmpvar_1; + tmpvar_1 = (_View2Shadow * eyePos).xyz; + sc0 = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = (_View2Shadow1 * eyePos).xyz; + sc1 = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = (_View2Shadow2 * eyePos).xyz; + sc2 = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = (_View2Shadow3 * eyePos).xyz; + sc3 = tmpvar_4; + float tmpvar_5; + tmpvar_5 = eyePos.z; + z = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = vec4(z); + bvec4 tmpvar_7; + tmpvar_7 = greaterThanEqual (tmpvar_6, _LightSplitsNear); + vec4 tmpvar_8; + tmpvar_8 = vec4(tmpvar_7).xyzw; + vec4 tmpvar_9; + tmpvar_9 = tmpvar_8; + near = tmpvar_9; + vec4 tmpvar_10; + tmpvar_10 = vec4(z); + bvec4 tmpvar_11; + tmpvar_11 = lessThan (tmpvar_10, _LightSplitsFar); + vec4 tmpvar_12; + tmpvar_12 = vec4(tmpvar_11).xyzw; + vec4 tmpvar_13; + tmpvar_13 = tmpvar_12; + far = tmpvar_13; + vec4 tmpvar_14; + tmpvar_14 = (near * far); + weights = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15.w = 1.0; + tmpvar_15.xyz = ((((sc0 * weights.x) + (sc1 * weights.y)) + (sc2 * weights.z)) + (sc3 * weights.w)).xyz; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + coord = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17 = texture2D (_ShadowMapTexture, coord.xy); + float tmpvar_18; + if ((tmpvar_17.x < coord.z)) { + tmpvar_18 = _LightShadowData.x; + } else { + tmpvar_18 = 1.0; + }; + float tmpvar_19; + tmpvar_19 = tmpvar_18; + shadow = tmpvar_19; + return shadow; +} + +float Linear01Depth ( + in float z +) +{ + return (1.0 / ((_ZBufferParams.x * z) + _ZBufferParams.y)); +} + +vec2 EncodeFloatRG ( + in float v +) +{ + vec2 enc; + float kEncodeBit; + vec2 kEncodeMul; + vec2 tmpvar_1; + tmpvar_1 = vec2(1.0, 255.0); + kEncodeMul = tmpvar_1; + float tmpvar_2; + tmpvar_2 = 0.00392157; + kEncodeBit = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = (kEncodeMul * v); + enc = tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = fract (enc); + vec2 tmpvar_5; + tmpvar_5 = tmpvar_4; + enc = tmpvar_5; + float tmpvar_6; + tmpvar_6 = (enc.x - (enc.y * kEncodeBit)); + enc.x = tmpvar_6; + return enc; +} + +vec4 frag ( + in v2f i +) +{ + vec4 res; + float shadow; + vec4 vpos; + float depth; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_CameraDepthTexture, i.uv); + float tmpvar_2; + tmpvar_2 = tmpvar_1.x; + depth = tmpvar_2; + float tmpvar_3; + tmpvar_3 = Linear01Depth (depth); + float tmpvar_4; + tmpvar_4 = tmpvar_3; + depth = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5.w = 1.0; + tmpvar_5.xyz = (i.ray * depth).xyz; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_5; + vpos = tmpvar_6; + float tmpvar_7; + tmpvar_7 = unitySampleShadow (vpos); + float tmpvar_8; + tmpvar_8 = tmpvar_7; + shadow = tmpvar_8; + float tmpvar_9; + tmpvar_9 = shadow; + res.x = tmpvar_9; + float tmpvar_10; + tmpvar_10 = 1.0; + res.y = vec2(tmpvar_10).y; + vec2 tmpvar_11; + tmpvar_11 = EncodeFloatRG ((1.0 - depth)); + vec2 tmpvar_12; + tmpvar_12 = tmpvar_11; + res.zw = tmpvar_12.xxxy.zw; + return res; +} + +void main () +{ + v2f xlt_i; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_i.pos = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = gl_TexCoord[0].xy; + vec2 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_i.uv = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = gl_TexCoord[1].xyz; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_4; + xlt_i.ray = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = frag (xlt_i); + vec4 tmpvar_7; + tmpvar_7 = tmpvar_6; + xl_retval = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = xl_retval.xyzw; + vec4 tmpvar_9; + tmpvar_9 = tmpvar_8; + gl_FragData[0] = tmpvar_9; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Internal-PrePassCollectShadows-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Internal-PrePassCollectShadows-out.txt new file mode 100644 index 000000000..cf05b5448 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Internal-PrePassCollectShadows-out.txt @@ -0,0 +1,42 @@ +uniform vec4 _ZBufferParams; +uniform mat4 _View2Shadow3; +uniform mat4 _View2Shadow2; +uniform mat4 _View2Shadow1; +uniform mat4 _View2Shadow; +uniform sampler2D _ShadowMapTexture; +uniform vec4 _LightSplitsNear; +uniform vec4 _LightSplitsFar; +uniform vec4 _LightShadowData; +uniform sampler2D _CameraDepthTexture; +void main () +{ + vec4 res; + float tmpvar_1; + tmpvar_1 = (1.0/(((_ZBufferParams.x * texture2D (_CameraDepthTexture, gl_TexCoord[0].xy).x) + _ZBufferParams.y))); + vec4 tmpvar_2; + tmpvar_2.w = 1.0; + tmpvar_2.xyz = (gl_TexCoord[1].xyz * tmpvar_1); + vec4 tmpvar_3; + tmpvar_3 = (vec4(greaterThanEqual (tmpvar_2.zzzz, _LightSplitsNear)) * vec4(lessThan (tmpvar_2.zzzz, _LightSplitsFar))); + vec4 tmpvar_4; + tmpvar_4.w = 1.0; + tmpvar_4.xyz = (((((_View2Shadow * tmpvar_2).xyz * tmpvar_3.x) + ((_View2Shadow1 * tmpvar_2).xyz * tmpvar_3.y)) + ((_View2Shadow2 * tmpvar_2).xyz * tmpvar_3.z)) + ((_View2Shadow3 * tmpvar_2).xyz * tmpvar_3.w)); + vec4 tmpvar_5; + tmpvar_5 = texture2D (_ShadowMapTexture, tmpvar_4.xy); + float tmpvar_6; + if ((tmpvar_5.x < tmpvar_4.z)) { + tmpvar_6 = _LightShadowData.x; + } else { + tmpvar_6 = 1.0; + }; + res.x = tmpvar_6; + res.y = 1.0; + vec2 enc; + vec2 tmpvar_7; + tmpvar_7 = fract ((vec2(1.0, 255.0) * (1.0 - tmpvar_1))); + enc = tmpvar_7; + enc.x = (tmpvar_7.x - (tmpvar_7.y * 0.00392157)); + res.zw = enc; + gl_FragData[0] = res; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Internal-PrePassLighting-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Internal-PrePassLighting-in.txt new file mode 100644 index 000000000..5f0fc9e26 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Internal-PrePassLighting-in.txt @@ -0,0 +1,146 @@ +float xll_saturate( float x) { + return clamp( x, 0.0, 1.0); +} +vec2 xll_saturate( vec2 x) { + return clamp( x, 0.0, 1.0); +} +vec3 xll_saturate( vec3 x) { + return clamp( x, 0.0, 1.0); +} +vec4 xll_saturate( vec4 x) { + return clamp( x, 0.0, 1.0); +} +mat2 xll_saturate(mat2 m) { + return mat2( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0)); +} +mat3 xll_saturate(mat3 m) { + return mat3( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0), clamp(m[2], 0.0, 1.0)); +} +mat4 xll_saturate(mat4 m) { + return mat4( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0), clamp(m[2], 0.0, 1.0), clamp(m[3], 0.0, 1.0)); +} +mat3 xll_constructMat3( mat4 m) { + return mat3( vec3( m[0]), vec3( m[1]), vec3( m[2])); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct v2f { + vec4 pos; + vec4 uv; + vec3 ray; +}; +struct appdata { + vec4 vertex; + vec3 texcoord; +}; +uniform sampler2D _CameraDepthTexture; +uniform sampler2D _CameraNormalsTexture; +uniform vec4 _LightColor; +uniform vec4 _LightPos; +uniform vec4 _LightPositionRange; +uniform vec4 _LightShadowData; +uniform samplerCube _LightTexture0; +uniform sampler2D _LightTextureB0; +uniform vec4 _ProjectionParams; +uniform samplerCube _ShadowMapTexture; +uniform mat4 _View2Shadow; +uniform mat4 _ViewToCookie; +uniform vec4 _ZBufferParams; +uniform vec4 unity_LightmapFade; +float Luminance( in vec3 c ); +float Linear01Depth( in float z ); +float DecodeFloatRGBA( in vec4 enc ); +float SampleCubeDistance( in vec3 vec ); +float unitySampleShadow( in vec3 vec, in float mydist ); +float ComputeShadow( in vec3 vec, in vec2 uv ); +vec4 frag( in v2f i ); +float Luminance( in vec3 c ) { + return dot( c, vec3( 0.220000, 0.707000, 0.0710000)); +} +float Linear01Depth( in float z ) { + return (1.00000 / ((_ZBufferParams.x * z) + _ZBufferParams.y )); +} +float DecodeFloatRGBA( in vec4 enc ) { + vec4 kDecodeDot = vec4( 1.00000, 0.00392157, 1.53787e-005, 6.22737e-009); + return dot( enc, kDecodeDot); +} +float SampleCubeDistance( in vec3 vec ) { + vec4 packDist; + packDist = textureCube( _ShadowMapTexture, vec); + return DecodeFloatRGBA( packDist); +} +float unitySampleShadow( in vec3 vec, in float mydist ) { + float dist; + dist = SampleCubeDistance( vec); + return ( (dist < mydist) ) ? ( _LightShadowData.x ) : ( 1.00000 ); +} +float ComputeShadow( in vec3 vec, in vec2 uv ) { + float fade; + float mydist; + fade = ((vec.z * _LightShadowData.z ) + _LightShadowData.w ); + fade = xll_saturate( fade ); + vec = ( xll_constructMat3( _View2Shadow) * vec ); + mydist = (length( vec ) * _LightPositionRange.w ); + mydist *= 0.970000; + return unitySampleShadow( vec, mydist); + return 1.00000; +} +vec4 frag( in v2f i ) { + vec2 uv; + vec4 nspec; + vec3 normal; + float depth; + vec3 vpos; + vec3 tolight; + vec3 lightDir; + float att; + float atten; + float diff; + vec3 h; + float spec; + vec4 res; + float fade; + i.ray = (i.ray * (_ProjectionParams.z / i.ray.z )); + uv = (i.uv.xy / i.uv.w ); + nspec = texture2D( _CameraNormalsTexture, uv); + normal = ((nspec.xyz * 2.00000) - 1.00000); + normal = normalize( normal ); + depth = texture2D( _CameraDepthTexture, uv).x ; + depth = Linear01Depth( depth); + vpos = (i.ray * depth); + tolight = (_LightPos.xyz - vpos); + lightDir = normalize( tolight ); + att = (dot( tolight, tolight) * _LightPos.w ); + atten = texture2D( _LightTextureB0, vec2( vec2( att))).w ; + atten *= ComputeShadow( ( -tolight ), uv); + atten *= textureCube( _LightTexture0, ( _ViewToCookie * vec4( vpos, 1.00000) ).xyz ).w ; + diff = max( 0.000000, dot( lightDir, normal)); + h = normalize( (lightDir - normalize( vpos )) ); + spec = pow( max( 0.000000, dot( h, normal)), (nspec.w * 128.000)); + spec *= xll_saturate( atten ); + res.xyz = (_LightColor.xyz * (diff * atten)); + res.w = (spec * Luminance( _LightColor.xyz )); + fade = ((vpos.z * unity_LightmapFade.z ) + unity_LightmapFade.w ); + res *= xll_saturate( (1.00000 - fade) ); + return exp2( ( -res ) ); +} +void main() { + vec4 xl_retval; + v2f xlt_i; + xlt_i.pos = vec4(0.0); + xlt_i.uv = vec4( gl_TexCoord[0]); + xlt_i.ray = vec3( gl_TexCoord[1]); + xl_retval = frag( xlt_i); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Internal-PrePassLighting-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Internal-PrePassLighting-ir.txt new file mode 100644 index 000000000..015a1cab2 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Internal-PrePassLighting-ir.txt @@ -0,0 +1,408 @@ +struct v2f { + vec4 pos; + vec4 uv; + vec3 ray; +}; +uniform vec4 unity_LightmapFade; +uniform vec4 _ZBufferParams; +uniform mat4 _ViewToCookie; +uniform mat4 _View2Shadow; +uniform samplerCube _ShadowMapTexture; +uniform vec4 _ProjectionParams; +uniform sampler2D _LightTextureB0; +uniform samplerCube _LightTexture0; +uniform vec4 _LightShadowData; +uniform vec4 _LightPositionRange; +uniform vec4 _LightPos; +uniform vec4 _LightColor; +uniform sampler2D _CameraNormalsTexture; +uniform sampler2D _CameraDepthTexture; +float xll_saturate ( + in float x +) +{ + float tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec2 xll_saturate ( + in vec2 x +) +{ + vec2 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec3 xll_saturate ( + in vec3 x +) +{ + vec3 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec4 xll_saturate ( + in vec4 x +) +{ + vec4 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +mat2 xll_saturate ( + in mat2 m +) +{ + vec2 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec2 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + mat2 tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_1; + tmpvar_3[0] = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5 = tmpvar_2; + tmpvar_3[1] = tmpvar_5; + return tmpvar_3; +} + +mat3 xll_saturate ( + in mat3 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec3 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + vec3 tmpvar_3; + tmpvar_3 = clamp (m[2], 0.0, 1.0); + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +mat4 xll_saturate ( + in mat4 m +) +{ + vec4 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec4 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + vec4 tmpvar_3; + tmpvar_3 = clamp (m[2], 0.0, 1.0); + vec4 tmpvar_4; + tmpvar_4 = clamp (m[3], 0.0, 1.0); + mat4 tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_1; + tmpvar_5[0] = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = tmpvar_2; + tmpvar_5[1] = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_3; + tmpvar_5[2] = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = tmpvar_4; + tmpvar_5[3] = tmpvar_9; + return tmpvar_5; +} + +mat3 xll_constructMat3 ( + in mat4 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = m[0].xyz; + vec3 tmpvar_2; + tmpvar_2 = m[1].xyz; + vec3 tmpvar_3; + tmpvar_3 = m[2].xyz; + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +float Luminance ( + in vec3 c +) +{ + float tmpvar_1; + tmpvar_1 = dot (c, vec3(0.22, 0.707, 0.071)); + return tmpvar_1; +} + +float Linear01Depth ( + in float z +) +{ + return (1.0 / ((_ZBufferParams.x * z) + _ZBufferParams.y)); +} + +float DecodeFloatRGBA ( + in vec4 enc +) +{ + vec4 kDecodeDot; + vec4 tmpvar_1; + tmpvar_1 = vec4(1.0, 0.00392157, 1.53787e-05, 0.0); + kDecodeDot = tmpvar_1; + float tmpvar_2; + tmpvar_2 = dot (enc, kDecodeDot); + return tmpvar_2; +} + +float SampleCubeDistance ( + in vec3 vec +) +{ + vec4 packDist; + vec4 tmpvar_1; + tmpvar_1 = textureCube (_ShadowMapTexture, vec); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + packDist = tmpvar_2; + float tmpvar_3; + tmpvar_3 = DecodeFloatRGBA (packDist); + return tmpvar_3; +} + +float unitySampleShadow ( + in vec3 vec, + in float mydist +) +{ + float dist; + float tmpvar_1; + tmpvar_1 = SampleCubeDistance (vec); + float tmpvar_2; + tmpvar_2 = tmpvar_1; + dist = tmpvar_2; + float tmpvar_3; + if ((dist < mydist)) { + tmpvar_3 = _LightShadowData.x; + } else { + tmpvar_3 = 1.0; + }; + return tmpvar_3; +} + +float ComputeShadow ( + in vec3 vec, + in vec2 uv +) +{ + float mydist; + float fade; + float tmpvar_1; + tmpvar_1 = ((vec.z * _LightShadowData.z) + _LightShadowData.w); + fade = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xll_saturate (fade); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + fade = tmpvar_3; + mat3 tmpvar_4; + tmpvar_4 = (xll_constructMat3 (_View2Shadow)); + vec3 tmpvar_5; + tmpvar_5 = (tmpvar_4 * vec); + vec = tmpvar_5; + float tmpvar_6; + tmpvar_6 = length (vec); + float tmpvar_7; + tmpvar_7 = (tmpvar_6 * _LightPositionRange.w); + mydist = tmpvar_7; + float tmpvar_8; + tmpvar_8 = (mydist * 0.97); + mydist = tmpvar_8; + float tmpvar_9; + tmpvar_9 = unitySampleShadow (vec, mydist); + return tmpvar_9; + return 1.0; +} + +vec4 frag ( + in v2f i +) +{ + float fade; + vec4 res; + float spec; + vec3 h; + float diff; + float atten; + float att; + vec3 lightDir; + vec3 tolight; + vec3 vpos; + float depth; + vec3 normal; + vec4 nspec; + vec2 uv; + vec3 tmpvar_1; + tmpvar_1 = (i.ray * (_ProjectionParams.z / i.ray.z)); + i.ray = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = (i.uv.xy / i.uv.w); + uv = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = texture2D (_CameraNormalsTexture, uv); + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + nspec = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = ((nspec.xyz * 2.0) - 1.0); + normal = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = normalize (normal); + vec3 tmpvar_7; + tmpvar_7 = tmpvar_6; + normal = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = texture2D (_CameraDepthTexture, uv); + float tmpvar_9; + tmpvar_9 = tmpvar_8.x; + depth = tmpvar_9; + float tmpvar_10; + tmpvar_10 = Linear01Depth (depth); + float tmpvar_11; + tmpvar_11 = tmpvar_10; + depth = tmpvar_11; + vec3 tmpvar_12; + tmpvar_12 = (i.ray * depth); + vpos = tmpvar_12; + vec3 tmpvar_13; + tmpvar_13 = (_LightPos.xyz - vpos); + tolight = tmpvar_13; + vec3 tmpvar_14; + tmpvar_14 = normalize (tolight); + vec3 tmpvar_15; + tmpvar_15 = tmpvar_14; + lightDir = tmpvar_15; + float tmpvar_16; + tmpvar_16 = dot (tolight, tolight); + float tmpvar_17; + tmpvar_17 = (tmpvar_16 * _LightPos.w); + att = tmpvar_17; + vec2 tmpvar_18; + tmpvar_18 = vec2(att); + vec2 tmpvar_19; + tmpvar_19 = tmpvar_18.xy; + vec4 tmpvar_20; + tmpvar_20 = texture2D (_LightTextureB0, tmpvar_19); + float tmpvar_21; + tmpvar_21 = tmpvar_20.w; + atten = tmpvar_21; + float tmpvar_22; + tmpvar_22 = ComputeShadow (-(tolight), uv); + float tmpvar_23; + tmpvar_23 = (atten * tmpvar_22); + atten = tmpvar_23; + vec4 tmpvar_24; + tmpvar_24.w = 1.0; + tmpvar_24.xyz = vpos.xyz; + vec4 tmpvar_25; + tmpvar_25 = textureCube (_LightTexture0, (_ViewToCookie * tmpvar_24).xyz); + float tmpvar_26; + tmpvar_26 = (atten * tmpvar_25.w); + atten = tmpvar_26; + float tmpvar_27; + tmpvar_27 = dot (lightDir, normal); + float tmpvar_28; + tmpvar_28 = max (0.0, tmpvar_27); + float tmpvar_29; + tmpvar_29 = tmpvar_28; + diff = tmpvar_29; + vec3 tmpvar_30; + tmpvar_30 = normalize (vpos); + vec3 tmpvar_31; + tmpvar_31 = normalize ((lightDir - tmpvar_30)); + vec3 tmpvar_32; + tmpvar_32 = tmpvar_31; + h = tmpvar_32; + float tmpvar_33; + tmpvar_33 = dot (h, normal); + float tmpvar_34; + tmpvar_34 = max (0.0, tmpvar_33); + float tmpvar_35; + tmpvar_35 = pow (tmpvar_34, (nspec.w * 128.0)); + float tmpvar_36; + tmpvar_36 = tmpvar_35; + spec = tmpvar_36; + float tmpvar_37; + tmpvar_37 = xll_saturate (atten); + float tmpvar_38; + tmpvar_38 = (spec * tmpvar_37); + spec = tmpvar_38; + vec3 tmpvar_39; + tmpvar_39 = (_LightColor.xyz * (diff * atten)); + res.xyz = tmpvar_39.xyz.xyz; + float tmpvar_40; + tmpvar_40 = Luminance (_LightColor.xyz); + float tmpvar_41; + tmpvar_41 = (spec * tmpvar_40); + res.w = vec4(tmpvar_41).w; + float tmpvar_42; + tmpvar_42 = ((vpos.z * unity_LightmapFade.z) + unity_LightmapFade.w); + fade = tmpvar_42; + float tmpvar_43; + tmpvar_43 = xll_saturate ((1.0 - fade)); + vec4 tmpvar_44; + tmpvar_44 = (res * tmpvar_43); + res = tmpvar_44; + vec4 tmpvar_45; + tmpvar_45 = exp2 (-(res)); + return tmpvar_45; +} + +void main () +{ + v2f xlt_i; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_i.pos = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = gl_TexCoord[0].xyzw; + vec4 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_i.uv = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = gl_TexCoord[1].xyz; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_4; + xlt_i.ray = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = frag (xlt_i); + vec4 tmpvar_7; + tmpvar_7 = tmpvar_6; + xl_retval = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = xl_retval.xyzw; + vec4 tmpvar_9; + tmpvar_9 = tmpvar_8; + gl_FragData[0] = tmpvar_9; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Internal-PrePassLighting-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Internal-PrePassLighting-out.txt new file mode 100644 index 000000000..02a78d421 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Internal-PrePassLighting-out.txt @@ -0,0 +1,68 @@ +uniform vec4 unity_LightmapFade; +uniform vec4 _ZBufferParams; +uniform mat4 _ViewToCookie; +uniform mat4 _View2Shadow; +uniform samplerCube _ShadowMapTexture; +uniform vec4 _ProjectionParams; +uniform sampler2D _LightTextureB0; +uniform samplerCube _LightTexture0; +uniform vec4 _LightShadowData; +uniform vec4 _LightPositionRange; +uniform vec4 _LightPos; +uniform vec4 _LightColor; +uniform sampler2D _CameraNormalsTexture; +uniform sampler2D _CameraDepthTexture; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = gl_TexCoord[0]; + vec3 tmpvar_2; + tmpvar_2 = gl_TexCoord[1].xyz; + vec4 res; + float atten; + vec3 lightDir; + vec3 normal; + vec2 tmpvar_3; + tmpvar_3 = (tmpvar_1.xy / tmpvar_1.w); + vec4 tmpvar_4; + tmpvar_4 = texture2D (_CameraNormalsTexture, tmpvar_3); + normal = normalize (((tmpvar_4.xyz * 2.0) - 1.0)); + vec3 tmpvar_5; + tmpvar_5 = ((tmpvar_2 * (_ProjectionParams.z / tmpvar_2.z)) * (1.0/(((_ZBufferParams.x * texture2D (_CameraDepthTexture, tmpvar_3).x) + _ZBufferParams.y)))); + vec3 tmpvar_6; + tmpvar_6 = (_LightPos.xyz - tmpvar_5); + lightDir = normalize (tmpvar_6); + atten = texture2D (_LightTextureB0, vec2((dot (tmpvar_6, tmpvar_6) * _LightPos.w))).w; + vec3 vec; + vec = -(tmpvar_6); + mat3 tmpvar_7; + tmpvar_7[0] = _View2Shadow[0].xyz; + tmpvar_7[1] = _View2Shadow[1].xyz; + tmpvar_7[2] = _View2Shadow[2].xyz; + vec3 tmpvar_8; + tmpvar_8 = (tmpvar_7 * vec); + vec = tmpvar_8; + float tmpvar_9; + tmpvar_9 = ((length (tmpvar_8) * _LightPositionRange.w) * 0.97); + float tmpvar_10; + tmpvar_10 = dot (textureCube (_ShadowMapTexture, tmpvar_8), vec4(1.0, 0.00392157, 1.53787e-05, 0.0)); + float tmpvar_11; + if ((tmpvar_10 < tmpvar_9)) { + tmpvar_11 = _LightShadowData.x; + } else { + tmpvar_11 = 1.0; + }; + vec4 tmpvar_12; + tmpvar_12.w = 1.0; + tmpvar_12.xyz = tmpvar_5; + float tmpvar_13; + tmpvar_13 = ((atten * tmpvar_11) * textureCube (_LightTexture0, (_ViewToCookie * tmpvar_12).xyz).w); + atten = tmpvar_13; + res.xyz = (_LightColor.xyz * (max (0.0, dot (lightDir, normal)) * tmpvar_13)); + res.w = ((pow (max (0.0, dot (normalize ((lightDir - normalize (tmpvar_5))), normal)), (tmpvar_4.w * 128.0)) * clamp (tmpvar_13, 0.0, 1.0)) * dot (_LightColor.xyz, vec3(0.22, 0.707, 0.071))); + vec4 tmpvar_14; + tmpvar_14 = (res * clamp ((1.0 - ((tmpvar_5.z * unity_LightmapFade.z) + unity_LightmapFade.w)), 0.0, 1.0)); + res = tmpvar_14; + gl_FragData[0] = exp2 (-(tmpvar_14)); +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Noise_Shader_RGB-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Noise_Shader_RGB-in.txt new file mode 100644 index 000000000..af70ed93d --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Noise_Shader_RGB-in.txt @@ -0,0 +1,45 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct v2f { + vec4 pos; + vec2 uv; + vec2 uvg; + vec2 uvs; +}; +uniform sampler2D _GrainTex; +uniform vec4 _Intensity; +uniform sampler2D _MainTex; +uniform sampler2D _ScratchTex; +vec4 frag( in v2f i ); +vec4 frag( in v2f i ) { + vec4 col; + vec3 grain; + vec3 scratch; + col = texture2D( _MainTex, i.uv); + grain = ((texture2D( _GrainTex, i.uvg).xyz * 2.00000) - 1.00000); + col.xyz += (grain * _Intensity.x ); + scratch = ((texture2D( _ScratchTex, i.uvs).xyz * 2.00000) - 1.00000); + col.xyz += (scratch * _Intensity.y ); + return col; +} +void main() { + vec4 xl_retval; + v2f xlt_i; + xlt_i.pos = vec4(0.0); + xlt_i.uv = vec2( gl_TexCoord[0]); + xlt_i.uvg = vec2( gl_TexCoord[1]); + xlt_i.uvs = vec2( gl_TexCoord[2]); + xl_retval = frag( xlt_i); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Noise_Shader_RGB-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Noise_Shader_RGB-ir.txt new file mode 100644 index 000000000..efc88d41e --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Noise_Shader_RGB-ir.txt @@ -0,0 +1,75 @@ +struct v2f { + vec4 pos; + vec2 uv; + vec2 uvg; + vec2 uvs; +}; +uniform sampler2D _ScratchTex; +uniform sampler2D _MainTex; +uniform vec4 _Intensity; +uniform sampler2D _GrainTex; +vec4 frag ( + in v2f i +) +{ + vec3 scratch; + vec3 grain; + vec4 col; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, i.uv); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + col = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = texture2D (_GrainTex, i.uvg); + vec3 tmpvar_4; + tmpvar_4 = ((tmpvar_3.xyz * 2.0) - 1.0); + grain = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = (col.xyz + (grain * _Intensity.x)); + col.xyz = tmpvar_5.xyz.xyz; + vec4 tmpvar_6; + tmpvar_6 = texture2D (_ScratchTex, i.uvs); + vec3 tmpvar_7; + tmpvar_7 = ((tmpvar_6.xyz * 2.0) - 1.0); + scratch = tmpvar_7; + vec3 tmpvar_8; + tmpvar_8 = (col.xyz + (scratch * _Intensity.y)); + col.xyz = tmpvar_8.xyz.xyz; + return col; +} + +void main () +{ + v2f xlt_i; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_i.pos = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = gl_TexCoord[0].xy; + vec2 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_i.uv = tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = gl_TexCoord[1].xy; + vec2 tmpvar_5; + tmpvar_5 = tmpvar_4; + xlt_i.uvg = tmpvar_5; + vec2 tmpvar_6; + tmpvar_6 = gl_TexCoord[2].xy; + vec2 tmpvar_7; + tmpvar_7 = tmpvar_6; + xlt_i.uvs = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = frag (xlt_i); + vec4 tmpvar_9; + tmpvar_9 = tmpvar_8; + xl_retval = tmpvar_9; + vec4 tmpvar_10; + tmpvar_10 = xl_retval.xyzw; + vec4 tmpvar_11; + tmpvar_11 = tmpvar_10; + gl_FragData[0] = tmpvar_11; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Noise_Shader_RGB-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Noise_Shader_RGB-out.txt new file mode 100644 index 000000000..8d11dd68c --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Noise_Shader_RGB-out.txt @@ -0,0 +1,15 @@ +uniform sampler2D _ScratchTex; +uniform sampler2D _MainTex; +uniform vec4 _Intensity; +uniform sampler2D _GrainTex; +void main () +{ + vec4 col; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, gl_TexCoord[0].xy); + col = tmpvar_1; + col.xyz = (tmpvar_1.xyz + (((texture2D (_GrainTex, gl_TexCoord[1].xy).xyz * 2.0) - 1.0) * _Intensity.x)); + col.xyz = (col.xyz + (((texture2D (_ScratchTex, gl_TexCoord[2].xy).xyz * 2.0) - 1.0) * _Intensity.y)); + gl_FragData[0] = col; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Noise_Shader_YUV-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Noise_Shader_YUV-in.txt new file mode 100644 index 000000000..0bafbad1a --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Noise_Shader_YUV-in.txt @@ -0,0 +1,52 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct v2f { + vec4 pos; + vec2 uv; + vec2 uvg; + vec2 uvs; +}; +uniform sampler2D _GrainTex; +uniform vec4 _Intensity; +uniform sampler2D _MainTex; +uniform sampler2D _ScratchTex; +vec4 frag( in v2f i ); +vec4 frag( in v2f i ) { + vec4 col; + vec3 yuv; + vec3 grain; + vec3 scratch; + col = texture2D( _MainTex, i.uv); + yuv.x = dot( col.xyz , vec3( 0.299000, 0.587000, 0.114000)); + yuv.y = ((col.z - yuv.x ) * 0.492000); + yuv.z = ((col.x - yuv.x ) * 0.877000); + grain = ((texture2D( _GrainTex, i.uvg).xyz * 2.00000) - 1.00000); + yuv.xyz += (grain * _Intensity.x ); + col.x = ((yuv.z * 1.14000) + yuv.x ); + col.y = (((yuv.z * -0.581000) + (yuv.y * -0.395000)) + yuv.x ); + col.z = ((yuv.y * 2.03200) + yuv.x ); + scratch = ((texture2D( _ScratchTex, i.uvs).xyz * 2.00000) - 1.00000); + col.xyz += (scratch * _Intensity.y ); + return col; +} +void main() { + vec4 xl_retval; + v2f xlt_i; + xlt_i.pos = vec4(0.0); + xlt_i.uv = vec2( gl_TexCoord[0]); + xlt_i.uvg = vec2( gl_TexCoord[1]); + xlt_i.uvs = vec2( gl_TexCoord[2]); + xl_retval = frag( xlt_i); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Noise_Shader_YUV-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Noise_Shader_YUV-ir.txt new file mode 100644 index 000000000..a86c4ede2 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Noise_Shader_YUV-ir.txt @@ -0,0 +1,96 @@ +struct v2f { + vec4 pos; + vec2 uv; + vec2 uvg; + vec2 uvs; +}; +uniform sampler2D _ScratchTex; +uniform sampler2D _MainTex; +uniform vec4 _Intensity; +uniform sampler2D _GrainTex; +vec4 frag ( + in v2f i +) +{ + vec3 scratch; + vec3 grain; + vec3 yuv; + vec4 col; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, i.uv); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + col = tmpvar_2; + float tmpvar_3; + tmpvar_3 = dot (col.xyz, vec3(0.299, 0.587, 0.114)); + float tmpvar_4; + tmpvar_4 = tmpvar_3; + yuv.x = tmpvar_4; + float tmpvar_5; + tmpvar_5 = ((col.z - yuv.x) * 0.492); + yuv.y = vec2(tmpvar_5).y; + float tmpvar_6; + tmpvar_6 = ((col.x - yuv.x) * 0.877); + yuv.z = vec3(tmpvar_6).z; + vec4 tmpvar_7; + tmpvar_7 = texture2D (_GrainTex, i.uvg); + vec3 tmpvar_8; + tmpvar_8 = ((tmpvar_7.xyz * 2.0) - 1.0); + grain = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = (yuv.xyz + (grain * _Intensity.x)); + yuv = tmpvar_9.xyz.xyz; + float tmpvar_10; + tmpvar_10 = ((yuv.z * 1.14) + yuv.x); + col.x = tmpvar_10; + float tmpvar_11; + tmpvar_11 = (((yuv.z * -(0.581)) + (yuv.y * -(0.395))) + yuv.x); + col.y = vec2(tmpvar_11).y; + float tmpvar_12; + tmpvar_12 = ((yuv.y * 2.032) + yuv.x); + col.z = vec3(tmpvar_12).z; + vec4 tmpvar_13; + tmpvar_13 = texture2D (_ScratchTex, i.uvs); + vec3 tmpvar_14; + tmpvar_14 = ((tmpvar_13.xyz * 2.0) - 1.0); + scratch = tmpvar_14; + vec3 tmpvar_15; + tmpvar_15 = (col.xyz + (scratch * _Intensity.y)); + col.xyz = tmpvar_15.xyz.xyz; + return col; +} + +void main () +{ + v2f xlt_i; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_i.pos = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = gl_TexCoord[0].xy; + vec2 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_i.uv = tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = gl_TexCoord[1].xy; + vec2 tmpvar_5; + tmpvar_5 = tmpvar_4; + xlt_i.uvg = tmpvar_5; + vec2 tmpvar_6; + tmpvar_6 = gl_TexCoord[2].xy; + vec2 tmpvar_7; + tmpvar_7 = tmpvar_6; + xlt_i.uvs = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = frag (xlt_i); + vec4 tmpvar_9; + tmpvar_9 = tmpvar_8; + xl_retval = tmpvar_9; + vec4 tmpvar_10; + tmpvar_10 = xl_retval.xyzw; + vec4 tmpvar_11; + tmpvar_11 = tmpvar_10; + gl_FragData[0] = tmpvar_11; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Noise_Shader_YUV-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Noise_Shader_YUV-out.txt new file mode 100644 index 000000000..c200b2106 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Noise_Shader_YUV-out.txt @@ -0,0 +1,22 @@ +uniform sampler2D _ScratchTex; +uniform sampler2D _MainTex; +uniform vec4 _Intensity; +uniform sampler2D _GrainTex; +void main () +{ + vec3 yuv; + vec4 col; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, gl_TexCoord[0].xy); + col = tmpvar_1; + yuv.x = dot (tmpvar_1.xyz, vec3(0.299, 0.587, 0.114)); + yuv.y = ((tmpvar_1.z - yuv.x) * 0.492); + yuv.z = ((tmpvar_1.x - yuv.x) * 0.877); + yuv = (yuv + (((texture2D (_GrainTex, gl_TexCoord[1].xy).xyz * 2.0) - 1.0) * _Intensity.x)); + col.x = ((yuv.z * 1.14) + yuv.x); + col.y = (((yuv.z * -0.581) + (yuv.y * -0.395)) + yuv.x); + col.z = ((yuv.y * 2.032) + yuv.x); + col.xyz = (col.xyz + (((texture2D (_ScratchTex, gl_TexCoord[2].xy).xyz * 2.0) - 1.0) * _Intensity.y)); + gl_FragData[0] = col; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Sepiatone_Effect-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Sepiatone_Effect-in.txt new file mode 100644 index 000000000..91564c8f7 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Sepiatone_Effect-in.txt @@ -0,0 +1,34 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +uniform sampler2D _MainTex; +vec4 frag( in v2f_img i ); +vec4 frag( in v2f_img i ) { + vec4 original; + float Y; + vec4 sepiaConvert = vec4( 0.191000, -0.0540000, -0.221000, 0.000000); + vec4 xlat_var_output; + original = texture2D( _MainTex, i.uv); + Y = dot( vec3( 0.299000, 0.587000, 0.114000), original.xyz ); + xlat_var_output = (sepiaConvert + Y); + xlat_var_output.w = original.w ; + return xlat_var_output; +} +void main() { + vec4 xl_retval; + v2f_img xlt_i; + xlt_i.pos = vec4(0.0); + xlt_i.uv = vec2( gl_TexCoord[0]); + xl_retval = frag( xlt_i); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Sepiatone_Effect-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Sepiatone_Effect-ir.txt new file mode 100644 index 000000000..becb0278a --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Sepiatone_Effect-ir.txt @@ -0,0 +1,59 @@ +struct v2f_img { + vec4 pos; + vec2 uv; +}; +uniform sampler2D _MainTex; +vec4 frag ( + in v2f_img i +) +{ + vec4 xlat_var_output; + vec4 sepiaConvert; + float Y; + vec4 original; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.191, -0.054, -0.221, 0.0); + sepiaConvert = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = texture2D (_MainTex, i.uv); + vec4 tmpvar_3; + tmpvar_3 = tmpvar_2; + original = tmpvar_3; + float tmpvar_4; + tmpvar_4 = dot (vec3(0.299, 0.587, 0.114), original.xyz); + float tmpvar_5; + tmpvar_5 = tmpvar_4; + Y = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = (sepiaConvert + Y); + xlat_var_output = tmpvar_6; + float tmpvar_7; + tmpvar_7 = original.w; + xlat_var_output.w = vec4(tmpvar_7).w; + return xlat_var_output; +} + +void main () +{ + v2f_img xlt_i; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_i.pos = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = gl_TexCoord[0].xy; + vec2 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_i.uv = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = frag (xlt_i); + vec4 tmpvar_5; + tmpvar_5 = tmpvar_4; + xl_retval = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = xl_retval.xyzw; + vec4 tmpvar_7; + tmpvar_7 = tmpvar_6; + gl_FragData[0] = tmpvar_7; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Sepiatone_Effect-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Sepiatone_Effect-out.txt new file mode 100644 index 000000000..6bee30c53 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Sepiatone_Effect-out.txt @@ -0,0 +1,11 @@ +uniform sampler2D _MainTex; +void main () +{ + vec4 xlat_var_output; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, gl_TexCoord[0].xy); + xlat_var_output = (vec4(0.191, -0.054, -0.221, 0.0) + dot (vec3(0.299, 0.587, 0.114), tmpvar_1.xyz)); + xlat_var_output.w = tmpvar_1.w; + gl_FragData[0] = xlat_var_output; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Shadow-ScreenBlur-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Shadow-ScreenBlur-in.txt new file mode 100644 index 000000000..e7822e24c --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Shadow-ScreenBlur-in.txt @@ -0,0 +1,73 @@ +float xll_saturate( float x) { + return clamp( x, 0.0, 1.0); +} +vec2 xll_saturate( vec2 x) { + return clamp( x, 0.0, 1.0); +} +vec3 xll_saturate( vec3 x) { + return clamp( x, 0.0, 1.0); +} +vec4 xll_saturate( vec4 x) { + return clamp( x, 0.0, 1.0); +} +mat2 xll_saturate(mat2 m) { + return mat2( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0)); +} +mat3 xll_saturate(mat3 m) { + return mat3( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0), clamp(m[2], 0.0, 1.0)); +} +mat4 xll_saturate(mat4 m) { + return mat4( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0), clamp(m[2], 0.0, 1.0), clamp(m[3], 0.0, 1.0)); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +uniform vec4 _BlurOffsets[8]; +uniform sampler2D _MainTex; +uniform vec4 unity_ShadowBlurParams; +vec4 frag( in v2f_img i ); +vec4 frag( in v2f_img i ) { + vec4 coord; + vec4 mask; + float dist; + float radius; + float diffTolerance; + int i_1 = 0; + vec4 sample; + float sampleDist; + float diff; + float shadow; + coord = vec4( i.uv, 0.000000, 0.000000); + mask = texture2D( _MainTex, coord.xy ); + dist = (mask.z + (mask.w / 255.000)); + radius = xll_saturate( (unity_ShadowBlurParams.y / (1.00000 - dist)) ); + diffTolerance = unity_ShadowBlurParams.x ; + mask.xy *= diffTolerance; + for ( ; (i_1 < 8); ( i_1++ )) { + sample = texture2D( _MainTex, (coord + (radius * _BlurOffsets[ i_1 ])).xy ); + sampleDist = (sample.z + (sample.w / 255.000)); + diff = (dist - sampleDist); + diff = xll_saturate( (diffTolerance - abs( diff )) ); + mask.xy += (diff * sample.xy ); + } + shadow = (mask.x / mask.y ); + return vec4( shadow); +} +void main() { + vec4 xl_retval; + v2f_img xlt_i; + xlt_i.pos = vec4(0.0); + xlt_i.uv = vec2( gl_TexCoord[0]); + xl_retval = frag( xlt_i); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Shadow-ScreenBlur-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Shadow-ScreenBlur-ir.txt new file mode 100644 index 000000000..110612ef8 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Shadow-ScreenBlur-ir.txt @@ -0,0 +1,217 @@ +struct v2f_img { + vec4 pos; + vec2 uv; +}; +uniform vec4 unity_ShadowBlurParams; +uniform sampler2D _MainTex; +uniform vec4 _BlurOffsets[8]; +float xll_saturate ( + in float x +) +{ + float tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec2 xll_saturate ( + in vec2 x +) +{ + vec2 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec3 xll_saturate ( + in vec3 x +) +{ + vec3 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec4 xll_saturate ( + in vec4 x +) +{ + vec4 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +mat2 xll_saturate ( + in mat2 m +) +{ + vec2 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec2 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + mat2 tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_1; + tmpvar_3[0] = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5 = tmpvar_2; + tmpvar_3[1] = tmpvar_5; + return tmpvar_3; +} + +mat3 xll_saturate ( + in mat3 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec3 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + vec3 tmpvar_3; + tmpvar_3 = clamp (m[2], 0.0, 1.0); + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +mat4 xll_saturate ( + in mat4 m +) +{ + vec4 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec4 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + vec4 tmpvar_3; + tmpvar_3 = clamp (m[2], 0.0, 1.0); + vec4 tmpvar_4; + tmpvar_4 = clamp (m[3], 0.0, 1.0); + mat4 tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_1; + tmpvar_5[0] = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = tmpvar_2; + tmpvar_5[1] = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_3; + tmpvar_5[2] = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = tmpvar_4; + tmpvar_5[3] = tmpvar_9; + return tmpvar_5; +} + +vec4 frag ( + in v2f_img i +) +{ + float shadow; + float diff; + float sampleDist; + vec4 sample; + int i_1; + float diffTolerance; + float radius; + float dist; + vec4 mask; + vec4 coord; + int tmpvar_1; + tmpvar_1 = 0; + i_1 = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2.zw = vec2(0.0, 0.0); + tmpvar_2.xy = i.uv.xy; + vec4 tmpvar_3; + tmpvar_3 = tmpvar_2; + coord = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = texture2D (_MainTex, coord.xy); + vec4 tmpvar_5; + tmpvar_5 = tmpvar_4; + mask = tmpvar_5; + float tmpvar_6; + tmpvar_6 = (mask.z + (mask.w / 255.0)); + dist = tmpvar_6; + float tmpvar_7; + tmpvar_7 = xll_saturate ((unity_ShadowBlurParams.y / (1.0 - dist))); + float tmpvar_8; + tmpvar_8 = tmpvar_7; + radius = tmpvar_8; + float tmpvar_9; + tmpvar_9 = unity_ShadowBlurParams.x; + diffTolerance = tmpvar_9; + vec2 tmpvar_10; + tmpvar_10 = (mask.xy * diffTolerance); + mask.xy = tmpvar_10.xy.xy; + while (true) { + if (!((i_1 < 8))) { + break; + }; + vec4 tmpvar_11; + tmpvar_11 = texture2D (_MainTex, (coord + (radius * _BlurOffsets[i_1])).xy); + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + sample = tmpvar_12; + float tmpvar_13; + tmpvar_13 = (sample.z + (sample.w / 255.0)); + sampleDist = tmpvar_13; + float tmpvar_14; + tmpvar_14 = (dist - sampleDist); + diff = tmpvar_14; + float tmpvar_15; + tmpvar_15 = abs (diff); + float tmpvar_16; + tmpvar_16 = xll_saturate ((diffTolerance - tmpvar_15)); + float tmpvar_17; + tmpvar_17 = tmpvar_16; + diff = tmpvar_17; + vec2 tmpvar_18; + tmpvar_18 = (mask.xy + (diff * sample.xy)); + mask.xy = tmpvar_18.xy.xy; + int _post_incdec_tmp; + _post_incdec_tmp = i_1; + int tmpvar_19; + tmpvar_19 = (i_1 + 1); + i_1 = tmpvar_19; + }; + float tmpvar_20; + tmpvar_20 = (mask.x / mask.y); + shadow = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21 = vec4(shadow); + return tmpvar_21; +} + +void main () +{ + v2f_img xlt_i; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_i.pos = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = gl_TexCoord[0].xy; + vec2 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_i.uv = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = frag (xlt_i); + vec4 tmpvar_5; + tmpvar_5 = tmpvar_4; + xl_retval = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = xl_retval.xyzw; + vec4 tmpvar_7; + tmpvar_7 = tmpvar_6; + gl_FragData[0] = tmpvar_7; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Shadow-ScreenBlur-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Shadow-ScreenBlur-out.txt new file mode 100644 index 000000000..fe8dbe2c5 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Shadow-ScreenBlur-out.txt @@ -0,0 +1,44 @@ +uniform vec4 unity_ShadowBlurParams; +uniform sampler2D _MainTex; +uniform vec4 _BlurOffsets[8]; +void main () +{ + float radius; + vec4 mask; + vec4 tmpvar_1; + tmpvar_1.zw = vec2(0.0, 0.0); + tmpvar_1.xy = gl_TexCoord[0].xy; + vec4 tmpvar_2; + tmpvar_2 = texture2D (_MainTex, tmpvar_1.xy); + mask = tmpvar_2; + float tmpvar_3; + tmpvar_3 = (tmpvar_2.z + (tmpvar_2.w / 255.0)); + radius = clamp ((unity_ShadowBlurParams.y / (1.0 - tmpvar_3)), 0.0, 1.0); + mask.xy = (tmpvar_2.xy * unity_ShadowBlurParams.x); + vec4 tmpvar_4; + tmpvar_4 = texture2D (_MainTex, (tmpvar_1 + (radius * _BlurOffsets[0])).xy); + mask.xy = (mask.xy + (clamp ((unity_ShadowBlurParams.x - abs ((tmpvar_3 - (tmpvar_4.z + (tmpvar_4.w / 255.0))))), 0.0, 1.0) * tmpvar_4.xy)); + vec4 tmpvar_5; + tmpvar_5 = texture2D (_MainTex, (tmpvar_1 + (radius * _BlurOffsets[1])).xy); + mask.xy = (mask.xy + (clamp ((unity_ShadowBlurParams.x - abs ((tmpvar_3 - (tmpvar_5.z + (tmpvar_5.w / 255.0))))), 0.0, 1.0) * tmpvar_5.xy)); + vec4 tmpvar_6; + tmpvar_6 = texture2D (_MainTex, (tmpvar_1 + (radius * _BlurOffsets[2])).xy); + mask.xy = (mask.xy + (clamp ((unity_ShadowBlurParams.x - abs ((tmpvar_3 - (tmpvar_6.z + (tmpvar_6.w / 255.0))))), 0.0, 1.0) * tmpvar_6.xy)); + vec4 tmpvar_7; + tmpvar_7 = texture2D (_MainTex, (tmpvar_1 + (radius * _BlurOffsets[3])).xy); + mask.xy = (mask.xy + (clamp ((unity_ShadowBlurParams.x - abs ((tmpvar_3 - (tmpvar_7.z + (tmpvar_7.w / 255.0))))), 0.0, 1.0) * tmpvar_7.xy)); + vec4 tmpvar_8; + tmpvar_8 = texture2D (_MainTex, (tmpvar_1 + (radius * _BlurOffsets[4])).xy); + mask.xy = (mask.xy + (clamp ((unity_ShadowBlurParams.x - abs ((tmpvar_3 - (tmpvar_8.z + (tmpvar_8.w / 255.0))))), 0.0, 1.0) * tmpvar_8.xy)); + vec4 tmpvar_9; + tmpvar_9 = texture2D (_MainTex, (tmpvar_1 + (radius * _BlurOffsets[5])).xy); + mask.xy = (mask.xy + (clamp ((unity_ShadowBlurParams.x - abs ((tmpvar_3 - (tmpvar_9.z + (tmpvar_9.w / 255.0))))), 0.0, 1.0) * tmpvar_9.xy)); + vec4 tmpvar_10; + tmpvar_10 = texture2D (_MainTex, (tmpvar_1 + (radius * _BlurOffsets[6])).xy); + mask.xy = (mask.xy + (clamp ((unity_ShadowBlurParams.x - abs ((tmpvar_3 - (tmpvar_10.z + (tmpvar_10.w / 255.0))))), 0.0, 1.0) * tmpvar_10.xy)); + vec4 tmpvar_11; + tmpvar_11 = texture2D (_MainTex, (tmpvar_1 + (radius * _BlurOffsets[7])).xy); + mask.xy = (mask.xy + (clamp ((unity_ShadowBlurParams.x - abs ((tmpvar_3 - (tmpvar_11.z + (tmpvar_11.w / 255.0))))), 0.0, 1.0) * tmpvar_11.xy)); + gl_FragData[0] = vec4((mask.x / mask.y)); +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_ShowDepthNTexture-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_ShowDepthNTexture-in.txt new file mode 100644 index 000000000..7248cbe19 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_ShowDepthNTexture-in.txt @@ -0,0 +1,61 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +uniform sampler2D _CameraDepthNormalsTexture; +uniform sampler2D _MainTex; +vec3 DecodeViewNormalStereo( in vec4 enc4 ); +float DecodeFloatRG( in vec2 enc ); +void DecodeDepthNormal( in vec4 enc, out float depth, out vec3 normal ); +vec4 frag( in v2f_img i ); +vec3 DecodeViewNormalStereo( in vec4 enc4 ) { + float kScale = 1.77770; + vec3 nn; + float g; + vec3 n; + nn = ((enc4.xyz * vec3( (2.00000 * kScale), (2.00000 * kScale), 0.000000)) + vec3( ( -kScale ), ( -kScale ), 1.00000)); + g = (2.00000 / dot( nn.xyz , nn.xyz )); + n.xy = (g * nn.xy ); + n.z = (g - 1.00000); + return n; +} +float DecodeFloatRG( in vec2 enc ) { + vec2 kDecodeDot = vec2( 1.00000, 0.00392157); + return dot( enc, kDecodeDot); +} +void DecodeDepthNormal( in vec4 enc, out float depth, out vec3 normal ) { + depth = DecodeFloatRG( enc.zw ); + normal = DecodeViewNormalStereo( enc); +} +vec4 frag( in v2f_img i ) { + vec4 tex; + vec4 depth; + float z; + vec3 n; + vec4 col; + tex = texture2D( _MainTex, i.uv); + depth = texture2D( _CameraDepthNormalsTexture, i.uv); + DecodeDepthNormal( depth, z, n); + col.x = z; + col.y = ((n.x * 0.500000) + 0.500000); + col.z = ((n.y * 0.500000) + 0.500000); + col.w = tex.w ; + return col; +} +void main() { + vec4 xl_retval; + v2f_img xlt_i; + xlt_i.pos = vec4(0.0); + xlt_i.uv = vec2( gl_TexCoord[0]); + xl_retval = frag( xlt_i); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_ShowDepthNTexture-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_ShowDepthNTexture-ir.txt new file mode 100644 index 000000000..109327654 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_ShowDepthNTexture-ir.txt @@ -0,0 +1,132 @@ +struct v2f_img { + vec4 pos; + vec2 uv; +}; +uniform sampler2D _MainTex; +uniform sampler2D _CameraDepthNormalsTexture; +vec3 DecodeViewNormalStereo ( + in vec4 enc4 +) +{ + vec3 n; + float g; + vec3 nn; + float kScale; + float tmpvar_1; + tmpvar_1 = 1.7777; + kScale = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2.z = 0.0; + tmpvar_2.x = (2.0 * kScale); + tmpvar_2.y = (2.0 * kScale); + vec3 tmpvar_3; + tmpvar_3.z = 1.0; + tmpvar_3.x = -(kScale); + tmpvar_3.y = -(kScale); + vec3 tmpvar_4; + tmpvar_4 = ((enc4.xyz * tmpvar_2) + tmpvar_3); + nn = tmpvar_4; + float tmpvar_5; + tmpvar_5 = dot (nn.xyz, nn.xyz); + float tmpvar_6; + tmpvar_6 = (2.0 / tmpvar_5); + g = tmpvar_6; + vec2 tmpvar_7; + tmpvar_7 = (g * nn.xy); + n.xy = tmpvar_7.xy.xy; + float tmpvar_8; + tmpvar_8 = (g - 1.0); + n.z = vec3(tmpvar_8).z; + return n; +} + +float DecodeFloatRG ( + in vec2 enc +) +{ + vec2 kDecodeDot; + vec2 tmpvar_1; + tmpvar_1 = vec2(1.0, 0.00392157); + kDecodeDot = tmpvar_1; + float tmpvar_2; + tmpvar_2 = dot (enc, kDecodeDot); + return tmpvar_2; +} + +void DecodeDepthNormal ( + in vec4 enc, + out float depth, + out vec3 normal +) +{ + float tmpvar_1; + tmpvar_1 = DecodeFloatRG (enc.zw); + float tmpvar_2; + tmpvar_2 = tmpvar_1; + depth = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = DecodeViewNormalStereo (enc); + vec3 tmpvar_4; + tmpvar_4 = tmpvar_3; + normal = tmpvar_4; +} + +vec4 frag ( + in v2f_img i +) +{ + vec4 col; + vec3 n; + float z; + vec4 depth; + vec4 tex; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, i.uv); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + tex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = texture2D (_CameraDepthNormalsTexture, i.uv); + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + depth = tmpvar_4; + DecodeDepthNormal (depth, z, n); + float tmpvar_5; + tmpvar_5 = z; + col.x = tmpvar_5; + float tmpvar_6; + tmpvar_6 = ((n.x * 0.5) + 0.5); + col.y = vec2(tmpvar_6).y; + float tmpvar_7; + tmpvar_7 = ((n.y * 0.5) + 0.5); + col.z = vec3(tmpvar_7).z; + float tmpvar_8; + tmpvar_8 = tex.w; + col.w = vec4(tmpvar_8).w; + return col; +} + +void main () +{ + v2f_img xlt_i; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_i.pos = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = gl_TexCoord[0].xy; + vec2 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_i.uv = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = frag (xlt_i); + vec4 tmpvar_5; + tmpvar_5 = tmpvar_4; + xl_retval = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = xl_retval.xyzw; + vec4 tmpvar_7; + tmpvar_7 = tmpvar_6; + gl_FragData[0] = tmpvar_7; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_ShowDepthNTexture-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_ShowDepthNTexture-out.txt new file mode 100644 index 000000000..06eece771 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_ShowDepthNTexture-out.txt @@ -0,0 +1,23 @@ +uniform sampler2D _MainTex; +uniform sampler2D _CameraDepthNormalsTexture; +void main () +{ + vec2 tmpvar_1; + tmpvar_1 = gl_TexCoord[0].xy; + vec4 col; + vec4 tmpvar_2; + tmpvar_2 = texture2D (_CameraDepthNormalsTexture, tmpvar_1); + vec3 n_i0; + vec3 tmpvar_3; + tmpvar_3 = ((tmpvar_2.xyz * vec3(3.5554, 3.5554, 0.0)) + vec3(-1.7777, -1.7777, 1.0)); + float tmpvar_4; + tmpvar_4 = (2.0 / dot (tmpvar_3, tmpvar_3)); + n_i0.xy = (tmpvar_4 * tmpvar_3.xy); + n_i0.z = (tmpvar_4 - 1.0); + col.x = dot (tmpvar_2.zw, vec2(1.0, 0.00392157)); + col.y = ((n_i0.x * 0.5) + 0.5); + col.z = ((n_i0.y * 0.5) + 0.5); + col.w = texture2D (_MainTex, tmpvar_1).w; + gl_FragData[0] = col; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_ShowDepthTexture-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_ShowDepthTexture-in.txt new file mode 100644 index 000000000..339d8dfe6 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_ShowDepthTexture-in.txt @@ -0,0 +1,41 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +uniform sampler2D _CameraDepthTexture; +uniform sampler2D _MainTex; +uniform vec4 _ZBufferParams; +float LinearEyeDepth( in float z ); +vec4 frag( in v2f_img i ); +float LinearEyeDepth( in float z ) { + return (1.00000 / ((_ZBufferParams.z * z) + _ZBufferParams.w )); +} +vec4 frag( in v2f_img i ) { + vec4 tex; + vec4 depth; + float z; + vec4 col; + tex = texture2D( _MainTex, i.uv); + depth = texture2D( _CameraDepthTexture, i.uv); + z = (LinearEyeDepth( depth.x ) * 0.0100000); + col = tex; + col.xy = vec2( z); + return col; +} +void main() { + vec4 xl_retval; + v2f_img xlt_i; + xlt_i.pos = vec4(0.0); + xlt_i.uv = vec2( gl_TexCoord[0]); + xl_retval = frag( xlt_i); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_ShowDepthTexture-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_ShowDepthTexture-ir.txt new file mode 100644 index 000000000..aeb736b83 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_ShowDepthTexture-ir.txt @@ -0,0 +1,72 @@ +struct v2f_img { + vec4 pos; + vec2 uv; +}; +uniform vec4 _ZBufferParams; +uniform sampler2D _MainTex; +uniform sampler2D _CameraDepthTexture; +float LinearEyeDepth ( + in float z +) +{ + return (1.0 / ((_ZBufferParams.z * z) + _ZBufferParams.w)); +} + +vec4 frag ( + in v2f_img i +) +{ + vec4 col; + float z; + vec4 depth; + vec4 tex; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, i.uv); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + tex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = texture2D (_CameraDepthTexture, i.uv); + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + depth = tmpvar_4; + float tmpvar_5; + tmpvar_5 = LinearEyeDepth (depth.x); + float tmpvar_6; + tmpvar_6 = (tmpvar_5 * 0.01); + z = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = tex; + col = tmpvar_7; + vec2 tmpvar_8; + tmpvar_8 = vec2(z); + vec2 tmpvar_9; + tmpvar_9 = tmpvar_8; + col.xy = tmpvar_9.xy.xy; + return col; +} + +void main () +{ + v2f_img xlt_i; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_i.pos = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = gl_TexCoord[0].xy; + vec2 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_i.uv = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = frag (xlt_i); + vec4 tmpvar_5; + tmpvar_5 = tmpvar_4; + xl_retval = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = xl_retval.xyzw; + vec4 tmpvar_7; + tmpvar_7 = tmpvar_6; + gl_FragData[0] = tmpvar_7; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_ShowDepthTexture-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_ShowDepthTexture-out.txt new file mode 100644 index 000000000..26c26c943 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_ShowDepthTexture-out.txt @@ -0,0 +1,13 @@ +uniform vec4 _ZBufferParams; +uniform sampler2D _MainTex; +uniform sampler2D _CameraDepthTexture; +void main () +{ + vec2 tmpvar_1; + tmpvar_1 = gl_TexCoord[0].xy; + vec4 col; + col = texture2D (_MainTex, tmpvar_1); + col.xy = vec2(((1.0/(((_ZBufferParams.z * texture2D (_CameraDepthTexture, tmpvar_1).x) + _ZBufferParams.w))) * 0.01)); + gl_FragData[0] = col; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_BillboardTree-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_BillboardTree-in.txt new file mode 100644 index 000000000..b7d56d4c2 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_BillboardTree-in.txt @@ -0,0 +1,48 @@ +void xll_clip(float x) { + if ( x<0.0 ) discard; +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct v2f { + vec4 pos; + float fog; + vec4 color; + vec2 uv; +}; +struct appdata_tree_billboard { + vec4 vertex; + vec4 color; + vec4 texcoord; + vec2 texcoord1; +}; +uniform sampler2D _MainTex; +vec4 frag( in v2f xlat_var_input ); +vec4 frag( in v2f xlat_var_input ) { + vec4 col; + col = texture2D( _MainTex, xlat_var_input.uv); + col.xyz *= xlat_var_input.color.xyz ; + xll_clip( col.w ); + return col; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f xlt_xlat_var_input; + xlt_xlat_var_input.pos = vec4(0.0); + xlt_xlat_var_input.fog = float( xlv_FOG); + xlt_xlat_var_input.color = vec4( gl_Color); + xlt_xlat_var_input.uv = vec2( gl_TexCoord[0]); + xl_retval = frag( xlt_xlat_var_input); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_BillboardTree-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_BillboardTree-ir.txt new file mode 100644 index 000000000..7824f6dc7 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_BillboardTree-ir.txt @@ -0,0 +1,66 @@ +struct v2f { + vec4 pos; + float fog; + vec4 color; + vec2 uv; +}; +varying vec4 xlv_FOG; +uniform sampler2D _MainTex; +void xll_clip ( + in float x +) +{ + if ((x < 0.0)) { + discard; + }; +} + +vec4 frag ( + in v2f xlat_var_input +) +{ + vec4 col; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, xlat_var_input.uv); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + col = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = (col.xyz * xlat_var_input.color.xyz); + col.xyz = tmpvar_3.xyz.xyz; + xll_clip (col.w); + return col; +} + +void main () +{ + v2f xlt_xlat_var_input; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_xlat_var_input.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_xlat_var_input.fog = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = gl_Color.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_xlat_var_input.color = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5 = gl_TexCoord[0].xy; + vec2 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_xlat_var_input.uv = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = frag (xlt_xlat_var_input); + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xl_retval = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = xl_retval.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + gl_FragData[0] = tmpvar_10; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_BillboardTree-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_BillboardTree-out.txt new file mode 100644 index 000000000..c0f63ce66 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_BillboardTree-out.txt @@ -0,0 +1,14 @@ +uniform sampler2D _MainTex; +void main () +{ + vec4 col; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, gl_TexCoord[0].xy); + col = tmpvar_1; + col.xyz = (tmpvar_1.xyz * gl_Color.xyz); + if ((tmpvar_1.w < 0.0)) { + discard; + }; + gl_FragData[0] = col; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Details_BillboardWavingDoublePass-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Details_BillboardWavingDoublePass-in.txt new file mode 100644 index 000000000..8110f768e --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Details_BillboardWavingDoublePass-in.txt @@ -0,0 +1,98 @@ +void xll_clip(float x) { + if ( x<0.0 ) discard; +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +struct Input { + vec2 uv_MainTex; + vec4 color; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 lop_color; + vec3 normal; + vec3 vlight; +}; +uniform float _Cutoff; +uniform vec4 _LightColor0; +uniform sampler2D _MainTex; +uniform vec4 _WorldSpaceLightPos0; +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ); +vec4 frag_surf( in v2f_surf IN ); +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 c; + c = (texture2D( _MainTex, IN.uv_MainTex) * IN.color); + o.Albedo = c.xyz ; + o.Alpha = c.w ; +} +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ) { + float diff; + vec4 c; + diff = max( 0.000000, dot( s.Normal, lightDir)); + c.xyz = ((s.Albedo * _LightColor0.xyz ) * ((diff * atten) * 2.00000)); + c.w = s.Alpha; + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + float atten = 1.00000; + vec4 c; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + surfIN.color = IN.lop_color; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + o.Normal = IN.normal; + surf( surfIN, o); + xll_clip( (o.Alpha - _Cutoff) ); + c = LightingLambert( o, _WorldSpaceLightPos0.xyz , atten); + c.xyz += (o.Albedo * IN.vlight); + c.w = o.Alpha; + return c; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec2( gl_TexCoord[0]); + xlt_IN.lop_color = vec4( gl_Color); + xlt_IN.normal = vec3( gl_TexCoord[1]); + xlt_IN.vlight = vec3( gl_TexCoord[2]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Details_BillboardWavingDoublePass-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Details_BillboardWavingDoublePass-ir.txt new file mode 100644 index 000000000..718998ea2 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Details_BillboardWavingDoublePass-ir.txt @@ -0,0 +1,170 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec4 color; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 lop_color; + vec3 normal; + vec3 vlight; +}; +varying vec4 xlv_FOG; +uniform vec4 _WorldSpaceLightPos0; +uniform sampler2D _MainTex; +uniform vec4 _LightColor0; +uniform float _Cutoff; +void xll_clip ( + in float x +) +{ + if ((x < 0.0)) { + discard; + }; +} + +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 c; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = (tmpvar_1 * IN.color); + c = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = c.xyz; + o.Albedo = tmpvar_3; + float tmpvar_4; + tmpvar_4 = c.w; + o.Alpha = tmpvar_4; +} + +vec4 LightingLambert ( + in SurfaceOutput s, + in vec3 lightDir, + in float atten +) +{ + vec4 c; + float diff; + float tmpvar_1; + tmpvar_1 = dot (s.Normal, lightDir); + float tmpvar_2; + tmpvar_2 = max (0.0, tmpvar_1); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + diff = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = ((s.Albedo * _LightColor0.xyz) * ((diff * atten) * 2.0)); + c.xyz = tmpvar_4.xyz.xyz; + float tmpvar_5; + tmpvar_5 = s.Alpha; + c.w = vec4(tmpvar_5).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 c; + float atten; + SurfaceOutput o; + Input surfIN; + float tmpvar_1; + tmpvar_1 = 1.0; + atten = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = IN.lop_color; + surfIN.color = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Specular = tmpvar_6; + float tmpvar_7; + tmpvar_7 = 0.0; + o.Alpha = tmpvar_7; + float tmpvar_8; + tmpvar_8 = 0.0; + o.Gloss = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = IN.normal; + o.Normal = tmpvar_9; + surf (surfIN, o); + xll_clip ((o.Alpha - _Cutoff)); + vec4 tmpvar_10; + tmpvar_10 = LightingLambert (o, _WorldSpaceLightPos0.xyz, atten); + vec4 tmpvar_11; + tmpvar_11 = tmpvar_10; + c = tmpvar_11; + vec3 tmpvar_12; + tmpvar_12 = (c.xyz + (o.Albedo * IN.vlight)); + c.xyz = tmpvar_12.xyz.xyz; + float tmpvar_13; + tmpvar_13 = o.Alpha; + c.w = vec4(tmpvar_13).w; + return c; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xy; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = gl_Color.xyzw; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.lop_color = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = gl_TexCoord[1].xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.normal = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = gl_TexCoord[2].xyz; + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_IN.vlight = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = frag_surf (xlt_IN); + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xl_retval = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = xl_retval.xyzw; + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + gl_FragData[0] = tmpvar_14; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Details_BillboardWavingDoublePass-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Details_BillboardWavingDoublePass-out.txt new file mode 100644 index 000000000..d0e8fde97 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Details_BillboardWavingDoublePass-out.txt @@ -0,0 +1,27 @@ +uniform vec4 _WorldSpaceLightPos0; +uniform sampler2D _MainTex; +uniform vec4 _LightColor0; +uniform float _Cutoff; +void main () +{ + vec3 tmpvar_1; + tmpvar_1 = gl_TexCoord[1].xyz; + vec3 tmpvar_2; + tmpvar_2 = gl_TexCoord[2].xyz; + vec4 c; + vec4 tmpvar_3; + tmpvar_3 = (texture2D (_MainTex, gl_TexCoord[0].xy) * gl_Color); + float x; + x = (tmpvar_3.w - _Cutoff); + if ((x < 0.0)) { + discard; + }; + vec4 c_i0_i1; + c_i0_i1.xyz = ((tmpvar_3.xyz * _LightColor0.xyz) * (max (0.0, dot (tmpvar_1, _WorldSpaceLightPos0.xyz)) * 2.0)); + c_i0_i1.w = tmpvar_3.w; + c = c_i0_i1; + c.xyz = (c_i0_i1.xyz + (tmpvar_3.xyz * tmpvar_2)); + c.w = tmpvar_3.w; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Details_BillboardWavingDoublePass1-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Details_BillboardWavingDoublePass1-in.txt new file mode 100644 index 000000000..1f79d0aee --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Details_BillboardWavingDoublePass1-in.txt @@ -0,0 +1,102 @@ +void xll_clip(float x) { + if ( x<0.0 ) discard; +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +struct Input { + vec2 uv_MainTex; + vec4 color; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 lop_color; + vec3 normal; + vec3 lightDir; + vec3 _LightCoord; +}; +uniform float _Cutoff; +uniform vec4 _LightColor0; +uniform samplerCube _LightTexture0; +uniform sampler2D _LightTextureB0; +uniform sampler2D _MainTex; +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ); +vec4 frag_surf( in v2f_surf IN ); +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 c; + c = (texture2D( _MainTex, IN.uv_MainTex) * IN.color); + o.Albedo = c.xyz ; + o.Alpha = c.w ; +} +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ) { + float diff; + vec4 c; + diff = max( 0.000000, dot( s.Normal, lightDir)); + c.xyz = ((s.Albedo * _LightColor0.xyz ) * ((diff * atten) * 2.00000)); + c.w = s.Alpha; + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec3 lightDir; + vec4 c; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + surfIN.color = IN.lop_color; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + o.Normal = IN.normal; + surf( surfIN, o); + xll_clip( (o.Alpha - _Cutoff) ); + lightDir = IN.lightDir; + lightDir = normalize( lightDir ); + c = LightingLambert( o, lightDir, (texture2D( _LightTextureB0, vec2( vec2( dot( IN._LightCoord, IN._LightCoord)))).w * textureCube( _LightTexture0, IN._LightCoord).w )); + c.w = o.Alpha; + return c; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec2( gl_TexCoord[0]); + xlt_IN.lop_color = vec4( gl_Color); + xlt_IN.normal = vec3( gl_TexCoord[1]); + xlt_IN.lightDir = vec3( gl_TexCoord[2]); + xlt_IN._LightCoord = vec3( gl_TexCoord[3]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Details_BillboardWavingDoublePass1-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Details_BillboardWavingDoublePass1-ir.txt new file mode 100644 index 000000000..ba7cc1e1d --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Details_BillboardWavingDoublePass1-ir.txt @@ -0,0 +1,189 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec4 color; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 lop_color; + vec3 normal; + vec3 lightDir; + vec3 _LightCoord; +}; +varying vec4 xlv_FOG; +uniform sampler2D _MainTex; +uniform sampler2D _LightTextureB0; +uniform samplerCube _LightTexture0; +uniform vec4 _LightColor0; +uniform float _Cutoff; +void xll_clip ( + in float x +) +{ + if ((x < 0.0)) { + discard; + }; +} + +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 c; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = (tmpvar_1 * IN.color); + c = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = c.xyz; + o.Albedo = tmpvar_3; + float tmpvar_4; + tmpvar_4 = c.w; + o.Alpha = tmpvar_4; +} + +vec4 LightingLambert ( + in SurfaceOutput s, + in vec3 lightDir, + in float atten +) +{ + vec4 c; + float diff; + float tmpvar_1; + tmpvar_1 = dot (s.Normal, lightDir); + float tmpvar_2; + tmpvar_2 = max (0.0, tmpvar_1); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + diff = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = ((s.Albedo * _LightColor0.xyz) * ((diff * atten) * 2.0)); + c.xyz = tmpvar_4.xyz.xyz; + float tmpvar_5; + tmpvar_5 = s.Alpha; + c.w = vec4(tmpvar_5).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 c; + vec3 lightDir; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = IN.lop_color; + surfIN.color = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Specular = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Alpha = tmpvar_6; + float tmpvar_7; + tmpvar_7 = 0.0; + o.Gloss = tmpvar_7; + vec3 tmpvar_8; + tmpvar_8 = IN.normal; + o.Normal = tmpvar_8; + surf (surfIN, o); + xll_clip ((o.Alpha - _Cutoff)); + vec3 tmpvar_9; + tmpvar_9 = IN.lightDir; + lightDir = tmpvar_9; + vec3 tmpvar_10; + tmpvar_10 = normalize (lightDir); + vec3 tmpvar_11; + tmpvar_11 = tmpvar_10; + lightDir = tmpvar_11; + float tmpvar_12; + tmpvar_12 = dot (IN._LightCoord, IN._LightCoord); + vec2 tmpvar_13; + tmpvar_13 = vec2(tmpvar_12); + vec2 tmpvar_14; + tmpvar_14 = tmpvar_13.xy; + vec4 tmpvar_15; + tmpvar_15 = texture2D (_LightTextureB0, tmpvar_14); + vec4 tmpvar_16; + tmpvar_16 = textureCube (_LightTexture0, IN._LightCoord); + vec4 tmpvar_17; + tmpvar_17 = LightingLambert (o, lightDir, (tmpvar_15.w * tmpvar_16.w)); + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + c = tmpvar_18; + float tmpvar_19; + tmpvar_19 = o.Alpha; + c.w = vec4(tmpvar_19).w; + return c; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xy; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = gl_Color.xyzw; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.lop_color = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = gl_TexCoord[1].xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.normal = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = gl_TexCoord[2].xyz; + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_IN.lightDir = tmpvar_10; + vec3 tmpvar_11; + tmpvar_11 = gl_TexCoord[3].xyz; + vec3 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_IN._LightCoord = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = frag_surf (xlt_IN); + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_FragData[0] = tmpvar_16; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Details_BillboardWavingDoublePass1-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Details_BillboardWavingDoublePass1-out.txt new file mode 100644 index 000000000..140a3daf0 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Details_BillboardWavingDoublePass1-out.txt @@ -0,0 +1,29 @@ +uniform sampler2D _MainTex; +uniform sampler2D _LightTextureB0; +uniform samplerCube _LightTexture0; +uniform vec4 _LightColor0; +uniform float _Cutoff; +void main () +{ + vec3 tmpvar_1; + tmpvar_1 = gl_TexCoord[1].xyz; + vec3 tmpvar_2; + tmpvar_2 = gl_TexCoord[2].xyz; + vec3 tmpvar_3; + tmpvar_3 = gl_TexCoord[3].xyz; + vec4 c; + vec4 tmpvar_4; + tmpvar_4 = (texture2D (_MainTex, gl_TexCoord[0].xy) * gl_Color); + float x; + x = (tmpvar_4.w - _Cutoff); + if ((x < 0.0)) { + discard; + }; + vec4 c_i0_i1; + c_i0_i1.xyz = ((tmpvar_4.xyz * _LightColor0.xyz) * ((max (0.0, dot (tmpvar_1, normalize (tmpvar_2))) * (texture2D (_LightTextureB0, vec2(dot (tmpvar_3, tmpvar_3))).w * textureCube (_LightTexture0, tmpvar_3).w)) * 2.0)); + c_i0_i1.w = tmpvar_4.w; + c = c_i0_i1; + c.w = tmpvar_4.w; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Details_BillboardWavingDoublePass2-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Details_BillboardWavingDoublePass2-in.txt new file mode 100644 index 000000000..bcd59ae1e --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Details_BillboardWavingDoublePass2-in.txt @@ -0,0 +1,74 @@ +void xll_clip(float x) { + if ( x<0.0 ) discard; +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +struct Input { + vec2 uv_MainTex; + vec4 color; +}; +struct v2f_surf { + vec4 pos; + vec2 hip_pack0; + vec4 lop_color; +}; +uniform float _Cutoff; +uniform sampler2D _MainTex; +void surf( in Input IN, inout SurfaceOutput o ); +vec4 frag_surf( in v2f_surf IN ); +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 c; + c = (texture2D( _MainTex, IN.uv_MainTex) * IN.color); + o.Albedo = c.xyz ; + o.Alpha = c.w ; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + surfIN.color = IN.lop_color; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + surf( surfIN, o); + xll_clip( (o.Alpha - _Cutoff) ); + return vec4( 0.000000); +} +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.hip_pack0 = vec2( gl_TexCoord[1]); + xlt_IN.lop_color = vec4( gl_Color); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Details_BillboardWavingDoublePass2-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Details_BillboardWavingDoublePass2-ir.txt new file mode 100644 index 000000000..05c3389e1 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Details_BillboardWavingDoublePass2-ir.txt @@ -0,0 +1,108 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec4 color; +}; +struct v2f_surf { + vec4 pos; + vec2 hip_pack0; + vec4 lop_color; +}; +uniform sampler2D _MainTex; +uniform float _Cutoff; +void xll_clip ( + in float x +) +{ + if ((x < 0.0)) { + discard; + }; +} + +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 c; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = (tmpvar_1 * IN.color); + c = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = c.xyz; + o.Albedo = tmpvar_3; + float tmpvar_4; + tmpvar_4 = c.w; + o.Alpha = tmpvar_4; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = IN.lop_color; + surfIN.color = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Specular = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Alpha = tmpvar_6; + float tmpvar_7; + tmpvar_7 = 0.0; + o.Gloss = tmpvar_7; + surf (surfIN, o); + xll_clip ((o.Alpha - _Cutoff)); + return vec4(0.0, 0.0, 0.0, 0.0); +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = gl_TexCoord[1].xy; + vec2 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_IN.hip_pack0 = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = gl_Color.xyzw; + vec4 tmpvar_5; + tmpvar_5 = tmpvar_4; + xlt_IN.lop_color = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = frag_surf (xlt_IN); + vec4 tmpvar_7; + tmpvar_7 = tmpvar_6; + xl_retval = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = xl_retval.xyzw; + vec4 tmpvar_9; + tmpvar_9 = tmpvar_8; + gl_FragData[0] = tmpvar_9; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Details_BillboardWavingDoublePass2-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Details_BillboardWavingDoublePass2-out.txt new file mode 100644 index 000000000..4bc22acbf --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Details_BillboardWavingDoublePass2-out.txt @@ -0,0 +1,12 @@ +uniform sampler2D _MainTex; +uniform float _Cutoff; +void main () +{ + float x; + x = ((texture2D (_MainTex, gl_TexCoord[1].xy) * gl_Color).w - _Cutoff); + if ((x < 0.0)) { + discard; + }; + gl_FragData[0] = vec4(0.0, 0.0, 0.0, 0.0); +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Details_Vertexlit-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Details_Vertexlit-in.txt new file mode 100644 index 000000000..db506b16f --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Details_Vertexlit-in.txt @@ -0,0 +1,96 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec4 color; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 lop_color; + vec3 normal; + vec3 lightDir; + vec3 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _LightColor0; +uniform sampler2D _LightTexture0; +uniform sampler2D _MainTex; +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ); +vec4 frag_surf( in v2f_surf IN ); +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 c; + c = (texture2D( _MainTex, IN.uv_MainTex) * IN.color); + o.Albedo = c.xyz ; + o.Alpha = c.w ; +} +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ) { + float diff; + vec4 c; + diff = max( 0.000000, dot( s.Normal, lightDir)); + c.xyz = ((s.Albedo * _LightColor0.xyz ) * ((diff * atten) * 2.00000)); + c.w = s.Alpha; + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec3 lightDir; + vec4 c; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + surfIN.color = IN.lop_color; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + o.Normal = IN.normal; + surf( surfIN, o); + lightDir = IN.lightDir; + lightDir = normalize( lightDir ); + c = LightingLambert( o, lightDir, texture2D( _LightTexture0, vec2( vec2( dot( IN._LightCoord, IN._LightCoord)))).w ); + c.w = 0.000000; + return c; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec2( gl_TexCoord[0]); + xlt_IN.lop_color = vec4( gl_Color); + xlt_IN.normal = vec3( gl_TexCoord[1]); + xlt_IN.lightDir = vec3( gl_TexCoord[2]); + xlt_IN._LightCoord = vec3( gl_TexCoord[3]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Details_Vertexlit-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Details_Vertexlit-ir.txt new file mode 100644 index 000000000..dc4be9ccb --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Details_Vertexlit-ir.txt @@ -0,0 +1,175 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec4 color; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 lop_color; + vec3 normal; + vec3 lightDir; + vec3 _LightCoord; +}; +varying vec4 xlv_FOG; +uniform sampler2D _MainTex; +uniform sampler2D _LightTexture0; +uniform vec4 _LightColor0; +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 c; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = (tmpvar_1 * IN.color); + c = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = c.xyz; + o.Albedo = tmpvar_3; + float tmpvar_4; + tmpvar_4 = c.w; + o.Alpha = tmpvar_4; +} + +vec4 LightingLambert ( + in SurfaceOutput s, + in vec3 lightDir, + in float atten +) +{ + vec4 c; + float diff; + float tmpvar_1; + tmpvar_1 = dot (s.Normal, lightDir); + float tmpvar_2; + tmpvar_2 = max (0.0, tmpvar_1); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + diff = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = ((s.Albedo * _LightColor0.xyz) * ((diff * atten) * 2.0)); + c.xyz = tmpvar_4.xyz.xyz; + float tmpvar_5; + tmpvar_5 = s.Alpha; + c.w = vec4(tmpvar_5).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 c; + vec3 lightDir; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = IN.lop_color; + surfIN.color = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Specular = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Alpha = tmpvar_6; + float tmpvar_7; + tmpvar_7 = 0.0; + o.Gloss = tmpvar_7; + vec3 tmpvar_8; + tmpvar_8 = IN.normal; + o.Normal = tmpvar_8; + surf (surfIN, o); + vec3 tmpvar_9; + tmpvar_9 = IN.lightDir; + lightDir = tmpvar_9; + vec3 tmpvar_10; + tmpvar_10 = normalize (lightDir); + vec3 tmpvar_11; + tmpvar_11 = tmpvar_10; + lightDir = tmpvar_11; + float tmpvar_12; + tmpvar_12 = dot (IN._LightCoord, IN._LightCoord); + vec2 tmpvar_13; + tmpvar_13 = vec2(tmpvar_12); + vec2 tmpvar_14; + tmpvar_14 = tmpvar_13.xy; + vec4 tmpvar_15; + tmpvar_15 = texture2D (_LightTexture0, tmpvar_14); + vec4 tmpvar_16; + tmpvar_16 = LightingLambert (o, lightDir, tmpvar_15.w); + vec4 tmpvar_17; + tmpvar_17 = tmpvar_16; + c = tmpvar_17; + float tmpvar_18; + tmpvar_18 = 0.0; + c.w = vec4(tmpvar_18).w; + return c; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xy; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = gl_Color.xyzw; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.lop_color = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = gl_TexCoord[1].xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.normal = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = gl_TexCoord[2].xyz; + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_IN.lightDir = tmpvar_10; + vec3 tmpvar_11; + tmpvar_11 = gl_TexCoord[3].xyz; + vec3 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_IN._LightCoord = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = frag_surf (xlt_IN); + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_FragData[0] = tmpvar_16; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Details_Vertexlit-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Details_Vertexlit-out.txt new file mode 100644 index 000000000..bc9ba8766 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Details_Vertexlit-out.txt @@ -0,0 +1,18 @@ +uniform sampler2D _MainTex; +uniform sampler2D _LightTexture0; +uniform vec4 _LightColor0; +void main () +{ + vec3 tmpvar_1; + tmpvar_1 = gl_TexCoord[3].xyz; + vec4 c; + vec4 tmpvar_2; + tmpvar_2 = (texture2D (_MainTex, gl_TexCoord[0].xy) * gl_Color); + vec4 c_i0_i1; + c_i0_i1.xyz = ((tmpvar_2.xyz * _LightColor0.xyz) * ((max (0.0, dot (gl_TexCoord[1].xyz, normalize (gl_TexCoord[2].xyz))) * texture2D (_LightTexture0, vec2(dot (tmpvar_1, tmpvar_1))).w) * 2.0)); + c_i0_i1.w = tmpvar_2.w; + c = c_i0_i1; + c.w = 0.0; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Details_Vertexlit1-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Details_Vertexlit1-in.txt new file mode 100644 index 000000000..93e8267d7 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Details_Vertexlit1-in.txt @@ -0,0 +1,123 @@ +float xll_saturate( float x) { + return clamp( x, 0.0, 1.0); +} +vec2 xll_saturate( vec2 x) { + return clamp( x, 0.0, 1.0); +} +vec3 xll_saturate( vec3 x) { + return clamp( x, 0.0, 1.0); +} +vec4 xll_saturate( vec4 x) { + return clamp( x, 0.0, 1.0); +} +mat2 xll_saturate(mat2 m) { + return mat2( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0)); +} +mat3 xll_saturate(mat3 m) { + return mat3( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0), clamp(m[2], 0.0, 1.0)); +} +mat4 xll_saturate(mat4 m) { + return mat4( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0), clamp(m[2], 0.0, 1.0), clamp(m[3], 0.0, 1.0)); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec4 color; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 lop_color; + vec4 hip_screen; + vec3 hip_lmapFade; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform sampler2D _LightBuffer; +uniform sampler2D _MainTex; +uniform sampler2D unity_Lightmap; +uniform sampler2D unity_LightmapInd; +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingLambert_PrePass( in SurfaceOutput s, in vec4 light ); +vec3 DecodeLightmap( in vec4 color ); +vec4 frag_surf( in v2f_surf IN ); +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 c; + c = (texture2D( _MainTex, IN.uv_MainTex) * IN.color); + o.Albedo = c.xyz ; + o.Alpha = c.w ; +} +vec4 LightingLambert_PrePass( in SurfaceOutput s, in vec4 light ) { + vec4 c; + c.xyz = (s.Albedo * light.xyz ); + c.w = s.Alpha; + return c; +} +vec3 DecodeLightmap( in vec4 color ) { + return (2.00000 * color.xyz ); +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec4 light; + vec3 lmFull; + vec3 lmIndirect; + vec3 lm; + vec4 col; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + surfIN.color = IN.lop_color; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + surf( surfIN, o); + light = texture2DProj( _LightBuffer, IN.hip_screen); + light = ( -log2( light ) ); + lmFull = DecodeLightmap( texture2D( unity_Lightmap, IN.hip_lmapFade.xy )); + lmIndirect = DecodeLightmap( texture2D( unity_LightmapInd, IN.hip_lmapFade.xy )); + lm = mix( lmIndirect, lmFull, vec3( xll_saturate( IN.hip_lmapFade.z ))); + light.xyz += lm; + col = LightingLambert_PrePass( o, light); + return col; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec2( gl_TexCoord[0]); + xlt_IN.lop_color = vec4( gl_Color); + xlt_IN.hip_screen = vec4( gl_TexCoord[1]); + xlt_IN.hip_lmapFade = vec3( gl_TexCoord[2]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Details_Vertexlit1-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Details_Vertexlit1-ir.txt new file mode 100644 index 000000000..d7132f31d --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Details_Vertexlit1-ir.txt @@ -0,0 +1,290 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec4 color; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 lop_color; + vec4 hip_screen; + vec3 hip_lmapFade; +}; +varying vec4 xlv_FOG; +uniform sampler2D unity_LightmapInd; +uniform sampler2D unity_Lightmap; +uniform sampler2D _MainTex; +uniform sampler2D _LightBuffer; +float xll_saturate ( + in float x +) +{ + float tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec2 xll_saturate ( + in vec2 x +) +{ + vec2 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec3 xll_saturate ( + in vec3 x +) +{ + vec3 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec4 xll_saturate ( + in vec4 x +) +{ + vec4 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +mat2 xll_saturate ( + in mat2 m +) +{ + vec2 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec2 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + mat2 tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_1; + tmpvar_3[0] = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5 = tmpvar_2; + tmpvar_3[1] = tmpvar_5; + return tmpvar_3; +} + +mat3 xll_saturate ( + in mat3 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec3 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + vec3 tmpvar_3; + tmpvar_3 = clamp (m[2], 0.0, 1.0); + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +mat4 xll_saturate ( + in mat4 m +) +{ + vec4 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec4 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + vec4 tmpvar_3; + tmpvar_3 = clamp (m[2], 0.0, 1.0); + vec4 tmpvar_4; + tmpvar_4 = clamp (m[3], 0.0, 1.0); + mat4 tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_1; + tmpvar_5[0] = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = tmpvar_2; + tmpvar_5[1] = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_3; + tmpvar_5[2] = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = tmpvar_4; + tmpvar_5[3] = tmpvar_9; + return tmpvar_5; +} + +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 c; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = (tmpvar_1 * IN.color); + c = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = c.xyz; + o.Albedo = tmpvar_3; + float tmpvar_4; + tmpvar_4 = c.w; + o.Alpha = tmpvar_4; +} + +vec4 LightingLambert_PrePass ( + in SurfaceOutput s, + in vec4 light +) +{ + vec4 c; + vec3 tmpvar_1; + tmpvar_1 = (s.Albedo * light.xyz); + c.xyz = tmpvar_1.xyz.xyz; + float tmpvar_2; + tmpvar_2 = s.Alpha; + c.w = vec4(tmpvar_2).w; + return c; +} + +vec3 DecodeLightmap ( + in vec4 color +) +{ + return (2.0 * color.xyz); +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 col; + vec3 lm; + vec3 lmIndirect; + vec3 lmFull; + vec4 light; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = IN.lop_color; + surfIN.color = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Specular = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Alpha = tmpvar_6; + float tmpvar_7; + tmpvar_7 = 0.0; + o.Gloss = tmpvar_7; + surf (surfIN, o); + vec4 tmpvar_8; + tmpvar_8 = texture2DProj (_LightBuffer, IN.hip_screen); + vec4 tmpvar_9; + tmpvar_9 = tmpvar_8; + light = tmpvar_9; + vec4 tmpvar_10; + tmpvar_10 = log2 (light); + vec4 tmpvar_11; + tmpvar_11 = -(tmpvar_10); + light = tmpvar_11; + vec4 tmpvar_12; + tmpvar_12 = texture2D (unity_Lightmap, IN.hip_lmapFade.xy); + vec3 tmpvar_13; + tmpvar_13 = DecodeLightmap (tmpvar_12); + vec3 tmpvar_14; + tmpvar_14 = tmpvar_13; + lmFull = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = texture2D (unity_LightmapInd, IN.hip_lmapFade.xy); + vec3 tmpvar_16; + tmpvar_16 = DecodeLightmap (tmpvar_15); + vec3 tmpvar_17; + tmpvar_17 = tmpvar_16; + lmIndirect = tmpvar_17; + float tmpvar_18; + tmpvar_18 = xll_saturate (IN.hip_lmapFade.z); + vec3 tmpvar_19; + tmpvar_19 = vec3(tmpvar_18); + vec3 tmpvar_20; + tmpvar_20 = mix (lmIndirect, lmFull, tmpvar_19); + vec3 tmpvar_21; + tmpvar_21 = tmpvar_20; + lm = tmpvar_21; + vec3 tmpvar_22; + tmpvar_22 = (light.xyz + lm); + light.xyz = tmpvar_22.xyz.xyz; + vec4 tmpvar_23; + tmpvar_23 = LightingLambert_PrePass (o, light); + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + col = tmpvar_24; + return col; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xy; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = gl_Color.xyzw; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.lop_color = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_TexCoord[1].xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.hip_screen = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = gl_TexCoord[2].xyz; + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_IN.hip_lmapFade = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = frag_surf (xlt_IN); + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xl_retval = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = xl_retval.xyzw; + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + gl_FragData[0] = tmpvar_14; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Details_Vertexlit1-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Details_Vertexlit1-out.txt new file mode 100644 index 000000000..dbd23f2dc --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Details_Vertexlit1-out.txt @@ -0,0 +1,21 @@ +uniform sampler2D unity_LightmapInd; +uniform sampler2D unity_Lightmap; +uniform sampler2D _MainTex; +uniform sampler2D _LightBuffer; +void main () +{ + vec3 tmpvar_1; + tmpvar_1 = gl_TexCoord[2].xyz; + vec4 light; + vec4 tmpvar_2; + tmpvar_2 = (texture2D (_MainTex, gl_TexCoord[0].xy) * gl_Color); + vec4 tmpvar_3; + tmpvar_3 = -(log2 (texture2DProj (_LightBuffer, gl_TexCoord[1]))); + light = tmpvar_3; + light.xyz = (tmpvar_3.xyz + mix ((2.0 * texture2D (unity_LightmapInd, tmpvar_1.xy).xyz), (2.0 * texture2D (unity_Lightmap, tmpvar_1.xy).xyz), vec3(clamp (tmpvar_1.z, 0.0, 1.0)))); + vec4 c_i0; + c_i0.xyz = (tmpvar_2.xyz * light.xyz); + c_i0.w = tmpvar_2.w; + gl_FragData[0] = c_i0; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Details_WavingDoublePass-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Details_WavingDoublePass-in.txt new file mode 100644 index 000000000..2f1422ddf --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Details_WavingDoublePass-in.txt @@ -0,0 +1,108 @@ +void xll_clip(float x) { + if ( x<0.0 ) discard; +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +struct Input { + vec2 uv_MainTex; + vec4 color; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 lop_color; + vec3 normal; + vec3 vlight; + vec4 _ShadowCoord; +}; +uniform float _Cutoff; +uniform vec4 _LightColor0; +uniform sampler2D _MainTex; +uniform sampler2D _ShadowMapTexture; +uniform vec4 _WorldSpaceLightPos0; +float unitySampleShadow( in vec4 shadowCoord ); +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ); +vec4 frag_surf( in v2f_surf IN ); +float unitySampleShadow( in vec4 shadowCoord ) { + float shadow; + shadow = texture2DProj( _ShadowMapTexture, shadowCoord).x ; + return shadow; +} +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 c; + c = (texture2D( _MainTex, IN.uv_MainTex) * IN.color); + o.Albedo = c.xyz ; + o.Alpha = c.w ; +} +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ) { + float diff; + vec4 c; + diff = max( 0.000000, dot( s.Normal, lightDir)); + c.xyz = ((s.Albedo * _LightColor0.xyz ) * ((diff * atten) * 2.00000)); + c.w = s.Alpha; + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + float atten; + vec4 c; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + surfIN.color = IN.lop_color; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + o.Normal = IN.normal; + surf( surfIN, o); + xll_clip( (o.Alpha - _Cutoff) ); + atten = unitySampleShadow( IN._ShadowCoord); + c = LightingLambert( o, _WorldSpaceLightPos0.xyz , atten); + c.xyz += (o.Albedo * IN.vlight); + c.w = o.Alpha; + return c; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec2( gl_TexCoord[0]); + xlt_IN.lop_color = vec4( gl_Color); + xlt_IN.normal = vec3( gl_TexCoord[1]); + xlt_IN.vlight = vec3( gl_TexCoord[2]); + xlt_IN._ShadowCoord = vec4( gl_TexCoord[3]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Details_WavingDoublePass-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Details_WavingDoublePass-ir.txt new file mode 100644 index 000000000..316aa104a --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Details_WavingDoublePass-ir.txt @@ -0,0 +1,192 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec4 color; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 lop_color; + vec3 normal; + vec3 vlight; + vec4 _ShadowCoord; +}; +varying vec4 xlv_FOG; +uniform vec4 _WorldSpaceLightPos0; +uniform sampler2D _ShadowMapTexture; +uniform sampler2D _MainTex; +uniform vec4 _LightColor0; +uniform float _Cutoff; +void xll_clip ( + in float x +) +{ + if ((x < 0.0)) { + discard; + }; +} + +float unitySampleShadow ( + in vec4 shadowCoord +) +{ + float shadow; + vec4 tmpvar_1; + tmpvar_1 = texture2DProj (_ShadowMapTexture, shadowCoord); + float tmpvar_2; + tmpvar_2 = tmpvar_1.x; + shadow = tmpvar_2; + return shadow; +} + +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 c; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = (tmpvar_1 * IN.color); + c = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = c.xyz; + o.Albedo = tmpvar_3; + float tmpvar_4; + tmpvar_4 = c.w; + o.Alpha = tmpvar_4; +} + +vec4 LightingLambert ( + in SurfaceOutput s, + in vec3 lightDir, + in float atten +) +{ + vec4 c; + float diff; + float tmpvar_1; + tmpvar_1 = dot (s.Normal, lightDir); + float tmpvar_2; + tmpvar_2 = max (0.0, tmpvar_1); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + diff = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = ((s.Albedo * _LightColor0.xyz) * ((diff * atten) * 2.0)); + c.xyz = tmpvar_4.xyz.xyz; + float tmpvar_5; + tmpvar_5 = s.Alpha; + c.w = vec4(tmpvar_5).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 c; + float atten; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = IN.lop_color; + surfIN.color = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Specular = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Alpha = tmpvar_6; + float tmpvar_7; + tmpvar_7 = 0.0; + o.Gloss = tmpvar_7; + vec3 tmpvar_8; + tmpvar_8 = IN.normal; + o.Normal = tmpvar_8; + surf (surfIN, o); + xll_clip ((o.Alpha - _Cutoff)); + float tmpvar_9; + tmpvar_9 = unitySampleShadow (IN._ShadowCoord); + float tmpvar_10; + tmpvar_10 = tmpvar_9; + atten = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = LightingLambert (o, _WorldSpaceLightPos0.xyz, atten); + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + c = tmpvar_12; + vec3 tmpvar_13; + tmpvar_13 = (c.xyz + (o.Albedo * IN.vlight)); + c.xyz = tmpvar_13.xyz.xyz; + float tmpvar_14; + tmpvar_14 = o.Alpha; + c.w = vec4(tmpvar_14).w; + return c; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xy; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = gl_Color.xyzw; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.lop_color = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = gl_TexCoord[1].xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.normal = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = gl_TexCoord[2].xyz; + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_IN.vlight = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_TexCoord[3].xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_IN._ShadowCoord = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = frag_surf (xlt_IN); + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_FragData[0] = tmpvar_16; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Details_WavingDoublePass-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Details_WavingDoublePass-out.txt new file mode 100644 index 000000000..f8ff66311 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Details_WavingDoublePass-out.txt @@ -0,0 +1,30 @@ +uniform vec4 _WorldSpaceLightPos0; +uniform sampler2D _ShadowMapTexture; +uniform sampler2D _MainTex; +uniform vec4 _LightColor0; +uniform float _Cutoff; +void main () +{ + vec3 tmpvar_1; + tmpvar_1 = gl_TexCoord[1].xyz; + vec3 tmpvar_2; + tmpvar_2 = gl_TexCoord[2].xyz; + vec4 tmpvar_3; + tmpvar_3 = gl_TexCoord[3]; + vec4 c; + vec4 tmpvar_4; + tmpvar_4 = (texture2D (_MainTex, gl_TexCoord[0].xy) * gl_Color); + float x; + x = (tmpvar_4.w - _Cutoff); + if ((x < 0.0)) { + discard; + }; + vec4 c_i0_i1; + c_i0_i1.xyz = ((tmpvar_4.xyz * _LightColor0.xyz) * ((max (0.0, dot (tmpvar_1, _WorldSpaceLightPos0.xyz)) * texture2DProj (_ShadowMapTexture, tmpvar_3).x) * 2.0)); + c_i0_i1.w = tmpvar_4.w; + c = c_i0_i1; + c.xyz = (c_i0_i1.xyz + (tmpvar_4.xyz * tmpvar_2)); + c.w = tmpvar_4.w; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Details_WavingDoublePass1-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Details_WavingDoublePass1-in.txt new file mode 100644 index 000000000..3c5a190d3 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Details_WavingDoublePass1-in.txt @@ -0,0 +1,110 @@ +void xll_clip(float x) { + if ( x<0.0 ) discard; +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +struct Input { + vec2 uv_MainTex; + vec4 color; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 lop_color; + vec3 normal; + vec3 lightDir; + vec4 _LightCoord; +}; +uniform float _Cutoff; +uniform vec4 _LightColor0; +uniform sampler2D _LightTexture0; +uniform sampler2D _LightTextureB0; +uniform sampler2D _MainTex; +void surf( in Input IN, inout SurfaceOutput o ); +float UnitySpotCookie( in vec4 LightCoord ); +float UnitySpotAttenuate( in vec3 LightCoord ); +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ); +vec4 frag_surf( in v2f_surf IN ); +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 c; + c = (texture2D( _MainTex, IN.uv_MainTex) * IN.color); + o.Albedo = c.xyz ; + o.Alpha = c.w ; +} +float UnitySpotCookie( in vec4 LightCoord ) { + return texture2D( _LightTexture0, ((LightCoord.xy / LightCoord.w ) + 0.500000)).w ; +} +float UnitySpotAttenuate( in vec3 LightCoord ) { + return texture2D( _LightTextureB0, vec2( vec2( dot( LightCoord, LightCoord)))).w ; +} +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ) { + float diff; + vec4 c; + diff = max( 0.000000, dot( s.Normal, lightDir)); + c.xyz = ((s.Albedo * _LightColor0.xyz ) * ((diff * atten) * 2.00000)); + c.w = s.Alpha; + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec3 lightDir; + vec4 c; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + surfIN.color = IN.lop_color; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + o.Normal = IN.normal; + surf( surfIN, o); + xll_clip( (o.Alpha - _Cutoff) ); + lightDir = IN.lightDir; + lightDir = normalize( lightDir ); + c = LightingLambert( o, lightDir, ((float( (IN._LightCoord.z > 0.000000) ) * UnitySpotCookie( IN._LightCoord)) * UnitySpotAttenuate( IN._LightCoord.xyz ))); + c.w = o.Alpha; + return c; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec2( gl_TexCoord[0]); + xlt_IN.lop_color = vec4( gl_Color); + xlt_IN.normal = vec3( gl_TexCoord[1]); + xlt_IN.lightDir = vec3( gl_TexCoord[2]); + xlt_IN._LightCoord = vec4( gl_TexCoord[3]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Details_WavingDoublePass1-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Details_WavingDoublePass1-ir.txt new file mode 100644 index 000000000..d1d47cbb4 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Details_WavingDoublePass1-ir.txt @@ -0,0 +1,207 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec4 color; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 lop_color; + vec3 normal; + vec3 lightDir; + vec4 _LightCoord; +}; +varying vec4 xlv_FOG; +uniform sampler2D _MainTex; +uniform sampler2D _LightTextureB0; +uniform sampler2D _LightTexture0; +uniform vec4 _LightColor0; +uniform float _Cutoff; +void xll_clip ( + in float x +) +{ + if ((x < 0.0)) { + discard; + }; +} + +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 c; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = (tmpvar_1 * IN.color); + c = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = c.xyz; + o.Albedo = tmpvar_3; + float tmpvar_4; + tmpvar_4 = c.w; + o.Alpha = tmpvar_4; +} + +float UnitySpotCookie ( + in vec4 LightCoord +) +{ + vec4 tmpvar_1; + tmpvar_1 = texture2D (_LightTexture0, ((LightCoord.xy / LightCoord.w) + 0.5)); + return tmpvar_1.w; +} + +float UnitySpotAttenuate ( + in vec3 LightCoord +) +{ + float tmpvar_1; + tmpvar_1 = dot (LightCoord, LightCoord); + vec2 tmpvar_2; + tmpvar_2 = vec2(tmpvar_1); + vec2 tmpvar_3; + tmpvar_3 = tmpvar_2.xy; + vec4 tmpvar_4; + tmpvar_4 = texture2D (_LightTextureB0, tmpvar_3); + return tmpvar_4.w; +} + +vec4 LightingLambert ( + in SurfaceOutput s, + in vec3 lightDir, + in float atten +) +{ + vec4 c; + float diff; + float tmpvar_1; + tmpvar_1 = dot (s.Normal, lightDir); + float tmpvar_2; + tmpvar_2 = max (0.0, tmpvar_1); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + diff = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = ((s.Albedo * _LightColor0.xyz) * ((diff * atten) * 2.0)); + c.xyz = tmpvar_4.xyz.xyz; + float tmpvar_5; + tmpvar_5 = s.Alpha; + c.w = vec4(tmpvar_5).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 c; + vec3 lightDir; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = IN.lop_color; + surfIN.color = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Specular = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Alpha = tmpvar_6; + float tmpvar_7; + tmpvar_7 = 0.0; + o.Gloss = tmpvar_7; + vec3 tmpvar_8; + tmpvar_8 = IN.normal; + o.Normal = tmpvar_8; + surf (surfIN, o); + xll_clip ((o.Alpha - _Cutoff)); + vec3 tmpvar_9; + tmpvar_9 = IN.lightDir; + lightDir = tmpvar_9; + vec3 tmpvar_10; + tmpvar_10 = normalize (lightDir); + vec3 tmpvar_11; + tmpvar_11 = tmpvar_10; + lightDir = tmpvar_11; + float tmpvar_12; + tmpvar_12 = UnitySpotCookie (IN._LightCoord); + float tmpvar_13; + tmpvar_13 = UnitySpotAttenuate (IN._LightCoord.xyz); + vec4 tmpvar_14; + tmpvar_14 = LightingLambert (o, lightDir, ((float((IN._LightCoord.z > 0.0)) * tmpvar_12) * tmpvar_13)); + vec4 tmpvar_15; + tmpvar_15 = tmpvar_14; + c = tmpvar_15; + float tmpvar_16; + tmpvar_16 = o.Alpha; + c.w = vec4(tmpvar_16).w; + return c; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xy; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = gl_Color.xyzw; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.lop_color = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = gl_TexCoord[1].xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.normal = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = gl_TexCoord[2].xyz; + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_IN.lightDir = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_TexCoord[3].xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_IN._LightCoord = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = frag_surf (xlt_IN); + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_FragData[0] = tmpvar_16; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Details_WavingDoublePass1-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Details_WavingDoublePass1-out.txt new file mode 100644 index 000000000..9eebee1b1 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Details_WavingDoublePass1-out.txt @@ -0,0 +1,31 @@ +uniform sampler2D _MainTex; +uniform sampler2D _LightTextureB0; +uniform sampler2D _LightTexture0; +uniform vec4 _LightColor0; +uniform float _Cutoff; +void main () +{ + vec3 tmpvar_1; + tmpvar_1 = gl_TexCoord[1].xyz; + vec3 tmpvar_2; + tmpvar_2 = gl_TexCoord[2].xyz; + vec4 tmpvar_3; + tmpvar_3 = gl_TexCoord[3]; + vec4 c; + vec4 tmpvar_4; + tmpvar_4 = (texture2D (_MainTex, gl_TexCoord[0].xy) * gl_Color); + float x; + x = (tmpvar_4.w - _Cutoff); + if ((x < 0.0)) { + discard; + }; + vec3 LightCoord_i0; + LightCoord_i0 = tmpvar_3.xyz; + vec4 c_i0_i1; + c_i0_i1.xyz = ((tmpvar_4.xyz * _LightColor0.xyz) * ((max (0.0, dot (tmpvar_1, normalize (tmpvar_2))) * ((float((tmpvar_3.z > 0.0)) * texture2D (_LightTexture0, ((tmpvar_3.xy / tmpvar_3.w) + 0.5)).w) * texture2D (_LightTextureB0, vec2(dot (LightCoord_i0, LightCoord_i0))).w)) * 2.0)); + c_i0_i1.w = tmpvar_4.w; + c = c_i0_i1; + c.w = tmpvar_4.w; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Details_WavingDoublePass2-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Details_WavingDoublePass2-in.txt new file mode 100644 index 000000000..bf5bd9d3d --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Details_WavingDoublePass2-in.txt @@ -0,0 +1,94 @@ +void xll_clip(float x) { + if ( x<0.0 ) discard; +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +struct Input { + vec2 uv_MainTex; + vec4 color; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 lop_color; + vec4 hip_screen; +}; +uniform float _Cutoff; +uniform sampler2D _LightBuffer; +uniform sampler2D _MainTex; +uniform vec4 unity_Ambient; +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingLambert_PrePass( in SurfaceOutput s, in vec4 light ); +vec4 frag_surf( in v2f_surf IN ); +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 c; + c = (texture2D( _MainTex, IN.uv_MainTex) * IN.color); + o.Albedo = c.xyz ; + o.Alpha = c.w ; +} +vec4 LightingLambert_PrePass( in SurfaceOutput s, in vec4 light ) { + vec4 c; + c.xyz = (s.Albedo * light.xyz ); + c.w = s.Alpha; + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec4 light; + vec4 col; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + surfIN.color = IN.lop_color; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + surf( surfIN, o); + xll_clip( (o.Alpha - _Cutoff) ); + light = texture2DProj( _LightBuffer, IN.hip_screen); + light = ( -log2( light ) ); + light.xyz += unity_Ambient.xyz ; + col = LightingLambert_PrePass( o, light); + return col; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec2( gl_TexCoord[0]); + xlt_IN.lop_color = vec4( gl_Color); + xlt_IN.hip_screen = vec4( gl_TexCoord[1]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Details_WavingDoublePass2-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Details_WavingDoublePass2-ir.txt new file mode 100644 index 000000000..6346d95b8 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Details_WavingDoublePass2-ir.txt @@ -0,0 +1,156 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec4 color; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 lop_color; + vec4 hip_screen; +}; +varying vec4 xlv_FOG; +uniform vec4 unity_Ambient; +uniform sampler2D _MainTex; +uniform sampler2D _LightBuffer; +uniform float _Cutoff; +void xll_clip ( + in float x +) +{ + if ((x < 0.0)) { + discard; + }; +} + +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 c; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = (tmpvar_1 * IN.color); + c = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = c.xyz; + o.Albedo = tmpvar_3; + float tmpvar_4; + tmpvar_4 = c.w; + o.Alpha = tmpvar_4; +} + +vec4 LightingLambert_PrePass ( + in SurfaceOutput s, + in vec4 light +) +{ + vec4 c; + vec3 tmpvar_1; + tmpvar_1 = (s.Albedo * light.xyz); + c.xyz = tmpvar_1.xyz.xyz; + float tmpvar_2; + tmpvar_2 = s.Alpha; + c.w = vec4(tmpvar_2).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 col; + vec4 light; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = IN.lop_color; + surfIN.color = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Specular = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Alpha = tmpvar_6; + float tmpvar_7; + tmpvar_7 = 0.0; + o.Gloss = tmpvar_7; + surf (surfIN, o); + xll_clip ((o.Alpha - _Cutoff)); + vec4 tmpvar_8; + tmpvar_8 = texture2DProj (_LightBuffer, IN.hip_screen); + vec4 tmpvar_9; + tmpvar_9 = tmpvar_8; + light = tmpvar_9; + vec4 tmpvar_10; + tmpvar_10 = log2 (light); + vec4 tmpvar_11; + tmpvar_11 = -(tmpvar_10); + light = tmpvar_11; + vec3 tmpvar_12; + tmpvar_12 = (light.xyz + unity_Ambient.xyz); + light.xyz = tmpvar_12.xyz.xyz; + vec4 tmpvar_13; + tmpvar_13 = LightingLambert_PrePass (o, light); + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + col = tmpvar_14; + return col; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xy; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = gl_Color.xyzw; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.lop_color = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_TexCoord[1].xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.hip_screen = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = frag_surf (xlt_IN); + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xl_retval = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = xl_retval.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + gl_FragData[0] = tmpvar_12; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Details_WavingDoublePass2-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Details_WavingDoublePass2-out.txt new file mode 100644 index 000000000..f3656c05a --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Details_WavingDoublePass2-out.txt @@ -0,0 +1,26 @@ +uniform vec4 unity_Ambient; +uniform sampler2D _MainTex; +uniform sampler2D _LightBuffer; +uniform float _Cutoff; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = gl_TexCoord[1]; + vec4 light; + vec4 tmpvar_2; + tmpvar_2 = (texture2D (_MainTex, gl_TexCoord[0].xy) * gl_Color); + float x; + x = (tmpvar_2.w - _Cutoff); + if ((x < 0.0)) { + discard; + }; + vec4 tmpvar_3; + tmpvar_3 = -(log2 (texture2DProj (_LightBuffer, tmpvar_1))); + light = tmpvar_3; + light.xyz = (tmpvar_3.xyz + unity_Ambient.xyz); + vec4 c_i0; + c_i0.xyz = (tmpvar_2.xyz * light.xyz); + c_i0.w = tmpvar_2.w; + gl_FragData[0] = c_i0; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_My_Soft_Occlusion_Leaves_rendertex-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_My_Soft_Occlusion_Leaves_rendertex-in.txt new file mode 100644 index 000000000..32bc7b712 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_My_Soft_Occlusion_Leaves_rendertex-in.txt @@ -0,0 +1,37 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct v2f { + vec4 vertex; + vec4 color; + vec2 texcoord; +}; +struct appdata_t { + vec4 vertex; + vec4 color; + vec2 texcoord; +}; +uniform sampler2D _MainTex; +vec4 frag( in v2f i ); +vec4 frag( in v2f i ) { + return (texture2D( _MainTex, i.texcoord) * vec4( 1.00000, 0.000000, 0.000000, 1.00000)); +} +void main() { + vec4 xl_retval; + v2f xlt_i; + xlt_i.vertex = vec4(0.0); + xlt_i.color = vec4( gl_Color); + xlt_i.texcoord = vec2( gl_TexCoord[0]); + xl_retval = frag( xlt_i); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_My_Soft_Occlusion_Leaves_rendertex-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_My_Soft_Occlusion_Leaves_rendertex-ir.txt new file mode 100644 index 000000000..3ae052ffa --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_My_Soft_Occlusion_Leaves_rendertex-ir.txt @@ -0,0 +1,44 @@ +struct v2f { + vec4 vertex; + vec4 color; + vec2 texcoord; +}; +uniform sampler2D _MainTex; +vec4 frag ( + in v2f i +) +{ + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, i.texcoord); + return (tmpvar_1 * vec4(1.0, 0.0, 0.0, 1.0)); +} + +void main () +{ + v2f xlt_i; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_i.vertex = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = gl_Color.xyzw; + vec4 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_i.color = tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = gl_TexCoord[0].xy; + vec2 tmpvar_5; + tmpvar_5 = tmpvar_4; + xlt_i.texcoord = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = frag (xlt_i); + vec4 tmpvar_7; + tmpvar_7 = tmpvar_6; + xl_retval = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = xl_retval.xyzw; + vec4 tmpvar_9; + tmpvar_9 = tmpvar_8; + gl_FragData[0] = tmpvar_9; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_My_Soft_Occlusion_Leaves_rendertex-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_My_Soft_Occlusion_Leaves_rendertex-out.txt new file mode 100644 index 000000000..4a7488099 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_My_Soft_Occlusion_Leaves_rendertex-out.txt @@ -0,0 +1,6 @@ +uniform sampler2D _MainTex; +void main () +{ + gl_FragData[0] = (texture2D (_MainTex, gl_TexCoord[0].xy) * vec4(1.0, 0.0, 0.0, 1.0)); +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Soft_Occlusion_Bark_rendertex-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Soft_Occlusion_Bark_rendertex-in.txt new file mode 100644 index 000000000..8c08479f4 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Soft_Occlusion_Bark_rendertex-in.txt @@ -0,0 +1,45 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct v2f { + vec4 pos; + float fog; + vec4 uv; + vec4 color; +}; +struct appdata_tree { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 color; + vec4 texcoord; +}; +uniform sampler2D _MainTex; +vec4 frag( in v2f xlat_var_input ); +vec4 frag( in v2f xlat_var_input ) { + vec4 col; + col = xlat_var_input.color; + col.xyz *= (2.00000 * texture2D( _MainTex, xlat_var_input.uv.xy ).xyz ); + return col; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f xlt_xlat_var_input; + xlt_xlat_var_input.pos = vec4(0.0); + xlt_xlat_var_input.fog = float( xlv_FOG); + xlt_xlat_var_input.uv = vec4( gl_TexCoord[0]); + xlt_xlat_var_input.color = vec4( gl_Color); + xl_retval = frag( xlt_xlat_var_input); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Soft_Occlusion_Bark_rendertex-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Soft_Occlusion_Bark_rendertex-ir.txt new file mode 100644 index 000000000..4d7e39e52 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Soft_Occlusion_Bark_rendertex-ir.txt @@ -0,0 +1,56 @@ +struct v2f { + vec4 pos; + float fog; + vec4 uv; + vec4 color; +}; +varying vec4 xlv_FOG; +uniform sampler2D _MainTex; +vec4 frag ( + in v2f xlat_var_input +) +{ + vec4 col; + vec4 tmpvar_1; + tmpvar_1 = xlat_var_input.color; + col = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = texture2D (_MainTex, xlat_var_input.uv.xy); + vec3 tmpvar_3; + tmpvar_3 = (col.xyz * (2.0 * tmpvar_2.xyz)); + col.xyz = tmpvar_3.xyz.xyz; + return col; +} + +void main () +{ + v2f xlt_xlat_var_input; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_xlat_var_input.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_xlat_var_input.fog = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_xlat_var_input.uv = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = gl_Color.xyzw; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_xlat_var_input.color = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = frag (xlt_xlat_var_input); + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xl_retval = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = xl_retval.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + gl_FragData[0] = tmpvar_10; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Soft_Occlusion_Bark_rendertex-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Soft_Occlusion_Bark_rendertex-out.txt new file mode 100644 index 000000000..ca5e05b22 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Soft_Occlusion_Bark_rendertex-out.txt @@ -0,0 +1,9 @@ +uniform sampler2D _MainTex; +void main () +{ + vec4 col; + col = gl_Color; + col.xyz = (gl_Color.xyz * (2.0 * texture2D (_MainTex, gl_TexCoord[0].xy).xyz)); + gl_FragData[0] = col; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Soft_Occlusion_Leaves_rendertex-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Soft_Occlusion_Leaves_rendertex-in.txt new file mode 100644 index 000000000..146a19c54 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Soft_Occlusion_Leaves_rendertex-in.txt @@ -0,0 +1,51 @@ +void xll_clip(float x) { + if ( x<0.0 ) discard; +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct v2f { + vec4 pos; + float fog; + vec4 uv; + vec4 color; +}; +struct appdata_tree { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 color; + vec4 texcoord; +}; +uniform float _HalfOverCutoff; +uniform sampler2D _MainTex; +vec4 frag( in v2f xlat_var_input ); +vec4 frag( in v2f xlat_var_input ) { + vec4 col; + col = texture2D( _MainTex, xlat_var_input.uv.xy ); + col.xyz *= (2.00000 * xlat_var_input.color.xyz ); + col.w *= (2.00000 * _HalfOverCutoff); + xll_clip( (col.w - 1.00000) ); + return col; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f xlt_xlat_var_input; + xlt_xlat_var_input.pos = vec4(0.0); + xlt_xlat_var_input.fog = float( xlv_FOG); + xlt_xlat_var_input.uv = vec4( gl_TexCoord[0]); + xlt_xlat_var_input.color = vec4( gl_Color); + xl_retval = frag( xlt_xlat_var_input); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Soft_Occlusion_Leaves_rendertex-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Soft_Occlusion_Leaves_rendertex-ir.txt new file mode 100644 index 000000000..1c8ef8770 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Soft_Occlusion_Leaves_rendertex-ir.txt @@ -0,0 +1,70 @@ +struct v2f { + vec4 pos; + float fog; + vec4 uv; + vec4 color; +}; +varying vec4 xlv_FOG; +uniform sampler2D _MainTex; +uniform float _HalfOverCutoff; +void xll_clip ( + in float x +) +{ + if ((x < 0.0)) { + discard; + }; +} + +vec4 frag ( + in v2f xlat_var_input +) +{ + vec4 col; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, xlat_var_input.uv.xy); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + col = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = (col.xyz * (2.0 * xlat_var_input.color.xyz)); + col.xyz = tmpvar_3.xyz.xyz; + float tmpvar_4; + tmpvar_4 = (col.w * (2.0 * _HalfOverCutoff)); + col.w = vec4(tmpvar_4).w; + xll_clip ((col.w - 1.0)); + return col; +} + +void main () +{ + v2f xlt_xlat_var_input; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_xlat_var_input.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_xlat_var_input.fog = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_xlat_var_input.uv = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = gl_Color.xyzw; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_xlat_var_input.color = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = frag (xlt_xlat_var_input); + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xl_retval = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = xl_retval.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + gl_FragData[0] = tmpvar_10; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Soft_Occlusion_Leaves_rendertex-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Soft_Occlusion_Leaves_rendertex-out.txt new file mode 100644 index 000000000..3bf9ed00c --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Soft_Occlusion_Leaves_rendertex-out.txt @@ -0,0 +1,18 @@ +uniform sampler2D _MainTex; +uniform float _HalfOverCutoff; +void main () +{ + vec4 col; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, gl_TexCoord[0].xy); + col = tmpvar_1; + col.xyz = (tmpvar_1.xyz * (2.0 * gl_Color.xyz)); + col.w = (tmpvar_1.w * (2.0 * _HalfOverCutoff)); + float x; + x = (col.w - 1.0); + if ((x < 0.0)) { + discard; + }; + gl_FragData[0] = col; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Splatmap_Lightmap-AddPass-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Splatmap_Lightmap-AddPass-in.txt new file mode 100644 index 000000000..5bd09fdde --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Splatmap_Lightmap-AddPass-in.txt @@ -0,0 +1,119 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_Control; + vec2 uv_Splat0; + vec2 uv_Splat1; + vec2 uv_Splat2; + vec2 uv_Splat3; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec4 hip_pack1; + vec2 hip_pack2; + vec3 normal; + vec3 vlight; + vec4 _ShadowCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform sampler2D _Control; +uniform vec4 _LightColor0; +uniform sampler2D _ShadowMapTexture; +uniform sampler2D _Splat0; +uniform sampler2D _Splat1; +uniform sampler2D _Splat2; +uniform sampler2D _Splat3; +uniform vec4 _WorldSpaceLightPos0; +float unitySampleShadow( in vec4 shadowCoord ); +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ); +vec4 frag_surf( in v2f_surf IN ); +float unitySampleShadow( in vec4 shadowCoord ) { + float shadow; + shadow = texture2DProj( _ShadowMapTexture, shadowCoord).x ; + return shadow; +} +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 splat_control; + vec3 col; + splat_control = texture2D( _Control, IN.uv_Control); + col = (splat_control.x * texture2D( _Splat0, IN.uv_Splat0).xyz ); + col += (splat_control.y * texture2D( _Splat1, IN.uv_Splat1).xyz ); + col += (splat_control.z * texture2D( _Splat2, IN.uv_Splat2).xyz ); + col += (splat_control.w * texture2D( _Splat3, IN.uv_Splat3).xyz ); + o.Albedo = col; + o.Alpha = 0.000000; +} +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ) { + float diff; + vec4 c; + diff = max( 0.000000, dot( s.Normal, lightDir)); + c.xyz = ((s.Albedo * _LightColor0.xyz ) * ((diff * atten) * 2.00000)); + c.w = s.Alpha; + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + float atten; + vec4 c; + surfIN.uv_Control = IN.hip_pack0.xy ; + surfIN.uv_Splat0 = IN.hip_pack0.zw ; + surfIN.uv_Splat1 = IN.hip_pack1.xy ; + surfIN.uv_Splat2 = IN.hip_pack1.zw ; + surfIN.uv_Splat3 = IN.hip_pack2.xy ; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + o.Normal = IN.normal; + surf( surfIN, o); + atten = unitySampleShadow( IN._ShadowCoord); + c = LightingLambert( o, _WorldSpaceLightPos0.xyz , atten); + c.xyz += (o.Albedo * IN.vlight); + return c; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec4( gl_TexCoord[0]); + xlt_IN.hip_pack1 = vec4( gl_TexCoord[1]); + xlt_IN.hip_pack2 = vec2( gl_TexCoord[2]); + xlt_IN.normal = vec3( gl_TexCoord[3]); + xlt_IN.vlight = vec3( gl_TexCoord[4]); + xlt_IN._ShadowCoord = vec4( gl_TexCoord[5]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Splatmap_Lightmap-AddPass-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Splatmap_Lightmap-AddPass-ir.txt new file mode 100644 index 000000000..13bec1045 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Splatmap_Lightmap-AddPass-ir.txt @@ -0,0 +1,221 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_Control; + vec2 uv_Splat0; + vec2 uv_Splat1; + vec2 uv_Splat2; + vec2 uv_Splat3; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec4 hip_pack1; + vec2 hip_pack2; + vec3 normal; + vec3 vlight; + vec4 _ShadowCoord; +}; +varying vec4 xlv_FOG; +uniform vec4 _WorldSpaceLightPos0; +uniform sampler2D _Splat3; +uniform sampler2D _Splat2; +uniform sampler2D _Splat1; +uniform sampler2D _Splat0; +uniform sampler2D _ShadowMapTexture; +uniform vec4 _LightColor0; +uniform sampler2D _Control; +float unitySampleShadow ( + in vec4 shadowCoord +) +{ + float shadow; + vec4 tmpvar_1; + tmpvar_1 = texture2DProj (_ShadowMapTexture, shadowCoord); + float tmpvar_2; + tmpvar_2 = tmpvar_1.x; + shadow = tmpvar_2; + return shadow; +} + +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec3 col; + vec4 splat_control; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_Control, IN.uv_Control); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + splat_control = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = texture2D (_Splat0, IN.uv_Splat0); + vec3 tmpvar_4; + tmpvar_4 = (splat_control.x * tmpvar_3.xyz); + col = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = texture2D (_Splat1, IN.uv_Splat1); + vec3 tmpvar_6; + tmpvar_6 = (col + (splat_control.y * tmpvar_5.xyz)); + col = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = texture2D (_Splat2, IN.uv_Splat2); + vec3 tmpvar_8; + tmpvar_8 = (col + (splat_control.z * tmpvar_7.xyz)); + col = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = texture2D (_Splat3, IN.uv_Splat3); + vec3 tmpvar_10; + tmpvar_10 = (col + (splat_control.w * tmpvar_9.xyz)); + col = tmpvar_10; + vec3 tmpvar_11; + tmpvar_11 = col; + o.Albedo = tmpvar_11; + float tmpvar_12; + tmpvar_12 = 0.0; + o.Alpha = tmpvar_12; +} + +vec4 LightingLambert ( + in SurfaceOutput s, + in vec3 lightDir, + in float atten +) +{ + vec4 c; + float diff; + float tmpvar_1; + tmpvar_1 = dot (s.Normal, lightDir); + float tmpvar_2; + tmpvar_2 = max (0.0, tmpvar_1); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + diff = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = ((s.Albedo * _LightColor0.xyz) * ((diff * atten) * 2.0)); + c.xyz = tmpvar_4.xyz.xyz; + float tmpvar_5; + tmpvar_5 = s.Alpha; + c.w = vec4(tmpvar_5).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 c; + float atten; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_Control = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = IN.hip_pack0.zw; + surfIN.uv_Splat0 = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = IN.hip_pack1.xy; + surfIN.uv_Splat1 = tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = IN.hip_pack1.zw; + surfIN.uv_Splat2 = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5 = IN.hip_pack2.xy; + surfIN.uv_Splat3 = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_7; + float tmpvar_8; + tmpvar_8 = 0.0; + o.Specular = tmpvar_8; + float tmpvar_9; + tmpvar_9 = 0.0; + o.Alpha = tmpvar_9; + float tmpvar_10; + tmpvar_10 = 0.0; + o.Gloss = tmpvar_10; + vec3 tmpvar_11; + tmpvar_11 = IN.normal; + o.Normal = tmpvar_11; + surf (surfIN, o); + float tmpvar_12; + tmpvar_12 = unitySampleShadow (IN._ShadowCoord); + float tmpvar_13; + tmpvar_13 = tmpvar_12; + atten = tmpvar_13; + vec4 tmpvar_14; + tmpvar_14 = LightingLambert (o, _WorldSpaceLightPos0.xyz, atten); + vec4 tmpvar_15; + tmpvar_15 = tmpvar_14; + c = tmpvar_15; + vec3 tmpvar_16; + tmpvar_16 = (c.xyz + (o.Albedo * IN.vlight)); + c.xyz = tmpvar_16.xyz.xyz; + return c; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyzw; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.hip_pack1 = tmpvar_6; + vec2 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xy; + vec2 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.hip_pack2 = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = gl_TexCoord[3].xyz; + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_IN.normal = tmpvar_10; + vec3 tmpvar_11; + tmpvar_11 = gl_TexCoord[4].xyz; + vec3 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_IN.vlight = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = gl_TexCoord[5].xyzw; + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + xlt_IN._ShadowCoord = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = frag_surf (xlt_IN); + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + xl_retval = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17 = xl_retval.xyzw; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + gl_FragData[0] = tmpvar_18; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Splatmap_Lightmap-AddPass-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Splatmap_Lightmap-AddPass-out.txt new file mode 100644 index 000000000..c24720f04 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Splatmap_Lightmap-AddPass-out.txt @@ -0,0 +1,27 @@ +uniform vec4 _WorldSpaceLightPos0; +uniform sampler2D _Splat3; +uniform sampler2D _Splat2; +uniform sampler2D _Splat1; +uniform sampler2D _Splat0; +uniform sampler2D _ShadowMapTexture; +uniform vec4 _LightColor0; +uniform sampler2D _Control; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = gl_TexCoord[0]; + vec4 tmpvar_2; + tmpvar_2 = gl_TexCoord[1]; + vec4 c; + vec4 tmpvar_3; + tmpvar_3 = texture2D (_Control, tmpvar_1.xy); + vec3 tmpvar_4; + tmpvar_4 = ((((tmpvar_3.x * texture2D (_Splat0, tmpvar_1.zw).xyz) + (tmpvar_3.y * texture2D (_Splat1, tmpvar_2.xy).xyz)) + (tmpvar_3.z * texture2D (_Splat2, tmpvar_2.zw).xyz)) + (tmpvar_3.w * texture2D (_Splat3, gl_TexCoord[2].xy).xyz)); + vec4 c_i0; + c_i0.xyz = ((tmpvar_4 * _LightColor0.xyz) * ((max (0.0, dot (gl_TexCoord[3].xyz, _WorldSpaceLightPos0.xyz)) * texture2DProj (_ShadowMapTexture, gl_TexCoord[5]).x) * 2.0)); + c_i0.w = 0.0; + c = c_i0; + c.xyz = (c_i0.xyz + (tmpvar_4 * gl_TexCoord[4].xyz)); + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Splatmap_Lightmap-AddPass1-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Splatmap_Lightmap-AddPass1-in.txt new file mode 100644 index 000000000..7906335fc --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Splatmap_Lightmap-AddPass1-in.txt @@ -0,0 +1,106 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_Control; + vec2 uv_Splat0; + vec2 uv_Splat1; + vec2 uv_Splat2; + vec2 uv_Splat3; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec4 hip_pack1; + vec2 hip_pack2; + vec4 hip_screen; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform sampler2D _Control; +uniform sampler2D _LightBuffer; +uniform sampler2D _Splat0; +uniform sampler2D _Splat1; +uniform sampler2D _Splat2; +uniform sampler2D _Splat3; +uniform vec4 unity_Ambient; +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingLambert_PrePass( in SurfaceOutput s, in vec4 light ); +vec4 frag_surf( in v2f_surf IN ); +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 splat_control; + vec3 col; + splat_control = texture2D( _Control, IN.uv_Control); + col = (splat_control.x * texture2D( _Splat0, IN.uv_Splat0).xyz ); + col += (splat_control.y * texture2D( _Splat1, IN.uv_Splat1).xyz ); + col += (splat_control.z * texture2D( _Splat2, IN.uv_Splat2).xyz ); + col += (splat_control.w * texture2D( _Splat3, IN.uv_Splat3).xyz ); + o.Albedo = col; + o.Alpha = 0.000000; +} +vec4 LightingLambert_PrePass( in SurfaceOutput s, in vec4 light ) { + vec4 c; + c.xyz = (s.Albedo * light.xyz ); + c.w = s.Alpha; + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec4 light; + vec4 col; + surfIN.uv_Control = IN.hip_pack0.xy ; + surfIN.uv_Splat0 = IN.hip_pack0.zw ; + surfIN.uv_Splat1 = IN.hip_pack1.xy ; + surfIN.uv_Splat2 = IN.hip_pack1.zw ; + surfIN.uv_Splat3 = IN.hip_pack2.xy ; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + surf( surfIN, o); + light = texture2DProj( _LightBuffer, IN.hip_screen); + light = ( -log2( light ) ); + light.xyz += unity_Ambient.xyz ; + col = LightingLambert_PrePass( o, light); + return col; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec4( gl_TexCoord[0]); + xlt_IN.hip_pack1 = vec4( gl_TexCoord[1]); + xlt_IN.hip_pack2 = vec2( gl_TexCoord[2]); + xlt_IN.hip_screen = vec4( gl_TexCoord[3]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Splatmap_Lightmap-AddPass1-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Splatmap_Lightmap-AddPass1-ir.txt new file mode 100644 index 000000000..399baf05d --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Splatmap_Lightmap-AddPass1-ir.txt @@ -0,0 +1,188 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_Control; + vec2 uv_Splat0; + vec2 uv_Splat1; + vec2 uv_Splat2; + vec2 uv_Splat3; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec4 hip_pack1; + vec2 hip_pack2; + vec4 hip_screen; +}; +varying vec4 xlv_FOG; +uniform vec4 unity_Ambient; +uniform sampler2D _Splat3; +uniform sampler2D _Splat2; +uniform sampler2D _Splat1; +uniform sampler2D _Splat0; +uniform sampler2D _LightBuffer; +uniform sampler2D _Control; +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec3 col; + vec4 splat_control; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_Control, IN.uv_Control); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + splat_control = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = texture2D (_Splat0, IN.uv_Splat0); + vec3 tmpvar_4; + tmpvar_4 = (splat_control.x * tmpvar_3.xyz); + col = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = texture2D (_Splat1, IN.uv_Splat1); + vec3 tmpvar_6; + tmpvar_6 = (col + (splat_control.y * tmpvar_5.xyz)); + col = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = texture2D (_Splat2, IN.uv_Splat2); + vec3 tmpvar_8; + tmpvar_8 = (col + (splat_control.z * tmpvar_7.xyz)); + col = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = texture2D (_Splat3, IN.uv_Splat3); + vec3 tmpvar_10; + tmpvar_10 = (col + (splat_control.w * tmpvar_9.xyz)); + col = tmpvar_10; + vec3 tmpvar_11; + tmpvar_11 = col; + o.Albedo = tmpvar_11; + float tmpvar_12; + tmpvar_12 = 0.0; + o.Alpha = tmpvar_12; +} + +vec4 LightingLambert_PrePass ( + in SurfaceOutput s, + in vec4 light +) +{ + vec4 c; + vec3 tmpvar_1; + tmpvar_1 = (s.Albedo * light.xyz); + c.xyz = tmpvar_1.xyz.xyz; + float tmpvar_2; + tmpvar_2 = s.Alpha; + c.w = vec4(tmpvar_2).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 col; + vec4 light; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_Control = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = IN.hip_pack0.zw; + surfIN.uv_Splat0 = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = IN.hip_pack1.xy; + surfIN.uv_Splat1 = tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = IN.hip_pack1.zw; + surfIN.uv_Splat2 = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5 = IN.hip_pack2.xy; + surfIN.uv_Splat3 = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_7; + float tmpvar_8; + tmpvar_8 = 0.0; + o.Specular = tmpvar_8; + float tmpvar_9; + tmpvar_9 = 0.0; + o.Alpha = tmpvar_9; + float tmpvar_10; + tmpvar_10 = 0.0; + o.Gloss = tmpvar_10; + surf (surfIN, o); + vec4 tmpvar_11; + tmpvar_11 = texture2DProj (_LightBuffer, IN.hip_screen); + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + light = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = log2 (light); + vec4 tmpvar_14; + tmpvar_14 = -(tmpvar_13); + light = tmpvar_14; + vec3 tmpvar_15; + tmpvar_15 = (light.xyz + unity_Ambient.xyz); + light.xyz = tmpvar_15.xyz.xyz; + vec4 tmpvar_16; + tmpvar_16 = LightingLambert_PrePass (o, light); + vec4 tmpvar_17; + tmpvar_17 = tmpvar_16; + col = tmpvar_17; + return col; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyzw; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.hip_pack1 = tmpvar_6; + vec2 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xy; + vec2 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.hip_pack2 = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_TexCoord[3].xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_IN.hip_screen = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = frag_surf (xlt_IN); + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xl_retval = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = xl_retval.xyzw; + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + gl_FragData[0] = tmpvar_14; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Splatmap_Lightmap-AddPass1-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Splatmap_Lightmap-AddPass1-out.txt new file mode 100644 index 000000000..f7ff6a003 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Splatmap_Lightmap-AddPass1-out.txt @@ -0,0 +1,26 @@ +uniform vec4 unity_Ambient; +uniform sampler2D _Splat3; +uniform sampler2D _Splat2; +uniform sampler2D _Splat1; +uniform sampler2D _Splat0; +uniform sampler2D _LightBuffer; +uniform sampler2D _Control; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = gl_TexCoord[0]; + vec4 tmpvar_2; + tmpvar_2 = gl_TexCoord[1]; + vec4 light; + vec4 tmpvar_3; + tmpvar_3 = texture2D (_Control, tmpvar_1.xy); + vec4 tmpvar_4; + tmpvar_4 = -(log2 (texture2DProj (_LightBuffer, gl_TexCoord[3]))); + light = tmpvar_4; + light.xyz = (tmpvar_4.xyz + unity_Ambient.xyz); + vec4 c; + c.xyz = (((((tmpvar_3.x * texture2D (_Splat0, tmpvar_1.zw).xyz) + (tmpvar_3.y * texture2D (_Splat1, tmpvar_2.xy).xyz)) + (tmpvar_3.z * texture2D (_Splat2, tmpvar_2.zw).xyz)) + (tmpvar_3.w * texture2D (_Splat3, gl_TexCoord[2].xy).xyz)) * light.xyz); + c.w = 0.0; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Splatmap_Lightmap-FirstPass-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Splatmap_Lightmap-FirstPass-in.txt new file mode 100644 index 000000000..7906335fc --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Splatmap_Lightmap-FirstPass-in.txt @@ -0,0 +1,106 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_Control; + vec2 uv_Splat0; + vec2 uv_Splat1; + vec2 uv_Splat2; + vec2 uv_Splat3; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec4 hip_pack1; + vec2 hip_pack2; + vec4 hip_screen; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform sampler2D _Control; +uniform sampler2D _LightBuffer; +uniform sampler2D _Splat0; +uniform sampler2D _Splat1; +uniform sampler2D _Splat2; +uniform sampler2D _Splat3; +uniform vec4 unity_Ambient; +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingLambert_PrePass( in SurfaceOutput s, in vec4 light ); +vec4 frag_surf( in v2f_surf IN ); +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 splat_control; + vec3 col; + splat_control = texture2D( _Control, IN.uv_Control); + col = (splat_control.x * texture2D( _Splat0, IN.uv_Splat0).xyz ); + col += (splat_control.y * texture2D( _Splat1, IN.uv_Splat1).xyz ); + col += (splat_control.z * texture2D( _Splat2, IN.uv_Splat2).xyz ); + col += (splat_control.w * texture2D( _Splat3, IN.uv_Splat3).xyz ); + o.Albedo = col; + o.Alpha = 0.000000; +} +vec4 LightingLambert_PrePass( in SurfaceOutput s, in vec4 light ) { + vec4 c; + c.xyz = (s.Albedo * light.xyz ); + c.w = s.Alpha; + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec4 light; + vec4 col; + surfIN.uv_Control = IN.hip_pack0.xy ; + surfIN.uv_Splat0 = IN.hip_pack0.zw ; + surfIN.uv_Splat1 = IN.hip_pack1.xy ; + surfIN.uv_Splat2 = IN.hip_pack1.zw ; + surfIN.uv_Splat3 = IN.hip_pack2.xy ; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + surf( surfIN, o); + light = texture2DProj( _LightBuffer, IN.hip_screen); + light = ( -log2( light ) ); + light.xyz += unity_Ambient.xyz ; + col = LightingLambert_PrePass( o, light); + return col; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec4( gl_TexCoord[0]); + xlt_IN.hip_pack1 = vec4( gl_TexCoord[1]); + xlt_IN.hip_pack2 = vec2( gl_TexCoord[2]); + xlt_IN.hip_screen = vec4( gl_TexCoord[3]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Splatmap_Lightmap-FirstPass-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Splatmap_Lightmap-FirstPass-ir.txt new file mode 100644 index 000000000..399baf05d --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Splatmap_Lightmap-FirstPass-ir.txt @@ -0,0 +1,188 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_Control; + vec2 uv_Splat0; + vec2 uv_Splat1; + vec2 uv_Splat2; + vec2 uv_Splat3; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec4 hip_pack1; + vec2 hip_pack2; + vec4 hip_screen; +}; +varying vec4 xlv_FOG; +uniform vec4 unity_Ambient; +uniform sampler2D _Splat3; +uniform sampler2D _Splat2; +uniform sampler2D _Splat1; +uniform sampler2D _Splat0; +uniform sampler2D _LightBuffer; +uniform sampler2D _Control; +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec3 col; + vec4 splat_control; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_Control, IN.uv_Control); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + splat_control = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = texture2D (_Splat0, IN.uv_Splat0); + vec3 tmpvar_4; + tmpvar_4 = (splat_control.x * tmpvar_3.xyz); + col = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = texture2D (_Splat1, IN.uv_Splat1); + vec3 tmpvar_6; + tmpvar_6 = (col + (splat_control.y * tmpvar_5.xyz)); + col = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = texture2D (_Splat2, IN.uv_Splat2); + vec3 tmpvar_8; + tmpvar_8 = (col + (splat_control.z * tmpvar_7.xyz)); + col = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = texture2D (_Splat3, IN.uv_Splat3); + vec3 tmpvar_10; + tmpvar_10 = (col + (splat_control.w * tmpvar_9.xyz)); + col = tmpvar_10; + vec3 tmpvar_11; + tmpvar_11 = col; + o.Albedo = tmpvar_11; + float tmpvar_12; + tmpvar_12 = 0.0; + o.Alpha = tmpvar_12; +} + +vec4 LightingLambert_PrePass ( + in SurfaceOutput s, + in vec4 light +) +{ + vec4 c; + vec3 tmpvar_1; + tmpvar_1 = (s.Albedo * light.xyz); + c.xyz = tmpvar_1.xyz.xyz; + float tmpvar_2; + tmpvar_2 = s.Alpha; + c.w = vec4(tmpvar_2).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 col; + vec4 light; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_Control = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = IN.hip_pack0.zw; + surfIN.uv_Splat0 = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = IN.hip_pack1.xy; + surfIN.uv_Splat1 = tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = IN.hip_pack1.zw; + surfIN.uv_Splat2 = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5 = IN.hip_pack2.xy; + surfIN.uv_Splat3 = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_7; + float tmpvar_8; + tmpvar_8 = 0.0; + o.Specular = tmpvar_8; + float tmpvar_9; + tmpvar_9 = 0.0; + o.Alpha = tmpvar_9; + float tmpvar_10; + tmpvar_10 = 0.0; + o.Gloss = tmpvar_10; + surf (surfIN, o); + vec4 tmpvar_11; + tmpvar_11 = texture2DProj (_LightBuffer, IN.hip_screen); + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + light = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = log2 (light); + vec4 tmpvar_14; + tmpvar_14 = -(tmpvar_13); + light = tmpvar_14; + vec3 tmpvar_15; + tmpvar_15 = (light.xyz + unity_Ambient.xyz); + light.xyz = tmpvar_15.xyz.xyz; + vec4 tmpvar_16; + tmpvar_16 = LightingLambert_PrePass (o, light); + vec4 tmpvar_17; + tmpvar_17 = tmpvar_16; + col = tmpvar_17; + return col; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyzw; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.hip_pack1 = tmpvar_6; + vec2 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xy; + vec2 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.hip_pack2 = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_TexCoord[3].xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_IN.hip_screen = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = frag_surf (xlt_IN); + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xl_retval = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = xl_retval.xyzw; + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + gl_FragData[0] = tmpvar_14; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Splatmap_Lightmap-FirstPass-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Splatmap_Lightmap-FirstPass-out.txt new file mode 100644 index 000000000..f7ff6a003 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Splatmap_Lightmap-FirstPass-out.txt @@ -0,0 +1,26 @@ +uniform vec4 unity_Ambient; +uniform sampler2D _Splat3; +uniform sampler2D _Splat2; +uniform sampler2D _Splat1; +uniform sampler2D _Splat0; +uniform sampler2D _LightBuffer; +uniform sampler2D _Control; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = gl_TexCoord[0]; + vec4 tmpvar_2; + tmpvar_2 = gl_TexCoord[1]; + vec4 light; + vec4 tmpvar_3; + tmpvar_3 = texture2D (_Control, tmpvar_1.xy); + vec4 tmpvar_4; + tmpvar_4 = -(log2 (texture2DProj (_LightBuffer, gl_TexCoord[3]))); + light = tmpvar_4; + light.xyz = (tmpvar_4.xyz + unity_Ambient.xyz); + vec4 c; + c.xyz = (((((tmpvar_3.x * texture2D (_Splat0, tmpvar_1.zw).xyz) + (tmpvar_3.y * texture2D (_Splat1, tmpvar_2.xy).xyz)) + (tmpvar_3.z * texture2D (_Splat2, tmpvar_2.zw).xyz)) + (tmpvar_3.w * texture2D (_Splat3, gl_TexCoord[2].xy).xyz)) * light.xyz); + c.w = 0.0; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Splatmap_Lightmap-FirstPass1-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Splatmap_Lightmap-FirstPass1-in.txt new file mode 100644 index 000000000..a62326092 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Splatmap_Lightmap-FirstPass1-in.txt @@ -0,0 +1,140 @@ +float xll_saturate( float x) { + return clamp( x, 0.0, 1.0); +} +vec2 xll_saturate( vec2 x) { + return clamp( x, 0.0, 1.0); +} +vec3 xll_saturate( vec3 x) { + return clamp( x, 0.0, 1.0); +} +vec4 xll_saturate( vec4 x) { + return clamp( x, 0.0, 1.0); +} +mat2 xll_saturate(mat2 m) { + return mat2( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0)); +} +mat3 xll_saturate(mat3 m) { + return mat3( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0), clamp(m[2], 0.0, 1.0)); +} +mat4 xll_saturate(mat4 m) { + return mat4( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0), clamp(m[2], 0.0, 1.0), clamp(m[3], 0.0, 1.0)); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_Control; + vec2 uv_Splat0; + vec2 uv_Splat1; + vec2 uv_Splat2; + vec2 uv_Splat3; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec4 hip_pack1; + vec2 hip_pack2; + vec4 hip_screen; + vec3 hip_lmapFade; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform sampler2D _Control; +uniform sampler2D _LightBuffer; +uniform sampler2D _Splat0; +uniform sampler2D _Splat1; +uniform sampler2D _Splat2; +uniform sampler2D _Splat3; +uniform sampler2D unity_Lightmap; +uniform sampler2D unity_LightmapInd; +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingLambert_PrePass( in SurfaceOutput s, in vec4 light ); +vec3 DecodeLightmap( in vec4 color ); +vec4 frag_surf( in v2f_surf IN ); +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 splat_control; + vec3 col; + splat_control = texture2D( _Control, IN.uv_Control); + col = (splat_control.x * texture2D( _Splat0, IN.uv_Splat0).xyz ); + col += (splat_control.y * texture2D( _Splat1, IN.uv_Splat1).xyz ); + col += (splat_control.z * texture2D( _Splat2, IN.uv_Splat2).xyz ); + col += (splat_control.w * texture2D( _Splat3, IN.uv_Splat3).xyz ); + o.Albedo = col; + o.Alpha = 0.000000; +} +vec4 LightingLambert_PrePass( in SurfaceOutput s, in vec4 light ) { + vec4 c; + c.xyz = (s.Albedo * light.xyz ); + c.w = s.Alpha; + return c; +} +vec3 DecodeLightmap( in vec4 color ) { + return (2.00000 * color.xyz ); +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec4 light; + vec3 lmFull; + vec3 lmIndirect; + vec3 lm; + vec4 col; + surfIN.uv_Control = IN.hip_pack0.xy ; + surfIN.uv_Splat0 = IN.hip_pack0.zw ; + surfIN.uv_Splat1 = IN.hip_pack1.xy ; + surfIN.uv_Splat2 = IN.hip_pack1.zw ; + surfIN.uv_Splat3 = IN.hip_pack2.xy ; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + surf( surfIN, o); + light = texture2DProj( _LightBuffer, IN.hip_screen); + light = ( -log2( light ) ); + lmFull = DecodeLightmap( texture2D( unity_Lightmap, IN.hip_lmapFade.xy )); + lmIndirect = DecodeLightmap( texture2D( unity_LightmapInd, IN.hip_lmapFade.xy )); + lm = mix( lmIndirect, lmFull, vec3( xll_saturate( IN.hip_lmapFade.z ))); + light.xyz += lm; + col = LightingLambert_PrePass( o, light); + return col; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec4( gl_TexCoord[0]); + xlt_IN.hip_pack1 = vec4( gl_TexCoord[1]); + xlt_IN.hip_pack2 = vec2( gl_TexCoord[2]); + xlt_IN.hip_screen = vec4( gl_TexCoord[3]); + xlt_IN.hip_lmapFade = vec3( gl_TexCoord[4]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Splatmap_Lightmap-FirstPass1-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Splatmap_Lightmap-FirstPass1-ir.txt new file mode 100644 index 000000000..338d4817c --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Splatmap_Lightmap-FirstPass1-ir.txt @@ -0,0 +1,333 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_Control; + vec2 uv_Splat0; + vec2 uv_Splat1; + vec2 uv_Splat2; + vec2 uv_Splat3; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec4 hip_pack1; + vec2 hip_pack2; + vec4 hip_screen; + vec3 hip_lmapFade; +}; +varying vec4 xlv_FOG; +uniform sampler2D unity_LightmapInd; +uniform sampler2D unity_Lightmap; +uniform sampler2D _Splat3; +uniform sampler2D _Splat2; +uniform sampler2D _Splat1; +uniform sampler2D _Splat0; +uniform sampler2D _LightBuffer; +uniform sampler2D _Control; +float xll_saturate ( + in float x +) +{ + float tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec2 xll_saturate ( + in vec2 x +) +{ + vec2 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec3 xll_saturate ( + in vec3 x +) +{ + vec3 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec4 xll_saturate ( + in vec4 x +) +{ + vec4 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +mat2 xll_saturate ( + in mat2 m +) +{ + vec2 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec2 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + mat2 tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_1; + tmpvar_3[0] = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5 = tmpvar_2; + tmpvar_3[1] = tmpvar_5; + return tmpvar_3; +} + +mat3 xll_saturate ( + in mat3 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec3 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + vec3 tmpvar_3; + tmpvar_3 = clamp (m[2], 0.0, 1.0); + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +mat4 xll_saturate ( + in mat4 m +) +{ + vec4 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec4 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + vec4 tmpvar_3; + tmpvar_3 = clamp (m[2], 0.0, 1.0); + vec4 tmpvar_4; + tmpvar_4 = clamp (m[3], 0.0, 1.0); + mat4 tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_1; + tmpvar_5[0] = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = tmpvar_2; + tmpvar_5[1] = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_3; + tmpvar_5[2] = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = tmpvar_4; + tmpvar_5[3] = tmpvar_9; + return tmpvar_5; +} + +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec3 col; + vec4 splat_control; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_Control, IN.uv_Control); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + splat_control = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = texture2D (_Splat0, IN.uv_Splat0); + vec3 tmpvar_4; + tmpvar_4 = (splat_control.x * tmpvar_3.xyz); + col = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = texture2D (_Splat1, IN.uv_Splat1); + vec3 tmpvar_6; + tmpvar_6 = (col + (splat_control.y * tmpvar_5.xyz)); + col = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = texture2D (_Splat2, IN.uv_Splat2); + vec3 tmpvar_8; + tmpvar_8 = (col + (splat_control.z * tmpvar_7.xyz)); + col = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = texture2D (_Splat3, IN.uv_Splat3); + vec3 tmpvar_10; + tmpvar_10 = (col + (splat_control.w * tmpvar_9.xyz)); + col = tmpvar_10; + vec3 tmpvar_11; + tmpvar_11 = col; + o.Albedo = tmpvar_11; + float tmpvar_12; + tmpvar_12 = 0.0; + o.Alpha = tmpvar_12; +} + +vec4 LightingLambert_PrePass ( + in SurfaceOutput s, + in vec4 light +) +{ + vec4 c; + vec3 tmpvar_1; + tmpvar_1 = (s.Albedo * light.xyz); + c.xyz = tmpvar_1.xyz.xyz; + float tmpvar_2; + tmpvar_2 = s.Alpha; + c.w = vec4(tmpvar_2).w; + return c; +} + +vec3 DecodeLightmap ( + in vec4 color +) +{ + return (2.0 * color.xyz); +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 col; + vec3 lm; + vec3 lmIndirect; + vec3 lmFull; + vec4 light; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_Control = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = IN.hip_pack0.zw; + surfIN.uv_Splat0 = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = IN.hip_pack1.xy; + surfIN.uv_Splat1 = tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = IN.hip_pack1.zw; + surfIN.uv_Splat2 = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5 = IN.hip_pack2.xy; + surfIN.uv_Splat3 = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_7; + float tmpvar_8; + tmpvar_8 = 0.0; + o.Specular = tmpvar_8; + float tmpvar_9; + tmpvar_9 = 0.0; + o.Alpha = tmpvar_9; + float tmpvar_10; + tmpvar_10 = 0.0; + o.Gloss = tmpvar_10; + surf (surfIN, o); + vec4 tmpvar_11; + tmpvar_11 = texture2DProj (_LightBuffer, IN.hip_screen); + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + light = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = log2 (light); + vec4 tmpvar_14; + tmpvar_14 = -(tmpvar_13); + light = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = texture2D (unity_Lightmap, IN.hip_lmapFade.xy); + vec3 tmpvar_16; + tmpvar_16 = DecodeLightmap (tmpvar_15); + vec3 tmpvar_17; + tmpvar_17 = tmpvar_16; + lmFull = tmpvar_17; + vec4 tmpvar_18; + tmpvar_18 = texture2D (unity_LightmapInd, IN.hip_lmapFade.xy); + vec3 tmpvar_19; + tmpvar_19 = DecodeLightmap (tmpvar_18); + vec3 tmpvar_20; + tmpvar_20 = tmpvar_19; + lmIndirect = tmpvar_20; + float tmpvar_21; + tmpvar_21 = xll_saturate (IN.hip_lmapFade.z); + vec3 tmpvar_22; + tmpvar_22 = vec3(tmpvar_21); + vec3 tmpvar_23; + tmpvar_23 = mix (lmIndirect, lmFull, tmpvar_22); + vec3 tmpvar_24; + tmpvar_24 = tmpvar_23; + lm = tmpvar_24; + vec3 tmpvar_25; + tmpvar_25 = (light.xyz + lm); + light.xyz = tmpvar_25.xyz.xyz; + vec4 tmpvar_26; + tmpvar_26 = LightingLambert_PrePass (o, light); + vec4 tmpvar_27; + tmpvar_27 = tmpvar_26; + col = tmpvar_27; + return col; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyzw; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.hip_pack1 = tmpvar_6; + vec2 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xy; + vec2 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.hip_pack2 = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_TexCoord[3].xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_IN.hip_screen = tmpvar_10; + vec3 tmpvar_11; + tmpvar_11 = gl_TexCoord[4].xyz; + vec3 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_IN.hip_lmapFade = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = frag_surf (xlt_IN); + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_FragData[0] = tmpvar_16; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Splatmap_Lightmap-FirstPass1-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Splatmap_Lightmap-FirstPass1-out.txt new file mode 100644 index 000000000..a047be433 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_TerrainEngine_Splatmap_Lightmap-FirstPass1-out.txt @@ -0,0 +1,29 @@ +uniform sampler2D unity_LightmapInd; +uniform sampler2D unity_Lightmap; +uniform sampler2D _Splat3; +uniform sampler2D _Splat2; +uniform sampler2D _Splat1; +uniform sampler2D _Splat0; +uniform sampler2D _LightBuffer; +uniform sampler2D _Control; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = gl_TexCoord[0]; + vec4 tmpvar_2; + tmpvar_2 = gl_TexCoord[1]; + vec3 tmpvar_3; + tmpvar_3 = gl_TexCoord[4].xyz; + vec4 light; + vec4 tmpvar_4; + tmpvar_4 = texture2D (_Control, tmpvar_1.xy); + vec4 tmpvar_5; + tmpvar_5 = -(log2 (texture2DProj (_LightBuffer, gl_TexCoord[3]))); + light = tmpvar_5; + light.xyz = (tmpvar_5.xyz + mix ((2.0 * texture2D (unity_LightmapInd, tmpvar_3.xy).xyz), (2.0 * texture2D (unity_Lightmap, tmpvar_3.xy).xyz), vec3(clamp (tmpvar_3.z, 0.0, 1.0)))); + vec4 c; + c.xyz = (((((tmpvar_4.x * texture2D (_Splat0, tmpvar_1.zw).xyz) + (tmpvar_4.y * texture2D (_Splat1, tmpvar_2.xy).xyz)) + (tmpvar_4.z * texture2D (_Splat2, tmpvar_2.zw).xyz)) + (tmpvar_4.w * texture2D (_Splat3, gl_TexCoord[2].xy).xyz)) * light.xyz); + c.w = 0.0; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Tree_Bark_Shader_Rendertex-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Tree_Bark_Shader_Rendertex-in.txt new file mode 100644 index 000000000..1d49ccbb3 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Tree_Bark_Shader_Rendertex-in.txt @@ -0,0 +1,44 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct v2f { + vec4 pos; + vec2 uv; + vec3 color; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform sampler2D _MainTex; +vec4 frag( in v2f i ); +vec4 frag( in v2f i ) { + vec4 col; + col = texture2D( _MainTex, i.uv); + col.xyz *= (i.color * 2.00000); + col.w = 1.00000; + return col; +} +void main() { + vec4 xl_retval; + v2f xlt_i; + xlt_i.pos = vec4(0.0); + xlt_i.uv = vec2( gl_TexCoord[0]); + xlt_i.color = vec3( gl_TexCoord[1]); + xl_retval = frag( xlt_i); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Tree_Bark_Shader_Rendertex-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Tree_Bark_Shader_Rendertex-ir.txt new file mode 100644 index 000000000..81451eabe --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Tree_Bark_Shader_Rendertex-ir.txt @@ -0,0 +1,54 @@ +struct v2f { + vec4 pos; + vec2 uv; + vec3 color; +}; +uniform sampler2D _MainTex; +vec4 frag ( + in v2f i +) +{ + vec4 col; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, i.uv); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + col = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = (col.xyz * (i.color * 2.0)); + col.xyz = tmpvar_3.xyz.xyz; + float tmpvar_4; + tmpvar_4 = 1.0; + col.w = vec4(tmpvar_4).w; + return col; +} + +void main () +{ + v2f xlt_i; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_i.pos = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = gl_TexCoord[0].xy; + vec2 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_i.uv = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = gl_TexCoord[1].xyz; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_4; + xlt_i.color = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = frag (xlt_i); + vec4 tmpvar_7; + tmpvar_7 = tmpvar_6; + xl_retval = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = xl_retval.xyzw; + vec4 tmpvar_9; + tmpvar_9 = tmpvar_8; + gl_FragData[0] = tmpvar_9; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Tree_Bark_Shader_Rendertex-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Tree_Bark_Shader_Rendertex-out.txt new file mode 100644 index 000000000..a8427803d --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Tree_Bark_Shader_Rendertex-out.txt @@ -0,0 +1,12 @@ +uniform sampler2D _MainTex; +void main () +{ + vec4 col; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, gl_TexCoord[0].xy); + col = tmpvar_1; + col.xyz = (tmpvar_1.xyz * (gl_TexCoord[1].xyz * 2.0)); + col.w = 1.0; + gl_FragData[0] = col; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Tree_Leaf_Shader_Rendertex-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Tree_Leaf_Shader_Rendertex-in.txt new file mode 100644 index 000000000..e4baa940b --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Tree_Leaf_Shader_Rendertex-in.txt @@ -0,0 +1,66 @@ +void xll_clip(float x) { + if ( x<0.0 ) discard; +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +struct LeafSurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + vec3 Translucency; + float Specular; + float Gloss; + float Alpha; +}; +struct v2f { + vec4 pos; + vec2 uv; + vec3 color; +}; +uniform float _HalfOverCutoff; +uniform sampler2D _MainTex; +vec4 frag( in v2f i ); +vec4 frag( in v2f i ) { + vec4 col; + col = texture2D( _MainTex, i.uv); + col.xyz *= (i.color * 2.00000); + col.w *= (2.00000 * _HalfOverCutoff); + xll_clip( (col.w - 1.00000) ); + return col; +} +void main() { + vec4 xl_retval; + v2f xlt_i; + xlt_i.pos = vec4(0.0); + xlt_i.uv = vec2( gl_TexCoord[0]); + xlt_i.color = vec3( gl_TexCoord[1]); + xl_retval = frag( xlt_i); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Tree_Leaf_Shader_Rendertex-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Tree_Leaf_Shader_Rendertex-ir.txt new file mode 100644 index 000000000..70bda7ca5 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Tree_Leaf_Shader_Rendertex-ir.txt @@ -0,0 +1,65 @@ +struct v2f { + vec4 pos; + vec2 uv; + vec3 color; +}; +uniform sampler2D _MainTex; +uniform float _HalfOverCutoff; +void xll_clip ( + in float x +) +{ + if ((x < 0.0)) { + discard; + }; +} + +vec4 frag ( + in v2f i +) +{ + vec4 col; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, i.uv); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + col = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = (col.xyz * (i.color * 2.0)); + col.xyz = tmpvar_3.xyz.xyz; + float tmpvar_4; + tmpvar_4 = (col.w * (2.0 * _HalfOverCutoff)); + col.w = vec4(tmpvar_4).w; + xll_clip ((col.w - 1.0)); + return col; +} + +void main () +{ + v2f xlt_i; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_i.pos = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = gl_TexCoord[0].xy; + vec2 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_i.uv = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = gl_TexCoord[1].xyz; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_4; + xlt_i.color = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = frag (xlt_i); + vec4 tmpvar_7; + tmpvar_7 = tmpvar_6; + xl_retval = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = xl_retval.xyzw; + vec4 tmpvar_9; + tmpvar_9 = tmpvar_8; + gl_FragData[0] = tmpvar_9; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Tree_Leaf_Shader_Rendertex-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Tree_Leaf_Shader_Rendertex-out.txt new file mode 100644 index 000000000..ba964f62c --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Tree_Leaf_Shader_Rendertex-out.txt @@ -0,0 +1,18 @@ +uniform sampler2D _MainTex; +uniform float _HalfOverCutoff; +void main () +{ + vec4 col; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, gl_TexCoord[0].xy); + col = tmpvar_1; + col.xyz = (tmpvar_1.xyz * (gl_TexCoord[1].xyz * 2.0)); + col.w = (tmpvar_1.w * (2.0 * _HalfOverCutoff)); + float x; + x = (col.w - 1.0); + if ((x < 0.0)) { + discard; + }; + gl_FragData[0] = col; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Tree_Optimized_Bark_Shader-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Tree_Optimized_Bark_Shader-in.txt new file mode 100644 index 000000000..70a16f3df --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Tree_Optimized_Bark_Shader-in.txt @@ -0,0 +1,127 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +struct LeafSurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + vec3 Translucency; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec4 color; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 lop_color; + vec3 lightDir; + vec3 viewDir; + vec3 _LightCoord; +}; +uniform sampler2D _BumpSpecMap; +uniform vec4 _LightColor0; +uniform samplerCube _LightTexture0; +uniform sampler2D _LightTextureB0; +uniform sampler2D _MainTex; +uniform sampler2D _TranslucencyMap; +vec4 UnpackNormal( in vec4 packednormal ); +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingTreeBark( in SurfaceOutput s, in vec3 lightDir, in vec3 viewDir, in float atten ); +vec4 frag_surf( in v2f_surf IN ); +vec4 UnpackNormal( in vec4 packednormal ) { + vec4 normal; + normal.xy = ((packednormal.wy * 2.00000) - 1.00000); + normal.z = sqrt( ((1.00000 - (normal.x * normal.x )) - (normal.y * normal.y )) ); + return normal; +} +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 c; + vec4 trngls; + vec4 norspc; + c = texture2D( _MainTex, IN.uv_MainTex); + o.Albedo = (c.xyz * IN.color.xyz ); + trngls = texture2D( _TranslucencyMap, IN.uv_MainTex); + o.Gloss = trngls.w ; + o.Alpha = IN.color.w ; + norspc = texture2D( _BumpSpecMap, IN.uv_MainTex); + o.Specular = norspc.x ; + o.Normal = vec3( UnpackNormal( norspc)); +} +vec4 LightingTreeBark( in SurfaceOutput s, in vec3 lightDir, in vec3 viewDir, in float atten ) { + vec3 h; + float diff; + float nh; + float spec; + vec4 c; + h = normalize( (lightDir + viewDir) ); + diff = max( 0.000000, dot( s.Normal, lightDir)); + nh = max( 0.000000, dot( s.Normal, h)); + spec = (pow( nh, (s.Specular * 128.000)) * s.Gloss); + c.xyz = ((((s.Albedo * _LightColor0.xyz ) * diff) + (_LightColor0.xyz * spec)) * (atten * 2.00000)); + c.w = (((_LightColor0.w * spec) * atten) * s.Alpha); + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec3 lightDir; + vec4 c; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + surfIN.color = IN.lop_color; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + surf( surfIN, o); + lightDir = IN.lightDir; + lightDir = normalize( lightDir ); + c = LightingTreeBark( o, lightDir, normalize( vec3( IN.viewDir) ), (texture2D( _LightTextureB0, vec2( vec2( dot( IN._LightCoord, IN._LightCoord)))).w * textureCube( _LightTexture0, IN._LightCoord).w )); + c.w = 0.000000; + return c; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec2( gl_TexCoord[0]); + xlt_IN.lop_color = vec4( gl_Color); + xlt_IN.lightDir = vec3( gl_TexCoord[1]); + xlt_IN.viewDir = vec3( gl_TexCoord[2]); + xlt_IN._LightCoord = vec3( gl_TexCoord[3]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Tree_Optimized_Bark_Shader-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Tree_Optimized_Bark_Shader-ir.txt new file mode 100644 index 000000000..15e367d33 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Tree_Optimized_Bark_Shader-ir.txt @@ -0,0 +1,243 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec4 color; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 lop_color; + vec3 lightDir; + vec3 viewDir; + vec3 _LightCoord; +}; +varying vec4 xlv_FOG; +uniform sampler2D _TranslucencyMap; +uniform sampler2D _MainTex; +uniform sampler2D _LightTextureB0; +uniform samplerCube _LightTexture0; +uniform vec4 _LightColor0; +uniform sampler2D _BumpSpecMap; +vec4 UnpackNormal ( + in vec4 packednormal +) +{ + vec4 normal; + vec2 tmpvar_1; + tmpvar_1 = ((packednormal.wy * 2.0) - 1.0); + normal.xy = tmpvar_1.xy.xy; + float tmpvar_2; + tmpvar_2 = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + normal.z = vec3(tmpvar_3).z; + return normal; +} + +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 norspc; + vec4 trngls; + vec4 c; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + c = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = (c.xyz * IN.color.xyz); + o.Albedo = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = texture2D (_TranslucencyMap, IN.uv_MainTex); + vec4 tmpvar_5; + tmpvar_5 = tmpvar_4; + trngls = tmpvar_5; + float tmpvar_6; + tmpvar_6 = trngls.w; + o.Gloss = tmpvar_6; + float tmpvar_7; + tmpvar_7 = IN.color.w; + o.Alpha = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = texture2D (_BumpSpecMap, IN.uv_MainTex); + vec4 tmpvar_9; + tmpvar_9 = tmpvar_8; + norspc = tmpvar_9; + float tmpvar_10; + tmpvar_10 = norspc.x; + o.Specular = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = UnpackNormal (norspc); + vec3 tmpvar_12; + tmpvar_12 = tmpvar_11.xyz; + vec3 tmpvar_13; + tmpvar_13 = tmpvar_12; + o.Normal = tmpvar_13; +} + +vec4 LightingTreeBark ( + in SurfaceOutput s, + in vec3 lightDir, + in vec3 viewDir, + in float atten +) +{ + vec4 c; + float spec; + float nh; + float diff; + vec3 h; + vec3 tmpvar_1; + tmpvar_1 = normalize ((lightDir + viewDir)); + vec3 tmpvar_2; + tmpvar_2 = tmpvar_1; + h = tmpvar_2; + float tmpvar_3; + tmpvar_3 = dot (s.Normal, lightDir); + float tmpvar_4; + tmpvar_4 = max (0.0, tmpvar_3); + float tmpvar_5; + tmpvar_5 = tmpvar_4; + diff = tmpvar_5; + float tmpvar_6; + tmpvar_6 = dot (s.Normal, h); + float tmpvar_7; + tmpvar_7 = max (0.0, tmpvar_6); + float tmpvar_8; + tmpvar_8 = tmpvar_7; + nh = tmpvar_8; + float tmpvar_9; + tmpvar_9 = pow (nh, (s.Specular * 128.0)); + float tmpvar_10; + tmpvar_10 = (tmpvar_9 * s.Gloss); + spec = tmpvar_10; + vec3 tmpvar_11; + tmpvar_11 = ((((s.Albedo * _LightColor0.xyz) * diff) + (_LightColor0.xyz * spec)) * (atten * 2.0)); + c.xyz = tmpvar_11.xyz.xyz; + float tmpvar_12; + tmpvar_12 = (((_LightColor0.w * spec) * atten) * s.Alpha); + c.w = vec4(tmpvar_12).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 c; + vec3 lightDir; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = IN.lop_color; + surfIN.color = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Specular = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Alpha = tmpvar_6; + float tmpvar_7; + tmpvar_7 = 0.0; + o.Gloss = tmpvar_7; + surf (surfIN, o); + vec3 tmpvar_8; + tmpvar_8 = IN.lightDir; + lightDir = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = normalize (lightDir); + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + lightDir = tmpvar_10; + vec3 tmpvar_11; + tmpvar_11 = IN.viewDir.xyz; + vec3 tmpvar_12; + tmpvar_12 = normalize (tmpvar_11); + float tmpvar_13; + tmpvar_13 = dot (IN._LightCoord, IN._LightCoord); + vec2 tmpvar_14; + tmpvar_14 = vec2(tmpvar_13); + vec2 tmpvar_15; + tmpvar_15 = tmpvar_14.xy; + vec4 tmpvar_16; + tmpvar_16 = texture2D (_LightTextureB0, tmpvar_15); + vec4 tmpvar_17; + tmpvar_17 = textureCube (_LightTexture0, IN._LightCoord); + vec4 tmpvar_18; + tmpvar_18 = LightingTreeBark (o, lightDir, tmpvar_12, (tmpvar_16.w * tmpvar_17.w)); + vec4 tmpvar_19; + tmpvar_19 = tmpvar_18; + c = tmpvar_19; + float tmpvar_20; + tmpvar_20 = 0.0; + c.w = vec4(tmpvar_20).w; + return c; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xy; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = gl_Color.xyzw; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.lop_color = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = gl_TexCoord[1].xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.lightDir = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = gl_TexCoord[2].xyz; + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_IN.viewDir = tmpvar_10; + vec3 tmpvar_11; + tmpvar_11 = gl_TexCoord[3].xyz; + vec3 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_IN._LightCoord = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = frag_surf (xlt_IN); + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_FragData[0] = tmpvar_16; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Tree_Optimized_Bark_Shader-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Tree_Optimized_Bark_Shader-out.txt new file mode 100644 index 000000000..d2c6b9c8a --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Tree_Optimized_Bark_Shader-out.txt @@ -0,0 +1,34 @@ +uniform sampler2D _TranslucencyMap; +uniform sampler2D _MainTex; +uniform sampler2D _LightTextureB0; +uniform samplerCube _LightTexture0; +uniform vec4 _LightColor0; +uniform sampler2D _BumpSpecMap; +void main () +{ + vec3 tmpvar_1; + tmpvar_1 = gl_TexCoord[3].xyz; + vec4 c; + vec2 tmpvar_2; + tmpvar_2 = gl_TexCoord[0].xy; + vec4 tmpvar_3; + tmpvar_3 = texture2D (_BumpSpecMap, tmpvar_2); + vec4 normal; + normal.xy = ((tmpvar_3.wy * 2.0) - 1.0); + normal.z = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + vec3 tmpvar_4; + tmpvar_4 = normal.xyz; + vec3 tmpvar_5; + tmpvar_5 = normalize (gl_TexCoord[1].xyz); + float atten; + atten = (texture2D (_LightTextureB0, vec2(dot (tmpvar_1, tmpvar_1))).w * textureCube (_LightTexture0, tmpvar_1).w); + vec4 c_i0_i1; + float tmpvar_6; + tmpvar_6 = (pow (max (0.0, dot (tmpvar_4, normalize ((tmpvar_5 + normalize (gl_TexCoord[2].xyz))))), (tmpvar_3.x * 128.0)) * texture2D (_TranslucencyMap, tmpvar_2).w); + c_i0_i1.xyz = (((((texture2D (_MainTex, tmpvar_2).xyz * gl_Color.xyz) * _LightColor0.xyz) * max (0.0, dot (tmpvar_4, tmpvar_5))) + (_LightColor0.xyz * tmpvar_6)) * (atten * 2.0)); + c_i0_i1.w = (((_LightColor0.w * tmpvar_6) * atten) * gl_Color.w); + c = c_i0_i1; + c.w = 0.0; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Tree_Optimized_Bark_Shader1-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Tree_Optimized_Bark_Shader1-in.txt new file mode 100644 index 000000000..befaa8fda --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Tree_Optimized_Bark_Shader1-in.txt @@ -0,0 +1,88 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +struct LeafSurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + vec3 Translucency; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec4 color; +}; +struct v2f_surf { + vec4 pos; +}; +uniform sampler2D _BumpSpecMap; +uniform sampler2D _MainTex; +uniform sampler2D _TranslucencyMap; +vec4 UnpackNormal( in vec4 packednormal ); +void surf( in Input IN, inout SurfaceOutput o ); +vec4 frag_surf( in v2f_surf IN ); +vec4 UnpackNormal( in vec4 packednormal ) { + vec4 normal; + normal.xy = ((packednormal.wy * 2.00000) - 1.00000); + normal.z = sqrt( ((1.00000 - (normal.x * normal.x )) - (normal.y * normal.y )) ); + return normal; +} +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 c; + vec4 trngls; + vec4 norspc; + c = texture2D( _MainTex, IN.uv_MainTex); + o.Albedo = (c.xyz * IN.color.xyz ); + trngls = texture2D( _TranslucencyMap, IN.uv_MainTex); + o.Gloss = trngls.w ; + o.Alpha = IN.color.w ; + norspc = texture2D( _BumpSpecMap, IN.uv_MainTex); + o.Specular = norspc.x ; + o.Normal = vec3( UnpackNormal( norspc)); +} +vec4 frag_surf( in v2f_surf IN ) { + SurfaceOutput o; + Input surfIN; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + surf( surfIN, o); + return vec4( 0.000000); +} +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Tree_Optimized_Bark_Shader1-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Tree_Optimized_Bark_Shader1-ir.txt new file mode 100644 index 000000000..5ba204102 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Tree_Optimized_Bark_Shader1-ir.txt @@ -0,0 +1,122 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec4 color; +}; +struct v2f_surf { + vec4 pos; +}; +uniform sampler2D _TranslucencyMap; +uniform sampler2D _MainTex; +uniform sampler2D _BumpSpecMap; +vec4 UnpackNormal ( + in vec4 packednormal +) +{ + vec4 normal; + vec2 tmpvar_1; + tmpvar_1 = ((packednormal.wy * 2.0) - 1.0); + normal.xy = tmpvar_1.xy.xy; + float tmpvar_2; + tmpvar_2 = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + normal.z = vec3(tmpvar_3).z; + return normal; +} + +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 norspc; + vec4 trngls; + vec4 c; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + c = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = (c.xyz * IN.color.xyz); + o.Albedo = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = texture2D (_TranslucencyMap, IN.uv_MainTex); + vec4 tmpvar_5; + tmpvar_5 = tmpvar_4; + trngls = tmpvar_5; + float tmpvar_6; + tmpvar_6 = trngls.w; + o.Gloss = tmpvar_6; + float tmpvar_7; + tmpvar_7 = IN.color.w; + o.Alpha = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = texture2D (_BumpSpecMap, IN.uv_MainTex); + vec4 tmpvar_9; + tmpvar_9 = tmpvar_8; + norspc = tmpvar_9; + float tmpvar_10; + tmpvar_10 = norspc.x; + o.Specular = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = UnpackNormal (norspc); + vec3 tmpvar_12; + tmpvar_12 = tmpvar_11.xyz; + vec3 tmpvar_13; + tmpvar_13 = tmpvar_12; + o.Normal = tmpvar_13; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + Input surfIN; + SurfaceOutput o; + vec3 tmpvar_1; + tmpvar_1 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_2; + float tmpvar_3; + tmpvar_3 = 0.0; + o.Specular = tmpvar_3; + float tmpvar_4; + tmpvar_4 = 0.0; + o.Alpha = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Gloss = tmpvar_5; + surf (surfIN, o); + return vec4(0.0, 0.0, 0.0, 0.0); +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = frag_surf (xlt_IN); + vec4 tmpvar_3; + tmpvar_3 = tmpvar_2; + xl_retval = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = xl_retval.xyzw; + vec4 tmpvar_5; + tmpvar_5 = tmpvar_4; + gl_FragData[0] = tmpvar_5; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Tree_Optimized_Bark_Shader1-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Tree_Optimized_Bark_Shader1-out.txt new file mode 100644 index 000000000..84d467adf --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Tree_Optimized_Bark_Shader1-out.txt @@ -0,0 +1,10 @@ +uniform sampler2D _BumpSpecMap; +void main () +{ + vec2 tmpvar_1; + vec4 normal; + normal.xy = ((texture2D (_BumpSpecMap, tmpvar_1).wy * 2.0) - 1.0); + normal.z = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + gl_FragData[0] = vec4(0.0, 0.0, 0.0, 0.0); +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Tree_Optimized_Leaf_Shader-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Tree_Optimized_Leaf_Shader-in.txt new file mode 100644 index 000000000..ac1f8621b --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Tree_Optimized_Leaf_Shader-in.txt @@ -0,0 +1,156 @@ +void xll_clip(float x) { + if ( x<0.0 ) discard; +} +float xll_saturate( float x) { + return clamp( x, 0.0, 1.0); +} +vec2 xll_saturate( vec2 x) { + return clamp( x, 0.0, 1.0); +} +vec3 xll_saturate( vec3 x) { + return clamp( x, 0.0, 1.0); +} +vec4 xll_saturate( vec4 x) { + return clamp( x, 0.0, 1.0); +} +mat2 xll_saturate(mat2 m) { + return mat2( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0)); +} +mat3 xll_saturate(mat3 m) { + return mat3( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0), clamp(m[2], 0.0, 1.0)); +} +mat4 xll_saturate(mat4 m) { + return mat4( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0), clamp(m[2], 0.0, 1.0), clamp(m[3], 0.0, 1.0)); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +struct LeafSurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + vec3 Translucency; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec4 color; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 lop_color; + vec3 lightDir; + vec3 viewDir; +}; +uniform sampler2D _BumpSpecMap; +uniform float _Cutoff; +uniform vec4 _LightColor0; +uniform sampler2D _MainTex; +uniform sampler2D _TranslucencyMap; +vec4 UnpackNormal( in vec4 packednormal ); +void surf( in Input IN, inout LeafSurfaceOutput o ); +vec4 LightingTreeLeaf( in LeafSurfaceOutput s, in vec3 lightDir, in vec3 viewDir, in float atten ); +vec4 frag_surf( in v2f_surf IN ); +vec4 UnpackNormal( in vec4 packednormal ) { + vec4 normal; + normal.xy = ((packednormal.wy * 2.00000) - 1.00000); + normal.z = sqrt( ((1.00000 - (normal.x * normal.x )) - (normal.y * normal.y )) ); + return normal; +} +void surf( in Input IN, inout LeafSurfaceOutput o ) { + vec4 c; + vec4 trngls; + vec4 norspc; + c = texture2D( _MainTex, IN.uv_MainTex); + o.Albedo = (c.xyz * IN.color.xyz ); + trngls = texture2D( _TranslucencyMap, IN.uv_MainTex); + o.Translucency = trngls.xyz ; + o.Gloss = trngls.w ; + o.Alpha = (c.w * IN.color.w ); + norspc = texture2D( _BumpSpecMap, IN.uv_MainTex); + o.Specular = norspc.x ; + o.Normal = vec3( UnpackNormal( norspc)); +} +vec4 LightingTreeLeaf( in LeafSurfaceOutput s, in vec3 lightDir, in vec3 viewDir, in float atten ) { + vec3 h; + float diff; + float nh; + float spec; + float trans; + vec3 translucencyColor; + vec3 col; + vec4 c; + h = normalize( (lightDir + viewDir) ); + diff = dot( s.Normal, lightDir); + nh = max( 0.000000, dot( s.Normal, h)); + spec = (pow( nh, (s.Specular * 128.000)) * s.Gloss); + trans = max( 0.000000, ( -diff )); + translucencyColor = ((s.Translucency * trans) * 2.00000); + diff = max( 0.000000, ((diff * 0.500000) + 0.500000)); + col = (s.Albedo * (diff + translucencyColor)); + col += (spec * (1.00000 - xll_saturate( ceil( trans ) ))); + col *= _LightColor0.xyz ; + c.xyz = (col * (atten * 2.00000)); + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + LeafSurfaceOutput o; + vec3 lightDir; + vec4 c; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + surfIN.color = IN.lop_color; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + surf( surfIN, o); + xll_clip( (o.Alpha - _Cutoff) ); + lightDir = IN.lightDir; + c = LightingTreeLeaf( o, lightDir, normalize( vec3( IN.viewDir) ), 1.00000); + c.w = o.Alpha; + return c; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec2( gl_TexCoord[0]); + xlt_IN.lop_color = vec4( gl_Color); + xlt_IN.lightDir = vec3( gl_TexCoord[1]); + xlt_IN.viewDir = vec3( gl_TexCoord[2]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Tree_Optimized_Leaf_Shader-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Tree_Optimized_Leaf_Shader-ir.txt new file mode 100644 index 000000000..6cf07e17a --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Tree_Optimized_Leaf_Shader-ir.txt @@ -0,0 +1,361 @@ +struct LeafSurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + vec3 Translucency; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec4 color; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 lop_color; + vec3 lightDir; + vec3 viewDir; +}; +varying vec4 xlv_FOG; +uniform sampler2D _TranslucencyMap; +uniform sampler2D _MainTex; +uniform vec4 _LightColor0; +uniform float _Cutoff; +uniform sampler2D _BumpSpecMap; +void xll_clip ( + in float x +) +{ + if ((x < 0.0)) { + discard; + }; +} + +float xll_saturate ( + in float x +) +{ + float tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec2 xll_saturate ( + in vec2 x +) +{ + vec2 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec3 xll_saturate ( + in vec3 x +) +{ + vec3 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec4 xll_saturate ( + in vec4 x +) +{ + vec4 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +mat2 xll_saturate ( + in mat2 m +) +{ + vec2 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec2 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + mat2 tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_1; + tmpvar_3[0] = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5 = tmpvar_2; + tmpvar_3[1] = tmpvar_5; + return tmpvar_3; +} + +mat3 xll_saturate ( + in mat3 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec3 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + vec3 tmpvar_3; + tmpvar_3 = clamp (m[2], 0.0, 1.0); + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +mat4 xll_saturate ( + in mat4 m +) +{ + vec4 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec4 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + vec4 tmpvar_3; + tmpvar_3 = clamp (m[2], 0.0, 1.0); + vec4 tmpvar_4; + tmpvar_4 = clamp (m[3], 0.0, 1.0); + mat4 tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_1; + tmpvar_5[0] = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = tmpvar_2; + tmpvar_5[1] = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_3; + tmpvar_5[2] = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = tmpvar_4; + tmpvar_5[3] = tmpvar_9; + return tmpvar_5; +} + +vec4 UnpackNormal ( + in vec4 packednormal +) +{ + vec4 normal; + vec2 tmpvar_1; + tmpvar_1 = ((packednormal.wy * 2.0) - 1.0); + normal.xy = tmpvar_1.xy.xy; + float tmpvar_2; + tmpvar_2 = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + normal.z = vec3(tmpvar_3).z; + return normal; +} + +void surf ( + in Input IN, + inout LeafSurfaceOutput o +) +{ + vec4 norspc; + vec4 trngls; + vec4 c; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + c = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = (c.xyz * IN.color.xyz); + o.Albedo = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = texture2D (_TranslucencyMap, IN.uv_MainTex); + vec4 tmpvar_5; + tmpvar_5 = tmpvar_4; + trngls = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = trngls.xyz; + o.Translucency = tmpvar_6; + float tmpvar_7; + tmpvar_7 = trngls.w; + o.Gloss = tmpvar_7; + float tmpvar_8; + tmpvar_8 = (c.w * IN.color.w); + o.Alpha = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = texture2D (_BumpSpecMap, IN.uv_MainTex); + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + norspc = tmpvar_10; + float tmpvar_11; + tmpvar_11 = norspc.x; + o.Specular = tmpvar_11; + vec4 tmpvar_12; + tmpvar_12 = UnpackNormal (norspc); + vec3 tmpvar_13; + tmpvar_13 = tmpvar_12.xyz; + vec3 tmpvar_14; + tmpvar_14 = tmpvar_13; + o.Normal = tmpvar_14; +} + +vec4 LightingTreeLeaf ( + in LeafSurfaceOutput s, + in vec3 lightDir, + in vec3 viewDir, + in float atten +) +{ + vec4 c; + vec3 col; + vec3 translucencyColor; + float trans; + float spec; + float nh; + float diff; + vec3 h; + vec3 tmpvar_1; + tmpvar_1 = normalize ((lightDir + viewDir)); + vec3 tmpvar_2; + tmpvar_2 = tmpvar_1; + h = tmpvar_2; + float tmpvar_3; + tmpvar_3 = dot (s.Normal, lightDir); + float tmpvar_4; + tmpvar_4 = tmpvar_3; + diff = tmpvar_4; + float tmpvar_5; + tmpvar_5 = dot (s.Normal, h); + float tmpvar_6; + tmpvar_6 = max (0.0, tmpvar_5); + float tmpvar_7; + tmpvar_7 = tmpvar_6; + nh = tmpvar_7; + float tmpvar_8; + tmpvar_8 = pow (nh, (s.Specular * 128.0)); + float tmpvar_9; + tmpvar_9 = (tmpvar_8 * s.Gloss); + spec = tmpvar_9; + float tmpvar_10; + tmpvar_10 = max (0.0, -(diff)); + float tmpvar_11; + tmpvar_11 = tmpvar_10; + trans = tmpvar_11; + vec3 tmpvar_12; + tmpvar_12 = ((s.Translucency * trans) * 2.0); + translucencyColor = tmpvar_12; + float tmpvar_13; + tmpvar_13 = max (0.0, ((diff * 0.5) + 0.5)); + float tmpvar_14; + tmpvar_14 = tmpvar_13; + diff = tmpvar_14; + vec3 tmpvar_15; + tmpvar_15 = (s.Albedo * (diff + translucencyColor)); + col = tmpvar_15; + float tmpvar_16; + tmpvar_16 = ceil (trans); + float tmpvar_17; + tmpvar_17 = xll_saturate (tmpvar_16); + vec3 tmpvar_18; + tmpvar_18 = (col + (spec * (1.0 - tmpvar_17))); + col = tmpvar_18; + vec3 tmpvar_19; + tmpvar_19 = (col * _LightColor0.xyz); + col = tmpvar_19; + vec3 tmpvar_20; + tmpvar_20 = (col * (atten * 2.0)); + c.xyz = tmpvar_20.xyz.xyz; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 c; + vec3 lightDir; + LeafSurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = IN.lop_color; + surfIN.color = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Specular = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Alpha = tmpvar_6; + surf (surfIN, o); + xll_clip ((o.Alpha - _Cutoff)); + vec3 tmpvar_7; + tmpvar_7 = IN.lightDir; + lightDir = tmpvar_7; + vec3 tmpvar_8; + tmpvar_8 = IN.viewDir.xyz; + vec3 tmpvar_9; + tmpvar_9 = normalize (tmpvar_8); + vec4 tmpvar_10; + tmpvar_10 = LightingTreeLeaf (o, lightDir, tmpvar_9, 1.0); + vec4 tmpvar_11; + tmpvar_11 = tmpvar_10; + c = tmpvar_11; + float tmpvar_12; + tmpvar_12 = o.Alpha; + c.w = vec4(tmpvar_12).w; + return c; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xy; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = gl_Color.xyzw; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.lop_color = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = gl_TexCoord[1].xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.lightDir = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = gl_TexCoord[2].xyz; + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_IN.viewDir = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = frag_surf (xlt_IN); + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xl_retval = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = xl_retval.xyzw; + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + gl_FragData[0] = tmpvar_14; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Tree_Optimized_Leaf_Shader-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Tree_Optimized_Leaf_Shader-out.txt new file mode 100644 index 000000000..ad3243f7c --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Tree_Optimized_Leaf_Shader-out.txt @@ -0,0 +1,45 @@ +uniform sampler2D _TranslucencyMap; +uniform sampler2D _MainTex; +uniform vec4 _LightColor0; +uniform float _Cutoff; +uniform sampler2D _BumpSpecMap; +void main () +{ + vec3 tmpvar_1; + tmpvar_1 = gl_TexCoord[1].xyz; + vec3 tmpvar_2; + tmpvar_2 = gl_TexCoord[2].xyz; + vec4 c; + vec2 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xy; + vec4 tmpvar_4; + tmpvar_4 = texture2D (_MainTex, tmpvar_3); + vec3 tmpvar_5; + tmpvar_5 = (tmpvar_4.xyz * gl_Color.xyz); + vec4 tmpvar_6; + tmpvar_6 = texture2D (_TranslucencyMap, tmpvar_3); + float tmpvar_7; + tmpvar_7 = (tmpvar_4.w * gl_Color.w); + vec4 tmpvar_8; + tmpvar_8 = texture2D (_BumpSpecMap, tmpvar_3); + vec4 normal; + normal.xy = ((tmpvar_8.wy * 2.0) - 1.0); + normal.z = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + vec3 tmpvar_9; + tmpvar_9 = normal.xyz; + float x; + x = (tmpvar_7 - _Cutoff); + if ((x < 0.0)) { + discard; + }; + vec4 c_i0_i1; + float tmpvar_10; + tmpvar_10 = dot (tmpvar_9, tmpvar_1); + float tmpvar_11; + tmpvar_11 = max (0.0, -(tmpvar_10)); + c_i0_i1.xyz = ((((tmpvar_5 * (max (0.0, ((tmpvar_10 * 0.5) + 0.5)) + ((tmpvar_6.xyz * tmpvar_11) * 2.0))) + ((pow (max (0.0, dot (tmpvar_9, normalize ((tmpvar_1 + normalize (tmpvar_2))))), (tmpvar_8.x * 128.0)) * tmpvar_6.w) * (1.0 - clamp (ceil (tmpvar_11), 0.0, 1.0)))) * _LightColor0.xyz) * 2.0); + c = c_i0_i1; + c.w = tmpvar_7; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Tree_Optimized_Leaf_Shader1-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Tree_Optimized_Leaf_Shader1-in.txt new file mode 100644 index 000000000..a31302b15 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Tree_Optimized_Leaf_Shader1-in.txt @@ -0,0 +1,161 @@ +void xll_clip(float x) { + if ( x<0.0 ) discard; +} +float xll_saturate( float x) { + return clamp( x, 0.0, 1.0); +} +vec2 xll_saturate( vec2 x) { + return clamp( x, 0.0, 1.0); +} +vec3 xll_saturate( vec3 x) { + return clamp( x, 0.0, 1.0); +} +vec4 xll_saturate( vec4 x) { + return clamp( x, 0.0, 1.0); +} +mat2 xll_saturate(mat2 m) { + return mat2( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0)); +} +mat3 xll_saturate(mat3 m) { + return mat3( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0), clamp(m[2], 0.0, 1.0)); +} +mat4 xll_saturate(mat4 m) { + return mat4( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0), clamp(m[2], 0.0, 1.0), clamp(m[3], 0.0, 1.0)); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +struct LeafSurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + vec3 Translucency; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec4 color; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 lop_color; + vec3 lightDir; + vec3 viewDir; + vec3 _LightCoord; +}; +uniform sampler2D _BumpSpecMap; +uniform float _Cutoff; +uniform vec4 _LightColor0; +uniform samplerCube _LightTexture0; +uniform sampler2D _LightTextureB0; +uniform sampler2D _MainTex; +uniform sampler2D _TranslucencyMap; +vec4 UnpackNormal( in vec4 packednormal ); +void surf( in Input IN, inout LeafSurfaceOutput o ); +vec4 LightingTreeLeaf( in LeafSurfaceOutput s, in vec3 lightDir, in vec3 viewDir, in float atten ); +vec4 frag_surf( in v2f_surf IN ); +vec4 UnpackNormal( in vec4 packednormal ) { + vec4 normal; + normal.xy = ((packednormal.wy * 2.00000) - 1.00000); + normal.z = sqrt( ((1.00000 - (normal.x * normal.x )) - (normal.y * normal.y )) ); + return normal; +} +void surf( in Input IN, inout LeafSurfaceOutput o ) { + vec4 c; + vec4 trngls; + vec4 norspc; + c = texture2D( _MainTex, IN.uv_MainTex); + o.Albedo = (c.xyz * IN.color.xyz ); + trngls = texture2D( _TranslucencyMap, IN.uv_MainTex); + o.Translucency = trngls.xyz ; + o.Gloss = trngls.w ; + o.Alpha = (c.w * IN.color.w ); + norspc = texture2D( _BumpSpecMap, IN.uv_MainTex); + o.Specular = norspc.x ; + o.Normal = vec3( UnpackNormal( norspc)); +} +vec4 LightingTreeLeaf( in LeafSurfaceOutput s, in vec3 lightDir, in vec3 viewDir, in float atten ) { + vec3 h; + float diff; + float nh; + float spec; + float trans; + vec3 translucencyColor; + vec3 col; + vec4 c; + h = normalize( (lightDir + viewDir) ); + diff = dot( s.Normal, lightDir); + nh = max( 0.000000, dot( s.Normal, h)); + spec = (pow( nh, (s.Specular * 128.000)) * s.Gloss); + trans = max( 0.000000, ( -diff )); + translucencyColor = ((s.Translucency * trans) * 2.00000); + diff = max( 0.000000, ((diff * 0.500000) + 0.500000)); + col = (s.Albedo * (diff + translucencyColor)); + col += (spec * (1.00000 - xll_saturate( ceil( trans ) ))); + col *= _LightColor0.xyz ; + c.xyz = (col * (atten * 2.00000)); + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + LeafSurfaceOutput o; + vec3 lightDir; + vec4 c; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + surfIN.color = IN.lop_color; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + surf( surfIN, o); + xll_clip( (o.Alpha - _Cutoff) ); + lightDir = IN.lightDir; + lightDir = normalize( lightDir ); + c = LightingTreeLeaf( o, lightDir, normalize( vec3( IN.viewDir) ), (texture2D( _LightTextureB0, vec2( vec2( dot( IN._LightCoord, IN._LightCoord)))).w * textureCube( _LightTexture0, IN._LightCoord).w )); + c.w = o.Alpha; + return c; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec2( gl_TexCoord[0]); + xlt_IN.lop_color = vec4( gl_Color); + xlt_IN.lightDir = vec3( gl_TexCoord[1]); + xlt_IN.viewDir = vec3( gl_TexCoord[2]); + xlt_IN._LightCoord = vec3( gl_TexCoord[3]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Tree_Optimized_Leaf_Shader1-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Tree_Optimized_Leaf_Shader1-ir.txt new file mode 100644 index 000000000..6fcb293e3 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Tree_Optimized_Leaf_Shader1-ir.txt @@ -0,0 +1,384 @@ +struct LeafSurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + vec3 Translucency; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec4 color; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 lop_color; + vec3 lightDir; + vec3 viewDir; + vec3 _LightCoord; +}; +varying vec4 xlv_FOG; +uniform sampler2D _TranslucencyMap; +uniform sampler2D _MainTex; +uniform sampler2D _LightTextureB0; +uniform samplerCube _LightTexture0; +uniform vec4 _LightColor0; +uniform float _Cutoff; +uniform sampler2D _BumpSpecMap; +void xll_clip ( + in float x +) +{ + if ((x < 0.0)) { + discard; + }; +} + +float xll_saturate ( + in float x +) +{ + float tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec2 xll_saturate ( + in vec2 x +) +{ + vec2 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec3 xll_saturate ( + in vec3 x +) +{ + vec3 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec4 xll_saturate ( + in vec4 x +) +{ + vec4 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +mat2 xll_saturate ( + in mat2 m +) +{ + vec2 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec2 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + mat2 tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_1; + tmpvar_3[0] = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5 = tmpvar_2; + tmpvar_3[1] = tmpvar_5; + return tmpvar_3; +} + +mat3 xll_saturate ( + in mat3 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec3 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + vec3 tmpvar_3; + tmpvar_3 = clamp (m[2], 0.0, 1.0); + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +mat4 xll_saturate ( + in mat4 m +) +{ + vec4 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec4 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + vec4 tmpvar_3; + tmpvar_3 = clamp (m[2], 0.0, 1.0); + vec4 tmpvar_4; + tmpvar_4 = clamp (m[3], 0.0, 1.0); + mat4 tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_1; + tmpvar_5[0] = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = tmpvar_2; + tmpvar_5[1] = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_3; + tmpvar_5[2] = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = tmpvar_4; + tmpvar_5[3] = tmpvar_9; + return tmpvar_5; +} + +vec4 UnpackNormal ( + in vec4 packednormal +) +{ + vec4 normal; + vec2 tmpvar_1; + tmpvar_1 = ((packednormal.wy * 2.0) - 1.0); + normal.xy = tmpvar_1.xy.xy; + float tmpvar_2; + tmpvar_2 = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + normal.z = vec3(tmpvar_3).z; + return normal; +} + +void surf ( + in Input IN, + inout LeafSurfaceOutput o +) +{ + vec4 norspc; + vec4 trngls; + vec4 c; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + c = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = (c.xyz * IN.color.xyz); + o.Albedo = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = texture2D (_TranslucencyMap, IN.uv_MainTex); + vec4 tmpvar_5; + tmpvar_5 = tmpvar_4; + trngls = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = trngls.xyz; + o.Translucency = tmpvar_6; + float tmpvar_7; + tmpvar_7 = trngls.w; + o.Gloss = tmpvar_7; + float tmpvar_8; + tmpvar_8 = (c.w * IN.color.w); + o.Alpha = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = texture2D (_BumpSpecMap, IN.uv_MainTex); + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + norspc = tmpvar_10; + float tmpvar_11; + tmpvar_11 = norspc.x; + o.Specular = tmpvar_11; + vec4 tmpvar_12; + tmpvar_12 = UnpackNormal (norspc); + vec3 tmpvar_13; + tmpvar_13 = tmpvar_12.xyz; + vec3 tmpvar_14; + tmpvar_14 = tmpvar_13; + o.Normal = tmpvar_14; +} + +vec4 LightingTreeLeaf ( + in LeafSurfaceOutput s, + in vec3 lightDir, + in vec3 viewDir, + in float atten +) +{ + vec4 c; + vec3 col; + vec3 translucencyColor; + float trans; + float spec; + float nh; + float diff; + vec3 h; + vec3 tmpvar_1; + tmpvar_1 = normalize ((lightDir + viewDir)); + vec3 tmpvar_2; + tmpvar_2 = tmpvar_1; + h = tmpvar_2; + float tmpvar_3; + tmpvar_3 = dot (s.Normal, lightDir); + float tmpvar_4; + tmpvar_4 = tmpvar_3; + diff = tmpvar_4; + float tmpvar_5; + tmpvar_5 = dot (s.Normal, h); + float tmpvar_6; + tmpvar_6 = max (0.0, tmpvar_5); + float tmpvar_7; + tmpvar_7 = tmpvar_6; + nh = tmpvar_7; + float tmpvar_8; + tmpvar_8 = pow (nh, (s.Specular * 128.0)); + float tmpvar_9; + tmpvar_9 = (tmpvar_8 * s.Gloss); + spec = tmpvar_9; + float tmpvar_10; + tmpvar_10 = max (0.0, -(diff)); + float tmpvar_11; + tmpvar_11 = tmpvar_10; + trans = tmpvar_11; + vec3 tmpvar_12; + tmpvar_12 = ((s.Translucency * trans) * 2.0); + translucencyColor = tmpvar_12; + float tmpvar_13; + tmpvar_13 = max (0.0, ((diff * 0.5) + 0.5)); + float tmpvar_14; + tmpvar_14 = tmpvar_13; + diff = tmpvar_14; + vec3 tmpvar_15; + tmpvar_15 = (s.Albedo * (diff + translucencyColor)); + col = tmpvar_15; + float tmpvar_16; + tmpvar_16 = ceil (trans); + float tmpvar_17; + tmpvar_17 = xll_saturate (tmpvar_16); + vec3 tmpvar_18; + tmpvar_18 = (col + (spec * (1.0 - tmpvar_17))); + col = tmpvar_18; + vec3 tmpvar_19; + tmpvar_19 = (col * _LightColor0.xyz); + col = tmpvar_19; + vec3 tmpvar_20; + tmpvar_20 = (col * (atten * 2.0)); + c.xyz = tmpvar_20.xyz.xyz; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 c; + vec3 lightDir; + LeafSurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = IN.lop_color; + surfIN.color = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Specular = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Alpha = tmpvar_6; + surf (surfIN, o); + xll_clip ((o.Alpha - _Cutoff)); + vec3 tmpvar_7; + tmpvar_7 = IN.lightDir; + lightDir = tmpvar_7; + vec3 tmpvar_8; + tmpvar_8 = normalize (lightDir); + vec3 tmpvar_9; + tmpvar_9 = tmpvar_8; + lightDir = tmpvar_9; + vec3 tmpvar_10; + tmpvar_10 = IN.viewDir.xyz; + vec3 tmpvar_11; + tmpvar_11 = normalize (tmpvar_10); + float tmpvar_12; + tmpvar_12 = dot (IN._LightCoord, IN._LightCoord); + vec2 tmpvar_13; + tmpvar_13 = vec2(tmpvar_12); + vec2 tmpvar_14; + tmpvar_14 = tmpvar_13.xy; + vec4 tmpvar_15; + tmpvar_15 = texture2D (_LightTextureB0, tmpvar_14); + vec4 tmpvar_16; + tmpvar_16 = textureCube (_LightTexture0, IN._LightCoord); + vec4 tmpvar_17; + tmpvar_17 = LightingTreeLeaf (o, lightDir, tmpvar_11, (tmpvar_15.w * tmpvar_16.w)); + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + c = tmpvar_18; + float tmpvar_19; + tmpvar_19 = o.Alpha; + c.w = vec4(tmpvar_19).w; + return c; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xy; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = gl_Color.xyzw; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.lop_color = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = gl_TexCoord[1].xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.lightDir = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = gl_TexCoord[2].xyz; + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_IN.viewDir = tmpvar_10; + vec3 tmpvar_11; + tmpvar_11 = gl_TexCoord[3].xyz; + vec3 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_IN._LightCoord = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = frag_surf (xlt_IN); + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_FragData[0] = tmpvar_16; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Tree_Optimized_Leaf_Shader1-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Tree_Optimized_Leaf_Shader1-out.txt new file mode 100644 index 000000000..e3058dc70 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Tree_Optimized_Leaf_Shader1-out.txt @@ -0,0 +1,51 @@ +uniform sampler2D _TranslucencyMap; +uniform sampler2D _MainTex; +uniform sampler2D _LightTextureB0; +uniform samplerCube _LightTexture0; +uniform vec4 _LightColor0; +uniform float _Cutoff; +uniform sampler2D _BumpSpecMap; +void main () +{ + vec3 tmpvar_1; + tmpvar_1 = gl_TexCoord[1].xyz; + vec3 tmpvar_2; + tmpvar_2 = gl_TexCoord[2].xyz; + vec3 tmpvar_3; + tmpvar_3 = gl_TexCoord[3].xyz; + vec4 c; + vec2 tmpvar_4; + tmpvar_4 = gl_TexCoord[0].xy; + vec4 tmpvar_5; + tmpvar_5 = texture2D (_MainTex, tmpvar_4); + vec3 tmpvar_6; + tmpvar_6 = (tmpvar_5.xyz * gl_Color.xyz); + vec4 tmpvar_7; + tmpvar_7 = texture2D (_TranslucencyMap, tmpvar_4); + float tmpvar_8; + tmpvar_8 = (tmpvar_5.w * gl_Color.w); + vec4 tmpvar_9; + tmpvar_9 = texture2D (_BumpSpecMap, tmpvar_4); + vec4 normal; + normal.xy = ((tmpvar_9.wy * 2.0) - 1.0); + normal.z = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + vec3 tmpvar_10; + tmpvar_10 = normal.xyz; + float x; + x = (tmpvar_8 - _Cutoff); + if ((x < 0.0)) { + discard; + }; + vec3 tmpvar_11; + tmpvar_11 = normalize (tmpvar_1); + vec4 c_i0_i1; + float tmpvar_12; + tmpvar_12 = dot (tmpvar_10, tmpvar_11); + float tmpvar_13; + tmpvar_13 = max (0.0, -(tmpvar_12)); + c_i0_i1.xyz = ((((tmpvar_6 * (max (0.0, ((tmpvar_12 * 0.5) + 0.5)) + ((tmpvar_7.xyz * tmpvar_13) * 2.0))) + ((pow (max (0.0, dot (tmpvar_10, normalize ((tmpvar_11 + normalize (tmpvar_2))))), (tmpvar_9.x * 128.0)) * tmpvar_7.w) * (1.0 - clamp (ceil (tmpvar_13), 0.0, 1.0)))) * _LightColor0.xyz) * ((texture2D (_LightTextureB0, vec2(dot (tmpvar_3, tmpvar_3))).w * textureCube (_LightTexture0, tmpvar_3).w) * 2.0)); + c = c_i0_i1; + c.w = tmpvar_8; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Twirt_Effect_Shader-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Twirt_Effect_Shader-in.txt new file mode 100644 index 000000000..b7032ae44 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Twirt_Effect_Shader-in.txt @@ -0,0 +1,49 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct v2f { + vec4 pos; + vec2 uv; +}; +uniform vec4 _CenterRadius; +uniform sampler2D _MainTex; +uniform mat4 _RotationMatrix; +vec2 MultiplyUV( in mat4 mat, in vec2 inUV ); +vec4 frag( in v2f i ); +vec2 MultiplyUV( in mat4 mat, in vec2 inUV ) { + vec4 temp; + temp = vec4( inUV.x , inUV.y , 0.000000, 0.000000); + temp = ( mat * temp ); + return temp.xy ; +} +vec4 frag( in v2f i ) { + vec2 offset; + vec2 distortedOffset; + vec2 tmp; + float t; + offset = i.uv; + distortedOffset = MultiplyUV( _RotationMatrix, offset.xy ); + tmp = (offset / _CenterRadius.zw ); + t = min( 1.00000, length( tmp )); + offset = mix( distortedOffset, offset, vec2( t)); + offset += _CenterRadius.xy ; + return texture2D( _MainTex, offset); +} +void main() { + vec4 xl_retval; + v2f xlt_i; + xlt_i.pos = vec4(0.0); + xlt_i.uv = vec2( gl_TexCoord[0]); + xl_retval = frag( xlt_i); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Twirt_Effect_Shader-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Twirt_Effect_Shader-ir.txt new file mode 100644 index 000000000..cc3f2f061 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Twirt_Effect_Shader-ir.txt @@ -0,0 +1,91 @@ +struct v2f { + vec4 pos; + vec2 uv; +}; +uniform mat4 _RotationMatrix; +uniform sampler2D _MainTex; +uniform vec4 _CenterRadius; +vec2 MultiplyUV ( + in mat4 mat, + in vec2 inUV +) +{ + vec4 temp; + vec4 tmpvar_1; + tmpvar_1.zw = vec2(0.0, 0.0); + tmpvar_1.x = inUV.x; + tmpvar_1.y = inUV.y; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + temp = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = (mat * temp); + temp = tmpvar_3; + return temp.xy; +} + +vec4 frag ( + in v2f i +) +{ + float t; + vec2 tmp; + vec2 distortedOffset; + vec2 offset; + vec2 tmpvar_1; + tmpvar_1 = i.uv; + offset = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = MultiplyUV (_RotationMatrix, offset.xy); + vec2 tmpvar_3; + tmpvar_3 = tmpvar_2; + distortedOffset = tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = (offset / _CenterRadius.zw); + tmp = tmpvar_4; + float tmpvar_5; + tmpvar_5 = length (tmp); + float tmpvar_6; + tmpvar_6 = min (1.0, tmpvar_5); + float tmpvar_7; + tmpvar_7 = tmpvar_6; + t = tmpvar_7; + vec2 tmpvar_8; + tmpvar_8 = vec2(t); + vec2 tmpvar_9; + tmpvar_9 = mix (distortedOffset, offset, tmpvar_8); + vec2 tmpvar_10; + tmpvar_10 = tmpvar_9; + offset = tmpvar_10; + vec2 tmpvar_11; + tmpvar_11 = (offset + _CenterRadius.xy); + offset = tmpvar_11; + vec4 tmpvar_12; + tmpvar_12 = texture2D (_MainTex, offset); + return tmpvar_12; +} + +void main () +{ + v2f xlt_i; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_i.pos = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = gl_TexCoord[0].xy; + vec2 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_i.uv = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = frag (xlt_i); + vec4 tmpvar_5; + tmpvar_5 = tmpvar_4; + xl_retval = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = xl_retval.xyzw; + vec4 tmpvar_7; + tmpvar_7 = tmpvar_6; + gl_FragData[0] = tmpvar_7; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Twirt_Effect_Shader-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Twirt_Effect_Shader-out.txt new file mode 100644 index 000000000..e3ca834b4 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Twirt_Effect_Shader-out.txt @@ -0,0 +1,14 @@ +uniform mat4 _RotationMatrix; +uniform sampler2D _MainTex; +uniform vec4 _CenterRadius; +void main () +{ + vec2 tmpvar_1; + tmpvar_1 = gl_TexCoord[0].xy; + vec4 tmpvar_2; + tmpvar_2.zw = vec2(0.0, 0.0); + tmpvar_2.x = tmpvar_1.x; + tmpvar_2.y = tmpvar_1.y; + gl_FragData[0] = texture2D (_MainTex, (mix ((_RotationMatrix * tmpvar_2).xy, tmpvar_1, vec2(min (1.0, length ((tmpvar_1 / _CenterRadius.zw))))) + _CenterRadius.xy)); +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Twist_Effect-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Twist_Effect-in.txt new file mode 100644 index 000000000..2e90d990b --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Twist_Effect-in.txt @@ -0,0 +1,75 @@ +void xll_sincos( float x, out float s, out float c) { + s = sin(x); + c = cos(x); +} +void xll_sincos( vec2 x, out vec2 s, out vec2 c) { + s = sin(x); + c = cos(x); +} +void xll_sincos( vec3 x, out vec3 s, out vec3 c) { + s = sin(x); + c = cos(x); +} +void xll_sincos( vec4 x, out vec4 s, out vec4 c) { + s = sin(x); + c = cos(x); +} +void xll_sincos( mat2 x, out mat2 s, out mat2 c) { + s = mat2( sin ( x[0] ), sin ( x[1] ) ); + c = mat2( cos ( x[0] ), cos ( x[1] ) ); +} +void xll_sincos( mat3 x, out mat3 s, out mat3 c) { + s = mat3( sin ( x[0] ), sin ( x[1] ), sin ( x[2] ) ); + c = mat3( cos ( x[0] ), cos ( x[1] ), cos ( x[2] ) ); +} +void xll_sincos( mat4 x, out mat4 s, out mat4 c) { + s = mat4( sin ( x[0] ), sin ( x[1] ), sin ( x[2] ), sin ( x[3] ) ); + c = mat4( cos ( x[0] ), cos ( x[1] ), cos ( x[2] ), cos ( x[3] ) ); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct v2f { + vec4 pos; + vec2 uv; + vec2 uvOrig; +}; +uniform float _Angle; +uniform vec4 _CenterRadius; +uniform sampler2D _MainTex; +vec4 frag( in v2f i ); +vec4 frag( in v2f i ) { + vec2 offset; + float angle; + float sinLength; + float cosLength; + vec2 uv; + offset = i.uvOrig; + angle = (1.00000 - length( (offset / _CenterRadius.zw ) )); + angle = max( 0.000000, angle); + angle = ((angle * angle) * _Angle); + xll_sincos( angle, sinLength, cosLength); + uv.x = ((cosLength * offset.x ) - (sinLength * offset.y )); + uv.y = ((sinLength * offset.x ) + (cosLength * offset.y )); + uv += _CenterRadius.xy ; + return texture2D( _MainTex, uv); +} +void main() { + vec4 xl_retval; + v2f xlt_i; + xlt_i.pos = vec4(0.0); + xlt_i.uv = vec2( gl_TexCoord[0]); + xlt_i.uvOrig = vec2( gl_TexCoord[1]); + xl_retval = frag( xlt_i); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Twist_Effect-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Twist_Effect-ir.txt new file mode 100644 index 000000000..d2b734d76 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Twist_Effect-ir.txt @@ -0,0 +1,287 @@ +struct v2f { + vec4 pos; + vec2 uv; + vec2 uvOrig; +}; +uniform sampler2D _MainTex; +uniform vec4 _CenterRadius; +uniform float _Angle; +void xll_sincos ( + in float x, + out float s, + out float c +) +{ + float tmpvar_1; + tmpvar_1 = sin (x); + float tmpvar_2; + tmpvar_2 = tmpvar_1; + s = tmpvar_2; + float tmpvar_3; + tmpvar_3 = cos (x); + float tmpvar_4; + tmpvar_4 = tmpvar_3; + c = tmpvar_4; +} + +void xll_sincos ( + in vec2 x, + out vec2 s, + out vec2 c +) +{ + vec2 tmpvar_1; + tmpvar_1 = sin (x); + vec2 tmpvar_2; + tmpvar_2 = tmpvar_1; + s = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = cos (x); + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + c = tmpvar_4; +} + +void xll_sincos ( + in vec3 x, + out vec3 s, + out vec3 c +) +{ + vec3 tmpvar_1; + tmpvar_1 = sin (x); + vec3 tmpvar_2; + tmpvar_2 = tmpvar_1; + s = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = cos (x); + vec3 tmpvar_4; + tmpvar_4 = tmpvar_3; + c = tmpvar_4; +} + +void xll_sincos ( + in vec4 x, + out vec4 s, + out vec4 c +) +{ + vec4 tmpvar_1; + tmpvar_1 = sin (x); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + s = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = cos (x); + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + c = tmpvar_4; +} + +void xll_sincos ( + in mat2 x, + out mat2 s, + out mat2 c +) +{ + vec2 tmpvar_1; + tmpvar_1 = sin (x[0]); + vec2 tmpvar_2; + tmpvar_2 = sin (x[1]); + mat2 tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_1; + tmpvar_3[0] = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5 = tmpvar_2; + tmpvar_3[1] = tmpvar_5; + mat2 tmpvar_6; + tmpvar_6 = (tmpvar_3); + s = (tmpvar_6); + vec2 tmpvar_7; + tmpvar_7 = cos (x[0]); + vec2 tmpvar_8; + tmpvar_8 = cos (x[1]); + mat2 tmpvar_9; + vec2 tmpvar_10; + tmpvar_10 = tmpvar_7; + tmpvar_9[0] = tmpvar_10; + vec2 tmpvar_11; + tmpvar_11 = tmpvar_8; + tmpvar_9[1] = tmpvar_11; + mat2 tmpvar_12; + tmpvar_12 = (tmpvar_9); + c = (tmpvar_12); +} + +void xll_sincos ( + in mat3 x, + out mat3 s, + out mat3 c +) +{ + vec3 tmpvar_1; + tmpvar_1 = sin (x[0]); + vec3 tmpvar_2; + tmpvar_2 = sin (x[1]); + vec3 tmpvar_3; + tmpvar_3 = sin (x[2]); + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + mat3 tmpvar_8; + tmpvar_8 = (tmpvar_4); + s = (tmpvar_8); + vec3 tmpvar_9; + tmpvar_9 = cos (x[0]); + vec3 tmpvar_10; + tmpvar_10 = cos (x[1]); + vec3 tmpvar_11; + tmpvar_11 = cos (x[2]); + mat3 tmpvar_12; + vec3 tmpvar_13; + tmpvar_13 = tmpvar_9; + tmpvar_12[0] = tmpvar_13; + vec3 tmpvar_14; + tmpvar_14 = tmpvar_10; + tmpvar_12[1] = tmpvar_14; + vec3 tmpvar_15; + tmpvar_15 = tmpvar_11; + tmpvar_12[2] = tmpvar_15; + mat3 tmpvar_16; + tmpvar_16 = (tmpvar_12); + c = (tmpvar_16); +} + +void xll_sincos ( + in mat4 x, + out mat4 s, + out mat4 c +) +{ + vec4 tmpvar_1; + tmpvar_1 = sin (x[0]); + vec4 tmpvar_2; + tmpvar_2 = sin (x[1]); + vec4 tmpvar_3; + tmpvar_3 = sin (x[2]); + vec4 tmpvar_4; + tmpvar_4 = sin (x[3]); + mat4 tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_1; + tmpvar_5[0] = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = tmpvar_2; + tmpvar_5[1] = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_3; + tmpvar_5[2] = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = tmpvar_4; + tmpvar_5[3] = tmpvar_9; + mat4 tmpvar_10; + tmpvar_10 = (tmpvar_5); + s = (tmpvar_10); + vec4 tmpvar_11; + tmpvar_11 = cos (x[0]); + vec4 tmpvar_12; + tmpvar_12 = cos (x[1]); + vec4 tmpvar_13; + tmpvar_13 = cos (x[2]); + vec4 tmpvar_14; + tmpvar_14 = cos (x[3]); + mat4 tmpvar_15; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_11; + tmpvar_15[0] = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17 = tmpvar_12; + tmpvar_15[1] = tmpvar_17; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_13; + tmpvar_15[2] = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19 = tmpvar_14; + tmpvar_15[3] = tmpvar_19; + mat4 tmpvar_20; + tmpvar_20 = (tmpvar_15); + c = (tmpvar_20); +} + +vec4 frag ( + in v2f i +) +{ + vec2 uv; + float cosLength; + float sinLength; + float angle; + vec2 offset; + vec2 tmpvar_1; + tmpvar_1 = i.uvOrig; + offset = tmpvar_1; + float tmpvar_2; + tmpvar_2 = length ((offset / _CenterRadius.zw)); + float tmpvar_3; + tmpvar_3 = (1.0 - tmpvar_2); + angle = tmpvar_3; + float tmpvar_4; + tmpvar_4 = max (0.0, angle); + float tmpvar_5; + tmpvar_5 = tmpvar_4; + angle = tmpvar_5; + float tmpvar_6; + tmpvar_6 = ((angle * angle) * _Angle); + angle = tmpvar_6; + xll_sincos (angle, sinLength, cosLength); + float tmpvar_7; + tmpvar_7 = ((cosLength * offset.x) - (sinLength * offset.y)); + uv.x = tmpvar_7; + float tmpvar_8; + tmpvar_8 = ((sinLength * offset.x) + (cosLength * offset.y)); + uv.y = vec2(tmpvar_8).y; + vec2 tmpvar_9; + tmpvar_9 = (uv + _CenterRadius.xy); + uv = tmpvar_9; + vec4 tmpvar_10; + tmpvar_10 = texture2D (_MainTex, uv); + return tmpvar_10; +} + +void main () +{ + v2f xlt_i; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_i.pos = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = gl_TexCoord[0].xy; + vec2 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_i.uv = tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = gl_TexCoord[1].xy; + vec2 tmpvar_5; + tmpvar_5 = tmpvar_4; + xlt_i.uvOrig = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = frag (xlt_i); + vec4 tmpvar_7; + tmpvar_7 = tmpvar_6; + xl_retval = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = xl_retval.xyzw; + vec4 tmpvar_9; + tmpvar_9 = tmpvar_8; + gl_FragData[0] = tmpvar_9; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Twist_Effect-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Twist_Effect-out.txt new file mode 100644 index 000000000..567c13d72 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Hidden_Twist_Effect-out.txt @@ -0,0 +1,24 @@ +uniform sampler2D _MainTex; +uniform vec4 _CenterRadius; +uniform float _Angle; +void main () +{ + vec2 tmpvar_1; + tmpvar_1 = gl_TexCoord[1].xy; + vec2 uv; + float tmpvar_2; + tmpvar_2 = max (0.0, (1.0 - length ((tmpvar_1 / _CenterRadius.zw)))); + float tmpvar_3; + tmpvar_3 = ((tmpvar_2 * tmpvar_2) * _Angle); + float tmpvar_4; + tmpvar_4 = sin (tmpvar_3); + float tmpvar_5; + tmpvar_5 = cos (tmpvar_3); + uv.x = ((tmpvar_5 * tmpvar_1.x) - (tmpvar_4 * tmpvar_1.y)); + uv.y = ((tmpvar_4 * tmpvar_1.x) + (tmpvar_5 * tmpvar_1.y)); + vec2 tmpvar_6; + tmpvar_6 = (uv + _CenterRadius.xy); + uv = tmpvar_6; + gl_FragData[0] = texture2D (_MainTex, tmpvar_6); +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Legacy_Shaders_Lightmapped_Bumped_Diffuse-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Legacy_Shaders_Lightmapped_Bumped_Diffuse-in.txt new file mode 100644 index 000000000..a6f7b1238 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Legacy_Shaders_Lightmapped_Bumped_Diffuse-in.txt @@ -0,0 +1,103 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; + vec2 uv2_LightMap; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 lightDir; + vec2 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform sampler2D _BumpMap; +uniform vec4 _Color; +uniform vec4 _LightColor0; +uniform sampler2D _LightMap; +uniform sampler2D _LightTexture0; +uniform sampler2D _MainTex; +vec4 UnpackNormal( in vec4 packednormal ); +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ); +vec4 frag_surf( in v2f_surf IN ); +vec4 UnpackNormal( in vec4 packednormal ) { + vec4 normal; + normal.xy = ((packednormal.wy * 2.00000) - 1.00000); + normal.z = sqrt( ((1.00000 - (normal.x * normal.x )) - (normal.y * normal.y )) ); + return normal; +} +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 lm; + o.Albedo = (texture2D( _MainTex, IN.uv_MainTex).xyz * vec3( _Color)); + lm = texture2D( _LightMap, IN.uv2_LightMap); + o.Emission = (lm.xyz * o.Albedo.xyz ); + o.Alpha = (lm.w * _Color.w ); + o.Normal = vec3( UnpackNormal( texture2D( _BumpMap, IN.uv_BumpMap))); +} +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ) { + float diff; + vec4 c; + diff = max( 0.000000, dot( s.Normal, lightDir)); + c.xyz = ((s.Albedo * _LightColor0.xyz ) * ((diff * atten) * 2.00000)); + c.w = s.Alpha; + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec3 lightDir; + vec4 c; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + surfIN.uv_BumpMap = IN.hip_pack0.zw ; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + surf( surfIN, o); + lightDir = IN.lightDir; + c = LightingLambert( o, lightDir, (texture2D( _LightTexture0, IN._LightCoord).w * 1.00000)); + c.w = 0.000000; + return c; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec4( gl_TexCoord[0]); + xlt_IN.lightDir = vec3( gl_TexCoord[1]); + xlt_IN._LightCoord = vec2( gl_TexCoord[2]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Legacy_Shaders_Lightmapped_Bumped_Diffuse-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Legacy_Shaders_Lightmapped_Bumped_Diffuse-ir.txt new file mode 100644 index 000000000..67a588cc8 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Legacy_Shaders_Lightmapped_Bumped_Diffuse-ir.txt @@ -0,0 +1,185 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; + vec2 uv2_LightMap; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 lightDir; + vec2 _LightCoord; +}; +varying vec4 xlv_FOG; +uniform sampler2D _MainTex; +uniform sampler2D _LightTexture0; +uniform sampler2D _LightMap; +uniform vec4 _LightColor0; +uniform vec4 _Color; +uniform sampler2D _BumpMap; +vec4 UnpackNormal ( + in vec4 packednormal +) +{ + vec4 normal; + vec2 tmpvar_1; + tmpvar_1 = ((packednormal.wy * 2.0) - 1.0); + normal.xy = tmpvar_1.xy.xy; + float tmpvar_2; + tmpvar_2 = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + normal.z = vec3(tmpvar_3).z; + return normal; +} + +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 lm; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec3 tmpvar_2; + tmpvar_2 = _Color.xyz; + vec3 tmpvar_3; + tmpvar_3 = (tmpvar_1.xyz * tmpvar_2); + o.Albedo = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = texture2D (_LightMap, IN.uv2_LightMap); + vec4 tmpvar_5; + tmpvar_5 = tmpvar_4; + lm = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = (lm.xyz * o.Albedo.xyz); + o.Emission = tmpvar_6; + float tmpvar_7; + tmpvar_7 = (lm.w * _Color.w); + o.Alpha = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = texture2D (_BumpMap, IN.uv_BumpMap); + vec4 tmpvar_9; + tmpvar_9 = UnpackNormal (tmpvar_8); + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9.xyz; + vec3 tmpvar_11; + tmpvar_11 = tmpvar_10; + o.Normal = tmpvar_11; +} + +vec4 LightingLambert ( + in SurfaceOutput s, + in vec3 lightDir, + in float atten +) +{ + vec4 c; + float diff; + float tmpvar_1; + tmpvar_1 = dot (s.Normal, lightDir); + float tmpvar_2; + tmpvar_2 = max (0.0, tmpvar_1); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + diff = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = ((s.Albedo * _LightColor0.xyz) * ((diff * atten) * 2.0)); + c.xyz = tmpvar_4.xyz.xyz; + float tmpvar_5; + tmpvar_5 = s.Alpha; + c.w = vec4(tmpvar_5).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 c; + vec3 lightDir; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = IN.hip_pack0.zw; + surfIN.uv_BumpMap = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Specular = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Alpha = tmpvar_6; + float tmpvar_7; + tmpvar_7 = 0.0; + o.Gloss = tmpvar_7; + surf (surfIN, o); + vec3 tmpvar_8; + tmpvar_8 = IN.lightDir; + lightDir = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = texture2D (_LightTexture0, IN._LightCoord); + vec4 tmpvar_10; + tmpvar_10 = LightingLambert (o, lightDir, (tmpvar_9.w * 1.0)); + vec4 tmpvar_11; + tmpvar_11 = tmpvar_10; + c = tmpvar_11; + float tmpvar_12; + tmpvar_12 = 0.0; + c.w = vec4(tmpvar_12).w; + return c; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.lightDir = tmpvar_6; + vec2 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xy; + vec2 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN._LightCoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = frag_surf (xlt_IN); + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xl_retval = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = xl_retval.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + gl_FragData[0] = tmpvar_12; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Legacy_Shaders_Lightmapped_Bumped_Diffuse-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Legacy_Shaders_Lightmapped_Bumped_Diffuse-out.txt new file mode 100644 index 000000000..567d34db3 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Legacy_Shaders_Lightmapped_Bumped_Diffuse-out.txt @@ -0,0 +1,23 @@ +uniform sampler2D _MainTex; +uniform sampler2D _LightTexture0; +uniform sampler2D _LightMap; +uniform vec4 _LightColor0; +uniform vec4 _Color; +uniform sampler2D _BumpMap; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = gl_TexCoord[0]; + vec4 c; + vec2 tmpvar_2; + vec4 normal; + normal.xy = ((texture2D (_BumpMap, tmpvar_1.zw).wy * 2.0) - 1.0); + normal.z = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + vec4 c_i0; + c_i0.xyz = (((texture2D (_MainTex, tmpvar_1.xy).xyz * _Color.xyz) * _LightColor0.xyz) * ((max (0.0, dot (normal.xyz, gl_TexCoord[1].xyz)) * texture2D (_LightTexture0, gl_TexCoord[2].xy).w) * 2.0)); + c_i0.w = (texture2D (_LightMap, tmpvar_2).w * _Color.w); + c = c_i0; + c.w = 0.0; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Legacy_Shaders_Lightmapped_Bumped_Diffuse2-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Legacy_Shaders_Lightmapped_Bumped_Diffuse2-in.txt new file mode 100644 index 000000000..ea160ddf8 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Legacy_Shaders_Lightmapped_Bumped_Diffuse2-in.txt @@ -0,0 +1,101 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; + vec2 uv2_LightMap; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec4 hip_screen; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform sampler2D _BumpMap; +uniform vec4 _Color; +uniform sampler2D _LightBuffer; +uniform sampler2D _LightMap; +uniform sampler2D _MainTex; +uniform vec4 unity_Ambient; +vec4 UnpackNormal( in vec4 packednormal ); +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingLambert_PrePass( in SurfaceOutput s, in vec4 light ); +vec4 frag_surf( in v2f_surf IN ); +vec4 UnpackNormal( in vec4 packednormal ) { + vec4 normal; + normal.xy = ((packednormal.wy * 2.00000) - 1.00000); + normal.z = sqrt( ((1.00000 - (normal.x * normal.x )) - (normal.y * normal.y )) ); + return normal; +} +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 lm; + o.Albedo = (texture2D( _MainTex, IN.uv_MainTex).xyz * vec3( _Color)); + lm = texture2D( _LightMap, IN.uv2_LightMap); + o.Emission = (lm.xyz * o.Albedo.xyz ); + o.Alpha = (lm.w * _Color.w ); + o.Normal = vec3( UnpackNormal( texture2D( _BumpMap, IN.uv_BumpMap))); +} +vec4 LightingLambert_PrePass( in SurfaceOutput s, in vec4 light ) { + vec4 c; + c.xyz = (s.Albedo * light.xyz ); + c.w = s.Alpha; + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec4 light; + vec4 col; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + surfIN.uv2_LightMap = IN.hip_pack0.zw ; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + surf( surfIN, o); + light = texture2DProj( _LightBuffer, IN.hip_screen); + light = ( -log2( light ) ); + light.xyz += unity_Ambient.xyz ; + col = LightingLambert_PrePass( o, light); + col.xyz += o.Emission; + return col; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec4( gl_TexCoord[0]); + xlt_IN.hip_screen = vec4( gl_TexCoord[1]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Legacy_Shaders_Lightmapped_Bumped_Diffuse2-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Legacy_Shaders_Lightmapped_Bumped_Diffuse2-ir.txt new file mode 100644 index 000000000..5adb98c3d --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Legacy_Shaders_Lightmapped_Bumped_Diffuse2-ir.txt @@ -0,0 +1,178 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; + vec2 uv2_LightMap; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec4 hip_screen; +}; +varying vec4 xlv_FOG; +uniform vec4 unity_Ambient; +uniform sampler2D _MainTex; +uniform sampler2D _LightMap; +uniform sampler2D _LightBuffer; +uniform vec4 _Color; +uniform sampler2D _BumpMap; +vec4 UnpackNormal ( + in vec4 packednormal +) +{ + vec4 normal; + vec2 tmpvar_1; + tmpvar_1 = ((packednormal.wy * 2.0) - 1.0); + normal.xy = tmpvar_1.xy.xy; + float tmpvar_2; + tmpvar_2 = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + normal.z = vec3(tmpvar_3).z; + return normal; +} + +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 lm; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec3 tmpvar_2; + tmpvar_2 = _Color.xyz; + vec3 tmpvar_3; + tmpvar_3 = (tmpvar_1.xyz * tmpvar_2); + o.Albedo = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = texture2D (_LightMap, IN.uv2_LightMap); + vec4 tmpvar_5; + tmpvar_5 = tmpvar_4; + lm = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = (lm.xyz * o.Albedo.xyz); + o.Emission = tmpvar_6; + float tmpvar_7; + tmpvar_7 = (lm.w * _Color.w); + o.Alpha = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = texture2D (_BumpMap, IN.uv_BumpMap); + vec4 tmpvar_9; + tmpvar_9 = UnpackNormal (tmpvar_8); + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9.xyz; + vec3 tmpvar_11; + tmpvar_11 = tmpvar_10; + o.Normal = tmpvar_11; +} + +vec4 LightingLambert_PrePass ( + in SurfaceOutput s, + in vec4 light +) +{ + vec4 c; + vec3 tmpvar_1; + tmpvar_1 = (s.Albedo * light.xyz); + c.xyz = tmpvar_1.xyz.xyz; + float tmpvar_2; + tmpvar_2 = s.Alpha; + c.w = vec4(tmpvar_2).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 col; + vec4 light; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = IN.hip_pack0.zw; + surfIN.uv2_LightMap = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Specular = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Alpha = tmpvar_6; + float tmpvar_7; + tmpvar_7 = 0.0; + o.Gloss = tmpvar_7; + surf (surfIN, o); + vec4 tmpvar_8; + tmpvar_8 = texture2DProj (_LightBuffer, IN.hip_screen); + vec4 tmpvar_9; + tmpvar_9 = tmpvar_8; + light = tmpvar_9; + vec4 tmpvar_10; + tmpvar_10 = log2 (light); + vec4 tmpvar_11; + tmpvar_11 = -(tmpvar_10); + light = tmpvar_11; + vec3 tmpvar_12; + tmpvar_12 = (light.xyz + unity_Ambient.xyz); + light.xyz = tmpvar_12.xyz.xyz; + vec4 tmpvar_13; + tmpvar_13 = LightingLambert_PrePass (o, light); + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + col = tmpvar_14; + vec3 tmpvar_15; + tmpvar_15 = (col.xyz + o.Emission); + col.xyz = tmpvar_15.xyz.xyz; + return col; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyzw; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.hip_screen = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = frag_surf (xlt_IN); + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xl_retval = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = xl_retval.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + gl_FragData[0] = tmpvar_10; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Legacy_Shaders_Lightmapped_Bumped_Diffuse2-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Legacy_Shaders_Lightmapped_Bumped_Diffuse2-out.txt new file mode 100644 index 000000000..4009f2a23 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Legacy_Shaders_Lightmapped_Bumped_Diffuse2-out.txt @@ -0,0 +1,32 @@ +uniform vec4 unity_Ambient; +uniform sampler2D _MainTex; +uniform sampler2D _LightMap; +uniform sampler2D _LightBuffer; +uniform vec4 _Color; +uniform sampler2D _BumpMap; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = gl_TexCoord[0]; + vec4 col; + vec4 light; + vec2 tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = (texture2D (_MainTex, tmpvar_1.xy).xyz * _Color.xyz); + vec4 tmpvar_4; + tmpvar_4 = texture2D (_LightMap, tmpvar_1.zw); + vec4 normal; + normal.xy = ((texture2D (_BumpMap, tmpvar_2).wy * 2.0) - 1.0); + normal.z = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + vec4 tmpvar_5; + tmpvar_5 = -(log2 (texture2DProj (_LightBuffer, gl_TexCoord[1]))); + light = tmpvar_5; + light.xyz = (tmpvar_5.xyz + unity_Ambient.xyz); + vec4 c; + c.xyz = (tmpvar_3 * light.xyz); + c.w = (tmpvar_4.w * _Color.w); + col = c; + col.xyz = (c.xyz + (tmpvar_4.xyz * tmpvar_3)); + gl_FragData[0] = col; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Legacy_Shaders_Lightmapped_Diffuse-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Legacy_Shaders_Lightmapped_Diffuse-in.txt new file mode 100644 index 000000000..90441a170 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Legacy_Shaders_Lightmapped_Diffuse-in.txt @@ -0,0 +1,105 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv2_LightMap; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 normal; + vec3 lightDir; + vec4 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _Color; +uniform vec4 _LightColor0; +uniform sampler2D _LightMap; +uniform sampler2D _LightTexture0; +uniform sampler2D _LightTextureB0; +uniform sampler2D _MainTex; +void surf( in Input IN, inout SurfaceOutput o ); +float UnitySpotCookie( in vec4 LightCoord ); +float UnitySpotAttenuate( in vec3 LightCoord ); +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ); +vec4 frag_surf( in v2f_surf IN ); +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 lm; + o.Albedo = (texture2D( _MainTex, IN.uv_MainTex).xyz * vec3( _Color)); + lm = texture2D( _LightMap, IN.uv2_LightMap); + o.Emission = (lm.xyz * o.Albedo.xyz ); + o.Alpha = (lm.w * _Color.w ); +} +float UnitySpotCookie( in vec4 LightCoord ) { + return texture2D( _LightTexture0, ((LightCoord.xy / LightCoord.w ) + 0.500000)).w ; +} +float UnitySpotAttenuate( in vec3 LightCoord ) { + return texture2D( _LightTextureB0, vec2( vec2( dot( LightCoord, LightCoord)))).w ; +} +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ) { + float diff; + vec4 c; + diff = max( 0.000000, dot( s.Normal, lightDir)); + c.xyz = ((s.Albedo * _LightColor0.xyz ) * ((diff * atten) * 2.00000)); + c.w = s.Alpha; + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec3 lightDir; + vec4 c; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + o.Normal = IN.normal; + surf( surfIN, o); + lightDir = IN.lightDir; + lightDir = normalize( lightDir ); + c = LightingLambert( o, lightDir, ((float( (IN._LightCoord.z > 0.000000) ) * UnitySpotCookie( IN._LightCoord)) * UnitySpotAttenuate( IN._LightCoord.xyz ))); + c.w = 0.000000; + return c; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec2( gl_TexCoord[0]); + xlt_IN.normal = vec3( gl_TexCoord[1]); + xlt_IN.lightDir = vec3( gl_TexCoord[2]); + xlt_IN._LightCoord = vec4( gl_TexCoord[3]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Legacy_Shaders_Lightmapped_Diffuse-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Legacy_Shaders_Lightmapped_Diffuse-ir.txt new file mode 100644 index 000000000..fd1d23561 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Legacy_Shaders_Lightmapped_Diffuse-ir.txt @@ -0,0 +1,196 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv2_LightMap; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 normal; + vec3 lightDir; + vec4 _LightCoord; +}; +varying vec4 xlv_FOG; +uniform sampler2D _MainTex; +uniform sampler2D _LightTextureB0; +uniform sampler2D _LightTexture0; +uniform sampler2D _LightMap; +uniform vec4 _LightColor0; +uniform vec4 _Color; +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 lm; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec3 tmpvar_2; + tmpvar_2 = _Color.xyz; + vec3 tmpvar_3; + tmpvar_3 = (tmpvar_1.xyz * tmpvar_2); + o.Albedo = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = texture2D (_LightMap, IN.uv2_LightMap); + vec4 tmpvar_5; + tmpvar_5 = tmpvar_4; + lm = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = (lm.xyz * o.Albedo.xyz); + o.Emission = tmpvar_6; + float tmpvar_7; + tmpvar_7 = (lm.w * _Color.w); + o.Alpha = tmpvar_7; +} + +float UnitySpotCookie ( + in vec4 LightCoord +) +{ + vec4 tmpvar_1; + tmpvar_1 = texture2D (_LightTexture0, ((LightCoord.xy / LightCoord.w) + 0.5)); + return tmpvar_1.w; +} + +float UnitySpotAttenuate ( + in vec3 LightCoord +) +{ + float tmpvar_1; + tmpvar_1 = dot (LightCoord, LightCoord); + vec2 tmpvar_2; + tmpvar_2 = vec2(tmpvar_1); + vec2 tmpvar_3; + tmpvar_3 = tmpvar_2.xy; + vec4 tmpvar_4; + tmpvar_4 = texture2D (_LightTextureB0, tmpvar_3); + return tmpvar_4.w; +} + +vec4 LightingLambert ( + in SurfaceOutput s, + in vec3 lightDir, + in float atten +) +{ + vec4 c; + float diff; + float tmpvar_1; + tmpvar_1 = dot (s.Normal, lightDir); + float tmpvar_2; + tmpvar_2 = max (0.0, tmpvar_1); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + diff = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = ((s.Albedo * _LightColor0.xyz) * ((diff * atten) * 2.0)); + c.xyz = tmpvar_4.xyz.xyz; + float tmpvar_5; + tmpvar_5 = s.Alpha; + c.w = vec4(tmpvar_5).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 c; + vec3 lightDir; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_3; + float tmpvar_4; + tmpvar_4 = 0.0; + o.Specular = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Alpha = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Gloss = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = IN.normal; + o.Normal = tmpvar_7; + surf (surfIN, o); + vec3 tmpvar_8; + tmpvar_8 = IN.lightDir; + lightDir = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = normalize (lightDir); + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + lightDir = tmpvar_10; + float tmpvar_11; + tmpvar_11 = UnitySpotCookie (IN._LightCoord); + float tmpvar_12; + tmpvar_12 = UnitySpotAttenuate (IN._LightCoord.xyz); + vec4 tmpvar_13; + tmpvar_13 = LightingLambert (o, lightDir, ((float((IN._LightCoord.z > 0.0)) * tmpvar_11) * tmpvar_12)); + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + c = tmpvar_14; + float tmpvar_15; + tmpvar_15 = 0.0; + c.w = vec4(tmpvar_15).w; + return c; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xy; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.normal = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.lightDir = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_TexCoord[3].xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_IN._LightCoord = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = frag_surf (xlt_IN); + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xl_retval = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = xl_retval.xyzw; + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + gl_FragData[0] = tmpvar_14; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Legacy_Shaders_Lightmapped_Diffuse-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Legacy_Shaders_Lightmapped_Diffuse-out.txt new file mode 100644 index 000000000..0c538738d --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Legacy_Shaders_Lightmapped_Diffuse-out.txt @@ -0,0 +1,22 @@ +uniform sampler2D _MainTex; +uniform sampler2D _LightTextureB0; +uniform sampler2D _LightTexture0; +uniform sampler2D _LightMap; +uniform vec4 _LightColor0; +uniform vec4 _Color; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = gl_TexCoord[3]; + vec4 c; + vec2 tmpvar_2; + vec3 LightCoord_i0; + LightCoord_i0 = tmpvar_1.xyz; + vec4 c_i0; + c_i0.xyz = (((texture2D (_MainTex, gl_TexCoord[0].xy).xyz * _Color.xyz) * _LightColor0.xyz) * ((max (0.0, dot (gl_TexCoord[1].xyz, normalize (gl_TexCoord[2].xyz))) * ((float((tmpvar_1.z > 0.0)) * texture2D (_LightTexture0, ((tmpvar_1.xy / tmpvar_1.w) + 0.5)).w) * texture2D (_LightTextureB0, vec2(dot (LightCoord_i0, LightCoord_i0))).w)) * 2.0)); + c_i0.w = (texture2D (_LightMap, tmpvar_2).w * _Color.w); + c = c_i0; + c.w = 0.0; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-MobileBumpSpec-inES.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-MobileBumpSpec-inES.txt new file mode 100644 index 000000000..0867ee8a2 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-MobileBumpSpec-inES.txt @@ -0,0 +1,83 @@ +struct SurfaceOutput { + lowp vec3 Albedo; + lowp vec3 Normal; + lowp vec3 Emission; + mediump float Specular; + lowp float Gloss; + lowp float Alpha; +}; +struct Input { + mediump vec2 uv_MainTex; +}; +struct v2f_surf { + highp vec4 pos; + mediump vec2 pack0; + mediump vec3 viewDir; + lowp vec3 lightDir; + lowp vec3 vlight; +}; +uniform sampler2D _BumpMap; +uniform lowp vec4 _LightColor0; +uniform sampler2D _MainTex; +uniform mediump float _Shininess; +lowp vec3 UnpackNormal( in lowp vec4 packednormal ); +void surf( in Input IN, inout SurfaceOutput o ); +lowp vec4 LightingMobileBlinnPhong( in SurfaceOutput s, in lowp vec3 lightDir, in lowp vec3 halfDir, in lowp float atten ); +lowp vec4 frag_surf( in v2f_surf IN ); +lowp vec3 UnpackNormal( in lowp vec4 packednormal ) { + return ((packednormal.xyz * 2.0) - 1.0); +} +void surf( in Input IN, inout SurfaceOutput o ) { + lowp vec4 tex; + tex = texture2D( _MainTex, IN.uv_MainTex); + o.Albedo = tex.xyz ; + o.Gloss = tex.w ; + o.Alpha = tex.w ; + o.Specular = _Shininess; + o.Normal = UnpackNormal( texture2D( _BumpMap, IN.uv_MainTex)); +} +lowp vec4 LightingMobileBlinnPhong( in SurfaceOutput s, in lowp vec3 lightDir, in lowp vec3 halfDir, in lowp float atten ) { + lowp float diff; + lowp float nh; + lowp float spec; + lowp vec4 c; + diff = max( 0.0, dot( s.Normal, lightDir)); + nh = max( 0.0, dot( s.Normal, halfDir)); + spec = (pow( nh, (s.Specular * 128.0)) * s.Gloss); + c.xyz = ((((s.Albedo * diff) + spec) * _LightColor0.xyz ) * (atten * 2.0)); + c.w = 0.0; + return c; +} +lowp vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + lowp float atten; + lowp vec4 c; + surfIN.uv_MainTex = IN.pack0.xy ; + o.Albedo = vec3( 0.0); + o.Emission = vec3( 0.0); + o.Specular = 0.0; + o.Alpha = 0.0; + o.Gloss = 0.0; + surf( surfIN, o); + atten = 1.0; + c = vec4( 0.0); + c = LightingMobileBlinnPhong( o, IN.lightDir, IN.viewDir, atten); + c.xyz += (o.Albedo * IN.vlight); + return c; +} +varying mediump vec2 xlv_TEXCOORD0; +varying mediump vec3 xlv_TEXCOORD1; +varying lowp vec3 xlv_TEXCOORD2; +varying lowp vec3 xlv_TEXCOORD3; +void main() { + lowp vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.pack0 = vec2( xlv_TEXCOORD0); + xlt_IN.viewDir = vec3( xlv_TEXCOORD1); + xlt_IN.lightDir = vec3( xlv_TEXCOORD2); + xlt_IN.vlight = vec3( xlv_TEXCOORD3); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-MobileBumpSpec-irES.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-MobileBumpSpec-irES.txt new file mode 100644 index 000000000..fbc2ceb61 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-MobileBumpSpec-irES.txt @@ -0,0 +1,187 @@ +struct SurfaceOutput { + lowp vec3 Albedo; + lowp vec3 Normal; + lowp vec3 Emission; + mediump float Specular; + lowp float Gloss; + lowp float Alpha; +}; +struct Input { + mediump vec2 uv_MainTex; +}; +struct v2f_surf { + highp vec4 pos; + mediump vec2 pack0; + mediump vec3 viewDir; + lowp vec3 lightDir; + lowp vec3 vlight; +}; +varying lowp vec3 xlv_TEXCOORD3; +varying lowp vec3 xlv_TEXCOORD2; +varying mediump vec3 xlv_TEXCOORD1; +varying mediump vec2 xlv_TEXCOORD0; +uniform mediump float _Shininess; +uniform sampler2D _MainTex; +uniform lowp vec4 _LightColor0; +uniform sampler2D _BumpMap; +lowp vec3 UnpackNormal ( + in lowp vec4 packednormal +) +{ + return ((packednormal.xyz * 2.0) - 1.0); +} + +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + lowp vec4 tex; + lowp vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + lowp vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + tex = tmpvar_2; + lowp vec3 tmpvar_3; + tmpvar_3 = tex.xyz; + o.Albedo = tmpvar_3; + lowp float tmpvar_4; + tmpvar_4 = tex.w; + o.Gloss = tmpvar_4; + lowp float tmpvar_5; + tmpvar_5 = tex.w; + o.Alpha = tmpvar_5; + mediump float tmpvar_6; + tmpvar_6 = _Shininess; + o.Specular = tmpvar_6; + lowp vec4 tmpvar_7; + tmpvar_7 = texture2D (_BumpMap, IN.uv_MainTex); + lowp vec3 tmpvar_8; + tmpvar_8 = UnpackNormal (tmpvar_7); + lowp vec3 tmpvar_9; + tmpvar_9 = tmpvar_8; + o.Normal = tmpvar_9; +} + +lowp vec4 LightingMobileBlinnPhong ( + in SurfaceOutput s, + in lowp vec3 lightDir, + in lowp vec3 halfDir, + in lowp float atten +) +{ + lowp vec4 c; + lowp float spec; + lowp float nh; + lowp float diff; + lowp float tmpvar_1; + tmpvar_1 = dot (s.Normal, lightDir); + lowp float tmpvar_2; + tmpvar_2 = max (0.0, tmpvar_1); + lowp float tmpvar_3; + tmpvar_3 = tmpvar_2; + diff = tmpvar_3; + lowp float tmpvar_4; + tmpvar_4 = dot (s.Normal, halfDir); + lowp float tmpvar_5; + tmpvar_5 = max (0.0, tmpvar_4); + lowp float tmpvar_6; + tmpvar_6 = tmpvar_5; + nh = tmpvar_6; + mediump float tmpvar_7; + tmpvar_7 = pow (nh, (s.Specular * 128.0)); + mediump float tmpvar_8; + tmpvar_8 = (tmpvar_7 * s.Gloss); + spec = tmpvar_8; + lowp vec3 tmpvar_9; + tmpvar_9 = ((((s.Albedo * diff) + spec) * _LightColor0.xyz) * (atten * 2.0)); + c.xyz = tmpvar_9.xyz.xyz; + float tmpvar_10; + tmpvar_10 = 0.0; + c.w = vec4(tmpvar_10).w; + return c; +} + +lowp vec4 frag_surf ( + in v2f_surf IN +) +{ + lowp vec4 c; + lowp float atten; + SurfaceOutput o; + Input surfIN; + mediump vec2 tmpvar_1; + tmpvar_1 = IN.pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_3; + float tmpvar_4; + tmpvar_4 = 0.0; + o.Specular = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Alpha = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Gloss = tmpvar_6; + surf (surfIN, o); + float tmpvar_7; + tmpvar_7 = 1.0; + atten = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = vec4(0.0, 0.0, 0.0, 0.0); + c = tmpvar_8; + lowp vec4 tmpvar_9; + tmpvar_9 = LightingMobileBlinnPhong (o, IN.lightDir, IN.viewDir, atten); + lowp vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + c = tmpvar_10; + lowp vec3 tmpvar_11; + tmpvar_11 = (c.xyz + (o.Albedo * IN.vlight)); + c.xyz = tmpvar_11.xyz.xyz; + return c; +} + +void main () +{ + v2f_surf xlt_IN; + lowp vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + mediump vec2 tmpvar_2; + tmpvar_2 = xlv_TEXCOORD0.xy; + mediump vec2 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_IN.pack0 = tmpvar_3; + mediump vec3 tmpvar_4; + tmpvar_4 = xlv_TEXCOORD1.xyz; + mediump vec3 tmpvar_5; + tmpvar_5 = tmpvar_4; + xlt_IN.viewDir = tmpvar_5; + lowp vec3 tmpvar_6; + tmpvar_6 = xlv_TEXCOORD2.xyz; + lowp vec3 tmpvar_7; + tmpvar_7 = tmpvar_6; + xlt_IN.lightDir = tmpvar_7; + lowp vec3 tmpvar_8; + tmpvar_8 = xlv_TEXCOORD3.xyz; + lowp vec3 tmpvar_9; + tmpvar_9 = tmpvar_8; + xlt_IN.vlight = tmpvar_9; + lowp vec4 tmpvar_10; + tmpvar_10 = frag_surf (xlt_IN); + lowp vec4 tmpvar_11; + tmpvar_11 = tmpvar_10; + xl_retval = tmpvar_11; + lowp vec4 tmpvar_12; + tmpvar_12 = xl_retval.xyzw; + lowp vec4 tmpvar_13; + tmpvar_13 = tmpvar_12; + gl_FragData[0] = tmpvar_13; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-MobileBumpSpec-outES.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-MobileBumpSpec-outES.txt new file mode 100644 index 000000000..1845aef9f --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-MobileBumpSpec-outES.txt @@ -0,0 +1,31 @@ +varying lowp vec3 xlv_TEXCOORD3; +varying lowp vec3 xlv_TEXCOORD2; +varying mediump vec3 xlv_TEXCOORD1; +varying mediump vec2 xlv_TEXCOORD0; +uniform mediump float _Shininess; +uniform sampler2D _MainTex; +uniform lowp vec4 _LightColor0; +uniform sampler2D _BumpMap; +void main () +{ + lowp vec4 c; + lowp vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, xlv_TEXCOORD0); + lowp vec3 tmpvar_2; + tmpvar_2 = ((texture2D (_BumpMap, xlv_TEXCOORD0).xyz * 2.0) - 1.0); + lowp vec3 halfDir; + halfDir = xlv_TEXCOORD1; + lowp vec4 c_i0; + lowp float spec; + lowp float tmpvar_3; + tmpvar_3 = max (0.0, dot (tmpvar_2, halfDir)); + mediump float tmpvar_4; + tmpvar_4 = (pow (tmpvar_3, (_Shininess * 128.0)) * tmpvar_1.w); + spec = tmpvar_4; + c_i0.xyz = ((((tmpvar_1.xyz * max (0.0, dot (tmpvar_2, xlv_TEXCOORD2))) + spec) * _LightColor0.xyz) * 2.0); + c_i0.w = 0.0; + c = c_i0; + c.xyz = (c_i0.xyz + (tmpvar_1.xyz * xlv_TEXCOORD3)); + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_My_Soft_Occlusion_Leaves-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_My_Soft_Occlusion_Leaves-in.txt new file mode 100644 index 000000000..32bc7b712 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_My_Soft_Occlusion_Leaves-in.txt @@ -0,0 +1,37 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct v2f { + vec4 vertex; + vec4 color; + vec2 texcoord; +}; +struct appdata_t { + vec4 vertex; + vec4 color; + vec2 texcoord; +}; +uniform sampler2D _MainTex; +vec4 frag( in v2f i ); +vec4 frag( in v2f i ) { + return (texture2D( _MainTex, i.texcoord) * vec4( 1.00000, 0.000000, 0.000000, 1.00000)); +} +void main() { + vec4 xl_retval; + v2f xlt_i; + xlt_i.vertex = vec4(0.0); + xlt_i.color = vec4( gl_Color); + xlt_i.texcoord = vec2( gl_TexCoord[0]); + xl_retval = frag( xlt_i); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_My_Soft_Occlusion_Leaves-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_My_Soft_Occlusion_Leaves-ir.txt new file mode 100644 index 000000000..3ae052ffa --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_My_Soft_Occlusion_Leaves-ir.txt @@ -0,0 +1,44 @@ +struct v2f { + vec4 vertex; + vec4 color; + vec2 texcoord; +}; +uniform sampler2D _MainTex; +vec4 frag ( + in v2f i +) +{ + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, i.texcoord); + return (tmpvar_1 * vec4(1.0, 0.0, 0.0, 1.0)); +} + +void main () +{ + v2f xlt_i; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_i.vertex = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = gl_Color.xyzw; + vec4 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_i.color = tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = gl_TexCoord[0].xy; + vec2 tmpvar_5; + tmpvar_5 = tmpvar_4; + xlt_i.texcoord = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = frag (xlt_i); + vec4 tmpvar_7; + tmpvar_7 = tmpvar_6; + xl_retval = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = xl_retval.xyzw; + vec4 tmpvar_9; + tmpvar_9 = tmpvar_8; + gl_FragData[0] = tmpvar_9; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_My_Soft_Occlusion_Leaves-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_My_Soft_Occlusion_Leaves-out.txt new file mode 100644 index 000000000..4a7488099 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_My_Soft_Occlusion_Leaves-out.txt @@ -0,0 +1,6 @@ +uniform sampler2D _MainTex; +void main () +{ + gl_FragData[0] = (texture2D (_MainTex, gl_TexCoord[0].xy) * vec4(1.0, 0.0, 0.0, 1.0)); +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Soft_Occlusion_Bark-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Soft_Occlusion_Bark-in.txt new file mode 100644 index 000000000..a23a5b45e --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Soft_Occlusion_Bark-in.txt @@ -0,0 +1,102 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +struct Input { + vec2 uv_MainTex; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 normal; + vec3 lightDir; + vec4 _LightCoord; +}; +uniform vec4 _Color; +uniform vec4 _LightColor0; +uniform sampler2D _LightTexture0; +uniform sampler2D _LightTextureB0; +uniform sampler2D _MainTex; +void surf( in Input IN, inout SurfaceOutput o ); +float UnitySpotCookie( in vec4 LightCoord ); +float UnitySpotAttenuate( in vec3 LightCoord ); +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ); +vec4 frag_surf( in v2f_surf IN ); +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 c; + c = (texture2D( _MainTex, IN.uv_MainTex) * _Color); + o.Albedo = c.xyz ; + o.Alpha = c.w ; +} +float UnitySpotCookie( in vec4 LightCoord ) { + return texture2D( _LightTexture0, ((LightCoord.xy / LightCoord.w ) + 0.500000)).w ; +} +float UnitySpotAttenuate( in vec3 LightCoord ) { + return texture2D( _LightTextureB0, vec2( vec2( dot( LightCoord, LightCoord)))).w ; +} +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ) { + float diff; + vec4 c; + diff = max( 0.000000, dot( s.Normal, lightDir)); + c.xyz = ((s.Albedo * _LightColor0.xyz ) * ((diff * atten) * 2.00000)); + c.w = s.Alpha; + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec3 lightDir; + vec4 c; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + o.Normal = IN.normal; + surf( surfIN, o); + lightDir = IN.lightDir; + lightDir = normalize( lightDir ); + c = LightingLambert( o, lightDir, ((float( (IN._LightCoord.z > 0.000000) ) * UnitySpotCookie( IN._LightCoord)) * UnitySpotAttenuate( IN._LightCoord.xyz ))); + c.w = 0.000000; + return c; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec2( gl_TexCoord[0]); + xlt_IN.normal = vec3( gl_TexCoord[1]); + xlt_IN.lightDir = vec3( gl_TexCoord[2]); + xlt_IN._LightCoord = vec4( gl_TexCoord[3]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Soft_Occlusion_Bark-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Soft_Occlusion_Bark-ir.txt new file mode 100644 index 000000000..aabb08a73 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Soft_Occlusion_Bark-ir.txt @@ -0,0 +1,187 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 normal; + vec3 lightDir; + vec4 _LightCoord; +}; +varying vec4 xlv_FOG; +uniform sampler2D _MainTex; +uniform sampler2D _LightTextureB0; +uniform sampler2D _LightTexture0; +uniform vec4 _LightColor0; +uniform vec4 _Color; +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 c; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = (tmpvar_1 * _Color); + c = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = c.xyz; + o.Albedo = tmpvar_3; + float tmpvar_4; + tmpvar_4 = c.w; + o.Alpha = tmpvar_4; +} + +float UnitySpotCookie ( + in vec4 LightCoord +) +{ + vec4 tmpvar_1; + tmpvar_1 = texture2D (_LightTexture0, ((LightCoord.xy / LightCoord.w) + 0.5)); + return tmpvar_1.w; +} + +float UnitySpotAttenuate ( + in vec3 LightCoord +) +{ + float tmpvar_1; + tmpvar_1 = dot (LightCoord, LightCoord); + vec2 tmpvar_2; + tmpvar_2 = vec2(tmpvar_1); + vec2 tmpvar_3; + tmpvar_3 = tmpvar_2.xy; + vec4 tmpvar_4; + tmpvar_4 = texture2D (_LightTextureB0, tmpvar_3); + return tmpvar_4.w; +} + +vec4 LightingLambert ( + in SurfaceOutput s, + in vec3 lightDir, + in float atten +) +{ + vec4 c; + float diff; + float tmpvar_1; + tmpvar_1 = dot (s.Normal, lightDir); + float tmpvar_2; + tmpvar_2 = max (0.0, tmpvar_1); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + diff = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = ((s.Albedo * _LightColor0.xyz) * ((diff * atten) * 2.0)); + c.xyz = tmpvar_4.xyz.xyz; + float tmpvar_5; + tmpvar_5 = s.Alpha; + c.w = vec4(tmpvar_5).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 c; + vec3 lightDir; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_3; + float tmpvar_4; + tmpvar_4 = 0.0; + o.Specular = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Alpha = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Gloss = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = IN.normal; + o.Normal = tmpvar_7; + surf (surfIN, o); + vec3 tmpvar_8; + tmpvar_8 = IN.lightDir; + lightDir = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = normalize (lightDir); + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + lightDir = tmpvar_10; + float tmpvar_11; + tmpvar_11 = UnitySpotCookie (IN._LightCoord); + float tmpvar_12; + tmpvar_12 = UnitySpotAttenuate (IN._LightCoord.xyz); + vec4 tmpvar_13; + tmpvar_13 = LightingLambert (o, lightDir, ((float((IN._LightCoord.z > 0.0)) * tmpvar_11) * tmpvar_12)); + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + c = tmpvar_14; + float tmpvar_15; + tmpvar_15 = 0.0; + c.w = vec4(tmpvar_15).w; + return c; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xy; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.normal = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.lightDir = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_TexCoord[3].xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_IN._LightCoord = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = frag_surf (xlt_IN); + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xl_retval = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = xl_retval.xyzw; + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + gl_FragData[0] = tmpvar_14; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Soft_Occlusion_Bark-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Soft_Occlusion_Bark-out.txt new file mode 100644 index 000000000..226dc17e7 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Soft_Occlusion_Bark-out.txt @@ -0,0 +1,22 @@ +uniform sampler2D _MainTex; +uniform sampler2D _LightTextureB0; +uniform sampler2D _LightTexture0; +uniform vec4 _LightColor0; +uniform vec4 _Color; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = gl_TexCoord[3]; + vec4 c; + vec4 tmpvar_2; + tmpvar_2 = (texture2D (_MainTex, gl_TexCoord[0].xy) * _Color); + vec3 LightCoord_i0; + LightCoord_i0 = tmpvar_1.xyz; + vec4 c_i0_i1; + c_i0_i1.xyz = ((tmpvar_2.xyz * _LightColor0.xyz) * ((max (0.0, dot (gl_TexCoord[1].xyz, normalize (gl_TexCoord[2].xyz))) * ((float((tmpvar_1.z > 0.0)) * texture2D (_LightTexture0, ((tmpvar_1.xy / tmpvar_1.w) + 0.5)).w) * texture2D (_LightTextureB0, vec2(dot (LightCoord_i0, LightCoord_i0))).w)) * 2.0)); + c_i0_i1.w = tmpvar_2.w; + c = c_i0_i1; + c.w = 0.0; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Soft_Occlusion_Bark1-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Soft_Occlusion_Bark1-in.txt new file mode 100644 index 000000000..ea4625ddf --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Soft_Occlusion_Bark1-in.txt @@ -0,0 +1,92 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +struct Input { + vec2 uv_MainTex; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 normal; + vec3 lightDir; + vec2 _LightCoord; +}; +uniform vec4 _Color; +uniform vec4 _LightColor0; +uniform sampler2D _LightTexture0; +uniform sampler2D _MainTex; +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ); +vec4 frag_surf( in v2f_surf IN ); +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 c; + c = (texture2D( _MainTex, IN.uv_MainTex) * _Color); + o.Albedo = c.xyz ; + o.Alpha = c.w ; +} +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ) { + float diff; + vec4 c; + diff = max( 0.000000, dot( s.Normal, lightDir)); + c.xyz = ((s.Albedo * _LightColor0.xyz ) * ((diff * atten) * 2.00000)); + c.w = s.Alpha; + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec3 lightDir; + vec4 c; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + o.Normal = IN.normal; + surf( surfIN, o); + lightDir = IN.lightDir; + c = LightingLambert( o, lightDir, (texture2D( _LightTexture0, IN._LightCoord).w * 1.00000)); + c.w = 0.000000; + return c; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec2( gl_TexCoord[0]); + xlt_IN.normal = vec3( gl_TexCoord[1]); + xlt_IN.lightDir = vec3( gl_TexCoord[2]); + xlt_IN._LightCoord = vec2( gl_TexCoord[3]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Soft_Occlusion_Bark1-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Soft_Occlusion_Bark1-ir.txt new file mode 100644 index 000000000..6135e0121 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Soft_Occlusion_Bark1-ir.txt @@ -0,0 +1,155 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 normal; + vec3 lightDir; + vec2 _LightCoord; +}; +varying vec4 xlv_FOG; +uniform sampler2D _MainTex; +uniform sampler2D _LightTexture0; +uniform vec4 _LightColor0; +uniform vec4 _Color; +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 c; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = (tmpvar_1 * _Color); + c = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = c.xyz; + o.Albedo = tmpvar_3; + float tmpvar_4; + tmpvar_4 = c.w; + o.Alpha = tmpvar_4; +} + +vec4 LightingLambert ( + in SurfaceOutput s, + in vec3 lightDir, + in float atten +) +{ + vec4 c; + float diff; + float tmpvar_1; + tmpvar_1 = dot (s.Normal, lightDir); + float tmpvar_2; + tmpvar_2 = max (0.0, tmpvar_1); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + diff = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = ((s.Albedo * _LightColor0.xyz) * ((diff * atten) * 2.0)); + c.xyz = tmpvar_4.xyz.xyz; + float tmpvar_5; + tmpvar_5 = s.Alpha; + c.w = vec4(tmpvar_5).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 c; + vec3 lightDir; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_3; + float tmpvar_4; + tmpvar_4 = 0.0; + o.Specular = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Alpha = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Gloss = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = IN.normal; + o.Normal = tmpvar_7; + surf (surfIN, o); + vec3 tmpvar_8; + tmpvar_8 = IN.lightDir; + lightDir = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = texture2D (_LightTexture0, IN._LightCoord); + vec4 tmpvar_10; + tmpvar_10 = LightingLambert (o, lightDir, (tmpvar_9.w * 1.0)); + vec4 tmpvar_11; + tmpvar_11 = tmpvar_10; + c = tmpvar_11; + float tmpvar_12; + tmpvar_12 = 0.0; + c.w = vec4(tmpvar_12).w; + return c; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xy; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.normal = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.lightDir = tmpvar_8; + vec2 tmpvar_9; + tmpvar_9 = gl_TexCoord[3].xy; + vec2 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_IN._LightCoord = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = frag_surf (xlt_IN); + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xl_retval = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = xl_retval.xyzw; + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + gl_FragData[0] = tmpvar_14; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Soft_Occlusion_Bark1-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Soft_Occlusion_Bark1-out.txt new file mode 100644 index 000000000..cf0b90ffa --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Soft_Occlusion_Bark1-out.txt @@ -0,0 +1,17 @@ +uniform sampler2D _MainTex; +uniform sampler2D _LightTexture0; +uniform vec4 _LightColor0; +uniform vec4 _Color; +void main () +{ + vec4 c; + vec4 tmpvar_1; + tmpvar_1 = (texture2D (_MainTex, gl_TexCoord[0].xy) * _Color); + vec4 c_i0_i1; + c_i0_i1.xyz = ((tmpvar_1.xyz * _LightColor0.xyz) * ((max (0.0, dot (gl_TexCoord[1].xyz, gl_TexCoord[2].xyz)) * texture2D (_LightTexture0, gl_TexCoord[3].xy).w) * 2.0)); + c_i0_i1.w = tmpvar_1.w; + c = c_i0_i1; + c.w = 0.0; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Soft_Occlusion_Bark2-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Soft_Occlusion_Bark2-in.txt new file mode 100644 index 000000000..d10964c37 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Soft_Occlusion_Bark2-in.txt @@ -0,0 +1,76 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +struct Input { + vec2 uv_MainTex; +}; +struct v2f_surf { + vec4 pos; + vec3 vec; +}; +uniform vec4 _Color; +uniform vec4 _LightPositionRange; +uniform sampler2D _MainTex; +void surf( in Input IN, inout SurfaceOutput o ); +vec4 EncodeFloatRGBA( in float v ); +vec4 frag_surf( in v2f_surf IN ); +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 c; + c = (texture2D( _MainTex, IN.uv_MainTex) * _Color); + o.Albedo = c.xyz ; + o.Alpha = c.w ; +} +vec4 EncodeFloatRGBA( in float v ) { + vec4 kEncodeMul = vec4( 1.00000, 255.000, 65025.0, 1.60581e+008); + float kEncodeBit = 0.00392157; + vec4 enc; + enc = (kEncodeMul * v); + enc = fract( enc ); + enc -= (enc.yzww * kEncodeBit); + return enc; +} +vec4 frag_surf( in v2f_surf IN ) { + SurfaceOutput o; + Input surfIN; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + surf( surfIN, o); + return EncodeFloatRGBA( (length( IN.vec ) * _LightPositionRange.w )); +} +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.vec = vec3( gl_TexCoord[0]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Soft_Occlusion_Bark2-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Soft_Occlusion_Bark2-ir.txt new file mode 100644 index 000000000..d0aa9cc44 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Soft_Occlusion_Bark2-ir.txt @@ -0,0 +1,117 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; +}; +struct v2f_surf { + vec4 pos; + vec3 vec; +}; +uniform sampler2D _MainTex; +uniform vec4 _LightPositionRange; +uniform vec4 _Color; +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 c; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = (tmpvar_1 * _Color); + c = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = c.xyz; + o.Albedo = tmpvar_3; + float tmpvar_4; + tmpvar_4 = c.w; + o.Alpha = tmpvar_4; +} + +vec4 EncodeFloatRGBA ( + in float v +) +{ + vec4 enc; + float kEncodeBit; + vec4 kEncodeMul; + vec4 tmpvar_1; + tmpvar_1 = vec4(1.0, 255.0, 65025.0, 160580992.0); + kEncodeMul = tmpvar_1; + float tmpvar_2; + tmpvar_2 = 0.00392157; + kEncodeBit = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = (kEncodeMul * v); + enc = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = fract (enc); + vec4 tmpvar_5; + tmpvar_5 = tmpvar_4; + enc = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = (enc - (enc.yzww * kEncodeBit)); + enc = tmpvar_6; + return enc; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + Input surfIN; + SurfaceOutput o; + vec3 tmpvar_1; + tmpvar_1 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_2; + float tmpvar_3; + tmpvar_3 = 0.0; + o.Specular = tmpvar_3; + float tmpvar_4; + tmpvar_4 = 0.0; + o.Alpha = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Gloss = tmpvar_5; + surf (surfIN, o); + float tmpvar_6; + tmpvar_6 = length (IN.vec); + vec4 tmpvar_7; + tmpvar_7 = EncodeFloatRGBA ((tmpvar_6 * _LightPositionRange.w)); + return tmpvar_7; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = gl_TexCoord[0].xyz; + vec3 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_IN.vec = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = frag_surf (xlt_IN); + vec4 tmpvar_5; + tmpvar_5 = tmpvar_4; + xl_retval = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = xl_retval.xyzw; + vec4 tmpvar_7; + tmpvar_7 = tmpvar_6; + gl_FragData[0] = tmpvar_7; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Soft_Occlusion_Bark2-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Soft_Occlusion_Bark2-out.txt new file mode 100644 index 000000000..880249aed --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Soft_Occlusion_Bark2-out.txt @@ -0,0 +1,8 @@ +uniform vec4 _LightPositionRange; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = fract ((vec4(1.0, 255.0, 65025.0, 160580992.0) * (length (gl_TexCoord[0].xyz) * _LightPositionRange.w))); + gl_FragData[0] = (tmpvar_1 - (tmpvar_1.yzww * 0.00392157)); +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Soft_Occlusion_Bark3-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Soft_Occlusion_Bark3-in.txt new file mode 100644 index 000000000..f969f0d6c --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Soft_Occlusion_Bark3-in.txt @@ -0,0 +1,127 @@ +float xll_saturate( float x) { + return clamp( x, 0.0, 1.0); +} +vec2 xll_saturate( vec2 x) { + return clamp( x, 0.0, 1.0); +} +vec3 xll_saturate( vec3 x) { + return clamp( x, 0.0, 1.0); +} +vec4 xll_saturate( vec4 x) { + return clamp( x, 0.0, 1.0); +} +mat2 xll_saturate(mat2 m) { + return mat2( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0)); +} +mat3 xll_saturate(mat3 m) { + return mat3( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0), clamp(m[2], 0.0, 1.0)); +} +mat4 xll_saturate(mat4 m) { + return mat4( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0), clamp(m[2], 0.0, 1.0), clamp(m[3], 0.0, 1.0)); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +struct Input { + vec2 uv_MainTex; +}; +struct v2f_surf { + vec4 pos; + vec3 _ShadowCoord0; + vec3 _ShadowCoord1; + vec3 _ShadowCoord2; + vec3 _ShadowCoord3; + vec2 _ShadowZFade; +}; +uniform vec4 _Color; +uniform vec4 _LightShadowData; +uniform vec4 _LightSplitsFar; +uniform vec4 _LightSplitsNear; +uniform sampler2D _MainTex; +uniform vec4 _ProjectionParams; +uniform sampler2D _ShadowMapTexture; +void surf( in Input IN, inout SurfaceOutput o ); +vec2 EncodeFloatRG( in float v ); +vec4 frag_surf( in v2f_surf IN ); +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 c; + c = (texture2D( _MainTex, IN.uv_MainTex) * _Color); + o.Albedo = c.xyz ; + o.Alpha = c.w ; +} +vec2 EncodeFloatRG( in float v ) { + vec2 kEncodeMul = vec2( 1.00000, 255.000); + float kEncodeBit = 0.00392157; + vec2 enc; + enc = (kEncodeMul * v); + enc = fract( enc ); + enc.x -= (enc.y * kEncodeBit); + return enc; +} +vec4 frag_surf( in v2f_surf IN ) { + SurfaceOutput o; + Input surfIN; + vec4 z; + vec4 near; + vec4 far; + vec4 weights; + vec4 coord; + float shadow; + float faded; + vec4 res; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + surf( surfIN, o); + z = vec4( IN._ShadowZFade.x ); + near = vec4( greaterThanEqual( z, _LightSplitsNear) ); + far = vec4( lessThan( z, _LightSplitsFar) ); + weights = (near * far); + coord = vec4( ((((IN._ShadowCoord0 * weights.x ) + (IN._ShadowCoord1 * weights.y )) + (IN._ShadowCoord2 * weights.z )) + (IN._ShadowCoord3 * weights.w )), 1.00000); + shadow = ( (texture2D( _ShadowMapTexture, coord.xy ).x < coord.z ) ) ? ( _LightShadowData.x ) : ( 1.00000 ); + faded = xll_saturate( (shadow + xll_saturate( IN._ShadowZFade.y )) ); + res.x = faded; + res.y = 1.00000; + res.zw = EncodeFloatRG( float( (1.00000 - (z * _ProjectionParams.w )))); + return res; +} +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN._ShadowCoord0 = vec3( gl_TexCoord[0]); + xlt_IN._ShadowCoord1 = vec3( gl_TexCoord[1]); + xlt_IN._ShadowCoord2 = vec3( gl_TexCoord[2]); + xlt_IN._ShadowCoord3 = vec3( gl_TexCoord[3]); + xlt_IN._ShadowZFade = vec2( gl_TexCoord[4]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Soft_Occlusion_Bark3-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Soft_Occlusion_Bark3-ir.txt new file mode 100644 index 000000000..33b263652 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Soft_Occlusion_Bark3-ir.txt @@ -0,0 +1,311 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; +}; +struct v2f_surf { + vec4 pos; + vec3 _ShadowCoord0; + vec3 _ShadowCoord1; + vec3 _ShadowCoord2; + vec3 _ShadowCoord3; + vec2 _ShadowZFade; +}; +uniform sampler2D _ShadowMapTexture; +uniform vec4 _ProjectionParams; +uniform sampler2D _MainTex; +uniform vec4 _LightSplitsNear; +uniform vec4 _LightSplitsFar; +uniform vec4 _LightShadowData; +uniform vec4 _Color; +float xll_saturate ( + in float x +) +{ + float tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec2 xll_saturate ( + in vec2 x +) +{ + vec2 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec3 xll_saturate ( + in vec3 x +) +{ + vec3 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec4 xll_saturate ( + in vec4 x +) +{ + vec4 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +mat2 xll_saturate ( + in mat2 m +) +{ + vec2 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec2 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + mat2 tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_1; + tmpvar_3[0] = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5 = tmpvar_2; + tmpvar_3[1] = tmpvar_5; + return tmpvar_3; +} + +mat3 xll_saturate ( + in mat3 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec3 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + vec3 tmpvar_3; + tmpvar_3 = clamp (m[2], 0.0, 1.0); + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +mat4 xll_saturate ( + in mat4 m +) +{ + vec4 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec4 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + vec4 tmpvar_3; + tmpvar_3 = clamp (m[2], 0.0, 1.0); + vec4 tmpvar_4; + tmpvar_4 = clamp (m[3], 0.0, 1.0); + mat4 tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_1; + tmpvar_5[0] = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = tmpvar_2; + tmpvar_5[1] = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_3; + tmpvar_5[2] = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = tmpvar_4; + tmpvar_5[3] = tmpvar_9; + return tmpvar_5; +} + +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 c; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = (tmpvar_1 * _Color); + c = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = c.xyz; + o.Albedo = tmpvar_3; + float tmpvar_4; + tmpvar_4 = c.w; + o.Alpha = tmpvar_4; +} + +vec2 EncodeFloatRG ( + in float v +) +{ + vec2 enc; + float kEncodeBit; + vec2 kEncodeMul; + vec2 tmpvar_1; + tmpvar_1 = vec2(1.0, 255.0); + kEncodeMul = tmpvar_1; + float tmpvar_2; + tmpvar_2 = 0.00392157; + kEncodeBit = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = (kEncodeMul * v); + enc = tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = fract (enc); + vec2 tmpvar_5; + tmpvar_5 = tmpvar_4; + enc = tmpvar_5; + float tmpvar_6; + tmpvar_6 = (enc.x - (enc.y * kEncodeBit)); + enc.x = tmpvar_6; + return enc; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 res; + float faded; + float shadow; + vec4 coord; + vec4 weights; + vec4 far; + vec4 near; + vec4 z; + Input surfIN; + SurfaceOutput o; + vec3 tmpvar_1; + tmpvar_1 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_2; + float tmpvar_3; + tmpvar_3 = 0.0; + o.Specular = tmpvar_3; + float tmpvar_4; + tmpvar_4 = 0.0; + o.Alpha = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Gloss = tmpvar_5; + surf (surfIN, o); + vec4 tmpvar_6; + tmpvar_6 = vec4(IN._ShadowZFade.x); + vec4 tmpvar_7; + tmpvar_7 = tmpvar_6; + z = tmpvar_7; + bvec4 tmpvar_8; + tmpvar_8 = greaterThanEqual (z, _LightSplitsNear); + vec4 tmpvar_9; + tmpvar_9 = vec4(tmpvar_8).xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + near = tmpvar_10; + bvec4 tmpvar_11; + tmpvar_11 = lessThan (z, _LightSplitsFar); + vec4 tmpvar_12; + tmpvar_12 = vec4(tmpvar_11).xyzw; + vec4 tmpvar_13; + tmpvar_13 = tmpvar_12; + far = tmpvar_13; + vec4 tmpvar_14; + tmpvar_14 = (near * far); + weights = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15.w = 1.0; + tmpvar_15.xyz = ((((IN._ShadowCoord0 * weights.x) + (IN._ShadowCoord1 * weights.y)) + (IN._ShadowCoord2 * weights.z)) + (IN._ShadowCoord3 * weights.w)).xyz; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + coord = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17 = texture2D (_ShadowMapTexture, coord.xy); + float tmpvar_18; + if ((tmpvar_17.x < coord.z)) { + tmpvar_18 = _LightShadowData.x; + } else { + tmpvar_18 = 1.0; + }; + float tmpvar_19; + tmpvar_19 = tmpvar_18; + shadow = tmpvar_19; + float tmpvar_20; + tmpvar_20 = xll_saturate (IN._ShadowZFade.y); + float tmpvar_21; + tmpvar_21 = xll_saturate ((shadow + tmpvar_20)); + float tmpvar_22; + tmpvar_22 = tmpvar_21; + faded = tmpvar_22; + float tmpvar_23; + tmpvar_23 = faded; + res.x = tmpvar_23; + float tmpvar_24; + tmpvar_24 = 1.0; + res.y = vec2(tmpvar_24).y; + vec2 tmpvar_25; + tmpvar_25 = EncodeFloatRG ((1.0 - (z * _ProjectionParams.w)).x); + vec2 tmpvar_26; + tmpvar_26 = tmpvar_25; + res.zw = tmpvar_26.xxxy.zw; + return res; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = gl_TexCoord[0].xyz; + vec3 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_IN._ShadowCoord0 = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = gl_TexCoord[1].xyz; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_4; + xlt_IN._ShadowCoord1 = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = gl_TexCoord[2].xyz; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_6; + xlt_IN._ShadowCoord2 = tmpvar_7; + vec3 tmpvar_8; + tmpvar_8 = gl_TexCoord[3].xyz; + vec3 tmpvar_9; + tmpvar_9 = tmpvar_8; + xlt_IN._ShadowCoord3 = tmpvar_9; + vec2 tmpvar_10; + tmpvar_10 = gl_TexCoord[4].xy; + vec2 tmpvar_11; + tmpvar_11 = tmpvar_10; + xlt_IN._ShadowZFade = tmpvar_11; + vec4 tmpvar_12; + tmpvar_12 = frag_surf (xlt_IN); + vec4 tmpvar_13; + tmpvar_13 = tmpvar_12; + xl_retval = tmpvar_13; + vec4 tmpvar_14; + tmpvar_14 = xl_retval.xyzw; + vec4 tmpvar_15; + tmpvar_15 = tmpvar_14; + gl_FragData[0] = tmpvar_15; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Soft_Occlusion_Bark3-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Soft_Occlusion_Bark3-out.txt new file mode 100644 index 000000000..2c8a73d1a --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Soft_Occlusion_Bark3-out.txt @@ -0,0 +1,36 @@ +uniform sampler2D _ShadowMapTexture; +uniform vec4 _ProjectionParams; +uniform vec4 _LightSplitsNear; +uniform vec4 _LightSplitsFar; +uniform vec4 _LightShadowData; +void main () +{ + vec2 tmpvar_1; + tmpvar_1 = gl_TexCoord[4].xy; + vec4 res; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1.xxxx; + vec4 tmpvar_3; + tmpvar_3 = (vec4(greaterThanEqual (tmpvar_2, _LightSplitsNear)) * vec4(lessThan (tmpvar_2, _LightSplitsFar))); + vec4 tmpvar_4; + tmpvar_4.w = 1.0; + tmpvar_4.xyz = ((((gl_TexCoord[0].xyz * tmpvar_3.x) + (gl_TexCoord[1].xyz * tmpvar_3.y)) + (gl_TexCoord[2].xyz * tmpvar_3.z)) + (gl_TexCoord[3].xyz * tmpvar_3.w)); + vec4 tmpvar_5; + tmpvar_5 = texture2D (_ShadowMapTexture, tmpvar_4.xy); + float tmpvar_6; + if ((tmpvar_5.x < tmpvar_4.z)) { + tmpvar_6 = _LightShadowData.x; + } else { + tmpvar_6 = 1.0; + }; + res.x = clamp ((tmpvar_6 + clamp (tmpvar_1.y, 0.0, 1.0)), 0.0, 1.0); + res.y = 1.0; + vec2 enc; + vec2 tmpvar_7; + tmpvar_7 = fract ((vec2(1.0, 255.0) * (1.0 - (tmpvar_1.xxxx * _ProjectionParams.w)).x)); + enc = tmpvar_7; + enc.x = (tmpvar_7.x - (tmpvar_7.y * 0.00392157)); + res.zw = enc; + gl_FragData[0] = res; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Soft_Occlusion_Leaves-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Soft_Occlusion_Leaves-in.txt new file mode 100644 index 000000000..3ad85815d --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Soft_Occlusion_Leaves-in.txt @@ -0,0 +1,105 @@ +void xll_clip(float x) { + if ( x<0.0 ) discard; +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +struct Input { + vec2 uv_MainTex; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 normal; + vec3 vlight; + vec4 _ShadowCoord; +}; +uniform vec4 _Color; +uniform float _Cutoff; +uniform vec4 _LightColor0; +uniform sampler2D _MainTex; +uniform sampler2D _ShadowMapTexture; +uniform vec4 _WorldSpaceLightPos0; +float unitySampleShadow( in vec4 shadowCoord ); +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ); +vec4 frag_surf( in v2f_surf IN ); +float unitySampleShadow( in vec4 shadowCoord ) { + float shadow; + shadow = texture2DProj( _ShadowMapTexture, shadowCoord).x ; + return shadow; +} +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 c; + c = (texture2D( _MainTex, IN.uv_MainTex) * _Color); + o.Albedo = c.xyz ; + o.Alpha = c.w ; +} +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ) { + float diff; + vec4 c; + diff = max( 0.000000, dot( s.Normal, lightDir)); + c.xyz = ((s.Albedo * _LightColor0.xyz ) * ((diff * atten) * 2.00000)); + c.w = s.Alpha; + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + float atten; + vec4 c; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + o.Normal = IN.normal; + surf( surfIN, o); + xll_clip( (o.Alpha - _Cutoff) ); + atten = unitySampleShadow( IN._ShadowCoord); + c = LightingLambert( o, _WorldSpaceLightPos0.xyz , atten); + c.xyz += (o.Albedo * IN.vlight); + c.w = o.Alpha; + return c; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec2( gl_TexCoord[0]); + xlt_IN.normal = vec3( gl_TexCoord[1]); + xlt_IN.vlight = vec3( gl_TexCoord[2]); + xlt_IN._ShadowCoord = vec4( gl_TexCoord[3]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Soft_Occlusion_Leaves-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Soft_Occlusion_Leaves-ir.txt new file mode 100644 index 000000000..b35ab4aaf --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Soft_Occlusion_Leaves-ir.txt @@ -0,0 +1,183 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 normal; + vec3 vlight; + vec4 _ShadowCoord; +}; +varying vec4 xlv_FOG; +uniform vec4 _WorldSpaceLightPos0; +uniform sampler2D _ShadowMapTexture; +uniform sampler2D _MainTex; +uniform vec4 _LightColor0; +uniform float _Cutoff; +uniform vec4 _Color; +void xll_clip ( + in float x +) +{ + if ((x < 0.0)) { + discard; + }; +} + +float unitySampleShadow ( + in vec4 shadowCoord +) +{ + float shadow; + vec4 tmpvar_1; + tmpvar_1 = texture2DProj (_ShadowMapTexture, shadowCoord); + float tmpvar_2; + tmpvar_2 = tmpvar_1.x; + shadow = tmpvar_2; + return shadow; +} + +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 c; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = (tmpvar_1 * _Color); + c = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = c.xyz; + o.Albedo = tmpvar_3; + float tmpvar_4; + tmpvar_4 = c.w; + o.Alpha = tmpvar_4; +} + +vec4 LightingLambert ( + in SurfaceOutput s, + in vec3 lightDir, + in float atten +) +{ + vec4 c; + float diff; + float tmpvar_1; + tmpvar_1 = dot (s.Normal, lightDir); + float tmpvar_2; + tmpvar_2 = max (0.0, tmpvar_1); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + diff = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = ((s.Albedo * _LightColor0.xyz) * ((diff * atten) * 2.0)); + c.xyz = tmpvar_4.xyz.xyz; + float tmpvar_5; + tmpvar_5 = s.Alpha; + c.w = vec4(tmpvar_5).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 c; + float atten; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_3; + float tmpvar_4; + tmpvar_4 = 0.0; + o.Specular = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Alpha = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Gloss = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = IN.normal; + o.Normal = tmpvar_7; + surf (surfIN, o); + xll_clip ((o.Alpha - _Cutoff)); + float tmpvar_8; + tmpvar_8 = unitySampleShadow (IN._ShadowCoord); + float tmpvar_9; + tmpvar_9 = tmpvar_8; + atten = tmpvar_9; + vec4 tmpvar_10; + tmpvar_10 = LightingLambert (o, _WorldSpaceLightPos0.xyz, atten); + vec4 tmpvar_11; + tmpvar_11 = tmpvar_10; + c = tmpvar_11; + vec3 tmpvar_12; + tmpvar_12 = (c.xyz + (o.Albedo * IN.vlight)); + c.xyz = tmpvar_12.xyz.xyz; + float tmpvar_13; + tmpvar_13 = o.Alpha; + c.w = vec4(tmpvar_13).w; + return c; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xy; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.normal = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.vlight = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_TexCoord[3].xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_IN._ShadowCoord = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = frag_surf (xlt_IN); + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xl_retval = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = xl_retval.xyzw; + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + gl_FragData[0] = tmpvar_14; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Soft_Occlusion_Leaves-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Soft_Occlusion_Leaves-out.txt new file mode 100644 index 000000000..98981ed45 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Soft_Occlusion_Leaves-out.txt @@ -0,0 +1,31 @@ +uniform vec4 _WorldSpaceLightPos0; +uniform sampler2D _ShadowMapTexture; +uniform sampler2D _MainTex; +uniform vec4 _LightColor0; +uniform float _Cutoff; +uniform vec4 _Color; +void main () +{ + vec3 tmpvar_1; + tmpvar_1 = gl_TexCoord[1].xyz; + vec3 tmpvar_2; + tmpvar_2 = gl_TexCoord[2].xyz; + vec4 tmpvar_3; + tmpvar_3 = gl_TexCoord[3]; + vec4 c; + vec4 tmpvar_4; + tmpvar_4 = (texture2D (_MainTex, gl_TexCoord[0].xy) * _Color); + float x; + x = (tmpvar_4.w - _Cutoff); + if ((x < 0.0)) { + discard; + }; + vec4 c_i0_i1; + c_i0_i1.xyz = ((tmpvar_4.xyz * _LightColor0.xyz) * ((max (0.0, dot (tmpvar_1, _WorldSpaceLightPos0.xyz)) * texture2DProj (_ShadowMapTexture, tmpvar_3).x) * 2.0)); + c_i0_i1.w = tmpvar_4.w; + c = c_i0_i1; + c.xyz = (c_i0_i1.xyz + (tmpvar_4.xyz * tmpvar_2)); + c.w = tmpvar_4.w; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Soft_Occlusion_Leaves1-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Soft_Occlusion_Leaves1-in.txt new file mode 100644 index 000000000..6c683ae11 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Soft_Occlusion_Leaves1-in.txt @@ -0,0 +1,91 @@ +void xll_clip(float x) { + if ( x<0.0 ) discard; +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +struct Input { + vec2 uv_MainTex; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 hip_screen; +}; +uniform vec4 _Color; +uniform float _Cutoff; +uniform sampler2D _LightBuffer; +uniform sampler2D _MainTex; +uniform vec4 unity_Ambient; +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingLambert_PrePass( in SurfaceOutput s, in vec4 light ); +vec4 frag_surf( in v2f_surf IN ); +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 c; + c = (texture2D( _MainTex, IN.uv_MainTex) * _Color); + o.Albedo = c.xyz ; + o.Alpha = c.w ; +} +vec4 LightingLambert_PrePass( in SurfaceOutput s, in vec4 light ) { + vec4 c; + c.xyz = (s.Albedo * light.xyz ); + c.w = s.Alpha; + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec4 light; + vec4 col; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + surf( surfIN, o); + xll_clip( (o.Alpha - _Cutoff) ); + light = texture2DProj( _LightBuffer, IN.hip_screen); + light = ( -log2( light ) ); + light.xyz += unity_Ambient.xyz ; + col = LightingLambert_PrePass( o, light); + return col; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec2( gl_TexCoord[0]); + xlt_IN.hip_screen = vec4( gl_TexCoord[1]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Soft_Occlusion_Leaves1-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Soft_Occlusion_Leaves1-ir.txt new file mode 100644 index 000000000..b14d4f192 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Soft_Occlusion_Leaves1-ir.txt @@ -0,0 +1,147 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 hip_screen; +}; +varying vec4 xlv_FOG; +uniform vec4 unity_Ambient; +uniform sampler2D _MainTex; +uniform sampler2D _LightBuffer; +uniform float _Cutoff; +uniform vec4 _Color; +void xll_clip ( + in float x +) +{ + if ((x < 0.0)) { + discard; + }; +} + +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 c; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = (tmpvar_1 * _Color); + c = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = c.xyz; + o.Albedo = tmpvar_3; + float tmpvar_4; + tmpvar_4 = c.w; + o.Alpha = tmpvar_4; +} + +vec4 LightingLambert_PrePass ( + in SurfaceOutput s, + in vec4 light +) +{ + vec4 c; + vec3 tmpvar_1; + tmpvar_1 = (s.Albedo * light.xyz); + c.xyz = tmpvar_1.xyz.xyz; + float tmpvar_2; + tmpvar_2 = s.Alpha; + c.w = vec4(tmpvar_2).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 col; + vec4 light; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_3; + float tmpvar_4; + tmpvar_4 = 0.0; + o.Specular = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Alpha = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Gloss = tmpvar_6; + surf (surfIN, o); + xll_clip ((o.Alpha - _Cutoff)); + vec4 tmpvar_7; + tmpvar_7 = texture2DProj (_LightBuffer, IN.hip_screen); + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + light = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = log2 (light); + vec4 tmpvar_10; + tmpvar_10 = -(tmpvar_9); + light = tmpvar_10; + vec3 tmpvar_11; + tmpvar_11 = (light.xyz + unity_Ambient.xyz); + light.xyz = tmpvar_11.xyz.xyz; + vec4 tmpvar_12; + tmpvar_12 = LightingLambert_PrePass (o, light); + vec4 tmpvar_13; + tmpvar_13 = tmpvar_12; + col = tmpvar_13; + return col; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xy; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyzw; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.hip_screen = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = frag_surf (xlt_IN); + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xl_retval = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = xl_retval.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + gl_FragData[0] = tmpvar_10; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Soft_Occlusion_Leaves1-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Soft_Occlusion_Leaves1-out.txt new file mode 100644 index 000000000..c18db95bb --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Soft_Occlusion_Leaves1-out.txt @@ -0,0 +1,27 @@ +uniform vec4 unity_Ambient; +uniform sampler2D _MainTex; +uniform sampler2D _LightBuffer; +uniform float _Cutoff; +uniform vec4 _Color; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = gl_TexCoord[1]; + vec4 light; + vec4 tmpvar_2; + tmpvar_2 = (texture2D (_MainTex, gl_TexCoord[0].xy) * _Color); + float x; + x = (tmpvar_2.w - _Cutoff); + if ((x < 0.0)) { + discard; + }; + vec4 tmpvar_3; + tmpvar_3 = -(log2 (texture2DProj (_LightBuffer, tmpvar_1))); + light = tmpvar_3; + light.xyz = (tmpvar_3.xyz + unity_Ambient.xyz); + vec4 c_i0; + c_i0.xyz = (tmpvar_2.xyz * light.xyz); + c_i0.w = tmpvar_2.w; + gl_FragData[0] = c_i0; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Soft_Occlusion_Leaves2-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Soft_Occlusion_Leaves2-in.txt new file mode 100644 index 000000000..07589fddd --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Soft_Occlusion_Leaves2-in.txt @@ -0,0 +1,125 @@ +void xll_clip(float x) { + if ( x<0.0 ) discard; +} +float xll_saturate( float x) { + return clamp( x, 0.0, 1.0); +} +vec2 xll_saturate( vec2 x) { + return clamp( x, 0.0, 1.0); +} +vec3 xll_saturate( vec3 x) { + return clamp( x, 0.0, 1.0); +} +vec4 xll_saturate( vec4 x) { + return clamp( x, 0.0, 1.0); +} +mat2 xll_saturate(mat2 m) { + return mat2( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0)); +} +mat3 xll_saturate(mat3 m) { + return mat3( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0), clamp(m[2], 0.0, 1.0)); +} +mat4 xll_saturate(mat4 m) { + return mat4( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0), clamp(m[2], 0.0, 1.0), clamp(m[3], 0.0, 1.0)); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +struct Input { + vec2 uv_MainTex; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 hip_screen; + vec3 hip_lmapFade; +}; +uniform vec4 _Color; +uniform float _Cutoff; +uniform sampler2D _LightBuffer; +uniform sampler2D _MainTex; +uniform sampler2D unity_Lightmap; +uniform sampler2D unity_LightmapInd; +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingLambert_PrePass( in SurfaceOutput s, in vec4 light ); +vec3 DecodeLightmap( in vec4 color ); +vec4 frag_surf( in v2f_surf IN ); +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 c; + c = (texture2D( _MainTex, IN.uv_MainTex) * _Color); + o.Albedo = c.xyz ; + o.Alpha = c.w ; +} +vec4 LightingLambert_PrePass( in SurfaceOutput s, in vec4 light ) { + vec4 c; + c.xyz = (s.Albedo * light.xyz ); + c.w = s.Alpha; + return c; +} +vec3 DecodeLightmap( in vec4 color ) { + return (2.00000 * color.xyz ); +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec4 light; + vec3 lmFull; + vec3 lmIndirect; + vec3 lm; + vec4 col; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + surf( surfIN, o); + xll_clip( (o.Alpha - _Cutoff) ); + light = texture2DProj( _LightBuffer, IN.hip_screen); + light = ( -log2( light ) ); + lmFull = DecodeLightmap( texture2D( unity_Lightmap, IN.hip_lmapFade.xy )); + lmIndirect = DecodeLightmap( texture2D( unity_LightmapInd, IN.hip_lmapFade.xy )); + lm = mix( lmIndirect, lmFull, vec3( xll_saturate( IN.hip_lmapFade.z ))); + light.xyz += lm; + col = LightingLambert_PrePass( o, light); + return col; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec2( gl_TexCoord[0]); + xlt_IN.hip_screen = vec4( gl_TexCoord[1]); + xlt_IN.hip_lmapFade = vec3( gl_TexCoord[2]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Soft_Occlusion_Leaves2-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Soft_Occlusion_Leaves2-ir.txt new file mode 100644 index 000000000..80527df39 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Soft_Occlusion_Leaves2-ir.txt @@ -0,0 +1,292 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 hip_screen; + vec3 hip_lmapFade; +}; +varying vec4 xlv_FOG; +uniform sampler2D unity_LightmapInd; +uniform sampler2D unity_Lightmap; +uniform sampler2D _MainTex; +uniform sampler2D _LightBuffer; +uniform float _Cutoff; +uniform vec4 _Color; +void xll_clip ( + in float x +) +{ + if ((x < 0.0)) { + discard; + }; +} + +float xll_saturate ( + in float x +) +{ + float tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec2 xll_saturate ( + in vec2 x +) +{ + vec2 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec3 xll_saturate ( + in vec3 x +) +{ + vec3 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec4 xll_saturate ( + in vec4 x +) +{ + vec4 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +mat2 xll_saturate ( + in mat2 m +) +{ + vec2 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec2 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + mat2 tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_1; + tmpvar_3[0] = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5 = tmpvar_2; + tmpvar_3[1] = tmpvar_5; + return tmpvar_3; +} + +mat3 xll_saturate ( + in mat3 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec3 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + vec3 tmpvar_3; + tmpvar_3 = clamp (m[2], 0.0, 1.0); + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +mat4 xll_saturate ( + in mat4 m +) +{ + vec4 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec4 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + vec4 tmpvar_3; + tmpvar_3 = clamp (m[2], 0.0, 1.0); + vec4 tmpvar_4; + tmpvar_4 = clamp (m[3], 0.0, 1.0); + mat4 tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_1; + tmpvar_5[0] = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = tmpvar_2; + tmpvar_5[1] = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_3; + tmpvar_5[2] = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = tmpvar_4; + tmpvar_5[3] = tmpvar_9; + return tmpvar_5; +} + +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 c; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = (tmpvar_1 * _Color); + c = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = c.xyz; + o.Albedo = tmpvar_3; + float tmpvar_4; + tmpvar_4 = c.w; + o.Alpha = tmpvar_4; +} + +vec4 LightingLambert_PrePass ( + in SurfaceOutput s, + in vec4 light +) +{ + vec4 c; + vec3 tmpvar_1; + tmpvar_1 = (s.Albedo * light.xyz); + c.xyz = tmpvar_1.xyz.xyz; + float tmpvar_2; + tmpvar_2 = s.Alpha; + c.w = vec4(tmpvar_2).w; + return c; +} + +vec3 DecodeLightmap ( + in vec4 color +) +{ + return (2.0 * color.xyz); +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 col; + vec3 lm; + vec3 lmIndirect; + vec3 lmFull; + vec4 light; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_3; + float tmpvar_4; + tmpvar_4 = 0.0; + o.Specular = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Alpha = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Gloss = tmpvar_6; + surf (surfIN, o); + xll_clip ((o.Alpha - _Cutoff)); + vec4 tmpvar_7; + tmpvar_7 = texture2DProj (_LightBuffer, IN.hip_screen); + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + light = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = log2 (light); + vec4 tmpvar_10; + tmpvar_10 = -(tmpvar_9); + light = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = texture2D (unity_Lightmap, IN.hip_lmapFade.xy); + vec3 tmpvar_12; + tmpvar_12 = DecodeLightmap (tmpvar_11); + vec3 tmpvar_13; + tmpvar_13 = tmpvar_12; + lmFull = tmpvar_13; + vec4 tmpvar_14; + tmpvar_14 = texture2D (unity_LightmapInd, IN.hip_lmapFade.xy); + vec3 tmpvar_15; + tmpvar_15 = DecodeLightmap (tmpvar_14); + vec3 tmpvar_16; + tmpvar_16 = tmpvar_15; + lmIndirect = tmpvar_16; + float tmpvar_17; + tmpvar_17 = xll_saturate (IN.hip_lmapFade.z); + vec3 tmpvar_18; + tmpvar_18 = vec3(tmpvar_17); + vec3 tmpvar_19; + tmpvar_19 = mix (lmIndirect, lmFull, tmpvar_18); + vec3 tmpvar_20; + tmpvar_20 = tmpvar_19; + lm = tmpvar_20; + vec3 tmpvar_21; + tmpvar_21 = (light.xyz + lm); + light.xyz = tmpvar_21.xyz.xyz; + vec4 tmpvar_22; + tmpvar_22 = LightingLambert_PrePass (o, light); + vec4 tmpvar_23; + tmpvar_23 = tmpvar_22; + col = tmpvar_23; + return col; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xy; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyzw; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.hip_screen = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.hip_lmapFade = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = frag_surf (xlt_IN); + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xl_retval = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = xl_retval.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + gl_FragData[0] = tmpvar_12; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Soft_Occlusion_Leaves2-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Soft_Occlusion_Leaves2-out.txt new file mode 100644 index 000000000..df598544c --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Soft_Occlusion_Leaves2-out.txt @@ -0,0 +1,30 @@ +uniform sampler2D unity_LightmapInd; +uniform sampler2D unity_Lightmap; +uniform sampler2D _MainTex; +uniform sampler2D _LightBuffer; +uniform float _Cutoff; +uniform vec4 _Color; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = gl_TexCoord[1]; + vec3 tmpvar_2; + tmpvar_2 = gl_TexCoord[2].xyz; + vec4 light; + vec4 tmpvar_3; + tmpvar_3 = (texture2D (_MainTex, gl_TexCoord[0].xy) * _Color); + float x; + x = (tmpvar_3.w - _Cutoff); + if ((x < 0.0)) { + discard; + }; + vec4 tmpvar_4; + tmpvar_4 = -(log2 (texture2DProj (_LightBuffer, tmpvar_1))); + light = tmpvar_4; + light.xyz = (tmpvar_4.xyz + mix ((2.0 * texture2D (unity_LightmapInd, tmpvar_2.xy).xyz), (2.0 * texture2D (unity_Lightmap, tmpvar_2.xy).xyz), vec3(clamp (tmpvar_2.z, 0.0, 1.0)))); + vec4 c_i0; + c_i0.xyz = (tmpvar_3.xyz * light.xyz); + c_i0.w = tmpvar_3.w; + gl_FragData[0] = c_i0; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Soft_Occlusion_Leaves3-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Soft_Occlusion_Leaves3-in.txt new file mode 100644 index 000000000..d0065d331 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Soft_Occlusion_Leaves3-in.txt @@ -0,0 +1,84 @@ +void xll_clip(float x) { + if ( x<0.0 ) discard; +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +struct Input { + vec2 uv_MainTex; +}; +struct v2f_surf { + vec4 pos; + vec3 vec; + vec2 hip_pack0; +}; +uniform vec4 _Color; +uniform float _Cutoff; +uniform vec4 _LightPositionRange; +uniform sampler2D _MainTex; +void surf( in Input IN, inout SurfaceOutput o ); +vec4 EncodeFloatRGBA( in float v ); +vec4 frag_surf( in v2f_surf IN ); +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 c; + c = (texture2D( _MainTex, IN.uv_MainTex) * _Color); + o.Albedo = c.xyz ; + o.Alpha = c.w ; +} +vec4 EncodeFloatRGBA( in float v ) { + vec4 kEncodeMul = vec4( 1.00000, 255.000, 65025.0, 1.60581e+008); + float kEncodeBit = 0.00392157; + vec4 enc; + enc = (kEncodeMul * v); + enc = fract( enc ); + enc -= (enc.yzww * kEncodeBit); + return enc; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + surf( surfIN, o); + xll_clip( (o.Alpha - _Cutoff) ); + return EncodeFloatRGBA( (length( IN.vec ) * _LightPositionRange.w )); +} +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.vec = vec3( gl_TexCoord[0]); + xlt_IN.hip_pack0 = vec2( gl_TexCoord[1]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Soft_Occlusion_Leaves3-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Soft_Occlusion_Leaves3-ir.txt new file mode 100644 index 000000000..c815fda01 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Soft_Occlusion_Leaves3-ir.txt @@ -0,0 +1,137 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; +}; +struct v2f_surf { + vec4 pos; + vec3 vec; + vec2 hip_pack0; +}; +uniform sampler2D _MainTex; +uniform vec4 _LightPositionRange; +uniform float _Cutoff; +uniform vec4 _Color; +void xll_clip ( + in float x +) +{ + if ((x < 0.0)) { + discard; + }; +} + +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 c; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = (tmpvar_1 * _Color); + c = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = c.xyz; + o.Albedo = tmpvar_3; + float tmpvar_4; + tmpvar_4 = c.w; + o.Alpha = tmpvar_4; +} + +vec4 EncodeFloatRGBA ( + in float v +) +{ + vec4 enc; + float kEncodeBit; + vec4 kEncodeMul; + vec4 tmpvar_1; + tmpvar_1 = vec4(1.0, 255.0, 65025.0, 160580992.0); + kEncodeMul = tmpvar_1; + float tmpvar_2; + tmpvar_2 = 0.00392157; + kEncodeBit = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = (kEncodeMul * v); + enc = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = fract (enc); + vec4 tmpvar_5; + tmpvar_5 = tmpvar_4; + enc = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = (enc - (enc.yzww * kEncodeBit)); + enc = tmpvar_6; + return enc; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_3; + float tmpvar_4; + tmpvar_4 = 0.0; + o.Specular = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Alpha = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Gloss = tmpvar_6; + surf (surfIN, o); + xll_clip ((o.Alpha - _Cutoff)); + float tmpvar_7; + tmpvar_7 = length (IN.vec); + vec4 tmpvar_8; + tmpvar_8 = EncodeFloatRGBA ((tmpvar_7 * _LightPositionRange.w)); + return tmpvar_8; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = gl_TexCoord[0].xyz; + vec3 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_IN.vec = tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = gl_TexCoord[1].xy; + vec2 tmpvar_5; + tmpvar_5 = tmpvar_4; + xlt_IN.hip_pack0 = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = frag_surf (xlt_IN); + vec4 tmpvar_7; + tmpvar_7 = tmpvar_6; + xl_retval = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = xl_retval.xyzw; + vec4 tmpvar_9; + tmpvar_9 = tmpvar_8; + gl_FragData[0] = tmpvar_9; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Soft_Occlusion_Leaves3-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Soft_Occlusion_Leaves3-out.txt new file mode 100644 index 000000000..9ef8b150c --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Soft_Occlusion_Leaves3-out.txt @@ -0,0 +1,18 @@ +uniform sampler2D _MainTex; +uniform vec4 _LightPositionRange; +uniform float _Cutoff; +uniform vec4 _Color; +void main () +{ + vec3 tmpvar_1; + tmpvar_1 = gl_TexCoord[0].xyz; + float x; + x = ((texture2D (_MainTex, gl_TexCoord[1].xy) * _Color).w - _Cutoff); + if ((x < 0.0)) { + discard; + }; + vec4 tmpvar_2; + tmpvar_2 = fract ((vec4(1.0, 255.0, 65025.0, 160580992.0) * (length (tmpvar_1) * _LightPositionRange.w))); + gl_FragData[0] = (tmpvar_2 - (tmpvar_2.yzww * 0.00392157)); +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Vegetation_Two_Pass_unlit-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Vegetation_Two_Pass_unlit-in.txt new file mode 100644 index 000000000..04dd6ca64 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Vegetation_Two_Pass_unlit-in.txt @@ -0,0 +1,45 @@ +void xll_clip(float x) { + if ( x<0.0 ) discard; +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct v2f { + vec4 vertex; + vec4 color; + vec2 texcoord; +}; +struct appdata_t { + vec4 vertex; + vec4 color; + vec2 texcoord; +}; +uniform vec4 _Color; +uniform float _Cutoff; +uniform sampler2D _MainTex; +vec4 frag( in v2f i ); +vec4 frag( in v2f i ) { + vec4 col; + col = (_Color * texture2D( _MainTex, i.texcoord)); + xll_clip( (col.w - _Cutoff) ); + return col; +} +void main() { + vec4 xl_retval; + v2f xlt_i; + xlt_i.vertex = vec4(0.0); + xlt_i.color = vec4( gl_Color); + xlt_i.texcoord = vec2( gl_TexCoord[0]); + xl_retval = frag( xlt_i); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Vegetation_Two_Pass_unlit-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Vegetation_Two_Pass_unlit-ir.txt new file mode 100644 index 000000000..20ba356d8 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Vegetation_Two_Pass_unlit-ir.txt @@ -0,0 +1,60 @@ +struct v2f { + vec4 vertex; + vec4 color; + vec2 texcoord; +}; +uniform sampler2D _MainTex; +uniform float _Cutoff; +uniform vec4 _Color; +void xll_clip ( + in float x +) +{ + if ((x < 0.0)) { + discard; + }; +} + +vec4 frag ( + in v2f i +) +{ + vec4 col; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, i.texcoord); + vec4 tmpvar_2; + tmpvar_2 = (_Color * tmpvar_1); + col = tmpvar_2; + xll_clip ((col.w - _Cutoff)); + return col; +} + +void main () +{ + v2f xlt_i; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_i.vertex = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = gl_Color.xyzw; + vec4 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_i.color = tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = gl_TexCoord[0].xy; + vec2 tmpvar_5; + tmpvar_5 = tmpvar_4; + xlt_i.texcoord = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = frag (xlt_i); + vec4 tmpvar_7; + tmpvar_7 = tmpvar_6; + xl_retval = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = xl_retval.xyzw; + vec4 tmpvar_9; + tmpvar_9 = tmpvar_8; + gl_FragData[0] = tmpvar_9; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Vegetation_Two_Pass_unlit-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Vegetation_Two_Pass_unlit-out.txt new file mode 100644 index 000000000..05d8968ec --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Nature_Vegetation_Two_Pass_unlit-out.txt @@ -0,0 +1,15 @@ +uniform sampler2D _MainTex; +uniform float _Cutoff; +uniform vec4 _Color; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = (_Color * texture2D (_MainTex, gl_TexCoord[0].xy)); + float x; + x = (tmpvar_1.w - _Cutoff); + if ((x < 0.0)) { + discard; + }; + gl_FragData[0] = tmpvar_1; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Parallax_Diffuse-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Parallax_Diffuse-in.txt new file mode 100644 index 000000000..dd285de69 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Parallax_Diffuse-in.txt @@ -0,0 +1,128 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; + vec3 viewDir; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 viewDir; + vec3 lightDir; + vec3 vlight; + vec4 _ShadowCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform sampler2D _BumpMap; +uniform vec4 _Color; +uniform vec4 _LightColor0; +uniform sampler2D _MainTex; +uniform float _Parallax; +uniform sampler2D _ParallaxMap; +uniform sampler2D _ShadowMapTexture; +float unitySampleShadow( in vec4 shadowCoord ); +vec4 UnpackNormal( in vec4 packednormal ); +vec2 ParallaxOffset( in float h, in float height, in vec3 viewDir ); +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ); +vec4 frag_surf( in v2f_surf IN ); +float unitySampleShadow( in vec4 shadowCoord ) { + float shadow; + shadow = texture2DProj( _ShadowMapTexture, shadowCoord).x ; + return shadow; +} +vec4 UnpackNormal( in vec4 packednormal ) { + vec4 normal; + normal.xy = ((packednormal.wy * 2.00000) - 1.00000); + normal.z = sqrt( ((1.00000 - (normal.x * normal.x )) - (normal.y * normal.y )) ); + return normal; +} +vec2 ParallaxOffset( in float h, in float height, in vec3 viewDir ) { + vec3 v; + h = ((h * height) - (height / 2.00000)); + v = normalize( viewDir ); + v.z += 0.420000; + return (h * (v.xy / v.z )); +} +void surf( in Input IN, inout SurfaceOutput o ) { + float h; + vec2 offset; + vec4 c; + h = texture2D( _ParallaxMap, IN.uv_BumpMap).w ; + offset = ParallaxOffset( h, _Parallax, IN.viewDir); + IN.uv_MainTex += offset; + IN.uv_BumpMap += offset; + c = (texture2D( _MainTex, IN.uv_MainTex) * _Color); + o.Albedo = c.xyz ; + o.Alpha = c.w ; + o.Normal = vec3( UnpackNormal( texture2D( _BumpMap, IN.uv_BumpMap))); +} +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ) { + float diff; + vec4 c; + diff = max( 0.000000, dot( s.Normal, lightDir)); + c.xyz = ((s.Albedo * _LightColor0.xyz ) * ((diff * atten) * 2.00000)); + c.w = s.Alpha; + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + float atten; + vec4 c; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + surfIN.uv_BumpMap = IN.hip_pack0.zw ; + surfIN.viewDir = IN.viewDir; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + surf( surfIN, o); + atten = unitySampleShadow( IN._ShadowCoord); + c = LightingLambert( o, IN.lightDir, atten); + c.xyz += (o.Albedo * IN.vlight); + return c; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec4( gl_TexCoord[0]); + xlt_IN.viewDir = vec3( gl_TexCoord[1]); + xlt_IN.lightDir = vec3( gl_TexCoord[2]); + xlt_IN.vlight = vec3( gl_TexCoord[3]); + xlt_IN._ShadowCoord = vec4( gl_TexCoord[4]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Parallax_Diffuse-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Parallax_Diffuse-ir.txt new file mode 100644 index 000000000..67de6449d --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Parallax_Diffuse-ir.txt @@ -0,0 +1,246 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; + vec3 viewDir; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 viewDir; + vec3 lightDir; + vec3 vlight; + vec4 _ShadowCoord; +}; +varying vec4 xlv_FOG; +uniform sampler2D _ShadowMapTexture; +uniform sampler2D _ParallaxMap; +uniform float _Parallax; +uniform sampler2D _MainTex; +uniform vec4 _LightColor0; +uniform vec4 _Color; +uniform sampler2D _BumpMap; +float unitySampleShadow ( + in vec4 shadowCoord +) +{ + float shadow; + vec4 tmpvar_1; + tmpvar_1 = texture2DProj (_ShadowMapTexture, shadowCoord); + float tmpvar_2; + tmpvar_2 = tmpvar_1.x; + shadow = tmpvar_2; + return shadow; +} + +vec4 UnpackNormal ( + in vec4 packednormal +) +{ + vec4 normal; + vec2 tmpvar_1; + tmpvar_1 = ((packednormal.wy * 2.0) - 1.0); + normal.xy = tmpvar_1.xy.xy; + float tmpvar_2; + tmpvar_2 = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + normal.z = vec3(tmpvar_3).z; + return normal; +} + +vec2 ParallaxOffset ( + in float h, + in float height, + in vec3 viewDir +) +{ + vec3 v; + float tmpvar_1; + tmpvar_1 = ((h * height) - (height / 2.0)); + h = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = normalize (viewDir); + vec3 tmpvar_3; + tmpvar_3 = tmpvar_2; + v = tmpvar_3; + float tmpvar_4; + tmpvar_4 = (v.z + 0.42); + v.z = vec3(tmpvar_4).z; + return (h * (v.xy / v.z)); +} + +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 c; + vec2 offset; + float h; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_ParallaxMap, IN.uv_BumpMap); + float tmpvar_2; + tmpvar_2 = tmpvar_1.w; + h = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = ParallaxOffset (h, _Parallax, IN.viewDir); + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + offset = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5 = (IN.uv_MainTex + offset); + IN.uv_MainTex = tmpvar_5; + vec2 tmpvar_6; + tmpvar_6 = (IN.uv_BumpMap + offset); + IN.uv_BumpMap = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_8; + tmpvar_8 = (tmpvar_7 * _Color); + c = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = c.xyz; + o.Albedo = tmpvar_9; + float tmpvar_10; + tmpvar_10 = c.w; + o.Alpha = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = texture2D (_BumpMap, IN.uv_BumpMap); + vec4 tmpvar_12; + tmpvar_12 = UnpackNormal (tmpvar_11); + vec3 tmpvar_13; + tmpvar_13 = tmpvar_12.xyz; + vec3 tmpvar_14; + tmpvar_14 = tmpvar_13; + o.Normal = tmpvar_14; +} + +vec4 LightingLambert ( + in SurfaceOutput s, + in vec3 lightDir, + in float atten +) +{ + vec4 c; + float diff; + float tmpvar_1; + tmpvar_1 = dot (s.Normal, lightDir); + float tmpvar_2; + tmpvar_2 = max (0.0, tmpvar_1); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + diff = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = ((s.Albedo * _LightColor0.xyz) * ((diff * atten) * 2.0)); + c.xyz = tmpvar_4.xyz.xyz; + float tmpvar_5; + tmpvar_5 = s.Alpha; + c.w = vec4(tmpvar_5).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 c; + float atten; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = IN.hip_pack0.zw; + surfIN.uv_BumpMap = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = IN.viewDir; + surfIN.viewDir = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Specular = tmpvar_6; + float tmpvar_7; + tmpvar_7 = 0.0; + o.Alpha = tmpvar_7; + float tmpvar_8; + tmpvar_8 = 0.0; + o.Gloss = tmpvar_8; + surf (surfIN, o); + float tmpvar_9; + tmpvar_9 = unitySampleShadow (IN._ShadowCoord); + float tmpvar_10; + tmpvar_10 = tmpvar_9; + atten = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = LightingLambert (o, IN.lightDir, atten); + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + c = tmpvar_12; + vec3 tmpvar_13; + tmpvar_13 = (c.xyz + (o.Albedo * IN.vlight)); + c.xyz = tmpvar_13.xyz.xyz; + return c; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.viewDir = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.lightDir = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = gl_TexCoord[3].xyz; + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_IN.vlight = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_TexCoord[4].xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_IN._ShadowCoord = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = frag_surf (xlt_IN); + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_FragData[0] = tmpvar_16; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Parallax_Diffuse-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Parallax_Diffuse-out.txt new file mode 100644 index 000000000..c57eed0d2 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Parallax_Diffuse-out.txt @@ -0,0 +1,32 @@ +uniform sampler2D _ShadowMapTexture; +uniform sampler2D _ParallaxMap; +uniform float _Parallax; +uniform sampler2D _MainTex; +uniform vec4 _LightColor0; +uniform vec4 _Color; +uniform sampler2D _BumpMap; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = gl_TexCoord[0]; + vec4 c; + vec2 tmpvar_2; + vec3 v; + vec3 tmpvar_3; + tmpvar_3 = normalize (gl_TexCoord[1].xyz); + v = tmpvar_3; + v.z = (tmpvar_3.z + 0.42); + tmpvar_2 = (((texture2D (_ParallaxMap, tmpvar_1.zw).w * _Parallax) - (_Parallax / 2.0)) * (tmpvar_3.xy / v.z)); + vec4 tmpvar_4; + tmpvar_4 = (texture2D (_MainTex, (tmpvar_1.xy + tmpvar_2)) * _Color); + vec4 normal; + normal.xy = ((texture2D (_BumpMap, (tmpvar_1.zw + tmpvar_2)).wy * 2.0) - 1.0); + normal.z = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + vec4 c_i0_i1; + c_i0_i1.xyz = ((tmpvar_4.xyz * _LightColor0.xyz) * ((max (0.0, dot (normal.xyz, gl_TexCoord[2].xyz)) * texture2DProj (_ShadowMapTexture, gl_TexCoord[4]).x) * 2.0)); + c_i0_i1.w = tmpvar_4.w; + c = c_i0_i1; + c.xyz = (c_i0_i1.xyz + (tmpvar_4.xyz * gl_TexCoord[3].xyz)); + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Parallax_Diffuse1-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Parallax_Diffuse1-in.txt new file mode 100644 index 000000000..a2f75c79e --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Parallax_Diffuse1-in.txt @@ -0,0 +1,117 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; + vec3 viewDir; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 viewDir; + vec4 hip_screen; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform sampler2D _BumpMap; +uniform vec4 _Color; +uniform sampler2D _LightBuffer; +uniform sampler2D _MainTex; +uniform float _Parallax; +uniform sampler2D _ParallaxMap; +uniform vec4 unity_Ambient; +vec4 UnpackNormal( in vec4 packednormal ); +vec2 ParallaxOffset( in float h, in float height, in vec3 viewDir ); +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingLambert_PrePass( in SurfaceOutput s, in vec4 light ); +vec4 frag_surf( in v2f_surf IN ); +vec4 UnpackNormal( in vec4 packednormal ) { + vec4 normal; + normal.xy = ((packednormal.wy * 2.00000) - 1.00000); + normal.z = sqrt( ((1.00000 - (normal.x * normal.x )) - (normal.y * normal.y )) ); + return normal; +} +vec2 ParallaxOffset( in float h, in float height, in vec3 viewDir ) { + vec3 v; + h = ((h * height) - (height / 2.00000)); + v = normalize( viewDir ); + v.z += 0.420000; + return (h * (v.xy / v.z )); +} +void surf( in Input IN, inout SurfaceOutput o ) { + float h; + vec2 offset; + vec4 c; + h = texture2D( _ParallaxMap, IN.uv_BumpMap).w ; + offset = ParallaxOffset( h, _Parallax, IN.viewDir); + IN.uv_MainTex += offset; + IN.uv_BumpMap += offset; + c = (texture2D( _MainTex, IN.uv_MainTex) * _Color); + o.Albedo = c.xyz ; + o.Alpha = c.w ; + o.Normal = vec3( UnpackNormal( texture2D( _BumpMap, IN.uv_BumpMap))); +} +vec4 LightingLambert_PrePass( in SurfaceOutput s, in vec4 light ) { + vec4 c; + c.xyz = (s.Albedo * light.xyz ); + c.w = s.Alpha; + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec4 light; + vec4 col; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + surfIN.uv_BumpMap = IN.hip_pack0.zw ; + surfIN.viewDir = IN.viewDir; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + surf( surfIN, o); + light = texture2DProj( _LightBuffer, IN.hip_screen); + light = ( -log2( light ) ); + light.xyz += unity_Ambient.xyz ; + col = LightingLambert_PrePass( o, light); + return col; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec4( gl_TexCoord[0]); + xlt_IN.viewDir = vec3( gl_TexCoord[1]); + xlt_IN.hip_screen = vec4( gl_TexCoord[2]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Parallax_Diffuse1-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Parallax_Diffuse1-ir.txt new file mode 100644 index 000000000..d87c4bf1d --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Parallax_Diffuse1-ir.txt @@ -0,0 +1,217 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; + vec3 viewDir; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 viewDir; + vec4 hip_screen; +}; +varying vec4 xlv_FOG; +uniform vec4 unity_Ambient; +uniform sampler2D _ParallaxMap; +uniform float _Parallax; +uniform sampler2D _MainTex; +uniform sampler2D _LightBuffer; +uniform vec4 _Color; +uniform sampler2D _BumpMap; +vec4 UnpackNormal ( + in vec4 packednormal +) +{ + vec4 normal; + vec2 tmpvar_1; + tmpvar_1 = ((packednormal.wy * 2.0) - 1.0); + normal.xy = tmpvar_1.xy.xy; + float tmpvar_2; + tmpvar_2 = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + normal.z = vec3(tmpvar_3).z; + return normal; +} + +vec2 ParallaxOffset ( + in float h, + in float height, + in vec3 viewDir +) +{ + vec3 v; + float tmpvar_1; + tmpvar_1 = ((h * height) - (height / 2.0)); + h = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = normalize (viewDir); + vec3 tmpvar_3; + tmpvar_3 = tmpvar_2; + v = tmpvar_3; + float tmpvar_4; + tmpvar_4 = (v.z + 0.42); + v.z = vec3(tmpvar_4).z; + return (h * (v.xy / v.z)); +} + +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 c; + vec2 offset; + float h; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_ParallaxMap, IN.uv_BumpMap); + float tmpvar_2; + tmpvar_2 = tmpvar_1.w; + h = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = ParallaxOffset (h, _Parallax, IN.viewDir); + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + offset = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5 = (IN.uv_MainTex + offset); + IN.uv_MainTex = tmpvar_5; + vec2 tmpvar_6; + tmpvar_6 = (IN.uv_BumpMap + offset); + IN.uv_BumpMap = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_8; + tmpvar_8 = (tmpvar_7 * _Color); + c = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = c.xyz; + o.Albedo = tmpvar_9; + float tmpvar_10; + tmpvar_10 = c.w; + o.Alpha = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = texture2D (_BumpMap, IN.uv_BumpMap); + vec4 tmpvar_12; + tmpvar_12 = UnpackNormal (tmpvar_11); + vec3 tmpvar_13; + tmpvar_13 = tmpvar_12.xyz; + vec3 tmpvar_14; + tmpvar_14 = tmpvar_13; + o.Normal = tmpvar_14; +} + +vec4 LightingLambert_PrePass ( + in SurfaceOutput s, + in vec4 light +) +{ + vec4 c; + vec3 tmpvar_1; + tmpvar_1 = (s.Albedo * light.xyz); + c.xyz = tmpvar_1.xyz.xyz; + float tmpvar_2; + tmpvar_2 = s.Alpha; + c.w = vec4(tmpvar_2).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 col; + vec4 light; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = IN.hip_pack0.zw; + surfIN.uv_BumpMap = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = IN.viewDir; + surfIN.viewDir = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Specular = tmpvar_6; + float tmpvar_7; + tmpvar_7 = 0.0; + o.Alpha = tmpvar_7; + float tmpvar_8; + tmpvar_8 = 0.0; + o.Gloss = tmpvar_8; + surf (surfIN, o); + vec4 tmpvar_9; + tmpvar_9 = texture2DProj (_LightBuffer, IN.hip_screen); + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + light = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = log2 (light); + vec4 tmpvar_12; + tmpvar_12 = -(tmpvar_11); + light = tmpvar_12; + vec3 tmpvar_13; + tmpvar_13 = (light.xyz + unity_Ambient.xyz); + light.xyz = tmpvar_13.xyz.xyz; + vec4 tmpvar_14; + tmpvar_14 = LightingLambert_PrePass (o, light); + vec4 tmpvar_15; + tmpvar_15 = tmpvar_14; + col = tmpvar_15; + return col; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.viewDir = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.hip_screen = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = frag_surf (xlt_IN); + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xl_retval = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = xl_retval.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + gl_FragData[0] = tmpvar_12; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Parallax_Diffuse1-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Parallax_Diffuse1-out.txt new file mode 100644 index 000000000..72c62060f --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Parallax_Diffuse1-out.txt @@ -0,0 +1,34 @@ +uniform vec4 unity_Ambient; +uniform sampler2D _ParallaxMap; +uniform float _Parallax; +uniform sampler2D _MainTex; +uniform sampler2D _LightBuffer; +uniform vec4 _Color; +uniform sampler2D _BumpMap; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = gl_TexCoord[0]; + vec4 light; + vec2 tmpvar_2; + vec3 v; + vec3 tmpvar_3; + tmpvar_3 = normalize (gl_TexCoord[1].xyz); + v = tmpvar_3; + v.z = (tmpvar_3.z + 0.42); + tmpvar_2 = (((texture2D (_ParallaxMap, tmpvar_1.zw).w * _Parallax) - (_Parallax / 2.0)) * (tmpvar_3.xy / v.z)); + vec4 tmpvar_4; + tmpvar_4 = (texture2D (_MainTex, (tmpvar_1.xy + tmpvar_2)) * _Color); + vec4 normal; + normal.xy = ((texture2D (_BumpMap, (tmpvar_1.zw + tmpvar_2)).wy * 2.0) - 1.0); + normal.z = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + vec4 tmpvar_5; + tmpvar_5 = -(log2 (texture2DProj (_LightBuffer, gl_TexCoord[2]))); + light = tmpvar_5; + light.xyz = (tmpvar_5.xyz + unity_Ambient.xyz); + vec4 c_i0; + c_i0.xyz = (tmpvar_4.xyz * light.xyz); + c_i0.w = tmpvar_4.w; + gl_FragData[0] = c_i0; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Parallax_Diffuse2-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Parallax_Diffuse2-in.txt new file mode 100644 index 000000000..1692621bd --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Parallax_Diffuse2-in.txt @@ -0,0 +1,151 @@ +float xll_saturate( float x) { + return clamp( x, 0.0, 1.0); +} +vec2 xll_saturate( vec2 x) { + return clamp( x, 0.0, 1.0); +} +vec3 xll_saturate( vec3 x) { + return clamp( x, 0.0, 1.0); +} +vec4 xll_saturate( vec4 x) { + return clamp( x, 0.0, 1.0); +} +mat2 xll_saturate(mat2 m) { + return mat2( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0)); +} +mat3 xll_saturate(mat3 m) { + return mat3( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0), clamp(m[2], 0.0, 1.0)); +} +mat4 xll_saturate(mat4 m) { + return mat4( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0), clamp(m[2], 0.0, 1.0), clamp(m[3], 0.0, 1.0)); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; + vec3 viewDir; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 viewDir; + vec4 hip_screen; + vec3 hip_lmapFade; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform sampler2D _BumpMap; +uniform vec4 _Color; +uniform sampler2D _LightBuffer; +uniform sampler2D _MainTex; +uniform float _Parallax; +uniform sampler2D _ParallaxMap; +uniform sampler2D unity_Lightmap; +uniform sampler2D unity_LightmapInd; +vec4 UnpackNormal( in vec4 packednormal ); +vec2 ParallaxOffset( in float h, in float height, in vec3 viewDir ); +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingLambert_PrePass( in SurfaceOutput s, in vec4 light ); +vec3 DecodeLightmap( in vec4 color ); +vec4 frag_surf( in v2f_surf IN ); +vec4 UnpackNormal( in vec4 packednormal ) { + vec4 normal; + normal.xy = ((packednormal.wy * 2.00000) - 1.00000); + normal.z = sqrt( ((1.00000 - (normal.x * normal.x )) - (normal.y * normal.y )) ); + return normal; +} +vec2 ParallaxOffset( in float h, in float height, in vec3 viewDir ) { + vec3 v; + h = ((h * height) - (height / 2.00000)); + v = normalize( viewDir ); + v.z += 0.420000; + return (h * (v.xy / v.z )); +} +void surf( in Input IN, inout SurfaceOutput o ) { + float h; + vec2 offset; + vec4 c; + h = texture2D( _ParallaxMap, IN.uv_BumpMap).w ; + offset = ParallaxOffset( h, _Parallax, IN.viewDir); + IN.uv_MainTex += offset; + IN.uv_BumpMap += offset; + c = (texture2D( _MainTex, IN.uv_MainTex) * _Color); + o.Albedo = c.xyz ; + o.Alpha = c.w ; + o.Normal = vec3( UnpackNormal( texture2D( _BumpMap, IN.uv_BumpMap))); +} +vec4 LightingLambert_PrePass( in SurfaceOutput s, in vec4 light ) { + vec4 c; + c.xyz = (s.Albedo * light.xyz ); + c.w = s.Alpha; + return c; +} +vec3 DecodeLightmap( in vec4 color ) { + return (2.00000 * color.xyz ); +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec4 light; + vec3 lmFull; + vec3 lmIndirect; + vec3 lm; + vec4 col; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + surfIN.uv_BumpMap = IN.hip_pack0.zw ; + surfIN.viewDir = IN.viewDir; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + surf( surfIN, o); + light = texture2DProj( _LightBuffer, IN.hip_screen); + light = ( -log2( light ) ); + lmFull = DecodeLightmap( texture2D( unity_Lightmap, IN.hip_lmapFade.xy )); + lmIndirect = DecodeLightmap( texture2D( unity_LightmapInd, IN.hip_lmapFade.xy )); + lm = mix( lmIndirect, lmFull, vec3( xll_saturate( IN.hip_lmapFade.z ))); + light.xyz += lm; + col = LightingLambert_PrePass( o, light); + return col; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec4( gl_TexCoord[0]); + xlt_IN.viewDir = vec3( gl_TexCoord[1]); + xlt_IN.hip_screen = vec4( gl_TexCoord[2]); + xlt_IN.hip_lmapFade = vec3( gl_TexCoord[3]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Parallax_Diffuse2-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Parallax_Diffuse2-ir.txt new file mode 100644 index 000000000..51ab3a040 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Parallax_Diffuse2-ir.txt @@ -0,0 +1,362 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; + vec3 viewDir; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 viewDir; + vec4 hip_screen; + vec3 hip_lmapFade; +}; +varying vec4 xlv_FOG; +uniform sampler2D unity_LightmapInd; +uniform sampler2D unity_Lightmap; +uniform sampler2D _ParallaxMap; +uniform float _Parallax; +uniform sampler2D _MainTex; +uniform sampler2D _LightBuffer; +uniform vec4 _Color; +uniform sampler2D _BumpMap; +float xll_saturate ( + in float x +) +{ + float tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec2 xll_saturate ( + in vec2 x +) +{ + vec2 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec3 xll_saturate ( + in vec3 x +) +{ + vec3 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec4 xll_saturate ( + in vec4 x +) +{ + vec4 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +mat2 xll_saturate ( + in mat2 m +) +{ + vec2 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec2 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + mat2 tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_1; + tmpvar_3[0] = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5 = tmpvar_2; + tmpvar_3[1] = tmpvar_5; + return tmpvar_3; +} + +mat3 xll_saturate ( + in mat3 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec3 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + vec3 tmpvar_3; + tmpvar_3 = clamp (m[2], 0.0, 1.0); + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +mat4 xll_saturate ( + in mat4 m +) +{ + vec4 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec4 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + vec4 tmpvar_3; + tmpvar_3 = clamp (m[2], 0.0, 1.0); + vec4 tmpvar_4; + tmpvar_4 = clamp (m[3], 0.0, 1.0); + mat4 tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_1; + tmpvar_5[0] = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = tmpvar_2; + tmpvar_5[1] = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_3; + tmpvar_5[2] = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = tmpvar_4; + tmpvar_5[3] = tmpvar_9; + return tmpvar_5; +} + +vec4 UnpackNormal ( + in vec4 packednormal +) +{ + vec4 normal; + vec2 tmpvar_1; + tmpvar_1 = ((packednormal.wy * 2.0) - 1.0); + normal.xy = tmpvar_1.xy.xy; + float tmpvar_2; + tmpvar_2 = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + normal.z = vec3(tmpvar_3).z; + return normal; +} + +vec2 ParallaxOffset ( + in float h, + in float height, + in vec3 viewDir +) +{ + vec3 v; + float tmpvar_1; + tmpvar_1 = ((h * height) - (height / 2.0)); + h = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = normalize (viewDir); + vec3 tmpvar_3; + tmpvar_3 = tmpvar_2; + v = tmpvar_3; + float tmpvar_4; + tmpvar_4 = (v.z + 0.42); + v.z = vec3(tmpvar_4).z; + return (h * (v.xy / v.z)); +} + +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 c; + vec2 offset; + float h; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_ParallaxMap, IN.uv_BumpMap); + float tmpvar_2; + tmpvar_2 = tmpvar_1.w; + h = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = ParallaxOffset (h, _Parallax, IN.viewDir); + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + offset = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5 = (IN.uv_MainTex + offset); + IN.uv_MainTex = tmpvar_5; + vec2 tmpvar_6; + tmpvar_6 = (IN.uv_BumpMap + offset); + IN.uv_BumpMap = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_8; + tmpvar_8 = (tmpvar_7 * _Color); + c = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = c.xyz; + o.Albedo = tmpvar_9; + float tmpvar_10; + tmpvar_10 = c.w; + o.Alpha = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = texture2D (_BumpMap, IN.uv_BumpMap); + vec4 tmpvar_12; + tmpvar_12 = UnpackNormal (tmpvar_11); + vec3 tmpvar_13; + tmpvar_13 = tmpvar_12.xyz; + vec3 tmpvar_14; + tmpvar_14 = tmpvar_13; + o.Normal = tmpvar_14; +} + +vec4 LightingLambert_PrePass ( + in SurfaceOutput s, + in vec4 light +) +{ + vec4 c; + vec3 tmpvar_1; + tmpvar_1 = (s.Albedo * light.xyz); + c.xyz = tmpvar_1.xyz.xyz; + float tmpvar_2; + tmpvar_2 = s.Alpha; + c.w = vec4(tmpvar_2).w; + return c; +} + +vec3 DecodeLightmap ( + in vec4 color +) +{ + return (2.0 * color.xyz); +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 col; + vec3 lm; + vec3 lmIndirect; + vec3 lmFull; + vec4 light; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = IN.hip_pack0.zw; + surfIN.uv_BumpMap = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = IN.viewDir; + surfIN.viewDir = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Specular = tmpvar_6; + float tmpvar_7; + tmpvar_7 = 0.0; + o.Alpha = tmpvar_7; + float tmpvar_8; + tmpvar_8 = 0.0; + o.Gloss = tmpvar_8; + surf (surfIN, o); + vec4 tmpvar_9; + tmpvar_9 = texture2DProj (_LightBuffer, IN.hip_screen); + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + light = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = log2 (light); + vec4 tmpvar_12; + tmpvar_12 = -(tmpvar_11); + light = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = texture2D (unity_Lightmap, IN.hip_lmapFade.xy); + vec3 tmpvar_14; + tmpvar_14 = DecodeLightmap (tmpvar_13); + vec3 tmpvar_15; + tmpvar_15 = tmpvar_14; + lmFull = tmpvar_15; + vec4 tmpvar_16; + tmpvar_16 = texture2D (unity_LightmapInd, IN.hip_lmapFade.xy); + vec3 tmpvar_17; + tmpvar_17 = DecodeLightmap (tmpvar_16); + vec3 tmpvar_18; + tmpvar_18 = tmpvar_17; + lmIndirect = tmpvar_18; + float tmpvar_19; + tmpvar_19 = xll_saturate (IN.hip_lmapFade.z); + vec3 tmpvar_20; + tmpvar_20 = vec3(tmpvar_19); + vec3 tmpvar_21; + tmpvar_21 = mix (lmIndirect, lmFull, tmpvar_20); + vec3 tmpvar_22; + tmpvar_22 = tmpvar_21; + lm = tmpvar_22; + vec3 tmpvar_23; + tmpvar_23 = (light.xyz + lm); + light.xyz = tmpvar_23.xyz.xyz; + vec4 tmpvar_24; + tmpvar_24 = LightingLambert_PrePass (o, light); + vec4 tmpvar_25; + tmpvar_25 = tmpvar_24; + col = tmpvar_25; + return col; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.viewDir = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.hip_screen = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = gl_TexCoord[3].xyz; + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_IN.hip_lmapFade = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = frag_surf (xlt_IN); + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xl_retval = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = xl_retval.xyzw; + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + gl_FragData[0] = tmpvar_14; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Parallax_Diffuse2-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Parallax_Diffuse2-out.txt new file mode 100644 index 000000000..09ca96c8c --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Parallax_Diffuse2-out.txt @@ -0,0 +1,37 @@ +uniform sampler2D unity_LightmapInd; +uniform sampler2D unity_Lightmap; +uniform sampler2D _ParallaxMap; +uniform float _Parallax; +uniform sampler2D _MainTex; +uniform sampler2D _LightBuffer; +uniform vec4 _Color; +uniform sampler2D _BumpMap; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = gl_TexCoord[0]; + vec3 tmpvar_2; + tmpvar_2 = gl_TexCoord[3].xyz; + vec4 light; + vec2 tmpvar_3; + vec3 v; + vec3 tmpvar_4; + tmpvar_4 = normalize (gl_TexCoord[1].xyz); + v = tmpvar_4; + v.z = (tmpvar_4.z + 0.42); + tmpvar_3 = (((texture2D (_ParallaxMap, tmpvar_1.zw).w * _Parallax) - (_Parallax / 2.0)) * (tmpvar_4.xy / v.z)); + vec4 tmpvar_5; + tmpvar_5 = (texture2D (_MainTex, (tmpvar_1.xy + tmpvar_3)) * _Color); + vec4 normal; + normal.xy = ((texture2D (_BumpMap, (tmpvar_1.zw + tmpvar_3)).wy * 2.0) - 1.0); + normal.z = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + vec4 tmpvar_6; + tmpvar_6 = -(log2 (texture2DProj (_LightBuffer, gl_TexCoord[2]))); + light = tmpvar_6; + light.xyz = (tmpvar_6.xyz + mix ((2.0 * texture2D (unity_LightmapInd, tmpvar_2.xy).xyz), (2.0 * texture2D (unity_Lightmap, tmpvar_2.xy).xyz), vec3(clamp (tmpvar_2.z, 0.0, 1.0)))); + vec4 c_i0; + c_i0.xyz = (tmpvar_5.xyz * light.xyz); + c_i0.w = tmpvar_5.w; + gl_FragData[0] = c_i0; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Parallax_Specular-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Parallax_Specular-in.txt new file mode 100644 index 000000000..e938f555f --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Parallax_Specular-in.txt @@ -0,0 +1,140 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; + vec3 viewDir; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 viewDir; + vec3 lightDir; + vec4 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform sampler2D _BumpMap; +uniform vec4 _Color; +uniform vec4 _LightColor0; +uniform sampler2D _LightTexture0; +uniform sampler2D _LightTextureB0; +uniform sampler2D _MainTex; +uniform float _Parallax; +uniform sampler2D _ParallaxMap; +uniform float _Shininess; +uniform vec4 _SpecColor; +vec4 UnpackNormal( in vec4 packednormal ); +vec2 ParallaxOffset( in float h, in float height, in vec3 viewDir ); +void surf( in Input IN, inout SurfaceOutput o ); +float UnitySpotCookie( in vec4 LightCoord ); +float UnitySpotAttenuate( in vec3 LightCoord ); +vec4 LightingBlinnPhong( in SurfaceOutput s, in vec3 lightDir, in vec3 viewDir, in float atten ); +vec4 frag_surf( in v2f_surf IN ); +vec4 UnpackNormal( in vec4 packednormal ) { + vec4 normal; + normal.xy = ((packednormal.wy * 2.00000) - 1.00000); + normal.z = sqrt( ((1.00000 - (normal.x * normal.x )) - (normal.y * normal.y )) ); + return normal; +} +vec2 ParallaxOffset( in float h, in float height, in vec3 viewDir ) { + vec3 v; + h = ((h * height) - (height / 2.00000)); + v = normalize( viewDir ); + v.z += 0.420000; + return (h * (v.xy / v.z )); +} +void surf( in Input IN, inout SurfaceOutput o ) { + float h; + vec2 offset; + vec4 tex; + h = texture2D( _ParallaxMap, IN.uv_BumpMap).w ; + offset = ParallaxOffset( h, _Parallax, IN.viewDir); + IN.uv_MainTex += offset; + IN.uv_BumpMap += offset; + tex = texture2D( _MainTex, IN.uv_MainTex); + o.Albedo = (tex.xyz * _Color.xyz ); + o.Gloss = tex.w ; + o.Alpha = (tex.w * _Color.w ); + o.Specular = _Shininess; + o.Normal = vec3( UnpackNormal( texture2D( _BumpMap, IN.uv_BumpMap))); +} +float UnitySpotCookie( in vec4 LightCoord ) { + return texture2D( _LightTexture0, ((LightCoord.xy / LightCoord.w ) + 0.500000)).w ; +} +float UnitySpotAttenuate( in vec3 LightCoord ) { + return texture2D( _LightTextureB0, vec2( vec2( dot( LightCoord, LightCoord)))).w ; +} +vec4 LightingBlinnPhong( in SurfaceOutput s, in vec3 lightDir, in vec3 viewDir, in float atten ) { + vec3 h; + float diff; + float nh; + float spec; + vec4 c; + h = normalize( (lightDir + viewDir) ); + diff = max( 0.000000, dot( s.Normal, lightDir)); + nh = max( 0.000000, dot( s.Normal, h)); + spec = (pow( nh, (s.Specular * 128.000)) * s.Gloss); + c.xyz = ((((s.Albedo * _LightColor0.xyz ) * diff) + ((_LightColor0.xyz * _SpecColor.xyz ) * spec)) * (atten * 2.00000)); + c.w = (s.Alpha + (((_LightColor0.w * _SpecColor.w ) * spec) * atten)); + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec3 lightDir; + vec4 c; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + surfIN.uv_BumpMap = IN.hip_pack0.zw ; + surfIN.viewDir = IN.viewDir; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + surf( surfIN, o); + lightDir = IN.lightDir; + lightDir = normalize( lightDir ); + c = LightingBlinnPhong( o, lightDir, normalize( vec3( IN.viewDir) ), ((float( (IN._LightCoord.z > 0.000000) ) * UnitySpotCookie( IN._LightCoord)) * UnitySpotAttenuate( IN._LightCoord.xyz ))); + c.w = 0.000000; + return c; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec4( gl_TexCoord[0]); + xlt_IN.viewDir = vec3( gl_TexCoord[1]); + xlt_IN.lightDir = vec3( gl_TexCoord[2]); + xlt_IN._LightCoord = vec4( gl_TexCoord[3]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Parallax_Specular-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Parallax_Specular-ir.txt new file mode 100644 index 000000000..4c07dfaf0 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Parallax_Specular-ir.txt @@ -0,0 +1,292 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; + vec3 viewDir; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 viewDir; + vec3 lightDir; + vec4 _LightCoord; +}; +varying vec4 xlv_FOG; +uniform vec4 _SpecColor; +uniform float _Shininess; +uniform sampler2D _ParallaxMap; +uniform float _Parallax; +uniform sampler2D _MainTex; +uniform sampler2D _LightTextureB0; +uniform sampler2D _LightTexture0; +uniform vec4 _LightColor0; +uniform vec4 _Color; +uniform sampler2D _BumpMap; +vec4 UnpackNormal ( + in vec4 packednormal +) +{ + vec4 normal; + vec2 tmpvar_1; + tmpvar_1 = ((packednormal.wy * 2.0) - 1.0); + normal.xy = tmpvar_1.xy.xy; + float tmpvar_2; + tmpvar_2 = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + normal.z = vec3(tmpvar_3).z; + return normal; +} + +vec2 ParallaxOffset ( + in float h, + in float height, + in vec3 viewDir +) +{ + vec3 v; + float tmpvar_1; + tmpvar_1 = ((h * height) - (height / 2.0)); + h = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = normalize (viewDir); + vec3 tmpvar_3; + tmpvar_3 = tmpvar_2; + v = tmpvar_3; + float tmpvar_4; + tmpvar_4 = (v.z + 0.42); + v.z = vec3(tmpvar_4).z; + return (h * (v.xy / v.z)); +} + +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 tex; + vec2 offset; + float h; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_ParallaxMap, IN.uv_BumpMap); + float tmpvar_2; + tmpvar_2 = tmpvar_1.w; + h = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = ParallaxOffset (h, _Parallax, IN.viewDir); + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + offset = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5 = (IN.uv_MainTex + offset); + IN.uv_MainTex = tmpvar_5; + vec2 tmpvar_6; + tmpvar_6 = (IN.uv_BumpMap + offset); + IN.uv_BumpMap = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + tex = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = (tex.xyz * _Color.xyz); + o.Albedo = tmpvar_9; + float tmpvar_10; + tmpvar_10 = tex.w; + o.Gloss = tmpvar_10; + float tmpvar_11; + tmpvar_11 = (tex.w * _Color.w); + o.Alpha = tmpvar_11; + float tmpvar_12; + tmpvar_12 = _Shininess; + o.Specular = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = texture2D (_BumpMap, IN.uv_BumpMap); + vec4 tmpvar_14; + tmpvar_14 = UnpackNormal (tmpvar_13); + vec3 tmpvar_15; + tmpvar_15 = tmpvar_14.xyz; + vec3 tmpvar_16; + tmpvar_16 = tmpvar_15; + o.Normal = tmpvar_16; +} + +float UnitySpotCookie ( + in vec4 LightCoord +) +{ + vec4 tmpvar_1; + tmpvar_1 = texture2D (_LightTexture0, ((LightCoord.xy / LightCoord.w) + 0.5)); + return tmpvar_1.w; +} + +float UnitySpotAttenuate ( + in vec3 LightCoord +) +{ + float tmpvar_1; + tmpvar_1 = dot (LightCoord, LightCoord); + vec2 tmpvar_2; + tmpvar_2 = vec2(tmpvar_1); + vec2 tmpvar_3; + tmpvar_3 = tmpvar_2.xy; + vec4 tmpvar_4; + tmpvar_4 = texture2D (_LightTextureB0, tmpvar_3); + return tmpvar_4.w; +} + +vec4 LightingBlinnPhong ( + in SurfaceOutput s, + in vec3 lightDir, + in vec3 viewDir, + in float atten +) +{ + vec4 c; + float spec; + float nh; + float diff; + vec3 h; + vec3 tmpvar_1; + tmpvar_1 = normalize ((lightDir + viewDir)); + vec3 tmpvar_2; + tmpvar_2 = tmpvar_1; + h = tmpvar_2; + float tmpvar_3; + tmpvar_3 = dot (s.Normal, lightDir); + float tmpvar_4; + tmpvar_4 = max (0.0, tmpvar_3); + float tmpvar_5; + tmpvar_5 = tmpvar_4; + diff = tmpvar_5; + float tmpvar_6; + tmpvar_6 = dot (s.Normal, h); + float tmpvar_7; + tmpvar_7 = max (0.0, tmpvar_6); + float tmpvar_8; + tmpvar_8 = tmpvar_7; + nh = tmpvar_8; + float tmpvar_9; + tmpvar_9 = pow (nh, (s.Specular * 128.0)); + float tmpvar_10; + tmpvar_10 = (tmpvar_9 * s.Gloss); + spec = tmpvar_10; + vec3 tmpvar_11; + tmpvar_11 = ((((s.Albedo * _LightColor0.xyz) * diff) + ((_LightColor0.xyz * _SpecColor.xyz) * spec)) * (atten * 2.0)); + c.xyz = tmpvar_11.xyz.xyz; + float tmpvar_12; + tmpvar_12 = (s.Alpha + (((_LightColor0.w * _SpecColor.w) * spec) * atten)); + c.w = vec4(tmpvar_12).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 c; + vec3 lightDir; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = IN.hip_pack0.zw; + surfIN.uv_BumpMap = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = IN.viewDir; + surfIN.viewDir = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Specular = tmpvar_6; + float tmpvar_7; + tmpvar_7 = 0.0; + o.Alpha = tmpvar_7; + float tmpvar_8; + tmpvar_8 = 0.0; + o.Gloss = tmpvar_8; + surf (surfIN, o); + vec3 tmpvar_9; + tmpvar_9 = IN.lightDir; + lightDir = tmpvar_9; + vec3 tmpvar_10; + tmpvar_10 = normalize (lightDir); + vec3 tmpvar_11; + tmpvar_11 = tmpvar_10; + lightDir = tmpvar_11; + vec3 tmpvar_12; + tmpvar_12 = IN.viewDir.xyz; + vec3 tmpvar_13; + tmpvar_13 = normalize (tmpvar_12); + float tmpvar_14; + tmpvar_14 = UnitySpotCookie (IN._LightCoord); + float tmpvar_15; + tmpvar_15 = UnitySpotAttenuate (IN._LightCoord.xyz); + vec4 tmpvar_16; + tmpvar_16 = LightingBlinnPhong (o, lightDir, tmpvar_13, ((float((IN._LightCoord.z > 0.0)) * tmpvar_14) * tmpvar_15)); + vec4 tmpvar_17; + tmpvar_17 = tmpvar_16; + c = tmpvar_17; + float tmpvar_18; + tmpvar_18 = 0.0; + c.w = vec4(tmpvar_18).w; + return c; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.viewDir = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.lightDir = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_TexCoord[3].xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_IN._LightCoord = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = frag_surf (xlt_IN); + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xl_retval = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = xl_retval.xyzw; + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + gl_FragData[0] = tmpvar_14; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Parallax_Specular-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Parallax_Specular-out.txt new file mode 100644 index 000000000..98f980cbb --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Parallax_Specular-out.txt @@ -0,0 +1,49 @@ +uniform vec4 _SpecColor; +uniform float _Shininess; +uniform sampler2D _ParallaxMap; +uniform float _Parallax; +uniform sampler2D _MainTex; +uniform sampler2D _LightTextureB0; +uniform sampler2D _LightTexture0; +uniform vec4 _LightColor0; +uniform vec4 _Color; +uniform sampler2D _BumpMap; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = gl_TexCoord[0]; + vec3 tmpvar_2; + tmpvar_2 = gl_TexCoord[1].xyz; + vec4 tmpvar_3; + tmpvar_3 = gl_TexCoord[3]; + vec4 c; + vec2 tmpvar_4; + vec3 v; + vec3 tmpvar_5; + tmpvar_5 = normalize (tmpvar_2); + v = tmpvar_5; + v.z = (tmpvar_5.z + 0.42); + tmpvar_4 = (((texture2D (_ParallaxMap, tmpvar_1.zw).w * _Parallax) - (_Parallax / 2.0)) * (tmpvar_5.xy / v.z)); + vec4 tmpvar_6; + tmpvar_6 = texture2D (_MainTex, (tmpvar_1.xy + tmpvar_4)); + vec4 normal; + normal.xy = ((texture2D (_BumpMap, (tmpvar_1.zw + tmpvar_4)).wy * 2.0) - 1.0); + normal.z = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + vec3 tmpvar_7; + tmpvar_7 = normal.xyz; + vec3 tmpvar_8; + tmpvar_8 = normalize (gl_TexCoord[2].xyz); + vec3 LightCoord_i0; + LightCoord_i0 = tmpvar_3.xyz; + float atten; + atten = ((float((tmpvar_3.z > 0.0)) * texture2D (_LightTexture0, ((tmpvar_3.xy / tmpvar_3.w) + 0.5)).w) * texture2D (_LightTextureB0, vec2(dot (LightCoord_i0, LightCoord_i0))).w); + vec4 c_i0; + float tmpvar_9; + tmpvar_9 = (pow (max (0.0, dot (tmpvar_7, normalize ((tmpvar_8 + normalize (tmpvar_2))))), (_Shininess * 128.0)) * tmpvar_6.w); + c_i0.xyz = (((((tmpvar_6.xyz * _Color.xyz) * _LightColor0.xyz) * max (0.0, dot (tmpvar_7, tmpvar_8))) + ((_LightColor0.xyz * _SpecColor.xyz) * tmpvar_9)) * (atten * 2.0)); + c_i0.w = ((tmpvar_6.w * _Color.w) + (((_LightColor0.w * _SpecColor.w) * tmpvar_9) * atten)); + c = c_i0; + c.w = 0.0; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Particles_Additive-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Particles_Additive-in.txt new file mode 100644 index 000000000..967365d83 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Particles_Additive-in.txt @@ -0,0 +1,38 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct v2f { + vec4 vertex; + vec4 color; + vec2 texcoord; +}; +struct appdata_t { + vec4 vertex; + vec4 color; + vec2 texcoord; +}; +uniform sampler2D _MainTex; +uniform vec4 _TintColor; +vec4 frag( in v2f i ); +vec4 frag( in v2f i ) { + return (((2.00000 * i.color) * _TintColor) * texture2D( _MainTex, i.texcoord)); +} +void main() { + vec4 xl_retval; + v2f xlt_i; + xlt_i.vertex = vec4(0.0); + xlt_i.color = vec4( gl_Color); + xlt_i.texcoord = vec2( gl_TexCoord[0]); + xl_retval = frag( xlt_i); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Particles_Additive-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Particles_Additive-ir.txt new file mode 100644 index 000000000..bb7aae3ba --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Particles_Additive-ir.txt @@ -0,0 +1,45 @@ +struct v2f { + vec4 vertex; + vec4 color; + vec2 texcoord; +}; +uniform vec4 _TintColor; +uniform sampler2D _MainTex; +vec4 frag ( + in v2f i +) +{ + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, i.texcoord); + return (((2.0 * i.color) * _TintColor) * tmpvar_1); +} + +void main () +{ + v2f xlt_i; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_i.vertex = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = gl_Color.xyzw; + vec4 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_i.color = tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = gl_TexCoord[0].xy; + vec2 tmpvar_5; + tmpvar_5 = tmpvar_4; + xlt_i.texcoord = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = frag (xlt_i); + vec4 tmpvar_7; + tmpvar_7 = tmpvar_6; + xl_retval = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = xl_retval.xyzw; + vec4 tmpvar_9; + tmpvar_9 = tmpvar_8; + gl_FragData[0] = tmpvar_9; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Particles_Additive-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Particles_Additive-out.txt new file mode 100644 index 000000000..4606b1906 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Particles_Additive-out.txt @@ -0,0 +1,7 @@ +uniform vec4 _TintColor; +uniform sampler2D _MainTex; +void main () +{ + gl_FragData[0] = (((2.0 * gl_Color) * _TintColor) * texture2D (_MainTex, gl_TexCoord[0].xy)); +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Particles_Additive_(Soft)-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Particles_Additive_(Soft)-in.txt new file mode 100644 index 000000000..70c58119f --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Particles_Additive_(Soft)-in.txt @@ -0,0 +1,40 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct v2f { + vec4 vertex; + vec4 color; + vec2 texcoord; +}; +struct appdata_t { + vec4 vertex; + vec4 color; + vec2 texcoord; +}; +uniform sampler2D _MainTex; +vec4 frag( in v2f i ); +vec4 frag( in v2f i ) { + vec4 prev; + prev = (i.color * texture2D( _MainTex, i.texcoord)); + prev.xyz *= prev.w ; + return prev; +} +void main() { + vec4 xl_retval; + v2f xlt_i; + xlt_i.vertex = vec4(0.0); + xlt_i.color = vec4( gl_Color); + xlt_i.texcoord = vec2( gl_TexCoord[0]); + xl_retval = frag( xlt_i); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Particles_Additive_(Soft)-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Particles_Additive_(Soft)-ir.txt new file mode 100644 index 000000000..8a73ae172 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Particles_Additive_(Soft)-ir.txt @@ -0,0 +1,51 @@ +struct v2f { + vec4 vertex; + vec4 color; + vec2 texcoord; +}; +uniform sampler2D _MainTex; +vec4 frag ( + in v2f i +) +{ + vec4 prev; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, i.texcoord); + vec4 tmpvar_2; + tmpvar_2 = (i.color * tmpvar_1); + prev = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = (prev.xyz * prev.w); + prev.xyz = tmpvar_3.xyz.xyz; + return prev; +} + +void main () +{ + v2f xlt_i; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_i.vertex = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = gl_Color.xyzw; + vec4 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_i.color = tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = gl_TexCoord[0].xy; + vec2 tmpvar_5; + tmpvar_5 = tmpvar_4; + xlt_i.texcoord = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = frag (xlt_i); + vec4 tmpvar_7; + tmpvar_7 = tmpvar_6; + xl_retval = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = xl_retval.xyzw; + vec4 tmpvar_9; + tmpvar_9 = tmpvar_8; + gl_FragData[0] = tmpvar_9; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Particles_Additive_(Soft)-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Particles_Additive_(Soft)-out.txt new file mode 100644 index 000000000..45bb03a32 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Particles_Additive_(Soft)-out.txt @@ -0,0 +1,11 @@ +uniform sampler2D _MainTex; +void main () +{ + vec4 prev; + vec4 tmpvar_1; + tmpvar_1 = (gl_Color * texture2D (_MainTex, gl_TexCoord[0].xy)); + prev = tmpvar_1; + prev.xyz = (tmpvar_1.xyz * tmpvar_1.w); + gl_FragData[0] = prev; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Particles_Alpha_Blended_Premultiply-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Particles_Alpha_Blended_Premultiply-in.txt new file mode 100644 index 000000000..327354da0 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Particles_Alpha_Blended_Premultiply-in.txt @@ -0,0 +1,37 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct v2f { + vec4 vertex; + vec4 color; + vec2 texcoord; +}; +struct appdata_t { + vec4 vertex; + vec4 color; + vec2 texcoord; +}; +uniform sampler2D _MainTex; +vec4 frag( in v2f i ); +vec4 frag( in v2f i ) { + return ((i.color * texture2D( _MainTex, i.texcoord)) * i.color.w ); +} +void main() { + vec4 xl_retval; + v2f xlt_i; + xlt_i.vertex = vec4(0.0); + xlt_i.color = vec4( gl_Color); + xlt_i.texcoord = vec2( gl_TexCoord[0]); + xl_retval = frag( xlt_i); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Particles_Alpha_Blended_Premultiply-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Particles_Alpha_Blended_Premultiply-ir.txt new file mode 100644 index 000000000..52a3d3c70 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Particles_Alpha_Blended_Premultiply-ir.txt @@ -0,0 +1,44 @@ +struct v2f { + vec4 vertex; + vec4 color; + vec2 texcoord; +}; +uniform sampler2D _MainTex; +vec4 frag ( + in v2f i +) +{ + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, i.texcoord); + return ((i.color * tmpvar_1) * i.color.w); +} + +void main () +{ + v2f xlt_i; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_i.vertex = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = gl_Color.xyzw; + vec4 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_i.color = tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = gl_TexCoord[0].xy; + vec2 tmpvar_5; + tmpvar_5 = tmpvar_4; + xlt_i.texcoord = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = frag (xlt_i); + vec4 tmpvar_7; + tmpvar_7 = tmpvar_6; + xl_retval = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = xl_retval.xyzw; + vec4 tmpvar_9; + tmpvar_9 = tmpvar_8; + gl_FragData[0] = tmpvar_9; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Particles_Alpha_Blended_Premultiply-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Particles_Alpha_Blended_Premultiply-out.txt new file mode 100644 index 000000000..75d9a0add --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Particles_Alpha_Blended_Premultiply-out.txt @@ -0,0 +1,6 @@ +uniform sampler2D _MainTex; +void main () +{ + gl_FragData[0] = ((gl_Color * texture2D (_MainTex, gl_TexCoord[0].xy)) * gl_Color.w); +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Particles_Multiply-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Particles_Multiply-in.txt new file mode 100644 index 000000000..c262ae200 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Particles_Multiply-in.txt @@ -0,0 +1,39 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct v2f { + vec4 vertex; + vec4 color; + vec2 texcoord; +}; +struct appdata_t { + vec4 vertex; + vec4 color; + vec2 texcoord; +}; +uniform sampler2D _MainTex; +vec4 frag( in v2f i ); +vec4 frag( in v2f i ) { + vec4 prev; + prev = (i.color * texture2D( _MainTex, i.texcoord)); + return mix( vec4( 1.00000, 1.00000, 1.00000, 1.00000), prev, vec4( prev.w )); +} +void main() { + vec4 xl_retval; + v2f xlt_i; + xlt_i.vertex = vec4(0.0); + xlt_i.color = vec4( gl_Color); + xlt_i.texcoord = vec2( gl_TexCoord[0]); + xl_retval = frag( xlt_i); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Particles_Multiply-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Particles_Multiply-ir.txt new file mode 100644 index 000000000..c5ead733f --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Particles_Multiply-ir.txt @@ -0,0 +1,52 @@ +struct v2f { + vec4 vertex; + vec4 color; + vec2 texcoord; +}; +uniform sampler2D _MainTex; +vec4 frag ( + in v2f i +) +{ + vec4 prev; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, i.texcoord); + vec4 tmpvar_2; + tmpvar_2 = (i.color * tmpvar_1); + prev = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = vec4(prev.w); + vec4 tmpvar_4; + tmpvar_4 = mix (vec4(1.0, 1.0, 1.0, 1.0), prev, tmpvar_3); + return tmpvar_4; +} + +void main () +{ + v2f xlt_i; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_i.vertex = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = gl_Color.xyzw; + vec4 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_i.color = tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = gl_TexCoord[0].xy; + vec2 tmpvar_5; + tmpvar_5 = tmpvar_4; + xlt_i.texcoord = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = frag (xlt_i); + vec4 tmpvar_7; + tmpvar_7 = tmpvar_6; + xl_retval = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = xl_retval.xyzw; + vec4 tmpvar_9; + tmpvar_9 = tmpvar_8; + gl_FragData[0] = tmpvar_9; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Particles_Multiply-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Particles_Multiply-out.txt new file mode 100644 index 000000000..5965c6d92 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Particles_Multiply-out.txt @@ -0,0 +1,8 @@ +uniform sampler2D _MainTex; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_Color * texture2D (_MainTex, gl_TexCoord[0].xy)); + gl_FragData[0] = mix (vec4(1.0, 1.0, 1.0, 1.0), tmpvar_1, tmpvar_1.wwww); +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Particles_Multiply_(Double)-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Particles_Multiply_(Double)-in.txt new file mode 100644 index 000000000..856c5663a --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Particles_Multiply_(Double)-in.txt @@ -0,0 +1,42 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct v2f { + vec4 vertex; + vec4 color; + vec2 texcoord; +}; +struct appdata_t { + vec4 vertex; + vec4 color; + vec2 texcoord; +}; +uniform sampler2D _MainTex; +vec4 frag( in v2f i ); +vec4 frag( in v2f i ) { + vec4 tex; + vec4 col; + tex = texture2D( _MainTex, i.texcoord); + col.xyz = ((tex.xyz * i.color.xyz ) * 2.00000); + col.w = (i.color.w * tex.w ); + return mix( vec4( 0.500000, 0.500000, 0.500000, 0.500000), col, vec4( col.w )); +} +void main() { + vec4 xl_retval; + v2f xlt_i; + xlt_i.vertex = vec4(0.0); + xlt_i.color = vec4( gl_Color); + xlt_i.texcoord = vec2( gl_TexCoord[0]); + xl_retval = frag( xlt_i); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Particles_Multiply_(Double)-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Particles_Multiply_(Double)-ir.txt new file mode 100644 index 000000000..d77412a21 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Particles_Multiply_(Double)-ir.txt @@ -0,0 +1,59 @@ +struct v2f { + vec4 vertex; + vec4 color; + vec2 texcoord; +}; +uniform sampler2D _MainTex; +vec4 frag ( + in v2f i +) +{ + vec4 col; + vec4 tex; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, i.texcoord); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + tex = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = ((tex.xyz * i.color.xyz) * 2.0); + col.xyz = tmpvar_3.xyz.xyz; + float tmpvar_4; + tmpvar_4 = (i.color.w * tex.w); + col.w = vec4(tmpvar_4).w; + vec4 tmpvar_5; + tmpvar_5 = vec4(col.w); + vec4 tmpvar_6; + tmpvar_6 = mix (vec4(0.5, 0.5, 0.5, 0.5), col, tmpvar_5); + return tmpvar_6; +} + +void main () +{ + v2f xlt_i; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_i.vertex = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = gl_Color.xyzw; + vec4 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_i.color = tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = gl_TexCoord[0].xy; + vec2 tmpvar_5; + tmpvar_5 = tmpvar_4; + xlt_i.texcoord = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = frag (xlt_i); + vec4 tmpvar_7; + tmpvar_7 = tmpvar_6; + xl_retval = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = xl_retval.xyzw; + vec4 tmpvar_9; + tmpvar_9 = tmpvar_8; + gl_FragData[0] = tmpvar_9; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Particles_Multiply_(Double)-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Particles_Multiply_(Double)-out.txt new file mode 100644 index 000000000..5cbe4356a --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Particles_Multiply_(Double)-out.txt @@ -0,0 +1,11 @@ +uniform sampler2D _MainTex; +void main () +{ + vec4 col; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, gl_TexCoord[0].xy); + col.xyz = ((tmpvar_1.xyz * gl_Color.xyz) * 2.0); + col.w = (gl_Color.w * tmpvar_1.w); + gl_FragData[0] = mix (vec4(0.5, 0.5, 0.5, 0.5), col, col.wwww); +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Particles__Additive-Multiply-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Particles__Additive-Multiply-in.txt new file mode 100644 index 000000000..10d4aa725 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Particles__Additive-Multiply-in.txt @@ -0,0 +1,43 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct v2f { + vec4 vertex; + vec4 color; + vec2 texcoord; +}; +struct appdata_t { + vec4 vertex; + vec4 color; + vec2 texcoord; +}; +uniform sampler2D _MainTex; +uniform vec4 _TintColor; +vec4 frag( in v2f i ); +vec4 frag( in v2f i ) { + vec4 tex; + vec4 col; + tex = texture2D( _MainTex, i.texcoord); + col.xyz = (((_TintColor.xyz * tex.xyz ) * i.color.xyz ) * 2.00000); + col.w = ((1.00000 - tex.w ) * ((_TintColor.w * i.color.w ) * 2.00000)); + return col; +} +void main() { + vec4 xl_retval; + v2f xlt_i; + xlt_i.vertex = vec4(0.0); + xlt_i.color = vec4( gl_Color); + xlt_i.texcoord = vec2( gl_TexCoord[0]); + xl_retval = frag( xlt_i); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Particles__Additive-Multiply-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Particles__Additive-Multiply-ir.txt new file mode 100644 index 000000000..276afb1b2 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Particles__Additive-Multiply-ir.txt @@ -0,0 +1,56 @@ +struct v2f { + vec4 vertex; + vec4 color; + vec2 texcoord; +}; +uniform vec4 _TintColor; +uniform sampler2D _MainTex; +vec4 frag ( + in v2f i +) +{ + vec4 col; + vec4 tex; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, i.texcoord); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + tex = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = (((_TintColor.xyz * tex.xyz) * i.color.xyz) * 2.0); + col.xyz = tmpvar_3.xyz.xyz; + float tmpvar_4; + tmpvar_4 = ((1.0 - tex.w) * ((_TintColor.w * i.color.w) * 2.0)); + col.w = vec4(tmpvar_4).w; + return col; +} + +void main () +{ + v2f xlt_i; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_i.vertex = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = gl_Color.xyzw; + vec4 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_i.color = tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = gl_TexCoord[0].xy; + vec2 tmpvar_5; + tmpvar_5 = tmpvar_4; + xlt_i.texcoord = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = frag (xlt_i); + vec4 tmpvar_7; + tmpvar_7 = tmpvar_6; + xl_retval = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = xl_retval.xyzw; + vec4 tmpvar_9; + tmpvar_9 = tmpvar_8; + gl_FragData[0] = tmpvar_9; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Particles__Additive-Multiply-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Particles__Additive-Multiply-out.txt new file mode 100644 index 000000000..675fbcf84 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Particles__Additive-Multiply-out.txt @@ -0,0 +1,12 @@ +uniform vec4 _TintColor; +uniform sampler2D _MainTex; +void main () +{ + vec4 col; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, gl_TexCoord[0].xy); + col.xyz = (((_TintColor.xyz * tmpvar_1.xyz) * gl_Color.xyz) * 2.0); + col.w = ((1.0 - tmpvar_1.w) * ((_TintColor.w * gl_Color.w) * 2.0)); + gl_FragData[0] = col; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Bumped_Diffuse-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Bumped_Diffuse-in.txt new file mode 100644 index 000000000..46d999d6a --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Bumped_Diffuse-in.txt @@ -0,0 +1,111 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; + vec3 worldRefl; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 lightDir; + vec2 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform sampler2D _BumpMap; +uniform vec4 _Color; +uniform samplerCube _Cube; +uniform vec4 _LightColor0; +uniform sampler2D _LightTexture0; +uniform sampler2D _MainTex; +uniform vec4 _ReflectColor; +vec4 UnpackNormal( in vec4 packednormal ); +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ); +vec4 frag_surf( in v2f_surf IN ); +vec4 UnpackNormal( in vec4 packednormal ) { + vec4 normal; + normal.xy = ((packednormal.wy * 2.00000) - 1.00000); + normal.z = sqrt( ((1.00000 - (normal.x * normal.x )) - (normal.y * normal.y )) ); + return normal; +} +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 tex; + vec4 c; + vec3 worldRefl; + vec4 reflcol; + tex = texture2D( _MainTex, IN.uv_MainTex); + c = (tex * _Color); + o.Albedo = c.xyz ; + o.Normal = vec3( UnpackNormal( texture2D( _BumpMap, IN.uv_BumpMap))); + worldRefl = IN.worldRefl; + reflcol = textureCube( _Cube, worldRefl); + reflcol *= tex.w ; + o.Emission = (reflcol.xyz * _ReflectColor.xyz ); + o.Alpha = (reflcol.w * _ReflectColor.w ); +} +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ) { + float diff; + vec4 c; + diff = max( 0.000000, dot( s.Normal, lightDir)); + c.xyz = ((s.Albedo * _LightColor0.xyz ) * ((diff * atten) * 2.00000)); + c.w = s.Alpha; + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec3 lightDir; + vec4 c; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + surfIN.uv_BumpMap = IN.hip_pack0.zw ; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + surf( surfIN, o); + lightDir = IN.lightDir; + c = LightingLambert( o, lightDir, (texture2D( _LightTexture0, IN._LightCoord).w * 1.00000)); + c.w = 0.000000; + return c; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec4( gl_TexCoord[0]); + xlt_IN.lightDir = vec3( gl_TexCoord[1]); + xlt_IN._LightCoord = vec2( gl_TexCoord[2]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Bumped_Diffuse-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Bumped_Diffuse-ir.txt new file mode 100644 index 000000000..dfced2b8c --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Bumped_Diffuse-ir.txt @@ -0,0 +1,199 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; + vec3 worldRefl; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 lightDir; + vec2 _LightCoord; +}; +varying vec4 xlv_FOG; +uniform vec4 _ReflectColor; +uniform sampler2D _MainTex; +uniform sampler2D _LightTexture0; +uniform vec4 _LightColor0; +uniform samplerCube _Cube; +uniform vec4 _Color; +uniform sampler2D _BumpMap; +vec4 UnpackNormal ( + in vec4 packednormal +) +{ + vec4 normal; + vec2 tmpvar_1; + tmpvar_1 = ((packednormal.wy * 2.0) - 1.0); + normal.xy = tmpvar_1.xy.xy; + float tmpvar_2; + tmpvar_2 = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + normal.z = vec3(tmpvar_3).z; + return normal; +} + +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 reflcol; + vec3 worldRefl; + vec4 c; + vec4 tex; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + tex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = (tex * _Color); + c = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = c.xyz; + o.Albedo = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = texture2D (_BumpMap, IN.uv_BumpMap); + vec4 tmpvar_6; + tmpvar_6 = UnpackNormal (tmpvar_5); + vec3 tmpvar_7; + tmpvar_7 = tmpvar_6.xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + o.Normal = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = IN.worldRefl; + worldRefl = tmpvar_9; + vec4 tmpvar_10; + tmpvar_10 = textureCube (_Cube, worldRefl); + vec4 tmpvar_11; + tmpvar_11 = tmpvar_10; + reflcol = tmpvar_11; + vec4 tmpvar_12; + tmpvar_12 = (reflcol * tex.w); + reflcol = tmpvar_12; + vec3 tmpvar_13; + tmpvar_13 = (reflcol.xyz * _ReflectColor.xyz); + o.Emission = tmpvar_13; + float tmpvar_14; + tmpvar_14 = (reflcol.w * _ReflectColor.w); + o.Alpha = tmpvar_14; +} + +vec4 LightingLambert ( + in SurfaceOutput s, + in vec3 lightDir, + in float atten +) +{ + vec4 c; + float diff; + float tmpvar_1; + tmpvar_1 = dot (s.Normal, lightDir); + float tmpvar_2; + tmpvar_2 = max (0.0, tmpvar_1); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + diff = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = ((s.Albedo * _LightColor0.xyz) * ((diff * atten) * 2.0)); + c.xyz = tmpvar_4.xyz.xyz; + float tmpvar_5; + tmpvar_5 = s.Alpha; + c.w = vec4(tmpvar_5).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 c; + vec3 lightDir; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = IN.hip_pack0.zw; + surfIN.uv_BumpMap = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Specular = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Alpha = tmpvar_6; + float tmpvar_7; + tmpvar_7 = 0.0; + o.Gloss = tmpvar_7; + surf (surfIN, o); + vec3 tmpvar_8; + tmpvar_8 = IN.lightDir; + lightDir = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = texture2D (_LightTexture0, IN._LightCoord); + vec4 tmpvar_10; + tmpvar_10 = LightingLambert (o, lightDir, (tmpvar_9.w * 1.0)); + vec4 tmpvar_11; + tmpvar_11 = tmpvar_10; + c = tmpvar_11; + float tmpvar_12; + tmpvar_12 = 0.0; + c.w = vec4(tmpvar_12).w; + return c; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.lightDir = tmpvar_6; + vec2 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xy; + vec2 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN._LightCoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = frag_surf (xlt_IN); + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xl_retval = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = xl_retval.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + gl_FragData[0] = tmpvar_12; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Bumped_Diffuse-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Bumped_Diffuse-out.txt new file mode 100644 index 000000000..2d76062f2 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Bumped_Diffuse-out.txt @@ -0,0 +1,26 @@ +uniform vec4 _ReflectColor; +uniform sampler2D _MainTex; +uniform sampler2D _LightTexture0; +uniform vec4 _LightColor0; +uniform samplerCube _Cube; +uniform vec4 _Color; +uniform sampler2D _BumpMap; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = gl_TexCoord[0]; + vec4 c; + vec3 tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = texture2D (_MainTex, tmpvar_1.xy); + vec4 normal; + normal.xy = ((texture2D (_BumpMap, tmpvar_1.zw).wy * 2.0) - 1.0); + normal.z = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + vec4 c_i0_i1; + c_i0_i1.xyz = (((tmpvar_3 * _Color).xyz * _LightColor0.xyz) * ((max (0.0, dot (normal.xyz, gl_TexCoord[1].xyz)) * texture2D (_LightTexture0, gl_TexCoord[2].xy).w) * 2.0)); + c_i0_i1.w = ((textureCube (_Cube, tmpvar_2) * tmpvar_3.w).w * _ReflectColor.w); + c = c_i0_i1; + c.w = 0.0; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Bumped_Diffuse1-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Bumped_Diffuse1-in.txt new file mode 100644 index 000000000..5faa60723 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Bumped_Diffuse1-in.txt @@ -0,0 +1,156 @@ +float xll_saturate( float x) { + return clamp( x, 0.0, 1.0); +} +vec2 xll_saturate( vec2 x) { + return clamp( x, 0.0, 1.0); +} +vec3 xll_saturate( vec3 x) { + return clamp( x, 0.0, 1.0); +} +vec4 xll_saturate( vec4 x) { + return clamp( x, 0.0, 1.0); +} +mat2 xll_saturate(mat2 m) { + return mat2( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0)); +} +mat3 xll_saturate(mat3 m) { + return mat3( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0), clamp(m[2], 0.0, 1.0)); +} +mat4 xll_saturate(mat4 m) { + return mat4( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0), clamp(m[2], 0.0, 1.0), clamp(m[3], 0.0, 1.0)); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; + vec3 worldRefl; + vec3 TtoW0; + vec3 TtoW1; + vec3 TtoW2; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec4 hip_screen; + vec4 TtoW0; + vec4 TtoW1; + vec4 TtoW2; + vec3 hip_lmapFade; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform sampler2D _BumpMap; +uniform vec4 _Color; +uniform samplerCube _Cube; +uniform sampler2D _LightBuffer; +uniform sampler2D _MainTex; +uniform vec4 _ReflectColor; +uniform sampler2D unity_Lightmap; +uniform sampler2D unity_LightmapInd; +vec4 UnpackNormal( in vec4 packednormal ); +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingLambert_PrePass( in SurfaceOutput s, in vec4 light ); +vec3 DecodeLightmap( in vec4 color ); +vec4 frag_surf( in v2f_surf IN ); +vec4 UnpackNormal( in vec4 packednormal ) { + vec4 normal; + normal.xy = ((packednormal.wy * 2.00000) - 1.00000); + normal.z = sqrt( ((1.00000 - (normal.x * normal.x )) - (normal.y * normal.y )) ); + return normal; +} +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 tex; + vec4 c; + vec3 worldRefl; + vec4 reflcol; + tex = texture2D( _MainTex, IN.uv_MainTex); + c = (tex * _Color); + o.Albedo = c.xyz ; + o.Normal = vec3( UnpackNormal( texture2D( _BumpMap, IN.uv_BumpMap))); + worldRefl = reflect( IN.worldRefl, vec3( dot( IN.TtoW0, o.Normal), dot( IN.TtoW1, o.Normal), dot( IN.TtoW2, o.Normal))); + reflcol = textureCube( _Cube, worldRefl); + reflcol *= tex.w ; + o.Emission = (reflcol.xyz * _ReflectColor.xyz ); + o.Alpha = (reflcol.w * _ReflectColor.w ); +} +vec4 LightingLambert_PrePass( in SurfaceOutput s, in vec4 light ) { + vec4 c; + c.xyz = (s.Albedo * light.xyz ); + c.w = s.Alpha; + return c; +} +vec3 DecodeLightmap( in vec4 color ) { + return (2.00000 * color.xyz ); +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec4 light; + vec3 lmFull; + vec3 lmIndirect; + vec3 lm; + vec4 col; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + surfIN.uv_BumpMap = IN.hip_pack0.zw ; + surfIN.worldRefl = vec3( IN.TtoW0.w , IN.TtoW1.w , IN.TtoW2.w ); + surfIN.TtoW0 = IN.TtoW0.xyz ; + surfIN.TtoW1 = IN.TtoW1.xyz ; + surfIN.TtoW2 = IN.TtoW2.xyz ; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + surf( surfIN, o); + light = texture2DProj( _LightBuffer, IN.hip_screen); + light = ( -log2( light ) ); + lmFull = DecodeLightmap( texture2D( unity_Lightmap, IN.hip_lmapFade.xy )); + lmIndirect = DecodeLightmap( texture2D( unity_LightmapInd, IN.hip_lmapFade.xy )); + lm = mix( lmIndirect, lmFull, vec3( xll_saturate( IN.hip_lmapFade.z ))); + light.xyz += lm; + col = LightingLambert_PrePass( o, light); + col.xyz += o.Emission; + return col; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec4( gl_TexCoord[0]); + xlt_IN.hip_screen = vec4( gl_TexCoord[1]); + xlt_IN.TtoW0 = vec4( gl_TexCoord[2]); + xlt_IN.TtoW1 = vec4( gl_TexCoord[3]); + xlt_IN.TtoW2 = vec4( gl_TexCoord[4]); + xlt_IN.hip_lmapFade = vec3( gl_TexCoord[5]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Bumped_Diffuse1-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Bumped_Diffuse1-ir.txt new file mode 100644 index 000000000..514ff2f58 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Bumped_Diffuse1-ir.txt @@ -0,0 +1,386 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; + vec3 worldRefl; + vec3 TtoW0; + vec3 TtoW1; + vec3 TtoW2; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec4 hip_screen; + vec4 TtoW0; + vec4 TtoW1; + vec4 TtoW2; + vec3 hip_lmapFade; +}; +varying vec4 xlv_FOG; +uniform sampler2D unity_LightmapInd; +uniform sampler2D unity_Lightmap; +uniform vec4 _ReflectColor; +uniform sampler2D _MainTex; +uniform sampler2D _LightBuffer; +uniform samplerCube _Cube; +uniform vec4 _Color; +uniform sampler2D _BumpMap; +float xll_saturate ( + in float x +) +{ + float tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec2 xll_saturate ( + in vec2 x +) +{ + vec2 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec3 xll_saturate ( + in vec3 x +) +{ + vec3 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec4 xll_saturate ( + in vec4 x +) +{ + vec4 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +mat2 xll_saturate ( + in mat2 m +) +{ + vec2 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec2 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + mat2 tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_1; + tmpvar_3[0] = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5 = tmpvar_2; + tmpvar_3[1] = tmpvar_5; + return tmpvar_3; +} + +mat3 xll_saturate ( + in mat3 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec3 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + vec3 tmpvar_3; + tmpvar_3 = clamp (m[2], 0.0, 1.0); + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +mat4 xll_saturate ( + in mat4 m +) +{ + vec4 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec4 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + vec4 tmpvar_3; + tmpvar_3 = clamp (m[2], 0.0, 1.0); + vec4 tmpvar_4; + tmpvar_4 = clamp (m[3], 0.0, 1.0); + mat4 tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_1; + tmpvar_5[0] = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = tmpvar_2; + tmpvar_5[1] = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_3; + tmpvar_5[2] = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = tmpvar_4; + tmpvar_5[3] = tmpvar_9; + return tmpvar_5; +} + +vec4 UnpackNormal ( + in vec4 packednormal +) +{ + vec4 normal; + vec2 tmpvar_1; + tmpvar_1 = ((packednormal.wy * 2.0) - 1.0); + normal.xy = tmpvar_1.xy.xy; + float tmpvar_2; + tmpvar_2 = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + normal.z = vec3(tmpvar_3).z; + return normal; +} + +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 reflcol; + vec3 worldRefl; + vec4 c; + vec4 tex; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + tex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = (tex * _Color); + c = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = c.xyz; + o.Albedo = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = texture2D (_BumpMap, IN.uv_BumpMap); + vec4 tmpvar_6; + tmpvar_6 = UnpackNormal (tmpvar_5); + vec3 tmpvar_7; + tmpvar_7 = tmpvar_6.xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + o.Normal = tmpvar_8; + float tmpvar_9; + tmpvar_9 = dot (IN.TtoW0, o.Normal); + float tmpvar_10; + tmpvar_10 = dot (IN.TtoW1, o.Normal); + float tmpvar_11; + tmpvar_11 = dot (IN.TtoW2, o.Normal); + vec3 tmpvar_12; + tmpvar_12.x = tmpvar_9; + tmpvar_12.y = tmpvar_10; + tmpvar_12.z = tmpvar_11; + vec3 tmpvar_13; + tmpvar_13 = reflect (IN.worldRefl, tmpvar_12); + vec3 tmpvar_14; + tmpvar_14 = tmpvar_13; + worldRefl = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = textureCube (_Cube, worldRefl); + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + reflcol = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17 = (reflcol * tex.w); + reflcol = tmpvar_17; + vec3 tmpvar_18; + tmpvar_18 = (reflcol.xyz * _ReflectColor.xyz); + o.Emission = tmpvar_18; + float tmpvar_19; + tmpvar_19 = (reflcol.w * _ReflectColor.w); + o.Alpha = tmpvar_19; +} + +vec4 LightingLambert_PrePass ( + in SurfaceOutput s, + in vec4 light +) +{ + vec4 c; + vec3 tmpvar_1; + tmpvar_1 = (s.Albedo * light.xyz); + c.xyz = tmpvar_1.xyz.xyz; + float tmpvar_2; + tmpvar_2 = s.Alpha; + c.w = vec4(tmpvar_2).w; + return c; +} + +vec3 DecodeLightmap ( + in vec4 color +) +{ + return (2.0 * color.xyz); +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 col; + vec3 lm; + vec3 lmIndirect; + vec3 lmFull; + vec4 light; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = IN.hip_pack0.zw; + surfIN.uv_BumpMap = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3.x = IN.TtoW0.w; + tmpvar_3.y = IN.TtoW1.w; + tmpvar_3.z = IN.TtoW2.w; + vec3 tmpvar_4; + tmpvar_4 = tmpvar_3; + surfIN.worldRefl = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = IN.TtoW0.xyz; + surfIN.TtoW0 = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = IN.TtoW1.xyz; + surfIN.TtoW1 = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = IN.TtoW2.xyz; + surfIN.TtoW2 = tmpvar_7; + vec3 tmpvar_8; + tmpvar_8 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_9; + float tmpvar_10; + tmpvar_10 = 0.0; + o.Specular = tmpvar_10; + float tmpvar_11; + tmpvar_11 = 0.0; + o.Alpha = tmpvar_11; + float tmpvar_12; + tmpvar_12 = 0.0; + o.Gloss = tmpvar_12; + surf (surfIN, o); + vec4 tmpvar_13; + tmpvar_13 = texture2DProj (_LightBuffer, IN.hip_screen); + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + light = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = log2 (light); + vec4 tmpvar_16; + tmpvar_16 = -(tmpvar_15); + light = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17 = texture2D (unity_Lightmap, IN.hip_lmapFade.xy); + vec3 tmpvar_18; + tmpvar_18 = DecodeLightmap (tmpvar_17); + vec3 tmpvar_19; + tmpvar_19 = tmpvar_18; + lmFull = tmpvar_19; + vec4 tmpvar_20; + tmpvar_20 = texture2D (unity_LightmapInd, IN.hip_lmapFade.xy); + vec3 tmpvar_21; + tmpvar_21 = DecodeLightmap (tmpvar_20); + vec3 tmpvar_22; + tmpvar_22 = tmpvar_21; + lmIndirect = tmpvar_22; + float tmpvar_23; + tmpvar_23 = xll_saturate (IN.hip_lmapFade.z); + vec3 tmpvar_24; + tmpvar_24 = vec3(tmpvar_23); + vec3 tmpvar_25; + tmpvar_25 = mix (lmIndirect, lmFull, tmpvar_24); + vec3 tmpvar_26; + tmpvar_26 = tmpvar_25; + lm = tmpvar_26; + vec3 tmpvar_27; + tmpvar_27 = (light.xyz + lm); + light.xyz = tmpvar_27.xyz.xyz; + vec4 tmpvar_28; + tmpvar_28 = LightingLambert_PrePass (o, light); + vec4 tmpvar_29; + tmpvar_29 = tmpvar_28; + col = tmpvar_29; + vec3 tmpvar_30; + tmpvar_30 = (col.xyz + o.Emission); + col.xyz = tmpvar_30.xyz.xyz; + return col; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyzw; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.hip_screen = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.TtoW0 = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_TexCoord[3].xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_IN.TtoW1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_TexCoord[4].xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_IN.TtoW2 = tmpvar_12; + vec3 tmpvar_13; + tmpvar_13 = gl_TexCoord[5].xyz; + vec3 tmpvar_14; + tmpvar_14 = tmpvar_13; + xlt_IN.hip_lmapFade = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = frag_surf (xlt_IN); + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + xl_retval = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17 = xl_retval.xyzw; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + gl_FragData[0] = tmpvar_18; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Bumped_Diffuse1-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Bumped_Diffuse1-out.txt new file mode 100644 index 000000000..4fd80480c --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Bumped_Diffuse1-out.txt @@ -0,0 +1,51 @@ +uniform sampler2D unity_LightmapInd; +uniform sampler2D unity_Lightmap; +uniform vec4 _ReflectColor; +uniform sampler2D _MainTex; +uniform sampler2D _LightBuffer; +uniform samplerCube _Cube; +uniform vec4 _Color; +uniform sampler2D _BumpMap; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = gl_TexCoord[0]; + vec4 tmpvar_2; + tmpvar_2 = gl_TexCoord[2]; + vec4 tmpvar_3; + tmpvar_3 = gl_TexCoord[3]; + vec4 tmpvar_4; + tmpvar_4 = gl_TexCoord[4]; + vec3 tmpvar_5; + tmpvar_5 = gl_TexCoord[5].xyz; + vec4 col; + vec4 light; + vec3 tmpvar_6; + tmpvar_6.x = tmpvar_2.w; + tmpvar_6.y = tmpvar_3.w; + tmpvar_6.z = tmpvar_4.w; + vec4 tmpvar_7; + tmpvar_7 = texture2D (_MainTex, tmpvar_1.xy); + vec4 normal; + normal.xy = ((texture2D (_BumpMap, tmpvar_1.zw).wy * 2.0) - 1.0); + normal.z = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + vec3 tmpvar_8; + tmpvar_8 = normal.xyz; + vec3 tmpvar_9; + tmpvar_9.x = dot (tmpvar_2.xyz, tmpvar_8); + tmpvar_9.y = dot (tmpvar_3.xyz, tmpvar_8); + tmpvar_9.z = dot (tmpvar_4.xyz, tmpvar_8); + vec4 tmpvar_10; + tmpvar_10 = (textureCube (_Cube, reflect (tmpvar_6, tmpvar_9)) * tmpvar_7.w); + vec4 tmpvar_11; + tmpvar_11 = -(log2 (texture2DProj (_LightBuffer, gl_TexCoord[1]))); + light = tmpvar_11; + light.xyz = (tmpvar_11.xyz + mix ((2.0 * texture2D (unity_LightmapInd, tmpvar_5.xy).xyz), (2.0 * texture2D (unity_Lightmap, tmpvar_5.xy).xyz), vec3(clamp (tmpvar_5.z, 0.0, 1.0)))); + vec4 c_i0; + c_i0.xyz = ((tmpvar_7 * _Color).xyz * light.xyz); + c_i0.w = (tmpvar_10.w * _ReflectColor.w); + col = c_i0; + col.xyz = (c_i0.xyz + (tmpvar_10.xyz * _ReflectColor.xyz)); + gl_FragData[0] = col; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Bumped_Specular-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Bumped_Specular-in.txt new file mode 100644 index 000000000..7b7c7e96c --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Bumped_Specular-in.txt @@ -0,0 +1,124 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; + vec3 worldRefl; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 lightDir; + vec3 viewDir; + vec3 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform sampler2D _BumpMap; +uniform vec4 _Color; +uniform samplerCube _Cube; +uniform vec4 _LightColor0; +uniform sampler2D _LightTexture0; +uniform sampler2D _MainTex; +uniform vec4 _ReflectColor; +uniform float _Shininess; +uniform vec4 _SpecColor; +vec4 UnpackNormal( in vec4 packednormal ); +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingBlinnPhong( in SurfaceOutput s, in vec3 lightDir, in vec3 viewDir, in float atten ); +vec4 frag_surf( in v2f_surf IN ); +vec4 UnpackNormal( in vec4 packednormal ) { + vec4 normal; + normal.xy = ((packednormal.wy * 2.00000) - 1.00000); + normal.z = sqrt( ((1.00000 - (normal.x * normal.x )) - (normal.y * normal.y )) ); + return normal; +} +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 tex; + vec4 c; + vec3 worldRefl; + vec4 reflcol; + tex = texture2D( _MainTex, IN.uv_MainTex); + c = (tex * _Color); + o.Albedo = c.xyz ; + o.Gloss = tex.w ; + o.Specular = _Shininess; + o.Normal = vec3( UnpackNormal( texture2D( _BumpMap, IN.uv_BumpMap))); + worldRefl = IN.worldRefl; + reflcol = textureCube( _Cube, worldRefl); + reflcol *= tex.w ; + o.Emission = (reflcol.xyz * _ReflectColor.xyz ); + o.Alpha = (reflcol.w * _ReflectColor.w ); +} +vec4 LightingBlinnPhong( in SurfaceOutput s, in vec3 lightDir, in vec3 viewDir, in float atten ) { + vec3 h; + float diff; + float nh; + float spec; + vec4 c; + h = normalize( (lightDir + viewDir) ); + diff = max( 0.000000, dot( s.Normal, lightDir)); + nh = max( 0.000000, dot( s.Normal, h)); + spec = (pow( nh, (s.Specular * 128.000)) * s.Gloss); + c.xyz = ((((s.Albedo * _LightColor0.xyz ) * diff) + ((_LightColor0.xyz * _SpecColor.xyz ) * spec)) * (atten * 2.00000)); + c.w = (s.Alpha + (((_LightColor0.w * _SpecColor.w ) * spec) * atten)); + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec3 lightDir; + vec4 c; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + surfIN.uv_BumpMap = IN.hip_pack0.zw ; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + surf( surfIN, o); + lightDir = IN.lightDir; + lightDir = normalize( lightDir ); + c = LightingBlinnPhong( o, lightDir, normalize( vec3( IN.viewDir) ), texture2D( _LightTexture0, vec2( vec2( dot( IN._LightCoord, IN._LightCoord)))).w ); + c.w = 0.000000; + return c; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec4( gl_TexCoord[0]); + xlt_IN.lightDir = vec3( gl_TexCoord[1]); + xlt_IN.viewDir = vec3( gl_TexCoord[2]); + xlt_IN._LightCoord = vec3( gl_TexCoord[3]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Bumped_Specular-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Bumped_Specular-ir.txt new file mode 100644 index 000000000..85e398a50 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Bumped_Specular-ir.txt @@ -0,0 +1,249 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; + vec3 worldRefl; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 lightDir; + vec3 viewDir; + vec3 _LightCoord; +}; +varying vec4 xlv_FOG; +uniform vec4 _SpecColor; +uniform float _Shininess; +uniform vec4 _ReflectColor; +uniform sampler2D _MainTex; +uniform sampler2D _LightTexture0; +uniform vec4 _LightColor0; +uniform samplerCube _Cube; +uniform vec4 _Color; +uniform sampler2D _BumpMap; +vec4 UnpackNormal ( + in vec4 packednormal +) +{ + vec4 normal; + vec2 tmpvar_1; + tmpvar_1 = ((packednormal.wy * 2.0) - 1.0); + normal.xy = tmpvar_1.xy.xy; + float tmpvar_2; + tmpvar_2 = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + normal.z = vec3(tmpvar_3).z; + return normal; +} + +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 reflcol; + vec3 worldRefl; + vec4 c; + vec4 tex; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + tex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = (tex * _Color); + c = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = c.xyz; + o.Albedo = tmpvar_4; + float tmpvar_5; + tmpvar_5 = tex.w; + o.Gloss = tmpvar_5; + float tmpvar_6; + tmpvar_6 = _Shininess; + o.Specular = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = texture2D (_BumpMap, IN.uv_BumpMap); + vec4 tmpvar_8; + tmpvar_8 = UnpackNormal (tmpvar_7); + vec3 tmpvar_9; + tmpvar_9 = tmpvar_8.xyz; + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + o.Normal = tmpvar_10; + vec3 tmpvar_11; + tmpvar_11 = IN.worldRefl; + worldRefl = tmpvar_11; + vec4 tmpvar_12; + tmpvar_12 = textureCube (_Cube, worldRefl); + vec4 tmpvar_13; + tmpvar_13 = tmpvar_12; + reflcol = tmpvar_13; + vec4 tmpvar_14; + tmpvar_14 = (reflcol * tex.w); + reflcol = tmpvar_14; + vec3 tmpvar_15; + tmpvar_15 = (reflcol.xyz * _ReflectColor.xyz); + o.Emission = tmpvar_15; + float tmpvar_16; + tmpvar_16 = (reflcol.w * _ReflectColor.w); + o.Alpha = tmpvar_16; +} + +vec4 LightingBlinnPhong ( + in SurfaceOutput s, + in vec3 lightDir, + in vec3 viewDir, + in float atten +) +{ + vec4 c; + float spec; + float nh; + float diff; + vec3 h; + vec3 tmpvar_1; + tmpvar_1 = normalize ((lightDir + viewDir)); + vec3 tmpvar_2; + tmpvar_2 = tmpvar_1; + h = tmpvar_2; + float tmpvar_3; + tmpvar_3 = dot (s.Normal, lightDir); + float tmpvar_4; + tmpvar_4 = max (0.0, tmpvar_3); + float tmpvar_5; + tmpvar_5 = tmpvar_4; + diff = tmpvar_5; + float tmpvar_6; + tmpvar_6 = dot (s.Normal, h); + float tmpvar_7; + tmpvar_7 = max (0.0, tmpvar_6); + float tmpvar_8; + tmpvar_8 = tmpvar_7; + nh = tmpvar_8; + float tmpvar_9; + tmpvar_9 = pow (nh, (s.Specular * 128.0)); + float tmpvar_10; + tmpvar_10 = (tmpvar_9 * s.Gloss); + spec = tmpvar_10; + vec3 tmpvar_11; + tmpvar_11 = ((((s.Albedo * _LightColor0.xyz) * diff) + ((_LightColor0.xyz * _SpecColor.xyz) * spec)) * (atten * 2.0)); + c.xyz = tmpvar_11.xyz.xyz; + float tmpvar_12; + tmpvar_12 = (s.Alpha + (((_LightColor0.w * _SpecColor.w) * spec) * atten)); + c.w = vec4(tmpvar_12).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 c; + vec3 lightDir; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = IN.hip_pack0.zw; + surfIN.uv_BumpMap = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Specular = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Alpha = tmpvar_6; + float tmpvar_7; + tmpvar_7 = 0.0; + o.Gloss = tmpvar_7; + surf (surfIN, o); + vec3 tmpvar_8; + tmpvar_8 = IN.lightDir; + lightDir = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = normalize (lightDir); + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + lightDir = tmpvar_10; + vec3 tmpvar_11; + tmpvar_11 = IN.viewDir.xyz; + vec3 tmpvar_12; + tmpvar_12 = normalize (tmpvar_11); + float tmpvar_13; + tmpvar_13 = dot (IN._LightCoord, IN._LightCoord); + vec2 tmpvar_14; + tmpvar_14 = vec2(tmpvar_13); + vec2 tmpvar_15; + tmpvar_15 = tmpvar_14.xy; + vec4 tmpvar_16; + tmpvar_16 = texture2D (_LightTexture0, tmpvar_15); + vec4 tmpvar_17; + tmpvar_17 = LightingBlinnPhong (o, lightDir, tmpvar_12, tmpvar_16.w); + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + c = tmpvar_18; + float tmpvar_19; + tmpvar_19 = 0.0; + c.w = vec4(tmpvar_19).w; + return c; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.lightDir = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.viewDir = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = gl_TexCoord[3].xyz; + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_IN._LightCoord = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = frag_surf (xlt_IN); + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xl_retval = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = xl_retval.xyzw; + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + gl_FragData[0] = tmpvar_14; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Bumped_Specular-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Bumped_Specular-out.txt new file mode 100644 index 000000000..d544a118c --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Bumped_Specular-out.txt @@ -0,0 +1,38 @@ +uniform vec4 _SpecColor; +uniform float _Shininess; +uniform vec4 _ReflectColor; +uniform sampler2D _MainTex; +uniform sampler2D _LightTexture0; +uniform vec4 _LightColor0; +uniform samplerCube _Cube; +uniform vec4 _Color; +uniform sampler2D _BumpMap; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = gl_TexCoord[0]; + vec3 tmpvar_2; + tmpvar_2 = gl_TexCoord[3].xyz; + vec4 c; + vec3 tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = texture2D (_MainTex, tmpvar_1.xy); + vec4 normal; + normal.xy = ((texture2D (_BumpMap, tmpvar_1.zw).wy * 2.0) - 1.0); + normal.z = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + vec3 tmpvar_5; + tmpvar_5 = normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = normalize (gl_TexCoord[1].xyz); + vec4 tmpvar_7; + tmpvar_7 = texture2D (_LightTexture0, vec2(dot (tmpvar_2, tmpvar_2))); + vec4 c_i0_i1; + float tmpvar_8; + tmpvar_8 = (pow (max (0.0, dot (tmpvar_5, normalize ((tmpvar_6 + normalize (gl_TexCoord[2].xyz))))), (_Shininess * 128.0)) * tmpvar_4.w); + c_i0_i1.xyz = (((((tmpvar_4 * _Color).xyz * _LightColor0.xyz) * max (0.0, dot (tmpvar_5, tmpvar_6))) + ((_LightColor0.xyz * _SpecColor.xyz) * tmpvar_8)) * (tmpvar_7.w * 2.0)); + c_i0_i1.w = (((textureCube (_Cube, tmpvar_3) * tmpvar_4.w).w * _ReflectColor.w) + (((_LightColor0.w * _SpecColor.w) * tmpvar_8) * tmpvar_7.w)); + c = c_i0_i1; + c.w = 0.0; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Bumped_Specular1-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Bumped_Specular1-in.txt new file mode 100644 index 000000000..048ee847b --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Bumped_Specular1-in.txt @@ -0,0 +1,104 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; + vec3 worldRefl; +}; +struct v2f_surf { + vec4 pos; + vec2 hip_pack0; + vec3 TtoV0; + vec3 TtoV1; + vec3 TtoV2; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform sampler2D _BumpMap; +uniform vec4 _Color; +uniform samplerCube _Cube; +uniform sampler2D _MainTex; +uniform vec4 _ReflectColor; +uniform float _Shininess; +vec4 UnpackNormal( in vec4 packednormal ); +void surf( in Input IN, inout SurfaceOutput o ); +vec4 frag_surf( in v2f_surf IN ); +vec4 UnpackNormal( in vec4 packednormal ) { + vec4 normal; + normal.xy = ((packednormal.wy * 2.00000) - 1.00000); + normal.z = sqrt( ((1.00000 - (normal.x * normal.x )) - (normal.y * normal.y )) ); + return normal; +} +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 tex; + vec4 c; + vec3 worldRefl; + vec4 reflcol; + tex = texture2D( _MainTex, IN.uv_MainTex); + c = (tex * _Color); + o.Albedo = c.xyz ; + o.Gloss = tex.w ; + o.Specular = _Shininess; + o.Normal = vec3( UnpackNormal( texture2D( _BumpMap, IN.uv_BumpMap))); + worldRefl = IN.worldRefl; + reflcol = textureCube( _Cube, worldRefl); + reflcol *= tex.w ; + o.Emission = (reflcol.xyz * _ReflectColor.xyz ); + o.Alpha = (reflcol.w * _ReflectColor.w ); +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec3 viewN; + vec4 res; + surfIN.uv_BumpMap = IN.hip_pack0.xy ; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + surf( surfIN, o); + viewN.x = dot( IN.TtoV0, o.Normal); + viewN.y = dot( IN.TtoV1, o.Normal); + viewN.z = dot( IN.TtoV2, o.Normal); + o.Normal = viewN; + res.xyz = ((o.Normal * vec3( 0.500000, 0.500000, -0.500000)) + 0.500000); + res.w = o.Specular; + return res; +} +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.hip_pack0 = vec2( gl_TexCoord[0]); + xlt_IN.TtoV0 = vec3( gl_TexCoord[1]); + xlt_IN.TtoV1 = vec3( gl_TexCoord[2]); + xlt_IN.TtoV2 = vec3( gl_TexCoord[3]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Bumped_Specular1-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Bumped_Specular1-ir.txt new file mode 100644 index 000000000..ffe73d3e2 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Bumped_Specular1-ir.txt @@ -0,0 +1,189 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; + vec3 worldRefl; +}; +struct v2f_surf { + vec4 pos; + vec2 hip_pack0; + vec3 TtoV0; + vec3 TtoV1; + vec3 TtoV2; +}; +uniform float _Shininess; +uniform vec4 _ReflectColor; +uniform sampler2D _MainTex; +uniform samplerCube _Cube; +uniform vec4 _Color; +uniform sampler2D _BumpMap; +vec4 UnpackNormal ( + in vec4 packednormal +) +{ + vec4 normal; + vec2 tmpvar_1; + tmpvar_1 = ((packednormal.wy * 2.0) - 1.0); + normal.xy = tmpvar_1.xy.xy; + float tmpvar_2; + tmpvar_2 = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + normal.z = vec3(tmpvar_3).z; + return normal; +} + +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 reflcol; + vec3 worldRefl; + vec4 c; + vec4 tex; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + tex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = (tex * _Color); + c = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = c.xyz; + o.Albedo = tmpvar_4; + float tmpvar_5; + tmpvar_5 = tex.w; + o.Gloss = tmpvar_5; + float tmpvar_6; + tmpvar_6 = _Shininess; + o.Specular = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = texture2D (_BumpMap, IN.uv_BumpMap); + vec4 tmpvar_8; + tmpvar_8 = UnpackNormal (tmpvar_7); + vec3 tmpvar_9; + tmpvar_9 = tmpvar_8.xyz; + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + o.Normal = tmpvar_10; + vec3 tmpvar_11; + tmpvar_11 = IN.worldRefl; + worldRefl = tmpvar_11; + vec4 tmpvar_12; + tmpvar_12 = textureCube (_Cube, worldRefl); + vec4 tmpvar_13; + tmpvar_13 = tmpvar_12; + reflcol = tmpvar_13; + vec4 tmpvar_14; + tmpvar_14 = (reflcol * tex.w); + reflcol = tmpvar_14; + vec3 tmpvar_15; + tmpvar_15 = (reflcol.xyz * _ReflectColor.xyz); + o.Emission = tmpvar_15; + float tmpvar_16; + tmpvar_16 = (reflcol.w * _ReflectColor.w); + o.Alpha = tmpvar_16; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 res; + vec3 viewN; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_BumpMap = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_3; + float tmpvar_4; + tmpvar_4 = 0.0; + o.Specular = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Alpha = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Gloss = tmpvar_6; + surf (surfIN, o); + float tmpvar_7; + tmpvar_7 = dot (IN.TtoV0, o.Normal); + float tmpvar_8; + tmpvar_8 = tmpvar_7; + viewN.x = tmpvar_8; + float tmpvar_9; + tmpvar_9 = dot (IN.TtoV1, o.Normal); + float tmpvar_10; + tmpvar_10 = tmpvar_9; + viewN.y = vec2(tmpvar_10).y; + float tmpvar_11; + tmpvar_11 = dot (IN.TtoV2, o.Normal); + float tmpvar_12; + tmpvar_12 = tmpvar_11; + viewN.z = vec3(tmpvar_12).z; + vec3 tmpvar_13; + tmpvar_13 = viewN; + o.Normal = tmpvar_13; + vec3 tmpvar_14; + tmpvar_14 = ((o.Normal * vec3(0.5, 0.5, -0.5)) + 0.5); + res.xyz = tmpvar_14.xyz.xyz; + float tmpvar_15; + tmpvar_15 = o.Specular; + res.w = vec4(tmpvar_15).w; + return res; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = gl_TexCoord[0].xy; + vec2 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_IN.hip_pack0 = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = gl_TexCoord[1].xyz; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_4; + xlt_IN.TtoV0 = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = gl_TexCoord[2].xyz; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_6; + xlt_IN.TtoV1 = tmpvar_7; + vec3 tmpvar_8; + tmpvar_8 = gl_TexCoord[3].xyz; + vec3 tmpvar_9; + tmpvar_9 = tmpvar_8; + xlt_IN.TtoV2 = tmpvar_9; + vec4 tmpvar_10; + tmpvar_10 = frag_surf (xlt_IN); + vec4 tmpvar_11; + tmpvar_11 = tmpvar_10; + xl_retval = tmpvar_11; + vec4 tmpvar_12; + tmpvar_12 = xl_retval.xyzw; + vec4 tmpvar_13; + tmpvar_13 = tmpvar_12; + gl_FragData[0] = tmpvar_13; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Bumped_Specular1-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Bumped_Specular1-out.txt new file mode 100644 index 000000000..e805953b8 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Bumped_Specular1-out.txt @@ -0,0 +1,19 @@ +uniform float _Shininess; +uniform sampler2D _BumpMap; +void main () +{ + vec4 res; + vec3 viewN; + vec4 normal; + normal.xy = ((texture2D (_BumpMap, gl_TexCoord[0].xy).wy * 2.0) - 1.0); + normal.z = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + vec3 tmpvar_1; + tmpvar_1 = normal.xyz; + viewN.x = dot (gl_TexCoord[1].xyz, tmpvar_1); + viewN.y = dot (gl_TexCoord[2].xyz, tmpvar_1); + viewN.z = dot (gl_TexCoord[3].xyz, tmpvar_1); + res.xyz = ((viewN * vec3(0.5, 0.5, -0.5)) + 0.5); + res.w = _Shininess; + gl_FragData[0] = res; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Bumped_Specular2-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Bumped_Specular2-in.txt new file mode 100644 index 000000000..37f2e786c --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Bumped_Specular2-in.txt @@ -0,0 +1,128 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; + vec3 worldRefl; + vec3 TtoW0; + vec3 TtoW1; + vec3 TtoW2; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec4 hip_screen; + vec4 TtoW0; + vec4 TtoW1; + vec4 TtoW2; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform sampler2D _BumpMap; +uniform vec4 _Color; +uniform samplerCube _Cube; +uniform sampler2D _LightBuffer; +uniform sampler2D _MainTex; +uniform vec4 _ReflectColor; +uniform float _Shininess; +uniform vec4 _SpecColor; +uniform vec4 unity_Ambient; +vec4 UnpackNormal( in vec4 packednormal ); +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingBlinnPhong_PrePass( in SurfaceOutput s, in vec4 light ); +vec4 frag_surf( in v2f_surf IN ); +vec4 UnpackNormal( in vec4 packednormal ) { + vec4 normal; + normal.xy = ((packednormal.wy * 2.00000) - 1.00000); + normal.z = sqrt( ((1.00000 - (normal.x * normal.x )) - (normal.y * normal.y )) ); + return normal; +} +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 tex; + vec4 c; + vec3 worldRefl; + vec4 reflcol; + tex = texture2D( _MainTex, IN.uv_MainTex); + c = (tex * _Color); + o.Albedo = c.xyz ; + o.Gloss = tex.w ; + o.Specular = _Shininess; + o.Normal = vec3( UnpackNormal( texture2D( _BumpMap, IN.uv_BumpMap))); + worldRefl = reflect( IN.worldRefl, vec3( dot( IN.TtoW0, o.Normal), dot( IN.TtoW1, o.Normal), dot( IN.TtoW2, o.Normal))); + reflcol = textureCube( _Cube, worldRefl); + reflcol *= tex.w ; + o.Emission = (reflcol.xyz * _ReflectColor.xyz ); + o.Alpha = (reflcol.w * _ReflectColor.w ); +} +vec4 LightingBlinnPhong_PrePass( in SurfaceOutput s, in vec4 light ) { + float spec; + vec4 c; + spec = (light.w * s.Gloss); + c.xyz = ((s.Albedo * light.xyz ) + ((light.xyz * _SpecColor.xyz ) * spec)); + c.w = (s.Alpha + (spec * _SpecColor.w )); + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec4 light; + vec4 col; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + surfIN.uv_BumpMap = IN.hip_pack0.zw ; + surfIN.worldRefl = vec3( IN.TtoW0.w , IN.TtoW1.w , IN.TtoW2.w ); + surfIN.TtoW0 = IN.TtoW0.xyz ; + surfIN.TtoW1 = IN.TtoW1.xyz ; + surfIN.TtoW2 = IN.TtoW2.xyz ; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + surf( surfIN, o); + light = texture2DProj( _LightBuffer, IN.hip_screen); + light = ( -log2( light ) ); + light.xyz += unity_Ambient.xyz ; + col = LightingBlinnPhong_PrePass( o, light); + col.xyz += o.Emission; + return col; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec4( gl_TexCoord[0]); + xlt_IN.hip_screen = vec4( gl_TexCoord[1]); + xlt_IN.TtoW0 = vec4( gl_TexCoord[2]); + xlt_IN.TtoW1 = vec4( gl_TexCoord[3]); + xlt_IN.TtoW2 = vec4( gl_TexCoord[4]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Bumped_Specular2-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Bumped_Specular2-ir.txt new file mode 100644 index 000000000..def3bac5e --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Bumped_Specular2-ir.txt @@ -0,0 +1,253 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; + vec3 worldRefl; + vec3 TtoW0; + vec3 TtoW1; + vec3 TtoW2; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec4 hip_screen; + vec4 TtoW0; + vec4 TtoW1; + vec4 TtoW2; +}; +varying vec4 xlv_FOG; +uniform vec4 unity_Ambient; +uniform vec4 _SpecColor; +uniform float _Shininess; +uniform vec4 _ReflectColor; +uniform sampler2D _MainTex; +uniform sampler2D _LightBuffer; +uniform samplerCube _Cube; +uniform vec4 _Color; +uniform sampler2D _BumpMap; +vec4 UnpackNormal ( + in vec4 packednormal +) +{ + vec4 normal; + vec2 tmpvar_1; + tmpvar_1 = ((packednormal.wy * 2.0) - 1.0); + normal.xy = tmpvar_1.xy.xy; + float tmpvar_2; + tmpvar_2 = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + normal.z = vec3(tmpvar_3).z; + return normal; +} + +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 reflcol; + vec3 worldRefl; + vec4 c; + vec4 tex; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + tex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = (tex * _Color); + c = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = c.xyz; + o.Albedo = tmpvar_4; + float tmpvar_5; + tmpvar_5 = tex.w; + o.Gloss = tmpvar_5; + float tmpvar_6; + tmpvar_6 = _Shininess; + o.Specular = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = texture2D (_BumpMap, IN.uv_BumpMap); + vec4 tmpvar_8; + tmpvar_8 = UnpackNormal (tmpvar_7); + vec3 tmpvar_9; + tmpvar_9 = tmpvar_8.xyz; + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + o.Normal = tmpvar_10; + float tmpvar_11; + tmpvar_11 = dot (IN.TtoW0, o.Normal); + float tmpvar_12; + tmpvar_12 = dot (IN.TtoW1, o.Normal); + float tmpvar_13; + tmpvar_13 = dot (IN.TtoW2, o.Normal); + vec3 tmpvar_14; + tmpvar_14.x = tmpvar_11; + tmpvar_14.y = tmpvar_12; + tmpvar_14.z = tmpvar_13; + vec3 tmpvar_15; + tmpvar_15 = reflect (IN.worldRefl, tmpvar_14); + vec3 tmpvar_16; + tmpvar_16 = tmpvar_15; + worldRefl = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17 = textureCube (_Cube, worldRefl); + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + reflcol = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19 = (reflcol * tex.w); + reflcol = tmpvar_19; + vec3 tmpvar_20; + tmpvar_20 = (reflcol.xyz * _ReflectColor.xyz); + o.Emission = tmpvar_20; + float tmpvar_21; + tmpvar_21 = (reflcol.w * _ReflectColor.w); + o.Alpha = tmpvar_21; +} + +vec4 LightingBlinnPhong_PrePass ( + in SurfaceOutput s, + in vec4 light +) +{ + vec4 c; + float spec; + float tmpvar_1; + tmpvar_1 = (light.w * s.Gloss); + spec = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = ((s.Albedo * light.xyz) + ((light.xyz * _SpecColor.xyz) * spec)); + c.xyz = tmpvar_2.xyz.xyz; + float tmpvar_3; + tmpvar_3 = (s.Alpha + (spec * _SpecColor.w)); + c.w = vec4(tmpvar_3).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 col; + vec4 light; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = IN.hip_pack0.zw; + surfIN.uv_BumpMap = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3.x = IN.TtoW0.w; + tmpvar_3.y = IN.TtoW1.w; + tmpvar_3.z = IN.TtoW2.w; + vec3 tmpvar_4; + tmpvar_4 = tmpvar_3; + surfIN.worldRefl = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = IN.TtoW0.xyz; + surfIN.TtoW0 = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = IN.TtoW1.xyz; + surfIN.TtoW1 = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = IN.TtoW2.xyz; + surfIN.TtoW2 = tmpvar_7; + vec3 tmpvar_8; + tmpvar_8 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_9; + float tmpvar_10; + tmpvar_10 = 0.0; + o.Specular = tmpvar_10; + float tmpvar_11; + tmpvar_11 = 0.0; + o.Alpha = tmpvar_11; + float tmpvar_12; + tmpvar_12 = 0.0; + o.Gloss = tmpvar_12; + surf (surfIN, o); + vec4 tmpvar_13; + tmpvar_13 = texture2DProj (_LightBuffer, IN.hip_screen); + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + light = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = log2 (light); + vec4 tmpvar_16; + tmpvar_16 = -(tmpvar_15); + light = tmpvar_16; + vec3 tmpvar_17; + tmpvar_17 = (light.xyz + unity_Ambient.xyz); + light.xyz = tmpvar_17.xyz.xyz; + vec4 tmpvar_18; + tmpvar_18 = LightingBlinnPhong_PrePass (o, light); + vec4 tmpvar_19; + tmpvar_19 = tmpvar_18; + col = tmpvar_19; + vec3 tmpvar_20; + tmpvar_20 = (col.xyz + o.Emission); + col.xyz = tmpvar_20.xyz.xyz; + return col; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyzw; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.hip_screen = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.TtoW0 = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_TexCoord[3].xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_IN.TtoW1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_TexCoord[4].xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_IN.TtoW2 = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = frag_surf (xlt_IN); + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_FragData[0] = tmpvar_16; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Bumped_Specular2-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Bumped_Specular2-out.txt new file mode 100644 index 000000000..bd71e7b25 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Bumped_Specular2-out.txt @@ -0,0 +1,51 @@ +uniform vec4 unity_Ambient; +uniform vec4 _SpecColor; +uniform vec4 _ReflectColor; +uniform sampler2D _MainTex; +uniform sampler2D _LightBuffer; +uniform samplerCube _Cube; +uniform vec4 _Color; +uniform sampler2D _BumpMap; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = gl_TexCoord[0]; + vec4 tmpvar_2; + tmpvar_2 = gl_TexCoord[2]; + vec4 tmpvar_3; + tmpvar_3 = gl_TexCoord[3]; + vec4 tmpvar_4; + tmpvar_4 = gl_TexCoord[4]; + vec4 col; + vec4 light; + vec3 tmpvar_5; + tmpvar_5.x = tmpvar_2.w; + tmpvar_5.y = tmpvar_3.w; + tmpvar_5.z = tmpvar_4.w; + vec4 tmpvar_6; + tmpvar_6 = texture2D (_MainTex, tmpvar_1.xy); + vec4 normal; + normal.xy = ((texture2D (_BumpMap, tmpvar_1.zw).wy * 2.0) - 1.0); + normal.z = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + vec3 tmpvar_7; + tmpvar_7 = normal.xyz; + vec3 tmpvar_8; + tmpvar_8.x = dot (tmpvar_2.xyz, tmpvar_7); + tmpvar_8.y = dot (tmpvar_3.xyz, tmpvar_7); + tmpvar_8.z = dot (tmpvar_4.xyz, tmpvar_7); + vec4 tmpvar_9; + tmpvar_9 = (textureCube (_Cube, reflect (tmpvar_5, tmpvar_8)) * tmpvar_6.w); + vec4 tmpvar_10; + tmpvar_10 = -(log2 (texture2DProj (_LightBuffer, gl_TexCoord[1]))); + light = tmpvar_10; + light.xyz = (tmpvar_10.xyz + unity_Ambient.xyz); + vec4 c_i0; + float tmpvar_11; + tmpvar_11 = (tmpvar_10.w * tmpvar_6.w); + c_i0.xyz = (((tmpvar_6 * _Color).xyz * light.xyz) + ((light.xyz * _SpecColor.xyz) * tmpvar_11)); + c_i0.w = ((tmpvar_9.w * _ReflectColor.w) + (tmpvar_11 * _SpecColor.w)); + col = c_i0; + col.xyz = (c_i0.xyz + (tmpvar_9.xyz * _ReflectColor.xyz)); + gl_FragData[0] = col; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Bumped_Unlit-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Bumped_Unlit-in.txt new file mode 100644 index 000000000..3d3a3aec4 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Bumped_Unlit-in.txt @@ -0,0 +1,75 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct v2f { + vec4 pos; + float fog; + vec2 uv; + vec2 uv2; + vec3 I; + vec3 TtoW0; + vec3 TtoW1; + vec3 TtoW2; +}; +struct appdata_tan { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; +}; +uniform sampler2D _BumpMap; +uniform samplerCube _Cube; +uniform sampler2D _MainTex; +uniform vec4 _ReflectColor; + +vec4 UnpackNormal( in vec4 packednormal ); +vec4 frag( in v2f i ); +vec4 UnpackNormal( in vec4 packednormal ) { + vec4 normal; + normal.xy = ((packednormal.wy * 2.00000) - 1.00000); + normal.z = sqrt( ((1.00000 - (normal.x * normal.x )) - (normal.y * normal.y )) ); + return normal; +} +vec4 frag( in v2f i ) { + vec4 normal; + vec4 texcol; + vec3 wn; + vec3 r; + vec4 c; + vec4 reflcolor; + normal = UnpackNormal( texture2D( _BumpMap, i.uv2)); + texcol = texture2D( _MainTex, i.uv); + wn.x = dot( i.TtoW0, normal.xyz ); + wn.y = dot( i.TtoW1, normal.xyz ); + wn.z = dot( i.TtoW2, normal.xyz ); + r = reflect( i.I, wn); + c = (gl_LightModel.ambient * texcol); + c.xyz *= 2.00000; + reflcolor = ((textureCube( _Cube, r) * _ReflectColor) * texcol.w ); + return (c + reflcolor); +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f xlt_i; + xlt_i.pos = vec4(0.0); + xlt_i.fog = float( xlv_FOG); + xlt_i.uv = vec2( gl_TexCoord[0]); + xlt_i.uv2 = vec2( gl_TexCoord[1]); + xlt_i.I = vec3( gl_TexCoord[2]); + xlt_i.TtoW0 = vec3( gl_TexCoord[3]); + xlt_i.TtoW1 = vec3( gl_TexCoord[4]); + xlt_i.TtoW2 = vec3( gl_TexCoord[5]); + xl_retval = frag( xlt_i); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Bumped_Unlit-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Bumped_Unlit-ir.txt new file mode 100644 index 000000000..7e82eeb3f --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Bumped_Unlit-ir.txt @@ -0,0 +1,139 @@ +struct v2f { + vec4 pos; + float fog; + vec2 uv; + vec2 uv2; + vec3 I; + vec3 TtoW0; + vec3 TtoW1; + vec3 TtoW2; +}; +varying vec4 xlv_FOG; +uniform vec4 _ReflectColor; +uniform sampler2D _MainTex; +uniform samplerCube _Cube; +uniform sampler2D _BumpMap; +vec4 UnpackNormal ( + in vec4 packednormal +) +{ + vec4 normal; + vec2 tmpvar_1; + tmpvar_1 = ((packednormal.wy * 2.0) - 1.0); + normal.xy = tmpvar_1.xy.xy; + float tmpvar_2; + tmpvar_2 = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + normal.z = vec3(tmpvar_3).z; + return normal; +} + +vec4 frag ( + in v2f i +) +{ + vec4 reflcolor; + vec4 c; + vec3 r; + vec3 wn; + vec4 texcol; + vec4 normal; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_BumpMap, i.uv2); + vec4 tmpvar_2; + tmpvar_2 = UnpackNormal (tmpvar_1); + vec4 tmpvar_3; + tmpvar_3 = tmpvar_2; + normal = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = texture2D (_MainTex, i.uv); + vec4 tmpvar_5; + tmpvar_5 = tmpvar_4; + texcol = tmpvar_5; + float tmpvar_6; + tmpvar_6 = dot (i.TtoW0, normal.xyz); + float tmpvar_7; + tmpvar_7 = tmpvar_6; + wn.x = tmpvar_7; + float tmpvar_8; + tmpvar_8 = dot (i.TtoW1, normal.xyz); + float tmpvar_9; + tmpvar_9 = tmpvar_8; + wn.y = vec2(tmpvar_9).y; + float tmpvar_10; + tmpvar_10 = dot (i.TtoW2, normal.xyz); + float tmpvar_11; + tmpvar_11 = tmpvar_10; + wn.z = vec3(tmpvar_11).z; + vec3 tmpvar_12; + tmpvar_12 = reflect (i.I, wn); + vec3 tmpvar_13; + tmpvar_13 = tmpvar_12; + r = tmpvar_13; + vec4 tmpvar_14; + tmpvar_14 = (gl_LightModel.ambient * texcol); + c = tmpvar_14; + vec3 tmpvar_15; + tmpvar_15 = (c.xyz * 2.0); + c.xyz = tmpvar_15.xyz.xyz; + vec4 tmpvar_16; + tmpvar_16 = textureCube (_Cube, r); + vec4 tmpvar_17; + tmpvar_17 = ((tmpvar_16 * _ReflectColor) * texcol.w); + reflcolor = tmpvar_17; + return (c + reflcolor); +} + +void main () +{ + v2f xlt_i; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_i.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_i.fog = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xy; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_i.uv = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xy; + vec2 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_i.uv2 = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_i.I = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = gl_TexCoord[3].xyz; + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_i.TtoW0 = tmpvar_10; + vec3 tmpvar_11; + tmpvar_11 = gl_TexCoord[4].xyz; + vec3 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_i.TtoW1 = tmpvar_12; + vec3 tmpvar_13; + tmpvar_13 = gl_TexCoord[5].xyz; + vec3 tmpvar_14; + tmpvar_14 = tmpvar_13; + xlt_i.TtoW2 = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = frag (xlt_i); + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + xl_retval = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17 = xl_retval.xyzw; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + gl_FragData[0] = tmpvar_18; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Bumped_Unlit-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Bumped_Unlit-out.txt new file mode 100644 index 000000000..45d6ab104 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Bumped_Unlit-out.txt @@ -0,0 +1,23 @@ +uniform vec4 _ReflectColor; +uniform sampler2D _MainTex; +uniform samplerCube _Cube; +uniform sampler2D _BumpMap; +void main () +{ + vec4 c; + vec3 wn; + vec4 normal_i0; + normal_i0.xy = ((texture2D (_BumpMap, gl_TexCoord[1].xy).wy * 2.0) - 1.0); + normal_i0.z = sqrt (((1.0 - (normal_i0.x * normal_i0.x)) - (normal_i0.y * normal_i0.y))); + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, gl_TexCoord[0].xy); + wn.x = dot (gl_TexCoord[3].xyz, normal_i0.xyz); + wn.y = dot (gl_TexCoord[4].xyz, normal_i0.xyz); + wn.z = dot (gl_TexCoord[5].xyz, normal_i0.xyz); + vec4 tmpvar_2; + tmpvar_2 = (gl_LightModel.ambient * tmpvar_1); + c = tmpvar_2; + c.xyz = (tmpvar_2.xyz * 2.0); + gl_FragData[0] = (c + ((textureCube (_Cube, reflect (gl_TexCoord[2].xyz, wn)) * _ReflectColor) * tmpvar_1.w)); +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Diffuse-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Diffuse-in.txt new file mode 100644 index 000000000..b7b4e5683 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Diffuse-in.txt @@ -0,0 +1,111 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec3 worldRefl; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 normal; + vec3 lightDir; + vec4 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _Color; +uniform samplerCube _Cube; +uniform vec4 _LightColor0; +uniform sampler2D _LightTexture0; +uniform sampler2D _LightTextureB0; +uniform sampler2D _MainTex; +uniform vec4 _ReflectColor; +void surf( in Input IN, inout SurfaceOutput o ); +float UnitySpotCookie( in vec4 LightCoord ); +float UnitySpotAttenuate( in vec3 LightCoord ); +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ); +vec4 frag_surf( in v2f_surf IN ); +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 tex; + vec4 c; + vec4 reflcol; + tex = texture2D( _MainTex, IN.uv_MainTex); + c = (tex * _Color); + o.Albedo = c.xyz ; + reflcol = textureCube( _Cube, IN.worldRefl); + reflcol *= tex.w ; + o.Emission = (reflcol.xyz * _ReflectColor.xyz ); + o.Alpha = (reflcol.w * _ReflectColor.w ); +} +float UnitySpotCookie( in vec4 LightCoord ) { + return texture2D( _LightTexture0, ((LightCoord.xy / LightCoord.w ) + 0.500000)).w ; +} +float UnitySpotAttenuate( in vec3 LightCoord ) { + return texture2D( _LightTextureB0, vec2( vec2( dot( LightCoord, LightCoord)))).w ; +} +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ) { + float diff; + vec4 c; + diff = max( 0.000000, dot( s.Normal, lightDir)); + c.xyz = ((s.Albedo * _LightColor0.xyz ) * ((diff * atten) * 2.00000)); + c.w = s.Alpha; + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec3 lightDir; + vec4 c; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + o.Normal = IN.normal; + surf( surfIN, o); + lightDir = IN.lightDir; + lightDir = normalize( lightDir ); + c = LightingLambert( o, lightDir, ((float( (IN._LightCoord.z > 0.000000) ) * UnitySpotCookie( IN._LightCoord)) * UnitySpotAttenuate( IN._LightCoord.xyz ))); + c.w = 0.000000; + return c; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec2( gl_TexCoord[0]); + xlt_IN.normal = vec3( gl_TexCoord[1]); + xlt_IN.lightDir = vec3( gl_TexCoord[2]); + xlt_IN._LightCoord = vec4( gl_TexCoord[3]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Diffuse-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Diffuse-ir.txt new file mode 100644 index 000000000..ee8c30709 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Diffuse-ir.txt @@ -0,0 +1,206 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec3 worldRefl; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 normal; + vec3 lightDir; + vec4 _LightCoord; +}; +varying vec4 xlv_FOG; +uniform vec4 _ReflectColor; +uniform sampler2D _MainTex; +uniform sampler2D _LightTextureB0; +uniform sampler2D _LightTexture0; +uniform vec4 _LightColor0; +uniform samplerCube _Cube; +uniform vec4 _Color; +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 reflcol; + vec4 c; + vec4 tex; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + tex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = (tex * _Color); + c = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = c.xyz; + o.Albedo = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = textureCube (_Cube, IN.worldRefl); + vec4 tmpvar_6; + tmpvar_6 = tmpvar_5; + reflcol = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = (reflcol * tex.w); + reflcol = tmpvar_7; + vec3 tmpvar_8; + tmpvar_8 = (reflcol.xyz * _ReflectColor.xyz); + o.Emission = tmpvar_8; + float tmpvar_9; + tmpvar_9 = (reflcol.w * _ReflectColor.w); + o.Alpha = tmpvar_9; +} + +float UnitySpotCookie ( + in vec4 LightCoord +) +{ + vec4 tmpvar_1; + tmpvar_1 = texture2D (_LightTexture0, ((LightCoord.xy / LightCoord.w) + 0.5)); + return tmpvar_1.w; +} + +float UnitySpotAttenuate ( + in vec3 LightCoord +) +{ + float tmpvar_1; + tmpvar_1 = dot (LightCoord, LightCoord); + vec2 tmpvar_2; + tmpvar_2 = vec2(tmpvar_1); + vec2 tmpvar_3; + tmpvar_3 = tmpvar_2.xy; + vec4 tmpvar_4; + tmpvar_4 = texture2D (_LightTextureB0, tmpvar_3); + return tmpvar_4.w; +} + +vec4 LightingLambert ( + in SurfaceOutput s, + in vec3 lightDir, + in float atten +) +{ + vec4 c; + float diff; + float tmpvar_1; + tmpvar_1 = dot (s.Normal, lightDir); + float tmpvar_2; + tmpvar_2 = max (0.0, tmpvar_1); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + diff = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = ((s.Albedo * _LightColor0.xyz) * ((diff * atten) * 2.0)); + c.xyz = tmpvar_4.xyz.xyz; + float tmpvar_5; + tmpvar_5 = s.Alpha; + c.w = vec4(tmpvar_5).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 c; + vec3 lightDir; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_3; + float tmpvar_4; + tmpvar_4 = 0.0; + o.Specular = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Alpha = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Gloss = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = IN.normal; + o.Normal = tmpvar_7; + surf (surfIN, o); + vec3 tmpvar_8; + tmpvar_8 = IN.lightDir; + lightDir = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = normalize (lightDir); + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + lightDir = tmpvar_10; + float tmpvar_11; + tmpvar_11 = UnitySpotCookie (IN._LightCoord); + float tmpvar_12; + tmpvar_12 = UnitySpotAttenuate (IN._LightCoord.xyz); + vec4 tmpvar_13; + tmpvar_13 = LightingLambert (o, lightDir, ((float((IN._LightCoord.z > 0.0)) * tmpvar_11) * tmpvar_12)); + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + c = tmpvar_14; + float tmpvar_15; + tmpvar_15 = 0.0; + c.w = vec4(tmpvar_15).w; + return c; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xy; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.normal = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.lightDir = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_TexCoord[3].xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_IN._LightCoord = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = frag_surf (xlt_IN); + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xl_retval = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = xl_retval.xyzw; + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + gl_FragData[0] = tmpvar_14; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Diffuse-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Diffuse-out.txt new file mode 100644 index 000000000..aa233225a --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Diffuse-out.txt @@ -0,0 +1,25 @@ +uniform vec4 _ReflectColor; +uniform sampler2D _MainTex; +uniform sampler2D _LightTextureB0; +uniform sampler2D _LightTexture0; +uniform vec4 _LightColor0; +uniform samplerCube _Cube; +uniform vec4 _Color; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = gl_TexCoord[3]; + vec4 c; + vec3 tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = texture2D (_MainTex, gl_TexCoord[0].xy); + vec3 LightCoord_i0; + LightCoord_i0 = tmpvar_1.xyz; + vec4 c_i0_i1; + c_i0_i1.xyz = (((tmpvar_3 * _Color).xyz * _LightColor0.xyz) * ((max (0.0, dot (gl_TexCoord[1].xyz, normalize (gl_TexCoord[2].xyz))) * ((float((tmpvar_1.z > 0.0)) * texture2D (_LightTexture0, ((tmpvar_1.xy / tmpvar_1.w) + 0.5)).w) * texture2D (_LightTextureB0, vec2(dot (LightCoord_i0, LightCoord_i0))).w)) * 2.0)); + c_i0_i1.w = ((textureCube (_Cube, tmpvar_2) * tmpvar_3.w).w * _ReflectColor.w); + c = c_i0_i1; + c.w = 0.0; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Diffuse1-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Diffuse1-in.txt new file mode 100644 index 000000000..fd969be51 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Diffuse1-in.txt @@ -0,0 +1,99 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec3 worldRefl; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 worldRefl; + vec4 hip_screen; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _Color; +uniform samplerCube _Cube; +uniform sampler2D _LightBuffer; +uniform sampler2D _MainTex; +uniform vec4 _ReflectColor; +uniform vec4 unity_Ambient; +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingLambert_PrePass( in SurfaceOutput s, in vec4 light ); +vec4 frag_surf( in v2f_surf IN ); +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 tex; + vec4 c; + vec4 reflcol; + tex = texture2D( _MainTex, IN.uv_MainTex); + c = (tex * _Color); + o.Albedo = c.xyz ; + reflcol = textureCube( _Cube, IN.worldRefl); + reflcol *= tex.w ; + o.Emission = (reflcol.xyz * _ReflectColor.xyz ); + o.Alpha = (reflcol.w * _ReflectColor.w ); +} +vec4 LightingLambert_PrePass( in SurfaceOutput s, in vec4 light ) { + vec4 c; + c.xyz = (s.Albedo * light.xyz ); + c.w = s.Alpha; + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec4 light; + vec4 col; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + surfIN.worldRefl = IN.worldRefl; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + surf( surfIN, o); + light = texture2DProj( _LightBuffer, IN.hip_screen); + light = ( -log2( light ) ); + light.xyz += unity_Ambient.xyz ; + col = LightingLambert_PrePass( o, light); + col.xyz += o.Emission; + return col; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec2( gl_TexCoord[0]); + xlt_IN.worldRefl = vec3( gl_TexCoord[1]); + xlt_IN.hip_screen = vec4( gl_TexCoord[2]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Diffuse1-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Diffuse1-ir.txt new file mode 100644 index 000000000..33fca39f6 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Diffuse1-ir.txt @@ -0,0 +1,167 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec3 worldRefl; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 worldRefl; + vec4 hip_screen; +}; +varying vec4 xlv_FOG; +uniform vec4 unity_Ambient; +uniform vec4 _ReflectColor; +uniform sampler2D _MainTex; +uniform sampler2D _LightBuffer; +uniform samplerCube _Cube; +uniform vec4 _Color; +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 reflcol; + vec4 c; + vec4 tex; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + tex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = (tex * _Color); + c = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = c.xyz; + o.Albedo = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = textureCube (_Cube, IN.worldRefl); + vec4 tmpvar_6; + tmpvar_6 = tmpvar_5; + reflcol = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = (reflcol * tex.w); + reflcol = tmpvar_7; + vec3 tmpvar_8; + tmpvar_8 = (reflcol.xyz * _ReflectColor.xyz); + o.Emission = tmpvar_8; + float tmpvar_9; + tmpvar_9 = (reflcol.w * _ReflectColor.w); + o.Alpha = tmpvar_9; +} + +vec4 LightingLambert_PrePass ( + in SurfaceOutput s, + in vec4 light +) +{ + vec4 c; + vec3 tmpvar_1; + tmpvar_1 = (s.Albedo * light.xyz); + c.xyz = tmpvar_1.xyz.xyz; + float tmpvar_2; + tmpvar_2 = s.Alpha; + c.w = vec4(tmpvar_2).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 col; + vec4 light; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = IN.worldRefl; + surfIN.worldRefl = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Specular = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Alpha = tmpvar_6; + float tmpvar_7; + tmpvar_7 = 0.0; + o.Gloss = tmpvar_7; + surf (surfIN, o); + vec4 tmpvar_8; + tmpvar_8 = texture2DProj (_LightBuffer, IN.hip_screen); + vec4 tmpvar_9; + tmpvar_9 = tmpvar_8; + light = tmpvar_9; + vec4 tmpvar_10; + tmpvar_10 = log2 (light); + vec4 tmpvar_11; + tmpvar_11 = -(tmpvar_10); + light = tmpvar_11; + vec3 tmpvar_12; + tmpvar_12 = (light.xyz + unity_Ambient.xyz); + light.xyz = tmpvar_12.xyz.xyz; + vec4 tmpvar_13; + tmpvar_13 = LightingLambert_PrePass (o, light); + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + col = tmpvar_14; + vec3 tmpvar_15; + tmpvar_15 = (col.xyz + o.Emission); + col.xyz = tmpvar_15.xyz.xyz; + return col; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xy; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.worldRefl = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.hip_screen = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = frag_surf (xlt_IN); + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xl_retval = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = xl_retval.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + gl_FragData[0] = tmpvar_12; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Diffuse1-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Diffuse1-out.txt new file mode 100644 index 000000000..ce57a40b7 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Diffuse1-out.txt @@ -0,0 +1,26 @@ +uniform vec4 unity_Ambient; +uniform vec4 _ReflectColor; +uniform sampler2D _MainTex; +uniform sampler2D _LightBuffer; +uniform samplerCube _Cube; +uniform vec4 _Color; +void main () +{ + vec4 col; + vec4 light; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, gl_TexCoord[0].xy); + vec4 tmpvar_2; + tmpvar_2 = (textureCube (_Cube, gl_TexCoord[1].xyz) * tmpvar_1.w); + vec4 tmpvar_3; + tmpvar_3 = -(log2 (texture2DProj (_LightBuffer, gl_TexCoord[2]))); + light = tmpvar_3; + light.xyz = (tmpvar_3.xyz + unity_Ambient.xyz); + vec4 c_i0; + c_i0.xyz = ((tmpvar_1 * _Color).xyz * light.xyz); + c_i0.w = (tmpvar_2.w * _ReflectColor.w); + col = c_i0; + col.xyz = (c_i0.xyz + (tmpvar_2.xyz * _ReflectColor.xyz)); + gl_FragData[0] = col; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Parallax_Diffuse-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Parallax_Diffuse-in.txt new file mode 100644 index 000000000..4ac625d1e --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Parallax_Diffuse-in.txt @@ -0,0 +1,141 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; + vec3 worldRefl; + vec3 viewDir; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 viewDir; + vec3 lightDir; + vec4 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform sampler2D _BumpMap; +uniform vec4 _Color; +uniform samplerCube _Cube; +uniform vec4 _LightColor0; +uniform sampler2D _LightTexture0; +uniform sampler2D _LightTextureB0; +uniform sampler2D _MainTex; +uniform float _Parallax; +uniform sampler2D _ParallaxMap; +uniform vec4 _ReflectColor; +vec4 UnpackNormal( in vec4 packednormal ); +vec2 ParallaxOffset( in float h, in float height, in vec3 viewDir ); +void surf( in Input IN, inout SurfaceOutput o ); +float UnitySpotCookie( in vec4 LightCoord ); +float UnitySpotAttenuate( in vec3 LightCoord ); +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ); +vec4 frag_surf( in v2f_surf IN ); +vec4 UnpackNormal( in vec4 packednormal ) { + vec4 normal; + normal.xy = ((packednormal.wy * 2.00000) - 1.00000); + normal.z = sqrt( ((1.00000 - (normal.x * normal.x )) - (normal.y * normal.y )) ); + return normal; +} +vec2 ParallaxOffset( in float h, in float height, in vec3 viewDir ) { + vec3 v; + h = ((h * height) - (height / 2.00000)); + v = normalize( viewDir ); + v.z += 0.420000; + return (h * (v.xy / v.z )); +} +void surf( in Input IN, inout SurfaceOutput o ) { + float h; + vec2 offset; + vec4 tex; + vec4 c; + vec3 worldRefl; + vec4 reflcol; + h = texture2D( _ParallaxMap, IN.uv_BumpMap).w ; + offset = ParallaxOffset( h, _Parallax, IN.viewDir); + IN.uv_MainTex += offset; + IN.uv_BumpMap += offset; + tex = texture2D( _MainTex, IN.uv_MainTex); + c = (tex * _Color); + o.Albedo = c.xyz ; + o.Normal = vec3( UnpackNormal( texture2D( _BumpMap, IN.uv_BumpMap))); + worldRefl = IN.worldRefl; + reflcol = textureCube( _Cube, worldRefl); + reflcol *= tex.w ; + o.Emission = (reflcol.xyz * _ReflectColor.xyz ); + o.Alpha = (reflcol.w * _ReflectColor.w ); +} +float UnitySpotCookie( in vec4 LightCoord ) { + return texture2D( _LightTexture0, ((LightCoord.xy / LightCoord.w ) + 0.500000)).w ; +} +float UnitySpotAttenuate( in vec3 LightCoord ) { + return texture2D( _LightTextureB0, vec2( vec2( dot( LightCoord, LightCoord)))).w ; +} +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ) { + float diff; + vec4 c; + diff = max( 0.000000, dot( s.Normal, lightDir)); + c.xyz = ((s.Albedo * _LightColor0.xyz ) * ((diff * atten) * 2.00000)); + c.w = s.Alpha; + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec3 lightDir; + vec4 c; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + surfIN.uv_BumpMap = IN.hip_pack0.zw ; + surfIN.viewDir = IN.viewDir; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + surf( surfIN, o); + lightDir = IN.lightDir; + lightDir = normalize( lightDir ); + c = LightingLambert( o, lightDir, ((float( (IN._LightCoord.z > 0.000000) ) * UnitySpotCookie( IN._LightCoord)) * UnitySpotAttenuate( IN._LightCoord.xyz ))); + c.w = 0.000000; + return c; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec4( gl_TexCoord[0]); + xlt_IN.viewDir = vec3( gl_TexCoord[1]); + xlt_IN.lightDir = vec3( gl_TexCoord[2]); + xlt_IN._LightCoord = vec4( gl_TexCoord[3]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Parallax_Diffuse-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Parallax_Diffuse-ir.txt new file mode 100644 index 000000000..6257aca25 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Parallax_Diffuse-ir.txt @@ -0,0 +1,282 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; + vec3 worldRefl; + vec3 viewDir; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 viewDir; + vec3 lightDir; + vec4 _LightCoord; +}; +varying vec4 xlv_FOG; +uniform vec4 _ReflectColor; +uniform sampler2D _ParallaxMap; +uniform float _Parallax; +uniform sampler2D _MainTex; +uniform sampler2D _LightTextureB0; +uniform sampler2D _LightTexture0; +uniform vec4 _LightColor0; +uniform samplerCube _Cube; +uniform vec4 _Color; +uniform sampler2D _BumpMap; +vec4 UnpackNormal ( + in vec4 packednormal +) +{ + vec4 normal; + vec2 tmpvar_1; + tmpvar_1 = ((packednormal.wy * 2.0) - 1.0); + normal.xy = tmpvar_1.xy.xy; + float tmpvar_2; + tmpvar_2 = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + normal.z = vec3(tmpvar_3).z; + return normal; +} + +vec2 ParallaxOffset ( + in float h, + in float height, + in vec3 viewDir +) +{ + vec3 v; + float tmpvar_1; + tmpvar_1 = ((h * height) - (height / 2.0)); + h = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = normalize (viewDir); + vec3 tmpvar_3; + tmpvar_3 = tmpvar_2; + v = tmpvar_3; + float tmpvar_4; + tmpvar_4 = (v.z + 0.42); + v.z = vec3(tmpvar_4).z; + return (h * (v.xy / v.z)); +} + +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 reflcol; + vec3 worldRefl; + vec4 c; + vec4 tex; + vec2 offset; + float h; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_ParallaxMap, IN.uv_BumpMap); + float tmpvar_2; + tmpvar_2 = tmpvar_1.w; + h = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = ParallaxOffset (h, _Parallax, IN.viewDir); + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + offset = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5 = (IN.uv_MainTex + offset); + IN.uv_MainTex = tmpvar_5; + vec2 tmpvar_6; + tmpvar_6 = (IN.uv_BumpMap + offset); + IN.uv_BumpMap = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + tex = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = (tex * _Color); + c = tmpvar_9; + vec3 tmpvar_10; + tmpvar_10 = c.xyz; + o.Albedo = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = texture2D (_BumpMap, IN.uv_BumpMap); + vec4 tmpvar_12; + tmpvar_12 = UnpackNormal (tmpvar_11); + vec3 tmpvar_13; + tmpvar_13 = tmpvar_12.xyz; + vec3 tmpvar_14; + tmpvar_14 = tmpvar_13; + o.Normal = tmpvar_14; + vec3 tmpvar_15; + tmpvar_15 = IN.worldRefl; + worldRefl = tmpvar_15; + vec4 tmpvar_16; + tmpvar_16 = textureCube (_Cube, worldRefl); + vec4 tmpvar_17; + tmpvar_17 = tmpvar_16; + reflcol = tmpvar_17; + vec4 tmpvar_18; + tmpvar_18 = (reflcol * tex.w); + reflcol = tmpvar_18; + vec3 tmpvar_19; + tmpvar_19 = (reflcol.xyz * _ReflectColor.xyz); + o.Emission = tmpvar_19; + float tmpvar_20; + tmpvar_20 = (reflcol.w * _ReflectColor.w); + o.Alpha = tmpvar_20; +} + +float UnitySpotCookie ( + in vec4 LightCoord +) +{ + vec4 tmpvar_1; + tmpvar_1 = texture2D (_LightTexture0, ((LightCoord.xy / LightCoord.w) + 0.5)); + return tmpvar_1.w; +} + +float UnitySpotAttenuate ( + in vec3 LightCoord +) +{ + float tmpvar_1; + tmpvar_1 = dot (LightCoord, LightCoord); + vec2 tmpvar_2; + tmpvar_2 = vec2(tmpvar_1); + vec2 tmpvar_3; + tmpvar_3 = tmpvar_2.xy; + vec4 tmpvar_4; + tmpvar_4 = texture2D (_LightTextureB0, tmpvar_3); + return tmpvar_4.w; +} + +vec4 LightingLambert ( + in SurfaceOutput s, + in vec3 lightDir, + in float atten +) +{ + vec4 c; + float diff; + float tmpvar_1; + tmpvar_1 = dot (s.Normal, lightDir); + float tmpvar_2; + tmpvar_2 = max (0.0, tmpvar_1); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + diff = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = ((s.Albedo * _LightColor0.xyz) * ((diff * atten) * 2.0)); + c.xyz = tmpvar_4.xyz.xyz; + float tmpvar_5; + tmpvar_5 = s.Alpha; + c.w = vec4(tmpvar_5).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 c; + vec3 lightDir; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = IN.hip_pack0.zw; + surfIN.uv_BumpMap = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = IN.viewDir; + surfIN.viewDir = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Specular = tmpvar_6; + float tmpvar_7; + tmpvar_7 = 0.0; + o.Alpha = tmpvar_7; + float tmpvar_8; + tmpvar_8 = 0.0; + o.Gloss = tmpvar_8; + surf (surfIN, o); + vec3 tmpvar_9; + tmpvar_9 = IN.lightDir; + lightDir = tmpvar_9; + vec3 tmpvar_10; + tmpvar_10 = normalize (lightDir); + vec3 tmpvar_11; + tmpvar_11 = tmpvar_10; + lightDir = tmpvar_11; + float tmpvar_12; + tmpvar_12 = UnitySpotCookie (IN._LightCoord); + float tmpvar_13; + tmpvar_13 = UnitySpotAttenuate (IN._LightCoord.xyz); + vec4 tmpvar_14; + tmpvar_14 = LightingLambert (o, lightDir, ((float((IN._LightCoord.z > 0.0)) * tmpvar_12) * tmpvar_13)); + vec4 tmpvar_15; + tmpvar_15 = tmpvar_14; + c = tmpvar_15; + float tmpvar_16; + tmpvar_16 = 0.0; + c.w = vec4(tmpvar_16).w; + return c; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.viewDir = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.lightDir = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_TexCoord[3].xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_IN._LightCoord = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = frag_surf (xlt_IN); + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xl_retval = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = xl_retval.xyzw; + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + gl_FragData[0] = tmpvar_14; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Parallax_Diffuse-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Parallax_Diffuse-out.txt new file mode 100644 index 000000000..2f5816a74 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Parallax_Diffuse-out.txt @@ -0,0 +1,40 @@ +uniform vec4 _ReflectColor; +uniform sampler2D _ParallaxMap; +uniform float _Parallax; +uniform sampler2D _MainTex; +uniform sampler2D _LightTextureB0; +uniform sampler2D _LightTexture0; +uniform vec4 _LightColor0; +uniform samplerCube _Cube; +uniform vec4 _Color; +uniform sampler2D _BumpMap; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = gl_TexCoord[0]; + vec4 tmpvar_2; + tmpvar_2 = gl_TexCoord[3]; + vec4 c; + vec3 tmpvar_3; + vec2 tmpvar_4; + vec3 v; + vec3 tmpvar_5; + tmpvar_5 = normalize (gl_TexCoord[1].xyz); + v = tmpvar_5; + v.z = (tmpvar_5.z + 0.42); + tmpvar_4 = (((texture2D (_ParallaxMap, tmpvar_1.zw).w * _Parallax) - (_Parallax / 2.0)) * (tmpvar_5.xy / v.z)); + vec4 tmpvar_6; + tmpvar_6 = texture2D (_MainTex, (tmpvar_1.xy + tmpvar_4)); + vec4 normal; + normal.xy = ((texture2D (_BumpMap, (tmpvar_1.zw + tmpvar_4)).wy * 2.0) - 1.0); + normal.z = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + vec3 LightCoord_i0; + LightCoord_i0 = tmpvar_2.xyz; + vec4 c_i0_i1; + c_i0_i1.xyz = (((tmpvar_6 * _Color).xyz * _LightColor0.xyz) * ((max (0.0, dot (normal.xyz, normalize (gl_TexCoord[2].xyz))) * ((float((tmpvar_2.z > 0.0)) * texture2D (_LightTexture0, ((tmpvar_2.xy / tmpvar_2.w) + 0.5)).w) * texture2D (_LightTextureB0, vec2(dot (LightCoord_i0, LightCoord_i0))).w)) * 2.0)); + c_i0_i1.w = ((textureCube (_Cube, tmpvar_3) * tmpvar_6.w).w * _ReflectColor.w); + c = c_i0_i1; + c.w = 0.0; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Parallax_Diffuse1-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Parallax_Diffuse1-in.txt new file mode 100644 index 000000000..69d0ff01f --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Parallax_Diffuse1-in.txt @@ -0,0 +1,142 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; + vec3 worldRefl; + vec3 viewDir; + vec3 TtoW0; + vec3 TtoW1; + vec3 TtoW2; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 viewDir; + vec4 hip_screen; + vec4 TtoW0; + vec4 TtoW1; + vec4 TtoW2; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform sampler2D _BumpMap; +uniform vec4 _Color; +uniform samplerCube _Cube; +uniform sampler2D _LightBuffer; +uniform sampler2D _MainTex; +uniform float _Parallax; +uniform sampler2D _ParallaxMap; +uniform vec4 _ReflectColor; +uniform vec4 unity_Ambient; +vec4 UnpackNormal( in vec4 packednormal ); +vec2 ParallaxOffset( in float h, in float height, in vec3 viewDir ); +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingLambert_PrePass( in SurfaceOutput s, in vec4 light ); +vec4 frag_surf( in v2f_surf IN ); +vec4 UnpackNormal( in vec4 packednormal ) { + vec4 normal; + normal.xy = ((packednormal.wy * 2.00000) - 1.00000); + normal.z = sqrt( ((1.00000 - (normal.x * normal.x )) - (normal.y * normal.y )) ); + return normal; +} +vec2 ParallaxOffset( in float h, in float height, in vec3 viewDir ) { + vec3 v; + h = ((h * height) - (height / 2.00000)); + v = normalize( viewDir ); + v.z += 0.420000; + return (h * (v.xy / v.z )); +} +void surf( in Input IN, inout SurfaceOutput o ) { + float h; + vec2 offset; + vec4 tex; + vec4 c; + vec3 worldRefl; + vec4 reflcol; + h = texture2D( _ParallaxMap, IN.uv_BumpMap).w ; + offset = ParallaxOffset( h, _Parallax, IN.viewDir); + IN.uv_MainTex += offset; + IN.uv_BumpMap += offset; + tex = texture2D( _MainTex, IN.uv_MainTex); + c = (tex * _Color); + o.Albedo = c.xyz ; + o.Normal = vec3( UnpackNormal( texture2D( _BumpMap, IN.uv_BumpMap))); + worldRefl = reflect( IN.worldRefl, vec3( dot( IN.TtoW0, o.Normal), dot( IN.TtoW1, o.Normal), dot( IN.TtoW2, o.Normal))); + reflcol = textureCube( _Cube, worldRefl); + reflcol *= tex.w ; + o.Emission = (reflcol.xyz * _ReflectColor.xyz ); + o.Alpha = (reflcol.w * _ReflectColor.w ); +} +vec4 LightingLambert_PrePass( in SurfaceOutput s, in vec4 light ) { + vec4 c; + c.xyz = (s.Albedo * light.xyz ); + c.w = s.Alpha; + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec4 light; + vec4 col; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + surfIN.uv_BumpMap = IN.hip_pack0.zw ; + surfIN.worldRefl = vec3( IN.TtoW0.w , IN.TtoW1.w , IN.TtoW2.w ); + surfIN.TtoW0 = IN.TtoW0.xyz ; + surfIN.TtoW1 = IN.TtoW1.xyz ; + surfIN.TtoW2 = IN.TtoW2.xyz ; + surfIN.viewDir = IN.viewDir; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + surf( surfIN, o); + light = texture2DProj( _LightBuffer, IN.hip_screen); + light = ( -log2( light ) ); + light.xyz += unity_Ambient.xyz ; + col = LightingLambert_PrePass( o, light); + col.xyz += o.Emission; + return col; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec4( gl_TexCoord[0]); + xlt_IN.viewDir = vec3( gl_TexCoord[1]); + xlt_IN.hip_screen = vec4( gl_TexCoord[2]); + xlt_IN.TtoW0 = vec4( gl_TexCoord[3]); + xlt_IN.TtoW1 = vec4( gl_TexCoord[4]); + xlt_IN.TtoW2 = vec4( gl_TexCoord[5]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Parallax_Diffuse1-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Parallax_Diffuse1-ir.txt new file mode 100644 index 000000000..216d6865f --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Parallax_Diffuse1-ir.txt @@ -0,0 +1,292 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; + vec3 worldRefl; + vec3 viewDir; + vec3 TtoW0; + vec3 TtoW1; + vec3 TtoW2; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 viewDir; + vec4 hip_screen; + vec4 TtoW0; + vec4 TtoW1; + vec4 TtoW2; +}; +varying vec4 xlv_FOG; +uniform vec4 unity_Ambient; +uniform vec4 _ReflectColor; +uniform sampler2D _ParallaxMap; +uniform float _Parallax; +uniform sampler2D _MainTex; +uniform sampler2D _LightBuffer; +uniform samplerCube _Cube; +uniform vec4 _Color; +uniform sampler2D _BumpMap; +vec4 UnpackNormal ( + in vec4 packednormal +) +{ + vec4 normal; + vec2 tmpvar_1; + tmpvar_1 = ((packednormal.wy * 2.0) - 1.0); + normal.xy = tmpvar_1.xy.xy; + float tmpvar_2; + tmpvar_2 = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + normal.z = vec3(tmpvar_3).z; + return normal; +} + +vec2 ParallaxOffset ( + in float h, + in float height, + in vec3 viewDir +) +{ + vec3 v; + float tmpvar_1; + tmpvar_1 = ((h * height) - (height / 2.0)); + h = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = normalize (viewDir); + vec3 tmpvar_3; + tmpvar_3 = tmpvar_2; + v = tmpvar_3; + float tmpvar_4; + tmpvar_4 = (v.z + 0.42); + v.z = vec3(tmpvar_4).z; + return (h * (v.xy / v.z)); +} + +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 reflcol; + vec3 worldRefl; + vec4 c; + vec4 tex; + vec2 offset; + float h; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_ParallaxMap, IN.uv_BumpMap); + float tmpvar_2; + tmpvar_2 = tmpvar_1.w; + h = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = ParallaxOffset (h, _Parallax, IN.viewDir); + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + offset = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5 = (IN.uv_MainTex + offset); + IN.uv_MainTex = tmpvar_5; + vec2 tmpvar_6; + tmpvar_6 = (IN.uv_BumpMap + offset); + IN.uv_BumpMap = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + tex = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = (tex * _Color); + c = tmpvar_9; + vec3 tmpvar_10; + tmpvar_10 = c.xyz; + o.Albedo = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = texture2D (_BumpMap, IN.uv_BumpMap); + vec4 tmpvar_12; + tmpvar_12 = UnpackNormal (tmpvar_11); + vec3 tmpvar_13; + tmpvar_13 = tmpvar_12.xyz; + vec3 tmpvar_14; + tmpvar_14 = tmpvar_13; + o.Normal = tmpvar_14; + float tmpvar_15; + tmpvar_15 = dot (IN.TtoW0, o.Normal); + float tmpvar_16; + tmpvar_16 = dot (IN.TtoW1, o.Normal); + float tmpvar_17; + tmpvar_17 = dot (IN.TtoW2, o.Normal); + vec3 tmpvar_18; + tmpvar_18.x = tmpvar_15; + tmpvar_18.y = tmpvar_16; + tmpvar_18.z = tmpvar_17; + vec3 tmpvar_19; + tmpvar_19 = reflect (IN.worldRefl, tmpvar_18); + vec3 tmpvar_20; + tmpvar_20 = tmpvar_19; + worldRefl = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21 = textureCube (_Cube, worldRefl); + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + reflcol = tmpvar_22; + vec4 tmpvar_23; + tmpvar_23 = (reflcol * tex.w); + reflcol = tmpvar_23; + vec3 tmpvar_24; + tmpvar_24 = (reflcol.xyz * _ReflectColor.xyz); + o.Emission = tmpvar_24; + float tmpvar_25; + tmpvar_25 = (reflcol.w * _ReflectColor.w); + o.Alpha = tmpvar_25; +} + +vec4 LightingLambert_PrePass ( + in SurfaceOutput s, + in vec4 light +) +{ + vec4 c; + vec3 tmpvar_1; + tmpvar_1 = (s.Albedo * light.xyz); + c.xyz = tmpvar_1.xyz.xyz; + float tmpvar_2; + tmpvar_2 = s.Alpha; + c.w = vec4(tmpvar_2).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 col; + vec4 light; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = IN.hip_pack0.zw; + surfIN.uv_BumpMap = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3.x = IN.TtoW0.w; + tmpvar_3.y = IN.TtoW1.w; + tmpvar_3.z = IN.TtoW2.w; + vec3 tmpvar_4; + tmpvar_4 = tmpvar_3; + surfIN.worldRefl = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = IN.TtoW0.xyz; + surfIN.TtoW0 = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = IN.TtoW1.xyz; + surfIN.TtoW1 = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = IN.TtoW2.xyz; + surfIN.TtoW2 = tmpvar_7; + vec3 tmpvar_8; + tmpvar_8 = IN.viewDir; + surfIN.viewDir = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_9; + vec3 tmpvar_10; + tmpvar_10 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_10; + float tmpvar_11; + tmpvar_11 = 0.0; + o.Specular = tmpvar_11; + float tmpvar_12; + tmpvar_12 = 0.0; + o.Alpha = tmpvar_12; + float tmpvar_13; + tmpvar_13 = 0.0; + o.Gloss = tmpvar_13; + surf (surfIN, o); + vec4 tmpvar_14; + tmpvar_14 = texture2DProj (_LightBuffer, IN.hip_screen); + vec4 tmpvar_15; + tmpvar_15 = tmpvar_14; + light = tmpvar_15; + vec4 tmpvar_16; + tmpvar_16 = log2 (light); + vec4 tmpvar_17; + tmpvar_17 = -(tmpvar_16); + light = tmpvar_17; + vec3 tmpvar_18; + tmpvar_18 = (light.xyz + unity_Ambient.xyz); + light.xyz = tmpvar_18.xyz.xyz; + vec4 tmpvar_19; + tmpvar_19 = LightingLambert_PrePass (o, light); + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + col = tmpvar_20; + vec3 tmpvar_21; + tmpvar_21 = (col.xyz + o.Emission); + col.xyz = tmpvar_21.xyz.xyz; + return col; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.viewDir = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.hip_screen = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_TexCoord[3].xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_IN.TtoW0 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_TexCoord[4].xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_IN.TtoW1 = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = gl_TexCoord[5].xyzw; + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + xlt_IN.TtoW2 = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = frag_surf (xlt_IN); + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + xl_retval = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17 = xl_retval.xyzw; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + gl_FragData[0] = tmpvar_18; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Parallax_Diffuse1-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Parallax_Diffuse1-out.txt new file mode 100644 index 000000000..ec8ecba95 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Parallax_Diffuse1-out.txt @@ -0,0 +1,57 @@ +uniform vec4 unity_Ambient; +uniform vec4 _ReflectColor; +uniform sampler2D _ParallaxMap; +uniform float _Parallax; +uniform sampler2D _MainTex; +uniform sampler2D _LightBuffer; +uniform samplerCube _Cube; +uniform vec4 _Color; +uniform sampler2D _BumpMap; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = gl_TexCoord[0]; + vec4 tmpvar_2; + tmpvar_2 = gl_TexCoord[3]; + vec4 tmpvar_3; + tmpvar_3 = gl_TexCoord[4]; + vec4 tmpvar_4; + tmpvar_4 = gl_TexCoord[5]; + vec4 col; + vec4 light; + vec3 tmpvar_5; + tmpvar_5.x = tmpvar_2.w; + tmpvar_5.y = tmpvar_3.w; + tmpvar_5.z = tmpvar_4.w; + vec2 tmpvar_6; + vec3 v; + vec3 tmpvar_7; + tmpvar_7 = normalize (gl_TexCoord[1].xyz); + v = tmpvar_7; + v.z = (tmpvar_7.z + 0.42); + tmpvar_6 = (((texture2D (_ParallaxMap, tmpvar_1.zw).w * _Parallax) - (_Parallax / 2.0)) * (tmpvar_7.xy / v.z)); + vec4 tmpvar_8; + tmpvar_8 = texture2D (_MainTex, (tmpvar_1.xy + tmpvar_6)); + vec4 normal; + normal.xy = ((texture2D (_BumpMap, (tmpvar_1.zw + tmpvar_6)).wy * 2.0) - 1.0); + normal.z = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + vec3 tmpvar_9; + tmpvar_9 = normal.xyz; + vec3 tmpvar_10; + tmpvar_10.x = dot (tmpvar_2.xyz, tmpvar_9); + tmpvar_10.y = dot (tmpvar_3.xyz, tmpvar_9); + tmpvar_10.z = dot (tmpvar_4.xyz, tmpvar_9); + vec4 tmpvar_11; + tmpvar_11 = (textureCube (_Cube, reflect (tmpvar_5, tmpvar_10)) * tmpvar_8.w); + vec4 tmpvar_12; + tmpvar_12 = -(log2 (texture2DProj (_LightBuffer, gl_TexCoord[2]))); + light = tmpvar_12; + light.xyz = (tmpvar_12.xyz + unity_Ambient.xyz); + vec4 c_i0; + c_i0.xyz = ((tmpvar_8 * _Color).xyz * light.xyz); + c_i0.w = (tmpvar_11.w * _ReflectColor.w); + col = c_i0; + col.xyz = (c_i0.xyz + (tmpvar_11.xyz * _ReflectColor.xyz)); + gl_FragData[0] = col; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Parallax_Specular-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Parallax_Specular-in.txt new file mode 100644 index 000000000..16d2d6f87 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Parallax_Specular-in.txt @@ -0,0 +1,140 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; + vec3 worldRefl; + vec3 viewDir; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 viewDir; + vec3 lightDir; + vec3 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform sampler2D _BumpMap; +uniform vec4 _Color; +uniform samplerCube _Cube; +uniform vec4 _LightColor0; +uniform sampler2D _LightTexture0; +uniform sampler2D _MainTex; +uniform float _Parallax; +uniform sampler2D _ParallaxMap; +uniform vec4 _ReflectColor; +uniform float _Shininess; +uniform vec4 _SpecColor; +vec4 UnpackNormal( in vec4 packednormal ); +vec2 ParallaxOffset( in float h, in float height, in vec3 viewDir ); +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingBlinnPhong( in SurfaceOutput s, in vec3 lightDir, in vec3 viewDir, in float atten ); +vec4 frag_surf( in v2f_surf IN ); +vec4 UnpackNormal( in vec4 packednormal ) { + vec4 normal; + normal.xy = ((packednormal.wy * 2.00000) - 1.00000); + normal.z = sqrt( ((1.00000 - (normal.x * normal.x )) - (normal.y * normal.y )) ); + return normal; +} +vec2 ParallaxOffset( in float h, in float height, in vec3 viewDir ) { + vec3 v; + h = ((h * height) - (height / 2.00000)); + v = normalize( viewDir ); + v.z += 0.420000; + return (h * (v.xy / v.z )); +} +void surf( in Input IN, inout SurfaceOutput o ) { + float h; + vec2 offset; + vec4 tex; + vec3 worldRefl; + vec4 reflcol; + h = texture2D( _ParallaxMap, IN.uv_BumpMap).w ; + offset = ParallaxOffset( h, _Parallax, IN.viewDir); + IN.uv_MainTex += offset; + IN.uv_BumpMap += offset; + tex = texture2D( _MainTex, IN.uv_MainTex); + o.Albedo = (tex.xyz * _Color.xyz ); + o.Gloss = tex.w ; + o.Specular = _Shininess; + o.Normal = vec3( UnpackNormal( texture2D( _BumpMap, IN.uv_BumpMap))); + worldRefl = IN.worldRefl; + reflcol = textureCube( _Cube, worldRefl); + reflcol *= tex.w ; + o.Emission = (reflcol.xyz * _ReflectColor.xyz ); + o.Alpha = (reflcol.w * _ReflectColor.w ); +} +vec4 LightingBlinnPhong( in SurfaceOutput s, in vec3 lightDir, in vec3 viewDir, in float atten ) { + vec3 h; + float diff; + float nh; + float spec; + vec4 c; + h = normalize( (lightDir + viewDir) ); + diff = max( 0.000000, dot( s.Normal, lightDir)); + nh = max( 0.000000, dot( s.Normal, h)); + spec = (pow( nh, (s.Specular * 128.000)) * s.Gloss); + c.xyz = ((((s.Albedo * _LightColor0.xyz ) * diff) + ((_LightColor0.xyz * _SpecColor.xyz ) * spec)) * (atten * 2.00000)); + c.w = (s.Alpha + (((_LightColor0.w * _SpecColor.w ) * spec) * atten)); + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec3 lightDir; + vec4 c; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + surfIN.uv_BumpMap = IN.hip_pack0.zw ; + surfIN.viewDir = IN.viewDir; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + surf( surfIN, o); + lightDir = IN.lightDir; + lightDir = normalize( lightDir ); + c = LightingBlinnPhong( o, lightDir, normalize( vec3( IN.viewDir) ), texture2D( _LightTexture0, vec2( vec2( dot( IN._LightCoord, IN._LightCoord)))).w ); + c.w = 0.000000; + return c; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec4( gl_TexCoord[0]); + xlt_IN.viewDir = vec3( gl_TexCoord[1]); + xlt_IN.lightDir = vec3( gl_TexCoord[2]); + xlt_IN._LightCoord = vec3( gl_TexCoord[3]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Parallax_Specular-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Parallax_Specular-ir.txt new file mode 100644 index 000000000..d3cb3f1f1 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Parallax_Specular-ir.txt @@ -0,0 +1,290 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; + vec3 worldRefl; + vec3 viewDir; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 viewDir; + vec3 lightDir; + vec3 _LightCoord; +}; +varying vec4 xlv_FOG; +uniform vec4 _SpecColor; +uniform float _Shininess; +uniform vec4 _ReflectColor; +uniform sampler2D _ParallaxMap; +uniform float _Parallax; +uniform sampler2D _MainTex; +uniform sampler2D _LightTexture0; +uniform vec4 _LightColor0; +uniform samplerCube _Cube; +uniform vec4 _Color; +uniform sampler2D _BumpMap; +vec4 UnpackNormal ( + in vec4 packednormal +) +{ + vec4 normal; + vec2 tmpvar_1; + tmpvar_1 = ((packednormal.wy * 2.0) - 1.0); + normal.xy = tmpvar_1.xy.xy; + float tmpvar_2; + tmpvar_2 = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + normal.z = vec3(tmpvar_3).z; + return normal; +} + +vec2 ParallaxOffset ( + in float h, + in float height, + in vec3 viewDir +) +{ + vec3 v; + float tmpvar_1; + tmpvar_1 = ((h * height) - (height / 2.0)); + h = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = normalize (viewDir); + vec3 tmpvar_3; + tmpvar_3 = tmpvar_2; + v = tmpvar_3; + float tmpvar_4; + tmpvar_4 = (v.z + 0.42); + v.z = vec3(tmpvar_4).z; + return (h * (v.xy / v.z)); +} + +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 reflcol; + vec3 worldRefl; + vec4 tex; + vec2 offset; + float h; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_ParallaxMap, IN.uv_BumpMap); + float tmpvar_2; + tmpvar_2 = tmpvar_1.w; + h = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = ParallaxOffset (h, _Parallax, IN.viewDir); + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + offset = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5 = (IN.uv_MainTex + offset); + IN.uv_MainTex = tmpvar_5; + vec2 tmpvar_6; + tmpvar_6 = (IN.uv_BumpMap + offset); + IN.uv_BumpMap = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + tex = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = (tex.xyz * _Color.xyz); + o.Albedo = tmpvar_9; + float tmpvar_10; + tmpvar_10 = tex.w; + o.Gloss = tmpvar_10; + float tmpvar_11; + tmpvar_11 = _Shininess; + o.Specular = tmpvar_11; + vec4 tmpvar_12; + tmpvar_12 = texture2D (_BumpMap, IN.uv_BumpMap); + vec4 tmpvar_13; + tmpvar_13 = UnpackNormal (tmpvar_12); + vec3 tmpvar_14; + tmpvar_14 = tmpvar_13.xyz; + vec3 tmpvar_15; + tmpvar_15 = tmpvar_14; + o.Normal = tmpvar_15; + vec3 tmpvar_16; + tmpvar_16 = IN.worldRefl; + worldRefl = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17 = textureCube (_Cube, worldRefl); + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + reflcol = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19 = (reflcol * tex.w); + reflcol = tmpvar_19; + vec3 tmpvar_20; + tmpvar_20 = (reflcol.xyz * _ReflectColor.xyz); + o.Emission = tmpvar_20; + float tmpvar_21; + tmpvar_21 = (reflcol.w * _ReflectColor.w); + o.Alpha = tmpvar_21; +} + +vec4 LightingBlinnPhong ( + in SurfaceOutput s, + in vec3 lightDir, + in vec3 viewDir, + in float atten +) +{ + vec4 c; + float spec; + float nh; + float diff; + vec3 h; + vec3 tmpvar_1; + tmpvar_1 = normalize ((lightDir + viewDir)); + vec3 tmpvar_2; + tmpvar_2 = tmpvar_1; + h = tmpvar_2; + float tmpvar_3; + tmpvar_3 = dot (s.Normal, lightDir); + float tmpvar_4; + tmpvar_4 = max (0.0, tmpvar_3); + float tmpvar_5; + tmpvar_5 = tmpvar_4; + diff = tmpvar_5; + float tmpvar_6; + tmpvar_6 = dot (s.Normal, h); + float tmpvar_7; + tmpvar_7 = max (0.0, tmpvar_6); + float tmpvar_8; + tmpvar_8 = tmpvar_7; + nh = tmpvar_8; + float tmpvar_9; + tmpvar_9 = pow (nh, (s.Specular * 128.0)); + float tmpvar_10; + tmpvar_10 = (tmpvar_9 * s.Gloss); + spec = tmpvar_10; + vec3 tmpvar_11; + tmpvar_11 = ((((s.Albedo * _LightColor0.xyz) * diff) + ((_LightColor0.xyz * _SpecColor.xyz) * spec)) * (atten * 2.0)); + c.xyz = tmpvar_11.xyz.xyz; + float tmpvar_12; + tmpvar_12 = (s.Alpha + (((_LightColor0.w * _SpecColor.w) * spec) * atten)); + c.w = vec4(tmpvar_12).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 c; + vec3 lightDir; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = IN.hip_pack0.zw; + surfIN.uv_BumpMap = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = IN.viewDir; + surfIN.viewDir = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Specular = tmpvar_6; + float tmpvar_7; + tmpvar_7 = 0.0; + o.Alpha = tmpvar_7; + float tmpvar_8; + tmpvar_8 = 0.0; + o.Gloss = tmpvar_8; + surf (surfIN, o); + vec3 tmpvar_9; + tmpvar_9 = IN.lightDir; + lightDir = tmpvar_9; + vec3 tmpvar_10; + tmpvar_10 = normalize (lightDir); + vec3 tmpvar_11; + tmpvar_11 = tmpvar_10; + lightDir = tmpvar_11; + vec3 tmpvar_12; + tmpvar_12 = IN.viewDir.xyz; + vec3 tmpvar_13; + tmpvar_13 = normalize (tmpvar_12); + float tmpvar_14; + tmpvar_14 = dot (IN._LightCoord, IN._LightCoord); + vec2 tmpvar_15; + tmpvar_15 = vec2(tmpvar_14); + vec2 tmpvar_16; + tmpvar_16 = tmpvar_15.xy; + vec4 tmpvar_17; + tmpvar_17 = texture2D (_LightTexture0, tmpvar_16); + vec4 tmpvar_18; + tmpvar_18 = LightingBlinnPhong (o, lightDir, tmpvar_13, tmpvar_17.w); + vec4 tmpvar_19; + tmpvar_19 = tmpvar_18; + c = tmpvar_19; + float tmpvar_20; + tmpvar_20 = 0.0; + c.w = vec4(tmpvar_20).w; + return c; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.viewDir = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.lightDir = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = gl_TexCoord[3].xyz; + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_IN._LightCoord = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = frag_surf (xlt_IN); + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xl_retval = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = xl_retval.xyzw; + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + gl_FragData[0] = tmpvar_14; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Parallax_Specular-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Parallax_Specular-out.txt new file mode 100644 index 000000000..ff383f115 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Parallax_Specular-out.txt @@ -0,0 +1,49 @@ +uniform vec4 _SpecColor; +uniform float _Shininess; +uniform vec4 _ReflectColor; +uniform sampler2D _ParallaxMap; +uniform float _Parallax; +uniform sampler2D _MainTex; +uniform sampler2D _LightTexture0; +uniform vec4 _LightColor0; +uniform samplerCube _Cube; +uniform vec4 _Color; +uniform sampler2D _BumpMap; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = gl_TexCoord[0]; + vec3 tmpvar_2; + tmpvar_2 = gl_TexCoord[1].xyz; + vec3 tmpvar_3; + tmpvar_3 = gl_TexCoord[3].xyz; + vec4 c; + vec3 tmpvar_4; + vec2 tmpvar_5; + vec3 v; + vec3 tmpvar_6; + tmpvar_6 = normalize (tmpvar_2); + v = tmpvar_6; + v.z = (tmpvar_6.z + 0.42); + tmpvar_5 = (((texture2D (_ParallaxMap, tmpvar_1.zw).w * _Parallax) - (_Parallax / 2.0)) * (tmpvar_6.xy / v.z)); + vec4 tmpvar_7; + tmpvar_7 = texture2D (_MainTex, (tmpvar_1.xy + tmpvar_5)); + vec4 normal; + normal.xy = ((texture2D (_BumpMap, (tmpvar_1.zw + tmpvar_5)).wy * 2.0) - 1.0); + normal.z = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + vec3 tmpvar_8; + tmpvar_8 = normal.xyz; + vec3 tmpvar_9; + tmpvar_9 = normalize (gl_TexCoord[2].xyz); + vec4 tmpvar_10; + tmpvar_10 = texture2D (_LightTexture0, vec2(dot (tmpvar_3, tmpvar_3))); + vec4 c_i0; + float tmpvar_11; + tmpvar_11 = (pow (max (0.0, dot (tmpvar_8, normalize ((tmpvar_9 + normalize (tmpvar_2))))), (_Shininess * 128.0)) * tmpvar_7.w); + c_i0.xyz = (((((tmpvar_7.xyz * _Color.xyz) * _LightColor0.xyz) * max (0.0, dot (tmpvar_8, tmpvar_9))) + ((_LightColor0.xyz * _SpecColor.xyz) * tmpvar_11)) * (tmpvar_10.w * 2.0)); + c_i0.w = (((textureCube (_Cube, tmpvar_4) * tmpvar_7.w).w * _ReflectColor.w) + (((_LightColor0.w * _SpecColor.w) * tmpvar_11) * tmpvar_10.w)); + c = c_i0; + c.w = 0.0; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Parallax_Specular1-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Parallax_Specular1-in.txt new file mode 100644 index 000000000..9c49e608a --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Parallax_Specular1-in.txt @@ -0,0 +1,139 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; + vec3 worldRefl; + vec3 viewDir; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 viewDir; + vec3 lightDir; + vec2 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform sampler2D _BumpMap; +uniform vec4 _Color; +uniform samplerCube _Cube; +uniform vec4 _LightColor0; +uniform sampler2D _LightTexture0; +uniform sampler2D _MainTex; +uniform float _Parallax; +uniform sampler2D _ParallaxMap; +uniform vec4 _ReflectColor; +uniform float _Shininess; +uniform vec4 _SpecColor; +vec4 UnpackNormal( in vec4 packednormal ); +vec2 ParallaxOffset( in float h, in float height, in vec3 viewDir ); +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingBlinnPhong( in SurfaceOutput s, in vec3 lightDir, in vec3 viewDir, in float atten ); +vec4 frag_surf( in v2f_surf IN ); +vec4 UnpackNormal( in vec4 packednormal ) { + vec4 normal; + normal.xy = ((packednormal.wy * 2.00000) - 1.00000); + normal.z = sqrt( ((1.00000 - (normal.x * normal.x )) - (normal.y * normal.y )) ); + return normal; +} +vec2 ParallaxOffset( in float h, in float height, in vec3 viewDir ) { + vec3 v; + h = ((h * height) - (height / 2.00000)); + v = normalize( viewDir ); + v.z += 0.420000; + return (h * (v.xy / v.z )); +} +void surf( in Input IN, inout SurfaceOutput o ) { + float h; + vec2 offset; + vec4 tex; + vec3 worldRefl; + vec4 reflcol; + h = texture2D( _ParallaxMap, IN.uv_BumpMap).w ; + offset = ParallaxOffset( h, _Parallax, IN.viewDir); + IN.uv_MainTex += offset; + IN.uv_BumpMap += offset; + tex = texture2D( _MainTex, IN.uv_MainTex); + o.Albedo = (tex.xyz * _Color.xyz ); + o.Gloss = tex.w ; + o.Specular = _Shininess; + o.Normal = vec3( UnpackNormal( texture2D( _BumpMap, IN.uv_BumpMap))); + worldRefl = IN.worldRefl; + reflcol = textureCube( _Cube, worldRefl); + reflcol *= tex.w ; + o.Emission = (reflcol.xyz * _ReflectColor.xyz ); + o.Alpha = (reflcol.w * _ReflectColor.w ); +} +vec4 LightingBlinnPhong( in SurfaceOutput s, in vec3 lightDir, in vec3 viewDir, in float atten ) { + vec3 h; + float diff; + float nh; + float spec; + vec4 c; + h = normalize( (lightDir + viewDir) ); + diff = max( 0.000000, dot( s.Normal, lightDir)); + nh = max( 0.000000, dot( s.Normal, h)); + spec = (pow( nh, (s.Specular * 128.000)) * s.Gloss); + c.xyz = ((((s.Albedo * _LightColor0.xyz ) * diff) + ((_LightColor0.xyz * _SpecColor.xyz ) * spec)) * (atten * 2.00000)); + c.w = (s.Alpha + (((_LightColor0.w * _SpecColor.w ) * spec) * atten)); + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec3 lightDir; + vec4 c; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + surfIN.uv_BumpMap = IN.hip_pack0.zw ; + surfIN.viewDir = IN.viewDir; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + surf( surfIN, o); + lightDir = IN.lightDir; + c = LightingBlinnPhong( o, lightDir, normalize( vec3( IN.viewDir) ), (texture2D( _LightTexture0, IN._LightCoord).w * 1.00000)); + c.w = 0.000000; + return c; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec4( gl_TexCoord[0]); + xlt_IN.viewDir = vec3( gl_TexCoord[1]); + xlt_IN.lightDir = vec3( gl_TexCoord[2]); + xlt_IN._LightCoord = vec2( gl_TexCoord[3]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Parallax_Specular1-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Parallax_Specular1-ir.txt new file mode 100644 index 000000000..02f16f204 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Parallax_Specular1-ir.txt @@ -0,0 +1,279 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; + vec3 worldRefl; + vec3 viewDir; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 viewDir; + vec3 lightDir; + vec2 _LightCoord; +}; +varying vec4 xlv_FOG; +uniform vec4 _SpecColor; +uniform float _Shininess; +uniform vec4 _ReflectColor; +uniform sampler2D _ParallaxMap; +uniform float _Parallax; +uniform sampler2D _MainTex; +uniform sampler2D _LightTexture0; +uniform vec4 _LightColor0; +uniform samplerCube _Cube; +uniform vec4 _Color; +uniform sampler2D _BumpMap; +vec4 UnpackNormal ( + in vec4 packednormal +) +{ + vec4 normal; + vec2 tmpvar_1; + tmpvar_1 = ((packednormal.wy * 2.0) - 1.0); + normal.xy = tmpvar_1.xy.xy; + float tmpvar_2; + tmpvar_2 = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + normal.z = vec3(tmpvar_3).z; + return normal; +} + +vec2 ParallaxOffset ( + in float h, + in float height, + in vec3 viewDir +) +{ + vec3 v; + float tmpvar_1; + tmpvar_1 = ((h * height) - (height / 2.0)); + h = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = normalize (viewDir); + vec3 tmpvar_3; + tmpvar_3 = tmpvar_2; + v = tmpvar_3; + float tmpvar_4; + tmpvar_4 = (v.z + 0.42); + v.z = vec3(tmpvar_4).z; + return (h * (v.xy / v.z)); +} + +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 reflcol; + vec3 worldRefl; + vec4 tex; + vec2 offset; + float h; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_ParallaxMap, IN.uv_BumpMap); + float tmpvar_2; + tmpvar_2 = tmpvar_1.w; + h = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = ParallaxOffset (h, _Parallax, IN.viewDir); + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + offset = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5 = (IN.uv_MainTex + offset); + IN.uv_MainTex = tmpvar_5; + vec2 tmpvar_6; + tmpvar_6 = (IN.uv_BumpMap + offset); + IN.uv_BumpMap = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + tex = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = (tex.xyz * _Color.xyz); + o.Albedo = tmpvar_9; + float tmpvar_10; + tmpvar_10 = tex.w; + o.Gloss = tmpvar_10; + float tmpvar_11; + tmpvar_11 = _Shininess; + o.Specular = tmpvar_11; + vec4 tmpvar_12; + tmpvar_12 = texture2D (_BumpMap, IN.uv_BumpMap); + vec4 tmpvar_13; + tmpvar_13 = UnpackNormal (tmpvar_12); + vec3 tmpvar_14; + tmpvar_14 = tmpvar_13.xyz; + vec3 tmpvar_15; + tmpvar_15 = tmpvar_14; + o.Normal = tmpvar_15; + vec3 tmpvar_16; + tmpvar_16 = IN.worldRefl; + worldRefl = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17 = textureCube (_Cube, worldRefl); + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + reflcol = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19 = (reflcol * tex.w); + reflcol = tmpvar_19; + vec3 tmpvar_20; + tmpvar_20 = (reflcol.xyz * _ReflectColor.xyz); + o.Emission = tmpvar_20; + float tmpvar_21; + tmpvar_21 = (reflcol.w * _ReflectColor.w); + o.Alpha = tmpvar_21; +} + +vec4 LightingBlinnPhong ( + in SurfaceOutput s, + in vec3 lightDir, + in vec3 viewDir, + in float atten +) +{ + vec4 c; + float spec; + float nh; + float diff; + vec3 h; + vec3 tmpvar_1; + tmpvar_1 = normalize ((lightDir + viewDir)); + vec3 tmpvar_2; + tmpvar_2 = tmpvar_1; + h = tmpvar_2; + float tmpvar_3; + tmpvar_3 = dot (s.Normal, lightDir); + float tmpvar_4; + tmpvar_4 = max (0.0, tmpvar_3); + float tmpvar_5; + tmpvar_5 = tmpvar_4; + diff = tmpvar_5; + float tmpvar_6; + tmpvar_6 = dot (s.Normal, h); + float tmpvar_7; + tmpvar_7 = max (0.0, tmpvar_6); + float tmpvar_8; + tmpvar_8 = tmpvar_7; + nh = tmpvar_8; + float tmpvar_9; + tmpvar_9 = pow (nh, (s.Specular * 128.0)); + float tmpvar_10; + tmpvar_10 = (tmpvar_9 * s.Gloss); + spec = tmpvar_10; + vec3 tmpvar_11; + tmpvar_11 = ((((s.Albedo * _LightColor0.xyz) * diff) + ((_LightColor0.xyz * _SpecColor.xyz) * spec)) * (atten * 2.0)); + c.xyz = tmpvar_11.xyz.xyz; + float tmpvar_12; + tmpvar_12 = (s.Alpha + (((_LightColor0.w * _SpecColor.w) * spec) * atten)); + c.w = vec4(tmpvar_12).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 c; + vec3 lightDir; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = IN.hip_pack0.zw; + surfIN.uv_BumpMap = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = IN.viewDir; + surfIN.viewDir = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Specular = tmpvar_6; + float tmpvar_7; + tmpvar_7 = 0.0; + o.Alpha = tmpvar_7; + float tmpvar_8; + tmpvar_8 = 0.0; + o.Gloss = tmpvar_8; + surf (surfIN, o); + vec3 tmpvar_9; + tmpvar_9 = IN.lightDir; + lightDir = tmpvar_9; + vec3 tmpvar_10; + tmpvar_10 = IN.viewDir.xyz; + vec3 tmpvar_11; + tmpvar_11 = normalize (tmpvar_10); + vec4 tmpvar_12; + tmpvar_12 = texture2D (_LightTexture0, IN._LightCoord); + vec4 tmpvar_13; + tmpvar_13 = LightingBlinnPhong (o, lightDir, tmpvar_11, (tmpvar_12.w * 1.0)); + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + c = tmpvar_14; + float tmpvar_15; + tmpvar_15 = 0.0; + c.w = vec4(tmpvar_15).w; + return c; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.viewDir = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.lightDir = tmpvar_8; + vec2 tmpvar_9; + tmpvar_9 = gl_TexCoord[3].xy; + vec2 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_IN._LightCoord = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = frag_surf (xlt_IN); + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xl_retval = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = xl_retval.xyzw; + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + gl_FragData[0] = tmpvar_14; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Parallax_Specular1-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Parallax_Specular1-out.txt new file mode 100644 index 000000000..69b0f78a5 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Parallax_Specular1-out.txt @@ -0,0 +1,47 @@ +uniform vec4 _SpecColor; +uniform float _Shininess; +uniform vec4 _ReflectColor; +uniform sampler2D _ParallaxMap; +uniform float _Parallax; +uniform sampler2D _MainTex; +uniform sampler2D _LightTexture0; +uniform vec4 _LightColor0; +uniform samplerCube _Cube; +uniform vec4 _Color; +uniform sampler2D _BumpMap; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = gl_TexCoord[0]; + vec3 tmpvar_2; + tmpvar_2 = gl_TexCoord[1].xyz; + vec3 tmpvar_3; + tmpvar_3 = gl_TexCoord[2].xyz; + vec4 c; + vec3 tmpvar_4; + vec2 tmpvar_5; + vec3 v; + vec3 tmpvar_6; + tmpvar_6 = normalize (tmpvar_2); + v = tmpvar_6; + v.z = (tmpvar_6.z + 0.42); + tmpvar_5 = (((texture2D (_ParallaxMap, tmpvar_1.zw).w * _Parallax) - (_Parallax / 2.0)) * (tmpvar_6.xy / v.z)); + vec4 tmpvar_7; + tmpvar_7 = texture2D (_MainTex, (tmpvar_1.xy + tmpvar_5)); + vec4 normal; + normal.xy = ((texture2D (_BumpMap, (tmpvar_1.zw + tmpvar_5)).wy * 2.0) - 1.0); + normal.z = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + vec3 tmpvar_8; + tmpvar_8 = normal.xyz; + float atten; + atten = texture2D (_LightTexture0, gl_TexCoord[3].xy).w; + vec4 c_i0; + float tmpvar_9; + tmpvar_9 = (pow (max (0.0, dot (tmpvar_8, normalize ((tmpvar_3 + normalize (tmpvar_2))))), (_Shininess * 128.0)) * tmpvar_7.w); + c_i0.xyz = (((((tmpvar_7.xyz * _Color.xyz) * _LightColor0.xyz) * max (0.0, dot (tmpvar_8, tmpvar_3))) + ((_LightColor0.xyz * _SpecColor.xyz) * tmpvar_9)) * (atten * 2.0)); + c_i0.w = (((textureCube (_Cube, tmpvar_4) * tmpvar_7.w).w * _ReflectColor.w) + (((_LightColor0.w * _SpecColor.w) * tmpvar_9) * atten)); + c = c_i0; + c.w = 0.0; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Specular-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Specular-in.txt new file mode 100644 index 000000000..395bcebc5 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Specular-in.txt @@ -0,0 +1,123 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec3 worldRefl; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 normal; + vec3 lightDir; + vec3 viewDir; + vec4 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _Color; +uniform samplerCube _Cube; +uniform vec4 _LightColor0; +uniform sampler2D _LightTexture0; +uniform sampler2D _LightTextureB0; +uniform sampler2D _MainTex; +uniform vec4 _ReflectColor; +uniform float _Shininess; +uniform vec4 _SpecColor; +void surf( in Input IN, inout SurfaceOutput o ); +float UnitySpotCookie( in vec4 LightCoord ); +float UnitySpotAttenuate( in vec3 LightCoord ); +vec4 LightingBlinnPhong( in SurfaceOutput s, in vec3 lightDir, in vec3 viewDir, in float atten ); +vec4 frag_surf( in v2f_surf IN ); +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 tex; + vec4 c; + vec4 reflcol; + tex = texture2D( _MainTex, IN.uv_MainTex); + c = (tex * _Color); + o.Albedo = c.xyz ; + o.Gloss = tex.w ; + o.Specular = _Shininess; + reflcol = textureCube( _Cube, IN.worldRefl); + reflcol *= tex.w ; + o.Emission = (reflcol.xyz * _ReflectColor.xyz ); + o.Alpha = (reflcol.w * _ReflectColor.w ); +} +float UnitySpotCookie( in vec4 LightCoord ) { + return texture2D( _LightTexture0, ((LightCoord.xy / LightCoord.w ) + 0.500000)).w ; +} +float UnitySpotAttenuate( in vec3 LightCoord ) { + return texture2D( _LightTextureB0, vec2( vec2( dot( LightCoord, LightCoord)))).w ; +} +vec4 LightingBlinnPhong( in SurfaceOutput s, in vec3 lightDir, in vec3 viewDir, in float atten ) { + vec3 h; + float diff; + float nh; + float spec; + vec4 c; + h = normalize( (lightDir + viewDir) ); + diff = max( 0.000000, dot( s.Normal, lightDir)); + nh = max( 0.000000, dot( s.Normal, h)); + spec = (pow( nh, (s.Specular * 128.000)) * s.Gloss); + c.xyz = ((((s.Albedo * _LightColor0.xyz ) * diff) + ((_LightColor0.xyz * _SpecColor.xyz ) * spec)) * (atten * 2.00000)); + c.w = (s.Alpha + (((_LightColor0.w * _SpecColor.w ) * spec) * atten)); + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec3 lightDir; + vec4 c; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + o.Normal = IN.normal; + surf( surfIN, o); + lightDir = IN.lightDir; + lightDir = normalize( lightDir ); + c = LightingBlinnPhong( o, lightDir, normalize( vec3( IN.viewDir) ), ((float( (IN._LightCoord.z > 0.000000) ) * UnitySpotCookie( IN._LightCoord)) * UnitySpotAttenuate( IN._LightCoord.xyz ))); + c.w = 0.000000; + return c; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec2( gl_TexCoord[0]); + xlt_IN.normal = vec3( gl_TexCoord[1]); + xlt_IN.lightDir = vec3( gl_TexCoord[2]); + xlt_IN.viewDir = vec3( gl_TexCoord[3]); + xlt_IN._LightCoord = vec4( gl_TexCoord[4]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Specular-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Specular-ir.txt new file mode 100644 index 000000000..761b14dc5 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Specular-ir.txt @@ -0,0 +1,245 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec3 worldRefl; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 normal; + vec3 lightDir; + vec3 viewDir; + vec4 _LightCoord; +}; +varying vec4 xlv_FOG; +uniform vec4 _SpecColor; +uniform float _Shininess; +uniform vec4 _ReflectColor; +uniform sampler2D _MainTex; +uniform sampler2D _LightTextureB0; +uniform sampler2D _LightTexture0; +uniform vec4 _LightColor0; +uniform samplerCube _Cube; +uniform vec4 _Color; +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 reflcol; + vec4 c; + vec4 tex; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + tex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = (tex * _Color); + c = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = c.xyz; + o.Albedo = tmpvar_4; + float tmpvar_5; + tmpvar_5 = tex.w; + o.Gloss = tmpvar_5; + float tmpvar_6; + tmpvar_6 = _Shininess; + o.Specular = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = textureCube (_Cube, IN.worldRefl); + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + reflcol = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = (reflcol * tex.w); + reflcol = tmpvar_9; + vec3 tmpvar_10; + tmpvar_10 = (reflcol.xyz * _ReflectColor.xyz); + o.Emission = tmpvar_10; + float tmpvar_11; + tmpvar_11 = (reflcol.w * _ReflectColor.w); + o.Alpha = tmpvar_11; +} + +float UnitySpotCookie ( + in vec4 LightCoord +) +{ + vec4 tmpvar_1; + tmpvar_1 = texture2D (_LightTexture0, ((LightCoord.xy / LightCoord.w) + 0.5)); + return tmpvar_1.w; +} + +float UnitySpotAttenuate ( + in vec3 LightCoord +) +{ + float tmpvar_1; + tmpvar_1 = dot (LightCoord, LightCoord); + vec2 tmpvar_2; + tmpvar_2 = vec2(tmpvar_1); + vec2 tmpvar_3; + tmpvar_3 = tmpvar_2.xy; + vec4 tmpvar_4; + tmpvar_4 = texture2D (_LightTextureB0, tmpvar_3); + return tmpvar_4.w; +} + +vec4 LightingBlinnPhong ( + in SurfaceOutput s, + in vec3 lightDir, + in vec3 viewDir, + in float atten +) +{ + vec4 c; + float spec; + float nh; + float diff; + vec3 h; + vec3 tmpvar_1; + tmpvar_1 = normalize ((lightDir + viewDir)); + vec3 tmpvar_2; + tmpvar_2 = tmpvar_1; + h = tmpvar_2; + float tmpvar_3; + tmpvar_3 = dot (s.Normal, lightDir); + float tmpvar_4; + tmpvar_4 = max (0.0, tmpvar_3); + float tmpvar_5; + tmpvar_5 = tmpvar_4; + diff = tmpvar_5; + float tmpvar_6; + tmpvar_6 = dot (s.Normal, h); + float tmpvar_7; + tmpvar_7 = max (0.0, tmpvar_6); + float tmpvar_8; + tmpvar_8 = tmpvar_7; + nh = tmpvar_8; + float tmpvar_9; + tmpvar_9 = pow (nh, (s.Specular * 128.0)); + float tmpvar_10; + tmpvar_10 = (tmpvar_9 * s.Gloss); + spec = tmpvar_10; + vec3 tmpvar_11; + tmpvar_11 = ((((s.Albedo * _LightColor0.xyz) * diff) + ((_LightColor0.xyz * _SpecColor.xyz) * spec)) * (atten * 2.0)); + c.xyz = tmpvar_11.xyz.xyz; + float tmpvar_12; + tmpvar_12 = (s.Alpha + (((_LightColor0.w * _SpecColor.w) * spec) * atten)); + c.w = vec4(tmpvar_12).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 c; + vec3 lightDir; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_3; + float tmpvar_4; + tmpvar_4 = 0.0; + o.Specular = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Alpha = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Gloss = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = IN.normal; + o.Normal = tmpvar_7; + surf (surfIN, o); + vec3 tmpvar_8; + tmpvar_8 = IN.lightDir; + lightDir = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = normalize (lightDir); + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + lightDir = tmpvar_10; + vec3 tmpvar_11; + tmpvar_11 = IN.viewDir.xyz; + vec3 tmpvar_12; + tmpvar_12 = normalize (tmpvar_11); + float tmpvar_13; + tmpvar_13 = UnitySpotCookie (IN._LightCoord); + float tmpvar_14; + tmpvar_14 = UnitySpotAttenuate (IN._LightCoord.xyz); + vec4 tmpvar_15; + tmpvar_15 = LightingBlinnPhong (o, lightDir, tmpvar_12, ((float((IN._LightCoord.z > 0.0)) * tmpvar_13) * tmpvar_14)); + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + c = tmpvar_16; + float tmpvar_17; + tmpvar_17 = 0.0; + c.w = vec4(tmpvar_17).w; + return c; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xy; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.normal = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.lightDir = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = gl_TexCoord[3].xyz; + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_IN.viewDir = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_TexCoord[4].xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_IN._LightCoord = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = frag_surf (xlt_IN); + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_FragData[0] = tmpvar_16; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Specular-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Specular-out.txt new file mode 100644 index 000000000..3d27c29a4 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Specular-out.txt @@ -0,0 +1,35 @@ +uniform vec4 _SpecColor; +uniform float _Shininess; +uniform vec4 _ReflectColor; +uniform sampler2D _MainTex; +uniform sampler2D _LightTextureB0; +uniform sampler2D _LightTexture0; +uniform vec4 _LightColor0; +uniform samplerCube _Cube; +uniform vec4 _Color; +void main () +{ + vec3 tmpvar_1; + tmpvar_1 = gl_TexCoord[1].xyz; + vec4 tmpvar_2; + tmpvar_2 = gl_TexCoord[4]; + vec4 c; + vec3 tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = texture2D (_MainTex, gl_TexCoord[0].xy); + vec3 tmpvar_5; + tmpvar_5 = normalize (gl_TexCoord[2].xyz); + vec3 LightCoord_i0; + LightCoord_i0 = tmpvar_2.xyz; + float atten; + atten = ((float((tmpvar_2.z > 0.0)) * texture2D (_LightTexture0, ((tmpvar_2.xy / tmpvar_2.w) + 0.5)).w) * texture2D (_LightTextureB0, vec2(dot (LightCoord_i0, LightCoord_i0))).w); + vec4 c_i0_i1; + float tmpvar_6; + tmpvar_6 = (pow (max (0.0, dot (tmpvar_1, normalize ((tmpvar_5 + normalize (gl_TexCoord[3].xyz))))), (_Shininess * 128.0)) * tmpvar_4.w); + c_i0_i1.xyz = (((((tmpvar_4 * _Color).xyz * _LightColor0.xyz) * max (0.0, dot (tmpvar_1, tmpvar_5))) + ((_LightColor0.xyz * _SpecColor.xyz) * tmpvar_6)) * (atten * 2.0)); + c_i0_i1.w = (((textureCube (_Cube, tmpvar_3) * tmpvar_4.w).w * _ReflectColor.w) + (((_LightColor0.w * _SpecColor.w) * tmpvar_6) * atten)); + c = c_i0_i1; + c.w = 0.0; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Specular1-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Specular1-in.txt new file mode 100644 index 000000000..e60633693 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Specular1-in.txt @@ -0,0 +1,81 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec3 worldRefl; +}; +struct v2f_surf { + vec4 pos; + vec3 normal; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _Color; +uniform samplerCube _Cube; +uniform sampler2D _MainTex; +uniform vec4 _ReflectColor; +uniform float _Shininess; +void surf( in Input IN, inout SurfaceOutput o ); +vec4 frag_surf( in v2f_surf IN ); +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 tex; + vec4 c; + vec4 reflcol; + tex = texture2D( _MainTex, IN.uv_MainTex); + c = (tex * _Color); + o.Albedo = c.xyz ; + o.Gloss = tex.w ; + o.Specular = _Shininess; + reflcol = textureCube( _Cube, IN.worldRefl); + reflcol *= tex.w ; + o.Emission = (reflcol.xyz * _ReflectColor.xyz ); + o.Alpha = (reflcol.w * _ReflectColor.w ); +} +vec4 frag_surf( in v2f_surf IN ) { + SurfaceOutput o; + Input surfIN; + vec4 res; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + o.Normal = IN.normal; + surf( surfIN, o); + res.xyz = ((o.Normal * vec3( 0.500000, 0.500000, -0.500000)) + 0.500000); + res.w = o.Specular; + return res; +} +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.normal = vec3( gl_TexCoord[0]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Specular1-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Specular1-ir.txt new file mode 100644 index 000000000..b5d6b75b9 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Specular1-ir.txt @@ -0,0 +1,121 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec3 worldRefl; +}; +struct v2f_surf { + vec4 pos; + vec3 normal; +}; +uniform float _Shininess; +uniform vec4 _ReflectColor; +uniform sampler2D _MainTex; +uniform samplerCube _Cube; +uniform vec4 _Color; +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 reflcol; + vec4 c; + vec4 tex; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + tex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = (tex * _Color); + c = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = c.xyz; + o.Albedo = tmpvar_4; + float tmpvar_5; + tmpvar_5 = tex.w; + o.Gloss = tmpvar_5; + float tmpvar_6; + tmpvar_6 = _Shininess; + o.Specular = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = textureCube (_Cube, IN.worldRefl); + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + reflcol = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = (reflcol * tex.w); + reflcol = tmpvar_9; + vec3 tmpvar_10; + tmpvar_10 = (reflcol.xyz * _ReflectColor.xyz); + o.Emission = tmpvar_10; + float tmpvar_11; + tmpvar_11 = (reflcol.w * _ReflectColor.w); + o.Alpha = tmpvar_11; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 res; + Input surfIN; + SurfaceOutput o; + vec3 tmpvar_1; + tmpvar_1 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_2; + float tmpvar_3; + tmpvar_3 = 0.0; + o.Specular = tmpvar_3; + float tmpvar_4; + tmpvar_4 = 0.0; + o.Alpha = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Gloss = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = IN.normal; + o.Normal = tmpvar_6; + surf (surfIN, o); + vec3 tmpvar_7; + tmpvar_7 = ((o.Normal * vec3(0.5, 0.5, -0.5)) + 0.5); + res.xyz = tmpvar_7.xyz.xyz; + float tmpvar_8; + tmpvar_8 = o.Specular; + res.w = vec4(tmpvar_8).w; + return res; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = gl_TexCoord[0].xyz; + vec3 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_IN.normal = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = frag_surf (xlt_IN); + vec4 tmpvar_5; + tmpvar_5 = tmpvar_4; + xl_retval = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = xl_retval.xyzw; + vec4 tmpvar_7; + tmpvar_7 = tmpvar_6; + gl_FragData[0] = tmpvar_7; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Specular1-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Specular1-out.txt new file mode 100644 index 000000000..73b819c9d --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Specular1-out.txt @@ -0,0 +1,9 @@ +uniform float _Shininess; +void main () +{ + vec4 res; + res.xyz = ((gl_TexCoord[0].xyz * vec3(0.5, 0.5, -0.5)) + 0.5); + res.w = _Shininess; + gl_FragData[0] = res; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Specular2-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Specular2-in.txt new file mode 100644 index 000000000..6e4d5d03e --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Specular2-in.txt @@ -0,0 +1,105 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec3 worldRefl; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 worldRefl; + vec4 hip_screen; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _Color; +uniform samplerCube _Cube; +uniform sampler2D _LightBuffer; +uniform sampler2D _MainTex; +uniform vec4 _ReflectColor; +uniform float _Shininess; +uniform vec4 _SpecColor; +uniform vec4 unity_Ambient; +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingBlinnPhong_PrePass( in SurfaceOutput s, in vec4 light ); +vec4 frag_surf( in v2f_surf IN ); +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 tex; + vec4 c; + vec4 reflcol; + tex = texture2D( _MainTex, IN.uv_MainTex); + c = (tex * _Color); + o.Albedo = c.xyz ; + o.Gloss = tex.w ; + o.Specular = _Shininess; + reflcol = textureCube( _Cube, IN.worldRefl); + reflcol *= tex.w ; + o.Emission = (reflcol.xyz * _ReflectColor.xyz ); + o.Alpha = (reflcol.w * _ReflectColor.w ); +} +vec4 LightingBlinnPhong_PrePass( in SurfaceOutput s, in vec4 light ) { + float spec; + vec4 c; + spec = (light.w * s.Gloss); + c.xyz = ((s.Albedo * light.xyz ) + ((light.xyz * _SpecColor.xyz ) * spec)); + c.w = (s.Alpha + (spec * _SpecColor.w )); + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec4 light; + vec4 col; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + surfIN.worldRefl = IN.worldRefl; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + surf( surfIN, o); + light = texture2DProj( _LightBuffer, IN.hip_screen); + light = ( -log2( light ) ); + light.xyz += unity_Ambient.xyz ; + col = LightingBlinnPhong_PrePass( o, light); + col.xyz += o.Emission; + return col; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec2( gl_TexCoord[0]); + xlt_IN.worldRefl = vec3( gl_TexCoord[1]); + xlt_IN.hip_screen = vec4( gl_TexCoord[2]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Specular2-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Specular2-ir.txt new file mode 100644 index 000000000..105a2155a --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Specular2-ir.txt @@ -0,0 +1,179 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec3 worldRefl; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 worldRefl; + vec4 hip_screen; +}; +varying vec4 xlv_FOG; +uniform vec4 unity_Ambient; +uniform vec4 _SpecColor; +uniform float _Shininess; +uniform vec4 _ReflectColor; +uniform sampler2D _MainTex; +uniform sampler2D _LightBuffer; +uniform samplerCube _Cube; +uniform vec4 _Color; +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 reflcol; + vec4 c; + vec4 tex; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + tex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = (tex * _Color); + c = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = c.xyz; + o.Albedo = tmpvar_4; + float tmpvar_5; + tmpvar_5 = tex.w; + o.Gloss = tmpvar_5; + float tmpvar_6; + tmpvar_6 = _Shininess; + o.Specular = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = textureCube (_Cube, IN.worldRefl); + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + reflcol = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = (reflcol * tex.w); + reflcol = tmpvar_9; + vec3 tmpvar_10; + tmpvar_10 = (reflcol.xyz * _ReflectColor.xyz); + o.Emission = tmpvar_10; + float tmpvar_11; + tmpvar_11 = (reflcol.w * _ReflectColor.w); + o.Alpha = tmpvar_11; +} + +vec4 LightingBlinnPhong_PrePass ( + in SurfaceOutput s, + in vec4 light +) +{ + vec4 c; + float spec; + float tmpvar_1; + tmpvar_1 = (light.w * s.Gloss); + spec = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = ((s.Albedo * light.xyz) + ((light.xyz * _SpecColor.xyz) * spec)); + c.xyz = tmpvar_2.xyz.xyz; + float tmpvar_3; + tmpvar_3 = (s.Alpha + (spec * _SpecColor.w)); + c.w = vec4(tmpvar_3).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 col; + vec4 light; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = IN.worldRefl; + surfIN.worldRefl = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Specular = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Alpha = tmpvar_6; + float tmpvar_7; + tmpvar_7 = 0.0; + o.Gloss = tmpvar_7; + surf (surfIN, o); + vec4 tmpvar_8; + tmpvar_8 = texture2DProj (_LightBuffer, IN.hip_screen); + vec4 tmpvar_9; + tmpvar_9 = tmpvar_8; + light = tmpvar_9; + vec4 tmpvar_10; + tmpvar_10 = log2 (light); + vec4 tmpvar_11; + tmpvar_11 = -(tmpvar_10); + light = tmpvar_11; + vec3 tmpvar_12; + tmpvar_12 = (light.xyz + unity_Ambient.xyz); + light.xyz = tmpvar_12.xyz.xyz; + vec4 tmpvar_13; + tmpvar_13 = LightingBlinnPhong_PrePass (o, light); + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + col = tmpvar_14; + vec3 tmpvar_15; + tmpvar_15 = (col.xyz + o.Emission); + col.xyz = tmpvar_15.xyz.xyz; + return col; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xy; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.worldRefl = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.hip_screen = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = frag_surf (xlt_IN); + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xl_retval = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = xl_retval.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + gl_FragData[0] = tmpvar_12; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Specular2-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Specular2-out.txt new file mode 100644 index 000000000..e0adfa455 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Reflective_Specular2-out.txt @@ -0,0 +1,29 @@ +uniform vec4 unity_Ambient; +uniform vec4 _SpecColor; +uniform vec4 _ReflectColor; +uniform sampler2D _MainTex; +uniform sampler2D _LightBuffer; +uniform samplerCube _Cube; +uniform vec4 _Color; +void main () +{ + vec4 col; + vec4 light; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, gl_TexCoord[0].xy); + vec4 tmpvar_2; + tmpvar_2 = (textureCube (_Cube, gl_TexCoord[1].xyz) * tmpvar_1.w); + vec4 tmpvar_3; + tmpvar_3 = -(log2 (texture2DProj (_LightBuffer, gl_TexCoord[2]))); + light = tmpvar_3; + light.xyz = (tmpvar_3.xyz + unity_Ambient.xyz); + vec4 c_i0; + float tmpvar_4; + tmpvar_4 = (tmpvar_3.w * tmpvar_1.w); + c_i0.xyz = (((tmpvar_1 * _Color).xyz * light.xyz) + ((light.xyz * _SpecColor.xyz) * tmpvar_4)); + c_i0.w = ((tmpvar_2.w * _ReflectColor.w) + (tmpvar_4 * _SpecColor.w)); + col = c_i0; + col.xyz = (c_i0.xyz + (tmpvar_2.xyz * _ReflectColor.xyz)); + gl_FragData[0] = col; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-RenderFX_Skybox-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-RenderFX_Skybox-in.txt new file mode 100644 index 000000000..8beb53f7e --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-RenderFX_Skybox-in.txt @@ -0,0 +1,44 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct v2f { + vec4 vertex; + vec2 texcoord; +}; +struct appdata_t { + vec4 vertex; + vec2 texcoord; +}; +uniform vec4 _Tint; +uniform sampler2D _UpTex; +vec4 skybox_frag( in v2f i, in sampler2D smp ); +vec4 frag( in v2f i ); +vec4 skybox_frag( in v2f i, in sampler2D smp ) { + vec4 tex; + vec4 col; + tex = texture2D( smp, i.texcoord); + col.xyz = ((tex.xyz + _Tint.xyz ) - 0.500000); + col.w = (tex.w * _Tint.w ); + return col; +} +vec4 frag( in v2f i ) { + return skybox_frag( i, _UpTex); +} +void main() { + vec4 xl_retval; + v2f xlt_i; + xlt_i.vertex = vec4(0.0); + xlt_i.texcoord = vec2( gl_TexCoord[0]); + xl_retval = frag( xlt_i); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-RenderFX_Skybox-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-RenderFX_Skybox-ir.txt new file mode 100644 index 000000000..c959c12f8 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-RenderFX_Skybox-ir.txt @@ -0,0 +1,60 @@ +struct v2f { + vec4 vertex; + vec2 texcoord; +}; +uniform sampler2D _UpTex; +uniform vec4 _Tint; +vec4 skybox_frag ( + in v2f i, + in sampler2D smp +) +{ + vec4 col; + vec4 tex; + vec4 tmpvar_1; + tmpvar_1 = texture2D (smp, i.texcoord); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + tex = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = ((tex.xyz + _Tint.xyz) - 0.5); + col.xyz = tmpvar_3.xyz.xyz; + float tmpvar_4; + tmpvar_4 = (tex.w * _Tint.w); + col.w = vec4(tmpvar_4).w; + return col; +} + +vec4 frag ( + in v2f i +) +{ + vec4 tmpvar_1; + tmpvar_1 = skybox_frag (i, _UpTex); + return tmpvar_1; +} + +void main () +{ + v2f xlt_i; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_i.vertex = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = gl_TexCoord[0].xy; + vec2 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_i.texcoord = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = frag (xlt_i); + vec4 tmpvar_5; + tmpvar_5 = tmpvar_4; + xl_retval = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = xl_retval.xyzw; + vec4 tmpvar_7; + tmpvar_7 = tmpvar_6; + gl_FragData[0] = tmpvar_7; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-RenderFX_Skybox-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-RenderFX_Skybox-out.txt new file mode 100644 index 000000000..306696331 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-RenderFX_Skybox-out.txt @@ -0,0 +1,12 @@ +uniform sampler2D _UpTex; +uniform vec4 _Tint; +void main () +{ + vec4 col; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_UpTex, gl_TexCoord[0].xy); + col.xyz = ((tmpvar_1.xyz + _Tint.xyz) - 0.5); + col.w = (tmpvar_1.w * _Tint.w); + gl_FragData[0] = col; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-RenderFX_Skybox_Cubed-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-RenderFX_Skybox_Cubed-in.txt new file mode 100644 index 000000000..61e0d0e1c --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-RenderFX_Skybox_Cubed-in.txt @@ -0,0 +1,40 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct v2f { + vec4 vertex; + vec3 texcoord; +}; +struct appdata_t { + vec4 vertex; + vec3 texcoord; +}; +uniform samplerCube _Tex; +uniform vec4 _Tint; +vec4 frag( in v2f i ); +vec4 frag( in v2f i ) { + vec4 tex; + vec4 col; + tex = textureCube( _Tex, i.texcoord); + col.xyz = ((tex.xyz + _Tint.xyz ) - 0.500000); + col.w = (tex.w * _Tint.w ); + return col; +} +void main() { + vec4 xl_retval; + v2f xlt_i; + xlt_i.vertex = vec4(0.0); + xlt_i.texcoord = vec3( gl_TexCoord[0]); + xl_retval = frag( xlt_i); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-RenderFX_Skybox_Cubed-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-RenderFX_Skybox_Cubed-ir.txt new file mode 100644 index 000000000..cb7778811 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-RenderFX_Skybox_Cubed-ir.txt @@ -0,0 +1,50 @@ +struct v2f { + vec4 vertex; + vec3 texcoord; +}; +uniform vec4 _Tint; +uniform samplerCube _Tex; +vec4 frag ( + in v2f i +) +{ + vec4 col; + vec4 tex; + vec4 tmpvar_1; + tmpvar_1 = textureCube (_Tex, i.texcoord); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + tex = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = ((tex.xyz + _Tint.xyz) - 0.5); + col.xyz = tmpvar_3.xyz.xyz; + float tmpvar_4; + tmpvar_4 = (tex.w * _Tint.w); + col.w = vec4(tmpvar_4).w; + return col; +} + +void main () +{ + v2f xlt_i; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_i.vertex = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = gl_TexCoord[0].xyz; + vec3 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_i.texcoord = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = frag (xlt_i); + vec4 tmpvar_5; + tmpvar_5 = tmpvar_4; + xl_retval = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = xl_retval.xyzw; + vec4 tmpvar_7; + tmpvar_7 = tmpvar_6; + gl_FragData[0] = tmpvar_7; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-RenderFX_Skybox_Cubed-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-RenderFX_Skybox_Cubed-out.txt new file mode 100644 index 000000000..78f6e682e --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-RenderFX_Skybox_Cubed-out.txt @@ -0,0 +1,12 @@ +uniform vec4 _Tint; +uniform samplerCube _Tex; +void main () +{ + vec4 col; + vec4 tmpvar_1; + tmpvar_1 = textureCube (_Tex, gl_TexCoord[0].xyz); + col.xyz = ((tmpvar_1.xyz + _Tint.xyz) - 0.5); + col.w = (tmpvar_1.w * _Tint.w); + gl_FragData[0] = col; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Bumped_Diffuse-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Bumped_Diffuse-in.txt new file mode 100644 index 000000000..d22a81b7d --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Bumped_Diffuse-in.txt @@ -0,0 +1,115 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_Illum; + vec2 uv_BumpMap; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 lightDir; + vec4 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform sampler2D _BumpMap; +uniform vec4 _Color; +uniform sampler2D _Illum; +uniform vec4 _LightColor0; +uniform sampler2D _LightTexture0; +uniform sampler2D _LightTextureB0; +uniform sampler2D _MainTex; +vec4 UnpackNormal( in vec4 packednormal ); +void surf( in Input IN, inout SurfaceOutput o ); +float UnitySpotCookie( in vec4 LightCoord ); +float UnitySpotAttenuate( in vec3 LightCoord ); +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ); +vec4 frag_surf( in v2f_surf IN ); +vec4 UnpackNormal( in vec4 packednormal ) { + vec4 normal; + normal.xy = ((packednormal.wy * 2.00000) - 1.00000); + normal.z = sqrt( ((1.00000 - (normal.x * normal.x )) - (normal.y * normal.y )) ); + return normal; +} +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 tex; + vec4 c; + tex = texture2D( _MainTex, IN.uv_MainTex); + c = (tex * _Color); + o.Albedo = c.xyz ; + o.Emission = (c.xyz * texture2D( _Illum, IN.uv_Illum).w ); + o.Alpha = c.w ; + o.Normal = vec3( UnpackNormal( texture2D( _BumpMap, IN.uv_BumpMap))); +} +float UnitySpotCookie( in vec4 LightCoord ) { + return texture2D( _LightTexture0, ((LightCoord.xy / LightCoord.w ) + 0.500000)).w ; +} +float UnitySpotAttenuate( in vec3 LightCoord ) { + return texture2D( _LightTextureB0, vec2( vec2( dot( LightCoord, LightCoord)))).w ; +} +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ) { + float diff; + vec4 c; + diff = max( 0.000000, dot( s.Normal, lightDir)); + c.xyz = ((s.Albedo * _LightColor0.xyz ) * ((diff * atten) * 2.00000)); + c.w = s.Alpha; + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec3 lightDir; + vec4 c; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + surfIN.uv_BumpMap = IN.hip_pack0.zw ; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + surf( surfIN, o); + lightDir = IN.lightDir; + lightDir = normalize( lightDir ); + c = LightingLambert( o, lightDir, ((float( (IN._LightCoord.z > 0.000000) ) * UnitySpotCookie( IN._LightCoord)) * UnitySpotAttenuate( IN._LightCoord.xyz ))); + c.w = 0.000000; + return c; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec4( gl_TexCoord[0]); + xlt_IN.lightDir = vec3( gl_TexCoord[1]); + xlt_IN._LightCoord = vec4( gl_TexCoord[2]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Bumped_Diffuse-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Bumped_Diffuse-ir.txt new file mode 100644 index 000000000..560b8d306 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Bumped_Diffuse-ir.txt @@ -0,0 +1,219 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_Illum; + vec2 uv_BumpMap; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 lightDir; + vec4 _LightCoord; +}; +varying vec4 xlv_FOG; +uniform sampler2D _MainTex; +uniform sampler2D _LightTextureB0; +uniform sampler2D _LightTexture0; +uniform vec4 _LightColor0; +uniform sampler2D _Illum; +uniform vec4 _Color; +uniform sampler2D _BumpMap; +vec4 UnpackNormal ( + in vec4 packednormal +) +{ + vec4 normal; + vec2 tmpvar_1; + tmpvar_1 = ((packednormal.wy * 2.0) - 1.0); + normal.xy = tmpvar_1.xy.xy; + float tmpvar_2; + tmpvar_2 = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + normal.z = vec3(tmpvar_3).z; + return normal; +} + +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 c; + vec4 tex; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + tex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = (tex * _Color); + c = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = c.xyz; + o.Albedo = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = texture2D (_Illum, IN.uv_Illum); + vec3 tmpvar_6; + tmpvar_6 = (c.xyz * tmpvar_5.w); + o.Emission = tmpvar_6; + float tmpvar_7; + tmpvar_7 = c.w; + o.Alpha = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = texture2D (_BumpMap, IN.uv_BumpMap); + vec4 tmpvar_9; + tmpvar_9 = UnpackNormal (tmpvar_8); + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9.xyz; + vec3 tmpvar_11; + tmpvar_11 = tmpvar_10; + o.Normal = tmpvar_11; +} + +float UnitySpotCookie ( + in vec4 LightCoord +) +{ + vec4 tmpvar_1; + tmpvar_1 = texture2D (_LightTexture0, ((LightCoord.xy / LightCoord.w) + 0.5)); + return tmpvar_1.w; +} + +float UnitySpotAttenuate ( + in vec3 LightCoord +) +{ + float tmpvar_1; + tmpvar_1 = dot (LightCoord, LightCoord); + vec2 tmpvar_2; + tmpvar_2 = vec2(tmpvar_1); + vec2 tmpvar_3; + tmpvar_3 = tmpvar_2.xy; + vec4 tmpvar_4; + tmpvar_4 = texture2D (_LightTextureB0, tmpvar_3); + return tmpvar_4.w; +} + +vec4 LightingLambert ( + in SurfaceOutput s, + in vec3 lightDir, + in float atten +) +{ + vec4 c; + float diff; + float tmpvar_1; + tmpvar_1 = dot (s.Normal, lightDir); + float tmpvar_2; + tmpvar_2 = max (0.0, tmpvar_1); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + diff = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = ((s.Albedo * _LightColor0.xyz) * ((diff * atten) * 2.0)); + c.xyz = tmpvar_4.xyz.xyz; + float tmpvar_5; + tmpvar_5 = s.Alpha; + c.w = vec4(tmpvar_5).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 c; + vec3 lightDir; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = IN.hip_pack0.zw; + surfIN.uv_BumpMap = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Specular = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Alpha = tmpvar_6; + float tmpvar_7; + tmpvar_7 = 0.0; + o.Gloss = tmpvar_7; + surf (surfIN, o); + vec3 tmpvar_8; + tmpvar_8 = IN.lightDir; + lightDir = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = normalize (lightDir); + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + lightDir = tmpvar_10; + float tmpvar_11; + tmpvar_11 = UnitySpotCookie (IN._LightCoord); + float tmpvar_12; + tmpvar_12 = UnitySpotAttenuate (IN._LightCoord.xyz); + vec4 tmpvar_13; + tmpvar_13 = LightingLambert (o, lightDir, ((float((IN._LightCoord.z > 0.0)) * tmpvar_11) * tmpvar_12)); + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + c = tmpvar_14; + float tmpvar_15; + tmpvar_15 = 0.0; + c.w = vec4(tmpvar_15).w; + return c; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.lightDir = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN._LightCoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = frag_surf (xlt_IN); + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xl_retval = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = xl_retval.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + gl_FragData[0] = tmpvar_12; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Bumped_Diffuse-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Bumped_Diffuse-out.txt new file mode 100644 index 000000000..13cef4135 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Bumped_Diffuse-out.txt @@ -0,0 +1,28 @@ +uniform sampler2D _MainTex; +uniform sampler2D _LightTextureB0; +uniform sampler2D _LightTexture0; +uniform vec4 _LightColor0; +uniform vec4 _Color; +uniform sampler2D _BumpMap; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = gl_TexCoord[0]; + vec4 tmpvar_2; + tmpvar_2 = gl_TexCoord[2]; + vec4 c; + vec4 tmpvar_3; + tmpvar_3 = (texture2D (_MainTex, tmpvar_1.xy) * _Color); + vec4 normal; + normal.xy = ((texture2D (_BumpMap, tmpvar_1.zw).wy * 2.0) - 1.0); + normal.z = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + vec3 LightCoord_i0; + LightCoord_i0 = tmpvar_2.xyz; + vec4 c_i0_i1; + c_i0_i1.xyz = ((tmpvar_3.xyz * _LightColor0.xyz) * ((max (0.0, dot (normal.xyz, normalize (gl_TexCoord[1].xyz))) * ((float((tmpvar_2.z > 0.0)) * texture2D (_LightTexture0, ((tmpvar_2.xy / tmpvar_2.w) + 0.5)).w) * texture2D (_LightTextureB0, vec2(dot (LightCoord_i0, LightCoord_i0))).w)) * 2.0)); + c_i0_i1.w = tmpvar_3.w; + c = c_i0_i1; + c.w = 0.0; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Bumped_Diffuse1-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Bumped_Diffuse1-in.txt new file mode 100644 index 000000000..b9b2afc28 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Bumped_Diffuse1-in.txt @@ -0,0 +1,95 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_Illum; + vec2 uv_BumpMap; +}; +struct v2f_surf { + vec4 pos; + vec2 hip_pack0; + vec3 TtoV0; + vec3 TtoV1; + vec3 TtoV2; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform sampler2D _BumpMap; +uniform vec4 _Color; +uniform sampler2D _Illum; +uniform sampler2D _MainTex; +vec4 UnpackNormal( in vec4 packednormal ); +void surf( in Input IN, inout SurfaceOutput o ); +vec4 frag_surf( in v2f_surf IN ); +vec4 UnpackNormal( in vec4 packednormal ) { + vec4 normal; + normal.xy = ((packednormal.wy * 2.00000) - 1.00000); + normal.z = sqrt( ((1.00000 - (normal.x * normal.x )) - (normal.y * normal.y )) ); + return normal; +} +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 tex; + vec4 c; + tex = texture2D( _MainTex, IN.uv_MainTex); + c = (tex * _Color); + o.Albedo = c.xyz ; + o.Emission = (c.xyz * texture2D( _Illum, IN.uv_Illum).w ); + o.Alpha = c.w ; + o.Normal = vec3( UnpackNormal( texture2D( _BumpMap, IN.uv_BumpMap))); +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec3 viewN; + vec4 res; + surfIN.uv_BumpMap = IN.hip_pack0.xy ; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + surf( surfIN, o); + viewN.x = dot( IN.TtoV0, o.Normal); + viewN.y = dot( IN.TtoV1, o.Normal); + viewN.z = dot( IN.TtoV2, o.Normal); + o.Normal = viewN; + res.xyz = ((o.Normal * vec3( 0.500000, 0.500000, -0.500000)) + 0.500000); + res.w = o.Specular; + return res; +} +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.hip_pack0 = vec2( gl_TexCoord[0]); + xlt_IN.TtoV0 = vec3( gl_TexCoord[1]); + xlt_IN.TtoV1 = vec3( gl_TexCoord[2]); + xlt_IN.TtoV2 = vec3( gl_TexCoord[3]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Bumped_Diffuse1-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Bumped_Diffuse1-ir.txt new file mode 100644 index 000000000..e8189150d --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Bumped_Diffuse1-ir.txt @@ -0,0 +1,170 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_Illum; + vec2 uv_BumpMap; +}; +struct v2f_surf { + vec4 pos; + vec2 hip_pack0; + vec3 TtoV0; + vec3 TtoV1; + vec3 TtoV2; +}; +uniform sampler2D _MainTex; +uniform sampler2D _Illum; +uniform vec4 _Color; +uniform sampler2D _BumpMap; +vec4 UnpackNormal ( + in vec4 packednormal +) +{ + vec4 normal; + vec2 tmpvar_1; + tmpvar_1 = ((packednormal.wy * 2.0) - 1.0); + normal.xy = tmpvar_1.xy.xy; + float tmpvar_2; + tmpvar_2 = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + normal.z = vec3(tmpvar_3).z; + return normal; +} + +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 c; + vec4 tex; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + tex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = (tex * _Color); + c = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = c.xyz; + o.Albedo = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = texture2D (_Illum, IN.uv_Illum); + vec3 tmpvar_6; + tmpvar_6 = (c.xyz * tmpvar_5.w); + o.Emission = tmpvar_6; + float tmpvar_7; + tmpvar_7 = c.w; + o.Alpha = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = texture2D (_BumpMap, IN.uv_BumpMap); + vec4 tmpvar_9; + tmpvar_9 = UnpackNormal (tmpvar_8); + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9.xyz; + vec3 tmpvar_11; + tmpvar_11 = tmpvar_10; + o.Normal = tmpvar_11; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 res; + vec3 viewN; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_BumpMap = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_3; + float tmpvar_4; + tmpvar_4 = 0.0; + o.Specular = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Alpha = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Gloss = tmpvar_6; + surf (surfIN, o); + float tmpvar_7; + tmpvar_7 = dot (IN.TtoV0, o.Normal); + float tmpvar_8; + tmpvar_8 = tmpvar_7; + viewN.x = tmpvar_8; + float tmpvar_9; + tmpvar_9 = dot (IN.TtoV1, o.Normal); + float tmpvar_10; + tmpvar_10 = tmpvar_9; + viewN.y = vec2(tmpvar_10).y; + float tmpvar_11; + tmpvar_11 = dot (IN.TtoV2, o.Normal); + float tmpvar_12; + tmpvar_12 = tmpvar_11; + viewN.z = vec3(tmpvar_12).z; + vec3 tmpvar_13; + tmpvar_13 = viewN; + o.Normal = tmpvar_13; + vec3 tmpvar_14; + tmpvar_14 = ((o.Normal * vec3(0.5, 0.5, -0.5)) + 0.5); + res.xyz = tmpvar_14.xyz.xyz; + float tmpvar_15; + tmpvar_15 = o.Specular; + res.w = vec4(tmpvar_15).w; + return res; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = gl_TexCoord[0].xy; + vec2 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_IN.hip_pack0 = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = gl_TexCoord[1].xyz; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_4; + xlt_IN.TtoV0 = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = gl_TexCoord[2].xyz; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_6; + xlt_IN.TtoV1 = tmpvar_7; + vec3 tmpvar_8; + tmpvar_8 = gl_TexCoord[3].xyz; + vec3 tmpvar_9; + tmpvar_9 = tmpvar_8; + xlt_IN.TtoV2 = tmpvar_9; + vec4 tmpvar_10; + tmpvar_10 = frag_surf (xlt_IN); + vec4 tmpvar_11; + tmpvar_11 = tmpvar_10; + xl_retval = tmpvar_11; + vec4 tmpvar_12; + tmpvar_12 = xl_retval.xyzw; + vec4 tmpvar_13; + tmpvar_13 = tmpvar_12; + gl_FragData[0] = tmpvar_13; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Bumped_Diffuse1-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Bumped_Diffuse1-out.txt new file mode 100644 index 000000000..3c1dec354 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Bumped_Diffuse1-out.txt @@ -0,0 +1,18 @@ +uniform sampler2D _BumpMap; +void main () +{ + vec4 res; + vec3 viewN; + vec4 normal; + normal.xy = ((texture2D (_BumpMap, gl_TexCoord[0].xy).wy * 2.0) - 1.0); + normal.z = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + vec3 tmpvar_1; + tmpvar_1 = normal.xyz; + viewN.x = dot (gl_TexCoord[1].xyz, tmpvar_1); + viewN.y = dot (gl_TexCoord[2].xyz, tmpvar_1); + viewN.z = dot (gl_TexCoord[3].xyz, tmpvar_1); + res.xyz = ((viewN * vec3(0.5, 0.5, -0.5)) + 0.5); + res.w = 0.0; + gl_FragData[0] = res; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Bumped_Diffuse2-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Bumped_Diffuse2-in.txt new file mode 100644 index 000000000..9ab13c1db --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Bumped_Diffuse2-in.txt @@ -0,0 +1,103 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_Illum; + vec2 uv_BumpMap; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec4 hip_screen; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform sampler2D _BumpMap; +uniform vec4 _Color; +uniform sampler2D _Illum; +uniform sampler2D _LightBuffer; +uniform sampler2D _MainTex; +uniform vec4 unity_Ambient; +vec4 UnpackNormal( in vec4 packednormal ); +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingLambert_PrePass( in SurfaceOutput s, in vec4 light ); +vec4 frag_surf( in v2f_surf IN ); +vec4 UnpackNormal( in vec4 packednormal ) { + vec4 normal; + normal.xy = ((packednormal.wy * 2.00000) - 1.00000); + normal.z = sqrt( ((1.00000 - (normal.x * normal.x )) - (normal.y * normal.y )) ); + return normal; +} +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 tex; + vec4 c; + tex = texture2D( _MainTex, IN.uv_MainTex); + c = (tex * _Color); + o.Albedo = c.xyz ; + o.Emission = (c.xyz * texture2D( _Illum, IN.uv_Illum).w ); + o.Alpha = c.w ; + o.Normal = vec3( UnpackNormal( texture2D( _BumpMap, IN.uv_BumpMap))); +} +vec4 LightingLambert_PrePass( in SurfaceOutput s, in vec4 light ) { + vec4 c; + c.xyz = (s.Albedo * light.xyz ); + c.w = s.Alpha; + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec4 light; + vec4 col; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + surfIN.uv_Illum = IN.hip_pack0.zw ; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + surf( surfIN, o); + light = texture2DProj( _LightBuffer, IN.hip_screen); + light = ( -log2( light ) ); + light.xyz += unity_Ambient.xyz ; + col = LightingLambert_PrePass( o, light); + col.xyz += o.Emission; + return col; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec4( gl_TexCoord[0]); + xlt_IN.hip_screen = vec4( gl_TexCoord[1]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Bumped_Diffuse2-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Bumped_Diffuse2-ir.txt new file mode 100644 index 000000000..8b7646f60 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Bumped_Diffuse2-ir.txt @@ -0,0 +1,180 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_Illum; + vec2 uv_BumpMap; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec4 hip_screen; +}; +varying vec4 xlv_FOG; +uniform vec4 unity_Ambient; +uniform sampler2D _MainTex; +uniform sampler2D _LightBuffer; +uniform sampler2D _Illum; +uniform vec4 _Color; +uniform sampler2D _BumpMap; +vec4 UnpackNormal ( + in vec4 packednormal +) +{ + vec4 normal; + vec2 tmpvar_1; + tmpvar_1 = ((packednormal.wy * 2.0) - 1.0); + normal.xy = tmpvar_1.xy.xy; + float tmpvar_2; + tmpvar_2 = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + normal.z = vec3(tmpvar_3).z; + return normal; +} + +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 c; + vec4 tex; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + tex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = (tex * _Color); + c = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = c.xyz; + o.Albedo = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = texture2D (_Illum, IN.uv_Illum); + vec3 tmpvar_6; + tmpvar_6 = (c.xyz * tmpvar_5.w); + o.Emission = tmpvar_6; + float tmpvar_7; + tmpvar_7 = c.w; + o.Alpha = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = texture2D (_BumpMap, IN.uv_BumpMap); + vec4 tmpvar_9; + tmpvar_9 = UnpackNormal (tmpvar_8); + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9.xyz; + vec3 tmpvar_11; + tmpvar_11 = tmpvar_10; + o.Normal = tmpvar_11; +} + +vec4 LightingLambert_PrePass ( + in SurfaceOutput s, + in vec4 light +) +{ + vec4 c; + vec3 tmpvar_1; + tmpvar_1 = (s.Albedo * light.xyz); + c.xyz = tmpvar_1.xyz.xyz; + float tmpvar_2; + tmpvar_2 = s.Alpha; + c.w = vec4(tmpvar_2).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 col; + vec4 light; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = IN.hip_pack0.zw; + surfIN.uv_Illum = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Specular = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Alpha = tmpvar_6; + float tmpvar_7; + tmpvar_7 = 0.0; + o.Gloss = tmpvar_7; + surf (surfIN, o); + vec4 tmpvar_8; + tmpvar_8 = texture2DProj (_LightBuffer, IN.hip_screen); + vec4 tmpvar_9; + tmpvar_9 = tmpvar_8; + light = tmpvar_9; + vec4 tmpvar_10; + tmpvar_10 = log2 (light); + vec4 tmpvar_11; + tmpvar_11 = -(tmpvar_10); + light = tmpvar_11; + vec3 tmpvar_12; + tmpvar_12 = (light.xyz + unity_Ambient.xyz); + light.xyz = tmpvar_12.xyz.xyz; + vec4 tmpvar_13; + tmpvar_13 = LightingLambert_PrePass (o, light); + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + col = tmpvar_14; + vec3 tmpvar_15; + tmpvar_15 = (col.xyz + o.Emission); + col.xyz = tmpvar_15.xyz.xyz; + return col; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyzw; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.hip_screen = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = frag_surf (xlt_IN); + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xl_retval = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = xl_retval.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + gl_FragData[0] = tmpvar_10; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Bumped_Diffuse2-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Bumped_Diffuse2-out.txt new file mode 100644 index 000000000..eb7ec9c2f --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Bumped_Diffuse2-out.txt @@ -0,0 +1,30 @@ +uniform vec4 unity_Ambient; +uniform sampler2D _MainTex; +uniform sampler2D _LightBuffer; +uniform sampler2D _Illum; +uniform vec4 _Color; +uniform sampler2D _BumpMap; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = gl_TexCoord[0]; + vec4 col; + vec4 light; + vec2 tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = (texture2D (_MainTex, tmpvar_1.xy) * _Color); + vec4 normal; + normal.xy = ((texture2D (_BumpMap, tmpvar_2).wy * 2.0) - 1.0); + normal.z = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + vec4 tmpvar_4; + tmpvar_4 = -(log2 (texture2DProj (_LightBuffer, gl_TexCoord[1]))); + light = tmpvar_4; + light.xyz = (tmpvar_4.xyz + unity_Ambient.xyz); + vec4 c_i0; + c_i0.xyz = (tmpvar_3.xyz * light.xyz); + c_i0.w = tmpvar_3.w; + col = c_i0; + col.xyz = (c_i0.xyz + (tmpvar_3.xyz * texture2D (_Illum, tmpvar_1.zw).w)); + gl_FragData[0] = col; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Bumped_Specular-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Bumped_Specular-in.txt new file mode 100644 index 000000000..b1542ffac --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Bumped_Specular-in.txt @@ -0,0 +1,98 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_Illum; + vec2 uv_BumpMap; +}; +struct v2f_surf { + vec4 pos; + vec2 hip_pack0; + vec3 TtoV0; + vec3 TtoV1; + vec3 TtoV2; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform sampler2D _BumpMap; +uniform vec4 _Color; +uniform sampler2D _Illum; +uniform sampler2D _MainTex; +uniform float _Shininess; +vec4 UnpackNormal( in vec4 packednormal ); +void surf( in Input IN, inout SurfaceOutput o ); +vec4 frag_surf( in v2f_surf IN ); +vec4 UnpackNormal( in vec4 packednormal ) { + vec4 normal; + normal.xy = ((packednormal.wy * 2.00000) - 1.00000); + normal.z = sqrt( ((1.00000 - (normal.x * normal.x )) - (normal.y * normal.y )) ); + return normal; +} +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 tex; + vec4 c; + tex = texture2D( _MainTex, IN.uv_MainTex); + c = (tex * _Color); + o.Albedo = c.xyz ; + o.Emission = (c.xyz * texture2D( _Illum, IN.uv_Illum).w ); + o.Gloss = tex.w ; + o.Alpha = c.w ; + o.Specular = _Shininess; + o.Normal = vec3( UnpackNormal( texture2D( _BumpMap, IN.uv_BumpMap))); +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec3 viewN; + vec4 res; + surfIN.uv_BumpMap = IN.hip_pack0.xy ; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + surf( surfIN, o); + viewN.x = dot( IN.TtoV0, o.Normal); + viewN.y = dot( IN.TtoV1, o.Normal); + viewN.z = dot( IN.TtoV2, o.Normal); + o.Normal = viewN; + res.xyz = ((o.Normal * vec3( 0.500000, 0.500000, -0.500000)) + 0.500000); + res.w = o.Specular; + return res; +} +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.hip_pack0 = vec2( gl_TexCoord[0]); + xlt_IN.TtoV0 = vec3( gl_TexCoord[1]); + xlt_IN.TtoV1 = vec3( gl_TexCoord[2]); + xlt_IN.TtoV2 = vec3( gl_TexCoord[3]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Bumped_Specular-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Bumped_Specular-ir.txt new file mode 100644 index 000000000..7f2879dde --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Bumped_Specular-ir.txt @@ -0,0 +1,177 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_Illum; + vec2 uv_BumpMap; +}; +struct v2f_surf { + vec4 pos; + vec2 hip_pack0; + vec3 TtoV0; + vec3 TtoV1; + vec3 TtoV2; +}; +uniform float _Shininess; +uniform sampler2D _MainTex; +uniform sampler2D _Illum; +uniform vec4 _Color; +uniform sampler2D _BumpMap; +vec4 UnpackNormal ( + in vec4 packednormal +) +{ + vec4 normal; + vec2 tmpvar_1; + tmpvar_1 = ((packednormal.wy * 2.0) - 1.0); + normal.xy = tmpvar_1.xy.xy; + float tmpvar_2; + tmpvar_2 = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + normal.z = vec3(tmpvar_3).z; + return normal; +} + +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 c; + vec4 tex; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + tex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = (tex * _Color); + c = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = c.xyz; + o.Albedo = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = texture2D (_Illum, IN.uv_Illum); + vec3 tmpvar_6; + tmpvar_6 = (c.xyz * tmpvar_5.w); + o.Emission = tmpvar_6; + float tmpvar_7; + tmpvar_7 = tex.w; + o.Gloss = tmpvar_7; + float tmpvar_8; + tmpvar_8 = c.w; + o.Alpha = tmpvar_8; + float tmpvar_9; + tmpvar_9 = _Shininess; + o.Specular = tmpvar_9; + vec4 tmpvar_10; + tmpvar_10 = texture2D (_BumpMap, IN.uv_BumpMap); + vec4 tmpvar_11; + tmpvar_11 = UnpackNormal (tmpvar_10); + vec3 tmpvar_12; + tmpvar_12 = tmpvar_11.xyz; + vec3 tmpvar_13; + tmpvar_13 = tmpvar_12; + o.Normal = tmpvar_13; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 res; + vec3 viewN; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_BumpMap = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_3; + float tmpvar_4; + tmpvar_4 = 0.0; + o.Specular = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Alpha = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Gloss = tmpvar_6; + surf (surfIN, o); + float tmpvar_7; + tmpvar_7 = dot (IN.TtoV0, o.Normal); + float tmpvar_8; + tmpvar_8 = tmpvar_7; + viewN.x = tmpvar_8; + float tmpvar_9; + tmpvar_9 = dot (IN.TtoV1, o.Normal); + float tmpvar_10; + tmpvar_10 = tmpvar_9; + viewN.y = vec2(tmpvar_10).y; + float tmpvar_11; + tmpvar_11 = dot (IN.TtoV2, o.Normal); + float tmpvar_12; + tmpvar_12 = tmpvar_11; + viewN.z = vec3(tmpvar_12).z; + vec3 tmpvar_13; + tmpvar_13 = viewN; + o.Normal = tmpvar_13; + vec3 tmpvar_14; + tmpvar_14 = ((o.Normal * vec3(0.5, 0.5, -0.5)) + 0.5); + res.xyz = tmpvar_14.xyz.xyz; + float tmpvar_15; + tmpvar_15 = o.Specular; + res.w = vec4(tmpvar_15).w; + return res; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = gl_TexCoord[0].xy; + vec2 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_IN.hip_pack0 = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = gl_TexCoord[1].xyz; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_4; + xlt_IN.TtoV0 = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = gl_TexCoord[2].xyz; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_6; + xlt_IN.TtoV1 = tmpvar_7; + vec3 tmpvar_8; + tmpvar_8 = gl_TexCoord[3].xyz; + vec3 tmpvar_9; + tmpvar_9 = tmpvar_8; + xlt_IN.TtoV2 = tmpvar_9; + vec4 tmpvar_10; + tmpvar_10 = frag_surf (xlt_IN); + vec4 tmpvar_11; + tmpvar_11 = tmpvar_10; + xl_retval = tmpvar_11; + vec4 tmpvar_12; + tmpvar_12 = xl_retval.xyzw; + vec4 tmpvar_13; + tmpvar_13 = tmpvar_12; + gl_FragData[0] = tmpvar_13; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Bumped_Specular-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Bumped_Specular-out.txt new file mode 100644 index 000000000..e805953b8 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Bumped_Specular-out.txt @@ -0,0 +1,19 @@ +uniform float _Shininess; +uniform sampler2D _BumpMap; +void main () +{ + vec4 res; + vec3 viewN; + vec4 normal; + normal.xy = ((texture2D (_BumpMap, gl_TexCoord[0].xy).wy * 2.0) - 1.0); + normal.z = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + vec3 tmpvar_1; + tmpvar_1 = normal.xyz; + viewN.x = dot (gl_TexCoord[1].xyz, tmpvar_1); + viewN.y = dot (gl_TexCoord[2].xyz, tmpvar_1); + viewN.z = dot (gl_TexCoord[3].xyz, tmpvar_1); + res.xyz = ((viewN * vec3(0.5, 0.5, -0.5)) + 0.5); + res.w = _Shininess; + gl_FragData[0] = res; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Bumped_Specular1-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Bumped_Specular1-in.txt new file mode 100644 index 000000000..576a23ac7 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Bumped_Specular1-in.txt @@ -0,0 +1,109 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_Illum; + vec2 uv_BumpMap; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec4 hip_screen; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform sampler2D _BumpMap; +uniform vec4 _Color; +uniform sampler2D _Illum; +uniform sampler2D _LightBuffer; +uniform sampler2D _MainTex; +uniform float _Shininess; +uniform vec4 _SpecColor; +uniform vec4 unity_Ambient; +vec4 UnpackNormal( in vec4 packednormal ); +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingBlinnPhong_PrePass( in SurfaceOutput s, in vec4 light ); +vec4 frag_surf( in v2f_surf IN ); +vec4 UnpackNormal( in vec4 packednormal ) { + vec4 normal; + normal.xy = ((packednormal.wy * 2.00000) - 1.00000); + normal.z = sqrt( ((1.00000 - (normal.x * normal.x )) - (normal.y * normal.y )) ); + return normal; +} +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 tex; + vec4 c; + tex = texture2D( _MainTex, IN.uv_MainTex); + c = (tex * _Color); + o.Albedo = c.xyz ; + o.Emission = (c.xyz * texture2D( _Illum, IN.uv_Illum).w ); + o.Gloss = tex.w ; + o.Alpha = c.w ; + o.Specular = _Shininess; + o.Normal = vec3( UnpackNormal( texture2D( _BumpMap, IN.uv_BumpMap))); +} +vec4 LightingBlinnPhong_PrePass( in SurfaceOutput s, in vec4 light ) { + float spec; + vec4 c; + spec = (light.w * s.Gloss); + c.xyz = ((s.Albedo * light.xyz ) + ((light.xyz * _SpecColor.xyz ) * spec)); + c.w = (s.Alpha + (spec * _SpecColor.w )); + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec4 light; + vec4 col; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + surfIN.uv_Illum = IN.hip_pack0.zw ; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + surf( surfIN, o); + light = texture2DProj( _LightBuffer, IN.hip_screen); + light = ( -log2( light ) ); + light.xyz += unity_Ambient.xyz ; + col = LightingBlinnPhong_PrePass( o, light); + col.xyz += o.Emission; + return col; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec4( gl_TexCoord[0]); + xlt_IN.hip_screen = vec4( gl_TexCoord[1]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Bumped_Specular1-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Bumped_Specular1-ir.txt new file mode 100644 index 000000000..5328ef1ae --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Bumped_Specular1-ir.txt @@ -0,0 +1,192 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_Illum; + vec2 uv_BumpMap; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec4 hip_screen; +}; +varying vec4 xlv_FOG; +uniform vec4 unity_Ambient; +uniform vec4 _SpecColor; +uniform float _Shininess; +uniform sampler2D _MainTex; +uniform sampler2D _LightBuffer; +uniform sampler2D _Illum; +uniform vec4 _Color; +uniform sampler2D _BumpMap; +vec4 UnpackNormal ( + in vec4 packednormal +) +{ + vec4 normal; + vec2 tmpvar_1; + tmpvar_1 = ((packednormal.wy * 2.0) - 1.0); + normal.xy = tmpvar_1.xy.xy; + float tmpvar_2; + tmpvar_2 = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + normal.z = vec3(tmpvar_3).z; + return normal; +} + +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 c; + vec4 tex; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + tex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = (tex * _Color); + c = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = c.xyz; + o.Albedo = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = texture2D (_Illum, IN.uv_Illum); + vec3 tmpvar_6; + tmpvar_6 = (c.xyz * tmpvar_5.w); + o.Emission = tmpvar_6; + float tmpvar_7; + tmpvar_7 = tex.w; + o.Gloss = tmpvar_7; + float tmpvar_8; + tmpvar_8 = c.w; + o.Alpha = tmpvar_8; + float tmpvar_9; + tmpvar_9 = _Shininess; + o.Specular = tmpvar_9; + vec4 tmpvar_10; + tmpvar_10 = texture2D (_BumpMap, IN.uv_BumpMap); + vec4 tmpvar_11; + tmpvar_11 = UnpackNormal (tmpvar_10); + vec3 tmpvar_12; + tmpvar_12 = tmpvar_11.xyz; + vec3 tmpvar_13; + tmpvar_13 = tmpvar_12; + o.Normal = tmpvar_13; +} + +vec4 LightingBlinnPhong_PrePass ( + in SurfaceOutput s, + in vec4 light +) +{ + vec4 c; + float spec; + float tmpvar_1; + tmpvar_1 = (light.w * s.Gloss); + spec = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = ((s.Albedo * light.xyz) + ((light.xyz * _SpecColor.xyz) * spec)); + c.xyz = tmpvar_2.xyz.xyz; + float tmpvar_3; + tmpvar_3 = (s.Alpha + (spec * _SpecColor.w)); + c.w = vec4(tmpvar_3).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 col; + vec4 light; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = IN.hip_pack0.zw; + surfIN.uv_Illum = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Specular = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Alpha = tmpvar_6; + float tmpvar_7; + tmpvar_7 = 0.0; + o.Gloss = tmpvar_7; + surf (surfIN, o); + vec4 tmpvar_8; + tmpvar_8 = texture2DProj (_LightBuffer, IN.hip_screen); + vec4 tmpvar_9; + tmpvar_9 = tmpvar_8; + light = tmpvar_9; + vec4 tmpvar_10; + tmpvar_10 = log2 (light); + vec4 tmpvar_11; + tmpvar_11 = -(tmpvar_10); + light = tmpvar_11; + vec3 tmpvar_12; + tmpvar_12 = (light.xyz + unity_Ambient.xyz); + light.xyz = tmpvar_12.xyz.xyz; + vec4 tmpvar_13; + tmpvar_13 = LightingBlinnPhong_PrePass (o, light); + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + col = tmpvar_14; + vec3 tmpvar_15; + tmpvar_15 = (col.xyz + o.Emission); + col.xyz = tmpvar_15.xyz.xyz; + return col; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyzw; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.hip_screen = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = frag_surf (xlt_IN); + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xl_retval = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = xl_retval.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + gl_FragData[0] = tmpvar_10; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Bumped_Specular1-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Bumped_Specular1-out.txt new file mode 100644 index 000000000..47fa2b406 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Bumped_Specular1-out.txt @@ -0,0 +1,35 @@ +uniform vec4 unity_Ambient; +uniform vec4 _SpecColor; +uniform sampler2D _MainTex; +uniform sampler2D _LightBuffer; +uniform sampler2D _Illum; +uniform vec4 _Color; +uniform sampler2D _BumpMap; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = gl_TexCoord[0]; + vec4 col; + vec4 light; + vec2 tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = texture2D (_MainTex, tmpvar_1.xy); + vec4 tmpvar_4; + tmpvar_4 = (tmpvar_3 * _Color); + vec4 normal; + normal.xy = ((texture2D (_BumpMap, tmpvar_2).wy * 2.0) - 1.0); + normal.z = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + vec4 tmpvar_5; + tmpvar_5 = -(log2 (texture2DProj (_LightBuffer, gl_TexCoord[1]))); + light = tmpvar_5; + light.xyz = (tmpvar_5.xyz + unity_Ambient.xyz); + vec4 c_i0; + float tmpvar_6; + tmpvar_6 = (tmpvar_5.w * tmpvar_3.w); + c_i0.xyz = ((tmpvar_4.xyz * light.xyz) + ((light.xyz * _SpecColor.xyz) * tmpvar_6)); + c_i0.w = (tmpvar_4.w + (tmpvar_6 * _SpecColor.w)); + col = c_i0; + col.xyz = (c_i0.xyz + (tmpvar_4.xyz * texture2D (_Illum, tmpvar_1.zw).w)); + gl_FragData[0] = col; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Diffuse-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Diffuse-in.txt new file mode 100644 index 000000000..3e3bb132e --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Diffuse-in.txt @@ -0,0 +1,97 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_Illum; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 normal; + vec3 lightDir; + vec2 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _Color; +uniform sampler2D _Illum; +uniform vec4 _LightColor0; +uniform sampler2D _LightTexture0; +uniform sampler2D _MainTex; +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ); +vec4 frag_surf( in v2f_surf IN ); +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 tex; + vec4 c; + tex = texture2D( _MainTex, IN.uv_MainTex); + c = (tex * _Color); + o.Albedo = c.xyz ; + o.Emission = (c.xyz * texture2D( _Illum, IN.uv_Illum).w ); + o.Alpha = c.w ; +} +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ) { + float diff; + vec4 c; + diff = max( 0.000000, dot( s.Normal, lightDir)); + c.xyz = ((s.Albedo * _LightColor0.xyz ) * ((diff * atten) * 2.00000)); + c.w = s.Alpha; + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec3 lightDir; + vec4 c; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + o.Normal = IN.normal; + surf( surfIN, o); + lightDir = IN.lightDir; + c = LightingLambert( o, lightDir, (texture2D( _LightTexture0, IN._LightCoord).w * 1.00000)); + c.w = 0.000000; + return c; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec2( gl_TexCoord[0]); + xlt_IN.normal = vec3( gl_TexCoord[1]); + xlt_IN.lightDir = vec3( gl_TexCoord[2]); + xlt_IN._LightCoord = vec2( gl_TexCoord[3]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Diffuse-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Diffuse-ir.txt new file mode 100644 index 000000000..f5a354570 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Diffuse-ir.txt @@ -0,0 +1,166 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_Illum; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 normal; + vec3 lightDir; + vec2 _LightCoord; +}; +varying vec4 xlv_FOG; +uniform sampler2D _MainTex; +uniform sampler2D _LightTexture0; +uniform vec4 _LightColor0; +uniform sampler2D _Illum; +uniform vec4 _Color; +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 c; + vec4 tex; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + tex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = (tex * _Color); + c = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = c.xyz; + o.Albedo = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = texture2D (_Illum, IN.uv_Illum); + vec3 tmpvar_6; + tmpvar_6 = (c.xyz * tmpvar_5.w); + o.Emission = tmpvar_6; + float tmpvar_7; + tmpvar_7 = c.w; + o.Alpha = tmpvar_7; +} + +vec4 LightingLambert ( + in SurfaceOutput s, + in vec3 lightDir, + in float atten +) +{ + vec4 c; + float diff; + float tmpvar_1; + tmpvar_1 = dot (s.Normal, lightDir); + float tmpvar_2; + tmpvar_2 = max (0.0, tmpvar_1); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + diff = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = ((s.Albedo * _LightColor0.xyz) * ((diff * atten) * 2.0)); + c.xyz = tmpvar_4.xyz.xyz; + float tmpvar_5; + tmpvar_5 = s.Alpha; + c.w = vec4(tmpvar_5).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 c; + vec3 lightDir; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_3; + float tmpvar_4; + tmpvar_4 = 0.0; + o.Specular = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Alpha = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Gloss = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = IN.normal; + o.Normal = tmpvar_7; + surf (surfIN, o); + vec3 tmpvar_8; + tmpvar_8 = IN.lightDir; + lightDir = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = texture2D (_LightTexture0, IN._LightCoord); + vec4 tmpvar_10; + tmpvar_10 = LightingLambert (o, lightDir, (tmpvar_9.w * 1.0)); + vec4 tmpvar_11; + tmpvar_11 = tmpvar_10; + c = tmpvar_11; + float tmpvar_12; + tmpvar_12 = 0.0; + c.w = vec4(tmpvar_12).w; + return c; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xy; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.normal = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.lightDir = tmpvar_8; + vec2 tmpvar_9; + tmpvar_9 = gl_TexCoord[3].xy; + vec2 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_IN._LightCoord = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = frag_surf (xlt_IN); + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xl_retval = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = xl_retval.xyzw; + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + gl_FragData[0] = tmpvar_14; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Diffuse-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Diffuse-out.txt new file mode 100644 index 000000000..cf0b90ffa --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Diffuse-out.txt @@ -0,0 +1,17 @@ +uniform sampler2D _MainTex; +uniform sampler2D _LightTexture0; +uniform vec4 _LightColor0; +uniform vec4 _Color; +void main () +{ + vec4 c; + vec4 tmpvar_1; + tmpvar_1 = (texture2D (_MainTex, gl_TexCoord[0].xy) * _Color); + vec4 c_i0_i1; + c_i0_i1.xyz = ((tmpvar_1.xyz * _LightColor0.xyz) * ((max (0.0, dot (gl_TexCoord[1].xyz, gl_TexCoord[2].xyz)) * texture2D (_LightTexture0, gl_TexCoord[3].xy).w) * 2.0)); + c_i0_i1.w = tmpvar_1.w; + c = c_i0_i1; + c.w = 0.0; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Diffuse1-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Diffuse1-in.txt new file mode 100644 index 000000000..5d3ca86c2 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Diffuse1-in.txt @@ -0,0 +1,127 @@ +float xll_saturate( float x) { + return clamp( x, 0.0, 1.0); +} +vec2 xll_saturate( vec2 x) { + return clamp( x, 0.0, 1.0); +} +vec3 xll_saturate( vec3 x) { + return clamp( x, 0.0, 1.0); +} +vec4 xll_saturate( vec4 x) { + return clamp( x, 0.0, 1.0); +} +mat2 xll_saturate(mat2 m) { + return mat2( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0)); +} +mat3 xll_saturate(mat3 m) { + return mat3( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0), clamp(m[2], 0.0, 1.0)); +} +mat4 xll_saturate(mat4 m) { + return mat4( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0), clamp(m[2], 0.0, 1.0), clamp(m[3], 0.0, 1.0)); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_Illum; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec4 hip_screen; + vec3 hip_lmapFade; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _Color; +uniform sampler2D _Illum; +uniform sampler2D _LightBuffer; +uniform sampler2D _MainTex; +uniform sampler2D unity_Lightmap; +uniform sampler2D unity_LightmapInd; +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingLambert_PrePass( in SurfaceOutput s, in vec4 light ); +vec3 DecodeLightmap( in vec4 color ); +vec4 frag_surf( in v2f_surf IN ); +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 tex; + vec4 c; + tex = texture2D( _MainTex, IN.uv_MainTex); + c = (tex * _Color); + o.Albedo = c.xyz ; + o.Emission = (c.xyz * texture2D( _Illum, IN.uv_Illum).w ); + o.Alpha = c.w ; +} +vec4 LightingLambert_PrePass( in SurfaceOutput s, in vec4 light ) { + vec4 c; + c.xyz = (s.Albedo * light.xyz ); + c.w = s.Alpha; + return c; +} +vec3 DecodeLightmap( in vec4 color ) { + return (2.00000 * color.xyz ); +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec4 light; + vec3 lmFull; + vec3 lmIndirect; + vec3 lm; + vec4 col; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + surfIN.uv_Illum = IN.hip_pack0.zw ; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + surf( surfIN, o); + light = texture2DProj( _LightBuffer, IN.hip_screen); + light = ( -log2( light ) ); + lmFull = DecodeLightmap( texture2D( unity_Lightmap, IN.hip_lmapFade.xy )); + lmIndirect = DecodeLightmap( texture2D( unity_LightmapInd, IN.hip_lmapFade.xy )); + lm = mix( lmIndirect, lmFull, vec3( xll_saturate( IN.hip_lmapFade.z ))); + light.xyz += lm; + col = LightingLambert_PrePass( o, light); + col.xyz += o.Emission; + return col; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec4( gl_TexCoord[0]); + xlt_IN.hip_screen = vec4( gl_TexCoord[1]); + xlt_IN.hip_lmapFade = vec3( gl_TexCoord[2]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Diffuse1-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Diffuse1-ir.txt new file mode 100644 index 000000000..0d8b382fd --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Diffuse1-ir.txt @@ -0,0 +1,298 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_Illum; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec4 hip_screen; + vec3 hip_lmapFade; +}; +varying vec4 xlv_FOG; +uniform sampler2D unity_LightmapInd; +uniform sampler2D unity_Lightmap; +uniform sampler2D _MainTex; +uniform sampler2D _LightBuffer; +uniform sampler2D _Illum; +uniform vec4 _Color; +float xll_saturate ( + in float x +) +{ + float tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec2 xll_saturate ( + in vec2 x +) +{ + vec2 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec3 xll_saturate ( + in vec3 x +) +{ + vec3 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec4 xll_saturate ( + in vec4 x +) +{ + vec4 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +mat2 xll_saturate ( + in mat2 m +) +{ + vec2 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec2 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + mat2 tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_1; + tmpvar_3[0] = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5 = tmpvar_2; + tmpvar_3[1] = tmpvar_5; + return tmpvar_3; +} + +mat3 xll_saturate ( + in mat3 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec3 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + vec3 tmpvar_3; + tmpvar_3 = clamp (m[2], 0.0, 1.0); + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +mat4 xll_saturate ( + in mat4 m +) +{ + vec4 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec4 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + vec4 tmpvar_3; + tmpvar_3 = clamp (m[2], 0.0, 1.0); + vec4 tmpvar_4; + tmpvar_4 = clamp (m[3], 0.0, 1.0); + mat4 tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_1; + tmpvar_5[0] = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = tmpvar_2; + tmpvar_5[1] = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_3; + tmpvar_5[2] = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = tmpvar_4; + tmpvar_5[3] = tmpvar_9; + return tmpvar_5; +} + +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 c; + vec4 tex; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + tex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = (tex * _Color); + c = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = c.xyz; + o.Albedo = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = texture2D (_Illum, IN.uv_Illum); + vec3 tmpvar_6; + tmpvar_6 = (c.xyz * tmpvar_5.w); + o.Emission = tmpvar_6; + float tmpvar_7; + tmpvar_7 = c.w; + o.Alpha = tmpvar_7; +} + +vec4 LightingLambert_PrePass ( + in SurfaceOutput s, + in vec4 light +) +{ + vec4 c; + vec3 tmpvar_1; + tmpvar_1 = (s.Albedo * light.xyz); + c.xyz = tmpvar_1.xyz.xyz; + float tmpvar_2; + tmpvar_2 = s.Alpha; + c.w = vec4(tmpvar_2).w; + return c; +} + +vec3 DecodeLightmap ( + in vec4 color +) +{ + return (2.0 * color.xyz); +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 col; + vec3 lm; + vec3 lmIndirect; + vec3 lmFull; + vec4 light; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = IN.hip_pack0.zw; + surfIN.uv_Illum = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Specular = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Alpha = tmpvar_6; + float tmpvar_7; + tmpvar_7 = 0.0; + o.Gloss = tmpvar_7; + surf (surfIN, o); + vec4 tmpvar_8; + tmpvar_8 = texture2DProj (_LightBuffer, IN.hip_screen); + vec4 tmpvar_9; + tmpvar_9 = tmpvar_8; + light = tmpvar_9; + vec4 tmpvar_10; + tmpvar_10 = log2 (light); + vec4 tmpvar_11; + tmpvar_11 = -(tmpvar_10); + light = tmpvar_11; + vec4 tmpvar_12; + tmpvar_12 = texture2D (unity_Lightmap, IN.hip_lmapFade.xy); + vec3 tmpvar_13; + tmpvar_13 = DecodeLightmap (tmpvar_12); + vec3 tmpvar_14; + tmpvar_14 = tmpvar_13; + lmFull = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = texture2D (unity_LightmapInd, IN.hip_lmapFade.xy); + vec3 tmpvar_16; + tmpvar_16 = DecodeLightmap (tmpvar_15); + vec3 tmpvar_17; + tmpvar_17 = tmpvar_16; + lmIndirect = tmpvar_17; + float tmpvar_18; + tmpvar_18 = xll_saturate (IN.hip_lmapFade.z); + vec3 tmpvar_19; + tmpvar_19 = vec3(tmpvar_18); + vec3 tmpvar_20; + tmpvar_20 = mix (lmIndirect, lmFull, tmpvar_19); + vec3 tmpvar_21; + tmpvar_21 = tmpvar_20; + lm = tmpvar_21; + vec3 tmpvar_22; + tmpvar_22 = (light.xyz + lm); + light.xyz = tmpvar_22.xyz.xyz; + vec4 tmpvar_23; + tmpvar_23 = LightingLambert_PrePass (o, light); + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + col = tmpvar_24; + vec3 tmpvar_25; + tmpvar_25 = (col.xyz + o.Emission); + col.xyz = tmpvar_25.xyz.xyz; + return col; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyzw; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.hip_screen = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.hip_lmapFade = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = frag_surf (xlt_IN); + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xl_retval = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = xl_retval.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + gl_FragData[0] = tmpvar_12; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Diffuse1-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Diffuse1-out.txt new file mode 100644 index 000000000..2a6aa153e --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Diffuse1-out.txt @@ -0,0 +1,28 @@ +uniform sampler2D unity_LightmapInd; +uniform sampler2D unity_Lightmap; +uniform sampler2D _MainTex; +uniform sampler2D _LightBuffer; +uniform sampler2D _Illum; +uniform vec4 _Color; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = gl_TexCoord[0]; + vec3 tmpvar_2; + tmpvar_2 = gl_TexCoord[2].xyz; + vec4 col; + vec4 light; + vec4 tmpvar_3; + tmpvar_3 = (texture2D (_MainTex, tmpvar_1.xy) * _Color); + vec4 tmpvar_4; + tmpvar_4 = -(log2 (texture2DProj (_LightBuffer, gl_TexCoord[1]))); + light = tmpvar_4; + light.xyz = (tmpvar_4.xyz + mix ((2.0 * texture2D (unity_LightmapInd, tmpvar_2.xy).xyz), (2.0 * texture2D (unity_Lightmap, tmpvar_2.xy).xyz), vec3(clamp (tmpvar_2.z, 0.0, 1.0)))); + vec4 c_i0; + c_i0.xyz = (tmpvar_3.xyz * light.xyz); + c_i0.w = tmpvar_3.w; + col = c_i0; + col.xyz = (c_i0.xyz + (tmpvar_3.xyz * texture2D (_Illum, tmpvar_1.zw).w)); + gl_FragData[0] = col; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Parallax_Diffuse-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Parallax_Diffuse-in.txt new file mode 100644 index 000000000..d556f4e7b --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Parallax_Diffuse-in.txt @@ -0,0 +1,134 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; + vec2 uv_Illum; + vec3 viewDir; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 viewDir; + vec3 lightDir; + vec4 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform sampler2D _BumpMap; +uniform vec4 _Color; +uniform sampler2D _Illum; +uniform vec4 _LightColor0; +uniform sampler2D _LightTexture0; +uniform sampler2D _LightTextureB0; +uniform sampler2D _MainTex; +uniform float _Parallax; +uniform sampler2D _ParallaxMap; +vec4 UnpackNormal( in vec4 packednormal ); +vec2 ParallaxOffset( in float h, in float height, in vec3 viewDir ); +void surf( in Input IN, inout SurfaceOutput o ); +float UnitySpotCookie( in vec4 LightCoord ); +float UnitySpotAttenuate( in vec3 LightCoord ); +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ); +vec4 frag_surf( in v2f_surf IN ); +vec4 UnpackNormal( in vec4 packednormal ) { + vec4 normal; + normal.xy = ((packednormal.wy * 2.00000) - 1.00000); + normal.z = sqrt( ((1.00000 - (normal.x * normal.x )) - (normal.y * normal.y )) ); + return normal; +} +vec2 ParallaxOffset( in float h, in float height, in vec3 viewDir ) { + vec3 v; + h = ((h * height) - (height / 2.00000)); + v = normalize( viewDir ); + v.z += 0.420000; + return (h * (v.xy / v.z )); +} +void surf( in Input IN, inout SurfaceOutput o ) { + float h; + vec2 offset; + vec4 c; + h = texture2D( _ParallaxMap, IN.uv_BumpMap).w ; + offset = ParallaxOffset( h, _Parallax, IN.viewDir); + IN.uv_MainTex += offset; + IN.uv_BumpMap += offset; + IN.uv_Illum += offset; + c = (texture2D( _MainTex, IN.uv_MainTex) * _Color); + o.Albedo = c.xyz ; + o.Emission = (c.xyz * texture2D( _Illum, IN.uv_Illum).w ); + o.Alpha = c.w ; + o.Normal = vec3( UnpackNormal( texture2D( _BumpMap, IN.uv_BumpMap))); +} +float UnitySpotCookie( in vec4 LightCoord ) { + return texture2D( _LightTexture0, ((LightCoord.xy / LightCoord.w ) + 0.500000)).w ; +} +float UnitySpotAttenuate( in vec3 LightCoord ) { + return texture2D( _LightTextureB0, vec2( vec2( dot( LightCoord, LightCoord)))).w ; +} +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ) { + float diff; + vec4 c; + diff = max( 0.000000, dot( s.Normal, lightDir)); + c.xyz = ((s.Albedo * _LightColor0.xyz ) * ((diff * atten) * 2.00000)); + c.w = s.Alpha; + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec3 lightDir; + vec4 c; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + surfIN.uv_BumpMap = IN.hip_pack0.zw ; + surfIN.viewDir = IN.viewDir; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + surf( surfIN, o); + lightDir = IN.lightDir; + lightDir = normalize( lightDir ); + c = LightingLambert( o, lightDir, ((float( (IN._LightCoord.z > 0.000000) ) * UnitySpotCookie( IN._LightCoord)) * UnitySpotAttenuate( IN._LightCoord.xyz ))); + c.w = 0.000000; + return c; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec4( gl_TexCoord[0]); + xlt_IN.viewDir = vec3( gl_TexCoord[1]); + xlt_IN.lightDir = vec3( gl_TexCoord[2]); + xlt_IN._LightCoord = vec4( gl_TexCoord[3]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Parallax_Diffuse-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Parallax_Diffuse-ir.txt new file mode 100644 index 000000000..10c95e6ce --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Parallax_Diffuse-ir.txt @@ -0,0 +1,269 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; + vec2 uv_Illum; + vec3 viewDir; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 viewDir; + vec3 lightDir; + vec4 _LightCoord; +}; +varying vec4 xlv_FOG; +uniform sampler2D _ParallaxMap; +uniform float _Parallax; +uniform sampler2D _MainTex; +uniform sampler2D _LightTextureB0; +uniform sampler2D _LightTexture0; +uniform vec4 _LightColor0; +uniform sampler2D _Illum; +uniform vec4 _Color; +uniform sampler2D _BumpMap; +vec4 UnpackNormal ( + in vec4 packednormal +) +{ + vec4 normal; + vec2 tmpvar_1; + tmpvar_1 = ((packednormal.wy * 2.0) - 1.0); + normal.xy = tmpvar_1.xy.xy; + float tmpvar_2; + tmpvar_2 = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + normal.z = vec3(tmpvar_3).z; + return normal; +} + +vec2 ParallaxOffset ( + in float h, + in float height, + in vec3 viewDir +) +{ + vec3 v; + float tmpvar_1; + tmpvar_1 = ((h * height) - (height / 2.0)); + h = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = normalize (viewDir); + vec3 tmpvar_3; + tmpvar_3 = tmpvar_2; + v = tmpvar_3; + float tmpvar_4; + tmpvar_4 = (v.z + 0.42); + v.z = vec3(tmpvar_4).z; + return (h * (v.xy / v.z)); +} + +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 c; + vec2 offset; + float h; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_ParallaxMap, IN.uv_BumpMap); + float tmpvar_2; + tmpvar_2 = tmpvar_1.w; + h = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = ParallaxOffset (h, _Parallax, IN.viewDir); + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + offset = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5 = (IN.uv_MainTex + offset); + IN.uv_MainTex = tmpvar_5; + vec2 tmpvar_6; + tmpvar_6 = (IN.uv_BumpMap + offset); + IN.uv_BumpMap = tmpvar_6; + vec2 tmpvar_7; + tmpvar_7 = (IN.uv_Illum + offset); + IN.uv_Illum = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_9; + tmpvar_9 = (tmpvar_8 * _Color); + c = tmpvar_9; + vec3 tmpvar_10; + tmpvar_10 = c.xyz; + o.Albedo = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = texture2D (_Illum, IN.uv_Illum); + vec3 tmpvar_12; + tmpvar_12 = (c.xyz * tmpvar_11.w); + o.Emission = tmpvar_12; + float tmpvar_13; + tmpvar_13 = c.w; + o.Alpha = tmpvar_13; + vec4 tmpvar_14; + tmpvar_14 = texture2D (_BumpMap, IN.uv_BumpMap); + vec4 tmpvar_15; + tmpvar_15 = UnpackNormal (tmpvar_14); + vec3 tmpvar_16; + tmpvar_16 = tmpvar_15.xyz; + vec3 tmpvar_17; + tmpvar_17 = tmpvar_16; + o.Normal = tmpvar_17; +} + +float UnitySpotCookie ( + in vec4 LightCoord +) +{ + vec4 tmpvar_1; + tmpvar_1 = texture2D (_LightTexture0, ((LightCoord.xy / LightCoord.w) + 0.5)); + return tmpvar_1.w; +} + +float UnitySpotAttenuate ( + in vec3 LightCoord +) +{ + float tmpvar_1; + tmpvar_1 = dot (LightCoord, LightCoord); + vec2 tmpvar_2; + tmpvar_2 = vec2(tmpvar_1); + vec2 tmpvar_3; + tmpvar_3 = tmpvar_2.xy; + vec4 tmpvar_4; + tmpvar_4 = texture2D (_LightTextureB0, tmpvar_3); + return tmpvar_4.w; +} + +vec4 LightingLambert ( + in SurfaceOutput s, + in vec3 lightDir, + in float atten +) +{ + vec4 c; + float diff; + float tmpvar_1; + tmpvar_1 = dot (s.Normal, lightDir); + float tmpvar_2; + tmpvar_2 = max (0.0, tmpvar_1); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + diff = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = ((s.Albedo * _LightColor0.xyz) * ((diff * atten) * 2.0)); + c.xyz = tmpvar_4.xyz.xyz; + float tmpvar_5; + tmpvar_5 = s.Alpha; + c.w = vec4(tmpvar_5).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 c; + vec3 lightDir; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = IN.hip_pack0.zw; + surfIN.uv_BumpMap = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = IN.viewDir; + surfIN.viewDir = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Specular = tmpvar_6; + float tmpvar_7; + tmpvar_7 = 0.0; + o.Alpha = tmpvar_7; + float tmpvar_8; + tmpvar_8 = 0.0; + o.Gloss = tmpvar_8; + surf (surfIN, o); + vec3 tmpvar_9; + tmpvar_9 = IN.lightDir; + lightDir = tmpvar_9; + vec3 tmpvar_10; + tmpvar_10 = normalize (lightDir); + vec3 tmpvar_11; + tmpvar_11 = tmpvar_10; + lightDir = tmpvar_11; + float tmpvar_12; + tmpvar_12 = UnitySpotCookie (IN._LightCoord); + float tmpvar_13; + tmpvar_13 = UnitySpotAttenuate (IN._LightCoord.xyz); + vec4 tmpvar_14; + tmpvar_14 = LightingLambert (o, lightDir, ((float((IN._LightCoord.z > 0.0)) * tmpvar_12) * tmpvar_13)); + vec4 tmpvar_15; + tmpvar_15 = tmpvar_14; + c = tmpvar_15; + float tmpvar_16; + tmpvar_16 = 0.0; + c.w = vec4(tmpvar_16).w; + return c; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.viewDir = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.lightDir = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_TexCoord[3].xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_IN._LightCoord = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = frag_surf (xlt_IN); + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xl_retval = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = xl_retval.xyzw; + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + gl_FragData[0] = tmpvar_14; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Parallax_Diffuse-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Parallax_Diffuse-out.txt new file mode 100644 index 000000000..b81bd1ac8 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Parallax_Diffuse-out.txt @@ -0,0 +1,37 @@ +uniform sampler2D _ParallaxMap; +uniform float _Parallax; +uniform sampler2D _MainTex; +uniform sampler2D _LightTextureB0; +uniform sampler2D _LightTexture0; +uniform vec4 _LightColor0; +uniform vec4 _Color; +uniform sampler2D _BumpMap; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = gl_TexCoord[0]; + vec4 tmpvar_2; + tmpvar_2 = gl_TexCoord[3]; + vec4 c; + vec2 tmpvar_3; + vec3 v; + vec3 tmpvar_4; + tmpvar_4 = normalize (gl_TexCoord[1].xyz); + v = tmpvar_4; + v.z = (tmpvar_4.z + 0.42); + tmpvar_3 = (((texture2D (_ParallaxMap, tmpvar_1.zw).w * _Parallax) - (_Parallax / 2.0)) * (tmpvar_4.xy / v.z)); + vec4 tmpvar_5; + tmpvar_5 = (texture2D (_MainTex, (tmpvar_1.xy + tmpvar_3)) * _Color); + vec4 normal; + normal.xy = ((texture2D (_BumpMap, (tmpvar_1.zw + tmpvar_3)).wy * 2.0) - 1.0); + normal.z = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + vec3 LightCoord_i0; + LightCoord_i0 = tmpvar_2.xyz; + vec4 c_i0_i1; + c_i0_i1.xyz = ((tmpvar_5.xyz * _LightColor0.xyz) * ((max (0.0, dot (normal.xyz, normalize (gl_TexCoord[2].xyz))) * ((float((tmpvar_2.z > 0.0)) * texture2D (_LightTexture0, ((tmpvar_2.xy / tmpvar_2.w) + 0.5)).w) * texture2D (_LightTextureB0, vec2(dot (LightCoord_i0, LightCoord_i0))).w)) * 2.0)); + c_i0_i1.w = tmpvar_5.w; + c = c_i0_i1; + c.w = 0.0; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Parallax_Diffuse1-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Parallax_Diffuse1-in.txt new file mode 100644 index 000000000..b3efee054 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Parallax_Diffuse1-in.txt @@ -0,0 +1,124 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; + vec2 uv_Illum; + vec3 viewDir; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 viewDir; + vec3 lightDir; + vec2 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform sampler2D _BumpMap; +uniform vec4 _Color; +uniform sampler2D _Illum; +uniform vec4 _LightColor0; +uniform sampler2D _LightTexture0; +uniform sampler2D _MainTex; +uniform float _Parallax; +uniform sampler2D _ParallaxMap; +vec4 UnpackNormal( in vec4 packednormal ); +vec2 ParallaxOffset( in float h, in float height, in vec3 viewDir ); +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ); +vec4 frag_surf( in v2f_surf IN ); +vec4 UnpackNormal( in vec4 packednormal ) { + vec4 normal; + normal.xy = ((packednormal.wy * 2.00000) - 1.00000); + normal.z = sqrt( ((1.00000 - (normal.x * normal.x )) - (normal.y * normal.y )) ); + return normal; +} +vec2 ParallaxOffset( in float h, in float height, in vec3 viewDir ) { + vec3 v; + h = ((h * height) - (height / 2.00000)); + v = normalize( viewDir ); + v.z += 0.420000; + return (h * (v.xy / v.z )); +} +void surf( in Input IN, inout SurfaceOutput o ) { + float h; + vec2 offset; + vec4 c; + h = texture2D( _ParallaxMap, IN.uv_BumpMap).w ; + offset = ParallaxOffset( h, _Parallax, IN.viewDir); + IN.uv_MainTex += offset; + IN.uv_BumpMap += offset; + IN.uv_Illum += offset; + c = (texture2D( _MainTex, IN.uv_MainTex) * _Color); + o.Albedo = c.xyz ; + o.Emission = (c.xyz * texture2D( _Illum, IN.uv_Illum).w ); + o.Alpha = c.w ; + o.Normal = vec3( UnpackNormal( texture2D( _BumpMap, IN.uv_BumpMap))); +} +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ) { + float diff; + vec4 c; + diff = max( 0.000000, dot( s.Normal, lightDir)); + c.xyz = ((s.Albedo * _LightColor0.xyz ) * ((diff * atten) * 2.00000)); + c.w = s.Alpha; + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec3 lightDir; + vec4 c; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + surfIN.uv_BumpMap = IN.hip_pack0.zw ; + surfIN.viewDir = IN.viewDir; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + surf( surfIN, o); + lightDir = IN.lightDir; + c = LightingLambert( o, lightDir, (texture2D( _LightTexture0, IN._LightCoord).w * 1.00000)); + c.w = 0.000000; + return c; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec4( gl_TexCoord[0]); + xlt_IN.viewDir = vec3( gl_TexCoord[1]); + xlt_IN.lightDir = vec3( gl_TexCoord[2]); + xlt_IN._LightCoord = vec2( gl_TexCoord[3]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Parallax_Diffuse1-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Parallax_Diffuse1-ir.txt new file mode 100644 index 000000000..86abcee64 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Parallax_Diffuse1-ir.txt @@ -0,0 +1,237 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; + vec2 uv_Illum; + vec3 viewDir; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 viewDir; + vec3 lightDir; + vec2 _LightCoord; +}; +varying vec4 xlv_FOG; +uniform sampler2D _ParallaxMap; +uniform float _Parallax; +uniform sampler2D _MainTex; +uniform sampler2D _LightTexture0; +uniform vec4 _LightColor0; +uniform sampler2D _Illum; +uniform vec4 _Color; +uniform sampler2D _BumpMap; +vec4 UnpackNormal ( + in vec4 packednormal +) +{ + vec4 normal; + vec2 tmpvar_1; + tmpvar_1 = ((packednormal.wy * 2.0) - 1.0); + normal.xy = tmpvar_1.xy.xy; + float tmpvar_2; + tmpvar_2 = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + normal.z = vec3(tmpvar_3).z; + return normal; +} + +vec2 ParallaxOffset ( + in float h, + in float height, + in vec3 viewDir +) +{ + vec3 v; + float tmpvar_1; + tmpvar_1 = ((h * height) - (height / 2.0)); + h = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = normalize (viewDir); + vec3 tmpvar_3; + tmpvar_3 = tmpvar_2; + v = tmpvar_3; + float tmpvar_4; + tmpvar_4 = (v.z + 0.42); + v.z = vec3(tmpvar_4).z; + return (h * (v.xy / v.z)); +} + +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 c; + vec2 offset; + float h; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_ParallaxMap, IN.uv_BumpMap); + float tmpvar_2; + tmpvar_2 = tmpvar_1.w; + h = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = ParallaxOffset (h, _Parallax, IN.viewDir); + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + offset = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5 = (IN.uv_MainTex + offset); + IN.uv_MainTex = tmpvar_5; + vec2 tmpvar_6; + tmpvar_6 = (IN.uv_BumpMap + offset); + IN.uv_BumpMap = tmpvar_6; + vec2 tmpvar_7; + tmpvar_7 = (IN.uv_Illum + offset); + IN.uv_Illum = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_9; + tmpvar_9 = (tmpvar_8 * _Color); + c = tmpvar_9; + vec3 tmpvar_10; + tmpvar_10 = c.xyz; + o.Albedo = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = texture2D (_Illum, IN.uv_Illum); + vec3 tmpvar_12; + tmpvar_12 = (c.xyz * tmpvar_11.w); + o.Emission = tmpvar_12; + float tmpvar_13; + tmpvar_13 = c.w; + o.Alpha = tmpvar_13; + vec4 tmpvar_14; + tmpvar_14 = texture2D (_BumpMap, IN.uv_BumpMap); + vec4 tmpvar_15; + tmpvar_15 = UnpackNormal (tmpvar_14); + vec3 tmpvar_16; + tmpvar_16 = tmpvar_15.xyz; + vec3 tmpvar_17; + tmpvar_17 = tmpvar_16; + o.Normal = tmpvar_17; +} + +vec4 LightingLambert ( + in SurfaceOutput s, + in vec3 lightDir, + in float atten +) +{ + vec4 c; + float diff; + float tmpvar_1; + tmpvar_1 = dot (s.Normal, lightDir); + float tmpvar_2; + tmpvar_2 = max (0.0, tmpvar_1); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + diff = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = ((s.Albedo * _LightColor0.xyz) * ((diff * atten) * 2.0)); + c.xyz = tmpvar_4.xyz.xyz; + float tmpvar_5; + tmpvar_5 = s.Alpha; + c.w = vec4(tmpvar_5).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 c; + vec3 lightDir; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = IN.hip_pack0.zw; + surfIN.uv_BumpMap = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = IN.viewDir; + surfIN.viewDir = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Specular = tmpvar_6; + float tmpvar_7; + tmpvar_7 = 0.0; + o.Alpha = tmpvar_7; + float tmpvar_8; + tmpvar_8 = 0.0; + o.Gloss = tmpvar_8; + surf (surfIN, o); + vec3 tmpvar_9; + tmpvar_9 = IN.lightDir; + lightDir = tmpvar_9; + vec4 tmpvar_10; + tmpvar_10 = texture2D (_LightTexture0, IN._LightCoord); + vec4 tmpvar_11; + tmpvar_11 = LightingLambert (o, lightDir, (tmpvar_10.w * 1.0)); + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + c = tmpvar_12; + float tmpvar_13; + tmpvar_13 = 0.0; + c.w = vec4(tmpvar_13).w; + return c; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.viewDir = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.lightDir = tmpvar_8; + vec2 tmpvar_9; + tmpvar_9 = gl_TexCoord[3].xy; + vec2 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_IN._LightCoord = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = frag_surf (xlt_IN); + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xl_retval = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = xl_retval.xyzw; + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + gl_FragData[0] = tmpvar_14; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Parallax_Diffuse1-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Parallax_Diffuse1-out.txt new file mode 100644 index 000000000..6dca21aef --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Parallax_Diffuse1-out.txt @@ -0,0 +1,32 @@ +uniform sampler2D _ParallaxMap; +uniform float _Parallax; +uniform sampler2D _MainTex; +uniform sampler2D _LightTexture0; +uniform vec4 _LightColor0; +uniform vec4 _Color; +uniform sampler2D _BumpMap; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = gl_TexCoord[0]; + vec4 c; + vec2 tmpvar_2; + vec3 v; + vec3 tmpvar_3; + tmpvar_3 = normalize (gl_TexCoord[1].xyz); + v = tmpvar_3; + v.z = (tmpvar_3.z + 0.42); + tmpvar_2 = (((texture2D (_ParallaxMap, tmpvar_1.zw).w * _Parallax) - (_Parallax / 2.0)) * (tmpvar_3.xy / v.z)); + vec4 tmpvar_4; + tmpvar_4 = (texture2D (_MainTex, (tmpvar_1.xy + tmpvar_2)) * _Color); + vec4 normal; + normal.xy = ((texture2D (_BumpMap, (tmpvar_1.zw + tmpvar_2)).wy * 2.0) - 1.0); + normal.z = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + vec4 c_i0_i1; + c_i0_i1.xyz = ((tmpvar_4.xyz * _LightColor0.xyz) * ((max (0.0, dot (normal.xyz, gl_TexCoord[2].xyz)) * texture2D (_LightTexture0, gl_TexCoord[3].xy).w) * 2.0)); + c_i0_i1.w = tmpvar_4.w; + c = c_i0_i1; + c.w = 0.0; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Parallax_Diffuse2-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Parallax_Diffuse2-in.txt new file mode 100644 index 000000000..0d08c5a73 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Parallax_Diffuse2-in.txt @@ -0,0 +1,125 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; + vec2 uv_Illum; + vec3 viewDir; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec2 hip_pack1; + vec3 viewDir; + vec4 hip_screen; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform sampler2D _BumpMap; +uniform vec4 _Color; +uniform sampler2D _Illum; +uniform sampler2D _LightBuffer; +uniform sampler2D _MainTex; +uniform float _Parallax; +uniform sampler2D _ParallaxMap; +uniform vec4 unity_Ambient; +vec4 UnpackNormal( in vec4 packednormal ); +vec2 ParallaxOffset( in float h, in float height, in vec3 viewDir ); +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingLambert_PrePass( in SurfaceOutput s, in vec4 light ); +vec4 frag_surf( in v2f_surf IN ); +vec4 UnpackNormal( in vec4 packednormal ) { + vec4 normal; + normal.xy = ((packednormal.wy * 2.00000) - 1.00000); + normal.z = sqrt( ((1.00000 - (normal.x * normal.x )) - (normal.y * normal.y )) ); + return normal; +} +vec2 ParallaxOffset( in float h, in float height, in vec3 viewDir ) { + vec3 v; + h = ((h * height) - (height / 2.00000)); + v = normalize( viewDir ); + v.z += 0.420000; + return (h * (v.xy / v.z )); +} +void surf( in Input IN, inout SurfaceOutput o ) { + float h; + vec2 offset; + vec4 c; + h = texture2D( _ParallaxMap, IN.uv_BumpMap).w ; + offset = ParallaxOffset( h, _Parallax, IN.viewDir); + IN.uv_MainTex += offset; + IN.uv_BumpMap += offset; + IN.uv_Illum += offset; + c = (texture2D( _MainTex, IN.uv_MainTex) * _Color); + o.Albedo = c.xyz ; + o.Emission = (c.xyz * texture2D( _Illum, IN.uv_Illum).w ); + o.Alpha = c.w ; + o.Normal = vec3( UnpackNormal( texture2D( _BumpMap, IN.uv_BumpMap))); +} +vec4 LightingLambert_PrePass( in SurfaceOutput s, in vec4 light ) { + vec4 c; + c.xyz = (s.Albedo * light.xyz ); + c.w = s.Alpha; + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec4 light; + vec4 col; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + surfIN.uv_BumpMap = IN.hip_pack0.zw ; + surfIN.uv_Illum = IN.hip_pack1.xy ; + surfIN.viewDir = IN.viewDir; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + surf( surfIN, o); + light = texture2DProj( _LightBuffer, IN.hip_screen); + light = ( -log2( light ) ); + light.xyz += unity_Ambient.xyz ; + col = LightingLambert_PrePass( o, light); + col.xyz += o.Emission; + return col; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec4( gl_TexCoord[0]); + xlt_IN.hip_pack1 = vec2( gl_TexCoord[1]); + xlt_IN.viewDir = vec3( gl_TexCoord[2]); + xlt_IN.hip_screen = vec4( gl_TexCoord[3]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Parallax_Diffuse2-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Parallax_Diffuse2-ir.txt new file mode 100644 index 000000000..d10ce26fa --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Parallax_Diffuse2-ir.txt @@ -0,0 +1,239 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; + vec2 uv_Illum; + vec3 viewDir; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec2 hip_pack1; + vec3 viewDir; + vec4 hip_screen; +}; +varying vec4 xlv_FOG; +uniform vec4 unity_Ambient; +uniform sampler2D _ParallaxMap; +uniform float _Parallax; +uniform sampler2D _MainTex; +uniform sampler2D _LightBuffer; +uniform sampler2D _Illum; +uniform vec4 _Color; +uniform sampler2D _BumpMap; +vec4 UnpackNormal ( + in vec4 packednormal +) +{ + vec4 normal; + vec2 tmpvar_1; + tmpvar_1 = ((packednormal.wy * 2.0) - 1.0); + normal.xy = tmpvar_1.xy.xy; + float tmpvar_2; + tmpvar_2 = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + normal.z = vec3(tmpvar_3).z; + return normal; +} + +vec2 ParallaxOffset ( + in float h, + in float height, + in vec3 viewDir +) +{ + vec3 v; + float tmpvar_1; + tmpvar_1 = ((h * height) - (height / 2.0)); + h = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = normalize (viewDir); + vec3 tmpvar_3; + tmpvar_3 = tmpvar_2; + v = tmpvar_3; + float tmpvar_4; + tmpvar_4 = (v.z + 0.42); + v.z = vec3(tmpvar_4).z; + return (h * (v.xy / v.z)); +} + +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 c; + vec2 offset; + float h; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_ParallaxMap, IN.uv_BumpMap); + float tmpvar_2; + tmpvar_2 = tmpvar_1.w; + h = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = ParallaxOffset (h, _Parallax, IN.viewDir); + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + offset = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5 = (IN.uv_MainTex + offset); + IN.uv_MainTex = tmpvar_5; + vec2 tmpvar_6; + tmpvar_6 = (IN.uv_BumpMap + offset); + IN.uv_BumpMap = tmpvar_6; + vec2 tmpvar_7; + tmpvar_7 = (IN.uv_Illum + offset); + IN.uv_Illum = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_9; + tmpvar_9 = (tmpvar_8 * _Color); + c = tmpvar_9; + vec3 tmpvar_10; + tmpvar_10 = c.xyz; + o.Albedo = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = texture2D (_Illum, IN.uv_Illum); + vec3 tmpvar_12; + tmpvar_12 = (c.xyz * tmpvar_11.w); + o.Emission = tmpvar_12; + float tmpvar_13; + tmpvar_13 = c.w; + o.Alpha = tmpvar_13; + vec4 tmpvar_14; + tmpvar_14 = texture2D (_BumpMap, IN.uv_BumpMap); + vec4 tmpvar_15; + tmpvar_15 = UnpackNormal (tmpvar_14); + vec3 tmpvar_16; + tmpvar_16 = tmpvar_15.xyz; + vec3 tmpvar_17; + tmpvar_17 = tmpvar_16; + o.Normal = tmpvar_17; +} + +vec4 LightingLambert_PrePass ( + in SurfaceOutput s, + in vec4 light +) +{ + vec4 c; + vec3 tmpvar_1; + tmpvar_1 = (s.Albedo * light.xyz); + c.xyz = tmpvar_1.xyz.xyz; + float tmpvar_2; + tmpvar_2 = s.Alpha; + c.w = vec4(tmpvar_2).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 col; + vec4 light; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = IN.hip_pack0.zw; + surfIN.uv_BumpMap = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = IN.hip_pack1.xy; + surfIN.uv_Illum = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = IN.viewDir; + surfIN.viewDir = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_6; + float tmpvar_7; + tmpvar_7 = 0.0; + o.Specular = tmpvar_7; + float tmpvar_8; + tmpvar_8 = 0.0; + o.Alpha = tmpvar_8; + float tmpvar_9; + tmpvar_9 = 0.0; + o.Gloss = tmpvar_9; + surf (surfIN, o); + vec4 tmpvar_10; + tmpvar_10 = texture2DProj (_LightBuffer, IN.hip_screen); + vec4 tmpvar_11; + tmpvar_11 = tmpvar_10; + light = tmpvar_11; + vec4 tmpvar_12; + tmpvar_12 = log2 (light); + vec4 tmpvar_13; + tmpvar_13 = -(tmpvar_12); + light = tmpvar_13; + vec3 tmpvar_14; + tmpvar_14 = (light.xyz + unity_Ambient.xyz); + light.xyz = tmpvar_14.xyz.xyz; + vec4 tmpvar_15; + tmpvar_15 = LightingLambert_PrePass (o, light); + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + col = tmpvar_16; + vec3 tmpvar_17; + tmpvar_17 = (col.xyz + o.Emission); + col.xyz = tmpvar_17.xyz.xyz; + return col; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xy; + vec2 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.hip_pack1 = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.viewDir = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_TexCoord[3].xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_IN.hip_screen = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = frag_surf (xlt_IN); + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xl_retval = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = xl_retval.xyzw; + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + gl_FragData[0] = tmpvar_14; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Parallax_Diffuse2-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Parallax_Diffuse2-out.txt new file mode 100644 index 000000000..a2307098d --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Parallax_Diffuse2-out.txt @@ -0,0 +1,38 @@ +uniform vec4 unity_Ambient; +uniform sampler2D _ParallaxMap; +uniform float _Parallax; +uniform sampler2D _MainTex; +uniform sampler2D _LightBuffer; +uniform sampler2D _Illum; +uniform vec4 _Color; +uniform sampler2D _BumpMap; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = gl_TexCoord[0]; + vec4 col; + vec4 light; + vec2 tmpvar_2; + vec3 v; + vec3 tmpvar_3; + tmpvar_3 = normalize (gl_TexCoord[2].xyz); + v = tmpvar_3; + v.z = (tmpvar_3.z + 0.42); + tmpvar_2 = (((texture2D (_ParallaxMap, tmpvar_1.zw).w * _Parallax) - (_Parallax / 2.0)) * (tmpvar_3.xy / v.z)); + vec4 tmpvar_4; + tmpvar_4 = (texture2D (_MainTex, (tmpvar_1.xy + tmpvar_2)) * _Color); + vec4 normal; + normal.xy = ((texture2D (_BumpMap, (tmpvar_1.zw + tmpvar_2)).wy * 2.0) - 1.0); + normal.z = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + vec4 tmpvar_5; + tmpvar_5 = -(log2 (texture2DProj (_LightBuffer, gl_TexCoord[3]))); + light = tmpvar_5; + light.xyz = (tmpvar_5.xyz + unity_Ambient.xyz); + vec4 c_i0; + c_i0.xyz = (tmpvar_4.xyz * light.xyz); + c_i0.w = tmpvar_4.w; + col = c_i0; + col.xyz = (c_i0.xyz + (tmpvar_4.xyz * texture2D (_Illum, (gl_TexCoord[1].xy + tmpvar_2)).w)); + gl_FragData[0] = col; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Parallax_Specular-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Parallax_Specular-in.txt new file mode 100644 index 000000000..64349e860 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Parallax_Specular-in.txt @@ -0,0 +1,137 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; + vec2 uv_Illum; + vec3 viewDir; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 viewDir; + vec3 lightDir; + vec3 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform sampler2D _BumpMap; +uniform vec4 _Color; +uniform sampler2D _Illum; +uniform vec4 _LightColor0; +uniform sampler2D _LightTexture0; +uniform sampler2D _MainTex; +uniform float _Parallax; +uniform sampler2D _ParallaxMap; +uniform float _Shininess; +uniform vec4 _SpecColor; +vec4 UnpackNormal( in vec4 packednormal ); +vec2 ParallaxOffset( in float h, in float height, in vec3 viewDir ); +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingBlinnPhong( in SurfaceOutput s, in vec3 lightDir, in vec3 viewDir, in float atten ); +vec4 frag_surf( in v2f_surf IN ); +vec4 UnpackNormal( in vec4 packednormal ) { + vec4 normal; + normal.xy = ((packednormal.wy * 2.00000) - 1.00000); + normal.z = sqrt( ((1.00000 - (normal.x * normal.x )) - (normal.y * normal.y )) ); + return normal; +} +vec2 ParallaxOffset( in float h, in float height, in vec3 viewDir ) { + vec3 v; + h = ((h * height) - (height / 2.00000)); + v = normalize( viewDir ); + v.z += 0.420000; + return (h * (v.xy / v.z )); +} +void surf( in Input IN, inout SurfaceOutput o ) { + float h; + vec2 offset; + vec4 tex; + vec4 c; + h = texture2D( _ParallaxMap, IN.uv_BumpMap).w ; + offset = ParallaxOffset( h, _Parallax, IN.viewDir); + IN.uv_MainTex += offset; + IN.uv_BumpMap += offset; + IN.uv_Illum += offset; + tex = texture2D( _MainTex, IN.uv_MainTex); + c = (tex * _Color); + o.Albedo = c.xyz ; + o.Gloss = tex.w ; + o.Emission = (c.xyz * texture2D( _Illum, IN.uv_Illum).w ); + o.Specular = _Shininess; + o.Alpha = c.w ; + o.Normal = vec3( UnpackNormal( texture2D( _BumpMap, IN.uv_BumpMap))); +} +vec4 LightingBlinnPhong( in SurfaceOutput s, in vec3 lightDir, in vec3 viewDir, in float atten ) { + vec3 h; + float diff; + float nh; + float spec; + vec4 c; + h = normalize( (lightDir + viewDir) ); + diff = max( 0.000000, dot( s.Normal, lightDir)); + nh = max( 0.000000, dot( s.Normal, h)); + spec = (pow( nh, (s.Specular * 128.000)) * s.Gloss); + c.xyz = ((((s.Albedo * _LightColor0.xyz ) * diff) + ((_LightColor0.xyz * _SpecColor.xyz ) * spec)) * (atten * 2.00000)); + c.w = (s.Alpha + (((_LightColor0.w * _SpecColor.w ) * spec) * atten)); + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec3 lightDir; + vec4 c; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + surfIN.uv_BumpMap = IN.hip_pack0.zw ; + surfIN.viewDir = IN.viewDir; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + surf( surfIN, o); + lightDir = IN.lightDir; + lightDir = normalize( lightDir ); + c = LightingBlinnPhong( o, lightDir, normalize( vec3( IN.viewDir) ), texture2D( _LightTexture0, vec2( vec2( dot( IN._LightCoord, IN._LightCoord)))).w ); + c.w = 0.000000; + return c; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec4( gl_TexCoord[0]); + xlt_IN.viewDir = vec3( gl_TexCoord[1]); + xlt_IN.lightDir = vec3( gl_TexCoord[2]); + xlt_IN._LightCoord = vec3( gl_TexCoord[3]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Parallax_Specular-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Parallax_Specular-ir.txt new file mode 100644 index 000000000..963295d53 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Parallax_Specular-ir.txt @@ -0,0 +1,285 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; + vec2 uv_Illum; + vec3 viewDir; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 viewDir; + vec3 lightDir; + vec3 _LightCoord; +}; +varying vec4 xlv_FOG; +uniform vec4 _SpecColor; +uniform float _Shininess; +uniform sampler2D _ParallaxMap; +uniform float _Parallax; +uniform sampler2D _MainTex; +uniform sampler2D _LightTexture0; +uniform vec4 _LightColor0; +uniform sampler2D _Illum; +uniform vec4 _Color; +uniform sampler2D _BumpMap; +vec4 UnpackNormal ( + in vec4 packednormal +) +{ + vec4 normal; + vec2 tmpvar_1; + tmpvar_1 = ((packednormal.wy * 2.0) - 1.0); + normal.xy = tmpvar_1.xy.xy; + float tmpvar_2; + tmpvar_2 = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + normal.z = vec3(tmpvar_3).z; + return normal; +} + +vec2 ParallaxOffset ( + in float h, + in float height, + in vec3 viewDir +) +{ + vec3 v; + float tmpvar_1; + tmpvar_1 = ((h * height) - (height / 2.0)); + h = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = normalize (viewDir); + vec3 tmpvar_3; + tmpvar_3 = tmpvar_2; + v = tmpvar_3; + float tmpvar_4; + tmpvar_4 = (v.z + 0.42); + v.z = vec3(tmpvar_4).z; + return (h * (v.xy / v.z)); +} + +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 c; + vec4 tex; + vec2 offset; + float h; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_ParallaxMap, IN.uv_BumpMap); + float tmpvar_2; + tmpvar_2 = tmpvar_1.w; + h = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = ParallaxOffset (h, _Parallax, IN.viewDir); + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + offset = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5 = (IN.uv_MainTex + offset); + IN.uv_MainTex = tmpvar_5; + vec2 tmpvar_6; + tmpvar_6 = (IN.uv_BumpMap + offset); + IN.uv_BumpMap = tmpvar_6; + vec2 tmpvar_7; + tmpvar_7 = (IN.uv_Illum + offset); + IN.uv_Illum = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_9; + tmpvar_9 = tmpvar_8; + tex = tmpvar_9; + vec4 tmpvar_10; + tmpvar_10 = (tex * _Color); + c = tmpvar_10; + vec3 tmpvar_11; + tmpvar_11 = c.xyz; + o.Albedo = tmpvar_11; + float tmpvar_12; + tmpvar_12 = tex.w; + o.Gloss = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = texture2D (_Illum, IN.uv_Illum); + vec3 tmpvar_14; + tmpvar_14 = (c.xyz * tmpvar_13.w); + o.Emission = tmpvar_14; + float tmpvar_15; + tmpvar_15 = _Shininess; + o.Specular = tmpvar_15; + float tmpvar_16; + tmpvar_16 = c.w; + o.Alpha = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17 = texture2D (_BumpMap, IN.uv_BumpMap); + vec4 tmpvar_18; + tmpvar_18 = UnpackNormal (tmpvar_17); + vec3 tmpvar_19; + tmpvar_19 = tmpvar_18.xyz; + vec3 tmpvar_20; + tmpvar_20 = tmpvar_19; + o.Normal = tmpvar_20; +} + +vec4 LightingBlinnPhong ( + in SurfaceOutput s, + in vec3 lightDir, + in vec3 viewDir, + in float atten +) +{ + vec4 c; + float spec; + float nh; + float diff; + vec3 h; + vec3 tmpvar_1; + tmpvar_1 = normalize ((lightDir + viewDir)); + vec3 tmpvar_2; + tmpvar_2 = tmpvar_1; + h = tmpvar_2; + float tmpvar_3; + tmpvar_3 = dot (s.Normal, lightDir); + float tmpvar_4; + tmpvar_4 = max (0.0, tmpvar_3); + float tmpvar_5; + tmpvar_5 = tmpvar_4; + diff = tmpvar_5; + float tmpvar_6; + tmpvar_6 = dot (s.Normal, h); + float tmpvar_7; + tmpvar_7 = max (0.0, tmpvar_6); + float tmpvar_8; + tmpvar_8 = tmpvar_7; + nh = tmpvar_8; + float tmpvar_9; + tmpvar_9 = pow (nh, (s.Specular * 128.0)); + float tmpvar_10; + tmpvar_10 = (tmpvar_9 * s.Gloss); + spec = tmpvar_10; + vec3 tmpvar_11; + tmpvar_11 = ((((s.Albedo * _LightColor0.xyz) * diff) + ((_LightColor0.xyz * _SpecColor.xyz) * spec)) * (atten * 2.0)); + c.xyz = tmpvar_11.xyz.xyz; + float tmpvar_12; + tmpvar_12 = (s.Alpha + (((_LightColor0.w * _SpecColor.w) * spec) * atten)); + c.w = vec4(tmpvar_12).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 c; + vec3 lightDir; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = IN.hip_pack0.zw; + surfIN.uv_BumpMap = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = IN.viewDir; + surfIN.viewDir = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Specular = tmpvar_6; + float tmpvar_7; + tmpvar_7 = 0.0; + o.Alpha = tmpvar_7; + float tmpvar_8; + tmpvar_8 = 0.0; + o.Gloss = tmpvar_8; + surf (surfIN, o); + vec3 tmpvar_9; + tmpvar_9 = IN.lightDir; + lightDir = tmpvar_9; + vec3 tmpvar_10; + tmpvar_10 = normalize (lightDir); + vec3 tmpvar_11; + tmpvar_11 = tmpvar_10; + lightDir = tmpvar_11; + vec3 tmpvar_12; + tmpvar_12 = IN.viewDir.xyz; + vec3 tmpvar_13; + tmpvar_13 = normalize (tmpvar_12); + float tmpvar_14; + tmpvar_14 = dot (IN._LightCoord, IN._LightCoord); + vec2 tmpvar_15; + tmpvar_15 = vec2(tmpvar_14); + vec2 tmpvar_16; + tmpvar_16 = tmpvar_15.xy; + vec4 tmpvar_17; + tmpvar_17 = texture2D (_LightTexture0, tmpvar_16); + vec4 tmpvar_18; + tmpvar_18 = LightingBlinnPhong (o, lightDir, tmpvar_13, tmpvar_17.w); + vec4 tmpvar_19; + tmpvar_19 = tmpvar_18; + c = tmpvar_19; + float tmpvar_20; + tmpvar_20 = 0.0; + c.w = vec4(tmpvar_20).w; + return c; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.viewDir = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.lightDir = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = gl_TexCoord[3].xyz; + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_IN._LightCoord = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = frag_surf (xlt_IN); + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xl_retval = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = xl_retval.xyzw; + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + gl_FragData[0] = tmpvar_14; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Parallax_Specular-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Parallax_Specular-out.txt new file mode 100644 index 000000000..89e535174 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Parallax_Specular-out.txt @@ -0,0 +1,48 @@ +uniform vec4 _SpecColor; +uniform float _Shininess; +uniform sampler2D _ParallaxMap; +uniform float _Parallax; +uniform sampler2D _MainTex; +uniform sampler2D _LightTexture0; +uniform vec4 _LightColor0; +uniform vec4 _Color; +uniform sampler2D _BumpMap; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = gl_TexCoord[0]; + vec3 tmpvar_2; + tmpvar_2 = gl_TexCoord[1].xyz; + vec3 tmpvar_3; + tmpvar_3 = gl_TexCoord[3].xyz; + vec4 c; + vec2 tmpvar_4; + vec3 v; + vec3 tmpvar_5; + tmpvar_5 = normalize (tmpvar_2); + v = tmpvar_5; + v.z = (tmpvar_5.z + 0.42); + tmpvar_4 = (((texture2D (_ParallaxMap, tmpvar_1.zw).w * _Parallax) - (_Parallax / 2.0)) * (tmpvar_5.xy / v.z)); + vec4 tmpvar_6; + tmpvar_6 = texture2D (_MainTex, (tmpvar_1.xy + tmpvar_4)); + vec4 tmpvar_7; + tmpvar_7 = (tmpvar_6 * _Color); + vec4 normal; + normal.xy = ((texture2D (_BumpMap, (tmpvar_1.zw + tmpvar_4)).wy * 2.0) - 1.0); + normal.z = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + vec3 tmpvar_8; + tmpvar_8 = normal.xyz; + vec3 tmpvar_9; + tmpvar_9 = normalize (gl_TexCoord[2].xyz); + vec4 tmpvar_10; + tmpvar_10 = texture2D (_LightTexture0, vec2(dot (tmpvar_3, tmpvar_3))); + vec4 c_i0_i1; + float tmpvar_11; + tmpvar_11 = (pow (max (0.0, dot (tmpvar_8, normalize ((tmpvar_9 + normalize (tmpvar_2))))), (_Shininess * 128.0)) * tmpvar_6.w); + c_i0_i1.xyz = ((((tmpvar_7.xyz * _LightColor0.xyz) * max (0.0, dot (tmpvar_8, tmpvar_9))) + ((_LightColor0.xyz * _SpecColor.xyz) * tmpvar_11)) * (tmpvar_10.w * 2.0)); + c_i0_i1.w = (tmpvar_7.w + (((_LightColor0.w * _SpecColor.w) * tmpvar_11) * tmpvar_10.w)); + c = c_i0_i1; + c.w = 0.0; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Parallax_Specular1-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Parallax_Specular1-in.txt new file mode 100644 index 000000000..4efc7afec --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Parallax_Specular1-in.txt @@ -0,0 +1,138 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; + vec2 uv_Illum; + vec3 viewDir; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 viewDir; + vec3 lightDir; + vec3 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform sampler2D _BumpMap; +uniform vec4 _Color; +uniform sampler2D _Illum; +uniform vec4 _LightColor0; +uniform samplerCube _LightTexture0; +uniform sampler2D _LightTextureB0; +uniform sampler2D _MainTex; +uniform float _Parallax; +uniform sampler2D _ParallaxMap; +uniform float _Shininess; +uniform vec4 _SpecColor; +vec4 UnpackNormal( in vec4 packednormal ); +vec2 ParallaxOffset( in float h, in float height, in vec3 viewDir ); +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingBlinnPhong( in SurfaceOutput s, in vec3 lightDir, in vec3 viewDir, in float atten ); +vec4 frag_surf( in v2f_surf IN ); +vec4 UnpackNormal( in vec4 packednormal ) { + vec4 normal; + normal.xy = ((packednormal.wy * 2.00000) - 1.00000); + normal.z = sqrt( ((1.00000 - (normal.x * normal.x )) - (normal.y * normal.y )) ); + return normal; +} +vec2 ParallaxOffset( in float h, in float height, in vec3 viewDir ) { + vec3 v; + h = ((h * height) - (height / 2.00000)); + v = normalize( viewDir ); + v.z += 0.420000; + return (h * (v.xy / v.z )); +} +void surf( in Input IN, inout SurfaceOutput o ) { + float h; + vec2 offset; + vec4 tex; + vec4 c; + h = texture2D( _ParallaxMap, IN.uv_BumpMap).w ; + offset = ParallaxOffset( h, _Parallax, IN.viewDir); + IN.uv_MainTex += offset; + IN.uv_BumpMap += offset; + IN.uv_Illum += offset; + tex = texture2D( _MainTex, IN.uv_MainTex); + c = (tex * _Color); + o.Albedo = c.xyz ; + o.Gloss = tex.w ; + o.Emission = (c.xyz * texture2D( _Illum, IN.uv_Illum).w ); + o.Specular = _Shininess; + o.Alpha = c.w ; + o.Normal = vec3( UnpackNormal( texture2D( _BumpMap, IN.uv_BumpMap))); +} +vec4 LightingBlinnPhong( in SurfaceOutput s, in vec3 lightDir, in vec3 viewDir, in float atten ) { + vec3 h; + float diff; + float nh; + float spec; + vec4 c; + h = normalize( (lightDir + viewDir) ); + diff = max( 0.000000, dot( s.Normal, lightDir)); + nh = max( 0.000000, dot( s.Normal, h)); + spec = (pow( nh, (s.Specular * 128.000)) * s.Gloss); + c.xyz = ((((s.Albedo * _LightColor0.xyz ) * diff) + ((_LightColor0.xyz * _SpecColor.xyz ) * spec)) * (atten * 2.00000)); + c.w = (s.Alpha + (((_LightColor0.w * _SpecColor.w ) * spec) * atten)); + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec3 lightDir; + vec4 c; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + surfIN.uv_BumpMap = IN.hip_pack0.zw ; + surfIN.viewDir = IN.viewDir; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + surf( surfIN, o); + lightDir = IN.lightDir; + lightDir = normalize( lightDir ); + c = LightingBlinnPhong( o, lightDir, normalize( vec3( IN.viewDir) ), (texture2D( _LightTextureB0, vec2( vec2( dot( IN._LightCoord, IN._LightCoord)))).w * textureCube( _LightTexture0, IN._LightCoord).w )); + c.w = 0.000000; + return c; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec4( gl_TexCoord[0]); + xlt_IN.viewDir = vec3( gl_TexCoord[1]); + xlt_IN.lightDir = vec3( gl_TexCoord[2]); + xlt_IN._LightCoord = vec3( gl_TexCoord[3]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Parallax_Specular1-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Parallax_Specular1-ir.txt new file mode 100644 index 000000000..f97f52647 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Parallax_Specular1-ir.txt @@ -0,0 +1,288 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; + vec2 uv_Illum; + vec3 viewDir; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 viewDir; + vec3 lightDir; + vec3 _LightCoord; +}; +varying vec4 xlv_FOG; +uniform vec4 _SpecColor; +uniform float _Shininess; +uniform sampler2D _ParallaxMap; +uniform float _Parallax; +uniform sampler2D _MainTex; +uniform sampler2D _LightTextureB0; +uniform samplerCube _LightTexture0; +uniform vec4 _LightColor0; +uniform sampler2D _Illum; +uniform vec4 _Color; +uniform sampler2D _BumpMap; +vec4 UnpackNormal ( + in vec4 packednormal +) +{ + vec4 normal; + vec2 tmpvar_1; + tmpvar_1 = ((packednormal.wy * 2.0) - 1.0); + normal.xy = tmpvar_1.xy.xy; + float tmpvar_2; + tmpvar_2 = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + normal.z = vec3(tmpvar_3).z; + return normal; +} + +vec2 ParallaxOffset ( + in float h, + in float height, + in vec3 viewDir +) +{ + vec3 v; + float tmpvar_1; + tmpvar_1 = ((h * height) - (height / 2.0)); + h = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = normalize (viewDir); + vec3 tmpvar_3; + tmpvar_3 = tmpvar_2; + v = tmpvar_3; + float tmpvar_4; + tmpvar_4 = (v.z + 0.42); + v.z = vec3(tmpvar_4).z; + return (h * (v.xy / v.z)); +} + +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 c; + vec4 tex; + vec2 offset; + float h; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_ParallaxMap, IN.uv_BumpMap); + float tmpvar_2; + tmpvar_2 = tmpvar_1.w; + h = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = ParallaxOffset (h, _Parallax, IN.viewDir); + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + offset = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5 = (IN.uv_MainTex + offset); + IN.uv_MainTex = tmpvar_5; + vec2 tmpvar_6; + tmpvar_6 = (IN.uv_BumpMap + offset); + IN.uv_BumpMap = tmpvar_6; + vec2 tmpvar_7; + tmpvar_7 = (IN.uv_Illum + offset); + IN.uv_Illum = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_9; + tmpvar_9 = tmpvar_8; + tex = tmpvar_9; + vec4 tmpvar_10; + tmpvar_10 = (tex * _Color); + c = tmpvar_10; + vec3 tmpvar_11; + tmpvar_11 = c.xyz; + o.Albedo = tmpvar_11; + float tmpvar_12; + tmpvar_12 = tex.w; + o.Gloss = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = texture2D (_Illum, IN.uv_Illum); + vec3 tmpvar_14; + tmpvar_14 = (c.xyz * tmpvar_13.w); + o.Emission = tmpvar_14; + float tmpvar_15; + tmpvar_15 = _Shininess; + o.Specular = tmpvar_15; + float tmpvar_16; + tmpvar_16 = c.w; + o.Alpha = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17 = texture2D (_BumpMap, IN.uv_BumpMap); + vec4 tmpvar_18; + tmpvar_18 = UnpackNormal (tmpvar_17); + vec3 tmpvar_19; + tmpvar_19 = tmpvar_18.xyz; + vec3 tmpvar_20; + tmpvar_20 = tmpvar_19; + o.Normal = tmpvar_20; +} + +vec4 LightingBlinnPhong ( + in SurfaceOutput s, + in vec3 lightDir, + in vec3 viewDir, + in float atten +) +{ + vec4 c; + float spec; + float nh; + float diff; + vec3 h; + vec3 tmpvar_1; + tmpvar_1 = normalize ((lightDir + viewDir)); + vec3 tmpvar_2; + tmpvar_2 = tmpvar_1; + h = tmpvar_2; + float tmpvar_3; + tmpvar_3 = dot (s.Normal, lightDir); + float tmpvar_4; + tmpvar_4 = max (0.0, tmpvar_3); + float tmpvar_5; + tmpvar_5 = tmpvar_4; + diff = tmpvar_5; + float tmpvar_6; + tmpvar_6 = dot (s.Normal, h); + float tmpvar_7; + tmpvar_7 = max (0.0, tmpvar_6); + float tmpvar_8; + tmpvar_8 = tmpvar_7; + nh = tmpvar_8; + float tmpvar_9; + tmpvar_9 = pow (nh, (s.Specular * 128.0)); + float tmpvar_10; + tmpvar_10 = (tmpvar_9 * s.Gloss); + spec = tmpvar_10; + vec3 tmpvar_11; + tmpvar_11 = ((((s.Albedo * _LightColor0.xyz) * diff) + ((_LightColor0.xyz * _SpecColor.xyz) * spec)) * (atten * 2.0)); + c.xyz = tmpvar_11.xyz.xyz; + float tmpvar_12; + tmpvar_12 = (s.Alpha + (((_LightColor0.w * _SpecColor.w) * spec) * atten)); + c.w = vec4(tmpvar_12).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 c; + vec3 lightDir; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = IN.hip_pack0.zw; + surfIN.uv_BumpMap = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = IN.viewDir; + surfIN.viewDir = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Specular = tmpvar_6; + float tmpvar_7; + tmpvar_7 = 0.0; + o.Alpha = tmpvar_7; + float tmpvar_8; + tmpvar_8 = 0.0; + o.Gloss = tmpvar_8; + surf (surfIN, o); + vec3 tmpvar_9; + tmpvar_9 = IN.lightDir; + lightDir = tmpvar_9; + vec3 tmpvar_10; + tmpvar_10 = normalize (lightDir); + vec3 tmpvar_11; + tmpvar_11 = tmpvar_10; + lightDir = tmpvar_11; + vec3 tmpvar_12; + tmpvar_12 = IN.viewDir.xyz; + vec3 tmpvar_13; + tmpvar_13 = normalize (tmpvar_12); + float tmpvar_14; + tmpvar_14 = dot (IN._LightCoord, IN._LightCoord); + vec2 tmpvar_15; + tmpvar_15 = vec2(tmpvar_14); + vec2 tmpvar_16; + tmpvar_16 = tmpvar_15.xy; + vec4 tmpvar_17; + tmpvar_17 = texture2D (_LightTextureB0, tmpvar_16); + vec4 tmpvar_18; + tmpvar_18 = textureCube (_LightTexture0, IN._LightCoord); + vec4 tmpvar_19; + tmpvar_19 = LightingBlinnPhong (o, lightDir, tmpvar_13, (tmpvar_17.w * tmpvar_18.w)); + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + c = tmpvar_20; + float tmpvar_21; + tmpvar_21 = 0.0; + c.w = vec4(tmpvar_21).w; + return c; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.viewDir = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.lightDir = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = gl_TexCoord[3].xyz; + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_IN._LightCoord = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = frag_surf (xlt_IN); + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xl_retval = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = xl_retval.xyzw; + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + gl_FragData[0] = tmpvar_14; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Parallax_Specular1-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Parallax_Specular1-out.txt new file mode 100644 index 000000000..0ca39d700 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Parallax_Specular1-out.txt @@ -0,0 +1,49 @@ +uniform vec4 _SpecColor; +uniform float _Shininess; +uniform sampler2D _ParallaxMap; +uniform float _Parallax; +uniform sampler2D _MainTex; +uniform sampler2D _LightTextureB0; +uniform samplerCube _LightTexture0; +uniform vec4 _LightColor0; +uniform vec4 _Color; +uniform sampler2D _BumpMap; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = gl_TexCoord[0]; + vec3 tmpvar_2; + tmpvar_2 = gl_TexCoord[1].xyz; + vec3 tmpvar_3; + tmpvar_3 = gl_TexCoord[3].xyz; + vec4 c; + vec2 tmpvar_4; + vec3 v; + vec3 tmpvar_5; + tmpvar_5 = normalize (tmpvar_2); + v = tmpvar_5; + v.z = (tmpvar_5.z + 0.42); + tmpvar_4 = (((texture2D (_ParallaxMap, tmpvar_1.zw).w * _Parallax) - (_Parallax / 2.0)) * (tmpvar_5.xy / v.z)); + vec4 tmpvar_6; + tmpvar_6 = texture2D (_MainTex, (tmpvar_1.xy + tmpvar_4)); + vec4 tmpvar_7; + tmpvar_7 = (tmpvar_6 * _Color); + vec4 normal; + normal.xy = ((texture2D (_BumpMap, (tmpvar_1.zw + tmpvar_4)).wy * 2.0) - 1.0); + normal.z = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + vec3 tmpvar_8; + tmpvar_8 = normal.xyz; + vec3 tmpvar_9; + tmpvar_9 = normalize (gl_TexCoord[2].xyz); + float atten; + atten = (texture2D (_LightTextureB0, vec2(dot (tmpvar_3, tmpvar_3))).w * textureCube (_LightTexture0, tmpvar_3).w); + vec4 c_i0_i1; + float tmpvar_10; + tmpvar_10 = (pow (max (0.0, dot (tmpvar_8, normalize ((tmpvar_9 + normalize (tmpvar_2))))), (_Shininess * 128.0)) * tmpvar_6.w); + c_i0_i1.xyz = ((((tmpvar_7.xyz * _LightColor0.xyz) * max (0.0, dot (tmpvar_8, tmpvar_9))) + ((_LightColor0.xyz * _SpecColor.xyz) * tmpvar_10)) * (atten * 2.0)); + c_i0_i1.w = (tmpvar_7.w + (((_LightColor0.w * _SpecColor.w) * tmpvar_10) * atten)); + c = c_i0_i1; + c.w = 0.0; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Specular-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Specular-in.txt new file mode 100644 index 000000000..c06f03100 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Specular-in.txt @@ -0,0 +1,119 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_Illum; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 normal; + vec3 lightDir; + vec3 viewDir; + vec4 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _Color; +uniform sampler2D _Illum; +uniform vec4 _LightColor0; +uniform sampler2D _LightTexture0; +uniform sampler2D _LightTextureB0; +uniform sampler2D _MainTex; +uniform float _Shininess; +uniform vec4 _SpecColor; +void surf( in Input IN, inout SurfaceOutput o ); +float UnitySpotCookie( in vec4 LightCoord ); +float UnitySpotAttenuate( in vec3 LightCoord ); +vec4 LightingBlinnPhong( in SurfaceOutput s, in vec3 lightDir, in vec3 viewDir, in float atten ); +vec4 frag_surf( in v2f_surf IN ); +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 tex; + vec4 c; + tex = texture2D( _MainTex, IN.uv_MainTex); + c = (tex * _Color); + o.Albedo = c.xyz ; + o.Emission = (c.xyz * texture2D( _Illum, IN.uv_Illum).w ); + o.Gloss = tex.w ; + o.Alpha = c.w ; + o.Specular = _Shininess; +} +float UnitySpotCookie( in vec4 LightCoord ) { + return texture2D( _LightTexture0, ((LightCoord.xy / LightCoord.w ) + 0.500000)).w ; +} +float UnitySpotAttenuate( in vec3 LightCoord ) { + return texture2D( _LightTextureB0, vec2( vec2( dot( LightCoord, LightCoord)))).w ; +} +vec4 LightingBlinnPhong( in SurfaceOutput s, in vec3 lightDir, in vec3 viewDir, in float atten ) { + vec3 h; + float diff; + float nh; + float spec; + vec4 c; + h = normalize( (lightDir + viewDir) ); + diff = max( 0.000000, dot( s.Normal, lightDir)); + nh = max( 0.000000, dot( s.Normal, h)); + spec = (pow( nh, (s.Specular * 128.000)) * s.Gloss); + c.xyz = ((((s.Albedo * _LightColor0.xyz ) * diff) + ((_LightColor0.xyz * _SpecColor.xyz ) * spec)) * (atten * 2.00000)); + c.w = (s.Alpha + (((_LightColor0.w * _SpecColor.w ) * spec) * atten)); + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec3 lightDir; + vec4 c; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + o.Normal = IN.normal; + surf( surfIN, o); + lightDir = IN.lightDir; + lightDir = normalize( lightDir ); + c = LightingBlinnPhong( o, lightDir, normalize( vec3( IN.viewDir) ), ((float( (IN._LightCoord.z > 0.000000) ) * UnitySpotCookie( IN._LightCoord)) * UnitySpotAttenuate( IN._LightCoord.xyz ))); + c.w = 0.000000; + return c; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec2( gl_TexCoord[0]); + xlt_IN.normal = vec3( gl_TexCoord[1]); + xlt_IN.lightDir = vec3( gl_TexCoord[2]); + xlt_IN.viewDir = vec3( gl_TexCoord[3]); + xlt_IN._LightCoord = vec4( gl_TexCoord[4]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Specular-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Specular-ir.txt new file mode 100644 index 000000000..c88ad4485 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Specular-ir.txt @@ -0,0 +1,237 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_Illum; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 normal; + vec3 lightDir; + vec3 viewDir; + vec4 _LightCoord; +}; +varying vec4 xlv_FOG; +uniform vec4 _SpecColor; +uniform float _Shininess; +uniform sampler2D _MainTex; +uniform sampler2D _LightTextureB0; +uniform sampler2D _LightTexture0; +uniform vec4 _LightColor0; +uniform sampler2D _Illum; +uniform vec4 _Color; +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 c; + vec4 tex; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + tex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = (tex * _Color); + c = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = c.xyz; + o.Albedo = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = texture2D (_Illum, IN.uv_Illum); + vec3 tmpvar_6; + tmpvar_6 = (c.xyz * tmpvar_5.w); + o.Emission = tmpvar_6; + float tmpvar_7; + tmpvar_7 = tex.w; + o.Gloss = tmpvar_7; + float tmpvar_8; + tmpvar_8 = c.w; + o.Alpha = tmpvar_8; + float tmpvar_9; + tmpvar_9 = _Shininess; + o.Specular = tmpvar_9; +} + +float UnitySpotCookie ( + in vec4 LightCoord +) +{ + vec4 tmpvar_1; + tmpvar_1 = texture2D (_LightTexture0, ((LightCoord.xy / LightCoord.w) + 0.5)); + return tmpvar_1.w; +} + +float UnitySpotAttenuate ( + in vec3 LightCoord +) +{ + float tmpvar_1; + tmpvar_1 = dot (LightCoord, LightCoord); + vec2 tmpvar_2; + tmpvar_2 = vec2(tmpvar_1); + vec2 tmpvar_3; + tmpvar_3 = tmpvar_2.xy; + vec4 tmpvar_4; + tmpvar_4 = texture2D (_LightTextureB0, tmpvar_3); + return tmpvar_4.w; +} + +vec4 LightingBlinnPhong ( + in SurfaceOutput s, + in vec3 lightDir, + in vec3 viewDir, + in float atten +) +{ + vec4 c; + float spec; + float nh; + float diff; + vec3 h; + vec3 tmpvar_1; + tmpvar_1 = normalize ((lightDir + viewDir)); + vec3 tmpvar_2; + tmpvar_2 = tmpvar_1; + h = tmpvar_2; + float tmpvar_3; + tmpvar_3 = dot (s.Normal, lightDir); + float tmpvar_4; + tmpvar_4 = max (0.0, tmpvar_3); + float tmpvar_5; + tmpvar_5 = tmpvar_4; + diff = tmpvar_5; + float tmpvar_6; + tmpvar_6 = dot (s.Normal, h); + float tmpvar_7; + tmpvar_7 = max (0.0, tmpvar_6); + float tmpvar_8; + tmpvar_8 = tmpvar_7; + nh = tmpvar_8; + float tmpvar_9; + tmpvar_9 = pow (nh, (s.Specular * 128.0)); + float tmpvar_10; + tmpvar_10 = (tmpvar_9 * s.Gloss); + spec = tmpvar_10; + vec3 tmpvar_11; + tmpvar_11 = ((((s.Albedo * _LightColor0.xyz) * diff) + ((_LightColor0.xyz * _SpecColor.xyz) * spec)) * (atten * 2.0)); + c.xyz = tmpvar_11.xyz.xyz; + float tmpvar_12; + tmpvar_12 = (s.Alpha + (((_LightColor0.w * _SpecColor.w) * spec) * atten)); + c.w = vec4(tmpvar_12).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 c; + vec3 lightDir; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_3; + float tmpvar_4; + tmpvar_4 = 0.0; + o.Specular = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Alpha = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Gloss = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = IN.normal; + o.Normal = tmpvar_7; + surf (surfIN, o); + vec3 tmpvar_8; + tmpvar_8 = IN.lightDir; + lightDir = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = normalize (lightDir); + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + lightDir = tmpvar_10; + vec3 tmpvar_11; + tmpvar_11 = IN.viewDir.xyz; + vec3 tmpvar_12; + tmpvar_12 = normalize (tmpvar_11); + float tmpvar_13; + tmpvar_13 = UnitySpotCookie (IN._LightCoord); + float tmpvar_14; + tmpvar_14 = UnitySpotAttenuate (IN._LightCoord.xyz); + vec4 tmpvar_15; + tmpvar_15 = LightingBlinnPhong (o, lightDir, tmpvar_12, ((float((IN._LightCoord.z > 0.0)) * tmpvar_13) * tmpvar_14)); + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + c = tmpvar_16; + float tmpvar_17; + tmpvar_17 = 0.0; + c.w = vec4(tmpvar_17).w; + return c; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xy; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.normal = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.lightDir = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = gl_TexCoord[3].xyz; + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_IN.viewDir = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_TexCoord[4].xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_IN._LightCoord = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = frag_surf (xlt_IN); + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_FragData[0] = tmpvar_16; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Specular-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Specular-out.txt new file mode 100644 index 000000000..6fe99f41f --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Specular-out.txt @@ -0,0 +1,34 @@ +uniform vec4 _SpecColor; +uniform float _Shininess; +uniform sampler2D _MainTex; +uniform sampler2D _LightTextureB0; +uniform sampler2D _LightTexture0; +uniform vec4 _LightColor0; +uniform vec4 _Color; +void main () +{ + vec3 tmpvar_1; + tmpvar_1 = gl_TexCoord[1].xyz; + vec4 tmpvar_2; + tmpvar_2 = gl_TexCoord[4]; + vec4 c; + vec4 tmpvar_3; + tmpvar_3 = texture2D (_MainTex, gl_TexCoord[0].xy); + vec4 tmpvar_4; + tmpvar_4 = (tmpvar_3 * _Color); + vec3 tmpvar_5; + tmpvar_5 = normalize (gl_TexCoord[2].xyz); + vec3 LightCoord_i0; + LightCoord_i0 = tmpvar_2.xyz; + float atten; + atten = ((float((tmpvar_2.z > 0.0)) * texture2D (_LightTexture0, ((tmpvar_2.xy / tmpvar_2.w) + 0.5)).w) * texture2D (_LightTextureB0, vec2(dot (LightCoord_i0, LightCoord_i0))).w); + vec4 c_i0_i1; + float tmpvar_6; + tmpvar_6 = (pow (max (0.0, dot (tmpvar_1, normalize ((tmpvar_5 + normalize (gl_TexCoord[3].xyz))))), (_Shininess * 128.0)) * tmpvar_3.w); + c_i0_i1.xyz = ((((tmpvar_4.xyz * _LightColor0.xyz) * max (0.0, dot (tmpvar_1, tmpvar_5))) + ((_LightColor0.xyz * _SpecColor.xyz) * tmpvar_6)) * (atten * 2.0)); + c_i0_i1.w = (tmpvar_4.w + (((_LightColor0.w * _SpecColor.w) * tmpvar_6) * atten)); + c = c_i0_i1; + c.w = 0.0; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Specular1-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Specular1-in.txt new file mode 100644 index 000000000..a233b144e --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Specular1-in.txt @@ -0,0 +1,77 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_Illum; +}; +struct v2f_surf { + vec4 pos; + vec3 normal; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _Color; +uniform sampler2D _Illum; +uniform sampler2D _MainTex; +uniform float _Shininess; +void surf( in Input IN, inout SurfaceOutput o ); +vec4 frag_surf( in v2f_surf IN ); +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 tex; + vec4 c; + tex = texture2D( _MainTex, IN.uv_MainTex); + c = (tex * _Color); + o.Albedo = c.xyz ; + o.Emission = (c.xyz * texture2D( _Illum, IN.uv_Illum).w ); + o.Gloss = tex.w ; + o.Alpha = c.w ; + o.Specular = _Shininess; +} +vec4 frag_surf( in v2f_surf IN ) { + SurfaceOutput o; + Input surfIN; + vec4 res; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + o.Normal = IN.normal; + surf( surfIN, o); + res.xyz = ((o.Normal * vec3( 0.500000, 0.500000, -0.500000)) + 0.500000); + res.w = o.Specular; + return res; +} +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.normal = vec3( gl_TexCoord[0]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Specular1-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Specular1-ir.txt new file mode 100644 index 000000000..3134c41d6 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Specular1-ir.txt @@ -0,0 +1,113 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_Illum; +}; +struct v2f_surf { + vec4 pos; + vec3 normal; +}; +uniform float _Shininess; +uniform sampler2D _MainTex; +uniform sampler2D _Illum; +uniform vec4 _Color; +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 c; + vec4 tex; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + tex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = (tex * _Color); + c = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = c.xyz; + o.Albedo = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = texture2D (_Illum, IN.uv_Illum); + vec3 tmpvar_6; + tmpvar_6 = (c.xyz * tmpvar_5.w); + o.Emission = tmpvar_6; + float tmpvar_7; + tmpvar_7 = tex.w; + o.Gloss = tmpvar_7; + float tmpvar_8; + tmpvar_8 = c.w; + o.Alpha = tmpvar_8; + float tmpvar_9; + tmpvar_9 = _Shininess; + o.Specular = tmpvar_9; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 res; + Input surfIN; + SurfaceOutput o; + vec3 tmpvar_1; + tmpvar_1 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_2; + float tmpvar_3; + tmpvar_3 = 0.0; + o.Specular = tmpvar_3; + float tmpvar_4; + tmpvar_4 = 0.0; + o.Alpha = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Gloss = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = IN.normal; + o.Normal = tmpvar_6; + surf (surfIN, o); + vec3 tmpvar_7; + tmpvar_7 = ((o.Normal * vec3(0.5, 0.5, -0.5)) + 0.5); + res.xyz = tmpvar_7.xyz.xyz; + float tmpvar_8; + tmpvar_8 = o.Specular; + res.w = vec4(tmpvar_8).w; + return res; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = gl_TexCoord[0].xyz; + vec3 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_IN.normal = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = frag_surf (xlt_IN); + vec4 tmpvar_5; + tmpvar_5 = tmpvar_4; + xl_retval = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = xl_retval.xyzw; + vec4 tmpvar_7; + tmpvar_7 = tmpvar_6; + gl_FragData[0] = tmpvar_7; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Specular1-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Specular1-out.txt new file mode 100644 index 000000000..73b819c9d --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Specular1-out.txt @@ -0,0 +1,9 @@ +uniform float _Shininess; +void main () +{ + vec4 res; + res.xyz = ((gl_TexCoord[0].xyz * vec3(0.5, 0.5, -0.5)) + 0.5); + res.w = _Shininess; + gl_FragData[0] = res; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Specular2-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Specular2-in.txt new file mode 100644 index 000000000..85521d5cf --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Specular2-in.txt @@ -0,0 +1,133 @@ +float xll_saturate( float x) { + return clamp( x, 0.0, 1.0); +} +vec2 xll_saturate( vec2 x) { + return clamp( x, 0.0, 1.0); +} +vec3 xll_saturate( vec3 x) { + return clamp( x, 0.0, 1.0); +} +vec4 xll_saturate( vec4 x) { + return clamp( x, 0.0, 1.0); +} +mat2 xll_saturate(mat2 m) { + return mat2( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0)); +} +mat3 xll_saturate(mat3 m) { + return mat3( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0), clamp(m[2], 0.0, 1.0)); +} +mat4 xll_saturate(mat4 m) { + return mat4( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0), clamp(m[2], 0.0, 1.0), clamp(m[3], 0.0, 1.0)); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_Illum; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec4 hip_screen; + vec3 hip_lmapFade; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _Color; +uniform sampler2D _Illum; +uniform sampler2D _LightBuffer; +uniform sampler2D _MainTex; +uniform float _Shininess; +uniform vec4 _SpecColor; +uniform sampler2D unity_Lightmap; +uniform sampler2D unity_LightmapInd; +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingBlinnPhong_PrePass( in SurfaceOutput s, in vec4 light ); +vec3 DecodeLightmap( in vec4 color ); +vec4 frag_surf( in v2f_surf IN ); +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 tex; + vec4 c; + tex = texture2D( _MainTex, IN.uv_MainTex); + c = (tex * _Color); + o.Albedo = c.xyz ; + o.Emission = (c.xyz * texture2D( _Illum, IN.uv_Illum).w ); + o.Gloss = tex.w ; + o.Alpha = c.w ; + o.Specular = _Shininess; +} +vec4 LightingBlinnPhong_PrePass( in SurfaceOutput s, in vec4 light ) { + float spec; + vec4 c; + spec = (light.w * s.Gloss); + c.xyz = ((s.Albedo * light.xyz ) + ((light.xyz * _SpecColor.xyz ) * spec)); + c.w = (s.Alpha + (spec * _SpecColor.w )); + return c; +} +vec3 DecodeLightmap( in vec4 color ) { + return (2.00000 * color.xyz ); +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec4 light; + vec3 lmFull; + vec3 lmIndirect; + vec3 lm; + vec4 col; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + surfIN.uv_Illum = IN.hip_pack0.zw ; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + surf( surfIN, o); + light = texture2DProj( _LightBuffer, IN.hip_screen); + light = ( -log2( light ) ); + lmFull = DecodeLightmap( texture2D( unity_Lightmap, IN.hip_lmapFade.xy )); + lmIndirect = DecodeLightmap( texture2D( unity_LightmapInd, IN.hip_lmapFade.xy )); + lm = mix( lmIndirect, lmFull, vec3( xll_saturate( IN.hip_lmapFade.z ))); + light.xyz += lm; + col = LightingBlinnPhong_PrePass( o, light); + col.xyz += o.Emission; + return col; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec4( gl_TexCoord[0]); + xlt_IN.hip_screen = vec4( gl_TexCoord[1]); + xlt_IN.hip_lmapFade = vec3( gl_TexCoord[2]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Specular2-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Specular2-ir.txt new file mode 100644 index 000000000..62c44bcab --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Specular2-ir.txt @@ -0,0 +1,310 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_Illum; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec4 hip_screen; + vec3 hip_lmapFade; +}; +varying vec4 xlv_FOG; +uniform sampler2D unity_LightmapInd; +uniform sampler2D unity_Lightmap; +uniform vec4 _SpecColor; +uniform float _Shininess; +uniform sampler2D _MainTex; +uniform sampler2D _LightBuffer; +uniform sampler2D _Illum; +uniform vec4 _Color; +float xll_saturate ( + in float x +) +{ + float tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec2 xll_saturate ( + in vec2 x +) +{ + vec2 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec3 xll_saturate ( + in vec3 x +) +{ + vec3 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec4 xll_saturate ( + in vec4 x +) +{ + vec4 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +mat2 xll_saturate ( + in mat2 m +) +{ + vec2 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec2 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + mat2 tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_1; + tmpvar_3[0] = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5 = tmpvar_2; + tmpvar_3[1] = tmpvar_5; + return tmpvar_3; +} + +mat3 xll_saturate ( + in mat3 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec3 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + vec3 tmpvar_3; + tmpvar_3 = clamp (m[2], 0.0, 1.0); + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +mat4 xll_saturate ( + in mat4 m +) +{ + vec4 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec4 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + vec4 tmpvar_3; + tmpvar_3 = clamp (m[2], 0.0, 1.0); + vec4 tmpvar_4; + tmpvar_4 = clamp (m[3], 0.0, 1.0); + mat4 tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_1; + tmpvar_5[0] = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = tmpvar_2; + tmpvar_5[1] = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_3; + tmpvar_5[2] = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = tmpvar_4; + tmpvar_5[3] = tmpvar_9; + return tmpvar_5; +} + +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 c; + vec4 tex; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + tex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = (tex * _Color); + c = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = c.xyz; + o.Albedo = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = texture2D (_Illum, IN.uv_Illum); + vec3 tmpvar_6; + tmpvar_6 = (c.xyz * tmpvar_5.w); + o.Emission = tmpvar_6; + float tmpvar_7; + tmpvar_7 = tex.w; + o.Gloss = tmpvar_7; + float tmpvar_8; + tmpvar_8 = c.w; + o.Alpha = tmpvar_8; + float tmpvar_9; + tmpvar_9 = _Shininess; + o.Specular = tmpvar_9; +} + +vec4 LightingBlinnPhong_PrePass ( + in SurfaceOutput s, + in vec4 light +) +{ + vec4 c; + float spec; + float tmpvar_1; + tmpvar_1 = (light.w * s.Gloss); + spec = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = ((s.Albedo * light.xyz) + ((light.xyz * _SpecColor.xyz) * spec)); + c.xyz = tmpvar_2.xyz.xyz; + float tmpvar_3; + tmpvar_3 = (s.Alpha + (spec * _SpecColor.w)); + c.w = vec4(tmpvar_3).w; + return c; +} + +vec3 DecodeLightmap ( + in vec4 color +) +{ + return (2.0 * color.xyz); +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 col; + vec3 lm; + vec3 lmIndirect; + vec3 lmFull; + vec4 light; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = IN.hip_pack0.zw; + surfIN.uv_Illum = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Specular = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Alpha = tmpvar_6; + float tmpvar_7; + tmpvar_7 = 0.0; + o.Gloss = tmpvar_7; + surf (surfIN, o); + vec4 tmpvar_8; + tmpvar_8 = texture2DProj (_LightBuffer, IN.hip_screen); + vec4 tmpvar_9; + tmpvar_9 = tmpvar_8; + light = tmpvar_9; + vec4 tmpvar_10; + tmpvar_10 = log2 (light); + vec4 tmpvar_11; + tmpvar_11 = -(tmpvar_10); + light = tmpvar_11; + vec4 tmpvar_12; + tmpvar_12 = texture2D (unity_Lightmap, IN.hip_lmapFade.xy); + vec3 tmpvar_13; + tmpvar_13 = DecodeLightmap (tmpvar_12); + vec3 tmpvar_14; + tmpvar_14 = tmpvar_13; + lmFull = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = texture2D (unity_LightmapInd, IN.hip_lmapFade.xy); + vec3 tmpvar_16; + tmpvar_16 = DecodeLightmap (tmpvar_15); + vec3 tmpvar_17; + tmpvar_17 = tmpvar_16; + lmIndirect = tmpvar_17; + float tmpvar_18; + tmpvar_18 = xll_saturate (IN.hip_lmapFade.z); + vec3 tmpvar_19; + tmpvar_19 = vec3(tmpvar_18); + vec3 tmpvar_20; + tmpvar_20 = mix (lmIndirect, lmFull, tmpvar_19); + vec3 tmpvar_21; + tmpvar_21 = tmpvar_20; + lm = tmpvar_21; + vec3 tmpvar_22; + tmpvar_22 = (light.xyz + lm); + light.xyz = tmpvar_22.xyz.xyz; + vec4 tmpvar_23; + tmpvar_23 = LightingBlinnPhong_PrePass (o, light); + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + col = tmpvar_24; + vec3 tmpvar_25; + tmpvar_25 = (col.xyz + o.Emission); + col.xyz = tmpvar_25.xyz.xyz; + return col; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyzw; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.hip_screen = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.hip_lmapFade = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = frag_surf (xlt_IN); + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xl_retval = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = xl_retval.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + gl_FragData[0] = tmpvar_12; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Specular2-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Specular2-out.txt new file mode 100644 index 000000000..8d30b5634 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Self-Illumin_Specular2-out.txt @@ -0,0 +1,33 @@ +uniform sampler2D unity_LightmapInd; +uniform sampler2D unity_Lightmap; +uniform vec4 _SpecColor; +uniform sampler2D _MainTex; +uniform sampler2D _LightBuffer; +uniform sampler2D _Illum; +uniform vec4 _Color; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = gl_TexCoord[0]; + vec3 tmpvar_2; + tmpvar_2 = gl_TexCoord[2].xyz; + vec4 col; + vec4 light; + vec4 tmpvar_3; + tmpvar_3 = texture2D (_MainTex, tmpvar_1.xy); + vec4 tmpvar_4; + tmpvar_4 = (tmpvar_3 * _Color); + vec4 tmpvar_5; + tmpvar_5 = -(log2 (texture2DProj (_LightBuffer, gl_TexCoord[1]))); + light = tmpvar_5; + light.xyz = (tmpvar_5.xyz + mix ((2.0 * texture2D (unity_LightmapInd, tmpvar_2.xy).xyz), (2.0 * texture2D (unity_Lightmap, tmpvar_2.xy).xyz), vec3(clamp (tmpvar_2.z, 0.0, 1.0)))); + vec4 c_i0; + float tmpvar_6; + tmpvar_6 = (tmpvar_5.w * tmpvar_3.w); + c_i0.xyz = ((tmpvar_4.xyz * light.xyz) + ((light.xyz * _SpecColor.xyz) * tmpvar_6)); + c_i0.w = (tmpvar_4.w + (tmpvar_6 * _SpecColor.w)); + col = c_i0; + col.xyz = (c_i0.xyz + (tmpvar_4.xyz * texture2D (_Illum, tmpvar_1.zw).w)); + gl_FragData[0] = col; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Specular-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Specular-in.txt new file mode 100644 index 000000000..681dff856 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Specular-in.txt @@ -0,0 +1,114 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 normal; + vec3 lightDir; + vec3 viewDir; + vec4 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _Color; +uniform vec4 _LightColor0; +uniform sampler2D _LightTexture0; +uniform sampler2D _LightTextureB0; +uniform sampler2D _MainTex; +uniform float _Shininess; +uniform vec4 _SpecColor; +void surf( in Input IN, inout SurfaceOutput o ); +float UnitySpotCookie( in vec4 LightCoord ); +float UnitySpotAttenuate( in vec3 LightCoord ); +vec4 LightingBlinnPhong( in SurfaceOutput s, in vec3 lightDir, in vec3 viewDir, in float atten ); +vec4 frag_surf( in v2f_surf IN ); +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 tex; + tex = texture2D( _MainTex, IN.uv_MainTex); + o.Albedo = (tex.xyz * _Color.xyz ); + o.Gloss = tex.w ; + o.Alpha = (tex.w * _Color.w ); + o.Specular = _Shininess; +} +float UnitySpotCookie( in vec4 LightCoord ) { + return texture2D( _LightTexture0, ((LightCoord.xy / LightCoord.w ) + 0.500000)).w ; +} +float UnitySpotAttenuate( in vec3 LightCoord ) { + return texture2D( _LightTextureB0, vec2( vec2( dot( LightCoord, LightCoord)))).w ; +} +vec4 LightingBlinnPhong( in SurfaceOutput s, in vec3 lightDir, in vec3 viewDir, in float atten ) { + vec3 h; + float diff; + float nh; + float spec; + vec4 c; + h = normalize( (lightDir + viewDir) ); + diff = max( 0.000000, dot( s.Normal, lightDir)); + nh = max( 0.000000, dot( s.Normal, h)); + spec = (pow( nh, (s.Specular * 128.000)) * s.Gloss); + c.xyz = ((((s.Albedo * _LightColor0.xyz ) * diff) + ((_LightColor0.xyz * _SpecColor.xyz ) * spec)) * (atten * 2.00000)); + c.w = (s.Alpha + (((_LightColor0.w * _SpecColor.w ) * spec) * atten)); + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec3 lightDir; + vec4 c; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + o.Normal = IN.normal; + surf( surfIN, o); + lightDir = IN.lightDir; + lightDir = normalize( lightDir ); + c = LightingBlinnPhong( o, lightDir, normalize( vec3( IN.viewDir) ), ((float( (IN._LightCoord.z > 0.000000) ) * UnitySpotCookie( IN._LightCoord)) * UnitySpotAttenuate( IN._LightCoord.xyz ))); + c.w = 0.000000; + return c; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec2( gl_TexCoord[0]); + xlt_IN.normal = vec3( gl_TexCoord[1]); + xlt_IN.lightDir = vec3( gl_TexCoord[2]); + xlt_IN.viewDir = vec3( gl_TexCoord[3]); + xlt_IN._LightCoord = vec4( gl_TexCoord[4]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Specular-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Specular-ir.txt new file mode 100644 index 000000000..89434846a --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Specular-ir.txt @@ -0,0 +1,226 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 normal; + vec3 lightDir; + vec3 viewDir; + vec4 _LightCoord; +}; +varying vec4 xlv_FOG; +uniform vec4 _SpecColor; +uniform float _Shininess; +uniform sampler2D _MainTex; +uniform sampler2D _LightTextureB0; +uniform sampler2D _LightTexture0; +uniform vec4 _LightColor0; +uniform vec4 _Color; +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 tex; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + tex = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = (tex.xyz * _Color.xyz); + o.Albedo = tmpvar_3; + float tmpvar_4; + tmpvar_4 = tex.w; + o.Gloss = tmpvar_4; + float tmpvar_5; + tmpvar_5 = (tex.w * _Color.w); + o.Alpha = tmpvar_5; + float tmpvar_6; + tmpvar_6 = _Shininess; + o.Specular = tmpvar_6; +} + +float UnitySpotCookie ( + in vec4 LightCoord +) +{ + vec4 tmpvar_1; + tmpvar_1 = texture2D (_LightTexture0, ((LightCoord.xy / LightCoord.w) + 0.5)); + return tmpvar_1.w; +} + +float UnitySpotAttenuate ( + in vec3 LightCoord +) +{ + float tmpvar_1; + tmpvar_1 = dot (LightCoord, LightCoord); + vec2 tmpvar_2; + tmpvar_2 = vec2(tmpvar_1); + vec2 tmpvar_3; + tmpvar_3 = tmpvar_2.xy; + vec4 tmpvar_4; + tmpvar_4 = texture2D (_LightTextureB0, tmpvar_3); + return tmpvar_4.w; +} + +vec4 LightingBlinnPhong ( + in SurfaceOutput s, + in vec3 lightDir, + in vec3 viewDir, + in float atten +) +{ + vec4 c; + float spec; + float nh; + float diff; + vec3 h; + vec3 tmpvar_1; + tmpvar_1 = normalize ((lightDir + viewDir)); + vec3 tmpvar_2; + tmpvar_2 = tmpvar_1; + h = tmpvar_2; + float tmpvar_3; + tmpvar_3 = dot (s.Normal, lightDir); + float tmpvar_4; + tmpvar_4 = max (0.0, tmpvar_3); + float tmpvar_5; + tmpvar_5 = tmpvar_4; + diff = tmpvar_5; + float tmpvar_6; + tmpvar_6 = dot (s.Normal, h); + float tmpvar_7; + tmpvar_7 = max (0.0, tmpvar_6); + float tmpvar_8; + tmpvar_8 = tmpvar_7; + nh = tmpvar_8; + float tmpvar_9; + tmpvar_9 = pow (nh, (s.Specular * 128.0)); + float tmpvar_10; + tmpvar_10 = (tmpvar_9 * s.Gloss); + spec = tmpvar_10; + vec3 tmpvar_11; + tmpvar_11 = ((((s.Albedo * _LightColor0.xyz) * diff) + ((_LightColor0.xyz * _SpecColor.xyz) * spec)) * (atten * 2.0)); + c.xyz = tmpvar_11.xyz.xyz; + float tmpvar_12; + tmpvar_12 = (s.Alpha + (((_LightColor0.w * _SpecColor.w) * spec) * atten)); + c.w = vec4(tmpvar_12).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 c; + vec3 lightDir; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_3; + float tmpvar_4; + tmpvar_4 = 0.0; + o.Specular = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Alpha = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Gloss = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = IN.normal; + o.Normal = tmpvar_7; + surf (surfIN, o); + vec3 tmpvar_8; + tmpvar_8 = IN.lightDir; + lightDir = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = normalize (lightDir); + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + lightDir = tmpvar_10; + vec3 tmpvar_11; + tmpvar_11 = IN.viewDir.xyz; + vec3 tmpvar_12; + tmpvar_12 = normalize (tmpvar_11); + float tmpvar_13; + tmpvar_13 = UnitySpotCookie (IN._LightCoord); + float tmpvar_14; + tmpvar_14 = UnitySpotAttenuate (IN._LightCoord.xyz); + vec4 tmpvar_15; + tmpvar_15 = LightingBlinnPhong (o, lightDir, tmpvar_12, ((float((IN._LightCoord.z > 0.0)) * tmpvar_13) * tmpvar_14)); + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + c = tmpvar_16; + float tmpvar_17; + tmpvar_17 = 0.0; + c.w = vec4(tmpvar_17).w; + return c; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xy; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.normal = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.lightDir = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = gl_TexCoord[3].xyz; + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_IN.viewDir = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_TexCoord[4].xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_IN._LightCoord = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = frag_surf (xlt_IN); + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_FragData[0] = tmpvar_16; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Specular-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Specular-out.txt new file mode 100644 index 000000000..da0ca3a67 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Specular-out.txt @@ -0,0 +1,32 @@ +uniform vec4 _SpecColor; +uniform float _Shininess; +uniform sampler2D _MainTex; +uniform sampler2D _LightTextureB0; +uniform sampler2D _LightTexture0; +uniform vec4 _LightColor0; +uniform vec4 _Color; +void main () +{ + vec3 tmpvar_1; + tmpvar_1 = gl_TexCoord[1].xyz; + vec4 tmpvar_2; + tmpvar_2 = gl_TexCoord[4]; + vec4 c; + vec4 tmpvar_3; + tmpvar_3 = texture2D (_MainTex, gl_TexCoord[0].xy); + vec3 tmpvar_4; + tmpvar_4 = normalize (gl_TexCoord[2].xyz); + vec3 LightCoord_i0; + LightCoord_i0 = tmpvar_2.xyz; + float atten; + atten = ((float((tmpvar_2.z > 0.0)) * texture2D (_LightTexture0, ((tmpvar_2.xy / tmpvar_2.w) + 0.5)).w) * texture2D (_LightTextureB0, vec2(dot (LightCoord_i0, LightCoord_i0))).w); + vec4 c_i0; + float tmpvar_5; + tmpvar_5 = (pow (max (0.0, dot (tmpvar_1, normalize ((tmpvar_4 + normalize (gl_TexCoord[3].xyz))))), (_Shininess * 128.0)) * tmpvar_3.w); + c_i0.xyz = (((((tmpvar_3.xyz * _Color.xyz) * _LightColor0.xyz) * max (0.0, dot (tmpvar_1, tmpvar_4))) + ((_LightColor0.xyz * _SpecColor.xyz) * tmpvar_5)) * (atten * 2.0)); + c_i0.w = ((tmpvar_3.w * _Color.w) + (((_LightColor0.w * _SpecColor.w) * tmpvar_5) * atten)); + c = c_i0; + c.w = 0.0; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Specular1-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Specular1-in.txt new file mode 100644 index 000000000..4b417be75 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Specular1-in.txt @@ -0,0 +1,72 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; +}; +struct v2f_surf { + vec4 pos; + vec3 normal; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _Color; +uniform sampler2D _MainTex; +uniform float _Shininess; +void surf( in Input IN, inout SurfaceOutput o ); +vec4 frag_surf( in v2f_surf IN ); +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 tex; + tex = texture2D( _MainTex, IN.uv_MainTex); + o.Albedo = (tex.xyz * _Color.xyz ); + o.Gloss = tex.w ; + o.Alpha = (tex.w * _Color.w ); + o.Specular = _Shininess; +} +vec4 frag_surf( in v2f_surf IN ) { + SurfaceOutput o; + Input surfIN; + vec4 res; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + o.Normal = IN.normal; + surf( surfIN, o); + res.xyz = ((o.Normal * vec3( 0.500000, 0.500000, -0.500000)) + 0.500000); + res.w = o.Specular; + return res; +} +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.normal = vec3( gl_TexCoord[0]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Specular1-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Specular1-ir.txt new file mode 100644 index 000000000..f4c829c8e --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Specular1-ir.txt @@ -0,0 +1,102 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; +}; +struct v2f_surf { + vec4 pos; + vec3 normal; +}; +uniform float _Shininess; +uniform sampler2D _MainTex; +uniform vec4 _Color; +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 tex; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + tex = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = (tex.xyz * _Color.xyz); + o.Albedo = tmpvar_3; + float tmpvar_4; + tmpvar_4 = tex.w; + o.Gloss = tmpvar_4; + float tmpvar_5; + tmpvar_5 = (tex.w * _Color.w); + o.Alpha = tmpvar_5; + float tmpvar_6; + tmpvar_6 = _Shininess; + o.Specular = tmpvar_6; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 res; + Input surfIN; + SurfaceOutput o; + vec3 tmpvar_1; + tmpvar_1 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_2; + float tmpvar_3; + tmpvar_3 = 0.0; + o.Specular = tmpvar_3; + float tmpvar_4; + tmpvar_4 = 0.0; + o.Alpha = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Gloss = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = IN.normal; + o.Normal = tmpvar_6; + surf (surfIN, o); + vec3 tmpvar_7; + tmpvar_7 = ((o.Normal * vec3(0.5, 0.5, -0.5)) + 0.5); + res.xyz = tmpvar_7.xyz.xyz; + float tmpvar_8; + tmpvar_8 = o.Specular; + res.w = vec4(tmpvar_8).w; + return res; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = gl_TexCoord[0].xyz; + vec3 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_IN.normal = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = frag_surf (xlt_IN); + vec4 tmpvar_5; + tmpvar_5 = tmpvar_4; + xl_retval = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = xl_retval.xyzw; + vec4 tmpvar_7; + tmpvar_7 = tmpvar_6; + gl_FragData[0] = tmpvar_7; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Specular1-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Specular1-out.txt new file mode 100644 index 000000000..73b819c9d --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Specular1-out.txt @@ -0,0 +1,9 @@ +uniform float _Shininess; +void main () +{ + vec4 res; + res.xyz = ((gl_TexCoord[0].xyz * vec3(0.5, 0.5, -0.5)) + 0.5); + res.w = _Shininess; + gl_FragData[0] = res; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Specular2-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Specular2-in.txt new file mode 100644 index 000000000..3c30d0528 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Specular2-in.txt @@ -0,0 +1,126 @@ +float xll_saturate( float x) { + return clamp( x, 0.0, 1.0); +} +vec2 xll_saturate( vec2 x) { + return clamp( x, 0.0, 1.0); +} +vec3 xll_saturate( vec3 x) { + return clamp( x, 0.0, 1.0); +} +vec4 xll_saturate( vec4 x) { + return clamp( x, 0.0, 1.0); +} +mat2 xll_saturate(mat2 m) { + return mat2( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0)); +} +mat3 xll_saturate(mat3 m) { + return mat3( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0), clamp(m[2], 0.0, 1.0)); +} +mat4 xll_saturate(mat4 m) { + return mat4( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0), clamp(m[2], 0.0, 1.0), clamp(m[3], 0.0, 1.0)); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 hip_screen; + vec3 hip_lmapFade; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _Color; +uniform sampler2D _LightBuffer; +uniform sampler2D _MainTex; +uniform float _Shininess; +uniform vec4 _SpecColor; +uniform sampler2D unity_Lightmap; +uniform sampler2D unity_LightmapInd; +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingBlinnPhong_PrePass( in SurfaceOutput s, in vec4 light ); +vec3 DecodeLightmap( in vec4 color ); +vec4 frag_surf( in v2f_surf IN ); +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 tex; + tex = texture2D( _MainTex, IN.uv_MainTex); + o.Albedo = (tex.xyz * _Color.xyz ); + o.Gloss = tex.w ; + o.Alpha = (tex.w * _Color.w ); + o.Specular = _Shininess; +} +vec4 LightingBlinnPhong_PrePass( in SurfaceOutput s, in vec4 light ) { + float spec; + vec4 c; + spec = (light.w * s.Gloss); + c.xyz = ((s.Albedo * light.xyz ) + ((light.xyz * _SpecColor.xyz ) * spec)); + c.w = (s.Alpha + (spec * _SpecColor.w )); + return c; +} +vec3 DecodeLightmap( in vec4 color ) { + return (2.00000 * color.xyz ); +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec4 light; + vec3 lmFull; + vec3 lmIndirect; + vec3 lm; + vec4 col; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + surf( surfIN, o); + light = texture2DProj( _LightBuffer, IN.hip_screen); + light = ( -log2( light ) ); + lmFull = DecodeLightmap( texture2D( unity_Lightmap, IN.hip_lmapFade.xy )); + lmIndirect = DecodeLightmap( texture2D( unity_LightmapInd, IN.hip_lmapFade.xy )); + lm = mix( lmIndirect, lmFull, vec3( xll_saturate( IN.hip_lmapFade.z ))); + light.xyz += lm; + col = LightingBlinnPhong_PrePass( o, light); + return col; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec2( gl_TexCoord[0]); + xlt_IN.hip_screen = vec4( gl_TexCoord[1]); + xlt_IN.hip_lmapFade = vec3( gl_TexCoord[2]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Specular2-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Specular2-ir.txt new file mode 100644 index 000000000..a7d243c63 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Specular2-ir.txt @@ -0,0 +1,293 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 hip_screen; + vec3 hip_lmapFade; +}; +varying vec4 xlv_FOG; +uniform sampler2D unity_LightmapInd; +uniform sampler2D unity_Lightmap; +uniform vec4 _SpecColor; +uniform float _Shininess; +uniform sampler2D _MainTex; +uniform sampler2D _LightBuffer; +uniform vec4 _Color; +float xll_saturate ( + in float x +) +{ + float tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec2 xll_saturate ( + in vec2 x +) +{ + vec2 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec3 xll_saturate ( + in vec3 x +) +{ + vec3 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec4 xll_saturate ( + in vec4 x +) +{ + vec4 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +mat2 xll_saturate ( + in mat2 m +) +{ + vec2 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec2 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + mat2 tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_1; + tmpvar_3[0] = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5 = tmpvar_2; + tmpvar_3[1] = tmpvar_5; + return tmpvar_3; +} + +mat3 xll_saturate ( + in mat3 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec3 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + vec3 tmpvar_3; + tmpvar_3 = clamp (m[2], 0.0, 1.0); + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +mat4 xll_saturate ( + in mat4 m +) +{ + vec4 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec4 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + vec4 tmpvar_3; + tmpvar_3 = clamp (m[2], 0.0, 1.0); + vec4 tmpvar_4; + tmpvar_4 = clamp (m[3], 0.0, 1.0); + mat4 tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_1; + tmpvar_5[0] = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = tmpvar_2; + tmpvar_5[1] = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_3; + tmpvar_5[2] = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = tmpvar_4; + tmpvar_5[3] = tmpvar_9; + return tmpvar_5; +} + +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 tex; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + tex = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = (tex.xyz * _Color.xyz); + o.Albedo = tmpvar_3; + float tmpvar_4; + tmpvar_4 = tex.w; + o.Gloss = tmpvar_4; + float tmpvar_5; + tmpvar_5 = (tex.w * _Color.w); + o.Alpha = tmpvar_5; + float tmpvar_6; + tmpvar_6 = _Shininess; + o.Specular = tmpvar_6; +} + +vec4 LightingBlinnPhong_PrePass ( + in SurfaceOutput s, + in vec4 light +) +{ + vec4 c; + float spec; + float tmpvar_1; + tmpvar_1 = (light.w * s.Gloss); + spec = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = ((s.Albedo * light.xyz) + ((light.xyz * _SpecColor.xyz) * spec)); + c.xyz = tmpvar_2.xyz.xyz; + float tmpvar_3; + tmpvar_3 = (s.Alpha + (spec * _SpecColor.w)); + c.w = vec4(tmpvar_3).w; + return c; +} + +vec3 DecodeLightmap ( + in vec4 color +) +{ + return (2.0 * color.xyz); +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 col; + vec3 lm; + vec3 lmIndirect; + vec3 lmFull; + vec4 light; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_3; + float tmpvar_4; + tmpvar_4 = 0.0; + o.Specular = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Alpha = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Gloss = tmpvar_6; + surf (surfIN, o); + vec4 tmpvar_7; + tmpvar_7 = texture2DProj (_LightBuffer, IN.hip_screen); + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + light = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = log2 (light); + vec4 tmpvar_10; + tmpvar_10 = -(tmpvar_9); + light = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = texture2D (unity_Lightmap, IN.hip_lmapFade.xy); + vec3 tmpvar_12; + tmpvar_12 = DecodeLightmap (tmpvar_11); + vec3 tmpvar_13; + tmpvar_13 = tmpvar_12; + lmFull = tmpvar_13; + vec4 tmpvar_14; + tmpvar_14 = texture2D (unity_LightmapInd, IN.hip_lmapFade.xy); + vec3 tmpvar_15; + tmpvar_15 = DecodeLightmap (tmpvar_14); + vec3 tmpvar_16; + tmpvar_16 = tmpvar_15; + lmIndirect = tmpvar_16; + float tmpvar_17; + tmpvar_17 = xll_saturate (IN.hip_lmapFade.z); + vec3 tmpvar_18; + tmpvar_18 = vec3(tmpvar_17); + vec3 tmpvar_19; + tmpvar_19 = mix (lmIndirect, lmFull, tmpvar_18); + vec3 tmpvar_20; + tmpvar_20 = tmpvar_19; + lm = tmpvar_20; + vec3 tmpvar_21; + tmpvar_21 = (light.xyz + lm); + light.xyz = tmpvar_21.xyz.xyz; + vec4 tmpvar_22; + tmpvar_22 = LightingBlinnPhong_PrePass (o, light); + vec4 tmpvar_23; + tmpvar_23 = tmpvar_22; + col = tmpvar_23; + return col; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xy; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyzw; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.hip_screen = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.hip_lmapFade = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = frag_surf (xlt_IN); + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xl_retval = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = xl_retval.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + gl_FragData[0] = tmpvar_12; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Specular2-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Specular2-out.txt new file mode 100644 index 000000000..1cd4202af --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Specular2-out.txt @@ -0,0 +1,25 @@ +uniform sampler2D unity_LightmapInd; +uniform sampler2D unity_Lightmap; +uniform vec4 _SpecColor; +uniform sampler2D _MainTex; +uniform sampler2D _LightBuffer; +uniform vec4 _Color; +void main () +{ + vec3 tmpvar_1; + tmpvar_1 = gl_TexCoord[2].xyz; + vec4 light; + vec4 tmpvar_2; + tmpvar_2 = texture2D (_MainTex, gl_TexCoord[0].xy); + vec4 tmpvar_3; + tmpvar_3 = -(log2 (texture2DProj (_LightBuffer, gl_TexCoord[1]))); + light = tmpvar_3; + light.xyz = (tmpvar_3.xyz + mix ((2.0 * texture2D (unity_LightmapInd, tmpvar_1.xy).xyz), (2.0 * texture2D (unity_Lightmap, tmpvar_1.xy).xyz), vec3(clamp (tmpvar_1.z, 0.0, 1.0)))); + vec4 c; + float tmpvar_4; + tmpvar_4 = (tmpvar_3.w * tmpvar_2.w); + c.xyz = (((tmpvar_2.xyz * _Color.xyz) * light.xyz) + ((light.xyz * _SpecColor.xyz) * tmpvar_4)); + c.w = ((tmpvar_2.w * _Color.w) + (tmpvar_4 * _SpecColor.w)); + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_2UV-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_2UV-in.txt new file mode 100644 index 000000000..bc667de7a --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_2UV-in.txt @@ -0,0 +1,101 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv2_Detail; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 normal; + vec3 lightDir; + vec4 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform sampler2D _Detail; +uniform vec4 _LightColor0; +uniform sampler2D _LightTexture0; +uniform sampler2D _LightTextureB0; +uniform sampler2D _MainTex; +void surf( in Input IN, inout SurfaceOutput o ); +float UnitySpotCookie( in vec4 LightCoord ); +float UnitySpotAttenuate( in vec3 LightCoord ); +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ); +vec4 frag_surf( in v2f_surf IN ); +void surf( in Input IN, inout SurfaceOutput o ) { + o.Albedo = ((texture2D( _MainTex, IN.uv_MainTex).xyz * texture2D( _Detail, IN.uv2_Detail).xyz ) * 2.00000); +} +float UnitySpotCookie( in vec4 LightCoord ) { + return texture2D( _LightTexture0, ((LightCoord.xy / LightCoord.w ) + 0.500000)).w ; +} +float UnitySpotAttenuate( in vec3 LightCoord ) { + return texture2D( _LightTextureB0, vec2( vec2( dot( LightCoord, LightCoord)))).w ; +} +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ) { + float diff; + vec4 c; + diff = max( 0.000000, dot( s.Normal, lightDir)); + c.xyz = ((s.Albedo * _LightColor0.xyz ) * ((diff * atten) * 2.00000)); + c.w = s.Alpha; + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec3 lightDir; + vec4 c; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + surfIN.uv2_Detail = IN.hip_pack0.zw ; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + o.Normal = IN.normal; + surf( surfIN, o); + lightDir = IN.lightDir; + lightDir = normalize( lightDir ); + c = LightingLambert( o, lightDir, ((float( (IN._LightCoord.z > 0.000000) ) * UnitySpotCookie( IN._LightCoord)) * UnitySpotAttenuate( IN._LightCoord.xyz ))); + c.w = 0.000000; + return c; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec4( gl_TexCoord[0]); + xlt_IN.normal = vec3( gl_TexCoord[1]); + xlt_IN.lightDir = vec3( gl_TexCoord[2]); + xlt_IN._LightCoord = vec4( gl_TexCoord[3]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_2UV-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_2UV-ir.txt new file mode 100644 index 000000000..55e9414b6 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_2UV-ir.txt @@ -0,0 +1,186 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv2_Detail; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 normal; + vec3 lightDir; + vec4 _LightCoord; +}; +varying vec4 xlv_FOG; +uniform sampler2D _MainTex; +uniform sampler2D _LightTextureB0; +uniform sampler2D _LightTexture0; +uniform vec4 _LightColor0; +uniform sampler2D _Detail; +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = texture2D (_Detail, IN.uv2_Detail); + vec3 tmpvar_3; + tmpvar_3 = ((tmpvar_1.xyz * tmpvar_2.xyz) * 2.0); + o.Albedo = tmpvar_3; +} + +float UnitySpotCookie ( + in vec4 LightCoord +) +{ + vec4 tmpvar_1; + tmpvar_1 = texture2D (_LightTexture0, ((LightCoord.xy / LightCoord.w) + 0.5)); + return tmpvar_1.w; +} + +float UnitySpotAttenuate ( + in vec3 LightCoord +) +{ + float tmpvar_1; + tmpvar_1 = dot (LightCoord, LightCoord); + vec2 tmpvar_2; + tmpvar_2 = vec2(tmpvar_1); + vec2 tmpvar_3; + tmpvar_3 = tmpvar_2.xy; + vec4 tmpvar_4; + tmpvar_4 = texture2D (_LightTextureB0, tmpvar_3); + return tmpvar_4.w; +} + +vec4 LightingLambert ( + in SurfaceOutput s, + in vec3 lightDir, + in float atten +) +{ + vec4 c; + float diff; + float tmpvar_1; + tmpvar_1 = dot (s.Normal, lightDir); + float tmpvar_2; + tmpvar_2 = max (0.0, tmpvar_1); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + diff = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = ((s.Albedo * _LightColor0.xyz) * ((diff * atten) * 2.0)); + c.xyz = tmpvar_4.xyz.xyz; + float tmpvar_5; + tmpvar_5 = s.Alpha; + c.w = vec4(tmpvar_5).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 c; + vec3 lightDir; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = IN.hip_pack0.zw; + surfIN.uv2_Detail = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Specular = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Alpha = tmpvar_6; + float tmpvar_7; + tmpvar_7 = 0.0; + o.Gloss = tmpvar_7; + vec3 tmpvar_8; + tmpvar_8 = IN.normal; + o.Normal = tmpvar_8; + surf (surfIN, o); + vec3 tmpvar_9; + tmpvar_9 = IN.lightDir; + lightDir = tmpvar_9; + vec3 tmpvar_10; + tmpvar_10 = normalize (lightDir); + vec3 tmpvar_11; + tmpvar_11 = tmpvar_10; + lightDir = tmpvar_11; + float tmpvar_12; + tmpvar_12 = UnitySpotCookie (IN._LightCoord); + float tmpvar_13; + tmpvar_13 = UnitySpotAttenuate (IN._LightCoord.xyz); + vec4 tmpvar_14; + tmpvar_14 = LightingLambert (o, lightDir, ((float((IN._LightCoord.z > 0.0)) * tmpvar_12) * tmpvar_13)); + vec4 tmpvar_15; + tmpvar_15 = tmpvar_14; + c = tmpvar_15; + float tmpvar_16; + tmpvar_16 = 0.0; + c.w = vec4(tmpvar_16).w; + return c; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.normal = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.lightDir = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_TexCoord[3].xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_IN._LightCoord = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = frag_surf (xlt_IN); + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xl_retval = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = xl_retval.xyzw; + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + gl_FragData[0] = tmpvar_14; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_2UV-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_2UV-out.txt new file mode 100644 index 000000000..c72f751a7 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_2UV-out.txt @@ -0,0 +1,22 @@ +uniform sampler2D _MainTex; +uniform sampler2D _LightTextureB0; +uniform sampler2D _LightTexture0; +uniform vec4 _LightColor0; +uniform sampler2D _Detail; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = gl_TexCoord[0]; + vec4 tmpvar_2; + tmpvar_2 = gl_TexCoord[3]; + vec4 c; + vec3 LightCoord_i0; + LightCoord_i0 = tmpvar_2.xyz; + vec4 c_i0; + c_i0.xyz = ((((texture2D (_MainTex, tmpvar_1.xy).xyz * texture2D (_Detail, tmpvar_1.zw).xyz) * 2.0) * _LightColor0.xyz) * ((max (0.0, dot (gl_TexCoord[1].xyz, normalize (gl_TexCoord[2].xyz))) * ((float((tmpvar_2.z > 0.0)) * texture2D (_LightTexture0, ((tmpvar_2.xy / tmpvar_2.w) + 0.5)).w) * texture2D (_LightTextureB0, vec2(dot (LightCoord_i0, LightCoord_i0))).w)) * 2.0)); + c_i0.w = 0.0; + c = c_i0; + c.w = 0.0; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_2UV1-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_2UV1-in.txt new file mode 100644 index 000000000..7a64f00ab --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_2UV1-in.txt @@ -0,0 +1,85 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv2_Detail; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec4 hip_screen; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform sampler2D _Detail; +uniform sampler2D _LightBuffer; +uniform sampler2D _MainTex; +uniform vec4 unity_Ambient; +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingLambert_PrePass( in SurfaceOutput s, in vec4 light ); +vec4 frag_surf( in v2f_surf IN ); +void surf( in Input IN, inout SurfaceOutput o ) { + o.Albedo = ((texture2D( _MainTex, IN.uv_MainTex).xyz * texture2D( _Detail, IN.uv2_Detail).xyz ) * 2.00000); +} +vec4 LightingLambert_PrePass( in SurfaceOutput s, in vec4 light ) { + vec4 c; + c.xyz = (s.Albedo * light.xyz ); + c.w = s.Alpha; + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec4 light; + vec4 col; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + surfIN.uv2_Detail = IN.hip_pack0.zw ; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + surf( surfIN, o); + light = texture2DProj( _LightBuffer, IN.hip_screen); + light = ( -log2( light ) ); + light.xyz += unity_Ambient.xyz ; + col = LightingLambert_PrePass( o, light); + return col; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec4( gl_TexCoord[0]); + xlt_IN.hip_screen = vec4( gl_TexCoord[1]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_2UV1-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_2UV1-ir.txt new file mode 100644 index 000000000..563afd66d --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_2UV1-ir.txt @@ -0,0 +1,135 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv2_Detail; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec4 hip_screen; +}; +varying vec4 xlv_FOG; +uniform vec4 unity_Ambient; +uniform sampler2D _MainTex; +uniform sampler2D _LightBuffer; +uniform sampler2D _Detail; +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = texture2D (_Detail, IN.uv2_Detail); + vec3 tmpvar_3; + tmpvar_3 = ((tmpvar_1.xyz * tmpvar_2.xyz) * 2.0); + o.Albedo = tmpvar_3; +} + +vec4 LightingLambert_PrePass ( + in SurfaceOutput s, + in vec4 light +) +{ + vec4 c; + vec3 tmpvar_1; + tmpvar_1 = (s.Albedo * light.xyz); + c.xyz = tmpvar_1.xyz.xyz; + float tmpvar_2; + tmpvar_2 = s.Alpha; + c.w = vec4(tmpvar_2).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 col; + vec4 light; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = IN.hip_pack0.zw; + surfIN.uv2_Detail = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Specular = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Alpha = tmpvar_6; + float tmpvar_7; + tmpvar_7 = 0.0; + o.Gloss = tmpvar_7; + surf (surfIN, o); + vec4 tmpvar_8; + tmpvar_8 = texture2DProj (_LightBuffer, IN.hip_screen); + vec4 tmpvar_9; + tmpvar_9 = tmpvar_8; + light = tmpvar_9; + vec4 tmpvar_10; + tmpvar_10 = log2 (light); + vec4 tmpvar_11; + tmpvar_11 = -(tmpvar_10); + light = tmpvar_11; + vec3 tmpvar_12; + tmpvar_12 = (light.xyz + unity_Ambient.xyz); + light.xyz = tmpvar_12.xyz.xyz; + vec4 tmpvar_13; + tmpvar_13 = LightingLambert_PrePass (o, light); + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + col = tmpvar_14; + return col; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyzw; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.hip_screen = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = frag_surf (xlt_IN); + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xl_retval = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = xl_retval.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + gl_FragData[0] = tmpvar_10; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_2UV1-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_2UV1-out.txt new file mode 100644 index 000000000..8f67442e4 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_2UV1-out.txt @@ -0,0 +1,19 @@ +uniform vec4 unity_Ambient; +uniform sampler2D _MainTex; +uniform sampler2D _LightBuffer; +uniform sampler2D _Detail; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = gl_TexCoord[0]; + vec4 light; + vec4 tmpvar_2; + tmpvar_2 = -(log2 (texture2DProj (_LightBuffer, gl_TexCoord[1]))); + light = tmpvar_2; + light.xyz = (tmpvar_2.xyz + unity_Ambient.xyz); + vec4 c; + c.xyz = (((texture2D (_MainTex, tmpvar_1.xy).xyz * texture2D (_Detail, tmpvar_1.zw).xyz) * 2.0) * light.xyz); + c.w = 0.0; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Colored_Specular-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Colored_Specular-in.txt new file mode 100644 index 000000000..56385d877 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Colored_Specular-in.txt @@ -0,0 +1,122 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct MySurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + vec3 GlossColor; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_SpecMap; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 normal; + vec3 lightDir; + vec3 viewDir; + vec4 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _LightColor0; +uniform sampler2D _LightTexture0; +uniform sampler2D _LightTextureB0; +uniform sampler2D _MainTex; +uniform sampler2D _SpecMap; +void surf( in Input IN, inout MySurfaceOutput o ); +float UnitySpotCookie( in vec4 LightCoord ); +float UnitySpotAttenuate( in vec3 LightCoord ); +vec4 LightingColoredSpecular( in MySurfaceOutput s, in vec3 lightDir, in vec3 viewDir, in float atten ); +vec4 frag_surf( in v2f_surf IN ); +void surf( in Input IN, inout MySurfaceOutput o ) { + vec4 spec; + o.Albedo = (texture2D( _MainTex, IN.uv_MainTex).xyz * 0.300000); + spec = texture2D( _SpecMap, IN.uv_SpecMap); + o.GlossColor = spec.xyz ; + o.Specular = 0.250000; +} +float UnitySpotCookie( in vec4 LightCoord ) { + return texture2D( _LightTexture0, ((LightCoord.xy / LightCoord.w ) + 0.500000)).w ; +} +float UnitySpotAttenuate( in vec3 LightCoord ) { + return texture2D( _LightTextureB0, vec2( vec2( dot( LightCoord, LightCoord)))).w ; +} +vec4 LightingColoredSpecular( in MySurfaceOutput s, in vec3 lightDir, in vec3 viewDir, in float atten ) { + vec3 h; + float diff; + float nh; + float spec; + vec3 specCol; + vec4 c; + h = normalize( (lightDir + viewDir) ); + diff = max( 0.000000, dot( s.Normal, lightDir)); + nh = max( 0.000000, dot( s.Normal, h)); + spec = pow( nh, 32.0000); + specCol = (spec * s.GlossColor); + c.xyz = ((((s.Albedo * _LightColor0.xyz ) * diff) + (_LightColor0.xyz * specCol)) * (atten * 2.00000)); + c.w = s.Alpha; + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + MySurfaceOutput o; + vec3 lightDir; + vec4 c; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + surfIN.uv_SpecMap = IN.hip_pack0.zw ; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Normal = IN.normal; + surf( surfIN, o); + lightDir = IN.lightDir; + lightDir = normalize( lightDir ); + c = LightingColoredSpecular( o, lightDir, normalize( vec3( IN.viewDir) ), ((float( (IN._LightCoord.z > 0.000000) ) * UnitySpotCookie( IN._LightCoord)) * UnitySpotAttenuate( IN._LightCoord.xyz ))); + c.w = 0.000000; + return c; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec4( gl_TexCoord[0]); + xlt_IN.normal = vec3( gl_TexCoord[1]); + xlt_IN.lightDir = vec3( gl_TexCoord[2]); + xlt_IN.viewDir = vec3( gl_TexCoord[3]); + xlt_IN._LightCoord = vec4( gl_TexCoord[4]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Colored_Specular-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Colored_Specular-ir.txt new file mode 100644 index 000000000..fbd756c01 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Colored_Specular-ir.txt @@ -0,0 +1,228 @@ +struct MySurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + vec3 GlossColor; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_SpecMap; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 normal; + vec3 lightDir; + vec3 viewDir; + vec4 _LightCoord; +}; +varying vec4 xlv_FOG; +uniform sampler2D _SpecMap; +uniform sampler2D _MainTex; +uniform sampler2D _LightTextureB0; +uniform sampler2D _LightTexture0; +uniform vec4 _LightColor0; +void surf ( + in Input IN, + inout MySurfaceOutput o +) +{ + vec4 spec; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec3 tmpvar_2; + tmpvar_2 = (tmpvar_1.xyz * 0.3); + o.Albedo = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = texture2D (_SpecMap, IN.uv_SpecMap); + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + spec = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = spec.xyz; + o.GlossColor = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.25; + o.Specular = tmpvar_6; +} + +float UnitySpotCookie ( + in vec4 LightCoord +) +{ + vec4 tmpvar_1; + tmpvar_1 = texture2D (_LightTexture0, ((LightCoord.xy / LightCoord.w) + 0.5)); + return tmpvar_1.w; +} + +float UnitySpotAttenuate ( + in vec3 LightCoord +) +{ + float tmpvar_1; + tmpvar_1 = dot (LightCoord, LightCoord); + vec2 tmpvar_2; + tmpvar_2 = vec2(tmpvar_1); + vec2 tmpvar_3; + tmpvar_3 = tmpvar_2.xy; + vec4 tmpvar_4; + tmpvar_4 = texture2D (_LightTextureB0, tmpvar_3); + return tmpvar_4.w; +} + +vec4 LightingColoredSpecular ( + in MySurfaceOutput s, + in vec3 lightDir, + in vec3 viewDir, + in float atten +) +{ + vec4 c; + vec3 specCol; + float spec; + float nh; + float diff; + vec3 h; + vec3 tmpvar_1; + tmpvar_1 = normalize ((lightDir + viewDir)); + vec3 tmpvar_2; + tmpvar_2 = tmpvar_1; + h = tmpvar_2; + float tmpvar_3; + tmpvar_3 = dot (s.Normal, lightDir); + float tmpvar_4; + tmpvar_4 = max (0.0, tmpvar_3); + float tmpvar_5; + tmpvar_5 = tmpvar_4; + diff = tmpvar_5; + float tmpvar_6; + tmpvar_6 = dot (s.Normal, h); + float tmpvar_7; + tmpvar_7 = max (0.0, tmpvar_6); + float tmpvar_8; + tmpvar_8 = tmpvar_7; + nh = tmpvar_8; + float tmpvar_9; + tmpvar_9 = pow (nh, 32.0); + float tmpvar_10; + tmpvar_10 = tmpvar_9; + spec = tmpvar_10; + vec3 tmpvar_11; + tmpvar_11 = (spec * s.GlossColor); + specCol = tmpvar_11; + vec3 tmpvar_12; + tmpvar_12 = ((((s.Albedo * _LightColor0.xyz) * diff) + (_LightColor0.xyz * specCol)) * (atten * 2.0)); + c.xyz = tmpvar_12.xyz.xyz; + float tmpvar_13; + tmpvar_13 = s.Alpha; + c.w = vec4(tmpvar_13).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 c; + vec3 lightDir; + MySurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = IN.hip_pack0.zw; + surfIN.uv_SpecMap = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Specular = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Alpha = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = IN.normal; + o.Normal = tmpvar_7; + surf (surfIN, o); + vec3 tmpvar_8; + tmpvar_8 = IN.lightDir; + lightDir = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = normalize (lightDir); + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + lightDir = tmpvar_10; + vec3 tmpvar_11; + tmpvar_11 = IN.viewDir.xyz; + vec3 tmpvar_12; + tmpvar_12 = normalize (tmpvar_11); + float tmpvar_13; + tmpvar_13 = UnitySpotCookie (IN._LightCoord); + float tmpvar_14; + tmpvar_14 = UnitySpotAttenuate (IN._LightCoord.xyz); + vec4 tmpvar_15; + tmpvar_15 = LightingColoredSpecular (o, lightDir, tmpvar_12, ((float((IN._LightCoord.z > 0.0)) * tmpvar_13) * tmpvar_14)); + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + c = tmpvar_16; + float tmpvar_17; + tmpvar_17 = 0.0; + c.w = vec4(tmpvar_17).w; + return c; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.normal = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.lightDir = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = gl_TexCoord[3].xyz; + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_IN.viewDir = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_TexCoord[4].xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_IN._LightCoord = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = frag_surf (xlt_IN); + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_FragData[0] = tmpvar_16; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Colored_Specular-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Colored_Specular-out.txt new file mode 100644 index 000000000..e18ba85a8 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Colored_Specular-out.txt @@ -0,0 +1,26 @@ +uniform sampler2D _SpecMap; +uniform sampler2D _MainTex; +uniform sampler2D _LightTextureB0; +uniform sampler2D _LightTexture0; +uniform vec4 _LightColor0; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = gl_TexCoord[0]; + vec3 tmpvar_2; + tmpvar_2 = gl_TexCoord[1].xyz; + vec4 tmpvar_3; + tmpvar_3 = gl_TexCoord[4]; + vec4 c; + vec3 tmpvar_4; + tmpvar_4 = normalize (gl_TexCoord[2].xyz); + vec3 LightCoord_i0; + LightCoord_i0 = tmpvar_3.xyz; + vec4 c_i0; + c_i0.xyz = (((((texture2D (_MainTex, tmpvar_1.xy).xyz * 0.3) * _LightColor0.xyz) * max (0.0, dot (tmpvar_2, tmpvar_4))) + (_LightColor0.xyz * (pow (max (0.0, dot (tmpvar_2, normalize ((tmpvar_4 + normalize (gl_TexCoord[3].xyz))))), 32.0) * texture2D (_SpecMap, tmpvar_1.zw).xyz))) * (((float((tmpvar_3.z > 0.0)) * texture2D (_LightTexture0, ((tmpvar_3.xy / tmpvar_3.w) + 0.5)).w) * texture2D (_LightTextureB0, vec2(dot (LightCoord_i0, LightCoord_i0))).w) * 2.0)); + c_i0.w = 0.0; + c = c_i0; + c.w = 0.0; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Colored_Specular1-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Colored_Specular1-in.txt new file mode 100644 index 000000000..57e31326d --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Colored_Specular1-in.txt @@ -0,0 +1,78 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct MySurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + vec3 GlossColor; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_SpecMap; +}; +struct v2f_surf { + vec4 pos; + vec3 normal; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform sampler2D _MainTex; +uniform sampler2D _SpecMap; +void surf( in Input IN, inout MySurfaceOutput o ); +vec4 frag_surf( in v2f_surf IN ); +void surf( in Input IN, inout MySurfaceOutput o ) { + vec4 spec; + o.Albedo = (texture2D( _MainTex, IN.uv_MainTex).xyz * 0.300000); + spec = texture2D( _SpecMap, IN.uv_SpecMap); + o.GlossColor = spec.xyz ; + o.Specular = 0.250000; +} +vec4 frag_surf( in v2f_surf IN ) { + MySurfaceOutput o; + Input surfIN; + vec4 res; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Normal = IN.normal; + surf( surfIN, o); + res.xyz = ((o.Normal * vec3( 0.500000, 0.500000, -0.500000)) + 0.500000); + res.w = o.Specular; + return res; +} +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.normal = vec3( gl_TexCoord[0]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Colored_Specular1-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Colored_Specular1-ir.txt new file mode 100644 index 000000000..a79e9df93 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Colored_Specular1-ir.txt @@ -0,0 +1,98 @@ +struct MySurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + vec3 GlossColor; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_SpecMap; +}; +struct v2f_surf { + vec4 pos; + vec3 normal; +}; +uniform sampler2D _SpecMap; +uniform sampler2D _MainTex; +void surf ( + in Input IN, + inout MySurfaceOutput o +) +{ + vec4 spec; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec3 tmpvar_2; + tmpvar_2 = (tmpvar_1.xyz * 0.3); + o.Albedo = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = texture2D (_SpecMap, IN.uv_SpecMap); + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + spec = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = spec.xyz; + o.GlossColor = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.25; + o.Specular = tmpvar_6; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 res; + Input surfIN; + MySurfaceOutput o; + vec3 tmpvar_1; + tmpvar_1 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_2; + float tmpvar_3; + tmpvar_3 = 0.0; + o.Specular = tmpvar_3; + float tmpvar_4; + tmpvar_4 = 0.0; + o.Alpha = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = IN.normal; + o.Normal = tmpvar_5; + surf (surfIN, o); + vec3 tmpvar_6; + tmpvar_6 = ((o.Normal * vec3(0.5, 0.5, -0.5)) + 0.5); + res.xyz = tmpvar_6.xyz.xyz; + float tmpvar_7; + tmpvar_7 = o.Specular; + res.w = vec4(tmpvar_7).w; + return res; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = gl_TexCoord[0].xyz; + vec3 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_IN.normal = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = frag_surf (xlt_IN); + vec4 tmpvar_5; + tmpvar_5 = tmpvar_4; + xl_retval = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = xl_retval.xyzw; + vec4 tmpvar_7; + tmpvar_7 = tmpvar_6; + gl_FragData[0] = tmpvar_7; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Colored_Specular1-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Colored_Specular1-out.txt new file mode 100644 index 000000000..4fe695bf9 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Colored_Specular1-out.txt @@ -0,0 +1,8 @@ +void main () +{ + vec4 res; + res.xyz = ((gl_TexCoord[0].xyz * vec3(0.5, 0.5, -0.5)) + 0.5); + res.w = 0.25; + gl_FragData[0] = res; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Custom_Data-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Custom_Data-in.txt new file mode 100644 index 000000000..6dd56e88c --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Custom_Data-in.txt @@ -0,0 +1,89 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +struct Input { + vec3 foo; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec3 cust_foo; + vec3 normal; + vec3 lightDir; + vec3 _LightCoord; +}; +uniform vec4 _LightColor0; +uniform samplerCube _LightTexture0; +uniform sampler2D _LightTextureB0; +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ); +vec4 frag_surf( in v2f_surf IN ); +void surf( in Input IN, inout SurfaceOutput o ) { + o.Albedo = IN.foo; +} +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ) { + float diff; + vec4 c; + diff = max( 0.000000, dot( s.Normal, lightDir)); + c.xyz = ((s.Albedo * _LightColor0.xyz ) * ((diff * atten) * 2.00000)); + c.w = s.Alpha; + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec3 lightDir; + vec4 c; + surfIN.foo = IN.cust_foo; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + o.Normal = IN.normal; + surf( surfIN, o); + lightDir = IN.lightDir; + lightDir = normalize( lightDir ); + c = LightingLambert( o, lightDir, (texture2D( _LightTextureB0, vec2( vec2( dot( IN._LightCoord, IN._LightCoord)))).w * textureCube( _LightTexture0, IN._LightCoord).w )); + c.w = 0.000000; + return c; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.cust_foo = vec3( gl_TexCoord[0]); + xlt_IN.normal = vec3( gl_TexCoord[1]); + xlt_IN.lightDir = vec3( gl_TexCoord[2]); + xlt_IN._LightCoord = vec3( gl_TexCoord[3]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Custom_Data-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Custom_Data-ir.txt new file mode 100644 index 000000000..bb32f9635 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Custom_Data-ir.txt @@ -0,0 +1,158 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec3 foo; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec3 cust_foo; + vec3 normal; + vec3 lightDir; + vec3 _LightCoord; +}; +varying vec4 xlv_FOG; +uniform sampler2D _LightTextureB0; +uniform samplerCube _LightTexture0; +uniform vec4 _LightColor0; +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec3 tmpvar_1; + tmpvar_1 = IN.foo; + o.Albedo = tmpvar_1; +} + +vec4 LightingLambert ( + in SurfaceOutput s, + in vec3 lightDir, + in float atten +) +{ + vec4 c; + float diff; + float tmpvar_1; + tmpvar_1 = dot (s.Normal, lightDir); + float tmpvar_2; + tmpvar_2 = max (0.0, tmpvar_1); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + diff = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = ((s.Albedo * _LightColor0.xyz) * ((diff * atten) * 2.0)); + c.xyz = tmpvar_4.xyz.xyz; + float tmpvar_5; + tmpvar_5 = s.Alpha; + c.w = vec4(tmpvar_5).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 c; + vec3 lightDir; + SurfaceOutput o; + Input surfIN; + vec3 tmpvar_1; + tmpvar_1 = IN.cust_foo; + surfIN.foo = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_3; + float tmpvar_4; + tmpvar_4 = 0.0; + o.Specular = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Alpha = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Gloss = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = IN.normal; + o.Normal = tmpvar_7; + surf (surfIN, o); + vec3 tmpvar_8; + tmpvar_8 = IN.lightDir; + lightDir = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = normalize (lightDir); + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + lightDir = tmpvar_10; + float tmpvar_11; + tmpvar_11 = dot (IN._LightCoord, IN._LightCoord); + vec2 tmpvar_12; + tmpvar_12 = vec2(tmpvar_11); + vec2 tmpvar_13; + tmpvar_13 = tmpvar_12.xy; + vec4 tmpvar_14; + tmpvar_14 = texture2D (_LightTextureB0, tmpvar_13); + vec4 tmpvar_15; + tmpvar_15 = textureCube (_LightTexture0, IN._LightCoord); + vec4 tmpvar_16; + tmpvar_16 = LightingLambert (o, lightDir, (tmpvar_14.w * tmpvar_15.w)); + vec4 tmpvar_17; + tmpvar_17 = tmpvar_16; + c = tmpvar_17; + float tmpvar_18; + tmpvar_18 = 0.0; + c.w = vec4(tmpvar_18).w; + return c; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xyz; + vec3 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.cust_foo = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.normal = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.lightDir = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = gl_TexCoord[3].xyz; + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_IN._LightCoord = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = frag_surf (xlt_IN); + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xl_retval = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = xl_retval.xyzw; + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + gl_FragData[0] = tmpvar_14; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Custom_Data-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Custom_Data-out.txt new file mode 100644 index 000000000..9b64f3394 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Custom_Data-out.txt @@ -0,0 +1,16 @@ +uniform sampler2D _LightTextureB0; +uniform samplerCube _LightTexture0; +uniform vec4 _LightColor0; +void main () +{ + vec3 tmpvar_1; + tmpvar_1 = gl_TexCoord[3].xyz; + vec4 c; + vec4 c_i0; + c_i0.xyz = ((gl_TexCoord[0].xyz * _LightColor0.xyz) * ((max (0.0, dot (gl_TexCoord[1].xyz, normalize (gl_TexCoord[2].xyz))) * (texture2D (_LightTextureB0, vec2(dot (tmpvar_1, tmpvar_1))).w * textureCube (_LightTexture0, tmpvar_1).w)) * 2.0)); + c_i0.w = 0.0; + c = c_i0; + c.w = 0.0; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Custom_Data1-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Custom_Data1-in.txt new file mode 100644 index 000000000..7eb067b9b --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Custom_Data1-in.txt @@ -0,0 +1,87 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +struct Input { + vec3 foo; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec3 cust_foo; + vec3 normal; + vec3 lightDir; + vec2 _LightCoord; +}; +uniform vec4 _LightColor0; +uniform sampler2D _LightTexture0; +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ); +vec4 frag_surf( in v2f_surf IN ); +void surf( in Input IN, inout SurfaceOutput o ) { + o.Albedo = IN.foo; +} +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ) { + float diff; + vec4 c; + diff = max( 0.000000, dot( s.Normal, lightDir)); + c.xyz = ((s.Albedo * _LightColor0.xyz ) * ((diff * atten) * 2.00000)); + c.w = s.Alpha; + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec3 lightDir; + vec4 c; + surfIN.foo = IN.cust_foo; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + o.Normal = IN.normal; + surf( surfIN, o); + lightDir = IN.lightDir; + c = LightingLambert( o, lightDir, (texture2D( _LightTexture0, IN._LightCoord).w * 1.00000)); + c.w = 0.000000; + return c; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.cust_foo = vec3( gl_TexCoord[0]); + xlt_IN.normal = vec3( gl_TexCoord[1]); + xlt_IN.lightDir = vec3( gl_TexCoord[2]); + xlt_IN._LightCoord = vec2( gl_TexCoord[3]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Custom_Data1-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Custom_Data1-ir.txt new file mode 100644 index 000000000..92e69913c --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Custom_Data1-ir.txt @@ -0,0 +1,144 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec3 foo; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec3 cust_foo; + vec3 normal; + vec3 lightDir; + vec2 _LightCoord; +}; +varying vec4 xlv_FOG; +uniform sampler2D _LightTexture0; +uniform vec4 _LightColor0; +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec3 tmpvar_1; + tmpvar_1 = IN.foo; + o.Albedo = tmpvar_1; +} + +vec4 LightingLambert ( + in SurfaceOutput s, + in vec3 lightDir, + in float atten +) +{ + vec4 c; + float diff; + float tmpvar_1; + tmpvar_1 = dot (s.Normal, lightDir); + float tmpvar_2; + tmpvar_2 = max (0.0, tmpvar_1); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + diff = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = ((s.Albedo * _LightColor0.xyz) * ((diff * atten) * 2.0)); + c.xyz = tmpvar_4.xyz.xyz; + float tmpvar_5; + tmpvar_5 = s.Alpha; + c.w = vec4(tmpvar_5).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 c; + vec3 lightDir; + SurfaceOutput o; + Input surfIN; + vec3 tmpvar_1; + tmpvar_1 = IN.cust_foo; + surfIN.foo = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_3; + float tmpvar_4; + tmpvar_4 = 0.0; + o.Specular = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Alpha = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Gloss = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = IN.normal; + o.Normal = tmpvar_7; + surf (surfIN, o); + vec3 tmpvar_8; + tmpvar_8 = IN.lightDir; + lightDir = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = texture2D (_LightTexture0, IN._LightCoord); + vec4 tmpvar_10; + tmpvar_10 = LightingLambert (o, lightDir, (tmpvar_9.w * 1.0)); + vec4 tmpvar_11; + tmpvar_11 = tmpvar_10; + c = tmpvar_11; + float tmpvar_12; + tmpvar_12 = 0.0; + c.w = vec4(tmpvar_12).w; + return c; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xyz; + vec3 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.cust_foo = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.normal = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.lightDir = tmpvar_8; + vec2 tmpvar_9; + tmpvar_9 = gl_TexCoord[3].xy; + vec2 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_IN._LightCoord = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = frag_surf (xlt_IN); + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xl_retval = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = xl_retval.xyzw; + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + gl_FragData[0] = tmpvar_14; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Custom_Data1-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Custom_Data1-out.txt new file mode 100644 index 000000000..9c8743ce5 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Custom_Data1-out.txt @@ -0,0 +1,13 @@ +uniform sampler2D _LightTexture0; +uniform vec4 _LightColor0; +void main () +{ + vec4 c; + vec4 c_i0; + c_i0.xyz = ((gl_TexCoord[0].xyz * _LightColor0.xyz) * ((max (0.0, dot (gl_TexCoord[1].xyz, gl_TexCoord[2].xyz)) * texture2D (_LightTexture0, gl_TexCoord[3].xy).w) * 2.0)); + c_i0.w = 0.0; + c = c_i0; + c.w = 0.0; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Custom_Data2-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Custom_Data2-in.txt new file mode 100644 index 000000000..ce91810db --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Custom_Data2-in.txt @@ -0,0 +1,115 @@ +float xll_saturate( float x) { + return clamp( x, 0.0, 1.0); +} +vec2 xll_saturate( vec2 x) { + return clamp( x, 0.0, 1.0); +} +vec3 xll_saturate( vec3 x) { + return clamp( x, 0.0, 1.0); +} +vec4 xll_saturate( vec4 x) { + return clamp( x, 0.0, 1.0); +} +mat2 xll_saturate(mat2 m) { + return mat2( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0)); +} +mat3 xll_saturate(mat3 m) { + return mat3( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0), clamp(m[2], 0.0, 1.0)); +} +mat4 xll_saturate(mat4 m) { + return mat4( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0), clamp(m[2], 0.0, 1.0), clamp(m[3], 0.0, 1.0)); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +struct Input { + vec3 foo; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec3 cust_foo; + vec4 hip_screen; + vec3 hip_lmapFade; +}; +uniform sampler2D _LightBuffer; +uniform sampler2D unity_Lightmap; +uniform sampler2D unity_LightmapInd; +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingLambert_PrePass( in SurfaceOutput s, in vec4 light ); +vec3 DecodeLightmap( in vec4 color ); +vec4 frag_surf( in v2f_surf IN ); +void surf( in Input IN, inout SurfaceOutput o ) { + o.Albedo = IN.foo; +} +vec4 LightingLambert_PrePass( in SurfaceOutput s, in vec4 light ) { + vec4 c; + c.xyz = (s.Albedo * light.xyz ); + c.w = s.Alpha; + return c; +} +vec3 DecodeLightmap( in vec4 color ) { + return (2.00000 * color.xyz ); +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec4 light; + vec3 lmFull; + vec3 lmIndirect; + vec3 lm; + vec4 col; + surfIN.foo = IN.cust_foo; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + surf( surfIN, o); + light = texture2DProj( _LightBuffer, IN.hip_screen); + light = ( -log2( light ) ); + lmFull = DecodeLightmap( texture2D( unity_Lightmap, IN.hip_lmapFade.xy )); + lmIndirect = DecodeLightmap( texture2D( unity_LightmapInd, IN.hip_lmapFade.xy )); + lm = mix( lmIndirect, lmFull, vec3( xll_saturate( IN.hip_lmapFade.z ))); + light.xyz += lm; + col = LightingLambert_PrePass( o, light); + return col; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.cust_foo = vec3( gl_TexCoord[0]); + xlt_IN.hip_screen = vec4( gl_TexCoord[1]); + xlt_IN.hip_lmapFade = vec3( gl_TexCoord[2]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Custom_Data2-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Custom_Data2-ir.txt new file mode 100644 index 000000000..0ea908e56 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Custom_Data2-ir.txt @@ -0,0 +1,270 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec3 foo; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec3 cust_foo; + vec4 hip_screen; + vec3 hip_lmapFade; +}; +varying vec4 xlv_FOG; +uniform sampler2D unity_LightmapInd; +uniform sampler2D unity_Lightmap; +uniform sampler2D _LightBuffer; +float xll_saturate ( + in float x +) +{ + float tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec2 xll_saturate ( + in vec2 x +) +{ + vec2 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec3 xll_saturate ( + in vec3 x +) +{ + vec3 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec4 xll_saturate ( + in vec4 x +) +{ + vec4 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +mat2 xll_saturate ( + in mat2 m +) +{ + vec2 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec2 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + mat2 tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_1; + tmpvar_3[0] = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5 = tmpvar_2; + tmpvar_3[1] = tmpvar_5; + return tmpvar_3; +} + +mat3 xll_saturate ( + in mat3 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec3 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + vec3 tmpvar_3; + tmpvar_3 = clamp (m[2], 0.0, 1.0); + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +mat4 xll_saturate ( + in mat4 m +) +{ + vec4 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec4 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + vec4 tmpvar_3; + tmpvar_3 = clamp (m[2], 0.0, 1.0); + vec4 tmpvar_4; + tmpvar_4 = clamp (m[3], 0.0, 1.0); + mat4 tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_1; + tmpvar_5[0] = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = tmpvar_2; + tmpvar_5[1] = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_3; + tmpvar_5[2] = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = tmpvar_4; + tmpvar_5[3] = tmpvar_9; + return tmpvar_5; +} + +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec3 tmpvar_1; + tmpvar_1 = IN.foo; + o.Albedo = tmpvar_1; +} + +vec4 LightingLambert_PrePass ( + in SurfaceOutput s, + in vec4 light +) +{ + vec4 c; + vec3 tmpvar_1; + tmpvar_1 = (s.Albedo * light.xyz); + c.xyz = tmpvar_1.xyz.xyz; + float tmpvar_2; + tmpvar_2 = s.Alpha; + c.w = vec4(tmpvar_2).w; + return c; +} + +vec3 DecodeLightmap ( + in vec4 color +) +{ + return (2.0 * color.xyz); +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 col; + vec3 lm; + vec3 lmIndirect; + vec3 lmFull; + vec4 light; + SurfaceOutput o; + Input surfIN; + vec3 tmpvar_1; + tmpvar_1 = IN.cust_foo; + surfIN.foo = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_3; + float tmpvar_4; + tmpvar_4 = 0.0; + o.Specular = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Alpha = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Gloss = tmpvar_6; + surf (surfIN, o); + vec4 tmpvar_7; + tmpvar_7 = texture2DProj (_LightBuffer, IN.hip_screen); + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + light = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = log2 (light); + vec4 tmpvar_10; + tmpvar_10 = -(tmpvar_9); + light = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = texture2D (unity_Lightmap, IN.hip_lmapFade.xy); + vec3 tmpvar_12; + tmpvar_12 = DecodeLightmap (tmpvar_11); + vec3 tmpvar_13; + tmpvar_13 = tmpvar_12; + lmFull = tmpvar_13; + vec4 tmpvar_14; + tmpvar_14 = texture2D (unity_LightmapInd, IN.hip_lmapFade.xy); + vec3 tmpvar_15; + tmpvar_15 = DecodeLightmap (tmpvar_14); + vec3 tmpvar_16; + tmpvar_16 = tmpvar_15; + lmIndirect = tmpvar_16; + float tmpvar_17; + tmpvar_17 = xll_saturate (IN.hip_lmapFade.z); + vec3 tmpvar_18; + tmpvar_18 = vec3(tmpvar_17); + vec3 tmpvar_19; + tmpvar_19 = mix (lmIndirect, lmFull, tmpvar_18); + vec3 tmpvar_20; + tmpvar_20 = tmpvar_19; + lm = tmpvar_20; + vec3 tmpvar_21; + tmpvar_21 = (light.xyz + lm); + light.xyz = tmpvar_21.xyz.xyz; + vec4 tmpvar_22; + tmpvar_22 = LightingLambert_PrePass (o, light); + vec4 tmpvar_23; + tmpvar_23 = tmpvar_22; + col = tmpvar_23; + return col; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xyz; + vec3 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.cust_foo = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyzw; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.hip_screen = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.hip_lmapFade = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = frag_surf (xlt_IN); + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xl_retval = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = xl_retval.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + gl_FragData[0] = tmpvar_12; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Custom_Data2-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Custom_Data2-out.txt new file mode 100644 index 000000000..a11dfd387 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Custom_Data2-out.txt @@ -0,0 +1,18 @@ +uniform sampler2D unity_LightmapInd; +uniform sampler2D unity_Lightmap; +uniform sampler2D _LightBuffer; +void main () +{ + vec3 tmpvar_1; + tmpvar_1 = gl_TexCoord[2].xyz; + vec4 light; + vec4 tmpvar_2; + tmpvar_2 = -(log2 (texture2DProj (_LightBuffer, gl_TexCoord[1]))); + light = tmpvar_2; + light.xyz = (tmpvar_2.xyz + mix ((2.0 * texture2D (unity_LightmapInd, tmpvar_1.xy).xyz), (2.0 * texture2D (unity_Lightmap, tmpvar_1.xy).xyz), vec3(clamp (tmpvar_1.z, 0.0, 1.0)))); + vec4 c; + c.xyz = (gl_TexCoord[0].xyz * light.xyz); + c.w = 0.0; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_DecalAdd-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_DecalAdd-in.txt new file mode 100644 index 000000000..1f296aca4 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_DecalAdd-in.txt @@ -0,0 +1,88 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 normal; + vec3 lightDir; + vec2 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _LightColor0; +uniform sampler2D _LightTexture0; +uniform sampler2D _MainTex; +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ); +vec4 frag_surf( in v2f_surf IN ); +void surf( in Input IN, inout SurfaceOutput o ) { + o.Albedo = (texture2D( _MainTex, IN.uv_MainTex).xyz * 0.500000); +} +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ) { + float diff; + vec4 c; + diff = max( 0.000000, dot( s.Normal, lightDir)); + c.xyz = ((s.Albedo * _LightColor0.xyz ) * ((diff * atten) * 2.00000)); + c.w = s.Alpha; + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec3 lightDir; + vec4 c; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + o.Normal = IN.normal; + surf( surfIN, o); + lightDir = IN.lightDir; + c = LightingLambert( o, lightDir, (texture2D( _LightTexture0, IN._LightCoord).w * 1.00000)); + c.w = 0.000000; + return c; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec2( gl_TexCoord[0]); + xlt_IN.normal = vec3( gl_TexCoord[1]); + xlt_IN.lightDir = vec3( gl_TexCoord[2]); + xlt_IN._LightCoord = vec2( gl_TexCoord[3]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_DecalAdd-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_DecalAdd-ir.txt new file mode 100644 index 000000000..001e0343b --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_DecalAdd-ir.txt @@ -0,0 +1,147 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 normal; + vec3 lightDir; + vec2 _LightCoord; +}; +varying vec4 xlv_FOG; +uniform sampler2D _MainTex; +uniform sampler2D _LightTexture0; +uniform vec4 _LightColor0; +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec3 tmpvar_2; + tmpvar_2 = (tmpvar_1.xyz * 0.5); + o.Albedo = tmpvar_2; +} + +vec4 LightingLambert ( + in SurfaceOutput s, + in vec3 lightDir, + in float atten +) +{ + vec4 c; + float diff; + float tmpvar_1; + tmpvar_1 = dot (s.Normal, lightDir); + float tmpvar_2; + tmpvar_2 = max (0.0, tmpvar_1); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + diff = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = ((s.Albedo * _LightColor0.xyz) * ((diff * atten) * 2.0)); + c.xyz = tmpvar_4.xyz.xyz; + float tmpvar_5; + tmpvar_5 = s.Alpha; + c.w = vec4(tmpvar_5).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 c; + vec3 lightDir; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_3; + float tmpvar_4; + tmpvar_4 = 0.0; + o.Specular = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Alpha = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Gloss = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = IN.normal; + o.Normal = tmpvar_7; + surf (surfIN, o); + vec3 tmpvar_8; + tmpvar_8 = IN.lightDir; + lightDir = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = texture2D (_LightTexture0, IN._LightCoord); + vec4 tmpvar_10; + tmpvar_10 = LightingLambert (o, lightDir, (tmpvar_9.w * 1.0)); + vec4 tmpvar_11; + tmpvar_11 = tmpvar_10; + c = tmpvar_11; + float tmpvar_12; + tmpvar_12 = 0.0; + c.w = vec4(tmpvar_12).w; + return c; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xy; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.normal = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.lightDir = tmpvar_8; + vec2 tmpvar_9; + tmpvar_9 = gl_TexCoord[3].xy; + vec2 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_IN._LightCoord = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = frag_surf (xlt_IN); + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xl_retval = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = xl_retval.xyzw; + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + gl_FragData[0] = tmpvar_14; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_DecalAdd-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_DecalAdd-out.txt new file mode 100644 index 000000000..bd0621bd9 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_DecalAdd-out.txt @@ -0,0 +1,14 @@ +uniform sampler2D _MainTex; +uniform sampler2D _LightTexture0; +uniform vec4 _LightColor0; +void main () +{ + vec4 c; + vec4 c_i0; + c_i0.xyz = (((texture2D (_MainTex, gl_TexCoord[0].xy).xyz * 0.5) * _LightColor0.xyz) * ((max (0.0, dot (gl_TexCoord[1].xyz, gl_TexCoord[2].xyz)) * texture2D (_LightTexture0, gl_TexCoord[3].xy).w) * 2.0)); + c_i0.w = 0.0; + c = c_i0; + c.w = 0.0; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_DecalAddBump3-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_DecalAddBump3-in.txt new file mode 100644 index 000000000..6bc127799 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_DecalAddBump3-in.txt @@ -0,0 +1,104 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_Decal; + vec2 uv_DecalBump; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 lightDir; + vec3 vlight; + vec4 _ShadowCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform sampler2D _Decal; +uniform sampler2D _DecalBump; +uniform vec4 _LightColor0; +uniform sampler2D _ShadowMapTexture; +float unitySampleShadow( in vec4 shadowCoord ); +vec4 UnpackNormal( in vec4 packednormal ); +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ); +vec4 frag_surf( in v2f_surf IN ); +float unitySampleShadow( in vec4 shadowCoord ) { + float shadow; + shadow = texture2DProj( _ShadowMapTexture, shadowCoord).x ; + return shadow; +} +vec4 UnpackNormal( in vec4 packednormal ) { + vec4 normal; + normal.xy = ((packednormal.wy * 2.00000) - 1.00000); + normal.z = sqrt( ((1.00000 - (normal.x * normal.x )) - (normal.y * normal.y )) ); + return normal; +} +void surf( in Input IN, inout SurfaceOutput o ) { + o.Albedo = (texture2D( _Decal, IN.uv_Decal).xyz * 0.500000); + o.Normal = vec3( UnpackNormal( texture2D( _DecalBump, IN.uv_DecalBump))); +} +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ) { + float diff; + vec4 c; + diff = max( 0.000000, dot( s.Normal, lightDir)); + c.xyz = ((s.Albedo * _LightColor0.xyz ) * ((diff * atten) * 2.00000)); + c.w = s.Alpha; + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + float atten; + vec4 c; + surfIN.uv_Decal = IN.hip_pack0.xy ; + surfIN.uv_DecalBump = IN.hip_pack0.zw ; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + surf( surfIN, o); + atten = unitySampleShadow( IN._ShadowCoord); + c = LightingLambert( o, IN.lightDir, atten); + c.xyz += (o.Albedo * IN.vlight); + return c; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec4( gl_TexCoord[0]); + xlt_IN.lightDir = vec3( gl_TexCoord[1]); + xlt_IN.vlight = vec3( gl_TexCoord[2]); + xlt_IN._ShadowCoord = vec4( gl_TexCoord[3]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_DecalAddBump3-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_DecalAddBump3-ir.txt new file mode 100644 index 000000000..cae128f93 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_DecalAddBump3-ir.txt @@ -0,0 +1,187 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_Decal; + vec2 uv_DecalBump; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 lightDir; + vec3 vlight; + vec4 _ShadowCoord; +}; +varying vec4 xlv_FOG; +uniform sampler2D _ShadowMapTexture; +uniform vec4 _LightColor0; +uniform sampler2D _DecalBump; +uniform sampler2D _Decal; +float unitySampleShadow ( + in vec4 shadowCoord +) +{ + float shadow; + vec4 tmpvar_1; + tmpvar_1 = texture2DProj (_ShadowMapTexture, shadowCoord); + float tmpvar_2; + tmpvar_2 = tmpvar_1.x; + shadow = tmpvar_2; + return shadow; +} + +vec4 UnpackNormal ( + in vec4 packednormal +) +{ + vec4 normal; + vec2 tmpvar_1; + tmpvar_1 = ((packednormal.wy * 2.0) - 1.0); + normal.xy = tmpvar_1.xy.xy; + float tmpvar_2; + tmpvar_2 = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + normal.z = vec3(tmpvar_3).z; + return normal; +} + +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 tmpvar_1; + tmpvar_1 = texture2D (_Decal, IN.uv_Decal); + vec3 tmpvar_2; + tmpvar_2 = (tmpvar_1.xyz * 0.5); + o.Albedo = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = texture2D (_DecalBump, IN.uv_DecalBump); + vec4 tmpvar_4; + tmpvar_4 = UnpackNormal (tmpvar_3); + vec3 tmpvar_5; + tmpvar_5 = tmpvar_4.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + o.Normal = tmpvar_6; +} + +vec4 LightingLambert ( + in SurfaceOutput s, + in vec3 lightDir, + in float atten +) +{ + vec4 c; + float diff; + float tmpvar_1; + tmpvar_1 = dot (s.Normal, lightDir); + float tmpvar_2; + tmpvar_2 = max (0.0, tmpvar_1); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + diff = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = ((s.Albedo * _LightColor0.xyz) * ((diff * atten) * 2.0)); + c.xyz = tmpvar_4.xyz.xyz; + float tmpvar_5; + tmpvar_5 = s.Alpha; + c.w = vec4(tmpvar_5).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 c; + float atten; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_Decal = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = IN.hip_pack0.zw; + surfIN.uv_DecalBump = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Specular = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Alpha = tmpvar_6; + float tmpvar_7; + tmpvar_7 = 0.0; + o.Gloss = tmpvar_7; + surf (surfIN, o); + float tmpvar_8; + tmpvar_8 = unitySampleShadow (IN._ShadowCoord); + float tmpvar_9; + tmpvar_9 = tmpvar_8; + atten = tmpvar_9; + vec4 tmpvar_10; + tmpvar_10 = LightingLambert (o, IN.lightDir, atten); + vec4 tmpvar_11; + tmpvar_11 = tmpvar_10; + c = tmpvar_11; + vec3 tmpvar_12; + tmpvar_12 = (c.xyz + (o.Albedo * IN.vlight)); + c.xyz = tmpvar_12.xyz.xyz; + return c; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.lightDir = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.vlight = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_TexCoord[3].xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_IN._ShadowCoord = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = frag_surf (xlt_IN); + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xl_retval = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = xl_retval.xyzw; + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + gl_FragData[0] = tmpvar_14; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_DecalAddBump3-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_DecalAddBump3-out.txt new file mode 100644 index 000000000..11a407e22 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_DecalAddBump3-out.txt @@ -0,0 +1,22 @@ +uniform sampler2D _ShadowMapTexture; +uniform vec4 _LightColor0; +uniform sampler2D _DecalBump; +uniform sampler2D _Decal; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = gl_TexCoord[0]; + vec4 c; + vec3 tmpvar_2; + tmpvar_2 = (texture2D (_Decal, tmpvar_1.xy).xyz * 0.5); + vec4 normal; + normal.xy = ((texture2D (_DecalBump, tmpvar_1.zw).wy * 2.0) - 1.0); + normal.z = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + vec4 c_i0; + c_i0.xyz = ((tmpvar_2 * _LightColor0.xyz) * ((max (0.0, dot (normal.xyz, gl_TexCoord[1].xyz)) * texture2DProj (_ShadowMapTexture, gl_TexCoord[3]).x) * 2.0)); + c_i0.w = 0.0; + c = c_i0; + c.xyz = (c_i0.xyz + (tmpvar_2 * gl_TexCoord[2].xyz)); + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_DecalAddBump5-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_DecalAddBump5-in.txt new file mode 100644 index 000000000..1d5921b82 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_DecalAddBump5-in.txt @@ -0,0 +1,97 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_Decal; + vec2 uv_DecalBump; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 lightDir; + vec3 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform sampler2D _Decal; +uniform sampler2D _DecalBump; +uniform vec4 _LightColor0; +uniform sampler2D _LightTexture0; +vec4 UnpackNormal( in vec4 packednormal ); +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ); +vec4 frag_surf( in v2f_surf IN ); +vec4 UnpackNormal( in vec4 packednormal ) { + vec4 normal; + normal.xy = ((packednormal.wy * 2.00000) - 1.00000); + normal.z = sqrt( ((1.00000 - (normal.x * normal.x )) - (normal.y * normal.y )) ); + return normal; +} +void surf( in Input IN, inout SurfaceOutput o ) { + o.Albedo = (texture2D( _Decal, IN.uv_Decal).xyz * 0.500000); + o.Normal = vec3( UnpackNormal( texture2D( _DecalBump, IN.uv_DecalBump))); +} +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ) { + float diff; + vec4 c; + diff = max( 0.000000, dot( s.Normal, lightDir)); + c.xyz = ((s.Albedo * _LightColor0.xyz ) * ((diff * atten) * 2.00000)); + c.w = s.Alpha; + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec3 lightDir; + vec4 c; + surfIN.uv_Decal = IN.hip_pack0.xy ; + surfIN.uv_DecalBump = IN.hip_pack0.zw ; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + surf( surfIN, o); + lightDir = IN.lightDir; + lightDir = normalize( lightDir ); + c = LightingLambert( o, lightDir, texture2D( _LightTexture0, vec2( vec2( dot( IN._LightCoord, IN._LightCoord)))).w ); + c.w = 0.000000; + return c; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec4( gl_TexCoord[0]); + xlt_IN.lightDir = vec3( gl_TexCoord[1]); + xlt_IN._LightCoord = vec3( gl_TexCoord[2]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_DecalAddBump5-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_DecalAddBump5-ir.txt new file mode 100644 index 000000000..65d0a8a0a --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_DecalAddBump5-ir.txt @@ -0,0 +1,179 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_Decal; + vec2 uv_DecalBump; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 lightDir; + vec3 _LightCoord; +}; +varying vec4 xlv_FOG; +uniform sampler2D _LightTexture0; +uniform vec4 _LightColor0; +uniform sampler2D _DecalBump; +uniform sampler2D _Decal; +vec4 UnpackNormal ( + in vec4 packednormal +) +{ + vec4 normal; + vec2 tmpvar_1; + tmpvar_1 = ((packednormal.wy * 2.0) - 1.0); + normal.xy = tmpvar_1.xy.xy; + float tmpvar_2; + tmpvar_2 = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + normal.z = vec3(tmpvar_3).z; + return normal; +} + +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 tmpvar_1; + tmpvar_1 = texture2D (_Decal, IN.uv_Decal); + vec3 tmpvar_2; + tmpvar_2 = (tmpvar_1.xyz * 0.5); + o.Albedo = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = texture2D (_DecalBump, IN.uv_DecalBump); + vec4 tmpvar_4; + tmpvar_4 = UnpackNormal (tmpvar_3); + vec3 tmpvar_5; + tmpvar_5 = tmpvar_4.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + o.Normal = tmpvar_6; +} + +vec4 LightingLambert ( + in SurfaceOutput s, + in vec3 lightDir, + in float atten +) +{ + vec4 c; + float diff; + float tmpvar_1; + tmpvar_1 = dot (s.Normal, lightDir); + float tmpvar_2; + tmpvar_2 = max (0.0, tmpvar_1); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + diff = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = ((s.Albedo * _LightColor0.xyz) * ((diff * atten) * 2.0)); + c.xyz = tmpvar_4.xyz.xyz; + float tmpvar_5; + tmpvar_5 = s.Alpha; + c.w = vec4(tmpvar_5).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 c; + vec3 lightDir; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_Decal = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = IN.hip_pack0.zw; + surfIN.uv_DecalBump = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Specular = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Alpha = tmpvar_6; + float tmpvar_7; + tmpvar_7 = 0.0; + o.Gloss = tmpvar_7; + surf (surfIN, o); + vec3 tmpvar_8; + tmpvar_8 = IN.lightDir; + lightDir = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = normalize (lightDir); + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + lightDir = tmpvar_10; + float tmpvar_11; + tmpvar_11 = dot (IN._LightCoord, IN._LightCoord); + vec2 tmpvar_12; + tmpvar_12 = vec2(tmpvar_11); + vec2 tmpvar_13; + tmpvar_13 = tmpvar_12.xy; + vec4 tmpvar_14; + tmpvar_14 = texture2D (_LightTexture0, tmpvar_13); + vec4 tmpvar_15; + tmpvar_15 = LightingLambert (o, lightDir, tmpvar_14.w); + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + c = tmpvar_16; + float tmpvar_17; + tmpvar_17 = 0.0; + c.w = vec4(tmpvar_17).w; + return c; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.lightDir = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN._LightCoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = frag_surf (xlt_IN); + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xl_retval = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = xl_retval.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + gl_FragData[0] = tmpvar_12; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_DecalAddBump5-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_DecalAddBump5-out.txt new file mode 100644 index 000000000..44c752add --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_DecalAddBump5-out.txt @@ -0,0 +1,22 @@ +uniform sampler2D _LightTexture0; +uniform vec4 _LightColor0; +uniform sampler2D _DecalBump; +uniform sampler2D _Decal; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = gl_TexCoord[0]; + vec3 tmpvar_2; + tmpvar_2 = gl_TexCoord[2].xyz; + vec4 c; + vec4 normal; + normal.xy = ((texture2D (_DecalBump, tmpvar_1.zw).wy * 2.0) - 1.0); + normal.z = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + vec4 c_i0; + c_i0.xyz = (((texture2D (_Decal, tmpvar_1.xy).xyz * 0.5) * _LightColor0.xyz) * ((max (0.0, dot (normal.xyz, normalize (gl_TexCoord[1].xyz))) * texture2D (_LightTexture0, vec2(dot (tmpvar_2, tmpvar_2))).w) * 2.0)); + c_i0.w = 0.0; + c = c_i0; + c.w = 0.0; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Diffuse_Wrapped-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Diffuse_Wrapped-in.txt new file mode 100644 index 000000000..0c2d0cbc0 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Diffuse_Wrapped-in.txt @@ -0,0 +1,90 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 normal; + vec3 lightDir; + vec2 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _LightColor0; +uniform sampler2D _LightTexture0; +uniform sampler2D _MainTex; +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingWrapLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ); +vec4 frag_surf( in v2f_surf IN ); +void surf( in Input IN, inout SurfaceOutput o ) { + o.Albedo = texture2D( _MainTex, IN.uv_MainTex).xyz ; +} +vec4 LightingWrapLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ) { + float NdotL; + float diff; + vec4 c; + NdotL = dot( s.Normal, lightDir); + diff = ((NdotL * 0.500000) + 0.500000); + c.xyz = ((s.Albedo * _LightColor0.xyz ) * ((diff * atten) * 2.00000)); + c.w = s.Alpha; + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec3 lightDir; + vec4 c; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + o.Normal = IN.normal; + surf( surfIN, o); + lightDir = IN.lightDir; + c = LightingWrapLambert( o, lightDir, (texture2D( _LightTexture0, IN._LightCoord).w * 1.00000)); + c.w = 0.000000; + return c; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec2( gl_TexCoord[0]); + xlt_IN.normal = vec3( gl_TexCoord[1]); + xlt_IN.lightDir = vec3( gl_TexCoord[2]); + xlt_IN._LightCoord = vec2( gl_TexCoord[3]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Diffuse_Wrapped-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Diffuse_Wrapped-ir.txt new file mode 100644 index 000000000..936c59954 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Diffuse_Wrapped-ir.txt @@ -0,0 +1,149 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 normal; + vec3 lightDir; + vec2 _LightCoord; +}; +varying vec4 xlv_FOG; +uniform sampler2D _MainTex; +uniform sampler2D _LightTexture0; +uniform vec4 _LightColor0; +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec3 tmpvar_2; + tmpvar_2 = tmpvar_1.xyz; + o.Albedo = tmpvar_2; +} + +vec4 LightingWrapLambert ( + in SurfaceOutput s, + in vec3 lightDir, + in float atten +) +{ + vec4 c; + float diff; + float NdotL; + float tmpvar_1; + tmpvar_1 = dot (s.Normal, lightDir); + float tmpvar_2; + tmpvar_2 = tmpvar_1; + NdotL = tmpvar_2; + float tmpvar_3; + tmpvar_3 = ((NdotL * 0.5) + 0.5); + diff = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = ((s.Albedo * _LightColor0.xyz) * ((diff * atten) * 2.0)); + c.xyz = tmpvar_4.xyz.xyz; + float tmpvar_5; + tmpvar_5 = s.Alpha; + c.w = vec4(tmpvar_5).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 c; + vec3 lightDir; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_3; + float tmpvar_4; + tmpvar_4 = 0.0; + o.Specular = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Alpha = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Gloss = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = IN.normal; + o.Normal = tmpvar_7; + surf (surfIN, o); + vec3 tmpvar_8; + tmpvar_8 = IN.lightDir; + lightDir = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = texture2D (_LightTexture0, IN._LightCoord); + vec4 tmpvar_10; + tmpvar_10 = LightingWrapLambert (o, lightDir, (tmpvar_9.w * 1.0)); + vec4 tmpvar_11; + tmpvar_11 = tmpvar_10; + c = tmpvar_11; + float tmpvar_12; + tmpvar_12 = 0.0; + c.w = vec4(tmpvar_12).w; + return c; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xy; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.normal = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.lightDir = tmpvar_8; + vec2 tmpvar_9; + tmpvar_9 = gl_TexCoord[3].xy; + vec2 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_IN._LightCoord = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = frag_surf (xlt_IN); + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xl_retval = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = xl_retval.xyzw; + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + gl_FragData[0] = tmpvar_14; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Diffuse_Wrapped-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Diffuse_Wrapped-out.txt new file mode 100644 index 000000000..b40e6133e --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Diffuse_Wrapped-out.txt @@ -0,0 +1,14 @@ +uniform sampler2D _MainTex; +uniform sampler2D _LightTexture0; +uniform vec4 _LightColor0; +void main () +{ + vec4 c; + vec4 c_i0; + c_i0.xyz = ((texture2D (_MainTex, gl_TexCoord[0].xy).xyz * _LightColor0.xyz) * ((((dot (gl_TexCoord[1].xyz, gl_TexCoord[2].xyz) * 0.5) + 0.5) * texture2D (_LightTexture0, gl_TexCoord[3].xy).w) * 2.0)); + c_i0.w = 0.0; + c = c_i0; + c.w = 0.0; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Rim-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Rim-in.txt new file mode 100644 index 000000000..3361d28cc --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Rim-in.txt @@ -0,0 +1,112 @@ +float xll_saturate( float x) { + return clamp( x, 0.0, 1.0); +} +vec2 xll_saturate( vec2 x) { + return clamp( x, 0.0, 1.0); +} +vec3 xll_saturate( vec3 x) { + return clamp( x, 0.0, 1.0); +} +vec4 xll_saturate( vec4 x) { + return clamp( x, 0.0, 1.0); +} +mat2 xll_saturate(mat2 m) { + return mat2( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0)); +} +mat3 xll_saturate(mat3 m) { + return mat3( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0), clamp(m[2], 0.0, 1.0)); +} +mat4 xll_saturate(mat4 m) { + return mat4( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0), clamp(m[2], 0.0, 1.0), clamp(m[3], 0.0, 1.0)); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec3 viewDir; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 normal; + vec3 lightDir; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _LightColor0; +uniform sampler2D _MainTex; +uniform vec4 _RimColor; +uniform float _RimPower; +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ); +vec4 frag_surf( in v2f_surf IN ); +void surf( in Input IN, inout SurfaceOutput o ) { + float rim; + o.Albedo = texture2D( _MainTex, IN.uv_MainTex).xyz ; + rim = (1.00000 - xll_saturate( dot( normalize( IN.viewDir ), o.Normal) )); + o.Emission = (_RimColor.xyz * pow( rim, _RimPower)); +} +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ) { + float diff; + vec4 c; + diff = max( 0.000000, dot( s.Normal, lightDir)); + c.xyz = ((s.Albedo * _LightColor0.xyz ) * ((diff * atten) * 2.00000)); + c.w = s.Alpha; + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec3 lightDir; + vec4 c; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + o.Normal = IN.normal; + surf( surfIN, o); + lightDir = IN.lightDir; + c = LightingLambert( o, lightDir, 1.00000); + c.w = 0.000000; + return c; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec2( gl_TexCoord[0]); + xlt_IN.normal = vec3( gl_TexCoord[1]); + xlt_IN.lightDir = vec3( gl_TexCoord[2]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Rim-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Rim-ir.txt new file mode 100644 index 000000000..2a63a151d --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Rim-ir.txt @@ -0,0 +1,261 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec3 viewDir; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 normal; + vec3 lightDir; +}; +varying vec4 xlv_FOG; +uniform float _RimPower; +uniform vec4 _RimColor; +uniform sampler2D _MainTex; +uniform vec4 _LightColor0; +float xll_saturate ( + in float x +) +{ + float tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec2 xll_saturate ( + in vec2 x +) +{ + vec2 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec3 xll_saturate ( + in vec3 x +) +{ + vec3 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec4 xll_saturate ( + in vec4 x +) +{ + vec4 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +mat2 xll_saturate ( + in mat2 m +) +{ + vec2 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec2 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + mat2 tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_1; + tmpvar_3[0] = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5 = tmpvar_2; + tmpvar_3[1] = tmpvar_5; + return tmpvar_3; +} + +mat3 xll_saturate ( + in mat3 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec3 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + vec3 tmpvar_3; + tmpvar_3 = clamp (m[2], 0.0, 1.0); + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +mat4 xll_saturate ( + in mat4 m +) +{ + vec4 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec4 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + vec4 tmpvar_3; + tmpvar_3 = clamp (m[2], 0.0, 1.0); + vec4 tmpvar_4; + tmpvar_4 = clamp (m[3], 0.0, 1.0); + mat4 tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_1; + tmpvar_5[0] = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = tmpvar_2; + tmpvar_5[1] = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_3; + tmpvar_5[2] = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = tmpvar_4; + tmpvar_5[3] = tmpvar_9; + return tmpvar_5; +} + +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + float rim; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec3 tmpvar_2; + tmpvar_2 = tmpvar_1.xyz; + o.Albedo = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = normalize (IN.viewDir); + float tmpvar_4; + tmpvar_4 = dot (tmpvar_3, o.Normal); + float tmpvar_5; + tmpvar_5 = xll_saturate (tmpvar_4); + float tmpvar_6; + tmpvar_6 = (1.0 - tmpvar_5); + rim = tmpvar_6; + float tmpvar_7; + tmpvar_7 = pow (rim, _RimPower); + vec3 tmpvar_8; + tmpvar_8 = (_RimColor.xyz * tmpvar_7); + o.Emission = tmpvar_8; +} + +vec4 LightingLambert ( + in SurfaceOutput s, + in vec3 lightDir, + in float atten +) +{ + vec4 c; + float diff; + float tmpvar_1; + tmpvar_1 = dot (s.Normal, lightDir); + float tmpvar_2; + tmpvar_2 = max (0.0, tmpvar_1); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + diff = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = ((s.Albedo * _LightColor0.xyz) * ((diff * atten) * 2.0)); + c.xyz = tmpvar_4.xyz.xyz; + float tmpvar_5; + tmpvar_5 = s.Alpha; + c.w = vec4(tmpvar_5).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 c; + vec3 lightDir; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_3; + float tmpvar_4; + tmpvar_4 = 0.0; + o.Specular = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Alpha = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Gloss = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = IN.normal; + o.Normal = tmpvar_7; + surf (surfIN, o); + vec3 tmpvar_8; + tmpvar_8 = IN.lightDir; + lightDir = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = LightingLambert (o, lightDir, 1.0); + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + c = tmpvar_10; + float tmpvar_11; + tmpvar_11 = 0.0; + c.w = vec4(tmpvar_11).w; + return c; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xy; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.normal = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.lightDir = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = frag_surf (xlt_IN); + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xl_retval = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = xl_retval.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + gl_FragData[0] = tmpvar_12; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Rim-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Rim-out.txt new file mode 100644 index 000000000..cfd82130b --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Rim-out.txt @@ -0,0 +1,13 @@ +uniform sampler2D _MainTex; +uniform vec4 _LightColor0; +void main () +{ + vec4 c; + vec4 c_i0; + c_i0.xyz = ((texture2D (_MainTex, gl_TexCoord[0].xy).xyz * _LightColor0.xyz) * (max (0.0, dot (gl_TexCoord[1].xyz, gl_TexCoord[2].xyz)) * 2.0)); + c_i0.w = 0.0; + c = c_i0; + c.w = 0.0; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Rim1-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Rim1-in.txt new file mode 100644 index 000000000..6fc5df14e --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Rim1-in.txt @@ -0,0 +1,116 @@ +float xll_saturate( float x) { + return clamp( x, 0.0, 1.0); +} +vec2 xll_saturate( vec2 x) { + return clamp( x, 0.0, 1.0); +} +vec3 xll_saturate( vec3 x) { + return clamp( x, 0.0, 1.0); +} +vec4 xll_saturate( vec4 x) { + return clamp( x, 0.0, 1.0); +} +mat2 xll_saturate(mat2 m) { + return mat2( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0)); +} +mat3 xll_saturate(mat3 m) { + return mat3( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0), clamp(m[2], 0.0, 1.0)); +} +mat4 xll_saturate(mat4 m) { + return mat4( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0), clamp(m[2], 0.0, 1.0), clamp(m[3], 0.0, 1.0)); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec3 viewDir; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 viewDir; + vec4 hip_screen; + vec3 normal; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform sampler2D _LightBuffer; +uniform sampler2D _MainTex; +uniform vec4 _RimColor; +uniform float _RimPower; +uniform vec4 unity_Ambient; +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingLambert_PrePass( in SurfaceOutput s, in vec4 light ); +vec4 frag_surf( in v2f_surf IN ); +void surf( in Input IN, inout SurfaceOutput o ) { + float rim; + o.Albedo = texture2D( _MainTex, IN.uv_MainTex).xyz ; + rim = (1.00000 - xll_saturate( dot( normalize( IN.viewDir ), o.Normal) )); + o.Emission = (_RimColor.xyz * pow( rim, _RimPower)); +} +vec4 LightingLambert_PrePass( in SurfaceOutput s, in vec4 light ) { + vec4 c; + c.xyz = (s.Albedo * light.xyz ); + c.w = s.Alpha; + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec4 light; + vec4 col; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + surfIN.viewDir = IN.viewDir; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + o.Normal = IN.normal; + surf( surfIN, o); + light = texture2DProj( _LightBuffer, IN.hip_screen); + light = ( -log2( light ) ); + light.xyz += unity_Ambient.xyz ; + col = LightingLambert_PrePass( o, light); + col.xyz += o.Emission; + return col; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec2( gl_TexCoord[0]); + xlt_IN.viewDir = vec3( gl_TexCoord[1]); + xlt_IN.hip_screen = vec4( gl_TexCoord[2]); + xlt_IN.normal = vec3( gl_TexCoord[3]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Rim1-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Rim1-ir.txt new file mode 100644 index 000000000..6e20abb1f --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Rim1-ir.txt @@ -0,0 +1,272 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec3 viewDir; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 viewDir; + vec4 hip_screen; + vec3 normal; +}; +varying vec4 xlv_FOG; +uniform vec4 unity_Ambient; +uniform float _RimPower; +uniform vec4 _RimColor; +uniform sampler2D _MainTex; +uniform sampler2D _LightBuffer; +float xll_saturate ( + in float x +) +{ + float tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec2 xll_saturate ( + in vec2 x +) +{ + vec2 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec3 xll_saturate ( + in vec3 x +) +{ + vec3 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec4 xll_saturate ( + in vec4 x +) +{ + vec4 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +mat2 xll_saturate ( + in mat2 m +) +{ + vec2 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec2 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + mat2 tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_1; + tmpvar_3[0] = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5 = tmpvar_2; + tmpvar_3[1] = tmpvar_5; + return tmpvar_3; +} + +mat3 xll_saturate ( + in mat3 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec3 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + vec3 tmpvar_3; + tmpvar_3 = clamp (m[2], 0.0, 1.0); + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +mat4 xll_saturate ( + in mat4 m +) +{ + vec4 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec4 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + vec4 tmpvar_3; + tmpvar_3 = clamp (m[2], 0.0, 1.0); + vec4 tmpvar_4; + tmpvar_4 = clamp (m[3], 0.0, 1.0); + mat4 tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_1; + tmpvar_5[0] = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = tmpvar_2; + tmpvar_5[1] = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_3; + tmpvar_5[2] = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = tmpvar_4; + tmpvar_5[3] = tmpvar_9; + return tmpvar_5; +} + +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + float rim; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec3 tmpvar_2; + tmpvar_2 = tmpvar_1.xyz; + o.Albedo = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = normalize (IN.viewDir); + float tmpvar_4; + tmpvar_4 = dot (tmpvar_3, o.Normal); + float tmpvar_5; + tmpvar_5 = xll_saturate (tmpvar_4); + float tmpvar_6; + tmpvar_6 = (1.0 - tmpvar_5); + rim = tmpvar_6; + float tmpvar_7; + tmpvar_7 = pow (rim, _RimPower); + vec3 tmpvar_8; + tmpvar_8 = (_RimColor.xyz * tmpvar_7); + o.Emission = tmpvar_8; +} + +vec4 LightingLambert_PrePass ( + in SurfaceOutput s, + in vec4 light +) +{ + vec4 c; + vec3 tmpvar_1; + tmpvar_1 = (s.Albedo * light.xyz); + c.xyz = tmpvar_1.xyz.xyz; + float tmpvar_2; + tmpvar_2 = s.Alpha; + c.w = vec4(tmpvar_2).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 col; + vec4 light; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = IN.viewDir; + surfIN.viewDir = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Specular = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Alpha = tmpvar_6; + float tmpvar_7; + tmpvar_7 = 0.0; + o.Gloss = tmpvar_7; + vec3 tmpvar_8; + tmpvar_8 = IN.normal; + o.Normal = tmpvar_8; + surf (surfIN, o); + vec4 tmpvar_9; + tmpvar_9 = texture2DProj (_LightBuffer, IN.hip_screen); + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + light = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = log2 (light); + vec4 tmpvar_12; + tmpvar_12 = -(tmpvar_11); + light = tmpvar_12; + vec3 tmpvar_13; + tmpvar_13 = (light.xyz + unity_Ambient.xyz); + light.xyz = tmpvar_13.xyz.xyz; + vec4 tmpvar_14; + tmpvar_14 = LightingLambert_PrePass (o, light); + vec4 tmpvar_15; + tmpvar_15 = tmpvar_14; + col = tmpvar_15; + vec3 tmpvar_16; + tmpvar_16 = (col.xyz + o.Emission); + col.xyz = tmpvar_16.xyz.xyz; + return col; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xy; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.viewDir = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.hip_screen = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = gl_TexCoord[3].xyz; + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_IN.normal = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = frag_surf (xlt_IN); + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xl_retval = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = xl_retval.xyzw; + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + gl_FragData[0] = tmpvar_14; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Rim1-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Rim1-out.txt new file mode 100644 index 000000000..540cc27aa --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Rim1-out.txt @@ -0,0 +1,21 @@ +uniform vec4 unity_Ambient; +uniform float _RimPower; +uniform vec4 _RimColor; +uniform sampler2D _MainTex; +uniform sampler2D _LightBuffer; +void main () +{ + vec4 col; + vec4 light; + vec4 tmpvar_1; + tmpvar_1 = -(log2 (texture2DProj (_LightBuffer, gl_TexCoord[2]))); + light = tmpvar_1; + light.xyz = (tmpvar_1.xyz + unity_Ambient.xyz); + vec4 c; + c.xyz = (texture2D (_MainTex, gl_TexCoord[0].xy).xyz * light.xyz); + c.w = 0.0; + col = c; + col.xyz = (c.xyz + (_RimColor.xyz * pow ((1.0 - clamp (dot (normalize (gl_TexCoord[1].xyz), gl_TexCoord[3].xyz), 0.0, 1.0)), _RimPower))); + gl_FragData[0] = col; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Rim2-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Rim2-in.txt new file mode 100644 index 000000000..3fc23f384 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Rim2-in.txt @@ -0,0 +1,129 @@ +float xll_saturate( float x) { + return clamp( x, 0.0, 1.0); +} +vec2 xll_saturate( vec2 x) { + return clamp( x, 0.0, 1.0); +} +vec3 xll_saturate( vec3 x) { + return clamp( x, 0.0, 1.0); +} +vec4 xll_saturate( vec4 x) { + return clamp( x, 0.0, 1.0); +} +mat2 xll_saturate(mat2 m) { + return mat2( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0)); +} +mat3 xll_saturate(mat3 m) { + return mat3( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0), clamp(m[2], 0.0, 1.0)); +} +mat4 xll_saturate(mat4 m) { + return mat4( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0), clamp(m[2], 0.0, 1.0), clamp(m[3], 0.0, 1.0)); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec3 viewDir; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 viewDir; + vec4 hip_screen; + vec3 normal; + vec3 hip_lmapFade; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform sampler2D _LightBuffer; +uniform sampler2D _MainTex; +uniform vec4 _RimColor; +uniform float _RimPower; +uniform sampler2D unity_Lightmap; +uniform sampler2D unity_LightmapInd; +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingLambert_PrePass( in SurfaceOutput s, in vec4 light ); +vec3 DecodeLightmap( in vec4 color ); +vec4 frag_surf( in v2f_surf IN ); +void surf( in Input IN, inout SurfaceOutput o ) { + float rim; + o.Albedo = texture2D( _MainTex, IN.uv_MainTex).xyz ; + rim = (1.00000 - xll_saturate( dot( normalize( IN.viewDir ), o.Normal) )); + o.Emission = (_RimColor.xyz * pow( rim, _RimPower)); +} +vec4 LightingLambert_PrePass( in SurfaceOutput s, in vec4 light ) { + vec4 c; + c.xyz = (s.Albedo * light.xyz ); + c.w = s.Alpha; + return c; +} +vec3 DecodeLightmap( in vec4 color ) { + return (2.00000 * color.xyz ); +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec4 light; + vec3 lmFull; + vec3 lmIndirect; + vec3 lm; + vec4 col; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + surfIN.viewDir = IN.viewDir; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + o.Normal = IN.normal; + surf( surfIN, o); + light = texture2DProj( _LightBuffer, IN.hip_screen); + light = ( -log2( light ) ); + lmFull = DecodeLightmap( texture2D( unity_Lightmap, IN.hip_lmapFade.xy )); + lmIndirect = DecodeLightmap( texture2D( unity_LightmapInd, IN.hip_lmapFade.xy )); + lm = mix( lmIndirect, lmFull, vec3( xll_saturate( IN.hip_lmapFade.z ))); + light.xyz += lm; + col = LightingLambert_PrePass( o, light); + col.xyz += o.Emission; + return col; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec2( gl_TexCoord[0]); + xlt_IN.viewDir = vec3( gl_TexCoord[1]); + xlt_IN.hip_screen = vec4( gl_TexCoord[2]); + xlt_IN.normal = vec3( gl_TexCoord[3]); + xlt_IN.hip_lmapFade = vec3( gl_TexCoord[4]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Rim2-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Rim2-ir.txt new file mode 100644 index 000000000..fbd15353b --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Rim2-ir.txt @@ -0,0 +1,312 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec3 viewDir; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 viewDir; + vec4 hip_screen; + vec3 normal; + vec3 hip_lmapFade; +}; +varying vec4 xlv_FOG; +uniform sampler2D unity_LightmapInd; +uniform sampler2D unity_Lightmap; +uniform float _RimPower; +uniform vec4 _RimColor; +uniform sampler2D _MainTex; +uniform sampler2D _LightBuffer; +float xll_saturate ( + in float x +) +{ + float tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec2 xll_saturate ( + in vec2 x +) +{ + vec2 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec3 xll_saturate ( + in vec3 x +) +{ + vec3 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec4 xll_saturate ( + in vec4 x +) +{ + vec4 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +mat2 xll_saturate ( + in mat2 m +) +{ + vec2 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec2 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + mat2 tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_1; + tmpvar_3[0] = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5 = tmpvar_2; + tmpvar_3[1] = tmpvar_5; + return tmpvar_3; +} + +mat3 xll_saturate ( + in mat3 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec3 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + vec3 tmpvar_3; + tmpvar_3 = clamp (m[2], 0.0, 1.0); + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +mat4 xll_saturate ( + in mat4 m +) +{ + vec4 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec4 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + vec4 tmpvar_3; + tmpvar_3 = clamp (m[2], 0.0, 1.0); + vec4 tmpvar_4; + tmpvar_4 = clamp (m[3], 0.0, 1.0); + mat4 tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_1; + tmpvar_5[0] = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = tmpvar_2; + tmpvar_5[1] = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_3; + tmpvar_5[2] = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = tmpvar_4; + tmpvar_5[3] = tmpvar_9; + return tmpvar_5; +} + +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + float rim; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec3 tmpvar_2; + tmpvar_2 = tmpvar_1.xyz; + o.Albedo = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = normalize (IN.viewDir); + float tmpvar_4; + tmpvar_4 = dot (tmpvar_3, o.Normal); + float tmpvar_5; + tmpvar_5 = xll_saturate (tmpvar_4); + float tmpvar_6; + tmpvar_6 = (1.0 - tmpvar_5); + rim = tmpvar_6; + float tmpvar_7; + tmpvar_7 = pow (rim, _RimPower); + vec3 tmpvar_8; + tmpvar_8 = (_RimColor.xyz * tmpvar_7); + o.Emission = tmpvar_8; +} + +vec4 LightingLambert_PrePass ( + in SurfaceOutput s, + in vec4 light +) +{ + vec4 c; + vec3 tmpvar_1; + tmpvar_1 = (s.Albedo * light.xyz); + c.xyz = tmpvar_1.xyz.xyz; + float tmpvar_2; + tmpvar_2 = s.Alpha; + c.w = vec4(tmpvar_2).w; + return c; +} + +vec3 DecodeLightmap ( + in vec4 color +) +{ + return (2.0 * color.xyz); +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 col; + vec3 lm; + vec3 lmIndirect; + vec3 lmFull; + vec4 light; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = IN.viewDir; + surfIN.viewDir = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Specular = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Alpha = tmpvar_6; + float tmpvar_7; + tmpvar_7 = 0.0; + o.Gloss = tmpvar_7; + vec3 tmpvar_8; + tmpvar_8 = IN.normal; + o.Normal = tmpvar_8; + surf (surfIN, o); + vec4 tmpvar_9; + tmpvar_9 = texture2DProj (_LightBuffer, IN.hip_screen); + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + light = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = log2 (light); + vec4 tmpvar_12; + tmpvar_12 = -(tmpvar_11); + light = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = texture2D (unity_Lightmap, IN.hip_lmapFade.xy); + vec3 tmpvar_14; + tmpvar_14 = DecodeLightmap (tmpvar_13); + vec3 tmpvar_15; + tmpvar_15 = tmpvar_14; + lmFull = tmpvar_15; + vec4 tmpvar_16; + tmpvar_16 = texture2D (unity_LightmapInd, IN.hip_lmapFade.xy); + vec3 tmpvar_17; + tmpvar_17 = DecodeLightmap (tmpvar_16); + vec3 tmpvar_18; + tmpvar_18 = tmpvar_17; + lmIndirect = tmpvar_18; + float tmpvar_19; + tmpvar_19 = xll_saturate (IN.hip_lmapFade.z); + vec3 tmpvar_20; + tmpvar_20 = vec3(tmpvar_19); + vec3 tmpvar_21; + tmpvar_21 = mix (lmIndirect, lmFull, tmpvar_20); + vec3 tmpvar_22; + tmpvar_22 = tmpvar_21; + lm = tmpvar_22; + vec3 tmpvar_23; + tmpvar_23 = (light.xyz + lm); + light.xyz = tmpvar_23.xyz.xyz; + vec4 tmpvar_24; + tmpvar_24 = LightingLambert_PrePass (o, light); + vec4 tmpvar_25; + tmpvar_25 = tmpvar_24; + col = tmpvar_25; + vec3 tmpvar_26; + tmpvar_26 = (col.xyz + o.Emission); + col.xyz = tmpvar_26.xyz.xyz; + return col; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xy; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.viewDir = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.hip_screen = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = gl_TexCoord[3].xyz; + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_IN.normal = tmpvar_10; + vec3 tmpvar_11; + tmpvar_11 = gl_TexCoord[4].xyz; + vec3 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_IN.hip_lmapFade = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = frag_surf (xlt_IN); + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_FragData[0] = tmpvar_16; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Rim2-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Rim2-out.txt new file mode 100644 index 000000000..83a0f379a --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Rim2-out.txt @@ -0,0 +1,24 @@ +uniform sampler2D unity_LightmapInd; +uniform sampler2D unity_Lightmap; +uniform float _RimPower; +uniform vec4 _RimColor; +uniform sampler2D _MainTex; +uniform sampler2D _LightBuffer; +void main () +{ + vec3 tmpvar_1; + tmpvar_1 = gl_TexCoord[4].xyz; + vec4 col; + vec4 light; + vec4 tmpvar_2; + tmpvar_2 = -(log2 (texture2DProj (_LightBuffer, gl_TexCoord[2]))); + light = tmpvar_2; + light.xyz = (tmpvar_2.xyz + mix ((2.0 * texture2D (unity_LightmapInd, tmpvar_1.xy).xyz), (2.0 * texture2D (unity_Lightmap, tmpvar_1.xy).xyz), vec3(clamp (tmpvar_1.z, 0.0, 1.0)))); + vec4 c; + c.xyz = (texture2D (_MainTex, gl_TexCoord[0].xy).xyz * light.xyz); + c.w = 0.0; + col = c; + col.xyz = (c.xyz + (_RimColor.xyz * pow ((1.0 - clamp (dot (normalize (gl_TexCoord[1].xyz), gl_TexCoord[3].xyz), 0.0, 1.0)), _RimPower))); + gl_FragData[0] = col; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Rim_Bump-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Rim_Bump-in.txt new file mode 100644 index 000000000..423cff294 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Rim_Bump-in.txt @@ -0,0 +1,131 @@ +float xll_saturate( float x) { + return clamp( x, 0.0, 1.0); +} +vec2 xll_saturate( vec2 x) { + return clamp( x, 0.0, 1.0); +} +vec3 xll_saturate( vec3 x) { + return clamp( x, 0.0, 1.0); +} +vec4 xll_saturate( vec4 x) { + return clamp( x, 0.0, 1.0); +} +mat2 xll_saturate(mat2 m) { + return mat2( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0)); +} +mat3 xll_saturate(mat3 m) { + return mat3( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0), clamp(m[2], 0.0, 1.0)); +} +mat4 xll_saturate(mat4 m) { + return mat4( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0), clamp(m[2], 0.0, 1.0), clamp(m[3], 0.0, 1.0)); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_BumpMap; + vec3 viewDir; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 lightDir; + vec4 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform sampler2D _BumpMap; +uniform vec4 _LightColor0; +uniform sampler2D _LightTexture0; +uniform sampler2D _LightTextureB0; +uniform sampler2D _MainTex; +uniform vec4 _RimColor; +uniform float _RimPower; +vec4 UnpackNormal( in vec4 packednormal ); +void surf( in Input IN, inout SurfaceOutput o ); +float UnitySpotCookie( in vec4 LightCoord ); +float UnitySpotAttenuate( in vec3 LightCoord ); +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ); +vec4 frag_surf( in v2f_surf IN ); +vec4 UnpackNormal( in vec4 packednormal ) { + vec4 normal; + normal.xy = ((packednormal.wy * 2.00000) - 1.00000); + normal.z = sqrt( ((1.00000 - (normal.x * normal.x )) - (normal.y * normal.y )) ); + return normal; +} +void surf( in Input IN, inout SurfaceOutput o ) { + float rim; + o.Albedo = texture2D( _MainTex, IN.uv_BumpMap).xyz ; + o.Normal = vec3( UnpackNormal( texture2D( _BumpMap, IN.uv_BumpMap))); + rim = (1.00000 - xll_saturate( dot( normalize( IN.viewDir ), o.Normal) )); + o.Emission = (_RimColor.xyz * pow( rim, _RimPower)); +} +float UnitySpotCookie( in vec4 LightCoord ) { + return texture2D( _LightTexture0, ((LightCoord.xy / LightCoord.w ) + 0.500000)).w ; +} +float UnitySpotAttenuate( in vec3 LightCoord ) { + return texture2D( _LightTextureB0, vec2( vec2( dot( LightCoord, LightCoord)))).w ; +} +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ) { + float diff; + vec4 c; + diff = max( 0.000000, dot( s.Normal, lightDir)); + c.xyz = ((s.Albedo * _LightColor0.xyz ) * ((diff * atten) * 2.00000)); + c.w = s.Alpha; + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec3 lightDir; + vec4 c; + surfIN.uv_BumpMap = IN.hip_pack0.xy ; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + surf( surfIN, o); + lightDir = IN.lightDir; + lightDir = normalize( lightDir ); + c = LightingLambert( o, lightDir, ((float( (IN._LightCoord.z > 0.000000) ) * UnitySpotCookie( IN._LightCoord)) * UnitySpotAttenuate( IN._LightCoord.xyz ))); + c.w = 0.000000; + return c; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec2( gl_TexCoord[0]); + xlt_IN.lightDir = vec3( gl_TexCoord[1]); + xlt_IN._LightCoord = vec4( gl_TexCoord[2]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Rim_Bump-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Rim_Bump-ir.txt new file mode 100644 index 000000000..545710391 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Rim_Bump-ir.txt @@ -0,0 +1,319 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_BumpMap; + vec3 viewDir; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 lightDir; + vec4 _LightCoord; +}; +varying vec4 xlv_FOG; +uniform float _RimPower; +uniform vec4 _RimColor; +uniform sampler2D _MainTex; +uniform sampler2D _LightTextureB0; +uniform sampler2D _LightTexture0; +uniform vec4 _LightColor0; +uniform sampler2D _BumpMap; +float xll_saturate ( + in float x +) +{ + float tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec2 xll_saturate ( + in vec2 x +) +{ + vec2 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec3 xll_saturate ( + in vec3 x +) +{ + vec3 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec4 xll_saturate ( + in vec4 x +) +{ + vec4 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +mat2 xll_saturate ( + in mat2 m +) +{ + vec2 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec2 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + mat2 tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_1; + tmpvar_3[0] = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5 = tmpvar_2; + tmpvar_3[1] = tmpvar_5; + return tmpvar_3; +} + +mat3 xll_saturate ( + in mat3 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec3 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + vec3 tmpvar_3; + tmpvar_3 = clamp (m[2], 0.0, 1.0); + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +mat4 xll_saturate ( + in mat4 m +) +{ + vec4 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec4 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + vec4 tmpvar_3; + tmpvar_3 = clamp (m[2], 0.0, 1.0); + vec4 tmpvar_4; + tmpvar_4 = clamp (m[3], 0.0, 1.0); + mat4 tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_1; + tmpvar_5[0] = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = tmpvar_2; + tmpvar_5[1] = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_3; + tmpvar_5[2] = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = tmpvar_4; + tmpvar_5[3] = tmpvar_9; + return tmpvar_5; +} + +vec4 UnpackNormal ( + in vec4 packednormal +) +{ + vec4 normal; + vec2 tmpvar_1; + tmpvar_1 = ((packednormal.wy * 2.0) - 1.0); + normal.xy = tmpvar_1.xy.xy; + float tmpvar_2; + tmpvar_2 = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + normal.z = vec3(tmpvar_3).z; + return normal; +} + +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + float rim; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_BumpMap); + vec3 tmpvar_2; + tmpvar_2 = tmpvar_1.xyz; + o.Albedo = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = texture2D (_BumpMap, IN.uv_BumpMap); + vec4 tmpvar_4; + tmpvar_4 = UnpackNormal (tmpvar_3); + vec3 tmpvar_5; + tmpvar_5 = tmpvar_4.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + o.Normal = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = normalize (IN.viewDir); + float tmpvar_8; + tmpvar_8 = dot (tmpvar_7, o.Normal); + float tmpvar_9; + tmpvar_9 = xll_saturate (tmpvar_8); + float tmpvar_10; + tmpvar_10 = (1.0 - tmpvar_9); + rim = tmpvar_10; + float tmpvar_11; + tmpvar_11 = pow (rim, _RimPower); + vec3 tmpvar_12; + tmpvar_12 = (_RimColor.xyz * tmpvar_11); + o.Emission = tmpvar_12; +} + +float UnitySpotCookie ( + in vec4 LightCoord +) +{ + vec4 tmpvar_1; + tmpvar_1 = texture2D (_LightTexture0, ((LightCoord.xy / LightCoord.w) + 0.5)); + return tmpvar_1.w; +} + +float UnitySpotAttenuate ( + in vec3 LightCoord +) +{ + float tmpvar_1; + tmpvar_1 = dot (LightCoord, LightCoord); + vec2 tmpvar_2; + tmpvar_2 = vec2(tmpvar_1); + vec2 tmpvar_3; + tmpvar_3 = tmpvar_2.xy; + vec4 tmpvar_4; + tmpvar_4 = texture2D (_LightTextureB0, tmpvar_3); + return tmpvar_4.w; +} + +vec4 LightingLambert ( + in SurfaceOutput s, + in vec3 lightDir, + in float atten +) +{ + vec4 c; + float diff; + float tmpvar_1; + tmpvar_1 = dot (s.Normal, lightDir); + float tmpvar_2; + tmpvar_2 = max (0.0, tmpvar_1); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + diff = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = ((s.Albedo * _LightColor0.xyz) * ((diff * atten) * 2.0)); + c.xyz = tmpvar_4.xyz.xyz; + float tmpvar_5; + tmpvar_5 = s.Alpha; + c.w = vec4(tmpvar_5).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 c; + vec3 lightDir; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_BumpMap = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_3; + float tmpvar_4; + tmpvar_4 = 0.0; + o.Specular = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Alpha = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Gloss = tmpvar_6; + surf (surfIN, o); + vec3 tmpvar_7; + tmpvar_7 = IN.lightDir; + lightDir = tmpvar_7; + vec3 tmpvar_8; + tmpvar_8 = normalize (lightDir); + vec3 tmpvar_9; + tmpvar_9 = tmpvar_8; + lightDir = tmpvar_9; + float tmpvar_10; + tmpvar_10 = UnitySpotCookie (IN._LightCoord); + float tmpvar_11; + tmpvar_11 = UnitySpotAttenuate (IN._LightCoord.xyz); + vec4 tmpvar_12; + tmpvar_12 = LightingLambert (o, lightDir, ((float((IN._LightCoord.z > 0.0)) * tmpvar_10) * tmpvar_11)); + vec4 tmpvar_13; + tmpvar_13 = tmpvar_12; + c = tmpvar_13; + float tmpvar_14; + tmpvar_14 = 0.0; + c.w = vec4(tmpvar_14).w; + return c; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xy; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.lightDir = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN._LightCoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = frag_surf (xlt_IN); + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xl_retval = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = xl_retval.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + gl_FragData[0] = tmpvar_12; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Rim_Bump-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Rim_Bump-out.txt new file mode 100644 index 000000000..81a462a08 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Rim_Bump-out.txt @@ -0,0 +1,25 @@ +uniform sampler2D _MainTex; +uniform sampler2D _LightTextureB0; +uniform sampler2D _LightTexture0; +uniform vec4 _LightColor0; +uniform sampler2D _BumpMap; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = gl_TexCoord[2]; + vec4 c; + vec2 tmpvar_2; + tmpvar_2 = gl_TexCoord[0].xy; + vec4 normal; + normal.xy = ((texture2D (_BumpMap, tmpvar_2).wy * 2.0) - 1.0); + normal.z = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + vec3 LightCoord_i0; + LightCoord_i0 = tmpvar_1.xyz; + vec4 c_i0; + c_i0.xyz = ((texture2D (_MainTex, tmpvar_2).xyz * _LightColor0.xyz) * ((max (0.0, dot (normal.xyz, normalize (gl_TexCoord[1].xyz))) * ((float((tmpvar_1.z > 0.0)) * texture2D (_LightTexture0, ((tmpvar_1.xy / tmpvar_1.w) + 0.5)).w) * texture2D (_LightTextureB0, vec2(dot (LightCoord_i0, LightCoord_i0))).w)) * 2.0)); + c_i0.w = 0.0; + c = c_i0; + c.w = 0.0; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Rim_Bump1-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Rim_Bump1-in.txt new file mode 100644 index 000000000..36c99facd --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Rim_Bump1-in.txt @@ -0,0 +1,123 @@ +float xll_saturate( float x) { + return clamp( x, 0.0, 1.0); +} +vec2 xll_saturate( vec2 x) { + return clamp( x, 0.0, 1.0); +} +vec3 xll_saturate( vec3 x) { + return clamp( x, 0.0, 1.0); +} +vec4 xll_saturate( vec4 x) { + return clamp( x, 0.0, 1.0); +} +mat2 xll_saturate(mat2 m) { + return mat2( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0)); +} +mat3 xll_saturate(mat3 m) { + return mat3( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0), clamp(m[2], 0.0, 1.0)); +} +mat4 xll_saturate(mat4 m) { + return mat4( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0), clamp(m[2], 0.0, 1.0), clamp(m[3], 0.0, 1.0)); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_BumpMap; + vec3 viewDir; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 lightDir; + vec3 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform sampler2D _BumpMap; +uniform vec4 _LightColor0; +uniform samplerCube _LightTexture0; +uniform sampler2D _LightTextureB0; +uniform sampler2D _MainTex; +uniform vec4 _RimColor; +uniform float _RimPower; +vec4 UnpackNormal( in vec4 packednormal ); +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ); +vec4 frag_surf( in v2f_surf IN ); +vec4 UnpackNormal( in vec4 packednormal ) { + vec4 normal; + normal.xy = ((packednormal.wy * 2.00000) - 1.00000); + normal.z = sqrt( ((1.00000 - (normal.x * normal.x )) - (normal.y * normal.y )) ); + return normal; +} +void surf( in Input IN, inout SurfaceOutput o ) { + float rim; + o.Albedo = texture2D( _MainTex, IN.uv_BumpMap).xyz ; + o.Normal = vec3( UnpackNormal( texture2D( _BumpMap, IN.uv_BumpMap))); + rim = (1.00000 - xll_saturate( dot( normalize( IN.viewDir ), o.Normal) )); + o.Emission = (_RimColor.xyz * pow( rim, _RimPower)); +} +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ) { + float diff; + vec4 c; + diff = max( 0.000000, dot( s.Normal, lightDir)); + c.xyz = ((s.Albedo * _LightColor0.xyz ) * ((diff * atten) * 2.00000)); + c.w = s.Alpha; + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec3 lightDir; + vec4 c; + surfIN.uv_BumpMap = IN.hip_pack0.xy ; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + surf( surfIN, o); + lightDir = IN.lightDir; + lightDir = normalize( lightDir ); + c = LightingLambert( o, lightDir, (texture2D( _LightTextureB0, vec2( vec2( dot( IN._LightCoord, IN._LightCoord)))).w * textureCube( _LightTexture0, IN._LightCoord).w )); + c.w = 0.000000; + return c; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec2( gl_TexCoord[0]); + xlt_IN.lightDir = vec3( gl_TexCoord[1]); + xlt_IN._LightCoord = vec3( gl_TexCoord[2]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Rim_Bump1-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Rim_Bump1-ir.txt new file mode 100644 index 000000000..a796c4f0f --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Rim_Bump1-ir.txt @@ -0,0 +1,301 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_BumpMap; + vec3 viewDir; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 lightDir; + vec3 _LightCoord; +}; +varying vec4 xlv_FOG; +uniform float _RimPower; +uniform vec4 _RimColor; +uniform sampler2D _MainTex; +uniform sampler2D _LightTextureB0; +uniform samplerCube _LightTexture0; +uniform vec4 _LightColor0; +uniform sampler2D _BumpMap; +float xll_saturate ( + in float x +) +{ + float tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec2 xll_saturate ( + in vec2 x +) +{ + vec2 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec3 xll_saturate ( + in vec3 x +) +{ + vec3 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec4 xll_saturate ( + in vec4 x +) +{ + vec4 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +mat2 xll_saturate ( + in mat2 m +) +{ + vec2 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec2 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + mat2 tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_1; + tmpvar_3[0] = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5 = tmpvar_2; + tmpvar_3[1] = tmpvar_5; + return tmpvar_3; +} + +mat3 xll_saturate ( + in mat3 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec3 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + vec3 tmpvar_3; + tmpvar_3 = clamp (m[2], 0.0, 1.0); + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +mat4 xll_saturate ( + in mat4 m +) +{ + vec4 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec4 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + vec4 tmpvar_3; + tmpvar_3 = clamp (m[2], 0.0, 1.0); + vec4 tmpvar_4; + tmpvar_4 = clamp (m[3], 0.0, 1.0); + mat4 tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_1; + tmpvar_5[0] = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = tmpvar_2; + tmpvar_5[1] = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_3; + tmpvar_5[2] = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = tmpvar_4; + tmpvar_5[3] = tmpvar_9; + return tmpvar_5; +} + +vec4 UnpackNormal ( + in vec4 packednormal +) +{ + vec4 normal; + vec2 tmpvar_1; + tmpvar_1 = ((packednormal.wy * 2.0) - 1.0); + normal.xy = tmpvar_1.xy.xy; + float tmpvar_2; + tmpvar_2 = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + normal.z = vec3(tmpvar_3).z; + return normal; +} + +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + float rim; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_BumpMap); + vec3 tmpvar_2; + tmpvar_2 = tmpvar_1.xyz; + o.Albedo = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = texture2D (_BumpMap, IN.uv_BumpMap); + vec4 tmpvar_4; + tmpvar_4 = UnpackNormal (tmpvar_3); + vec3 tmpvar_5; + tmpvar_5 = tmpvar_4.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + o.Normal = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = normalize (IN.viewDir); + float tmpvar_8; + tmpvar_8 = dot (tmpvar_7, o.Normal); + float tmpvar_9; + tmpvar_9 = xll_saturate (tmpvar_8); + float tmpvar_10; + tmpvar_10 = (1.0 - tmpvar_9); + rim = tmpvar_10; + float tmpvar_11; + tmpvar_11 = pow (rim, _RimPower); + vec3 tmpvar_12; + tmpvar_12 = (_RimColor.xyz * tmpvar_11); + o.Emission = tmpvar_12; +} + +vec4 LightingLambert ( + in SurfaceOutput s, + in vec3 lightDir, + in float atten +) +{ + vec4 c; + float diff; + float tmpvar_1; + tmpvar_1 = dot (s.Normal, lightDir); + float tmpvar_2; + tmpvar_2 = max (0.0, tmpvar_1); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + diff = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = ((s.Albedo * _LightColor0.xyz) * ((diff * atten) * 2.0)); + c.xyz = tmpvar_4.xyz.xyz; + float tmpvar_5; + tmpvar_5 = s.Alpha; + c.w = vec4(tmpvar_5).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 c; + vec3 lightDir; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_BumpMap = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_3; + float tmpvar_4; + tmpvar_4 = 0.0; + o.Specular = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Alpha = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Gloss = tmpvar_6; + surf (surfIN, o); + vec3 tmpvar_7; + tmpvar_7 = IN.lightDir; + lightDir = tmpvar_7; + vec3 tmpvar_8; + tmpvar_8 = normalize (lightDir); + vec3 tmpvar_9; + tmpvar_9 = tmpvar_8; + lightDir = tmpvar_9; + float tmpvar_10; + tmpvar_10 = dot (IN._LightCoord, IN._LightCoord); + vec2 tmpvar_11; + tmpvar_11 = vec2(tmpvar_10); + vec2 tmpvar_12; + tmpvar_12 = tmpvar_11.xy; + vec4 tmpvar_13; + tmpvar_13 = texture2D (_LightTextureB0, tmpvar_12); + vec4 tmpvar_14; + tmpvar_14 = textureCube (_LightTexture0, IN._LightCoord); + vec4 tmpvar_15; + tmpvar_15 = LightingLambert (o, lightDir, (tmpvar_13.w * tmpvar_14.w)); + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + c = tmpvar_16; + float tmpvar_17; + tmpvar_17 = 0.0; + c.w = vec4(tmpvar_17).w; + return c; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xy; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.lightDir = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN._LightCoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = frag_surf (xlt_IN); + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xl_retval = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = xl_retval.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + gl_FragData[0] = tmpvar_12; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Rim_Bump1-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Rim_Bump1-out.txt new file mode 100644 index 000000000..0d75f2e53 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Rim_Bump1-out.txt @@ -0,0 +1,23 @@ +uniform sampler2D _MainTex; +uniform sampler2D _LightTextureB0; +uniform samplerCube _LightTexture0; +uniform vec4 _LightColor0; +uniform sampler2D _BumpMap; +void main () +{ + vec3 tmpvar_1; + tmpvar_1 = gl_TexCoord[2].xyz; + vec4 c; + vec2 tmpvar_2; + tmpvar_2 = gl_TexCoord[0].xy; + vec4 normal; + normal.xy = ((texture2D (_BumpMap, tmpvar_2).wy * 2.0) - 1.0); + normal.z = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + vec4 c_i0; + c_i0.xyz = ((texture2D (_MainTex, tmpvar_2).xyz * _LightColor0.xyz) * ((max (0.0, dot (normal.xyz, normalize (gl_TexCoord[1].xyz))) * (texture2D (_LightTextureB0, vec2(dot (tmpvar_1, tmpvar_1))).w * textureCube (_LightTexture0, tmpvar_1).w)) * 2.0)); + c_i0.w = 0.0; + c = c_i0; + c.w = 0.0; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_ScreenPos-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_ScreenPos-in.txt new file mode 100644 index 000000000..71fa3b901 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_ScreenPos-in.txt @@ -0,0 +1,99 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec4 screenPos; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec3 normal; + vec3 lightDir; + vec4 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _LightColor0; +uniform sampler2D _LightTexture0; +uniform sampler2D _LightTextureB0; +uniform sampler2D _MainTex; +void surf( in Input IN, inout SurfaceOutput o ); +float UnitySpotCookie( in vec4 LightCoord ); +float UnitySpotAttenuate( in vec3 LightCoord ); +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ); +vec4 frag_surf( in v2f_surf IN ); +void surf( in Input IN, inout SurfaceOutput o ) { + vec2 uv; + uv = (IN.screenPos.xy / IN.screenPos.w ); + uv *= vec2( 2.00000, 1.00000); + o.Albedo = vec3( 0.500000); + o.Emission = (texture2D( _MainTex, uv).xyz * 0.500000); +} +float UnitySpotCookie( in vec4 LightCoord ) { + return texture2D( _LightTexture0, ((LightCoord.xy / LightCoord.w ) + 0.500000)).w ; +} +float UnitySpotAttenuate( in vec3 LightCoord ) { + return texture2D( _LightTextureB0, vec2( vec2( dot( LightCoord, LightCoord)))).w ; +} +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ) { + float diff; + vec4 c; + diff = max( 0.000000, dot( s.Normal, lightDir)); + c.xyz = ((s.Albedo * _LightColor0.xyz ) * ((diff * atten) * 2.00000)); + c.w = s.Alpha; + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + SurfaceOutput o; + Input surfIN; + vec3 lightDir; + vec4 c; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + o.Normal = IN.normal; + surf( surfIN, o); + lightDir = IN.lightDir; + lightDir = normalize( lightDir ); + c = LightingLambert( o, lightDir, ((float( (IN._LightCoord.z > 0.000000) ) * UnitySpotCookie( IN._LightCoord)) * UnitySpotAttenuate( IN._LightCoord.xyz ))); + c.w = 0.000000; + return c; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.normal = vec3( gl_TexCoord[0]); + xlt_IN.lightDir = vec3( gl_TexCoord[1]); + xlt_IN._LightCoord = vec4( gl_TexCoord[2]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_ScreenPos-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_ScreenPos-ir.txt new file mode 100644 index 000000000..3f1b999ff --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_ScreenPos-ir.txt @@ -0,0 +1,180 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec4 screenPos; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec3 normal; + vec3 lightDir; + vec4 _LightCoord; +}; +varying vec4 xlv_FOG; +uniform sampler2D _MainTex; +uniform sampler2D _LightTextureB0; +uniform sampler2D _LightTexture0; +uniform vec4 _LightColor0; +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec2 uv; + vec2 tmpvar_1; + tmpvar_1 = (IN.screenPos.xy / IN.screenPos.w); + uv = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = (uv * vec2(2.0, 1.0)); + uv = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.5, 0.5, 0.5); + o.Albedo = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = texture2D (_MainTex, uv); + vec3 tmpvar_5; + tmpvar_5 = (tmpvar_4.xyz * 0.5); + o.Emission = tmpvar_5; +} + +float UnitySpotCookie ( + in vec4 LightCoord +) +{ + vec4 tmpvar_1; + tmpvar_1 = texture2D (_LightTexture0, ((LightCoord.xy / LightCoord.w) + 0.5)); + return tmpvar_1.w; +} + +float UnitySpotAttenuate ( + in vec3 LightCoord +) +{ + float tmpvar_1; + tmpvar_1 = dot (LightCoord, LightCoord); + vec2 tmpvar_2; + tmpvar_2 = vec2(tmpvar_1); + vec2 tmpvar_3; + tmpvar_3 = tmpvar_2.xy; + vec4 tmpvar_4; + tmpvar_4 = texture2D (_LightTextureB0, tmpvar_3); + return tmpvar_4.w; +} + +vec4 LightingLambert ( + in SurfaceOutput s, + in vec3 lightDir, + in float atten +) +{ + vec4 c; + float diff; + float tmpvar_1; + tmpvar_1 = dot (s.Normal, lightDir); + float tmpvar_2; + tmpvar_2 = max (0.0, tmpvar_1); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + diff = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = ((s.Albedo * _LightColor0.xyz) * ((diff * atten) * 2.0)); + c.xyz = tmpvar_4.xyz.xyz; + float tmpvar_5; + tmpvar_5 = s.Alpha; + c.w = vec4(tmpvar_5).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 c; + vec3 lightDir; + Input surfIN; + SurfaceOutput o; + vec3 tmpvar_1; + tmpvar_1 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_2; + float tmpvar_3; + tmpvar_3 = 0.0; + o.Specular = tmpvar_3; + float tmpvar_4; + tmpvar_4 = 0.0; + o.Alpha = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Gloss = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = IN.normal; + o.Normal = tmpvar_6; + surf (surfIN, o); + vec3 tmpvar_7; + tmpvar_7 = IN.lightDir; + lightDir = tmpvar_7; + vec3 tmpvar_8; + tmpvar_8 = normalize (lightDir); + vec3 tmpvar_9; + tmpvar_9 = tmpvar_8; + lightDir = tmpvar_9; + float tmpvar_10; + tmpvar_10 = UnitySpotCookie (IN._LightCoord); + float tmpvar_11; + tmpvar_11 = UnitySpotAttenuate (IN._LightCoord.xyz); + vec4 tmpvar_12; + tmpvar_12 = LightingLambert (o, lightDir, ((float((IN._LightCoord.z > 0.0)) * tmpvar_10) * tmpvar_11)); + vec4 tmpvar_13; + tmpvar_13 = tmpvar_12; + c = tmpvar_13; + float tmpvar_14; + tmpvar_14 = 0.0; + c.w = vec4(tmpvar_14).w; + return c; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xyz; + vec3 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.normal = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.lightDir = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN._LightCoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = frag_surf (xlt_IN); + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xl_retval = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = xl_retval.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + gl_FragData[0] = tmpvar_12; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_ScreenPos-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_ScreenPos-out.txt new file mode 100644 index 000000000..a27066ef4 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_ScreenPos-out.txt @@ -0,0 +1,18 @@ +uniform sampler2D _LightTextureB0; +uniform sampler2D _LightTexture0; +uniform vec4 _LightColor0; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = gl_TexCoord[2]; + vec4 c; + vec3 LightCoord_i0; + LightCoord_i0 = tmpvar_1.xyz; + vec4 c_i0; + c_i0.xyz = ((vec3(0.5, 0.5, 0.5) * _LightColor0.xyz) * ((max (0.0, dot (gl_TexCoord[0].xyz, normalize (gl_TexCoord[1].xyz))) * ((float((tmpvar_1.z > 0.0)) * texture2D (_LightTexture0, ((tmpvar_1.xy / tmpvar_1.w) + 0.5)).w) * texture2D (_LightTextureB0, vec2(dot (LightCoord_i0, LightCoord_i0))).w)) * 2.0)); + c_i0.w = 0.0; + c = c_i0; + c.w = 0.0; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_ScreenPos1-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_ScreenPos1-in.txt new file mode 100644 index 000000000..9272fb1f6 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_ScreenPos1-in.txt @@ -0,0 +1,91 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec4 screenPos; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec3 normal; + vec3 lightDir; + vec3 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _LightColor0; +uniform samplerCube _LightTexture0; +uniform sampler2D _LightTextureB0; +uniform sampler2D _MainTex; +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ); +vec4 frag_surf( in v2f_surf IN ); +void surf( in Input IN, inout SurfaceOutput o ) { + vec2 uv; + uv = (IN.screenPos.xy / IN.screenPos.w ); + uv *= vec2( 2.00000, 1.00000); + o.Albedo = vec3( 0.500000); + o.Emission = (texture2D( _MainTex, uv).xyz * 0.500000); +} +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ) { + float diff; + vec4 c; + diff = max( 0.000000, dot( s.Normal, lightDir)); + c.xyz = ((s.Albedo * _LightColor0.xyz ) * ((diff * atten) * 2.00000)); + c.w = s.Alpha; + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + SurfaceOutput o; + Input surfIN; + vec3 lightDir; + vec4 c; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + o.Normal = IN.normal; + surf( surfIN, o); + lightDir = IN.lightDir; + lightDir = normalize( lightDir ); + c = LightingLambert( o, lightDir, (texture2D( _LightTextureB0, vec2( vec2( dot( IN._LightCoord, IN._LightCoord)))).w * textureCube( _LightTexture0, IN._LightCoord).w )); + c.w = 0.000000; + return c; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.normal = vec3( gl_TexCoord[0]); + xlt_IN.lightDir = vec3( gl_TexCoord[1]); + xlt_IN._LightCoord = vec3( gl_TexCoord[2]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_ScreenPos1-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_ScreenPos1-ir.txt new file mode 100644 index 000000000..d38426d81 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_ScreenPos1-ir.txt @@ -0,0 +1,162 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec4 screenPos; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec3 normal; + vec3 lightDir; + vec3 _LightCoord; +}; +varying vec4 xlv_FOG; +uniform sampler2D _MainTex; +uniform sampler2D _LightTextureB0; +uniform samplerCube _LightTexture0; +uniform vec4 _LightColor0; +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec2 uv; + vec2 tmpvar_1; + tmpvar_1 = (IN.screenPos.xy / IN.screenPos.w); + uv = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = (uv * vec2(2.0, 1.0)); + uv = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.5, 0.5, 0.5); + o.Albedo = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = texture2D (_MainTex, uv); + vec3 tmpvar_5; + tmpvar_5 = (tmpvar_4.xyz * 0.5); + o.Emission = tmpvar_5; +} + +vec4 LightingLambert ( + in SurfaceOutput s, + in vec3 lightDir, + in float atten +) +{ + vec4 c; + float diff; + float tmpvar_1; + tmpvar_1 = dot (s.Normal, lightDir); + float tmpvar_2; + tmpvar_2 = max (0.0, tmpvar_1); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + diff = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = ((s.Albedo * _LightColor0.xyz) * ((diff * atten) * 2.0)); + c.xyz = tmpvar_4.xyz.xyz; + float tmpvar_5; + tmpvar_5 = s.Alpha; + c.w = vec4(tmpvar_5).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 c; + vec3 lightDir; + Input surfIN; + SurfaceOutput o; + vec3 tmpvar_1; + tmpvar_1 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_2; + float tmpvar_3; + tmpvar_3 = 0.0; + o.Specular = tmpvar_3; + float tmpvar_4; + tmpvar_4 = 0.0; + o.Alpha = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Gloss = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = IN.normal; + o.Normal = tmpvar_6; + surf (surfIN, o); + vec3 tmpvar_7; + tmpvar_7 = IN.lightDir; + lightDir = tmpvar_7; + vec3 tmpvar_8; + tmpvar_8 = normalize (lightDir); + vec3 tmpvar_9; + tmpvar_9 = tmpvar_8; + lightDir = tmpvar_9; + float tmpvar_10; + tmpvar_10 = dot (IN._LightCoord, IN._LightCoord); + vec2 tmpvar_11; + tmpvar_11 = vec2(tmpvar_10); + vec2 tmpvar_12; + tmpvar_12 = tmpvar_11.xy; + vec4 tmpvar_13; + tmpvar_13 = texture2D (_LightTextureB0, tmpvar_12); + vec4 tmpvar_14; + tmpvar_14 = textureCube (_LightTexture0, IN._LightCoord); + vec4 tmpvar_15; + tmpvar_15 = LightingLambert (o, lightDir, (tmpvar_13.w * tmpvar_14.w)); + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + c = tmpvar_16; + float tmpvar_17; + tmpvar_17 = 0.0; + c.w = vec4(tmpvar_17).w; + return c; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xyz; + vec3 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.normal = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.lightDir = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN._LightCoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = frag_surf (xlt_IN); + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xl_retval = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = xl_retval.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + gl_FragData[0] = tmpvar_12; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_ScreenPos1-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_ScreenPos1-out.txt new file mode 100644 index 000000000..11be005fe --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_ScreenPos1-out.txt @@ -0,0 +1,16 @@ +uniform sampler2D _LightTextureB0; +uniform samplerCube _LightTexture0; +uniform vec4 _LightColor0; +void main () +{ + vec3 tmpvar_1; + tmpvar_1 = gl_TexCoord[2].xyz; + vec4 c; + vec4 c_i0; + c_i0.xyz = ((vec3(0.5, 0.5, 0.5) * _LightColor0.xyz) * ((max (0.0, dot (gl_TexCoord[0].xyz, normalize (gl_TexCoord[1].xyz))) * (texture2D (_LightTextureB0, vec2(dot (tmpvar_1, tmpvar_1))).w * textureCube (_LightTexture0, tmpvar_1).w)) * 2.0)); + c_i0.w = 0.0; + c = c_i0; + c.w = 0.0; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_ScreenPos2-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_ScreenPos2-in.txt new file mode 100644 index 000000000..61b0c0323 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_ScreenPos2-in.txt @@ -0,0 +1,69 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec4 screenPos; +}; +struct v2f_surf { + vec4 pos; + vec3 normal; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform sampler2D _MainTex; +void surf( in Input IN, inout SurfaceOutput o ); +vec4 frag_surf( in v2f_surf IN ); +void surf( in Input IN, inout SurfaceOutput o ) { + vec2 uv; + uv = (IN.screenPos.xy / IN.screenPos.w ); + uv *= vec2( 2.00000, 1.00000); + o.Albedo = vec3( 0.500000); + o.Emission = (texture2D( _MainTex, uv).xyz * 0.500000); +} +vec4 frag_surf( in v2f_surf IN ) { + SurfaceOutput o; + Input surfIN; + vec4 res; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + o.Normal = IN.normal; + surf( surfIN, o); + res.xyz = ((o.Normal * vec3( 0.500000, 0.500000, -0.500000)) + 0.500000); + res.w = o.Specular; + return res; +} +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.normal = vec3( gl_TexCoord[0]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_ScreenPos2-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_ScreenPos2-ir.txt new file mode 100644 index 000000000..6b252fb3b --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_ScreenPos2-ir.txt @@ -0,0 +1,97 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec4 screenPos; +}; +struct v2f_surf { + vec4 pos; + vec3 normal; +}; +uniform sampler2D _MainTex; +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec2 uv; + vec2 tmpvar_1; + tmpvar_1 = (IN.screenPos.xy / IN.screenPos.w); + uv = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = (uv * vec2(2.0, 1.0)); + uv = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.5, 0.5, 0.5); + o.Albedo = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = texture2D (_MainTex, uv); + vec3 tmpvar_5; + tmpvar_5 = (tmpvar_4.xyz * 0.5); + o.Emission = tmpvar_5; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 res; + Input surfIN; + SurfaceOutput o; + vec3 tmpvar_1; + tmpvar_1 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_2; + float tmpvar_3; + tmpvar_3 = 0.0; + o.Specular = tmpvar_3; + float tmpvar_4; + tmpvar_4 = 0.0; + o.Alpha = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Gloss = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = IN.normal; + o.Normal = tmpvar_6; + surf (surfIN, o); + vec3 tmpvar_7; + tmpvar_7 = ((o.Normal * vec3(0.5, 0.5, -0.5)) + 0.5); + res.xyz = tmpvar_7.xyz.xyz; + float tmpvar_8; + tmpvar_8 = o.Specular; + res.w = vec4(tmpvar_8).w; + return res; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = gl_TexCoord[0].xyz; + vec3 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_IN.normal = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = frag_surf (xlt_IN); + vec4 tmpvar_5; + tmpvar_5 = tmpvar_4; + xl_retval = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = xl_retval.xyzw; + vec4 tmpvar_7; + tmpvar_7 = tmpvar_6; + gl_FragData[0] = tmpvar_7; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_ScreenPos2-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_ScreenPos2-out.txt new file mode 100644 index 000000000..2a4e65f10 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_ScreenPos2-out.txt @@ -0,0 +1,8 @@ +void main () +{ + vec4 res; + res.xyz = ((gl_TexCoord[0].xyz * vec3(0.5, 0.5, -0.5)) + 0.5); + res.w = 0.0; + gl_FragData[0] = res; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_ScreenPosAlbedo-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_ScreenPosAlbedo-in.txt new file mode 100644 index 000000000..bdf5e0896 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_ScreenPosAlbedo-in.txt @@ -0,0 +1,68 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec4 screenPos; +}; +struct v2f_surf { + vec4 pos; + vec3 normal; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform sampler2D _MainTex; +void surf( in Input IN, inout SurfaceOutput o ); +vec4 frag_surf( in v2f_surf IN ); +void surf( in Input IN, inout SurfaceOutput o ) { + vec2 uv; + uv = (IN.screenPos.xy / IN.screenPos.w ); + uv *= vec2( 2.00000, 1.00000); + o.Albedo = texture2D( _MainTex, uv).xyz ; +} +vec4 frag_surf( in v2f_surf IN ) { + SurfaceOutput o; + Input surfIN; + vec4 res; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + o.Normal = IN.normal; + surf( surfIN, o); + res.xyz = ((o.Normal * vec3( 0.500000, 0.500000, -0.500000)) + 0.500000); + res.w = o.Specular; + return res; +} +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.normal = vec3( gl_TexCoord[0]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_ScreenPosAlbedo-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_ScreenPosAlbedo-ir.txt new file mode 100644 index 000000000..47247f28c --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_ScreenPosAlbedo-ir.txt @@ -0,0 +1,94 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec4 screenPos; +}; +struct v2f_surf { + vec4 pos; + vec3 normal; +}; +uniform sampler2D _MainTex; +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec2 uv; + vec2 tmpvar_1; + tmpvar_1 = (IN.screenPos.xy / IN.screenPos.w); + uv = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = (uv * vec2(2.0, 1.0)); + uv = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = texture2D (_MainTex, uv); + vec3 tmpvar_4; + tmpvar_4 = tmpvar_3.xyz; + o.Albedo = tmpvar_4; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 res; + Input surfIN; + SurfaceOutput o; + vec3 tmpvar_1; + tmpvar_1 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_2; + float tmpvar_3; + tmpvar_3 = 0.0; + o.Specular = tmpvar_3; + float tmpvar_4; + tmpvar_4 = 0.0; + o.Alpha = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Gloss = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = IN.normal; + o.Normal = tmpvar_6; + surf (surfIN, o); + vec3 tmpvar_7; + tmpvar_7 = ((o.Normal * vec3(0.5, 0.5, -0.5)) + 0.5); + res.xyz = tmpvar_7.xyz.xyz; + float tmpvar_8; + tmpvar_8 = o.Specular; + res.w = vec4(tmpvar_8).w; + return res; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = gl_TexCoord[0].xyz; + vec3 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_IN.normal = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = frag_surf (xlt_IN); + vec4 tmpvar_5; + tmpvar_5 = tmpvar_4; + xl_retval = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = xl_retval.xyzw; + vec4 tmpvar_7; + tmpvar_7 = tmpvar_6; + gl_FragData[0] = tmpvar_7; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_ScreenPosAlbedo-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_ScreenPosAlbedo-out.txt new file mode 100644 index 000000000..2a4e65f10 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_ScreenPosAlbedo-out.txt @@ -0,0 +1,8 @@ +void main () +{ + vec4 res; + res.xyz = ((gl_TexCoord[0].xyz * vec3(0.5, 0.5, -0.5)) + 0.5); + res.w = 0.0; + gl_FragData[0] = res; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_ScreenPosAlbedo1-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_ScreenPosAlbedo1-in.txt new file mode 100644 index 000000000..3450105ad --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_ScreenPosAlbedo1-in.txt @@ -0,0 +1,85 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec4 screenPos; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_screenPos; + vec4 hip_screen; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform sampler2D _LightBuffer; +uniform sampler2D _MainTex; +uniform vec4 unity_Ambient; +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingLambert_PrePass( in SurfaceOutput s, in vec4 light ); +vec4 frag_surf( in v2f_surf IN ); +void surf( in Input IN, inout SurfaceOutput o ) { + vec2 uv; + uv = (IN.screenPos.xy / IN.screenPos.w ); + uv *= vec2( 2.00000, 1.00000); + o.Albedo = texture2D( _MainTex, uv).xyz ; +} +vec4 LightingLambert_PrePass( in SurfaceOutput s, in vec4 light ) { + vec4 c; + c.xyz = (s.Albedo * light.xyz ); + c.w = s.Alpha; + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec4 light; + vec4 col; + surfIN.screenPos = IN.hip_screenPos; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + surf( surfIN, o); + light = texture2DProj( _LightBuffer, IN.hip_screen); + light = ( -log2( light ) ); + light.xyz += unity_Ambient.xyz ; + col = LightingLambert_PrePass( o, light); + return col; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_screenPos = vec4( gl_TexCoord[0]); + xlt_IN.hip_screen = vec4( gl_TexCoord[1]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_ScreenPosAlbedo1-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_ScreenPosAlbedo1-ir.txt new file mode 100644 index 000000000..cd37f1a13 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_ScreenPosAlbedo1-ir.txt @@ -0,0 +1,135 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec4 screenPos; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_screenPos; + vec4 hip_screen; +}; +varying vec4 xlv_FOG; +uniform vec4 unity_Ambient; +uniform sampler2D _MainTex; +uniform sampler2D _LightBuffer; +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec2 uv; + vec2 tmpvar_1; + tmpvar_1 = (IN.screenPos.xy / IN.screenPos.w); + uv = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = (uv * vec2(2.0, 1.0)); + uv = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = texture2D (_MainTex, uv); + vec3 tmpvar_4; + tmpvar_4 = tmpvar_3.xyz; + o.Albedo = tmpvar_4; +} + +vec4 LightingLambert_PrePass ( + in SurfaceOutput s, + in vec4 light +) +{ + vec4 c; + vec3 tmpvar_1; + tmpvar_1 = (s.Albedo * light.xyz); + c.xyz = tmpvar_1.xyz.xyz; + float tmpvar_2; + tmpvar_2 = s.Alpha; + c.w = vec4(tmpvar_2).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 col; + vec4 light; + SurfaceOutput o; + Input surfIN; + vec4 tmpvar_1; + tmpvar_1 = IN.hip_screenPos; + surfIN.screenPos = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_3; + float tmpvar_4; + tmpvar_4 = 0.0; + o.Specular = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Alpha = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Gloss = tmpvar_6; + surf (surfIN, o); + vec4 tmpvar_7; + tmpvar_7 = texture2DProj (_LightBuffer, IN.hip_screen); + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + light = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = log2 (light); + vec4 tmpvar_10; + tmpvar_10 = -(tmpvar_9); + light = tmpvar_10; + vec3 tmpvar_11; + tmpvar_11 = (light.xyz + unity_Ambient.xyz); + light.xyz = tmpvar_11.xyz.xyz; + vec4 tmpvar_12; + tmpvar_12 = LightingLambert_PrePass (o, light); + vec4 tmpvar_13; + tmpvar_13 = tmpvar_12; + col = tmpvar_13; + return col; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_screenPos = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyzw; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.hip_screen = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = frag_surf (xlt_IN); + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xl_retval = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = xl_retval.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + gl_FragData[0] = tmpvar_10; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_ScreenPosAlbedo1-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_ScreenPosAlbedo1-out.txt new file mode 100644 index 000000000..34c019671 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_ScreenPosAlbedo1-out.txt @@ -0,0 +1,18 @@ +uniform vec4 unity_Ambient; +uniform sampler2D _MainTex; +uniform sampler2D _LightBuffer; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = gl_TexCoord[0]; + vec4 light; + vec4 tmpvar_2; + tmpvar_2 = -(log2 (texture2DProj (_LightBuffer, gl_TexCoord[1]))); + light = tmpvar_2; + light.xyz = (tmpvar_2.xyz + unity_Ambient.xyz); + vec4 c; + c.xyz = (texture2D (_MainTex, ((tmpvar_1.xy / tmpvar_1.w) * vec2(2.0, 1.0))).xyz * light.xyz); + c.w = 0.0; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Slices-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Slices-in.txt new file mode 100644 index 000000000..97ccff30f --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Slices-in.txt @@ -0,0 +1,106 @@ +void xll_clip(float x) { + if ( x<0.0 ) discard; +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec3 worldPos; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 worldPos; + vec3 normal; + vec3 lightDir; + vec4 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _LightColor0; +uniform sampler2D _LightTexture0; +uniform sampler2D _LightTextureB0; +uniform sampler2D _MainTex; +void surf( in Input IN, inout SurfaceOutput o ); +float UnitySpotCookie( in vec4 LightCoord ); +float UnitySpotAttenuate( in vec3 LightCoord ); +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ); +vec4 frag_surf( in v2f_surf IN ); +void surf( in Input IN, inout SurfaceOutput o ) { + xll_clip( (fract( ((IN.worldPos.y + (IN.worldPos.z * 0.100000)) * 5.00000) ) - 0.500000) ); + o.Albedo = texture2D( _MainTex, IN.uv_MainTex).xyz ; +} +float UnitySpotCookie( in vec4 LightCoord ) { + return texture2D( _LightTexture0, ((LightCoord.xy / LightCoord.w ) + 0.500000)).w ; +} +float UnitySpotAttenuate( in vec3 LightCoord ) { + return texture2D( _LightTextureB0, vec2( vec2( dot( LightCoord, LightCoord)))).w ; +} +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ) { + float diff; + vec4 c; + diff = max( 0.000000, dot( s.Normal, lightDir)); + c.xyz = ((s.Albedo * _LightColor0.xyz ) * ((diff * atten) * 2.00000)); + c.w = s.Alpha; + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec3 lightDir; + vec4 c; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + surfIN.worldPos = IN.worldPos; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + o.Normal = IN.normal; + surf( surfIN, o); + lightDir = IN.lightDir; + lightDir = normalize( lightDir ); + c = LightingLambert( o, lightDir, ((float( (IN._LightCoord.z > 0.000000) ) * UnitySpotCookie( IN._LightCoord)) * UnitySpotAttenuate( IN._LightCoord.xyz ))); + c.w = 0.000000; + return c; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec2( gl_TexCoord[0]); + xlt_IN.worldPos = vec3( gl_TexCoord[1]); + xlt_IN.normal = vec3( gl_TexCoord[2]); + xlt_IN.lightDir = vec3( gl_TexCoord[3]); + xlt_IN._LightCoord = vec4( gl_TexCoord[4]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Slices-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Slices-ir.txt new file mode 100644 index 000000000..f51f54538 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Slices-ir.txt @@ -0,0 +1,201 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec3 worldPos; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 worldPos; + vec3 normal; + vec3 lightDir; + vec4 _LightCoord; +}; +varying vec4 xlv_FOG; +uniform sampler2D _MainTex; +uniform sampler2D _LightTextureB0; +uniform sampler2D _LightTexture0; +uniform vec4 _LightColor0; +void xll_clip ( + in float x +) +{ + if ((x < 0.0)) { + discard; + }; +} + +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + float tmpvar_1; + tmpvar_1 = fract (((IN.worldPos.y + (IN.worldPos.z * 0.1)) * 5.0)); + xll_clip ((tmpvar_1 - 0.5)); + vec4 tmpvar_2; + tmpvar_2 = texture2D (_MainTex, IN.uv_MainTex); + vec3 tmpvar_3; + tmpvar_3 = tmpvar_2.xyz; + o.Albedo = tmpvar_3; +} + +float UnitySpotCookie ( + in vec4 LightCoord +) +{ + vec4 tmpvar_1; + tmpvar_1 = texture2D (_LightTexture0, ((LightCoord.xy / LightCoord.w) + 0.5)); + return tmpvar_1.w; +} + +float UnitySpotAttenuate ( + in vec3 LightCoord +) +{ + float tmpvar_1; + tmpvar_1 = dot (LightCoord, LightCoord); + vec2 tmpvar_2; + tmpvar_2 = vec2(tmpvar_1); + vec2 tmpvar_3; + tmpvar_3 = tmpvar_2.xy; + vec4 tmpvar_4; + tmpvar_4 = texture2D (_LightTextureB0, tmpvar_3); + return tmpvar_4.w; +} + +vec4 LightingLambert ( + in SurfaceOutput s, + in vec3 lightDir, + in float atten +) +{ + vec4 c; + float diff; + float tmpvar_1; + tmpvar_1 = dot (s.Normal, lightDir); + float tmpvar_2; + tmpvar_2 = max (0.0, tmpvar_1); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + diff = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = ((s.Albedo * _LightColor0.xyz) * ((diff * atten) * 2.0)); + c.xyz = tmpvar_4.xyz.xyz; + float tmpvar_5; + tmpvar_5 = s.Alpha; + c.w = vec4(tmpvar_5).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 c; + vec3 lightDir; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = IN.worldPos; + surfIN.worldPos = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Specular = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Alpha = tmpvar_6; + float tmpvar_7; + tmpvar_7 = 0.0; + o.Gloss = tmpvar_7; + vec3 tmpvar_8; + tmpvar_8 = IN.normal; + o.Normal = tmpvar_8; + surf (surfIN, o); + vec3 tmpvar_9; + tmpvar_9 = IN.lightDir; + lightDir = tmpvar_9; + vec3 tmpvar_10; + tmpvar_10 = normalize (lightDir); + vec3 tmpvar_11; + tmpvar_11 = tmpvar_10; + lightDir = tmpvar_11; + float tmpvar_12; + tmpvar_12 = UnitySpotCookie (IN._LightCoord); + float tmpvar_13; + tmpvar_13 = UnitySpotAttenuate (IN._LightCoord.xyz); + vec4 tmpvar_14; + tmpvar_14 = LightingLambert (o, lightDir, ((float((IN._LightCoord.z > 0.0)) * tmpvar_12) * tmpvar_13)); + vec4 tmpvar_15; + tmpvar_15 = tmpvar_14; + c = tmpvar_15; + float tmpvar_16; + tmpvar_16 = 0.0; + c.w = vec4(tmpvar_16).w; + return c; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xy; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.worldPos = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.normal = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = gl_TexCoord[3].xyz; + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_IN.lightDir = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_TexCoord[4].xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_IN._LightCoord = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = frag_surf (xlt_IN); + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_FragData[0] = tmpvar_16; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Slices-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Slices-out.txt new file mode 100644 index 000000000..22848af00 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Slices-out.txt @@ -0,0 +1,32 @@ +uniform sampler2D _MainTex; +uniform sampler2D _LightTextureB0; +uniform sampler2D _LightTexture0; +uniform vec4 _LightColor0; +void main () +{ + vec3 tmpvar_1; + tmpvar_1 = gl_TexCoord[1].xyz; + vec3 tmpvar_2; + tmpvar_2 = gl_TexCoord[2].xyz; + vec3 tmpvar_3; + tmpvar_3 = gl_TexCoord[3].xyz; + vec4 tmpvar_4; + tmpvar_4 = gl_TexCoord[4]; + vec4 c; + vec2 tmpvar_5; + tmpvar_5 = gl_TexCoord[0].xy; + float x; + x = (fract (((tmpvar_1.y + (tmpvar_1.z * 0.1)) * 5.0)) - 0.5); + if ((x < 0.0)) { + discard; + }; + vec3 LightCoord_i0; + LightCoord_i0 = tmpvar_4.xyz; + vec4 c_i0; + c_i0.xyz = ((texture2D (_MainTex, tmpvar_5).xyz * _LightColor0.xyz) * ((max (0.0, dot (tmpvar_2, normalize (tmpvar_3))) * ((float((tmpvar_4.z > 0.0)) * texture2D (_LightTexture0, ((tmpvar_4.xy / tmpvar_4.w) + 0.5)).w) * texture2D (_LightTextureB0, vec2(dot (LightCoord_i0, LightCoord_i0))).w)) * 2.0)); + c_i0.w = 0.0; + c = c_i0; + c.w = 0.0; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Slices1-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Slices1-in.txt new file mode 100644 index 000000000..fa83426b4 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Slices1-in.txt @@ -0,0 +1,90 @@ +void xll_clip(float x) { + if ( x<0.0 ) discard; +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec3 worldPos; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 worldPos; + vec4 hip_screen; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform sampler2D _LightBuffer; +uniform sampler2D _MainTex; +uniform vec4 unity_Ambient; +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingLambert_PrePass( in SurfaceOutput s, in vec4 light ); +vec4 frag_surf( in v2f_surf IN ); +void surf( in Input IN, inout SurfaceOutput o ) { + xll_clip( (fract( ((IN.worldPos.y + (IN.worldPos.z * 0.100000)) * 5.00000) ) - 0.500000) ); + o.Albedo = texture2D( _MainTex, IN.uv_MainTex).xyz ; +} +vec4 LightingLambert_PrePass( in SurfaceOutput s, in vec4 light ) { + vec4 c; + c.xyz = (s.Albedo * light.xyz ); + c.w = s.Alpha; + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec4 light; + vec4 col; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + surfIN.worldPos = IN.worldPos; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + surf( surfIN, o); + light = texture2DProj( _LightBuffer, IN.hip_screen); + light = ( -log2( light ) ); + light.xyz += unity_Ambient.xyz ; + col = LightingLambert_PrePass( o, light); + return col; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec2( gl_TexCoord[0]); + xlt_IN.worldPos = vec3( gl_TexCoord[1]); + xlt_IN.hip_screen = vec4( gl_TexCoord[2]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Slices1-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Slices1-ir.txt new file mode 100644 index 000000000..3b6a84fb9 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Slices1-ir.txt @@ -0,0 +1,150 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec3 worldPos; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 worldPos; + vec4 hip_screen; +}; +varying vec4 xlv_FOG; +uniform vec4 unity_Ambient; +uniform sampler2D _MainTex; +uniform sampler2D _LightBuffer; +void xll_clip ( + in float x +) +{ + if ((x < 0.0)) { + discard; + }; +} + +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + float tmpvar_1; + tmpvar_1 = fract (((IN.worldPos.y + (IN.worldPos.z * 0.1)) * 5.0)); + xll_clip ((tmpvar_1 - 0.5)); + vec4 tmpvar_2; + tmpvar_2 = texture2D (_MainTex, IN.uv_MainTex); + vec3 tmpvar_3; + tmpvar_3 = tmpvar_2.xyz; + o.Albedo = tmpvar_3; +} + +vec4 LightingLambert_PrePass ( + in SurfaceOutput s, + in vec4 light +) +{ + vec4 c; + vec3 tmpvar_1; + tmpvar_1 = (s.Albedo * light.xyz); + c.xyz = tmpvar_1.xyz.xyz; + float tmpvar_2; + tmpvar_2 = s.Alpha; + c.w = vec4(tmpvar_2).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 col; + vec4 light; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = IN.worldPos; + surfIN.worldPos = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Specular = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Alpha = tmpvar_6; + float tmpvar_7; + tmpvar_7 = 0.0; + o.Gloss = tmpvar_7; + surf (surfIN, o); + vec4 tmpvar_8; + tmpvar_8 = texture2DProj (_LightBuffer, IN.hip_screen); + vec4 tmpvar_9; + tmpvar_9 = tmpvar_8; + light = tmpvar_9; + vec4 tmpvar_10; + tmpvar_10 = log2 (light); + vec4 tmpvar_11; + tmpvar_11 = -(tmpvar_10); + light = tmpvar_11; + vec3 tmpvar_12; + tmpvar_12 = (light.xyz + unity_Ambient.xyz); + light.xyz = tmpvar_12.xyz.xyz; + vec4 tmpvar_13; + tmpvar_13 = LightingLambert_PrePass (o, light); + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + col = tmpvar_14; + return col; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xy; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.worldPos = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.hip_screen = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = frag_surf (xlt_IN); + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xl_retval = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = xl_retval.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + gl_FragData[0] = tmpvar_12; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Slices1-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Slices1-out.txt new file mode 100644 index 000000000..043c5917f --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Slices1-out.txt @@ -0,0 +1,27 @@ +uniform vec4 unity_Ambient; +uniform sampler2D _MainTex; +uniform sampler2D _LightBuffer; +void main () +{ + vec3 tmpvar_1; + tmpvar_1 = gl_TexCoord[1].xyz; + vec4 tmpvar_2; + tmpvar_2 = gl_TexCoord[2]; + vec4 light; + vec2 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xy; + float x; + x = (fract (((tmpvar_1.y + (tmpvar_1.z * 0.1)) * 5.0)) - 0.5); + if ((x < 0.0)) { + discard; + }; + vec4 tmpvar_4; + tmpvar_4 = -(log2 (texture2DProj (_LightBuffer, tmpvar_2))); + light = tmpvar_4; + light.xyz = (tmpvar_4.xyz + unity_Ambient.xyz); + vec4 c; + c.xyz = (texture2D (_MainTex, tmpvar_3).xyz * light.xyz); + c.w = 0.0; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Slices2-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Slices2-in.txt new file mode 100644 index 000000000..2034e9215 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Slices2-in.txt @@ -0,0 +1,124 @@ +void xll_clip(float x) { + if ( x<0.0 ) discard; +} +float xll_saturate( float x) { + return clamp( x, 0.0, 1.0); +} +vec2 xll_saturate( vec2 x) { + return clamp( x, 0.0, 1.0); +} +vec3 xll_saturate( vec3 x) { + return clamp( x, 0.0, 1.0); +} +vec4 xll_saturate( vec4 x) { + return clamp( x, 0.0, 1.0); +} +mat2 xll_saturate(mat2 m) { + return mat2( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0)); +} +mat3 xll_saturate(mat3 m) { + return mat3( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0), clamp(m[2], 0.0, 1.0)); +} +mat4 xll_saturate(mat4 m) { + return mat4( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0), clamp(m[2], 0.0, 1.0), clamp(m[3], 0.0, 1.0)); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec3 worldPos; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 worldPos; + vec4 hip_screen; + vec3 hip_lmapFade; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform sampler2D _LightBuffer; +uniform sampler2D _MainTex; +uniform sampler2D unity_Lightmap; +uniform sampler2D unity_LightmapInd; +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingLambert_PrePass( in SurfaceOutput s, in vec4 light ); +vec3 DecodeLightmap( in vec4 color ); +vec4 frag_surf( in v2f_surf IN ); +void surf( in Input IN, inout SurfaceOutput o ) { + xll_clip( (fract( ((IN.worldPos.y + (IN.worldPos.z * 0.100000)) * 5.00000) ) - 0.500000) ); + o.Albedo = texture2D( _MainTex, IN.uv_MainTex).xyz ; +} +vec4 LightingLambert_PrePass( in SurfaceOutput s, in vec4 light ) { + vec4 c; + c.xyz = (s.Albedo * light.xyz ); + c.w = s.Alpha; + return c; +} +vec3 DecodeLightmap( in vec4 color ) { + return (2.00000 * color.xyz ); +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec4 light; + vec3 lmFull; + vec3 lmIndirect; + vec3 lm; + vec4 col; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + surfIN.worldPos = IN.worldPos; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + surf( surfIN, o); + light = texture2DProj( _LightBuffer, IN.hip_screen); + light = ( -log2( light ) ); + lmFull = DecodeLightmap( texture2D( unity_Lightmap, IN.hip_lmapFade.xy )); + lmIndirect = DecodeLightmap( texture2D( unity_LightmapInd, IN.hip_lmapFade.xy )); + lm = mix( lmIndirect, lmFull, vec3( xll_saturate( IN.hip_lmapFade.z ))); + light.xyz += lm; + col = LightingLambert_PrePass( o, light); + return col; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec2( gl_TexCoord[0]); + xlt_IN.worldPos = vec3( gl_TexCoord[1]); + xlt_IN.hip_screen = vec4( gl_TexCoord[2]); + xlt_IN.hip_lmapFade = vec3( gl_TexCoord[3]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Slices2-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Slices2-ir.txt new file mode 100644 index 000000000..556c00100 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Slices2-ir.txt @@ -0,0 +1,295 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec3 worldPos; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 worldPos; + vec4 hip_screen; + vec3 hip_lmapFade; +}; +varying vec4 xlv_FOG; +uniform sampler2D unity_LightmapInd; +uniform sampler2D unity_Lightmap; +uniform sampler2D _MainTex; +uniform sampler2D _LightBuffer; +void xll_clip ( + in float x +) +{ + if ((x < 0.0)) { + discard; + }; +} + +float xll_saturate ( + in float x +) +{ + float tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec2 xll_saturate ( + in vec2 x +) +{ + vec2 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec3 xll_saturate ( + in vec3 x +) +{ + vec3 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec4 xll_saturate ( + in vec4 x +) +{ + vec4 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +mat2 xll_saturate ( + in mat2 m +) +{ + vec2 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec2 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + mat2 tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_1; + tmpvar_3[0] = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5 = tmpvar_2; + tmpvar_3[1] = tmpvar_5; + return tmpvar_3; +} + +mat3 xll_saturate ( + in mat3 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec3 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + vec3 tmpvar_3; + tmpvar_3 = clamp (m[2], 0.0, 1.0); + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +mat4 xll_saturate ( + in mat4 m +) +{ + vec4 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec4 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + vec4 tmpvar_3; + tmpvar_3 = clamp (m[2], 0.0, 1.0); + vec4 tmpvar_4; + tmpvar_4 = clamp (m[3], 0.0, 1.0); + mat4 tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_1; + tmpvar_5[0] = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = tmpvar_2; + tmpvar_5[1] = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_3; + tmpvar_5[2] = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = tmpvar_4; + tmpvar_5[3] = tmpvar_9; + return tmpvar_5; +} + +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + float tmpvar_1; + tmpvar_1 = fract (((IN.worldPos.y + (IN.worldPos.z * 0.1)) * 5.0)); + xll_clip ((tmpvar_1 - 0.5)); + vec4 tmpvar_2; + tmpvar_2 = texture2D (_MainTex, IN.uv_MainTex); + vec3 tmpvar_3; + tmpvar_3 = tmpvar_2.xyz; + o.Albedo = tmpvar_3; +} + +vec4 LightingLambert_PrePass ( + in SurfaceOutput s, + in vec4 light +) +{ + vec4 c; + vec3 tmpvar_1; + tmpvar_1 = (s.Albedo * light.xyz); + c.xyz = tmpvar_1.xyz.xyz; + float tmpvar_2; + tmpvar_2 = s.Alpha; + c.w = vec4(tmpvar_2).w; + return c; +} + +vec3 DecodeLightmap ( + in vec4 color +) +{ + return (2.0 * color.xyz); +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 col; + vec3 lm; + vec3 lmIndirect; + vec3 lmFull; + vec4 light; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = IN.worldPos; + surfIN.worldPos = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Specular = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Alpha = tmpvar_6; + float tmpvar_7; + tmpvar_7 = 0.0; + o.Gloss = tmpvar_7; + surf (surfIN, o); + vec4 tmpvar_8; + tmpvar_8 = texture2DProj (_LightBuffer, IN.hip_screen); + vec4 tmpvar_9; + tmpvar_9 = tmpvar_8; + light = tmpvar_9; + vec4 tmpvar_10; + tmpvar_10 = log2 (light); + vec4 tmpvar_11; + tmpvar_11 = -(tmpvar_10); + light = tmpvar_11; + vec4 tmpvar_12; + tmpvar_12 = texture2D (unity_Lightmap, IN.hip_lmapFade.xy); + vec3 tmpvar_13; + tmpvar_13 = DecodeLightmap (tmpvar_12); + vec3 tmpvar_14; + tmpvar_14 = tmpvar_13; + lmFull = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = texture2D (unity_LightmapInd, IN.hip_lmapFade.xy); + vec3 tmpvar_16; + tmpvar_16 = DecodeLightmap (tmpvar_15); + vec3 tmpvar_17; + tmpvar_17 = tmpvar_16; + lmIndirect = tmpvar_17; + float tmpvar_18; + tmpvar_18 = xll_saturate (IN.hip_lmapFade.z); + vec3 tmpvar_19; + tmpvar_19 = vec3(tmpvar_18); + vec3 tmpvar_20; + tmpvar_20 = mix (lmIndirect, lmFull, tmpvar_19); + vec3 tmpvar_21; + tmpvar_21 = tmpvar_20; + lm = tmpvar_21; + vec3 tmpvar_22; + tmpvar_22 = (light.xyz + lm); + light.xyz = tmpvar_22.xyz.xyz; + vec4 tmpvar_23; + tmpvar_23 = LightingLambert_PrePass (o, light); + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + col = tmpvar_24; + return col; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xy; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.worldPos = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.hip_screen = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = gl_TexCoord[3].xyz; + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_IN.hip_lmapFade = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = frag_surf (xlt_IN); + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xl_retval = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = xl_retval.xyzw; + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + gl_FragData[0] = tmpvar_14; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Slices2-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Slices2-out.txt new file mode 100644 index 000000000..2c27c576c --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Slices2-out.txt @@ -0,0 +1,30 @@ +uniform sampler2D unity_LightmapInd; +uniform sampler2D unity_Lightmap; +uniform sampler2D _MainTex; +uniform sampler2D _LightBuffer; +void main () +{ + vec3 tmpvar_1; + tmpvar_1 = gl_TexCoord[1].xyz; + vec4 tmpvar_2; + tmpvar_2 = gl_TexCoord[2]; + vec3 tmpvar_3; + tmpvar_3 = gl_TexCoord[3].xyz; + vec4 light; + vec2 tmpvar_4; + tmpvar_4 = gl_TexCoord[0].xy; + float x; + x = (fract (((tmpvar_1.y + (tmpvar_1.z * 0.1)) * 5.0)) - 0.5); + if ((x < 0.0)) { + discard; + }; + vec4 tmpvar_5; + tmpvar_5 = -(log2 (texture2DProj (_LightBuffer, tmpvar_2))); + light = tmpvar_5; + light.xyz = (tmpvar_5.xyz + mix ((2.0 * texture2D (unity_LightmapInd, tmpvar_3.xy).xyz), (2.0 * texture2D (unity_Lightmap, tmpvar_3.xy).xyz), vec3(clamp (tmpvar_3.z, 0.0, 1.0)))); + vec4 c; + c.xyz = (texture2D (_MainTex, tmpvar_4).xyz * light.xyz); + c.w = 0.0; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Slices3-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Slices3-in.txt new file mode 100644 index 000000000..d384756da --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Slices3-in.txt @@ -0,0 +1,131 @@ +void xll_clip(float x) { + if ( x<0.0 ) discard; +} +float xll_saturate( float x) { + return clamp( x, 0.0, 1.0); +} +vec2 xll_saturate( vec2 x) { + return clamp( x, 0.0, 1.0); +} +vec3 xll_saturate( vec3 x) { + return clamp( x, 0.0, 1.0); +} +vec4 xll_saturate( vec4 x) { + return clamp( x, 0.0, 1.0); +} +mat2 xll_saturate(mat2 m) { + return mat2( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0)); +} +mat3 xll_saturate(mat3 m) { + return mat3( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0), clamp(m[2], 0.0, 1.0)); +} +mat4 xll_saturate(mat4 m) { + return mat4( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0), clamp(m[2], 0.0, 1.0), clamp(m[3], 0.0, 1.0)); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec3 worldPos; +}; +struct v2f_surf { + vec4 pos; + vec3 _ShadowCoord0; + vec3 _ShadowCoord1; + vec3 _ShadowCoord2; + vec3 _ShadowCoord3; + vec2 _ShadowZFade; + vec3 worldPos; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _LightShadowData; +uniform vec4 _LightSplitsFar; +uniform vec4 _LightSplitsNear; +uniform sampler2D _MainTex; +uniform vec4 _ProjectionParams; +uniform sampler2D _ShadowMapTexture; +void surf( in Input IN, inout SurfaceOutput o ); +vec2 EncodeFloatRG( in float v ); +vec4 frag_surf( in v2f_surf IN ); +void surf( in Input IN, inout SurfaceOutput o ) { + xll_clip( (fract( ((IN.worldPos.y + (IN.worldPos.z * 0.100000)) * 5.00000) ) - 0.500000) ); + o.Albedo = texture2D( _MainTex, IN.uv_MainTex).xyz ; +} +vec2 EncodeFloatRG( in float v ) { + vec2 kEncodeMul = vec2( 1.00000, 255.000); + float kEncodeBit = 0.00392157; + vec2 enc; + enc = (kEncodeMul * v); + enc = fract( enc ); + enc.x -= (enc.y * kEncodeBit); + return enc; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec4 z; + vec4 near; + vec4 far; + vec4 weights; + vec4 coord; + float shadow; + float faded; + vec4 res; + surfIN.worldPos = IN.worldPos; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + surf( surfIN, o); + z = vec4( IN._ShadowZFade.x ); + near = vec4( greaterThanEqual( z, _LightSplitsNear) ); + far = vec4( lessThan( z, _LightSplitsFar) ); + weights = (near * far); + coord = vec4( ((((IN._ShadowCoord0 * weights.x ) + (IN._ShadowCoord1 * weights.y )) + (IN._ShadowCoord2 * weights.z )) + (IN._ShadowCoord3 * weights.w )), 1.00000); + shadow = ( (texture2D( _ShadowMapTexture, coord.xy ).x < coord.z ) ) ? ( _LightShadowData.x ) : ( 1.00000 ); + faded = xll_saturate( (shadow + xll_saturate( IN._ShadowZFade.y )) ); + res.x = faded; + res.y = 1.00000; + res.zw = EncodeFloatRG( float( (1.00000 - (z * _ProjectionParams.w )))); + return res; +} +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN._ShadowCoord0 = vec3( gl_TexCoord[0]); + xlt_IN._ShadowCoord1 = vec3( gl_TexCoord[1]); + xlt_IN._ShadowCoord2 = vec3( gl_TexCoord[2]); + xlt_IN._ShadowCoord3 = vec3( gl_TexCoord[3]); + xlt_IN._ShadowZFade = vec2( gl_TexCoord[4]); + xlt_IN.worldPos = vec3( gl_TexCoord[5]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Slices3-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Slices3-ir.txt new file mode 100644 index 000000000..420955e51 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Slices3-ir.txt @@ -0,0 +1,325 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec3 worldPos; +}; +struct v2f_surf { + vec4 pos; + vec3 _ShadowCoord0; + vec3 _ShadowCoord1; + vec3 _ShadowCoord2; + vec3 _ShadowCoord3; + vec2 _ShadowZFade; + vec3 worldPos; +}; +uniform sampler2D _ShadowMapTexture; +uniform vec4 _ProjectionParams; +uniform sampler2D _MainTex; +uniform vec4 _LightSplitsNear; +uniform vec4 _LightSplitsFar; +uniform vec4 _LightShadowData; +void xll_clip ( + in float x +) +{ + if ((x < 0.0)) { + discard; + }; +} + +float xll_saturate ( + in float x +) +{ + float tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec2 xll_saturate ( + in vec2 x +) +{ + vec2 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec3 xll_saturate ( + in vec3 x +) +{ + vec3 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec4 xll_saturate ( + in vec4 x +) +{ + vec4 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +mat2 xll_saturate ( + in mat2 m +) +{ + vec2 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec2 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + mat2 tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_1; + tmpvar_3[0] = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5 = tmpvar_2; + tmpvar_3[1] = tmpvar_5; + return tmpvar_3; +} + +mat3 xll_saturate ( + in mat3 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec3 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + vec3 tmpvar_3; + tmpvar_3 = clamp (m[2], 0.0, 1.0); + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +mat4 xll_saturate ( + in mat4 m +) +{ + vec4 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec4 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + vec4 tmpvar_3; + tmpvar_3 = clamp (m[2], 0.0, 1.0); + vec4 tmpvar_4; + tmpvar_4 = clamp (m[3], 0.0, 1.0); + mat4 tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_1; + tmpvar_5[0] = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = tmpvar_2; + tmpvar_5[1] = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_3; + tmpvar_5[2] = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = tmpvar_4; + tmpvar_5[3] = tmpvar_9; + return tmpvar_5; +} + +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + float tmpvar_1; + tmpvar_1 = fract (((IN.worldPos.y + (IN.worldPos.z * 0.1)) * 5.0)); + xll_clip ((tmpvar_1 - 0.5)); + vec4 tmpvar_2; + tmpvar_2 = texture2D (_MainTex, IN.uv_MainTex); + vec3 tmpvar_3; + tmpvar_3 = tmpvar_2.xyz; + o.Albedo = tmpvar_3; +} + +vec2 EncodeFloatRG ( + in float v +) +{ + vec2 enc; + float kEncodeBit; + vec2 kEncodeMul; + vec2 tmpvar_1; + tmpvar_1 = vec2(1.0, 255.0); + kEncodeMul = tmpvar_1; + float tmpvar_2; + tmpvar_2 = 0.00392157; + kEncodeBit = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = (kEncodeMul * v); + enc = tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = fract (enc); + vec2 tmpvar_5; + tmpvar_5 = tmpvar_4; + enc = tmpvar_5; + float tmpvar_6; + tmpvar_6 = (enc.x - (enc.y * kEncodeBit)); + enc.x = tmpvar_6; + return enc; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 res; + float faded; + float shadow; + vec4 coord; + vec4 weights; + vec4 far; + vec4 near; + vec4 z; + SurfaceOutput o; + Input surfIN; + vec3 tmpvar_1; + tmpvar_1 = IN.worldPos; + surfIN.worldPos = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_3; + float tmpvar_4; + tmpvar_4 = 0.0; + o.Specular = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Alpha = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Gloss = tmpvar_6; + surf (surfIN, o); + vec4 tmpvar_7; + tmpvar_7 = vec4(IN._ShadowZFade.x); + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + z = tmpvar_8; + bvec4 tmpvar_9; + tmpvar_9 = greaterThanEqual (z, _LightSplitsNear); + vec4 tmpvar_10; + tmpvar_10 = vec4(tmpvar_9).xyzw; + vec4 tmpvar_11; + tmpvar_11 = tmpvar_10; + near = tmpvar_11; + bvec4 tmpvar_12; + tmpvar_12 = lessThan (z, _LightSplitsFar); + vec4 tmpvar_13; + tmpvar_13 = vec4(tmpvar_12).xyzw; + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + far = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = (near * far); + weights = tmpvar_15; + vec4 tmpvar_16; + tmpvar_16.w = 1.0; + tmpvar_16.xyz = ((((IN._ShadowCoord0 * weights.x) + (IN._ShadowCoord1 * weights.y)) + (IN._ShadowCoord2 * weights.z)) + (IN._ShadowCoord3 * weights.w)).xyz; + vec4 tmpvar_17; + tmpvar_17 = tmpvar_16; + coord = tmpvar_17; + vec4 tmpvar_18; + tmpvar_18 = texture2D (_ShadowMapTexture, coord.xy); + float tmpvar_19; + if ((tmpvar_18.x < coord.z)) { + tmpvar_19 = _LightShadowData.x; + } else { + tmpvar_19 = 1.0; + }; + float tmpvar_20; + tmpvar_20 = tmpvar_19; + shadow = tmpvar_20; + float tmpvar_21; + tmpvar_21 = xll_saturate (IN._ShadowZFade.y); + float tmpvar_22; + tmpvar_22 = xll_saturate ((shadow + tmpvar_21)); + float tmpvar_23; + tmpvar_23 = tmpvar_22; + faded = tmpvar_23; + float tmpvar_24; + tmpvar_24 = faded; + res.x = tmpvar_24; + float tmpvar_25; + tmpvar_25 = 1.0; + res.y = vec2(tmpvar_25).y; + vec2 tmpvar_26; + tmpvar_26 = EncodeFloatRG ((1.0 - (z * _ProjectionParams.w)).x); + vec2 tmpvar_27; + tmpvar_27 = tmpvar_26; + res.zw = tmpvar_27.xxxy.zw; + return res; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = gl_TexCoord[0].xyz; + vec3 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_IN._ShadowCoord0 = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = gl_TexCoord[1].xyz; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_4; + xlt_IN._ShadowCoord1 = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = gl_TexCoord[2].xyz; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_6; + xlt_IN._ShadowCoord2 = tmpvar_7; + vec3 tmpvar_8; + tmpvar_8 = gl_TexCoord[3].xyz; + vec3 tmpvar_9; + tmpvar_9 = tmpvar_8; + xlt_IN._ShadowCoord3 = tmpvar_9; + vec2 tmpvar_10; + tmpvar_10 = gl_TexCoord[4].xy; + vec2 tmpvar_11; + tmpvar_11 = tmpvar_10; + xlt_IN._ShadowZFade = tmpvar_11; + vec3 tmpvar_12; + tmpvar_12 = gl_TexCoord[5].xyz; + vec3 tmpvar_13; + tmpvar_13 = tmpvar_12; + xlt_IN.worldPos = tmpvar_13; + vec4 tmpvar_14; + tmpvar_14 = frag_surf (xlt_IN); + vec4 tmpvar_15; + tmpvar_15 = tmpvar_14; + xl_retval = tmpvar_15; + vec4 tmpvar_16; + tmpvar_16 = xl_retval.xyzw; + vec4 tmpvar_17; + tmpvar_17 = tmpvar_16; + gl_FragData[0] = tmpvar_17; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Slices3-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Slices3-out.txt new file mode 100644 index 000000000..d047bcd21 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_Slices3-out.txt @@ -0,0 +1,51 @@ +uniform sampler2D _ShadowMapTexture; +uniform vec4 _ProjectionParams; +uniform vec4 _LightSplitsNear; +uniform vec4 _LightSplitsFar; +uniform vec4 _LightShadowData; +void main () +{ + vec3 tmpvar_1; + tmpvar_1 = gl_TexCoord[0].xyz; + vec3 tmpvar_2; + tmpvar_2 = gl_TexCoord[1].xyz; + vec3 tmpvar_3; + tmpvar_3 = gl_TexCoord[2].xyz; + vec3 tmpvar_4; + tmpvar_4 = gl_TexCoord[3].xyz; + vec2 tmpvar_5; + tmpvar_5 = gl_TexCoord[4].xy; + vec3 tmpvar_6; + tmpvar_6 = gl_TexCoord[5].xyz; + vec4 res; + float x; + x = (fract (((tmpvar_6.y + (tmpvar_6.z * 0.1)) * 5.0)) - 0.5); + if ((x < 0.0)) { + discard; + }; + vec4 tmpvar_7; + tmpvar_7 = tmpvar_5.xxxx; + vec4 tmpvar_8; + tmpvar_8 = (vec4(greaterThanEqual (tmpvar_7, _LightSplitsNear)) * vec4(lessThan (tmpvar_7, _LightSplitsFar))); + vec4 tmpvar_9; + tmpvar_9.w = 1.0; + tmpvar_9.xyz = ((((tmpvar_1 * tmpvar_8.x) + (tmpvar_2 * tmpvar_8.y)) + (tmpvar_3 * tmpvar_8.z)) + (tmpvar_4 * tmpvar_8.w)); + vec4 tmpvar_10; + tmpvar_10 = texture2D (_ShadowMapTexture, tmpvar_9.xy); + float tmpvar_11; + if ((tmpvar_10.x < tmpvar_9.z)) { + tmpvar_11 = _LightShadowData.x; + } else { + tmpvar_11 = 1.0; + }; + res.x = clamp ((tmpvar_11 + clamp (tmpvar_5.y, 0.0, 1.0)), 0.0, 1.0); + res.y = 1.0; + vec2 enc; + vec2 tmpvar_12; + tmpvar_12 = fract ((vec2(1.0, 255.0) * (1.0 - (tmpvar_5.xxxx * _ProjectionParams.w)).x)); + enc = tmpvar_12; + enc.x = (tmpvar_12.x - (tmpvar_12.y * 0.00392157)); + res.zw = enc; + gl_FragData[0] = res; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_WorldRefl-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_WorldRefl-in.txt new file mode 100644 index 000000000..85001146b --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_WorldRefl-in.txt @@ -0,0 +1,85 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec3 worldRefl; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec3 worldRefl; + vec3 normal; + vec3 lightDir; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform samplerCube _Cube; +uniform vec4 _LightColor0; +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ); +vec4 frag_surf( in v2f_surf IN ); +void surf( in Input IN, inout SurfaceOutput o ) { + o.Albedo = textureCube( _Cube, IN.worldRefl).xyz ; +} +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ) { + float diff; + vec4 c; + diff = max( 0.000000, dot( s.Normal, lightDir)); + c.xyz = ((s.Albedo * _LightColor0.xyz ) * ((diff * atten) * 2.00000)); + c.w = s.Alpha; + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec3 lightDir; + vec4 c; + surfIN.worldRefl = IN.worldRefl; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + o.Normal = IN.normal; + surf( surfIN, o); + lightDir = IN.lightDir; + c = LightingLambert( o, lightDir, 1.00000); + c.w = 0.000000; + return c; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.worldRefl = vec3( gl_TexCoord[0]); + xlt_IN.normal = vec3( gl_TexCoord[1]); + xlt_IN.lightDir = vec3( gl_TexCoord[2]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_WorldRefl-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_WorldRefl-ir.txt new file mode 100644 index 000000000..639d05f1a --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_WorldRefl-ir.txt @@ -0,0 +1,138 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec3 worldRefl; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec3 worldRefl; + vec3 normal; + vec3 lightDir; +}; +varying vec4 xlv_FOG; +uniform vec4 _LightColor0; +uniform samplerCube _Cube; +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 tmpvar_1; + tmpvar_1 = textureCube (_Cube, IN.worldRefl); + vec3 tmpvar_2; + tmpvar_2 = tmpvar_1.xyz; + o.Albedo = tmpvar_2; +} + +vec4 LightingLambert ( + in SurfaceOutput s, + in vec3 lightDir, + in float atten +) +{ + vec4 c; + float diff; + float tmpvar_1; + tmpvar_1 = dot (s.Normal, lightDir); + float tmpvar_2; + tmpvar_2 = max (0.0, tmpvar_1); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + diff = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = ((s.Albedo * _LightColor0.xyz) * ((diff * atten) * 2.0)); + c.xyz = tmpvar_4.xyz.xyz; + float tmpvar_5; + tmpvar_5 = s.Alpha; + c.w = vec4(tmpvar_5).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 c; + vec3 lightDir; + SurfaceOutput o; + Input surfIN; + vec3 tmpvar_1; + tmpvar_1 = IN.worldRefl; + surfIN.worldRefl = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_3; + float tmpvar_4; + tmpvar_4 = 0.0; + o.Specular = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Alpha = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Gloss = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = IN.normal; + o.Normal = tmpvar_7; + surf (surfIN, o); + vec3 tmpvar_8; + tmpvar_8 = IN.lightDir; + lightDir = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = LightingLambert (o, lightDir, 1.0); + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + c = tmpvar_10; + float tmpvar_11; + tmpvar_11 = 0.0; + c.w = vec4(tmpvar_11).w; + return c; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xyz; + vec3 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.worldRefl = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.normal = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.lightDir = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = frag_surf (xlt_IN); + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xl_retval = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = xl_retval.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + gl_FragData[0] = tmpvar_12; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_WorldRefl-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_WorldRefl-out.txt new file mode 100644 index 000000000..7781483e2 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_WorldRefl-out.txt @@ -0,0 +1,13 @@ +uniform vec4 _LightColor0; +uniform samplerCube _Cube; +void main () +{ + vec4 c; + vec4 c_i0; + c_i0.xyz = ((textureCube (_Cube, gl_TexCoord[0].xyz).xyz * _LightColor0.xyz) * (max (0.0, dot (gl_TexCoord[1].xyz, gl_TexCoord[2].xyz)) * 2.0)); + c_i0.w = 0.0; + c = c_i0; + c.w = 0.0; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_WorldRefl1-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_WorldRefl1-in.txt new file mode 100644 index 000000000..973321c67 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_WorldRefl1-in.txt @@ -0,0 +1,65 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec3 worldRefl; +}; +struct v2f_surf { + vec4 pos; + vec3 normal; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform samplerCube _Cube; +void surf( in Input IN, inout SurfaceOutput o ); +vec4 frag_surf( in v2f_surf IN ); +void surf( in Input IN, inout SurfaceOutput o ) { + o.Albedo = textureCube( _Cube, IN.worldRefl).xyz ; +} +vec4 frag_surf( in v2f_surf IN ) { + SurfaceOutput o; + Input surfIN; + vec4 res; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + o.Normal = IN.normal; + surf( surfIN, o); + res.xyz = ((o.Normal * vec3( 0.500000, 0.500000, -0.500000)) + 0.500000); + res.w = o.Specular; + return res; +} +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.normal = vec3( gl_TexCoord[0]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_WorldRefl1-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_WorldRefl1-ir.txt new file mode 100644 index 000000000..94e66c645 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_WorldRefl1-ir.txt @@ -0,0 +1,87 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec3 worldRefl; +}; +struct v2f_surf { + vec4 pos; + vec3 normal; +}; +uniform samplerCube _Cube; +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 tmpvar_1; + tmpvar_1 = textureCube (_Cube, IN.worldRefl); + vec3 tmpvar_2; + tmpvar_2 = tmpvar_1.xyz; + o.Albedo = tmpvar_2; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 res; + Input surfIN; + SurfaceOutput o; + vec3 tmpvar_1; + tmpvar_1 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_2; + float tmpvar_3; + tmpvar_3 = 0.0; + o.Specular = tmpvar_3; + float tmpvar_4; + tmpvar_4 = 0.0; + o.Alpha = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Gloss = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = IN.normal; + o.Normal = tmpvar_6; + surf (surfIN, o); + vec3 tmpvar_7; + tmpvar_7 = ((o.Normal * vec3(0.5, 0.5, -0.5)) + 0.5); + res.xyz = tmpvar_7.xyz.xyz; + float tmpvar_8; + tmpvar_8 = o.Specular; + res.w = vec4(tmpvar_8).w; + return res; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = gl_TexCoord[0].xyz; + vec3 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_IN.normal = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = frag_surf (xlt_IN); + vec4 tmpvar_5; + tmpvar_5 = tmpvar_4; + xl_retval = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = xl_retval.xyzw; + vec4 tmpvar_7; + tmpvar_7 = tmpvar_6; + gl_FragData[0] = tmpvar_7; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_WorldRefl1-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_WorldRefl1-out.txt new file mode 100644 index 000000000..2a4e65f10 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Surface_WorldRefl1-out.txt @@ -0,0 +1,8 @@ +void main () +{ + vec4 res; + res.xyz = ((gl_TexCoord[0].xyz * vec3(0.5, 0.5, -0.5)) + 0.5); + res.w = 0.0; + gl_FragData[0] = res; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Test_CgNormals-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Test_CgNormals-in.txt new file mode 100644 index 000000000..6597b9cd6 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Test_CgNormals-in.txt @@ -0,0 +1,34 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct v2f { + vec4 pos; + vec4 color; +}; +struct appdata_base { + vec4 vertex; + vec3 normal; + vec4 texcoord; +}; +vec4 frag( in v2f i ); +vec4 frag( in v2f i ) { + return i.color; +} +void main() { + vec4 xl_retval; + v2f xlt_i; + xlt_i.pos = vec4(0.0); + xlt_i.color = vec4( gl_Color); + xl_retval = frag( xlt_i); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Test_CgNormals-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Test_CgNormals-ir.txt new file mode 100644 index 000000000..5ecfe530c --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Test_CgNormals-ir.txt @@ -0,0 +1,35 @@ +struct v2f { + vec4 pos; + vec4 color; +}; +vec4 frag ( + in v2f i +) +{ + return i.color; +} + +void main () +{ + v2f xlt_i; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_i.pos = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = gl_Color.xyzw; + vec4 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_i.color = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = frag (xlt_i); + vec4 tmpvar_5; + tmpvar_5 = tmpvar_4; + xl_retval = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = xl_retval.xyzw; + vec4 tmpvar_7; + tmpvar_7 = tmpvar_6; + gl_FragData[0] = tmpvar_7; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Test_CgNormals-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Test_CgNormals-out.txt new file mode 100644 index 000000000..74e3fb284 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Test_CgNormals-out.txt @@ -0,0 +1,5 @@ +void main () +{ + gl_FragData[0] = gl_Color; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Test_FontShaderCull-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Test_FontShaderCull-in.txt new file mode 100644 index 000000000..b74c048cf --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Test_FontShaderCull-in.txt @@ -0,0 +1,35 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct v2f { + vec4 vertex; + vec2 texcoord; +}; +struct appdata_t { + vec4 vertex; + vec2 texcoord; +}; +uniform vec4 _Color; +uniform sampler2D _MainTex; +vec4 frag( in v2f i ); +vec4 frag( in v2f i ) { + return (texture2D( _MainTex, i.texcoord) * _Color); +} +void main() { + vec4 xl_retval; + v2f xlt_i; + xlt_i.vertex = vec4(0.0); + xlt_i.texcoord = vec2( gl_TexCoord[0]); + xl_retval = frag( xlt_i); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Test_FontShaderCull-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Test_FontShaderCull-ir.txt new file mode 100644 index 000000000..e528171f0 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Test_FontShaderCull-ir.txt @@ -0,0 +1,39 @@ +struct v2f { + vec4 vertex; + vec2 texcoord; +}; +uniform sampler2D _MainTex; +uniform vec4 _Color; +vec4 frag ( + in v2f i +) +{ + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, i.texcoord); + return (tmpvar_1 * _Color); +} + +void main () +{ + v2f xlt_i; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_i.vertex = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = gl_TexCoord[0].xy; + vec2 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_i.texcoord = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = frag (xlt_i); + vec4 tmpvar_5; + tmpvar_5 = tmpvar_4; + xl_retval = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = xl_retval.xyzw; + vec4 tmpvar_7; + tmpvar_7 = tmpvar_6; + gl_FragData[0] = tmpvar_7; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Test_FontShaderCull-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Test_FontShaderCull-out.txt new file mode 100644 index 000000000..775cddc57 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Test_FontShaderCull-out.txt @@ -0,0 +1,7 @@ +uniform sampler2D _MainTex; +uniform vec4 _Color; +void main () +{ + gl_FragData[0] = (texture2D (_MainTex, gl_TexCoord[0].xy) * _Color); +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Test_VertexShaderDepthTexture-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Test_VertexShaderDepthTexture-in.txt new file mode 100644 index 000000000..48454d866 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Test_VertexShaderDepthTexture-in.txt @@ -0,0 +1,40 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct v2f { + vec4 pos; + vec2 uv; +}; +struct appdata_base { + vec4 vertex; + vec3 normal; + vec4 texcoord; +}; +uniform sampler2D _CameraDepthTexture; +uniform vec4 _ZBufferParams; +float Linear01Depth( in float z ); +vec4 frag( in v2f i ); +float Linear01Depth( in float z ) { + return (1.00000 / ((_ZBufferParams.x * z) + _ZBufferParams.y )); +} +vec4 frag( in v2f i ) { + return vec4( (1.00000 - Linear01Depth( texture2D( _CameraDepthTexture, i.uv).x ))); +} +void main() { + vec4 xl_retval; + v2f xlt_i; + xlt_i.pos = vec4(0.0); + xlt_i.uv = vec2( gl_TexCoord[0]); + xl_retval = frag( xlt_i); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Test_VertexShaderDepthTexture-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Test_VertexShaderDepthTexture-ir.txt new file mode 100644 index 000000000..29ee52c61 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Test_VertexShaderDepthTexture-ir.txt @@ -0,0 +1,50 @@ +struct v2f { + vec4 pos; + vec2 uv; +}; +uniform vec4 _ZBufferParams; +uniform sampler2D _CameraDepthTexture; +float Linear01Depth ( + in float z +) +{ + return (1.0 / ((_ZBufferParams.x * z) + _ZBufferParams.y)); +} + +vec4 frag ( + in v2f i +) +{ + vec4 tmpvar_1; + tmpvar_1 = texture2D (_CameraDepthTexture, i.uv); + float tmpvar_2; + tmpvar_2 = Linear01Depth (tmpvar_1.x); + vec4 tmpvar_3; + tmpvar_3 = vec4((1.0 - tmpvar_2)); + return tmpvar_3; +} + +void main () +{ + v2f xlt_i; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_i.pos = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = gl_TexCoord[0].xy; + vec2 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_i.uv = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = frag (xlt_i); + vec4 tmpvar_5; + tmpvar_5 = tmpvar_4; + xl_retval = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = xl_retval.xyzw; + vec4 tmpvar_7; + tmpvar_7 = tmpvar_6; + gl_FragData[0] = tmpvar_7; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Test_VertexShaderDepthTexture-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Test_VertexShaderDepthTexture-out.txt new file mode 100644 index 000000000..896249a0c --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Test_VertexShaderDepthTexture-out.txt @@ -0,0 +1,7 @@ +uniform vec4 _ZBufferParams; +uniform sampler2D _CameraDepthTexture; +void main () +{ + gl_FragData[0] = vec4((1.0 - (1.0/(((_ZBufferParams.x * texture2D (_CameraDepthTexture, gl_TexCoord[0].xy).x) + _ZBufferParams.y))))); +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Test_VertexShaderTexture-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Test_VertexShaderTexture-in.txt new file mode 100644 index 000000000..302008237 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Test_VertexShaderTexture-in.txt @@ -0,0 +1,35 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct v2f { + vec4 pos; + vec2 uv; +}; +struct appdata_base { + vec4 vertex; + vec3 normal; + vec4 texcoord; +}; +uniform sampler2D _MainTex; +vec4 frag( in v2f i ); +vec4 frag( in v2f i ) { + return texture2D( _MainTex, i.uv); +} +void main() { + vec4 xl_retval; + v2f xlt_i; + xlt_i.pos = vec4(0.0); + xlt_i.uv = vec2( gl_TexCoord[0]); + xl_retval = frag( xlt_i); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Test_VertexShaderTexture-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Test_VertexShaderTexture-ir.txt new file mode 100644 index 000000000..f7921820c --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Test_VertexShaderTexture-ir.txt @@ -0,0 +1,38 @@ +struct v2f { + vec4 pos; + vec2 uv; +}; +uniform sampler2D _MainTex; +vec4 frag ( + in v2f i +) +{ + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, i.uv); + return tmpvar_1; +} + +void main () +{ + v2f xlt_i; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_i.pos = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = gl_TexCoord[0].xy; + vec2 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_i.uv = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = frag (xlt_i); + vec4 tmpvar_5; + tmpvar_5 = tmpvar_4; + xl_retval = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = xl_retval.xyzw; + vec4 tmpvar_7; + tmpvar_7 = tmpvar_6; + gl_FragData[0] = tmpvar_7; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Test_VertexShaderTexture-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Test_VertexShaderTexture-out.txt new file mode 100644 index 000000000..4cb551151 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Test_VertexShaderTexture-out.txt @@ -0,0 +1,6 @@ +uniform sampler2D _MainTex; +void main () +{ + gl_FragData[0] = texture2D (_MainTex, gl_TexCoord[0].xy); +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Tests_Blend_Many_Textures-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Tests_Blend_Many_Textures-in.txt new file mode 100644 index 000000000..1c2c0f659 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Tests_Blend_Many_Textures-in.txt @@ -0,0 +1,67 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct v2f { + vec4 pos; + vec2 uv; +}; +struct appdata_base { + vec4 vertex; + vec3 normal; + vec4 texcoord; +}; +uniform sampler2D _MainTex0; +uniform sampler2D _MainTex1; +uniform sampler2D _MainTex10; +uniform sampler2D _MainTex11; +uniform sampler2D _MainTex12; +uniform sampler2D _MainTex13; +uniform sampler2D _MainTex14; +uniform sampler2D _MainTex15; +uniform sampler2D _MainTex2; +uniform sampler2D _MainTex3; +uniform sampler2D _MainTex4; +uniform sampler2D _MainTex5; +uniform sampler2D _MainTex6; +uniform sampler2D _MainTex7; +uniform sampler2D _MainTex8; +uniform sampler2D _MainTex9; +vec4 frag( in v2f i ); +vec4 frag( in v2f i ) { + vec4 col; + col = texture2D( _MainTex0, i.uv); + col += texture2D( _MainTex1, i.uv); + col += texture2D( _MainTex2, i.uv); + col += texture2D( _MainTex3, i.uv); + col += texture2D( _MainTex4, i.uv); + col += texture2D( _MainTex5, i.uv); + col += texture2D( _MainTex6, i.uv); + col += texture2D( _MainTex7, i.uv); + col += texture2D( _MainTex8, i.uv); + col += texture2D( _MainTex9, i.uv); + col += texture2D( _MainTex10, i.uv); + col += texture2D( _MainTex11, i.uv); + col += texture2D( _MainTex12, i.uv); + col += texture2D( _MainTex13, i.uv); + col += texture2D( _MainTex14, i.uv); + col += texture2D( _MainTex15, i.uv); + return col; +} +void main() { + vec4 xl_retval; + v2f xlt_i; + xlt_i.pos = vec4(0.0); + xlt_i.uv = vec2( gl_TexCoord[0]); + xl_retval = frag( xlt_i); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Tests_Blend_Many_Textures-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Tests_Blend_Many_Textures-ir.txt new file mode 100644 index 000000000..2d025bed3 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Tests_Blend_Many_Textures-ir.txt @@ -0,0 +1,132 @@ +struct v2f { + vec4 pos; + vec2 uv; +}; +uniform sampler2D _MainTex9; +uniform sampler2D _MainTex8; +uniform sampler2D _MainTex7; +uniform sampler2D _MainTex6; +uniform sampler2D _MainTex5; +uniform sampler2D _MainTex4; +uniform sampler2D _MainTex3; +uniform sampler2D _MainTex2; +uniform sampler2D _MainTex15; +uniform sampler2D _MainTex14; +uniform sampler2D _MainTex13; +uniform sampler2D _MainTex12; +uniform sampler2D _MainTex11; +uniform sampler2D _MainTex10; +uniform sampler2D _MainTex1; +uniform sampler2D _MainTex0; +vec4 frag ( + in v2f i +) +{ + vec4 col; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex0, i.uv); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + col = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = texture2D (_MainTex1, i.uv); + vec4 tmpvar_4; + tmpvar_4 = (col + tmpvar_3); + col = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = texture2D (_MainTex2, i.uv); + vec4 tmpvar_6; + tmpvar_6 = (col + tmpvar_5); + col = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = texture2D (_MainTex3, i.uv); + vec4 tmpvar_8; + tmpvar_8 = (col + tmpvar_7); + col = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = texture2D (_MainTex4, i.uv); + vec4 tmpvar_10; + tmpvar_10 = (col + tmpvar_9); + col = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = texture2D (_MainTex5, i.uv); + vec4 tmpvar_12; + tmpvar_12 = (col + tmpvar_11); + col = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = texture2D (_MainTex6, i.uv); + vec4 tmpvar_14; + tmpvar_14 = (col + tmpvar_13); + col = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = texture2D (_MainTex7, i.uv); + vec4 tmpvar_16; + tmpvar_16 = (col + tmpvar_15); + col = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17 = texture2D (_MainTex8, i.uv); + vec4 tmpvar_18; + tmpvar_18 = (col + tmpvar_17); + col = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19 = texture2D (_MainTex9, i.uv); + vec4 tmpvar_20; + tmpvar_20 = (col + tmpvar_19); + col = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21 = texture2D (_MainTex10, i.uv); + vec4 tmpvar_22; + tmpvar_22 = (col + tmpvar_21); + col = tmpvar_22; + vec4 tmpvar_23; + tmpvar_23 = texture2D (_MainTex11, i.uv); + vec4 tmpvar_24; + tmpvar_24 = (col + tmpvar_23); + col = tmpvar_24; + vec4 tmpvar_25; + tmpvar_25 = texture2D (_MainTex12, i.uv); + vec4 tmpvar_26; + tmpvar_26 = (col + tmpvar_25); + col = tmpvar_26; + vec4 tmpvar_27; + tmpvar_27 = texture2D (_MainTex13, i.uv); + vec4 tmpvar_28; + tmpvar_28 = (col + tmpvar_27); + col = tmpvar_28; + vec4 tmpvar_29; + tmpvar_29 = texture2D (_MainTex14, i.uv); + vec4 tmpvar_30; + tmpvar_30 = (col + tmpvar_29); + col = tmpvar_30; + vec4 tmpvar_31; + tmpvar_31 = texture2D (_MainTex15, i.uv); + vec4 tmpvar_32; + tmpvar_32 = (col + tmpvar_31); + col = tmpvar_32; + return col; +} + +void main () +{ + v2f xlt_i; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_i.pos = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = gl_TexCoord[0].xy; + vec2 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_i.uv = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = frag (xlt_i); + vec4 tmpvar_5; + tmpvar_5 = tmpvar_4; + xl_retval = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = xl_retval.xyzw; + vec4 tmpvar_7; + tmpvar_7 = tmpvar_6; + gl_FragData[0] = tmpvar_7; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Tests_Blend_Many_Textures-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Tests_Blend_Many_Textures-out.txt new file mode 100644 index 000000000..5bd4641fc --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Tests_Blend_Many_Textures-out.txt @@ -0,0 +1,23 @@ +uniform sampler2D _MainTex9; +uniform sampler2D _MainTex8; +uniform sampler2D _MainTex7; +uniform sampler2D _MainTex6; +uniform sampler2D _MainTex5; +uniform sampler2D _MainTex4; +uniform sampler2D _MainTex3; +uniform sampler2D _MainTex2; +uniform sampler2D _MainTex15; +uniform sampler2D _MainTex14; +uniform sampler2D _MainTex13; +uniform sampler2D _MainTex12; +uniform sampler2D _MainTex11; +uniform sampler2D _MainTex10; +uniform sampler2D _MainTex1; +uniform sampler2D _MainTex0; +void main () +{ + vec2 tmpvar_1; + tmpvar_1 = gl_TexCoord[0].xy; + gl_FragData[0] = (((((((((((((((texture2D (_MainTex0, tmpvar_1) + texture2D (_MainTex1, tmpvar_1)) + texture2D (_MainTex2, tmpvar_1)) + texture2D (_MainTex3, tmpvar_1)) + texture2D (_MainTex4, tmpvar_1)) + texture2D (_MainTex5, tmpvar_1)) + texture2D (_MainTex6, tmpvar_1)) + texture2D (_MainTex7, tmpvar_1)) + texture2D (_MainTex8, tmpvar_1)) + texture2D (_MainTex9, tmpvar_1)) + texture2D (_MainTex10, tmpvar_1)) + texture2D (_MainTex11, tmpvar_1)) + texture2D (_MainTex12, tmpvar_1)) + texture2D (_MainTex13, tmpvar_1)) + texture2D (_MainTex14, tmpvar_1)) + texture2D (_MainTex15, tmpvar_1)); +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Tests_Fwd-Def-Vert-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Tests_Fwd-Def-Vert-in.txt new file mode 100644 index 000000000..3e04a3397 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Tests_Fwd-Def-Vert-in.txt @@ -0,0 +1,85 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec3 normal; + vec3 lightDir; + vec3 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _LightColor0; +uniform sampler2D _LightTexture0; +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ); +vec4 frag_surf( in v2f_surf IN ); +void surf( in Input IN, inout SurfaceOutput o ) { + o.Emission = vec3( vec4( 0.000000, 1.00000, 0.000000, 0.000000)); +} +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ) { + float diff; + vec4 c; + diff = max( 0.000000, dot( s.Normal, lightDir)); + c.xyz = ((s.Albedo * _LightColor0.xyz ) * ((diff * atten) * 2.00000)); + c.w = s.Alpha; + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + SurfaceOutput o; + Input surfIN; + vec3 lightDir; + vec4 c; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + o.Normal = IN.normal; + surf( surfIN, o); + lightDir = IN.lightDir; + lightDir = normalize( lightDir ); + c = LightingLambert( o, lightDir, texture2D( _LightTexture0, vec2( vec2( dot( IN._LightCoord, IN._LightCoord)))).w ); + c.w = 0.000000; + return c; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.normal = vec3( gl_TexCoord[0]); + xlt_IN.lightDir = vec3( gl_TexCoord[1]); + xlt_IN._LightCoord = vec3( gl_TexCoord[2]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Tests_Fwd-Def-Vert-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Tests_Fwd-Def-Vert-ir.txt new file mode 100644 index 000000000..8a871c83c --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Tests_Fwd-Def-Vert-ir.txt @@ -0,0 +1,146 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec3 normal; + vec3 lightDir; + vec3 _LightCoord; +}; +varying vec4 xlv_FOG; +uniform sampler2D _LightTexture0; +uniform vec4 _LightColor0; +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec3 tmpvar_1; + tmpvar_1 = vec3(0.0, 1.0, 0.0); + o.Emission = tmpvar_1; +} + +vec4 LightingLambert ( + in SurfaceOutput s, + in vec3 lightDir, + in float atten +) +{ + vec4 c; + float diff; + float tmpvar_1; + tmpvar_1 = dot (s.Normal, lightDir); + float tmpvar_2; + tmpvar_2 = max (0.0, tmpvar_1); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + diff = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = ((s.Albedo * _LightColor0.xyz) * ((diff * atten) * 2.0)); + c.xyz = tmpvar_4.xyz.xyz; + float tmpvar_5; + tmpvar_5 = s.Alpha; + c.w = vec4(tmpvar_5).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 c; + vec3 lightDir; + Input surfIN; + SurfaceOutput o; + vec3 tmpvar_1; + tmpvar_1 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_2; + float tmpvar_3; + tmpvar_3 = 0.0; + o.Specular = tmpvar_3; + float tmpvar_4; + tmpvar_4 = 0.0; + o.Alpha = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Gloss = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = IN.normal; + o.Normal = tmpvar_6; + surf (surfIN, o); + vec3 tmpvar_7; + tmpvar_7 = IN.lightDir; + lightDir = tmpvar_7; + vec3 tmpvar_8; + tmpvar_8 = normalize (lightDir); + vec3 tmpvar_9; + tmpvar_9 = tmpvar_8; + lightDir = tmpvar_9; + float tmpvar_10; + tmpvar_10 = dot (IN._LightCoord, IN._LightCoord); + vec2 tmpvar_11; + tmpvar_11 = vec2(tmpvar_10); + vec2 tmpvar_12; + tmpvar_12 = tmpvar_11.xy; + vec4 tmpvar_13; + tmpvar_13 = texture2D (_LightTexture0, tmpvar_12); + vec4 tmpvar_14; + tmpvar_14 = LightingLambert (o, lightDir, tmpvar_13.w); + vec4 tmpvar_15; + tmpvar_15 = tmpvar_14; + c = tmpvar_15; + float tmpvar_16; + tmpvar_16 = 0.0; + c.w = vec4(tmpvar_16).w; + return c; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xyz; + vec3 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.normal = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.lightDir = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN._LightCoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = frag_surf (xlt_IN); + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xl_retval = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = xl_retval.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + gl_FragData[0] = tmpvar_12; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Tests_Fwd-Def-Vert-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Tests_Fwd-Def-Vert-out.txt new file mode 100644 index 000000000..ec2e39e33 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Tests_Fwd-Def-Vert-out.txt @@ -0,0 +1,11 @@ +void main () +{ + vec4 c; + vec4 c_i0; + c_i0.xyz = vec3(0.0, 0.0, 0.0); + c_i0.w = 0.0; + c = c_i0; + c.w = 0.0; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Tests_Fwd-Def-Vert1-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Tests_Fwd-Def-Vert1-in.txt new file mode 100644 index 000000000..e54b9bf51 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Tests_Fwd-Def-Vert1-in.txt @@ -0,0 +1,64 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; +}; +struct v2f_surf { + vec4 pos; + vec3 normal; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +void surf( in Input IN, inout SurfaceOutput o ); +vec4 frag_surf( in v2f_surf IN ); +void surf( in Input IN, inout SurfaceOutput o ) { + o.Emission = vec3( vec4( 1.00000, 0.000000, 0.000000, 0.000000)); +} +vec4 frag_surf( in v2f_surf IN ) { + SurfaceOutput o; + Input surfIN; + vec4 res; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + o.Normal = IN.normal; + surf( surfIN, o); + res.xyz = ((o.Normal * vec3( 0.500000, 0.500000, -0.500000)) + 0.500000); + res.w = o.Specular; + return res; +} +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.normal = vec3( gl_TexCoord[0]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Tests_Fwd-Def-Vert1-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Tests_Fwd-Def-Vert1-ir.txt new file mode 100644 index 000000000..0719c8662 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Tests_Fwd-Def-Vert1-ir.txt @@ -0,0 +1,84 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; +}; +struct v2f_surf { + vec4 pos; + vec3 normal; +}; +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec3 tmpvar_1; + tmpvar_1 = vec3(1.0, 0.0, 0.0); + o.Emission = tmpvar_1; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 res; + Input surfIN; + SurfaceOutput o; + vec3 tmpvar_1; + tmpvar_1 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_2; + float tmpvar_3; + tmpvar_3 = 0.0; + o.Specular = tmpvar_3; + float tmpvar_4; + tmpvar_4 = 0.0; + o.Alpha = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Gloss = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = IN.normal; + o.Normal = tmpvar_6; + surf (surfIN, o); + vec3 tmpvar_7; + tmpvar_7 = ((o.Normal * vec3(0.5, 0.5, -0.5)) + 0.5); + res.xyz = tmpvar_7.xyz.xyz; + float tmpvar_8; + tmpvar_8 = o.Specular; + res.w = vec4(tmpvar_8).w; + return res; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = gl_TexCoord[0].xyz; + vec3 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_IN.normal = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = frag_surf (xlt_IN); + vec4 tmpvar_5; + tmpvar_5 = tmpvar_4; + xl_retval = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = xl_retval.xyzw; + vec4 tmpvar_7; + tmpvar_7 = tmpvar_6; + gl_FragData[0] = tmpvar_7; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Tests_Fwd-Def-Vert1-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Tests_Fwd-Def-Vert1-out.txt new file mode 100644 index 000000000..2a4e65f10 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Tests_Fwd-Def-Vert1-out.txt @@ -0,0 +1,8 @@ +void main () +{ + vec4 res; + res.xyz = ((gl_TexCoord[0].xyz * vec3(0.5, 0.5, -0.5)) + 0.5); + res.w = 0.0; + gl_FragData[0] = res; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-TexGen_Cube_Refl-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-TexGen_Cube_Refl-in.txt new file mode 100644 index 000000000..29d1b2ba1 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-TexGen_Cube_Refl-in.txt @@ -0,0 +1,37 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct v2f { + vec4 vertex; + vec4 color; + vec3 texcoord; +}; +struct appdata_t { + vec4 vertex; + vec4 color; + vec3 normal; +}; +uniform samplerCube _MainTex; +vec4 frag( in v2f i ); +vec4 frag( in v2f i ) { + return textureCube( _MainTex, i.texcoord); +} +void main() { + vec4 xl_retval; + v2f xlt_i; + xlt_i.vertex = vec4(0.0); + xlt_i.color = vec4( gl_Color); + xlt_i.texcoord = vec3( gl_TexCoord[0]); + xl_retval = frag( xlt_i); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-TexGen_Cube_Refl-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-TexGen_Cube_Refl-ir.txt new file mode 100644 index 000000000..860854dda --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-TexGen_Cube_Refl-ir.txt @@ -0,0 +1,44 @@ +struct v2f { + vec4 vertex; + vec4 color; + vec3 texcoord; +}; +uniform samplerCube _MainTex; +vec4 frag ( + in v2f i +) +{ + vec4 tmpvar_1; + tmpvar_1 = textureCube (_MainTex, i.texcoord); + return tmpvar_1; +} + +void main () +{ + v2f xlt_i; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_i.vertex = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = gl_Color.xyzw; + vec4 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_i.color = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = gl_TexCoord[0].xyz; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_4; + xlt_i.texcoord = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = frag (xlt_i); + vec4 tmpvar_7; + tmpvar_7 = tmpvar_6; + xl_retval = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = xl_retval.xyzw; + vec4 tmpvar_9; + tmpvar_9 = tmpvar_8; + gl_FragData[0] = tmpvar_9; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-TexGen_Cube_Refl-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-TexGen_Cube_Refl-out.txt new file mode 100644 index 000000000..114c707c6 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-TexGen_Cube_Refl-out.txt @@ -0,0 +1,6 @@ +uniform samplerCube _MainTex; +void main () +{ + gl_FragData[0] = textureCube (_MainTex, gl_TexCoord[0].xyz); +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Toon_Basic-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Toon_Basic-in.txt new file mode 100644 index 000000000..700c47947 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Toon_Basic-in.txt @@ -0,0 +1,43 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct v2f { + vec4 pos; + vec2 texcoord; + vec3 cubenormal; +}; +struct appdata { + vec4 vertex; + vec2 texcoord; + vec3 normal; +}; +uniform vec4 _Color; +uniform sampler2D _MainTex; +uniform samplerCube _ToonShade; +vec4 frag( in v2f i ); +vec4 frag( in v2f i ) { + vec4 col; + vec4 cube; + col = (_Color * texture2D( _MainTex, i.texcoord)); + cube = textureCube( _ToonShade, i.cubenormal); + return vec4( ((2.00000 * cube.xyz ) * col.xyz ), col.w ); +} +void main() { + vec4 xl_retval; + v2f xlt_i; + xlt_i.pos = vec4(0.0); + xlt_i.texcoord = vec2( gl_TexCoord[0]); + xlt_i.cubenormal = vec3( gl_TexCoord[1]); + xl_retval = frag( xlt_i); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Toon_Basic-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Toon_Basic-ir.txt new file mode 100644 index 000000000..74d32dda4 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Toon_Basic-ir.txt @@ -0,0 +1,59 @@ +struct v2f { + vec4 pos; + vec2 texcoord; + vec3 cubenormal; +}; +uniform samplerCube _ToonShade; +uniform sampler2D _MainTex; +uniform vec4 _Color; +vec4 frag ( + in v2f i +) +{ + vec4 cube; + vec4 col; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, i.texcoord); + vec4 tmpvar_2; + tmpvar_2 = (_Color * tmpvar_1); + col = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = textureCube (_ToonShade, i.cubenormal); + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + cube = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5.xyz = ((2.0 * cube.xyz) * col.xyz).xyz; + tmpvar_5.w = col.w; + return tmpvar_5; +} + +void main () +{ + v2f xlt_i; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_i.pos = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = gl_TexCoord[0].xy; + vec2 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_i.texcoord = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = gl_TexCoord[1].xyz; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_4; + xlt_i.cubenormal = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = frag (xlt_i); + vec4 tmpvar_7; + tmpvar_7 = tmpvar_6; + xl_retval = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = xl_retval.xyzw; + vec4 tmpvar_9; + tmpvar_9 = tmpvar_8; + gl_FragData[0] = tmpvar_9; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Toon_Basic-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Toon_Basic-out.txt new file mode 100644 index 000000000..76911fc75 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Toon_Basic-out.txt @@ -0,0 +1,13 @@ +uniform samplerCube _ToonShade; +uniform sampler2D _MainTex; +uniform vec4 _Color; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = (_Color * texture2D (_MainTex, gl_TexCoord[0].xy)); + vec4 tmpvar_2; + tmpvar_2.xyz = ((2.0 * textureCube (_ToonShade, gl_TexCoord[1].xyz).xyz) * tmpvar_1.xyz); + tmpvar_2.w = tmpvar_1.w; + gl_FragData[0] = tmpvar_2; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Toon_Lighted-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Toon_Lighted-in.txt new file mode 100644 index 000000000..e302d18a9 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Toon_Lighted-in.txt @@ -0,0 +1,95 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 normal; + vec3 lightDir; + vec2 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _Color; +uniform vec4 _LightColor0; +uniform sampler2D _LightTexture0; +uniform sampler2D _MainTex; +uniform sampler2D _Ramp; +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingToonRamp( in SurfaceOutput s, in vec3 lightDir, in float atten ); +vec4 frag_surf( in v2f_surf IN ); +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 c; + c = (texture2D( _MainTex, IN.uv_MainTex) * _Color); + o.Albedo = c.xyz ; + o.Alpha = c.w ; +} +vec4 LightingToonRamp( in SurfaceOutput s, in vec3 lightDir, in float atten ) { + float d; + vec3 ramp; + vec4 c; + d = ((dot( s.Normal, lightDir) * 0.500000) + 0.500000); + ramp = texture2D( _Ramp, vec2( d, d)).xyz ; + c.xyz = (((s.Albedo * _LightColor0.xyz ) * ramp) * (atten * 2.00000)); + c.w = 0.000000; + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec3 lightDir; + vec4 c; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + o.Normal = IN.normal; + surf( surfIN, o); + lightDir = IN.lightDir; + c = LightingToonRamp( o, lightDir, (texture2D( _LightTexture0, IN._LightCoord).w * 1.00000)); + c.w = 0.000000; + return c; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec2( gl_TexCoord[0]); + xlt_IN.normal = vec3( gl_TexCoord[1]); + xlt_IN.lightDir = vec3( gl_TexCoord[2]); + xlt_IN._LightCoord = vec2( gl_TexCoord[3]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Toon_Lighted-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Toon_Lighted-ir.txt new file mode 100644 index 000000000..a7210dece --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Toon_Lighted-ir.txt @@ -0,0 +1,163 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 normal; + vec3 lightDir; + vec2 _LightCoord; +}; +varying vec4 xlv_FOG; +uniform sampler2D _Ramp; +uniform sampler2D _MainTex; +uniform sampler2D _LightTexture0; +uniform vec4 _LightColor0; +uniform vec4 _Color; +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 c; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = (tmpvar_1 * _Color); + c = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = c.xyz; + o.Albedo = tmpvar_3; + float tmpvar_4; + tmpvar_4 = c.w; + o.Alpha = tmpvar_4; +} + +vec4 LightingToonRamp ( + in SurfaceOutput s, + in vec3 lightDir, + in float atten +) +{ + vec4 c; + vec3 ramp; + float d; + float tmpvar_1; + tmpvar_1 = dot (s.Normal, lightDir); + float tmpvar_2; + tmpvar_2 = ((tmpvar_1 * 0.5) + 0.5); + d = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3.x = d; + tmpvar_3.y = d; + vec4 tmpvar_4; + tmpvar_4 = texture2D (_Ramp, tmpvar_3); + vec3 tmpvar_5; + tmpvar_5 = tmpvar_4.xyz; + ramp = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = (((s.Albedo * _LightColor0.xyz) * ramp) * (atten * 2.0)); + c.xyz = tmpvar_6.xyz.xyz; + float tmpvar_7; + tmpvar_7 = 0.0; + c.w = vec4(tmpvar_7).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 c; + vec3 lightDir; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_3; + float tmpvar_4; + tmpvar_4 = 0.0; + o.Specular = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Alpha = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Gloss = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = IN.normal; + o.Normal = tmpvar_7; + surf (surfIN, o); + vec3 tmpvar_8; + tmpvar_8 = IN.lightDir; + lightDir = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = texture2D (_LightTexture0, IN._LightCoord); + vec4 tmpvar_10; + tmpvar_10 = LightingToonRamp (o, lightDir, (tmpvar_9.w * 1.0)); + vec4 tmpvar_11; + tmpvar_11 = tmpvar_10; + c = tmpvar_11; + float tmpvar_12; + tmpvar_12 = 0.0; + c.w = vec4(tmpvar_12).w; + return c; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xy; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.normal = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.lightDir = tmpvar_8; + vec2 tmpvar_9; + tmpvar_9 = gl_TexCoord[3].xy; + vec2 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_IN._LightCoord = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = frag_surf (xlt_IN); + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xl_retval = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = xl_retval.xyzw; + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + gl_FragData[0] = tmpvar_14; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Toon_Lighted-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Toon_Lighted-out.txt new file mode 100644 index 000000000..12ec0a75c --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Toon_Lighted-out.txt @@ -0,0 +1,21 @@ +uniform sampler2D _Ramp; +uniform sampler2D _MainTex; +uniform sampler2D _LightTexture0; +uniform vec4 _LightColor0; +uniform vec4 _Color; +void main () +{ + vec4 c; + vec4 c_i0_i1; + float tmpvar_1; + tmpvar_1 = ((dot (gl_TexCoord[1].xyz, gl_TexCoord[2].xyz) * 0.5) + 0.5); + vec2 tmpvar_2; + tmpvar_2.x = tmpvar_1; + tmpvar_2.y = tmpvar_1; + c_i0_i1.xyz = ((((texture2D (_MainTex, gl_TexCoord[0].xy) * _Color).xyz * _LightColor0.xyz) * texture2D (_Ramp, tmpvar_2).xyz) * (texture2D (_LightTexture0, gl_TexCoord[3].xy).w * 2.0)); + c_i0_i1.w = 0.0; + c = c_i0_i1; + c.w = 0.0; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Bumped_Specular-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Bumped_Specular-in.txt new file mode 100644 index 000000000..6306de8d9 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Bumped_Specular-in.txt @@ -0,0 +1,114 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 lightDir; + vec3 viewDir; + vec3 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform sampler2D _BumpMap; +uniform vec4 _Color; +uniform vec4 _LightColor0; +uniform samplerCube _LightTexture0; +uniform sampler2D _LightTextureB0; +uniform sampler2D _MainTex; +uniform float _Shininess; +uniform vec4 _SpecColor; +vec4 UnpackNormal( in vec4 packednormal ); +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingBlinnPhong( in SurfaceOutput s, in vec3 lightDir, in vec3 viewDir, in float atten ); +vec4 frag_surf( in v2f_surf IN ); +vec4 UnpackNormal( in vec4 packednormal ) { + vec4 normal; + normal.xy = ((packednormal.wy * 2.00000) - 1.00000); + normal.z = sqrt( ((1.00000 - (normal.x * normal.x )) - (normal.y * normal.y )) ); + return normal; +} +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 tex; + tex = texture2D( _MainTex, IN.uv_MainTex); + o.Albedo = (tex.xyz * _Color.xyz ); + o.Gloss = tex.w ; + o.Alpha = (tex.w * _Color.w ); + o.Specular = _Shininess; + o.Normal = vec3( UnpackNormal( texture2D( _BumpMap, IN.uv_BumpMap))); +} +vec4 LightingBlinnPhong( in SurfaceOutput s, in vec3 lightDir, in vec3 viewDir, in float atten ) { + vec3 h; + float diff; + float nh; + float spec; + vec4 c; + h = normalize( (lightDir + viewDir) ); + diff = max( 0.000000, dot( s.Normal, lightDir)); + nh = max( 0.000000, dot( s.Normal, h)); + spec = (pow( nh, (s.Specular * 128.000)) * s.Gloss); + c.xyz = ((((s.Albedo * _LightColor0.xyz ) * diff) + ((_LightColor0.xyz * _SpecColor.xyz ) * spec)) * (atten * 2.00000)); + c.w = (s.Alpha + (((_LightColor0.w * _SpecColor.w ) * spec) * atten)); + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec3 lightDir; + vec4 c; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + surfIN.uv_BumpMap = IN.hip_pack0.zw ; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + surf( surfIN, o); + lightDir = IN.lightDir; + lightDir = normalize( lightDir ); + c = LightingBlinnPhong( o, lightDir, normalize( vec3( IN.viewDir) ), (texture2D( _LightTextureB0, vec2( vec2( dot( IN._LightCoord, IN._LightCoord)))).w * textureCube( _LightTexture0, IN._LightCoord).w )); + c.w = o.Alpha; + return c; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec4( gl_TexCoord[0]); + xlt_IN.lightDir = vec3( gl_TexCoord[1]); + xlt_IN.viewDir = vec3( gl_TexCoord[2]); + xlt_IN._LightCoord = vec3( gl_TexCoord[3]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Bumped_Specular-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Bumped_Specular-ir.txt new file mode 100644 index 000000000..6d4b111a3 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Bumped_Specular-ir.txt @@ -0,0 +1,229 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 lightDir; + vec3 viewDir; + vec3 _LightCoord; +}; +varying vec4 xlv_FOG; +uniform vec4 _SpecColor; +uniform float _Shininess; +uniform sampler2D _MainTex; +uniform sampler2D _LightTextureB0; +uniform samplerCube _LightTexture0; +uniform vec4 _LightColor0; +uniform vec4 _Color; +uniform sampler2D _BumpMap; +vec4 UnpackNormal ( + in vec4 packednormal +) +{ + vec4 normal; + vec2 tmpvar_1; + tmpvar_1 = ((packednormal.wy * 2.0) - 1.0); + normal.xy = tmpvar_1.xy.xy; + float tmpvar_2; + tmpvar_2 = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + normal.z = vec3(tmpvar_3).z; + return normal; +} + +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 tex; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + tex = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = (tex.xyz * _Color.xyz); + o.Albedo = tmpvar_3; + float tmpvar_4; + tmpvar_4 = tex.w; + o.Gloss = tmpvar_4; + float tmpvar_5; + tmpvar_5 = (tex.w * _Color.w); + o.Alpha = tmpvar_5; + float tmpvar_6; + tmpvar_6 = _Shininess; + o.Specular = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = texture2D (_BumpMap, IN.uv_BumpMap); + vec4 tmpvar_8; + tmpvar_8 = UnpackNormal (tmpvar_7); + vec3 tmpvar_9; + tmpvar_9 = tmpvar_8.xyz; + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + o.Normal = tmpvar_10; +} + +vec4 LightingBlinnPhong ( + in SurfaceOutput s, + in vec3 lightDir, + in vec3 viewDir, + in float atten +) +{ + vec4 c; + float spec; + float nh; + float diff; + vec3 h; + vec3 tmpvar_1; + tmpvar_1 = normalize ((lightDir + viewDir)); + vec3 tmpvar_2; + tmpvar_2 = tmpvar_1; + h = tmpvar_2; + float tmpvar_3; + tmpvar_3 = dot (s.Normal, lightDir); + float tmpvar_4; + tmpvar_4 = max (0.0, tmpvar_3); + float tmpvar_5; + tmpvar_5 = tmpvar_4; + diff = tmpvar_5; + float tmpvar_6; + tmpvar_6 = dot (s.Normal, h); + float tmpvar_7; + tmpvar_7 = max (0.0, tmpvar_6); + float tmpvar_8; + tmpvar_8 = tmpvar_7; + nh = tmpvar_8; + float tmpvar_9; + tmpvar_9 = pow (nh, (s.Specular * 128.0)); + float tmpvar_10; + tmpvar_10 = (tmpvar_9 * s.Gloss); + spec = tmpvar_10; + vec3 tmpvar_11; + tmpvar_11 = ((((s.Albedo * _LightColor0.xyz) * diff) + ((_LightColor0.xyz * _SpecColor.xyz) * spec)) * (atten * 2.0)); + c.xyz = tmpvar_11.xyz.xyz; + float tmpvar_12; + tmpvar_12 = (s.Alpha + (((_LightColor0.w * _SpecColor.w) * spec) * atten)); + c.w = vec4(tmpvar_12).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 c; + vec3 lightDir; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = IN.hip_pack0.zw; + surfIN.uv_BumpMap = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Specular = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Alpha = tmpvar_6; + float tmpvar_7; + tmpvar_7 = 0.0; + o.Gloss = tmpvar_7; + surf (surfIN, o); + vec3 tmpvar_8; + tmpvar_8 = IN.lightDir; + lightDir = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = normalize (lightDir); + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + lightDir = tmpvar_10; + vec3 tmpvar_11; + tmpvar_11 = IN.viewDir.xyz; + vec3 tmpvar_12; + tmpvar_12 = normalize (tmpvar_11); + float tmpvar_13; + tmpvar_13 = dot (IN._LightCoord, IN._LightCoord); + vec2 tmpvar_14; + tmpvar_14 = vec2(tmpvar_13); + vec2 tmpvar_15; + tmpvar_15 = tmpvar_14.xy; + vec4 tmpvar_16; + tmpvar_16 = texture2D (_LightTextureB0, tmpvar_15); + vec4 tmpvar_17; + tmpvar_17 = textureCube (_LightTexture0, IN._LightCoord); + vec4 tmpvar_18; + tmpvar_18 = LightingBlinnPhong (o, lightDir, tmpvar_12, (tmpvar_16.w * tmpvar_17.w)); + vec4 tmpvar_19; + tmpvar_19 = tmpvar_18; + c = tmpvar_19; + float tmpvar_20; + tmpvar_20 = o.Alpha; + c.w = vec4(tmpvar_20).w; + return c; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.lightDir = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.viewDir = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = gl_TexCoord[3].xyz; + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_IN._LightCoord = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = frag_surf (xlt_IN); + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xl_retval = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = xl_retval.xyzw; + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + gl_FragData[0] = tmpvar_14; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Bumped_Specular-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Bumped_Specular-out.txt new file mode 100644 index 000000000..051726245 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Bumped_Specular-out.txt @@ -0,0 +1,38 @@ +uniform vec4 _SpecColor; +uniform float _Shininess; +uniform sampler2D _MainTex; +uniform sampler2D _LightTextureB0; +uniform samplerCube _LightTexture0; +uniform vec4 _LightColor0; +uniform vec4 _Color; +uniform sampler2D _BumpMap; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = gl_TexCoord[0]; + vec3 tmpvar_2; + tmpvar_2 = gl_TexCoord[3].xyz; + vec4 c; + vec4 tmpvar_3; + tmpvar_3 = texture2D (_MainTex, tmpvar_1.xy); + float tmpvar_4; + tmpvar_4 = (tmpvar_3.w * _Color.w); + vec4 normal; + normal.xy = ((texture2D (_BumpMap, tmpvar_1.zw).wy * 2.0) - 1.0); + normal.z = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + vec3 tmpvar_5; + tmpvar_5 = normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = normalize (gl_TexCoord[1].xyz); + float atten; + atten = (texture2D (_LightTextureB0, vec2(dot (tmpvar_2, tmpvar_2))).w * textureCube (_LightTexture0, tmpvar_2).w); + vec4 c_i0; + float tmpvar_7; + tmpvar_7 = (pow (max (0.0, dot (tmpvar_5, normalize ((tmpvar_6 + normalize (gl_TexCoord[2].xyz))))), (_Shininess * 128.0)) * tmpvar_3.w); + c_i0.xyz = (((((tmpvar_3.xyz * _Color.xyz) * _LightColor0.xyz) * max (0.0, dot (tmpvar_5, tmpvar_6))) + ((_LightColor0.xyz * _SpecColor.xyz) * tmpvar_7)) * (atten * 2.0)); + c_i0.w = (tmpvar_4 + (((_LightColor0.w * _SpecColor.w) * tmpvar_7) * atten)); + c = c_i0; + c.w = tmpvar_4; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Cutout_Bumped_Diffuse-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Cutout_Bumped_Diffuse-in.txt new file mode 100644 index 000000000..4e2fc1660 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Cutout_Bumped_Diffuse-in.txt @@ -0,0 +1,102 @@ +void xll_clip(float x) { + if ( x<0.0 ) discard; +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 lightDir; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform sampler2D _BumpMap; +uniform vec4 _Color; +uniform float _Cutoff; +uniform vec4 _LightColor0; +uniform sampler2D _MainTex; +vec4 UnpackNormal( in vec4 packednormal ); +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ); +vec4 frag_surf( in v2f_surf IN ); +vec4 UnpackNormal( in vec4 packednormal ) { + vec4 normal; + normal.xy = ((packednormal.wy * 2.00000) - 1.00000); + normal.z = sqrt( ((1.00000 - (normal.x * normal.x )) - (normal.y * normal.y )) ); + return normal; +} +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 c; + c = (texture2D( _MainTex, IN.uv_MainTex) * _Color); + o.Albedo = c.xyz ; + o.Alpha = c.w ; + o.Normal = vec3( UnpackNormal( texture2D( _BumpMap, IN.uv_BumpMap))); +} +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ) { + float diff; + vec4 c; + diff = max( 0.000000, dot( s.Normal, lightDir)); + c.xyz = ((s.Albedo * _LightColor0.xyz ) * ((diff * atten) * 2.00000)); + c.w = s.Alpha; + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec3 lightDir; + vec4 c; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + surfIN.uv_BumpMap = IN.hip_pack0.zw ; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + surf( surfIN, o); + xll_clip( (o.Alpha - _Cutoff) ); + lightDir = IN.lightDir; + c = LightingLambert( o, lightDir, 1.00000); + c.w = o.Alpha; + return c; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec4( gl_TexCoord[0]); + xlt_IN.lightDir = vec3( gl_TexCoord[1]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Cutout_Bumped_Diffuse-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Cutout_Bumped_Diffuse-ir.txt new file mode 100644 index 000000000..e1024c12f --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Cutout_Bumped_Diffuse-ir.txt @@ -0,0 +1,178 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 lightDir; +}; +varying vec4 xlv_FOG; +uniform sampler2D _MainTex; +uniform vec4 _LightColor0; +uniform float _Cutoff; +uniform vec4 _Color; +uniform sampler2D _BumpMap; +void xll_clip ( + in float x +) +{ + if ((x < 0.0)) { + discard; + }; +} + +vec4 UnpackNormal ( + in vec4 packednormal +) +{ + vec4 normal; + vec2 tmpvar_1; + tmpvar_1 = ((packednormal.wy * 2.0) - 1.0); + normal.xy = tmpvar_1.xy.xy; + float tmpvar_2; + tmpvar_2 = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + normal.z = vec3(tmpvar_3).z; + return normal; +} + +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 c; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = (tmpvar_1 * _Color); + c = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = c.xyz; + o.Albedo = tmpvar_3; + float tmpvar_4; + tmpvar_4 = c.w; + o.Alpha = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = texture2D (_BumpMap, IN.uv_BumpMap); + vec4 tmpvar_6; + tmpvar_6 = UnpackNormal (tmpvar_5); + vec3 tmpvar_7; + tmpvar_7 = tmpvar_6.xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + o.Normal = tmpvar_8; +} + +vec4 LightingLambert ( + in SurfaceOutput s, + in vec3 lightDir, + in float atten +) +{ + vec4 c; + float diff; + float tmpvar_1; + tmpvar_1 = dot (s.Normal, lightDir); + float tmpvar_2; + tmpvar_2 = max (0.0, tmpvar_1); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + diff = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = ((s.Albedo * _LightColor0.xyz) * ((diff * atten) * 2.0)); + c.xyz = tmpvar_4.xyz.xyz; + float tmpvar_5; + tmpvar_5 = s.Alpha; + c.w = vec4(tmpvar_5).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 c; + vec3 lightDir; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = IN.hip_pack0.zw; + surfIN.uv_BumpMap = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Specular = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Alpha = tmpvar_6; + float tmpvar_7; + tmpvar_7 = 0.0; + o.Gloss = tmpvar_7; + surf (surfIN, o); + xll_clip ((o.Alpha - _Cutoff)); + vec3 tmpvar_8; + tmpvar_8 = IN.lightDir; + lightDir = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = LightingLambert (o, lightDir, 1.0); + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + c = tmpvar_10; + float tmpvar_11; + tmpvar_11 = o.Alpha; + c.w = vec4(tmpvar_11).w; + return c; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.lightDir = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = frag_surf (xlt_IN); + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xl_retval = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = xl_retval.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + gl_FragData[0] = tmpvar_10; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Cutout_Bumped_Diffuse-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Cutout_Bumped_Diffuse-out.txt new file mode 100644 index 000000000..faea0a619 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Cutout_Bumped_Diffuse-out.txt @@ -0,0 +1,32 @@ +uniform sampler2D _MainTex; +uniform vec4 _LightColor0; +uniform float _Cutoff; +uniform vec4 _Color; +uniform sampler2D _BumpMap; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = gl_TexCoord[0]; + vec3 tmpvar_2; + tmpvar_2 = gl_TexCoord[1].xyz; + vec4 c; + vec4 tmpvar_3; + tmpvar_3 = (texture2D (_MainTex, tmpvar_1.xy) * _Color); + vec4 normal; + normal.xy = ((texture2D (_BumpMap, tmpvar_1.zw).wy * 2.0) - 1.0); + normal.z = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + vec3 tmpvar_4; + tmpvar_4 = normal.xyz; + float x; + x = (tmpvar_3.w - _Cutoff); + if ((x < 0.0)) { + discard; + }; + vec4 c_i0_i1; + c_i0_i1.xyz = ((tmpvar_3.xyz * _LightColor0.xyz) * (max (0.0, dot (tmpvar_4, tmpvar_2)) * 2.0)); + c_i0_i1.w = tmpvar_3.w; + c = c_i0_i1; + c.w = tmpvar_3.w; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Cutout_Bumped_Diffuse1-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Cutout_Bumped_Diffuse1-in.txt new file mode 100644 index 000000000..43ee94fa4 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Cutout_Bumped_Diffuse1-in.txt @@ -0,0 +1,101 @@ +void xll_clip(float x) { + if ( x<0.0 ) discard; +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 hip_screen; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform sampler2D _BumpMap; +uniform vec4 _Color; +uniform float _Cutoff; +uniform sampler2D _LightBuffer; +uniform sampler2D _MainTex; +uniform vec4 unity_Ambient; +vec4 UnpackNormal( in vec4 packednormal ); +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingLambert_PrePass( in SurfaceOutput s, in vec4 light ); +vec4 frag_surf( in v2f_surf IN ); +vec4 UnpackNormal( in vec4 packednormal ) { + vec4 normal; + normal.xy = ((packednormal.wy * 2.00000) - 1.00000); + normal.z = sqrt( ((1.00000 - (normal.x * normal.x )) - (normal.y * normal.y )) ); + return normal; +} +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 c; + c = (texture2D( _MainTex, IN.uv_MainTex) * _Color); + o.Albedo = c.xyz ; + o.Alpha = c.w ; + o.Normal = vec3( UnpackNormal( texture2D( _BumpMap, IN.uv_BumpMap))); +} +vec4 LightingLambert_PrePass( in SurfaceOutput s, in vec4 light ) { + vec4 c; + c.xyz = (s.Albedo * light.xyz ); + c.w = s.Alpha; + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec4 light; + vec4 col; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + surf( surfIN, o); + xll_clip( (o.Alpha - _Cutoff) ); + light = texture2DProj( _LightBuffer, IN.hip_screen); + light = ( -log2( light ) ); + light.xyz += unity_Ambient.xyz ; + col = LightingLambert_PrePass( o, light); + return col; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec2( gl_TexCoord[0]); + xlt_IN.hip_screen = vec4( gl_TexCoord[1]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Cutout_Bumped_Diffuse1-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Cutout_Bumped_Diffuse1-ir.txt new file mode 100644 index 000000000..48026d700 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Cutout_Bumped_Diffuse1-ir.txt @@ -0,0 +1,174 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 hip_screen; +}; +varying vec4 xlv_FOG; +uniform vec4 unity_Ambient; +uniform sampler2D _MainTex; +uniform sampler2D _LightBuffer; +uniform float _Cutoff; +uniform vec4 _Color; +uniform sampler2D _BumpMap; +void xll_clip ( + in float x +) +{ + if ((x < 0.0)) { + discard; + }; +} + +vec4 UnpackNormal ( + in vec4 packednormal +) +{ + vec4 normal; + vec2 tmpvar_1; + tmpvar_1 = ((packednormal.wy * 2.0) - 1.0); + normal.xy = tmpvar_1.xy.xy; + float tmpvar_2; + tmpvar_2 = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + normal.z = vec3(tmpvar_3).z; + return normal; +} + +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 c; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = (tmpvar_1 * _Color); + c = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = c.xyz; + o.Albedo = tmpvar_3; + float tmpvar_4; + tmpvar_4 = c.w; + o.Alpha = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = texture2D (_BumpMap, IN.uv_BumpMap); + vec4 tmpvar_6; + tmpvar_6 = UnpackNormal (tmpvar_5); + vec3 tmpvar_7; + tmpvar_7 = tmpvar_6.xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + o.Normal = tmpvar_8; +} + +vec4 LightingLambert_PrePass ( + in SurfaceOutput s, + in vec4 light +) +{ + vec4 c; + vec3 tmpvar_1; + tmpvar_1 = (s.Albedo * light.xyz); + c.xyz = tmpvar_1.xyz.xyz; + float tmpvar_2; + tmpvar_2 = s.Alpha; + c.w = vec4(tmpvar_2).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 col; + vec4 light; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_3; + float tmpvar_4; + tmpvar_4 = 0.0; + o.Specular = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Alpha = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Gloss = tmpvar_6; + surf (surfIN, o); + xll_clip ((o.Alpha - _Cutoff)); + vec4 tmpvar_7; + tmpvar_7 = texture2DProj (_LightBuffer, IN.hip_screen); + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + light = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = log2 (light); + vec4 tmpvar_10; + tmpvar_10 = -(tmpvar_9); + light = tmpvar_10; + vec3 tmpvar_11; + tmpvar_11 = (light.xyz + unity_Ambient.xyz); + light.xyz = tmpvar_11.xyz.xyz; + vec4 tmpvar_12; + tmpvar_12 = LightingLambert_PrePass (o, light); + vec4 tmpvar_13; + tmpvar_13 = tmpvar_12; + col = tmpvar_13; + return col; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xy; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyzw; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.hip_screen = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = frag_surf (xlt_IN); + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xl_retval = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = xl_retval.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + gl_FragData[0] = tmpvar_10; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Cutout_Bumped_Diffuse1-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Cutout_Bumped_Diffuse1-out.txt new file mode 100644 index 000000000..5a5790522 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Cutout_Bumped_Diffuse1-out.txt @@ -0,0 +1,32 @@ +uniform vec4 unity_Ambient; +uniform sampler2D _MainTex; +uniform sampler2D _LightBuffer; +uniform float _Cutoff; +uniform vec4 _Color; +uniform sampler2D _BumpMap; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = gl_TexCoord[1]; + vec4 light; + vec2 tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = (texture2D (_MainTex, gl_TexCoord[0].xy) * _Color); + vec4 normal; + normal.xy = ((texture2D (_BumpMap, tmpvar_2).wy * 2.0) - 1.0); + normal.z = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + float x; + x = (tmpvar_3.w - _Cutoff); + if ((x < 0.0)) { + discard; + }; + vec4 tmpvar_4; + tmpvar_4 = -(log2 (texture2DProj (_LightBuffer, tmpvar_1))); + light = tmpvar_4; + light.xyz = (tmpvar_4.xyz + unity_Ambient.xyz); + vec4 c_i0; + c_i0.xyz = (tmpvar_3.xyz * light.xyz); + c_i0.w = tmpvar_3.w; + gl_FragData[0] = c_i0; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Cutout_Bumped_Specular-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Cutout_Bumped_Specular-in.txt new file mode 100644 index 000000000..7c46c068f --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Cutout_Bumped_Specular-in.txt @@ -0,0 +1,99 @@ +void xll_clip(float x) { + if ( x<0.0 ) discard; +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; +}; +struct v2f_surf { + vec4 pos; + vec4 hip_pack0; + vec3 TtoV0; + vec3 TtoV1; + vec3 TtoV2; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform sampler2D _BumpMap; +uniform vec4 _Color; +uniform float _Cutoff; +uniform sampler2D _MainTex; +uniform float _Shininess; +vec4 UnpackNormal( in vec4 packednormal ); +void surf( in Input IN, inout SurfaceOutput o ); +vec4 frag_surf( in v2f_surf IN ); +vec4 UnpackNormal( in vec4 packednormal ) { + vec4 normal; + normal.xy = ((packednormal.wy * 2.00000) - 1.00000); + normal.z = sqrt( ((1.00000 - (normal.x * normal.x )) - (normal.y * normal.y )) ); + return normal; +} +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 tex; + tex = texture2D( _MainTex, IN.uv_MainTex); + o.Albedo = (tex.xyz * _Color.xyz ); + o.Gloss = tex.w ; + o.Alpha = (tex.w * _Color.w ); + o.Specular = _Shininess; + o.Normal = vec3( UnpackNormal( texture2D( _BumpMap, IN.uv_BumpMap))); +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec3 viewN; + vec4 res; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + surfIN.uv_BumpMap = IN.hip_pack0.zw ; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + surf( surfIN, o); + xll_clip( (o.Alpha - _Cutoff) ); + viewN.x = dot( IN.TtoV0, o.Normal); + viewN.y = dot( IN.TtoV1, o.Normal); + viewN.z = dot( IN.TtoV2, o.Normal); + o.Normal = viewN; + res.xyz = ((o.Normal * vec3( 0.500000, 0.500000, -0.500000)) + 0.500000); + res.w = o.Specular; + return res; +} +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.hip_pack0 = vec4( gl_TexCoord[0]); + xlt_IN.TtoV0 = vec3( gl_TexCoord[1]); + xlt_IN.TtoV1 = vec3( gl_TexCoord[2]); + xlt_IN.TtoV2 = vec3( gl_TexCoord[3]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Cutout_Bumped_Specular-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Cutout_Bumped_Specular-ir.txt new file mode 100644 index 000000000..1815a29f1 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Cutout_Bumped_Specular-ir.txt @@ -0,0 +1,180 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; +}; +struct v2f_surf { + vec4 pos; + vec4 hip_pack0; + vec3 TtoV0; + vec3 TtoV1; + vec3 TtoV2; +}; +uniform float _Shininess; +uniform sampler2D _MainTex; +uniform float _Cutoff; +uniform vec4 _Color; +uniform sampler2D _BumpMap; +void xll_clip ( + in float x +) +{ + if ((x < 0.0)) { + discard; + }; +} + +vec4 UnpackNormal ( + in vec4 packednormal +) +{ + vec4 normal; + vec2 tmpvar_1; + tmpvar_1 = ((packednormal.wy * 2.0) - 1.0); + normal.xy = tmpvar_1.xy.xy; + float tmpvar_2; + tmpvar_2 = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + normal.z = vec3(tmpvar_3).z; + return normal; +} + +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 tex; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + tex = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = (tex.xyz * _Color.xyz); + o.Albedo = tmpvar_3; + float tmpvar_4; + tmpvar_4 = tex.w; + o.Gloss = tmpvar_4; + float tmpvar_5; + tmpvar_5 = (tex.w * _Color.w); + o.Alpha = tmpvar_5; + float tmpvar_6; + tmpvar_6 = _Shininess; + o.Specular = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = texture2D (_BumpMap, IN.uv_BumpMap); + vec4 tmpvar_8; + tmpvar_8 = UnpackNormal (tmpvar_7); + vec3 tmpvar_9; + tmpvar_9 = tmpvar_8.xyz; + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + o.Normal = tmpvar_10; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 res; + vec3 viewN; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = IN.hip_pack0.zw; + surfIN.uv_BumpMap = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Specular = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Alpha = tmpvar_6; + float tmpvar_7; + tmpvar_7 = 0.0; + o.Gloss = tmpvar_7; + surf (surfIN, o); + xll_clip ((o.Alpha - _Cutoff)); + float tmpvar_8; + tmpvar_8 = dot (IN.TtoV0, o.Normal); + float tmpvar_9; + tmpvar_9 = tmpvar_8; + viewN.x = tmpvar_9; + float tmpvar_10; + tmpvar_10 = dot (IN.TtoV1, o.Normal); + float tmpvar_11; + tmpvar_11 = tmpvar_10; + viewN.y = vec2(tmpvar_11).y; + float tmpvar_12; + tmpvar_12 = dot (IN.TtoV2, o.Normal); + float tmpvar_13; + tmpvar_13 = tmpvar_12; + viewN.z = vec3(tmpvar_13).z; + vec3 tmpvar_14; + tmpvar_14 = viewN; + o.Normal = tmpvar_14; + vec3 tmpvar_15; + tmpvar_15 = ((o.Normal * vec3(0.5, 0.5, -0.5)) + 0.5); + res.xyz = tmpvar_15.xyz.xyz; + float tmpvar_16; + tmpvar_16 = o.Specular; + res.w = vec4(tmpvar_16).w; + return res; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = gl_TexCoord[0].xyzw; + vec4 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_IN.hip_pack0 = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = gl_TexCoord[1].xyz; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_4; + xlt_IN.TtoV0 = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = gl_TexCoord[2].xyz; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_6; + xlt_IN.TtoV1 = tmpvar_7; + vec3 tmpvar_8; + tmpvar_8 = gl_TexCoord[3].xyz; + vec3 tmpvar_9; + tmpvar_9 = tmpvar_8; + xlt_IN.TtoV2 = tmpvar_9; + vec4 tmpvar_10; + tmpvar_10 = frag_surf (xlt_IN); + vec4 tmpvar_11; + tmpvar_11 = tmpvar_10; + xl_retval = tmpvar_11; + vec4 tmpvar_12; + tmpvar_12 = xl_retval.xyzw; + vec4 tmpvar_13; + tmpvar_13 = tmpvar_12; + gl_FragData[0] = tmpvar_13; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Cutout_Bumped_Specular-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Cutout_Bumped_Specular-out.txt new file mode 100644 index 000000000..16f359b20 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Cutout_Bumped_Specular-out.txt @@ -0,0 +1,35 @@ +uniform float _Shininess; +uniform sampler2D _MainTex; +uniform float _Cutoff; +uniform vec4 _Color; +uniform sampler2D _BumpMap; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = gl_TexCoord[0]; + vec3 tmpvar_2; + tmpvar_2 = gl_TexCoord[1].xyz; + vec3 tmpvar_3; + tmpvar_3 = gl_TexCoord[2].xyz; + vec3 tmpvar_4; + tmpvar_4 = gl_TexCoord[3].xyz; + vec4 res; + vec3 viewN; + vec4 normal; + normal.xy = ((texture2D (_BumpMap, tmpvar_1.zw).wy * 2.0) - 1.0); + normal.z = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + vec3 tmpvar_5; + tmpvar_5 = normal.xyz; + float x; + x = ((texture2D (_MainTex, tmpvar_1.xy).w * _Color.w) - _Cutoff); + if ((x < 0.0)) { + discard; + }; + viewN.x = dot (tmpvar_2, tmpvar_5); + viewN.y = dot (tmpvar_3, tmpvar_5); + viewN.z = dot (tmpvar_4, tmpvar_5); + res.xyz = ((viewN * vec3(0.5, 0.5, -0.5)) + 0.5); + res.w = _Shininess; + gl_FragData[0] = res; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Cutout_Bumped_Specular1-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Cutout_Bumped_Specular1-in.txt new file mode 100644 index 000000000..4b96e3b82 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Cutout_Bumped_Specular1-in.txt @@ -0,0 +1,107 @@ +void xll_clip(float x) { + if ( x<0.0 ) discard; +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 hip_screen; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform sampler2D _BumpMap; +uniform vec4 _Color; +uniform float _Cutoff; +uniform sampler2D _LightBuffer; +uniform sampler2D _MainTex; +uniform float _Shininess; +uniform vec4 _SpecColor; +uniform vec4 unity_Ambient; +vec4 UnpackNormal( in vec4 packednormal ); +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingBlinnPhong_PrePass( in SurfaceOutput s, in vec4 light ); +vec4 frag_surf( in v2f_surf IN ); +vec4 UnpackNormal( in vec4 packednormal ) { + vec4 normal; + normal.xy = ((packednormal.wy * 2.00000) - 1.00000); + normal.z = sqrt( ((1.00000 - (normal.x * normal.x )) - (normal.y * normal.y )) ); + return normal; +} +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 tex; + tex = texture2D( _MainTex, IN.uv_MainTex); + o.Albedo = (tex.xyz * _Color.xyz ); + o.Gloss = tex.w ; + o.Alpha = (tex.w * _Color.w ); + o.Specular = _Shininess; + o.Normal = vec3( UnpackNormal( texture2D( _BumpMap, IN.uv_BumpMap))); +} +vec4 LightingBlinnPhong_PrePass( in SurfaceOutput s, in vec4 light ) { + float spec; + vec4 c; + spec = (light.w * s.Gloss); + c.xyz = ((s.Albedo * light.xyz ) + ((light.xyz * _SpecColor.xyz ) * spec)); + c.w = (s.Alpha + (spec * _SpecColor.w )); + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec4 light; + vec4 col; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + surf( surfIN, o); + xll_clip( (o.Alpha - _Cutoff) ); + light = texture2DProj( _LightBuffer, IN.hip_screen); + light = ( -log2( light ) ); + light.xyz += unity_Ambient.xyz ; + col = LightingBlinnPhong_PrePass( o, light); + return col; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec2( gl_TexCoord[0]); + xlt_IN.hip_screen = vec4( gl_TexCoord[1]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Cutout_Bumped_Specular1-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Cutout_Bumped_Specular1-ir.txt new file mode 100644 index 000000000..3f37d51ac --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Cutout_Bumped_Specular1-ir.txt @@ -0,0 +1,186 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 hip_screen; +}; +varying vec4 xlv_FOG; +uniform vec4 unity_Ambient; +uniform vec4 _SpecColor; +uniform float _Shininess; +uniform sampler2D _MainTex; +uniform sampler2D _LightBuffer; +uniform float _Cutoff; +uniform vec4 _Color; +uniform sampler2D _BumpMap; +void xll_clip ( + in float x +) +{ + if ((x < 0.0)) { + discard; + }; +} + +vec4 UnpackNormal ( + in vec4 packednormal +) +{ + vec4 normal; + vec2 tmpvar_1; + tmpvar_1 = ((packednormal.wy * 2.0) - 1.0); + normal.xy = tmpvar_1.xy.xy; + float tmpvar_2; + tmpvar_2 = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + normal.z = vec3(tmpvar_3).z; + return normal; +} + +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 tex; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + tex = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = (tex.xyz * _Color.xyz); + o.Albedo = tmpvar_3; + float tmpvar_4; + tmpvar_4 = tex.w; + o.Gloss = tmpvar_4; + float tmpvar_5; + tmpvar_5 = (tex.w * _Color.w); + o.Alpha = tmpvar_5; + float tmpvar_6; + tmpvar_6 = _Shininess; + o.Specular = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = texture2D (_BumpMap, IN.uv_BumpMap); + vec4 tmpvar_8; + tmpvar_8 = UnpackNormal (tmpvar_7); + vec3 tmpvar_9; + tmpvar_9 = tmpvar_8.xyz; + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + o.Normal = tmpvar_10; +} + +vec4 LightingBlinnPhong_PrePass ( + in SurfaceOutput s, + in vec4 light +) +{ + vec4 c; + float spec; + float tmpvar_1; + tmpvar_1 = (light.w * s.Gloss); + spec = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = ((s.Albedo * light.xyz) + ((light.xyz * _SpecColor.xyz) * spec)); + c.xyz = tmpvar_2.xyz.xyz; + float tmpvar_3; + tmpvar_3 = (s.Alpha + (spec * _SpecColor.w)); + c.w = vec4(tmpvar_3).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 col; + vec4 light; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_3; + float tmpvar_4; + tmpvar_4 = 0.0; + o.Specular = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Alpha = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Gloss = tmpvar_6; + surf (surfIN, o); + xll_clip ((o.Alpha - _Cutoff)); + vec4 tmpvar_7; + tmpvar_7 = texture2DProj (_LightBuffer, IN.hip_screen); + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + light = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = log2 (light); + vec4 tmpvar_10; + tmpvar_10 = -(tmpvar_9); + light = tmpvar_10; + vec3 tmpvar_11; + tmpvar_11 = (light.xyz + unity_Ambient.xyz); + light.xyz = tmpvar_11.xyz.xyz; + vec4 tmpvar_12; + tmpvar_12 = LightingBlinnPhong_PrePass (o, light); + vec4 tmpvar_13; + tmpvar_13 = tmpvar_12; + col = tmpvar_13; + return col; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xy; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyzw; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.hip_screen = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = frag_surf (xlt_IN); + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xl_retval = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = xl_retval.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + gl_FragData[0] = tmpvar_10; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Cutout_Bumped_Specular1-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Cutout_Bumped_Specular1-out.txt new file mode 100644 index 000000000..bb9e9711c --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Cutout_Bumped_Specular1-out.txt @@ -0,0 +1,39 @@ +uniform vec4 unity_Ambient; +uniform vec4 _SpecColor; +uniform sampler2D _MainTex; +uniform sampler2D _LightBuffer; +uniform float _Cutoff; +uniform vec4 _Color; +uniform sampler2D _BumpMap; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = gl_TexCoord[1]; + vec4 light; + vec2 tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = texture2D (_MainTex, gl_TexCoord[0].xy); + vec3 tmpvar_4; + tmpvar_4 = (tmpvar_3.xyz * _Color.xyz); + float tmpvar_5; + tmpvar_5 = (tmpvar_3.w * _Color.w); + vec4 normal; + normal.xy = ((texture2D (_BumpMap, tmpvar_2).wy * 2.0) - 1.0); + normal.z = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + float x; + x = (tmpvar_5 - _Cutoff); + if ((x < 0.0)) { + discard; + }; + vec4 tmpvar_6; + tmpvar_6 = -(log2 (texture2DProj (_LightBuffer, tmpvar_1))); + light = tmpvar_6; + light.xyz = (tmpvar_6.xyz + unity_Ambient.xyz); + vec4 c; + float tmpvar_7; + tmpvar_7 = (tmpvar_6.w * tmpvar_3.w); + c.xyz = ((tmpvar_4 * light.xyz) + ((light.xyz * _SpecColor.xyz) * tmpvar_7)); + c.w = (tmpvar_5 + (tmpvar_7 * _SpecColor.w)); + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Cutout_Diffuse-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Cutout_Diffuse-in.txt new file mode 100644 index 000000000..3aad0f783 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Cutout_Diffuse-in.txt @@ -0,0 +1,107 @@ +void xll_clip(float x) { + if ( x<0.0 ) discard; +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 normal; + vec3 lightDir; + vec4 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _Color; +uniform float _Cutoff; +uniform vec4 _LightColor0; +uniform sampler2D _LightTexture0; +uniform sampler2D _LightTextureB0; +uniform sampler2D _MainTex; +void surf( in Input IN, inout SurfaceOutput o ); +float UnitySpotCookie( in vec4 LightCoord ); +float UnitySpotAttenuate( in vec3 LightCoord ); +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ); +vec4 frag_surf( in v2f_surf IN ); +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 c; + c = (texture2D( _MainTex, IN.uv_MainTex) * _Color); + o.Albedo = c.xyz ; + o.Alpha = c.w ; +} +float UnitySpotCookie( in vec4 LightCoord ) { + return texture2D( _LightTexture0, ((LightCoord.xy / LightCoord.w ) + 0.500000)).w ; +} +float UnitySpotAttenuate( in vec3 LightCoord ) { + return texture2D( _LightTextureB0, vec2( vec2( dot( LightCoord, LightCoord)))).w ; +} +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ) { + float diff; + vec4 c; + diff = max( 0.000000, dot( s.Normal, lightDir)); + c.xyz = ((s.Albedo * _LightColor0.xyz ) * ((diff * atten) * 2.00000)); + c.w = s.Alpha; + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec3 lightDir; + vec4 c; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + o.Normal = IN.normal; + surf( surfIN, o); + xll_clip( (o.Alpha - _Cutoff) ); + lightDir = IN.lightDir; + lightDir = normalize( lightDir ); + c = LightingLambert( o, lightDir, ((float( (IN._LightCoord.z > 0.000000) ) * UnitySpotCookie( IN._LightCoord)) * UnitySpotAttenuate( IN._LightCoord.xyz ))); + c.w = o.Alpha; + return c; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec2( gl_TexCoord[0]); + xlt_IN.normal = vec3( gl_TexCoord[1]); + xlt_IN.lightDir = vec3( gl_TexCoord[2]); + xlt_IN._LightCoord = vec4( gl_TexCoord[3]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Cutout_Diffuse-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Cutout_Diffuse-ir.txt new file mode 100644 index 000000000..bf42aa042 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Cutout_Diffuse-ir.txt @@ -0,0 +1,198 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 normal; + vec3 lightDir; + vec4 _LightCoord; +}; +varying vec4 xlv_FOG; +uniform sampler2D _MainTex; +uniform sampler2D _LightTextureB0; +uniform sampler2D _LightTexture0; +uniform vec4 _LightColor0; +uniform float _Cutoff; +uniform vec4 _Color; +void xll_clip ( + in float x +) +{ + if ((x < 0.0)) { + discard; + }; +} + +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 c; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = (tmpvar_1 * _Color); + c = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = c.xyz; + o.Albedo = tmpvar_3; + float tmpvar_4; + tmpvar_4 = c.w; + o.Alpha = tmpvar_4; +} + +float UnitySpotCookie ( + in vec4 LightCoord +) +{ + vec4 tmpvar_1; + tmpvar_1 = texture2D (_LightTexture0, ((LightCoord.xy / LightCoord.w) + 0.5)); + return tmpvar_1.w; +} + +float UnitySpotAttenuate ( + in vec3 LightCoord +) +{ + float tmpvar_1; + tmpvar_1 = dot (LightCoord, LightCoord); + vec2 tmpvar_2; + tmpvar_2 = vec2(tmpvar_1); + vec2 tmpvar_3; + tmpvar_3 = tmpvar_2.xy; + vec4 tmpvar_4; + tmpvar_4 = texture2D (_LightTextureB0, tmpvar_3); + return tmpvar_4.w; +} + +vec4 LightingLambert ( + in SurfaceOutput s, + in vec3 lightDir, + in float atten +) +{ + vec4 c; + float diff; + float tmpvar_1; + tmpvar_1 = dot (s.Normal, lightDir); + float tmpvar_2; + tmpvar_2 = max (0.0, tmpvar_1); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + diff = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = ((s.Albedo * _LightColor0.xyz) * ((diff * atten) * 2.0)); + c.xyz = tmpvar_4.xyz.xyz; + float tmpvar_5; + tmpvar_5 = s.Alpha; + c.w = vec4(tmpvar_5).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 c; + vec3 lightDir; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_3; + float tmpvar_4; + tmpvar_4 = 0.0; + o.Specular = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Alpha = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Gloss = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = IN.normal; + o.Normal = tmpvar_7; + surf (surfIN, o); + xll_clip ((o.Alpha - _Cutoff)); + vec3 tmpvar_8; + tmpvar_8 = IN.lightDir; + lightDir = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = normalize (lightDir); + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + lightDir = tmpvar_10; + float tmpvar_11; + tmpvar_11 = UnitySpotCookie (IN._LightCoord); + float tmpvar_12; + tmpvar_12 = UnitySpotAttenuate (IN._LightCoord.xyz); + vec4 tmpvar_13; + tmpvar_13 = LightingLambert (o, lightDir, ((float((IN._LightCoord.z > 0.0)) * tmpvar_11) * tmpvar_12)); + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + c = tmpvar_14; + float tmpvar_15; + tmpvar_15 = o.Alpha; + c.w = vec4(tmpvar_15).w; + return c; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xy; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.normal = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.lightDir = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_TexCoord[3].xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_IN._LightCoord = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = frag_surf (xlt_IN); + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xl_retval = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = xl_retval.xyzw; + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + gl_FragData[0] = tmpvar_14; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Cutout_Diffuse-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Cutout_Diffuse-out.txt new file mode 100644 index 000000000..fb00de87a --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Cutout_Diffuse-out.txt @@ -0,0 +1,32 @@ +uniform sampler2D _MainTex; +uniform sampler2D _LightTextureB0; +uniform sampler2D _LightTexture0; +uniform vec4 _LightColor0; +uniform float _Cutoff; +uniform vec4 _Color; +void main () +{ + vec3 tmpvar_1; + tmpvar_1 = gl_TexCoord[1].xyz; + vec3 tmpvar_2; + tmpvar_2 = gl_TexCoord[2].xyz; + vec4 tmpvar_3; + tmpvar_3 = gl_TexCoord[3]; + vec4 c; + vec4 tmpvar_4; + tmpvar_4 = (texture2D (_MainTex, gl_TexCoord[0].xy) * _Color); + float x; + x = (tmpvar_4.w - _Cutoff); + if ((x < 0.0)) { + discard; + }; + vec3 LightCoord_i0; + LightCoord_i0 = tmpvar_3.xyz; + vec4 c_i0_i1; + c_i0_i1.xyz = ((tmpvar_4.xyz * _LightColor0.xyz) * ((max (0.0, dot (tmpvar_1, normalize (tmpvar_2))) * ((float((tmpvar_3.z > 0.0)) * texture2D (_LightTexture0, ((tmpvar_3.xy / tmpvar_3.w) + 0.5)).w) * texture2D (_LightTextureB0, vec2(dot (LightCoord_i0, LightCoord_i0))).w)) * 2.0)); + c_i0_i1.w = tmpvar_4.w; + c = c_i0_i1; + c.w = tmpvar_4.w; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Cutout_Specular-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Cutout_Specular-in.txt new file mode 100644 index 000000000..fef6a9fdd --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Cutout_Specular-in.txt @@ -0,0 +1,106 @@ +void xll_clip(float x) { + if ( x<0.0 ) discard; +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 normal; + vec3 lightDir; + vec3 viewDir; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _Color; +uniform float _Cutoff; +uniform vec4 _LightColor0; +uniform sampler2D _MainTex; +uniform float _Shininess; +uniform vec4 _SpecColor; +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingBlinnPhong( in SurfaceOutput s, in vec3 lightDir, in vec3 viewDir, in float atten ); +vec4 frag_surf( in v2f_surf IN ); +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 tex; + tex = texture2D( _MainTex, IN.uv_MainTex); + o.Albedo = (tex.xyz * _Color.xyz ); + o.Gloss = tex.w ; + o.Alpha = (tex.w * _Color.w ); + o.Specular = _Shininess; +} +vec4 LightingBlinnPhong( in SurfaceOutput s, in vec3 lightDir, in vec3 viewDir, in float atten ) { + vec3 h; + float diff; + float nh; + float spec; + vec4 c; + h = normalize( (lightDir + viewDir) ); + diff = max( 0.000000, dot( s.Normal, lightDir)); + nh = max( 0.000000, dot( s.Normal, h)); + spec = (pow( nh, (s.Specular * 128.000)) * s.Gloss); + c.xyz = ((((s.Albedo * _LightColor0.xyz ) * diff) + ((_LightColor0.xyz * _SpecColor.xyz ) * spec)) * (atten * 2.00000)); + c.w = (s.Alpha + (((_LightColor0.w * _SpecColor.w ) * spec) * atten)); + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec3 lightDir; + vec4 c; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + o.Normal = IN.normal; + surf( surfIN, o); + xll_clip( (o.Alpha - _Cutoff) ); + lightDir = IN.lightDir; + c = LightingBlinnPhong( o, lightDir, normalize( vec3( IN.viewDir) ), 1.00000); + c.w = o.Alpha; + return c; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec2( gl_TexCoord[0]); + xlt_IN.normal = vec3( gl_TexCoord[1]); + xlt_IN.lightDir = vec3( gl_TexCoord[2]); + xlt_IN.viewDir = vec3( gl_TexCoord[3]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Cutout_Specular-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Cutout_Specular-ir.txt new file mode 100644 index 000000000..607192b1f --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Cutout_Specular-ir.txt @@ -0,0 +1,196 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 normal; + vec3 lightDir; + vec3 viewDir; +}; +varying vec4 xlv_FOG; +uniform vec4 _SpecColor; +uniform float _Shininess; +uniform sampler2D _MainTex; +uniform vec4 _LightColor0; +uniform float _Cutoff; +uniform vec4 _Color; +void xll_clip ( + in float x +) +{ + if ((x < 0.0)) { + discard; + }; +} + +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 tex; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + tex = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = (tex.xyz * _Color.xyz); + o.Albedo = tmpvar_3; + float tmpvar_4; + tmpvar_4 = tex.w; + o.Gloss = tmpvar_4; + float tmpvar_5; + tmpvar_5 = (tex.w * _Color.w); + o.Alpha = tmpvar_5; + float tmpvar_6; + tmpvar_6 = _Shininess; + o.Specular = tmpvar_6; +} + +vec4 LightingBlinnPhong ( + in SurfaceOutput s, + in vec3 lightDir, + in vec3 viewDir, + in float atten +) +{ + vec4 c; + float spec; + float nh; + float diff; + vec3 h; + vec3 tmpvar_1; + tmpvar_1 = normalize ((lightDir + viewDir)); + vec3 tmpvar_2; + tmpvar_2 = tmpvar_1; + h = tmpvar_2; + float tmpvar_3; + tmpvar_3 = dot (s.Normal, lightDir); + float tmpvar_4; + tmpvar_4 = max (0.0, tmpvar_3); + float tmpvar_5; + tmpvar_5 = tmpvar_4; + diff = tmpvar_5; + float tmpvar_6; + tmpvar_6 = dot (s.Normal, h); + float tmpvar_7; + tmpvar_7 = max (0.0, tmpvar_6); + float tmpvar_8; + tmpvar_8 = tmpvar_7; + nh = tmpvar_8; + float tmpvar_9; + tmpvar_9 = pow (nh, (s.Specular * 128.0)); + float tmpvar_10; + tmpvar_10 = (tmpvar_9 * s.Gloss); + spec = tmpvar_10; + vec3 tmpvar_11; + tmpvar_11 = ((((s.Albedo * _LightColor0.xyz) * diff) + ((_LightColor0.xyz * _SpecColor.xyz) * spec)) * (atten * 2.0)); + c.xyz = tmpvar_11.xyz.xyz; + float tmpvar_12; + tmpvar_12 = (s.Alpha + (((_LightColor0.w * _SpecColor.w) * spec) * atten)); + c.w = vec4(tmpvar_12).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 c; + vec3 lightDir; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_3; + float tmpvar_4; + tmpvar_4 = 0.0; + o.Specular = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Alpha = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Gloss = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = IN.normal; + o.Normal = tmpvar_7; + surf (surfIN, o); + xll_clip ((o.Alpha - _Cutoff)); + vec3 tmpvar_8; + tmpvar_8 = IN.lightDir; + lightDir = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = IN.viewDir.xyz; + vec3 tmpvar_10; + tmpvar_10 = normalize (tmpvar_9); + vec4 tmpvar_11; + tmpvar_11 = LightingBlinnPhong (o, lightDir, tmpvar_10, 1.0); + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + c = tmpvar_12; + float tmpvar_13; + tmpvar_13 = o.Alpha; + c.w = vec4(tmpvar_13).w; + return c; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xy; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.normal = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.lightDir = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = gl_TexCoord[3].xyz; + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_IN.viewDir = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = frag_surf (xlt_IN); + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xl_retval = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = xl_retval.xyzw; + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + gl_FragData[0] = tmpvar_14; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Cutout_Specular-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Cutout_Specular-out.txt new file mode 100644 index 000000000..4ba47c16c --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Cutout_Specular-out.txt @@ -0,0 +1,36 @@ +uniform vec4 _SpecColor; +uniform float _Shininess; +uniform sampler2D _MainTex; +uniform vec4 _LightColor0; +uniform float _Cutoff; +uniform vec4 _Color; +void main () +{ + vec3 tmpvar_1; + tmpvar_1 = gl_TexCoord[1].xyz; + vec3 tmpvar_2; + tmpvar_2 = gl_TexCoord[2].xyz; + vec3 tmpvar_3; + tmpvar_3 = gl_TexCoord[3].xyz; + vec4 c; + vec4 tmpvar_4; + tmpvar_4 = texture2D (_MainTex, gl_TexCoord[0].xy); + vec3 tmpvar_5; + tmpvar_5 = (tmpvar_4.xyz * _Color.xyz); + float tmpvar_6; + tmpvar_6 = (tmpvar_4.w * _Color.w); + float x; + x = (tmpvar_6 - _Cutoff); + if ((x < 0.0)) { + discard; + }; + vec4 c_i0; + float tmpvar_7; + tmpvar_7 = (pow (max (0.0, dot (tmpvar_1, normalize ((tmpvar_2 + normalize (tmpvar_3))))), (_Shininess * 128.0)) * tmpvar_4.w); + c_i0.xyz = ((((tmpvar_5 * _LightColor0.xyz) * max (0.0, dot (tmpvar_1, tmpvar_2))) + ((_LightColor0.xyz * _SpecColor.xyz) * tmpvar_7)) * 2.0); + c_i0.w = (tmpvar_6 + ((_LightColor0.w * _SpecColor.w) * tmpvar_7)); + c = c_i0; + c.w = tmpvar_6; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Cutout_Specular1-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Cutout_Specular1-in.txt new file mode 100644 index 000000000..bfe4c547b --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Cutout_Specular1-in.txt @@ -0,0 +1,111 @@ +void xll_clip(float x) { + if ( x<0.0 ) discard; +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 normal; + vec3 lightDir; + vec3 viewDir; + vec3 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _Color; +uniform float _Cutoff; +uniform vec4 _LightColor0; +uniform samplerCube _LightTexture0; +uniform sampler2D _LightTextureB0; +uniform sampler2D _MainTex; +uniform float _Shininess; +uniform vec4 _SpecColor; +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingBlinnPhong( in SurfaceOutput s, in vec3 lightDir, in vec3 viewDir, in float atten ); +vec4 frag_surf( in v2f_surf IN ); +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 tex; + tex = texture2D( _MainTex, IN.uv_MainTex); + o.Albedo = (tex.xyz * _Color.xyz ); + o.Gloss = tex.w ; + o.Alpha = (tex.w * _Color.w ); + o.Specular = _Shininess; +} +vec4 LightingBlinnPhong( in SurfaceOutput s, in vec3 lightDir, in vec3 viewDir, in float atten ) { + vec3 h; + float diff; + float nh; + float spec; + vec4 c; + h = normalize( (lightDir + viewDir) ); + diff = max( 0.000000, dot( s.Normal, lightDir)); + nh = max( 0.000000, dot( s.Normal, h)); + spec = (pow( nh, (s.Specular * 128.000)) * s.Gloss); + c.xyz = ((((s.Albedo * _LightColor0.xyz ) * diff) + ((_LightColor0.xyz * _SpecColor.xyz ) * spec)) * (atten * 2.00000)); + c.w = (s.Alpha + (((_LightColor0.w * _SpecColor.w ) * spec) * atten)); + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec3 lightDir; + vec4 c; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + o.Normal = IN.normal; + surf( surfIN, o); + xll_clip( (o.Alpha - _Cutoff) ); + lightDir = IN.lightDir; + lightDir = normalize( lightDir ); + c = LightingBlinnPhong( o, lightDir, normalize( vec3( IN.viewDir) ), (texture2D( _LightTextureB0, vec2( vec2( dot( IN._LightCoord, IN._LightCoord)))).w * textureCube( _LightTexture0, IN._LightCoord).w )); + c.w = o.Alpha; + return c; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec2( gl_TexCoord[0]); + xlt_IN.normal = vec3( gl_TexCoord[1]); + xlt_IN.lightDir = vec3( gl_TexCoord[2]); + xlt_IN.viewDir = vec3( gl_TexCoord[3]); + xlt_IN._LightCoord = vec3( gl_TexCoord[4]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Cutout_Specular1-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Cutout_Specular1-ir.txt new file mode 100644 index 000000000..b8b92f9c2 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Cutout_Specular1-ir.txt @@ -0,0 +1,219 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 normal; + vec3 lightDir; + vec3 viewDir; + vec3 _LightCoord; +}; +varying vec4 xlv_FOG; +uniform vec4 _SpecColor; +uniform float _Shininess; +uniform sampler2D _MainTex; +uniform sampler2D _LightTextureB0; +uniform samplerCube _LightTexture0; +uniform vec4 _LightColor0; +uniform float _Cutoff; +uniform vec4 _Color; +void xll_clip ( + in float x +) +{ + if ((x < 0.0)) { + discard; + }; +} + +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 tex; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + tex = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = (tex.xyz * _Color.xyz); + o.Albedo = tmpvar_3; + float tmpvar_4; + tmpvar_4 = tex.w; + o.Gloss = tmpvar_4; + float tmpvar_5; + tmpvar_5 = (tex.w * _Color.w); + o.Alpha = tmpvar_5; + float tmpvar_6; + tmpvar_6 = _Shininess; + o.Specular = tmpvar_6; +} + +vec4 LightingBlinnPhong ( + in SurfaceOutput s, + in vec3 lightDir, + in vec3 viewDir, + in float atten +) +{ + vec4 c; + float spec; + float nh; + float diff; + vec3 h; + vec3 tmpvar_1; + tmpvar_1 = normalize ((lightDir + viewDir)); + vec3 tmpvar_2; + tmpvar_2 = tmpvar_1; + h = tmpvar_2; + float tmpvar_3; + tmpvar_3 = dot (s.Normal, lightDir); + float tmpvar_4; + tmpvar_4 = max (0.0, tmpvar_3); + float tmpvar_5; + tmpvar_5 = tmpvar_4; + diff = tmpvar_5; + float tmpvar_6; + tmpvar_6 = dot (s.Normal, h); + float tmpvar_7; + tmpvar_7 = max (0.0, tmpvar_6); + float tmpvar_8; + tmpvar_8 = tmpvar_7; + nh = tmpvar_8; + float tmpvar_9; + tmpvar_9 = pow (nh, (s.Specular * 128.0)); + float tmpvar_10; + tmpvar_10 = (tmpvar_9 * s.Gloss); + spec = tmpvar_10; + vec3 tmpvar_11; + tmpvar_11 = ((((s.Albedo * _LightColor0.xyz) * diff) + ((_LightColor0.xyz * _SpecColor.xyz) * spec)) * (atten * 2.0)); + c.xyz = tmpvar_11.xyz.xyz; + float tmpvar_12; + tmpvar_12 = (s.Alpha + (((_LightColor0.w * _SpecColor.w) * spec) * atten)); + c.w = vec4(tmpvar_12).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 c; + vec3 lightDir; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_3; + float tmpvar_4; + tmpvar_4 = 0.0; + o.Specular = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Alpha = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Gloss = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = IN.normal; + o.Normal = tmpvar_7; + surf (surfIN, o); + xll_clip ((o.Alpha - _Cutoff)); + vec3 tmpvar_8; + tmpvar_8 = IN.lightDir; + lightDir = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = normalize (lightDir); + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + lightDir = tmpvar_10; + vec3 tmpvar_11; + tmpvar_11 = IN.viewDir.xyz; + vec3 tmpvar_12; + tmpvar_12 = normalize (tmpvar_11); + float tmpvar_13; + tmpvar_13 = dot (IN._LightCoord, IN._LightCoord); + vec2 tmpvar_14; + tmpvar_14 = vec2(tmpvar_13); + vec2 tmpvar_15; + tmpvar_15 = tmpvar_14.xy; + vec4 tmpvar_16; + tmpvar_16 = texture2D (_LightTextureB0, tmpvar_15); + vec4 tmpvar_17; + tmpvar_17 = textureCube (_LightTexture0, IN._LightCoord); + vec4 tmpvar_18; + tmpvar_18 = LightingBlinnPhong (o, lightDir, tmpvar_12, (tmpvar_16.w * tmpvar_17.w)); + vec4 tmpvar_19; + tmpvar_19 = tmpvar_18; + c = tmpvar_19; + float tmpvar_20; + tmpvar_20 = o.Alpha; + c.w = vec4(tmpvar_20).w; + return c; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xy; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.normal = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.lightDir = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = gl_TexCoord[3].xyz; + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_IN.viewDir = tmpvar_10; + vec3 tmpvar_11; + tmpvar_11 = gl_TexCoord[4].xyz; + vec3 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_IN._LightCoord = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = frag_surf (xlt_IN); + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_FragData[0] = tmpvar_16; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Cutout_Specular1-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Cutout_Specular1-out.txt new file mode 100644 index 000000000..09ccc25d4 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Cutout_Specular1-out.txt @@ -0,0 +1,44 @@ +uniform vec4 _SpecColor; +uniform float _Shininess; +uniform sampler2D _MainTex; +uniform sampler2D _LightTextureB0; +uniform samplerCube _LightTexture0; +uniform vec4 _LightColor0; +uniform float _Cutoff; +uniform vec4 _Color; +void main () +{ + vec3 tmpvar_1; + tmpvar_1 = gl_TexCoord[1].xyz; + vec3 tmpvar_2; + tmpvar_2 = gl_TexCoord[2].xyz; + vec3 tmpvar_3; + tmpvar_3 = gl_TexCoord[3].xyz; + vec3 tmpvar_4; + tmpvar_4 = gl_TexCoord[4].xyz; + vec4 c; + vec4 tmpvar_5; + tmpvar_5 = texture2D (_MainTex, gl_TexCoord[0].xy); + vec3 tmpvar_6; + tmpvar_6 = (tmpvar_5.xyz * _Color.xyz); + float tmpvar_7; + tmpvar_7 = (tmpvar_5.w * _Color.w); + float x; + x = (tmpvar_7 - _Cutoff); + if ((x < 0.0)) { + discard; + }; + vec3 tmpvar_8; + tmpvar_8 = normalize (tmpvar_2); + float atten; + atten = (texture2D (_LightTextureB0, vec2(dot (tmpvar_4, tmpvar_4))).w * textureCube (_LightTexture0, tmpvar_4).w); + vec4 c_i0; + float tmpvar_9; + tmpvar_9 = (pow (max (0.0, dot (tmpvar_1, normalize ((tmpvar_8 + normalize (tmpvar_3))))), (_Shininess * 128.0)) * tmpvar_5.w); + c_i0.xyz = ((((tmpvar_6 * _LightColor0.xyz) * max (0.0, dot (tmpvar_1, tmpvar_8))) + ((_LightColor0.xyz * _SpecColor.xyz) * tmpvar_9)) * (atten * 2.0)); + c_i0.w = (tmpvar_7 + (((_LightColor0.w * _SpecColor.w) * tmpvar_9) * atten)); + c = c_i0; + c.w = tmpvar_7; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Cutout_Specular2-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Cutout_Specular2-in.txt new file mode 100644 index 000000000..eaa50c2a3 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Cutout_Specular2-in.txt @@ -0,0 +1,131 @@ +void xll_clip(float x) { + if ( x<0.0 ) discard; +} +float xll_saturate( float x) { + return clamp( x, 0.0, 1.0); +} +vec2 xll_saturate( vec2 x) { + return clamp( x, 0.0, 1.0); +} +vec3 xll_saturate( vec3 x) { + return clamp( x, 0.0, 1.0); +} +vec4 xll_saturate( vec4 x) { + return clamp( x, 0.0, 1.0); +} +mat2 xll_saturate(mat2 m) { + return mat2( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0)); +} +mat3 xll_saturate(mat3 m) { + return mat3( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0), clamp(m[2], 0.0, 1.0)); +} +mat4 xll_saturate(mat4 m) { + return mat4( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0), clamp(m[2], 0.0, 1.0), clamp(m[3], 0.0, 1.0)); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 hip_screen; + vec3 hip_lmapFade; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _Color; +uniform float _Cutoff; +uniform sampler2D _LightBuffer; +uniform sampler2D _MainTex; +uniform float _Shininess; +uniform vec4 _SpecColor; +uniform sampler2D unity_Lightmap; +uniform sampler2D unity_LightmapInd; +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingBlinnPhong_PrePass( in SurfaceOutput s, in vec4 light ); +vec3 DecodeLightmap( in vec4 color ); +vec4 frag_surf( in v2f_surf IN ); +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 tex; + tex = texture2D( _MainTex, IN.uv_MainTex); + o.Albedo = (tex.xyz * _Color.xyz ); + o.Gloss = tex.w ; + o.Alpha = (tex.w * _Color.w ); + o.Specular = _Shininess; +} +vec4 LightingBlinnPhong_PrePass( in SurfaceOutput s, in vec4 light ) { + float spec; + vec4 c; + spec = (light.w * s.Gloss); + c.xyz = ((s.Albedo * light.xyz ) + ((light.xyz * _SpecColor.xyz ) * spec)); + c.w = (s.Alpha + (spec * _SpecColor.w )); + return c; +} +vec3 DecodeLightmap( in vec4 color ) { + return (2.00000 * color.xyz ); +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec4 light; + vec3 lmFull; + vec3 lmIndirect; + vec3 lm; + vec4 col; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + surf( surfIN, o); + xll_clip( (o.Alpha - _Cutoff) ); + light = texture2DProj( _LightBuffer, IN.hip_screen); + light = ( -log2( light ) ); + lmFull = DecodeLightmap( texture2D( unity_Lightmap, IN.hip_lmapFade.xy )); + lmIndirect = DecodeLightmap( texture2D( unity_LightmapInd, IN.hip_lmapFade.xy )); + lm = mix( lmIndirect, lmFull, vec3( xll_saturate( IN.hip_lmapFade.z ))); + light.xyz += lm; + col = LightingBlinnPhong_PrePass( o, light); + return col; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec2( gl_TexCoord[0]); + xlt_IN.hip_screen = vec4( gl_TexCoord[1]); + xlt_IN.hip_lmapFade = vec3( gl_TexCoord[2]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Cutout_Specular2-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Cutout_Specular2-ir.txt new file mode 100644 index 000000000..03057daa3 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Cutout_Specular2-ir.txt @@ -0,0 +1,304 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 hip_screen; + vec3 hip_lmapFade; +}; +varying vec4 xlv_FOG; +uniform sampler2D unity_LightmapInd; +uniform sampler2D unity_Lightmap; +uniform vec4 _SpecColor; +uniform float _Shininess; +uniform sampler2D _MainTex; +uniform sampler2D _LightBuffer; +uniform float _Cutoff; +uniform vec4 _Color; +void xll_clip ( + in float x +) +{ + if ((x < 0.0)) { + discard; + }; +} + +float xll_saturate ( + in float x +) +{ + float tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec2 xll_saturate ( + in vec2 x +) +{ + vec2 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec3 xll_saturate ( + in vec3 x +) +{ + vec3 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec4 xll_saturate ( + in vec4 x +) +{ + vec4 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +mat2 xll_saturate ( + in mat2 m +) +{ + vec2 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec2 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + mat2 tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_1; + tmpvar_3[0] = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5 = tmpvar_2; + tmpvar_3[1] = tmpvar_5; + return tmpvar_3; +} + +mat3 xll_saturate ( + in mat3 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec3 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + vec3 tmpvar_3; + tmpvar_3 = clamp (m[2], 0.0, 1.0); + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +mat4 xll_saturate ( + in mat4 m +) +{ + vec4 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec4 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + vec4 tmpvar_3; + tmpvar_3 = clamp (m[2], 0.0, 1.0); + vec4 tmpvar_4; + tmpvar_4 = clamp (m[3], 0.0, 1.0); + mat4 tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_1; + tmpvar_5[0] = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = tmpvar_2; + tmpvar_5[1] = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_3; + tmpvar_5[2] = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = tmpvar_4; + tmpvar_5[3] = tmpvar_9; + return tmpvar_5; +} + +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 tex; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + tex = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = (tex.xyz * _Color.xyz); + o.Albedo = tmpvar_3; + float tmpvar_4; + tmpvar_4 = tex.w; + o.Gloss = tmpvar_4; + float tmpvar_5; + tmpvar_5 = (tex.w * _Color.w); + o.Alpha = tmpvar_5; + float tmpvar_6; + tmpvar_6 = _Shininess; + o.Specular = tmpvar_6; +} + +vec4 LightingBlinnPhong_PrePass ( + in SurfaceOutput s, + in vec4 light +) +{ + vec4 c; + float spec; + float tmpvar_1; + tmpvar_1 = (light.w * s.Gloss); + spec = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = ((s.Albedo * light.xyz) + ((light.xyz * _SpecColor.xyz) * spec)); + c.xyz = tmpvar_2.xyz.xyz; + float tmpvar_3; + tmpvar_3 = (s.Alpha + (spec * _SpecColor.w)); + c.w = vec4(tmpvar_3).w; + return c; +} + +vec3 DecodeLightmap ( + in vec4 color +) +{ + return (2.0 * color.xyz); +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 col; + vec3 lm; + vec3 lmIndirect; + vec3 lmFull; + vec4 light; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_3; + float tmpvar_4; + tmpvar_4 = 0.0; + o.Specular = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Alpha = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Gloss = tmpvar_6; + surf (surfIN, o); + xll_clip ((o.Alpha - _Cutoff)); + vec4 tmpvar_7; + tmpvar_7 = texture2DProj (_LightBuffer, IN.hip_screen); + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + light = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = log2 (light); + vec4 tmpvar_10; + tmpvar_10 = -(tmpvar_9); + light = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = texture2D (unity_Lightmap, IN.hip_lmapFade.xy); + vec3 tmpvar_12; + tmpvar_12 = DecodeLightmap (tmpvar_11); + vec3 tmpvar_13; + tmpvar_13 = tmpvar_12; + lmFull = tmpvar_13; + vec4 tmpvar_14; + tmpvar_14 = texture2D (unity_LightmapInd, IN.hip_lmapFade.xy); + vec3 tmpvar_15; + tmpvar_15 = DecodeLightmap (tmpvar_14); + vec3 tmpvar_16; + tmpvar_16 = tmpvar_15; + lmIndirect = tmpvar_16; + float tmpvar_17; + tmpvar_17 = xll_saturate (IN.hip_lmapFade.z); + vec3 tmpvar_18; + tmpvar_18 = vec3(tmpvar_17); + vec3 tmpvar_19; + tmpvar_19 = mix (lmIndirect, lmFull, tmpvar_18); + vec3 tmpvar_20; + tmpvar_20 = tmpvar_19; + lm = tmpvar_20; + vec3 tmpvar_21; + tmpvar_21 = (light.xyz + lm); + light.xyz = tmpvar_21.xyz.xyz; + vec4 tmpvar_22; + tmpvar_22 = LightingBlinnPhong_PrePass (o, light); + vec4 tmpvar_23; + tmpvar_23 = tmpvar_22; + col = tmpvar_23; + return col; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xy; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyzw; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.hip_screen = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.hip_lmapFade = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = frag_surf (xlt_IN); + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xl_retval = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = xl_retval.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + gl_FragData[0] = tmpvar_12; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Cutout_Specular2-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Cutout_Specular2-out.txt new file mode 100644 index 000000000..d22b57507 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Cutout_Specular2-out.txt @@ -0,0 +1,37 @@ +uniform sampler2D unity_LightmapInd; +uniform sampler2D unity_Lightmap; +uniform vec4 _SpecColor; +uniform sampler2D _MainTex; +uniform sampler2D _LightBuffer; +uniform float _Cutoff; +uniform vec4 _Color; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = gl_TexCoord[1]; + vec3 tmpvar_2; + tmpvar_2 = gl_TexCoord[2].xyz; + vec4 light; + vec4 tmpvar_3; + tmpvar_3 = texture2D (_MainTex, gl_TexCoord[0].xy); + vec3 tmpvar_4; + tmpvar_4 = (tmpvar_3.xyz * _Color.xyz); + float tmpvar_5; + tmpvar_5 = (tmpvar_3.w * _Color.w); + float x; + x = (tmpvar_5 - _Cutoff); + if ((x < 0.0)) { + discard; + }; + vec4 tmpvar_6; + tmpvar_6 = -(log2 (texture2DProj (_LightBuffer, tmpvar_1))); + light = tmpvar_6; + light.xyz = (tmpvar_6.xyz + mix ((2.0 * texture2D (unity_LightmapInd, tmpvar_2.xy).xyz), (2.0 * texture2D (unity_Lightmap, tmpvar_2.xy).xyz), vec3(clamp (tmpvar_2.z, 0.0, 1.0)))); + vec4 c; + float tmpvar_7; + tmpvar_7 = (tmpvar_6.w * tmpvar_3.w); + c.xyz = ((tmpvar_4 * light.xyz) + ((light.xyz * _SpecColor.xyz) * tmpvar_7)); + c.w = (tmpvar_5 + (tmpvar_7 * _SpecColor.w)); + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Diffuse-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Diffuse-in.txt new file mode 100644 index 000000000..23b2d6d31 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Diffuse-in.txt @@ -0,0 +1,94 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 normal; + vec3 lightDir; + vec3 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _Color; +uniform vec4 _LightColor0; +uniform samplerCube _LightTexture0; +uniform sampler2D _LightTextureB0; +uniform sampler2D _MainTex; +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ); +vec4 frag_surf( in v2f_surf IN ); +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 c; + c = (texture2D( _MainTex, IN.uv_MainTex) * _Color); + o.Albedo = c.xyz ; + o.Alpha = c.w ; +} +vec4 LightingLambert( in SurfaceOutput s, in vec3 lightDir, in float atten ) { + float diff; + vec4 c; + diff = max( 0.000000, dot( s.Normal, lightDir)); + c.xyz = ((s.Albedo * _LightColor0.xyz ) * ((diff * atten) * 2.00000)); + c.w = s.Alpha; + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec3 lightDir; + vec4 c; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + o.Normal = IN.normal; + surf( surfIN, o); + lightDir = IN.lightDir; + lightDir = normalize( lightDir ); + c = LightingLambert( o, lightDir, (texture2D( _LightTextureB0, vec2( vec2( dot( IN._LightCoord, IN._LightCoord)))).w * textureCube( _LightTexture0, IN._LightCoord).w )); + c.w = o.Alpha; + return c; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec2( gl_TexCoord[0]); + xlt_IN.normal = vec3( gl_TexCoord[1]); + xlt_IN.lightDir = vec3( gl_TexCoord[2]); + xlt_IN._LightCoord = vec3( gl_TexCoord[3]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Diffuse-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Diffuse-ir.txt new file mode 100644 index 000000000..c8b173e33 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Diffuse-ir.txt @@ -0,0 +1,169 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 normal; + vec3 lightDir; + vec3 _LightCoord; +}; +varying vec4 xlv_FOG; +uniform sampler2D _MainTex; +uniform sampler2D _LightTextureB0; +uniform samplerCube _LightTexture0; +uniform vec4 _LightColor0; +uniform vec4 _Color; +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 c; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = (tmpvar_1 * _Color); + c = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = c.xyz; + o.Albedo = tmpvar_3; + float tmpvar_4; + tmpvar_4 = c.w; + o.Alpha = tmpvar_4; +} + +vec4 LightingLambert ( + in SurfaceOutput s, + in vec3 lightDir, + in float atten +) +{ + vec4 c; + float diff; + float tmpvar_1; + tmpvar_1 = dot (s.Normal, lightDir); + float tmpvar_2; + tmpvar_2 = max (0.0, tmpvar_1); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + diff = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = ((s.Albedo * _LightColor0.xyz) * ((diff * atten) * 2.0)); + c.xyz = tmpvar_4.xyz.xyz; + float tmpvar_5; + tmpvar_5 = s.Alpha; + c.w = vec4(tmpvar_5).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 c; + vec3 lightDir; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_3; + float tmpvar_4; + tmpvar_4 = 0.0; + o.Specular = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Alpha = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Gloss = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = IN.normal; + o.Normal = tmpvar_7; + surf (surfIN, o); + vec3 tmpvar_8; + tmpvar_8 = IN.lightDir; + lightDir = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = normalize (lightDir); + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + lightDir = tmpvar_10; + float tmpvar_11; + tmpvar_11 = dot (IN._LightCoord, IN._LightCoord); + vec2 tmpvar_12; + tmpvar_12 = vec2(tmpvar_11); + vec2 tmpvar_13; + tmpvar_13 = tmpvar_12.xy; + vec4 tmpvar_14; + tmpvar_14 = texture2D (_LightTextureB0, tmpvar_13); + vec4 tmpvar_15; + tmpvar_15 = textureCube (_LightTexture0, IN._LightCoord); + vec4 tmpvar_16; + tmpvar_16 = LightingLambert (o, lightDir, (tmpvar_14.w * tmpvar_15.w)); + vec4 tmpvar_17; + tmpvar_17 = tmpvar_16; + c = tmpvar_17; + float tmpvar_18; + tmpvar_18 = o.Alpha; + c.w = vec4(tmpvar_18).w; + return c; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xy; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.normal = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.lightDir = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = gl_TexCoord[3].xyz; + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_IN._LightCoord = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = frag_surf (xlt_IN); + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xl_retval = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = xl_retval.xyzw; + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + gl_FragData[0] = tmpvar_14; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Diffuse-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Diffuse-out.txt new file mode 100644 index 000000000..78761124f --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Diffuse-out.txt @@ -0,0 +1,20 @@ +uniform sampler2D _MainTex; +uniform sampler2D _LightTextureB0; +uniform samplerCube _LightTexture0; +uniform vec4 _LightColor0; +uniform vec4 _Color; +void main () +{ + vec3 tmpvar_1; + tmpvar_1 = gl_TexCoord[3].xyz; + vec4 c; + vec4 tmpvar_2; + tmpvar_2 = (texture2D (_MainTex, gl_TexCoord[0].xy) * _Color); + vec4 c_i0_i1; + c_i0_i1.xyz = ((tmpvar_2.xyz * _LightColor0.xyz) * ((max (0.0, dot (gl_TexCoord[1].xyz, normalize (gl_TexCoord[2].xyz))) * (texture2D (_LightTextureB0, vec2(dot (tmpvar_1, tmpvar_1))).w * textureCube (_LightTexture0, tmpvar_1).w)) * 2.0)); + c_i0_i1.w = tmpvar_2.w; + c = c_i0_i1; + c.w = tmpvar_2.w; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Specular-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Specular-in.txt new file mode 100644 index 000000000..72f6765ed --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Specular-in.txt @@ -0,0 +1,104 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 normal; + vec3 lightDir; + vec3 viewDir; + vec2 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _Color; +uniform vec4 _LightColor0; +uniform sampler2D _LightTexture0; +uniform sampler2D _MainTex; +uniform float _Shininess; +uniform vec4 _SpecColor; +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingBlinnPhong( in SurfaceOutput s, in vec3 lightDir, in vec3 viewDir, in float atten ); +vec4 frag_surf( in v2f_surf IN ); +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 tex; + tex = texture2D( _MainTex, IN.uv_MainTex); + o.Albedo = (tex.xyz * _Color.xyz ); + o.Gloss = tex.w ; + o.Alpha = (tex.w * _Color.w ); + o.Specular = _Shininess; +} +vec4 LightingBlinnPhong( in SurfaceOutput s, in vec3 lightDir, in vec3 viewDir, in float atten ) { + vec3 h; + float diff; + float nh; + float spec; + vec4 c; + h = normalize( (lightDir + viewDir) ); + diff = max( 0.000000, dot( s.Normal, lightDir)); + nh = max( 0.000000, dot( s.Normal, h)); + spec = (pow( nh, (s.Specular * 128.000)) * s.Gloss); + c.xyz = ((((s.Albedo * _LightColor0.xyz ) * diff) + ((_LightColor0.xyz * _SpecColor.xyz ) * spec)) * (atten * 2.00000)); + c.w = (s.Alpha + (((_LightColor0.w * _SpecColor.w ) * spec) * atten)); + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec3 lightDir; + vec4 c; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + o.Normal = IN.normal; + surf( surfIN, o); + lightDir = IN.lightDir; + c = LightingBlinnPhong( o, lightDir, normalize( vec3( IN.viewDir) ), (texture2D( _LightTexture0, IN._LightCoord).w * 1.00000)); + c.w = o.Alpha; + return c; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec2( gl_TexCoord[0]); + xlt_IN.normal = vec3( gl_TexCoord[1]); + xlt_IN.lightDir = vec3( gl_TexCoord[2]); + xlt_IN.viewDir = vec3( gl_TexCoord[3]); + xlt_IN._LightCoord = vec2( gl_TexCoord[4]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Specular-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Specular-ir.txt new file mode 100644 index 000000000..861eee51b --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Specular-ir.txt @@ -0,0 +1,194 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 normal; + vec3 lightDir; + vec3 viewDir; + vec2 _LightCoord; +}; +varying vec4 xlv_FOG; +uniform vec4 _SpecColor; +uniform float _Shininess; +uniform sampler2D _MainTex; +uniform sampler2D _LightTexture0; +uniform vec4 _LightColor0; +uniform vec4 _Color; +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 tex; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + tex = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = (tex.xyz * _Color.xyz); + o.Albedo = tmpvar_3; + float tmpvar_4; + tmpvar_4 = tex.w; + o.Gloss = tmpvar_4; + float tmpvar_5; + tmpvar_5 = (tex.w * _Color.w); + o.Alpha = tmpvar_5; + float tmpvar_6; + tmpvar_6 = _Shininess; + o.Specular = tmpvar_6; +} + +vec4 LightingBlinnPhong ( + in SurfaceOutput s, + in vec3 lightDir, + in vec3 viewDir, + in float atten +) +{ + vec4 c; + float spec; + float nh; + float diff; + vec3 h; + vec3 tmpvar_1; + tmpvar_1 = normalize ((lightDir + viewDir)); + vec3 tmpvar_2; + tmpvar_2 = tmpvar_1; + h = tmpvar_2; + float tmpvar_3; + tmpvar_3 = dot (s.Normal, lightDir); + float tmpvar_4; + tmpvar_4 = max (0.0, tmpvar_3); + float tmpvar_5; + tmpvar_5 = tmpvar_4; + diff = tmpvar_5; + float tmpvar_6; + tmpvar_6 = dot (s.Normal, h); + float tmpvar_7; + tmpvar_7 = max (0.0, tmpvar_6); + float tmpvar_8; + tmpvar_8 = tmpvar_7; + nh = tmpvar_8; + float tmpvar_9; + tmpvar_9 = pow (nh, (s.Specular * 128.0)); + float tmpvar_10; + tmpvar_10 = (tmpvar_9 * s.Gloss); + spec = tmpvar_10; + vec3 tmpvar_11; + tmpvar_11 = ((((s.Albedo * _LightColor0.xyz) * diff) + ((_LightColor0.xyz * _SpecColor.xyz) * spec)) * (atten * 2.0)); + c.xyz = tmpvar_11.xyz.xyz; + float tmpvar_12; + tmpvar_12 = (s.Alpha + (((_LightColor0.w * _SpecColor.w) * spec) * atten)); + c.w = vec4(tmpvar_12).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 c; + vec3 lightDir; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_3; + float tmpvar_4; + tmpvar_4 = 0.0; + o.Specular = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Alpha = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Gloss = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = IN.normal; + o.Normal = tmpvar_7; + surf (surfIN, o); + vec3 tmpvar_8; + tmpvar_8 = IN.lightDir; + lightDir = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = IN.viewDir.xyz; + vec3 tmpvar_10; + tmpvar_10 = normalize (tmpvar_9); + vec4 tmpvar_11; + tmpvar_11 = texture2D (_LightTexture0, IN._LightCoord); + vec4 tmpvar_12; + tmpvar_12 = LightingBlinnPhong (o, lightDir, tmpvar_10, (tmpvar_11.w * 1.0)); + vec4 tmpvar_13; + tmpvar_13 = tmpvar_12; + c = tmpvar_13; + float tmpvar_14; + tmpvar_14 = o.Alpha; + c.w = vec4(tmpvar_14).w; + return c; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xy; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_TexCoord[1].xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.normal = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = gl_TexCoord[2].xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.lightDir = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = gl_TexCoord[3].xyz; + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_IN.viewDir = tmpvar_10; + vec2 tmpvar_11; + tmpvar_11 = gl_TexCoord[4].xy; + vec2 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_IN._LightCoord = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = frag_surf (xlt_IN); + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_FragData[0] = tmpvar_16; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Specular-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Specular-out.txt new file mode 100644 index 000000000..6f5efaf0f --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Transparent_Specular-out.txt @@ -0,0 +1,29 @@ +uniform vec4 _SpecColor; +uniform float _Shininess; +uniform sampler2D _MainTex; +uniform sampler2D _LightTexture0; +uniform vec4 _LightColor0; +uniform vec4 _Color; +void main () +{ + vec3 tmpvar_1; + tmpvar_1 = gl_TexCoord[1].xyz; + vec3 tmpvar_2; + tmpvar_2 = gl_TexCoord[2].xyz; + vec4 c; + vec4 tmpvar_3; + tmpvar_3 = texture2D (_MainTex, gl_TexCoord[0].xy); + float tmpvar_4; + tmpvar_4 = (tmpvar_3.w * _Color.w); + float atten; + atten = texture2D (_LightTexture0, gl_TexCoord[4].xy).w; + vec4 c_i0; + float tmpvar_5; + tmpvar_5 = (pow (max (0.0, dot (tmpvar_1, normalize ((tmpvar_2 + normalize (gl_TexCoord[3].xyz))))), (_Shininess * 128.0)) * tmpvar_3.w); + c_i0.xyz = (((((tmpvar_3.xyz * _Color.xyz) * _LightColor0.xyz) * max (0.0, dot (tmpvar_1, tmpvar_2))) + ((_LightColor0.xyz * _SpecColor.xyz) * tmpvar_5)) * (atten * 2.0)); + c_i0.w = (tmpvar_4 + (((_LightColor0.w * _SpecColor.w) * tmpvar_5) * atten)); + c = c_i0; + c.w = tmpvar_4; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-TreeCreatorLeavesRT-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-TreeCreatorLeavesRT-in.txt new file mode 100644 index 000000000..f6e77189c --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-TreeCreatorLeavesRT-in.txt @@ -0,0 +1,66 @@ +void xll_clip(float x) { + if ( x<0.0 ) discard; +} +struct v2f { + vec4 pos; + vec2 uv; + vec3 color; + vec3 backContrib; + vec3 nl; + vec3 nh; +}; +uniform sampler2D _BumpSpecMap; +uniform float _Cutoff; +uniform sampler2D _MainTex; +uniform vec4 _SpecColor; +uniform vec4 _TerrainTreeLightColors[4]; +uniform vec3 _TranslucencyColor; +uniform sampler2D _TranslucencyMap; + +vec4 frag( in v2f i ) { + vec4 col; + vec3 albedo; + float specular; + vec4 trngls; + float gloss; + vec3 light; + vec3 backContribs; + int j = 0; + vec3 lightColor; + vec3 translucencyColor; + float nl; + float nh; + float spec; + vec4 c; + col = texture2D( _MainTex, i.uv); + xll_clip( (col.w - _Cutoff) ); + albedo = (col.xyz * i.color); + specular = (texture2D( _BumpSpecMap, i.uv).x * 128.000); + trngls = texture2D( _TranslucencyMap, i.uv); + gloss = trngls.w ; + light = (vec3( gl_LightModel.ambient) * albedo); + backContribs = (i.backContrib * trngls.z ); + for ( ; (j < 3); ( j++ )) { + lightColor = _TerrainTreeLightColors[ j ].xyz ; + translucencyColor = (backContribs[ j ] * _TranslucencyColor); + nl = i.nl[ j ]; + nh = i.nh[ j ]; + spec = (pow( nh, specular) * gloss); + light += (((albedo * (translucencyColor + nl)) + (_SpecColor.xyz * spec)) * lightColor); + } + c.xyz = (light * 2.00000); + c.w = 1.00000; + return c; +} +void main() { + vec4 xl_retval; + v2f xlt_i; + xlt_i.pos = vec4(0.0); + xlt_i.uv = vec2( gl_TexCoord[0]); + xlt_i.color = vec3( gl_TexCoord[1]); + xlt_i.backContrib = vec3( gl_TexCoord[2]); + xlt_i.nl = vec3( gl_TexCoord[3]); + xlt_i.nh = vec3( gl_TexCoord[4]); + xl_retval = frag( xlt_i); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-TreeCreatorLeavesRT-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-TreeCreatorLeavesRT-ir.txt new file mode 100644 index 000000000..63ac2a6b3 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-TreeCreatorLeavesRT-ir.txt @@ -0,0 +1,158 @@ +struct v2f { + vec4 pos; + vec2 uv; + vec3 color; + vec3 backContrib; + vec3 nl; + vec3 nh; +}; +uniform sampler2D _TranslucencyMap; +uniform vec3 _TranslucencyColor; +uniform vec4 _TerrainTreeLightColors[4]; +uniform vec4 _SpecColor; +uniform sampler2D _MainTex; +uniform float _Cutoff; +uniform sampler2D _BumpSpecMap; +void xll_clip ( + in float x +) +{ + if ((x < 0.0)) { + discard; + }; +} + +vec4 frag ( + in v2f i +) +{ + vec4 c; + float spec; + float nh; + float nl; + vec3 translucencyColor; + vec3 lightColor; + int j; + vec3 backContribs; + vec3 light; + float gloss; + vec4 trngls; + float specular; + vec3 albedo; + vec4 col; + int tmpvar_1; + tmpvar_1 = 0; + j = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = texture2D (_MainTex, i.uv); + vec4 tmpvar_3; + tmpvar_3 = tmpvar_2; + col = tmpvar_3; + xll_clip ((col.w - _Cutoff)); + vec3 tmpvar_4; + tmpvar_4 = (col.xyz * i.color); + albedo = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = texture2D (_BumpSpecMap, i.uv); + float tmpvar_6; + tmpvar_6 = (tmpvar_5.x * 128.0); + specular = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = texture2D (_TranslucencyMap, i.uv); + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + trngls = tmpvar_8; + float tmpvar_9; + tmpvar_9 = trngls.w; + gloss = tmpvar_9; + vec3 tmpvar_10; + tmpvar_10 = gl_LightModel.ambient.xyz; + vec3 tmpvar_11; + tmpvar_11 = (tmpvar_10 * albedo); + light = tmpvar_11; + vec3 tmpvar_12; + tmpvar_12 = (i.backContrib * trngls.z); + backContribs = tmpvar_12; + while (true) { + if (!((j < 3))) { + break; + }; + vec3 tmpvar_13; + tmpvar_13 = _TerrainTreeLightColors[j].xyz; + lightColor = tmpvar_13; + vec3 tmpvar_14; + tmpvar_14 = (backContribs[j] * _TranslucencyColor); + translucencyColor = tmpvar_14; + float tmpvar_15; + tmpvar_15 = i.nl[j]; + nl = tmpvar_15; + float tmpvar_16; + tmpvar_16 = i.nh[j]; + nh = tmpvar_16; + float tmpvar_17; + tmpvar_17 = pow (nh, specular); + float tmpvar_18; + tmpvar_18 = (tmpvar_17 * gloss); + spec = tmpvar_18; + vec3 tmpvar_19; + tmpvar_19 = (light + (((albedo * (translucencyColor + nl)) + (_SpecColor.xyz * spec)) * lightColor)); + light = tmpvar_19; + int _post_incdec_tmp; + _post_incdec_tmp = j; + int tmpvar_20; + tmpvar_20 = (j + 1); + j = tmpvar_20; + }; + vec3 tmpvar_21; + tmpvar_21 = (light * 2.0); + c.xyz = tmpvar_21.xyz.xyz; + float tmpvar_22; + tmpvar_22 = 1.0; + c.w = vec4(tmpvar_22).w; + return c; +} + +void main () +{ + v2f xlt_i; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_i.pos = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = gl_TexCoord[0].xy; + vec2 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_i.uv = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = gl_TexCoord[1].xyz; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_4; + xlt_i.color = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = gl_TexCoord[2].xyz; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_6; + xlt_i.backContrib = tmpvar_7; + vec3 tmpvar_8; + tmpvar_8 = gl_TexCoord[3].xyz; + vec3 tmpvar_9; + tmpvar_9 = tmpvar_8; + xlt_i.nl = tmpvar_9; + vec3 tmpvar_10; + tmpvar_10 = gl_TexCoord[4].xyz; + vec3 tmpvar_11; + tmpvar_11 = tmpvar_10; + xlt_i.nh = tmpvar_11; + vec4 tmpvar_12; + tmpvar_12 = frag (xlt_i); + vec4 tmpvar_13; + tmpvar_13 = tmpvar_12; + xl_retval = tmpvar_13; + vec4 tmpvar_14; + tmpvar_14 = xl_retval.xyzw; + vec4 tmpvar_15; + tmpvar_15 = tmpvar_14; + gl_FragData[0] = tmpvar_15; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-TreeCreatorLeavesRT-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-TreeCreatorLeavesRT-out.txt new file mode 100644 index 000000000..ae33185e9 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-TreeCreatorLeavesRT-out.txt @@ -0,0 +1,55 @@ +uniform sampler2D _TranslucencyMap; +uniform vec3 _TranslucencyColor; +uniform vec4 _TerrainTreeLightColors[4]; +uniform vec4 _SpecColor; +uniform sampler2D _MainTex; +uniform float _Cutoff; +uniform sampler2D _BumpSpecMap; +void main () +{ + vec2 tmpvar_1; + tmpvar_1 = gl_TexCoord[0].xy; + vec3 tmpvar_2; + tmpvar_2 = gl_TexCoord[1].xyz; + vec3 tmpvar_3; + tmpvar_3 = gl_TexCoord[2].xyz; + vec3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_4 = gl_TexCoord[3].xyz; + tmpvar_5 = gl_TexCoord[4].xyz; + vec4 c; + int j; + vec3 backContribs; + vec3 light; + float gloss; + float specular; + vec3 albedo; + j = 0; + vec4 tmpvar_6; + tmpvar_6 = texture2D (_MainTex, tmpvar_1); + float x; + x = (tmpvar_6.w - _Cutoff); + if ((x < 0.0)) { + discard; + }; + vec3 tmpvar_7; + tmpvar_7 = (tmpvar_6.xyz * tmpvar_2); + albedo = tmpvar_7; + specular = (texture2D (_BumpSpecMap, tmpvar_1).x * 128.0); + vec4 tmpvar_8; + tmpvar_8 = texture2D (_TranslucencyMap, tmpvar_1); + gloss = tmpvar_8.w; + light = (gl_LightModel.ambient.xyz * tmpvar_7); + backContribs = (tmpvar_3 * tmpvar_8.z); + while (true) { + if ((j >= 3)) { + break; + }; + light = (light + (((albedo * ((backContribs[j] * _TranslucencyColor) + tmpvar_4[j])) + (_SpecColor.xyz * (pow (tmpvar_5[j], specular) * gloss))) * _TerrainTreeLightColors[j].xyz)); + j = (j + 1); + }; + c.xyz = (light * 2.0); + c.w = 1.0; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Tree_Editor_Bark_Shader-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Tree_Editor_Bark_Shader-in.txt new file mode 100644 index 000000000..1060b0f49 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Tree_Editor_Bark_Shader-in.txt @@ -0,0 +1,120 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +struct LeafSurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + vec3 Translucency; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec4 color; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 lop_color; + vec3 lightDir; + vec3 viewDir; +}; +uniform sampler2D _BumpMap; +uniform vec4 _Color; +uniform sampler2D _GlossMap; +uniform vec4 _LightColor0; +uniform sampler2D _MainTex; +uniform float _Shininess; +vec4 UnpackNormal( in vec4 packednormal ); +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingTreeBark( in SurfaceOutput s, in vec3 lightDir, in vec3 viewDir, in float atten ); +vec4 frag_surf( in v2f_surf IN ); +vec4 UnpackNormal( in vec4 packednormal ) { + vec4 normal; + normal.xy = ((packednormal.wy * 2.00000) - 1.00000); + normal.z = sqrt( ((1.00000 - (normal.x * normal.x )) - (normal.y * normal.y )) ); + return normal; +} +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 c; + c = texture2D( _MainTex, IN.uv_MainTex); + o.Albedo = (c.xyz * IN.color.xyz ); + o.Gloss = texture2D( _GlossMap, IN.uv_MainTex).w ; + o.Alpha = _Color.w ; + o.Specular = _Shininess; + o.Normal = vec3( UnpackNormal( texture2D( _BumpMap, IN.uv_MainTex))); +} +vec4 LightingTreeBark( in SurfaceOutput s, in vec3 lightDir, in vec3 viewDir, in float atten ) { + vec3 h; + float diff; + float nh; + float spec; + vec4 c; + h = normalize( (lightDir + viewDir) ); + diff = max( 0.000000, dot( s.Normal, lightDir)); + nh = max( 0.000000, dot( s.Normal, h)); + spec = (pow( nh, (s.Specular * 128.000)) * s.Gloss); + c.xyz = ((((s.Albedo * _LightColor0.xyz ) * diff) + (_LightColor0.xyz * spec)) * (atten * 2.00000)); + c.w = (((_LightColor0.w * spec) * atten) * s.Alpha); + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec3 lightDir; + vec4 c; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + surfIN.color = IN.lop_color; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + surf( surfIN, o); + lightDir = IN.lightDir; + c = LightingTreeBark( o, lightDir, normalize( vec3( IN.viewDir) ), 1.00000); + c.w = 0.000000; + return c; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec2( gl_TexCoord[0]); + xlt_IN.lop_color = vec4( gl_Color); + xlt_IN.lightDir = vec3( gl_TexCoord[1]); + xlt_IN.viewDir = vec3( gl_TexCoord[2]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Tree_Editor_Bark_Shader-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Tree_Editor_Bark_Shader-ir.txt new file mode 100644 index 000000000..421464c32 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Tree_Editor_Bark_Shader-ir.txt @@ -0,0 +1,214 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec4 color; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 lop_color; + vec3 lightDir; + vec3 viewDir; +}; +varying vec4 xlv_FOG; +uniform float _Shininess; +uniform sampler2D _MainTex; +uniform vec4 _LightColor0; +uniform sampler2D _GlossMap; +uniform vec4 _Color; +uniform sampler2D _BumpMap; +vec4 UnpackNormal ( + in vec4 packednormal +) +{ + vec4 normal; + vec2 tmpvar_1; + tmpvar_1 = ((packednormal.wy * 2.0) - 1.0); + normal.xy = tmpvar_1.xy.xy; + float tmpvar_2; + tmpvar_2 = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + normal.z = vec3(tmpvar_3).z; + return normal; +} + +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 c; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + c = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = (c.xyz * IN.color.xyz); + o.Albedo = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = texture2D (_GlossMap, IN.uv_MainTex); + float tmpvar_5; + tmpvar_5 = tmpvar_4.w; + o.Gloss = tmpvar_5; + float tmpvar_6; + tmpvar_6 = _Color.w; + o.Alpha = tmpvar_6; + float tmpvar_7; + tmpvar_7 = _Shininess; + o.Specular = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = texture2D (_BumpMap, IN.uv_MainTex); + vec4 tmpvar_9; + tmpvar_9 = UnpackNormal (tmpvar_8); + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9.xyz; + vec3 tmpvar_11; + tmpvar_11 = tmpvar_10; + o.Normal = tmpvar_11; +} + +vec4 LightingTreeBark ( + in SurfaceOutput s, + in vec3 lightDir, + in vec3 viewDir, + in float atten +) +{ + vec4 c; + float spec; + float nh; + float diff; + vec3 h; + vec3 tmpvar_1; + tmpvar_1 = normalize ((lightDir + viewDir)); + vec3 tmpvar_2; + tmpvar_2 = tmpvar_1; + h = tmpvar_2; + float tmpvar_3; + tmpvar_3 = dot (s.Normal, lightDir); + float tmpvar_4; + tmpvar_4 = max (0.0, tmpvar_3); + float tmpvar_5; + tmpvar_5 = tmpvar_4; + diff = tmpvar_5; + float tmpvar_6; + tmpvar_6 = dot (s.Normal, h); + float tmpvar_7; + tmpvar_7 = max (0.0, tmpvar_6); + float tmpvar_8; + tmpvar_8 = tmpvar_7; + nh = tmpvar_8; + float tmpvar_9; + tmpvar_9 = pow (nh, (s.Specular * 128.0)); + float tmpvar_10; + tmpvar_10 = (tmpvar_9 * s.Gloss); + spec = tmpvar_10; + vec3 tmpvar_11; + tmpvar_11 = ((((s.Albedo * _LightColor0.xyz) * diff) + (_LightColor0.xyz * spec)) * (atten * 2.0)); + c.xyz = tmpvar_11.xyz.xyz; + float tmpvar_12; + tmpvar_12 = (((_LightColor0.w * spec) * atten) * s.Alpha); + c.w = vec4(tmpvar_12).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 c; + vec3 lightDir; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = IN.lop_color; + surfIN.color = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Specular = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Alpha = tmpvar_6; + float tmpvar_7; + tmpvar_7 = 0.0; + o.Gloss = tmpvar_7; + surf (surfIN, o); + vec3 tmpvar_8; + tmpvar_8 = IN.lightDir; + lightDir = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = IN.viewDir.xyz; + vec3 tmpvar_10; + tmpvar_10 = normalize (tmpvar_9); + vec4 tmpvar_11; + tmpvar_11 = LightingTreeBark (o, lightDir, tmpvar_10, 1.0); + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + c = tmpvar_12; + float tmpvar_13; + tmpvar_13 = 0.0; + c.w = vec4(tmpvar_13).w; + return c; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xy; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = gl_Color.xyzw; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.lop_color = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = gl_TexCoord[1].xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.lightDir = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = gl_TexCoord[2].xyz; + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_IN.viewDir = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = frag_surf (xlt_IN); + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xl_retval = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = xl_retval.xyzw; + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + gl_FragData[0] = tmpvar_14; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Tree_Editor_Bark_Shader-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Tree_Editor_Bark_Shader-out.txt new file mode 100644 index 000000000..95002af2d --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Tree_Editor_Bark_Shader-out.txt @@ -0,0 +1,28 @@ +uniform float _Shininess; +uniform sampler2D _MainTex; +uniform vec4 _LightColor0; +uniform sampler2D _GlossMap; +uniform vec4 _Color; +uniform sampler2D _BumpMap; +void main () +{ + vec3 tmpvar_1; + tmpvar_1 = gl_TexCoord[1].xyz; + vec4 c; + vec2 tmpvar_2; + tmpvar_2 = gl_TexCoord[0].xy; + vec4 normal; + normal.xy = ((texture2D (_BumpMap, tmpvar_2).wy * 2.0) - 1.0); + normal.z = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + vec3 tmpvar_3; + tmpvar_3 = normal.xyz; + vec4 c_i0_i1; + float tmpvar_4; + tmpvar_4 = (pow (max (0.0, dot (tmpvar_3, normalize ((tmpvar_1 + normalize (gl_TexCoord[2].xyz))))), (_Shininess * 128.0)) * texture2D (_GlossMap, tmpvar_2).w); + c_i0_i1.xyz = (((((texture2D (_MainTex, tmpvar_2).xyz * gl_Color.xyz) * _LightColor0.xyz) * max (0.0, dot (tmpvar_3, tmpvar_1))) + (_LightColor0.xyz * tmpvar_4)) * 2.0); + c_i0_i1.w = ((_LightColor0.w * tmpvar_4) * _Color.w); + c = c_i0_i1; + c.w = 0.0; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Tree_Editor_Bark_Shader1-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Tree_Editor_Bark_Shader1-in.txt new file mode 100644 index 000000000..98070bde4 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Tree_Editor_Bark_Shader1-in.txt @@ -0,0 +1,125 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +struct LeafSurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + vec3 Translucency; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec4 color; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 lop_color; + vec3 lightDir; + vec3 viewDir; + vec3 _LightCoord; +}; +uniform sampler2D _BumpMap; +uniform vec4 _Color; +uniform sampler2D _GlossMap; +uniform vec4 _LightColor0; +uniform samplerCube _LightTexture0; +uniform sampler2D _LightTextureB0; +uniform sampler2D _MainTex; +uniform float _Shininess; +vec4 UnpackNormal( in vec4 packednormal ); +void surf( in Input IN, inout SurfaceOutput o ); +vec4 LightingTreeBark( in SurfaceOutput s, in vec3 lightDir, in vec3 viewDir, in float atten ); +vec4 frag_surf( in v2f_surf IN ); +vec4 UnpackNormal( in vec4 packednormal ) { + vec4 normal; + normal.xy = ((packednormal.wy * 2.00000) - 1.00000); + normal.z = sqrt( ((1.00000 - (normal.x * normal.x )) - (normal.y * normal.y )) ); + return normal; +} +void surf( in Input IN, inout SurfaceOutput o ) { + vec4 c; + c = texture2D( _MainTex, IN.uv_MainTex); + o.Albedo = (c.xyz * IN.color.xyz ); + o.Gloss = texture2D( _GlossMap, IN.uv_MainTex).w ; + o.Alpha = _Color.w ; + o.Specular = _Shininess; + o.Normal = vec3( UnpackNormal( texture2D( _BumpMap, IN.uv_MainTex))); +} +vec4 LightingTreeBark( in SurfaceOutput s, in vec3 lightDir, in vec3 viewDir, in float atten ) { + vec3 h; + float diff; + float nh; + float spec; + vec4 c; + h = normalize( (lightDir + viewDir) ); + diff = max( 0.000000, dot( s.Normal, lightDir)); + nh = max( 0.000000, dot( s.Normal, h)); + spec = (pow( nh, (s.Specular * 128.000)) * s.Gloss); + c.xyz = ((((s.Albedo * _LightColor0.xyz ) * diff) + (_LightColor0.xyz * spec)) * (atten * 2.00000)); + c.w = (((_LightColor0.w * spec) * atten) * s.Alpha); + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + SurfaceOutput o; + vec3 lightDir; + vec4 c; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + surfIN.color = IN.lop_color; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + o.Gloss = 0.000000; + surf( surfIN, o); + lightDir = IN.lightDir; + lightDir = normalize( lightDir ); + c = LightingTreeBark( o, lightDir, normalize( vec3( IN.viewDir) ), (texture2D( _LightTextureB0, vec2( vec2( dot( IN._LightCoord, IN._LightCoord)))).w * textureCube( _LightTexture0, IN._LightCoord).w )); + c.w = 0.000000; + return c; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec2( gl_TexCoord[0]); + xlt_IN.lop_color = vec4( gl_Color); + xlt_IN.lightDir = vec3( gl_TexCoord[1]); + xlt_IN.viewDir = vec3( gl_TexCoord[2]); + xlt_IN._LightCoord = vec3( gl_TexCoord[3]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Tree_Editor_Bark_Shader1-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Tree_Editor_Bark_Shader1-ir.txt new file mode 100644 index 000000000..0cca7f57f --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Tree_Editor_Bark_Shader1-ir.txt @@ -0,0 +1,237 @@ +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec4 color; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 lop_color; + vec3 lightDir; + vec3 viewDir; + vec3 _LightCoord; +}; +varying vec4 xlv_FOG; +uniform float _Shininess; +uniform sampler2D _MainTex; +uniform sampler2D _LightTextureB0; +uniform samplerCube _LightTexture0; +uniform vec4 _LightColor0; +uniform sampler2D _GlossMap; +uniform vec4 _Color; +uniform sampler2D _BumpMap; +vec4 UnpackNormal ( + in vec4 packednormal +) +{ + vec4 normal; + vec2 tmpvar_1; + tmpvar_1 = ((packednormal.wy * 2.0) - 1.0); + normal.xy = tmpvar_1.xy.xy; + float tmpvar_2; + tmpvar_2 = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + normal.z = vec3(tmpvar_3).z; + return normal; +} + +void surf ( + in Input IN, + inout SurfaceOutput o +) +{ + vec4 c; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + c = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = (c.xyz * IN.color.xyz); + o.Albedo = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = texture2D (_GlossMap, IN.uv_MainTex); + float tmpvar_5; + tmpvar_5 = tmpvar_4.w; + o.Gloss = tmpvar_5; + float tmpvar_6; + tmpvar_6 = _Color.w; + o.Alpha = tmpvar_6; + float tmpvar_7; + tmpvar_7 = _Shininess; + o.Specular = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = texture2D (_BumpMap, IN.uv_MainTex); + vec4 tmpvar_9; + tmpvar_9 = UnpackNormal (tmpvar_8); + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9.xyz; + vec3 tmpvar_11; + tmpvar_11 = tmpvar_10; + o.Normal = tmpvar_11; +} + +vec4 LightingTreeBark ( + in SurfaceOutput s, + in vec3 lightDir, + in vec3 viewDir, + in float atten +) +{ + vec4 c; + float spec; + float nh; + float diff; + vec3 h; + vec3 tmpvar_1; + tmpvar_1 = normalize ((lightDir + viewDir)); + vec3 tmpvar_2; + tmpvar_2 = tmpvar_1; + h = tmpvar_2; + float tmpvar_3; + tmpvar_3 = dot (s.Normal, lightDir); + float tmpvar_4; + tmpvar_4 = max (0.0, tmpvar_3); + float tmpvar_5; + tmpvar_5 = tmpvar_4; + diff = tmpvar_5; + float tmpvar_6; + tmpvar_6 = dot (s.Normal, h); + float tmpvar_7; + tmpvar_7 = max (0.0, tmpvar_6); + float tmpvar_8; + tmpvar_8 = tmpvar_7; + nh = tmpvar_8; + float tmpvar_9; + tmpvar_9 = pow (nh, (s.Specular * 128.0)); + float tmpvar_10; + tmpvar_10 = (tmpvar_9 * s.Gloss); + spec = tmpvar_10; + vec3 tmpvar_11; + tmpvar_11 = ((((s.Albedo * _LightColor0.xyz) * diff) + (_LightColor0.xyz * spec)) * (atten * 2.0)); + c.xyz = tmpvar_11.xyz.xyz; + float tmpvar_12; + tmpvar_12 = (((_LightColor0.w * spec) * atten) * s.Alpha); + c.w = vec4(tmpvar_12).w; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 c; + vec3 lightDir; + SurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = IN.lop_color; + surfIN.color = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Specular = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Alpha = tmpvar_6; + float tmpvar_7; + tmpvar_7 = 0.0; + o.Gloss = tmpvar_7; + surf (surfIN, o); + vec3 tmpvar_8; + tmpvar_8 = IN.lightDir; + lightDir = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = normalize (lightDir); + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + lightDir = tmpvar_10; + vec3 tmpvar_11; + tmpvar_11 = IN.viewDir.xyz; + vec3 tmpvar_12; + tmpvar_12 = normalize (tmpvar_11); + float tmpvar_13; + tmpvar_13 = dot (IN._LightCoord, IN._LightCoord); + vec2 tmpvar_14; + tmpvar_14 = vec2(tmpvar_13); + vec2 tmpvar_15; + tmpvar_15 = tmpvar_14.xy; + vec4 tmpvar_16; + tmpvar_16 = texture2D (_LightTextureB0, tmpvar_15); + vec4 tmpvar_17; + tmpvar_17 = textureCube (_LightTexture0, IN._LightCoord); + vec4 tmpvar_18; + tmpvar_18 = LightingTreeBark (o, lightDir, tmpvar_12, (tmpvar_16.w * tmpvar_17.w)); + vec4 tmpvar_19; + tmpvar_19 = tmpvar_18; + c = tmpvar_19; + float tmpvar_20; + tmpvar_20 = 0.0; + c.w = vec4(tmpvar_20).w; + return c; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xy; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = gl_Color.xyzw; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.lop_color = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = gl_TexCoord[1].xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.lightDir = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = gl_TexCoord[2].xyz; + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_IN.viewDir = tmpvar_10; + vec3 tmpvar_11; + tmpvar_11 = gl_TexCoord[3].xyz; + vec3 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_IN._LightCoord = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = frag_surf (xlt_IN); + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_FragData[0] = tmpvar_16; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Tree_Editor_Bark_Shader1-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Tree_Editor_Bark_Shader1-out.txt new file mode 100644 index 000000000..5b91da654 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Tree_Editor_Bark_Shader1-out.txt @@ -0,0 +1,34 @@ +uniform float _Shininess; +uniform sampler2D _MainTex; +uniform sampler2D _LightTextureB0; +uniform samplerCube _LightTexture0; +uniform vec4 _LightColor0; +uniform sampler2D _GlossMap; +uniform vec4 _Color; +uniform sampler2D _BumpMap; +void main () +{ + vec3 tmpvar_1; + tmpvar_1 = gl_TexCoord[3].xyz; + vec4 c; + vec2 tmpvar_2; + tmpvar_2 = gl_TexCoord[0].xy; + vec4 normal; + normal.xy = ((texture2D (_BumpMap, tmpvar_2).wy * 2.0) - 1.0); + normal.z = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + vec3 tmpvar_3; + tmpvar_3 = normal.xyz; + vec3 tmpvar_4; + tmpvar_4 = normalize (gl_TexCoord[1].xyz); + float atten; + atten = (texture2D (_LightTextureB0, vec2(dot (tmpvar_1, tmpvar_1))).w * textureCube (_LightTexture0, tmpvar_1).w); + vec4 c_i0_i1; + float tmpvar_5; + tmpvar_5 = (pow (max (0.0, dot (tmpvar_3, normalize ((tmpvar_4 + normalize (gl_TexCoord[2].xyz))))), (_Shininess * 128.0)) * texture2D (_GlossMap, tmpvar_2).w); + c_i0_i1.xyz = (((((texture2D (_MainTex, tmpvar_2).xyz * gl_Color.xyz) * _LightColor0.xyz) * max (0.0, dot (tmpvar_3, tmpvar_4))) + (_LightColor0.xyz * tmpvar_5)) * (atten * 2.0)); + c_i0_i1.w = (((_LightColor0.w * tmpvar_5) * atten) * _Color.w); + c = c_i0_i1; + c.w = 0.0; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Tree_Editor_Leaf_Shader-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Tree_Editor_Leaf_Shader-in.txt new file mode 100644 index 000000000..137dd9847 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Tree_Editor_Leaf_Shader-in.txt @@ -0,0 +1,160 @@ +void xll_clip(float x) { + if ( x<0.0 ) discard; +} +float xll_saturate( float x) { + return clamp( x, 0.0, 1.0); +} +vec2 xll_saturate( vec2 x) { + return clamp( x, 0.0, 1.0); +} +vec3 xll_saturate( vec3 x) { + return clamp( x, 0.0, 1.0); +} +vec4 xll_saturate( vec4 x) { + return clamp( x, 0.0, 1.0); +} +mat2 xll_saturate(mat2 m) { + return mat2( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0)); +} +mat3 xll_saturate(mat3 m) { + return mat3( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0), clamp(m[2], 0.0, 1.0)); +} +mat4 xll_saturate(mat4 m) { + return mat4( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0), clamp(m[2], 0.0, 1.0), clamp(m[3], 0.0, 1.0)); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +struct LeafSurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + vec3 Translucency; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec4 color; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 lop_color; + vec3 lightDir; + vec3 viewDir; + vec3 _LightCoord; +}; +uniform sampler2D _BumpMap; +uniform float _Cutoff; +uniform sampler2D _GlossMap; +uniform vec4 _LightColor0; +uniform samplerCube _LightTexture0; +uniform sampler2D _LightTextureB0; +uniform sampler2D _MainTex; +uniform float _Shininess; +uniform vec4 _TranslucencyColor; +uniform sampler2D _TranslucencyMap; +vec4 UnpackNormal( in vec4 packednormal ); +void surf( in Input IN, inout LeafSurfaceOutput o ); +vec4 LightingTreeLeaf( in LeafSurfaceOutput s, in vec3 lightDir, in vec3 viewDir, in float atten ); +vec4 frag_surf( in v2f_surf IN ); +vec4 UnpackNormal( in vec4 packednormal ) { + vec4 normal; + normal.xy = ((packednormal.wy * 2.00000) - 1.00000); + normal.z = sqrt( ((1.00000 - (normal.x * normal.x )) - (normal.y * normal.y )) ); + return normal; +} +void surf( in Input IN, inout LeafSurfaceOutput o ) { + vec4 c; + c = texture2D( _MainTex, IN.uv_MainTex); + o.Albedo = (c.xyz * IN.color.xyz ); + o.Translucency = (texture2D( _TranslucencyMap, IN.uv_MainTex).xyz * vec3( _TranslucencyColor)); + o.Gloss = texture2D( _GlossMap, IN.uv_MainTex).w ; + o.Alpha = (c.w * IN.color.w ); + o.Specular = _Shininess; + o.Normal = vec3( UnpackNormal( texture2D( _BumpMap, IN.uv_MainTex))); +} +vec4 LightingTreeLeaf( in LeafSurfaceOutput s, in vec3 lightDir, in vec3 viewDir, in float atten ) { + vec3 h; + float diff; + float nh; + float spec; + float trans; + vec3 translucencyColor; + vec3 col; + vec4 c; + h = normalize( (lightDir + viewDir) ); + diff = dot( s.Normal, lightDir); + nh = max( 0.000000, dot( s.Normal, h)); + spec = (pow( nh, (s.Specular * 128.000)) * s.Gloss); + trans = max( 0.000000, ( -diff )); + translucencyColor = ((s.Translucency * trans) * 2.00000); + diff = max( 0.000000, ((diff * 0.500000) + 0.500000)); + col = (s.Albedo * (diff + translucencyColor)); + col += (spec * (1.00000 - xll_saturate( ceil( trans ) ))); + col *= _LightColor0.xyz ; + c.xyz = (col * (atten * 2.00000)); + return c; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + LeafSurfaceOutput o; + vec3 lightDir; + vec4 c; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + surfIN.color = IN.lop_color; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + surf( surfIN, o); + xll_clip( (o.Alpha - _Cutoff) ); + lightDir = IN.lightDir; + lightDir = normalize( lightDir ); + c = LightingTreeLeaf( o, lightDir, normalize( vec3( IN.viewDir) ), (texture2D( _LightTextureB0, vec2( vec2( dot( IN._LightCoord, IN._LightCoord)))).w * textureCube( _LightTexture0, IN._LightCoord).w )); + c.w = o.Alpha; + return c; +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.fog = float( xlv_FOG); + xlt_IN.hip_pack0 = vec2( gl_TexCoord[0]); + xlt_IN.lop_color = vec4( gl_Color); + xlt_IN.lightDir = vec3( gl_TexCoord[1]); + xlt_IN.viewDir = vec3( gl_TexCoord[2]); + xlt_IN._LightCoord = vec3( gl_TexCoord[3]); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Tree_Editor_Leaf_Shader-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Tree_Editor_Leaf_Shader-ir.txt new file mode 100644 index 000000000..6f679448d --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Tree_Editor_Leaf_Shader-ir.txt @@ -0,0 +1,383 @@ +struct LeafSurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + vec3 Translucency; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec4 color; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 lop_color; + vec3 lightDir; + vec3 viewDir; + vec3 _LightCoord; +}; +varying vec4 xlv_FOG; +uniform sampler2D _TranslucencyMap; +uniform vec4 _TranslucencyColor; +uniform float _Shininess; +uniform sampler2D _MainTex; +uniform sampler2D _LightTextureB0; +uniform samplerCube _LightTexture0; +uniform vec4 _LightColor0; +uniform sampler2D _GlossMap; +uniform float _Cutoff; +uniform sampler2D _BumpMap; +void xll_clip ( + in float x +) +{ + if ((x < 0.0)) { + discard; + }; +} + +float xll_saturate ( + in float x +) +{ + float tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec2 xll_saturate ( + in vec2 x +) +{ + vec2 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec3 xll_saturate ( + in vec3 x +) +{ + vec3 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec4 xll_saturate ( + in vec4 x +) +{ + vec4 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +mat2 xll_saturate ( + in mat2 m +) +{ + vec2 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec2 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + mat2 tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_1; + tmpvar_3[0] = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5 = tmpvar_2; + tmpvar_3[1] = tmpvar_5; + return tmpvar_3; +} + +mat3 xll_saturate ( + in mat3 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec3 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + vec3 tmpvar_3; + tmpvar_3 = clamp (m[2], 0.0, 1.0); + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +mat4 xll_saturate ( + in mat4 m +) +{ + vec4 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec4 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + vec4 tmpvar_3; + tmpvar_3 = clamp (m[2], 0.0, 1.0); + vec4 tmpvar_4; + tmpvar_4 = clamp (m[3], 0.0, 1.0); + mat4 tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_1; + tmpvar_5[0] = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = tmpvar_2; + tmpvar_5[1] = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_3; + tmpvar_5[2] = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = tmpvar_4; + tmpvar_5[3] = tmpvar_9; + return tmpvar_5; +} + +vec4 UnpackNormal ( + in vec4 packednormal +) +{ + vec4 normal; + vec2 tmpvar_1; + tmpvar_1 = ((packednormal.wy * 2.0) - 1.0); + normal.xy = tmpvar_1.xy.xy; + float tmpvar_2; + tmpvar_2 = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + normal.z = vec3(tmpvar_3).z; + return normal; +} + +void surf ( + in Input IN, + inout LeafSurfaceOutput o +) +{ + vec4 c; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + c = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = (c.xyz * IN.color.xyz); + o.Albedo = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = texture2D (_TranslucencyMap, IN.uv_MainTex); + vec3 tmpvar_5; + tmpvar_5 = _TranslucencyColor.xyz; + vec3 tmpvar_6; + tmpvar_6 = (tmpvar_4.xyz * tmpvar_5); + o.Translucency = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = texture2D (_GlossMap, IN.uv_MainTex); + float tmpvar_8; + tmpvar_8 = tmpvar_7.w; + o.Gloss = tmpvar_8; + float tmpvar_9; + tmpvar_9 = (c.w * IN.color.w); + o.Alpha = tmpvar_9; + float tmpvar_10; + tmpvar_10 = _Shininess; + o.Specular = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = texture2D (_BumpMap, IN.uv_MainTex); + vec4 tmpvar_12; + tmpvar_12 = UnpackNormal (tmpvar_11); + vec3 tmpvar_13; + tmpvar_13 = tmpvar_12.xyz; + vec3 tmpvar_14; + tmpvar_14 = tmpvar_13; + o.Normal = tmpvar_14; +} + +vec4 LightingTreeLeaf ( + in LeafSurfaceOutput s, + in vec3 lightDir, + in vec3 viewDir, + in float atten +) +{ + vec4 c; + vec3 col; + vec3 translucencyColor; + float trans; + float spec; + float nh; + float diff; + vec3 h; + vec3 tmpvar_1; + tmpvar_1 = normalize ((lightDir + viewDir)); + vec3 tmpvar_2; + tmpvar_2 = tmpvar_1; + h = tmpvar_2; + float tmpvar_3; + tmpvar_3 = dot (s.Normal, lightDir); + float tmpvar_4; + tmpvar_4 = tmpvar_3; + diff = tmpvar_4; + float tmpvar_5; + tmpvar_5 = dot (s.Normal, h); + float tmpvar_6; + tmpvar_6 = max (0.0, tmpvar_5); + float tmpvar_7; + tmpvar_7 = tmpvar_6; + nh = tmpvar_7; + float tmpvar_8; + tmpvar_8 = pow (nh, (s.Specular * 128.0)); + float tmpvar_9; + tmpvar_9 = (tmpvar_8 * s.Gloss); + spec = tmpvar_9; + float tmpvar_10; + tmpvar_10 = max (0.0, -(diff)); + float tmpvar_11; + tmpvar_11 = tmpvar_10; + trans = tmpvar_11; + vec3 tmpvar_12; + tmpvar_12 = ((s.Translucency * trans) * 2.0); + translucencyColor = tmpvar_12; + float tmpvar_13; + tmpvar_13 = max (0.0, ((diff * 0.5) + 0.5)); + float tmpvar_14; + tmpvar_14 = tmpvar_13; + diff = tmpvar_14; + vec3 tmpvar_15; + tmpvar_15 = (s.Albedo * (diff + translucencyColor)); + col = tmpvar_15; + float tmpvar_16; + tmpvar_16 = ceil (trans); + float tmpvar_17; + tmpvar_17 = xll_saturate (tmpvar_16); + vec3 tmpvar_18; + tmpvar_18 = (col + (spec * (1.0 - tmpvar_17))); + col = tmpvar_18; + vec3 tmpvar_19; + tmpvar_19 = (col * _LightColor0.xyz); + col = tmpvar_19; + vec3 tmpvar_20; + tmpvar_20 = (col * (atten * 2.0)); + c.xyz = tmpvar_20.xyz.xyz; + return c; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 c; + vec3 lightDir; + LeafSurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = IN.lop_color; + surfIN.color = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Specular = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Alpha = tmpvar_6; + surf (surfIN, o); + xll_clip ((o.Alpha - _Cutoff)); + vec3 tmpvar_7; + tmpvar_7 = IN.lightDir; + lightDir = tmpvar_7; + vec3 tmpvar_8; + tmpvar_8 = normalize (lightDir); + vec3 tmpvar_9; + tmpvar_9 = tmpvar_8; + lightDir = tmpvar_9; + vec3 tmpvar_10; + tmpvar_10 = IN.viewDir.xyz; + vec3 tmpvar_11; + tmpvar_11 = normalize (tmpvar_10); + float tmpvar_12; + tmpvar_12 = dot (IN._LightCoord, IN._LightCoord); + vec2 tmpvar_13; + tmpvar_13 = vec2(tmpvar_12); + vec2 tmpvar_14; + tmpvar_14 = tmpvar_13.xy; + vec4 tmpvar_15; + tmpvar_15 = texture2D (_LightTextureB0, tmpvar_14); + vec4 tmpvar_16; + tmpvar_16 = textureCube (_LightTexture0, IN._LightCoord); + vec4 tmpvar_17; + tmpvar_17 = LightingTreeLeaf (o, lightDir, tmpvar_11, (tmpvar_15.w * tmpvar_16.w)); + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + c = tmpvar_18; + float tmpvar_19; + tmpvar_19 = o.Alpha; + c.w = vec4(tmpvar_19).w; + return c; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_IN.fog = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = gl_TexCoord[0].xy; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_IN.hip_pack0 = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = gl_Color.xyzw; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_IN.lop_color = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = gl_TexCoord[1].xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_IN.lightDir = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = gl_TexCoord[2].xyz; + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_IN.viewDir = tmpvar_10; + vec3 tmpvar_11; + tmpvar_11 = gl_TexCoord[3].xyz; + vec3 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_IN._LightCoord = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = frag_surf (xlt_IN); + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_FragData[0] = tmpvar_16; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Tree_Editor_Leaf_Shader-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Tree_Editor_Leaf_Shader-out.txt new file mode 100644 index 000000000..86fb49223 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Tree_Editor_Leaf_Shader-out.txt @@ -0,0 +1,54 @@ +uniform sampler2D _TranslucencyMap; +uniform vec4 _TranslucencyColor; +uniform float _Shininess; +uniform sampler2D _MainTex; +uniform sampler2D _LightTextureB0; +uniform samplerCube _LightTexture0; +uniform vec4 _LightColor0; +uniform sampler2D _GlossMap; +uniform float _Cutoff; +uniform sampler2D _BumpMap; +void main () +{ + vec3 tmpvar_1; + tmpvar_1 = gl_TexCoord[1].xyz; + vec3 tmpvar_2; + tmpvar_2 = gl_TexCoord[2].xyz; + vec3 tmpvar_3; + tmpvar_3 = gl_TexCoord[3].xyz; + vec4 c; + vec2 tmpvar_4; + tmpvar_4 = gl_TexCoord[0].xy; + vec4 tmpvar_5; + tmpvar_5 = texture2D (_MainTex, tmpvar_4); + vec3 tmpvar_6; + tmpvar_6 = (tmpvar_5.xyz * gl_Color.xyz); + vec3 tmpvar_7; + tmpvar_7 = (texture2D (_TranslucencyMap, tmpvar_4).xyz * _TranslucencyColor.xyz); + vec4 tmpvar_8; + tmpvar_8 = texture2D (_GlossMap, tmpvar_4); + float tmpvar_9; + tmpvar_9 = (tmpvar_5.w * gl_Color.w); + vec4 normal; + normal.xy = ((texture2D (_BumpMap, tmpvar_4).wy * 2.0) - 1.0); + normal.z = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + vec3 tmpvar_10; + tmpvar_10 = normal.xyz; + float x; + x = (tmpvar_9 - _Cutoff); + if ((x < 0.0)) { + discard; + }; + vec3 tmpvar_11; + tmpvar_11 = normalize (tmpvar_1); + vec4 c_i0_i1; + float tmpvar_12; + tmpvar_12 = dot (tmpvar_10, tmpvar_11); + float tmpvar_13; + tmpvar_13 = max (0.0, -(tmpvar_12)); + c_i0_i1.xyz = ((((tmpvar_6 * (max (0.0, ((tmpvar_12 * 0.5) + 0.5)) + ((tmpvar_7 * tmpvar_13) * 2.0))) + ((pow (max (0.0, dot (tmpvar_10, normalize ((tmpvar_11 + normalize (tmpvar_2))))), (_Shininess * 128.0)) * tmpvar_8.w) * (1.0 - clamp (ceil (tmpvar_13), 0.0, 1.0)))) * _LightColor0.xyz) * ((texture2D (_LightTextureB0, vec2(dot (tmpvar_3, tmpvar_3))).w * textureCube (_LightTexture0, tmpvar_3).w) * 2.0)); + c = c_i0_i1; + c.w = tmpvar_9; + gl_FragData[0] = c; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Tree_Editor_Leaf_Shader1-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Tree_Editor_Leaf_Shader1-in.txt new file mode 100644 index 000000000..e6bddbf01 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Tree_Editor_Leaf_Shader1-in.txt @@ -0,0 +1,162 @@ +void xll_clip(float x) { + if ( x<0.0 ) discard; +} +float xll_saturate( float x) { + return clamp( x, 0.0, 1.0); +} +vec2 xll_saturate( vec2 x) { + return clamp( x, 0.0, 1.0); +} +vec3 xll_saturate( vec3 x) { + return clamp( x, 0.0, 1.0); +} +vec4 xll_saturate( vec4 x) { + return clamp( x, 0.0, 1.0); +} +mat2 xll_saturate(mat2 m) { + return mat2( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0)); +} +mat3 xll_saturate(mat3 m) { + return mat3( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0), clamp(m[2], 0.0, 1.0)); +} +mat4 xll_saturate(mat4 m) { + return mat4( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0), clamp(m[2], 0.0, 1.0), clamp(m[3], 0.0, 1.0)); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +struct LeafSurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + vec3 Translucency; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec4 color; +}; +struct v2f_surf { + vec4 pos; + vec3 _ShadowCoord0; + vec3 _ShadowCoord1; + vec3 _ShadowCoord2; + vec3 _ShadowCoord3; + vec2 _ShadowZFade; + vec2 hip_pack0; + vec4 lop_color; +}; +uniform sampler2D _BumpMap; +uniform float _Cutoff; +uniform sampler2D _GlossMap; +uniform vec4 _LightShadowData; +uniform vec4 _LightSplitsFar; +uniform vec4 _LightSplitsNear; +uniform sampler2D _MainTex; +uniform vec4 _ProjectionParams; +uniform sampler2D _ShadowMapTexture; +uniform float _Shininess; +uniform vec4 _TranslucencyColor; +uniform sampler2D _TranslucencyMap; +vec4 UnpackNormal( in vec4 packednormal ); +void surf( in Input IN, inout LeafSurfaceOutput o ); +vec2 EncodeFloatRG( in float v ); +vec4 frag_surf( in v2f_surf IN ); +vec4 UnpackNormal( in vec4 packednormal ) { + vec4 normal; + normal.xy = ((packednormal.wy * 2.00000) - 1.00000); + normal.z = sqrt( ((1.00000 - (normal.x * normal.x )) - (normal.y * normal.y )) ); + return normal; +} +void surf( in Input IN, inout LeafSurfaceOutput o ) { + vec4 c; + c = texture2D( _MainTex, IN.uv_MainTex); + o.Albedo = (c.xyz * IN.color.xyz ); + o.Translucency = (texture2D( _TranslucencyMap, IN.uv_MainTex).xyz * vec3( _TranslucencyColor)); + o.Gloss = texture2D( _GlossMap, IN.uv_MainTex).w ; + o.Alpha = (c.w * IN.color.w ); + o.Specular = _Shininess; + o.Normal = vec3( UnpackNormal( texture2D( _BumpMap, IN.uv_MainTex))); +} +vec2 EncodeFloatRG( in float v ) { + vec2 kEncodeMul = vec2( 1.00000, 255.000); + float kEncodeBit = 0.00392157; + vec2 enc; + enc = (kEncodeMul * v); + enc = fract( enc ); + enc.x -= (enc.y * kEncodeBit); + return enc; +} +vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + LeafSurfaceOutput o; + vec4 z; + vec4 near; + vec4 far; + vec4 weights; + vec4 coord; + float shadow; + float faded; + vec4 res; + surfIN.uv_MainTex = IN.hip_pack0.xy ; + surfIN.color = IN.lop_color; + o.Albedo = vec3( 0.000000); + o.Emission = vec3( 0.000000); + o.Specular = 0.000000; + o.Alpha = 0.000000; + surf( surfIN, o); + xll_clip( (o.Alpha - _Cutoff) ); + z = vec4( IN._ShadowZFade.x ); + near = vec4( greaterThanEqual( z, _LightSplitsNear) ); + far = vec4( lessThan( z, _LightSplitsFar) ); + weights = (near * far); + coord = vec4( ((((IN._ShadowCoord0 * weights.x ) + (IN._ShadowCoord1 * weights.y )) + (IN._ShadowCoord2 * weights.z )) + (IN._ShadowCoord3 * weights.w )), 1.00000); + shadow = ( (texture2D( _ShadowMapTexture, coord.xy ).x < coord.z ) ) ? ( _LightShadowData.x ) : ( 1.00000 ); + faded = xll_saturate( (shadow + xll_saturate( IN._ShadowZFade.y )) ); + res.x = faded; + res.y = 1.00000; + res.zw = EncodeFloatRG( float( (1.00000 - (z * _ProjectionParams.w )))); + return res; +} +void main() { + vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN._ShadowCoord0 = vec3( gl_TexCoord[0]); + xlt_IN._ShadowCoord1 = vec3( gl_TexCoord[1]); + xlt_IN._ShadowCoord2 = vec3( gl_TexCoord[2]); + xlt_IN._ShadowCoord3 = vec3( gl_TexCoord[3]); + xlt_IN._ShadowZFade = vec2( gl_TexCoord[4]); + xlt_IN.hip_pack0 = vec2( gl_TexCoord[5]); + xlt_IN.lop_color = vec4( gl_Color); + xl_retval = frag_surf( xlt_IN); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Tree_Editor_Leaf_Shader1-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Tree_Editor_Leaf_Shader1-ir.txt new file mode 100644 index 000000000..821f30984 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Tree_Editor_Leaf_Shader1-ir.txt @@ -0,0 +1,383 @@ +struct LeafSurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + vec3 Translucency; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec4 color; +}; +struct v2f_surf { + vec4 pos; + vec3 _ShadowCoord0; + vec3 _ShadowCoord1; + vec3 _ShadowCoord2; + vec3 _ShadowCoord3; + vec2 _ShadowZFade; + vec2 hip_pack0; + vec4 lop_color; +}; +uniform sampler2D _TranslucencyMap; +uniform vec4 _TranslucencyColor; +uniform float _Shininess; +uniform sampler2D _ShadowMapTexture; +uniform vec4 _ProjectionParams; +uniform sampler2D _MainTex; +uniform vec4 _LightSplitsNear; +uniform vec4 _LightSplitsFar; +uniform vec4 _LightShadowData; +uniform sampler2D _GlossMap; +uniform float _Cutoff; +uniform sampler2D _BumpMap; +void xll_clip ( + in float x +) +{ + if ((x < 0.0)) { + discard; + }; +} + +float xll_saturate ( + in float x +) +{ + float tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec2 xll_saturate ( + in vec2 x +) +{ + vec2 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec3 xll_saturate ( + in vec3 x +) +{ + vec3 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec4 xll_saturate ( + in vec4 x +) +{ + vec4 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +mat2 xll_saturate ( + in mat2 m +) +{ + vec2 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec2 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + mat2 tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_1; + tmpvar_3[0] = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5 = tmpvar_2; + tmpvar_3[1] = tmpvar_5; + return tmpvar_3; +} + +mat3 xll_saturate ( + in mat3 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec3 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + vec3 tmpvar_3; + tmpvar_3 = clamp (m[2], 0.0, 1.0); + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +mat4 xll_saturate ( + in mat4 m +) +{ + vec4 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec4 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + vec4 tmpvar_3; + tmpvar_3 = clamp (m[2], 0.0, 1.0); + vec4 tmpvar_4; + tmpvar_4 = clamp (m[3], 0.0, 1.0); + mat4 tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_1; + tmpvar_5[0] = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = tmpvar_2; + tmpvar_5[1] = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_3; + tmpvar_5[2] = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = tmpvar_4; + tmpvar_5[3] = tmpvar_9; + return tmpvar_5; +} + +vec4 UnpackNormal ( + in vec4 packednormal +) +{ + vec4 normal; + vec2 tmpvar_1; + tmpvar_1 = ((packednormal.wy * 2.0) - 1.0); + normal.xy = tmpvar_1.xy.xy; + float tmpvar_2; + tmpvar_2 = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + normal.z = vec3(tmpvar_3).z; + return normal; +} + +void surf ( + in Input IN, + inout LeafSurfaceOutput o +) +{ + vec4 c; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + c = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = (c.xyz * IN.color.xyz); + o.Albedo = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = texture2D (_TranslucencyMap, IN.uv_MainTex); + vec3 tmpvar_5; + tmpvar_5 = _TranslucencyColor.xyz; + vec3 tmpvar_6; + tmpvar_6 = (tmpvar_4.xyz * tmpvar_5); + o.Translucency = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = texture2D (_GlossMap, IN.uv_MainTex); + float tmpvar_8; + tmpvar_8 = tmpvar_7.w; + o.Gloss = tmpvar_8; + float tmpvar_9; + tmpvar_9 = (c.w * IN.color.w); + o.Alpha = tmpvar_9; + float tmpvar_10; + tmpvar_10 = _Shininess; + o.Specular = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = texture2D (_BumpMap, IN.uv_MainTex); + vec4 tmpvar_12; + tmpvar_12 = UnpackNormal (tmpvar_11); + vec3 tmpvar_13; + tmpvar_13 = tmpvar_12.xyz; + vec3 tmpvar_14; + tmpvar_14 = tmpvar_13; + o.Normal = tmpvar_14; +} + +vec2 EncodeFloatRG ( + in float v +) +{ + vec2 enc; + float kEncodeBit; + vec2 kEncodeMul; + vec2 tmpvar_1; + tmpvar_1 = vec2(1.0, 255.0); + kEncodeMul = tmpvar_1; + float tmpvar_2; + tmpvar_2 = 0.00392157; + kEncodeBit = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = (kEncodeMul * v); + enc = tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = fract (enc); + vec2 tmpvar_5; + tmpvar_5 = tmpvar_4; + enc = tmpvar_5; + float tmpvar_6; + tmpvar_6 = (enc.x - (enc.y * kEncodeBit)); + enc.x = tmpvar_6; + return enc; +} + +vec4 frag_surf ( + in v2f_surf IN +) +{ + vec4 res; + float faded; + float shadow; + vec4 coord; + vec4 weights; + vec4 far; + vec4 near; + vec4 z; + LeafSurfaceOutput o; + Input surfIN; + vec2 tmpvar_1; + tmpvar_1 = IN.hip_pack0.xy; + surfIN.uv_MainTex = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = IN.lop_color; + surfIN.color = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = vec3(0.0, 0.0, 0.0); + o.Albedo = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = vec3(0.0, 0.0, 0.0); + o.Emission = tmpvar_4; + float tmpvar_5; + tmpvar_5 = 0.0; + o.Specular = tmpvar_5; + float tmpvar_6; + tmpvar_6 = 0.0; + o.Alpha = tmpvar_6; + surf (surfIN, o); + xll_clip ((o.Alpha - _Cutoff)); + vec4 tmpvar_7; + tmpvar_7 = vec4(IN._ShadowZFade.x); + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + z = tmpvar_8; + bvec4 tmpvar_9; + tmpvar_9 = greaterThanEqual (z, _LightSplitsNear); + vec4 tmpvar_10; + tmpvar_10 = vec4(tmpvar_9).xyzw; + vec4 tmpvar_11; + tmpvar_11 = tmpvar_10; + near = tmpvar_11; + bvec4 tmpvar_12; + tmpvar_12 = lessThan (z, _LightSplitsFar); + vec4 tmpvar_13; + tmpvar_13 = vec4(tmpvar_12).xyzw; + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + far = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = (near * far); + weights = tmpvar_15; + vec4 tmpvar_16; + tmpvar_16.w = 1.0; + tmpvar_16.xyz = ((((IN._ShadowCoord0 * weights.x) + (IN._ShadowCoord1 * weights.y)) + (IN._ShadowCoord2 * weights.z)) + (IN._ShadowCoord3 * weights.w)).xyz; + vec4 tmpvar_17; + tmpvar_17 = tmpvar_16; + coord = tmpvar_17; + vec4 tmpvar_18; + tmpvar_18 = texture2D (_ShadowMapTexture, coord.xy); + float tmpvar_19; + if ((tmpvar_18.x < coord.z)) { + tmpvar_19 = _LightShadowData.x; + } else { + tmpvar_19 = 1.0; + }; + float tmpvar_20; + tmpvar_20 = tmpvar_19; + shadow = tmpvar_20; + float tmpvar_21; + tmpvar_21 = xll_saturate (IN._ShadowZFade.y); + float tmpvar_22; + tmpvar_22 = xll_saturate ((shadow + tmpvar_21)); + float tmpvar_23; + tmpvar_23 = tmpvar_22; + faded = tmpvar_23; + float tmpvar_24; + tmpvar_24 = faded; + res.x = tmpvar_24; + float tmpvar_25; + tmpvar_25 = 1.0; + res.y = vec2(tmpvar_25).y; + vec2 tmpvar_26; + tmpvar_26 = EncodeFloatRG ((1.0 - (z * _ProjectionParams.w)).x); + vec2 tmpvar_27; + tmpvar_27 = tmpvar_26; + res.zw = tmpvar_27.xxxy.zw; + return res; +} + +void main () +{ + v2f_surf xlt_IN; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_IN.pos = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = gl_TexCoord[0].xyz; + vec3 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_IN._ShadowCoord0 = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = gl_TexCoord[1].xyz; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_4; + xlt_IN._ShadowCoord1 = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = gl_TexCoord[2].xyz; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_6; + xlt_IN._ShadowCoord2 = tmpvar_7; + vec3 tmpvar_8; + tmpvar_8 = gl_TexCoord[3].xyz; + vec3 tmpvar_9; + tmpvar_9 = tmpvar_8; + xlt_IN._ShadowCoord3 = tmpvar_9; + vec2 tmpvar_10; + tmpvar_10 = gl_TexCoord[4].xy; + vec2 tmpvar_11; + tmpvar_11 = tmpvar_10; + xlt_IN._ShadowZFade = tmpvar_11; + vec2 tmpvar_12; + tmpvar_12 = gl_TexCoord[5].xy; + vec2 tmpvar_13; + tmpvar_13 = tmpvar_12; + xlt_IN.hip_pack0 = tmpvar_13; + vec4 tmpvar_14; + tmpvar_14 = gl_Color.xyzw; + vec4 tmpvar_15; + tmpvar_15 = tmpvar_14; + xlt_IN.lop_color = tmpvar_15; + vec4 tmpvar_16; + tmpvar_16 = frag_surf (xlt_IN); + vec4 tmpvar_17; + tmpvar_17 = tmpvar_16; + xl_retval = tmpvar_17; + vec4 tmpvar_18; + tmpvar_18 = xl_retval.xyzw; + vec4 tmpvar_19; + tmpvar_19 = tmpvar_18; + gl_FragData[0] = tmpvar_19; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Tree_Editor_Leaf_Shader1-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Tree_Editor_Leaf_Shader1-out.txt new file mode 100644 index 000000000..0c588039c --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Tree_Editor_Leaf_Shader1-out.txt @@ -0,0 +1,57 @@ +uniform sampler2D _ShadowMapTexture; +uniform vec4 _ProjectionParams; +uniform sampler2D _MainTex; +uniform vec4 _LightSplitsNear; +uniform vec4 _LightSplitsFar; +uniform vec4 _LightShadowData; +uniform float _Cutoff; +uniform sampler2D _BumpMap; +void main () +{ + vec3 tmpvar_1; + tmpvar_1 = gl_TexCoord[0].xyz; + vec3 tmpvar_2; + tmpvar_2 = gl_TexCoord[1].xyz; + vec3 tmpvar_3; + tmpvar_3 = gl_TexCoord[2].xyz; + vec3 tmpvar_4; + tmpvar_4 = gl_TexCoord[3].xyz; + vec2 tmpvar_5; + tmpvar_5 = gl_TexCoord[4].xy; + vec4 res; + vec2 tmpvar_6; + tmpvar_6 = gl_TexCoord[5].xy; + vec4 normal; + normal.xy = ((texture2D (_BumpMap, tmpvar_6).wy * 2.0) - 1.0); + normal.z = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y))); + float x; + x = ((texture2D (_MainTex, tmpvar_6).w * gl_Color.w) - _Cutoff); + if ((x < 0.0)) { + discard; + }; + vec4 tmpvar_7; + tmpvar_7 = tmpvar_5.xxxx; + vec4 tmpvar_8; + tmpvar_8 = (vec4(greaterThanEqual (tmpvar_7, _LightSplitsNear)) * vec4(lessThan (tmpvar_7, _LightSplitsFar))); + vec4 tmpvar_9; + tmpvar_9.w = 1.0; + tmpvar_9.xyz = ((((tmpvar_1 * tmpvar_8.x) + (tmpvar_2 * tmpvar_8.y)) + (tmpvar_3 * tmpvar_8.z)) + (tmpvar_4 * tmpvar_8.w)); + vec4 tmpvar_10; + tmpvar_10 = texture2D (_ShadowMapTexture, tmpvar_9.xy); + float tmpvar_11; + if ((tmpvar_10.x < tmpvar_9.z)) { + tmpvar_11 = _LightShadowData.x; + } else { + tmpvar_11 = 1.0; + }; + res.x = clamp ((tmpvar_11 + clamp (tmpvar_5.y, 0.0, 1.0)), 0.0, 1.0); + res.y = 1.0; + vec2 enc; + vec2 tmpvar_12; + tmpvar_12 = fract ((vec2(1.0, 255.0) * (1.0 - (tmpvar_5.xxxx * _ProjectionParams.w)).x)); + enc = tmpvar_12; + enc.x = (tmpvar_12.x - (tmpvar_12.y * 0.00392157)); + res.zw = enc; + gl_FragData[0] = res; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Vertex_Colored-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Vertex_Colored-in.txt new file mode 100644 index 000000000..14955aa62 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Vertex_Colored-in.txt @@ -0,0 +1,43 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct v2f { + vec4 pos; + float fog; + vec4 color; + vec2 texcoord; + vec3 normal; +}; +struct appdata_t { + vec4 vertex; + vec4 color; + vec3 normal; + vec2 texcoord; +}; +uniform sampler2D _MainTex; +vec4 frag( in v2f i ); +vec4 frag( in v2f i ) { + return (i.color * texture2D( _MainTex, i.texcoord)); +} +varying vec4 xlv_FOG; +void main() { + vec4 xl_retval; + v2f xlt_i; + xlt_i.pos = vec4(0.0); + xlt_i.fog = float( xlv_FOG); + xlt_i.color = vec4( gl_Color); + xlt_i.texcoord = vec2( gl_TexCoord[0]); + xlt_i.normal = vec3( gl_TexCoord[1]); + xl_retval = frag( xlt_i); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Vertex_Colored-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Vertex_Colored-ir.txt new file mode 100644 index 000000000..3f56271e5 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Vertex_Colored-ir.txt @@ -0,0 +1,55 @@ +struct v2f { + vec4 pos; + float fog; + vec4 color; + vec2 texcoord; + vec3 normal; +}; +varying vec4 xlv_FOG; +uniform sampler2D _MainTex; +vec4 frag ( + in v2f i +) +{ + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, i.texcoord); + return (i.color * tmpvar_1); +} + +void main () +{ + v2f xlt_i; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_i.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = xlv_FOG.x; + xlt_i.fog = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = gl_Color.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_i.color = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5 = gl_TexCoord[0].xy; + vec2 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_i.texcoord = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = gl_TexCoord[1].xyz; + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_i.normal = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = frag (xlt_i); + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xl_retval = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = xl_retval.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + gl_FragData[0] = tmpvar_12; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-Vertex_Colored-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-Vertex_Colored-out.txt new file mode 100644 index 000000000..852501ba4 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-Vertex_Colored-out.txt @@ -0,0 +1,6 @@ +uniform sampler2D _MainTex; +void main () +{ + gl_FragData[0] = (gl_Color * texture2D (_MainTex, gl_TexCoord[0].xy)); +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-currently_adapted-in.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-currently_adapted-in.txt new file mode 100644 index 000000000..175bd1128 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-currently_adapted-in.txt @@ -0,0 +1,42 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +uniform vec4 _AdaptParams; +uniform sampler2D _CurTex; +uniform sampler2D _MainTex; +vec4 frag( in v2f_img i ); +vec4 frag( in v2f_img i ) { + vec2 valAdapted; + vec2 valCur; + vec2 delta; + vec4 valNew; + valAdapted = texture2D( _MainTex, i.uv).xy ; + valCur = texture2D( _CurTex, i.uv).xy ; + delta = ((valCur - valAdapted) * _AdaptParams.x ); + delta.x = (sign( delta.x ) * max( 0.00392157, abs( delta.x ))); + delta.y = (sign( delta.y ) * max( 0.00392157, abs( delta.y ))); + valNew.xy = (valAdapted + delta); + valNew.x = max( valNew.x , _AdaptParams.z ); + valNew.y = min( valNew.y , _AdaptParams.y ); + valNew.z = ((valNew.x - valNew.y ) + 0.0100000); + valNew.w = (valNew.y / valNew.z ); + return valNew; +} +void main() { + vec4 xl_retval; + v2f_img xlt_i; + xlt_i.pos = vec4(0.0); + xlt_i.uv = vec2( gl_TexCoord[0]); + xl_retval = frag( xlt_i); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-currently_adapted-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-currently_adapted-ir.txt new file mode 100644 index 000000000..f7fd80e32 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-currently_adapted-ir.txt @@ -0,0 +1,92 @@ +struct v2f_img { + vec4 pos; + vec2 uv; +}; +uniform sampler2D _MainTex; +uniform sampler2D _CurTex; +uniform vec4 _AdaptParams; +vec4 frag ( + in v2f_img i +) +{ + vec4 valNew; + vec2 delta; + vec2 valCur; + vec2 valAdapted; + vec4 tmpvar_1; + tmpvar_1 = texture2D (_MainTex, i.uv); + vec2 tmpvar_2; + tmpvar_2 = tmpvar_1.xy; + valAdapted = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = texture2D (_CurTex, i.uv); + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3.xy; + valCur = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5 = ((valCur - valAdapted) * _AdaptParams.x); + delta = tmpvar_5; + float tmpvar_6; + tmpvar_6 = sign (delta.x); + float tmpvar_7; + tmpvar_7 = abs (delta.x); + float tmpvar_8; + tmpvar_8 = max (0.00392157, tmpvar_7); + float tmpvar_9; + tmpvar_9 = (tmpvar_6 * tmpvar_8); + delta.x = tmpvar_9; + float tmpvar_10; + tmpvar_10 = sign (delta.y); + float tmpvar_11; + tmpvar_11 = abs (delta.y); + float tmpvar_12; + tmpvar_12 = max (0.00392157, tmpvar_11); + float tmpvar_13; + tmpvar_13 = (tmpvar_10 * tmpvar_12); + delta.y = vec2(tmpvar_13).y; + vec2 tmpvar_14; + tmpvar_14 = (valAdapted + delta); + valNew.xy = tmpvar_14.xy.xy; + float tmpvar_15; + tmpvar_15 = max (valNew.x, _AdaptParams.z); + float tmpvar_16; + tmpvar_16 = tmpvar_15; + valNew.x = tmpvar_16; + float tmpvar_17; + tmpvar_17 = min (valNew.y, _AdaptParams.y); + float tmpvar_18; + tmpvar_18 = tmpvar_17; + valNew.y = vec2(tmpvar_18).y; + float tmpvar_19; + tmpvar_19 = ((valNew.x - valNew.y) + 0.01); + valNew.z = vec3(tmpvar_19).z; + float tmpvar_20; + tmpvar_20 = (valNew.y / valNew.z); + valNew.w = vec4(tmpvar_20).w; + return valNew; +} + +void main () +{ + v2f_img xlt_i; + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + xlt_i.pos = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = gl_TexCoord[0].xy; + vec2 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlt_i.uv = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = frag (xlt_i); + vec4 tmpvar_5; + tmpvar_5 = tmpvar_4; + xl_retval = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = xl_retval.xyzw; + vec4 tmpvar_7; + tmpvar_7 = tmpvar_6; + gl_FragData[0] = tmpvar_7; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/unity-currently_adapted-out.txt b/3rdparty/glsl-optimizer/tests/fragment/unity-currently_adapted-out.txt new file mode 100644 index 000000000..7526e60f6 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/unity-currently_adapted-out.txt @@ -0,0 +1,24 @@ +uniform sampler2D _MainTex; +uniform sampler2D _CurTex; +uniform vec4 _AdaptParams; +void main () +{ + vec2 tmpvar_1; + tmpvar_1 = gl_TexCoord[0].xy; + vec4 valNew; + vec2 delta; + vec4 tmpvar_2; + tmpvar_2 = texture2D (_MainTex, tmpvar_1); + vec2 tmpvar_3; + tmpvar_3 = ((texture2D (_CurTex, tmpvar_1).xy - tmpvar_2.xy) * _AdaptParams.x); + delta = tmpvar_3; + delta.x = (sign (tmpvar_3.x) * max (0.00392157, abs (tmpvar_3.x))); + delta.y = (sign (delta.y) * max (0.00392157, abs (delta.y))); + valNew.xy = (tmpvar_2.xy + delta); + valNew.x = max (valNew.x, _AdaptParams.z); + valNew.y = min (valNew.y, _AdaptParams.y); + valNew.z = ((valNew.x - valNew.y) + 0.01); + valNew.w = (valNew.y / valNew.z); + gl_FragData[0] = valNew; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/varyings-in.txt b/3rdparty/glsl-optimizer/tests/fragment/varyings-in.txt new file mode 100644 index 000000000..835df7d57 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/varyings-in.txt @@ -0,0 +1,13 @@ +vec4 xlat_main( in vec4 uv, in vec4 foobar_xlv_foo ); +vec4 xlat_main( in vec4 uv, in vec4 foobar_xlv_foo ) { + vec4 c; + c = vec4( 0.000000); + return c; +} +varying vec4 xlv_TEXCOORD0; +varying vec4 xlv_TEXCOORD1; +void main() { + vec4 xl_retval; + xl_retval = xlat_main( vec4(xlv_TEXCOORD0), vec4(xlv_TEXCOORD1)); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/varyings-inES.txt b/3rdparty/glsl-optimizer/tests/fragment/varyings-inES.txt new file mode 100644 index 000000000..904a5862f --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/varyings-inES.txt @@ -0,0 +1,13 @@ +mediump vec4 xlat_main( in highp vec4 uv, in highp vec4 foobar_xlv_foo ); +mediump vec4 xlat_main( in highp vec4 uv, in highp vec4 foobar_xlv_foo ) { + mediump vec4 c; + c = vec4( 0.000000); + return c; +} +varying highp vec4 xlv_TEXCOORD0; +varying highp vec4 xlv_TEXCOORD1; +void main() { + mediump vec4 xl_retval; + xl_retval = xlat_main( highp vec4(xlv_TEXCOORD0), highp vec4(xlv_TEXCOORD1)); + gl_FragData[0] = mediump vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/varyings-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/varyings-ir.txt new file mode 100644 index 000000000..a0b9ec6b6 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/varyings-ir.txt @@ -0,0 +1,33 @@ +varying vec4 xlv_TEXCOORD1; +varying vec4 xlv_TEXCOORD0; +vec4 xlat_main ( + in vec4 uv, + in vec4 foobar_xlv_foo +) +{ + vec4 c; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + c = tmpvar_1; + return c; +} + +void main () +{ + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = xlv_TEXCOORD0.xyzw; + vec4 tmpvar_2; + tmpvar_2 = xlv_TEXCOORD1.xyzw; + vec4 tmpvar_3; + tmpvar_3 = xlat_main (tmpvar_1, tmpvar_2); + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xl_retval = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = xl_retval.xyzw; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_5; + gl_FragData[0] = tmpvar_6; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/varyings-irES.txt b/3rdparty/glsl-optimizer/tests/fragment/varyings-irES.txt new file mode 100644 index 000000000..006733700 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/varyings-irES.txt @@ -0,0 +1,33 @@ +varying highp vec4 xlv_TEXCOORD1; +varying highp vec4 xlv_TEXCOORD0; +mediump vec4 xlat_main ( + in highp vec4 uv, + in highp vec4 foobar_xlv_foo +) +{ + mediump vec4 c; + vec4 tmpvar_1; + tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0); + c = tmpvar_1; + return c; +} + +void main () +{ + mediump vec4 xl_retval; + highp vec4 tmpvar_1; + tmpvar_1 = xlv_TEXCOORD0.xyzw; + highp vec4 tmpvar_2; + tmpvar_2 = xlv_TEXCOORD1.xyzw; + mediump vec4 tmpvar_3; + tmpvar_3 = xlat_main (tmpvar_1, tmpvar_2); + mediump vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xl_retval = tmpvar_4; + mediump vec4 tmpvar_5; + tmpvar_5 = xl_retval.xyzw; + mediump vec4 tmpvar_6; + tmpvar_6 = tmpvar_5; + gl_FragData[0] = tmpvar_6; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/varyings-out.txt b/3rdparty/glsl-optimizer/tests/fragment/varyings-out.txt new file mode 100644 index 000000000..8e5694df1 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/varyings-out.txt @@ -0,0 +1,5 @@ +void main () +{ + gl_FragData[0] = vec4(0.0, 0.0, 0.0, 0.0); +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/varyings-outES.txt b/3rdparty/glsl-optimizer/tests/fragment/varyings-outES.txt new file mode 100644 index 000000000..8e5694df1 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/varyings-outES.txt @@ -0,0 +1,5 @@ +void main () +{ + gl_FragData[0] = vec4(0.0, 0.0, 0.0, 0.0); +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/vface-in.txt b/3rdparty/glsl-optimizer/tests/fragment/vface-in.txt new file mode 100644 index 000000000..07384c500 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/vface-in.txt @@ -0,0 +1,10 @@ +vec4 xlat_main( in float face ); +vec4 xlat_main( in float face ) { + return vec4( face); +} +varying float xlv_VFACE; +void main() { + vec4 xl_retval; + xl_retval = xlat_main( float(xlv_VFACE)); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/vface-inES.txt b/3rdparty/glsl-optimizer/tests/fragment/vface-inES.txt new file mode 100644 index 000000000..99f9acd47 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/vface-inES.txt @@ -0,0 +1,10 @@ +mediump vec4 xlat_main( in highp float face ); +mediump vec4 xlat_main( in highp float face ) { + return vec4( face); +} +varying highp float xlv_VFACE; +void main() { + mediump vec4 xl_retval; + xl_retval = xlat_main( highp float(xlv_VFACE)); + gl_FragData[0] = mediump vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/vface-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/vface-ir.txt new file mode 100644 index 000000000..5b500e20d --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/vface-ir.txt @@ -0,0 +1,25 @@ +varying float xlv_VFACE; +vec4 xlat_main ( + in float face +) +{ + vec4 tmpvar_1; + tmpvar_1 = vec4(face); + return tmpvar_1; +} + +void main () +{ + vec4 xl_retval; + vec4 tmpvar_1; + tmpvar_1 = xlat_main (xlv_VFACE); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xl_retval = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = xl_retval.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + gl_FragData[0] = tmpvar_4; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/vface-irES.txt b/3rdparty/glsl-optimizer/tests/fragment/vface-irES.txt new file mode 100644 index 000000000..da932cc9a --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/vface-irES.txt @@ -0,0 +1,25 @@ +varying highp float xlv_VFACE; +mediump vec4 xlat_main ( + in highp float face +) +{ + highp vec4 tmpvar_1; + tmpvar_1 = vec4(face); + return tmpvar_1; +} + +void main () +{ + mediump vec4 xl_retval; + mediump vec4 tmpvar_1; + tmpvar_1 = xlat_main (xlv_VFACE); + mediump vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xl_retval = tmpvar_2; + mediump vec4 tmpvar_3; + tmpvar_3 = xl_retval.xyzw; + mediump vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + gl_FragData[0] = tmpvar_4; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/vface-out.txt b/3rdparty/glsl-optimizer/tests/fragment/vface-out.txt new file mode 100644 index 000000000..24d1b04a5 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/vface-out.txt @@ -0,0 +1,6 @@ +varying float xlv_VFACE; +void main () +{ + gl_FragData[0] = vec4(xlv_VFACE); +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/vface-outES.txt b/3rdparty/glsl-optimizer/tests/fragment/vface-outES.txt new file mode 100644 index 000000000..d02e6f2f4 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/vface-outES.txt @@ -0,0 +1,10 @@ +varying highp float xlv_VFACE; +void main () +{ + mediump vec4 tmpvar_1; + highp vec4 tmpvar_2; + tmpvar_2 = vec4(xlv_VFACE); + tmpvar_1 = tmpvar_2; + gl_FragData[0] = tmpvar_1; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/vpos-in.txt b/3rdparty/glsl-optimizer/tests/fragment/vpos-in.txt new file mode 100644 index 000000000..9411353e5 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/vpos-in.txt @@ -0,0 +1,10 @@ +vec4 xlat_main( in vec2 pos ); +vec4 xlat_main( in vec2 pos ) { + return vec4( pos, 0.000000, 0.000000); +} +varying vec2 xlv_VPOS; +void main() { + vec4 xl_retval; + xl_retval = xlat_main( vec2(xlv_VPOS)); + gl_FragData[0] = vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/vpos-inES.txt b/3rdparty/glsl-optimizer/tests/fragment/vpos-inES.txt new file mode 100644 index 000000000..4bac40367 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/vpos-inES.txt @@ -0,0 +1,10 @@ +mediump vec4 xlat_main( in highp vec2 pos ); +mediump vec4 xlat_main( in highp vec2 pos ) { + return vec4( pos, 0.000000, 0.000000); +} +varying highp vec2 xlv_VPOS; +void main() { + mediump vec4 xl_retval; + xl_retval = xlat_main( highp vec2(xlv_VPOS)); + gl_FragData[0] = mediump vec4( xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/vpos-ir.txt b/3rdparty/glsl-optimizer/tests/fragment/vpos-ir.txt new file mode 100644 index 000000000..22dbab67d --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/vpos-ir.txt @@ -0,0 +1,28 @@ +varying vec2 xlv_VPOS; +vec4 xlat_main ( + in vec2 pos +) +{ + vec4 tmpvar_1; + tmpvar_1.zw = vec2(0.0, 0.0); + tmpvar_1.xy = pos.xy; + return tmpvar_1; +} + +void main () +{ + vec4 xl_retval; + vec2 tmpvar_1; + tmpvar_1 = xlv_VPOS.xy; + vec4 tmpvar_2; + tmpvar_2 = xlat_main (tmpvar_1); + vec4 tmpvar_3; + tmpvar_3 = tmpvar_2; + xl_retval = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = xl_retval.xyzw; + vec4 tmpvar_5; + tmpvar_5 = tmpvar_4; + gl_FragData[0] = tmpvar_5; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/vpos-irES.txt b/3rdparty/glsl-optimizer/tests/fragment/vpos-irES.txt new file mode 100644 index 000000000..e4c4c240c --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/vpos-irES.txt @@ -0,0 +1,28 @@ +varying highp vec2 xlv_VPOS; +mediump vec4 xlat_main ( + in highp vec2 pos +) +{ + highp vec4 tmpvar_1; + tmpvar_1.zw = vec2(0.0, 0.0); + tmpvar_1.xy = pos.xy; + return tmpvar_1; +} + +void main () +{ + mediump vec4 xl_retval; + highp vec2 tmpvar_1; + tmpvar_1 = xlv_VPOS.xy; + mediump vec4 tmpvar_2; + tmpvar_2 = xlat_main (tmpvar_1); + mediump vec4 tmpvar_3; + tmpvar_3 = tmpvar_2; + xl_retval = tmpvar_3; + mediump vec4 tmpvar_4; + tmpvar_4 = xl_retval.xyzw; + mediump vec4 tmpvar_5; + tmpvar_5 = tmpvar_4; + gl_FragData[0] = tmpvar_5; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/vpos-out.txt b/3rdparty/glsl-optimizer/tests/fragment/vpos-out.txt new file mode 100644 index 000000000..dd3489c7f --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/vpos-out.txt @@ -0,0 +1,9 @@ +varying vec2 xlv_VPOS; +void main () +{ + vec4 tmpvar_1; + tmpvar_1.zw = vec2(0.0, 0.0); + tmpvar_1.xy = xlv_VPOS; + gl_FragData[0] = tmpvar_1; +} + diff --git a/3rdparty/glsl-optimizer/tests/fragment/vpos-outES.txt b/3rdparty/glsl-optimizer/tests/fragment/vpos-outES.txt new file mode 100644 index 000000000..3fda16fc1 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/vpos-outES.txt @@ -0,0 +1,11 @@ +varying highp vec2 xlv_VPOS; +void main () +{ + mediump vec4 tmpvar_1; + highp vec4 tmpvar_2; + tmpvar_2.zw = vec2(0.0, 0.0); + tmpvar_2.xy = xlv_VPOS; + tmpvar_1 = tmpvar_2; + gl_FragData[0] = tmpvar_1; +} + diff --git a/3rdparty/glsl-optimizer/tests/glsl-optimizer-tests.xcodeproj/project.pbxproj b/3rdparty/glsl-optimizer/tests/glsl-optimizer-tests.xcodeproj/project.pbxproj new file mode 100644 index 000000000..5154e3e47 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/glsl-optimizer-tests.xcodeproj/project.pbxproj @@ -0,0 +1,281 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 45; + objects = { + +/* Begin PBXBuildFile section */ + 2B47D9AB1209C6AC00937F2C /* glsl_optimizer_tests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2B47D9AA1209C6AC00937F2C /* glsl_optimizer_tests.cpp */; }; + 2B47D9BA1209C71700937F2C /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2B47D9B91209C71700937F2C /* OpenGL.framework */; }; + 2B47D9C01209C72100937F2C /* AGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2B47D9BF1209C72100937F2C /* AGL.framework */; }; + 2B62803D13A15D7D00B735C2 /* libmesaglsl2.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2B62800E13A15CE100B735C2 /* libmesaglsl2.a */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 2B62800D13A15CE100B735C2 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 2B47D9C51209C72F00937F2C /* mesaglsl2.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = D2AAC046055464E500DB518D; + remoteInfo = mesaglsl2; + }; + 2B62800F13A15CE100B735C2 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 2B47D9C51209C72F00937F2C /* mesaglsl2.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 2BA0803D1352EB9300A1C074; + remoteInfo = builtin_compiler; + }; + 2B62803913A15D6300B735C2 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 2B47D9C51209C72F00937F2C /* mesaglsl2.xcodeproj */; + proxyType = 1; + remoteGlobalIDString = D2AAC045055464E500DB518D; + remoteInfo = mesaglsl2; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 8DD76FAF0486AB0100D96B5E /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 8; + dstPath = /usr/share/man/man1/; + dstSubfolderSpec = 0; + files = ( + ); + runOnlyForDeploymentPostprocessing = 1; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 2B47D9AA1209C6AC00937F2C /* glsl_optimizer_tests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = glsl_optimizer_tests.cpp; sourceTree = ""; }; + 2B47D9B91209C71700937F2C /* OpenGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGL.framework; path = System/Library/Frameworks/OpenGL.framework; sourceTree = SDKROOT; }; + 2B47D9BF1209C72100937F2C /* AGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AGL.framework; path = System/Library/Frameworks/AGL.framework; sourceTree = SDKROOT; }; + 2B47D9C51209C72F00937F2C /* mesaglsl2.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = mesaglsl2.xcodeproj; path = ../src/glsl/xcode/mesaglsl2.xcodeproj; sourceTree = SOURCE_ROOT; }; + 8DD76FB20486AB0100D96B5E /* glsl-optimizer-test */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "glsl-optimizer-test"; sourceTree = BUILT_PRODUCTS_DIR; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 8DD76FAD0486AB0100D96B5E /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 2B62803D13A15D7D00B735C2 /* libmesaglsl2.a in Frameworks */, + 2B47D9BA1209C71700937F2C /* OpenGL.framework in Frameworks */, + 2B47D9C01209C72100937F2C /* AGL.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 08FB7794FE84155DC02AAC07 /* glsl-optimizer-test */ = { + isa = PBXGroup; + children = ( + 08FB7795FE84155DC02AAC07 /* Source */, + 1AB674ADFE9D54B511CA2CBB /* Products */, + 2B47D9C51209C72F00937F2C /* mesaglsl2.xcodeproj */, + 2B47D9B91209C71700937F2C /* OpenGL.framework */, + 2B47D9BF1209C72100937F2C /* AGL.framework */, + ); + name = "glsl-optimizer-test"; + sourceTree = ""; + }; + 08FB7795FE84155DC02AAC07 /* Source */ = { + isa = PBXGroup; + children = ( + 2B47D9AA1209C6AC00937F2C /* glsl_optimizer_tests.cpp */, + ); + name = Source; + sourceTree = ""; + }; + 1AB674ADFE9D54B511CA2CBB /* Products */ = { + isa = PBXGroup; + children = ( + 8DD76FB20486AB0100D96B5E /* glsl-optimizer-test */, + ); + name = Products; + sourceTree = ""; + }; + 2B62800913A15CE100B735C2 /* Products */ = { + isa = PBXGroup; + children = ( + 2B62800E13A15CE100B735C2 /* libmesaglsl2.a */, + 2B62801013A15CE100B735C2 /* builtin_compiler */, + ); + name = Products; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 8DD76FA90486AB0100D96B5E /* glsl-optimizer-test */ = { + isa = PBXNativeTarget; + buildConfigurationList = 1DEB928508733DD80010E9CD /* Build configuration list for PBXNativeTarget "glsl-optimizer-test" */; + buildPhases = ( + 8DD76FAB0486AB0100D96B5E /* Sources */, + 8DD76FAD0486AB0100D96B5E /* Frameworks */, + 8DD76FAF0486AB0100D96B5E /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + 2B62803A13A15D6300B735C2 /* PBXTargetDependency */, + ); + name = "glsl-optimizer-test"; + productInstallPath = "$(HOME)/bin"; + productName = "glsl-optimizer-test"; + productReference = 8DD76FB20486AB0100D96B5E /* glsl-optimizer-test */; + productType = "com.apple.product-type.tool"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 08FB7793FE84155DC02AAC07 /* Project object */ = { + isa = PBXProject; + buildConfigurationList = 1DEB928908733DD80010E9CD /* Build configuration list for PBXProject "glsl-optimizer-tests" */; + compatibilityVersion = "Xcode 3.1"; + developmentRegion = English; + hasScannedForEncodings = 1; + knownRegions = ( + English, + Japanese, + French, + German, + ); + mainGroup = 08FB7794FE84155DC02AAC07 /* glsl-optimizer-test */; + projectDirPath = ""; + projectReferences = ( + { + ProductGroup = 2B62800913A15CE100B735C2 /* Products */; + ProjectRef = 2B47D9C51209C72F00937F2C /* mesaglsl2.xcodeproj */; + }, + ); + projectRoot = ""; + targets = ( + 8DD76FA90486AB0100D96B5E /* glsl-optimizer-test */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXReferenceProxy section */ + 2B62800E13A15CE100B735C2 /* libmesaglsl2.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = libmesaglsl2.a; + remoteRef = 2B62800D13A15CE100B735C2 /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 2B62801013A15CE100B735C2 /* builtin_compiler */ = { + isa = PBXReferenceProxy; + fileType = "compiled.mach-o.executable"; + path = builtin_compiler; + remoteRef = 2B62800F13A15CE100B735C2 /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; +/* End PBXReferenceProxy section */ + +/* Begin PBXSourcesBuildPhase section */ + 8DD76FAB0486AB0100D96B5E /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 2B47D9AB1209C6AC00937F2C /* glsl_optimizer_tests.cpp in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 2B62803A13A15D6300B735C2 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = mesaglsl2; + targetProxy = 2B62803913A15D6300B735C2 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin XCBuildConfiguration section */ + 1DEB928608733DD80010E9CD /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + COPY_PHASE_STRIP = NO; + GCC_DYNAMIC_NO_PIC = NO; + GCC_ENABLE_FIX_AND_CONTINUE = YES; + GCC_MODEL_TUNING = G5; + GCC_OPTIMIZATION_LEVEL = 0; + INSTALL_PATH = /usr/local/bin; + PRODUCT_NAME = "glsl-optimizer-test"; + }; + name = Debug; + }; + 1DEB928708733DD80010E9CD /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + GCC_MODEL_TUNING = G5; + INSTALL_PATH = /usr/local/bin; + PRODUCT_NAME = "glsl-optimizer-test"; + }; + name = Release; + }; + 1DEB928A08733DD80010E9CD /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = i386; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_VERSION = 4.0; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + ONLY_ACTIVE_ARCH = YES; + PREBINDING = NO; + SDKROOT = macosx10.4; + }; + name = Debug; + }; + 1DEB928B08733DD80010E9CD /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = i386; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_VERSION = 4.0; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES; + GCC_WARN_PROTOTYPE_CONVERSION = YES; + GCC_WARN_SHADOW = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + PREBINDING = NO; + SDKROOT = macosx10.4; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 1DEB928508733DD80010E9CD /* Build configuration list for PBXNativeTarget "glsl-optimizer-test" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 1DEB928608733DD80010E9CD /* Debug */, + 1DEB928708733DD80010E9CD /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 1DEB928908733DD80010E9CD /* Build configuration list for PBXProject "glsl-optimizer-tests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 1DEB928A08733DD80010E9CD /* Debug */, + 1DEB928B08733DD80010E9CD /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 08FB7793FE84155DC02AAC07 /* Project object */; +} diff --git a/3rdparty/glsl-optimizer/tests/glsl_optimizer_tests.cpp b/3rdparty/glsl-optimizer/tests/glsl_optimizer_tests.cpp new file mode 100644 index 000000000..36f4a66c1 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/glsl_optimizer_tests.cpp @@ -0,0 +1,425 @@ +#include +#include +#include +#include "../src/glsl/glsl_optimizer.h" + +#if __linux__ +#define GOT_GFX 0 +#else +#define GOT_GFX 1 +#endif + +#if GOT_GFX + +#ifdef _MSC_VER +#include +#include +extern "C" { +typedef char GLcharARB; /* native character */ +typedef unsigned int GLhandleARB; /* shader object handle */ +#define GL_VERTEX_SHADER_ARB 0x8B31 +#define GL_FRAGMENT_SHADER_ARB 0x8B30 +#define GL_OBJECT_COMPILE_STATUS_ARB 0x8B81 +typedef void (WINAPI * PFNGLDELETEOBJECTARBPROC) (GLhandleARB obj); +typedef GLhandleARB (WINAPI * PFNGLCREATESHADEROBJECTARBPROC) (GLenum shaderType); +typedef void (WINAPI * PFNGLSHADERSOURCEARBPROC) (GLhandleARB shaderObj, GLsizei count, const GLcharARB* *string, const GLint *length); +typedef void (WINAPI * PFNGLCOMPILESHADERARBPROC) (GLhandleARB shaderObj); +typedef void (WINAPI * PFNGLGETINFOLOGARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); +typedef void (WINAPI * PFNGLGETOBJECTPARAMETERIVARBPROC) (GLhandleARB obj, GLenum pname, GLint *params); +static PFNGLDELETEOBJECTARBPROC glDeleteObjectARB; +static PFNGLCREATESHADEROBJECTARBPROC glCreateShaderObjectARB; +static PFNGLSHADERSOURCEARBPROC glShaderSourceARB; +static PFNGLCOMPILESHADERARBPROC glCompileShaderARB; +static PFNGLGETINFOLOGARBPROC glGetInfoLogARB; +static PFNGLGETOBJECTPARAMETERIVARBPROC glGetObjectParameterivARB; +} +#else +#include +#include +#include +#endif + +#else // GOT_GFX +#include +#include +#include "dirent.h" +#include "GL/gl.h" +#include "GL/glext.h" +#endif + +static bool InitializeOpenGL () +{ + bool hasGLSL = false; + +#if GOT_GFX + +#ifdef _MSC_VER + // setup minimal required GL + HWND wnd = CreateWindowA( + "STATIC", + "GL", + WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, + 0, 0, 16, 16, + NULL, NULL, + GetModuleHandle(NULL), NULL ); + HDC dc = GetDC( wnd ); + + PIXELFORMATDESCRIPTOR pfd = { + sizeof(PIXELFORMATDESCRIPTOR), 1, + PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL, + PFD_TYPE_RGBA, 32, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 16, 0, + 0, PFD_MAIN_PLANE, 0, 0, 0, 0 + }; + + int fmt = ChoosePixelFormat( dc, &pfd ); + SetPixelFormat( dc, fmt, &pfd ); + + HGLRC rc = wglCreateContext( dc ); + wglMakeCurrent( dc, rc ); + +#else + GLint attributes[16]; + int i = 0; + attributes[i++]=AGL_RGBA; + attributes[i++]=AGL_PIXEL_SIZE; + attributes[i++]=32; + attributes[i++]=AGL_NO_RECOVERY; + attributes[i++]=AGL_NONE; + + AGLPixelFormat pixelFormat = aglChoosePixelFormat(NULL,0,attributes); + AGLContext agl = aglCreateContext(pixelFormat, NULL); + aglSetCurrentContext (agl); + +#endif + + // check if we have GLSL + const char* extensions = (const char*)glGetString(GL_EXTENSIONS); + hasGLSL = strstr(extensions, "GL_ARB_shader_objects") && strstr(extensions, "GL_ARB_vertex_shader") && strstr(extensions, "GL_ARB_fragment_shader"); + +#ifdef _MSC_VER + if (hasGLSL) + { + glDeleteObjectARB = (PFNGLDELETEOBJECTARBPROC)wglGetProcAddress("glDeleteObjectARB"); + glCreateShaderObjectARB = (PFNGLCREATESHADEROBJECTARBPROC)wglGetProcAddress("glCreateShaderObjectARB"); + glShaderSourceARB = (PFNGLSHADERSOURCEARBPROC)wglGetProcAddress("glShaderSourceARB"); + glCompileShaderARB = (PFNGLCOMPILESHADERARBPROC)wglGetProcAddress("glCompileShaderARB"); + glGetInfoLogARB = (PFNGLGETINFOLOGARBPROC)wglGetProcAddress("glGetInfoLogARB"); + glGetObjectParameterivARB = (PFNGLGETOBJECTPARAMETERIVARBPROC)wglGetProcAddress("glGetObjectParameterivARB"); + } +#endif + +#endif + return hasGLSL; +} + +static void replace_string (std::string& target, const std::string& search, const std::string& replace, size_t startPos) +{ + if (search.empty()) + return; + + std::string::size_type p = startPos; + while ((p = target.find (search, p)) != std::string::npos) + { + target.replace (p, search.size (), replace); + p += replace.size (); + } +} + +static bool CheckGLSL (bool vertex, bool gles, const char* prefix, const std::string& source) +{ + std::string src; + if (gles) + { + src += "#define lowp\n"; + src += "#define mediump\n"; + src += "#define highp\n"; + src += "#define texture2DLodEXT texture2DLod\n"; + } + src += source; + if (gles) + { + replace_string (src, "GL_EXT_shader_texture_lod", "GL_ARB_shader_texture_lod", 0); + replace_string (src, "#extension GL_OES_standard_derivatives : require", "", 0); + } + const char* sourcePtr = src.c_str(); + +#if GOT_GFX + + GLhandleARB shader = glCreateShaderObjectARB (vertex ? GL_VERTEX_SHADER_ARB : GL_FRAGMENT_SHADER_ARB); + glShaderSourceARB (shader, 1, &sourcePtr, NULL); + glCompileShaderARB (shader); + GLint status; + glGetObjectParameterivARB (shader, GL_OBJECT_COMPILE_STATUS_ARB, &status); + bool res = true; + if (status == 0) + { + char log[4096]; + GLsizei logLength; + glGetInfoLogARB (shader, sizeof(log), &logLength, log); + printf (" glsl compile error on %s:\n%s\n", prefix, log); + res = false; + } + glDeleteObjectARB (shader); + return res; +#else + // just assume it's ok... + return true; +#endif +} + + +static bool ReadStringFromFile (const char* pathName, std::string& output) +{ + FILE* file = fopen( pathName, "rb" ); + if (file == NULL) + return false; + fseek(file, 0, SEEK_END); + int length = ftell(file); + fseek(file, 0, SEEK_SET); + if (length < 0) + { + fclose( file ); + return false; + } + output.resize(length); + int readLength = fread(&*output.begin(), 1, length, file); + fclose(file); + if (readLength != length) + { + output.clear(); + return false; + } + return true; +} + +bool EndsWith (const std::string& str, const std::string& sub) +{ + return (str.size() >= sub.size()) && (strncmp (str.c_str()+str.size()-sub.size(), sub.c_str(), sub.size())==0); +} + +typedef std::vector StringVector; + +static StringVector GetFiles (const std::string& folder, const std::string& endsWith) +{ + StringVector res; + + #ifdef _MSC_VER + WIN32_FIND_DATAA FindFileData; + HANDLE hFind = FindFirstFileA ((folder+"/*"+endsWith).c_str(), &FindFileData); + if (hFind == INVALID_HANDLE_VALUE) + return res; + + do { + res.push_back (FindFileData.cFileName); + } while (FindNextFileA (hFind, &FindFileData)); + + FindClose (hFind); + + #else + + DIR *dirp; + struct dirent *dp; + + if ((dirp = opendir(folder.c_str())) == NULL) + return res; + + while ( (dp = readdir(dirp)) ) + { + std::string fname = dp->d_name; + if (fname == "." || fname == "..") + continue; + if (!EndsWith (fname, endsWith)) + continue; + res.push_back (fname); + } + closedir(dirp); + + #endif + + return res; +} + +static void DeleteFile (const std::string& path) +{ + #ifdef _MSC_VER + DeleteFileA (path.c_str()); + #else + unlink (path.c_str()); + #endif +} + +static void MassageVertexForGLES (std::string& s) +{ + std::string pre; + pre += "#define gl_Vertex _glesVertex\nattribute highp vec4 _glesVertex;\n"; + pre += "#define gl_Normal _glesNormal\nattribute mediump vec3 _glesNormal;\n"; + pre += "#define gl_MultiTexCoord0 _glesMultiTexCoord0\nattribute highp vec4 _glesMultiTexCoord0;\n"; + pre += "#define gl_MultiTexCoord1 _glesMultiTexCoord1\nattribute highp vec4 _glesMultiTexCoord1;\n"; + pre += "#define gl_Color _glesColor\nattribute lowp vec4 _glesColor;\n"; + s = pre + s; +} + +static void MassageFragmentForGLES (std::string& s) +{ + std::string pre; + s = pre + s; +} + +static bool TestFile (glslopt_ctx* ctx, bool vertex, + const std::string& inputPath, + const std::string& hirPath, + const std::string& outputPath, + bool gles, + bool doCheckGLSL) +{ + std::string input; + if (!ReadStringFromFile (inputPath.c_str(), input)) + { + printf (" failed to read input file\n"); + return false; + } + if (doCheckGLSL) + { + if (!CheckGLSL (vertex, gles, "input", input.c_str())) + return false; + } + + if (gles) + { + if (vertex) + MassageVertexForGLES (input); + else + MassageFragmentForGLES (input); + } + + bool res = true; + + glslopt_shader_type type = vertex ? kGlslOptShaderVertex : kGlslOptShaderFragment; + glslopt_shader* shader = glslopt_optimize (ctx, type, input.c_str(), 0); + + bool optimizeOk = glslopt_get_status(shader); + if (optimizeOk) + { + std::string textHir = glslopt_get_raw_output (shader); + std::string textOpt = glslopt_get_output (shader); + std::string outputHir; + ReadStringFromFile (hirPath.c_str(), outputHir); + std::string outputOpt; + ReadStringFromFile (outputPath.c_str(), outputOpt); + + if (textHir != outputHir) + { + // write output + FILE* f = fopen (hirPath.c_str(), "wb"); + if (!f) + { + printf (" can't write to IR file!\n"); + } + else + { + fwrite (textHir.c_str(), 1, textHir.size(), f); + fclose (f); + } + printf (" does not match raw output\n"); + res = false; + } + + if (textOpt != outputOpt) + { + // write output + FILE* f = fopen (outputPath.c_str(), "wb"); + if (!f) + { + printf (" can't write to optimized file!\n"); + } + else + { + fwrite (textOpt.c_str(), 1, textOpt.size(), f); + fclose (f); + } + printf (" does not match optimized output\n"); + res = false; + } + if (res && doCheckGLSL && !CheckGLSL (vertex, gles, "raw", textHir.c_str())) + res = false; + if (res && doCheckGLSL && !CheckGLSL (vertex, gles, "optimized", textOpt.c_str())) + res = false; + } + else + { + printf (" optimize error: %s\n", glslopt_get_log(shader)); + res = false; + } + + glslopt_shader_delete (shader); + + return res; +} + + +int main (int argc, const char** argv) +{ + if (argc < 2) + { + printf ("USAGE: glsloptimizer testfolder\n"); + return 1; + } + + bool hasOpenGL = InitializeOpenGL (); + glslopt_ctx* ctx[2] = { + glslopt_initialize(true), + glslopt_initialize(false), + }; + + std::string baseFolder = argv[1]; + + clock_t time0 = clock(); + + static const char* kTypeName[2] = { "vertex", "fragment" }; + size_t tests = 0; + size_t errors = 0; + for (int type = 0; type < 2; ++type) + { + std::string testFolder = baseFolder + "/" + kTypeName[type]; + + static const char* kAPIName[2] = { "OpenGL ES 2.0", "OpenGL" }; + static const char* kApiIn [2] = {"-inES.txt", "-in.txt"}; + static const char* kApiIR [2] = {"-irES.txt", "-ir.txt"}; + static const char* kApiOut[2] = {"-outES.txt", "-out.txt"}; + for (int api = 0; api < 2; ++api) + { + printf ("** running %s tests for %s...\n", kTypeName[type], kAPIName[api]); + StringVector inputFiles = GetFiles (testFolder, kApiIn[api]); + + size_t n = inputFiles.size(); + for (size_t i = 0; i < n; ++i) + { + std::string inname = inputFiles[i]; + printf ("test %s\n", inname.c_str()); + std::string hirname = inname.substr (0,inname.size()-strlen(kApiIn[api])) + kApiIR[api]; + std::string outname = inname.substr (0,inname.size()-strlen(kApiIn[api])) + kApiOut[api]; + bool ok = TestFile (ctx[api], type==0, testFolder + "/" + inname, testFolder + "/" + hirname, testFolder + "/" + outname, api==0, hasOpenGL); + if (!ok) + { + ++errors; + } + ++tests; + } + } + } + clock_t time1 = clock(); + float timeDelta = float(time1-time0)/CLOCKS_PER_SEC; + + if (errors != 0) + printf ("**** %i tests (%.2fsec), %i !!!FAILED!!!\n", tests, timeDelta, errors); + else + printf ("**** %i tests (%.2fsec) succeeded\n", tests, timeDelta); + + for (int i = 0; i < 2; ++i) + glslopt_cleanup (ctx[i]); + + return errors ? 1 : 0; +} diff --git a/3rdparty/glsl-optimizer/tests/glsl_optimizer_tests.vcproj b/3rdparty/glsl-optimizer/tests/glsl_optimizer_tests.vcproj new file mode 100644 index 000000000..b3521331a --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/glsl_optimizer_tests.vcproj @@ -0,0 +1,183 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/3rdparty/glsl-optimizer/tests/vertex/MF-GodRays-inES.txt b/3rdparty/glsl-optimizer/tests/vertex/MF-GodRays-inES.txt new file mode 100644 index 000000000..c6c4b1f9e --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/MF-GodRays-inES.txt @@ -0,0 +1,155 @@ +float xll_mod( float x, float y ) { + float d = x / y; + float f = fract (abs(d)) * y; + return d >= 0.0 ? f : -f; +} +vec2 xll_mod( vec2 x, vec2 y ) { + vec2 d = x / y; + vec2 f = fract (abs(d)) * y; + return vec2 (d.x >= 0.0 ? f.x : -f.x, d.y >= 0.0 ? f.y : -f.y); +} +vec3 xll_mod( vec3 x, vec3 y ) { + vec3 d = x / y; + vec3 f = fract (abs(d)) * y; + return vec3 (d.x >= 0.0 ? f.x : -f.x, d.y >= 0.0 ? f.y : -f.y, d.z >= 0.0 ? f.z : -f.z); +} +vec4 xll_mod( vec4 x, vec4 y ) { + vec4 d = x / y; + vec4 f = fract (abs(d)) * y; + return vec4 (d.x >= 0.0 ? f.x : -f.x, d.y >= 0.0 ? f.y : -f.y, d.z >= 0.0 ? f.z : -f.z, d.w >= 0.0 ? f.w : -f.w); +} +float xll_saturate( float x) { + return clamp( x, 0.0, 1.0); +} +vec2 xll_saturate( vec2 x) { + return clamp( x, 0.0, 1.0); +} +vec3 xll_saturate( vec3 x) { + return clamp( x, 0.0, 1.0); +} +vec4 xll_saturate( vec4 x) { + return clamp( x, 0.0, 1.0); +} +mat2 xll_saturate(mat2 m) { + return mat2( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0)); +} +mat3 xll_saturate(mat3 m) { + return mat3( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0), clamp(m[2], 0.0, 1.0)); +} +mat4 xll_saturate(mat4 m) { + return mat4( clamp(m[0], 0.0, 1.0), clamp(m[1], 0.0, 1.0), clamp(m[2], 0.0, 1.0), clamp(m[3], 0.0, 1.0)); +} +struct v2f { + highp vec4 pos; + highp vec2 uv; + lowp vec4 color; +}; +struct appdata_full { + highp vec4 vertex; + highp vec4 tangent; + highp vec3 normal; + highp vec4 texcoord; + highp vec4 texcoord1; + highp vec4 color; +}; +uniform highp float _Bias; +uniform highp float _BlinkingTimeOffsScale; +uniform highp vec4 _Color; +uniform highp float _FadeOutDistFar; +uniform highp float _FadeOutDistNear; +uniform highp float _MaxGrowSize; +uniform highp float _Multiplier; +uniform highp float _NoiseAmount; +uniform highp float _SizeGrowEndDist; +uniform highp float _SizeGrowStartDist; +uniform highp vec4 _Time; +uniform highp float _TimeOffDuration; +uniform highp float _TimeOnDuration; +uniform highp float _VerticalBillboarding; +uniform highp mat4 _World2Object; +uniform highp vec3 _WorldSpaceCameraPos; +uniform highp mat4 glstate_matrix_mvp; +void CalcOrthonormalBasis( in highp vec3 dir, out highp vec3 right, out highp vec3 up ); +highp float CalcFadeOutFactor( in highp float dist ); +highp float CalcDistScale( in highp float dist ); +v2f xlat_main( in appdata_full v ); +void CalcOrthonormalBasis( in highp vec3 dir, out highp vec3 right, out highp vec3 up ) { + up = (( (abs( dir.y ) > 0.999000) ) ? ( highp vec3( 0.00000, 0.00000, 1.00000) ) : ( highp vec3( 0.00000, 1.00000, 0.00000) )); + right = normalize( cross( up, dir) ); + up = cross( dir, right); +} +highp float CalcFadeOutFactor( in highp float dist ) { + highp float nfadeout; + highp float ffadeout; + nfadeout = xll_saturate( (dist / _FadeOutDistNear) ); + ffadeout = (1.00000 - xll_saturate( (max( (dist - _FadeOutDistFar), 0.00000) * 0.200000) )); + ffadeout *= ffadeout; + nfadeout *= nfadeout; + nfadeout *= nfadeout; + nfadeout *= ffadeout; + return nfadeout; +} +highp float CalcDistScale( in highp float dist ) { + highp float distScale; + distScale = min( (max( (dist - _SizeGrowStartDist), 0.00000) / _SizeGrowEndDist), 1.00000); + return ((distScale * distScale) * _MaxGrowSize); +} +v2f xlat_main( in appdata_full v ) { + highp vec3 centerOffs; + highp vec3 centerLocal; + highp vec3 viewerLocal; + highp vec3 localDir; + highp float localDirLength; + highp vec3 rightLocal; + highp vec3 upLocal; + highp float distScale; + highp vec3 BBNormal; + highp vec3 BBLocalPos; + highp float time; + highp float fracTime; + highp float wave; + highp float noiseTime; + highp float noise; + highp float noiseWave; + v2f o; + centerOffs = (vec3( (vec2( 0.500000) - v.color.xy ), 0.00000) * v.texcoord1.xyy ); + centerLocal = (v.vertex.xyz + centerOffs.xyz ); + viewerLocal = vec3( ( _World2Object * vec4( _WorldSpaceCameraPos, 1.00000) )); + localDir = (viewerLocal - centerLocal); + localDir.y = mix( 0.00000, localDir.y , _VerticalBillboarding); + localDirLength = length( localDir ); + CalcOrthonormalBasis( (localDir / localDirLength), rightLocal, upLocal); + distScale = (CalcDistScale( localDirLength) * v.color.w ); + BBNormal = ((rightLocal * v.normal.x ) + (upLocal * v.normal.y )); + BBLocalPos = ((centerLocal - ((rightLocal * centerOffs.x ) + (upLocal * centerOffs.y ))) + (BBNormal * distScale)); + time = (_Time.y + (_BlinkingTimeOffsScale * v.color.z )); + fracTime = xll_mod( time, (_TimeOnDuration + _TimeOffDuration)); + wave = (smoothstep( 0.00000, (_TimeOnDuration * 0.250000), fracTime) * (1.00000 - smoothstep( (_TimeOnDuration * 0.750000), _TimeOnDuration, fracTime))); + noiseTime = (time * (6.28319 / _TimeOnDuration)); + noise = (sin( noiseTime ) * ((0.500000 * cos( ((noiseTime * 0.636600) + 56.7272) )) + 0.500000)); + noiseWave = ((_NoiseAmount * noise) + (1.00000 - _NoiseAmount)); + wave = (( (_NoiseAmount < 0.0100000) ) ? ( wave ) : ( noiseWave )); + wave += _Bias; + o.uv = v.texcoord.xy ; + o.pos = ( glstate_matrix_mvp * vec4( BBLocalPos, 1.00000) ); + o.color = (((CalcFadeOutFactor( localDirLength) * _Color) * _Multiplier) * wave); + return o; +} +attribute vec4 TANGENT; +varying highp vec4 xlv_SV_POSITION; +varying highp vec2 xlv_TEXCOORD0; +varying lowp vec4 xlv_TEXCOORD1; +void main() { + v2f xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = xlat_main( xlt_v); + xlv_SV_POSITION = vec4( xl_retval.pos); + xlv_TEXCOORD0 = vec2( xl_retval.uv); + xlv_TEXCOORD1 = vec4( xl_retval.color); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/MF-GodRays-irES.txt b/3rdparty/glsl-optimizer/tests/vertex/MF-GodRays-irES.txt new file mode 100644 index 000000000..6dd6f4521 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/MF-GodRays-irES.txt @@ -0,0 +1,551 @@ +struct v2f { + highp vec4 pos; + highp vec2 uv; + lowp vec4 color; +}; +struct appdata_full { + highp vec4 vertex; + highp vec4 tangent; + highp vec3 normal; + highp vec4 texcoord; + highp vec4 texcoord1; + highp vec4 color; +}; +varying lowp vec4 xlv_TEXCOORD1; +varying highp vec2 xlv_TEXCOORD0; +varying highp vec4 xlv_SV_POSITION; +attribute vec4 TANGENT; +uniform highp mat4 glstate_matrix_mvp; +uniform highp vec3 _WorldSpaceCameraPos; +uniform highp mat4 _World2Object; +uniform highp float _VerticalBillboarding; +uniform highp float _TimeOnDuration; +uniform highp float _TimeOffDuration; +uniform highp vec4 _Time; +uniform highp float _SizeGrowStartDist; +uniform highp float _SizeGrowEndDist; +uniform highp float _NoiseAmount; +uniform highp float _Multiplier; +uniform highp float _MaxGrowSize; +uniform highp float _FadeOutDistNear; +uniform highp float _FadeOutDistFar; +uniform highp vec4 _Color; +uniform highp float _BlinkingTimeOffsScale; +uniform highp float _Bias; +attribute lowp vec4 _glesColor; +attribute highp vec4 _glesMultiTexCoord1; +attribute highp vec4 _glesMultiTexCoord0; +attribute mediump vec3 _glesNormal; +attribute highp vec4 _glesVertex; +float xll_mod ( + in float x, + in float y +) +{ + float f; + float d; + float tmpvar_1; + tmpvar_1 = (x / y); + d = tmpvar_1; + float tmpvar_2; + tmpvar_2 = abs (d); + float tmpvar_3; + tmpvar_3 = fract (tmpvar_2); + float tmpvar_4; + tmpvar_4 = (tmpvar_3 * y); + f = tmpvar_4; + float tmpvar_5; + if ((d >= 0.0)) { + tmpvar_5 = f; + } else { + tmpvar_5 = -(f); + }; + return tmpvar_5; +} + +vec2 xll_mod ( + in vec2 x, + in vec2 y +) +{ + vec2 f; + vec2 d; + vec2 tmpvar_1; + tmpvar_1 = (x / y); + d = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = abs (d); + vec2 tmpvar_3; + tmpvar_3 = fract (tmpvar_2); + vec2 tmpvar_4; + tmpvar_4 = (tmpvar_3 * y); + f = tmpvar_4; + float tmpvar_5; + if ((d.x >= 0.0)) { + tmpvar_5 = f.x; + } else { + tmpvar_5 = -(f.x); + }; + float tmpvar_6; + if ((d.y >= 0.0)) { + tmpvar_6 = f.y; + } else { + tmpvar_6 = -(f.y); + }; + vec2 tmpvar_7; + tmpvar_7.x = tmpvar_5; + tmpvar_7.y = tmpvar_6; + return tmpvar_7; +} + +vec3 xll_mod ( + in vec3 x, + in vec3 y +) +{ + vec3 f; + vec3 d; + vec3 tmpvar_1; + tmpvar_1 = (x / y); + d = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = abs (d); + vec3 tmpvar_3; + tmpvar_3 = fract (tmpvar_2); + vec3 tmpvar_4; + tmpvar_4 = (tmpvar_3 * y); + f = tmpvar_4; + float tmpvar_5; + if ((d.x >= 0.0)) { + tmpvar_5 = f.x; + } else { + tmpvar_5 = -(f.x); + }; + float tmpvar_6; + if ((d.y >= 0.0)) { + tmpvar_6 = f.y; + } else { + tmpvar_6 = -(f.y); + }; + float tmpvar_7; + if ((d.z >= 0.0)) { + tmpvar_7 = f.z; + } else { + tmpvar_7 = -(f.z); + }; + vec3 tmpvar_8; + tmpvar_8.x = tmpvar_5; + tmpvar_8.y = tmpvar_6; + tmpvar_8.z = tmpvar_7; + return tmpvar_8; +} + +vec4 xll_mod ( + in vec4 x, + in vec4 y +) +{ + vec4 f; + vec4 d; + vec4 tmpvar_1; + tmpvar_1 = (x / y); + d = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = abs (d); + vec4 tmpvar_3; + tmpvar_3 = fract (tmpvar_2); + vec4 tmpvar_4; + tmpvar_4 = (tmpvar_3 * y); + f = tmpvar_4; + float tmpvar_5; + if ((d.x >= 0.0)) { + tmpvar_5 = f.x; + } else { + tmpvar_5 = -(f.x); + }; + float tmpvar_6; + if ((d.y >= 0.0)) { + tmpvar_6 = f.y; + } else { + tmpvar_6 = -(f.y); + }; + float tmpvar_7; + if ((d.z >= 0.0)) { + tmpvar_7 = f.z; + } else { + tmpvar_7 = -(f.z); + }; + float tmpvar_8; + if ((d.w >= 0.0)) { + tmpvar_8 = f.w; + } else { + tmpvar_8 = -(f.w); + }; + vec4 tmpvar_9; + tmpvar_9.x = tmpvar_5; + tmpvar_9.y = tmpvar_6; + tmpvar_9.z = tmpvar_7; + tmpvar_9.w = tmpvar_8; + return tmpvar_9; +} + +float xll_saturate ( + in float x +) +{ + float tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec2 xll_saturate ( + in vec2 x +) +{ + vec2 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec3 xll_saturate ( + in vec3 x +) +{ + vec3 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec4 xll_saturate ( + in vec4 x +) +{ + vec4 tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +mat2 xll_saturate ( + in mat2 m +) +{ + vec2 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec2 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + mat2 tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_1; + tmpvar_3[0] = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5 = tmpvar_2; + tmpvar_3[1] = tmpvar_5; + return tmpvar_3; +} + +mat3 xll_saturate ( + in mat3 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec3 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + vec3 tmpvar_3; + tmpvar_3 = clamp (m[2], 0.0, 1.0); + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +mat4 xll_saturate ( + in mat4 m +) +{ + vec4 tmpvar_1; + tmpvar_1 = clamp (m[0], 0.0, 1.0); + vec4 tmpvar_2; + tmpvar_2 = clamp (m[1], 0.0, 1.0); + vec4 tmpvar_3; + tmpvar_3 = clamp (m[2], 0.0, 1.0); + vec4 tmpvar_4; + tmpvar_4 = clamp (m[3], 0.0, 1.0); + mat4 tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_1; + tmpvar_5[0] = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = tmpvar_2; + tmpvar_5[1] = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_3; + tmpvar_5[2] = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = tmpvar_4; + tmpvar_5[3] = tmpvar_9; + return tmpvar_5; +} + +void CalcOrthonormalBasis ( + in highp vec3 dir, + out highp vec3 right, + out highp vec3 up +) +{ + highp float tmpvar_1; + tmpvar_1 = abs (dir.y); + vec3 tmpvar_2; + if ((tmpvar_1 > 0.999)) { + tmpvar_2 = vec3(0.0, 0.0, 1.0); + } else { + tmpvar_2 = vec3(0.0, 1.0, 0.0); + }; + vec3 tmpvar_3; + tmpvar_3 = tmpvar_2; + up = tmpvar_3; + highp vec3 tmpvar_4; + tmpvar_4 = cross (up, dir); + highp vec3 tmpvar_5; + tmpvar_5 = normalize (tmpvar_4); + highp vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + right = tmpvar_6; + highp vec3 tmpvar_7; + tmpvar_7 = cross (dir, right); + highp vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + up = tmpvar_8; +} + +float CalcFadeOutFactor ( + in highp float dist +) +{ + highp float ffadeout; + highp float nfadeout; + float tmpvar_1; + tmpvar_1 = xll_saturate ((dist / _FadeOutDistNear)); + float tmpvar_2; + tmpvar_2 = tmpvar_1; + nfadeout = tmpvar_2; + highp float tmpvar_3; + tmpvar_3 = max ((dist - _FadeOutDistFar), 0.0); + float tmpvar_4; + tmpvar_4 = xll_saturate ((tmpvar_3 * 0.2)); + float tmpvar_5; + tmpvar_5 = (1.0 - tmpvar_4); + ffadeout = tmpvar_5; + highp float tmpvar_6; + tmpvar_6 = (ffadeout * ffadeout); + ffadeout = tmpvar_6; + highp float tmpvar_7; + tmpvar_7 = (nfadeout * nfadeout); + nfadeout = tmpvar_7; + highp float tmpvar_8; + tmpvar_8 = (nfadeout * nfadeout); + nfadeout = tmpvar_8; + highp float tmpvar_9; + tmpvar_9 = (nfadeout * ffadeout); + nfadeout = tmpvar_9; + return nfadeout; +} + +float CalcDistScale ( + in highp float dist +) +{ + highp float distScale; + highp float tmpvar_1; + tmpvar_1 = max ((dist - _SizeGrowStartDist), 0.0); + highp float tmpvar_2; + tmpvar_2 = min ((tmpvar_1 / _SizeGrowEndDist), 1.0); + highp float tmpvar_3; + tmpvar_3 = tmpvar_2; + distScale = tmpvar_3; + return ((distScale * distScale) * _MaxGrowSize); +} + +v2f xlat_main ( + in appdata_full v +) +{ + v2f o; + highp float noiseWave; + highp float noise; + highp float noiseTime; + highp float wave; + highp float fracTime; + highp float time; + highp vec3 BBLocalPos; + highp vec3 BBNormal; + highp float distScale; + highp vec3 upLocal; + highp vec3 rightLocal; + highp float localDirLength; + highp vec3 localDir; + highp vec3 viewerLocal; + highp vec3 centerLocal; + highp vec3 centerOffs; + highp vec3 tmpvar_1; + tmpvar_1.z = 0.0; + tmpvar_1.xy = (vec2(0.5, 0.5) - v.color.xy).xy; + highp vec3 tmpvar_2; + tmpvar_2 = (tmpvar_1 * v.texcoord1.xyy); + centerOffs = tmpvar_2; + highp vec3 tmpvar_3; + tmpvar_3 = (v.vertex.xyz + centerOffs.xyz); + centerLocal = tmpvar_3; + highp vec4 tmpvar_4; + tmpvar_4.w = 1.0; + tmpvar_4.xyz = _WorldSpaceCameraPos.xyz; + highp vec3 tmpvar_5; + tmpvar_5 = (_World2Object * tmpvar_4).xyz; + highp vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + viewerLocal = tmpvar_6; + highp vec3 tmpvar_7; + tmpvar_7 = (viewerLocal - centerLocal); + localDir = tmpvar_7; + highp float tmpvar_8; + tmpvar_8 = mix (0.0, localDir.y, _VerticalBillboarding); + highp float tmpvar_9; + tmpvar_9 = tmpvar_8; + localDir.y = vec2(tmpvar_9).y; + highp float tmpvar_10; + tmpvar_10 = length (localDir); + highp float tmpvar_11; + tmpvar_11 = tmpvar_10; + localDirLength = tmpvar_11; + CalcOrthonormalBasis ((localDir / localDirLength), rightLocal, upLocal); + highp float tmpvar_12; + tmpvar_12 = CalcDistScale (localDirLength); + highp float tmpvar_13; + tmpvar_13 = (tmpvar_12 * v.color.w); + distScale = tmpvar_13; + highp vec3 tmpvar_14; + tmpvar_14 = ((rightLocal * v.normal.x) + (upLocal * v.normal.y)); + BBNormal = tmpvar_14; + highp vec3 tmpvar_15; + tmpvar_15 = ((centerLocal - ((rightLocal * centerOffs.x) + (upLocal * centerOffs.y))) + (BBNormal * distScale)); + BBLocalPos = tmpvar_15; + highp float tmpvar_16; + tmpvar_16 = (_Time.y + (_BlinkingTimeOffsScale * v.color.z)); + time = tmpvar_16; + float tmpvar_17; + tmpvar_17 = xll_mod (time, (_TimeOnDuration + _TimeOffDuration)); + float tmpvar_18; + tmpvar_18 = tmpvar_17; + fracTime = tmpvar_18; + highp float tmpvar_19; + tmpvar_19 = smoothstep (0.0, (_TimeOnDuration * 0.25), fracTime); + highp float tmpvar_20; + tmpvar_20 = smoothstep ((_TimeOnDuration * 0.75), _TimeOnDuration, fracTime); + highp float tmpvar_21; + tmpvar_21 = (tmpvar_19 * (1.0 - tmpvar_20)); + wave = tmpvar_21; + highp float tmpvar_22; + tmpvar_22 = (time * (6.28319 / _TimeOnDuration)); + noiseTime = tmpvar_22; + highp float tmpvar_23; + tmpvar_23 = sin (noiseTime); + highp float tmpvar_24; + tmpvar_24 = cos (((noiseTime * 0.6366) + 56.7272)); + highp float tmpvar_25; + tmpvar_25 = (tmpvar_23 * ((0.5 * tmpvar_24) + 0.5)); + noise = tmpvar_25; + highp float tmpvar_26; + tmpvar_26 = ((_NoiseAmount * noise) + (1.0 - _NoiseAmount)); + noiseWave = tmpvar_26; + highp float tmpvar_27; + if ((_NoiseAmount < 0.01)) { + tmpvar_27 = wave; + } else { + tmpvar_27 = noiseWave; + }; + highp float tmpvar_28; + tmpvar_28 = tmpvar_27; + wave = tmpvar_28; + highp float tmpvar_29; + tmpvar_29 = (wave + _Bias); + wave = tmpvar_29; + highp vec2 tmpvar_30; + tmpvar_30 = v.texcoord.xy; + o.uv = tmpvar_30; + highp vec4 tmpvar_31; + tmpvar_31.w = 1.0; + tmpvar_31.xyz = BBLocalPos.xyz; + highp vec4 tmpvar_32; + tmpvar_32 = (glstate_matrix_mvp * tmpvar_31); + o.pos = tmpvar_32; + highp float tmpvar_33; + tmpvar_33 = CalcFadeOutFactor (localDirLength); + highp vec4 tmpvar_34; + tmpvar_34 = (((tmpvar_33 * _Color) * _Multiplier) * wave); + o.color = tmpvar_34; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f xl_retval; + highp vec4 tmpvar_1; + tmpvar_1 = _glesVertex.xyzw; + highp vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + mediump vec3 tmpvar_5; + tmpvar_5 = _glesNormal.xyz; + mediump vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + highp vec4 tmpvar_7; + tmpvar_7 = _glesMultiTexCoord0.xyzw; + highp vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + highp vec4 tmpvar_9; + tmpvar_9 = _glesMultiTexCoord1.xyzw; + highp vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + lowp vec4 tmpvar_11; + tmpvar_11 = _glesColor.xyzw; + lowp vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f tmpvar_13; + tmpvar_13 = xlat_main (xlt_v); + v2f tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + highp vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + highp vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + xlv_SV_POSITION = tmpvar_16; + highp vec2 tmpvar_17; + tmpvar_17 = xl_retval.uv.xy; + highp vec2 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_TEXCOORD0 = tmpvar_18; + lowp vec4 tmpvar_19; + tmpvar_19 = xl_retval.color.xyzw; + lowp vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + xlv_TEXCOORD1 = tmpvar_20; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/MF-GodRays-outES.txt b/3rdparty/glsl-optimizer/tests/vertex/MF-GodRays-outES.txt new file mode 100644 index 000000000..e18ec17c6 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/MF-GodRays-outES.txt @@ -0,0 +1,110 @@ +varying lowp vec4 xlv_TEXCOORD1; +varying highp vec2 xlv_TEXCOORD0; +varying highp vec4 xlv_SV_POSITION; +uniform highp mat4 glstate_matrix_mvp; +uniform highp vec3 _WorldSpaceCameraPos; +uniform highp mat4 _World2Object; +uniform highp float _VerticalBillboarding; +uniform highp float _TimeOnDuration; +uniform highp float _TimeOffDuration; +uniform highp vec4 _Time; +uniform highp float _SizeGrowStartDist; +uniform highp float _SizeGrowEndDist; +uniform highp float _NoiseAmount; +uniform highp float _Multiplier; +uniform highp float _MaxGrowSize; +uniform highp float _FadeOutDistNear; +uniform highp float _FadeOutDistFar; +uniform highp vec4 _Color; +uniform highp float _BlinkingTimeOffsScale; +uniform highp float _Bias; +attribute lowp vec4 _glesColor; +attribute highp vec4 _glesMultiTexCoord1; +attribute highp vec4 _glesMultiTexCoord0; +attribute mediump vec3 _glesNormal; +attribute highp vec4 _glesVertex; +void main () +{ + highp vec3 tmpvar_1; + highp vec4 tmpvar_2; + tmpvar_1 = _glesNormal; + tmpvar_2 = _glesColor; + lowp vec4 tmpvar_3; + highp vec3 localDir; + highp vec3 tmpvar_4; + tmpvar_4.z = 0.0; + tmpvar_4.xy = (vec2(0.5, 0.5) - tmpvar_2.xy); + highp vec3 tmpvar_5; + tmpvar_5 = (tmpvar_4 * _glesMultiTexCoord1.xyy); + highp vec3 tmpvar_6; + tmpvar_6 = (_glesVertex.xyz + tmpvar_5); + highp vec4 tmpvar_7; + tmpvar_7.w = 1.0; + tmpvar_7.xyz = _WorldSpaceCameraPos; + highp vec3 tmpvar_8; + tmpvar_8 = ((_World2Object * tmpvar_7).xyz - tmpvar_6); + localDir = tmpvar_8; + localDir.y = mix (0.0, tmpvar_8.y, _VerticalBillboarding); + highp float tmpvar_9; + tmpvar_9 = length (localDir); + highp vec3 dir; + dir = (localDir / tmpvar_9); + highp float tmpvar_10; + tmpvar_10 = abs (dir.y); + vec3 tmpvar_11; + if ((tmpvar_10 > 0.999)) { + tmpvar_11 = vec3(0.0, 0.0, 1.0); + } else { + tmpvar_11 = vec3(0.0, 1.0, 0.0); + }; + highp vec3 tmpvar_12; + tmpvar_12 = normalize (cross (tmpvar_11, dir)); + highp vec3 tmpvar_13; + tmpvar_13 = cross (dir, tmpvar_12); + highp float tmpvar_14; + tmpvar_14 = min ((max ((tmpvar_9 - _SizeGrowStartDist), 0.0) / _SizeGrowEndDist), 1.0); + highp vec3 tmpvar_15; + tmpvar_15 = ((tmpvar_6 - ((tmpvar_12 * tmpvar_5.x) + (tmpvar_13 * tmpvar_5.y))) + (((tmpvar_12 * tmpvar_1.x) + (tmpvar_13 * tmpvar_1.y)) * (((tmpvar_14 * tmpvar_14) * _MaxGrowSize) * tmpvar_2.w))); + highp float tmpvar_16; + tmpvar_16 = (_Time.y + (_BlinkingTimeOffsScale * tmpvar_2.z)); + highp float y; + y = (_TimeOnDuration + _TimeOffDuration); + float tmpvar_17; + tmpvar_17 = (tmpvar_16 / y); + float tmpvar_18; + tmpvar_18 = (fract (abs (tmpvar_17)) * y); + float tmpvar_19; + if ((tmpvar_17 >= 0.0)) { + tmpvar_19 = tmpvar_18; + } else { + tmpvar_19 = -(tmpvar_18); + }; + highp float tmpvar_20; + tmpvar_20 = (smoothstep (0.0, (_TimeOnDuration * 0.25), tmpvar_19) * (1.0 - smoothstep ((_TimeOnDuration * 0.75), _TimeOnDuration, tmpvar_19))); + highp float tmpvar_21; + tmpvar_21 = (tmpvar_16 * (6.28319 / _TimeOnDuration)); + highp float tmpvar_22; + tmpvar_22 = ((_NoiseAmount * (sin (tmpvar_21) * ((0.5 * cos (((tmpvar_21 * 0.6366) + 56.7272))) + 0.5))) + (1.0 - _NoiseAmount)); + highp float tmpvar_23; + if ((_NoiseAmount < 0.01)) { + tmpvar_23 = tmpvar_20; + } else { + tmpvar_23 = tmpvar_22; + }; + highp vec4 tmpvar_24; + tmpvar_24.w = 1.0; + tmpvar_24.xyz = tmpvar_15; + highp float tmpvar_25; + tmpvar_25 = clamp ((tmpvar_9 / _FadeOutDistNear), 0.0, 1.0); + float tmpvar_26; + tmpvar_26 = (1.0 - clamp ((max ((tmpvar_9 - _FadeOutDistFar), 0.0) * 0.2), 0.0, 1.0)); + highp float tmpvar_27; + tmpvar_27 = (tmpvar_25 * tmpvar_25); + highp vec4 tmpvar_28; + tmpvar_28 = (((((tmpvar_27 * tmpvar_27) * (tmpvar_26 * tmpvar_26)) * _Color) * _Multiplier) * (tmpvar_23 + _Bias)); + tmpvar_3 = tmpvar_28; + xlv_SV_POSITION = (glstate_matrix_mvp * tmpvar_24); + xlv_TEXCOORD0 = _glesMultiTexCoord0.xy; + xlv_TEXCOORD1 = tmpvar_3; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/complex-alphabumpspec-in.txt b/3rdparty/glsl-optimizer/tests/vertex/complex-alphabumpspec-in.txt new file mode 100644 index 000000000..a1aeca242 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/complex-alphabumpspec-in.txt @@ -0,0 +1,132 @@ +mat3 xll_constructMat3( mat4 m) { + return mat3( vec3( m[0]), vec3( m[1]), vec3( m[2])); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 viewDir; + vec3 lightDir; + vec3 vlight; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _BumpMap_ST; +uniform vec4 _MainTex_ST; +uniform mat4 _Object2World; +uniform mat4 _World2Object; +uniform vec3 _WorldSpaceCameraPos; +uniform vec4 _WorldSpaceLightPos0; + +uniform vec4 unity_SHAb; +uniform vec4 unity_SHAg; +uniform vec4 unity_SHAr; +uniform vec4 unity_SHBb; +uniform vec4 unity_SHBg; +uniform vec4 unity_SHBr; +uniform vec4 unity_SHC; +uniform vec4 unity_Scale; +vec3 ShadeSH9( in vec4 normal ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +vec3 ObjSpaceViewDir( in vec4 v ); +vec3 ObjSpaceLightDir( in vec4 v ); +v2f_surf vert_surf( in appdata_full v ); +vec3 ShadeSH9( in vec4 normal ) { + vec3 x1; + vec4 vB; + vec3 x2; + float vC; + vec3 x3; + x1.x = dot( unity_SHAr, normal); + x1.y = dot( unity_SHAg, normal); + x1.z = dot( unity_SHAb, normal); + vB = (normal.xyzz * normal.yzzx ); + x2.x = dot( unity_SHBr, vB); + x2.y = dot( unity_SHBg, vB); + x2.z = dot( unity_SHBb, vB); + vC = ((normal.x * normal.x ) - (normal.y * normal.y )); + x3 = (unity_SHC.xyz * vC); + return ((x1 + x2) + x3); +} +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +vec3 ObjSpaceViewDir( in vec4 v ) { + vec3 objSpaceCameraPos; + objSpaceCameraPos = (( _World2Object * vec4( _WorldSpaceCameraPos.xyz , 1.00000) ).xyz * unity_Scale.w ); + return (objSpaceCameraPos - v.xyz ); +} +vec3 ObjSpaceLightDir( in vec4 v ) { + vec3 objSpaceLightPos; + objSpaceLightPos = ( _World2Object * _WorldSpaceLightPos0 ).xyz ; + return objSpaceLightPos.xyz ; +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + vec3 worldN; + vec3 binormal; + mat3 rotation; + vec3 shlight; + PositionFog( v.vertex, o.pos, o.fog); + o.hip_pack0.xy = ((v.texcoord.xy * _MainTex_ST.xy ) + _MainTex_ST.zw ); + o.hip_pack0.zw = ((v.texcoord.xy * _BumpMap_ST.xy ) + _BumpMap_ST.zw ); + worldN = ( xll_constructMat3( _Object2World) * (v.normal * unity_Scale.w ) ); + binormal = (cross( v.normal, v.tangent.xyz ) * v.tangent.w ); + rotation = mat3( v.tangent.x , binormal.x , v.normal.x , v.tangent.y , binormal.y , v.normal.y , v.tangent.z , binormal.z , v.normal.z ); + o.lightDir = ( rotation * ObjSpaceLightDir( v.vertex) ); + o.viewDir = ( rotation * ObjSpaceViewDir( v.vertex) ); + shlight = ShadeSH9( vec4( worldN, 1.00000)); + o.vlight = shlight; + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.hip_pack0); + gl_TexCoord[1] = vec4( xl_retval.viewDir, 0.0); + gl_TexCoord[2] = vec4( xl_retval.lightDir, 0.0); + gl_TexCoord[3] = vec4( xl_retval.vlight, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/complex-alphabumpspec-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/complex-alphabumpspec-ir.txt new file mode 100644 index 000000000..0e67c7308 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/complex-alphabumpspec-ir.txt @@ -0,0 +1,301 @@ +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 viewDir; + vec3 lightDir; + vec3 vlight; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec4 unity_SHC; +uniform vec4 unity_SHBr; +uniform vec4 unity_SHBg; +uniform vec4 unity_SHBb; +uniform vec4 unity_SHAr; +uniform vec4 unity_SHAg; +uniform vec4 unity_SHAb; +uniform vec4 _WorldSpaceLightPos0; +uniform vec3 _WorldSpaceCameraPos; +uniform mat4 _World2Object; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform vec4 _BumpMap_ST; +mat3 xll_constructMat3 ( + in mat4 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = m[0].xyz; + vec3 tmpvar_2; + tmpvar_2 = m[1].xyz; + vec3 tmpvar_3; + tmpvar_3 = m[2].xyz; + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +vec3 ShadeSH9 ( + in vec4 normal +) +{ + vec3 x3; + float vC; + vec3 x2; + vec4 vB; + vec3 x1; + float tmpvar_1; + tmpvar_1 = dot (unity_SHAr, normal); + float tmpvar_2; + tmpvar_2 = tmpvar_1; + x1.x = tmpvar_2; + float tmpvar_3; + tmpvar_3 = dot (unity_SHAg, normal); + float tmpvar_4; + tmpvar_4 = tmpvar_3; + x1.y = vec2(tmpvar_4).y; + float tmpvar_5; + tmpvar_5 = dot (unity_SHAb, normal); + float tmpvar_6; + tmpvar_6 = tmpvar_5; + x1.z = vec3(tmpvar_6).z; + vec4 tmpvar_7; + tmpvar_7 = (normal.xyzz * normal.yzzx); + vB = tmpvar_7; + float tmpvar_8; + tmpvar_8 = dot (unity_SHBr, vB); + float tmpvar_9; + tmpvar_9 = tmpvar_8; + x2.x = tmpvar_9; + float tmpvar_10; + tmpvar_10 = dot (unity_SHBg, vB); + float tmpvar_11; + tmpvar_11 = tmpvar_10; + x2.y = vec2(tmpvar_11).y; + float tmpvar_12; + tmpvar_12 = dot (unity_SHBb, vB); + float tmpvar_13; + tmpvar_13 = tmpvar_12; + x2.z = vec3(tmpvar_13).z; + float tmpvar_14; + tmpvar_14 = ((normal.x * normal.x) - (normal.y * normal.y)); + vC = tmpvar_14; + vec3 tmpvar_15; + tmpvar_15 = (unity_SHC.xyz * vC); + x3 = tmpvar_15; + return ((x1 + x2) + x3); +} + +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +vec3 ObjSpaceViewDir ( + in vec4 v +) +{ + vec3 objSpaceCameraPos; + vec4 tmpvar_1; + tmpvar_1.w = 1.0; + tmpvar_1.xyz = _WorldSpaceCameraPos.xyz.xyz; + vec3 tmpvar_2; + tmpvar_2 = ((_World2Object * tmpvar_1).xyz * unity_Scale.w); + objSpaceCameraPos = tmpvar_2; + return (objSpaceCameraPos - v.xyz); +} + +vec3 ObjSpaceLightDir ( + in vec4 v +) +{ + vec3 objSpaceLightPos; + vec3 tmpvar_1; + tmpvar_1 = (_World2Object * _WorldSpaceLightPos0).xyz; + objSpaceLightPos = tmpvar_1; + return objSpaceLightPos.xyz; +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + vec3 shlight; + mat3 rotation; + vec3 binormal; + vec3 worldN; + v2f_surf o; + PositionFog (v.vertex, o.pos, o.fog); + vec2 tmpvar_1; + tmpvar_1 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + o.hip_pack0.xy = tmpvar_1.xy.xy; + vec2 tmpvar_2; + tmpvar_2 = ((v.texcoord.xy * _BumpMap_ST.xy) + _BumpMap_ST.zw); + o.hip_pack0.zw = tmpvar_2.xxxy.zw; + mat3 tmpvar_3; + tmpvar_3 = (xll_constructMat3 (_Object2World)); + vec3 tmpvar_4; + tmpvar_4 = (tmpvar_3 * (v.normal * unity_Scale.w)); + worldN = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = cross (v.normal, v.tangent.xyz); + vec3 tmpvar_6; + tmpvar_6 = (tmpvar_5 * v.tangent.w); + binormal = tmpvar_6; + mat3 tmpvar_7; + float tmpvar_8; + tmpvar_8 = v.tangent.x; + tmpvar_7[0].x = tmpvar_8; + float tmpvar_9; + tmpvar_9 = binormal.x; + tmpvar_7[0].y = tmpvar_9; + float tmpvar_10; + tmpvar_10 = v.normal.x; + tmpvar_7[0].z = tmpvar_10; + float tmpvar_11; + tmpvar_11 = v.tangent.y; + tmpvar_7[1].x = tmpvar_11; + float tmpvar_12; + tmpvar_12 = binormal.y; + tmpvar_7[1].y = tmpvar_12; + float tmpvar_13; + tmpvar_13 = v.normal.y; + tmpvar_7[1].z = tmpvar_13; + float tmpvar_14; + tmpvar_14 = v.tangent.z; + tmpvar_7[2].x = tmpvar_14; + float tmpvar_15; + tmpvar_15 = binormal.z; + tmpvar_7[2].y = tmpvar_15; + float tmpvar_16; + tmpvar_16 = v.normal.z; + tmpvar_7[2].z = tmpvar_16; + mat3 tmpvar_17; + tmpvar_17 = (tmpvar_7); + rotation = (tmpvar_17); + vec3 tmpvar_18; + tmpvar_18 = ObjSpaceLightDir (v.vertex); + vec3 tmpvar_19; + tmpvar_19 = (rotation * tmpvar_18); + o.lightDir = tmpvar_19; + vec3 tmpvar_20; + tmpvar_20 = ObjSpaceViewDir (v.vertex); + vec3 tmpvar_21; + tmpvar_21 = (rotation * tmpvar_20); + o.viewDir = tmpvar_21; + vec4 tmpvar_22; + tmpvar_22.w = 1.0; + tmpvar_22.xyz = worldN.xyz; + vec3 tmpvar_23; + tmpvar_23 = ShadeSH9 (tmpvar_22); + vec3 tmpvar_24; + tmpvar_24 = tmpvar_23; + shlight = tmpvar_24; + vec3 tmpvar_25; + tmpvar_25 = shlight; + o.vlight = tmpvar_25; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = xl_retval.fog; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_FOG = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19 = xl_retval.hip_pack0.xyzw; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[0] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21.w = 0.0; + tmpvar_21.xyz = xl_retval.viewDir.xyz; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_TexCoord[1] = tmpvar_22; + vec4 tmpvar_23; + tmpvar_23.w = 0.0; + tmpvar_23.xyz = xl_retval.lightDir.xyz; + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + gl_TexCoord[2] = tmpvar_24; + vec4 tmpvar_25; + tmpvar_25.w = 0.0; + tmpvar_25.xyz = xl_retval.vlight.xyz; + vec4 tmpvar_26; + tmpvar_26 = tmpvar_25; + gl_TexCoord[3] = tmpvar_26; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/complex-alphabumpspec-out.txt b/3rdparty/glsl-optimizer/tests/vertex/complex-alphabumpspec-out.txt new file mode 100644 index 000000000..012b6fe3e --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/complex-alphabumpspec-out.txt @@ -0,0 +1,77 @@ +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec4 unity_SHC; +uniform vec4 unity_SHBr; +uniform vec4 unity_SHBg; +uniform vec4 unity_SHBb; +uniform vec4 unity_SHAr; +uniform vec4 unity_SHAg; +uniform vec4 unity_SHAb; +uniform vec4 _WorldSpaceLightPos0; +uniform vec3 _WorldSpaceCameraPos; +uniform mat4 _World2Object; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform vec4 _BumpMap_ST; +void main () +{ + vec4 tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = (gl_ModelViewProjectionMatrix * gl_Vertex); + tmpvar_1.xy = ((gl_MultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + tmpvar_1.zw = ((gl_MultiTexCoord0.xy * _BumpMap_ST.xy) + _BumpMap_ST.zw); + mat3 tmpvar_3; + tmpvar_3[0] = _Object2World[0].xyz; + tmpvar_3[1] = _Object2World[1].xyz; + tmpvar_3[2] = _Object2World[2].xyz; + vec3 tmpvar_4; + tmpvar_4 = (tmpvar_3 * (gl_Normal * unity_Scale.w)); + vec3 tmpvar_5; + tmpvar_5 = (cross (gl_Normal, TANGENT.xyz) * TANGENT.w); + mat3 tmpvar_6; + tmpvar_6[0].x = TANGENT.x; + tmpvar_6[0].y = tmpvar_5.x; + tmpvar_6[0].z = gl_Normal.x; + tmpvar_6[1].x = TANGENT.y; + tmpvar_6[1].y = tmpvar_5.y; + tmpvar_6[1].z = gl_Normal.y; + tmpvar_6[2].x = TANGENT.z; + tmpvar_6[2].y = tmpvar_5.z; + tmpvar_6[2].z = gl_Normal.z; + vec4 tmpvar_7; + tmpvar_7.w = 1.0; + tmpvar_7.xyz = _WorldSpaceCameraPos; + vec4 tmpvar_8; + tmpvar_8.w = 1.0; + tmpvar_8.xyz = tmpvar_4; + vec3 x2; + vec3 x1; + x1.x = dot (unity_SHAr, tmpvar_8); + x1.y = dot (unity_SHAg, tmpvar_8); + x1.z = dot (unity_SHAb, tmpvar_8); + vec4 tmpvar_9; + tmpvar_9 = (tmpvar_4.xyzz * tmpvar_4.yzzx); + x2.x = dot (unity_SHBr, tmpvar_9); + x2.y = dot (unity_SHBg, tmpvar_9); + x2.z = dot (unity_SHBb, tmpvar_9); + gl_Position = tmpvar_2; + vec4 tmpvar_10; + tmpvar_10.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_10.x = tmpvar_2.z; + xlv_FOG = tmpvar_10; + gl_TexCoord[0] = tmpvar_1; + vec4 tmpvar_11; + tmpvar_11.w = 0.0; + tmpvar_11.xyz = (tmpvar_6 * (((_World2Object * tmpvar_7).xyz * unity_Scale.w) - gl_Vertex.xyz)); + gl_TexCoord[1] = tmpvar_11; + vec4 tmpvar_12; + tmpvar_12.w = 0.0; + tmpvar_12.xyz = (tmpvar_6 * (_World2Object * _WorldSpaceLightPos0).xyz); + gl_TexCoord[2] = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13.w = 0.0; + tmpvar_13.xyz = ((x1 + x2) + (unity_SHC.xyz * ((tmpvar_4.x * tmpvar_4.x) - (tmpvar_4.y * tmpvar_4.y)))); + gl_TexCoord[3] = tmpvar_13; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/complex-particle-in.txt b/3rdparty/glsl-optimizer/tests/vertex/complex-particle-in.txt new file mode 100644 index 000000000..f2bd760a5 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/complex-particle-in.txt @@ -0,0 +1,33 @@ +struct v2f { + vec4 vertex; + vec4 color; + vec2 texcoord; +}; +struct appdata_t { + vec4 vertex; + vec4 color; + vec2 texcoord; +}; +uniform vec4 _MainTex_ST; +uniform mat4 glstate_matrix_mvp; +v2f xlat_main( in appdata_t v ); +v2f xlat_main( in appdata_t v ) { + v2f o; + o.vertex = ( glstate_matrix_mvp * v.vertex ); + o.color = v.color; + o.texcoord = ((v.texcoord.xy * _MainTex_ST.xy ) + _MainTex_ST.zw ); + return o; +} +varying vec4 xlv_COLOR; +varying vec2 xlv_TEXCOORD0; +void main() { + v2f xl_retval; + appdata_t xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.color = vec4( gl_Color); + xlt_v.texcoord = vec2( gl_MultiTexCoord0); + xl_retval = xlat_main( xlt_v); + gl_Position = vec4( xl_retval.vertex); + xlv_COLOR = vec4( xl_retval.color); + xlv_TEXCOORD0 = vec2( xl_retval.texcoord); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/complex-particle-inES.txt b/3rdparty/glsl-optimizer/tests/vertex/complex-particle-inES.txt new file mode 100644 index 000000000..38165ebab --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/complex-particle-inES.txt @@ -0,0 +1,33 @@ +struct v2f { + highp vec4 vertex; + lowp vec4 color; + mediump vec2 texcoord; +}; +struct appdata_t { + highp vec4 vertex; + lowp vec4 color; + highp vec2 texcoord; +}; +uniform highp vec4 _MainTex_ST; +uniform highp mat4 glstate_matrix_mvp; +v2f xlat_main( in appdata_t v ); +v2f xlat_main( in appdata_t v ) { + v2f o; + o.vertex = ( glstate_matrix_mvp * v.vertex ); + o.color = v.color; + o.texcoord = ((v.texcoord.xy * _MainTex_ST.xy ) + _MainTex_ST.zw ); + return o; +} +varying lowp vec4 xlv_COLOR; +varying mediump vec2 xlv_TEXCOORD0; +void main() { + v2f xl_retval; + appdata_t xlt_v; + xlt_v.vertex = highp vec4( gl_Vertex); + xlt_v.color = lowp vec4( gl_Color); + xlt_v.texcoord = highp vec2( gl_MultiTexCoord0); + xl_retval = xlat_main( xlt_v); + gl_Position = highp vec4( xl_retval.vertex); + xlv_COLOR = lowp vec4( xl_retval.color); + xlv_TEXCOORD0 = mediump vec2( xl_retval.texcoord); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/complex-particle-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/complex-particle-ir.txt new file mode 100644 index 000000000..2b6a518cb --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/complex-particle-ir.txt @@ -0,0 +1,72 @@ +struct v2f { + vec4 vertex; + vec4 color; + vec2 texcoord; +}; +struct appdata_t { + vec4 vertex; + vec4 color; + vec2 texcoord; +}; +varying vec2 xlv_TEXCOORD0; +varying vec4 xlv_COLOR; +uniform mat4 glstate_matrix_mvp; +uniform vec4 _MainTex_ST; +v2f xlat_main ( + in appdata_t v +) +{ + v2f o; + vec4 tmpvar_1; + tmpvar_1 = (glstate_matrix_mvp * v.vertex); + o.vertex = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = v.color; + o.color = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + o.texcoord = tmpvar_3; + return o; +} + +void main () +{ + appdata_t xlt_v; + v2f xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = gl_Color.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.color = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5 = gl_MultiTexCoord0.xy; + vec2 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.texcoord = tmpvar_6; + v2f tmpvar_7; + tmpvar_7 = xlat_main (xlt_v); + v2f tmpvar_8; + tmpvar_8 = tmpvar_7; + xl_retval = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = xl_retval.vertex.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + gl_Position = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = xl_retval.color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlv_COLOR = tmpvar_12; + vec2 tmpvar_13; + tmpvar_13 = xl_retval.texcoord.xy; + vec2 tmpvar_14; + tmpvar_14 = tmpvar_13; + xlv_TEXCOORD0 = tmpvar_14; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/complex-particle-irES.txt b/3rdparty/glsl-optimizer/tests/vertex/complex-particle-irES.txt new file mode 100644 index 000000000..6da34f81e --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/complex-particle-irES.txt @@ -0,0 +1,77 @@ +struct v2f { + highp vec4 vertex; + lowp vec4 color; + mediump vec2 texcoord; +}; +struct appdata_t { + highp vec4 vertex; + lowp vec4 color; + highp vec2 texcoord; +}; +varying mediump vec2 xlv_TEXCOORD0; +varying lowp vec4 xlv_COLOR; +uniform highp mat4 glstate_matrix_mvp; +uniform highp vec4 _MainTex_ST; +attribute lowp vec4 _glesColor; +attribute highp vec4 _glesMultiTexCoord1; +attribute highp vec4 _glesMultiTexCoord0; +attribute mediump vec3 _glesNormal; +attribute highp vec4 _glesVertex; +v2f xlat_main ( + in appdata_t v +) +{ + v2f o; + highp vec4 tmpvar_1; + tmpvar_1 = (glstate_matrix_mvp * v.vertex); + o.vertex = tmpvar_1; + lowp vec4 tmpvar_2; + tmpvar_2 = v.color; + o.color = tmpvar_2; + highp vec2 tmpvar_3; + tmpvar_3 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + o.texcoord = tmpvar_3; + return o; +} + +void main () +{ + appdata_t xlt_v; + v2f xl_retval; + highp vec4 tmpvar_1; + tmpvar_1 = _glesVertex.xyzw; + highp vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + lowp vec4 tmpvar_3; + tmpvar_3 = _glesColor.xyzw; + lowp vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.color = tmpvar_4; + highp vec2 tmpvar_5; + tmpvar_5 = _glesMultiTexCoord0.xy; + highp vec2 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.texcoord = tmpvar_6; + v2f tmpvar_7; + tmpvar_7 = xlat_main (xlt_v); + v2f tmpvar_8; + tmpvar_8 = tmpvar_7; + xl_retval = tmpvar_8; + highp vec4 tmpvar_9; + tmpvar_9 = xl_retval.vertex.xyzw; + highp vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + gl_Position = tmpvar_10; + lowp vec4 tmpvar_11; + tmpvar_11 = xl_retval.color.xyzw; + lowp vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlv_COLOR = tmpvar_12; + mediump vec2 tmpvar_13; + tmpvar_13 = xl_retval.texcoord.xy; + mediump vec2 tmpvar_14; + tmpvar_14 = tmpvar_13; + xlv_TEXCOORD0 = tmpvar_14; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/complex-particle-out.txt b/3rdparty/glsl-optimizer/tests/vertex/complex-particle-out.txt new file mode 100644 index 000000000..6573aef04 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/complex-particle-out.txt @@ -0,0 +1,11 @@ +varying vec2 xlv_TEXCOORD0; +varying vec4 xlv_COLOR; +uniform mat4 glstate_matrix_mvp; +uniform vec4 _MainTex_ST; +void main () +{ + gl_Position = (glstate_matrix_mvp * gl_Vertex); + xlv_COLOR = gl_Color; + xlv_TEXCOORD0 = ((gl_MultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw); +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/complex-particle-outES.txt b/3rdparty/glsl-optimizer/tests/vertex/complex-particle-outES.txt new file mode 100644 index 000000000..1d3225bdd --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/complex-particle-outES.txt @@ -0,0 +1,18 @@ +varying mediump vec2 xlv_TEXCOORD0; +varying lowp vec4 xlv_COLOR; +uniform highp mat4 glstate_matrix_mvp; +uniform highp vec4 _MainTex_ST; +attribute lowp vec4 _glesColor; +attribute highp vec4 _glesMultiTexCoord0; +attribute highp vec4 _glesVertex; +void main () +{ + mediump vec2 tmpvar_1; + highp vec2 tmpvar_2; + tmpvar_2 = ((_glesMultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + tmpvar_1 = tmpvar_2; + gl_Position = (glstate_matrix_mvp * _glesVertex); + xlv_COLOR = _glesColor; + xlv_TEXCOORD0 = tmpvar_1; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/complex-prepasslight-in.txt b/3rdparty/glsl-optimizer/tests/vertex/complex-prepasslight-in.txt new file mode 100644 index 000000000..851a2bbfa --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/complex-prepasslight-in.txt @@ -0,0 +1,41 @@ +struct v2f { + vec4 pos; + vec4 uv; + vec3 ray; +}; +struct appdata { + vec4 vertex; + vec3 normal; +}; +uniform vec4 _ProjectionParams; +uniform mat4 glstate_matrix_modelview0; +uniform mat4 glstate_matrix_mvp; +vec4 ComputeScreenPos( in vec4 pos ); +v2f xlat_main( in appdata v ); +vec4 ComputeScreenPos( in vec4 pos ) { + vec4 o; + o = (pos * 0.500000); + o.xy = (vec2( o.x , (o.y * _ProjectionParams.x )) + o.w ); + o.zw = pos.zw ; + return o; +} +v2f xlat_main( in appdata v ) { + v2f o; + o.pos = ( glstate_matrix_mvp * v.vertex ); + o.uv = ComputeScreenPos( o.pos); + o.ray = (( glstate_matrix_modelview0 * v.vertex ).xyz * vec3( -1.00000, -1.00000, 1.00000)); + o.ray = mix( o.ray, v.normal, vec3( float( (v.normal.z != 0.000000) ))); + return o; +} +varying vec4 xlv_TEXCOORD0; +varying vec3 xlv_TEXCOORD1; +void main() { + v2f xl_retval; + appdata xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.normal = vec3( gl_Normal); + xl_retval = xlat_main( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_TEXCOORD0 = vec4( xl_retval.uv); + xlv_TEXCOORD1 = vec3( xl_retval.ray); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/complex-prepasslight-inES.txt b/3rdparty/glsl-optimizer/tests/vertex/complex-prepasslight-inES.txt new file mode 100644 index 000000000..a675d38f6 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/complex-prepasslight-inES.txt @@ -0,0 +1,41 @@ +struct v2f { + highp vec4 pos; + highp vec4 uv; + highp vec3 ray; +}; +struct appdata { + highp vec4 vertex; + highp vec3 normal; +}; +uniform highp vec4 _ProjectionParams; +uniform highp mat4 glstate_matrix_modelview0; +uniform highp mat4 glstate_matrix_mvp; +highp vec4 ComputeScreenPos( in highp vec4 pos ); +v2f xlat_main( in appdata v ); +highp vec4 ComputeScreenPos( in highp vec4 pos ) { + highp vec4 o; + o = (pos * 0.500000); + o.xy = (vec2( o.x , (o.y * _ProjectionParams.x )) + o.w ); + o.zw = pos.zw ; + return o; +} +v2f xlat_main( in appdata v ) { + v2f o; + o.pos = ( glstate_matrix_mvp * v.vertex ); + o.uv = ComputeScreenPos( o.pos); + o.ray = (( glstate_matrix_modelview0 * v.vertex ).xyz * highp vec3( -1.00000, -1.00000, 1.00000)); + o.ray = mix( o.ray, v.normal, vec3( float( (v.normal.z != 0.000000) ))); + return o; +} +varying highp vec4 xlv_TEXCOORD0; +varying highp vec3 xlv_TEXCOORD1; +void main() { + v2f xl_retval; + appdata xlt_v; + xlt_v.vertex = highp vec4( gl_Vertex); + xlt_v.normal = highp vec3( gl_Normal); + xl_retval = xlat_main( xlt_v); + gl_Position = highp vec4( xl_retval.pos); + xlv_TEXCOORD0 = highp vec4( xl_retval.uv); + xlv_TEXCOORD1 = highp vec3( xl_retval.ray); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/complex-prepasslight-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/complex-prepasslight-ir.txt new file mode 100644 index 000000000..7c24b07b0 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/complex-prepasslight-ir.txt @@ -0,0 +1,96 @@ +struct v2f { + vec4 pos; + vec4 uv; + vec3 ray; +}; +struct appdata { + vec4 vertex; + vec3 normal; +}; +varying vec3 xlv_TEXCOORD1; +varying vec4 xlv_TEXCOORD0; +uniform mat4 glstate_matrix_mvp; +uniform mat4 glstate_matrix_modelview0; +uniform vec4 _ProjectionParams; +vec4 ComputeScreenPos ( + in vec4 pos +) +{ + vec4 o; + vec4 tmpvar_1; + tmpvar_1 = (pos * 0.5); + o = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2.x = o.x; + tmpvar_2.y = (o.y * _ProjectionParams.x); + vec2 tmpvar_3; + tmpvar_3 = (tmpvar_2 + o.w); + o.xy = tmpvar_3.xy.xy; + vec2 tmpvar_4; + tmpvar_4 = pos.zw; + o.zw = tmpvar_4.xxxy.zw; + return o; +} + +v2f xlat_main ( + in appdata v +) +{ + v2f o; + vec4 tmpvar_1; + tmpvar_1 = (glstate_matrix_mvp * v.vertex); + o.pos = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = ComputeScreenPos (o.pos); + vec4 tmpvar_3; + tmpvar_3 = tmpvar_2; + o.uv = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = ((glstate_matrix_modelview0 * v.vertex).xyz * vec3(-1.0, -1.0, 1.0)); + o.ray = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = vec3(float((v.normal.z != 0.0))); + vec3 tmpvar_6; + tmpvar_6 = mix (o.ray, v.normal, tmpvar_5); + vec3 tmpvar_7; + tmpvar_7 = tmpvar_6; + o.ray = tmpvar_7; + return o; +} + +void main () +{ + appdata xlt_v; + v2f xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = gl_Normal.xyz; + vec3 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.normal = tmpvar_4; + v2f tmpvar_5; + tmpvar_5 = xlat_main (xlt_v); + v2f tmpvar_6; + tmpvar_6 = tmpvar_5; + xl_retval = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = xl_retval.pos.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + gl_Position = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = xl_retval.uv.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlv_TEXCOORD0 = tmpvar_10; + vec3 tmpvar_11; + tmpvar_11 = xl_retval.ray.xyz; + vec3 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlv_TEXCOORD1 = tmpvar_12; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/complex-prepasslight-irES.txt b/3rdparty/glsl-optimizer/tests/vertex/complex-prepasslight-irES.txt new file mode 100644 index 000000000..0620c2ea0 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/complex-prepasslight-irES.txt @@ -0,0 +1,101 @@ +struct v2f { + highp vec4 pos; + highp vec4 uv; + highp vec3 ray; +}; +struct appdata { + highp vec4 vertex; + highp vec3 normal; +}; +varying highp vec3 xlv_TEXCOORD1; +varying highp vec4 xlv_TEXCOORD0; +uniform highp mat4 glstate_matrix_mvp; +uniform highp mat4 glstate_matrix_modelview0; +uniform highp vec4 _ProjectionParams; +attribute lowp vec4 _glesColor; +attribute highp vec4 _glesMultiTexCoord1; +attribute highp vec4 _glesMultiTexCoord0; +attribute mediump vec3 _glesNormal; +attribute highp vec4 _glesVertex; +vec4 ComputeScreenPos ( + in highp vec4 pos +) +{ + highp vec4 o; + highp vec4 tmpvar_1; + tmpvar_1 = (pos * 0.5); + o = tmpvar_1; + highp vec2 tmpvar_2; + tmpvar_2.x = o.x; + tmpvar_2.y = (o.y * _ProjectionParams.x); + highp vec2 tmpvar_3; + tmpvar_3 = (tmpvar_2 + o.w); + o.xy = tmpvar_3.xy.xy; + highp vec2 tmpvar_4; + tmpvar_4 = pos.zw; + o.zw = tmpvar_4.xxxy.zw; + return o; +} + +v2f xlat_main ( + in appdata v +) +{ + v2f o; + highp vec4 tmpvar_1; + tmpvar_1 = (glstate_matrix_mvp * v.vertex); + o.pos = tmpvar_1; + highp vec4 tmpvar_2; + tmpvar_2 = ComputeScreenPos (o.pos); + highp vec4 tmpvar_3; + tmpvar_3 = tmpvar_2; + o.uv = tmpvar_3; + highp vec3 tmpvar_4; + tmpvar_4 = ((glstate_matrix_modelview0 * v.vertex).xyz * vec3(-1.0, -1.0, 1.0)); + o.ray = tmpvar_4; + highp vec3 tmpvar_5; + tmpvar_5 = vec3(float((v.normal.z != 0.0))); + highp vec3 tmpvar_6; + tmpvar_6 = mix (o.ray, v.normal, tmpvar_5); + highp vec3 tmpvar_7; + tmpvar_7 = tmpvar_6; + o.ray = tmpvar_7; + return o; +} + +void main () +{ + appdata xlt_v; + v2f xl_retval; + highp vec4 tmpvar_1; + tmpvar_1 = _glesVertex.xyzw; + highp vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + highp vec3 tmpvar_3; + tmpvar_3 = _glesNormal.xyz; + highp vec3 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.normal = tmpvar_4; + v2f tmpvar_5; + tmpvar_5 = xlat_main (xlt_v); + v2f tmpvar_6; + tmpvar_6 = tmpvar_5; + xl_retval = tmpvar_6; + highp vec4 tmpvar_7; + tmpvar_7 = xl_retval.pos.xyzw; + highp vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + gl_Position = tmpvar_8; + highp vec4 tmpvar_9; + tmpvar_9 = xl_retval.uv.xyzw; + highp vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlv_TEXCOORD0 = tmpvar_10; + highp vec3 tmpvar_11; + tmpvar_11 = xl_retval.ray.xyz; + highp vec3 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlv_TEXCOORD1 = tmpvar_12; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/complex-prepasslight-out.txt b/3rdparty/glsl-optimizer/tests/vertex/complex-prepasslight-out.txt new file mode 100644 index 000000000..8a3200d64 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/complex-prepasslight-out.txt @@ -0,0 +1,23 @@ +varying vec3 xlv_TEXCOORD1; +varying vec4 xlv_TEXCOORD0; +uniform mat4 glstate_matrix_mvp; +uniform mat4 glstate_matrix_modelview0; +uniform vec4 _ProjectionParams; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = (glstate_matrix_mvp * gl_Vertex); + vec4 o_i0; + vec4 tmpvar_2; + tmpvar_2 = (tmpvar_1 * 0.5); + o_i0 = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3.x = tmpvar_2.x; + tmpvar_3.y = (tmpvar_2.y * _ProjectionParams.x); + o_i0.xy = (tmpvar_3 + tmpvar_2.w); + o_i0.zw = tmpvar_1.zw; + gl_Position = tmpvar_1; + xlv_TEXCOORD0 = o_i0; + xlv_TEXCOORD1 = mix (((glstate_matrix_modelview0 * gl_Vertex).xyz * vec3(-1.0, -1.0, 1.0)), gl_Normal, vec3(float((gl_Normal.z != 0.0)))); +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/complex-prepasslight-outES.txt b/3rdparty/glsl-optimizer/tests/vertex/complex-prepasslight-outES.txt new file mode 100644 index 000000000..52e38cd27 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/complex-prepasslight-outES.txt @@ -0,0 +1,27 @@ +varying highp vec3 xlv_TEXCOORD1; +varying highp vec4 xlv_TEXCOORD0; +uniform highp mat4 glstate_matrix_mvp; +uniform highp mat4 glstate_matrix_modelview0; +uniform highp vec4 _ProjectionParams; +attribute mediump vec3 _glesNormal; +attribute highp vec4 _glesVertex; +void main () +{ + highp vec3 tmpvar_1; + tmpvar_1 = _glesNormal; + highp vec4 tmpvar_2; + tmpvar_2 = (glstate_matrix_mvp * _glesVertex); + highp vec4 o_i0; + highp vec4 tmpvar_3; + tmpvar_3 = (tmpvar_2 * 0.5); + o_i0 = tmpvar_3; + highp vec2 tmpvar_4; + tmpvar_4.x = tmpvar_3.x; + tmpvar_4.y = (tmpvar_3.y * _ProjectionParams.x); + o_i0.xy = (tmpvar_4 + tmpvar_3.w); + o_i0.zw = tmpvar_2.zw; + gl_Position = tmpvar_2; + xlv_TEXCOORD0 = o_i0; + xlv_TEXCOORD1 = mix (((glstate_matrix_modelview0 * _glesVertex).xyz * vec3(-1.0, -1.0, 1.0)), tmpvar_1, vec3(float((tmpvar_1.z != 0.0)))); +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/complex-treeleaf-in.txt b/3rdparty/glsl-optimizer/tests/vertex/complex-treeleaf-in.txt new file mode 100644 index 000000000..25c138a7e --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/complex-treeleaf-in.txt @@ -0,0 +1,148 @@ +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +struct v2f_surf { + vec4 pos; + vec2 hip_pack0; + vec4 lop_color; + vec3 lightDir; + vec3 viewDir; + vec2 _LightCoord; +}; +uniform mat4 _LightMatrix0; +uniform vec4 _MainTex_ST; +uniform mat4 _Object2World; +uniform vec4 _Scale; +uniform float _SquashAmount; +uniform vec4 _SquashPlaneNormal; +uniform vec4 _Time; +uniform vec4 _Wind; +uniform mat4 _World2Object; +uniform vec3 _WorldSpaceCameraPos; +uniform vec4 _WorldSpaceLightPos0; +uniform mat4 glstate_matrix_invtrans_modelview0; +uniform mat4 glstate_matrix_mvp; +uniform vec4 unity_Scale; +vec4 Squash( in vec4 pos ); +void ExpandBillboard( in mat4 mat, inout vec4 pos, inout vec3 normal, inout vec4 tangent ); +vec4 TriangleWave( in vec4 x ); +vec4 SmoothCurve( in vec4 x ); +vec4 SmoothTriangleWave( in vec4 x ); +vec4 AnimateVertex( in vec4 pos, in vec3 normal, in vec4 animParams ); +void TreeVertLeaf( inout appdata_full v ); +vec3 ObjSpaceViewDir( in vec4 v ); +vec3 ObjSpaceLightDir( in vec4 v ); +v2f_surf xlat_main( in appdata_full v ); +vec4 Squash( in vec4 pos ) { + vec3 planeNormal; + vec3 projectedVertex; + planeNormal = _SquashPlaneNormal.xyz ; + projectedVertex = (pos.xyz - ((dot( planeNormal, vec3( pos)) + _SquashPlaneNormal.w ) * planeNormal)); + pos = vec4( mix( projectedVertex, pos.xyz , vec3( _SquashAmount)), 1.00000); + return pos; +} +void ExpandBillboard( in mat4 mat, inout vec4 pos, inout vec3 normal, inout vec4 tangent ) { + float isBillboard; + vec3 norb; + vec3 tanb; + isBillboard = (1.00000 - abs( tangent.w )); + norb = vec3( normalize( ( vec4( normal, 0.000000) * mat ) )); + tanb = vec3( normalize( ( vec4( tangent.xyz , 0.000000) * mat ) )); + pos += (( vec4( normal.xy , 0.000000, 0.000000) * mat ) * isBillboard); + normal = mix( normal, norb, vec3( isBillboard)); + tangent = mix( tangent, vec4( tanb, -1.00000), vec4( isBillboard)); +} +vec4 TriangleWave( in vec4 x ) { + return abs( ((fract( (x + 0.500000) ) * 2.00000) - 1.00000) ); +} +vec4 SmoothCurve( in vec4 x ) { + return ((x * x) * (3.00000 - (2.00000 * x))); +} +vec4 SmoothTriangleWave( in vec4 x ) { + return SmoothCurve( TriangleWave( x)); +} +vec4 AnimateVertex( in vec4 pos, in vec3 normal, in vec4 animParams ) { + float fDetailAmp = 0.100000; + float fBranchAmp = 0.300000; + float fObjPhase; + float fBranchPhase; + float fVtxPhase; + vec2 vWavesIn; + vec4 vWaves; + vec2 vWavesSum; + vec3 bend; + fObjPhase = dot( _Object2World[ 3 ].xyz , vec3( 1.00000)); + fBranchPhase = (fObjPhase + animParams.x ); + fVtxPhase = dot( pos.xyz , vec3( (animParams.y + fBranchPhase))); + vWavesIn = (_Time.yy + vec2( fVtxPhase, fBranchPhase)); + vWaves = ((fract( (vWavesIn.xxyy * vec4( 1.97500, 0.793000, 0.375000, 0.193000)) ) * 2.00000) - 1.00000); + vWaves = SmoothTriangleWave( vWaves); + vWavesSum = (vWaves.xz + vWaves.yw ); + bend = ((animParams.y * fDetailAmp) * normal.xyz ); + bend.y = (animParams.w * fBranchAmp); + pos.xyz += (((vWavesSum.xyx * bend) + ((_Wind.xyz * vWavesSum.y ) * animParams.w )) * _Wind.w ); + pos.xyz += (animParams.z * _Wind.xyz ); + return pos; +} +void TreeVertLeaf( inout appdata_full v ) { + ExpandBillboard( glstate_matrix_invtrans_modelview0, v.vertex, v.normal, v.tangent); + v.vertex.xyz *= _Scale.xyz ; + v.vertex = AnimateVertex( v.vertex, v.normal, vec4( v.color.xy , v.texcoord1.xy )); + v.vertex = Squash( v.vertex); + v.color = vec4( 1.00000, 1.00000, 1.00000, v.color.w ); + v.normal = normalize( v.normal ); + v.tangent.xyz = normalize( v.tangent.xyz ); +} +vec3 ObjSpaceViewDir( in vec4 v ) { + vec3 objSpaceCameraPos; + objSpaceCameraPos = (( _World2Object * vec4( _WorldSpaceCameraPos.xyz , 1.00000) ).xyz * unity_Scale.w ); + return (objSpaceCameraPos - v.xyz ); +} +vec3 ObjSpaceLightDir( in vec4 v ) { + vec3 objSpaceLightPos; + objSpaceLightPos = ( _World2Object * _WorldSpaceLightPos0 ).xyz ; + return objSpaceLightPos.xyz ; +} +v2f_surf xlat_main( in appdata_full v ) { + v2f_surf o; + vec3 binormal; + mat3 rotation; + TreeVertLeaf( v); + o.pos = ( glstate_matrix_mvp * v.vertex ); + o.hip_pack0.xy = ((v.texcoord.xy * _MainTex_ST.xy ) + _MainTex_ST.zw ); + o.lop_color = v.color; + binormal = (cross( v.normal, v.tangent.xyz ) * v.tangent.w ); + rotation = mat3( v.tangent.x , binormal.x , v.normal.x , v.tangent.y , binormal.y , v.normal.y , v.tangent.z , binormal.z , v.normal.z ); + o.lightDir = ( rotation * ObjSpaceLightDir( v.vertex) ); + o.viewDir = ( rotation * ObjSpaceViewDir( v.vertex) ); + o._LightCoord = ( _LightMatrix0 * ( _Object2World * v.vertex ) ).xy ; + return o; +} +attribute vec4 TANGENT; +varying vec2 xlv_TEXCOORD0; +varying vec4 xlv_COLOR0; +varying vec3 xlv_TEXCOORD1; +varying vec3 xlv_TEXCOORD2; +varying vec2 xlv_TEXCOORD3; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = xlat_main( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_TEXCOORD0 = vec2( xl_retval.hip_pack0); + xlv_COLOR0 = vec4( xl_retval.lop_color); + xlv_TEXCOORD1 = vec3( xl_retval.lightDir); + xlv_TEXCOORD2 = vec3( xl_retval.viewDir); + xlv_TEXCOORD3 = vec2( xl_retval._LightCoord); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/complex-treeleaf-inES.txt b/3rdparty/glsl-optimizer/tests/vertex/complex-treeleaf-inES.txt new file mode 100644 index 000000000..7466b4370 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/complex-treeleaf-inES.txt @@ -0,0 +1,148 @@ +struct appdata_full { + highp vec4 vertex; + highp vec4 tangent; + highp vec3 normal; + highp vec4 texcoord; + highp vec4 texcoord1; + highp vec4 color; +}; +struct v2f_surf { + highp vec4 pos; + highp vec2 hip_pack0; + highp vec4 lop_color; + highp vec3 lightDir; + highp vec3 viewDir; + highp vec2 _LightCoord; +}; +uniform highp mat4 _LightMatrix0; +uniform highp vec4 _MainTex_ST; +uniform highp mat4 _Object2World; +uniform highp vec4 _Scale; +uniform highp float _SquashAmount; +uniform highp vec4 _SquashPlaneNormal; +uniform highp vec4 _Time; +uniform highp vec4 _Wind; +uniform highp mat4 _World2Object; +uniform highp vec3 _WorldSpaceCameraPos; +uniform highp vec4 _WorldSpaceLightPos0; +uniform highp mat4 glstate_matrix_invtrans_modelview0; +uniform highp mat4 glstate_matrix_mvp; +uniform highp vec4 unity_Scale; +highp vec4 Squash( in highp vec4 pos ); +void ExpandBillboard( in highp mat4 mat, inout highp vec4 pos, inout highp vec3 normal, inout highp vec4 tangent ); +highp vec4 TriangleWave( in highp vec4 x ); +highp vec4 SmoothCurve( in highp vec4 x ); +highp vec4 SmoothTriangleWave( in highp vec4 x ); +highp vec4 AnimateVertex( in highp vec4 pos, in highp vec3 normal, in highp vec4 animParams ); +void TreeVertLeaf( inout appdata_full v ); +highp vec3 ObjSpaceViewDir( in highp vec4 v ); +highp vec3 ObjSpaceLightDir( in highp vec4 v ); +v2f_surf xlat_main( in appdata_full v ); +highp vec4 Squash( in highp vec4 pos ) { + highp vec3 planeNormal; + highp vec3 projectedVertex; + planeNormal = _SquashPlaneNormal.xyz ; + projectedVertex = (pos.xyz - ((dot( planeNormal, vec3( pos)) + _SquashPlaneNormal.w ) * planeNormal)); + pos = vec4( mix( projectedVertex, pos.xyz , vec3( _SquashAmount)), 1.00000); + return pos; +} +void ExpandBillboard( in highp mat4 mat, inout highp vec4 pos, inout highp vec3 normal, inout highp vec4 tangent ) { + highp float isBillboard; + highp vec3 norb; + highp vec3 tanb; + isBillboard = (1.00000 - abs( tangent.w )); + norb = vec3( normalize( ( vec4( normal, 0.000000) * mat ) )); + tanb = vec3( normalize( ( vec4( tangent.xyz , 0.000000) * mat ) )); + pos += (( vec4( normal.xy , 0.000000, 0.000000) * mat ) * isBillboard); + normal = mix( normal, norb, vec3( isBillboard)); + tangent = mix( tangent, vec4( tanb, -1.00000), vec4( isBillboard)); +} +highp vec4 TriangleWave( in highp vec4 x ) { + return abs( ((fract( (x + 0.500000) ) * 2.00000) - 1.00000) ); +} +highp vec4 SmoothCurve( in highp vec4 x ) { + return ((x * x) * (3.00000 - (2.00000 * x))); +} +highp vec4 SmoothTriangleWave( in highp vec4 x ) { + return SmoothCurve( TriangleWave( x)); +} +highp vec4 AnimateVertex( in highp vec4 pos, in highp vec3 normal, in highp vec4 animParams ) { + highp float fDetailAmp = 0.100000; + highp float fBranchAmp = 0.300000; + highp float fObjPhase; + highp float fBranchPhase; + highp float fVtxPhase; + highp vec2 vWavesIn; + highp vec4 vWaves; + highp vec2 vWavesSum; + highp vec3 bend; + fObjPhase = dot( _Object2World[ 3 ].xyz , vec3( 1.00000)); + fBranchPhase = (fObjPhase + animParams.x ); + fVtxPhase = dot( pos.xyz , vec3( (animParams.y + fBranchPhase))); + vWavesIn = (_Time.yy + vec2( fVtxPhase, fBranchPhase)); + vWaves = ((fract( (vWavesIn.xxyy * highp vec4( 1.97500, 0.793000, 0.375000, 0.193000)) ) * 2.00000) - 1.00000); + vWaves = SmoothTriangleWave( vWaves); + vWavesSum = (vWaves.xz + vWaves.yw ); + bend = ((animParams.y * fDetailAmp) * normal.xyz ); + bend.y = (animParams.w * fBranchAmp); + pos.xyz += (((vWavesSum.xyx * bend) + ((_Wind.xyz * vWavesSum.y ) * animParams.w )) * _Wind.w ); + pos.xyz += (animParams.z * _Wind.xyz ); + return pos; +} +void TreeVertLeaf( inout appdata_full v ) { + ExpandBillboard( glstate_matrix_invtrans_modelview0, v.vertex, v.normal, v.tangent); + v.vertex.xyz *= _Scale.xyz ; + v.vertex = AnimateVertex( v.vertex, v.normal, vec4( v.color.xy , v.texcoord1.xy )); + v.vertex = Squash( v.vertex); + v.color = vec4( 1.00000, 1.00000, 1.00000, v.color.w ); + v.normal = normalize( v.normal ); + v.tangent.xyz = normalize( v.tangent.xyz ); +} +highp vec3 ObjSpaceViewDir( in highp vec4 v ) { + highp vec3 objSpaceCameraPos; + objSpaceCameraPos = (( _World2Object * vec4( _WorldSpaceCameraPos.xyz , 1.00000) ).xyz * unity_Scale.w ); + return (objSpaceCameraPos - v.xyz ); +} +highp vec3 ObjSpaceLightDir( in highp vec4 v ) { + highp vec3 objSpaceLightPos; + objSpaceLightPos = ( _World2Object * _WorldSpaceLightPos0 ).xyz ; + return objSpaceLightPos.xyz ; +} +v2f_surf xlat_main( in appdata_full v ) { + v2f_surf o; + highp vec3 binormal; + highp mat3 rotation; + TreeVertLeaf( v); + o.pos = ( glstate_matrix_mvp * v.vertex ); + o.hip_pack0.xy = ((v.texcoord.xy * _MainTex_ST.xy ) + _MainTex_ST.zw ); + o.lop_color = v.color; + binormal = (cross( v.normal, v.tangent.xyz ) * v.tangent.w ); + rotation = mat3( v.tangent.x , binormal.x , v.normal.x , v.tangent.y , binormal.y , v.normal.y , v.tangent.z , binormal.z , v.normal.z ); + o.lightDir = ( rotation * ObjSpaceLightDir( v.vertex) ); + o.viewDir = ( rotation * ObjSpaceViewDir( v.vertex) ); + o._LightCoord = ( _LightMatrix0 * ( _Object2World * v.vertex ) ).xy ; + return o; +} +attribute vec4 TANGENT; +varying highp vec2 xlv_TEXCOORD0; +varying highp vec4 xlv_COLOR0; +varying highp vec3 xlv_TEXCOORD1; +varying highp vec3 xlv_TEXCOORD2; +varying highp vec2 xlv_TEXCOORD3; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = highp vec4( gl_Vertex); + xlt_v.tangent = highp vec4( TANGENT); + xlt_v.normal = highp vec3( gl_Normal); + xlt_v.texcoord = highp vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = highp vec4( gl_MultiTexCoord1); + xlt_v.color = highp vec4( gl_Color); + xl_retval = xlat_main( xlt_v); + gl_Position = highp vec4( xl_retval.pos); + xlv_TEXCOORD0 = highp vec2( xl_retval.hip_pack0); + xlv_COLOR0 = highp vec4( xl_retval.lop_color); + xlv_TEXCOORD1 = highp vec3( xl_retval.lightDir); + xlv_TEXCOORD2 = highp vec3( xl_retval.viewDir); + xlv_TEXCOORD3 = highp vec2( xl_retval._LightCoord); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/complex-treeleaf-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/complex-treeleaf-ir.txt new file mode 100644 index 000000000..624dfb076 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/complex-treeleaf-ir.txt @@ -0,0 +1,428 @@ +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +struct v2f_surf { + vec4 pos; + vec2 hip_pack0; + vec4 lop_color; + vec3 lightDir; + vec3 viewDir; + vec2 _LightCoord; +}; +varying vec2 xlv_TEXCOORD3; +varying vec3 xlv_TEXCOORD2; +varying vec3 xlv_TEXCOORD1; +varying vec4 xlv_COLOR0; +varying vec2 xlv_TEXCOORD0; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform mat4 glstate_matrix_mvp; +uniform mat4 glstate_matrix_invtrans_modelview0; +uniform vec4 _WorldSpaceLightPos0; +uniform vec3 _WorldSpaceCameraPos; +uniform mat4 _World2Object; +uniform vec4 _Wind; +uniform vec4 _Time; +uniform vec4 _SquashPlaneNormal; +uniform float _SquashAmount; +uniform vec4 _Scale; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform mat4 _LightMatrix0; +vec4 Squash ( + in vec4 pos +) +{ + vec3 projectedVertex; + vec3 planeNormal; + vec3 tmpvar_1; + tmpvar_1 = _SquashPlaneNormal.xyz; + planeNormal = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = pos.xyz; + float tmpvar_3; + tmpvar_3 = dot (planeNormal, tmpvar_2); + vec3 tmpvar_4; + tmpvar_4 = (pos.xyz - ((tmpvar_3 + _SquashPlaneNormal.w) * planeNormal)); + projectedVertex = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = vec3(_SquashAmount); + vec3 tmpvar_6; + tmpvar_6 = mix (projectedVertex, pos.xyz, tmpvar_5); + vec4 tmpvar_7; + tmpvar_7.w = 1.0; + tmpvar_7.xyz = tmpvar_6.xyz; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + pos = tmpvar_8; + return pos; +} + +void ExpandBillboard ( + in mat4 mat, + inout vec4 pos, + inout vec3 normal, + inout vec4 tangent +) +{ + vec3 tanb; + vec3 norb; + float isBillboard; + float tmpvar_1; + tmpvar_1 = abs (tangent.w); + float tmpvar_2; + tmpvar_2 = (1.0 - tmpvar_1); + isBillboard = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3.w = 0.0; + tmpvar_3.xyz = normal.xyz; + vec4 tmpvar_4; + tmpvar_4 = normalize ((tmpvar_3 * mat)); + vec3 tmpvar_5; + tmpvar_5 = tmpvar_4.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + norb = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7.w = 0.0; + tmpvar_7.xyz = tangent.xyz.xyz; + vec4 tmpvar_8; + tmpvar_8 = normalize ((tmpvar_7 * mat)); + vec3 tmpvar_9; + tmpvar_9 = tmpvar_8.xyz; + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + tanb = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11.zw = vec2(0.0, 0.0); + tmpvar_11.xy = normal.xy.xy; + vec4 tmpvar_12; + tmpvar_12 = (pos + ((tmpvar_11 * mat) * isBillboard)); + pos = tmpvar_12; + vec3 tmpvar_13; + tmpvar_13 = vec3(isBillboard); + vec3 tmpvar_14; + tmpvar_14 = mix (normal, norb, tmpvar_13); + vec3 tmpvar_15; + tmpvar_15 = tmpvar_14; + normal = tmpvar_15; + vec4 tmpvar_16; + tmpvar_16.w = -1.0; + tmpvar_16.xyz = tanb.xyz; + vec4 tmpvar_17; + tmpvar_17 = vec4(isBillboard); + vec4 tmpvar_18; + tmpvar_18 = mix (tangent, tmpvar_16, tmpvar_17); + vec4 tmpvar_19; + tmpvar_19 = tmpvar_18; + tangent = tmpvar_19; +} + +vec4 TriangleWave ( + in vec4 x +) +{ + vec4 tmpvar_1; + tmpvar_1 = fract ((x + 0.5)); + vec4 tmpvar_2; + tmpvar_2 = abs (((tmpvar_1 * 2.0) - 1.0)); + return tmpvar_2; +} + +vec4 SmoothCurve ( + in vec4 x +) +{ + return ((x * x) * (3.0 - (2.0 * x))); +} + +vec4 SmoothTriangleWave ( + in vec4 x +) +{ + vec4 tmpvar_1; + tmpvar_1 = TriangleWave (x); + vec4 tmpvar_2; + tmpvar_2 = SmoothCurve (tmpvar_1); + return tmpvar_2; +} + +vec4 AnimateVertex ( + in vec4 pos, + in vec3 normal, + in vec4 animParams +) +{ + vec3 bend; + vec2 vWavesSum; + vec4 vWaves; + vec2 vWavesIn; + float fVtxPhase; + float fBranchPhase; + float fObjPhase; + float fBranchAmp; + float fDetailAmp; + float tmpvar_1; + tmpvar_1 = 0.1; + fDetailAmp = tmpvar_1; + float tmpvar_2; + tmpvar_2 = 0.3; + fBranchAmp = tmpvar_2; + float tmpvar_3; + tmpvar_3 = dot (_Object2World[3].xyz, vec3(1.0, 1.0, 1.0)); + float tmpvar_4; + tmpvar_4 = tmpvar_3; + fObjPhase = tmpvar_4; + float tmpvar_5; + tmpvar_5 = (fObjPhase + animParams.x); + fBranchPhase = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = vec3((animParams.y + fBranchPhase)); + float tmpvar_7; + tmpvar_7 = dot (pos.xyz, tmpvar_6); + float tmpvar_8; + tmpvar_8 = tmpvar_7; + fVtxPhase = tmpvar_8; + vec2 tmpvar_9; + tmpvar_9.x = fVtxPhase; + tmpvar_9.y = fBranchPhase; + vec2 tmpvar_10; + tmpvar_10 = (_Time.yy + tmpvar_9); + vWavesIn = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = fract ((vWavesIn.xxyy * vec4(1.975, 0.793, 0.375, 0.193))); + vec4 tmpvar_12; + tmpvar_12 = ((tmpvar_11 * 2.0) - 1.0); + vWaves = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = SmoothTriangleWave (vWaves); + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + vWaves = tmpvar_14; + vec2 tmpvar_15; + tmpvar_15 = (vWaves.xz + vWaves.yw); + vWavesSum = tmpvar_15; + vec3 tmpvar_16; + tmpvar_16 = ((animParams.y * fDetailAmp) * normal.xyz); + bend = tmpvar_16; + float tmpvar_17; + tmpvar_17 = (animParams.w * fBranchAmp); + bend.y = vec2(tmpvar_17).y; + vec3 tmpvar_18; + tmpvar_18 = (pos.xyz + (((vWavesSum.xyx * bend) + ((_Wind.xyz * vWavesSum.y) * animParams.w)) * _Wind.w)); + pos.xyz = tmpvar_18.xyz.xyz; + vec3 tmpvar_19; + tmpvar_19 = (pos.xyz + (animParams.z * _Wind.xyz)); + pos.xyz = tmpvar_19.xyz.xyz; + return pos; +} + +void TreeVertLeaf ( + inout appdata_full v +) +{ + ExpandBillboard (glstate_matrix_invtrans_modelview0, v.vertex, v.normal, v.tangent); + vec3 tmpvar_1; + tmpvar_1 = (v.vertex.xyz * _Scale.xyz); + v.vertex.xyz = tmpvar_1.xyz.xyz; + vec4 tmpvar_2; + tmpvar_2.xy = v.color.xy.xy; + tmpvar_2.zw = v.texcoord1.xy.xy; + vec4 tmpvar_3; + tmpvar_3 = AnimateVertex (v.vertex, v.normal, tmpvar_2); + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + v.vertex = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = Squash (v.vertex); + vec4 tmpvar_6; + tmpvar_6 = tmpvar_5; + v.vertex = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7.xyz = vec3(1.0, 1.0, 1.0); + tmpvar_7.w = v.color.w; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + v.color = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = normalize (v.normal); + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + v.normal = tmpvar_10; + vec3 tmpvar_11; + tmpvar_11 = normalize (v.tangent.xyz); + vec3 tmpvar_12; + tmpvar_12 = tmpvar_11; + v.tangent.xyz = tmpvar_12.xyz.xyz; +} + +vec3 ObjSpaceViewDir ( + in vec4 v +) +{ + vec3 objSpaceCameraPos; + vec4 tmpvar_1; + tmpvar_1.w = 1.0; + tmpvar_1.xyz = _WorldSpaceCameraPos.xyz.xyz; + vec3 tmpvar_2; + tmpvar_2 = ((_World2Object * tmpvar_1).xyz * unity_Scale.w); + objSpaceCameraPos = tmpvar_2; + return (objSpaceCameraPos - v.xyz); +} + +vec3 ObjSpaceLightDir ( + in vec4 v +) +{ + vec3 objSpaceLightPos; + vec3 tmpvar_1; + tmpvar_1 = (_World2Object * _WorldSpaceLightPos0).xyz; + objSpaceLightPos = tmpvar_1; + return objSpaceLightPos.xyz; +} + +v2f_surf xlat_main ( + in appdata_full v +) +{ + mat3 rotation; + vec3 binormal; + v2f_surf o; + TreeVertLeaf (v); + vec4 tmpvar_1; + tmpvar_1 = (glstate_matrix_mvp * v.vertex); + o.pos = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + o.hip_pack0 = tmpvar_2.xy.xy; + vec4 tmpvar_3; + tmpvar_3 = v.color; + o.lop_color = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = cross (v.normal, v.tangent.xyz); + vec3 tmpvar_5; + tmpvar_5 = (tmpvar_4 * v.tangent.w); + binormal = tmpvar_5; + mat3 tmpvar_6; + float tmpvar_7; + tmpvar_7 = v.tangent.x; + tmpvar_6[0].x = tmpvar_7; + float tmpvar_8; + tmpvar_8 = binormal.x; + tmpvar_6[0].y = tmpvar_8; + float tmpvar_9; + tmpvar_9 = v.normal.x; + tmpvar_6[0].z = tmpvar_9; + float tmpvar_10; + tmpvar_10 = v.tangent.y; + tmpvar_6[1].x = tmpvar_10; + float tmpvar_11; + tmpvar_11 = binormal.y; + tmpvar_6[1].y = tmpvar_11; + float tmpvar_12; + tmpvar_12 = v.normal.y; + tmpvar_6[1].z = tmpvar_12; + float tmpvar_13; + tmpvar_13 = v.tangent.z; + tmpvar_6[2].x = tmpvar_13; + float tmpvar_14; + tmpvar_14 = binormal.z; + tmpvar_6[2].y = tmpvar_14; + float tmpvar_15; + tmpvar_15 = v.normal.z; + tmpvar_6[2].z = tmpvar_15; + mat3 tmpvar_16; + tmpvar_16 = (tmpvar_6); + rotation = (tmpvar_16); + vec3 tmpvar_17; + tmpvar_17 = ObjSpaceLightDir (v.vertex); + vec3 tmpvar_18; + tmpvar_18 = (rotation * tmpvar_17); + o.lightDir = tmpvar_18; + vec3 tmpvar_19; + tmpvar_19 = ObjSpaceViewDir (v.vertex); + vec3 tmpvar_20; + tmpvar_20 = (rotation * tmpvar_19); + o.viewDir = tmpvar_20; + vec2 tmpvar_21; + tmpvar_21 = (_LightMatrix0 * (_Object2World * v.vertex)).xy; + o._LightCoord = tmpvar_21; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = xlat_main (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec2 tmpvar_17; + tmpvar_17 = xl_retval.hip_pack0.xy; + vec2 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_TEXCOORD0 = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19 = xl_retval.lop_color.xyzw; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + xlv_COLOR0 = tmpvar_20; + vec3 tmpvar_21; + tmpvar_21 = xl_retval.lightDir.xyz; + vec3 tmpvar_22; + tmpvar_22 = tmpvar_21; + xlv_TEXCOORD1 = tmpvar_22; + vec3 tmpvar_23; + tmpvar_23 = xl_retval.viewDir.xyz; + vec3 tmpvar_24; + tmpvar_24 = tmpvar_23; + xlv_TEXCOORD2 = tmpvar_24; + vec2 tmpvar_25; + tmpvar_25 = xl_retval._LightCoord.xy; + vec2 tmpvar_26; + tmpvar_26 = tmpvar_25; + xlv_TEXCOORD3 = tmpvar_26; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/complex-treeleaf-irES.txt b/3rdparty/glsl-optimizer/tests/vertex/complex-treeleaf-irES.txt new file mode 100644 index 000000000..56898d5da --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/complex-treeleaf-irES.txt @@ -0,0 +1,433 @@ +struct appdata_full { + highp vec4 vertex; + highp vec4 tangent; + highp vec3 normal; + highp vec4 texcoord; + highp vec4 texcoord1; + highp vec4 color; +}; +struct v2f_surf { + highp vec4 pos; + highp vec2 hip_pack0; + highp vec4 lop_color; + highp vec3 lightDir; + highp vec3 viewDir; + highp vec2 _LightCoord; +}; +varying highp vec2 xlv_TEXCOORD3; +varying highp vec3 xlv_TEXCOORD2; +varying highp vec3 xlv_TEXCOORD1; +varying highp vec4 xlv_COLOR0; +varying highp vec2 xlv_TEXCOORD0; +attribute vec4 TANGENT; +uniform highp vec4 unity_Scale; +uniform highp mat4 glstate_matrix_mvp; +uniform highp mat4 glstate_matrix_invtrans_modelview0; +uniform highp vec4 _WorldSpaceLightPos0; +uniform highp vec3 _WorldSpaceCameraPos; +uniform highp mat4 _World2Object; +uniform highp vec4 _Wind; +uniform highp vec4 _Time; +uniform highp vec4 _SquashPlaneNormal; +uniform highp float _SquashAmount; +uniform highp vec4 _Scale; +uniform highp mat4 _Object2World; +uniform highp vec4 _MainTex_ST; +uniform highp mat4 _LightMatrix0; +attribute lowp vec4 _glesColor; +attribute highp vec4 _glesMultiTexCoord1; +attribute highp vec4 _glesMultiTexCoord0; +attribute mediump vec3 _glesNormal; +attribute highp vec4 _glesVertex; +vec4 Squash ( + in highp vec4 pos +) +{ + highp vec3 projectedVertex; + highp vec3 planeNormal; + highp vec3 tmpvar_1; + tmpvar_1 = _SquashPlaneNormal.xyz; + planeNormal = tmpvar_1; + highp vec3 tmpvar_2; + tmpvar_2 = pos.xyz; + highp float tmpvar_3; + tmpvar_3 = dot (planeNormal, tmpvar_2); + highp vec3 tmpvar_4; + tmpvar_4 = (pos.xyz - ((tmpvar_3 + _SquashPlaneNormal.w) * planeNormal)); + projectedVertex = tmpvar_4; + highp vec3 tmpvar_5; + tmpvar_5 = vec3(_SquashAmount); + highp vec3 tmpvar_6; + tmpvar_6 = mix (projectedVertex, pos.xyz, tmpvar_5); + highp vec4 tmpvar_7; + tmpvar_7.w = 1.0; + tmpvar_7.xyz = tmpvar_6.xyz; + highp vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + pos = tmpvar_8; + return pos; +} + +void ExpandBillboard ( + in highp mat4 mat, + inout highp vec4 pos, + inout highp vec3 normal, + inout highp vec4 tangent +) +{ + highp vec3 tanb; + highp vec3 norb; + highp float isBillboard; + highp float tmpvar_1; + tmpvar_1 = abs (tangent.w); + highp float tmpvar_2; + tmpvar_2 = (1.0 - tmpvar_1); + isBillboard = tmpvar_2; + highp vec4 tmpvar_3; + tmpvar_3.w = 0.0; + tmpvar_3.xyz = normal.xyz; + highp vec4 tmpvar_4; + tmpvar_4 = normalize ((tmpvar_3 * mat)); + highp vec3 tmpvar_5; + tmpvar_5 = tmpvar_4.xyz; + highp vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + norb = tmpvar_6; + highp vec4 tmpvar_7; + tmpvar_7.w = 0.0; + tmpvar_7.xyz = tangent.xyz.xyz; + highp vec4 tmpvar_8; + tmpvar_8 = normalize ((tmpvar_7 * mat)); + highp vec3 tmpvar_9; + tmpvar_9 = tmpvar_8.xyz; + highp vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + tanb = tmpvar_10; + highp vec4 tmpvar_11; + tmpvar_11.zw = vec2(0.0, 0.0); + tmpvar_11.xy = normal.xy.xy; + highp vec4 tmpvar_12; + tmpvar_12 = (pos + ((tmpvar_11 * mat) * isBillboard)); + pos = tmpvar_12; + highp vec3 tmpvar_13; + tmpvar_13 = vec3(isBillboard); + highp vec3 tmpvar_14; + tmpvar_14 = mix (normal, norb, tmpvar_13); + highp vec3 tmpvar_15; + tmpvar_15 = tmpvar_14; + normal = tmpvar_15; + highp vec4 tmpvar_16; + tmpvar_16.w = -1.0; + tmpvar_16.xyz = tanb.xyz; + highp vec4 tmpvar_17; + tmpvar_17 = vec4(isBillboard); + highp vec4 tmpvar_18; + tmpvar_18 = mix (tangent, tmpvar_16, tmpvar_17); + highp vec4 tmpvar_19; + tmpvar_19 = tmpvar_18; + tangent = tmpvar_19; +} + +vec4 TriangleWave ( + in highp vec4 x +) +{ + highp vec4 tmpvar_1; + tmpvar_1 = fract ((x + 0.5)); + highp vec4 tmpvar_2; + tmpvar_2 = abs (((tmpvar_1 * 2.0) - 1.0)); + return tmpvar_2; +} + +vec4 SmoothCurve ( + in highp vec4 x +) +{ + return ((x * x) * (3.0 - (2.0 * x))); +} + +vec4 SmoothTriangleWave ( + in highp vec4 x +) +{ + highp vec4 tmpvar_1; + tmpvar_1 = TriangleWave (x); + highp vec4 tmpvar_2; + tmpvar_2 = SmoothCurve (tmpvar_1); + return tmpvar_2; +} + +vec4 AnimateVertex ( + in highp vec4 pos, + in highp vec3 normal, + in highp vec4 animParams +) +{ + highp vec3 bend; + highp vec2 vWavesSum; + highp vec4 vWaves; + highp vec2 vWavesIn; + highp float fVtxPhase; + highp float fBranchPhase; + highp float fObjPhase; + highp float fBranchAmp; + highp float fDetailAmp; + float tmpvar_1; + tmpvar_1 = 0.1; + fDetailAmp = tmpvar_1; + float tmpvar_2; + tmpvar_2 = 0.3; + fBranchAmp = tmpvar_2; + highp float tmpvar_3; + tmpvar_3 = dot (_Object2World[3].xyz, vec3(1.0, 1.0, 1.0)); + highp float tmpvar_4; + tmpvar_4 = tmpvar_3; + fObjPhase = tmpvar_4; + highp float tmpvar_5; + tmpvar_5 = (fObjPhase + animParams.x); + fBranchPhase = tmpvar_5; + highp vec3 tmpvar_6; + tmpvar_6 = vec3((animParams.y + fBranchPhase)); + highp float tmpvar_7; + tmpvar_7 = dot (pos.xyz, tmpvar_6); + highp float tmpvar_8; + tmpvar_8 = tmpvar_7; + fVtxPhase = tmpvar_8; + highp vec2 tmpvar_9; + tmpvar_9.x = fVtxPhase; + tmpvar_9.y = fBranchPhase; + highp vec2 tmpvar_10; + tmpvar_10 = (_Time.yy + tmpvar_9); + vWavesIn = tmpvar_10; + highp vec4 tmpvar_11; + tmpvar_11 = fract ((vWavesIn.xxyy * vec4(1.975, 0.793, 0.375, 0.193))); + highp vec4 tmpvar_12; + tmpvar_12 = ((tmpvar_11 * 2.0) - 1.0); + vWaves = tmpvar_12; + highp vec4 tmpvar_13; + tmpvar_13 = SmoothTriangleWave (vWaves); + highp vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + vWaves = tmpvar_14; + highp vec2 tmpvar_15; + tmpvar_15 = (vWaves.xz + vWaves.yw); + vWavesSum = tmpvar_15; + highp vec3 tmpvar_16; + tmpvar_16 = ((animParams.y * fDetailAmp) * normal.xyz); + bend = tmpvar_16; + highp float tmpvar_17; + tmpvar_17 = (animParams.w * fBranchAmp); + bend.y = vec2(tmpvar_17).y; + highp vec3 tmpvar_18; + tmpvar_18 = (pos.xyz + (((vWavesSum.xyx * bend) + ((_Wind.xyz * vWavesSum.y) * animParams.w)) * _Wind.w)); + pos.xyz = tmpvar_18.xyz.xyz; + highp vec3 tmpvar_19; + tmpvar_19 = (pos.xyz + (animParams.z * _Wind.xyz)); + pos.xyz = tmpvar_19.xyz.xyz; + return pos; +} + +void TreeVertLeaf ( + inout appdata_full v +) +{ + ExpandBillboard (glstate_matrix_invtrans_modelview0, v.vertex, v.normal, v.tangent); + highp vec3 tmpvar_1; + tmpvar_1 = (v.vertex.xyz * _Scale.xyz); + v.vertex.xyz = tmpvar_1.xyz.xyz; + highp vec4 tmpvar_2; + tmpvar_2.xy = v.color.xy.xy; + tmpvar_2.zw = v.texcoord1.xy.xy; + highp vec4 tmpvar_3; + tmpvar_3 = AnimateVertex (v.vertex, v.normal, tmpvar_2); + highp vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + v.vertex = tmpvar_4; + highp vec4 tmpvar_5; + tmpvar_5 = Squash (v.vertex); + highp vec4 tmpvar_6; + tmpvar_6 = tmpvar_5; + v.vertex = tmpvar_6; + highp vec4 tmpvar_7; + tmpvar_7.xyz = vec3(1.0, 1.0, 1.0); + tmpvar_7.w = v.color.w; + highp vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + v.color = tmpvar_8; + highp vec3 tmpvar_9; + tmpvar_9 = normalize (v.normal); + highp vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + v.normal = tmpvar_10; + highp vec3 tmpvar_11; + tmpvar_11 = normalize (v.tangent.xyz); + highp vec3 tmpvar_12; + tmpvar_12 = tmpvar_11; + v.tangent.xyz = tmpvar_12.xyz.xyz; +} + +vec3 ObjSpaceViewDir ( + in highp vec4 v +) +{ + highp vec3 objSpaceCameraPos; + highp vec4 tmpvar_1; + tmpvar_1.w = 1.0; + tmpvar_1.xyz = _WorldSpaceCameraPos.xyz.xyz; + highp vec3 tmpvar_2; + tmpvar_2 = ((_World2Object * tmpvar_1).xyz * unity_Scale.w); + objSpaceCameraPos = tmpvar_2; + return (objSpaceCameraPos - v.xyz); +} + +vec3 ObjSpaceLightDir ( + in highp vec4 v +) +{ + highp vec3 objSpaceLightPos; + highp vec3 tmpvar_1; + tmpvar_1 = (_World2Object * _WorldSpaceLightPos0).xyz; + objSpaceLightPos = tmpvar_1; + return objSpaceLightPos.xyz; +} + +v2f_surf xlat_main ( + in appdata_full v +) +{ + highp mat3 rotation; + highp vec3 binormal; + v2f_surf o; + TreeVertLeaf (v); + highp vec4 tmpvar_1; + tmpvar_1 = (glstate_matrix_mvp * v.vertex); + o.pos = tmpvar_1; + highp vec2 tmpvar_2; + tmpvar_2 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + o.hip_pack0 = tmpvar_2.xy.xy; + highp vec4 tmpvar_3; + tmpvar_3 = v.color; + o.lop_color = tmpvar_3; + highp vec3 tmpvar_4; + tmpvar_4 = cross (v.normal, v.tangent.xyz); + highp vec3 tmpvar_5; + tmpvar_5 = (tmpvar_4 * v.tangent.w); + binormal = tmpvar_5; + mat3 tmpvar_6; + float tmpvar_7; + tmpvar_7 = v.tangent.x; + tmpvar_6[0].x = tmpvar_7; + float tmpvar_8; + tmpvar_8 = binormal.x; + tmpvar_6[0].y = tmpvar_8; + float tmpvar_9; + tmpvar_9 = v.normal.x; + tmpvar_6[0].z = tmpvar_9; + float tmpvar_10; + tmpvar_10 = v.tangent.y; + tmpvar_6[1].x = tmpvar_10; + float tmpvar_11; + tmpvar_11 = binormal.y; + tmpvar_6[1].y = tmpvar_11; + float tmpvar_12; + tmpvar_12 = v.normal.y; + tmpvar_6[1].z = tmpvar_12; + float tmpvar_13; + tmpvar_13 = v.tangent.z; + tmpvar_6[2].x = tmpvar_13; + float tmpvar_14; + tmpvar_14 = binormal.z; + tmpvar_6[2].y = tmpvar_14; + float tmpvar_15; + tmpvar_15 = v.normal.z; + tmpvar_6[2].z = tmpvar_15; + mat3 tmpvar_16; + tmpvar_16 = (tmpvar_6); + rotation = (tmpvar_16); + highp vec3 tmpvar_17; + tmpvar_17 = ObjSpaceLightDir (v.vertex); + highp vec3 tmpvar_18; + tmpvar_18 = (rotation * tmpvar_17); + o.lightDir = tmpvar_18; + highp vec3 tmpvar_19; + tmpvar_19 = ObjSpaceViewDir (v.vertex); + highp vec3 tmpvar_20; + tmpvar_20 = (rotation * tmpvar_19); + o.viewDir = tmpvar_20; + highp vec2 tmpvar_21; + tmpvar_21 = (_LightMatrix0 * (_Object2World * v.vertex)).xy; + o._LightCoord = tmpvar_21; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + highp vec4 tmpvar_1; + tmpvar_1 = _glesVertex.xyzw; + highp vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + highp vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + highp vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + highp vec3 tmpvar_5; + tmpvar_5 = _glesNormal.xyz; + highp vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + highp vec4 tmpvar_7; + tmpvar_7 = _glesMultiTexCoord0.xyzw; + highp vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + highp vec4 tmpvar_9; + tmpvar_9 = _glesMultiTexCoord1.xyzw; + highp vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + highp vec4 tmpvar_11; + tmpvar_11 = _glesColor.xyzw; + highp vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = xlat_main (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + highp vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + highp vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + highp vec2 tmpvar_17; + tmpvar_17 = xl_retval.hip_pack0.xy; + highp vec2 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_TEXCOORD0 = tmpvar_18; + highp vec4 tmpvar_19; + tmpvar_19 = xl_retval.lop_color.xyzw; + highp vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + xlv_COLOR0 = tmpvar_20; + highp vec3 tmpvar_21; + tmpvar_21 = xl_retval.lightDir.xyz; + highp vec3 tmpvar_22; + tmpvar_22 = tmpvar_21; + xlv_TEXCOORD1 = tmpvar_22; + highp vec3 tmpvar_23; + tmpvar_23 = xl_retval.viewDir.xyz; + highp vec3 tmpvar_24; + tmpvar_24 = tmpvar_23; + xlv_TEXCOORD2 = tmpvar_24; + highp vec2 tmpvar_25; + tmpvar_25 = xl_retval._LightCoord.xy; + highp vec2 tmpvar_26; + tmpvar_26 = tmpvar_25; + xlv_TEXCOORD3 = tmpvar_26; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/complex-treeleaf-out.txt b/3rdparty/glsl-optimizer/tests/vertex/complex-treeleaf-out.txt new file mode 100644 index 000000000..088ebb942 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/complex-treeleaf-out.txt @@ -0,0 +1,100 @@ +varying vec2 xlv_TEXCOORD3; +varying vec3 xlv_TEXCOORD2; +varying vec3 xlv_TEXCOORD1; +varying vec4 xlv_COLOR0; +varying vec2 xlv_TEXCOORD0; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform mat4 glstate_matrix_mvp; +uniform mat4 glstate_matrix_invtrans_modelview0; +uniform vec4 _WorldSpaceLightPos0; +uniform vec3 _WorldSpaceCameraPos; +uniform mat4 _World2Object; +uniform vec4 _Wind; +uniform vec4 _Time; +uniform vec4 _SquashPlaneNormal; +uniform float _SquashAmount; +uniform vec4 _Scale; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform mat4 _LightMatrix0; +void main () +{ + vec4 tmpvar_1; + vec4 tmpvar_2; + float tmpvar_3; + tmpvar_3 = (1.0 - abs (TANGENT.w)); + vec4 tmpvar_4; + tmpvar_4.w = 0.0; + tmpvar_4.xyz = gl_Normal; + vec4 tmpvar_5; + tmpvar_5.w = 0.0; + tmpvar_5.xyz = TANGENT.xyz; + vec4 tmpvar_6; + tmpvar_6.zw = vec2(0.0, 0.0); + tmpvar_6.xy = gl_Normal.xy; + vec4 tmpvar_7; + tmpvar_7 = (gl_Vertex + ((tmpvar_6 * glstate_matrix_invtrans_modelview0) * tmpvar_3)); + vec3 tmpvar_8; + tmpvar_8 = mix (gl_Normal, normalize ((tmpvar_4 * glstate_matrix_invtrans_modelview0)).xyz, vec3(tmpvar_3)); + vec4 tmpvar_9; + tmpvar_9.w = -1.0; + tmpvar_9.xyz = normalize ((tmpvar_5 * glstate_matrix_invtrans_modelview0)).xyz; + vec4 tmpvar_10; + tmpvar_10 = mix (TANGENT, tmpvar_9, vec4(tmpvar_3)); + tmpvar_1 = tmpvar_7; + tmpvar_2 = tmpvar_10; + tmpvar_1.xyz = (tmpvar_7.xyz * _Scale.xyz); + vec4 pos_i0; + pos_i0 = tmpvar_1; + vec3 bend; + float tmpvar_11; + tmpvar_11 = (dot (_Object2World[3].xyz, vec3(1.0, 1.0, 1.0)) + gl_Color.x); + vec2 tmpvar_12; + tmpvar_12.x = dot (tmpvar_1.xyz, vec3((gl_Color.y + tmpvar_11))); + tmpvar_12.y = tmpvar_11; + vec4 tmpvar_13; + tmpvar_13 = abs (((fract ((((fract (((_Time.yy + tmpvar_12).xxyy * vec4(1.975, 0.793, 0.375, 0.193))) * 2.0) - 1.0) + 0.5)) * 2.0) - 1.0)); + vec4 tmpvar_14; + tmpvar_14 = ((tmpvar_13 * tmpvar_13) * (3.0 - (2.0 * tmpvar_13))); + vec2 tmpvar_15; + tmpvar_15 = (tmpvar_14.xz + tmpvar_14.yw); + bend = ((gl_Color.y * 0.1) * tmpvar_8); + bend.y = (gl_MultiTexCoord1.y * 0.3); + pos_i0.xyz = (tmpvar_1.xyz + (((tmpvar_15.xyx * bend) + ((_Wind.xyz * tmpvar_15.y) * gl_MultiTexCoord1.y)) * _Wind.w)); + pos_i0.xyz = (pos_i0.xyz + (gl_MultiTexCoord1.x * _Wind.xyz)); + vec3 tmpvar_16; + tmpvar_16 = mix ((pos_i0.xyz - ((dot (_SquashPlaneNormal.xyz, pos_i0.xyz) + _SquashPlaneNormal.w) * _SquashPlaneNormal.xyz)), pos_i0.xyz, vec3(_SquashAmount)); + vec4 tmpvar_17; + tmpvar_17.w = 1.0; + tmpvar_17.xyz = tmpvar_16; + tmpvar_1 = tmpvar_17; + vec4 tmpvar_18; + tmpvar_18.xyz = vec3(1.0, 1.0, 1.0); + tmpvar_18.w = gl_Color.w; + vec3 tmpvar_19; + tmpvar_19 = normalize (tmpvar_8); + tmpvar_2.xyz = normalize (tmpvar_10.xyz); + vec3 tmpvar_20; + tmpvar_20 = (cross (tmpvar_19, tmpvar_2.xyz) * tmpvar_10.w); + mat3 tmpvar_21; + tmpvar_21[0].x = tmpvar_2.x; + tmpvar_21[0].y = tmpvar_20.x; + tmpvar_21[0].z = tmpvar_19.x; + tmpvar_21[1].x = tmpvar_2.y; + tmpvar_21[1].y = tmpvar_20.y; + tmpvar_21[1].z = tmpvar_19.y; + tmpvar_21[2].x = tmpvar_2.z; + tmpvar_21[2].y = tmpvar_20.z; + tmpvar_21[2].z = tmpvar_19.z; + vec4 tmpvar_22; + tmpvar_22.w = 1.0; + tmpvar_22.xyz = _WorldSpaceCameraPos; + gl_Position = (glstate_matrix_mvp * tmpvar_17); + xlv_TEXCOORD0 = ((gl_MultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + xlv_COLOR0 = tmpvar_18; + xlv_TEXCOORD1 = (tmpvar_21 * (_World2Object * _WorldSpaceLightPos0).xyz); + xlv_TEXCOORD2 = (tmpvar_21 * (((_World2Object * tmpvar_22).xyz * unity_Scale.w) - tmpvar_16)); + xlv_TEXCOORD3 = (_LightMatrix0 * (_Object2World * tmpvar_17)).xy; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/complex-treeleaf-outES.txt b/3rdparty/glsl-optimizer/tests/vertex/complex-treeleaf-outES.txt new file mode 100644 index 000000000..efb2800bd --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/complex-treeleaf-outES.txt @@ -0,0 +1,109 @@ +varying highp vec2 xlv_TEXCOORD3; +varying highp vec3 xlv_TEXCOORD2; +varying highp vec3 xlv_TEXCOORD1; +varying highp vec4 xlv_COLOR0; +varying highp vec2 xlv_TEXCOORD0; +attribute vec4 TANGENT; +uniform highp vec4 unity_Scale; +uniform highp mat4 glstate_matrix_mvp; +uniform highp mat4 glstate_matrix_invtrans_modelview0; +uniform highp vec4 _WorldSpaceLightPos0; +uniform highp vec3 _WorldSpaceCameraPos; +uniform highp mat4 _World2Object; +uniform highp vec4 _Wind; +uniform highp vec4 _Time; +uniform highp vec4 _SquashPlaneNormal; +uniform highp float _SquashAmount; +uniform highp vec4 _Scale; +uniform highp mat4 _Object2World; +uniform highp vec4 _MainTex_ST; +uniform highp mat4 _LightMatrix0; +attribute lowp vec4 _glesColor; +attribute highp vec4 _glesMultiTexCoord1; +attribute highp vec4 _glesMultiTexCoord0; +attribute mediump vec3 _glesNormal; +attribute highp vec4 _glesVertex; +void main () +{ + highp vec3 tmpvar_1; + tmpvar_1 = _glesNormal; + highp vec4 tmpvar_2; + tmpvar_2 = _glesColor; + highp vec4 tmpvar_3; + highp vec4 tmpvar_4; + highp float tmpvar_5; + tmpvar_5 = (1.0 - abs (TANGENT.w)); + highp vec4 tmpvar_6; + tmpvar_6.w = 0.0; + tmpvar_6.xyz = tmpvar_1; + highp vec4 tmpvar_7; + tmpvar_7.w = 0.0; + tmpvar_7.xyz = TANGENT.xyz; + highp vec4 tmpvar_8; + tmpvar_8.zw = vec2(0.0, 0.0); + tmpvar_8.xy = tmpvar_1.xy; + highp vec4 tmpvar_9; + tmpvar_9 = (_glesVertex + ((tmpvar_8 * glstate_matrix_invtrans_modelview0) * tmpvar_5)); + highp vec3 tmpvar_10; + tmpvar_10 = mix (tmpvar_1, normalize ((tmpvar_6 * glstate_matrix_invtrans_modelview0)).xyz, vec3(tmpvar_5)); + highp vec4 tmpvar_11; + tmpvar_11.w = -1.0; + tmpvar_11.xyz = normalize ((tmpvar_7 * glstate_matrix_invtrans_modelview0)).xyz; + highp vec4 tmpvar_12; + tmpvar_12 = mix (TANGENT, tmpvar_11, vec4(tmpvar_5)); + tmpvar_3 = tmpvar_9; + tmpvar_4 = tmpvar_12; + tmpvar_3.xyz = (tmpvar_9.xyz * _Scale.xyz); + highp vec4 pos_i0; + pos_i0 = tmpvar_3; + highp vec3 bend; + highp float tmpvar_13; + tmpvar_13 = (dot (_Object2World[3].xyz, vec3(1.0, 1.0, 1.0)) + tmpvar_2.x); + highp vec2 tmpvar_14; + tmpvar_14.x = dot (tmpvar_3.xyz, vec3((tmpvar_2.y + tmpvar_13))); + tmpvar_14.y = tmpvar_13; + highp vec4 tmpvar_15; + tmpvar_15 = abs (((fract ((((fract (((_Time.yy + tmpvar_14).xxyy * vec4(1.975, 0.793, 0.375, 0.193))) * 2.0) - 1.0) + 0.5)) * 2.0) - 1.0)); + highp vec4 tmpvar_16; + tmpvar_16 = ((tmpvar_15 * tmpvar_15) * (3.0 - (2.0 * tmpvar_15))); + highp vec2 tmpvar_17; + tmpvar_17 = (tmpvar_16.xz + tmpvar_16.yw); + bend = ((tmpvar_2.y * 0.1) * tmpvar_10); + bend.y = (_glesMultiTexCoord1.y * 0.3); + pos_i0.xyz = (tmpvar_3.xyz + (((tmpvar_17.xyx * bend) + ((_Wind.xyz * tmpvar_17.y) * _glesMultiTexCoord1.y)) * _Wind.w)); + pos_i0.xyz = (pos_i0.xyz + (_glesMultiTexCoord1.x * _Wind.xyz)); + highp vec3 tmpvar_18; + tmpvar_18 = mix ((pos_i0.xyz - ((dot (_SquashPlaneNormal.xyz, pos_i0.xyz) + _SquashPlaneNormal.w) * _SquashPlaneNormal.xyz)), pos_i0.xyz, vec3(_SquashAmount)); + highp vec4 tmpvar_19; + tmpvar_19.w = 1.0; + tmpvar_19.xyz = tmpvar_18; + tmpvar_3 = tmpvar_19; + highp vec4 tmpvar_20; + tmpvar_20.xyz = vec3(1.0, 1.0, 1.0); + tmpvar_20.w = tmpvar_2.w; + highp vec3 tmpvar_21; + tmpvar_21 = normalize (tmpvar_10); + tmpvar_4.xyz = normalize (tmpvar_12.xyz); + highp vec3 tmpvar_22; + tmpvar_22 = (cross (tmpvar_21, tmpvar_4.xyz) * tmpvar_12.w); + highp mat3 tmpvar_23; + tmpvar_23[0].x = tmpvar_4.x; + tmpvar_23[0].y = tmpvar_22.x; + tmpvar_23[0].z = tmpvar_21.x; + tmpvar_23[1].x = tmpvar_4.y; + tmpvar_23[1].y = tmpvar_22.y; + tmpvar_23[1].z = tmpvar_21.y; + tmpvar_23[2].x = tmpvar_4.z; + tmpvar_23[2].y = tmpvar_22.z; + tmpvar_23[2].z = tmpvar_21.z; + highp vec4 tmpvar_24; + tmpvar_24.w = 1.0; + tmpvar_24.xyz = _WorldSpaceCameraPos; + gl_Position = (glstate_matrix_mvp * tmpvar_19); + xlv_TEXCOORD0 = ((_glesMultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + xlv_COLOR0 = tmpvar_20; + xlv_TEXCOORD1 = (tmpvar_23 * (_World2Object * _WorldSpaceLightPos0).xyz); + xlv_TEXCOORD2 = (tmpvar_23 * (((_World2Object * tmpvar_24).xyz * unity_Scale.w) - tmpvar_18)); + xlv_TEXCOORD3 = (_LightMatrix0 * (_Object2World * tmpvar_19)).xy; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/estest1-in.txt b/3rdparty/glsl-optimizer/tests/vertex/estest1-in.txt new file mode 100644 index 000000000..c668baed1 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/estest1-in.txt @@ -0,0 +1,19 @@ +struct v2f { + vec4 pos; + vec2 uv0; + vec2 uv1; +}; + +attribute vec4 position; + +uniform mat4 modelViewProjectionMatrix; + +varying vec4 xlv_TEXCOORD0; +varying vec4 xlv_TEXCOORD1; + +void main() +{ + gl_Position = modelViewProjectionMatrix * position; + xlv_TEXCOORD0 = vec4(position.xy * vec2(4.0), 0.0, 0.0); + xlv_TEXCOORD1 = vec4(position.xy, 0.0, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/estest1-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/estest1-ir.txt new file mode 100644 index 000000000..6c3f232f7 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/estest1-ir.txt @@ -0,0 +1,23 @@ +varying vec4 xlv_TEXCOORD1; +varying vec4 xlv_TEXCOORD0; +uniform mat4 modelViewProjectionMatrix; +attribute vec4 position; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = (modelViewProjectionMatrix * position); + gl_Position = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2.zw = vec2(0.0, 0.0); + tmpvar_2.xy = (position.xy * vec2(4.0, 4.0)).xy; + vec4 tmpvar_3; + tmpvar_3 = tmpvar_2; + xlv_TEXCOORD0 = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4.zw = vec2(0.0, 0.0); + tmpvar_4.xy = position.xy.xy; + vec4 tmpvar_5; + tmpvar_5 = tmpvar_4; + xlv_TEXCOORD1 = tmpvar_5; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/estest1-out.txt b/3rdparty/glsl-optimizer/tests/vertex/estest1-out.txt new file mode 100644 index 000000000..77e06763b --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/estest1-out.txt @@ -0,0 +1,17 @@ +varying vec4 xlv_TEXCOORD1; +varying vec4 xlv_TEXCOORD0; +uniform mat4 modelViewProjectionMatrix; +attribute vec4 position; +void main () +{ + gl_Position = (modelViewProjectionMatrix * position); + vec4 tmpvar_1; + tmpvar_1.zw = vec2(0.0, 0.0); + tmpvar_1.xy = (position.xy * vec2(4.0, 4.0)); + xlv_TEXCOORD0 = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2.zw = vec2(0.0, 0.0); + tmpvar_2.xy = position.xy; + xlv_TEXCOORD1 = tmpvar_2; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/loops-for-in.txt b/3rdparty/glsl-optimizer/tests/vertex/loops-for-in.txt new file mode 100644 index 000000000..bdfcfff40 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/loops-for-in.txt @@ -0,0 +1,55 @@ +mat3 xll_constructMat3( mat4 m) { + return mat3( vec3( m[0]), vec3( m[1]), vec3( m[2])); +} +struct v2f { + vec4 pos; + vec4 color; +}; +struct appdata { + vec4 vertex; + vec3 normal; +}; +uniform mat4 UNITY_MATRIX_IT_MV; +uniform mat4 UNITY_MATRIX_MV; +uniform mat4 UNITY_MATRIX_MVP; +uniform vec4 unity_LightAtten[4]; +uniform vec4 unity_LightColor[4]; +uniform vec4 unity_LightPosition[4]; +vec3 ShadeMyVertexLights( in vec4 vertex, in vec3 normal ); +v2f xlat_main( in appdata v ); +vec3 ShadeMyVertexLights( in vec4 vertex, in vec3 normal ) { + vec3 viewpos; + vec3 viewN; + vec3 lightColor = vec3( 0.00000, 0.00000, 0.00000); + int i = 0; + vec3 toLight; + float lengthSq; + float atten; + float diff; + viewpos = ( UNITY_MATRIX_MV * vertex ).xyz ; + viewN = ( xll_constructMat3( UNITY_MATRIX_IT_MV) * normal ); + for ( ; (i < 2); ( i++ )) { + toLight = (unity_LightPosition[ i ].xyz - viewpos.xyz ); + lengthSq = dot( toLight, toLight); + atten = (1.00000 / (1.00000 + (lengthSq * unity_LightAtten[ i ].z ))); + diff = max( 0.00000, dot( viewN, normalize( toLight ))); + lightColor += (unity_LightColor[ i ].xyz * (diff * atten)); + } + return (lightColor * 2.00000); +} +v2f xlat_main( in appdata v ) { + v2f o; + o.pos = ( UNITY_MATRIX_MVP * v.vertex ); + o.color = vec4( ShadeMyVertexLights( v.vertex, v.normal), 1.00000); + return o; +} +varying vec4 xlv_TEXCOORD0; +void main() { + v2f xl_retval; + appdata xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.normal = vec3( gl_Normal); + xl_retval = xlat_main( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_TEXCOORD0 = vec4( xl_retval.color); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/loops-for-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/loops-for-ir.txt new file mode 100644 index 000000000..c4f5c5fb1 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/loops-for-ir.txt @@ -0,0 +1,151 @@ +struct v2f { + vec4 pos; + vec4 color; +}; +struct appdata { + vec4 vertex; + vec3 normal; +}; +varying vec4 xlv_TEXCOORD0; +uniform vec4 unity_LightPosition[4]; +uniform vec4 unity_LightColor[4]; +uniform vec4 unity_LightAtten[4]; +uniform mat4 UNITY_MATRIX_MVP; +uniform mat4 UNITY_MATRIX_MV; +uniform mat4 UNITY_MATRIX_IT_MV; +mat3 xll_constructMat3 ( + in mat4 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = m[0].xyz; + vec3 tmpvar_2; + tmpvar_2 = m[1].xyz; + vec3 tmpvar_3; + tmpvar_3 = m[2].xyz; + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +vec3 ShadeMyVertexLights ( + in vec4 vertex, + in vec3 normal +) +{ + float diff; + float atten; + float lengthSq; + vec3 toLight; + int i; + vec3 lightColor; + vec3 viewN; + vec3 viewpos; + vec3 tmpvar_1; + tmpvar_1 = vec3(0.0, 0.0, 0.0); + lightColor = tmpvar_1; + int tmpvar_2; + tmpvar_2 = 0; + i = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = (UNITY_MATRIX_MV * vertex).xyz; + viewpos = tmpvar_3; + mat3 tmpvar_4; + tmpvar_4 = (xll_constructMat3 (UNITY_MATRIX_IT_MV)); + vec3 tmpvar_5; + tmpvar_5 = (tmpvar_4 * normal); + viewN = tmpvar_5; + while (true) { + if (!((i < 2))) { + break; + }; + vec3 tmpvar_6; + tmpvar_6 = (unity_LightPosition[i].xyz - viewpos.xyz); + toLight = tmpvar_6; + float tmpvar_7; + tmpvar_7 = dot (toLight, toLight); + float tmpvar_8; + tmpvar_8 = tmpvar_7; + lengthSq = tmpvar_8; + float tmpvar_9; + tmpvar_9 = (1.0 / (1.0 + (lengthSq * unity_LightAtten[i].z))); + atten = tmpvar_9; + vec3 tmpvar_10; + tmpvar_10 = normalize (toLight); + float tmpvar_11; + tmpvar_11 = dot (viewN, tmpvar_10); + float tmpvar_12; + tmpvar_12 = max (0.0, tmpvar_11); + float tmpvar_13; + tmpvar_13 = tmpvar_12; + diff = tmpvar_13; + vec3 tmpvar_14; + tmpvar_14 = (lightColor + (unity_LightColor[i].xyz * (diff * atten))); + lightColor = tmpvar_14; + int _post_incdec_tmp; + _post_incdec_tmp = i; + int tmpvar_15; + tmpvar_15 = (i + 1); + i = tmpvar_15; + }; + return (lightColor * 2.0); +} + +v2f xlat_main ( + in appdata v +) +{ + v2f o; + vec4 tmpvar_1; + tmpvar_1 = (UNITY_MATRIX_MVP * v.vertex); + o.pos = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = ShadeMyVertexLights (v.vertex, v.normal); + vec4 tmpvar_3; + tmpvar_3.w = 1.0; + tmpvar_3.xyz = tmpvar_2.xyz; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + o.color = tmpvar_4; + return o; +} + +void main () +{ + appdata xlt_v; + v2f xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = gl_Normal.xyz; + vec3 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.normal = tmpvar_4; + v2f tmpvar_5; + tmpvar_5 = xlat_main (xlt_v); + v2f tmpvar_6; + tmpvar_6 = tmpvar_5; + xl_retval = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = xl_retval.pos.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + gl_Position = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = xl_retval.color.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlv_TEXCOORD0 = tmpvar_10; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/loops-for-out.txt b/3rdparty/glsl-optimizer/tests/vertex/loops-for-out.txt new file mode 100644 index 000000000..ab2bda1d5 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/loops-for-out.txt @@ -0,0 +1,31 @@ +varying vec4 xlv_TEXCOORD0; +uniform vec4 unity_LightPosition[4]; +uniform vec4 unity_LightColor[4]; +uniform vec4 unity_LightAtten[4]; +uniform mat4 UNITY_MATRIX_MVP; +uniform mat4 UNITY_MATRIX_MV; +uniform mat4 UNITY_MATRIX_IT_MV; +void main () +{ + vec3 lightColor; + vec3 viewN; + vec3 viewpos; + viewpos = (UNITY_MATRIX_MV * gl_Vertex).xyz; + mat3 tmpvar_1; + tmpvar_1[0] = UNITY_MATRIX_IT_MV[0].xyz; + tmpvar_1[1] = UNITY_MATRIX_IT_MV[1].xyz; + tmpvar_1[2] = UNITY_MATRIX_IT_MV[2].xyz; + viewN = (tmpvar_1 * gl_Normal); + vec3 tmpvar_2; + tmpvar_2 = (unity_LightPosition[0].xyz - viewpos); + lightColor = (unity_LightColor[0].xyz * (max (0.0, dot (viewN, normalize (tmpvar_2))) * (1.0/((1.0 + (dot (tmpvar_2, tmpvar_2) * unity_LightAtten[0].z)))))); + vec3 tmpvar_3; + tmpvar_3 = (unity_LightPosition[1].xyz - viewpos); + lightColor = (lightColor + (unity_LightColor[1].xyz * (max (0.0, dot (viewN, normalize (tmpvar_3))) * (1.0/((1.0 + (dot (tmpvar_3, tmpvar_3) * unity_LightAtten[1].z))))))); + vec4 tmpvar_4; + tmpvar_4.w = 1.0; + tmpvar_4.xyz = (lightColor * 2.0); + gl_Position = (UNITY_MATRIX_MVP * gl_Vertex); + xlv_TEXCOORD0 = tmpvar_4; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/loops-forsimple-in.txt b/3rdparty/glsl-optimizer/tests/vertex/loops-forsimple-in.txt new file mode 100644 index 000000000..91a3ae3aa --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/loops-forsimple-in.txt @@ -0,0 +1,9 @@ +uniform vec4 uniColors[4]; +varying vec4 varColor; +void main() { + gl_Position = gl_Vertex; + vec4 col = vec4(0.0); + for (int i = 0; i < 4; ++i) + col += uniColors[i]; + varColor = col; +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/loops-forsimple-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/loops-forsimple-ir.txt new file mode 100644 index 000000000..6fef85024 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/loops-forsimple-ir.txt @@ -0,0 +1,31 @@ +varying vec4 varColor; +uniform vec4 uniColors[4]; +void main () +{ + int i; + vec4 col; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex; + gl_Position = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = vec4(0.0, 0.0, 0.0, 0.0); + col = tmpvar_2; + int tmpvar_3; + tmpvar_3 = 0; + i = tmpvar_3; + while (true) { + if (!((i < 4))) { + break; + }; + vec4 tmpvar_4; + tmpvar_4 = (col + uniColors[i]); + col = tmpvar_4; + int tmpvar_5; + tmpvar_5 = (i + 1); + i = tmpvar_5; + }; + vec4 tmpvar_6; + tmpvar_6 = col; + varColor = tmpvar_6; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/loops-forsimple-out.txt b/3rdparty/glsl-optimizer/tests/vertex/loops-forsimple-out.txt new file mode 100644 index 000000000..3058fbb9f --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/loops-forsimple-out.txt @@ -0,0 +1,13 @@ +varying vec4 varColor; +uniform vec4 uniColors[4]; +void main () +{ + vec4 col; + gl_Position = gl_Vertex; + col = uniColors[0]; + col = (col + uniColors[1]); + col = (col + uniColors[2]); + col = (col + uniColors[3]); + varColor = col; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/loops-forwithcalls-in.txt b/3rdparty/glsl-optimizer/tests/vertex/loops-forwithcalls-in.txt new file mode 100644 index 000000000..8647c9e7f --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/loops-forwithcalls-in.txt @@ -0,0 +1,9 @@ +uniform vec4 uniColors[4]; +varying vec4 varColor; +void main() { + gl_Position = gl_Vertex; + vec4 col = vec4(0.0); + for (int i = 0; i < 4; ++i) + col += max (vec4(0.0), uniColors[i]); + varColor = col; +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/loops-forwithcalls-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/loops-forwithcalls-ir.txt new file mode 100644 index 000000000..113552d2f --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/loops-forwithcalls-ir.txt @@ -0,0 +1,33 @@ +varying vec4 varColor; +uniform vec4 uniColors[4]; +void main () +{ + int i; + vec4 col; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex; + gl_Position = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = vec4(0.0, 0.0, 0.0, 0.0); + col = tmpvar_2; + int tmpvar_3; + tmpvar_3 = 0; + i = tmpvar_3; + while (true) { + if (!((i < 4))) { + break; + }; + vec4 tmpvar_4; + tmpvar_4 = max (vec4(0.0, 0.0, 0.0, 0.0), uniColors[i]); + vec4 tmpvar_5; + tmpvar_5 = (col + tmpvar_4); + col = tmpvar_5; + int tmpvar_6; + tmpvar_6 = (i + 1); + i = tmpvar_6; + }; + vec4 tmpvar_7; + tmpvar_7 = col; + varColor = tmpvar_7; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/loops-forwithcalls-out.txt b/3rdparty/glsl-optimizer/tests/vertex/loops-forwithcalls-out.txt new file mode 100644 index 000000000..f98c7df20 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/loops-forwithcalls-out.txt @@ -0,0 +1,13 @@ +varying vec4 varColor; +uniform vec4 uniColors[4]; +void main () +{ + vec4 col; + gl_Position = gl_Vertex; + col = max (vec4(0.0, 0.0, 0.0, 0.0), uniColors[0]); + col = (col + max (vec4(0.0, 0.0, 0.0, 0.0), uniColors[1])); + col = (col + max (vec4(0.0, 0.0, 0.0, 0.0), uniColors[2])); + col = (col + max (vec4(0.0, 0.0, 0.0, 0.0), uniColors[3])); + varColor = col; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/opt-inline-varnames-in.txt b/3rdparty/glsl-optimizer/tests/vertex/opt-inline-varnames-in.txt new file mode 100644 index 000000000..fe33b86bf --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/opt-inline-varnames-in.txt @@ -0,0 +1,16 @@ +float foo (float a, float b, float c) { + return a+b+c; +} +float bar (float a, float b) { + float c = a*b; + return foo (a, b, c); +} +float har (float a) { + float b = sqrt(a); + float c = sqrt(b); + return bar (a, b) + c; +} +void main () +{ + gl_Position = vec4(har(gl_Vertex.x)); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/opt-inline-varnames-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/opt-inline-varnames-ir.txt new file mode 100644 index 000000000..96120b37c --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/opt-inline-varnames-ir.txt @@ -0,0 +1,55 @@ +float foo ( + in float a, + in float b, + in float c +) +{ + return ((a + b) + c); +} + +float bar ( + in float a, + in float b +) +{ + float c; + float tmpvar_1; + tmpvar_1 = (a * b); + c = tmpvar_1; + float tmpvar_2; + tmpvar_2 = foo (a, b, c); + return tmpvar_2; +} + +float har ( + in float a +) +{ + float c; + float b; + float tmpvar_1; + tmpvar_1 = sqrt (a); + float tmpvar_2; + tmpvar_2 = tmpvar_1; + b = tmpvar_2; + float tmpvar_3; + tmpvar_3 = sqrt (b); + float tmpvar_4; + tmpvar_4 = tmpvar_3; + c = tmpvar_4; + float tmpvar_5; + tmpvar_5 = bar (a, b); + return (tmpvar_5 + c); +} + +void main () +{ + float tmpvar_1; + tmpvar_1 = har (gl_Vertex.x); + vec4 tmpvar_2; + tmpvar_2 = vec4(tmpvar_1); + vec4 tmpvar_3; + tmpvar_3 = tmpvar_2; + gl_Position = tmpvar_3; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/opt-inline-varnames-out.txt b/3rdparty/glsl-optimizer/tests/vertex/opt-inline-varnames-out.txt new file mode 100644 index 000000000..4a6ac77e5 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/opt-inline-varnames-out.txt @@ -0,0 +1,7 @@ +void main () +{ + float tmpvar_1; + tmpvar_1 = sqrt (gl_Vertex.x); + gl_Position = vec4((((gl_Vertex.x + tmpvar_1) + (gl_Vertex.x * tmpvar_1)) + sqrt (tmpvar_1))); +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/opt-matrix-constr-in.txt b/3rdparty/glsl-optimizer/tests/vertex/opt-matrix-constr-in.txt new file mode 100644 index 000000000..daa11c346 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/opt-matrix-constr-in.txt @@ -0,0 +1,6 @@ +void main() { + gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; + mat3 m = mat3 (0.1, 0.8, 0.1, 0.3, 0.3, 0.5, 0.9, 0.0, 0.1); + vec3 n = m * gl_Normal; + gl_FrontColor = vec4(n*0.5+0.5, 1.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/opt-matrix-constr-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/opt-matrix-constr-ir.txt new file mode 100644 index 000000000..3e1bdc24a --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/opt-matrix-constr-ir.txt @@ -0,0 +1,21 @@ +void main () +{ + vec3 n; + mat3 m; + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * gl_Vertex); + gl_Position = tmpvar_1; + mat3 tmpvar_2; + tmpvar_2 = (mat3(0.1, 0.8, 0.1, 0.3, 0.3, 0.5, 0.9, 0.0, 0.1)); + m = (tmpvar_2); + vec3 tmpvar_3; + tmpvar_3 = (m * gl_Normal); + n = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4.w = 1.0; + tmpvar_4.xyz = ((n * 0.5) + 0.5).xyz; + vec4 tmpvar_5; + tmpvar_5 = tmpvar_4; + gl_FrontColor = tmpvar_5; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/opt-matrix-constr-out.txt b/3rdparty/glsl-optimizer/tests/vertex/opt-matrix-constr-out.txt new file mode 100644 index 000000000..392ae7f34 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/opt-matrix-constr-out.txt @@ -0,0 +1,9 @@ +void main () +{ + gl_Position = (gl_ModelViewProjectionMatrix * gl_Vertex); + vec4 tmpvar_1; + tmpvar_1.w = 1.0; + tmpvar_1.xyz = (((mat3(0.1, 0.8, 0.1, 0.3, 0.3, 0.5, 0.9, 0.0, 0.1) * gl_Normal) * 0.5) + 0.5); + gl_FrontColor = tmpvar_1; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/opt-matrix-transpose-mul-inES.txt b/3rdparty/glsl-optimizer/tests/vertex/opt-matrix-transpose-mul-inES.txt new file mode 100644 index 000000000..c71dd057b --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/opt-matrix-transpose-mul-inES.txt @@ -0,0 +1,81 @@ +uniform mat4 glstate_matrix_mvp; + +attribute vec4 attrVertex; +attribute vec3 attrNormal; +attribute vec4 attrTangent; + +mat3 xll_transpose(mat3 m) { + return mat3( m[0][0], m[1][0], m[2][0], + m[0][1], m[1][1], m[2][1], + m[0][2], m[1][2], m[2][2]); +} + +mat3 xll_constructMat3(mat4 m) { + return mat3(vec3(m[0]), vec3(m[1]), vec3(m[2])); +} + +struct v2f_surf { + highp vec4 pos; + lowp vec3 lightDir; + lowp vec3 viewDir; + lowp vec3 worldN; +}; + +struct appdata { + highp vec4 vertex; + highp vec4 tangent; + highp vec3 normal; +}; + +uniform highp mat4 _Object2World; +uniform highp mat4 _World2Object; +uniform highp vec3 _WorldSpaceCameraPos; +uniform lowp vec4 _WorldSpaceLightPos0; + +uniform highp vec4 unity_Scale; + +highp vec3 ObjSpaceViewDir( in highp vec4 v ) { + highp vec3 objSpaceCameraPos = (_World2Object * vec4(_WorldSpaceCameraPos.xyz, 1.0)).xyz * unity_Scale.w; + return objSpaceCameraPos - v.xyz; +} + +highp vec3 ObjSpaceLightDir( in highp vec4 v ) { + highp vec3 objSpaceLightPos = (_World2Object * _WorldSpaceLightPos0).xyz; + return objSpaceLightPos.xyz; +} + +v2f_surf vert_surf (in appdata v) { + v2f_surf o; + o.pos = glstate_matrix_mvp * v.vertex; + + highp vec3 worldN = xll_constructMat3(_Object2World) * v.normal; + o.worldN = worldN; + + highp vec3 binormal = cross(v.normal, v.tangent.xyz) * v.tangent.w; + highp mat3 rotation = xll_transpose (mat3(v.tangent.xyz, binormal, v.normal)); + + highp vec3 lightDir = rotation * ObjSpaceLightDir(v.vertex); + o.lightDir = lightDir; + + highp vec3 viewDirForLight = rotation * ObjSpaceViewDir(v.vertex); + o.viewDir = normalize( (lightDir + normalize( viewDirForLight )) ); + return o; +} + +varying lowp vec3 varWorldN; +varying lowp vec3 varLightDir; +varying lowp vec3 varViewDir; + +void main() { + appdata v; + v.vertex = attrVertex; + v.tangent = attrTangent; + v.normal = attrNormal; + + v2f_surf rv = vert_surf(v); + + gl_Position = rv.pos; + varWorldN = rv.worldN; + varLightDir = rv.lightDir; + varViewDir = rv.viewDir; +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/opt-matrix-transpose-mul-irES.txt b/3rdparty/glsl-optimizer/tests/vertex/opt-matrix-transpose-mul-irES.txt new file mode 100644 index 000000000..d8b61717d --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/opt-matrix-transpose-mul-irES.txt @@ -0,0 +1,207 @@ +struct v2f_surf { + highp vec4 pos; + lowp vec3 lightDir; + lowp vec3 viewDir; + lowp vec3 worldN; +}; +struct appdata { + highp vec4 vertex; + highp vec4 tangent; + highp vec3 normal; +}; +varying lowp vec3 varViewDir; +varying lowp vec3 varLightDir; +varying lowp vec3 varWorldN; +uniform highp vec4 unity_Scale; +uniform lowp vec4 _WorldSpaceLightPos0; +uniform highp vec3 _WorldSpaceCameraPos; +uniform highp mat4 _World2Object; +uniform highp mat4 _Object2World; +attribute vec4 attrTangent; +attribute vec3 attrNormal; +attribute vec4 attrVertex; +uniform mat4 glstate_matrix_mvp; +attribute lowp vec4 _glesColor; +attribute highp vec4 _glesMultiTexCoord1; +attribute highp vec4 _glesMultiTexCoord0; +attribute mediump vec3 _glesNormal; +attribute highp vec4 _glesVertex; +mat3 xll_transpose ( + in mat3 m +) +{ + mat3 tmpvar_1; + float tmpvar_2; + tmpvar_2 = m[0][0]; + tmpvar_1[0].x = tmpvar_2; + float tmpvar_3; + tmpvar_3 = m[1][0]; + tmpvar_1[0].y = tmpvar_3; + float tmpvar_4; + tmpvar_4 = m[2][0]; + tmpvar_1[0].z = tmpvar_4; + float tmpvar_5; + tmpvar_5 = m[0][1]; + tmpvar_1[1].x = tmpvar_5; + float tmpvar_6; + tmpvar_6 = m[1][1]; + tmpvar_1[1].y = tmpvar_6; + float tmpvar_7; + tmpvar_7 = m[2][1]; + tmpvar_1[1].z = tmpvar_7; + float tmpvar_8; + tmpvar_8 = m[0][2]; + tmpvar_1[2].x = tmpvar_8; + float tmpvar_9; + tmpvar_9 = m[1][2]; + tmpvar_1[2].y = tmpvar_9; + float tmpvar_10; + tmpvar_10 = m[2][2]; + tmpvar_1[2].z = tmpvar_10; + return tmpvar_1; +} + +mat3 xll_constructMat3 ( + in mat4 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = m[0].xyz; + vec3 tmpvar_2; + tmpvar_2 = m[1].xyz; + vec3 tmpvar_3; + tmpvar_3 = m[2].xyz; + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +vec3 ObjSpaceViewDir ( + in highp vec4 v +) +{ + highp vec3 objSpaceCameraPos; + highp vec4 tmpvar_1; + tmpvar_1.w = 1.0; + tmpvar_1.xyz = _WorldSpaceCameraPos.xyz.xyz; + highp vec3 tmpvar_2; + tmpvar_2 = ((_World2Object * tmpvar_1).xyz * unity_Scale.w); + objSpaceCameraPos = tmpvar_2; + return (objSpaceCameraPos - v.xyz); +} + +vec3 ObjSpaceLightDir ( + in highp vec4 v +) +{ + highp vec3 objSpaceLightPos; + highp vec3 tmpvar_1; + tmpvar_1 = (_World2Object * _WorldSpaceLightPos0).xyz; + objSpaceLightPos = tmpvar_1; + return objSpaceLightPos.xyz; +} + +v2f_surf vert_surf ( + in appdata v +) +{ + highp vec3 viewDirForLight; + highp vec3 lightDir; + highp mat3 rotation; + highp vec3 binormal; + highp vec3 worldN; + v2f_surf o; + highp vec4 tmpvar_1; + tmpvar_1 = (glstate_matrix_mvp * v.vertex); + o.pos = tmpvar_1; + mat3 tmpvar_2; + tmpvar_2 = (xll_constructMat3 (_Object2World)); + highp vec3 tmpvar_3; + tmpvar_3 = (tmpvar_2 * v.normal); + worldN = tmpvar_3; + highp vec3 tmpvar_4; + tmpvar_4 = worldN; + o.worldN = tmpvar_4; + highp vec3 tmpvar_5; + tmpvar_5 = cross (v.normal, v.tangent.xyz); + highp vec3 tmpvar_6; + tmpvar_6 = (tmpvar_5 * v.tangent.w); + binormal = tmpvar_6; + mat3 tmpvar_7; + vec3 tmpvar_8; + tmpvar_8 = v.tangent.xyz; + tmpvar_7[0] = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = binormal; + tmpvar_7[1] = tmpvar_9; + vec3 tmpvar_10; + tmpvar_10 = v.normal; + tmpvar_7[2] = tmpvar_10; + mat3 tmpvar_11; + tmpvar_11 = (xll_transpose (tmpvar_7)); + mat3 tmpvar_12; + tmpvar_12 = (tmpvar_11); + rotation = (tmpvar_12); + highp vec3 tmpvar_13; + tmpvar_13 = ObjSpaceLightDir (v.vertex); + highp vec3 tmpvar_14; + tmpvar_14 = (rotation * tmpvar_13); + lightDir = tmpvar_14; + highp vec3 tmpvar_15; + tmpvar_15 = lightDir; + o.lightDir = tmpvar_15; + highp vec3 tmpvar_16; + tmpvar_16 = ObjSpaceViewDir (v.vertex); + highp vec3 tmpvar_17; + tmpvar_17 = (rotation * tmpvar_16); + viewDirForLight = tmpvar_17; + highp vec3 tmpvar_18; + tmpvar_18 = normalize (viewDirForLight); + highp vec3 tmpvar_19; + tmpvar_19 = normalize ((lightDir + tmpvar_18)); + highp vec3 tmpvar_20; + tmpvar_20 = tmpvar_19; + o.viewDir = tmpvar_20; + return o; +} + +void main () +{ + v2f_surf rv; + appdata v; + vec4 tmpvar_1; + tmpvar_1 = attrVertex; + v.vertex = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = attrTangent; + v.tangent = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = attrNormal; + v.normal = tmpvar_3; + v2f_surf tmpvar_4; + tmpvar_4 = vert_surf (v); + v2f_surf tmpvar_5; + tmpvar_5 = tmpvar_4; + rv = tmpvar_5; + highp vec4 tmpvar_6; + tmpvar_6 = rv.pos; + gl_Position = tmpvar_6; + lowp vec3 tmpvar_7; + tmpvar_7 = rv.worldN; + varWorldN = tmpvar_7; + lowp vec3 tmpvar_8; + tmpvar_8 = rv.lightDir; + varLightDir = tmpvar_8; + lowp vec3 tmpvar_9; + tmpvar_9 = rv.viewDir; + varViewDir = tmpvar_9; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/opt-matrix-transpose-mul-outES.txt b/3rdparty/glsl-optimizer/tests/vertex/opt-matrix-transpose-mul-outES.txt new file mode 100644 index 000000000..feffd9b8b --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/opt-matrix-transpose-mul-outES.txt @@ -0,0 +1,53 @@ +varying lowp vec3 varViewDir; +varying lowp vec3 varLightDir; +varying lowp vec3 varWorldN; +uniform highp vec4 unity_Scale; +uniform lowp vec4 _WorldSpaceLightPos0; +uniform highp vec3 _WorldSpaceCameraPos; +uniform highp mat4 _World2Object; +uniform highp mat4 _Object2World; +attribute vec4 attrTangent; +attribute vec3 attrNormal; +attribute vec4 attrVertex; +uniform mat4 glstate_matrix_mvp; +void main () +{ + lowp vec3 tmpvar_1; + lowp vec3 tmpvar_2; + lowp vec3 tmpvar_3; + mat3 tmpvar_4; + tmpvar_4[0] = _Object2World[0].xyz; + tmpvar_4[1] = _Object2World[1].xyz; + tmpvar_4[2] = _Object2World[2].xyz; + highp vec3 tmpvar_5; + tmpvar_5 = (tmpvar_4 * attrNormal); + tmpvar_3 = tmpvar_5; + highp mat3 tmpvar_6; + tmpvar_6[0] = attrTangent.xyz; + tmpvar_6[1] = (cross (attrNormal, attrTangent.xyz) * attrTangent.w); + tmpvar_6[2] = attrNormal; + mat3 tmpvar_7; + tmpvar_7[0].x = tmpvar_6[0].x; + tmpvar_7[0].y = tmpvar_6[1].x; + tmpvar_7[0].z = tmpvar_6[2].x; + tmpvar_7[1].x = tmpvar_6[0].y; + tmpvar_7[1].y = tmpvar_6[1].y; + tmpvar_7[1].z = tmpvar_6[2].y; + tmpvar_7[2].x = tmpvar_6[0].z; + tmpvar_7[2].y = tmpvar_6[1].z; + tmpvar_7[2].z = tmpvar_6[2].z; + highp vec3 tmpvar_8; + tmpvar_8 = (tmpvar_7 * (_World2Object * _WorldSpaceLightPos0).xyz); + tmpvar_1 = tmpvar_8; + highp vec4 tmpvar_9; + tmpvar_9.w = 1.0; + tmpvar_9.xyz = _WorldSpaceCameraPos; + highp vec3 tmpvar_10; + tmpvar_10 = normalize ((tmpvar_8 + normalize ((tmpvar_7 * (((_World2Object * tmpvar_9).xyz * unity_Scale.w) - attrVertex.xyz))))); + tmpvar_2 = tmpvar_10; + gl_Position = (glstate_matrix_mvp * attrVertex); + varWorldN = tmpvar_3; + varLightDir = tmpvar_1; + varViewDir = tmpvar_2; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/opt-negsub-in.txt b/3rdparty/glsl-optimizer/tests/vertex/opt-negsub-in.txt new file mode 100644 index 000000000..aa2bf9e10 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/opt-negsub-in.txt @@ -0,0 +1,17 @@ +uniform mat4 mvp; +uniform mat3 m3a, m3b, m3c; +uniform vec4 v3a, v3b, v3c; + +void main() { + gl_Position = mvp * gl_Vertex; + + vec3 ta = -(v3a.xyz - gl_Vertex.xyz); + vec3 ra = m3a * ta; + + vec3 tb = -((mvp * v3b).xyz - gl_Vertex.xyz); + vec3 rb = m3b * tb; + + vec3 rc = m3c * (-(v3c.xyz - gl_Vertex.xyz)); + + gl_FrontColor = vec4(ra+rb+rc,1.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/opt-negsub-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/opt-negsub-ir.txt new file mode 100644 index 000000000..a6e068ede --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/opt-negsub-ir.txt @@ -0,0 +1,40 @@ +uniform vec4 v3c; +uniform vec4 v3b; +uniform vec4 v3a; +uniform mat3 m3c; +uniform mat3 m3b; +uniform mat3 m3a; +uniform mat4 mvp; +void main () +{ + vec3 rc; + vec3 rb; + vec3 tb; + vec3 ra; + vec3 ta; + vec4 tmpvar_1; + tmpvar_1 = (mvp * gl_Vertex); + gl_Position = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = -((v3a.xyz - gl_Vertex.xyz)); + ta = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = (m3a * ta); + ra = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = -(((mvp * v3b).xyz - gl_Vertex.xyz)); + tb = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = (m3b * tb); + rb = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = (m3c * -((v3c.xyz - gl_Vertex.xyz))); + rc = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7.w = 1.0; + tmpvar_7.xyz = ((ra + rb) + rc).xyz; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + gl_FrontColor = tmpvar_8; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/opt-negsub-out.txt b/3rdparty/glsl-optimizer/tests/vertex/opt-negsub-out.txt new file mode 100644 index 000000000..6a5fce0b1 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/opt-negsub-out.txt @@ -0,0 +1,16 @@ +uniform vec4 v3c; +uniform vec4 v3b; +uniform vec4 v3a; +uniform mat3 m3c; +uniform mat3 m3b; +uniform mat3 m3a; +uniform mat4 mvp; +void main () +{ + gl_Position = (mvp * gl_Vertex); + vec4 tmpvar_1; + tmpvar_1.w = 1.0; + tmpvar_1.xyz = (((m3a * (gl_Vertex.xyz - v3a.xyz)) + (m3b * (gl_Vertex.xyz - (mvp * v3b).xyz))) + (m3c * (gl_Vertex.xyz - v3c.xyz))); + gl_FrontColor = tmpvar_1; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/opt-unusedvars-in.txt b/3rdparty/glsl-optimizer/tests/vertex/opt-unusedvars-in.txt new file mode 100644 index 000000000..431913263 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/opt-unusedvars-in.txt @@ -0,0 +1,10 @@ +uniform mat4 mvp; +uniform mat4 unusedMatrix; +uniform float unusedFloat; +attribute vec4 myColor; +attribute vec3 myUnused; + +void main() { + gl_Position = mvp * gl_Vertex; + gl_FrontColor = myColor; +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/opt-unusedvars-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/opt-unusedvars-ir.txt new file mode 100644 index 000000000..53eac9e60 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/opt-unusedvars-ir.txt @@ -0,0 +1,15 @@ +attribute vec3 myUnused; +attribute vec4 myColor; +uniform float unusedFloat; +uniform mat4 unusedMatrix; +uniform mat4 mvp; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = (mvp * gl_Vertex); + gl_Position = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = myColor; + gl_FrontColor = tmpvar_2; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/opt-unusedvars-out.txt b/3rdparty/glsl-optimizer/tests/vertex/opt-unusedvars-out.txt new file mode 100644 index 000000000..20381eaa6 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/opt-unusedvars-out.txt @@ -0,0 +1,8 @@ +attribute vec4 myColor; +uniform mat4 mvp; +void main () +{ + gl_Position = (mvp * gl_Vertex); + gl_FrontColor = myColor; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/swizzlemask-in.txt b/3rdparty/glsl-optimizer/tests/vertex/swizzlemask-in.txt new file mode 100644 index 000000000..85325acfd --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/swizzlemask-in.txt @@ -0,0 +1,9 @@ +varying vec4 texcoord; +void main() +{ + gl_Position.zw = gl_Vertex.xy*2.0; + gl_Position.xy = gl_Vertex.xy; + texcoord.x = gl_Vertex.z; + texcoord.yz = gl_Vertex.zw; + texcoord.w = gl_Vertex.x; +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/swizzlemask-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/swizzlemask-ir.txt new file mode 100644 index 000000000..356c602ad --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/swizzlemask-ir.txt @@ -0,0 +1,20 @@ +varying vec4 texcoord; +void main () +{ + vec2 tmpvar_1; + tmpvar_1 = (gl_Vertex.xy * 2.0); + gl_Position.zw = tmpvar_1.xxxy.zw; + vec2 tmpvar_2; + tmpvar_2 = gl_Vertex.xy; + gl_Position.xy = tmpvar_2.xy.xy; + float tmpvar_3; + tmpvar_3 = gl_Vertex.z; + texcoord.x = tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = gl_Vertex.zw; + texcoord.yz = tmpvar_4.xxy.yz; + float tmpvar_5; + tmpvar_5 = gl_Vertex.x; + texcoord.w = vec4(tmpvar_5).w; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/swizzlemask-out.txt b/3rdparty/glsl-optimizer/tests/vertex/swizzlemask-out.txt new file mode 100644 index 000000000..718ecd892 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/swizzlemask-out.txt @@ -0,0 +1,10 @@ +varying vec4 texcoord; +void main () +{ + gl_Position.zw = (gl_Vertex.xy * 2.0); + gl_Position.xy = gl_Vertex.xy; + texcoord.x = gl_Vertex.z; + texcoord.yz = gl_Vertex.zw; + texcoord.w = gl_Vertex.x; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/types-in.txt b/3rdparty/glsl-optimizer/tests/vertex/types-in.txt new file mode 100644 index 000000000..c589b2feb --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/types-in.txt @@ -0,0 +1,41 @@ +struct v2f { + vec4 pos; + vec2 uv; + vec4 color; +}; +struct a2v { + vec4 pos; + vec2 uv; + vec3 normal; + vec4 color; +}; +uniform mat4 mvp; +v2f xlat_main( in a2v v ); +v2f xlat_main( in a2v v ) { + v2f o; + float dx; + float dy; + float dz; + o.pos = ( mvp * v.pos ); + o.color = v.color; + o.color.xyz += v.normal; + o.uv = v.uv; + dx = v.pos.x ; + dy = v.pos.y ; + dz = v.pos.z ; + return o; +} +varying vec2 xlv_TEXCOORD0; +varying vec4 xlv_COLOR; +void main() { + v2f xl_retval; + a2v xlt_v; + xlt_v.pos = vec4( gl_Vertex); + xlt_v.uv = vec2( gl_MultiTexCoord0); + xlt_v.normal = vec3( gl_Normal); + xlt_v.color = vec4( gl_Color); + xl_retval = xlat_main( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_TEXCOORD0 = vec2( xl_retval.uv); + xlv_COLOR = vec4( xl_retval.color); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/types-inES.txt b/3rdparty/glsl-optimizer/tests/vertex/types-inES.txt new file mode 100644 index 000000000..c6927fdd5 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/types-inES.txt @@ -0,0 +1,41 @@ +struct v2f { + highp vec4 pos; + mediump vec2 uv; + lowp vec4 color; +}; +struct a2v { + highp vec4 pos; + highp vec2 uv; + mediump vec3 normal; + lowp vec4 color; +}; +uniform highp mat4 mvp; +v2f xlat_main( in a2v v ); +v2f xlat_main( in a2v v ) { + v2f o; + highp float dx; + mediump float dy; + lowp float dz; + o.pos = ( mvp * v.pos ); + o.color = v.color; + o.color.xyz += v.normal; + o.uv = v.uv; + dx = v.pos.x ; + dy = v.pos.y ; + dz = v.pos.z ; + return o; +} +varying mediump vec2 xlv_TEXCOORD0; +varying lowp vec4 xlv_COLOR; +void main() { + v2f xl_retval; + a2v xlt_v; + xlt_v.pos = highp vec4( gl_Vertex); + xlt_v.uv = highp vec2( gl_MultiTexCoord0); + xlt_v.normal = mediump vec3( gl_Normal); + xlt_v.color = lowp vec4( gl_Color); + xl_retval = xlat_main( xlt_v); + gl_Position = highp vec4( xl_retval.pos); + xlv_TEXCOORD0 = mediump vec2( xl_retval.uv); + xlv_COLOR = lowp vec4( xl_retval.color); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/types-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/types-ir.txt new file mode 100644 index 000000000..e97b6a912 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/types-ir.txt @@ -0,0 +1,92 @@ +struct v2f { + vec4 pos; + vec2 uv; + vec4 color; +}; +struct a2v { + vec4 pos; + vec2 uv; + vec3 normal; + vec4 color; +}; +varying vec4 xlv_COLOR; +varying vec2 xlv_TEXCOORD0; +uniform mat4 mvp; +v2f xlat_main ( + in a2v v +) +{ + float dz; + float dy; + float dx; + v2f o; + vec4 tmpvar_1; + tmpvar_1 = (mvp * v.pos); + o.pos = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = v.color; + o.color = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = (o.color.xyz + v.normal); + o.color.xyz = tmpvar_3.xyz.xyz; + vec2 tmpvar_4; + tmpvar_4 = v.uv; + o.uv = tmpvar_4; + float tmpvar_5; + tmpvar_5 = v.pos.x; + dx = tmpvar_5; + float tmpvar_6; + tmpvar_6 = v.pos.y; + dy = tmpvar_6; + float tmpvar_7; + tmpvar_7 = v.pos.z; + dz = tmpvar_7; + return o; +} + +void main () +{ + a2v xlt_v; + v2f xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.pos = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = gl_MultiTexCoord0.xy; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.uv = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_Color.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.color = tmpvar_8; + v2f tmpvar_9; + tmpvar_9 = xlat_main (xlt_v); + v2f tmpvar_10; + tmpvar_10 = tmpvar_9; + xl_retval = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = xl_retval.pos.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + gl_Position = tmpvar_12; + vec2 tmpvar_13; + tmpvar_13 = xl_retval.uv.xy; + vec2 tmpvar_14; + tmpvar_14 = tmpvar_13; + xlv_TEXCOORD0 = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.color.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + xlv_COLOR = tmpvar_16; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/types-irES.txt b/3rdparty/glsl-optimizer/tests/vertex/types-irES.txt new file mode 100644 index 000000000..c967dde2b --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/types-irES.txt @@ -0,0 +1,97 @@ +struct v2f { + highp vec4 pos; + mediump vec2 uv; + lowp vec4 color; +}; +struct a2v { + highp vec4 pos; + highp vec2 uv; + mediump vec3 normal; + lowp vec4 color; +}; +varying lowp vec4 xlv_COLOR; +varying mediump vec2 xlv_TEXCOORD0; +uniform highp mat4 mvp; +attribute lowp vec4 _glesColor; +attribute highp vec4 _glesMultiTexCoord1; +attribute highp vec4 _glesMultiTexCoord0; +attribute mediump vec3 _glesNormal; +attribute highp vec4 _glesVertex; +v2f xlat_main ( + in a2v v +) +{ + lowp float dz; + mediump float dy; + highp float dx; + v2f o; + highp vec4 tmpvar_1; + tmpvar_1 = (mvp * v.pos); + o.pos = tmpvar_1; + lowp vec4 tmpvar_2; + tmpvar_2 = v.color; + o.color = tmpvar_2; + mediump vec3 tmpvar_3; + tmpvar_3 = (o.color.xyz + v.normal); + o.color.xyz = tmpvar_3.xyz.xyz; + highp vec2 tmpvar_4; + tmpvar_4 = v.uv; + o.uv = tmpvar_4; + highp float tmpvar_5; + tmpvar_5 = v.pos.x; + dx = tmpvar_5; + highp float tmpvar_6; + tmpvar_6 = v.pos.y; + dy = tmpvar_6; + highp float tmpvar_7; + tmpvar_7 = v.pos.z; + dz = tmpvar_7; + return o; +} + +void main () +{ + a2v xlt_v; + v2f xl_retval; + highp vec4 tmpvar_1; + tmpvar_1 = _glesVertex.xyzw; + highp vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.pos = tmpvar_2; + highp vec2 tmpvar_3; + tmpvar_3 = _glesMultiTexCoord0.xy; + highp vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.uv = tmpvar_4; + mediump vec3 tmpvar_5; + tmpvar_5 = _glesNormal.xyz; + mediump vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + lowp vec4 tmpvar_7; + tmpvar_7 = _glesColor.xyzw; + lowp vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.color = tmpvar_8; + v2f tmpvar_9; + tmpvar_9 = xlat_main (xlt_v); + v2f tmpvar_10; + tmpvar_10 = tmpvar_9; + xl_retval = tmpvar_10; + highp vec4 tmpvar_11; + tmpvar_11 = xl_retval.pos.xyzw; + highp vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + gl_Position = tmpvar_12; + mediump vec2 tmpvar_13; + tmpvar_13 = xl_retval.uv.xy; + mediump vec2 tmpvar_14; + tmpvar_14 = tmpvar_13; + xlv_TEXCOORD0 = tmpvar_14; + lowp vec4 tmpvar_15; + tmpvar_15 = xl_retval.color.xyzw; + lowp vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + xlv_COLOR = tmpvar_16; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/types-out.txt b/3rdparty/glsl-optimizer/tests/vertex/types-out.txt new file mode 100644 index 000000000..9bf1fc64c --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/types-out.txt @@ -0,0 +1,13 @@ +varying vec4 xlv_COLOR; +varying vec2 xlv_TEXCOORD0; +uniform mat4 mvp; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = gl_Color; + tmpvar_1.xyz = (gl_Color.xyz + gl_Normal); + gl_Position = (mvp * gl_Vertex); + xlv_TEXCOORD0 = gl_MultiTexCoord0.xy; + xlv_COLOR = tmpvar_1; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/types-outES.txt b/3rdparty/glsl-optimizer/tests/vertex/types-outES.txt new file mode 100644 index 000000000..431ab1794 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/types-outES.txt @@ -0,0 +1,23 @@ +varying lowp vec4 xlv_COLOR; +varying mediump vec2 xlv_TEXCOORD0; +uniform highp mat4 mvp; +attribute lowp vec4 _glesColor; +attribute highp vec4 _glesMultiTexCoord0; +attribute mediump vec3 _glesNormal; +attribute highp vec4 _glesVertex; +void main () +{ + highp vec2 tmpvar_1; + tmpvar_1 = _glesMultiTexCoord0.xy; + mediump vec2 tmpvar_2; + lowp vec4 tmpvar_3; + tmpvar_3 = _glesColor; + mediump vec3 tmpvar_4; + tmpvar_4 = (_glesColor.xyz + _glesNormal); + tmpvar_3.xyz = tmpvar_4; + tmpvar_2 = tmpvar_1; + gl_Position = (mvp * _glesVertex); + xlv_TEXCOORD0 = tmpvar_2; + xlv_COLOR = tmpvar_3; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Bumped_Diffuse-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Bumped_Diffuse-in.txt new file mode 100644 index 000000000..845bc9d16 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Bumped_Diffuse-in.txt @@ -0,0 +1,77 @@ +mat3 xll_constructMat3( mat4 m) { + return mat3( vec3( m[0]), vec3( m[1]), vec3( m[2])); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; +}; +struct v2f_surf { + vec4 pos; + vec2 hip_pack0; + vec3 TtoV0; + vec3 TtoV1; + vec3 TtoV2; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _BumpMap_ST; + + +v2f_surf vert_surf( in appdata_full v ); +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + vec3 binormal; + mat3 rotation; + o.pos = ( gl_ModelViewProjectionMatrix * v.vertex ); + o.hip_pack0.xy = ((v.texcoord.xy * _BumpMap_ST.xy ) + _BumpMap_ST.zw ); + binormal = (cross( v.normal, v.tangent.xyz ) * v.tangent.w ); + rotation = mat3( v.tangent.x , binormal.x , v.normal.x , v.tangent.y , binormal.y , v.normal.y , v.tangent.z , binormal.z , v.normal.z ); + o.TtoV0 = ( rotation * xll_constructMat3( gl_ModelViewMatrixInverseTranspose)[ 0 ].xyz ); + o.TtoV1 = ( rotation * xll_constructMat3( gl_ModelViewMatrixInverseTranspose)[ 1 ].xyz ); + o.TtoV2 = ( rotation * xll_constructMat3( gl_ModelViewMatrixInverseTranspose)[ 2 ].xyz ); + return o; +} +attribute vec4 TANGENT; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + gl_TexCoord[0] = vec4( xl_retval.hip_pack0, 0.0, 0.0); + gl_TexCoord[1] = vec4( xl_retval.TtoV0, 0.0); + gl_TexCoord[2] = vec4( xl_retval.TtoV1, 0.0); + gl_TexCoord[3] = vec4( xl_retval.TtoV2, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Bumped_Diffuse-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Bumped_Diffuse-ir.txt new file mode 100644 index 000000000..ff62ea859 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Bumped_Diffuse-ir.txt @@ -0,0 +1,177 @@ +struct v2f_surf { + vec4 pos; + vec2 hip_pack0; + vec3 TtoV0; + vec3 TtoV1; + vec3 TtoV2; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +attribute vec4 TANGENT; +uniform vec4 _BumpMap_ST; +mat3 xll_constructMat3 ( + in mat4 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = m[0].xyz; + vec3 tmpvar_2; + tmpvar_2 = m[1].xyz; + vec3 tmpvar_3; + tmpvar_3 = m[2].xyz; + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + mat3 rotation; + vec3 binormal; + v2f_surf o; + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v.vertex); + o.pos = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = ((v.texcoord.xy * _BumpMap_ST.xy) + _BumpMap_ST.zw); + o.hip_pack0 = tmpvar_2.xy.xy; + vec3 tmpvar_3; + tmpvar_3 = cross (v.normal, v.tangent.xyz); + vec3 tmpvar_4; + tmpvar_4 = (tmpvar_3 * v.tangent.w); + binormal = tmpvar_4; + mat3 tmpvar_5; + float tmpvar_6; + tmpvar_6 = v.tangent.x; + tmpvar_5[0].x = tmpvar_6; + float tmpvar_7; + tmpvar_7 = binormal.x; + tmpvar_5[0].y = tmpvar_7; + float tmpvar_8; + tmpvar_8 = v.normal.x; + tmpvar_5[0].z = tmpvar_8; + float tmpvar_9; + tmpvar_9 = v.tangent.y; + tmpvar_5[1].x = tmpvar_9; + float tmpvar_10; + tmpvar_10 = binormal.y; + tmpvar_5[1].y = tmpvar_10; + float tmpvar_11; + tmpvar_11 = v.normal.y; + tmpvar_5[1].z = tmpvar_11; + float tmpvar_12; + tmpvar_12 = v.tangent.z; + tmpvar_5[2].x = tmpvar_12; + float tmpvar_13; + tmpvar_13 = binormal.z; + tmpvar_5[2].y = tmpvar_13; + float tmpvar_14; + tmpvar_14 = v.normal.z; + tmpvar_5[2].z = tmpvar_14; + mat3 tmpvar_15; + tmpvar_15 = (tmpvar_5); + rotation = (tmpvar_15); + mat3 tmpvar_16; + tmpvar_16 = (xll_constructMat3 (gl_ModelViewMatrixInverseTranspose)); + vec3 tmpvar_17; + tmpvar_17 = (rotation * tmpvar_16[0].xyz); + o.TtoV0 = tmpvar_17; + mat3 tmpvar_18; + tmpvar_18 = (xll_constructMat3 (gl_ModelViewMatrixInverseTranspose)); + vec3 tmpvar_19; + tmpvar_19 = (rotation * tmpvar_18[1].xyz); + o.TtoV1 = tmpvar_19; + mat3 tmpvar_20; + tmpvar_20 = (xll_constructMat3 (gl_ModelViewMatrixInverseTranspose)); + vec3 tmpvar_21; + tmpvar_21 = (rotation * tmpvar_20[2].xyz); + o.TtoV2 = tmpvar_21; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.zw = vec2(0.0, 0.0); + tmpvar_17.xy = xl_retval.hip_pack0.xy; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + gl_TexCoord[0] = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19.w = 0.0; + tmpvar_19.xyz = xl_retval.TtoV0.xyz; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[1] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21.w = 0.0; + tmpvar_21.xyz = xl_retval.TtoV1.xyz; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_TexCoord[2] = tmpvar_22; + vec4 tmpvar_23; + tmpvar_23.w = 0.0; + tmpvar_23.xyz = xl_retval.TtoV2.xyz; + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + gl_TexCoord[3] = tmpvar_24; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Bumped_Diffuse-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Bumped_Diffuse-out.txt new file mode 100644 index 000000000..244b1b9f5 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Bumped_Diffuse-out.txt @@ -0,0 +1,47 @@ +attribute vec4 TANGENT; +uniform vec4 _BumpMap_ST; +void main () +{ + vec3 tmpvar_1; + tmpvar_1 = (cross (gl_Normal, TANGENT.xyz) * TANGENT.w); + mat3 tmpvar_2; + tmpvar_2[0].x = TANGENT.x; + tmpvar_2[0].y = tmpvar_1.x; + tmpvar_2[0].z = gl_Normal.x; + tmpvar_2[1].x = TANGENT.y; + tmpvar_2[1].y = tmpvar_1.y; + tmpvar_2[1].z = gl_Normal.y; + tmpvar_2[2].x = TANGENT.z; + tmpvar_2[2].y = tmpvar_1.z; + tmpvar_2[2].z = gl_Normal.z; + mat3 tmpvar_3; + tmpvar_3[0] = gl_ModelViewMatrixInverseTranspose[0].xyz; + tmpvar_3[1] = gl_ModelViewMatrixInverseTranspose[1].xyz; + tmpvar_3[2] = gl_ModelViewMatrixInverseTranspose[2].xyz; + mat3 tmpvar_4; + tmpvar_4[0] = gl_ModelViewMatrixInverseTranspose[0].xyz; + tmpvar_4[1] = gl_ModelViewMatrixInverseTranspose[1].xyz; + tmpvar_4[2] = gl_ModelViewMatrixInverseTranspose[2].xyz; + mat3 tmpvar_5; + tmpvar_5[0] = gl_ModelViewMatrixInverseTranspose[0].xyz; + tmpvar_5[1] = gl_ModelViewMatrixInverseTranspose[1].xyz; + tmpvar_5[2] = gl_ModelViewMatrixInverseTranspose[2].xyz; + gl_Position = (gl_ModelViewProjectionMatrix * gl_Vertex); + vec4 tmpvar_6; + tmpvar_6.zw = vec2(0.0, 0.0); + tmpvar_6.xy = ((gl_MultiTexCoord0.xy * _BumpMap_ST.xy) + _BumpMap_ST.zw); + gl_TexCoord[0] = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7.w = 0.0; + tmpvar_7.xyz = (tmpvar_2 * tmpvar_3[0]); + gl_TexCoord[1] = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8.w = 0.0; + tmpvar_8.xyz = (tmpvar_2 * tmpvar_4[1]); + gl_TexCoord[2] = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9.w = 0.0; + tmpvar_9.xyz = (tmpvar_2 * tmpvar_5[2]); + gl_TexCoord[3] = tmpvar_9; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Bumped_Diffuse1-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Bumped_Diffuse1-in.txt new file mode 100644 index 000000000..d4dfb2f5a --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Bumped_Diffuse1-in.txt @@ -0,0 +1,80 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 hip_screen; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _MainTex_ST; +uniform vec4 _ProjectionParams; + +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +vec4 ComputeScreenPos( in vec4 pos ); +v2f_surf vert_surf( in appdata_full v ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +vec4 ComputeScreenPos( in vec4 pos ) { + vec4 o; + o = (pos * 0.500000); + o.xy = (vec2( o.x , (o.y * _ProjectionParams.x )) + o.w ); + o.zw = pos.zw ; + return o; +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + PositionFog( v.vertex, o.pos, o.fog); + o.hip_pack0.xy = ((v.texcoord.xy * _MainTex_ST.xy ) + _MainTex_ST.zw ); + o.hip_screen = ComputeScreenPos( o.pos); + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.hip_pack0, 0.0, 0.0); + gl_TexCoord[1] = vec4( xl_retval.hip_screen); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Bumped_Diffuse1-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Bumped_Diffuse1-ir.txt new file mode 100644 index 000000000..6b7ae345b --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Bumped_Diffuse1-ir.txt @@ -0,0 +1,132 @@ +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 hip_screen; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 _ProjectionParams; +uniform vec4 _MainTex_ST; +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +vec4 ComputeScreenPos ( + in vec4 pos +) +{ + vec4 o; + vec4 tmpvar_1; + tmpvar_1 = (pos * 0.5); + o = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2.x = o.x; + tmpvar_2.y = (o.y * _ProjectionParams.x); + vec2 tmpvar_3; + tmpvar_3 = (tmpvar_2 + o.w); + o.xy = tmpvar_3.xy.xy; + vec2 tmpvar_4; + tmpvar_4 = pos.zw; + o.zw = tmpvar_4.xxxy.zw; + return o; +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + v2f_surf o; + PositionFog (v.vertex, o.pos, o.fog); + vec2 tmpvar_1; + tmpvar_1 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + o.hip_pack0 = tmpvar_1.xy.xy; + vec4 tmpvar_2; + tmpvar_2 = ComputeScreenPos (o.pos); + vec4 tmpvar_3; + tmpvar_3 = tmpvar_2; + o.hip_screen = tmpvar_3; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = xl_retval.fog; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_FOG = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19.zw = vec2(0.0, 0.0); + tmpvar_19.xy = xl_retval.hip_pack0.xy; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[0] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21 = xl_retval.hip_screen.xyzw; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_TexCoord[1] = tmpvar_22; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Bumped_Diffuse1-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Bumped_Diffuse1-out.txt new file mode 100644 index 000000000..2f3f8d3dc --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Bumped_Diffuse1-out.txt @@ -0,0 +1,28 @@ +varying vec4 xlv_FOG; +uniform vec4 _ProjectionParams; +uniform vec4 _MainTex_ST; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * gl_Vertex); + vec4 o_i0; + vec4 tmpvar_2; + tmpvar_2 = (tmpvar_1 * 0.5); + o_i0 = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3.x = tmpvar_2.x; + tmpvar_3.y = (tmpvar_2.y * _ProjectionParams.x); + o_i0.xy = (tmpvar_3 + tmpvar_2.w); + o_i0.zw = tmpvar_1.zw; + gl_Position = tmpvar_1; + vec4 tmpvar_4; + tmpvar_4.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_4.x = tmpvar_1.z; + xlv_FOG = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5.zw = vec2(0.0, 0.0); + tmpvar_5.xy = ((gl_MultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + gl_TexCoord[0] = tmpvar_5; + gl_TexCoord[1] = o_i0; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Bumped_Specular-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Bumped_Specular-in.txt new file mode 100644 index 000000000..230f6c882 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Bumped_Specular-in.txt @@ -0,0 +1,188 @@ +mat3 xll_constructMat3( mat4 m) { + return mat3( vec3( m[0]), vec3( m[1]), vec3( m[2])); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 viewDir; + vec3 lightDir; + vec3 vlight; + vec4 _ShadowCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _BumpMap_ST; +uniform vec4 _MainTex_ST; +uniform mat4 _Object2World; +uniform vec4 _ProjectionParams; +uniform mat4 _World2Object; +uniform vec3 _WorldSpaceCameraPos; +uniform vec4 _WorldSpaceLightPos0; + +uniform vec4 unity_4LightAtten0; +uniform vec4 unity_4LightPosX0; +uniform vec4 unity_4LightPosY0; +uniform vec4 unity_4LightPosZ0; +uniform vec3 unity_LightColor0; +uniform vec3 unity_LightColor1; +uniform vec3 unity_LightColor2; +uniform vec3 unity_LightColor3; +uniform vec4 unity_SHAb; +uniform vec4 unity_SHAg; +uniform vec4 unity_SHAr; +uniform vec4 unity_SHBb; +uniform vec4 unity_SHBg; +uniform vec4 unity_SHBr; +uniform vec4 unity_SHC; +uniform vec4 unity_Scale; +vec3 ShadeSH9( in vec4 normal ); +vec3 Shade4PointLights( in vec4 lightPosX, in vec4 lightPosY, in vec4 lightPosZ, in vec3 lightColor0, in vec3 lightColor1, in vec3 lightColor2, in vec3 lightColor3, in vec4 lightAttenSq, in vec3 pos, in vec3 normal ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +vec3 ObjSpaceViewDir( in vec4 v ); +vec3 ObjSpaceLightDir( in vec4 v ); +vec4 ComputeScreenPos( in vec4 pos ); +v2f_surf vert_surf( in appdata_full v ); +vec3 ShadeSH9( in vec4 normal ) { + vec3 x1; + vec4 vB; + vec3 x2; + float vC; + vec3 x3; + x1.x = dot( unity_SHAr, normal); + x1.y = dot( unity_SHAg, normal); + x1.z = dot( unity_SHAb, normal); + vB = (normal.xyzz * normal.yzzx ); + x2.x = dot( unity_SHBr, vB); + x2.y = dot( unity_SHBg, vB); + x2.z = dot( unity_SHBb, vB); + vC = ((normal.x * normal.x ) - (normal.y * normal.y )); + x3 = (unity_SHC.xyz * vC); + return ((x1 + x2) + x3); +} +vec3 Shade4PointLights( in vec4 lightPosX, in vec4 lightPosY, in vec4 lightPosZ, in vec3 lightColor0, in vec3 lightColor1, in vec3 lightColor2, in vec3 lightColor3, in vec4 lightAttenSq, in vec3 pos, in vec3 normal ) { + vec4 toLightX; + vec4 toLightY; + vec4 toLightZ; + vec4 lengthSq; + vec4 ndotl; + vec4 corr; + vec4 atten; + vec4 diff; + vec3 col; + toLightX = (lightPosX - pos.x ); + toLightY = (lightPosY - pos.y ); + toLightZ = (lightPosZ - pos.z ); + lengthSq = vec4( 0.000000); + lengthSq += (toLightX * toLightX); + lengthSq += (toLightY * toLightY); + lengthSq += (toLightZ * toLightZ); + ndotl = vec4( 0.000000); + ndotl += (toLightX * normal.x ); + ndotl += (toLightY * normal.y ); + ndotl += (toLightZ * normal.z ); + corr = inversesqrt( lengthSq ); + ndotl = max( vec4( 0.000000, 0.000000, 0.000000, 0.000000), (ndotl * corr)); + atten = (1.00000 / (1.00000 + (lengthSq * lightAttenSq))); + diff = (ndotl * atten); + col = vec3( 0.000000); + col += (lightColor0 * diff.x ); + col += (lightColor1 * diff.y ); + col += (lightColor2 * diff.z ); + col += (lightColor3 * diff.w ); + return col; +} +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +vec3 ObjSpaceViewDir( in vec4 v ) { + vec3 objSpaceCameraPos; + objSpaceCameraPos = (( _World2Object * vec4( _WorldSpaceCameraPos.xyz , 1.00000) ).xyz * unity_Scale.w ); + return (objSpaceCameraPos - v.xyz ); +} +vec3 ObjSpaceLightDir( in vec4 v ) { + vec3 objSpaceLightPos; + objSpaceLightPos = ( _World2Object * _WorldSpaceLightPos0 ).xyz ; + return objSpaceLightPos.xyz ; +} +vec4 ComputeScreenPos( in vec4 pos ) { + vec4 o; + o = (pos * 0.500000); + o.xy = (vec2( o.x , (o.y * _ProjectionParams.x )) + o.w ); + o.zw = pos.zw ; + return o; +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + vec3 worldN; + vec3 binormal; + mat3 rotation; + vec3 shlight; + vec3 worldPos; + PositionFog( v.vertex, o.pos, o.fog); + o.hip_pack0.xy = ((v.texcoord.xy * _MainTex_ST.xy ) + _MainTex_ST.zw ); + o.hip_pack0.zw = ((v.texcoord.xy * _BumpMap_ST.xy ) + _BumpMap_ST.zw ); + worldN = ( xll_constructMat3( _Object2World) * (v.normal * unity_Scale.w ) ); + binormal = (cross( v.normal, v.tangent.xyz ) * v.tangent.w ); + rotation = mat3( v.tangent.x , binormal.x , v.normal.x , v.tangent.y , binormal.y , v.normal.y , v.tangent.z , binormal.z , v.normal.z ); + o.lightDir = ( rotation * ObjSpaceLightDir( v.vertex) ); + o.viewDir = ( rotation * ObjSpaceViewDir( v.vertex) ); + shlight = ShadeSH9( vec4( worldN, 1.00000)); + o.vlight = shlight; + worldPos = ( _Object2World * v.vertex ).xyz ; + o.vlight += Shade4PointLights( unity_4LightPosX0, unity_4LightPosY0, unity_4LightPosZ0, unity_LightColor0, unity_LightColor1, unity_LightColor2, unity_LightColor3, unity_4LightAtten0, worldPos, worldN); + o._ShadowCoord = ComputeScreenPos( o.pos); + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.hip_pack0); + gl_TexCoord[1] = vec4( xl_retval.viewDir, 0.0); + gl_TexCoord[2] = vec4( xl_retval.lightDir, 0.0); + gl_TexCoord[3] = vec4( xl_retval.vlight, 0.0); + gl_TexCoord[4] = vec4( xl_retval._ShadowCoord); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Bumped_Specular-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Bumped_Specular-ir.txt new file mode 100644 index 000000000..7680c076f --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Bumped_Specular-ir.txt @@ -0,0 +1,439 @@ +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 viewDir; + vec3 lightDir; + vec3 vlight; + vec4 _ShadowCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec4 unity_SHC; +uniform vec4 unity_SHBr; +uniform vec4 unity_SHBg; +uniform vec4 unity_SHBb; +uniform vec4 unity_SHAr; +uniform vec4 unity_SHAg; +uniform vec4 unity_SHAb; +uniform vec3 unity_LightColor3; +uniform vec3 unity_LightColor2; +uniform vec3 unity_LightColor1; +uniform vec3 unity_LightColor0; +uniform vec4 unity_4LightPosZ0; +uniform vec4 unity_4LightPosY0; +uniform vec4 unity_4LightPosX0; +uniform vec4 unity_4LightAtten0; +uniform vec4 _WorldSpaceLightPos0; +uniform vec3 _WorldSpaceCameraPos; +uniform mat4 _World2Object; +uniform vec4 _ProjectionParams; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform vec4 _BumpMap_ST; +mat3 xll_constructMat3 ( + in mat4 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = m[0].xyz; + vec3 tmpvar_2; + tmpvar_2 = m[1].xyz; + vec3 tmpvar_3; + tmpvar_3 = m[2].xyz; + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +vec3 ShadeSH9 ( + in vec4 normal +) +{ + vec3 x3; + float vC; + vec3 x2; + vec4 vB; + vec3 x1; + float tmpvar_1; + tmpvar_1 = dot (unity_SHAr, normal); + float tmpvar_2; + tmpvar_2 = tmpvar_1; + x1.x = tmpvar_2; + float tmpvar_3; + tmpvar_3 = dot (unity_SHAg, normal); + float tmpvar_4; + tmpvar_4 = tmpvar_3; + x1.y = vec2(tmpvar_4).y; + float tmpvar_5; + tmpvar_5 = dot (unity_SHAb, normal); + float tmpvar_6; + tmpvar_6 = tmpvar_5; + x1.z = vec3(tmpvar_6).z; + vec4 tmpvar_7; + tmpvar_7 = (normal.xyzz * normal.yzzx); + vB = tmpvar_7; + float tmpvar_8; + tmpvar_8 = dot (unity_SHBr, vB); + float tmpvar_9; + tmpvar_9 = tmpvar_8; + x2.x = tmpvar_9; + float tmpvar_10; + tmpvar_10 = dot (unity_SHBg, vB); + float tmpvar_11; + tmpvar_11 = tmpvar_10; + x2.y = vec2(tmpvar_11).y; + float tmpvar_12; + tmpvar_12 = dot (unity_SHBb, vB); + float tmpvar_13; + tmpvar_13 = tmpvar_12; + x2.z = vec3(tmpvar_13).z; + float tmpvar_14; + tmpvar_14 = ((normal.x * normal.x) - (normal.y * normal.y)); + vC = tmpvar_14; + vec3 tmpvar_15; + tmpvar_15 = (unity_SHC.xyz * vC); + x3 = tmpvar_15; + return ((x1 + x2) + x3); +} + +vec3 Shade4PointLights ( + in vec4 lightPosX, + in vec4 lightPosY, + in vec4 lightPosZ, + in vec3 lightColor0, + in vec3 lightColor1, + in vec3 lightColor2, + in vec3 lightColor3, + in vec4 lightAttenSq, + in vec3 pos, + in vec3 normal +) +{ + vec3 col; + vec4 diff; + vec4 atten; + vec4 corr; + vec4 ndotl; + vec4 lengthSq; + vec4 toLightZ; + vec4 toLightY; + vec4 toLightX; + vec4 tmpvar_1; + tmpvar_1 = (lightPosX - pos.x); + toLightX = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = (lightPosY - pos.y); + toLightY = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = (lightPosZ - pos.z); + toLightZ = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = vec4(0.0, 0.0, 0.0, 0.0); + lengthSq = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = (lengthSq + (toLightX * toLightX)); + lengthSq = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = (lengthSq + (toLightY * toLightY)); + lengthSq = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = (lengthSq + (toLightZ * toLightZ)); + lengthSq = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = vec4(0.0, 0.0, 0.0, 0.0); + ndotl = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = (ndotl + (toLightX * normal.x)); + ndotl = tmpvar_9; + vec4 tmpvar_10; + tmpvar_10 = (ndotl + (toLightY * normal.y)); + ndotl = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = (ndotl + (toLightZ * normal.z)); + ndotl = tmpvar_11; + vec4 tmpvar_12; + tmpvar_12 = inversesqrt (lengthSq); + vec4 tmpvar_13; + tmpvar_13 = tmpvar_12; + corr = tmpvar_13; + vec4 tmpvar_14; + tmpvar_14 = max (vec4(0.0, 0.0, 0.0, 0.0), (ndotl * corr)); + vec4 tmpvar_15; + tmpvar_15 = tmpvar_14; + ndotl = tmpvar_15; + vec4 tmpvar_16; + tmpvar_16 = (1.0 / (1.0 + (lengthSq * lightAttenSq))); + atten = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17 = (ndotl * atten); + diff = tmpvar_17; + vec3 tmpvar_18; + tmpvar_18 = vec3(0.0, 0.0, 0.0); + col = tmpvar_18; + vec3 tmpvar_19; + tmpvar_19 = (col + (lightColor0 * diff.x)); + col = tmpvar_19; + vec3 tmpvar_20; + tmpvar_20 = (col + (lightColor1 * diff.y)); + col = tmpvar_20; + vec3 tmpvar_21; + tmpvar_21 = (col + (lightColor2 * diff.z)); + col = tmpvar_21; + vec3 tmpvar_22; + tmpvar_22 = (col + (lightColor3 * diff.w)); + col = tmpvar_22; + return col; +} + +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +vec3 ObjSpaceViewDir ( + in vec4 v +) +{ + vec3 objSpaceCameraPos; + vec4 tmpvar_1; + tmpvar_1.w = 1.0; + tmpvar_1.xyz = _WorldSpaceCameraPos.xyz.xyz; + vec3 tmpvar_2; + tmpvar_2 = ((_World2Object * tmpvar_1).xyz * unity_Scale.w); + objSpaceCameraPos = tmpvar_2; + return (objSpaceCameraPos - v.xyz); +} + +vec3 ObjSpaceLightDir ( + in vec4 v +) +{ + vec3 objSpaceLightPos; + vec3 tmpvar_1; + tmpvar_1 = (_World2Object * _WorldSpaceLightPos0).xyz; + objSpaceLightPos = tmpvar_1; + return objSpaceLightPos.xyz; +} + +vec4 ComputeScreenPos ( + in vec4 pos +) +{ + vec4 o; + vec4 tmpvar_1; + tmpvar_1 = (pos * 0.5); + o = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2.x = o.x; + tmpvar_2.y = (o.y * _ProjectionParams.x); + vec2 tmpvar_3; + tmpvar_3 = (tmpvar_2 + o.w); + o.xy = tmpvar_3.xy.xy; + vec2 tmpvar_4; + tmpvar_4 = pos.zw; + o.zw = tmpvar_4.xxxy.zw; + return o; +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + vec3 worldPos; + vec3 shlight; + mat3 rotation; + vec3 binormal; + vec3 worldN; + v2f_surf o; + PositionFog (v.vertex, o.pos, o.fog); + vec2 tmpvar_1; + tmpvar_1 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + o.hip_pack0.xy = tmpvar_1.xy.xy; + vec2 tmpvar_2; + tmpvar_2 = ((v.texcoord.xy * _BumpMap_ST.xy) + _BumpMap_ST.zw); + o.hip_pack0.zw = tmpvar_2.xxxy.zw; + mat3 tmpvar_3; + tmpvar_3 = (xll_constructMat3 (_Object2World)); + vec3 tmpvar_4; + tmpvar_4 = (tmpvar_3 * (v.normal * unity_Scale.w)); + worldN = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = cross (v.normal, v.tangent.xyz); + vec3 tmpvar_6; + tmpvar_6 = (tmpvar_5 * v.tangent.w); + binormal = tmpvar_6; + mat3 tmpvar_7; + float tmpvar_8; + tmpvar_8 = v.tangent.x; + tmpvar_7[0].x = tmpvar_8; + float tmpvar_9; + tmpvar_9 = binormal.x; + tmpvar_7[0].y = tmpvar_9; + float tmpvar_10; + tmpvar_10 = v.normal.x; + tmpvar_7[0].z = tmpvar_10; + float tmpvar_11; + tmpvar_11 = v.tangent.y; + tmpvar_7[1].x = tmpvar_11; + float tmpvar_12; + tmpvar_12 = binormal.y; + tmpvar_7[1].y = tmpvar_12; + float tmpvar_13; + tmpvar_13 = v.normal.y; + tmpvar_7[1].z = tmpvar_13; + float tmpvar_14; + tmpvar_14 = v.tangent.z; + tmpvar_7[2].x = tmpvar_14; + float tmpvar_15; + tmpvar_15 = binormal.z; + tmpvar_7[2].y = tmpvar_15; + float tmpvar_16; + tmpvar_16 = v.normal.z; + tmpvar_7[2].z = tmpvar_16; + mat3 tmpvar_17; + tmpvar_17 = (tmpvar_7); + rotation = (tmpvar_17); + vec3 tmpvar_18; + tmpvar_18 = ObjSpaceLightDir (v.vertex); + vec3 tmpvar_19; + tmpvar_19 = (rotation * tmpvar_18); + o.lightDir = tmpvar_19; + vec3 tmpvar_20; + tmpvar_20 = ObjSpaceViewDir (v.vertex); + vec3 tmpvar_21; + tmpvar_21 = (rotation * tmpvar_20); + o.viewDir = tmpvar_21; + vec4 tmpvar_22; + tmpvar_22.w = 1.0; + tmpvar_22.xyz = worldN.xyz; + vec3 tmpvar_23; + tmpvar_23 = ShadeSH9 (tmpvar_22); + vec3 tmpvar_24; + tmpvar_24 = tmpvar_23; + shlight = tmpvar_24; + vec3 tmpvar_25; + tmpvar_25 = shlight; + o.vlight = tmpvar_25; + vec3 tmpvar_26; + tmpvar_26 = (_Object2World * v.vertex).xyz; + worldPos = tmpvar_26; + vec3 tmpvar_27; + tmpvar_27 = Shade4PointLights (unity_4LightPosX0, unity_4LightPosY0, unity_4LightPosZ0, unity_LightColor0, unity_LightColor1, unity_LightColor2, unity_LightColor3, unity_4LightAtten0, worldPos, worldN); + vec3 tmpvar_28; + tmpvar_28 = (o.vlight + tmpvar_27); + o.vlight = tmpvar_28; + vec4 tmpvar_29; + tmpvar_29 = ComputeScreenPos (o.pos); + vec4 tmpvar_30; + tmpvar_30 = tmpvar_29; + o._ShadowCoord = tmpvar_30; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = xl_retval.fog; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_FOG = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19 = xl_retval.hip_pack0.xyzw; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[0] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21.w = 0.0; + tmpvar_21.xyz = xl_retval.viewDir.xyz; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_TexCoord[1] = tmpvar_22; + vec4 tmpvar_23; + tmpvar_23.w = 0.0; + tmpvar_23.xyz = xl_retval.lightDir.xyz; + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + gl_TexCoord[2] = tmpvar_24; + vec4 tmpvar_25; + tmpvar_25.w = 0.0; + tmpvar_25.xyz = xl_retval.vlight.xyz; + vec4 tmpvar_26; + tmpvar_26 = tmpvar_25; + gl_TexCoord[3] = tmpvar_26; + vec4 tmpvar_27; + tmpvar_27 = xl_retval._ShadowCoord.xyzw; + vec4 tmpvar_28; + tmpvar_28 = tmpvar_27; + gl_TexCoord[4] = tmpvar_28; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Bumped_Specular-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Bumped_Specular-out.txt new file mode 100644 index 000000000..f89a0eb27 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Bumped_Specular-out.txt @@ -0,0 +1,108 @@ +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec4 unity_SHC; +uniform vec4 unity_SHBr; +uniform vec4 unity_SHBg; +uniform vec4 unity_SHBb; +uniform vec4 unity_SHAr; +uniform vec4 unity_SHAg; +uniform vec4 unity_SHAb; +uniform vec3 unity_LightColor3; +uniform vec3 unity_LightColor2; +uniform vec3 unity_LightColor1; +uniform vec3 unity_LightColor0; +uniform vec4 unity_4LightPosZ0; +uniform vec4 unity_4LightPosY0; +uniform vec4 unity_4LightPosX0; +uniform vec4 unity_4LightAtten0; +uniform vec4 _WorldSpaceLightPos0; +uniform vec3 _WorldSpaceCameraPos; +uniform mat4 _World2Object; +uniform vec4 _ProjectionParams; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform vec4 _BumpMap_ST; +void main () +{ + vec4 tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = (gl_ModelViewProjectionMatrix * gl_Vertex); + tmpvar_1.xy = ((gl_MultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + tmpvar_1.zw = ((gl_MultiTexCoord0.xy * _BumpMap_ST.xy) + _BumpMap_ST.zw); + mat3 tmpvar_3; + tmpvar_3[0] = _Object2World[0].xyz; + tmpvar_3[1] = _Object2World[1].xyz; + tmpvar_3[2] = _Object2World[2].xyz; + vec3 tmpvar_4; + tmpvar_4 = (tmpvar_3 * (gl_Normal * unity_Scale.w)); + vec3 tmpvar_5; + tmpvar_5 = (cross (gl_Normal, TANGENT.xyz) * TANGENT.w); + mat3 tmpvar_6; + tmpvar_6[0].x = TANGENT.x; + tmpvar_6[0].y = tmpvar_5.x; + tmpvar_6[0].z = gl_Normal.x; + tmpvar_6[1].x = TANGENT.y; + tmpvar_6[1].y = tmpvar_5.y; + tmpvar_6[1].z = gl_Normal.y; + tmpvar_6[2].x = TANGENT.z; + tmpvar_6[2].y = tmpvar_5.z; + tmpvar_6[2].z = gl_Normal.z; + vec4 tmpvar_7; + tmpvar_7.w = 1.0; + tmpvar_7.xyz = _WorldSpaceCameraPos; + vec4 tmpvar_8; + tmpvar_8.w = 1.0; + tmpvar_8.xyz = tmpvar_4; + vec3 x2; + vec3 x1; + x1.x = dot (unity_SHAr, tmpvar_8); + x1.y = dot (unity_SHAg, tmpvar_8); + x1.z = dot (unity_SHAb, tmpvar_8); + vec4 tmpvar_9; + tmpvar_9 = (tmpvar_4.xyzz * tmpvar_4.yzzx); + x2.x = dot (unity_SHBr, tmpvar_9); + x2.y = dot (unity_SHBg, tmpvar_9); + x2.z = dot (unity_SHBb, tmpvar_9); + vec3 tmpvar_10; + tmpvar_10 = (_Object2World * gl_Vertex).xyz; + vec4 tmpvar_11; + tmpvar_11 = (unity_4LightPosX0 - tmpvar_10.x); + vec4 tmpvar_12; + tmpvar_12 = (unity_4LightPosY0 - tmpvar_10.y); + vec4 tmpvar_13; + tmpvar_13 = (unity_4LightPosZ0 - tmpvar_10.z); + vec4 tmpvar_14; + tmpvar_14 = (((tmpvar_11 * tmpvar_11) + (tmpvar_12 * tmpvar_12)) + (tmpvar_13 * tmpvar_13)); + vec4 tmpvar_15; + tmpvar_15 = (max (vec4(0.0, 0.0, 0.0, 0.0), ((((tmpvar_11 * tmpvar_4.x) + (tmpvar_12 * tmpvar_4.y)) + (tmpvar_13 * tmpvar_4.z)) * inversesqrt (tmpvar_14))) * (1.0/((1.0 + (tmpvar_14 * unity_4LightAtten0))))); + vec4 o_i0; + vec4 tmpvar_16; + tmpvar_16 = (tmpvar_2 * 0.5); + o_i0 = tmpvar_16; + vec2 tmpvar_17; + tmpvar_17.x = tmpvar_16.x; + tmpvar_17.y = (tmpvar_16.y * _ProjectionParams.x); + o_i0.xy = (tmpvar_17 + tmpvar_16.w); + o_i0.zw = tmpvar_2.zw; + gl_Position = tmpvar_2; + vec4 tmpvar_18; + tmpvar_18.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_18.x = tmpvar_2.z; + xlv_FOG = tmpvar_18; + gl_TexCoord[0] = tmpvar_1; + vec4 tmpvar_19; + tmpvar_19.w = 0.0; + tmpvar_19.xyz = (tmpvar_6 * (((_World2Object * tmpvar_7).xyz * unity_Scale.w) - gl_Vertex.xyz)); + gl_TexCoord[1] = tmpvar_19; + vec4 tmpvar_20; + tmpvar_20.w = 0.0; + tmpvar_20.xyz = (tmpvar_6 * (_World2Object * _WorldSpaceLightPos0).xyz); + gl_TexCoord[2] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21.w = 0.0; + tmpvar_21.xyz = (((x1 + x2) + (unity_SHC.xyz * ((tmpvar_4.x * tmpvar_4.x) - (tmpvar_4.y * tmpvar_4.y)))) + ((((unity_LightColor0 * tmpvar_15.x) + (unity_LightColor1 * tmpvar_15.y)) + (unity_LightColor2 * tmpvar_15.z)) + (unity_LightColor3 * tmpvar_15.w))); + gl_TexCoord[3] = tmpvar_21; + gl_TexCoord[4] = o_i0; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Bumped_Specular2-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Bumped_Specular2-in.txt new file mode 100644 index 000000000..2b6a86c76 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Bumped_Specular2-in.txt @@ -0,0 +1,87 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 hip_screen; + vec3 hip_lmapFade; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _MainTex_ST; +uniform vec4 _ProjectionParams; + + +uniform vec4 unity_LightmapFade; +uniform vec4 unity_LightmapST; +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +vec4 ComputeScreenPos( in vec4 pos ); +v2f_surf vert_surf( in appdata_full v ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +vec4 ComputeScreenPos( in vec4 pos ) { + vec4 o; + o = (pos * 0.500000); + o.xy = (vec2( o.x , (o.y * _ProjectionParams.x )) + o.w ); + o.zw = pos.zw ; + return o; +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + PositionFog( v.vertex, o.pos, o.fog); + o.hip_pack0.xy = ((v.texcoord.xy * _MainTex_ST.xy ) + _MainTex_ST.zw ); + o.hip_screen = ComputeScreenPos( o.pos); + o.hip_lmapFade.xy = ((v.texcoord1.xy * unity_LightmapST.xy ) + unity_LightmapST.zw ); + o.hip_lmapFade.z = ((( -( gl_ModelViewMatrix * v.vertex ).z ) * unity_LightmapFade.z ) + unity_LightmapFade.w ); + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.hip_pack0, 0.0, 0.0); + gl_TexCoord[1] = vec4( xl_retval.hip_screen); + gl_TexCoord[2] = vec4( xl_retval.hip_lmapFade, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Bumped_Specular2-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Bumped_Specular2-ir.txt new file mode 100644 index 000000000..c8752824a --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Bumped_Specular2-ir.txt @@ -0,0 +1,147 @@ +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 hip_screen; + vec3 hip_lmapFade; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_LightmapST; +uniform vec4 unity_LightmapFade; +uniform vec4 _ProjectionParams; +uniform vec4 _MainTex_ST; +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +vec4 ComputeScreenPos ( + in vec4 pos +) +{ + vec4 o; + vec4 tmpvar_1; + tmpvar_1 = (pos * 0.5); + o = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2.x = o.x; + tmpvar_2.y = (o.y * _ProjectionParams.x); + vec2 tmpvar_3; + tmpvar_3 = (tmpvar_2 + o.w); + o.xy = tmpvar_3.xy.xy; + vec2 tmpvar_4; + tmpvar_4 = pos.zw; + o.zw = tmpvar_4.xxxy.zw; + return o; +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + v2f_surf o; + PositionFog (v.vertex, o.pos, o.fog); + vec2 tmpvar_1; + tmpvar_1 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + o.hip_pack0 = tmpvar_1.xy.xy; + vec4 tmpvar_2; + tmpvar_2 = ComputeScreenPos (o.pos); + vec4 tmpvar_3; + tmpvar_3 = tmpvar_2; + o.hip_screen = tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = ((v.texcoord1.xy * unity_LightmapST.xy) + unity_LightmapST.zw); + o.hip_lmapFade.xy = tmpvar_4.xy.xy; + float tmpvar_5; + tmpvar_5 = ((-((gl_ModelViewMatrix * v.vertex).z) * unity_LightmapFade.z) + unity_LightmapFade.w); + o.hip_lmapFade.z = vec3(tmpvar_5).z; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = xl_retval.fog; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_FOG = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19.zw = vec2(0.0, 0.0); + tmpvar_19.xy = xl_retval.hip_pack0.xy; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[0] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21 = xl_retval.hip_screen.xyzw; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_TexCoord[1] = tmpvar_22; + vec4 tmpvar_23; + tmpvar_23.w = 0.0; + tmpvar_23.xyz = xl_retval.hip_lmapFade.xyz; + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + gl_TexCoord[2] = tmpvar_24; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Bumped_Specular2-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Bumped_Specular2-out.txt new file mode 100644 index 000000000..e52b6728b --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Bumped_Specular2-out.txt @@ -0,0 +1,37 @@ +varying vec4 xlv_FOG; +uniform vec4 unity_LightmapST; +uniform vec4 unity_LightmapFade; +uniform vec4 _ProjectionParams; +uniform vec4 _MainTex_ST; +void main () +{ + vec3 tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = (gl_ModelViewProjectionMatrix * gl_Vertex); + vec4 o_i0; + vec4 tmpvar_3; + tmpvar_3 = (tmpvar_2 * 0.5); + o_i0 = tmpvar_3; + vec2 tmpvar_4; + tmpvar_4.x = tmpvar_3.x; + tmpvar_4.y = (tmpvar_3.y * _ProjectionParams.x); + o_i0.xy = (tmpvar_4 + tmpvar_3.w); + o_i0.zw = tmpvar_2.zw; + tmpvar_1.xy = ((gl_MultiTexCoord1.xy * unity_LightmapST.xy) + unity_LightmapST.zw); + tmpvar_1.z = ((-((gl_ModelViewMatrix * gl_Vertex).z) * unity_LightmapFade.z) + unity_LightmapFade.w); + gl_Position = tmpvar_2; + vec4 tmpvar_5; + tmpvar_5.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_5.x = tmpvar_2.z; + xlv_FOG = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6.zw = vec2(0.0, 0.0); + tmpvar_6.xy = ((gl_MultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + gl_TexCoord[0] = tmpvar_6; + gl_TexCoord[1] = o_i0; + vec4 tmpvar_7; + tmpvar_7.w = 0.0; + tmpvar_7.xyz = tmpvar_1; + gl_TexCoord[2] = tmpvar_7; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Decal-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Decal-in.txt new file mode 100644 index 000000000..d97bb6ad2 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Decal-in.txt @@ -0,0 +1,88 @@ +mat3 xll_constructMat3( mat4 m) { + return mat3( vec3( m[0]), vec3( m[1]), vec3( m[2])); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_DecalTex; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 normal; + vec3 lightDir; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _DecalTex_ST; +uniform vec4 _MainTex_ST; +uniform mat4 _Object2World; +uniform vec4 _WorldSpaceLightPos0; + +uniform vec4 unity_Scale; +vec3 WorldSpaceLightDir( in vec4 v ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +v2f_surf vert_surf( in appdata_full v ); +vec3 WorldSpaceLightDir( in vec4 v ) { + vec3 worldPos; + worldPos = ( _Object2World * v ).xyz ; + return _WorldSpaceLightPos0.xyz ; +} +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + PositionFog( v.vertex, o.pos, o.fog); + o.hip_pack0.xy = ((v.texcoord.xy * _MainTex_ST.xy ) + _MainTex_ST.zw ); + o.hip_pack0.zw = ((v.texcoord.xy * _DecalTex_ST.xy ) + _DecalTex_ST.zw ); + o.normal = ( xll_constructMat3( _Object2World) * (v.normal * unity_Scale.w ) ); + o.lightDir = WorldSpaceLightDir( v.vertex); + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.hip_pack0); + gl_TexCoord[1] = vec4( xl_retval.normal, 0.0); + gl_TexCoord[2] = vec4( xl_retval.lightDir, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Decal-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Decal-ir.txt new file mode 100644 index 000000000..6bf98c141 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Decal-ir.txt @@ -0,0 +1,164 @@ +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 normal; + vec3 lightDir; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform vec4 _DecalTex_ST; +mat3 xll_constructMat3 ( + in mat4 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = m[0].xyz; + vec3 tmpvar_2; + tmpvar_2 = m[1].xyz; + vec3 tmpvar_3; + tmpvar_3 = m[2].xyz; + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +vec3 WorldSpaceLightDir ( + in vec4 v +) +{ + vec3 worldPos; + vec3 tmpvar_1; + tmpvar_1 = (_Object2World * v).xyz; + worldPos = tmpvar_1; + return _WorldSpaceLightPos0.xyz; +} + +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + v2f_surf o; + PositionFog (v.vertex, o.pos, o.fog); + vec2 tmpvar_1; + tmpvar_1 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + o.hip_pack0.xy = tmpvar_1.xy.xy; + vec2 tmpvar_2; + tmpvar_2 = ((v.texcoord.xy * _DecalTex_ST.xy) + _DecalTex_ST.zw); + o.hip_pack0.zw = tmpvar_2.xxxy.zw; + mat3 tmpvar_3; + tmpvar_3 = (xll_constructMat3 (_Object2World)); + vec3 tmpvar_4; + tmpvar_4 = (tmpvar_3 * (v.normal * unity_Scale.w)); + o.normal = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = WorldSpaceLightDir (v.vertex); + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + o.lightDir = tmpvar_6; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = xl_retval.fog; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_FOG = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19 = xl_retval.hip_pack0.xyzw; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[0] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21.w = 0.0; + tmpvar_21.xyz = xl_retval.normal.xyz; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_TexCoord[1] = tmpvar_22; + vec4 tmpvar_23; + tmpvar_23.w = 0.0; + tmpvar_23.xyz = xl_retval.lightDir.xyz; + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + gl_TexCoord[2] = tmpvar_24; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Decal-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Decal-out.txt new file mode 100644 index 000000000..c21429435 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Decal-out.txt @@ -0,0 +1,33 @@ +varying vec4 xlv_FOG; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform vec4 _DecalTex_ST; +void main () +{ + vec4 tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = (gl_ModelViewProjectionMatrix * gl_Vertex); + tmpvar_1.xy = ((gl_MultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + tmpvar_1.zw = ((gl_MultiTexCoord0.xy * _DecalTex_ST.xy) + _DecalTex_ST.zw); + mat3 tmpvar_3; + tmpvar_3[0] = _Object2World[0].xyz; + tmpvar_3[1] = _Object2World[1].xyz; + tmpvar_3[2] = _Object2World[2].xyz; + gl_Position = tmpvar_2; + vec4 tmpvar_4; + tmpvar_4.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_4.x = tmpvar_2.z; + xlv_FOG = tmpvar_4; + gl_TexCoord[0] = tmpvar_1; + vec4 tmpvar_5; + tmpvar_5.w = 0.0; + tmpvar_5.xyz = (tmpvar_3 * (gl_Normal * unity_Scale.w)); + gl_TexCoord[1] = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6.w = 0.0; + tmpvar_6.xyz = _WorldSpaceLightPos0.xyz; + gl_TexCoord[2] = tmpvar_6; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Diffuse-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Diffuse-in.txt new file mode 100644 index 000000000..95f216411 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Diffuse-in.txt @@ -0,0 +1,89 @@ +mat3 xll_constructMat3( mat4 m) { + return mat3( vec3( m[0]), vec3( m[1]), vec3( m[2])); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 normal; + vec3 lightDir; + vec3 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform mat4 _LightMatrix0; +uniform vec4 _MainTex_ST; +uniform mat4 _Object2World; +uniform vec4 _WorldSpaceLightPos0; + +uniform vec4 unity_Scale; +vec3 WorldSpaceLightDir( in vec4 v ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +v2f_surf vert_surf( in appdata_full v ); +vec3 WorldSpaceLightDir( in vec4 v ) { + vec3 worldPos; + worldPos = ( _Object2World * v ).xyz ; + return (_WorldSpaceLightPos0.xyz - worldPos); +} +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + PositionFog( v.vertex, o.pos, o.fog); + o.hip_pack0.xy = ((v.texcoord.xy * _MainTex_ST.xy ) + _MainTex_ST.zw ); + o.normal = ( xll_constructMat3( _Object2World) * (v.normal * unity_Scale.w ) ); + o.lightDir = WorldSpaceLightDir( v.vertex); + o._LightCoord = ( _LightMatrix0 * ( _Object2World * v.vertex ) ).xyz ; + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.hip_pack0, 0.0, 0.0); + gl_TexCoord[1] = vec4( xl_retval.normal, 0.0); + gl_TexCoord[2] = vec4( xl_retval.lightDir, 0.0); + gl_TexCoord[3] = vec4( xl_retval._LightCoord, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Diffuse-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Diffuse-ir.txt new file mode 100644 index 000000000..f7f80c2c0 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Diffuse-ir.txt @@ -0,0 +1,172 @@ +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 normal; + vec3 lightDir; + vec3 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform mat4 _LightMatrix0; +mat3 xll_constructMat3 ( + in mat4 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = m[0].xyz; + vec3 tmpvar_2; + tmpvar_2 = m[1].xyz; + vec3 tmpvar_3; + tmpvar_3 = m[2].xyz; + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +vec3 WorldSpaceLightDir ( + in vec4 v +) +{ + vec3 worldPos; + vec3 tmpvar_1; + tmpvar_1 = (_Object2World * v).xyz; + worldPos = tmpvar_1; + return (_WorldSpaceLightPos0.xyz - worldPos); +} + +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + v2f_surf o; + PositionFog (v.vertex, o.pos, o.fog); + vec2 tmpvar_1; + tmpvar_1 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + o.hip_pack0 = tmpvar_1.xy.xy; + mat3 tmpvar_2; + tmpvar_2 = (xll_constructMat3 (_Object2World)); + vec3 tmpvar_3; + tmpvar_3 = (tmpvar_2 * (v.normal * unity_Scale.w)); + o.normal = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = WorldSpaceLightDir (v.vertex); + vec3 tmpvar_5; + tmpvar_5 = tmpvar_4; + o.lightDir = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = (_LightMatrix0 * (_Object2World * v.vertex)).xyz; + o._LightCoord = tmpvar_6; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = xl_retval.fog; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_FOG = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19.zw = vec2(0.0, 0.0); + tmpvar_19.xy = xl_retval.hip_pack0.xy; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[0] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21.w = 0.0; + tmpvar_21.xyz = xl_retval.normal.xyz; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_TexCoord[1] = tmpvar_22; + vec4 tmpvar_23; + tmpvar_23.w = 0.0; + tmpvar_23.xyz = xl_retval.lightDir.xyz; + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + gl_TexCoord[2] = tmpvar_24; + vec4 tmpvar_25; + tmpvar_25.w = 0.0; + tmpvar_25.xyz = xl_retval._LightCoord.xyz; + vec4 tmpvar_26; + tmpvar_26 = tmpvar_25; + gl_TexCoord[3] = tmpvar_26; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Diffuse-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Diffuse-out.txt new file mode 100644 index 000000000..31addc376 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Diffuse-out.txt @@ -0,0 +1,37 @@ +varying vec4 xlv_FOG; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform mat4 _LightMatrix0; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * gl_Vertex); + mat3 tmpvar_2; + tmpvar_2[0] = _Object2World[0].xyz; + tmpvar_2[1] = _Object2World[1].xyz; + tmpvar_2[2] = _Object2World[2].xyz; + gl_Position = tmpvar_1; + vec4 tmpvar_3; + tmpvar_3.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_3.x = tmpvar_1.z; + xlv_FOG = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4.zw = vec2(0.0, 0.0); + tmpvar_4.xy = ((gl_MultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + gl_TexCoord[0] = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5.w = 0.0; + tmpvar_5.xyz = (tmpvar_2 * (gl_Normal * unity_Scale.w)); + gl_TexCoord[1] = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6.w = 0.0; + tmpvar_6.xyz = (_WorldSpaceLightPos0.xyz - (_Object2World * gl_Vertex).xyz); + gl_TexCoord[2] = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7.w = 0.0; + tmpvar_7.xyz = (_LightMatrix0 * (_Object2World * gl_Vertex)).xyz; + gl_TexCoord[3] = tmpvar_7; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Diffuse2-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Diffuse2-in.txt new file mode 100644 index 000000000..d531ecd7b --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Diffuse2-in.txt @@ -0,0 +1,86 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 hip_screen; + vec3 hip_lmapFade; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _MainTex_ST; +uniform vec4 _ProjectionParams; + + +uniform vec4 unity_LightmapFade; +uniform vec4 unity_LightmapST; +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +vec4 ComputeScreenPos( in vec4 pos ); +v2f_surf vert_surf( in appdata_full v ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +vec4 ComputeScreenPos( in vec4 pos ) { + vec4 o; + o = (pos * 0.500000); + o.xy = (vec2( o.x , (o.y * _ProjectionParams.x )) + o.w ); + o.zw = pos.zw ; + return o; +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + PositionFog( v.vertex, o.pos, o.fog); + o.hip_pack0.xy = ((v.texcoord.xy * _MainTex_ST.xy ) + _MainTex_ST.zw ); + o.hip_screen = ComputeScreenPos( o.pos); + o.hip_lmapFade.xy = ((v.texcoord1.xy * unity_LightmapST.xy ) + unity_LightmapST.zw ); + o.hip_lmapFade.z = ((( -( gl_ModelViewMatrix * v.vertex ).z ) * unity_LightmapFade.z ) + unity_LightmapFade.w ); + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.hip_pack0, 0.0, 0.0); + gl_TexCoord[1] = vec4( xl_retval.hip_screen); + gl_TexCoord[2] = vec4( xl_retval.hip_lmapFade, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Diffuse2-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Diffuse2-ir.txt new file mode 100644 index 000000000..c8752824a --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Diffuse2-ir.txt @@ -0,0 +1,147 @@ +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 hip_screen; + vec3 hip_lmapFade; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_LightmapST; +uniform vec4 unity_LightmapFade; +uniform vec4 _ProjectionParams; +uniform vec4 _MainTex_ST; +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +vec4 ComputeScreenPos ( + in vec4 pos +) +{ + vec4 o; + vec4 tmpvar_1; + tmpvar_1 = (pos * 0.5); + o = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2.x = o.x; + tmpvar_2.y = (o.y * _ProjectionParams.x); + vec2 tmpvar_3; + tmpvar_3 = (tmpvar_2 + o.w); + o.xy = tmpvar_3.xy.xy; + vec2 tmpvar_4; + tmpvar_4 = pos.zw; + o.zw = tmpvar_4.xxxy.zw; + return o; +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + v2f_surf o; + PositionFog (v.vertex, o.pos, o.fog); + vec2 tmpvar_1; + tmpvar_1 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + o.hip_pack0 = tmpvar_1.xy.xy; + vec4 tmpvar_2; + tmpvar_2 = ComputeScreenPos (o.pos); + vec4 tmpvar_3; + tmpvar_3 = tmpvar_2; + o.hip_screen = tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = ((v.texcoord1.xy * unity_LightmapST.xy) + unity_LightmapST.zw); + o.hip_lmapFade.xy = tmpvar_4.xy.xy; + float tmpvar_5; + tmpvar_5 = ((-((gl_ModelViewMatrix * v.vertex).z) * unity_LightmapFade.z) + unity_LightmapFade.w); + o.hip_lmapFade.z = vec3(tmpvar_5).z; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = xl_retval.fog; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_FOG = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19.zw = vec2(0.0, 0.0); + tmpvar_19.xy = xl_retval.hip_pack0.xy; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[0] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21 = xl_retval.hip_screen.xyzw; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_TexCoord[1] = tmpvar_22; + vec4 tmpvar_23; + tmpvar_23.w = 0.0; + tmpvar_23.xyz = xl_retval.hip_lmapFade.xyz; + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + gl_TexCoord[2] = tmpvar_24; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Diffuse2-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Diffuse2-out.txt new file mode 100644 index 000000000..e52b6728b --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Diffuse2-out.txt @@ -0,0 +1,37 @@ +varying vec4 xlv_FOG; +uniform vec4 unity_LightmapST; +uniform vec4 unity_LightmapFade; +uniform vec4 _ProjectionParams; +uniform vec4 _MainTex_ST; +void main () +{ + vec3 tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = (gl_ModelViewProjectionMatrix * gl_Vertex); + vec4 o_i0; + vec4 tmpvar_3; + tmpvar_3 = (tmpvar_2 * 0.5); + o_i0 = tmpvar_3; + vec2 tmpvar_4; + tmpvar_4.x = tmpvar_3.x; + tmpvar_4.y = (tmpvar_3.y * _ProjectionParams.x); + o_i0.xy = (tmpvar_4 + tmpvar_3.w); + o_i0.zw = tmpvar_2.zw; + tmpvar_1.xy = ((gl_MultiTexCoord1.xy * unity_LightmapST.xy) + unity_LightmapST.zw); + tmpvar_1.z = ((-((gl_ModelViewMatrix * gl_Vertex).z) * unity_LightmapFade.z) + unity_LightmapFade.w); + gl_Position = tmpvar_2; + vec4 tmpvar_5; + tmpvar_5.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_5.x = tmpvar_2.z; + xlv_FOG = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6.zw = vec2(0.0, 0.0); + tmpvar_6.xy = ((gl_MultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + gl_TexCoord[0] = tmpvar_6; + gl_TexCoord[1] = o_i0; + vec4 tmpvar_7; + tmpvar_7.w = 0.0; + tmpvar_7.xyz = tmpvar_1; + gl_TexCoord[2] = tmpvar_7; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Diffuse_Alpha_Shadowed_ZWrite-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Diffuse_Alpha_Shadowed_ZWrite-in.txt new file mode 100644 index 000000000..6af216a7c --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Diffuse_Alpha_Shadowed_ZWrite-in.txt @@ -0,0 +1,107 @@ +mat3 xll_constructMat3( mat4 m) { + return mat3( vec3( m[0]), vec3( m[1]), vec3( m[2])); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 normal; + vec3 vlight; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _MainTex_ST; +uniform mat4 _Object2World; + +uniform vec4 unity_SHAb; +uniform vec4 unity_SHAg; +uniform vec4 unity_SHAr; +uniform vec4 unity_SHBb; +uniform vec4 unity_SHBg; +uniform vec4 unity_SHBr; +uniform vec4 unity_SHC; +uniform vec4 unity_Scale; +vec3 ShadeSH9( in vec4 normal ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +v2f_surf vert_surf( in appdata_full v ); +vec3 ShadeSH9( in vec4 normal ) { + vec3 x1; + vec4 vB; + vec3 x2; + float vC; + vec3 x3; + x1.x = dot( unity_SHAr, normal); + x1.y = dot( unity_SHAg, normal); + x1.z = dot( unity_SHAb, normal); + vB = (normal.xyzz * normal.yzzx ); + x2.x = dot( unity_SHBr, vB); + x2.y = dot( unity_SHBg, vB); + x2.z = dot( unity_SHBb, vB); + vC = ((normal.x * normal.x ) - (normal.y * normal.y )); + x3 = (unity_SHC.xyz * vC); + return ((x1 + x2) + x3); +} +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + vec3 worldN; + vec3 shlight; + PositionFog( v.vertex, o.pos, o.fog); + o.hip_pack0.xy = ((v.texcoord.xy * _MainTex_ST.xy ) + _MainTex_ST.zw ); + worldN = ( xll_constructMat3( _Object2World) * (v.normal * unity_Scale.w ) ); + o.normal = worldN; + shlight = ShadeSH9( vec4( worldN, 1.00000)); + o.vlight = shlight; + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.hip_pack0, 0.0, 0.0); + gl_TexCoord[1] = vec4( xl_retval.normal, 0.0); + gl_TexCoord[2] = vec4( xl_retval.vlight, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Diffuse_Alpha_Shadowed_ZWrite-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Diffuse_Alpha_Shadowed_ZWrite-ir.txt new file mode 100644 index 000000000..af73215dd --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Diffuse_Alpha_Shadowed_ZWrite-ir.txt @@ -0,0 +1,218 @@ +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 normal; + vec3 vlight; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec4 unity_SHC; +uniform vec4 unity_SHBr; +uniform vec4 unity_SHBg; +uniform vec4 unity_SHBb; +uniform vec4 unity_SHAr; +uniform vec4 unity_SHAg; +uniform vec4 unity_SHAb; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +mat3 xll_constructMat3 ( + in mat4 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = m[0].xyz; + vec3 tmpvar_2; + tmpvar_2 = m[1].xyz; + vec3 tmpvar_3; + tmpvar_3 = m[2].xyz; + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +vec3 ShadeSH9 ( + in vec4 normal +) +{ + vec3 x3; + float vC; + vec3 x2; + vec4 vB; + vec3 x1; + float tmpvar_1; + tmpvar_1 = dot (unity_SHAr, normal); + float tmpvar_2; + tmpvar_2 = tmpvar_1; + x1.x = tmpvar_2; + float tmpvar_3; + tmpvar_3 = dot (unity_SHAg, normal); + float tmpvar_4; + tmpvar_4 = tmpvar_3; + x1.y = vec2(tmpvar_4).y; + float tmpvar_5; + tmpvar_5 = dot (unity_SHAb, normal); + float tmpvar_6; + tmpvar_6 = tmpvar_5; + x1.z = vec3(tmpvar_6).z; + vec4 tmpvar_7; + tmpvar_7 = (normal.xyzz * normal.yzzx); + vB = tmpvar_7; + float tmpvar_8; + tmpvar_8 = dot (unity_SHBr, vB); + float tmpvar_9; + tmpvar_9 = tmpvar_8; + x2.x = tmpvar_9; + float tmpvar_10; + tmpvar_10 = dot (unity_SHBg, vB); + float tmpvar_11; + tmpvar_11 = tmpvar_10; + x2.y = vec2(tmpvar_11).y; + float tmpvar_12; + tmpvar_12 = dot (unity_SHBb, vB); + float tmpvar_13; + tmpvar_13 = tmpvar_12; + x2.z = vec3(tmpvar_13).z; + float tmpvar_14; + tmpvar_14 = ((normal.x * normal.x) - (normal.y * normal.y)); + vC = tmpvar_14; + vec3 tmpvar_15; + tmpvar_15 = (unity_SHC.xyz * vC); + x3 = tmpvar_15; + return ((x1 + x2) + x3); +} + +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + vec3 shlight; + vec3 worldN; + v2f_surf o; + PositionFog (v.vertex, o.pos, o.fog); + vec2 tmpvar_1; + tmpvar_1 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + o.hip_pack0 = tmpvar_1.xy.xy; + mat3 tmpvar_2; + tmpvar_2 = (xll_constructMat3 (_Object2World)); + vec3 tmpvar_3; + tmpvar_3 = (tmpvar_2 * (v.normal * unity_Scale.w)); + worldN = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = worldN; + o.normal = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5.w = 1.0; + tmpvar_5.xyz = worldN.xyz; + vec3 tmpvar_6; + tmpvar_6 = ShadeSH9 (tmpvar_5); + vec3 tmpvar_7; + tmpvar_7 = tmpvar_6; + shlight = tmpvar_7; + vec3 tmpvar_8; + tmpvar_8 = shlight; + o.vlight = tmpvar_8; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = xl_retval.fog; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_FOG = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19.zw = vec2(0.0, 0.0); + tmpvar_19.xy = xl_retval.hip_pack0.xy; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[0] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21.w = 0.0; + tmpvar_21.xyz = xl_retval.normal.xyz; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_TexCoord[1] = tmpvar_22; + vec4 tmpvar_23; + tmpvar_23.w = 0.0; + tmpvar_23.xyz = xl_retval.vlight.xyz; + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + gl_TexCoord[2] = tmpvar_24; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Diffuse_Alpha_Shadowed_ZWrite-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Diffuse_Alpha_Shadowed_ZWrite-out.txt new file mode 100644 index 000000000..64d0a3561 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Diffuse_Alpha_Shadowed_ZWrite-out.txt @@ -0,0 +1,53 @@ +varying vec4 xlv_FOG; +uniform vec4 unity_Scale; +uniform vec4 unity_SHC; +uniform vec4 unity_SHBr; +uniform vec4 unity_SHBg; +uniform vec4 unity_SHBb; +uniform vec4 unity_SHAr; +uniform vec4 unity_SHAg; +uniform vec4 unity_SHAb; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * gl_Vertex); + mat3 tmpvar_2; + tmpvar_2[0] = _Object2World[0].xyz; + tmpvar_2[1] = _Object2World[1].xyz; + tmpvar_2[2] = _Object2World[2].xyz; + vec3 tmpvar_3; + tmpvar_3 = (tmpvar_2 * (gl_Normal * unity_Scale.w)); + vec4 tmpvar_4; + tmpvar_4.w = 1.0; + tmpvar_4.xyz = tmpvar_3; + vec3 x2; + vec3 x1; + x1.x = dot (unity_SHAr, tmpvar_4); + x1.y = dot (unity_SHAg, tmpvar_4); + x1.z = dot (unity_SHAb, tmpvar_4); + vec4 tmpvar_5; + tmpvar_5 = (tmpvar_3.xyzz * tmpvar_3.yzzx); + x2.x = dot (unity_SHBr, tmpvar_5); + x2.y = dot (unity_SHBg, tmpvar_5); + x2.z = dot (unity_SHBb, tmpvar_5); + gl_Position = tmpvar_1; + vec4 tmpvar_6; + tmpvar_6.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_6.x = tmpvar_1.z; + xlv_FOG = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7.zw = vec2(0.0, 0.0); + tmpvar_7.xy = ((gl_MultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + gl_TexCoord[0] = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8.w = 0.0; + tmpvar_8.xyz = tmpvar_3; + gl_TexCoord[1] = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9.w = 0.0; + tmpvar_9.xyz = ((x1 + x2) + (unity_SHC.xyz * ((tmpvar_3.x * tmpvar_3.x) - (tmpvar_3.y * tmpvar_3.y)))); + gl_TexCoord[2] = tmpvar_9; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-FX_Glass_Stained_BumpDistort-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-FX_Glass_Stained_BumpDistort-in.txt new file mode 100644 index 000000000..98c25b201 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-FX_Glass_Stained_BumpDistort-in.txt @@ -0,0 +1,55 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct v2f { + vec4 vertex; + vec4 uvgrab; + vec2 uvbump; + vec2 uvmain; +}; +struct appdata_t { + vec4 vertex; + vec2 texcoord; +}; + + + +vec2 MultiplyUV( in mat4 mat, in vec2 inUV ); +v2f vert( in appdata_t v ); +vec2 MultiplyUV( in mat4 mat, in vec2 inUV ) { + vec4 temp; + temp = vec4( inUV.x , inUV.y , 0.000000, 0.000000); + temp = ( mat * temp ); + return temp.xy ; +} +v2f vert( in appdata_t v ) { + v2f o; + float scale = 1.00000; + o.vertex = ( gl_ModelViewProjectionMatrix * v.vertex ); + o.uvgrab.xy = ((vec2( o.vertex.x , (o.vertex.y * scale)) + o.vertex.w ) * 0.500000); + o.uvgrab.zw = o.vertex.zw ; + o.uvbump = MultiplyUV( gl_TextureMatrix[1], v.texcoord); + o.uvmain = MultiplyUV( gl_TextureMatrix[2], v.texcoord); + return o; +} +void main() { + v2f xl_retval; + appdata_t xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.texcoord = vec2( gl_MultiTexCoord0); + xl_retval = vert( xlt_v); + gl_Position = vec4( xl_retval.vertex); + gl_TexCoord[0] = vec4( xl_retval.uvgrab); + gl_TexCoord[1] = vec4( xl_retval.uvbump, 0.0, 0.0); + gl_TexCoord[2] = vec4( xl_retval.uvmain, 0.0, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-FX_Glass_Stained_BumpDistort-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-FX_Glass_Stained_BumpDistort-ir.txt new file mode 100644 index 000000000..2cfb6c4df --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-FX_Glass_Stained_BumpDistort-ir.txt @@ -0,0 +1,106 @@ +struct v2f { + vec4 vertex; + vec4 uvgrab; + vec2 uvbump; + vec2 uvmain; +}; +struct appdata_t { + vec4 vertex; + vec2 texcoord; +}; +vec2 MultiplyUV ( + in mat4 mat, + in vec2 inUV +) +{ + vec4 temp; + vec4 tmpvar_1; + tmpvar_1.zw = vec2(0.0, 0.0); + tmpvar_1.x = inUV.x; + tmpvar_1.y = inUV.y; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + temp = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = (mat * temp); + temp = tmpvar_3; + return temp.xy; +} + +v2f vert ( + in appdata_t v +) +{ + float scale; + v2f o; + float tmpvar_1; + tmpvar_1 = 1.0; + scale = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = (gl_ModelViewProjectionMatrix * v.vertex); + o.vertex = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3.x = o.vertex.x; + tmpvar_3.y = (o.vertex.y * scale); + vec2 tmpvar_4; + tmpvar_4 = ((tmpvar_3 + o.vertex.w) * 0.5); + o.uvgrab.xy = tmpvar_4.xy.xy; + vec2 tmpvar_5; + tmpvar_5 = o.vertex.zw; + o.uvgrab.zw = tmpvar_5.xxxy.zw; + vec2 tmpvar_6; + tmpvar_6 = MultiplyUV (gl_TextureMatrix[1], v.texcoord); + vec2 tmpvar_7; + tmpvar_7 = tmpvar_6; + o.uvbump = tmpvar_7; + vec2 tmpvar_8; + tmpvar_8 = MultiplyUV (gl_TextureMatrix[2], v.texcoord); + vec2 tmpvar_9; + tmpvar_9 = tmpvar_8; + o.uvmain = tmpvar_9; + return o; +} + +void main () +{ + appdata_t xlt_v; + v2f xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = gl_MultiTexCoord0.xy; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.texcoord = tmpvar_4; + v2f tmpvar_5; + tmpvar_5 = vert (xlt_v); + v2f tmpvar_6; + tmpvar_6 = tmpvar_5; + xl_retval = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = xl_retval.vertex.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + gl_Position = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = xl_retval.uvgrab.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + gl_TexCoord[0] = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11.zw = vec2(0.0, 0.0); + tmpvar_11.xy = xl_retval.uvbump.xy; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + gl_TexCoord[1] = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13.zw = vec2(0.0, 0.0); + tmpvar_13.xy = xl_retval.uvmain.xy; + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + gl_TexCoord[2] = tmpvar_14; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-FX_Glass_Stained_BumpDistort-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-FX_Glass_Stained_BumpDistort-out.txt new file mode 100644 index 000000000..c301d9beb --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-FX_Glass_Stained_BumpDistort-out.txt @@ -0,0 +1,27 @@ +void main () +{ + vec4 tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = (gl_ModelViewProjectionMatrix * gl_Vertex); + tmpvar_1.xy = ((tmpvar_2.xy + tmpvar_2.w) * 0.5); + tmpvar_1.zw = tmpvar_2.zw; + vec4 tmpvar_3; + tmpvar_3.zw = vec2(0.0, 0.0); + tmpvar_3.x = gl_MultiTexCoord0.x; + tmpvar_3.y = gl_MultiTexCoord0.y; + vec4 tmpvar_4; + tmpvar_4.zw = vec2(0.0, 0.0); + tmpvar_4.x = gl_MultiTexCoord0.x; + tmpvar_4.y = gl_MultiTexCoord0.y; + gl_Position = tmpvar_2; + gl_TexCoord[0] = tmpvar_1; + vec4 tmpvar_5; + tmpvar_5.zw = vec2(0.0, 0.0); + tmpvar_5.xy = (gl_TextureMatrix[1] * tmpvar_3).xy; + gl_TexCoord[1] = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6.zw = vec2(0.0, 0.0); + tmpvar_6.xy = (gl_TextureMatrix[2] * tmpvar_4).xy; + gl_TexCoord[2] = tmpvar_6; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-FX_Water_(simple)-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-FX_Water_(simple)-in.txt new file mode 100644 index 000000000..ad02d50cd --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-FX_Water_(simple)-in.txt @@ -0,0 +1,64 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct v2f { + vec4 pos; + float fog; + vec2 bumpuv[2]; + vec3 viewDir; +}; +struct appdata { + vec4 vertex; + vec3 normal; +}; +uniform vec4 _WaveOffset; +uniform float _WaveScale; +uniform mat4 _World2Object; +uniform vec3 _WorldSpaceCameraPos; + +uniform vec4 unity_Scale; +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +vec3 ObjSpaceViewDir( in vec4 v ); +v2f vert( in appdata v ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +vec3 ObjSpaceViewDir( in vec4 v ) { + vec3 objSpaceCameraPos; + objSpaceCameraPos = (( _World2Object * vec4( _WorldSpaceCameraPos.xyz , 1.00000) ).xyz * unity_Scale.w ); + return (objSpaceCameraPos - v.xyz ); +} +v2f vert( in appdata v ) { + v2f o; + vec4 temp; + PositionFog( v.vertex, o.pos, o.fog); + temp.xyzw = ((v.vertex.xzxz * _WaveScale) + _WaveOffset); + o.bumpuv[ 0 ] = (temp.xy * vec2( 0.400000, 0.450000)); + o.bumpuv[ 1 ] = temp.wz ; + o.viewDir.xzy = normalize( ObjSpaceViewDir( v.vertex) ); + return o; +} +varying vec4 xlv_FOG; +void main() { + v2f xl_retval; + appdata xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.normal = vec3( gl_Normal); + xl_retval = vert( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.bumpuv[0], 0.0, 0.0); + gl_TexCoord[1] = vec4( xl_retval.bumpuv[1], 0.0, 0.0); + gl_TexCoord[2] = vec4( xl_retval.viewDir, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-FX_Water_(simple)-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-FX_Water_(simple)-ir.txt new file mode 100644 index 000000000..db8edeea9 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-FX_Water_(simple)-ir.txt @@ -0,0 +1,120 @@ +struct v2f { + vec4 pos; + float fog; + vec2 bumpuv[2]; + vec3 viewDir; +}; +struct appdata { + vec4 vertex; + vec3 normal; +}; +varying vec4 xlv_FOG; +uniform vec4 unity_Scale; +uniform vec3 _WorldSpaceCameraPos; +uniform mat4 _World2Object; +uniform float _WaveScale; +uniform vec4 _WaveOffset; +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +vec3 ObjSpaceViewDir ( + in vec4 v +) +{ + vec3 objSpaceCameraPos; + vec4 tmpvar_1; + tmpvar_1.w = 1.0; + tmpvar_1.xyz = _WorldSpaceCameraPos.xyz.xyz; + vec3 tmpvar_2; + tmpvar_2 = ((_World2Object * tmpvar_1).xyz * unity_Scale.w); + objSpaceCameraPos = tmpvar_2; + return (objSpaceCameraPos - v.xyz); +} + +v2f vert ( + in appdata v +) +{ + vec4 temp; + v2f o; + PositionFog (v.vertex, o.pos, o.fog); + vec4 tmpvar_1; + tmpvar_1 = ((v.vertex.xzxz * _WaveScale) + _WaveOffset); + temp = tmpvar_1.xyzw.xyzw; + vec2 tmpvar_2; + tmpvar_2 = (temp.xy * vec2(0.4, 0.45)); + o.bumpuv[0] = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = temp.wz; + o.bumpuv[1] = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = ObjSpaceViewDir (v.vertex); + vec3 tmpvar_5; + tmpvar_5 = normalize (tmpvar_4); + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + o.viewDir = tmpvar_6.xzy.xyz; + return o; +} + +void main () +{ + appdata xlt_v; + v2f xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = gl_Normal.xyz; + vec3 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.normal = tmpvar_4; + v2f tmpvar_5; + tmpvar_5 = vert (xlt_v); + v2f tmpvar_6; + tmpvar_6 = tmpvar_5; + xl_retval = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = xl_retval.pos.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + gl_Position = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_9.x = xl_retval.fog; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlv_FOG = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11.zw = vec2(0.0, 0.0); + tmpvar_11.xy = xl_retval.bumpuv[0].xy; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + gl_TexCoord[0] = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13.zw = vec2(0.0, 0.0); + tmpvar_13.xy = xl_retval.bumpuv[1].xy; + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + gl_TexCoord[1] = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15.w = 0.0; + tmpvar_15.xyz = xl_retval.viewDir.xyz; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_TexCoord[2] = tmpvar_16; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-FX_Water_(simple)-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-FX_Water_(simple)-out.txt new file mode 100644 index 000000000..e7b595ce1 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-FX_Water_(simple)-out.txt @@ -0,0 +1,37 @@ +varying vec4 xlv_FOG; +uniform vec4 unity_Scale; +uniform vec3 _WorldSpaceCameraPos; +uniform mat4 _World2Object; +uniform float _WaveScale; +uniform vec4 _WaveOffset; +void main () +{ + vec4 temp; + vec2 tmpvar_1[2]; + vec4 tmpvar_2; + tmpvar_2 = (gl_ModelViewProjectionMatrix * gl_Vertex); + temp = ((gl_Vertex.xzxz * _WaveScale) + _WaveOffset); + tmpvar_1[0] = (temp.xy * vec2(0.4, 0.45)); + tmpvar_1[1] = temp.wz; + vec4 tmpvar_3; + tmpvar_3.w = 1.0; + tmpvar_3.xyz = _WorldSpaceCameraPos; + gl_Position = tmpvar_2; + vec4 tmpvar_4; + tmpvar_4.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_4.x = tmpvar_2.z; + xlv_FOG = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5.zw = vec2(0.0, 0.0); + tmpvar_5.xy = tmpvar_1[0]; + gl_TexCoord[0] = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6.zw = vec2(0.0, 0.0); + tmpvar_6.xy = tmpvar_1[1]; + gl_TexCoord[1] = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7.w = 0.0; + tmpvar_7.xyz = normalize ((((_World2Object * tmpvar_3).xyz * unity_Scale.w) - gl_Vertex.xyz)).xzy; + gl_TexCoord[2] = tmpvar_7; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Grab_Invert-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Grab_Invert-in.txt new file mode 100644 index 000000000..d0b918440 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Grab_Invert-in.txt @@ -0,0 +1,33 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct v2f { + vec4 vertex; + vec4 uv; +}; + +v2f vert( in vec4 vertex, in vec2 uv ); +v2f vert( in vec4 vertex, in vec2 uv ) { + v2f o; + float scale = 1.00000; + o.vertex = ( gl_ModelViewProjectionMatrix * vertex ); + o.uv.xy = ((vec2( o.vertex.x , (o.vertex.y * scale)) + o.vertex.w ) * 0.500000); + o.uv.zw = o.vertex.zw ; + return o; +} +void main() { + v2f xl_retval; + xl_retval = vert( vec4(gl_Vertex), vec2(gl_MultiTexCoord0)); + gl_Position = vec4( xl_retval.vertex); + gl_TexCoord[0] = vec4( xl_retval.uv); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Grab_Invert-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Grab_Invert-ir.txt new file mode 100644 index 000000000..af38f4e83 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Grab_Invert-ir.txt @@ -0,0 +1,53 @@ +struct v2f { + vec4 vertex; + vec4 uv; +}; +v2f vert ( + in vec4 vertex, + in vec2 uv +) +{ + float scale; + v2f o; + float tmpvar_1; + tmpvar_1 = 1.0; + scale = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = (gl_ModelViewProjectionMatrix * vertex); + o.vertex = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3.x = o.vertex.x; + tmpvar_3.y = (o.vertex.y * scale); + vec2 tmpvar_4; + tmpvar_4 = ((tmpvar_3 + o.vertex.w) * 0.5); + o.uv.xy = tmpvar_4.xy.xy; + vec2 tmpvar_5; + tmpvar_5 = o.vertex.zw; + o.uv.zw = tmpvar_5.xxxy.zw; + return o; +} + +void main () +{ + v2f xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec2 tmpvar_2; + tmpvar_2 = gl_MultiTexCoord0.xy; + v2f tmpvar_3; + tmpvar_3 = vert (tmpvar_1, tmpvar_2); + v2f tmpvar_4; + tmpvar_4 = tmpvar_3; + xl_retval = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = xl_retval.vertex.xyzw; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_5; + gl_Position = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = xl_retval.uv.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + gl_TexCoord[0] = tmpvar_8; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Grab_Invert-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Grab_Invert-out.txt new file mode 100644 index 000000000..454756024 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Grab_Invert-out.txt @@ -0,0 +1,11 @@ +void main () +{ + vec4 tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = (gl_ModelViewProjectionMatrix * gl_Vertex); + tmpvar_1.xy = ((tmpvar_2.xy + tmpvar_2.w) * 0.5); + tmpvar_1.zw = tmpvar_2.zw; + gl_Position = tmpvar_2; + gl_TexCoord[0] = tmpvar_1; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Camera-DepthNormalTexture-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Camera-DepthNormalTexture-in.txt new file mode 100644 index 000000000..1e5fde83a --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Camera-DepthNormalTexture-in.txt @@ -0,0 +1,77 @@ +mat3 xll_constructMat3( mat4 m) { + return mat3( vec3( m[0]), vec3( m[1]), vec3( m[2])); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct v2f { + vec4 pos; + vec2 uv; + vec4 nz; +}; +struct appdata { + vec4 vertex; + vec3 normal; + vec4 color; + vec4 texcoord; +}; +uniform vec4 _ProjectionParams; +uniform vec4 _Scale; +uniform float _SquashAmount; +uniform vec4 _SquashPlaneNormal; +uniform mat4 _TerrainEngineBendTree; + + + +vec4 Squash( in vec4 pos ); +void TerrainAnimateTree( inout vec4 pos, in float alpha ); +v2f vert( in appdata v ); +vec4 Squash( in vec4 pos ) { + vec3 projectedVertex; + vec3 planePoint; + vec3 planeNormal; + projectedVertex = pos.xyz ; + planePoint = vec3( 0.000000, _SquashPlaneNormal.w , 0.000000); + planeNormal = _SquashPlaneNormal.xyz ; + projectedVertex += (dot( planeNormal, (planePoint - vec3( pos))) * planeNormal); + pos = vec4( mix( projectedVertex, pos.xyz , vec3( _SquashAmount)), 1.00000); + return pos; +} +void TerrainAnimateTree( inout vec4 pos, in float alpha ) { + vec3 bent; + pos.xyz *= _Scale.xyz ; + bent = ( _TerrainEngineBendTree * vec4( pos.xyz , 0.000000) ).xyz ; + pos.xyz = mix( pos.xyz , bent, vec3( alpha)); + pos = Squash( pos); +} +v2f vert( in appdata v ) { + v2f o; + TerrainAnimateTree( v.vertex, v.color.w ); + o.pos = ( gl_ModelViewProjectionMatrix * v.vertex ); + o.uv = v.texcoord.xy ; + o.nz.xyz = ( xll_constructMat3( gl_ModelViewMatrixInverseTranspose) * v.normal ); + o.nz.w = ( -(( gl_ModelViewMatrix * v.vertex ).z * _ProjectionParams.w ) ); + return o; +} +void main() { + v2f xl_retval; + appdata xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.normal = vec3( gl_Normal); + xlt_v.color = vec4( gl_Color); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xl_retval = vert( xlt_v); + gl_Position = vec4( xl_retval.pos); + gl_TexCoord[0] = vec4( xl_retval.uv, 0.0, 0.0); + gl_TexCoord[1] = vec4( xl_retval.nz); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Camera-DepthNormalTexture-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Camera-DepthNormalTexture-ir.txt new file mode 100644 index 000000000..150709f47 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Camera-DepthNormalTexture-ir.txt @@ -0,0 +1,177 @@ +struct v2f { + vec4 pos; + vec2 uv; + vec4 nz; +}; +struct appdata { + vec4 vertex; + vec3 normal; + vec4 color; + vec4 texcoord; +}; +uniform mat4 _TerrainEngineBendTree; +uniform vec4 _SquashPlaneNormal; +uniform float _SquashAmount; +uniform vec4 _Scale; +uniform vec4 _ProjectionParams; +mat3 xll_constructMat3 ( + in mat4 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = m[0].xyz; + vec3 tmpvar_2; + tmpvar_2 = m[1].xyz; + vec3 tmpvar_3; + tmpvar_3 = m[2].xyz; + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +vec4 Squash ( + in vec4 pos +) +{ + vec3 planeNormal; + vec3 planePoint; + vec3 projectedVertex; + vec3 tmpvar_1; + tmpvar_1 = pos.xyz; + projectedVertex = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2.xz = vec2(0.0, 0.0); + tmpvar_2.y = _SquashPlaneNormal.w; + vec3 tmpvar_3; + tmpvar_3 = tmpvar_2; + planePoint = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = _SquashPlaneNormal.xyz; + planeNormal = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = pos.xyz; + float tmpvar_6; + tmpvar_6 = dot (planeNormal, (planePoint - tmpvar_5)); + vec3 tmpvar_7; + tmpvar_7 = (projectedVertex + (tmpvar_6 * planeNormal)); + projectedVertex = tmpvar_7; + vec3 tmpvar_8; + tmpvar_8 = vec3(_SquashAmount); + vec3 tmpvar_9; + tmpvar_9 = mix (projectedVertex, pos.xyz, tmpvar_8); + vec4 tmpvar_10; + tmpvar_10.w = 1.0; + tmpvar_10.xyz = tmpvar_9.xyz; + vec4 tmpvar_11; + tmpvar_11 = tmpvar_10; + pos = tmpvar_11; + return pos; +} + +void TerrainAnimateTree ( + inout vec4 pos, + in float alpha +) +{ + vec3 bent; + vec3 tmpvar_1; + tmpvar_1 = (pos.xyz * _Scale.xyz); + pos.xyz = tmpvar_1.xyz.xyz; + vec4 tmpvar_2; + tmpvar_2.w = 0.0; + tmpvar_2.xyz = pos.xyz.xyz; + vec3 tmpvar_3; + tmpvar_3 = (_TerrainEngineBendTree * tmpvar_2).xyz; + bent = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = vec3(alpha); + vec3 tmpvar_5; + tmpvar_5 = mix (pos.xyz, bent, tmpvar_4); + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + pos.xyz = tmpvar_6.xyz.xyz; + vec4 tmpvar_7; + tmpvar_7 = Squash (pos); + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + pos = tmpvar_8; +} + +v2f vert ( + in appdata v +) +{ + v2f o; + TerrainAnimateTree (v.vertex, v.color.w); + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v.vertex); + o.pos = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = v.texcoord.xy; + o.uv = tmpvar_2; + mat3 tmpvar_3; + tmpvar_3 = (xll_constructMat3 (gl_ModelViewMatrixInverseTranspose)); + vec3 tmpvar_4; + tmpvar_4 = (tmpvar_3 * v.normal); + o.nz.xyz = tmpvar_4.xyz.xyz; + float tmpvar_5; + tmpvar_5 = -(((gl_ModelViewMatrix * v.vertex).z * _ProjectionParams.w)); + o.nz.w = vec4(tmpvar_5).w; + return o; +} + +void main () +{ + appdata xlt_v; + v2f xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = gl_Normal.xyz; + vec3 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.normal = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = gl_Color.xyzw; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.color = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + v2f tmpvar_9; + tmpvar_9 = vert (xlt_v); + v2f tmpvar_10; + tmpvar_10 = tmpvar_9; + xl_retval = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = xl_retval.pos.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + gl_Position = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13.zw = vec2(0.0, 0.0); + tmpvar_13.xy = xl_retval.uv.xy; + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + gl_TexCoord[0] = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.nz.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_TexCoord[1] = tmpvar_16; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Camera-DepthNormalTexture-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Camera-DepthNormalTexture-out.txt new file mode 100644 index 000000000..b5a42617b --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Camera-DepthNormalTexture-out.txt @@ -0,0 +1,36 @@ +uniform mat4 _TerrainEngineBendTree; +uniform vec4 _SquashPlaneNormal; +uniform float _SquashAmount; +uniform vec4 _Scale; +uniform vec4 _ProjectionParams; +void main () +{ + vec4 tmpvar_1; + vec4 pos; + pos = gl_Vertex; + pos.xyz = (gl_Vertex.xyz * _Scale.xyz); + vec4 tmpvar_2; + tmpvar_2.w = 0.0; + tmpvar_2.xyz = pos.xyz; + pos.xyz = mix (pos.xyz, (_TerrainEngineBendTree * tmpvar_2).xyz, gl_Color.www); + vec3 tmpvar_3; + tmpvar_3.xz = vec2(0.0, 0.0); + tmpvar_3.y = _SquashPlaneNormal.w; + vec4 tmpvar_4; + tmpvar_4.w = 1.0; + tmpvar_4.xyz = mix ((pos.xyz + (dot (_SquashPlaneNormal.xyz, (tmpvar_3 - pos.xyz)) * _SquashPlaneNormal.xyz)), pos.xyz, vec3(_SquashAmount)); + pos = tmpvar_4; + mat3 tmpvar_5; + tmpvar_5[0] = gl_ModelViewMatrixInverseTranspose[0].xyz; + tmpvar_5[1] = gl_ModelViewMatrixInverseTranspose[1].xyz; + tmpvar_5[2] = gl_ModelViewMatrixInverseTranspose[2].xyz; + tmpvar_1.xyz = (tmpvar_5 * gl_Normal); + tmpvar_1.w = -(((gl_ModelViewMatrix * tmpvar_4).z * _ProjectionParams.w)); + gl_Position = (gl_ModelViewProjectionMatrix * tmpvar_4); + vec4 tmpvar_6; + tmpvar_6.zw = vec2(0.0, 0.0); + tmpvar_6.xy = gl_MultiTexCoord0.xy; + gl_TexCoord[0] = tmpvar_6; + gl_TexCoord[1] = tmpvar_1; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Camera-DepthNormalTexture1-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Camera-DepthNormalTexture1-in.txt new file mode 100644 index 000000000..9d0ab80c4 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Camera-DepthNormalTexture1-in.txt @@ -0,0 +1,111 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct v2f { + vec4 pos; + vec2 uv; + vec4 nz; +}; +struct appdata_grass { + vec4 vertex; + vec4 tangent; + vec4 color; + vec4 texcoord; + vec4 texcoord1; +}; +uniform vec4 _ProjectionParams; +uniform vec4 _WaveAndDistance; +uniform vec4 _WavingTint; + + +void FastSinCos( in vec4 val, out vec4 s, out vec4 c ); +void TerrainWaveGrass( inout vec4 vertex, in float waveAmount, in vec3 color, out vec4 outColor ); +v2f vert( in appdata_grass v ); +void FastSinCos( in vec4 val, out vec4 s, out vec4 c ) { + vec4 r5; + vec4 r6; + vec4 r7; + vec4 r8; + vec4 r1; + vec4 r2; + vec4 r3; + vec4 sin7 = vec4( 1.00000, -0.161616, 0.00833330, -0.000198410); + vec4 cos8 = vec4( -0.500000, 0.0416667, -0.00138889, 2.48016e-005); + val = ((val * 6.40885) - 3.14159); + r5 = (val * val); + r6 = (r5 * r5); + r7 = (r6 * r5); + r8 = (r6 * r5); + r1 = (r5 * val); + r2 = (r1 * r5); + r3 = (r2 * r5); + s = (((val + (r1 * sin7.y )) + (r2 * sin7.z )) + (r3 * sin7.w )); + c = ((((1.00000 + (r5 * cos8.x )) + (r6 * cos8.y )) + (r7 * cos8.z )) + (r8 * cos8.w )); +} +void TerrainWaveGrass( inout vec4 vertex, in float waveAmount, in vec3 color, out vec4 outColor ) { + vec4 _waveXSize; + vec4 _waveZSize; + vec4 waveSpeed = vec4( 1.20000, 2.00000, 1.60000, 4.80000); + vec4 _waveXmove = vec4( 0.0240000, 0.0400000, -0.120000, 0.0960000); + vec4 _waveZmove = vec4( 0.00600000, 0.0200000, -0.0200000, 0.100000); + vec4 waves; + vec4 s; + vec4 c; + float lighting; + vec3 waveMove = vec3( 0.000000, 0.000000, 0.000000); + vec3 waveColor; + _waveXSize = (vec4( 0.0120000, 0.0200000, 0.0600000, 0.0240000) * _WaveAndDistance.y ); + _waveZSize = (vec4( 0.00600000, 0.0200000, 0.0200000, 0.0500000) * _WaveAndDistance.y ); + waves = (vertex.x * _waveXSize); + waves += (vertex.z * _waveZSize); + waves += (_WaveAndDistance.x * waveSpeed); + waves = fract( waves ); + FastSinCos( waves, s, c); + s = (s * s); + s = (s * s); + lighting = (dot( s, normalize( vec4( 1.00000, 1.00000, 0.400000, 0.200000) )) * 0.700000); + s = (s * waveAmount); + waveMove.x = dot( s, _waveXmove); + waveMove.z = dot( s, _waveZmove); + vertex.xz -= (waveMove.xz * _WaveAndDistance.z ); + waveColor = mix( vec3( 0.500000, 0.500000, 0.500000), _WavingTint.xyz , vec3( lighting)); + outColor.xyz = ((color * waveColor) * 2.00000); + outColor.w = 1.00000; +} +v2f vert( in appdata_grass v ) { + float waveAmount; + vec4 dummyColor; + v2f o; + waveAmount = (v.color.w * _WaveAndDistance.z ); + dummyColor = vec4( 0.000000); + TerrainWaveGrass( v.vertex, waveAmount, vec3( dummyColor), dummyColor); + o.pos = ( gl_ModelViewProjectionMatrix * v.vertex ); + o.uv = vec2( v.texcoord); + o.nz.xyz = vec3( 0.000000, 0.000000, 1.00000); + o.nz.w = ( -(( gl_ModelViewMatrix * v.vertex ).z * _ProjectionParams.w ) ); + return o; +} +attribute vec4 TANGENT; +void main() { + v2f xl_retval; + appdata_grass xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.color = vec4( gl_Color); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xl_retval = vert( xlt_v); + gl_Position = vec4( xl_retval.pos); + gl_TexCoord[0] = vec4( xl_retval.uv, 0.0, 0.0); + gl_TexCoord[1] = vec4( xl_retval.nz); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Camera-DepthNormalTexture1-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Camera-DepthNormalTexture1-ir.txt new file mode 100644 index 000000000..8f62b0648 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Camera-DepthNormalTexture1-ir.txt @@ -0,0 +1,249 @@ +struct v2f { + vec4 pos; + vec2 uv; + vec4 nz; +}; +struct appdata_grass { + vec4 vertex; + vec4 tangent; + vec4 color; + vec4 texcoord; + vec4 texcoord1; +}; +attribute vec4 TANGENT; +uniform vec4 _WavingTint; +uniform vec4 _WaveAndDistance; +uniform vec4 _ProjectionParams; +void FastSinCos ( + in vec4 val, + out vec4 s, + out vec4 c +) +{ + vec4 cos8; + vec4 sin7; + vec4 r3; + vec4 r2; + vec4 r1; + vec4 r8; + vec4 r7; + vec4 r6; + vec4 r5; + vec4 tmpvar_1; + tmpvar_1 = vec4(1.0, -0.161616, 0.0083333, -0.00019841); + sin7 = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = vec4(-0.5, 0.0416667, -0.00138889, 2.48016e-05); + cos8 = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = ((val * 6.40885) - 3.14159); + val = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = (val * val); + r5 = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = (r5 * r5); + r6 = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = (r6 * r5); + r7 = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = (r6 * r5); + r8 = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = (r5 * val); + r1 = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = (r1 * r5); + r2 = tmpvar_9; + vec4 tmpvar_10; + tmpvar_10 = (r2 * r5); + r3 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = (((val + (r1 * sin7.y)) + (r2 * sin7.z)) + (r3 * sin7.w)); + s = tmpvar_11; + vec4 tmpvar_12; + tmpvar_12 = ((((1.0 + (r5 * cos8.x)) + (r6 * cos8.y)) + (r7 * cos8.z)) + (r8 * cos8.w)); + c = tmpvar_12; +} + +void TerrainWaveGrass ( + inout vec4 vertex, + in float waveAmount, + in vec3 color, + out vec4 outColor +) +{ + vec3 waveColor; + vec3 waveMove; + float lighting; + vec4 c; + vec4 s; + vec4 waves; + vec4 _waveZmove; + vec4 _waveXmove; + vec4 waveSpeed; + vec4 _waveZSize; + vec4 _waveXSize; + vec4 tmpvar_1; + tmpvar_1 = vec4(1.2, 2.0, 1.6, 4.8); + waveSpeed = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = vec4(0.024, 0.04, -0.12, 0.096); + _waveXmove = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = vec4(0.006, 0.02, -0.02, 0.1); + _waveZmove = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = vec3(0.0, 0.0, 0.0); + waveMove = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = (vec4(0.012, 0.02, 0.06, 0.024) * _WaveAndDistance.y); + _waveXSize = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = (vec4(0.006, 0.02, 0.02, 0.05) * _WaveAndDistance.y); + _waveZSize = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = (vertex.x * _waveXSize); + waves = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = (waves + (vertex.z * _waveZSize)); + waves = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = (waves + (_WaveAndDistance.x * waveSpeed)); + waves = tmpvar_9; + vec4 tmpvar_10; + tmpvar_10 = fract (waves); + vec4 tmpvar_11; + tmpvar_11 = tmpvar_10; + waves = tmpvar_11; + FastSinCos (waves, s, c); + vec4 tmpvar_12; + tmpvar_12 = (s * s); + s = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = (s * s); + s = tmpvar_13; + vec4 tmpvar_14; + tmpvar_14 = normalize (vec4(1.0, 1.0, 0.4, 0.2)); + float tmpvar_15; + tmpvar_15 = dot (s, tmpvar_14); + float tmpvar_16; + tmpvar_16 = (tmpvar_15 * 0.7); + lighting = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17 = (s * waveAmount); + s = tmpvar_17; + float tmpvar_18; + tmpvar_18 = dot (s, _waveXmove); + float tmpvar_19; + tmpvar_19 = tmpvar_18; + waveMove.x = tmpvar_19; + float tmpvar_20; + tmpvar_20 = dot (s, _waveZmove); + float tmpvar_21; + tmpvar_21 = tmpvar_20; + waveMove.z = vec3(tmpvar_21).z; + vec2 tmpvar_22; + tmpvar_22 = (vertex.xz - (waveMove.xz * _WaveAndDistance.z)); + vertex.xz = tmpvar_22.xxy.xz; + vec3 tmpvar_23; + tmpvar_23 = vec3(lighting); + vec3 tmpvar_24; + tmpvar_24 = mix (vec3(0.5, 0.5, 0.5), _WavingTint.xyz, tmpvar_23); + vec3 tmpvar_25; + tmpvar_25 = tmpvar_24; + waveColor = tmpvar_25; + vec3 tmpvar_26; + tmpvar_26 = ((color * waveColor) * 2.0); + outColor.xyz = tmpvar_26.xyz.xyz; + float tmpvar_27; + tmpvar_27 = 1.0; + outColor.w = vec4(tmpvar_27).w; +} + +v2f vert ( + in appdata_grass v +) +{ + v2f o; + vec4 dummyColor; + float waveAmount; + float tmpvar_1; + tmpvar_1 = (v.color.w * _WaveAndDistance.z); + waveAmount = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = vec4(0.0, 0.0, 0.0, 0.0); + dummyColor = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = dummyColor.xyz; + TerrainWaveGrass (v.vertex, waveAmount, tmpvar_3, dummyColor); + vec4 tmpvar_4; + tmpvar_4 = (gl_ModelViewProjectionMatrix * v.vertex); + o.pos = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5 = v.texcoord.xy; + vec2 tmpvar_6; + tmpvar_6 = tmpvar_5; + o.uv = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = vec3(0.0, 0.0, 1.0); + o.nz.xyz = tmpvar_7.xyz.xyz; + float tmpvar_8; + tmpvar_8 = -(((gl_ModelViewMatrix * v.vertex).z * _ProjectionParams.w)); + o.nz.w = vec4(tmpvar_8).w; + return o; +} + +void main () +{ + appdata_grass xlt_v; + v2f xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = gl_Color.xyzw; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.color = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + v2f tmpvar_11; + tmpvar_11 = vert (xlt_v); + v2f tmpvar_12; + tmpvar_12 = tmpvar_11; + xl_retval = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = xl_retval.pos.xyzw; + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + gl_Position = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15.zw = vec2(0.0, 0.0); + tmpvar_15.xy = xl_retval.uv.xy; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_TexCoord[0] = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17 = xl_retval.nz.xyzw; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + gl_TexCoord[1] = tmpvar_18; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Camera-DepthNormalTexture1-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Camera-DepthNormalTexture1-out.txt new file mode 100644 index 000000000..7ecd879e9 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Camera-DepthNormalTexture1-out.txt @@ -0,0 +1,36 @@ +uniform vec4 _WaveAndDistance; +uniform vec4 _ProjectionParams; +void main () +{ + vec4 tmpvar_1; + vec4 vertex; + vertex = gl_Vertex; + vec3 waveMove; + waveMove = vec3(0.0, 0.0, 0.0); + vec4 tmpvar_2; + tmpvar_2 = ((fract ((((gl_Vertex.x * (vec4(0.012, 0.02, 0.06, 0.024) * _WaveAndDistance.y)) + (gl_Vertex.z * (vec4(0.006, 0.02, 0.02, 0.05) * _WaveAndDistance.y))) + (_WaveAndDistance.x * vec4(1.2, 2.0, 1.6, 4.8)))) * 6.40885) - 3.14159); + vec4 tmpvar_3; + tmpvar_3 = (tmpvar_2 * tmpvar_2); + vec4 tmpvar_4; + tmpvar_4 = (tmpvar_3 * tmpvar_2); + vec4 tmpvar_5; + tmpvar_5 = (tmpvar_4 * tmpvar_3); + vec4 tmpvar_6; + tmpvar_6 = (((tmpvar_2 + (tmpvar_4 * -0.161616)) + (tmpvar_5 * 0.0083333)) + ((tmpvar_5 * tmpvar_3) * -0.00019841)); + vec4 tmpvar_7; + tmpvar_7 = (tmpvar_6 * tmpvar_6); + vec4 tmpvar_8; + tmpvar_8 = ((tmpvar_7 * tmpvar_7) * (gl_Color.w * _WaveAndDistance.z)); + waveMove.x = dot (tmpvar_8, vec4(0.024, 0.04, -0.12, 0.096)); + waveMove.z = dot (tmpvar_8, vec4(0.006, 0.02, -0.02, 0.1)); + vertex.xz = (gl_Vertex.xz - (waveMove.xz * _WaveAndDistance.z)); + tmpvar_1.xyz = vec3(0.0, 0.0, 1.0); + tmpvar_1.w = -(((gl_ModelViewMatrix * vertex).z * _ProjectionParams.w)); + gl_Position = (gl_ModelViewProjectionMatrix * vertex); + vec4 tmpvar_9; + tmpvar_9.zw = vec2(0.0, 0.0); + tmpvar_9.xy = gl_MultiTexCoord0.xy; + gl_TexCoord[0] = tmpvar_9; + gl_TexCoord[1] = tmpvar_1; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Camera-DepthTexture-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Camera-DepthTexture-in.txt new file mode 100644 index 000000000..2c925ea97 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Camera-DepthTexture-in.txt @@ -0,0 +1,71 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct v2f { + vec4 pos; + vec2 uv; +}; +struct appdata_tree_billboard { + vec4 vertex; + vec4 color; + vec4 texcoord; + vec2 texcoord1; +}; +uniform vec4 _TreeBillboardCameraFront; +uniform vec4 _TreeBillboardCameraPos; +uniform vec3 _TreeBillboardCameraRight; +uniform vec4 _TreeBillboardCameraUp; +uniform vec4 _TreeBillboardDistances; + +void TerrainBillboardTree( inout vec4 pos, in vec2 offset, in float offsetz ); +v2f vert( in appdata_tree_billboard v ); +void TerrainBillboardTree( inout vec4 pos, in vec2 offset, in float offsetz ) { + vec3 treePos; + float treeDistanceSqr; + float billboardAngleFactor; + float radius; + float billboardModeFactor; + float billboardRootOffsetFactor; + float absRadius; + treePos = (pos.xyz - _TreeBillboardCameraPos.xyz ); + treeDistanceSqr = dot( treePos, treePos); + if ( (treeDistanceSqr > _TreeBillboardDistances.x ) ){ + offset.xy = vec2( 0.000000); + } + pos.xyz += (_TreeBillboardCameraRight.xyz * offset.x ); + billboardAngleFactor = _TreeBillboardCameraPos.w ; + radius = mix( offset.y , offsetz, billboardAngleFactor); + billboardModeFactor = _TreeBillboardCameraUp.w ; + billboardRootOffsetFactor = _TreeBillboardCameraFront.w ; + absRadius = abs( radius ); + pos.xyz += mix( ((((_TreeBillboardCameraUp.xyz * max( 0.000000, radius)) * 2.00000) - (vec3( 0.000000, 1.00000, 0.000000) * absRadius)) - ((_TreeBillboardCameraUp.xyz * absRadius) * billboardRootOffsetFactor)), (_TreeBillboardCameraUp.xyz * radius), vec3( billboardModeFactor)); +} +v2f vert( in appdata_tree_billboard v ) { + v2f o; + TerrainBillboardTree( v.vertex, v.texcoord1.xy , v.texcoord.y ); + o.pos = ( gl_ModelViewProjectionMatrix * v.vertex ); + o.uv.x = v.texcoord.x ; + o.uv.y = float( (v.texcoord.y > 0.000000) ); + return o; +} +void main() { + v2f xl_retval; + appdata_tree_billboard xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.color = vec4( gl_Color); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec2( gl_MultiTexCoord1); + xl_retval = vert( xlt_v); + gl_Position = vec4( xl_retval.pos); + gl_TexCoord[0] = vec4( xl_retval.uv, 0.0, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Camera-DepthTexture-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Camera-DepthTexture-ir.txt new file mode 100644 index 000000000..6026ddbe4 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Camera-DepthTexture-ir.txt @@ -0,0 +1,134 @@ +struct v2f { + vec4 pos; + vec2 uv; +}; +struct appdata_tree_billboard { + vec4 vertex; + vec4 color; + vec4 texcoord; + vec2 texcoord1; +}; +uniform vec4 _TreeBillboardDistances; +uniform vec4 _TreeBillboardCameraUp; +uniform vec3 _TreeBillboardCameraRight; +uniform vec4 _TreeBillboardCameraPos; +uniform vec4 _TreeBillboardCameraFront; +void TerrainBillboardTree ( + inout vec4 pos, + in vec2 offset, + in float offsetz +) +{ + float absRadius; + float billboardRootOffsetFactor; + float billboardModeFactor; + float radius; + float billboardAngleFactor; + float treeDistanceSqr; + vec3 treePos; + vec3 tmpvar_1; + tmpvar_1 = (pos.xyz - _TreeBillboardCameraPos.xyz); + treePos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = dot (treePos, treePos); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + treeDistanceSqr = tmpvar_3; + if ((treeDistanceSqr > _TreeBillboardDistances.x)) { + vec2 tmpvar_4; + tmpvar_4 = vec2(0.0, 0.0); + offset = tmpvar_4.xy.xy; + }; + vec3 tmpvar_5; + tmpvar_5 = (pos.xyz + (_TreeBillboardCameraRight.xyz * offset.x)); + pos.xyz = tmpvar_5.xyz.xyz; + float tmpvar_6; + tmpvar_6 = _TreeBillboardCameraPos.w; + billboardAngleFactor = tmpvar_6; + float tmpvar_7; + tmpvar_7 = mix (offset.y, offsetz, billboardAngleFactor); + float tmpvar_8; + tmpvar_8 = tmpvar_7; + radius = tmpvar_8; + float tmpvar_9; + tmpvar_9 = _TreeBillboardCameraUp.w; + billboardModeFactor = tmpvar_9; + float tmpvar_10; + tmpvar_10 = _TreeBillboardCameraFront.w; + billboardRootOffsetFactor = tmpvar_10; + float tmpvar_11; + tmpvar_11 = abs (radius); + float tmpvar_12; + tmpvar_12 = tmpvar_11; + absRadius = tmpvar_12; + float tmpvar_13; + tmpvar_13 = max (0.0, radius); + vec3 tmpvar_14; + tmpvar_14 = vec3(billboardModeFactor); + vec3 tmpvar_15; + tmpvar_15 = mix (((((_TreeBillboardCameraUp.xyz * tmpvar_13) * 2.0) - (vec3(0.0, 1.0, 0.0) * absRadius)) - ((_TreeBillboardCameraUp.xyz * absRadius) * billboardRootOffsetFactor)), (_TreeBillboardCameraUp.xyz * radius), tmpvar_14); + vec3 tmpvar_16; + tmpvar_16 = (pos.xyz + tmpvar_15); + pos.xyz = tmpvar_16.xyz.xyz; +} + +v2f vert ( + in appdata_tree_billboard v +) +{ + v2f o; + TerrainBillboardTree (v.vertex, v.texcoord1.xy, v.texcoord.y); + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v.vertex); + o.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = v.texcoord.x; + o.uv.x = tmpvar_2; + float tmpvar_3; + tmpvar_3 = float((v.texcoord.y > 0.0)); + o.uv.y = vec2(tmpvar_3).y; + return o; +} + +void main () +{ + appdata_tree_billboard xlt_v; + v2f xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = gl_Color.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.color = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.texcoord = tmpvar_6; + vec2 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord1.xy; + vec2 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord1 = tmpvar_8; + v2f tmpvar_9; + tmpvar_9 = vert (xlt_v); + v2f tmpvar_10; + tmpvar_10 = tmpvar_9; + xl_retval = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = xl_retval.pos.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + gl_Position = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13.zw = vec2(0.0, 0.0); + tmpvar_13.xy = xl_retval.uv.xy; + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + gl_TexCoord[0] = tmpvar_14; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Camera-DepthTexture-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Camera-DepthTexture-out.txt new file mode 100644 index 000000000..968ae2119 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Camera-DepthTexture-out.txt @@ -0,0 +1,36 @@ +uniform vec4 _TreeBillboardDistances; +uniform vec4 _TreeBillboardCameraUp; +uniform vec3 _TreeBillboardCameraRight; +uniform vec4 _TreeBillboardCameraPos; +uniform vec4 _TreeBillboardCameraFront; +void main () +{ + vec2 tmpvar_1; + vec4 pos; + pos = gl_Vertex; + vec2 offset; + offset = gl_MultiTexCoord1.xy; + float offsetz; + offsetz = gl_MultiTexCoord0.y; + vec3 tmpvar_2; + tmpvar_2 = (gl_Vertex.xyz - _TreeBillboardCameraPos.xyz); + float tmpvar_3; + tmpvar_3 = dot (tmpvar_2, tmpvar_2); + if ((tmpvar_3 > _TreeBillboardDistances.x)) { + offset = vec2(0.0, 0.0); + }; + pos.xyz = (gl_Vertex.xyz + (_TreeBillboardCameraRight * offset.x)); + float tmpvar_4; + tmpvar_4 = mix (offset.y, offsetz, _TreeBillboardCameraPos.w); + float tmpvar_5; + tmpvar_5 = abs (tmpvar_4); + pos.xyz = (pos.xyz + mix (((((_TreeBillboardCameraUp.xyz * max (0.0, tmpvar_4)) * 2.0) - (vec3(0.0, 1.0, 0.0) * tmpvar_5)) - ((_TreeBillboardCameraUp.xyz * tmpvar_5) * _TreeBillboardCameraFront.w)), (_TreeBillboardCameraUp.xyz * tmpvar_4), _TreeBillboardCameraUp.www)); + tmpvar_1.x = gl_MultiTexCoord0.x; + tmpvar_1.y = float((gl_MultiTexCoord0.y > 0.0)); + gl_Position = (gl_ModelViewProjectionMatrix * pos); + vec4 tmpvar_6; + tmpvar_6.zw = vec2(0.0, 0.0); + tmpvar_6.xy = tmpvar_1; + gl_TexCoord[0] = tmpvar_6; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Glow_Downsample-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Glow_Downsample-in.txt new file mode 100644 index 000000000..fea2be053 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Glow_Downsample-in.txt @@ -0,0 +1,56 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct v2f { + vec4 pos; + vec4 uv[4]; +}; +uniform vec4 _MainTex_TexelSize; + + +vec2 MultiplyUV( in mat4 mat, in vec2 inUV ); +v2f vert( in appdata_img v ); +vec2 MultiplyUV( in mat4 mat, in vec2 inUV ) { + vec4 temp; + temp = vec4( inUV.x , inUV.y , 0.000000, 0.000000); + temp = ( mat * temp ); + return temp.xy ; +} +v2f vert( in appdata_img v ) { + v2f o; + vec4 uv; + float offX; + float offY; + o.pos = ( gl_ModelViewProjectionMatrix * v.vertex ); + uv.xy = MultiplyUV( gl_TextureMatrix[0], v.texcoord); + uv.zw = vec2( 0.000000); + offX = _MainTex_TexelSize.x ; + offY = _MainTex_TexelSize.y ; + o.uv[ 0 ] = (uv + vec4( ( -offX ), ( -offY ), 0.000000, 1.00000)); + o.uv[ 1 ] = (uv + vec4( offX, ( -offY ), 0.000000, 1.00000)); + o.uv[ 2 ] = (uv + vec4( offX, offY, 0.000000, 1.00000)); + o.uv[ 3 ] = (uv + vec4( ( -offX ), offY, 0.000000, 1.00000)); + return o; +} +void main() { + v2f xl_retval; + appdata_img xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.texcoord = vec2( gl_MultiTexCoord0); + xl_retval = vert( xlt_v); + gl_Position = vec4( xl_retval.pos); + gl_TexCoord[0] = vec4( xl_retval.uv[0]); + gl_TexCoord[1] = vec4( xl_retval.uv[1]); + gl_TexCoord[2] = vec4( xl_retval.uv[2]); + gl_TexCoord[3] = vec4( xl_retval.uv[3]); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Glow_Downsample-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Glow_Downsample-ir.txt new file mode 100644 index 000000000..ede5989e1 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Glow_Downsample-ir.txt @@ -0,0 +1,130 @@ +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct v2f { + vec4 pos; + vec4 uv[4]; +}; +uniform vec4 _MainTex_TexelSize; +vec2 MultiplyUV ( + in mat4 mat, + in vec2 inUV +) +{ + vec4 temp; + vec4 tmpvar_1; + tmpvar_1.zw = vec2(0.0, 0.0); + tmpvar_1.x = inUV.x; + tmpvar_1.y = inUV.y; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + temp = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = (mat * temp); + temp = tmpvar_3; + return temp.xy; +} + +v2f vert ( + in appdata_img v +) +{ + float offY; + float offX; + vec4 uv; + v2f o; + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v.vertex); + o.pos = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = MultiplyUV (gl_TextureMatrix[0], v.texcoord); + vec2 tmpvar_3; + tmpvar_3 = tmpvar_2; + uv.xy = tmpvar_3.xy.xy; + vec2 tmpvar_4; + tmpvar_4 = vec2(0.0, 0.0); + uv.zw = tmpvar_4.xxxy.zw; + float tmpvar_5; + tmpvar_5 = _MainTex_TexelSize.x; + offX = tmpvar_5; + float tmpvar_6; + tmpvar_6 = _MainTex_TexelSize.y; + offY = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7.zw = vec2(0.0, 1.0); + tmpvar_7.x = -(offX); + tmpvar_7.y = -(offY); + vec4 tmpvar_8; + tmpvar_8 = (uv + tmpvar_7); + o.uv[0] = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9.zw = vec2(0.0, 1.0); + tmpvar_9.x = offX; + tmpvar_9.y = -(offY); + vec4 tmpvar_10; + tmpvar_10 = (uv + tmpvar_9); + o.uv[1] = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11.zw = vec2(0.0, 1.0); + tmpvar_11.x = offX; + tmpvar_11.y = offY; + vec4 tmpvar_12; + tmpvar_12 = (uv + tmpvar_11); + o.uv[2] = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13.zw = vec2(0.0, 1.0); + tmpvar_13.x = -(offX); + tmpvar_13.y = offY; + vec4 tmpvar_14; + tmpvar_14 = (uv + tmpvar_13); + o.uv[3] = tmpvar_14; + return o; +} + +void main () +{ + appdata_img xlt_v; + v2f xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = gl_MultiTexCoord0.xy; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.texcoord = tmpvar_4; + v2f tmpvar_5; + tmpvar_5 = vert (xlt_v); + v2f tmpvar_6; + tmpvar_6 = tmpvar_5; + xl_retval = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = xl_retval.pos.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + gl_Position = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = xl_retval.uv[0].xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + gl_TexCoord[0] = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = xl_retval.uv[1].xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + gl_TexCoord[1] = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = xl_retval.uv[2].xyzw; + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + gl_TexCoord[2] = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.uv[3].xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_TexCoord[3] = tmpvar_16; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Glow_Downsample-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Glow_Downsample-out.txt new file mode 100644 index 000000000..ef6485186 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Glow_Downsample-out.txt @@ -0,0 +1,38 @@ +uniform vec4 _MainTex_TexelSize; +void main () +{ + vec4 uv; + vec4 tmpvar_1[4]; + vec4 tmpvar_2; + tmpvar_2.zw = vec2(0.0, 0.0); + tmpvar_2.x = gl_MultiTexCoord0.x; + tmpvar_2.y = gl_MultiTexCoord0.y; + uv.xy = (gl_TextureMatrix[0] * tmpvar_2).xy; + uv.zw = vec2(0.0, 0.0); + vec4 tmpvar_3; + tmpvar_3.zw = vec2(0.0, 1.0); + tmpvar_3.x = -(_MainTex_TexelSize.x); + tmpvar_3.y = -(_MainTex_TexelSize.y); + tmpvar_1[0] = (uv + tmpvar_3); + vec4 tmpvar_4; + tmpvar_4.zw = vec2(0.0, 1.0); + tmpvar_4.x = _MainTex_TexelSize.x; + tmpvar_4.y = -(_MainTex_TexelSize.y); + tmpvar_1[1] = (uv + tmpvar_4); + vec4 tmpvar_5; + tmpvar_5.zw = vec2(0.0, 1.0); + tmpvar_5.x = _MainTex_TexelSize.x; + tmpvar_5.y = _MainTex_TexelSize.y; + tmpvar_1[2] = (uv + tmpvar_5); + vec4 tmpvar_6; + tmpvar_6.zw = vec2(0.0, 1.0); + tmpvar_6.x = -(_MainTex_TexelSize.x); + tmpvar_6.y = _MainTex_TexelSize.y; + tmpvar_1[3] = (uv + tmpvar_6); + gl_Position = (gl_ModelViewProjectionMatrix * gl_Vertex); + gl_TexCoord[0] = tmpvar_1[0]; + gl_TexCoord[1] = tmpvar_1[1]; + gl_TexCoord[2] = tmpvar_1[2]; + gl_TexCoord[3] = tmpvar_1[3]; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Internal-GUITextureClip-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Internal-GUITextureClip-in.txt new file mode 100644 index 000000000..fbf095416 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Internal-GUITextureClip-in.txt @@ -0,0 +1,51 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct v2f { + vec4 vertex; + vec4 color; + vec2 texcoord; + vec2 texgencoord; +}; +struct appdata_t { + vec4 vertex; + vec4 color; + vec2 texcoord; +}; +uniform mat4 _GUIClipTextureMatrix; +uniform vec4 _MainTex_ST; + + +v2f vert( in appdata_t v ); +v2f vert( in appdata_t v ) { + v2f o; + vec4 texgen; + o.vertex = ( gl_ModelViewProjectionMatrix * v.vertex ); + texgen = ( gl_ModelViewMatrix * v.vertex ); + o.texgencoord = vec2( ( _GUIClipTextureMatrix * texgen )); + o.color = v.color; + o.texcoord = ((v.texcoord.xy * _MainTex_ST.xy ) + _MainTex_ST.zw ); + return o; +} +void main() { + v2f xl_retval; + appdata_t xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.color = vec4( gl_Color); + xlt_v.texcoord = vec2( gl_MultiTexCoord0); + xl_retval = vert( xlt_v); + gl_Position = vec4( xl_retval.vertex); + gl_FrontColor = vec4( xl_retval.color); + gl_TexCoord[0] = vec4( xl_retval.texcoord, 0.0, 0.0); + gl_TexCoord[1] = vec4( xl_retval.texgencoord, 0.0, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Internal-GUITextureClip-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Internal-GUITextureClip-ir.txt new file mode 100644 index 000000000..86b83f28a --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Internal-GUITextureClip-ir.txt @@ -0,0 +1,87 @@ +struct v2f { + vec4 vertex; + vec4 color; + vec2 texcoord; + vec2 texgencoord; +}; +struct appdata_t { + vec4 vertex; + vec4 color; + vec2 texcoord; +}; +uniform vec4 _MainTex_ST; +uniform mat4 _GUIClipTextureMatrix; +v2f vert ( + in appdata_t v +) +{ + vec4 texgen; + v2f o; + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v.vertex); + o.vertex = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = (gl_ModelViewMatrix * v.vertex); + texgen = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = (_GUIClipTextureMatrix * texgen).xy; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + o.texgencoord = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = v.color; + o.color = tmpvar_5; + vec2 tmpvar_6; + tmpvar_6 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + o.texcoord = tmpvar_6; + return o; +} + +void main () +{ + appdata_t xlt_v; + v2f xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = gl_Color.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.color = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5 = gl_MultiTexCoord0.xy; + vec2 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.texcoord = tmpvar_6; + v2f tmpvar_7; + tmpvar_7 = vert (xlt_v); + v2f tmpvar_8; + tmpvar_8 = tmpvar_7; + xl_retval = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = xl_retval.vertex.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + gl_Position = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = xl_retval.color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + gl_FrontColor = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13.zw = vec2(0.0, 0.0); + tmpvar_13.xy = xl_retval.texcoord.xy; + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + gl_TexCoord[0] = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15.zw = vec2(0.0, 0.0); + tmpvar_15.xy = xl_retval.texgencoord.xy; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_TexCoord[1] = tmpvar_16; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Internal-GUITextureClip-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Internal-GUITextureClip-out.txt new file mode 100644 index 000000000..53f49cecc --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Internal-GUITextureClip-out.txt @@ -0,0 +1,16 @@ +uniform vec4 _MainTex_ST; +uniform mat4 _GUIClipTextureMatrix; +void main () +{ + gl_Position = (gl_ModelViewProjectionMatrix * gl_Vertex); + gl_FrontColor = gl_Color; + vec4 tmpvar_1; + tmpvar_1.zw = vec2(0.0, 0.0); + tmpvar_1.xy = ((gl_MultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + gl_TexCoord[0] = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2.zw = vec2(0.0, 0.0); + tmpvar_2.xy = (_GUIClipTextureMatrix * (gl_ModelViewMatrix * gl_Vertex)).xy; + gl_TexCoord[1] = tmpvar_2; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Internal-PrePassLighting-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Internal-PrePassLighting-in.txt new file mode 100644 index 000000000..e863a2410 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Internal-PrePassLighting-in.txt @@ -0,0 +1,52 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct v2f { + vec4 pos; + vec4 uv; + vec3 ray; +}; +struct appdata { + vec4 vertex; + vec3 texcoord; +}; +uniform vec4 _ProjectionParams; + + +vec4 ComputeScreenPos( in vec4 pos ); +v2f vert( in appdata v ); +vec4 ComputeScreenPos( in vec4 pos ) { + vec4 o; + o = (pos * 0.500000); + o.xy = (vec2( o.x , (o.y * _ProjectionParams.x )) + o.w ); + o.zw = pos.zw ; + return o; +} +v2f vert( in appdata v ) { + v2f o; + o.pos = ( gl_ModelViewProjectionMatrix * v.vertex ); + o.uv = ComputeScreenPos( o.pos); + o.ray = (( gl_ModelViewMatrix * v.vertex ).xyz * vec3( -1.00000, -1.00000, 1.00000)); + o.ray = mix( o.ray, v.texcoord, vec3( float( (v.texcoord.z != 0.000000) ))); + return o; +} +void main() { + v2f xl_retval; + appdata xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.texcoord = vec3( gl_MultiTexCoord0); + xl_retval = vert( xlt_v); + gl_Position = vec4( xl_retval.pos); + gl_TexCoord[0] = vec4( xl_retval.uv); + gl_TexCoord[1] = vec4( xl_retval.ray, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Internal-PrePassLighting-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Internal-PrePassLighting-ir.txt new file mode 100644 index 000000000..2d76ee708 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Internal-PrePassLighting-ir.txt @@ -0,0 +1,93 @@ +struct v2f { + vec4 pos; + vec4 uv; + vec3 ray; +}; +struct appdata { + vec4 vertex; + vec3 texcoord; +}; +uniform vec4 _ProjectionParams; +vec4 ComputeScreenPos ( + in vec4 pos +) +{ + vec4 o; + vec4 tmpvar_1; + tmpvar_1 = (pos * 0.5); + o = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2.x = o.x; + tmpvar_2.y = (o.y * _ProjectionParams.x); + vec2 tmpvar_3; + tmpvar_3 = (tmpvar_2 + o.w); + o.xy = tmpvar_3.xy.xy; + vec2 tmpvar_4; + tmpvar_4 = pos.zw; + o.zw = tmpvar_4.xxxy.zw; + return o; +} + +v2f vert ( + in appdata v +) +{ + v2f o; + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v.vertex); + o.pos = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = ComputeScreenPos (o.pos); + vec4 tmpvar_3; + tmpvar_3 = tmpvar_2; + o.uv = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = ((gl_ModelViewMatrix * v.vertex).xyz * vec3(-1.0, -1.0, 1.0)); + o.ray = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = vec3(float((v.texcoord.z != 0.0))); + vec3 tmpvar_6; + tmpvar_6 = mix (o.ray, v.texcoord, tmpvar_5); + vec3 tmpvar_7; + tmpvar_7 = tmpvar_6; + o.ray = tmpvar_7; + return o; +} + +void main () +{ + appdata xlt_v; + v2f xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = gl_MultiTexCoord0.xyz; + vec3 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.texcoord = tmpvar_4; + v2f tmpvar_5; + tmpvar_5 = vert (xlt_v); + v2f tmpvar_6; + tmpvar_6 = tmpvar_5; + xl_retval = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = xl_retval.pos.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + gl_Position = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = xl_retval.uv.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + gl_TexCoord[0] = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11.w = 0.0; + tmpvar_11.xyz = xl_retval.ray.xyz; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + gl_TexCoord[1] = tmpvar_12; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Internal-PrePassLighting-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Internal-PrePassLighting-out.txt new file mode 100644 index 000000000..f0ae277e6 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Internal-PrePassLighting-out.txt @@ -0,0 +1,22 @@ +uniform vec4 _ProjectionParams; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * gl_Vertex); + vec4 o_i0; + vec4 tmpvar_2; + tmpvar_2 = (tmpvar_1 * 0.5); + o_i0 = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3.x = tmpvar_2.x; + tmpvar_3.y = (tmpvar_2.y * _ProjectionParams.x); + o_i0.xy = (tmpvar_3 + tmpvar_2.w); + o_i0.zw = tmpvar_1.zw; + gl_Position = tmpvar_1; + gl_TexCoord[0] = o_i0; + vec4 tmpvar_4; + tmpvar_4.w = 0.0; + tmpvar_4.xyz = mix (((gl_ModelViewMatrix * gl_Vertex).xyz * vec3(-1.0, -1.0, 1.0)), gl_MultiTexCoord0.xyz, vec3(float((gl_MultiTexCoord0.z != 0.0)))); + gl_TexCoord[1] = tmpvar_4; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Noise_Shader_RGB-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Noise_Shader_RGB-in.txt new file mode 100644 index 000000000..7400198da --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Noise_Shader_RGB-in.txt @@ -0,0 +1,50 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct v2f { + vec4 pos; + vec2 uv; + vec2 uvg; + vec2 uvs; +}; +uniform vec4 _GrainOffsetScale; +uniform vec4 _ScratchOffsetScale; + + +vec2 MultiplyUV( in mat4 mat, in vec2 inUV ); +v2f vert( in appdata_img v ); +vec2 MultiplyUV( in mat4 mat, in vec2 inUV ) { + vec4 temp; + temp = vec4( inUV.x , inUV.y , 0.000000, 0.000000); + temp = ( mat * temp ); + return temp.xy ; +} +v2f vert( in appdata_img v ) { + v2f o; + o.pos = ( gl_ModelViewProjectionMatrix * v.vertex ); + o.uv = MultiplyUV( gl_TextureMatrix[0], v.texcoord); + o.uvg = ((v.texcoord.xy * _GrainOffsetScale.zw ) + _GrainOffsetScale.xy ); + o.uvs = ((v.texcoord.xy * _ScratchOffsetScale.zw ) + _ScratchOffsetScale.xy ); + return o; +} +void main() { + v2f xl_retval; + appdata_img xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.texcoord = vec2( gl_MultiTexCoord0); + xl_retval = vert( xlt_v); + gl_Position = vec4( xl_retval.pos); + gl_TexCoord[0] = vec4( xl_retval.uv, 0.0, 0.0); + gl_TexCoord[1] = vec4( xl_retval.uvg, 0.0, 0.0); + gl_TexCoord[2] = vec4( xl_retval.uvs, 0.0, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Noise_Shader_RGB-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Noise_Shader_RGB-ir.txt new file mode 100644 index 000000000..0e1332d5d --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Noise_Shader_RGB-ir.txt @@ -0,0 +1,97 @@ +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct v2f { + vec4 pos; + vec2 uv; + vec2 uvg; + vec2 uvs; +}; +uniform vec4 _ScratchOffsetScale; +uniform vec4 _GrainOffsetScale; +vec2 MultiplyUV ( + in mat4 mat, + in vec2 inUV +) +{ + vec4 temp; + vec4 tmpvar_1; + tmpvar_1.zw = vec2(0.0, 0.0); + tmpvar_1.x = inUV.x; + tmpvar_1.y = inUV.y; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + temp = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = (mat * temp); + temp = tmpvar_3; + return temp.xy; +} + +v2f vert ( + in appdata_img v +) +{ + v2f o; + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v.vertex); + o.pos = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = MultiplyUV (gl_TextureMatrix[0], v.texcoord); + vec2 tmpvar_3; + tmpvar_3 = tmpvar_2; + o.uv = tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = ((v.texcoord.xy * _GrainOffsetScale.zw) + _GrainOffsetScale.xy); + o.uvg = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5 = ((v.texcoord.xy * _ScratchOffsetScale.zw) + _ScratchOffsetScale.xy); + o.uvs = tmpvar_5; + return o; +} + +void main () +{ + appdata_img xlt_v; + v2f xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = gl_MultiTexCoord0.xy; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.texcoord = tmpvar_4; + v2f tmpvar_5; + tmpvar_5 = vert (xlt_v); + v2f tmpvar_6; + tmpvar_6 = tmpvar_5; + xl_retval = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = xl_retval.pos.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + gl_Position = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9.zw = vec2(0.0, 0.0); + tmpvar_9.xy = xl_retval.uv.xy; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + gl_TexCoord[0] = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11.zw = vec2(0.0, 0.0); + tmpvar_11.xy = xl_retval.uvg.xy; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + gl_TexCoord[1] = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13.zw = vec2(0.0, 0.0); + tmpvar_13.xy = xl_retval.uvs.xy; + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + gl_TexCoord[2] = tmpvar_14; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Noise_Shader_RGB-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Noise_Shader_RGB-out.txt new file mode 100644 index 000000000..8e1acf1de --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Noise_Shader_RGB-out.txt @@ -0,0 +1,23 @@ +uniform vec4 _ScratchOffsetScale; +uniform vec4 _GrainOffsetScale; +void main () +{ + vec4 tmpvar_1; + tmpvar_1.zw = vec2(0.0, 0.0); + tmpvar_1.x = gl_MultiTexCoord0.x; + tmpvar_1.y = gl_MultiTexCoord0.y; + gl_Position = (gl_ModelViewProjectionMatrix * gl_Vertex); + vec4 tmpvar_2; + tmpvar_2.zw = vec2(0.0, 0.0); + tmpvar_2.xy = (gl_TextureMatrix[0] * tmpvar_1).xy; + gl_TexCoord[0] = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3.zw = vec2(0.0, 0.0); + tmpvar_3.xy = ((gl_MultiTexCoord0.xy * _GrainOffsetScale.zw) + _GrainOffsetScale.xy); + gl_TexCoord[1] = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4.zw = vec2(0.0, 0.0); + tmpvar_4.xy = ((gl_MultiTexCoord0.xy * _ScratchOffsetScale.zw) + _ScratchOffsetScale.xy); + gl_TexCoord[2] = tmpvar_4; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_BillboardTree-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_BillboardTree-in.txt new file mode 100644 index 000000000..f9a5b53ce --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_BillboardTree-in.txt @@ -0,0 +1,78 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct v2f { + vec4 pos; + float fog; + vec4 color; + vec2 uv; +}; +struct appdata_tree_billboard { + vec4 vertex; + vec4 color; + vec4 texcoord; + vec2 texcoord1; +}; +uniform vec4 _TreeBillboardCameraFront; +uniform vec4 _TreeBillboardCameraPos; +uniform vec3 _TreeBillboardCameraRight; +uniform vec4 _TreeBillboardCameraUp; +uniform vec4 _TreeBillboardDistances; + +void TerrainBillboardTree( inout vec4 pos, in vec2 offset, in float offsetz ); +v2f vert( in appdata_tree_billboard v ); +void TerrainBillboardTree( inout vec4 pos, in vec2 offset, in float offsetz ) { + vec3 treePos; + float treeDistanceSqr; + float billboardAngleFactor; + float radius; + float billboardModeFactor; + float billboardRootOffsetFactor; + float absRadius; + treePos = (pos.xyz - _TreeBillboardCameraPos.xyz ); + treeDistanceSqr = dot( treePos, treePos); + if ( (treeDistanceSqr > _TreeBillboardDistances.x ) ){ + offset.xy = vec2( 0.000000); + } + pos.xyz += (_TreeBillboardCameraRight.xyz * offset.x ); + billboardAngleFactor = _TreeBillboardCameraPos.w ; + radius = mix( offset.y , offsetz, billboardAngleFactor); + billboardModeFactor = _TreeBillboardCameraUp.w ; + billboardRootOffsetFactor = _TreeBillboardCameraFront.w ; + absRadius = abs( radius ); + pos.xyz += mix( ((((_TreeBillboardCameraUp.xyz * max( 0.000000, radius)) * 2.00000) - (vec3( 0.000000, 1.00000, 0.000000) * absRadius)) - ((_TreeBillboardCameraUp.xyz * absRadius) * billboardRootOffsetFactor)), (_TreeBillboardCameraUp.xyz * radius), vec3( billboardModeFactor)); +} +v2f vert( in appdata_tree_billboard v ) { + v2f o; + TerrainBillboardTree( v.vertex, v.texcoord1.xy , v.texcoord.y ); + o.pos = ( gl_ModelViewProjectionMatrix * v.vertex ); + o.fog = o.pos.z ; + o.uv.x = v.texcoord.x ; + o.uv.y = float( (v.texcoord.y > 0.000000) ); + o.color = v.color; + return o; +} +varying vec4 xlv_FOG; +void main() { + v2f xl_retval; + appdata_tree_billboard xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.color = vec4( gl_Color); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec2( gl_MultiTexCoord1); + xl_retval = vert( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_FrontColor = vec4( xl_retval.color); + gl_TexCoord[0] = vec4( xl_retval.uv, 0.0, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_BillboardTree-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_BillboardTree-ir.txt new file mode 100644 index 000000000..b2fca6127 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_BillboardTree-ir.txt @@ -0,0 +1,154 @@ +struct v2f { + vec4 pos; + float fog; + vec4 color; + vec2 uv; +}; +struct appdata_tree_billboard { + vec4 vertex; + vec4 color; + vec4 texcoord; + vec2 texcoord1; +}; +varying vec4 xlv_FOG; +uniform vec4 _TreeBillboardDistances; +uniform vec4 _TreeBillboardCameraUp; +uniform vec3 _TreeBillboardCameraRight; +uniform vec4 _TreeBillboardCameraPos; +uniform vec4 _TreeBillboardCameraFront; +void TerrainBillboardTree ( + inout vec4 pos, + in vec2 offset, + in float offsetz +) +{ + float absRadius; + float billboardRootOffsetFactor; + float billboardModeFactor; + float radius; + float billboardAngleFactor; + float treeDistanceSqr; + vec3 treePos; + vec3 tmpvar_1; + tmpvar_1 = (pos.xyz - _TreeBillboardCameraPos.xyz); + treePos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = dot (treePos, treePos); + float tmpvar_3; + tmpvar_3 = tmpvar_2; + treeDistanceSqr = tmpvar_3; + if ((treeDistanceSqr > _TreeBillboardDistances.x)) { + vec2 tmpvar_4; + tmpvar_4 = vec2(0.0, 0.0); + offset = tmpvar_4.xy.xy; + }; + vec3 tmpvar_5; + tmpvar_5 = (pos.xyz + (_TreeBillboardCameraRight.xyz * offset.x)); + pos.xyz = tmpvar_5.xyz.xyz; + float tmpvar_6; + tmpvar_6 = _TreeBillboardCameraPos.w; + billboardAngleFactor = tmpvar_6; + float tmpvar_7; + tmpvar_7 = mix (offset.y, offsetz, billboardAngleFactor); + float tmpvar_8; + tmpvar_8 = tmpvar_7; + radius = tmpvar_8; + float tmpvar_9; + tmpvar_9 = _TreeBillboardCameraUp.w; + billboardModeFactor = tmpvar_9; + float tmpvar_10; + tmpvar_10 = _TreeBillboardCameraFront.w; + billboardRootOffsetFactor = tmpvar_10; + float tmpvar_11; + tmpvar_11 = abs (radius); + float tmpvar_12; + tmpvar_12 = tmpvar_11; + absRadius = tmpvar_12; + float tmpvar_13; + tmpvar_13 = max (0.0, radius); + vec3 tmpvar_14; + tmpvar_14 = vec3(billboardModeFactor); + vec3 tmpvar_15; + tmpvar_15 = mix (((((_TreeBillboardCameraUp.xyz * tmpvar_13) * 2.0) - (vec3(0.0, 1.0, 0.0) * absRadius)) - ((_TreeBillboardCameraUp.xyz * absRadius) * billboardRootOffsetFactor)), (_TreeBillboardCameraUp.xyz * radius), tmpvar_14); + vec3 tmpvar_16; + tmpvar_16 = (pos.xyz + tmpvar_15); + pos.xyz = tmpvar_16.xyz.xyz; +} + +v2f vert ( + in appdata_tree_billboard v +) +{ + v2f o; + TerrainBillboardTree (v.vertex, v.texcoord1.xy, v.texcoord.y); + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v.vertex); + o.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = o.pos.z; + o.fog = tmpvar_2; + float tmpvar_3; + tmpvar_3 = v.texcoord.x; + o.uv.x = tmpvar_3; + float tmpvar_4; + tmpvar_4 = float((v.texcoord.y > 0.0)); + o.uv.y = vec2(tmpvar_4).y; + vec4 tmpvar_5; + tmpvar_5 = v.color; + o.color = tmpvar_5; + return o; +} + +void main () +{ + appdata_tree_billboard xlt_v; + v2f xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = gl_Color.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.color = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.texcoord = tmpvar_6; + vec2 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord1.xy; + vec2 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord1 = tmpvar_8; + v2f tmpvar_9; + tmpvar_9 = vert (xlt_v); + v2f tmpvar_10; + tmpvar_10 = tmpvar_9; + xl_retval = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = xl_retval.pos.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + gl_Position = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_13.x = xl_retval.fog; + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + xlv_FOG = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.color.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_FrontColor = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.zw = vec2(0.0, 0.0); + tmpvar_17.xy = xl_retval.uv.xy; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + gl_TexCoord[0] = tmpvar_18; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_BillboardTree-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_BillboardTree-out.txt new file mode 100644 index 000000000..c9c8d4c78 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_BillboardTree-out.txt @@ -0,0 +1,44 @@ +varying vec4 xlv_FOG; +uniform vec4 _TreeBillboardDistances; +uniform vec4 _TreeBillboardCameraUp; +uniform vec3 _TreeBillboardCameraRight; +uniform vec4 _TreeBillboardCameraPos; +uniform vec4 _TreeBillboardCameraFront; +void main () +{ + vec2 tmpvar_1; + vec4 pos; + pos = gl_Vertex; + vec2 offset; + offset = gl_MultiTexCoord1.xy; + float offsetz; + offsetz = gl_MultiTexCoord0.y; + vec3 tmpvar_2; + tmpvar_2 = (gl_Vertex.xyz - _TreeBillboardCameraPos.xyz); + float tmpvar_3; + tmpvar_3 = dot (tmpvar_2, tmpvar_2); + if ((tmpvar_3 > _TreeBillboardDistances.x)) { + offset = vec2(0.0, 0.0); + }; + pos.xyz = (gl_Vertex.xyz + (_TreeBillboardCameraRight * offset.x)); + float tmpvar_4; + tmpvar_4 = mix (offset.y, offsetz, _TreeBillboardCameraPos.w); + float tmpvar_5; + tmpvar_5 = abs (tmpvar_4); + pos.xyz = (pos.xyz + mix (((((_TreeBillboardCameraUp.xyz * max (0.0, tmpvar_4)) * 2.0) - (vec3(0.0, 1.0, 0.0) * tmpvar_5)) - ((_TreeBillboardCameraUp.xyz * tmpvar_5) * _TreeBillboardCameraFront.w)), (_TreeBillboardCameraUp.xyz * tmpvar_4), _TreeBillboardCameraUp.www)); + vec4 tmpvar_6; + tmpvar_6 = (gl_ModelViewProjectionMatrix * pos); + tmpvar_1.x = gl_MultiTexCoord0.x; + tmpvar_1.y = float((gl_MultiTexCoord0.y > 0.0)); + gl_Position = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_7.x = tmpvar_6.z; + xlv_FOG = tmpvar_7; + gl_FrontColor = gl_Color; + vec4 tmpvar_8; + tmpvar_8.zw = vec2(0.0, 0.0); + tmpvar_8.xy = tmpvar_1; + gl_TexCoord[0] = tmpvar_8; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_Details_BillboardWavingDoublePass-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_Details_BillboardWavingDoublePass-in.txt new file mode 100644 index 000000000..2f032a333 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_Details_BillboardWavingDoublePass-in.txt @@ -0,0 +1,233 @@ +mat3 xll_constructMat3( mat4 m) { + return mat3( vec3( m[0]), vec3( m[1]), vec3( m[2])); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +struct Input { + vec2 uv_MainTex; + vec4 color; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 lop_color; + vec3 normal; + vec3 vlight; +}; +uniform vec4 _CameraPosition; +uniform vec3 _CameraRight; +uniform vec3 _CameraUp; +uniform vec4 _MainTex_ST; +uniform mat4 _Object2World; +uniform vec4 _WaveAndDistance; +uniform vec4 _WavingTint; + +uniform vec4 unity_4LightAtten0; +uniform vec4 unity_4LightPosX0; +uniform vec4 unity_4LightPosY0; +uniform vec4 unity_4LightPosZ0; +uniform vec3 unity_LightColor0; +uniform vec3 unity_LightColor1; +uniform vec3 unity_LightColor2; +uniform vec3 unity_LightColor3; +uniform vec4 unity_SHAb; +uniform vec4 unity_SHAg; +uniform vec4 unity_SHAr; +uniform vec4 unity_SHBb; +uniform vec4 unity_SHBg; +uniform vec4 unity_SHBr; +uniform vec4 unity_SHC; +uniform vec4 unity_Scale; +void FastSinCos( in vec4 val, out vec4 s, out vec4 c ); +void TerrainWaveGrass( inout vec4 vertex, in float waveAmount, in vec3 color, out vec4 outColor ); +void TerrainBillboardGrass( inout vec4 pos, in vec2 offset ); +void vert( inout appdata_full v ); +vec3 ShadeSH9( in vec4 normal ); +vec3 Shade4PointLights( in vec4 lightPosX, in vec4 lightPosY, in vec4 lightPosZ, in vec3 lightColor0, in vec3 lightColor1, in vec3 lightColor2, in vec3 lightColor3, in vec4 lightAttenSq, in vec3 pos, in vec3 normal ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +v2f_surf vert_surf( in appdata_full v ); +void FastSinCos( in vec4 val, out vec4 s, out vec4 c ) { + vec4 r5; + vec4 r6; + vec4 r7; + vec4 r8; + vec4 r1; + vec4 r2; + vec4 r3; + vec4 sin7 = vec4( 1.00000, -0.161616, 0.00833330, -0.000198410); + vec4 cos8 = vec4( -0.500000, 0.0416667, -0.00138889, 2.48016e-005); + val = ((val * 6.40885) - 3.14159); + r5 = (val * val); + r6 = (r5 * r5); + r7 = (r6 * r5); + r8 = (r6 * r5); + r1 = (r5 * val); + r2 = (r1 * r5); + r3 = (r2 * r5); + s = (((val + (r1 * sin7.y )) + (r2 * sin7.z )) + (r3 * sin7.w )); + c = ((((1.00000 + (r5 * cos8.x )) + (r6 * cos8.y )) + (r7 * cos8.z )) + (r8 * cos8.w )); +} +void TerrainWaveGrass( inout vec4 vertex, in float waveAmount, in vec3 color, out vec4 outColor ) { + vec4 _waveXSize; + vec4 _waveZSize; + vec4 waveSpeed = vec4( 1.20000, 2.00000, 1.60000, 4.80000); + vec4 _waveXmove = vec4( 0.0240000, 0.0400000, -0.120000, 0.0960000); + vec4 _waveZmove = vec4( 0.00600000, 0.0200000, -0.0200000, 0.100000); + vec4 waves; + vec4 s; + vec4 c; + float lighting; + vec3 waveMove = vec3( 0.000000, 0.000000, 0.000000); + vec3 waveColor; + _waveXSize = (vec4( 0.0120000, 0.0200000, 0.0600000, 0.0240000) * _WaveAndDistance.y ); + _waveZSize = (vec4( 0.00600000, 0.0200000, 0.0200000, 0.0500000) * _WaveAndDistance.y ); + waves = (vertex.x * _waveXSize); + waves += (vertex.z * _waveZSize); + waves += (_WaveAndDistance.x * waveSpeed); + waves = fract( waves ); + FastSinCos( waves, s, c); + s = (s * s); + s = (s * s); + lighting = (dot( s, normalize( vec4( 1.00000, 1.00000, 0.400000, 0.200000) )) * 0.700000); + s = (s * waveAmount); + waveMove.x = dot( s, _waveXmove); + waveMove.z = dot( s, _waveZmove); + vertex.xz -= (waveMove.xz * _WaveAndDistance.z ); + waveColor = mix( vec3( 0.500000, 0.500000, 0.500000), _WavingTint.xyz , vec3( lighting)); + outColor.xyz = ((color * waveColor) * 2.00000); + outColor.w = 1.00000; +} +void TerrainBillboardGrass( inout vec4 pos, in vec2 offset ) { + vec3 grasspos; + grasspos = (pos.xyz - _CameraPosition.xyz ); + if ( (dot( grasspos, grasspos) > _WaveAndDistance.w ) ){ + offset = vec2( 0.000000); + } + pos.xyz += (offset.x * _CameraRight.xyz ); + pos.xyz += (offset.y * _CameraUp.xyz ); +} +void vert( inout appdata_full v ) { + float waveAmount; + vec4 color; + TerrainBillboardGrass( v.vertex, v.tangent.xy ); + waveAmount = v.tangent.y ; + TerrainWaveGrass( v.vertex, waveAmount, v.color.xyz , color); + v.color = color; +} +vec3 ShadeSH9( in vec4 normal ) { + vec3 x1; + vec4 vB; + vec3 x2; + float vC; + vec3 x3; + x1.x = dot( unity_SHAr, normal); + x1.y = dot( unity_SHAg, normal); + x1.z = dot( unity_SHAb, normal); + vB = (normal.xyzz * normal.yzzx ); + x2.x = dot( unity_SHBr, vB); + x2.y = dot( unity_SHBg, vB); + x2.z = dot( unity_SHBb, vB); + vC = ((normal.x * normal.x ) - (normal.y * normal.y )); + x3 = (unity_SHC.xyz * vC); + return ((x1 + x2) + x3); +} +vec3 Shade4PointLights( in vec4 lightPosX, in vec4 lightPosY, in vec4 lightPosZ, in vec3 lightColor0, in vec3 lightColor1, in vec3 lightColor2, in vec3 lightColor3, in vec4 lightAttenSq, in vec3 pos, in vec3 normal ) { + vec4 toLightX; + vec4 toLightY; + vec4 toLightZ; + vec4 lengthSq; + vec4 ndotl; + vec4 corr; + vec4 atten; + vec4 diff; + vec3 col; + toLightX = (lightPosX - pos.x ); + toLightY = (lightPosY - pos.y ); + toLightZ = (lightPosZ - pos.z ); + lengthSq = vec4( 0.000000); + lengthSq += (toLightX * toLightX); + lengthSq += (toLightY * toLightY); + lengthSq += (toLightZ * toLightZ); + ndotl = vec4( 0.000000); + ndotl += (toLightX * normal.x ); + ndotl += (toLightY * normal.y ); + ndotl += (toLightZ * normal.z ); + corr = inversesqrt( lengthSq ); + ndotl = max( vec4( 0.000000, 0.000000, 0.000000, 0.000000), (ndotl * corr)); + atten = (1.00000 / (1.00000 + (lengthSq * lightAttenSq))); + diff = (ndotl * atten); + col = vec3( 0.000000); + col += (lightColor0 * diff.x ); + col += (lightColor1 * diff.y ); + col += (lightColor2 * diff.z ); + col += (lightColor3 * diff.w ); + return col; +} +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + vec3 worldN; + vec3 shlight; + vec3 worldPos; + vert( v); + PositionFog( v.vertex, o.pos, o.fog); + o.hip_pack0.xy = ((v.texcoord.xy * _MainTex_ST.xy ) + _MainTex_ST.zw ); + o.lop_color = v.color; + worldN = ( xll_constructMat3( _Object2World) * (v.normal * unity_Scale.w ) ); + o.normal = worldN; + shlight = ShadeSH9( vec4( worldN, 1.00000)); + o.vlight = shlight; + worldPos = ( _Object2World * v.vertex ).xyz ; + o.vlight += Shade4PointLights( unity_4LightPosX0, unity_4LightPosY0, unity_4LightPosZ0, unity_LightColor0, unity_LightColor1, unity_LightColor2, unity_LightColor3, unity_4LightAtten0, worldPos, worldN); + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.hip_pack0, 0.0, 0.0); + gl_FrontColor = vec4( xl_retval.lop_color); + gl_TexCoord[1] = vec4( xl_retval.normal, 0.0); + gl_TexCoord[2] = vec4( xl_retval.vlight, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_Details_BillboardWavingDoublePass-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_Details_BillboardWavingDoublePass-ir.txt new file mode 100644 index 000000000..0455f960b --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_Details_BillboardWavingDoublePass-ir.txt @@ -0,0 +1,527 @@ +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 lop_color; + vec3 normal; + vec3 vlight; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec4 unity_SHC; +uniform vec4 unity_SHBr; +uniform vec4 unity_SHBg; +uniform vec4 unity_SHBb; +uniform vec4 unity_SHAr; +uniform vec4 unity_SHAg; +uniform vec4 unity_SHAb; +uniform vec3 unity_LightColor3; +uniform vec3 unity_LightColor2; +uniform vec3 unity_LightColor1; +uniform vec3 unity_LightColor0; +uniform vec4 unity_4LightPosZ0; +uniform vec4 unity_4LightPosY0; +uniform vec4 unity_4LightPosX0; +uniform vec4 unity_4LightAtten0; +uniform vec4 _WavingTint; +uniform vec4 _WaveAndDistance; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform vec3 _CameraUp; +uniform vec3 _CameraRight; +uniform vec4 _CameraPosition; +mat3 xll_constructMat3 ( + in mat4 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = m[0].xyz; + vec3 tmpvar_2; + tmpvar_2 = m[1].xyz; + vec3 tmpvar_3; + tmpvar_3 = m[2].xyz; + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +void FastSinCos ( + in vec4 val, + out vec4 s, + out vec4 c +) +{ + vec4 cos8; + vec4 sin7; + vec4 r3; + vec4 r2; + vec4 r1; + vec4 r8; + vec4 r7; + vec4 r6; + vec4 r5; + vec4 tmpvar_1; + tmpvar_1 = vec4(1.0, -0.161616, 0.0083333, -0.00019841); + sin7 = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = vec4(-0.5, 0.0416667, -0.00138889, 2.48016e-05); + cos8 = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = ((val * 6.40885) - 3.14159); + val = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = (val * val); + r5 = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = (r5 * r5); + r6 = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = (r6 * r5); + r7 = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = (r6 * r5); + r8 = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = (r5 * val); + r1 = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = (r1 * r5); + r2 = tmpvar_9; + vec4 tmpvar_10; + tmpvar_10 = (r2 * r5); + r3 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = (((val + (r1 * sin7.y)) + (r2 * sin7.z)) + (r3 * sin7.w)); + s = tmpvar_11; + vec4 tmpvar_12; + tmpvar_12 = ((((1.0 + (r5 * cos8.x)) + (r6 * cos8.y)) + (r7 * cos8.z)) + (r8 * cos8.w)); + c = tmpvar_12; +} + +void TerrainWaveGrass ( + inout vec4 vertex, + in float waveAmount, + in vec3 color, + out vec4 outColor +) +{ + vec3 waveColor; + vec3 waveMove; + float lighting; + vec4 c; + vec4 s; + vec4 waves; + vec4 _waveZmove; + vec4 _waveXmove; + vec4 waveSpeed; + vec4 _waveZSize; + vec4 _waveXSize; + vec4 tmpvar_1; + tmpvar_1 = vec4(1.2, 2.0, 1.6, 4.8); + waveSpeed = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = vec4(0.024, 0.04, -0.12, 0.096); + _waveXmove = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = vec4(0.006, 0.02, -0.02, 0.1); + _waveZmove = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = vec3(0.0, 0.0, 0.0); + waveMove = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = (vec4(0.012, 0.02, 0.06, 0.024) * _WaveAndDistance.y); + _waveXSize = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = (vec4(0.006, 0.02, 0.02, 0.05) * _WaveAndDistance.y); + _waveZSize = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = (vertex.x * _waveXSize); + waves = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = (waves + (vertex.z * _waveZSize)); + waves = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = (waves + (_WaveAndDistance.x * waveSpeed)); + waves = tmpvar_9; + vec4 tmpvar_10; + tmpvar_10 = fract (waves); + vec4 tmpvar_11; + tmpvar_11 = tmpvar_10; + waves = tmpvar_11; + FastSinCos (waves, s, c); + vec4 tmpvar_12; + tmpvar_12 = (s * s); + s = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = (s * s); + s = tmpvar_13; + vec4 tmpvar_14; + tmpvar_14 = normalize (vec4(1.0, 1.0, 0.4, 0.2)); + float tmpvar_15; + tmpvar_15 = dot (s, tmpvar_14); + float tmpvar_16; + tmpvar_16 = (tmpvar_15 * 0.7); + lighting = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17 = (s * waveAmount); + s = tmpvar_17; + float tmpvar_18; + tmpvar_18 = dot (s, _waveXmove); + float tmpvar_19; + tmpvar_19 = tmpvar_18; + waveMove.x = tmpvar_19; + float tmpvar_20; + tmpvar_20 = dot (s, _waveZmove); + float tmpvar_21; + tmpvar_21 = tmpvar_20; + waveMove.z = vec3(tmpvar_21).z; + vec2 tmpvar_22; + tmpvar_22 = (vertex.xz - (waveMove.xz * _WaveAndDistance.z)); + vertex.xz = tmpvar_22.xxy.xz; + vec3 tmpvar_23; + tmpvar_23 = vec3(lighting); + vec3 tmpvar_24; + tmpvar_24 = mix (vec3(0.5, 0.5, 0.5), _WavingTint.xyz, tmpvar_23); + vec3 tmpvar_25; + tmpvar_25 = tmpvar_24; + waveColor = tmpvar_25; + vec3 tmpvar_26; + tmpvar_26 = ((color * waveColor) * 2.0); + outColor.xyz = tmpvar_26.xyz.xyz; + float tmpvar_27; + tmpvar_27 = 1.0; + outColor.w = vec4(tmpvar_27).w; +} + +void TerrainBillboardGrass ( + inout vec4 pos, + in vec2 offset +) +{ + vec3 grasspos; + vec3 tmpvar_1; + tmpvar_1 = (pos.xyz - _CameraPosition.xyz); + grasspos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = dot (grasspos, grasspos); + if ((tmpvar_2 > _WaveAndDistance.w)) { + vec2 tmpvar_3; + tmpvar_3 = vec2(0.0, 0.0); + offset = tmpvar_3; + }; + vec3 tmpvar_4; + tmpvar_4 = (pos.xyz + (offset.x * _CameraRight.xyz)); + pos.xyz = tmpvar_4.xyz.xyz; + vec3 tmpvar_5; + tmpvar_5 = (pos.xyz + (offset.y * _CameraUp.xyz)); + pos.xyz = tmpvar_5.xyz.xyz; +} + +void vert ( + inout appdata_full v +) +{ + vec4 color; + float waveAmount; + TerrainBillboardGrass (v.vertex, v.tangent.xy); + float tmpvar_1; + tmpvar_1 = v.tangent.y; + waveAmount = tmpvar_1; + TerrainWaveGrass (v.vertex, waveAmount, v.color.xyz, color); + vec4 tmpvar_2; + tmpvar_2 = color; + v.color = tmpvar_2; +} + +vec3 ShadeSH9 ( + in vec4 normal +) +{ + vec3 x3; + float vC; + vec3 x2; + vec4 vB; + vec3 x1; + float tmpvar_1; + tmpvar_1 = dot (unity_SHAr, normal); + float tmpvar_2; + tmpvar_2 = tmpvar_1; + x1.x = tmpvar_2; + float tmpvar_3; + tmpvar_3 = dot (unity_SHAg, normal); + float tmpvar_4; + tmpvar_4 = tmpvar_3; + x1.y = vec2(tmpvar_4).y; + float tmpvar_5; + tmpvar_5 = dot (unity_SHAb, normal); + float tmpvar_6; + tmpvar_6 = tmpvar_5; + x1.z = vec3(tmpvar_6).z; + vec4 tmpvar_7; + tmpvar_7 = (normal.xyzz * normal.yzzx); + vB = tmpvar_7; + float tmpvar_8; + tmpvar_8 = dot (unity_SHBr, vB); + float tmpvar_9; + tmpvar_9 = tmpvar_8; + x2.x = tmpvar_9; + float tmpvar_10; + tmpvar_10 = dot (unity_SHBg, vB); + float tmpvar_11; + tmpvar_11 = tmpvar_10; + x2.y = vec2(tmpvar_11).y; + float tmpvar_12; + tmpvar_12 = dot (unity_SHBb, vB); + float tmpvar_13; + tmpvar_13 = tmpvar_12; + x2.z = vec3(tmpvar_13).z; + float tmpvar_14; + tmpvar_14 = ((normal.x * normal.x) - (normal.y * normal.y)); + vC = tmpvar_14; + vec3 tmpvar_15; + tmpvar_15 = (unity_SHC.xyz * vC); + x3 = tmpvar_15; + return ((x1 + x2) + x3); +} + +vec3 Shade4PointLights ( + in vec4 lightPosX, + in vec4 lightPosY, + in vec4 lightPosZ, + in vec3 lightColor0, + in vec3 lightColor1, + in vec3 lightColor2, + in vec3 lightColor3, + in vec4 lightAttenSq, + in vec3 pos, + in vec3 normal +) +{ + vec3 col; + vec4 diff; + vec4 atten; + vec4 corr; + vec4 ndotl; + vec4 lengthSq; + vec4 toLightZ; + vec4 toLightY; + vec4 toLightX; + vec4 tmpvar_1; + tmpvar_1 = (lightPosX - pos.x); + toLightX = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = (lightPosY - pos.y); + toLightY = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = (lightPosZ - pos.z); + toLightZ = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = vec4(0.0, 0.0, 0.0, 0.0); + lengthSq = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = (lengthSq + (toLightX * toLightX)); + lengthSq = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = (lengthSq + (toLightY * toLightY)); + lengthSq = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = (lengthSq + (toLightZ * toLightZ)); + lengthSq = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = vec4(0.0, 0.0, 0.0, 0.0); + ndotl = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = (ndotl + (toLightX * normal.x)); + ndotl = tmpvar_9; + vec4 tmpvar_10; + tmpvar_10 = (ndotl + (toLightY * normal.y)); + ndotl = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = (ndotl + (toLightZ * normal.z)); + ndotl = tmpvar_11; + vec4 tmpvar_12; + tmpvar_12 = inversesqrt (lengthSq); + vec4 tmpvar_13; + tmpvar_13 = tmpvar_12; + corr = tmpvar_13; + vec4 tmpvar_14; + tmpvar_14 = max (vec4(0.0, 0.0, 0.0, 0.0), (ndotl * corr)); + vec4 tmpvar_15; + tmpvar_15 = tmpvar_14; + ndotl = tmpvar_15; + vec4 tmpvar_16; + tmpvar_16 = (1.0 / (1.0 + (lengthSq * lightAttenSq))); + atten = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17 = (ndotl * atten); + diff = tmpvar_17; + vec3 tmpvar_18; + tmpvar_18 = vec3(0.0, 0.0, 0.0); + col = tmpvar_18; + vec3 tmpvar_19; + tmpvar_19 = (col + (lightColor0 * diff.x)); + col = tmpvar_19; + vec3 tmpvar_20; + tmpvar_20 = (col + (lightColor1 * diff.y)); + col = tmpvar_20; + vec3 tmpvar_21; + tmpvar_21 = (col + (lightColor2 * diff.z)); + col = tmpvar_21; + vec3 tmpvar_22; + tmpvar_22 = (col + (lightColor3 * diff.w)); + col = tmpvar_22; + return col; +} + +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + vec3 worldPos; + vec3 shlight; + vec3 worldN; + v2f_surf o; + vert (v); + PositionFog (v.vertex, o.pos, o.fog); + vec2 tmpvar_1; + tmpvar_1 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + o.hip_pack0 = tmpvar_1.xy.xy; + vec4 tmpvar_2; + tmpvar_2 = v.color; + o.lop_color = tmpvar_2; + mat3 tmpvar_3; + tmpvar_3 = (xll_constructMat3 (_Object2World)); + vec3 tmpvar_4; + tmpvar_4 = (tmpvar_3 * (v.normal * unity_Scale.w)); + worldN = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = worldN; + o.normal = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6.w = 1.0; + tmpvar_6.xyz = worldN.xyz; + vec3 tmpvar_7; + tmpvar_7 = ShadeSH9 (tmpvar_6); + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + shlight = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = shlight; + o.vlight = tmpvar_9; + vec3 tmpvar_10; + tmpvar_10 = (_Object2World * v.vertex).xyz; + worldPos = tmpvar_10; + vec3 tmpvar_11; + tmpvar_11 = Shade4PointLights (unity_4LightPosX0, unity_4LightPosY0, unity_4LightPosZ0, unity_LightColor0, unity_LightColor1, unity_LightColor2, unity_LightColor3, unity_4LightAtten0, worldPos, worldN); + vec3 tmpvar_12; + tmpvar_12 = (o.vlight + tmpvar_11); + o.vlight = tmpvar_12; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = xl_retval.fog; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_FOG = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19.zw = vec2(0.0, 0.0); + tmpvar_19.xy = xl_retval.hip_pack0.xy; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[0] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21 = xl_retval.lop_color.xyzw; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_FrontColor = tmpvar_22; + vec4 tmpvar_23; + tmpvar_23.w = 0.0; + tmpvar_23.xyz = xl_retval.normal.xyz; + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + gl_TexCoord[1] = tmpvar_24; + vec4 tmpvar_25; + tmpvar_25.w = 0.0; + tmpvar_25.xyz = xl_retval.vlight.xyz; + vec4 tmpvar_26; + tmpvar_26 = tmpvar_25; + gl_TexCoord[2] = tmpvar_26; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_Details_BillboardWavingDoublePass-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_Details_BillboardWavingDoublePass-out.txt new file mode 100644 index 000000000..047690b2e --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_Details_BillboardWavingDoublePass-out.txt @@ -0,0 +1,119 @@ +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec4 unity_SHC; +uniform vec4 unity_SHBr; +uniform vec4 unity_SHBg; +uniform vec4 unity_SHBb; +uniform vec4 unity_SHAr; +uniform vec4 unity_SHAg; +uniform vec4 unity_SHAb; +uniform vec3 unity_LightColor3; +uniform vec3 unity_LightColor2; +uniform vec3 unity_LightColor1; +uniform vec3 unity_LightColor0; +uniform vec4 unity_4LightPosZ0; +uniform vec4 unity_4LightPosY0; +uniform vec4 unity_4LightPosX0; +uniform vec4 unity_4LightAtten0; +uniform vec4 _WavingTint; +uniform vec4 _WaveAndDistance; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform vec3 _CameraUp; +uniform vec3 _CameraRight; +uniform vec4 _CameraPosition; +void main () +{ + vec4 pos; + pos = gl_Vertex; + vec2 offset; + offset = TANGENT.xy; + vec3 tmpvar_1; + tmpvar_1 = (gl_Vertex.xyz - _CameraPosition.xyz); + float tmpvar_2; + tmpvar_2 = dot (tmpvar_1, tmpvar_1); + if ((tmpvar_2 > _WaveAndDistance.w)) { + offset = vec2(0.0, 0.0); + }; + pos.xyz = (gl_Vertex.xyz + (offset.x * _CameraRight)); + pos.xyz = (pos.xyz + (offset.y * _CameraUp)); + vec4 vertex; + vertex = pos; + vec4 outColor; + vec3 waveMove; + waveMove = vec3(0.0, 0.0, 0.0); + vec4 tmpvar_3; + tmpvar_3 = ((fract ((((pos.x * (vec4(0.012, 0.02, 0.06, 0.024) * _WaveAndDistance.y)) + (pos.z * (vec4(0.006, 0.02, 0.02, 0.05) * _WaveAndDistance.y))) + (_WaveAndDistance.x * vec4(1.2, 2.0, 1.6, 4.8)))) * 6.40885) - 3.14159); + vec4 tmpvar_4; + tmpvar_4 = (tmpvar_3 * tmpvar_3); + vec4 tmpvar_5; + tmpvar_5 = (tmpvar_4 * tmpvar_3); + vec4 tmpvar_6; + tmpvar_6 = (tmpvar_5 * tmpvar_4); + vec4 tmpvar_7; + tmpvar_7 = (((tmpvar_3 + (tmpvar_5 * -0.161616)) + (tmpvar_6 * 0.0083333)) + ((tmpvar_6 * tmpvar_4) * -0.00019841)); + vec4 tmpvar_8; + tmpvar_8 = (tmpvar_7 * tmpvar_7); + vec4 tmpvar_9; + tmpvar_9 = (tmpvar_8 * tmpvar_8); + vec4 tmpvar_10; + tmpvar_10 = (tmpvar_9 * TANGENT.y); + waveMove.x = dot (tmpvar_10, vec4(0.024, 0.04, -0.12, 0.096)); + waveMove.z = dot (tmpvar_10, vec4(0.006, 0.02, -0.02, 0.1)); + vertex.xz = (pos.xz - (waveMove.xz * _WaveAndDistance.z)); + outColor.xyz = ((gl_Color.xyz * mix (vec3(0.5, 0.5, 0.5), _WavingTint.xyz, vec3((dot (tmpvar_9, vec4(0.6742, 0.6742, 0.26968, 0.13484)) * 0.7)))) * 2.0); + outColor.w = 1.0; + vec4 tmpvar_11; + tmpvar_11 = (gl_ModelViewProjectionMatrix * vertex); + mat3 tmpvar_12; + tmpvar_12[0] = _Object2World[0].xyz; + tmpvar_12[1] = _Object2World[1].xyz; + tmpvar_12[2] = _Object2World[2].xyz; + vec3 tmpvar_13; + tmpvar_13 = (tmpvar_12 * (gl_Normal * unity_Scale.w)); + vec4 tmpvar_14; + tmpvar_14.w = 1.0; + tmpvar_14.xyz = tmpvar_13; + vec3 x2; + vec3 x1; + x1.x = dot (unity_SHAr, tmpvar_14); + x1.y = dot (unity_SHAg, tmpvar_14); + x1.z = dot (unity_SHAb, tmpvar_14); + vec4 tmpvar_15; + tmpvar_15 = (tmpvar_13.xyzz * tmpvar_13.yzzx); + x2.x = dot (unity_SHBr, tmpvar_15); + x2.y = dot (unity_SHBg, tmpvar_15); + x2.z = dot (unity_SHBb, tmpvar_15); + vec3 tmpvar_16; + tmpvar_16 = (_Object2World * vertex).xyz; + vec4 tmpvar_17; + tmpvar_17 = (unity_4LightPosX0 - tmpvar_16.x); + vec4 tmpvar_18; + tmpvar_18 = (unity_4LightPosY0 - tmpvar_16.y); + vec4 tmpvar_19; + tmpvar_19 = (unity_4LightPosZ0 - tmpvar_16.z); + vec4 tmpvar_20; + tmpvar_20 = (((tmpvar_17 * tmpvar_17) + (tmpvar_18 * tmpvar_18)) + (tmpvar_19 * tmpvar_19)); + vec4 tmpvar_21; + tmpvar_21 = (max (vec4(0.0, 0.0, 0.0, 0.0), ((((tmpvar_17 * tmpvar_13.x) + (tmpvar_18 * tmpvar_13.y)) + (tmpvar_19 * tmpvar_13.z)) * inversesqrt (tmpvar_20))) * (1.0/((1.0 + (tmpvar_20 * unity_4LightAtten0))))); + gl_Position = tmpvar_11; + vec4 tmpvar_22; + tmpvar_22.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_22.x = tmpvar_11.z; + xlv_FOG = tmpvar_22; + vec4 tmpvar_23; + tmpvar_23.zw = vec2(0.0, 0.0); + tmpvar_23.xy = ((gl_MultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + gl_TexCoord[0] = tmpvar_23; + gl_FrontColor = outColor; + vec4 tmpvar_24; + tmpvar_24.w = 0.0; + tmpvar_24.xyz = tmpvar_13; + gl_TexCoord[1] = tmpvar_24; + vec4 tmpvar_25; + tmpvar_25.w = 0.0; + tmpvar_25.xyz = (((x1 + x2) + (unity_SHC.xyz * ((tmpvar_13.x * tmpvar_13.x) - (tmpvar_13.y * tmpvar_13.y)))) + ((((unity_LightColor0 * tmpvar_21.x) + (unity_LightColor1 * tmpvar_21.y)) + (unity_LightColor2 * tmpvar_21.z)) + (unity_LightColor3 * tmpvar_21.w))); + gl_TexCoord[2] = tmpvar_25; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_Details_BillboardWavingDoublePass1-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_Details_BillboardWavingDoublePass1-in.txt new file mode 100644 index 000000000..9335ce246 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_Details_BillboardWavingDoublePass1-in.txt @@ -0,0 +1,171 @@ +mat3 xll_constructMat3( mat4 m) { + return mat3( vec3( m[0]), vec3( m[1]), vec3( m[2])); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +struct Input { + vec2 uv_MainTex; + vec4 color; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 lop_color; + vec3 normal; + vec3 lightDir; + vec3 _LightCoord; +}; +uniform vec4 _CameraPosition; +uniform vec3 _CameraRight; +uniform vec3 _CameraUp; +uniform mat4 _LightMatrix0; +uniform vec4 _MainTex_ST; +uniform mat4 _Object2World; +uniform vec4 _WaveAndDistance; +uniform vec4 _WavingTint; +uniform vec4 _WorldSpaceLightPos0; + +uniform vec4 unity_Scale; +void FastSinCos( in vec4 val, out vec4 s, out vec4 c ); +void TerrainWaveGrass( inout vec4 vertex, in float waveAmount, in vec3 color, out vec4 outColor ); +void TerrainBillboardGrass( inout vec4 pos, in vec2 offset ); +void vert( inout appdata_full v ); +vec3 WorldSpaceLightDir( in vec4 v ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +v2f_surf vert_surf( in appdata_full v ); +void FastSinCos( in vec4 val, out vec4 s, out vec4 c ) { + vec4 r5; + vec4 r6; + vec4 r7; + vec4 r8; + vec4 r1; + vec4 r2; + vec4 r3; + vec4 sin7 = vec4( 1.00000, -0.161616, 0.00833330, -0.000198410); + vec4 cos8 = vec4( -0.500000, 0.0416667, -0.00138889, 2.48016e-005); + val = ((val * 6.40885) - 3.14159); + r5 = (val * val); + r6 = (r5 * r5); + r7 = (r6 * r5); + r8 = (r6 * r5); + r1 = (r5 * val); + r2 = (r1 * r5); + r3 = (r2 * r5); + s = (((val + (r1 * sin7.y )) + (r2 * sin7.z )) + (r3 * sin7.w )); + c = ((((1.00000 + (r5 * cos8.x )) + (r6 * cos8.y )) + (r7 * cos8.z )) + (r8 * cos8.w )); +} +void TerrainWaveGrass( inout vec4 vertex, in float waveAmount, in vec3 color, out vec4 outColor ) { + vec4 _waveXSize; + vec4 _waveZSize; + vec4 waveSpeed = vec4( 1.20000, 2.00000, 1.60000, 4.80000); + vec4 _waveXmove = vec4( 0.0240000, 0.0400000, -0.120000, 0.0960000); + vec4 _waveZmove = vec4( 0.00600000, 0.0200000, -0.0200000, 0.100000); + vec4 waves; + vec4 s; + vec4 c; + float lighting; + vec3 waveMove = vec3( 0.000000, 0.000000, 0.000000); + vec3 waveColor; + _waveXSize = (vec4( 0.0120000, 0.0200000, 0.0600000, 0.0240000) * _WaveAndDistance.y ); + _waveZSize = (vec4( 0.00600000, 0.0200000, 0.0200000, 0.0500000) * _WaveAndDistance.y ); + waves = (vertex.x * _waveXSize); + waves += (vertex.z * _waveZSize); + waves += (_WaveAndDistance.x * waveSpeed); + waves = fract( waves ); + FastSinCos( waves, s, c); + s = (s * s); + s = (s * s); + lighting = (dot( s, normalize( vec4( 1.00000, 1.00000, 0.400000, 0.200000) )) * 0.700000); + s = (s * waveAmount); + waveMove.x = dot( s, _waveXmove); + waveMove.z = dot( s, _waveZmove); + vertex.xz -= (waveMove.xz * _WaveAndDistance.z ); + waveColor = mix( vec3( 0.500000, 0.500000, 0.500000), _WavingTint.xyz , vec3( lighting)); + outColor.xyz = ((color * waveColor) * 2.00000); + outColor.w = 1.00000; +} +void TerrainBillboardGrass( inout vec4 pos, in vec2 offset ) { + vec3 grasspos; + grasspos = (pos.xyz - _CameraPosition.xyz ); + if ( (dot( grasspos, grasspos) > _WaveAndDistance.w ) ){ + offset = vec2( 0.000000); + } + pos.xyz += (offset.x * _CameraRight.xyz ); + pos.xyz += (offset.y * _CameraUp.xyz ); +} +void vert( inout appdata_full v ) { + float waveAmount; + vec4 color; + TerrainBillboardGrass( v.vertex, v.tangent.xy ); + waveAmount = v.tangent.y ; + TerrainWaveGrass( v.vertex, waveAmount, v.color.xyz , color); + v.color = color; +} +vec3 WorldSpaceLightDir( in vec4 v ) { + vec3 worldPos; + worldPos = ( _Object2World * v ).xyz ; + return (_WorldSpaceLightPos0.xyz - worldPos); +} +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + vert( v); + PositionFog( v.vertex, o.pos, o.fog); + o.hip_pack0.xy = ((v.texcoord.xy * _MainTex_ST.xy ) + _MainTex_ST.zw ); + o.lop_color = v.color; + o.normal = ( xll_constructMat3( _Object2World) * (v.normal * unity_Scale.w ) ); + o.lightDir = WorldSpaceLightDir( v.vertex); + o._LightCoord = ( _LightMatrix0 * ( _Object2World * v.vertex ) ).xyz ; + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.hip_pack0, 0.0, 0.0); + gl_FrontColor = vec4( xl_retval.lop_color); + gl_TexCoord[1] = vec4( xl_retval.normal, 0.0); + gl_TexCoord[2] = vec4( xl_retval.lightDir, 0.0); + gl_TexCoord[3] = vec4( xl_retval._LightCoord, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_Details_BillboardWavingDoublePass1-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_Details_BillboardWavingDoublePass1-ir.txt new file mode 100644 index 000000000..7db8e7dd8 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_Details_BillboardWavingDoublePass1-ir.txt @@ -0,0 +1,375 @@ +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 lop_color; + vec3 normal; + vec3 lightDir; + vec3 _LightCoord; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform vec4 _WavingTint; +uniform vec4 _WaveAndDistance; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform mat4 _LightMatrix0; +uniform vec3 _CameraUp; +uniform vec3 _CameraRight; +uniform vec4 _CameraPosition; +mat3 xll_constructMat3 ( + in mat4 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = m[0].xyz; + vec3 tmpvar_2; + tmpvar_2 = m[1].xyz; + vec3 tmpvar_3; + tmpvar_3 = m[2].xyz; + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +void FastSinCos ( + in vec4 val, + out vec4 s, + out vec4 c +) +{ + vec4 cos8; + vec4 sin7; + vec4 r3; + vec4 r2; + vec4 r1; + vec4 r8; + vec4 r7; + vec4 r6; + vec4 r5; + vec4 tmpvar_1; + tmpvar_1 = vec4(1.0, -0.161616, 0.0083333, -0.00019841); + sin7 = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = vec4(-0.5, 0.0416667, -0.00138889, 2.48016e-05); + cos8 = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = ((val * 6.40885) - 3.14159); + val = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = (val * val); + r5 = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = (r5 * r5); + r6 = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = (r6 * r5); + r7 = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = (r6 * r5); + r8 = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = (r5 * val); + r1 = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = (r1 * r5); + r2 = tmpvar_9; + vec4 tmpvar_10; + tmpvar_10 = (r2 * r5); + r3 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = (((val + (r1 * sin7.y)) + (r2 * sin7.z)) + (r3 * sin7.w)); + s = tmpvar_11; + vec4 tmpvar_12; + tmpvar_12 = ((((1.0 + (r5 * cos8.x)) + (r6 * cos8.y)) + (r7 * cos8.z)) + (r8 * cos8.w)); + c = tmpvar_12; +} + +void TerrainWaveGrass ( + inout vec4 vertex, + in float waveAmount, + in vec3 color, + out vec4 outColor +) +{ + vec3 waveColor; + vec3 waveMove; + float lighting; + vec4 c; + vec4 s; + vec4 waves; + vec4 _waveZmove; + vec4 _waveXmove; + vec4 waveSpeed; + vec4 _waveZSize; + vec4 _waveXSize; + vec4 tmpvar_1; + tmpvar_1 = vec4(1.2, 2.0, 1.6, 4.8); + waveSpeed = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = vec4(0.024, 0.04, -0.12, 0.096); + _waveXmove = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = vec4(0.006, 0.02, -0.02, 0.1); + _waveZmove = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = vec3(0.0, 0.0, 0.0); + waveMove = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = (vec4(0.012, 0.02, 0.06, 0.024) * _WaveAndDistance.y); + _waveXSize = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = (vec4(0.006, 0.02, 0.02, 0.05) * _WaveAndDistance.y); + _waveZSize = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = (vertex.x * _waveXSize); + waves = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = (waves + (vertex.z * _waveZSize)); + waves = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = (waves + (_WaveAndDistance.x * waveSpeed)); + waves = tmpvar_9; + vec4 tmpvar_10; + tmpvar_10 = fract (waves); + vec4 tmpvar_11; + tmpvar_11 = tmpvar_10; + waves = tmpvar_11; + FastSinCos (waves, s, c); + vec4 tmpvar_12; + tmpvar_12 = (s * s); + s = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = (s * s); + s = tmpvar_13; + vec4 tmpvar_14; + tmpvar_14 = normalize (vec4(1.0, 1.0, 0.4, 0.2)); + float tmpvar_15; + tmpvar_15 = dot (s, tmpvar_14); + float tmpvar_16; + tmpvar_16 = (tmpvar_15 * 0.7); + lighting = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17 = (s * waveAmount); + s = tmpvar_17; + float tmpvar_18; + tmpvar_18 = dot (s, _waveXmove); + float tmpvar_19; + tmpvar_19 = tmpvar_18; + waveMove.x = tmpvar_19; + float tmpvar_20; + tmpvar_20 = dot (s, _waveZmove); + float tmpvar_21; + tmpvar_21 = tmpvar_20; + waveMove.z = vec3(tmpvar_21).z; + vec2 tmpvar_22; + tmpvar_22 = (vertex.xz - (waveMove.xz * _WaveAndDistance.z)); + vertex.xz = tmpvar_22.xxy.xz; + vec3 tmpvar_23; + tmpvar_23 = vec3(lighting); + vec3 tmpvar_24; + tmpvar_24 = mix (vec3(0.5, 0.5, 0.5), _WavingTint.xyz, tmpvar_23); + vec3 tmpvar_25; + tmpvar_25 = tmpvar_24; + waveColor = tmpvar_25; + vec3 tmpvar_26; + tmpvar_26 = ((color * waveColor) * 2.0); + outColor.xyz = tmpvar_26.xyz.xyz; + float tmpvar_27; + tmpvar_27 = 1.0; + outColor.w = vec4(tmpvar_27).w; +} + +void TerrainBillboardGrass ( + inout vec4 pos, + in vec2 offset +) +{ + vec3 grasspos; + vec3 tmpvar_1; + tmpvar_1 = (pos.xyz - _CameraPosition.xyz); + grasspos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = dot (grasspos, grasspos); + if ((tmpvar_2 > _WaveAndDistance.w)) { + vec2 tmpvar_3; + tmpvar_3 = vec2(0.0, 0.0); + offset = tmpvar_3; + }; + vec3 tmpvar_4; + tmpvar_4 = (pos.xyz + (offset.x * _CameraRight.xyz)); + pos.xyz = tmpvar_4.xyz.xyz; + vec3 tmpvar_5; + tmpvar_5 = (pos.xyz + (offset.y * _CameraUp.xyz)); + pos.xyz = tmpvar_5.xyz.xyz; +} + +void vert ( + inout appdata_full v +) +{ + vec4 color; + float waveAmount; + TerrainBillboardGrass (v.vertex, v.tangent.xy); + float tmpvar_1; + tmpvar_1 = v.tangent.y; + waveAmount = tmpvar_1; + TerrainWaveGrass (v.vertex, waveAmount, v.color.xyz, color); + vec4 tmpvar_2; + tmpvar_2 = color; + v.color = tmpvar_2; +} + +vec3 WorldSpaceLightDir ( + in vec4 v +) +{ + vec3 worldPos; + vec3 tmpvar_1; + tmpvar_1 = (_Object2World * v).xyz; + worldPos = tmpvar_1; + return (_WorldSpaceLightPos0.xyz - worldPos); +} + +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + v2f_surf o; + vert (v); + PositionFog (v.vertex, o.pos, o.fog); + vec2 tmpvar_1; + tmpvar_1 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + o.hip_pack0 = tmpvar_1.xy.xy; + vec4 tmpvar_2; + tmpvar_2 = v.color; + o.lop_color = tmpvar_2; + mat3 tmpvar_3; + tmpvar_3 = (xll_constructMat3 (_Object2World)); + vec3 tmpvar_4; + tmpvar_4 = (tmpvar_3 * (v.normal * unity_Scale.w)); + o.normal = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = WorldSpaceLightDir (v.vertex); + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + o.lightDir = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = (_LightMatrix0 * (_Object2World * v.vertex)).xyz; + o._LightCoord = tmpvar_7; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = xl_retval.fog; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_FOG = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19.zw = vec2(0.0, 0.0); + tmpvar_19.xy = xl_retval.hip_pack0.xy; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[0] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21 = xl_retval.lop_color.xyzw; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_FrontColor = tmpvar_22; + vec4 tmpvar_23; + tmpvar_23.w = 0.0; + tmpvar_23.xyz = xl_retval.normal.xyz; + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + gl_TexCoord[1] = tmpvar_24; + vec4 tmpvar_25; + tmpvar_25.w = 0.0; + tmpvar_25.xyz = xl_retval.lightDir.xyz; + vec4 tmpvar_26; + tmpvar_26 = tmpvar_25; + gl_TexCoord[2] = tmpvar_26; + vec4 tmpvar_27; + tmpvar_27.w = 0.0; + tmpvar_27.xyz = xl_retval._LightCoord.xyz; + vec4 tmpvar_28; + tmpvar_28 = tmpvar_27; + gl_TexCoord[3] = tmpvar_28; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_Details_BillboardWavingDoublePass1-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_Details_BillboardWavingDoublePass1-out.txt new file mode 100644 index 000000000..2fc97c544 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_Details_BillboardWavingDoublePass1-out.txt @@ -0,0 +1,83 @@ +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform vec4 _WavingTint; +uniform vec4 _WaveAndDistance; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform mat4 _LightMatrix0; +uniform vec3 _CameraUp; +uniform vec3 _CameraRight; +uniform vec4 _CameraPosition; +void main () +{ + vec4 pos; + pos = gl_Vertex; + vec2 offset; + offset = TANGENT.xy; + vec3 tmpvar_1; + tmpvar_1 = (gl_Vertex.xyz - _CameraPosition.xyz); + float tmpvar_2; + tmpvar_2 = dot (tmpvar_1, tmpvar_1); + if ((tmpvar_2 > _WaveAndDistance.w)) { + offset = vec2(0.0, 0.0); + }; + pos.xyz = (gl_Vertex.xyz + (offset.x * _CameraRight)); + pos.xyz = (pos.xyz + (offset.y * _CameraUp)); + vec4 vertex; + vertex = pos; + vec4 outColor; + vec3 waveMove; + waveMove = vec3(0.0, 0.0, 0.0); + vec4 tmpvar_3; + tmpvar_3 = ((fract ((((pos.x * (vec4(0.012, 0.02, 0.06, 0.024) * _WaveAndDistance.y)) + (pos.z * (vec4(0.006, 0.02, 0.02, 0.05) * _WaveAndDistance.y))) + (_WaveAndDistance.x * vec4(1.2, 2.0, 1.6, 4.8)))) * 6.40885) - 3.14159); + vec4 tmpvar_4; + tmpvar_4 = (tmpvar_3 * tmpvar_3); + vec4 tmpvar_5; + tmpvar_5 = (tmpvar_4 * tmpvar_3); + vec4 tmpvar_6; + tmpvar_6 = (tmpvar_5 * tmpvar_4); + vec4 tmpvar_7; + tmpvar_7 = (((tmpvar_3 + (tmpvar_5 * -0.161616)) + (tmpvar_6 * 0.0083333)) + ((tmpvar_6 * tmpvar_4) * -0.00019841)); + vec4 tmpvar_8; + tmpvar_8 = (tmpvar_7 * tmpvar_7); + vec4 tmpvar_9; + tmpvar_9 = (tmpvar_8 * tmpvar_8); + vec4 tmpvar_10; + tmpvar_10 = (tmpvar_9 * TANGENT.y); + waveMove.x = dot (tmpvar_10, vec4(0.024, 0.04, -0.12, 0.096)); + waveMove.z = dot (tmpvar_10, vec4(0.006, 0.02, -0.02, 0.1)); + vertex.xz = (pos.xz - (waveMove.xz * _WaveAndDistance.z)); + outColor.xyz = ((gl_Color.xyz * mix (vec3(0.5, 0.5, 0.5), _WavingTint.xyz, vec3((dot (tmpvar_9, vec4(0.6742, 0.6742, 0.26968, 0.13484)) * 0.7)))) * 2.0); + outColor.w = 1.0; + vec4 tmpvar_11; + tmpvar_11 = (gl_ModelViewProjectionMatrix * vertex); + mat3 tmpvar_12; + tmpvar_12[0] = _Object2World[0].xyz; + tmpvar_12[1] = _Object2World[1].xyz; + tmpvar_12[2] = _Object2World[2].xyz; + gl_Position = tmpvar_11; + vec4 tmpvar_13; + tmpvar_13.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_13.x = tmpvar_11.z; + xlv_FOG = tmpvar_13; + vec4 tmpvar_14; + tmpvar_14.zw = vec2(0.0, 0.0); + tmpvar_14.xy = ((gl_MultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + gl_TexCoord[0] = tmpvar_14; + gl_FrontColor = outColor; + vec4 tmpvar_15; + tmpvar_15.w = 0.0; + tmpvar_15.xyz = (tmpvar_12 * (gl_Normal * unity_Scale.w)); + gl_TexCoord[1] = tmpvar_15; + vec4 tmpvar_16; + tmpvar_16.w = 0.0; + tmpvar_16.xyz = (_WorldSpaceLightPos0.xyz - (_Object2World * vertex).xyz); + gl_TexCoord[2] = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.w = 0.0; + tmpvar_17.xyz = (_LightMatrix0 * (_Object2World * vertex)).xyz; + gl_TexCoord[3] = tmpvar_17; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_Details_BillboardWavingDoublePass2-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_Details_BillboardWavingDoublePass2-in.txt new file mode 100644 index 000000000..f5ccde334 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_Details_BillboardWavingDoublePass2-in.txt @@ -0,0 +1,146 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +struct Input { + vec2 uv_MainTex; + vec4 color; +}; +struct v2f_surf { + vec4 pos; + vec2 hip_pack0; + vec4 lop_color; +}; +uniform vec4 _CameraPosition; +uniform vec3 _CameraRight; +uniform vec3 _CameraUp; +uniform vec4 _MainTex_ST; +uniform vec4 _WaveAndDistance; +uniform vec4 _WavingTint; + +uniform vec4 unity_LightShadowBias; +void FastSinCos( in vec4 val, out vec4 s, out vec4 c ); +void TerrainWaveGrass( inout vec4 vertex, in float waveAmount, in vec3 color, out vec4 outColor ); +void TerrainBillboardGrass( inout vec4 pos, in vec2 offset ); +void vert( inout appdata_full v ); +v2f_surf vert_surf( in appdata_full v ); +void FastSinCos( in vec4 val, out vec4 s, out vec4 c ) { + vec4 r5; + vec4 r6; + vec4 r7; + vec4 r8; + vec4 r1; + vec4 r2; + vec4 r3; + vec4 sin7 = vec4( 1.00000, -0.161616, 0.00833330, -0.000198410); + vec4 cos8 = vec4( -0.500000, 0.0416667, -0.00138889, 2.48016e-005); + val = ((val * 6.40885) - 3.14159); + r5 = (val * val); + r6 = (r5 * r5); + r7 = (r6 * r5); + r8 = (r6 * r5); + r1 = (r5 * val); + r2 = (r1 * r5); + r3 = (r2 * r5); + s = (((val + (r1 * sin7.y )) + (r2 * sin7.z )) + (r3 * sin7.w )); + c = ((((1.00000 + (r5 * cos8.x )) + (r6 * cos8.y )) + (r7 * cos8.z )) + (r8 * cos8.w )); +} +void TerrainWaveGrass( inout vec4 vertex, in float waveAmount, in vec3 color, out vec4 outColor ) { + vec4 _waveXSize; + vec4 _waveZSize; + vec4 waveSpeed = vec4( 1.20000, 2.00000, 1.60000, 4.80000); + vec4 _waveXmove = vec4( 0.0240000, 0.0400000, -0.120000, 0.0960000); + vec4 _waveZmove = vec4( 0.00600000, 0.0200000, -0.0200000, 0.100000); + vec4 waves; + vec4 s; + vec4 c; + float lighting; + vec3 waveMove = vec3( 0.000000, 0.000000, 0.000000); + vec3 waveColor; + _waveXSize = (vec4( 0.0120000, 0.0200000, 0.0600000, 0.0240000) * _WaveAndDistance.y ); + _waveZSize = (vec4( 0.00600000, 0.0200000, 0.0200000, 0.0500000) * _WaveAndDistance.y ); + waves = (vertex.x * _waveXSize); + waves += (vertex.z * _waveZSize); + waves += (_WaveAndDistance.x * waveSpeed); + waves = fract( waves ); + FastSinCos( waves, s, c); + s = (s * s); + s = (s * s); + lighting = (dot( s, normalize( vec4( 1.00000, 1.00000, 0.400000, 0.200000) )) * 0.700000); + s = (s * waveAmount); + waveMove.x = dot( s, _waveXmove); + waveMove.z = dot( s, _waveZmove); + vertex.xz -= (waveMove.xz * _WaveAndDistance.z ); + waveColor = mix( vec3( 0.500000, 0.500000, 0.500000), _WavingTint.xyz , vec3( lighting)); + outColor.xyz = ((color * waveColor) * 2.00000); + outColor.w = 1.00000; +} +void TerrainBillboardGrass( inout vec4 pos, in vec2 offset ) { + vec3 grasspos; + grasspos = (pos.xyz - _CameraPosition.xyz ); + if ( (dot( grasspos, grasspos) > _WaveAndDistance.w ) ){ + offset = vec2( 0.000000); + } + pos.xyz += (offset.x * _CameraRight.xyz ); + pos.xyz += (offset.y * _CameraUp.xyz ); +} +void vert( inout appdata_full v ) { + float waveAmount; + vec4 color; + TerrainBillboardGrass( v.vertex, v.tangent.xy ); + waveAmount = v.tangent.y ; + TerrainWaveGrass( v.vertex, waveAmount, v.color.xyz , color); + v.color = color; +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + vert( v); + o.hip_pack0.xy = ((v.texcoord.xy * _MainTex_ST.xy ) + _MainTex_ST.zw ); + o.lop_color = v.color; + o.pos = ( gl_ModelViewProjectionMatrix * v.vertex ); + o.pos.z += unity_LightShadowBias.x ; + if ( (o.pos.z < ( -o.pos.w )) ){ + o.pos.z = ( -o.pos.w ); + } + return o; +} +attribute vec4 TANGENT; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + gl_TexCoord[1] = vec4( xl_retval.hip_pack0, 0.0, 0.0); + gl_FrontColor = vec4( xl_retval.lop_color); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_Details_BillboardWavingDoublePass2-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_Details_BillboardWavingDoublePass2-ir.txt new file mode 100644 index 000000000..4fcd54600 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_Details_BillboardWavingDoublePass2-ir.txt @@ -0,0 +1,292 @@ +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +struct v2f_surf { + vec4 pos; + vec2 hip_pack0; + vec4 lop_color; +}; +attribute vec4 TANGENT; +uniform vec4 unity_LightShadowBias; +uniform vec4 _WavingTint; +uniform vec4 _WaveAndDistance; +uniform vec4 _MainTex_ST; +uniform vec3 _CameraUp; +uniform vec3 _CameraRight; +uniform vec4 _CameraPosition; +void FastSinCos ( + in vec4 val, + out vec4 s, + out vec4 c +) +{ + vec4 cos8; + vec4 sin7; + vec4 r3; + vec4 r2; + vec4 r1; + vec4 r8; + vec4 r7; + vec4 r6; + vec4 r5; + vec4 tmpvar_1; + tmpvar_1 = vec4(1.0, -0.161616, 0.0083333, -0.00019841); + sin7 = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = vec4(-0.5, 0.0416667, -0.00138889, 2.48016e-05); + cos8 = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = ((val * 6.40885) - 3.14159); + val = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = (val * val); + r5 = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = (r5 * r5); + r6 = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = (r6 * r5); + r7 = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = (r6 * r5); + r8 = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = (r5 * val); + r1 = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = (r1 * r5); + r2 = tmpvar_9; + vec4 tmpvar_10; + tmpvar_10 = (r2 * r5); + r3 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = (((val + (r1 * sin7.y)) + (r2 * sin7.z)) + (r3 * sin7.w)); + s = tmpvar_11; + vec4 tmpvar_12; + tmpvar_12 = ((((1.0 + (r5 * cos8.x)) + (r6 * cos8.y)) + (r7 * cos8.z)) + (r8 * cos8.w)); + c = tmpvar_12; +} + +void TerrainWaveGrass ( + inout vec4 vertex, + in float waveAmount, + in vec3 color, + out vec4 outColor +) +{ + vec3 waveColor; + vec3 waveMove; + float lighting; + vec4 c; + vec4 s; + vec4 waves; + vec4 _waveZmove; + vec4 _waveXmove; + vec4 waveSpeed; + vec4 _waveZSize; + vec4 _waveXSize; + vec4 tmpvar_1; + tmpvar_1 = vec4(1.2, 2.0, 1.6, 4.8); + waveSpeed = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = vec4(0.024, 0.04, -0.12, 0.096); + _waveXmove = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = vec4(0.006, 0.02, -0.02, 0.1); + _waveZmove = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = vec3(0.0, 0.0, 0.0); + waveMove = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = (vec4(0.012, 0.02, 0.06, 0.024) * _WaveAndDistance.y); + _waveXSize = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = (vec4(0.006, 0.02, 0.02, 0.05) * _WaveAndDistance.y); + _waveZSize = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = (vertex.x * _waveXSize); + waves = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = (waves + (vertex.z * _waveZSize)); + waves = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = (waves + (_WaveAndDistance.x * waveSpeed)); + waves = tmpvar_9; + vec4 tmpvar_10; + tmpvar_10 = fract (waves); + vec4 tmpvar_11; + tmpvar_11 = tmpvar_10; + waves = tmpvar_11; + FastSinCos (waves, s, c); + vec4 tmpvar_12; + tmpvar_12 = (s * s); + s = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = (s * s); + s = tmpvar_13; + vec4 tmpvar_14; + tmpvar_14 = normalize (vec4(1.0, 1.0, 0.4, 0.2)); + float tmpvar_15; + tmpvar_15 = dot (s, tmpvar_14); + float tmpvar_16; + tmpvar_16 = (tmpvar_15 * 0.7); + lighting = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17 = (s * waveAmount); + s = tmpvar_17; + float tmpvar_18; + tmpvar_18 = dot (s, _waveXmove); + float tmpvar_19; + tmpvar_19 = tmpvar_18; + waveMove.x = tmpvar_19; + float tmpvar_20; + tmpvar_20 = dot (s, _waveZmove); + float tmpvar_21; + tmpvar_21 = tmpvar_20; + waveMove.z = vec3(tmpvar_21).z; + vec2 tmpvar_22; + tmpvar_22 = (vertex.xz - (waveMove.xz * _WaveAndDistance.z)); + vertex.xz = tmpvar_22.xxy.xz; + vec3 tmpvar_23; + tmpvar_23 = vec3(lighting); + vec3 tmpvar_24; + tmpvar_24 = mix (vec3(0.5, 0.5, 0.5), _WavingTint.xyz, tmpvar_23); + vec3 tmpvar_25; + tmpvar_25 = tmpvar_24; + waveColor = tmpvar_25; + vec3 tmpvar_26; + tmpvar_26 = ((color * waveColor) * 2.0); + outColor.xyz = tmpvar_26.xyz.xyz; + float tmpvar_27; + tmpvar_27 = 1.0; + outColor.w = vec4(tmpvar_27).w; +} + +void TerrainBillboardGrass ( + inout vec4 pos, + in vec2 offset +) +{ + vec3 grasspos; + vec3 tmpvar_1; + tmpvar_1 = (pos.xyz - _CameraPosition.xyz); + grasspos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = dot (grasspos, grasspos); + if ((tmpvar_2 > _WaveAndDistance.w)) { + vec2 tmpvar_3; + tmpvar_3 = vec2(0.0, 0.0); + offset = tmpvar_3; + }; + vec3 tmpvar_4; + tmpvar_4 = (pos.xyz + (offset.x * _CameraRight.xyz)); + pos.xyz = tmpvar_4.xyz.xyz; + vec3 tmpvar_5; + tmpvar_5 = (pos.xyz + (offset.y * _CameraUp.xyz)); + pos.xyz = tmpvar_5.xyz.xyz; +} + +void vert ( + inout appdata_full v +) +{ + vec4 color; + float waveAmount; + TerrainBillboardGrass (v.vertex, v.tangent.xy); + float tmpvar_1; + tmpvar_1 = v.tangent.y; + waveAmount = tmpvar_1; + TerrainWaveGrass (v.vertex, waveAmount, v.color.xyz, color); + vec4 tmpvar_2; + tmpvar_2 = color; + v.color = tmpvar_2; +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + v2f_surf o; + vert (v); + vec2 tmpvar_1; + tmpvar_1 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + o.hip_pack0 = tmpvar_1.xy.xy; + vec4 tmpvar_2; + tmpvar_2 = v.color; + o.lop_color = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = (gl_ModelViewProjectionMatrix * v.vertex); + o.pos = tmpvar_3; + float tmpvar_4; + tmpvar_4 = (o.pos.z + unity_LightShadowBias.x); + o.pos.z = vec3(tmpvar_4).z; + if ((o.pos.z < -(o.pos.w))) { + float tmpvar_5; + tmpvar_5 = -(o.pos.w); + o.pos.z = vec3(tmpvar_5).z; + }; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.zw = vec2(0.0, 0.0); + tmpvar_17.xy = xl_retval.hip_pack0.xy; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + gl_TexCoord[1] = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19 = xl_retval.lop_color.xyzw; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_FrontColor = tmpvar_20; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_Details_BillboardWavingDoublePass2-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_Details_BillboardWavingDoublePass2-out.txt new file mode 100644 index 000000000..1a4059276 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_Details_BillboardWavingDoublePass2-out.txt @@ -0,0 +1,67 @@ +attribute vec4 TANGENT; +uniform vec4 unity_LightShadowBias; +uniform vec4 _WavingTint; +uniform vec4 _WaveAndDistance; +uniform vec4 _MainTex_ST; +uniform vec3 _CameraUp; +uniform vec3 _CameraRight; +uniform vec4 _CameraPosition; +void main () +{ + vec4 tmpvar_1; + vec2 tmpvar_2; + vec4 pos; + pos = gl_Vertex; + vec2 offset; + offset = TANGENT.xy; + vec3 tmpvar_3; + tmpvar_3 = (gl_Vertex.xyz - _CameraPosition.xyz); + float tmpvar_4; + tmpvar_4 = dot (tmpvar_3, tmpvar_3); + if ((tmpvar_4 > _WaveAndDistance.w)) { + offset = vec2(0.0, 0.0); + }; + pos.xyz = (gl_Vertex.xyz + (offset.x * _CameraRight)); + pos.xyz = (pos.xyz + (offset.y * _CameraUp)); + vec4 vertex; + vertex = pos; + vec4 outColor; + vec3 waveMove; + waveMove = vec3(0.0, 0.0, 0.0); + vec4 tmpvar_5; + tmpvar_5 = ((fract ((((pos.x * (vec4(0.012, 0.02, 0.06, 0.024) * _WaveAndDistance.y)) + (pos.z * (vec4(0.006, 0.02, 0.02, 0.05) * _WaveAndDistance.y))) + (_WaveAndDistance.x * vec4(1.2, 2.0, 1.6, 4.8)))) * 6.40885) - 3.14159); + vec4 tmpvar_6; + tmpvar_6 = (tmpvar_5 * tmpvar_5); + vec4 tmpvar_7; + tmpvar_7 = (tmpvar_6 * tmpvar_5); + vec4 tmpvar_8; + tmpvar_8 = (tmpvar_7 * tmpvar_6); + vec4 tmpvar_9; + tmpvar_9 = (((tmpvar_5 + (tmpvar_7 * -0.161616)) + (tmpvar_8 * 0.0083333)) + ((tmpvar_8 * tmpvar_6) * -0.00019841)); + vec4 tmpvar_10; + tmpvar_10 = (tmpvar_9 * tmpvar_9); + vec4 tmpvar_11; + tmpvar_11 = (tmpvar_10 * tmpvar_10); + vec4 tmpvar_12; + tmpvar_12 = (tmpvar_11 * TANGENT.y); + waveMove.x = dot (tmpvar_12, vec4(0.024, 0.04, -0.12, 0.096)); + waveMove.z = dot (tmpvar_12, vec4(0.006, 0.02, -0.02, 0.1)); + vertex.xz = (pos.xz - (waveMove.xz * _WaveAndDistance.z)); + outColor.xyz = ((gl_Color.xyz * mix (vec3(0.5, 0.5, 0.5), _WavingTint.xyz, vec3((dot (tmpvar_11, vec4(0.6742, 0.6742, 0.26968, 0.13484)) * 0.7)))) * 2.0); + outColor.w = 1.0; + tmpvar_2 = ((gl_MultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + vec4 tmpvar_13; + tmpvar_13 = (gl_ModelViewProjectionMatrix * vertex); + tmpvar_1 = tmpvar_13; + tmpvar_1.z = (tmpvar_13.z + unity_LightShadowBias.x); + if ((tmpvar_1.z < -(tmpvar_13.w))) { + tmpvar_1.z = -(tmpvar_13.w); + }; + gl_Position = tmpvar_1; + vec4 tmpvar_14; + tmpvar_14.zw = vec2(0.0, 0.0); + tmpvar_14.xy = tmpvar_2; + gl_TexCoord[1] = tmpvar_14; + gl_FrontColor = outColor; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_Details_WavingDoublePass1-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_Details_WavingDoublePass1-in.txt new file mode 100644 index 000000000..eb98ccded --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_Details_WavingDoublePass1-in.txt @@ -0,0 +1,157 @@ +mat3 xll_constructMat3( mat4 m) { + return mat3( vec3( m[0]), vec3( m[1]), vec3( m[2])); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +struct Input { + vec2 uv_MainTex; + vec4 color; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 lop_color; + vec3 normal; + vec3 lightDir; + vec4 _LightCoord; +}; +uniform mat4 _LightMatrix0; +uniform vec4 _MainTex_ST; +uniform mat4 _Object2World; +uniform vec4 _WaveAndDistance; +uniform vec4 _WavingTint; +uniform vec4 _WorldSpaceLightPos0; + +uniform vec4 unity_Scale; +void FastSinCos( in vec4 val, out vec4 s, out vec4 c ); +void TerrainWaveGrass( inout vec4 vertex, in float waveAmount, in vec3 color, out vec4 outColor ); +void vert( inout appdata_full v ); +vec3 WorldSpaceLightDir( in vec4 v ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +v2f_surf vert_surf( in appdata_full v ); +void FastSinCos( in vec4 val, out vec4 s, out vec4 c ) { + vec4 r5; + vec4 r6; + vec4 r7; + vec4 r8; + vec4 r1; + vec4 r2; + vec4 r3; + vec4 sin7 = vec4( 1.00000, -0.161616, 0.00833330, -0.000198410); + vec4 cos8 = vec4( -0.500000, 0.0416667, -0.00138889, 2.48016e-005); + val = ((val * 6.40885) - 3.14159); + r5 = (val * val); + r6 = (r5 * r5); + r7 = (r6 * r5); + r8 = (r6 * r5); + r1 = (r5 * val); + r2 = (r1 * r5); + r3 = (r2 * r5); + s = (((val + (r1 * sin7.y )) + (r2 * sin7.z )) + (r3 * sin7.w )); + c = ((((1.00000 + (r5 * cos8.x )) + (r6 * cos8.y )) + (r7 * cos8.z )) + (r8 * cos8.w )); +} +void TerrainWaveGrass( inout vec4 vertex, in float waveAmount, in vec3 color, out vec4 outColor ) { + vec4 _waveXSize; + vec4 _waveZSize; + vec4 waveSpeed = vec4( 1.20000, 2.00000, 1.60000, 4.80000); + vec4 _waveXmove = vec4( 0.0240000, 0.0400000, -0.120000, 0.0960000); + vec4 _waveZmove = vec4( 0.00600000, 0.0200000, -0.0200000, 0.100000); + vec4 waves; + vec4 s; + vec4 c; + float lighting; + vec3 waveMove = vec3( 0.000000, 0.000000, 0.000000); + vec3 waveColor; + _waveXSize = (vec4( 0.0120000, 0.0200000, 0.0600000, 0.0240000) * _WaveAndDistance.y ); + _waveZSize = (vec4( 0.00600000, 0.0200000, 0.0200000, 0.0500000) * _WaveAndDistance.y ); + waves = (vertex.x * _waveXSize); + waves += (vertex.z * _waveZSize); + waves += (_WaveAndDistance.x * waveSpeed); + waves = fract( waves ); + FastSinCos( waves, s, c); + s = (s * s); + s = (s * s); + lighting = (dot( s, normalize( vec4( 1.00000, 1.00000, 0.400000, 0.200000) )) * 0.700000); + s = (s * waveAmount); + waveMove.x = dot( s, _waveXmove); + waveMove.z = dot( s, _waveZmove); + vertex.xz -= (waveMove.xz * _WaveAndDistance.z ); + waveColor = mix( vec3( 0.500000, 0.500000, 0.500000), _WavingTint.xyz , vec3( lighting)); + outColor.xyz = ((color * waveColor) * 2.00000); + outColor.w = 1.00000; +} +void vert( inout appdata_full v ) { + float waveAmount; + vec4 color; + waveAmount = (v.color.w * _WaveAndDistance.z ); + TerrainWaveGrass( v.vertex, waveAmount, v.color.xyz , color); + v.color = color; +} +vec3 WorldSpaceLightDir( in vec4 v ) { + vec3 worldPos; + worldPos = ( _Object2World * v ).xyz ; + return (_WorldSpaceLightPos0.xyz - worldPos); +} +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + vert( v); + PositionFog( v.vertex, o.pos, o.fog); + o.hip_pack0.xy = ((v.texcoord.xy * _MainTex_ST.xy ) + _MainTex_ST.zw ); + o.lop_color = v.color; + o.normal = ( xll_constructMat3( _Object2World) * (v.normal * unity_Scale.w ) ); + o.lightDir = WorldSpaceLightDir( v.vertex); + o._LightCoord = ( _LightMatrix0 * ( _Object2World * v.vertex ) ); + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.hip_pack0, 0.0, 0.0); + gl_FrontColor = vec4( xl_retval.lop_color); + gl_TexCoord[1] = vec4( xl_retval.normal, 0.0); + gl_TexCoord[2] = vec4( xl_retval.lightDir, 0.0); + gl_TexCoord[3] = vec4( xl_retval._LightCoord); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_Details_WavingDoublePass1-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_Details_WavingDoublePass1-ir.txt new file mode 100644 index 000000000..2bdac3dbe --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_Details_WavingDoublePass1-ir.txt @@ -0,0 +1,346 @@ +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 lop_color; + vec3 normal; + vec3 lightDir; + vec4 _LightCoord; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform vec4 _WavingTint; +uniform vec4 _WaveAndDistance; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform mat4 _LightMatrix0; +mat3 xll_constructMat3 ( + in mat4 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = m[0].xyz; + vec3 tmpvar_2; + tmpvar_2 = m[1].xyz; + vec3 tmpvar_3; + tmpvar_3 = m[2].xyz; + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +void FastSinCos ( + in vec4 val, + out vec4 s, + out vec4 c +) +{ + vec4 cos8; + vec4 sin7; + vec4 r3; + vec4 r2; + vec4 r1; + vec4 r8; + vec4 r7; + vec4 r6; + vec4 r5; + vec4 tmpvar_1; + tmpvar_1 = vec4(1.0, -0.161616, 0.0083333, -0.00019841); + sin7 = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = vec4(-0.5, 0.0416667, -0.00138889, 2.48016e-05); + cos8 = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = ((val * 6.40885) - 3.14159); + val = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = (val * val); + r5 = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = (r5 * r5); + r6 = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = (r6 * r5); + r7 = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = (r6 * r5); + r8 = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = (r5 * val); + r1 = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = (r1 * r5); + r2 = tmpvar_9; + vec4 tmpvar_10; + tmpvar_10 = (r2 * r5); + r3 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = (((val + (r1 * sin7.y)) + (r2 * sin7.z)) + (r3 * sin7.w)); + s = tmpvar_11; + vec4 tmpvar_12; + tmpvar_12 = ((((1.0 + (r5 * cos8.x)) + (r6 * cos8.y)) + (r7 * cos8.z)) + (r8 * cos8.w)); + c = tmpvar_12; +} + +void TerrainWaveGrass ( + inout vec4 vertex, + in float waveAmount, + in vec3 color, + out vec4 outColor +) +{ + vec3 waveColor; + vec3 waveMove; + float lighting; + vec4 c; + vec4 s; + vec4 waves; + vec4 _waveZmove; + vec4 _waveXmove; + vec4 waveSpeed; + vec4 _waveZSize; + vec4 _waveXSize; + vec4 tmpvar_1; + tmpvar_1 = vec4(1.2, 2.0, 1.6, 4.8); + waveSpeed = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = vec4(0.024, 0.04, -0.12, 0.096); + _waveXmove = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = vec4(0.006, 0.02, -0.02, 0.1); + _waveZmove = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = vec3(0.0, 0.0, 0.0); + waveMove = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = (vec4(0.012, 0.02, 0.06, 0.024) * _WaveAndDistance.y); + _waveXSize = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = (vec4(0.006, 0.02, 0.02, 0.05) * _WaveAndDistance.y); + _waveZSize = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = (vertex.x * _waveXSize); + waves = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = (waves + (vertex.z * _waveZSize)); + waves = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = (waves + (_WaveAndDistance.x * waveSpeed)); + waves = tmpvar_9; + vec4 tmpvar_10; + tmpvar_10 = fract (waves); + vec4 tmpvar_11; + tmpvar_11 = tmpvar_10; + waves = tmpvar_11; + FastSinCos (waves, s, c); + vec4 tmpvar_12; + tmpvar_12 = (s * s); + s = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = (s * s); + s = tmpvar_13; + vec4 tmpvar_14; + tmpvar_14 = normalize (vec4(1.0, 1.0, 0.4, 0.2)); + float tmpvar_15; + tmpvar_15 = dot (s, tmpvar_14); + float tmpvar_16; + tmpvar_16 = (tmpvar_15 * 0.7); + lighting = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17 = (s * waveAmount); + s = tmpvar_17; + float tmpvar_18; + tmpvar_18 = dot (s, _waveXmove); + float tmpvar_19; + tmpvar_19 = tmpvar_18; + waveMove.x = tmpvar_19; + float tmpvar_20; + tmpvar_20 = dot (s, _waveZmove); + float tmpvar_21; + tmpvar_21 = tmpvar_20; + waveMove.z = vec3(tmpvar_21).z; + vec2 tmpvar_22; + tmpvar_22 = (vertex.xz - (waveMove.xz * _WaveAndDistance.z)); + vertex.xz = tmpvar_22.xxy.xz; + vec3 tmpvar_23; + tmpvar_23 = vec3(lighting); + vec3 tmpvar_24; + tmpvar_24 = mix (vec3(0.5, 0.5, 0.5), _WavingTint.xyz, tmpvar_23); + vec3 tmpvar_25; + tmpvar_25 = tmpvar_24; + waveColor = tmpvar_25; + vec3 tmpvar_26; + tmpvar_26 = ((color * waveColor) * 2.0); + outColor.xyz = tmpvar_26.xyz.xyz; + float tmpvar_27; + tmpvar_27 = 1.0; + outColor.w = vec4(tmpvar_27).w; +} + +void vert ( + inout appdata_full v +) +{ + vec4 color; + float waveAmount; + float tmpvar_1; + tmpvar_1 = (v.color.w * _WaveAndDistance.z); + waveAmount = tmpvar_1; + TerrainWaveGrass (v.vertex, waveAmount, v.color.xyz, color); + vec4 tmpvar_2; + tmpvar_2 = color; + v.color = tmpvar_2; +} + +vec3 WorldSpaceLightDir ( + in vec4 v +) +{ + vec3 worldPos; + vec3 tmpvar_1; + tmpvar_1 = (_Object2World * v).xyz; + worldPos = tmpvar_1; + return (_WorldSpaceLightPos0.xyz - worldPos); +} + +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + v2f_surf o; + vert (v); + PositionFog (v.vertex, o.pos, o.fog); + vec2 tmpvar_1; + tmpvar_1 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + o.hip_pack0 = tmpvar_1.xy.xy; + vec4 tmpvar_2; + tmpvar_2 = v.color; + o.lop_color = tmpvar_2; + mat3 tmpvar_3; + tmpvar_3 = (xll_constructMat3 (_Object2World)); + vec3 tmpvar_4; + tmpvar_4 = (tmpvar_3 * (v.normal * unity_Scale.w)); + o.normal = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = WorldSpaceLightDir (v.vertex); + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + o.lightDir = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = (_LightMatrix0 * (_Object2World * v.vertex)); + o._LightCoord = tmpvar_7; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = xl_retval.fog; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_FOG = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19.zw = vec2(0.0, 0.0); + tmpvar_19.xy = xl_retval.hip_pack0.xy; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[0] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21 = xl_retval.lop_color.xyzw; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_FrontColor = tmpvar_22; + vec4 tmpvar_23; + tmpvar_23.w = 0.0; + tmpvar_23.xyz = xl_retval.normal.xyz; + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + gl_TexCoord[1] = tmpvar_24; + vec4 tmpvar_25; + tmpvar_25.w = 0.0; + tmpvar_25.xyz = xl_retval.lightDir.xyz; + vec4 tmpvar_26; + tmpvar_26 = tmpvar_25; + gl_TexCoord[2] = tmpvar_26; + vec4 tmpvar_27; + tmpvar_27 = xl_retval._LightCoord.xyzw; + vec4 tmpvar_28; + tmpvar_28 = tmpvar_27; + gl_TexCoord[3] = tmpvar_28; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_Details_WavingDoublePass1-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_Details_WavingDoublePass1-out.txt new file mode 100644 index 000000000..a032a431a --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_Details_WavingDoublePass1-out.txt @@ -0,0 +1,63 @@ +varying vec4 xlv_FOG; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform vec4 _WavingTint; +uniform vec4 _WaveAndDistance; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform mat4 _LightMatrix0; +void main () +{ + vec4 vertex; + vertex = gl_Vertex; + vec4 outColor; + vec3 waveMove; + waveMove = vec3(0.0, 0.0, 0.0); + vec4 tmpvar_1; + tmpvar_1 = ((fract ((((gl_Vertex.x * (vec4(0.012, 0.02, 0.06, 0.024) * _WaveAndDistance.y)) + (gl_Vertex.z * (vec4(0.006, 0.02, 0.02, 0.05) * _WaveAndDistance.y))) + (_WaveAndDistance.x * vec4(1.2, 2.0, 1.6, 4.8)))) * 6.40885) - 3.14159); + vec4 tmpvar_2; + tmpvar_2 = (tmpvar_1 * tmpvar_1); + vec4 tmpvar_3; + tmpvar_3 = (tmpvar_2 * tmpvar_1); + vec4 tmpvar_4; + tmpvar_4 = (tmpvar_3 * tmpvar_2); + vec4 tmpvar_5; + tmpvar_5 = (((tmpvar_1 + (tmpvar_3 * -0.161616)) + (tmpvar_4 * 0.0083333)) + ((tmpvar_4 * tmpvar_2) * -0.00019841)); + vec4 tmpvar_6; + tmpvar_6 = (tmpvar_5 * tmpvar_5); + vec4 tmpvar_7; + tmpvar_7 = (tmpvar_6 * tmpvar_6); + vec4 tmpvar_8; + tmpvar_8 = (tmpvar_7 * (gl_Color.w * _WaveAndDistance.z)); + waveMove.x = dot (tmpvar_8, vec4(0.024, 0.04, -0.12, 0.096)); + waveMove.z = dot (tmpvar_8, vec4(0.006, 0.02, -0.02, 0.1)); + vertex.xz = (gl_Vertex.xz - (waveMove.xz * _WaveAndDistance.z)); + outColor.xyz = ((gl_Color.xyz * mix (vec3(0.5, 0.5, 0.5), _WavingTint.xyz, vec3((dot (tmpvar_7, vec4(0.6742, 0.6742, 0.26968, 0.13484)) * 0.7)))) * 2.0); + outColor.w = 1.0; + vec4 tmpvar_9; + tmpvar_9 = (gl_ModelViewProjectionMatrix * vertex); + mat3 tmpvar_10; + tmpvar_10[0] = _Object2World[0].xyz; + tmpvar_10[1] = _Object2World[1].xyz; + tmpvar_10[2] = _Object2World[2].xyz; + gl_Position = tmpvar_9; + vec4 tmpvar_11; + tmpvar_11.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_11.x = tmpvar_9.z; + xlv_FOG = tmpvar_11; + vec4 tmpvar_12; + tmpvar_12.zw = vec2(0.0, 0.0); + tmpvar_12.xy = ((gl_MultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + gl_TexCoord[0] = tmpvar_12; + gl_FrontColor = outColor; + vec4 tmpvar_13; + tmpvar_13.w = 0.0; + tmpvar_13.xyz = (tmpvar_10 * (gl_Normal * unity_Scale.w)); + gl_TexCoord[1] = tmpvar_13; + vec4 tmpvar_14; + tmpvar_14.w = 0.0; + tmpvar_14.xyz = (_WorldSpaceLightPos0.xyz - (_Object2World * vertex).xyz); + gl_TexCoord[2] = tmpvar_14; + gl_TexCoord[3] = (_LightMatrix0 * (_Object2World * vertex)); +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_Soft_Occlusion_Bark_rendertex-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_Soft_Occlusion_Bark_rendertex-in.txt new file mode 100644 index 000000000..3deff8f58 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_Soft_Occlusion_Bark_rendertex-in.txt @@ -0,0 +1,101 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct v2f { + vec4 pos; + float fog; + vec4 uv; + vec4 color; +}; +struct appdata_tree { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 color; + vec4 texcoord; +}; +uniform float _AO; +uniform vec4 _Color; +uniform vec4 _Scale; +uniform float _SquashAmount; +uniform vec4 _SquashPlaneNormal; +uniform mat4 _TerrainEngineBendTree; +uniform vec4 _TerrainTreeLightColors[4]; +uniform vec3 _TerrainTreeLightDirections[4]; + + + +vec4 Squash( in vec4 pos ); +void TerrainAnimateTree( inout vec4 pos, in float alpha ); +v2f vert( in appdata_tree v ); +vec4 Squash( in vec4 pos ) { + vec3 projectedVertex; + vec3 planePoint; + vec3 planeNormal; + projectedVertex = pos.xyz ; + planePoint = vec3( 0.000000, _SquashPlaneNormal.w , 0.000000); + planeNormal = _SquashPlaneNormal.xyz ; + projectedVertex += (dot( planeNormal, (planePoint - vec3( pos))) * planeNormal); + pos = vec4( mix( projectedVertex, pos.xyz , vec3( _SquashAmount)), 1.00000); + return pos; +} +void TerrainAnimateTree( inout vec4 pos, in float alpha ) { + vec3 bent; + pos.xyz *= _Scale.xyz ; + bent = ( _TerrainEngineBendTree * vec4( pos.xyz , 0.000000) ).xyz ; + pos.xyz = mix( pos.xyz , bent, vec3( alpha)); + pos = Squash( pos); +} +v2f vert( in appdata_tree v ) { + vec3 viewpos; + v2f o; + vec4 lightDir; + vec4 lightColor; + int i = 0; + float atten = 1.00000; + float occ; + TerrainAnimateTree( v.vertex, v.color.w ); + viewpos = vec3( ( gl_ModelViewMatrix * v.vertex )); + o.pos = ( gl_ModelViewProjectionMatrix * v.vertex ); + o.fog = o.pos.z ; + o.uv = v.texcoord; + lightDir.w = _AO; + lightColor = gl_LightModel.ambient; + for ( ; (i < 4); ( i++ )) { + lightDir.xyz = _TerrainTreeLightDirections[ i ]; + occ = dot( lightDir.xyz , v.normal); + occ = max( 0.000000, occ); + occ *= atten; + lightColor += (_TerrainTreeLightColors[ i ] * occ); + } + lightColor.w = 1.00000; + o.color = (lightColor * _Color); + o.color.w = 1.00000; + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f xl_retval; + appdata_tree xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.color = vec4( gl_Color); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xl_retval = vert( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.uv); + gl_FrontColor = vec4( xl_retval.color); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_Soft_Occlusion_Bark_rendertex-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_Soft_Occlusion_Bark_rendertex-ir.txt new file mode 100644 index 000000000..d09aa2002 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_Soft_Occlusion_Bark_rendertex-ir.txt @@ -0,0 +1,227 @@ +struct v2f { + vec4 pos; + float fog; + vec4 uv; + vec4 color; +}; +struct appdata_tree { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 color; + vec4 texcoord; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec3 _TerrainTreeLightDirections[4]; +uniform vec4 _TerrainTreeLightColors[4]; +uniform mat4 _TerrainEngineBendTree; +uniform vec4 _SquashPlaneNormal; +uniform float _SquashAmount; +uniform vec4 _Scale; +uniform vec4 _Color; +uniform float _AO; +vec4 Squash ( + in vec4 pos +) +{ + vec3 planeNormal; + vec3 planePoint; + vec3 projectedVertex; + vec3 tmpvar_1; + tmpvar_1 = pos.xyz; + projectedVertex = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2.xz = vec2(0.0, 0.0); + tmpvar_2.y = _SquashPlaneNormal.w; + vec3 tmpvar_3; + tmpvar_3 = tmpvar_2; + planePoint = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = _SquashPlaneNormal.xyz; + planeNormal = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = pos.xyz; + float tmpvar_6; + tmpvar_6 = dot (planeNormal, (planePoint - tmpvar_5)); + vec3 tmpvar_7; + tmpvar_7 = (projectedVertex + (tmpvar_6 * planeNormal)); + projectedVertex = tmpvar_7; + vec3 tmpvar_8; + tmpvar_8 = vec3(_SquashAmount); + vec3 tmpvar_9; + tmpvar_9 = mix (projectedVertex, pos.xyz, tmpvar_8); + vec4 tmpvar_10; + tmpvar_10.w = 1.0; + tmpvar_10.xyz = tmpvar_9.xyz; + vec4 tmpvar_11; + tmpvar_11 = tmpvar_10; + pos = tmpvar_11; + return pos; +} + +void TerrainAnimateTree ( + inout vec4 pos, + in float alpha +) +{ + vec3 bent; + vec3 tmpvar_1; + tmpvar_1 = (pos.xyz * _Scale.xyz); + pos.xyz = tmpvar_1.xyz.xyz; + vec4 tmpvar_2; + tmpvar_2.w = 0.0; + tmpvar_2.xyz = pos.xyz.xyz; + vec3 tmpvar_3; + tmpvar_3 = (_TerrainEngineBendTree * tmpvar_2).xyz; + bent = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = vec3(alpha); + vec3 tmpvar_5; + tmpvar_5 = mix (pos.xyz, bent, tmpvar_4); + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + pos.xyz = tmpvar_6.xyz.xyz; + vec4 tmpvar_7; + tmpvar_7 = Squash (pos); + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + pos = tmpvar_8; +} + +v2f vert ( + in appdata_tree v +) +{ + float occ; + float atten; + int i; + vec4 lightColor; + vec4 lightDir; + v2f o; + vec3 viewpos; + int tmpvar_1; + tmpvar_1 = 0; + i = tmpvar_1; + float tmpvar_2; + tmpvar_2 = 1.0; + atten = tmpvar_2; + TerrainAnimateTree (v.vertex, v.color.w); + vec3 tmpvar_3; + tmpvar_3 = (gl_ModelViewMatrix * v.vertex).xyz; + vec3 tmpvar_4; + tmpvar_4 = tmpvar_3; + viewpos = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = (gl_ModelViewProjectionMatrix * v.vertex); + o.pos = tmpvar_5; + float tmpvar_6; + tmpvar_6 = o.pos.z; + o.fog = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = v.texcoord; + o.uv = tmpvar_7; + float tmpvar_8; + tmpvar_8 = _AO; + lightDir.w = vec4(tmpvar_8).w; + vec4 tmpvar_9; + tmpvar_9 = gl_LightModel.ambient; + lightColor = tmpvar_9; + while (true) { + if (!((i < 4))) { + break; + }; + vec3 tmpvar_10; + tmpvar_10 = _TerrainTreeLightDirections[i]; + lightDir.xyz = tmpvar_10.xyz.xyz; + float tmpvar_11; + tmpvar_11 = dot (lightDir.xyz, v.normal); + float tmpvar_12; + tmpvar_12 = tmpvar_11; + occ = tmpvar_12; + float tmpvar_13; + tmpvar_13 = max (0.0, occ); + float tmpvar_14; + tmpvar_14 = tmpvar_13; + occ = tmpvar_14; + float tmpvar_15; + tmpvar_15 = (occ * atten); + occ = tmpvar_15; + vec4 tmpvar_16; + tmpvar_16 = (lightColor + (_TerrainTreeLightColors[i] * occ)); + lightColor = tmpvar_16; + int _post_incdec_tmp; + _post_incdec_tmp = i; + int tmpvar_17; + tmpvar_17 = (i + 1); + i = tmpvar_17; + }; + float tmpvar_18; + tmpvar_18 = 1.0; + lightColor.w = vec4(tmpvar_18).w; + vec4 tmpvar_19; + tmpvar_19 = (lightColor * _Color); + o.color = tmpvar_19; + float tmpvar_20; + tmpvar_20 = 1.0; + o.color.w = vec4(tmpvar_20).w; + return o; +} + +void main () +{ + appdata_tree xlt_v; + v2f xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_Color.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.color = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord = tmpvar_10; + v2f tmpvar_11; + tmpvar_11 = vert (xlt_v); + v2f tmpvar_12; + tmpvar_12 = tmpvar_11; + xl_retval = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = xl_retval.pos.xyzw; + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + gl_Position = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_15.x = xl_retval.fog; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + xlv_FOG = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17 = xl_retval.uv.xyzw; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + gl_TexCoord[0] = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19 = xl_retval.color.xyzw; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_FrontColor = tmpvar_20; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_Soft_Occlusion_Bark_rendertex-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_Soft_Occlusion_Bark_rendertex-out.txt new file mode 100644 index 000000000..d42892552 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_Soft_Occlusion_Bark_rendertex-out.txt @@ -0,0 +1,52 @@ +varying vec4 xlv_FOG; +uniform vec3 _TerrainTreeLightDirections[4]; +uniform vec4 _TerrainTreeLightColors[4]; +uniform mat4 _TerrainEngineBendTree; +uniform vec4 _SquashPlaneNormal; +uniform float _SquashAmount; +uniform vec4 _Scale; +uniform vec4 _Color; +uniform float _AO; +void main () +{ + vec4 lightColor; + vec4 lightDir; + vec4 tmpvar_1; + vec4 pos; + pos = gl_Vertex; + pos.xyz = (gl_Vertex.xyz * _Scale.xyz); + vec4 tmpvar_2; + tmpvar_2.w = 0.0; + tmpvar_2.xyz = pos.xyz; + pos.xyz = mix (pos.xyz, (_TerrainEngineBendTree * tmpvar_2).xyz, gl_Color.www); + vec3 tmpvar_3; + tmpvar_3.xz = vec2(0.0, 0.0); + tmpvar_3.y = _SquashPlaneNormal.w; + vec4 tmpvar_4; + tmpvar_4.w = 1.0; + tmpvar_4.xyz = mix ((pos.xyz + (dot (_SquashPlaneNormal.xyz, (tmpvar_3 - pos.xyz)) * _SquashPlaneNormal.xyz)), pos.xyz, vec3(_SquashAmount)); + pos = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = (gl_ModelViewProjectionMatrix * tmpvar_4); + lightDir.w = _AO; + lightColor = gl_LightModel.ambient; + lightDir.xyz = _TerrainTreeLightDirections[0]; + lightColor = (lightColor + (_TerrainTreeLightColors[0] * max (0.0, dot (lightDir.xyz, gl_Normal)))); + lightDir.xyz = _TerrainTreeLightDirections[1]; + lightColor = (lightColor + (_TerrainTreeLightColors[1] * max (0.0, dot (lightDir.xyz, gl_Normal)))); + lightDir.xyz = _TerrainTreeLightDirections[2]; + lightColor = (lightColor + (_TerrainTreeLightColors[2] * max (0.0, dot (lightDir.xyz, gl_Normal)))); + lightDir.xyz = _TerrainTreeLightDirections[3]; + lightColor = (lightColor + (_TerrainTreeLightColors[3] * max (0.0, dot (lightDir.xyz, gl_Normal)))); + lightColor.w = 1.0; + tmpvar_1 = (lightColor * _Color); + tmpvar_1.w = 1.0; + gl_Position = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_6.x = tmpvar_5.z; + xlv_FOG = tmpvar_6; + gl_TexCoord[0] = gl_MultiTexCoord0; + gl_FrontColor = tmpvar_1; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_Soft_Occlusion_Leaves_rendertex-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_Soft_Occlusion_Leaves_rendertex-in.txt new file mode 100644 index 000000000..3deff8f58 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_Soft_Occlusion_Leaves_rendertex-in.txt @@ -0,0 +1,101 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct v2f { + vec4 pos; + float fog; + vec4 uv; + vec4 color; +}; +struct appdata_tree { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 color; + vec4 texcoord; +}; +uniform float _AO; +uniform vec4 _Color; +uniform vec4 _Scale; +uniform float _SquashAmount; +uniform vec4 _SquashPlaneNormal; +uniform mat4 _TerrainEngineBendTree; +uniform vec4 _TerrainTreeLightColors[4]; +uniform vec3 _TerrainTreeLightDirections[4]; + + + +vec4 Squash( in vec4 pos ); +void TerrainAnimateTree( inout vec4 pos, in float alpha ); +v2f vert( in appdata_tree v ); +vec4 Squash( in vec4 pos ) { + vec3 projectedVertex; + vec3 planePoint; + vec3 planeNormal; + projectedVertex = pos.xyz ; + planePoint = vec3( 0.000000, _SquashPlaneNormal.w , 0.000000); + planeNormal = _SquashPlaneNormal.xyz ; + projectedVertex += (dot( planeNormal, (planePoint - vec3( pos))) * planeNormal); + pos = vec4( mix( projectedVertex, pos.xyz , vec3( _SquashAmount)), 1.00000); + return pos; +} +void TerrainAnimateTree( inout vec4 pos, in float alpha ) { + vec3 bent; + pos.xyz *= _Scale.xyz ; + bent = ( _TerrainEngineBendTree * vec4( pos.xyz , 0.000000) ).xyz ; + pos.xyz = mix( pos.xyz , bent, vec3( alpha)); + pos = Squash( pos); +} +v2f vert( in appdata_tree v ) { + vec3 viewpos; + v2f o; + vec4 lightDir; + vec4 lightColor; + int i = 0; + float atten = 1.00000; + float occ; + TerrainAnimateTree( v.vertex, v.color.w ); + viewpos = vec3( ( gl_ModelViewMatrix * v.vertex )); + o.pos = ( gl_ModelViewProjectionMatrix * v.vertex ); + o.fog = o.pos.z ; + o.uv = v.texcoord; + lightDir.w = _AO; + lightColor = gl_LightModel.ambient; + for ( ; (i < 4); ( i++ )) { + lightDir.xyz = _TerrainTreeLightDirections[ i ]; + occ = dot( lightDir.xyz , v.normal); + occ = max( 0.000000, occ); + occ *= atten; + lightColor += (_TerrainTreeLightColors[ i ] * occ); + } + lightColor.w = 1.00000; + o.color = (lightColor * _Color); + o.color.w = 1.00000; + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f xl_retval; + appdata_tree xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.color = vec4( gl_Color); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xl_retval = vert( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.uv); + gl_FrontColor = vec4( xl_retval.color); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_Soft_Occlusion_Leaves_rendertex-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_Soft_Occlusion_Leaves_rendertex-ir.txt new file mode 100644 index 000000000..d09aa2002 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_Soft_Occlusion_Leaves_rendertex-ir.txt @@ -0,0 +1,227 @@ +struct v2f { + vec4 pos; + float fog; + vec4 uv; + vec4 color; +}; +struct appdata_tree { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 color; + vec4 texcoord; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec3 _TerrainTreeLightDirections[4]; +uniform vec4 _TerrainTreeLightColors[4]; +uniform mat4 _TerrainEngineBendTree; +uniform vec4 _SquashPlaneNormal; +uniform float _SquashAmount; +uniform vec4 _Scale; +uniform vec4 _Color; +uniform float _AO; +vec4 Squash ( + in vec4 pos +) +{ + vec3 planeNormal; + vec3 planePoint; + vec3 projectedVertex; + vec3 tmpvar_1; + tmpvar_1 = pos.xyz; + projectedVertex = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2.xz = vec2(0.0, 0.0); + tmpvar_2.y = _SquashPlaneNormal.w; + vec3 tmpvar_3; + tmpvar_3 = tmpvar_2; + planePoint = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = _SquashPlaneNormal.xyz; + planeNormal = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = pos.xyz; + float tmpvar_6; + tmpvar_6 = dot (planeNormal, (planePoint - tmpvar_5)); + vec3 tmpvar_7; + tmpvar_7 = (projectedVertex + (tmpvar_6 * planeNormal)); + projectedVertex = tmpvar_7; + vec3 tmpvar_8; + tmpvar_8 = vec3(_SquashAmount); + vec3 tmpvar_9; + tmpvar_9 = mix (projectedVertex, pos.xyz, tmpvar_8); + vec4 tmpvar_10; + tmpvar_10.w = 1.0; + tmpvar_10.xyz = tmpvar_9.xyz; + vec4 tmpvar_11; + tmpvar_11 = tmpvar_10; + pos = tmpvar_11; + return pos; +} + +void TerrainAnimateTree ( + inout vec4 pos, + in float alpha +) +{ + vec3 bent; + vec3 tmpvar_1; + tmpvar_1 = (pos.xyz * _Scale.xyz); + pos.xyz = tmpvar_1.xyz.xyz; + vec4 tmpvar_2; + tmpvar_2.w = 0.0; + tmpvar_2.xyz = pos.xyz.xyz; + vec3 tmpvar_3; + tmpvar_3 = (_TerrainEngineBendTree * tmpvar_2).xyz; + bent = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = vec3(alpha); + vec3 tmpvar_5; + tmpvar_5 = mix (pos.xyz, bent, tmpvar_4); + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + pos.xyz = tmpvar_6.xyz.xyz; + vec4 tmpvar_7; + tmpvar_7 = Squash (pos); + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + pos = tmpvar_8; +} + +v2f vert ( + in appdata_tree v +) +{ + float occ; + float atten; + int i; + vec4 lightColor; + vec4 lightDir; + v2f o; + vec3 viewpos; + int tmpvar_1; + tmpvar_1 = 0; + i = tmpvar_1; + float tmpvar_2; + tmpvar_2 = 1.0; + atten = tmpvar_2; + TerrainAnimateTree (v.vertex, v.color.w); + vec3 tmpvar_3; + tmpvar_3 = (gl_ModelViewMatrix * v.vertex).xyz; + vec3 tmpvar_4; + tmpvar_4 = tmpvar_3; + viewpos = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = (gl_ModelViewProjectionMatrix * v.vertex); + o.pos = tmpvar_5; + float tmpvar_6; + tmpvar_6 = o.pos.z; + o.fog = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = v.texcoord; + o.uv = tmpvar_7; + float tmpvar_8; + tmpvar_8 = _AO; + lightDir.w = vec4(tmpvar_8).w; + vec4 tmpvar_9; + tmpvar_9 = gl_LightModel.ambient; + lightColor = tmpvar_9; + while (true) { + if (!((i < 4))) { + break; + }; + vec3 tmpvar_10; + tmpvar_10 = _TerrainTreeLightDirections[i]; + lightDir.xyz = tmpvar_10.xyz.xyz; + float tmpvar_11; + tmpvar_11 = dot (lightDir.xyz, v.normal); + float tmpvar_12; + tmpvar_12 = tmpvar_11; + occ = tmpvar_12; + float tmpvar_13; + tmpvar_13 = max (0.0, occ); + float tmpvar_14; + tmpvar_14 = tmpvar_13; + occ = tmpvar_14; + float tmpvar_15; + tmpvar_15 = (occ * atten); + occ = tmpvar_15; + vec4 tmpvar_16; + tmpvar_16 = (lightColor + (_TerrainTreeLightColors[i] * occ)); + lightColor = tmpvar_16; + int _post_incdec_tmp; + _post_incdec_tmp = i; + int tmpvar_17; + tmpvar_17 = (i + 1); + i = tmpvar_17; + }; + float tmpvar_18; + tmpvar_18 = 1.0; + lightColor.w = vec4(tmpvar_18).w; + vec4 tmpvar_19; + tmpvar_19 = (lightColor * _Color); + o.color = tmpvar_19; + float tmpvar_20; + tmpvar_20 = 1.0; + o.color.w = vec4(tmpvar_20).w; + return o; +} + +void main () +{ + appdata_tree xlt_v; + v2f xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_Color.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.color = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord = tmpvar_10; + v2f tmpvar_11; + tmpvar_11 = vert (xlt_v); + v2f tmpvar_12; + tmpvar_12 = tmpvar_11; + xl_retval = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = xl_retval.pos.xyzw; + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + gl_Position = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_15.x = xl_retval.fog; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + xlv_FOG = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17 = xl_retval.uv.xyzw; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + gl_TexCoord[0] = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19 = xl_retval.color.xyzw; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_FrontColor = tmpvar_20; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_Soft_Occlusion_Leaves_rendertex-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_Soft_Occlusion_Leaves_rendertex-out.txt new file mode 100644 index 000000000..d42892552 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_Soft_Occlusion_Leaves_rendertex-out.txt @@ -0,0 +1,52 @@ +varying vec4 xlv_FOG; +uniform vec3 _TerrainTreeLightDirections[4]; +uniform vec4 _TerrainTreeLightColors[4]; +uniform mat4 _TerrainEngineBendTree; +uniform vec4 _SquashPlaneNormal; +uniform float _SquashAmount; +uniform vec4 _Scale; +uniform vec4 _Color; +uniform float _AO; +void main () +{ + vec4 lightColor; + vec4 lightDir; + vec4 tmpvar_1; + vec4 pos; + pos = gl_Vertex; + pos.xyz = (gl_Vertex.xyz * _Scale.xyz); + vec4 tmpvar_2; + tmpvar_2.w = 0.0; + tmpvar_2.xyz = pos.xyz; + pos.xyz = mix (pos.xyz, (_TerrainEngineBendTree * tmpvar_2).xyz, gl_Color.www); + vec3 tmpvar_3; + tmpvar_3.xz = vec2(0.0, 0.0); + tmpvar_3.y = _SquashPlaneNormal.w; + vec4 tmpvar_4; + tmpvar_4.w = 1.0; + tmpvar_4.xyz = mix ((pos.xyz + (dot (_SquashPlaneNormal.xyz, (tmpvar_3 - pos.xyz)) * _SquashPlaneNormal.xyz)), pos.xyz, vec3(_SquashAmount)); + pos = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = (gl_ModelViewProjectionMatrix * tmpvar_4); + lightDir.w = _AO; + lightColor = gl_LightModel.ambient; + lightDir.xyz = _TerrainTreeLightDirections[0]; + lightColor = (lightColor + (_TerrainTreeLightColors[0] * max (0.0, dot (lightDir.xyz, gl_Normal)))); + lightDir.xyz = _TerrainTreeLightDirections[1]; + lightColor = (lightColor + (_TerrainTreeLightColors[1] * max (0.0, dot (lightDir.xyz, gl_Normal)))); + lightDir.xyz = _TerrainTreeLightDirections[2]; + lightColor = (lightColor + (_TerrainTreeLightColors[2] * max (0.0, dot (lightDir.xyz, gl_Normal)))); + lightDir.xyz = _TerrainTreeLightDirections[3]; + lightColor = (lightColor + (_TerrainTreeLightColors[3] * max (0.0, dot (lightDir.xyz, gl_Normal)))); + lightColor.w = 1.0; + tmpvar_1 = (lightColor * _Color); + tmpvar_1.w = 1.0; + gl_Position = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_6.x = tmpvar_5.z; + xlv_FOG = tmpvar_6; + gl_TexCoord[0] = gl_MultiTexCoord0; + gl_FrontColor = tmpvar_1; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_Splatmap_Lightmap-AddPass-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_Splatmap_Lightmap-AddPass-in.txt new file mode 100644 index 000000000..f3a8fd1b9 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_Splatmap_Lightmap-AddPass-in.txt @@ -0,0 +1,179 @@ +mat3 xll_constructMat3( mat4 m) { + return mat3( vec3( m[0]), vec3( m[1]), vec3( m[2])); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_Control; + vec2 uv_Splat0; + vec2 uv_Splat1; + vec2 uv_Splat2; + vec2 uv_Splat3; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec4 hip_pack1; + vec2 hip_pack2; + vec3 normal; + vec3 vlight; + vec4 _ShadowCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _Control_ST; +uniform mat4 _Object2World; +uniform vec4 _ProjectionParams; +uniform vec4 _Splat0_ST; +uniform vec4 _Splat1_ST; +uniform vec4 _Splat2_ST; +uniform vec4 _Splat3_ST; + +uniform vec4 unity_4LightAtten0; +uniform vec4 unity_4LightPosX0; +uniform vec4 unity_4LightPosY0; +uniform vec4 unity_4LightPosZ0; +uniform vec3 unity_LightColor0; +uniform vec3 unity_LightColor1; +uniform vec3 unity_LightColor2; +uniform vec3 unity_LightColor3; +uniform vec4 unity_SHAb; +uniform vec4 unity_SHAg; +uniform vec4 unity_SHAr; +uniform vec4 unity_SHBb; +uniform vec4 unity_SHBg; +uniform vec4 unity_SHBr; +uniform vec4 unity_SHC; +uniform vec4 unity_Scale; +vec3 ShadeSH9( in vec4 normal ); +vec3 Shade4PointLights( in vec4 lightPosX, in vec4 lightPosY, in vec4 lightPosZ, in vec3 lightColor0, in vec3 lightColor1, in vec3 lightColor2, in vec3 lightColor3, in vec4 lightAttenSq, in vec3 pos, in vec3 normal ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +vec4 ComputeScreenPos( in vec4 pos ); +v2f_surf vert_surf( in appdata_full v ); +vec3 ShadeSH9( in vec4 normal ) { + vec3 x1; + vec4 vB; + vec3 x2; + float vC; + vec3 x3; + x1.x = dot( unity_SHAr, normal); + x1.y = dot( unity_SHAg, normal); + x1.z = dot( unity_SHAb, normal); + vB = (normal.xyzz * normal.yzzx ); + x2.x = dot( unity_SHBr, vB); + x2.y = dot( unity_SHBg, vB); + x2.z = dot( unity_SHBb, vB); + vC = ((normal.x * normal.x ) - (normal.y * normal.y )); + x3 = (unity_SHC.xyz * vC); + return ((x1 + x2) + x3); +} +vec3 Shade4PointLights( in vec4 lightPosX, in vec4 lightPosY, in vec4 lightPosZ, in vec3 lightColor0, in vec3 lightColor1, in vec3 lightColor2, in vec3 lightColor3, in vec4 lightAttenSq, in vec3 pos, in vec3 normal ) { + vec4 toLightX; + vec4 toLightY; + vec4 toLightZ; + vec4 lengthSq; + vec4 ndotl; + vec4 corr; + vec4 atten; + vec4 diff; + vec3 col; + toLightX = (lightPosX - pos.x ); + toLightY = (lightPosY - pos.y ); + toLightZ = (lightPosZ - pos.z ); + lengthSq = vec4( 0.000000); + lengthSq += (toLightX * toLightX); + lengthSq += (toLightY * toLightY); + lengthSq += (toLightZ * toLightZ); + ndotl = vec4( 0.000000); + ndotl += (toLightX * normal.x ); + ndotl += (toLightY * normal.y ); + ndotl += (toLightZ * normal.z ); + corr = inversesqrt( lengthSq ); + ndotl = max( vec4( 0.000000, 0.000000, 0.000000, 0.000000), (ndotl * corr)); + atten = (1.00000 / (1.00000 + (lengthSq * lightAttenSq))); + diff = (ndotl * atten); + col = vec3( 0.000000); + col += (lightColor0 * diff.x ); + col += (lightColor1 * diff.y ); + col += (lightColor2 * diff.z ); + col += (lightColor3 * diff.w ); + return col; +} +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +vec4 ComputeScreenPos( in vec4 pos ) { + vec4 o; + o = (pos * 0.500000); + o.xy = (vec2( o.x , (o.y * _ProjectionParams.x )) + o.w ); + o.zw = pos.zw ; + return o; +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + vec3 worldN; + vec3 shlight; + vec3 worldPos; + PositionFog( v.vertex, o.pos, o.fog); + o.hip_pack0.xy = ((v.texcoord.xy * _Control_ST.xy ) + _Control_ST.zw ); + o.hip_pack0.zw = ((v.texcoord.xy * _Splat0_ST.xy ) + _Splat0_ST.zw ); + o.hip_pack1.xy = ((v.texcoord.xy * _Splat1_ST.xy ) + _Splat1_ST.zw ); + o.hip_pack1.zw = ((v.texcoord.xy * _Splat2_ST.xy ) + _Splat2_ST.zw ); + o.hip_pack2.xy = ((v.texcoord.xy * _Splat3_ST.xy ) + _Splat3_ST.zw ); + worldN = ( xll_constructMat3( _Object2World) * (v.normal * unity_Scale.w ) ); + o.normal = worldN; + shlight = ShadeSH9( vec4( worldN, 1.00000)); + o.vlight = shlight; + worldPos = ( _Object2World * v.vertex ).xyz ; + o.vlight += Shade4PointLights( unity_4LightPosX0, unity_4LightPosY0, unity_4LightPosZ0, unity_LightColor0, unity_LightColor1, unity_LightColor2, unity_LightColor3, unity_4LightAtten0, worldPos, worldN); + o._ShadowCoord = ComputeScreenPos( o.pos); + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.hip_pack0); + gl_TexCoord[1] = vec4( xl_retval.hip_pack1); + gl_TexCoord[2] = vec4( xl_retval.hip_pack2, 0.0, 0.0); + gl_TexCoord[3] = vec4( xl_retval.normal, 0.0); + gl_TexCoord[4] = vec4( xl_retval.vlight, 0.0); + gl_TexCoord[5] = vec4( xl_retval._ShadowCoord); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_Splatmap_Lightmap-AddPass-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_Splatmap_Lightmap-AddPass-ir.txt new file mode 100644 index 000000000..a7e6fe4be --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_Splatmap_Lightmap-AddPass-ir.txt @@ -0,0 +1,384 @@ +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec4 hip_pack1; + vec2 hip_pack2; + vec3 normal; + vec3 vlight; + vec4 _ShadowCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec4 unity_SHC; +uniform vec4 unity_SHBr; +uniform vec4 unity_SHBg; +uniform vec4 unity_SHBb; +uniform vec4 unity_SHAr; +uniform vec4 unity_SHAg; +uniform vec4 unity_SHAb; +uniform vec3 unity_LightColor3; +uniform vec3 unity_LightColor2; +uniform vec3 unity_LightColor1; +uniform vec3 unity_LightColor0; +uniform vec4 unity_4LightPosZ0; +uniform vec4 unity_4LightPosY0; +uniform vec4 unity_4LightPosX0; +uniform vec4 unity_4LightAtten0; +uniform vec4 _Splat3_ST; +uniform vec4 _Splat2_ST; +uniform vec4 _Splat1_ST; +uniform vec4 _Splat0_ST; +uniform vec4 _ProjectionParams; +uniform mat4 _Object2World; +uniform vec4 _Control_ST; +mat3 xll_constructMat3 ( + in mat4 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = m[0].xyz; + vec3 tmpvar_2; + tmpvar_2 = m[1].xyz; + vec3 tmpvar_3; + tmpvar_3 = m[2].xyz; + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +vec3 ShadeSH9 ( + in vec4 normal +) +{ + vec3 x3; + float vC; + vec3 x2; + vec4 vB; + vec3 x1; + float tmpvar_1; + tmpvar_1 = dot (unity_SHAr, normal); + float tmpvar_2; + tmpvar_2 = tmpvar_1; + x1.x = tmpvar_2; + float tmpvar_3; + tmpvar_3 = dot (unity_SHAg, normal); + float tmpvar_4; + tmpvar_4 = tmpvar_3; + x1.y = vec2(tmpvar_4).y; + float tmpvar_5; + tmpvar_5 = dot (unity_SHAb, normal); + float tmpvar_6; + tmpvar_6 = tmpvar_5; + x1.z = vec3(tmpvar_6).z; + vec4 tmpvar_7; + tmpvar_7 = (normal.xyzz * normal.yzzx); + vB = tmpvar_7; + float tmpvar_8; + tmpvar_8 = dot (unity_SHBr, vB); + float tmpvar_9; + tmpvar_9 = tmpvar_8; + x2.x = tmpvar_9; + float tmpvar_10; + tmpvar_10 = dot (unity_SHBg, vB); + float tmpvar_11; + tmpvar_11 = tmpvar_10; + x2.y = vec2(tmpvar_11).y; + float tmpvar_12; + tmpvar_12 = dot (unity_SHBb, vB); + float tmpvar_13; + tmpvar_13 = tmpvar_12; + x2.z = vec3(tmpvar_13).z; + float tmpvar_14; + tmpvar_14 = ((normal.x * normal.x) - (normal.y * normal.y)); + vC = tmpvar_14; + vec3 tmpvar_15; + tmpvar_15 = (unity_SHC.xyz * vC); + x3 = tmpvar_15; + return ((x1 + x2) + x3); +} + +vec3 Shade4PointLights ( + in vec4 lightPosX, + in vec4 lightPosY, + in vec4 lightPosZ, + in vec3 lightColor0, + in vec3 lightColor1, + in vec3 lightColor2, + in vec3 lightColor3, + in vec4 lightAttenSq, + in vec3 pos, + in vec3 normal +) +{ + vec3 col; + vec4 diff; + vec4 atten; + vec4 corr; + vec4 ndotl; + vec4 lengthSq; + vec4 toLightZ; + vec4 toLightY; + vec4 toLightX; + vec4 tmpvar_1; + tmpvar_1 = (lightPosX - pos.x); + toLightX = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = (lightPosY - pos.y); + toLightY = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = (lightPosZ - pos.z); + toLightZ = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = vec4(0.0, 0.0, 0.0, 0.0); + lengthSq = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = (lengthSq + (toLightX * toLightX)); + lengthSq = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = (lengthSq + (toLightY * toLightY)); + lengthSq = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = (lengthSq + (toLightZ * toLightZ)); + lengthSq = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = vec4(0.0, 0.0, 0.0, 0.0); + ndotl = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = (ndotl + (toLightX * normal.x)); + ndotl = tmpvar_9; + vec4 tmpvar_10; + tmpvar_10 = (ndotl + (toLightY * normal.y)); + ndotl = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = (ndotl + (toLightZ * normal.z)); + ndotl = tmpvar_11; + vec4 tmpvar_12; + tmpvar_12 = inversesqrt (lengthSq); + vec4 tmpvar_13; + tmpvar_13 = tmpvar_12; + corr = tmpvar_13; + vec4 tmpvar_14; + tmpvar_14 = max (vec4(0.0, 0.0, 0.0, 0.0), (ndotl * corr)); + vec4 tmpvar_15; + tmpvar_15 = tmpvar_14; + ndotl = tmpvar_15; + vec4 tmpvar_16; + tmpvar_16 = (1.0 / (1.0 + (lengthSq * lightAttenSq))); + atten = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17 = (ndotl * atten); + diff = tmpvar_17; + vec3 tmpvar_18; + tmpvar_18 = vec3(0.0, 0.0, 0.0); + col = tmpvar_18; + vec3 tmpvar_19; + tmpvar_19 = (col + (lightColor0 * diff.x)); + col = tmpvar_19; + vec3 tmpvar_20; + tmpvar_20 = (col + (lightColor1 * diff.y)); + col = tmpvar_20; + vec3 tmpvar_21; + tmpvar_21 = (col + (lightColor2 * diff.z)); + col = tmpvar_21; + vec3 tmpvar_22; + tmpvar_22 = (col + (lightColor3 * diff.w)); + col = tmpvar_22; + return col; +} + +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +vec4 ComputeScreenPos ( + in vec4 pos +) +{ + vec4 o; + vec4 tmpvar_1; + tmpvar_1 = (pos * 0.5); + o = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2.x = o.x; + tmpvar_2.y = (o.y * _ProjectionParams.x); + vec2 tmpvar_3; + tmpvar_3 = (tmpvar_2 + o.w); + o.xy = tmpvar_3.xy.xy; + vec2 tmpvar_4; + tmpvar_4 = pos.zw; + o.zw = tmpvar_4.xxxy.zw; + return o; +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + vec3 worldPos; + vec3 shlight; + vec3 worldN; + v2f_surf o; + PositionFog (v.vertex, o.pos, o.fog); + vec2 tmpvar_1; + tmpvar_1 = ((v.texcoord.xy * _Control_ST.xy) + _Control_ST.zw); + o.hip_pack0.xy = tmpvar_1.xy.xy; + vec2 tmpvar_2; + tmpvar_2 = ((v.texcoord.xy * _Splat0_ST.xy) + _Splat0_ST.zw); + o.hip_pack0.zw = tmpvar_2.xxxy.zw; + vec2 tmpvar_3; + tmpvar_3 = ((v.texcoord.xy * _Splat1_ST.xy) + _Splat1_ST.zw); + o.hip_pack1.xy = tmpvar_3.xy.xy; + vec2 tmpvar_4; + tmpvar_4 = ((v.texcoord.xy * _Splat2_ST.xy) + _Splat2_ST.zw); + o.hip_pack1.zw = tmpvar_4.xxxy.zw; + vec2 tmpvar_5; + tmpvar_5 = ((v.texcoord.xy * _Splat3_ST.xy) + _Splat3_ST.zw); + o.hip_pack2 = tmpvar_5.xy.xy; + mat3 tmpvar_6; + tmpvar_6 = (xll_constructMat3 (_Object2World)); + vec3 tmpvar_7; + tmpvar_7 = (tmpvar_6 * (v.normal * unity_Scale.w)); + worldN = tmpvar_7; + vec3 tmpvar_8; + tmpvar_8 = worldN; + o.normal = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9.w = 1.0; + tmpvar_9.xyz = worldN.xyz; + vec3 tmpvar_10; + tmpvar_10 = ShadeSH9 (tmpvar_9); + vec3 tmpvar_11; + tmpvar_11 = tmpvar_10; + shlight = tmpvar_11; + vec3 tmpvar_12; + tmpvar_12 = shlight; + o.vlight = tmpvar_12; + vec3 tmpvar_13; + tmpvar_13 = (_Object2World * v.vertex).xyz; + worldPos = tmpvar_13; + vec3 tmpvar_14; + tmpvar_14 = Shade4PointLights (unity_4LightPosX0, unity_4LightPosY0, unity_4LightPosZ0, unity_LightColor0, unity_LightColor1, unity_LightColor2, unity_LightColor3, unity_4LightAtten0, worldPos, worldN); + vec3 tmpvar_15; + tmpvar_15 = (o.vlight + tmpvar_14); + o.vlight = tmpvar_15; + vec4 tmpvar_16; + tmpvar_16 = ComputeScreenPos (o.pos); + vec4 tmpvar_17; + tmpvar_17 = tmpvar_16; + o._ShadowCoord = tmpvar_17; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = xl_retval.fog; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_FOG = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19 = xl_retval.hip_pack0.xyzw; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[0] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21 = xl_retval.hip_pack1.xyzw; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_TexCoord[1] = tmpvar_22; + vec4 tmpvar_23; + tmpvar_23.zw = vec2(0.0, 0.0); + tmpvar_23.xy = xl_retval.hip_pack2.xy; + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + gl_TexCoord[2] = tmpvar_24; + vec4 tmpvar_25; + tmpvar_25.w = 0.0; + tmpvar_25.xyz = xl_retval.normal.xyz; + vec4 tmpvar_26; + tmpvar_26 = tmpvar_25; + gl_TexCoord[3] = tmpvar_26; + vec4 tmpvar_27; + tmpvar_27.w = 0.0; + tmpvar_27.xyz = xl_retval.vlight.xyz; + vec4 tmpvar_28; + tmpvar_28 = tmpvar_27; + gl_TexCoord[4] = tmpvar_28; + vec4 tmpvar_29; + tmpvar_29 = xl_retval._ShadowCoord.xyzw; + vec4 tmpvar_30; + tmpvar_30 = tmpvar_29; + gl_TexCoord[5] = tmpvar_30; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_Splatmap_Lightmap-AddPass-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_Splatmap_Lightmap-AddPass-out.txt new file mode 100644 index 000000000..fadbb41b9 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_Splatmap_Lightmap-AddPass-out.txt @@ -0,0 +1,96 @@ +varying vec4 xlv_FOG; +uniform vec4 unity_Scale; +uniform vec4 unity_SHC; +uniform vec4 unity_SHBr; +uniform vec4 unity_SHBg; +uniform vec4 unity_SHBb; +uniform vec4 unity_SHAr; +uniform vec4 unity_SHAg; +uniform vec4 unity_SHAb; +uniform vec3 unity_LightColor3; +uniform vec3 unity_LightColor2; +uniform vec3 unity_LightColor1; +uniform vec3 unity_LightColor0; +uniform vec4 unity_4LightPosZ0; +uniform vec4 unity_4LightPosY0; +uniform vec4 unity_4LightPosX0; +uniform vec4 unity_4LightAtten0; +uniform vec4 _Splat3_ST; +uniform vec4 _Splat2_ST; +uniform vec4 _Splat1_ST; +uniform vec4 _Splat0_ST; +uniform vec4 _ProjectionParams; +uniform mat4 _Object2World; +uniform vec4 _Control_ST; +void main () +{ + vec4 tmpvar_1; + vec4 tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = (gl_ModelViewProjectionMatrix * gl_Vertex); + tmpvar_1.xy = ((gl_MultiTexCoord0.xy * _Control_ST.xy) + _Control_ST.zw); + tmpvar_1.zw = ((gl_MultiTexCoord0.xy * _Splat0_ST.xy) + _Splat0_ST.zw); + tmpvar_2.xy = ((gl_MultiTexCoord0.xy * _Splat1_ST.xy) + _Splat1_ST.zw); + tmpvar_2.zw = ((gl_MultiTexCoord0.xy * _Splat2_ST.xy) + _Splat2_ST.zw); + mat3 tmpvar_4; + tmpvar_4[0] = _Object2World[0].xyz; + tmpvar_4[1] = _Object2World[1].xyz; + tmpvar_4[2] = _Object2World[2].xyz; + vec3 tmpvar_5; + tmpvar_5 = (tmpvar_4 * (gl_Normal * unity_Scale.w)); + vec4 tmpvar_6; + tmpvar_6.w = 1.0; + tmpvar_6.xyz = tmpvar_5; + vec3 x2; + vec3 x1; + x1.x = dot (unity_SHAr, tmpvar_6); + x1.y = dot (unity_SHAg, tmpvar_6); + x1.z = dot (unity_SHAb, tmpvar_6); + vec4 tmpvar_7; + tmpvar_7 = (tmpvar_5.xyzz * tmpvar_5.yzzx); + x2.x = dot (unity_SHBr, tmpvar_7); + x2.y = dot (unity_SHBg, tmpvar_7); + x2.z = dot (unity_SHBb, tmpvar_7); + vec3 tmpvar_8; + tmpvar_8 = (_Object2World * gl_Vertex).xyz; + vec4 tmpvar_9; + tmpvar_9 = (unity_4LightPosX0 - tmpvar_8.x); + vec4 tmpvar_10; + tmpvar_10 = (unity_4LightPosY0 - tmpvar_8.y); + vec4 tmpvar_11; + tmpvar_11 = (unity_4LightPosZ0 - tmpvar_8.z); + vec4 tmpvar_12; + tmpvar_12 = (((tmpvar_9 * tmpvar_9) + (tmpvar_10 * tmpvar_10)) + (tmpvar_11 * tmpvar_11)); + vec4 tmpvar_13; + tmpvar_13 = (max (vec4(0.0, 0.0, 0.0, 0.0), ((((tmpvar_9 * tmpvar_5.x) + (tmpvar_10 * tmpvar_5.y)) + (tmpvar_11 * tmpvar_5.z)) * inversesqrt (tmpvar_12))) * (1.0/((1.0 + (tmpvar_12 * unity_4LightAtten0))))); + vec4 o_i0; + vec4 tmpvar_14; + tmpvar_14 = (tmpvar_3 * 0.5); + o_i0 = tmpvar_14; + vec2 tmpvar_15; + tmpvar_15.x = tmpvar_14.x; + tmpvar_15.y = (tmpvar_14.y * _ProjectionParams.x); + o_i0.xy = (tmpvar_15 + tmpvar_14.w); + o_i0.zw = tmpvar_3.zw; + gl_Position = tmpvar_3; + vec4 tmpvar_16; + tmpvar_16.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_16.x = tmpvar_3.z; + xlv_FOG = tmpvar_16; + gl_TexCoord[0] = tmpvar_1; + gl_TexCoord[1] = tmpvar_2; + vec4 tmpvar_17; + tmpvar_17.zw = vec2(0.0, 0.0); + tmpvar_17.xy = ((gl_MultiTexCoord0.xy * _Splat3_ST.xy) + _Splat3_ST.zw); + gl_TexCoord[2] = tmpvar_17; + vec4 tmpvar_18; + tmpvar_18.w = 0.0; + tmpvar_18.xyz = tmpvar_5; + gl_TexCoord[3] = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19.w = 0.0; + tmpvar_19.xyz = (((x1 + x2) + (unity_SHC.xyz * ((tmpvar_5.x * tmpvar_5.x) - (tmpvar_5.y * tmpvar_5.y)))) + ((((unity_LightColor0 * tmpvar_13.x) + (unity_LightColor1 * tmpvar_13.y)) + (unity_LightColor2 * tmpvar_13.z)) + (unity_LightColor3 * tmpvar_13.w))); + gl_TexCoord[4] = tmpvar_19; + gl_TexCoord[5] = o_i0; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_Splatmap_Lightmap-FirstPass1-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_Splatmap_Lightmap-FirstPass1-in.txt new file mode 100644 index 000000000..941fcce09 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_Splatmap_Lightmap-FirstPass1-in.txt @@ -0,0 +1,102 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_Control; + vec2 uv_Splat0; + vec2 uv_Splat1; + vec2 uv_Splat2; + vec2 uv_Splat3; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec4 hip_pack1; + vec2 hip_pack2; + vec4 hip_screen; + vec3 hip_lmapFade; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _Control_ST; +uniform vec4 _ProjectionParams; +uniform vec4 _Splat0_ST; +uniform vec4 _Splat1_ST; +uniform vec4 _Splat2_ST; +uniform vec4 _Splat3_ST; + + +uniform vec4 unity_LightmapFade; +uniform vec4 unity_LightmapST; +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +vec4 ComputeScreenPos( in vec4 pos ); +v2f_surf vert_surf( in appdata_full v ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +vec4 ComputeScreenPos( in vec4 pos ) { + vec4 o; + o = (pos * 0.500000); + o.xy = (vec2( o.x , (o.y * _ProjectionParams.x )) + o.w ); + o.zw = pos.zw ; + return o; +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + PositionFog( v.vertex, o.pos, o.fog); + o.hip_pack0.xy = ((v.texcoord.xy * _Control_ST.xy ) + _Control_ST.zw ); + o.hip_pack0.zw = ((v.texcoord.xy * _Splat0_ST.xy ) + _Splat0_ST.zw ); + o.hip_pack1.xy = ((v.texcoord.xy * _Splat1_ST.xy ) + _Splat1_ST.zw ); + o.hip_pack1.zw = ((v.texcoord.xy * _Splat2_ST.xy ) + _Splat2_ST.zw ); + o.hip_pack2.xy = ((v.texcoord.xy * _Splat3_ST.xy ) + _Splat3_ST.zw ); + o.hip_screen = ComputeScreenPos( o.pos); + o.hip_lmapFade.xy = ((v.texcoord1.xy * unity_LightmapST.xy ) + unity_LightmapST.zw ); + o.hip_lmapFade.z = ((( -( gl_ModelViewMatrix * v.vertex ).z ) * unity_LightmapFade.z ) + unity_LightmapFade.w ); + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.hip_pack0); + gl_TexCoord[1] = vec4( xl_retval.hip_pack1); + gl_TexCoord[2] = vec4( xl_retval.hip_pack2, 0.0, 0.0); + gl_TexCoord[3] = vec4( xl_retval.hip_screen); + gl_TexCoord[4] = vec4( xl_retval.hip_lmapFade, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_Splatmap_Lightmap-FirstPass1-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_Splatmap_Lightmap-FirstPass1-ir.txt new file mode 100644 index 000000000..1b7af9e76 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_Splatmap_Lightmap-FirstPass1-ir.txt @@ -0,0 +1,175 @@ +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec4 hip_pack1; + vec2 hip_pack2; + vec4 hip_screen; + vec3 hip_lmapFade; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_LightmapST; +uniform vec4 unity_LightmapFade; +uniform vec4 _Splat3_ST; +uniform vec4 _Splat2_ST; +uniform vec4 _Splat1_ST; +uniform vec4 _Splat0_ST; +uniform vec4 _ProjectionParams; +uniform vec4 _Control_ST; +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +vec4 ComputeScreenPos ( + in vec4 pos +) +{ + vec4 o; + vec4 tmpvar_1; + tmpvar_1 = (pos * 0.5); + o = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2.x = o.x; + tmpvar_2.y = (o.y * _ProjectionParams.x); + vec2 tmpvar_3; + tmpvar_3 = (tmpvar_2 + o.w); + o.xy = tmpvar_3.xy.xy; + vec2 tmpvar_4; + tmpvar_4 = pos.zw; + o.zw = tmpvar_4.xxxy.zw; + return o; +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + v2f_surf o; + PositionFog (v.vertex, o.pos, o.fog); + vec2 tmpvar_1; + tmpvar_1 = ((v.texcoord.xy * _Control_ST.xy) + _Control_ST.zw); + o.hip_pack0.xy = tmpvar_1.xy.xy; + vec2 tmpvar_2; + tmpvar_2 = ((v.texcoord.xy * _Splat0_ST.xy) + _Splat0_ST.zw); + o.hip_pack0.zw = tmpvar_2.xxxy.zw; + vec2 tmpvar_3; + tmpvar_3 = ((v.texcoord.xy * _Splat1_ST.xy) + _Splat1_ST.zw); + o.hip_pack1.xy = tmpvar_3.xy.xy; + vec2 tmpvar_4; + tmpvar_4 = ((v.texcoord.xy * _Splat2_ST.xy) + _Splat2_ST.zw); + o.hip_pack1.zw = tmpvar_4.xxxy.zw; + vec2 tmpvar_5; + tmpvar_5 = ((v.texcoord.xy * _Splat3_ST.xy) + _Splat3_ST.zw); + o.hip_pack2 = tmpvar_5.xy.xy; + vec4 tmpvar_6; + tmpvar_6 = ComputeScreenPos (o.pos); + vec4 tmpvar_7; + tmpvar_7 = tmpvar_6; + o.hip_screen = tmpvar_7; + vec2 tmpvar_8; + tmpvar_8 = ((v.texcoord1.xy * unity_LightmapST.xy) + unity_LightmapST.zw); + o.hip_lmapFade.xy = tmpvar_8.xy.xy; + float tmpvar_9; + tmpvar_9 = ((-((gl_ModelViewMatrix * v.vertex).z) * unity_LightmapFade.z) + unity_LightmapFade.w); + o.hip_lmapFade.z = vec3(tmpvar_9).z; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = xl_retval.fog; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_FOG = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19 = xl_retval.hip_pack0.xyzw; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[0] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21 = xl_retval.hip_pack1.xyzw; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_TexCoord[1] = tmpvar_22; + vec4 tmpvar_23; + tmpvar_23.zw = vec2(0.0, 0.0); + tmpvar_23.xy = xl_retval.hip_pack2.xy; + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + gl_TexCoord[2] = tmpvar_24; + vec4 tmpvar_25; + tmpvar_25 = xl_retval.hip_screen.xyzw; + vec4 tmpvar_26; + tmpvar_26 = tmpvar_25; + gl_TexCoord[3] = tmpvar_26; + vec4 tmpvar_27; + tmpvar_27.w = 0.0; + tmpvar_27.xyz = xl_retval.hip_lmapFade.xyz; + vec4 tmpvar_28; + tmpvar_28 = tmpvar_27; + gl_TexCoord[4] = tmpvar_28; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_Splatmap_Lightmap-FirstPass1-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_Splatmap_Lightmap-FirstPass1-out.txt new file mode 100644 index 000000000..88957a7a7 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_TerrainEngine_Splatmap_Lightmap-FirstPass1-out.txt @@ -0,0 +1,49 @@ +varying vec4 xlv_FOG; +uniform vec4 unity_LightmapST; +uniform vec4 unity_LightmapFade; +uniform vec4 _Splat3_ST; +uniform vec4 _Splat2_ST; +uniform vec4 _Splat1_ST; +uniform vec4 _Splat0_ST; +uniform vec4 _ProjectionParams; +uniform vec4 _Control_ST; +void main () +{ + vec4 tmpvar_1; + vec4 tmpvar_2; + vec3 tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = (gl_ModelViewProjectionMatrix * gl_Vertex); + tmpvar_1.xy = ((gl_MultiTexCoord0.xy * _Control_ST.xy) + _Control_ST.zw); + tmpvar_1.zw = ((gl_MultiTexCoord0.xy * _Splat0_ST.xy) + _Splat0_ST.zw); + tmpvar_2.xy = ((gl_MultiTexCoord0.xy * _Splat1_ST.xy) + _Splat1_ST.zw); + tmpvar_2.zw = ((gl_MultiTexCoord0.xy * _Splat2_ST.xy) + _Splat2_ST.zw); + vec4 o_i0; + vec4 tmpvar_5; + tmpvar_5 = (tmpvar_4 * 0.5); + o_i0 = tmpvar_5; + vec2 tmpvar_6; + tmpvar_6.x = tmpvar_5.x; + tmpvar_6.y = (tmpvar_5.y * _ProjectionParams.x); + o_i0.xy = (tmpvar_6 + tmpvar_5.w); + o_i0.zw = tmpvar_4.zw; + tmpvar_3.xy = ((gl_MultiTexCoord1.xy * unity_LightmapST.xy) + unity_LightmapST.zw); + tmpvar_3.z = ((-((gl_ModelViewMatrix * gl_Vertex).z) * unity_LightmapFade.z) + unity_LightmapFade.w); + gl_Position = tmpvar_4; + vec4 tmpvar_7; + tmpvar_7.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_7.x = tmpvar_4.z; + xlv_FOG = tmpvar_7; + gl_TexCoord[0] = tmpvar_1; + gl_TexCoord[1] = tmpvar_2; + vec4 tmpvar_8; + tmpvar_8.zw = vec2(0.0, 0.0); + tmpvar_8.xy = ((gl_MultiTexCoord0.xy * _Splat3_ST.xy) + _Splat3_ST.zw); + gl_TexCoord[2] = tmpvar_8; + gl_TexCoord[3] = o_i0; + vec4 tmpvar_9; + tmpvar_9.w = 0.0; + tmpvar_9.xyz = tmpvar_3; + gl_TexCoord[4] = tmpvar_9; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Tree_Bark_Shader_Rendertex-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Tree_Bark_Shader_Rendertex-in.txt new file mode 100644 index 000000000..8c062b20a --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Tree_Bark_Shader_Rendertex-in.txt @@ -0,0 +1,63 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct v2f { + vec4 pos; + vec2 uv; + vec3 color; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _TerrainTreeLightColors[4]; +uniform vec3 _TerrainTreeLightDirections[4]; + + +v2f vert( in appdata_full v ); +v2f vert( in appdata_full v ) { + v2f o; + vec3 lightColor; + int i = 0; + vec3 lightDir; + float diff; + o.pos = ( gl_ModelViewProjectionMatrix * v.vertex ); + o.uv = v.texcoord.xy ; + lightColor = gl_LightModel.ambient.xyz ; + for ( ; (i < 4); ( i++ )) { + lightDir.xyz = _TerrainTreeLightDirections[ i ]; + diff = max( 0.000000, dot( lightDir.xyz , v.normal)); + lightColor += vec3( (_TerrainTreeLightColors[ i ] * diff)); + } + o.color = (lightColor * v.color.w ); + return o; +} +attribute vec4 TANGENT; +void main() { + v2f xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert( xlt_v); + gl_Position = vec4( xl_retval.pos); + gl_TexCoord[0] = vec4( xl_retval.uv, 0.0, 0.0); + gl_TexCoord[1] = vec4( xl_retval.color, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Tree_Bark_Shader_Rendertex-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Tree_Bark_Shader_Rendertex-ir.txt new file mode 100644 index 000000000..01a6175ad --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Tree_Bark_Shader_Rendertex-ir.txt @@ -0,0 +1,126 @@ +struct v2f { + vec4 pos; + vec2 uv; + vec3 color; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +attribute vec4 TANGENT; +uniform vec3 _TerrainTreeLightDirections[4]; +uniform vec4 _TerrainTreeLightColors[4]; +v2f vert ( + in appdata_full v +) +{ + float diff; + vec3 lightDir; + int i; + vec3 lightColor; + v2f o; + int tmpvar_1; + tmpvar_1 = 0; + i = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = (gl_ModelViewProjectionMatrix * v.vertex); + o.pos = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = v.texcoord.xy; + o.uv = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = gl_LightModel.ambient.xyz; + lightColor = tmpvar_4; + while (true) { + if (!((i < 4))) { + break; + }; + vec3 tmpvar_5; + tmpvar_5 = _TerrainTreeLightDirections[i]; + lightDir = tmpvar_5.xyz.xyz; + float tmpvar_6; + tmpvar_6 = dot (lightDir.xyz, v.normal); + float tmpvar_7; + tmpvar_7 = max (0.0, tmpvar_6); + float tmpvar_8; + tmpvar_8 = tmpvar_7; + diff = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = (_TerrainTreeLightColors[i] * diff).xyz; + vec3 tmpvar_10; + tmpvar_10 = (lightColor + tmpvar_9); + lightColor = tmpvar_10; + int _post_incdec_tmp; + _post_incdec_tmp = i; + int tmpvar_11; + tmpvar_11 = (i + 1); + i = tmpvar_11; + }; + vec3 tmpvar_12; + tmpvar_12 = (lightColor * v.color.w); + o.color = tmpvar_12; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f tmpvar_13; + tmpvar_13 = vert (xlt_v); + v2f tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.zw = vec2(0.0, 0.0); + tmpvar_17.xy = xl_retval.uv.xy; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + gl_TexCoord[0] = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19.w = 0.0; + tmpvar_19.xyz = xl_retval.color.xyz; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[1] = tmpvar_20; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Tree_Bark_Shader_Rendertex-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Tree_Bark_Shader_Rendertex-out.txt new file mode 100644 index 000000000..e8ecbc903 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Tree_Bark_Shader_Rendertex-out.txt @@ -0,0 +1,21 @@ +uniform vec3 _TerrainTreeLightDirections[4]; +uniform vec4 _TerrainTreeLightColors[4]; +void main () +{ + vec3 lightColor; + lightColor = gl_LightModel.ambient.xyz; + lightColor = (lightColor + (_TerrainTreeLightColors[0] * max (0.0, dot (_TerrainTreeLightDirections[0], gl_Normal))).xyz); + lightColor = (lightColor + (_TerrainTreeLightColors[1] * max (0.0, dot (_TerrainTreeLightDirections[1], gl_Normal))).xyz); + lightColor = (lightColor + (_TerrainTreeLightColors[2] * max (0.0, dot (_TerrainTreeLightDirections[2], gl_Normal))).xyz); + lightColor = (lightColor + (_TerrainTreeLightColors[3] * max (0.0, dot (_TerrainTreeLightDirections[3], gl_Normal))).xyz); + gl_Position = (gl_ModelViewProjectionMatrix * gl_Vertex); + vec4 tmpvar_1; + tmpvar_1.zw = vec2(0.0, 0.0); + tmpvar_1.xy = gl_MultiTexCoord0.xy; + gl_TexCoord[0] = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2.w = 0.0; + tmpvar_2.xyz = (lightColor * gl_Color.w); + gl_TexCoord[1] = tmpvar_2; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Tree_Leaf_Shader_Rendertex-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Tree_Leaf_Shader_Rendertex-in.txt new file mode 100644 index 000000000..7f2f23484 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Tree_Leaf_Shader_Rendertex-in.txt @@ -0,0 +1,94 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +struct LeafSurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + vec3 Translucency; + float Specular; + float Gloss; + float Alpha; +}; +struct v2f { + vec4 pos; + vec2 uv; + vec3 color; +}; +uniform vec4 _TerrainTreeLightColors[4]; +uniform vec3 _TerrainTreeLightDirections[4]; + + + +void ExpandBillboard( in mat4 mat, inout vec4 pos, inout vec3 normal, inout vec4 tangent ); +v2f vert( in appdata_full v ); +void ExpandBillboard( in mat4 mat, inout vec4 pos, inout vec3 normal, inout vec4 tangent ) { + float isBillboard; + vec3 norb; + vec3 tanb; + isBillboard = (1.00000 - abs( tangent.w )); + norb = vec3( normalize( ( vec4( normal, 0.000000) * mat ) )); + tanb = vec3( normalize( ( vec4( normal.z , 0.000000, ( -normal.x ), 0.000000) * mat ) )); + pos += (( tangent * mat ) * isBillboard); + normal = mix( normal, norb, vec3( isBillboard)); + tangent = mix( tangent, vec4( tanb, -1.00000), vec4( isBillboard)); +} +v2f vert( in appdata_full v ) { + v2f o; + vec3 lightColor; + int i = 0; + vec3 lightDir; + float diff; + ExpandBillboard( gl_ModelViewMatrixInverseTranspose, v.vertex, v.normal, v.tangent); + o.pos = ( gl_ModelViewProjectionMatrix * v.vertex ); + o.uv = v.texcoord.xy ; + lightColor = gl_LightModel.ambient.xyz ; + for ( ; (i < 4); ( i++ )) { + lightDir.xyz = _TerrainTreeLightDirections[ i ]; + diff = max( 0.000000, ((dot( lightDir.xyz , v.normal) * 0.500000) + 0.500000)); + lightColor += vec3( (_TerrainTreeLightColors[ i ] * diff)); + } + o.color = (lightColor * v.color.w ); + return o; +} +attribute vec4 TANGENT; +void main() { + v2f xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert( xlt_v); + gl_Position = vec4( xl_retval.pos); + gl_TexCoord[0] = vec4( xl_retval.uv, 0.0, 0.0); + gl_TexCoord[1] = vec4( xl_retval.color, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Tree_Leaf_Shader_Rendertex-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Tree_Leaf_Shader_Rendertex-ir.txt new file mode 100644 index 000000000..faf3df628 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Tree_Leaf_Shader_Rendertex-ir.txt @@ -0,0 +1,185 @@ +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +struct v2f { + vec4 pos; + vec2 uv; + vec3 color; +}; +attribute vec4 TANGENT; +uniform vec3 _TerrainTreeLightDirections[4]; +uniform vec4 _TerrainTreeLightColors[4]; +void ExpandBillboard ( + in mat4 mat, + inout vec4 pos, + inout vec3 normal, + inout vec4 tangent +) +{ + vec3 tanb; + vec3 norb; + float isBillboard; + float tmpvar_1; + tmpvar_1 = abs (tangent.w); + float tmpvar_2; + tmpvar_2 = (1.0 - tmpvar_1); + isBillboard = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3.w = 0.0; + tmpvar_3.xyz = normal.xyz; + vec4 tmpvar_4; + tmpvar_4 = normalize ((tmpvar_3 * mat)); + vec3 tmpvar_5; + tmpvar_5 = tmpvar_4.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + norb = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7.yw = vec2(0.0, 0.0); + tmpvar_7.x = normal.z; + tmpvar_7.z = -(normal.x); + vec4 tmpvar_8; + tmpvar_8 = normalize ((tmpvar_7 * mat)); + vec3 tmpvar_9; + tmpvar_9 = tmpvar_8.xyz; + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + tanb = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = (pos + ((tangent * mat) * isBillboard)); + pos = tmpvar_11; + vec3 tmpvar_12; + tmpvar_12 = vec3(isBillboard); + vec3 tmpvar_13; + tmpvar_13 = mix (normal, norb, tmpvar_12); + vec3 tmpvar_14; + tmpvar_14 = tmpvar_13; + normal = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15.w = -1.0; + tmpvar_15.xyz = tanb.xyz; + vec4 tmpvar_16; + tmpvar_16 = vec4(isBillboard); + vec4 tmpvar_17; + tmpvar_17 = mix (tangent, tmpvar_15, tmpvar_16); + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + tangent = tmpvar_18; +} + +v2f vert ( + in appdata_full v +) +{ + float diff; + vec3 lightDir; + int i; + vec3 lightColor; + v2f o; + int tmpvar_1; + tmpvar_1 = 0; + i = tmpvar_1; + ExpandBillboard (gl_ModelViewMatrixInverseTranspose, v.vertex, v.normal, v.tangent); + vec4 tmpvar_2; + tmpvar_2 = (gl_ModelViewProjectionMatrix * v.vertex); + o.pos = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = v.texcoord.xy; + o.uv = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = gl_LightModel.ambient.xyz; + lightColor = tmpvar_4; + while (true) { + if (!((i < 4))) { + break; + }; + vec3 tmpvar_5; + tmpvar_5 = _TerrainTreeLightDirections[i]; + lightDir = tmpvar_5.xyz.xyz; + float tmpvar_6; + tmpvar_6 = dot (lightDir.xyz, v.normal); + float tmpvar_7; + tmpvar_7 = max (0.0, ((tmpvar_6 * 0.5) + 0.5)); + float tmpvar_8; + tmpvar_8 = tmpvar_7; + diff = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = (_TerrainTreeLightColors[i] * diff).xyz; + vec3 tmpvar_10; + tmpvar_10 = (lightColor + tmpvar_9); + lightColor = tmpvar_10; + int _post_incdec_tmp; + _post_incdec_tmp = i; + int tmpvar_11; + tmpvar_11 = (i + 1); + i = tmpvar_11; + }; + vec3 tmpvar_12; + tmpvar_12 = (lightColor * v.color.w); + o.color = tmpvar_12; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f tmpvar_13; + tmpvar_13 = vert (xlt_v); + v2f tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.zw = vec2(0.0, 0.0); + tmpvar_17.xy = xl_retval.uv.xy; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + gl_TexCoord[0] = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19.w = 0.0; + tmpvar_19.xyz = xl_retval.color.xyz; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[1] = tmpvar_20; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Tree_Leaf_Shader_Rendertex-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Tree_Leaf_Shader_Rendertex-out.txt new file mode 100644 index 000000000..bf43c699b --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Tree_Leaf_Shader_Rendertex-out.txt @@ -0,0 +1,29 @@ +attribute vec4 TANGENT; +uniform vec3 _TerrainTreeLightDirections[4]; +uniform vec4 _TerrainTreeLightColors[4]; +void main () +{ + vec3 lightColor; + float tmpvar_1; + tmpvar_1 = (1.0 - abs (TANGENT.w)); + vec4 tmpvar_2; + tmpvar_2.w = 0.0; + tmpvar_2.xyz = gl_Normal; + vec3 tmpvar_3; + tmpvar_3 = mix (gl_Normal, normalize ((tmpvar_2 * gl_ModelViewMatrixInverseTranspose)).xyz, vec3(tmpvar_1)); + lightColor = gl_LightModel.ambient.xyz; + lightColor = (lightColor + (_TerrainTreeLightColors[0] * max (0.0, ((dot (_TerrainTreeLightDirections[0], tmpvar_3) * 0.5) + 0.5))).xyz); + lightColor = (lightColor + (_TerrainTreeLightColors[1] * max (0.0, ((dot (_TerrainTreeLightDirections[1], tmpvar_3) * 0.5) + 0.5))).xyz); + lightColor = (lightColor + (_TerrainTreeLightColors[2] * max (0.0, ((dot (_TerrainTreeLightDirections[2], tmpvar_3) * 0.5) + 0.5))).xyz); + lightColor = (lightColor + (_TerrainTreeLightColors[3] * max (0.0, ((dot (_TerrainTreeLightDirections[3], tmpvar_3) * 0.5) + 0.5))).xyz); + gl_Position = (gl_ModelViewProjectionMatrix * (gl_Vertex + ((TANGENT * gl_ModelViewMatrixInverseTranspose) * tmpvar_1))); + vec4 tmpvar_4; + tmpvar_4.zw = vec2(0.0, 0.0); + tmpvar_4.xy = gl_MultiTexCoord0.xy; + gl_TexCoord[0] = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5.w = 0.0; + tmpvar_5.xyz = (lightColor * gl_Color.w); + gl_TexCoord[1] = tmpvar_5; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Tree_Optimized_Bark_Shader-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Tree_Optimized_Bark_Shader-in.txt new file mode 100644 index 000000000..98804e6fe --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Tree_Optimized_Bark_Shader-in.txt @@ -0,0 +1,175 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +struct LeafSurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + vec3 Translucency; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec4 color; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 lop_color; + vec3 lightDir; + vec3 viewDir; + vec3 _LightCoord; +}; +uniform vec4 _Color; +uniform mat4 _LightMatrix0; +uniform vec4 _MainTex_ST; +uniform mat4 _Object2World; +uniform vec4 _Scale; +uniform float _SquashAmount; +uniform vec4 _SquashPlaneNormal; +uniform float _TimeX; +uniform vec4 _Wind; +uniform mat4 _World2Object; +uniform vec3 _WorldSpaceCameraPos; +uniform vec4 _WorldSpaceLightPos0; + +uniform vec4 unity_Scale; +vec4 Squash( in vec4 pos ); +vec4 TriangleWave( in vec4 x ); +vec4 SmoothCurve( in vec4 x ); +vec4 SmoothTriangleWave( in vec4 x ); +vec4 AnimateVertex( in vec4 pos, in vec3 normal, in vec4 animParams ); +void TreeVertBark( inout appdata_full v ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +vec3 ObjSpaceViewDir( in vec4 v ); +vec3 ObjSpaceLightDir( in vec4 v ); +v2f_surf vert_surf( in appdata_full v ); +vec4 Squash( in vec4 pos ) { + vec3 projectedVertex; + vec3 planePoint; + vec3 planeNormal; + projectedVertex = pos.xyz ; + planePoint = vec3( 0.000000, _SquashPlaneNormal.w , 0.000000); + planeNormal = _SquashPlaneNormal.xyz ; + projectedVertex += (dot( planeNormal, (planePoint - vec3( pos))) * planeNormal); + pos = vec4( mix( projectedVertex, pos.xyz , vec3( _SquashAmount)), 1.00000); + return pos; +} +vec4 TriangleWave( in vec4 x ) { + return abs( ((fract( (x + 0.500000) ) * 2.00000) - 1.00000) ); +} +vec4 SmoothCurve( in vec4 x ) { + return ((x * x) * (3.00000 - (2.00000 * x))); +} +vec4 SmoothTriangleWave( in vec4 x ) { + return SmoothCurve( TriangleWave( x)); +} +vec4 AnimateVertex( in vec4 pos, in vec3 normal, in vec4 animParams ) { + float fDetailAmp = 0.100000; + float fBranchAmp = 0.300000; + float fObjPhase; + float fBranchPhase; + float fVtxPhase; + vec2 vWavesIn; + vec4 vWaves; + vec2 vWavesSum; + vec3 bend; + fObjPhase = dot( _Object2World[ 3 ].xyz , vec3( 1.00000)); + fBranchPhase = (fObjPhase + animParams.x ); + fVtxPhase = dot( pos.xyz , vec3( (animParams.y + fBranchPhase))); + vWavesIn = (_TimeX + vec2( fVtxPhase, fBranchPhase)); + vWaves = ((fract( (vWavesIn.xxyy * vec4( 1.97500, 0.793000, 0.375000, 0.193000)) ) * 2.00000) - 1.00000); + vWaves = SmoothTriangleWave( vWaves); + vWavesSum = (vWaves.xz + vWaves.yw ); + bend = ((animParams.y * fDetailAmp) * normal.xyz ); + bend.y = (animParams.w * fBranchAmp); + pos.xyz += (((vWavesSum.xyx * bend) + ((_Wind.xyz * vWavesSum.y ) * animParams.w )) * _Wind.w ); + pos.xyz += (animParams.z * _Wind.xyz ); + return pos; +} +void TreeVertBark( inout appdata_full v ) { + v.vertex.xyz *= _Scale.xyz ; + v.vertex = AnimateVertex( v.vertex, v.normal, vec4( v.color.xy , v.texcoord1.xy )); + v.vertex = Squash( v.vertex); + v.color = vec4( (v.color.w * _Color.xyz ), _Color.w ); + v.normal = normalize( v.normal ); + v.tangent.xyz = normalize( v.tangent.xyz ); +} +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +vec3 ObjSpaceViewDir( in vec4 v ) { + vec3 objSpaceCameraPos; + objSpaceCameraPos = (( _World2Object * vec4( _WorldSpaceCameraPos.xyz , 1.00000) ).xyz * unity_Scale.w ); + return (objSpaceCameraPos - v.xyz ); +} +vec3 ObjSpaceLightDir( in vec4 v ) { + vec3 objSpaceLightPos; + objSpaceLightPos = ( _World2Object * _WorldSpaceLightPos0 ).xyz ; + return ((objSpaceLightPos.xyz * unity_Scale.w ) - v.xyz ); +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + vec3 binormal; + mat3 rotation; + TreeVertBark( v); + PositionFog( v.vertex, o.pos, o.fog); + o.hip_pack0.xy = ((v.texcoord.xy * _MainTex_ST.xy ) + _MainTex_ST.zw ); + o.lop_color = v.color; + binormal = (cross( v.normal, v.tangent.xyz ) * v.tangent.w ); + rotation = mat3( v.tangent.x , binormal.x , v.normal.x , v.tangent.y , binormal.y , v.normal.y , v.tangent.z , binormal.z , v.normal.z ); + o.lightDir = ( rotation * ObjSpaceLightDir( v.vertex) ); + o.viewDir = ( rotation * ObjSpaceViewDir( v.vertex) ); + o._LightCoord = ( _LightMatrix0 * ( _Object2World * v.vertex ) ).xyz ; + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.hip_pack0, 0.0, 0.0); + gl_FrontColor = vec4( xl_retval.lop_color); + gl_TexCoord[1] = vec4( xl_retval.lightDir, 0.0); + gl_TexCoord[2] = vec4( xl_retval.viewDir, 0.0); + gl_TexCoord[3] = vec4( xl_retval._LightCoord, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Tree_Optimized_Bark_Shader-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Tree_Optimized_Bark_Shader-ir.txt new file mode 100644 index 000000000..ac29aa707 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Tree_Optimized_Bark_Shader-ir.txt @@ -0,0 +1,395 @@ +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 lop_color; + vec3 lightDir; + vec3 viewDir; + vec3 _LightCoord; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform vec3 _WorldSpaceCameraPos; +uniform mat4 _World2Object; +uniform vec4 _Wind; +uniform float _TimeX; +uniform vec4 _SquashPlaneNormal; +uniform float _SquashAmount; +uniform vec4 _Scale; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform mat4 _LightMatrix0; +uniform vec4 _Color; +vec4 Squash ( + in vec4 pos +) +{ + vec3 planeNormal; + vec3 planePoint; + vec3 projectedVertex; + vec3 tmpvar_1; + tmpvar_1 = pos.xyz; + projectedVertex = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2.xz = vec2(0.0, 0.0); + tmpvar_2.y = _SquashPlaneNormal.w; + vec3 tmpvar_3; + tmpvar_3 = tmpvar_2; + planePoint = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = _SquashPlaneNormal.xyz; + planeNormal = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = pos.xyz; + float tmpvar_6; + tmpvar_6 = dot (planeNormal, (planePoint - tmpvar_5)); + vec3 tmpvar_7; + tmpvar_7 = (projectedVertex + (tmpvar_6 * planeNormal)); + projectedVertex = tmpvar_7; + vec3 tmpvar_8; + tmpvar_8 = vec3(_SquashAmount); + vec3 tmpvar_9; + tmpvar_9 = mix (projectedVertex, pos.xyz, tmpvar_8); + vec4 tmpvar_10; + tmpvar_10.w = 1.0; + tmpvar_10.xyz = tmpvar_9.xyz; + vec4 tmpvar_11; + tmpvar_11 = tmpvar_10; + pos = tmpvar_11; + return pos; +} + +vec4 TriangleWave ( + in vec4 x +) +{ + vec4 tmpvar_1; + tmpvar_1 = fract ((x + 0.5)); + vec4 tmpvar_2; + tmpvar_2 = abs (((tmpvar_1 * 2.0) - 1.0)); + return tmpvar_2; +} + +vec4 SmoothCurve ( + in vec4 x +) +{ + return ((x * x) * (3.0 - (2.0 * x))); +} + +vec4 SmoothTriangleWave ( + in vec4 x +) +{ + vec4 tmpvar_1; + tmpvar_1 = TriangleWave (x); + vec4 tmpvar_2; + tmpvar_2 = SmoothCurve (tmpvar_1); + return tmpvar_2; +} + +vec4 AnimateVertex ( + in vec4 pos, + in vec3 normal, + in vec4 animParams +) +{ + vec3 bend; + vec2 vWavesSum; + vec4 vWaves; + vec2 vWavesIn; + float fVtxPhase; + float fBranchPhase; + float fObjPhase; + float fBranchAmp; + float fDetailAmp; + float tmpvar_1; + tmpvar_1 = 0.1; + fDetailAmp = tmpvar_1; + float tmpvar_2; + tmpvar_2 = 0.3; + fBranchAmp = tmpvar_2; + float tmpvar_3; + tmpvar_3 = dot (_Object2World[3].xyz, vec3(1.0, 1.0, 1.0)); + float tmpvar_4; + tmpvar_4 = tmpvar_3; + fObjPhase = tmpvar_4; + float tmpvar_5; + tmpvar_5 = (fObjPhase + animParams.x); + fBranchPhase = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = vec3((animParams.y + fBranchPhase)); + float tmpvar_7; + tmpvar_7 = dot (pos.xyz, tmpvar_6); + float tmpvar_8; + tmpvar_8 = tmpvar_7; + fVtxPhase = tmpvar_8; + vec2 tmpvar_9; + tmpvar_9.x = fVtxPhase; + tmpvar_9.y = fBranchPhase; + vec2 tmpvar_10; + tmpvar_10 = (_TimeX + tmpvar_9); + vWavesIn = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = fract ((vWavesIn.xxyy * vec4(1.975, 0.793, 0.375, 0.193))); + vec4 tmpvar_12; + tmpvar_12 = ((tmpvar_11 * 2.0) - 1.0); + vWaves = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = SmoothTriangleWave (vWaves); + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + vWaves = tmpvar_14; + vec2 tmpvar_15; + tmpvar_15 = (vWaves.xz + vWaves.yw); + vWavesSum = tmpvar_15; + vec3 tmpvar_16; + tmpvar_16 = ((animParams.y * fDetailAmp) * normal.xyz); + bend = tmpvar_16; + float tmpvar_17; + tmpvar_17 = (animParams.w * fBranchAmp); + bend.y = vec2(tmpvar_17).y; + vec3 tmpvar_18; + tmpvar_18 = (pos.xyz + (((vWavesSum.xyx * bend) + ((_Wind.xyz * vWavesSum.y) * animParams.w)) * _Wind.w)); + pos.xyz = tmpvar_18.xyz.xyz; + vec3 tmpvar_19; + tmpvar_19 = (pos.xyz + (animParams.z * _Wind.xyz)); + pos.xyz = tmpvar_19.xyz.xyz; + return pos; +} + +void TreeVertBark ( + inout appdata_full v +) +{ + vec3 tmpvar_1; + tmpvar_1 = (v.vertex.xyz * _Scale.xyz); + v.vertex.xyz = tmpvar_1.xyz.xyz; + vec4 tmpvar_2; + tmpvar_2.xy = v.color.xy.xy; + tmpvar_2.zw = v.texcoord1.xy.xy; + vec4 tmpvar_3; + tmpvar_3 = AnimateVertex (v.vertex, v.normal, tmpvar_2); + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + v.vertex = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = Squash (v.vertex); + vec4 tmpvar_6; + tmpvar_6 = tmpvar_5; + v.vertex = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7.xyz = (v.color.w * _Color.xyz).xyz; + tmpvar_7.w = _Color.w; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + v.color = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = normalize (v.normal); + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + v.normal = tmpvar_10; + vec3 tmpvar_11; + tmpvar_11 = normalize (v.tangent.xyz); + vec3 tmpvar_12; + tmpvar_12 = tmpvar_11; + v.tangent.xyz = tmpvar_12.xyz.xyz; +} + +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +vec3 ObjSpaceViewDir ( + in vec4 v +) +{ + vec3 objSpaceCameraPos; + vec4 tmpvar_1; + tmpvar_1.w = 1.0; + tmpvar_1.xyz = _WorldSpaceCameraPos.xyz.xyz; + vec3 tmpvar_2; + tmpvar_2 = ((_World2Object * tmpvar_1).xyz * unity_Scale.w); + objSpaceCameraPos = tmpvar_2; + return (objSpaceCameraPos - v.xyz); +} + +vec3 ObjSpaceLightDir ( + in vec4 v +) +{ + vec3 objSpaceLightPos; + vec3 tmpvar_1; + tmpvar_1 = (_World2Object * _WorldSpaceLightPos0).xyz; + objSpaceLightPos = tmpvar_1; + return ((objSpaceLightPos.xyz * unity_Scale.w) - v.xyz); +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + mat3 rotation; + vec3 binormal; + v2f_surf o; + TreeVertBark (v); + PositionFog (v.vertex, o.pos, o.fog); + vec2 tmpvar_1; + tmpvar_1 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + o.hip_pack0 = tmpvar_1.xy.xy; + vec4 tmpvar_2; + tmpvar_2 = v.color; + o.lop_color = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = cross (v.normal, v.tangent.xyz); + vec3 tmpvar_4; + tmpvar_4 = (tmpvar_3 * v.tangent.w); + binormal = tmpvar_4; + mat3 tmpvar_5; + float tmpvar_6; + tmpvar_6 = v.tangent.x; + tmpvar_5[0].x = tmpvar_6; + float tmpvar_7; + tmpvar_7 = binormal.x; + tmpvar_5[0].y = tmpvar_7; + float tmpvar_8; + tmpvar_8 = v.normal.x; + tmpvar_5[0].z = tmpvar_8; + float tmpvar_9; + tmpvar_9 = v.tangent.y; + tmpvar_5[1].x = tmpvar_9; + float tmpvar_10; + tmpvar_10 = binormal.y; + tmpvar_5[1].y = tmpvar_10; + float tmpvar_11; + tmpvar_11 = v.normal.y; + tmpvar_5[1].z = tmpvar_11; + float tmpvar_12; + tmpvar_12 = v.tangent.z; + tmpvar_5[2].x = tmpvar_12; + float tmpvar_13; + tmpvar_13 = binormal.z; + tmpvar_5[2].y = tmpvar_13; + float tmpvar_14; + tmpvar_14 = v.normal.z; + tmpvar_5[2].z = tmpvar_14; + mat3 tmpvar_15; + tmpvar_15 = (tmpvar_5); + rotation = (tmpvar_15); + vec3 tmpvar_16; + tmpvar_16 = ObjSpaceLightDir (v.vertex); + vec3 tmpvar_17; + tmpvar_17 = (rotation * tmpvar_16); + o.lightDir = tmpvar_17; + vec3 tmpvar_18; + tmpvar_18 = ObjSpaceViewDir (v.vertex); + vec3 tmpvar_19; + tmpvar_19 = (rotation * tmpvar_18); + o.viewDir = tmpvar_19; + vec3 tmpvar_20; + tmpvar_20 = (_LightMatrix0 * (_Object2World * v.vertex)).xyz; + o._LightCoord = tmpvar_20; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = xl_retval.fog; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_FOG = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19.zw = vec2(0.0, 0.0); + tmpvar_19.xy = xl_retval.hip_pack0.xy; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[0] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21 = xl_retval.lop_color.xyzw; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_FrontColor = tmpvar_22; + vec4 tmpvar_23; + tmpvar_23.w = 0.0; + tmpvar_23.xyz = xl_retval.lightDir.xyz; + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + gl_TexCoord[1] = tmpvar_24; + vec4 tmpvar_25; + tmpvar_25.w = 0.0; + tmpvar_25.xyz = xl_retval.viewDir.xyz; + vec4 tmpvar_26; + tmpvar_26 = tmpvar_25; + gl_TexCoord[2] = tmpvar_26; + vec4 tmpvar_27; + tmpvar_27.w = 0.0; + tmpvar_27.xyz = xl_retval._LightCoord.xyz; + vec4 tmpvar_28; + tmpvar_28 = tmpvar_27; + gl_TexCoord[3] = tmpvar_28; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Tree_Optimized_Bark_Shader-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Tree_Optimized_Bark_Shader-out.txt new file mode 100644 index 000000000..6507427a8 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Tree_Optimized_Bark_Shader-out.txt @@ -0,0 +1,96 @@ +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform vec3 _WorldSpaceCameraPos; +uniform mat4 _World2Object; +uniform vec4 _Wind; +uniform float _TimeX; +uniform vec4 _SquashPlaneNormal; +uniform float _SquashAmount; +uniform vec4 _Scale; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform mat4 _LightMatrix0; +uniform vec4 _Color; +void main () +{ + vec4 tmpvar_1; + vec4 tmpvar_2; + tmpvar_1 = gl_Vertex; + tmpvar_2 = TANGENT; + tmpvar_1.xyz = (gl_Vertex.xyz * _Scale.xyz); + vec4 pos; + pos = tmpvar_1; + vec3 bend; + float tmpvar_3; + tmpvar_3 = (dot (_Object2World[3].xyz, vec3(1.0, 1.0, 1.0)) + gl_Color.x); + vec2 tmpvar_4; + tmpvar_4.x = dot (tmpvar_1.xyz, vec3((gl_Color.y + tmpvar_3))); + tmpvar_4.y = tmpvar_3; + vec4 tmpvar_5; + tmpvar_5 = abs (((fract ((((fract (((_TimeX + tmpvar_4).xxyy * vec4(1.975, 0.793, 0.375, 0.193))) * 2.0) - 1.0) + 0.5)) * 2.0) - 1.0)); + vec4 tmpvar_6; + tmpvar_6 = ((tmpvar_5 * tmpvar_5) * (3.0 - (2.0 * tmpvar_5))); + vec2 tmpvar_7; + tmpvar_7 = (tmpvar_6.xz + tmpvar_6.yw); + bend = ((gl_Color.y * 0.1) * gl_Normal); + bend.y = (gl_MultiTexCoord1.y * 0.3); + pos.xyz = (tmpvar_1.xyz + (((tmpvar_7.xyx * bend) + ((_Wind.xyz * tmpvar_7.y) * gl_MultiTexCoord1.y)) * _Wind.w)); + pos.xyz = (pos.xyz + (gl_MultiTexCoord1.x * _Wind.xyz)); + vec3 tmpvar_8; + tmpvar_8.xz = vec2(0.0, 0.0); + tmpvar_8.y = _SquashPlaneNormal.w; + vec3 tmpvar_9; + tmpvar_9 = mix ((pos.xyz + (dot (_SquashPlaneNormal.xyz, (tmpvar_8 - pos.xyz)) * _SquashPlaneNormal.xyz)), pos.xyz, vec3(_SquashAmount)); + vec4 tmpvar_10; + tmpvar_10.w = 1.0; + tmpvar_10.xyz = tmpvar_9; + tmpvar_1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11.xyz = (gl_Color.w * _Color.xyz); + tmpvar_11.w = _Color.w; + vec3 tmpvar_12; + tmpvar_12 = normalize (gl_Normal); + tmpvar_2.xyz = normalize (TANGENT.xyz); + vec4 tmpvar_13; + tmpvar_13 = (gl_ModelViewProjectionMatrix * tmpvar_10); + vec3 tmpvar_14; + tmpvar_14 = (cross (tmpvar_12, tmpvar_2.xyz) * TANGENT.w); + mat3 tmpvar_15; + tmpvar_15[0].x = tmpvar_2.x; + tmpvar_15[0].y = tmpvar_14.x; + tmpvar_15[0].z = tmpvar_12.x; + tmpvar_15[1].x = tmpvar_2.y; + tmpvar_15[1].y = tmpvar_14.y; + tmpvar_15[1].z = tmpvar_12.y; + tmpvar_15[2].x = tmpvar_2.z; + tmpvar_15[2].y = tmpvar_14.z; + tmpvar_15[2].z = tmpvar_12.z; + vec4 tmpvar_16; + tmpvar_16.w = 1.0; + tmpvar_16.xyz = _WorldSpaceCameraPos; + gl_Position = tmpvar_13; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = tmpvar_13.z; + xlv_FOG = tmpvar_17; + vec4 tmpvar_18; + tmpvar_18.zw = vec2(0.0, 0.0); + tmpvar_18.xy = ((gl_MultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + gl_TexCoord[0] = tmpvar_18; + gl_FrontColor = tmpvar_11; + vec4 tmpvar_19; + tmpvar_19.w = 0.0; + tmpvar_19.xyz = (tmpvar_15 * (((_World2Object * _WorldSpaceLightPos0).xyz * unity_Scale.w) - tmpvar_9)); + gl_TexCoord[1] = tmpvar_19; + vec4 tmpvar_20; + tmpvar_20.w = 0.0; + tmpvar_20.xyz = (tmpvar_15 * (((_World2Object * tmpvar_16).xyz * unity_Scale.w) - tmpvar_9)); + gl_TexCoord[2] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21.w = 0.0; + tmpvar_21.xyz = (_LightMatrix0 * (_Object2World * tmpvar_10)).xyz; + gl_TexCoord[3] = tmpvar_21; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Tree_Optimized_Bark_Shader1-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Tree_Optimized_Bark_Shader1-in.txt new file mode 100644 index 000000000..7e31c439e --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Tree_Optimized_Bark_Shader1-in.txt @@ -0,0 +1,135 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +struct LeafSurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + vec3 Translucency; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec4 color; +}; +struct v2f_surf { + vec4 pos; +}; +uniform vec4 _Color; +uniform mat4 _Object2World; +uniform vec4 _Scale; +uniform float _SquashAmount; +uniform vec4 _SquashPlaneNormal; +uniform float _TimeX; +uniform vec4 _Wind; + +uniform vec4 unity_LightShadowBias; +vec4 Squash( in vec4 pos ); +vec4 TriangleWave( in vec4 x ); +vec4 SmoothCurve( in vec4 x ); +vec4 SmoothTriangleWave( in vec4 x ); +vec4 AnimateVertex( in vec4 pos, in vec3 normal, in vec4 animParams ); +void TreeVertBark( inout appdata_full v ); +v2f_surf vert_surf( in appdata_full v ); +vec4 Squash( in vec4 pos ) { + vec3 projectedVertex; + vec3 planePoint; + vec3 planeNormal; + projectedVertex = pos.xyz ; + planePoint = vec3( 0.000000, _SquashPlaneNormal.w , 0.000000); + planeNormal = _SquashPlaneNormal.xyz ; + projectedVertex += (dot( planeNormal, (planePoint - vec3( pos))) * planeNormal); + pos = vec4( mix( projectedVertex, pos.xyz , vec3( _SquashAmount)), 1.00000); + return pos; +} +vec4 TriangleWave( in vec4 x ) { + return abs( ((fract( (x + 0.500000) ) * 2.00000) - 1.00000) ); +} +vec4 SmoothCurve( in vec4 x ) { + return ((x * x) * (3.00000 - (2.00000 * x))); +} +vec4 SmoothTriangleWave( in vec4 x ) { + return SmoothCurve( TriangleWave( x)); +} +vec4 AnimateVertex( in vec4 pos, in vec3 normal, in vec4 animParams ) { + float fDetailAmp = 0.100000; + float fBranchAmp = 0.300000; + float fObjPhase; + float fBranchPhase; + float fVtxPhase; + vec2 vWavesIn; + vec4 vWaves; + vec2 vWavesSum; + vec3 bend; + fObjPhase = dot( _Object2World[ 3 ].xyz , vec3( 1.00000)); + fBranchPhase = (fObjPhase + animParams.x ); + fVtxPhase = dot( pos.xyz , vec3( (animParams.y + fBranchPhase))); + vWavesIn = (_TimeX + vec2( fVtxPhase, fBranchPhase)); + vWaves = ((fract( (vWavesIn.xxyy * vec4( 1.97500, 0.793000, 0.375000, 0.193000)) ) * 2.00000) - 1.00000); + vWaves = SmoothTriangleWave( vWaves); + vWavesSum = (vWaves.xz + vWaves.yw ); + bend = ((animParams.y * fDetailAmp) * normal.xyz ); + bend.y = (animParams.w * fBranchAmp); + pos.xyz += (((vWavesSum.xyx * bend) + ((_Wind.xyz * vWavesSum.y ) * animParams.w )) * _Wind.w ); + pos.xyz += (animParams.z * _Wind.xyz ); + return pos; +} +void TreeVertBark( inout appdata_full v ) { + v.vertex.xyz *= _Scale.xyz ; + v.vertex = AnimateVertex( v.vertex, v.normal, vec4( v.color.xy , v.texcoord1.xy )); + v.vertex = Squash( v.vertex); + v.color = vec4( (v.color.w * _Color.xyz ), _Color.w ); + v.normal = normalize( v.normal ); + v.tangent.xyz = normalize( v.tangent.xyz ); +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + TreeVertBark( v); + o.pos = ( gl_ModelViewProjectionMatrix * v.vertex ); + o.pos.z += unity_LightShadowBias.x ; + if ( (o.pos.z < ( -o.pos.w )) ){ + o.pos.z = ( -o.pos.w ); + } + return o; +} +attribute vec4 TANGENT; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Tree_Optimized_Bark_Shader1-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Tree_Optimized_Bark_Shader1-ir.txt new file mode 100644 index 000000000..e3d14b336 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Tree_Optimized_Bark_Shader1-ir.txt @@ -0,0 +1,262 @@ +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +struct v2f_surf { + vec4 pos; +}; +attribute vec4 TANGENT; +uniform vec4 unity_LightShadowBias; +uniform vec4 _Wind; +uniform float _TimeX; +uniform vec4 _SquashPlaneNormal; +uniform float _SquashAmount; +uniform vec4 _Scale; +uniform mat4 _Object2World; +uniform vec4 _Color; +vec4 Squash ( + in vec4 pos +) +{ + vec3 planeNormal; + vec3 planePoint; + vec3 projectedVertex; + vec3 tmpvar_1; + tmpvar_1 = pos.xyz; + projectedVertex = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2.xz = vec2(0.0, 0.0); + tmpvar_2.y = _SquashPlaneNormal.w; + vec3 tmpvar_3; + tmpvar_3 = tmpvar_2; + planePoint = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = _SquashPlaneNormal.xyz; + planeNormal = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = pos.xyz; + float tmpvar_6; + tmpvar_6 = dot (planeNormal, (planePoint - tmpvar_5)); + vec3 tmpvar_7; + tmpvar_7 = (projectedVertex + (tmpvar_6 * planeNormal)); + projectedVertex = tmpvar_7; + vec3 tmpvar_8; + tmpvar_8 = vec3(_SquashAmount); + vec3 tmpvar_9; + tmpvar_9 = mix (projectedVertex, pos.xyz, tmpvar_8); + vec4 tmpvar_10; + tmpvar_10.w = 1.0; + tmpvar_10.xyz = tmpvar_9.xyz; + vec4 tmpvar_11; + tmpvar_11 = tmpvar_10; + pos = tmpvar_11; + return pos; +} + +vec4 TriangleWave ( + in vec4 x +) +{ + vec4 tmpvar_1; + tmpvar_1 = fract ((x + 0.5)); + vec4 tmpvar_2; + tmpvar_2 = abs (((tmpvar_1 * 2.0) - 1.0)); + return tmpvar_2; +} + +vec4 SmoothCurve ( + in vec4 x +) +{ + return ((x * x) * (3.0 - (2.0 * x))); +} + +vec4 SmoothTriangleWave ( + in vec4 x +) +{ + vec4 tmpvar_1; + tmpvar_1 = TriangleWave (x); + vec4 tmpvar_2; + tmpvar_2 = SmoothCurve (tmpvar_1); + return tmpvar_2; +} + +vec4 AnimateVertex ( + in vec4 pos, + in vec3 normal, + in vec4 animParams +) +{ + vec3 bend; + vec2 vWavesSum; + vec4 vWaves; + vec2 vWavesIn; + float fVtxPhase; + float fBranchPhase; + float fObjPhase; + float fBranchAmp; + float fDetailAmp; + float tmpvar_1; + tmpvar_1 = 0.1; + fDetailAmp = tmpvar_1; + float tmpvar_2; + tmpvar_2 = 0.3; + fBranchAmp = tmpvar_2; + float tmpvar_3; + tmpvar_3 = dot (_Object2World[3].xyz, vec3(1.0, 1.0, 1.0)); + float tmpvar_4; + tmpvar_4 = tmpvar_3; + fObjPhase = tmpvar_4; + float tmpvar_5; + tmpvar_5 = (fObjPhase + animParams.x); + fBranchPhase = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = vec3((animParams.y + fBranchPhase)); + float tmpvar_7; + tmpvar_7 = dot (pos.xyz, tmpvar_6); + float tmpvar_8; + tmpvar_8 = tmpvar_7; + fVtxPhase = tmpvar_8; + vec2 tmpvar_9; + tmpvar_9.x = fVtxPhase; + tmpvar_9.y = fBranchPhase; + vec2 tmpvar_10; + tmpvar_10 = (_TimeX + tmpvar_9); + vWavesIn = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = fract ((vWavesIn.xxyy * vec4(1.975, 0.793, 0.375, 0.193))); + vec4 tmpvar_12; + tmpvar_12 = ((tmpvar_11 * 2.0) - 1.0); + vWaves = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = SmoothTriangleWave (vWaves); + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + vWaves = tmpvar_14; + vec2 tmpvar_15; + tmpvar_15 = (vWaves.xz + vWaves.yw); + vWavesSum = tmpvar_15; + vec3 tmpvar_16; + tmpvar_16 = ((animParams.y * fDetailAmp) * normal.xyz); + bend = tmpvar_16; + float tmpvar_17; + tmpvar_17 = (animParams.w * fBranchAmp); + bend.y = vec2(tmpvar_17).y; + vec3 tmpvar_18; + tmpvar_18 = (pos.xyz + (((vWavesSum.xyx * bend) + ((_Wind.xyz * vWavesSum.y) * animParams.w)) * _Wind.w)); + pos.xyz = tmpvar_18.xyz.xyz; + vec3 tmpvar_19; + tmpvar_19 = (pos.xyz + (animParams.z * _Wind.xyz)); + pos.xyz = tmpvar_19.xyz.xyz; + return pos; +} + +void TreeVertBark ( + inout appdata_full v +) +{ + vec3 tmpvar_1; + tmpvar_1 = (v.vertex.xyz * _Scale.xyz); + v.vertex.xyz = tmpvar_1.xyz.xyz; + vec4 tmpvar_2; + tmpvar_2.xy = v.color.xy.xy; + tmpvar_2.zw = v.texcoord1.xy.xy; + vec4 tmpvar_3; + tmpvar_3 = AnimateVertex (v.vertex, v.normal, tmpvar_2); + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + v.vertex = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = Squash (v.vertex); + vec4 tmpvar_6; + tmpvar_6 = tmpvar_5; + v.vertex = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7.xyz = (v.color.w * _Color.xyz).xyz; + tmpvar_7.w = _Color.w; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + v.color = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = normalize (v.normal); + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + v.normal = tmpvar_10; + vec3 tmpvar_11; + tmpvar_11 = normalize (v.tangent.xyz); + vec3 tmpvar_12; + tmpvar_12 = tmpvar_11; + v.tangent.xyz = tmpvar_12.xyz.xyz; +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + v2f_surf o; + TreeVertBark (v); + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v.vertex); + o.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = (o.pos.z + unity_LightShadowBias.x); + o.pos.z = vec3(tmpvar_2).z; + if ((o.pos.z < -(o.pos.w))) { + float tmpvar_3; + tmpvar_3 = -(o.pos.w); + o.pos.z = vec3(tmpvar_3).z; + }; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Tree_Optimized_Bark_Shader1-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Tree_Optimized_Bark_Shader1-out.txt new file mode 100644 index 000000000..657b548fd --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Tree_Optimized_Bark_Shader1-out.txt @@ -0,0 +1,48 @@ +uniform vec4 unity_LightShadowBias; +uniform vec4 _Wind; +uniform float _TimeX; +uniform vec4 _SquashPlaneNormal; +uniform float _SquashAmount; +uniform vec4 _Scale; +uniform mat4 _Object2World; +void main () +{ + vec4 tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = gl_Vertex; + tmpvar_2.xyz = (gl_Vertex.xyz * _Scale.xyz); + vec4 pos; + pos = tmpvar_2; + vec3 bend; + float tmpvar_3; + tmpvar_3 = (dot (_Object2World[3].xyz, vec3(1.0, 1.0, 1.0)) + gl_Color.x); + vec2 tmpvar_4; + tmpvar_4.x = dot (tmpvar_2.xyz, vec3((gl_Color.y + tmpvar_3))); + tmpvar_4.y = tmpvar_3; + vec4 tmpvar_5; + tmpvar_5 = abs (((fract ((((fract (((_TimeX + tmpvar_4).xxyy * vec4(1.975, 0.793, 0.375, 0.193))) * 2.0) - 1.0) + 0.5)) * 2.0) - 1.0)); + vec4 tmpvar_6; + tmpvar_6 = ((tmpvar_5 * tmpvar_5) * (3.0 - (2.0 * tmpvar_5))); + vec2 tmpvar_7; + tmpvar_7 = (tmpvar_6.xz + tmpvar_6.yw); + bend = ((gl_Color.y * 0.1) * gl_Normal); + bend.y = (gl_MultiTexCoord1.y * 0.3); + pos.xyz = (tmpvar_2.xyz + (((tmpvar_7.xyx * bend) + ((_Wind.xyz * tmpvar_7.y) * gl_MultiTexCoord1.y)) * _Wind.w)); + pos.xyz = (pos.xyz + (gl_MultiTexCoord1.x * _Wind.xyz)); + vec3 tmpvar_8; + tmpvar_8.xz = vec2(0.0, 0.0); + tmpvar_8.y = _SquashPlaneNormal.w; + vec4 tmpvar_9; + tmpvar_9.w = 1.0; + tmpvar_9.xyz = mix ((pos.xyz + (dot (_SquashPlaneNormal.xyz, (tmpvar_8 - pos.xyz)) * _SquashPlaneNormal.xyz)), pos.xyz, vec3(_SquashAmount)); + tmpvar_2 = tmpvar_9; + vec4 tmpvar_10; + tmpvar_10 = (gl_ModelViewProjectionMatrix * tmpvar_9); + tmpvar_1 = tmpvar_10; + tmpvar_1.z = (tmpvar_10.z + unity_LightShadowBias.x); + if ((tmpvar_1.z < -(tmpvar_10.w))) { + tmpvar_1.z = -(tmpvar_10.w); + }; + gl_Position = tmpvar_1; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Tree_Optimized_Leaf_Shader-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Tree_Optimized_Leaf_Shader-in.txt new file mode 100644 index 000000000..52ba20e7e --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Tree_Optimized_Leaf_Shader-in.txt @@ -0,0 +1,185 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +struct LeafSurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + vec3 Translucency; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec4 color; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 lop_color; + vec3 lightDir; + vec3 viewDir; +}; +uniform vec4 _Color; +uniform vec4 _MainTex_ST; +uniform mat4 _Object2World; +uniform vec4 _Scale; +uniform float _SquashAmount; +uniform vec4 _SquashPlaneNormal; +uniform float _TimeX; +uniform vec4 _Wind; +uniform mat4 _World2Object; +uniform vec3 _WorldSpaceCameraPos; +uniform vec4 _WorldSpaceLightPos0; + + +uniform vec4 unity_Scale; +vec4 Squash( in vec4 pos ); +void ExpandBillboard( in mat4 mat, inout vec4 pos, inout vec3 normal, inout vec4 tangent ); +vec4 TriangleWave( in vec4 x ); +vec4 SmoothCurve( in vec4 x ); +vec4 SmoothTriangleWave( in vec4 x ); +vec4 AnimateVertex( in vec4 pos, in vec3 normal, in vec4 animParams ); +void TreeVertLeaf( inout appdata_full v ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +vec3 ObjSpaceViewDir( in vec4 v ); +vec3 ObjSpaceLightDir( in vec4 v ); +v2f_surf vert_surf( in appdata_full v ); +vec4 Squash( in vec4 pos ) { + vec3 projectedVertex; + vec3 planePoint; + vec3 planeNormal; + projectedVertex = pos.xyz ; + planePoint = vec3( 0.000000, _SquashPlaneNormal.w , 0.000000); + planeNormal = _SquashPlaneNormal.xyz ; + projectedVertex += (dot( planeNormal, (planePoint - vec3( pos))) * planeNormal); + pos = vec4( mix( projectedVertex, pos.xyz , vec3( _SquashAmount)), 1.00000); + return pos; +} +void ExpandBillboard( in mat4 mat, inout vec4 pos, inout vec3 normal, inout vec4 tangent ) { + float isBillboard; + vec3 norb; + vec3 tanb; + isBillboard = (1.00000 - abs( tangent.w )); + norb = vec3( normalize( ( vec4( normal, 0.000000) * mat ) )); + tanb = vec3( normalize( ( vec4( normal.z , 0.000000, ( -normal.x ), 0.000000) * mat ) )); + pos += (( tangent * mat ) * isBillboard); + normal = mix( normal, norb, vec3( isBillboard)); + tangent = mix( tangent, vec4( tanb, -1.00000), vec4( isBillboard)); +} +vec4 TriangleWave( in vec4 x ) { + return abs( ((fract( (x + 0.500000) ) * 2.00000) - 1.00000) ); +} +vec4 SmoothCurve( in vec4 x ) { + return ((x * x) * (3.00000 - (2.00000 * x))); +} +vec4 SmoothTriangleWave( in vec4 x ) { + return SmoothCurve( TriangleWave( x)); +} +vec4 AnimateVertex( in vec4 pos, in vec3 normal, in vec4 animParams ) { + float fDetailAmp = 0.100000; + float fBranchAmp = 0.300000; + float fObjPhase; + float fBranchPhase; + float fVtxPhase; + vec2 vWavesIn; + vec4 vWaves; + vec2 vWavesSum; + vec3 bend; + fObjPhase = dot( _Object2World[ 3 ].xyz , vec3( 1.00000)); + fBranchPhase = (fObjPhase + animParams.x ); + fVtxPhase = dot( pos.xyz , vec3( (animParams.y + fBranchPhase))); + vWavesIn = (_TimeX + vec2( fVtxPhase, fBranchPhase)); + vWaves = ((fract( (vWavesIn.xxyy * vec4( 1.97500, 0.793000, 0.375000, 0.193000)) ) * 2.00000) - 1.00000); + vWaves = SmoothTriangleWave( vWaves); + vWavesSum = (vWaves.xz + vWaves.yw ); + bend = ((animParams.y * fDetailAmp) * normal.xyz ); + bend.y = (animParams.w * fBranchAmp); + pos.xyz += (((vWavesSum.xyx * bend) + ((_Wind.xyz * vWavesSum.y ) * animParams.w )) * _Wind.w ); + pos.xyz += (animParams.z * _Wind.xyz ); + return pos; +} +void TreeVertLeaf( inout appdata_full v ) { + ExpandBillboard( gl_ModelViewMatrixInverseTranspose, v.vertex, v.normal, v.tangent); + v.vertex.xyz *= _Scale.xyz ; + v.vertex = AnimateVertex( v.vertex, v.normal, vec4( v.color.xy , v.texcoord1.xy )); + v.vertex = Squash( v.vertex); + v.color = vec4( (v.color.w * _Color.xyz ), _Color.w ); + v.normal = normalize( v.normal ); + v.tangent.xyz = normalize( v.tangent.xyz ); +} +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +vec3 ObjSpaceViewDir( in vec4 v ) { + vec3 objSpaceCameraPos; + objSpaceCameraPos = (( _World2Object * vec4( _WorldSpaceCameraPos.xyz , 1.00000) ).xyz * unity_Scale.w ); + return (objSpaceCameraPos - v.xyz ); +} +vec3 ObjSpaceLightDir( in vec4 v ) { + vec3 objSpaceLightPos; + objSpaceLightPos = ( _World2Object * _WorldSpaceLightPos0 ).xyz ; + return objSpaceLightPos.xyz ; +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + vec3 binormal; + mat3 rotation; + TreeVertLeaf( v); + PositionFog( v.vertex, o.pos, o.fog); + o.hip_pack0.xy = ((v.texcoord.xy * _MainTex_ST.xy ) + _MainTex_ST.zw ); + o.lop_color = v.color; + binormal = (cross( v.normal, v.tangent.xyz ) * v.tangent.w ); + rotation = mat3( v.tangent.x , binormal.x , v.normal.x , v.tangent.y , binormal.y , v.normal.y , v.tangent.z , binormal.z , v.normal.z ); + o.lightDir = ( rotation * ObjSpaceLightDir( v.vertex) ); + o.viewDir = ( rotation * ObjSpaceViewDir( v.vertex) ); + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.hip_pack0, 0.0, 0.0); + gl_FrontColor = vec4( xl_retval.lop_color); + gl_TexCoord[1] = vec4( xl_retval.lightDir, 0.0); + gl_TexCoord[2] = vec4( xl_retval.viewDir, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Tree_Optimized_Leaf_Shader-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Tree_Optimized_Leaf_Shader-ir.txt new file mode 100644 index 000000000..48ab8ed86 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Tree_Optimized_Leaf_Shader-ir.txt @@ -0,0 +1,443 @@ +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 lop_color; + vec3 lightDir; + vec3 viewDir; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform vec3 _WorldSpaceCameraPos; +uniform mat4 _World2Object; +uniform vec4 _Wind; +uniform float _TimeX; +uniform vec4 _SquashPlaneNormal; +uniform float _SquashAmount; +uniform vec4 _Scale; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform vec4 _Color; +vec4 Squash ( + in vec4 pos +) +{ + vec3 planeNormal; + vec3 planePoint; + vec3 projectedVertex; + vec3 tmpvar_1; + tmpvar_1 = pos.xyz; + projectedVertex = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2.xz = vec2(0.0, 0.0); + tmpvar_2.y = _SquashPlaneNormal.w; + vec3 tmpvar_3; + tmpvar_3 = tmpvar_2; + planePoint = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = _SquashPlaneNormal.xyz; + planeNormal = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = pos.xyz; + float tmpvar_6; + tmpvar_6 = dot (planeNormal, (planePoint - tmpvar_5)); + vec3 tmpvar_7; + tmpvar_7 = (projectedVertex + (tmpvar_6 * planeNormal)); + projectedVertex = tmpvar_7; + vec3 tmpvar_8; + tmpvar_8 = vec3(_SquashAmount); + vec3 tmpvar_9; + tmpvar_9 = mix (projectedVertex, pos.xyz, tmpvar_8); + vec4 tmpvar_10; + tmpvar_10.w = 1.0; + tmpvar_10.xyz = tmpvar_9.xyz; + vec4 tmpvar_11; + tmpvar_11 = tmpvar_10; + pos = tmpvar_11; + return pos; +} + +void ExpandBillboard ( + in mat4 mat, + inout vec4 pos, + inout vec3 normal, + inout vec4 tangent +) +{ + vec3 tanb; + vec3 norb; + float isBillboard; + float tmpvar_1; + tmpvar_1 = abs (tangent.w); + float tmpvar_2; + tmpvar_2 = (1.0 - tmpvar_1); + isBillboard = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3.w = 0.0; + tmpvar_3.xyz = normal.xyz; + vec4 tmpvar_4; + tmpvar_4 = normalize ((tmpvar_3 * mat)); + vec3 tmpvar_5; + tmpvar_5 = tmpvar_4.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + norb = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7.yw = vec2(0.0, 0.0); + tmpvar_7.x = normal.z; + tmpvar_7.z = -(normal.x); + vec4 tmpvar_8; + tmpvar_8 = normalize ((tmpvar_7 * mat)); + vec3 tmpvar_9; + tmpvar_9 = tmpvar_8.xyz; + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + tanb = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = (pos + ((tangent * mat) * isBillboard)); + pos = tmpvar_11; + vec3 tmpvar_12; + tmpvar_12 = vec3(isBillboard); + vec3 tmpvar_13; + tmpvar_13 = mix (normal, norb, tmpvar_12); + vec3 tmpvar_14; + tmpvar_14 = tmpvar_13; + normal = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15.w = -1.0; + tmpvar_15.xyz = tanb.xyz; + vec4 tmpvar_16; + tmpvar_16 = vec4(isBillboard); + vec4 tmpvar_17; + tmpvar_17 = mix (tangent, tmpvar_15, tmpvar_16); + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + tangent = tmpvar_18; +} + +vec4 TriangleWave ( + in vec4 x +) +{ + vec4 tmpvar_1; + tmpvar_1 = fract ((x + 0.5)); + vec4 tmpvar_2; + tmpvar_2 = abs (((tmpvar_1 * 2.0) - 1.0)); + return tmpvar_2; +} + +vec4 SmoothCurve ( + in vec4 x +) +{ + return ((x * x) * (3.0 - (2.0 * x))); +} + +vec4 SmoothTriangleWave ( + in vec4 x +) +{ + vec4 tmpvar_1; + tmpvar_1 = TriangleWave (x); + vec4 tmpvar_2; + tmpvar_2 = SmoothCurve (tmpvar_1); + return tmpvar_2; +} + +vec4 AnimateVertex ( + in vec4 pos, + in vec3 normal, + in vec4 animParams +) +{ + vec3 bend; + vec2 vWavesSum; + vec4 vWaves; + vec2 vWavesIn; + float fVtxPhase; + float fBranchPhase; + float fObjPhase; + float fBranchAmp; + float fDetailAmp; + float tmpvar_1; + tmpvar_1 = 0.1; + fDetailAmp = tmpvar_1; + float tmpvar_2; + tmpvar_2 = 0.3; + fBranchAmp = tmpvar_2; + float tmpvar_3; + tmpvar_3 = dot (_Object2World[3].xyz, vec3(1.0, 1.0, 1.0)); + float tmpvar_4; + tmpvar_4 = tmpvar_3; + fObjPhase = tmpvar_4; + float tmpvar_5; + tmpvar_5 = (fObjPhase + animParams.x); + fBranchPhase = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = vec3((animParams.y + fBranchPhase)); + float tmpvar_7; + tmpvar_7 = dot (pos.xyz, tmpvar_6); + float tmpvar_8; + tmpvar_8 = tmpvar_7; + fVtxPhase = tmpvar_8; + vec2 tmpvar_9; + tmpvar_9.x = fVtxPhase; + tmpvar_9.y = fBranchPhase; + vec2 tmpvar_10; + tmpvar_10 = (_TimeX + tmpvar_9); + vWavesIn = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = fract ((vWavesIn.xxyy * vec4(1.975, 0.793, 0.375, 0.193))); + vec4 tmpvar_12; + tmpvar_12 = ((tmpvar_11 * 2.0) - 1.0); + vWaves = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = SmoothTriangleWave (vWaves); + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + vWaves = tmpvar_14; + vec2 tmpvar_15; + tmpvar_15 = (vWaves.xz + vWaves.yw); + vWavesSum = tmpvar_15; + vec3 tmpvar_16; + tmpvar_16 = ((animParams.y * fDetailAmp) * normal.xyz); + bend = tmpvar_16; + float tmpvar_17; + tmpvar_17 = (animParams.w * fBranchAmp); + bend.y = vec2(tmpvar_17).y; + vec3 tmpvar_18; + tmpvar_18 = (pos.xyz + (((vWavesSum.xyx * bend) + ((_Wind.xyz * vWavesSum.y) * animParams.w)) * _Wind.w)); + pos.xyz = tmpvar_18.xyz.xyz; + vec3 tmpvar_19; + tmpvar_19 = (pos.xyz + (animParams.z * _Wind.xyz)); + pos.xyz = tmpvar_19.xyz.xyz; + return pos; +} + +void TreeVertLeaf ( + inout appdata_full v +) +{ + ExpandBillboard (gl_ModelViewMatrixInverseTranspose, v.vertex, v.normal, v.tangent); + vec3 tmpvar_1; + tmpvar_1 = (v.vertex.xyz * _Scale.xyz); + v.vertex.xyz = tmpvar_1.xyz.xyz; + vec4 tmpvar_2; + tmpvar_2.xy = v.color.xy.xy; + tmpvar_2.zw = v.texcoord1.xy.xy; + vec4 tmpvar_3; + tmpvar_3 = AnimateVertex (v.vertex, v.normal, tmpvar_2); + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + v.vertex = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = Squash (v.vertex); + vec4 tmpvar_6; + tmpvar_6 = tmpvar_5; + v.vertex = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7.xyz = (v.color.w * _Color.xyz).xyz; + tmpvar_7.w = _Color.w; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + v.color = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = normalize (v.normal); + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + v.normal = tmpvar_10; + vec3 tmpvar_11; + tmpvar_11 = normalize (v.tangent.xyz); + vec3 tmpvar_12; + tmpvar_12 = tmpvar_11; + v.tangent.xyz = tmpvar_12.xyz.xyz; +} + +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +vec3 ObjSpaceViewDir ( + in vec4 v +) +{ + vec3 objSpaceCameraPos; + vec4 tmpvar_1; + tmpvar_1.w = 1.0; + tmpvar_1.xyz = _WorldSpaceCameraPos.xyz.xyz; + vec3 tmpvar_2; + tmpvar_2 = ((_World2Object * tmpvar_1).xyz * unity_Scale.w); + objSpaceCameraPos = tmpvar_2; + return (objSpaceCameraPos - v.xyz); +} + +vec3 ObjSpaceLightDir ( + in vec4 v +) +{ + vec3 objSpaceLightPos; + vec3 tmpvar_1; + tmpvar_1 = (_World2Object * _WorldSpaceLightPos0).xyz; + objSpaceLightPos = tmpvar_1; + return objSpaceLightPos.xyz; +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + mat3 rotation; + vec3 binormal; + v2f_surf o; + TreeVertLeaf (v); + PositionFog (v.vertex, o.pos, o.fog); + vec2 tmpvar_1; + tmpvar_1 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + o.hip_pack0 = tmpvar_1.xy.xy; + vec4 tmpvar_2; + tmpvar_2 = v.color; + o.lop_color = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = cross (v.normal, v.tangent.xyz); + vec3 tmpvar_4; + tmpvar_4 = (tmpvar_3 * v.tangent.w); + binormal = tmpvar_4; + mat3 tmpvar_5; + float tmpvar_6; + tmpvar_6 = v.tangent.x; + tmpvar_5[0].x = tmpvar_6; + float tmpvar_7; + tmpvar_7 = binormal.x; + tmpvar_5[0].y = tmpvar_7; + float tmpvar_8; + tmpvar_8 = v.normal.x; + tmpvar_5[0].z = tmpvar_8; + float tmpvar_9; + tmpvar_9 = v.tangent.y; + tmpvar_5[1].x = tmpvar_9; + float tmpvar_10; + tmpvar_10 = binormal.y; + tmpvar_5[1].y = tmpvar_10; + float tmpvar_11; + tmpvar_11 = v.normal.y; + tmpvar_5[1].z = tmpvar_11; + float tmpvar_12; + tmpvar_12 = v.tangent.z; + tmpvar_5[2].x = tmpvar_12; + float tmpvar_13; + tmpvar_13 = binormal.z; + tmpvar_5[2].y = tmpvar_13; + float tmpvar_14; + tmpvar_14 = v.normal.z; + tmpvar_5[2].z = tmpvar_14; + mat3 tmpvar_15; + tmpvar_15 = (tmpvar_5); + rotation = (tmpvar_15); + vec3 tmpvar_16; + tmpvar_16 = ObjSpaceLightDir (v.vertex); + vec3 tmpvar_17; + tmpvar_17 = (rotation * tmpvar_16); + o.lightDir = tmpvar_17; + vec3 tmpvar_18; + tmpvar_18 = ObjSpaceViewDir (v.vertex); + vec3 tmpvar_19; + tmpvar_19 = (rotation * tmpvar_18); + o.viewDir = tmpvar_19; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = xl_retval.fog; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_FOG = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19.zw = vec2(0.0, 0.0); + tmpvar_19.xy = xl_retval.hip_pack0.xy; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[0] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21 = xl_retval.lop_color.xyzw; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_FrontColor = tmpvar_22; + vec4 tmpvar_23; + tmpvar_23.w = 0.0; + tmpvar_23.xyz = xl_retval.lightDir.xyz; + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + gl_TexCoord[1] = tmpvar_24; + vec4 tmpvar_25; + tmpvar_25.w = 0.0; + tmpvar_25.xyz = xl_retval.viewDir.xyz; + vec4 tmpvar_26; + tmpvar_26 = tmpvar_25; + gl_TexCoord[2] = tmpvar_26; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Tree_Optimized_Leaf_Shader-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Tree_Optimized_Leaf_Shader-out.txt new file mode 100644 index 000000000..6764a6f77 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Tree_Optimized_Leaf_Shader-out.txt @@ -0,0 +1,109 @@ +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform vec3 _WorldSpaceCameraPos; +uniform mat4 _World2Object; +uniform vec4 _Wind; +uniform float _TimeX; +uniform vec4 _SquashPlaneNormal; +uniform float _SquashAmount; +uniform vec4 _Scale; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform vec4 _Color; +void main () +{ + vec4 tmpvar_1; + vec4 tmpvar_2; + float tmpvar_3; + tmpvar_3 = (1.0 - abs (TANGENT.w)); + vec4 tmpvar_4; + tmpvar_4.w = 0.0; + tmpvar_4.xyz = gl_Normal; + vec4 tmpvar_5; + tmpvar_5.yw = vec2(0.0, 0.0); + tmpvar_5.x = gl_Normal.z; + tmpvar_5.z = -(gl_Normal.x); + vec4 tmpvar_6; + tmpvar_6 = (gl_Vertex + ((TANGENT * gl_ModelViewMatrixInverseTranspose) * tmpvar_3)); + vec3 tmpvar_7; + tmpvar_7 = mix (gl_Normal, normalize ((tmpvar_4 * gl_ModelViewMatrixInverseTranspose)).xyz, vec3(tmpvar_3)); + vec4 tmpvar_8; + tmpvar_8.w = -1.0; + tmpvar_8.xyz = normalize ((tmpvar_5 * gl_ModelViewMatrixInverseTranspose)).xyz; + vec4 tmpvar_9; + tmpvar_9 = mix (TANGENT, tmpvar_8, vec4(tmpvar_3)); + tmpvar_1 = tmpvar_6; + tmpvar_2 = tmpvar_9; + tmpvar_1.xyz = (tmpvar_6.xyz * _Scale.xyz); + vec4 pos_i0; + pos_i0 = tmpvar_1; + vec3 bend; + float tmpvar_10; + tmpvar_10 = (dot (_Object2World[3].xyz, vec3(1.0, 1.0, 1.0)) + gl_Color.x); + vec2 tmpvar_11; + tmpvar_11.x = dot (tmpvar_1.xyz, vec3((gl_Color.y + tmpvar_10))); + tmpvar_11.y = tmpvar_10; + vec4 tmpvar_12; + tmpvar_12 = abs (((fract ((((fract (((_TimeX + tmpvar_11).xxyy * vec4(1.975, 0.793, 0.375, 0.193))) * 2.0) - 1.0) + 0.5)) * 2.0) - 1.0)); + vec4 tmpvar_13; + tmpvar_13 = ((tmpvar_12 * tmpvar_12) * (3.0 - (2.0 * tmpvar_12))); + vec2 tmpvar_14; + tmpvar_14 = (tmpvar_13.xz + tmpvar_13.yw); + bend = ((gl_Color.y * 0.1) * tmpvar_7); + bend.y = (gl_MultiTexCoord1.y * 0.3); + pos_i0.xyz = (tmpvar_1.xyz + (((tmpvar_14.xyx * bend) + ((_Wind.xyz * tmpvar_14.y) * gl_MultiTexCoord1.y)) * _Wind.w)); + pos_i0.xyz = (pos_i0.xyz + (gl_MultiTexCoord1.x * _Wind.xyz)); + vec3 tmpvar_15; + tmpvar_15.xz = vec2(0.0, 0.0); + tmpvar_15.y = _SquashPlaneNormal.w; + vec3 tmpvar_16; + tmpvar_16 = mix ((pos_i0.xyz + (dot (_SquashPlaneNormal.xyz, (tmpvar_15 - pos_i0.xyz)) * _SquashPlaneNormal.xyz)), pos_i0.xyz, vec3(_SquashAmount)); + vec4 tmpvar_17; + tmpvar_17.w = 1.0; + tmpvar_17.xyz = tmpvar_16; + tmpvar_1 = tmpvar_17; + vec4 tmpvar_18; + tmpvar_18.xyz = (gl_Color.w * _Color.xyz); + tmpvar_18.w = _Color.w; + vec3 tmpvar_19; + tmpvar_19 = normalize (tmpvar_7); + tmpvar_2.xyz = normalize (tmpvar_9.xyz); + vec4 tmpvar_20; + tmpvar_20 = (gl_ModelViewProjectionMatrix * tmpvar_17); + vec3 tmpvar_21; + tmpvar_21 = (cross (tmpvar_19, tmpvar_2.xyz) * tmpvar_9.w); + mat3 tmpvar_22; + tmpvar_22[0].x = tmpvar_2.x; + tmpvar_22[0].y = tmpvar_21.x; + tmpvar_22[0].z = tmpvar_19.x; + tmpvar_22[1].x = tmpvar_2.y; + tmpvar_22[1].y = tmpvar_21.y; + tmpvar_22[1].z = tmpvar_19.y; + tmpvar_22[2].x = tmpvar_2.z; + tmpvar_22[2].y = tmpvar_21.z; + tmpvar_22[2].z = tmpvar_19.z; + vec4 tmpvar_23; + tmpvar_23.w = 1.0; + tmpvar_23.xyz = _WorldSpaceCameraPos; + gl_Position = tmpvar_20; + vec4 tmpvar_24; + tmpvar_24.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_24.x = tmpvar_20.z; + xlv_FOG = tmpvar_24; + vec4 tmpvar_25; + tmpvar_25.zw = vec2(0.0, 0.0); + tmpvar_25.xy = ((gl_MultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + gl_TexCoord[0] = tmpvar_25; + gl_FrontColor = tmpvar_18; + vec4 tmpvar_26; + tmpvar_26.w = 0.0; + tmpvar_26.xyz = (tmpvar_22 * (_World2Object * _WorldSpaceLightPos0).xyz); + gl_TexCoord[1] = tmpvar_26; + vec4 tmpvar_27; + tmpvar_27.w = 0.0; + tmpvar_27.xyz = (tmpvar_22 * (((_World2Object * tmpvar_23).xyz * unity_Scale.w) - tmpvar_16)); + gl_TexCoord[2] = tmpvar_27; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Tree_Optimized_Leaf_Shader1-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Tree_Optimized_Leaf_Shader1-in.txt new file mode 100644 index 000000000..886c919c5 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Tree_Optimized_Leaf_Shader1-in.txt @@ -0,0 +1,189 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +struct LeafSurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + vec3 Translucency; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec4 color; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 lop_color; + vec3 lightDir; + vec3 viewDir; + vec3 _LightCoord; +}; +uniform vec4 _Color; +uniform mat4 _LightMatrix0; +uniform vec4 _MainTex_ST; +uniform mat4 _Object2World; +uniform vec4 _Scale; +uniform float _SquashAmount; +uniform vec4 _SquashPlaneNormal; +uniform float _TimeX; +uniform vec4 _Wind; +uniform mat4 _World2Object; +uniform vec3 _WorldSpaceCameraPos; +uniform vec4 _WorldSpaceLightPos0; + + +uniform vec4 unity_Scale; +vec4 Squash( in vec4 pos ); +void ExpandBillboard( in mat4 mat, inout vec4 pos, inout vec3 normal, inout vec4 tangent ); +vec4 TriangleWave( in vec4 x ); +vec4 SmoothCurve( in vec4 x ); +vec4 SmoothTriangleWave( in vec4 x ); +vec4 AnimateVertex( in vec4 pos, in vec3 normal, in vec4 animParams ); +void TreeVertLeaf( inout appdata_full v ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +vec3 ObjSpaceViewDir( in vec4 v ); +vec3 ObjSpaceLightDir( in vec4 v ); +v2f_surf vert_surf( in appdata_full v ); +vec4 Squash( in vec4 pos ) { + vec3 projectedVertex; + vec3 planePoint; + vec3 planeNormal; + projectedVertex = pos.xyz ; + planePoint = vec3( 0.000000, _SquashPlaneNormal.w , 0.000000); + planeNormal = _SquashPlaneNormal.xyz ; + projectedVertex += (dot( planeNormal, (planePoint - vec3( pos))) * planeNormal); + pos = vec4( mix( projectedVertex, pos.xyz , vec3( _SquashAmount)), 1.00000); + return pos; +} +void ExpandBillboard( in mat4 mat, inout vec4 pos, inout vec3 normal, inout vec4 tangent ) { + float isBillboard; + vec3 norb; + vec3 tanb; + isBillboard = (1.00000 - abs( tangent.w )); + norb = vec3( normalize( ( vec4( normal, 0.000000) * mat ) )); + tanb = vec3( normalize( ( vec4( normal.z , 0.000000, ( -normal.x ), 0.000000) * mat ) )); + pos += (( tangent * mat ) * isBillboard); + normal = mix( normal, norb, vec3( isBillboard)); + tangent = mix( tangent, vec4( tanb, -1.00000), vec4( isBillboard)); +} +vec4 TriangleWave( in vec4 x ) { + return abs( ((fract( (x + 0.500000) ) * 2.00000) - 1.00000) ); +} +vec4 SmoothCurve( in vec4 x ) { + return ((x * x) * (3.00000 - (2.00000 * x))); +} +vec4 SmoothTriangleWave( in vec4 x ) { + return SmoothCurve( TriangleWave( x)); +} +vec4 AnimateVertex( in vec4 pos, in vec3 normal, in vec4 animParams ) { + float fDetailAmp = 0.100000; + float fBranchAmp = 0.300000; + float fObjPhase; + float fBranchPhase; + float fVtxPhase; + vec2 vWavesIn; + vec4 vWaves; + vec2 vWavesSum; + vec3 bend; + fObjPhase = dot( _Object2World[ 3 ].xyz , vec3( 1.00000)); + fBranchPhase = (fObjPhase + animParams.x ); + fVtxPhase = dot( pos.xyz , vec3( (animParams.y + fBranchPhase))); + vWavesIn = (_TimeX + vec2( fVtxPhase, fBranchPhase)); + vWaves = ((fract( (vWavesIn.xxyy * vec4( 1.97500, 0.793000, 0.375000, 0.193000)) ) * 2.00000) - 1.00000); + vWaves = SmoothTriangleWave( vWaves); + vWavesSum = (vWaves.xz + vWaves.yw ); + bend = ((animParams.y * fDetailAmp) * normal.xyz ); + bend.y = (animParams.w * fBranchAmp); + pos.xyz += (((vWavesSum.xyx * bend) + ((_Wind.xyz * vWavesSum.y ) * animParams.w )) * _Wind.w ); + pos.xyz += (animParams.z * _Wind.xyz ); + return pos; +} +void TreeVertLeaf( inout appdata_full v ) { + ExpandBillboard( gl_ModelViewMatrixInverseTranspose, v.vertex, v.normal, v.tangent); + v.vertex.xyz *= _Scale.xyz ; + v.vertex = AnimateVertex( v.vertex, v.normal, vec4( v.color.xy , v.texcoord1.xy )); + v.vertex = Squash( v.vertex); + v.color = vec4( (v.color.w * _Color.xyz ), _Color.w ); + v.normal = normalize( v.normal ); + v.tangent.xyz = normalize( v.tangent.xyz ); +} +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +vec3 ObjSpaceViewDir( in vec4 v ) { + vec3 objSpaceCameraPos; + objSpaceCameraPos = (( _World2Object * vec4( _WorldSpaceCameraPos.xyz , 1.00000) ).xyz * unity_Scale.w ); + return (objSpaceCameraPos - v.xyz ); +} +vec3 ObjSpaceLightDir( in vec4 v ) { + vec3 objSpaceLightPos; + objSpaceLightPos = ( _World2Object * _WorldSpaceLightPos0 ).xyz ; + return ((objSpaceLightPos.xyz * unity_Scale.w ) - v.xyz ); +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + vec3 binormal; + mat3 rotation; + TreeVertLeaf( v); + PositionFog( v.vertex, o.pos, o.fog); + o.hip_pack0.xy = ((v.texcoord.xy * _MainTex_ST.xy ) + _MainTex_ST.zw ); + o.lop_color = v.color; + binormal = (cross( v.normal, v.tangent.xyz ) * v.tangent.w ); + rotation = mat3( v.tangent.x , binormal.x , v.normal.x , v.tangent.y , binormal.y , v.normal.y , v.tangent.z , binormal.z , v.normal.z ); + o.lightDir = ( rotation * ObjSpaceLightDir( v.vertex) ); + o.viewDir = ( rotation * ObjSpaceViewDir( v.vertex) ); + o._LightCoord = ( _LightMatrix0 * ( _Object2World * v.vertex ) ).xyz ; + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.hip_pack0, 0.0, 0.0); + gl_FrontColor = vec4( xl_retval.lop_color); + gl_TexCoord[1] = vec4( xl_retval.lightDir, 0.0); + gl_TexCoord[2] = vec4( xl_retval.viewDir, 0.0); + gl_TexCoord[3] = vec4( xl_retval._LightCoord, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Tree_Optimized_Leaf_Shader1-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Tree_Optimized_Leaf_Shader1-ir.txt new file mode 100644 index 000000000..d18a617a0 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Tree_Optimized_Leaf_Shader1-ir.txt @@ -0,0 +1,454 @@ +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 lop_color; + vec3 lightDir; + vec3 viewDir; + vec3 _LightCoord; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform vec3 _WorldSpaceCameraPos; +uniform mat4 _World2Object; +uniform vec4 _Wind; +uniform float _TimeX; +uniform vec4 _SquashPlaneNormal; +uniform float _SquashAmount; +uniform vec4 _Scale; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform mat4 _LightMatrix0; +uniform vec4 _Color; +vec4 Squash ( + in vec4 pos +) +{ + vec3 planeNormal; + vec3 planePoint; + vec3 projectedVertex; + vec3 tmpvar_1; + tmpvar_1 = pos.xyz; + projectedVertex = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2.xz = vec2(0.0, 0.0); + tmpvar_2.y = _SquashPlaneNormal.w; + vec3 tmpvar_3; + tmpvar_3 = tmpvar_2; + planePoint = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = _SquashPlaneNormal.xyz; + planeNormal = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = pos.xyz; + float tmpvar_6; + tmpvar_6 = dot (planeNormal, (planePoint - tmpvar_5)); + vec3 tmpvar_7; + tmpvar_7 = (projectedVertex + (tmpvar_6 * planeNormal)); + projectedVertex = tmpvar_7; + vec3 tmpvar_8; + tmpvar_8 = vec3(_SquashAmount); + vec3 tmpvar_9; + tmpvar_9 = mix (projectedVertex, pos.xyz, tmpvar_8); + vec4 tmpvar_10; + tmpvar_10.w = 1.0; + tmpvar_10.xyz = tmpvar_9.xyz; + vec4 tmpvar_11; + tmpvar_11 = tmpvar_10; + pos = tmpvar_11; + return pos; +} + +void ExpandBillboard ( + in mat4 mat, + inout vec4 pos, + inout vec3 normal, + inout vec4 tangent +) +{ + vec3 tanb; + vec3 norb; + float isBillboard; + float tmpvar_1; + tmpvar_1 = abs (tangent.w); + float tmpvar_2; + tmpvar_2 = (1.0 - tmpvar_1); + isBillboard = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3.w = 0.0; + tmpvar_3.xyz = normal.xyz; + vec4 tmpvar_4; + tmpvar_4 = normalize ((tmpvar_3 * mat)); + vec3 tmpvar_5; + tmpvar_5 = tmpvar_4.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + norb = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7.yw = vec2(0.0, 0.0); + tmpvar_7.x = normal.z; + tmpvar_7.z = -(normal.x); + vec4 tmpvar_8; + tmpvar_8 = normalize ((tmpvar_7 * mat)); + vec3 tmpvar_9; + tmpvar_9 = tmpvar_8.xyz; + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + tanb = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = (pos + ((tangent * mat) * isBillboard)); + pos = tmpvar_11; + vec3 tmpvar_12; + tmpvar_12 = vec3(isBillboard); + vec3 tmpvar_13; + tmpvar_13 = mix (normal, norb, tmpvar_12); + vec3 tmpvar_14; + tmpvar_14 = tmpvar_13; + normal = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15.w = -1.0; + tmpvar_15.xyz = tanb.xyz; + vec4 tmpvar_16; + tmpvar_16 = vec4(isBillboard); + vec4 tmpvar_17; + tmpvar_17 = mix (tangent, tmpvar_15, tmpvar_16); + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + tangent = tmpvar_18; +} + +vec4 TriangleWave ( + in vec4 x +) +{ + vec4 tmpvar_1; + tmpvar_1 = fract ((x + 0.5)); + vec4 tmpvar_2; + tmpvar_2 = abs (((tmpvar_1 * 2.0) - 1.0)); + return tmpvar_2; +} + +vec4 SmoothCurve ( + in vec4 x +) +{ + return ((x * x) * (3.0 - (2.0 * x))); +} + +vec4 SmoothTriangleWave ( + in vec4 x +) +{ + vec4 tmpvar_1; + tmpvar_1 = TriangleWave (x); + vec4 tmpvar_2; + tmpvar_2 = SmoothCurve (tmpvar_1); + return tmpvar_2; +} + +vec4 AnimateVertex ( + in vec4 pos, + in vec3 normal, + in vec4 animParams +) +{ + vec3 bend; + vec2 vWavesSum; + vec4 vWaves; + vec2 vWavesIn; + float fVtxPhase; + float fBranchPhase; + float fObjPhase; + float fBranchAmp; + float fDetailAmp; + float tmpvar_1; + tmpvar_1 = 0.1; + fDetailAmp = tmpvar_1; + float tmpvar_2; + tmpvar_2 = 0.3; + fBranchAmp = tmpvar_2; + float tmpvar_3; + tmpvar_3 = dot (_Object2World[3].xyz, vec3(1.0, 1.0, 1.0)); + float tmpvar_4; + tmpvar_4 = tmpvar_3; + fObjPhase = tmpvar_4; + float tmpvar_5; + tmpvar_5 = (fObjPhase + animParams.x); + fBranchPhase = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = vec3((animParams.y + fBranchPhase)); + float tmpvar_7; + tmpvar_7 = dot (pos.xyz, tmpvar_6); + float tmpvar_8; + tmpvar_8 = tmpvar_7; + fVtxPhase = tmpvar_8; + vec2 tmpvar_9; + tmpvar_9.x = fVtxPhase; + tmpvar_9.y = fBranchPhase; + vec2 tmpvar_10; + tmpvar_10 = (_TimeX + tmpvar_9); + vWavesIn = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = fract ((vWavesIn.xxyy * vec4(1.975, 0.793, 0.375, 0.193))); + vec4 tmpvar_12; + tmpvar_12 = ((tmpvar_11 * 2.0) - 1.0); + vWaves = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = SmoothTriangleWave (vWaves); + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + vWaves = tmpvar_14; + vec2 tmpvar_15; + tmpvar_15 = (vWaves.xz + vWaves.yw); + vWavesSum = tmpvar_15; + vec3 tmpvar_16; + tmpvar_16 = ((animParams.y * fDetailAmp) * normal.xyz); + bend = tmpvar_16; + float tmpvar_17; + tmpvar_17 = (animParams.w * fBranchAmp); + bend.y = vec2(tmpvar_17).y; + vec3 tmpvar_18; + tmpvar_18 = (pos.xyz + (((vWavesSum.xyx * bend) + ((_Wind.xyz * vWavesSum.y) * animParams.w)) * _Wind.w)); + pos.xyz = tmpvar_18.xyz.xyz; + vec3 tmpvar_19; + tmpvar_19 = (pos.xyz + (animParams.z * _Wind.xyz)); + pos.xyz = tmpvar_19.xyz.xyz; + return pos; +} + +void TreeVertLeaf ( + inout appdata_full v +) +{ + ExpandBillboard (gl_ModelViewMatrixInverseTranspose, v.vertex, v.normal, v.tangent); + vec3 tmpvar_1; + tmpvar_1 = (v.vertex.xyz * _Scale.xyz); + v.vertex.xyz = tmpvar_1.xyz.xyz; + vec4 tmpvar_2; + tmpvar_2.xy = v.color.xy.xy; + tmpvar_2.zw = v.texcoord1.xy.xy; + vec4 tmpvar_3; + tmpvar_3 = AnimateVertex (v.vertex, v.normal, tmpvar_2); + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + v.vertex = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = Squash (v.vertex); + vec4 tmpvar_6; + tmpvar_6 = tmpvar_5; + v.vertex = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7.xyz = (v.color.w * _Color.xyz).xyz; + tmpvar_7.w = _Color.w; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + v.color = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = normalize (v.normal); + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + v.normal = tmpvar_10; + vec3 tmpvar_11; + tmpvar_11 = normalize (v.tangent.xyz); + vec3 tmpvar_12; + tmpvar_12 = tmpvar_11; + v.tangent.xyz = tmpvar_12.xyz.xyz; +} + +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +vec3 ObjSpaceViewDir ( + in vec4 v +) +{ + vec3 objSpaceCameraPos; + vec4 tmpvar_1; + tmpvar_1.w = 1.0; + tmpvar_1.xyz = _WorldSpaceCameraPos.xyz.xyz; + vec3 tmpvar_2; + tmpvar_2 = ((_World2Object * tmpvar_1).xyz * unity_Scale.w); + objSpaceCameraPos = tmpvar_2; + return (objSpaceCameraPos - v.xyz); +} + +vec3 ObjSpaceLightDir ( + in vec4 v +) +{ + vec3 objSpaceLightPos; + vec3 tmpvar_1; + tmpvar_1 = (_World2Object * _WorldSpaceLightPos0).xyz; + objSpaceLightPos = tmpvar_1; + return ((objSpaceLightPos.xyz * unity_Scale.w) - v.xyz); +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + mat3 rotation; + vec3 binormal; + v2f_surf o; + TreeVertLeaf (v); + PositionFog (v.vertex, o.pos, o.fog); + vec2 tmpvar_1; + tmpvar_1 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + o.hip_pack0 = tmpvar_1.xy.xy; + vec4 tmpvar_2; + tmpvar_2 = v.color; + o.lop_color = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = cross (v.normal, v.tangent.xyz); + vec3 tmpvar_4; + tmpvar_4 = (tmpvar_3 * v.tangent.w); + binormal = tmpvar_4; + mat3 tmpvar_5; + float tmpvar_6; + tmpvar_6 = v.tangent.x; + tmpvar_5[0].x = tmpvar_6; + float tmpvar_7; + tmpvar_7 = binormal.x; + tmpvar_5[0].y = tmpvar_7; + float tmpvar_8; + tmpvar_8 = v.normal.x; + tmpvar_5[0].z = tmpvar_8; + float tmpvar_9; + tmpvar_9 = v.tangent.y; + tmpvar_5[1].x = tmpvar_9; + float tmpvar_10; + tmpvar_10 = binormal.y; + tmpvar_5[1].y = tmpvar_10; + float tmpvar_11; + tmpvar_11 = v.normal.y; + tmpvar_5[1].z = tmpvar_11; + float tmpvar_12; + tmpvar_12 = v.tangent.z; + tmpvar_5[2].x = tmpvar_12; + float tmpvar_13; + tmpvar_13 = binormal.z; + tmpvar_5[2].y = tmpvar_13; + float tmpvar_14; + tmpvar_14 = v.normal.z; + tmpvar_5[2].z = tmpvar_14; + mat3 tmpvar_15; + tmpvar_15 = (tmpvar_5); + rotation = (tmpvar_15); + vec3 tmpvar_16; + tmpvar_16 = ObjSpaceLightDir (v.vertex); + vec3 tmpvar_17; + tmpvar_17 = (rotation * tmpvar_16); + o.lightDir = tmpvar_17; + vec3 tmpvar_18; + tmpvar_18 = ObjSpaceViewDir (v.vertex); + vec3 tmpvar_19; + tmpvar_19 = (rotation * tmpvar_18); + o.viewDir = tmpvar_19; + vec3 tmpvar_20; + tmpvar_20 = (_LightMatrix0 * (_Object2World * v.vertex)).xyz; + o._LightCoord = tmpvar_20; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = xl_retval.fog; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_FOG = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19.zw = vec2(0.0, 0.0); + tmpvar_19.xy = xl_retval.hip_pack0.xy; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[0] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21 = xl_retval.lop_color.xyzw; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_FrontColor = tmpvar_22; + vec4 tmpvar_23; + tmpvar_23.w = 0.0; + tmpvar_23.xyz = xl_retval.lightDir.xyz; + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + gl_TexCoord[1] = tmpvar_24; + vec4 tmpvar_25; + tmpvar_25.w = 0.0; + tmpvar_25.xyz = xl_retval.viewDir.xyz; + vec4 tmpvar_26; + tmpvar_26 = tmpvar_25; + gl_TexCoord[2] = tmpvar_26; + vec4 tmpvar_27; + tmpvar_27.w = 0.0; + tmpvar_27.xyz = xl_retval._LightCoord.xyz; + vec4 tmpvar_28; + tmpvar_28 = tmpvar_27; + gl_TexCoord[3] = tmpvar_28; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Tree_Optimized_Leaf_Shader1-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Tree_Optimized_Leaf_Shader1-out.txt new file mode 100644 index 000000000..456889bd5 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Tree_Optimized_Leaf_Shader1-out.txt @@ -0,0 +1,114 @@ +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform vec3 _WorldSpaceCameraPos; +uniform mat4 _World2Object; +uniform vec4 _Wind; +uniform float _TimeX; +uniform vec4 _SquashPlaneNormal; +uniform float _SquashAmount; +uniform vec4 _Scale; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform mat4 _LightMatrix0; +uniform vec4 _Color; +void main () +{ + vec4 tmpvar_1; + vec4 tmpvar_2; + float tmpvar_3; + tmpvar_3 = (1.0 - abs (TANGENT.w)); + vec4 tmpvar_4; + tmpvar_4.w = 0.0; + tmpvar_4.xyz = gl_Normal; + vec4 tmpvar_5; + tmpvar_5.yw = vec2(0.0, 0.0); + tmpvar_5.x = gl_Normal.z; + tmpvar_5.z = -(gl_Normal.x); + vec4 tmpvar_6; + tmpvar_6 = (gl_Vertex + ((TANGENT * gl_ModelViewMatrixInverseTranspose) * tmpvar_3)); + vec3 tmpvar_7; + tmpvar_7 = mix (gl_Normal, normalize ((tmpvar_4 * gl_ModelViewMatrixInverseTranspose)).xyz, vec3(tmpvar_3)); + vec4 tmpvar_8; + tmpvar_8.w = -1.0; + tmpvar_8.xyz = normalize ((tmpvar_5 * gl_ModelViewMatrixInverseTranspose)).xyz; + vec4 tmpvar_9; + tmpvar_9 = mix (TANGENT, tmpvar_8, vec4(tmpvar_3)); + tmpvar_1 = tmpvar_6; + tmpvar_2 = tmpvar_9; + tmpvar_1.xyz = (tmpvar_6.xyz * _Scale.xyz); + vec4 pos_i0; + pos_i0 = tmpvar_1; + vec3 bend; + float tmpvar_10; + tmpvar_10 = (dot (_Object2World[3].xyz, vec3(1.0, 1.0, 1.0)) + gl_Color.x); + vec2 tmpvar_11; + tmpvar_11.x = dot (tmpvar_1.xyz, vec3((gl_Color.y + tmpvar_10))); + tmpvar_11.y = tmpvar_10; + vec4 tmpvar_12; + tmpvar_12 = abs (((fract ((((fract (((_TimeX + tmpvar_11).xxyy * vec4(1.975, 0.793, 0.375, 0.193))) * 2.0) - 1.0) + 0.5)) * 2.0) - 1.0)); + vec4 tmpvar_13; + tmpvar_13 = ((tmpvar_12 * tmpvar_12) * (3.0 - (2.0 * tmpvar_12))); + vec2 tmpvar_14; + tmpvar_14 = (tmpvar_13.xz + tmpvar_13.yw); + bend = ((gl_Color.y * 0.1) * tmpvar_7); + bend.y = (gl_MultiTexCoord1.y * 0.3); + pos_i0.xyz = (tmpvar_1.xyz + (((tmpvar_14.xyx * bend) + ((_Wind.xyz * tmpvar_14.y) * gl_MultiTexCoord1.y)) * _Wind.w)); + pos_i0.xyz = (pos_i0.xyz + (gl_MultiTexCoord1.x * _Wind.xyz)); + vec3 tmpvar_15; + tmpvar_15.xz = vec2(0.0, 0.0); + tmpvar_15.y = _SquashPlaneNormal.w; + vec3 tmpvar_16; + tmpvar_16 = mix ((pos_i0.xyz + (dot (_SquashPlaneNormal.xyz, (tmpvar_15 - pos_i0.xyz)) * _SquashPlaneNormal.xyz)), pos_i0.xyz, vec3(_SquashAmount)); + vec4 tmpvar_17; + tmpvar_17.w = 1.0; + tmpvar_17.xyz = tmpvar_16; + tmpvar_1 = tmpvar_17; + vec4 tmpvar_18; + tmpvar_18.xyz = (gl_Color.w * _Color.xyz); + tmpvar_18.w = _Color.w; + vec3 tmpvar_19; + tmpvar_19 = normalize (tmpvar_7); + tmpvar_2.xyz = normalize (tmpvar_9.xyz); + vec4 tmpvar_20; + tmpvar_20 = (gl_ModelViewProjectionMatrix * tmpvar_17); + vec3 tmpvar_21; + tmpvar_21 = (cross (tmpvar_19, tmpvar_2.xyz) * tmpvar_9.w); + mat3 tmpvar_22; + tmpvar_22[0].x = tmpvar_2.x; + tmpvar_22[0].y = tmpvar_21.x; + tmpvar_22[0].z = tmpvar_19.x; + tmpvar_22[1].x = tmpvar_2.y; + tmpvar_22[1].y = tmpvar_21.y; + tmpvar_22[1].z = tmpvar_19.y; + tmpvar_22[2].x = tmpvar_2.z; + tmpvar_22[2].y = tmpvar_21.z; + tmpvar_22[2].z = tmpvar_19.z; + vec4 tmpvar_23; + tmpvar_23.w = 1.0; + tmpvar_23.xyz = _WorldSpaceCameraPos; + gl_Position = tmpvar_20; + vec4 tmpvar_24; + tmpvar_24.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_24.x = tmpvar_20.z; + xlv_FOG = tmpvar_24; + vec4 tmpvar_25; + tmpvar_25.zw = vec2(0.0, 0.0); + tmpvar_25.xy = ((gl_MultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + gl_TexCoord[0] = tmpvar_25; + gl_FrontColor = tmpvar_18; + vec4 tmpvar_26; + tmpvar_26.w = 0.0; + tmpvar_26.xyz = (tmpvar_22 * (((_World2Object * _WorldSpaceLightPos0).xyz * unity_Scale.w) - tmpvar_16)); + gl_TexCoord[1] = tmpvar_26; + vec4 tmpvar_27; + tmpvar_27.w = 0.0; + tmpvar_27.xyz = (tmpvar_22 * (((_World2Object * tmpvar_23).xyz * unity_Scale.w) - tmpvar_16)); + gl_TexCoord[2] = tmpvar_27; + vec4 tmpvar_28; + tmpvar_28.w = 0.0; + tmpvar_28.xyz = (_LightMatrix0 * (_Object2World * tmpvar_17)).xyz; + gl_TexCoord[3] = tmpvar_28; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Twist_Effect-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Twist_Effect-in.txt new file mode 100644 index 000000000..965d77b59 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Twist_Effect-in.txt @@ -0,0 +1,48 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct v2f { + vec4 pos; + vec2 uv; + vec2 uvOrig; +}; +uniform vec4 _CenterRadius; + + +vec2 MultiplyUV( in mat4 mat, in vec2 inUV ); +v2f vert( in appdata_img v ); +vec2 MultiplyUV( in mat4 mat, in vec2 inUV ) { + vec4 temp; + temp = vec4( inUV.x , inUV.y , 0.000000, 0.000000); + temp = ( mat * temp ); + return temp.xy ; +} +v2f vert( in appdata_img v ) { + v2f o; + vec2 uv; + o.pos = ( gl_ModelViewProjectionMatrix * v.vertex ); + uv = (v.texcoord.xy - _CenterRadius.xy ); + o.uv = MultiplyUV( gl_TextureMatrix[0], uv); + o.uvOrig = uv; + return o; +} +void main() { + v2f xl_retval; + appdata_img xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.texcoord = vec2( gl_MultiTexCoord0); + xl_retval = vert( xlt_v); + gl_Position = vec4( xl_retval.pos); + gl_TexCoord[0] = vec4( xl_retval.uv, 0.0, 0.0); + gl_TexCoord[1] = vec4( xl_retval.uvOrig, 0.0, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Twist_Effect-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Twist_Effect-ir.txt new file mode 100644 index 000000000..87eb3027b --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Twist_Effect-ir.txt @@ -0,0 +1,90 @@ +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct v2f { + vec4 pos; + vec2 uv; + vec2 uvOrig; +}; +uniform vec4 _CenterRadius; +vec2 MultiplyUV ( + in mat4 mat, + in vec2 inUV +) +{ + vec4 temp; + vec4 tmpvar_1; + tmpvar_1.zw = vec2(0.0, 0.0); + tmpvar_1.x = inUV.x; + tmpvar_1.y = inUV.y; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + temp = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = (mat * temp); + temp = tmpvar_3; + return temp.xy; +} + +v2f vert ( + in appdata_img v +) +{ + vec2 uv; + v2f o; + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v.vertex); + o.pos = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = (v.texcoord.xy - _CenterRadius.xy); + uv = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = MultiplyUV (gl_TextureMatrix[0], uv); + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + o.uv = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5 = uv; + o.uvOrig = tmpvar_5; + return o; +} + +void main () +{ + appdata_img xlt_v; + v2f xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = gl_MultiTexCoord0.xy; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.texcoord = tmpvar_4; + v2f tmpvar_5; + tmpvar_5 = vert (xlt_v); + v2f tmpvar_6; + tmpvar_6 = tmpvar_5; + xl_retval = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = xl_retval.pos.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + gl_Position = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9.zw = vec2(0.0, 0.0); + tmpvar_9.xy = xl_retval.uv.xy; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + gl_TexCoord[0] = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11.zw = vec2(0.0, 0.0); + tmpvar_11.xy = xl_retval.uvOrig.xy; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + gl_TexCoord[1] = tmpvar_12; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Twist_Effect-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Twist_Effect-out.txt new file mode 100644 index 000000000..2e0bb7cfb --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Hidden_Twist_Effect-out.txt @@ -0,0 +1,20 @@ +uniform vec4 _CenterRadius; +void main () +{ + vec2 tmpvar_1; + tmpvar_1 = (gl_MultiTexCoord0.xy - _CenterRadius.xy); + vec4 tmpvar_2; + tmpvar_2.zw = vec2(0.0, 0.0); + tmpvar_2.x = tmpvar_1.x; + tmpvar_2.y = tmpvar_1.y; + gl_Position = (gl_ModelViewProjectionMatrix * gl_Vertex); + vec4 tmpvar_3; + tmpvar_3.zw = vec2(0.0, 0.0); + tmpvar_3.xy = (gl_TextureMatrix[0] * tmpvar_2).xy; + gl_TexCoord[0] = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4.zw = vec2(0.0, 0.0); + tmpvar_4.xy = tmpvar_1; + gl_TexCoord[1] = tmpvar_4; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Legacy_Shaders_Lightmapped_Bumped_Diffuse-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Legacy_Shaders_Lightmapped_Bumped_Diffuse-in.txt new file mode 100644 index 000000000..a978a434c --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Legacy_Shaders_Lightmapped_Bumped_Diffuse-in.txt @@ -0,0 +1,91 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; + vec2 uv2_LightMap; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 lightDir; + vec2 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _BumpMap_ST; +uniform mat4 _LightMatrix0; +uniform vec4 _MainTex_ST; +uniform mat4 _Object2World; +uniform mat4 _World2Object; +uniform vec4 _WorldSpaceLightPos0; + +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +vec3 ObjSpaceLightDir( in vec4 v ); +v2f_surf vert_surf( in appdata_full v ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +vec3 ObjSpaceLightDir( in vec4 v ) { + vec3 objSpaceLightPos; + objSpaceLightPos = ( _World2Object * _WorldSpaceLightPos0 ).xyz ; + return objSpaceLightPos.xyz ; +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + vec3 binormal; + mat3 rotation; + PositionFog( v.vertex, o.pos, o.fog); + o.hip_pack0.xy = ((v.texcoord.xy * _MainTex_ST.xy ) + _MainTex_ST.zw ); + o.hip_pack0.zw = ((v.texcoord.xy * _BumpMap_ST.xy ) + _BumpMap_ST.zw ); + binormal = (cross( v.normal, v.tangent.xyz ) * v.tangent.w ); + rotation = mat3( v.tangent.x , binormal.x , v.normal.x , v.tangent.y , binormal.y , v.normal.y , v.tangent.z , binormal.z , v.normal.z ); + o.lightDir = ( rotation * ObjSpaceLightDir( v.vertex) ); + o._LightCoord = ( _LightMatrix0 * ( _Object2World * v.vertex ) ).xy ; + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.hip_pack0); + gl_TexCoord[1] = vec4( xl_retval.lightDir, 0.0); + gl_TexCoord[2] = vec4( xl_retval._LightCoord, 0.0, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Legacy_Shaders_Lightmapped_Bumped_Diffuse-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Legacy_Shaders_Lightmapped_Bumped_Diffuse-ir.txt new file mode 100644 index 000000000..9f3548686 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Legacy_Shaders_Lightmapped_Bumped_Diffuse-ir.txt @@ -0,0 +1,178 @@ +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 lightDir; + vec2 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 _WorldSpaceLightPos0; +uniform mat4 _World2Object; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform mat4 _LightMatrix0; +uniform vec4 _BumpMap_ST; +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +vec3 ObjSpaceLightDir ( + in vec4 v +) +{ + vec3 objSpaceLightPos; + vec3 tmpvar_1; + tmpvar_1 = (_World2Object * _WorldSpaceLightPos0).xyz; + objSpaceLightPos = tmpvar_1; + return objSpaceLightPos.xyz; +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + mat3 rotation; + vec3 binormal; + v2f_surf o; + PositionFog (v.vertex, o.pos, o.fog); + vec2 tmpvar_1; + tmpvar_1 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + o.hip_pack0.xy = tmpvar_1.xy.xy; + vec2 tmpvar_2; + tmpvar_2 = ((v.texcoord.xy * _BumpMap_ST.xy) + _BumpMap_ST.zw); + o.hip_pack0.zw = tmpvar_2.xxxy.zw; + vec3 tmpvar_3; + tmpvar_3 = cross (v.normal, v.tangent.xyz); + vec3 tmpvar_4; + tmpvar_4 = (tmpvar_3 * v.tangent.w); + binormal = tmpvar_4; + mat3 tmpvar_5; + float tmpvar_6; + tmpvar_6 = v.tangent.x; + tmpvar_5[0].x = tmpvar_6; + float tmpvar_7; + tmpvar_7 = binormal.x; + tmpvar_5[0].y = tmpvar_7; + float tmpvar_8; + tmpvar_8 = v.normal.x; + tmpvar_5[0].z = tmpvar_8; + float tmpvar_9; + tmpvar_9 = v.tangent.y; + tmpvar_5[1].x = tmpvar_9; + float tmpvar_10; + tmpvar_10 = binormal.y; + tmpvar_5[1].y = tmpvar_10; + float tmpvar_11; + tmpvar_11 = v.normal.y; + tmpvar_5[1].z = tmpvar_11; + float tmpvar_12; + tmpvar_12 = v.tangent.z; + tmpvar_5[2].x = tmpvar_12; + float tmpvar_13; + tmpvar_13 = binormal.z; + tmpvar_5[2].y = tmpvar_13; + float tmpvar_14; + tmpvar_14 = v.normal.z; + tmpvar_5[2].z = tmpvar_14; + mat3 tmpvar_15; + tmpvar_15 = (tmpvar_5); + rotation = (tmpvar_15); + vec3 tmpvar_16; + tmpvar_16 = ObjSpaceLightDir (v.vertex); + vec3 tmpvar_17; + tmpvar_17 = (rotation * tmpvar_16); + o.lightDir = tmpvar_17; + vec2 tmpvar_18; + tmpvar_18 = (_LightMatrix0 * (_Object2World * v.vertex)).xy; + o._LightCoord = tmpvar_18; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = xl_retval.fog; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_FOG = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19 = xl_retval.hip_pack0.xyzw; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[0] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21.w = 0.0; + tmpvar_21.xyz = xl_retval.lightDir.xyz; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_TexCoord[1] = tmpvar_22; + vec4 tmpvar_23; + tmpvar_23.zw = vec2(0.0, 0.0); + tmpvar_23.xy = xl_retval._LightCoord.xy; + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + gl_TexCoord[2] = tmpvar_24; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Legacy_Shaders_Lightmapped_Bumped_Diffuse-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Legacy_Shaders_Lightmapped_Bumped_Diffuse-out.txt new file mode 100644 index 000000000..ee11d4d75 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Legacy_Shaders_Lightmapped_Bumped_Diffuse-out.txt @@ -0,0 +1,43 @@ +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 _WorldSpaceLightPos0; +uniform mat4 _World2Object; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform mat4 _LightMatrix0; +uniform vec4 _BumpMap_ST; +void main () +{ + vec4 tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = (gl_ModelViewProjectionMatrix * gl_Vertex); + tmpvar_1.xy = ((gl_MultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + tmpvar_1.zw = ((gl_MultiTexCoord0.xy * _BumpMap_ST.xy) + _BumpMap_ST.zw); + vec3 tmpvar_3; + tmpvar_3 = (cross (gl_Normal, TANGENT.xyz) * TANGENT.w); + mat3 tmpvar_4; + tmpvar_4[0].x = TANGENT.x; + tmpvar_4[0].y = tmpvar_3.x; + tmpvar_4[0].z = gl_Normal.x; + tmpvar_4[1].x = TANGENT.y; + tmpvar_4[1].y = tmpvar_3.y; + tmpvar_4[1].z = gl_Normal.y; + tmpvar_4[2].x = TANGENT.z; + tmpvar_4[2].y = tmpvar_3.z; + tmpvar_4[2].z = gl_Normal.z; + gl_Position = tmpvar_2; + vec4 tmpvar_5; + tmpvar_5.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_5.x = tmpvar_2.z; + xlv_FOG = tmpvar_5; + gl_TexCoord[0] = tmpvar_1; + vec4 tmpvar_6; + tmpvar_6.w = 0.0; + tmpvar_6.xyz = (tmpvar_4 * (_World2Object * _WorldSpaceLightPos0).xyz); + gl_TexCoord[1] = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7.zw = vec2(0.0, 0.0); + tmpvar_7.xy = (_LightMatrix0 * (_Object2World * gl_Vertex)).xy; + gl_TexCoord[2] = tmpvar_7; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Nature_Soft_Occlusion_Bark-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Nature_Soft_Occlusion_Bark-in.txt new file mode 100644 index 000000000..ece7eedd8 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Nature_Soft_Occlusion_Bark-in.txt @@ -0,0 +1,118 @@ +mat3 xll_constructMat3( mat4 m) { + return mat3( vec3( m[0]), vec3( m[1]), vec3( m[2])); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +struct Input { + vec2 uv_MainTex; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 normal; + vec3 lightDir; + vec4 _LightCoord; +}; +uniform mat4 _LightMatrix0; +uniform vec4 _MainTex_ST; +uniform mat4 _Object2World; +uniform vec4 _Scale; +uniform float _SquashAmount; +uniform vec4 _SquashPlaneNormal; +uniform mat4 _TerrainEngineBendTree; +uniform vec4 _WorldSpaceLightPos0; + +uniform vec4 unity_Scale; +vec4 Squash( in vec4 pos ); +void TerrainAnimateTree( inout vec4 pos, in float alpha ); +void treevertex( inout appdata_full v ); +vec3 WorldSpaceLightDir( in vec4 v ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +v2f_surf vert_surf( in appdata_full v ); +vec4 Squash( in vec4 pos ) { + vec3 projectedVertex; + vec3 planePoint; + vec3 planeNormal; + projectedVertex = pos.xyz ; + planePoint = vec3( 0.000000, _SquashPlaneNormal.w , 0.000000); + planeNormal = _SquashPlaneNormal.xyz ; + projectedVertex += (dot( planeNormal, (planePoint - vec3( pos))) * planeNormal); + pos = vec4( mix( projectedVertex, pos.xyz , vec3( _SquashAmount)), 1.00000); + return pos; +} +void TerrainAnimateTree( inout vec4 pos, in float alpha ) { + vec3 bent; + pos.xyz *= _Scale.xyz ; + bent = ( _TerrainEngineBendTree * vec4( pos.xyz , 0.000000) ).xyz ; + pos.xyz = mix( pos.xyz , bent, vec3( alpha)); + pos = Squash( pos); +} +void treevertex( inout appdata_full v ) { + TerrainAnimateTree( v.vertex, v.color.w ); +} +vec3 WorldSpaceLightDir( in vec4 v ) { + vec3 worldPos; + worldPos = ( _Object2World * v ).xyz ; + return (_WorldSpaceLightPos0.xyz - worldPos); +} +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + treevertex( v); + PositionFog( v.vertex, o.pos, o.fog); + o.hip_pack0.xy = ((v.texcoord.xy * _MainTex_ST.xy ) + _MainTex_ST.zw ); + o.normal = ( xll_constructMat3( _Object2World) * (v.normal * unity_Scale.w ) ); + o.lightDir = WorldSpaceLightDir( v.vertex); + o._LightCoord = ( _LightMatrix0 * ( _Object2World * v.vertex ) ); + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.hip_pack0, 0.0, 0.0); + gl_TexCoord[1] = vec4( xl_retval.normal, 0.0); + gl_TexCoord[2] = vec4( xl_retval.lightDir, 0.0); + gl_TexCoord[3] = vec4( xl_retval._LightCoord); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Nature_Soft_Occlusion_Bark-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Nature_Soft_Occlusion_Bark-ir.txt new file mode 100644 index 000000000..0061670cc --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Nature_Soft_Occlusion_Bark-ir.txt @@ -0,0 +1,251 @@ +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 normal; + vec3 lightDir; + vec4 _LightCoord; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform mat4 _TerrainEngineBendTree; +uniform vec4 _SquashPlaneNormal; +uniform float _SquashAmount; +uniform vec4 _Scale; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform mat4 _LightMatrix0; +mat3 xll_constructMat3 ( + in mat4 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = m[0].xyz; + vec3 tmpvar_2; + tmpvar_2 = m[1].xyz; + vec3 tmpvar_3; + tmpvar_3 = m[2].xyz; + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +vec4 Squash ( + in vec4 pos +) +{ + vec3 planeNormal; + vec3 planePoint; + vec3 projectedVertex; + vec3 tmpvar_1; + tmpvar_1 = pos.xyz; + projectedVertex = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2.xz = vec2(0.0, 0.0); + tmpvar_2.y = _SquashPlaneNormal.w; + vec3 tmpvar_3; + tmpvar_3 = tmpvar_2; + planePoint = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = _SquashPlaneNormal.xyz; + planeNormal = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = pos.xyz; + float tmpvar_6; + tmpvar_6 = dot (planeNormal, (planePoint - tmpvar_5)); + vec3 tmpvar_7; + tmpvar_7 = (projectedVertex + (tmpvar_6 * planeNormal)); + projectedVertex = tmpvar_7; + vec3 tmpvar_8; + tmpvar_8 = vec3(_SquashAmount); + vec3 tmpvar_9; + tmpvar_9 = mix (projectedVertex, pos.xyz, tmpvar_8); + vec4 tmpvar_10; + tmpvar_10.w = 1.0; + tmpvar_10.xyz = tmpvar_9.xyz; + vec4 tmpvar_11; + tmpvar_11 = tmpvar_10; + pos = tmpvar_11; + return pos; +} + +void TerrainAnimateTree ( + inout vec4 pos, + in float alpha +) +{ + vec3 bent; + vec3 tmpvar_1; + tmpvar_1 = (pos.xyz * _Scale.xyz); + pos.xyz = tmpvar_1.xyz.xyz; + vec4 tmpvar_2; + tmpvar_2.w = 0.0; + tmpvar_2.xyz = pos.xyz.xyz; + vec3 tmpvar_3; + tmpvar_3 = (_TerrainEngineBendTree * tmpvar_2).xyz; + bent = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = vec3(alpha); + vec3 tmpvar_5; + tmpvar_5 = mix (pos.xyz, bent, tmpvar_4); + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + pos.xyz = tmpvar_6.xyz.xyz; + vec4 tmpvar_7; + tmpvar_7 = Squash (pos); + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + pos = tmpvar_8; +} + +void treevertex ( + inout appdata_full v +) +{ + TerrainAnimateTree (v.vertex, v.color.w); +} + +vec3 WorldSpaceLightDir ( + in vec4 v +) +{ + vec3 worldPos; + vec3 tmpvar_1; + tmpvar_1 = (_Object2World * v).xyz; + worldPos = tmpvar_1; + return (_WorldSpaceLightPos0.xyz - worldPos); +} + +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + v2f_surf o; + treevertex (v); + PositionFog (v.vertex, o.pos, o.fog); + vec2 tmpvar_1; + tmpvar_1 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + o.hip_pack0 = tmpvar_1.xy.xy; + mat3 tmpvar_2; + tmpvar_2 = (xll_constructMat3 (_Object2World)); + vec3 tmpvar_3; + tmpvar_3 = (tmpvar_2 * (v.normal * unity_Scale.w)); + o.normal = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = WorldSpaceLightDir (v.vertex); + vec3 tmpvar_5; + tmpvar_5 = tmpvar_4; + o.lightDir = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = (_LightMatrix0 * (_Object2World * v.vertex)); + o._LightCoord = tmpvar_6; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = xl_retval.fog; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_FOG = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19.zw = vec2(0.0, 0.0); + tmpvar_19.xy = xl_retval.hip_pack0.xy; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[0] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21.w = 0.0; + tmpvar_21.xyz = xl_retval.normal.xyz; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_TexCoord[1] = tmpvar_22; + vec4 tmpvar_23; + tmpvar_23.w = 0.0; + tmpvar_23.xyz = xl_retval.lightDir.xyz; + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + gl_TexCoord[2] = tmpvar_24; + vec4 tmpvar_25; + tmpvar_25 = xl_retval._LightCoord.xyzw; + vec4 tmpvar_26; + tmpvar_26 = tmpvar_25; + gl_TexCoord[3] = tmpvar_26; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Nature_Soft_Occlusion_Bark-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Nature_Soft_Occlusion_Bark-out.txt new file mode 100644 index 000000000..7781ece71 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Nature_Soft_Occlusion_Bark-out.txt @@ -0,0 +1,52 @@ +varying vec4 xlv_FOG; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform mat4 _TerrainEngineBendTree; +uniform vec4 _SquashPlaneNormal; +uniform float _SquashAmount; +uniform vec4 _Scale; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform mat4 _LightMatrix0; +void main () +{ + vec4 pos; + pos = gl_Vertex; + pos.xyz = (gl_Vertex.xyz * _Scale.xyz); + vec4 tmpvar_1; + tmpvar_1.w = 0.0; + tmpvar_1.xyz = pos.xyz; + pos.xyz = mix (pos.xyz, (_TerrainEngineBendTree * tmpvar_1).xyz, gl_Color.www); + vec3 tmpvar_2; + tmpvar_2.xz = vec2(0.0, 0.0); + tmpvar_2.y = _SquashPlaneNormal.w; + vec4 tmpvar_3; + tmpvar_3.w = 1.0; + tmpvar_3.xyz = mix ((pos.xyz + (dot (_SquashPlaneNormal.xyz, (tmpvar_2 - pos.xyz)) * _SquashPlaneNormal.xyz)), pos.xyz, vec3(_SquashAmount)); + pos = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = (gl_ModelViewProjectionMatrix * tmpvar_3); + mat3 tmpvar_5; + tmpvar_5[0] = _Object2World[0].xyz; + tmpvar_5[1] = _Object2World[1].xyz; + tmpvar_5[2] = _Object2World[2].xyz; + gl_Position = tmpvar_4; + vec4 tmpvar_6; + tmpvar_6.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_6.x = tmpvar_4.z; + xlv_FOG = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7.zw = vec2(0.0, 0.0); + tmpvar_7.xy = ((gl_MultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + gl_TexCoord[0] = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8.w = 0.0; + tmpvar_8.xyz = (tmpvar_5 * (gl_Normal * unity_Scale.w)); + gl_TexCoord[1] = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9.w = 0.0; + tmpvar_9.xyz = (_WorldSpaceLightPos0.xyz - (_Object2World * tmpvar_3).xyz); + gl_TexCoord[2] = tmpvar_9; + gl_TexCoord[3] = (_LightMatrix0 * (_Object2World * tmpvar_3)); +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Nature_Soft_Occlusion_Bark2-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Nature_Soft_Occlusion_Bark2-in.txt new file mode 100644 index 000000000..86a8c1012 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Nature_Soft_Occlusion_Bark2-in.txt @@ -0,0 +1,89 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +struct Input { + vec2 uv_MainTex; +}; +struct v2f_surf { + vec4 pos; + vec3 vec; +}; +uniform vec4 _LightPositionRange; +uniform mat4 _Object2World; +uniform vec4 _Scale; +uniform float _SquashAmount; +uniform vec4 _SquashPlaneNormal; +uniform mat4 _TerrainEngineBendTree; + +vec4 Squash( in vec4 pos ); +void TerrainAnimateTree( inout vec4 pos, in float alpha ); +void treevertex( inout appdata_full v ); +v2f_surf vert_surf( in appdata_full v ); +vec4 Squash( in vec4 pos ) { + vec3 projectedVertex; + vec3 planePoint; + vec3 planeNormal; + projectedVertex = pos.xyz ; + planePoint = vec3( 0.000000, _SquashPlaneNormal.w , 0.000000); + planeNormal = _SquashPlaneNormal.xyz ; + projectedVertex += (dot( planeNormal, (planePoint - vec3( pos))) * planeNormal); + pos = vec4( mix( projectedVertex, pos.xyz , vec3( _SquashAmount)), 1.00000); + return pos; +} +void TerrainAnimateTree( inout vec4 pos, in float alpha ) { + vec3 bent; + pos.xyz *= _Scale.xyz ; + bent = ( _TerrainEngineBendTree * vec4( pos.xyz , 0.000000) ).xyz ; + pos.xyz = mix( pos.xyz , bent, vec3( alpha)); + pos = Squash( pos); +} +void treevertex( inout appdata_full v ) { + TerrainAnimateTree( v.vertex, v.color.w ); +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + treevertex( v); + o.vec = (( _Object2World * v.vertex ).xyz - _LightPositionRange.xyz ); + o.pos = ( gl_ModelViewProjectionMatrix * v.vertex ); + return o; +} +attribute vec4 TANGENT; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + gl_TexCoord[0] = vec4( xl_retval.vec, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Nature_Soft_Occlusion_Bark2-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Nature_Soft_Occlusion_Bark2-ir.txt new file mode 100644 index 000000000..cd04249bc --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Nature_Soft_Occlusion_Bark2-ir.txt @@ -0,0 +1,161 @@ +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +struct v2f_surf { + vec4 pos; + vec3 vec; +}; +attribute vec4 TANGENT; +uniform mat4 _TerrainEngineBendTree; +uniform vec4 _SquashPlaneNormal; +uniform float _SquashAmount; +uniform vec4 _Scale; +uniform mat4 _Object2World; +uniform vec4 _LightPositionRange; +vec4 Squash ( + in vec4 pos +) +{ + vec3 planeNormal; + vec3 planePoint; + vec3 projectedVertex; + vec3 tmpvar_1; + tmpvar_1 = pos.xyz; + projectedVertex = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2.xz = vec2(0.0, 0.0); + tmpvar_2.y = _SquashPlaneNormal.w; + vec3 tmpvar_3; + tmpvar_3 = tmpvar_2; + planePoint = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = _SquashPlaneNormal.xyz; + planeNormal = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = pos.xyz; + float tmpvar_6; + tmpvar_6 = dot (planeNormal, (planePoint - tmpvar_5)); + vec3 tmpvar_7; + tmpvar_7 = (projectedVertex + (tmpvar_6 * planeNormal)); + projectedVertex = tmpvar_7; + vec3 tmpvar_8; + tmpvar_8 = vec3(_SquashAmount); + vec3 tmpvar_9; + tmpvar_9 = mix (projectedVertex, pos.xyz, tmpvar_8); + vec4 tmpvar_10; + tmpvar_10.w = 1.0; + tmpvar_10.xyz = tmpvar_9.xyz; + vec4 tmpvar_11; + tmpvar_11 = tmpvar_10; + pos = tmpvar_11; + return pos; +} + +void TerrainAnimateTree ( + inout vec4 pos, + in float alpha +) +{ + vec3 bent; + vec3 tmpvar_1; + tmpvar_1 = (pos.xyz * _Scale.xyz); + pos.xyz = tmpvar_1.xyz.xyz; + vec4 tmpvar_2; + tmpvar_2.w = 0.0; + tmpvar_2.xyz = pos.xyz.xyz; + vec3 tmpvar_3; + tmpvar_3 = (_TerrainEngineBendTree * tmpvar_2).xyz; + bent = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = vec3(alpha); + vec3 tmpvar_5; + tmpvar_5 = mix (pos.xyz, bent, tmpvar_4); + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + pos.xyz = tmpvar_6.xyz.xyz; + vec4 tmpvar_7; + tmpvar_7 = Squash (pos); + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + pos = tmpvar_8; +} + +void treevertex ( + inout appdata_full v +) +{ + TerrainAnimateTree (v.vertex, v.color.w); +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + v2f_surf o; + treevertex (v); + vec3 tmpvar_1; + tmpvar_1 = ((_Object2World * v.vertex).xyz - _LightPositionRange.xyz); + o.vec = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = (gl_ModelViewProjectionMatrix * v.vertex); + o.pos = tmpvar_2; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.w = 0.0; + tmpvar_17.xyz = xl_retval.vec.xyz; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + gl_TexCoord[0] = tmpvar_18; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Nature_Soft_Occlusion_Bark2-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Nature_Soft_Occlusion_Bark2-out.txt new file mode 100644 index 000000000..6a13816b5 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Nature_Soft_Occlusion_Bark2-out.txt @@ -0,0 +1,29 @@ +uniform mat4 _TerrainEngineBendTree; +uniform vec4 _SquashPlaneNormal; +uniform float _SquashAmount; +uniform vec4 _Scale; +uniform mat4 _Object2World; +uniform vec4 _LightPositionRange; +void main () +{ + vec4 pos; + pos = gl_Vertex; + pos.xyz = (gl_Vertex.xyz * _Scale.xyz); + vec4 tmpvar_1; + tmpvar_1.w = 0.0; + tmpvar_1.xyz = pos.xyz; + pos.xyz = mix (pos.xyz, (_TerrainEngineBendTree * tmpvar_1).xyz, gl_Color.www); + vec3 tmpvar_2; + tmpvar_2.xz = vec2(0.0, 0.0); + tmpvar_2.y = _SquashPlaneNormal.w; + vec4 tmpvar_3; + tmpvar_3.w = 1.0; + tmpvar_3.xyz = mix ((pos.xyz + (dot (_SquashPlaneNormal.xyz, (tmpvar_2 - pos.xyz)) * _SquashPlaneNormal.xyz)), pos.xyz, vec3(_SquashAmount)); + pos = tmpvar_3; + gl_Position = (gl_ModelViewProjectionMatrix * tmpvar_3); + vec4 tmpvar_4; + tmpvar_4.w = 0.0; + tmpvar_4.xyz = ((_Object2World * tmpvar_3).xyz - _LightPositionRange.xyz); + gl_TexCoord[0] = tmpvar_4; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Nature_Soft_Occlusion_Bark3-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Nature_Soft_Occlusion_Bark3-in.txt new file mode 100644 index 000000000..552b08a0d --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Nature_Soft_Occlusion_Bark3-in.txt @@ -0,0 +1,111 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +struct Input { + vec2 uv_MainTex; +}; +struct v2f_surf { + vec4 pos; + vec3 _ShadowCoord0; + vec3 _ShadowCoord1; + vec3 _ShadowCoord2; + vec3 _ShadowCoord3; + vec2 _ShadowZFade; +}; +uniform vec4 _LightShadowData; +uniform mat4 _Object2World; +uniform vec4 _Scale; +uniform float _SquashAmount; +uniform vec4 _SquashPlaneNormal; +uniform mat4 _TerrainEngineBendTree; +uniform mat4 _World2Shadow; +uniform mat4 _World2Shadow1; +uniform mat4 _World2Shadow2; +uniform mat4 _World2Shadow3; + + +vec4 Squash( in vec4 pos ); +void TerrainAnimateTree( inout vec4 pos, in float alpha ); +void treevertex( inout appdata_full v ); +v2f_surf vert_surf( in appdata_full v ); +vec4 Squash( in vec4 pos ) { + vec3 projectedVertex; + vec3 planePoint; + vec3 planeNormal; + projectedVertex = pos.xyz ; + planePoint = vec3( 0.000000, _SquashPlaneNormal.w , 0.000000); + planeNormal = _SquashPlaneNormal.xyz ; + projectedVertex += (dot( planeNormal, (planePoint - vec3( pos))) * planeNormal); + pos = vec4( mix( projectedVertex, pos.xyz , vec3( _SquashAmount)), 1.00000); + return pos; +} +void TerrainAnimateTree( inout vec4 pos, in float alpha ) { + vec3 bent; + pos.xyz *= _Scale.xyz ; + bent = ( _TerrainEngineBendTree * vec4( pos.xyz , 0.000000) ).xyz ; + pos.xyz = mix( pos.xyz , bent, vec3( alpha)); + pos = Squash( pos); +} +void treevertex( inout appdata_full v ) { + TerrainAnimateTree( v.vertex, v.color.w ); +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + float z; + vec4 wpos; + treevertex( v); + o.pos = ( gl_ModelViewProjectionMatrix * v.vertex ); + z = ( -( gl_ModelViewMatrix * v.vertex ).z ); + o._ShadowZFade.x = z; + o._ShadowZFade.y = ((z * _LightShadowData.z ) + _LightShadowData.w ); + wpos = ( _Object2World * v.vertex ); + o._ShadowCoord0 = ( _World2Shadow * wpos ).xyz ; + o._ShadowCoord1 = ( _World2Shadow1 * wpos ).xyz ; + o._ShadowCoord2 = ( _World2Shadow2 * wpos ).xyz ; + o._ShadowCoord3 = ( _World2Shadow3 * wpos ).xyz ; + return o; +} +attribute vec4 TANGENT; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + gl_TexCoord[0] = vec4( xl_retval._ShadowCoord0, 0.0); + gl_TexCoord[1] = vec4( xl_retval._ShadowCoord1, 0.0); + gl_TexCoord[2] = vec4( xl_retval._ShadowCoord2, 0.0); + gl_TexCoord[3] = vec4( xl_retval._ShadowCoord3, 0.0); + gl_TexCoord[4] = vec4( xl_retval._ShadowZFade, 0.0, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Nature_Soft_Occlusion_Bark3-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Nature_Soft_Occlusion_Bark3-ir.txt new file mode 100644 index 000000000..8527b65e0 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Nature_Soft_Occlusion_Bark3-ir.txt @@ -0,0 +1,216 @@ +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +struct v2f_surf { + vec4 pos; + vec3 _ShadowCoord0; + vec3 _ShadowCoord1; + vec3 _ShadowCoord2; + vec3 _ShadowCoord3; + vec2 _ShadowZFade; +}; +attribute vec4 TANGENT; +uniform mat4 _World2Shadow3; +uniform mat4 _World2Shadow2; +uniform mat4 _World2Shadow1; +uniform mat4 _World2Shadow; +uniform mat4 _TerrainEngineBendTree; +uniform vec4 _SquashPlaneNormal; +uniform float _SquashAmount; +uniform vec4 _Scale; +uniform mat4 _Object2World; +uniform vec4 _LightShadowData; +vec4 Squash ( + in vec4 pos +) +{ + vec3 planeNormal; + vec3 planePoint; + vec3 projectedVertex; + vec3 tmpvar_1; + tmpvar_1 = pos.xyz; + projectedVertex = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2.xz = vec2(0.0, 0.0); + tmpvar_2.y = _SquashPlaneNormal.w; + vec3 tmpvar_3; + tmpvar_3 = tmpvar_2; + planePoint = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = _SquashPlaneNormal.xyz; + planeNormal = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = pos.xyz; + float tmpvar_6; + tmpvar_6 = dot (planeNormal, (planePoint - tmpvar_5)); + vec3 tmpvar_7; + tmpvar_7 = (projectedVertex + (tmpvar_6 * planeNormal)); + projectedVertex = tmpvar_7; + vec3 tmpvar_8; + tmpvar_8 = vec3(_SquashAmount); + vec3 tmpvar_9; + tmpvar_9 = mix (projectedVertex, pos.xyz, tmpvar_8); + vec4 tmpvar_10; + tmpvar_10.w = 1.0; + tmpvar_10.xyz = tmpvar_9.xyz; + vec4 tmpvar_11; + tmpvar_11 = tmpvar_10; + pos = tmpvar_11; + return pos; +} + +void TerrainAnimateTree ( + inout vec4 pos, + in float alpha +) +{ + vec3 bent; + vec3 tmpvar_1; + tmpvar_1 = (pos.xyz * _Scale.xyz); + pos.xyz = tmpvar_1.xyz.xyz; + vec4 tmpvar_2; + tmpvar_2.w = 0.0; + tmpvar_2.xyz = pos.xyz.xyz; + vec3 tmpvar_3; + tmpvar_3 = (_TerrainEngineBendTree * tmpvar_2).xyz; + bent = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = vec3(alpha); + vec3 tmpvar_5; + tmpvar_5 = mix (pos.xyz, bent, tmpvar_4); + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + pos.xyz = tmpvar_6.xyz.xyz; + vec4 tmpvar_7; + tmpvar_7 = Squash (pos); + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + pos = tmpvar_8; +} + +void treevertex ( + inout appdata_full v +) +{ + TerrainAnimateTree (v.vertex, v.color.w); +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + vec4 wpos; + float z; + v2f_surf o; + treevertex (v); + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v.vertex); + o.pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = -((gl_ModelViewMatrix * v.vertex).z); + z = tmpvar_2; + float tmpvar_3; + tmpvar_3 = z; + o._ShadowZFade.x = tmpvar_3; + float tmpvar_4; + tmpvar_4 = ((z * _LightShadowData.z) + _LightShadowData.w); + o._ShadowZFade.y = vec2(tmpvar_4).y; + vec4 tmpvar_5; + tmpvar_5 = (_Object2World * v.vertex); + wpos = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = (_World2Shadow * wpos).xyz; + o._ShadowCoord0 = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = (_World2Shadow1 * wpos).xyz; + o._ShadowCoord1 = tmpvar_7; + vec3 tmpvar_8; + tmpvar_8 = (_World2Shadow2 * wpos).xyz; + o._ShadowCoord2 = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = (_World2Shadow3 * wpos).xyz; + o._ShadowCoord3 = tmpvar_9; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.w = 0.0; + tmpvar_17.xyz = xl_retval._ShadowCoord0.xyz; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + gl_TexCoord[0] = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19.w = 0.0; + tmpvar_19.xyz = xl_retval._ShadowCoord1.xyz; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[1] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21.w = 0.0; + tmpvar_21.xyz = xl_retval._ShadowCoord2.xyz; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_TexCoord[2] = tmpvar_22; + vec4 tmpvar_23; + tmpvar_23.w = 0.0; + tmpvar_23.xyz = xl_retval._ShadowCoord3.xyz; + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + gl_TexCoord[3] = tmpvar_24; + vec4 tmpvar_25; + tmpvar_25.zw = vec2(0.0, 0.0); + tmpvar_25.xy = xl_retval._ShadowZFade.xy; + vec4 tmpvar_26; + tmpvar_26 = tmpvar_25; + gl_TexCoord[4] = tmpvar_26; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Nature_Soft_Occlusion_Bark3-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Nature_Soft_Occlusion_Bark3-out.txt new file mode 100644 index 000000000..beb0c7ab0 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Nature_Soft_Occlusion_Bark3-out.txt @@ -0,0 +1,56 @@ +uniform mat4 _World2Shadow3; +uniform mat4 _World2Shadow2; +uniform mat4 _World2Shadow1; +uniform mat4 _World2Shadow; +uniform mat4 _TerrainEngineBendTree; +uniform vec4 _SquashPlaneNormal; +uniform float _SquashAmount; +uniform vec4 _Scale; +uniform mat4 _Object2World; +uniform vec4 _LightShadowData; +void main () +{ + vec2 tmpvar_1; + vec4 pos; + pos = gl_Vertex; + pos.xyz = (gl_Vertex.xyz * _Scale.xyz); + vec4 tmpvar_2; + tmpvar_2.w = 0.0; + tmpvar_2.xyz = pos.xyz; + pos.xyz = mix (pos.xyz, (_TerrainEngineBendTree * tmpvar_2).xyz, gl_Color.www); + vec3 tmpvar_3; + tmpvar_3.xz = vec2(0.0, 0.0); + tmpvar_3.y = _SquashPlaneNormal.w; + vec4 tmpvar_4; + tmpvar_4.w = 1.0; + tmpvar_4.xyz = mix ((pos.xyz + (dot (_SquashPlaneNormal.xyz, (tmpvar_3 - pos.xyz)) * _SquashPlaneNormal.xyz)), pos.xyz, vec3(_SquashAmount)); + pos = tmpvar_4; + float tmpvar_5; + tmpvar_5 = -((gl_ModelViewMatrix * tmpvar_4).z); + tmpvar_1.x = tmpvar_5; + tmpvar_1.y = ((tmpvar_5 * _LightShadowData.z) + _LightShadowData.w); + vec4 tmpvar_6; + tmpvar_6 = (_Object2World * tmpvar_4); + gl_Position = (gl_ModelViewProjectionMatrix * tmpvar_4); + vec4 tmpvar_7; + tmpvar_7.w = 0.0; + tmpvar_7.xyz = (_World2Shadow * tmpvar_6).xyz; + gl_TexCoord[0] = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8.w = 0.0; + tmpvar_8.xyz = (_World2Shadow1 * tmpvar_6).xyz; + gl_TexCoord[1] = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9.w = 0.0; + tmpvar_9.xyz = (_World2Shadow2 * tmpvar_6).xyz; + gl_TexCoord[2] = tmpvar_9; + vec4 tmpvar_10; + tmpvar_10.w = 0.0; + tmpvar_10.xyz = (_World2Shadow3 * tmpvar_6).xyz; + gl_TexCoord[3] = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11.zw = vec2(0.0, 0.0); + tmpvar_11.xy = tmpvar_1; + gl_TexCoord[4] = tmpvar_11; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Nature_Soft_Occlusion_Leaves1-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Nature_Soft_Occlusion_Leaves1-in.txt new file mode 100644 index 000000000..94dd93e7d --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Nature_Soft_Occlusion_Leaves1-in.txt @@ -0,0 +1,108 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +struct Input { + vec2 uv_MainTex; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 hip_screen; +}; +uniform vec4 _MainTex_ST; +uniform vec4 _ProjectionParams; +uniform vec4 _Scale; +uniform float _SquashAmount; +uniform vec4 _SquashPlaneNormal; +uniform mat4 _TerrainEngineBendTree; + +vec4 Squash( in vec4 pos ); +void TerrainAnimateTree( inout vec4 pos, in float alpha ); +void treevertex( inout appdata_full v ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +vec4 ComputeScreenPos( in vec4 pos ); +v2f_surf vert_surf( in appdata_full v ); +vec4 Squash( in vec4 pos ) { + vec3 projectedVertex; + vec3 planePoint; + vec3 planeNormal; + projectedVertex = pos.xyz ; + planePoint = vec3( 0.000000, _SquashPlaneNormal.w , 0.000000); + planeNormal = _SquashPlaneNormal.xyz ; + projectedVertex += (dot( planeNormal, (planePoint - vec3( pos))) * planeNormal); + pos = vec4( mix( projectedVertex, pos.xyz , vec3( _SquashAmount)), 1.00000); + return pos; +} +void TerrainAnimateTree( inout vec4 pos, in float alpha ) { + vec3 bent; + pos.xyz *= _Scale.xyz ; + bent = ( _TerrainEngineBendTree * vec4( pos.xyz , 0.000000) ).xyz ; + pos.xyz = mix( pos.xyz , bent, vec3( alpha)); + pos = Squash( pos); +} +void treevertex( inout appdata_full v ) { + TerrainAnimateTree( v.vertex, v.color.w ); +} +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +vec4 ComputeScreenPos( in vec4 pos ) { + vec4 o; + o = (pos * 0.500000); + o.xy = (vec2( o.x , (o.y * _ProjectionParams.x )) + o.w ); + o.zw = pos.zw ; + return o; +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + treevertex( v); + PositionFog( v.vertex, o.pos, o.fog); + o.hip_pack0.xy = ((v.texcoord.xy * _MainTex_ST.xy ) + _MainTex_ST.zw ); + o.hip_screen = ComputeScreenPos( o.pos); + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.hip_pack0, 0.0, 0.0); + gl_TexCoord[1] = vec4( xl_retval.hip_screen); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Nature_Soft_Occlusion_Leaves1-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Nature_Soft_Occlusion_Leaves1-ir.txt new file mode 100644 index 000000000..797761e1c --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Nature_Soft_Occlusion_Leaves1-ir.txt @@ -0,0 +1,212 @@ +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 hip_screen; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform mat4 _TerrainEngineBendTree; +uniform vec4 _SquashPlaneNormal; +uniform float _SquashAmount; +uniform vec4 _Scale; +uniform vec4 _ProjectionParams; +uniform vec4 _MainTex_ST; +vec4 Squash ( + in vec4 pos +) +{ + vec3 planeNormal; + vec3 planePoint; + vec3 projectedVertex; + vec3 tmpvar_1; + tmpvar_1 = pos.xyz; + projectedVertex = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2.xz = vec2(0.0, 0.0); + tmpvar_2.y = _SquashPlaneNormal.w; + vec3 tmpvar_3; + tmpvar_3 = tmpvar_2; + planePoint = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = _SquashPlaneNormal.xyz; + planeNormal = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = pos.xyz; + float tmpvar_6; + tmpvar_6 = dot (planeNormal, (planePoint - tmpvar_5)); + vec3 tmpvar_7; + tmpvar_7 = (projectedVertex + (tmpvar_6 * planeNormal)); + projectedVertex = tmpvar_7; + vec3 tmpvar_8; + tmpvar_8 = vec3(_SquashAmount); + vec3 tmpvar_9; + tmpvar_9 = mix (projectedVertex, pos.xyz, tmpvar_8); + vec4 tmpvar_10; + tmpvar_10.w = 1.0; + tmpvar_10.xyz = tmpvar_9.xyz; + vec4 tmpvar_11; + tmpvar_11 = tmpvar_10; + pos = tmpvar_11; + return pos; +} + +void TerrainAnimateTree ( + inout vec4 pos, + in float alpha +) +{ + vec3 bent; + vec3 tmpvar_1; + tmpvar_1 = (pos.xyz * _Scale.xyz); + pos.xyz = tmpvar_1.xyz.xyz; + vec4 tmpvar_2; + tmpvar_2.w = 0.0; + tmpvar_2.xyz = pos.xyz.xyz; + vec3 tmpvar_3; + tmpvar_3 = (_TerrainEngineBendTree * tmpvar_2).xyz; + bent = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = vec3(alpha); + vec3 tmpvar_5; + tmpvar_5 = mix (pos.xyz, bent, tmpvar_4); + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + pos.xyz = tmpvar_6.xyz.xyz; + vec4 tmpvar_7; + tmpvar_7 = Squash (pos); + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + pos = tmpvar_8; +} + +void treevertex ( + inout appdata_full v +) +{ + TerrainAnimateTree (v.vertex, v.color.w); +} + +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +vec4 ComputeScreenPos ( + in vec4 pos +) +{ + vec4 o; + vec4 tmpvar_1; + tmpvar_1 = (pos * 0.5); + o = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2.x = o.x; + tmpvar_2.y = (o.y * _ProjectionParams.x); + vec2 tmpvar_3; + tmpvar_3 = (tmpvar_2 + o.w); + o.xy = tmpvar_3.xy.xy; + vec2 tmpvar_4; + tmpvar_4 = pos.zw; + o.zw = tmpvar_4.xxxy.zw; + return o; +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + v2f_surf o; + treevertex (v); + PositionFog (v.vertex, o.pos, o.fog); + vec2 tmpvar_1; + tmpvar_1 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + o.hip_pack0 = tmpvar_1.xy.xy; + vec4 tmpvar_2; + tmpvar_2 = ComputeScreenPos (o.pos); + vec4 tmpvar_3; + tmpvar_3 = tmpvar_2; + o.hip_screen = tmpvar_3; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = xl_retval.fog; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_FOG = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19.zw = vec2(0.0, 0.0); + tmpvar_19.xy = xl_retval.hip_pack0.xy; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[0] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21 = xl_retval.hip_screen.xyzw; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_TexCoord[1] = tmpvar_22; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Nature_Soft_Occlusion_Leaves1-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Nature_Soft_Occlusion_Leaves1-out.txt new file mode 100644 index 000000000..71dd9bfd2 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Nature_Soft_Occlusion_Leaves1-out.txt @@ -0,0 +1,46 @@ +varying vec4 xlv_FOG; +uniform mat4 _TerrainEngineBendTree; +uniform vec4 _SquashPlaneNormal; +uniform float _SquashAmount; +uniform vec4 _Scale; +uniform vec4 _ProjectionParams; +uniform vec4 _MainTex_ST; +void main () +{ + vec4 pos; + pos = gl_Vertex; + pos.xyz = (gl_Vertex.xyz * _Scale.xyz); + vec4 tmpvar_1; + tmpvar_1.w = 0.0; + tmpvar_1.xyz = pos.xyz; + pos.xyz = mix (pos.xyz, (_TerrainEngineBendTree * tmpvar_1).xyz, gl_Color.www); + vec3 tmpvar_2; + tmpvar_2.xz = vec2(0.0, 0.0); + tmpvar_2.y = _SquashPlaneNormal.w; + vec4 tmpvar_3; + tmpvar_3.w = 1.0; + tmpvar_3.xyz = mix ((pos.xyz + (dot (_SquashPlaneNormal.xyz, (tmpvar_2 - pos.xyz)) * _SquashPlaneNormal.xyz)), pos.xyz, vec3(_SquashAmount)); + pos = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = (gl_ModelViewProjectionMatrix * tmpvar_3); + vec4 o_i0; + vec4 tmpvar_5; + tmpvar_5 = (tmpvar_4 * 0.5); + o_i0 = tmpvar_5; + vec2 tmpvar_6; + tmpvar_6.x = tmpvar_5.x; + tmpvar_6.y = (tmpvar_5.y * _ProjectionParams.x); + o_i0.xy = (tmpvar_6 + tmpvar_5.w); + o_i0.zw = tmpvar_4.zw; + gl_Position = tmpvar_4; + vec4 tmpvar_7; + tmpvar_7.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_7.x = tmpvar_4.z; + xlv_FOG = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8.zw = vec2(0.0, 0.0); + tmpvar_8.xy = ((gl_MultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + gl_TexCoord[0] = tmpvar_8; + gl_TexCoord[1] = o_i0; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Nature_Soft_Occlusion_Leaves3-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Nature_Soft_Occlusion_Leaves3-in.txt new file mode 100644 index 000000000..9b0c492c0 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Nature_Soft_Occlusion_Leaves3-in.txt @@ -0,0 +1,93 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +struct Input { + vec2 uv_MainTex; +}; +struct v2f_surf { + vec4 pos; + vec3 vec; + vec2 hip_pack0; +}; +uniform vec4 _LightPositionRange; +uniform vec4 _MainTex_ST; +uniform mat4 _Object2World; +uniform vec4 _Scale; +uniform float _SquashAmount; +uniform vec4 _SquashPlaneNormal; +uniform mat4 _TerrainEngineBendTree; + +vec4 Squash( in vec4 pos ); +void TerrainAnimateTree( inout vec4 pos, in float alpha ); +void treevertex( inout appdata_full v ); +v2f_surf vert_surf( in appdata_full v ); +vec4 Squash( in vec4 pos ) { + vec3 projectedVertex; + vec3 planePoint; + vec3 planeNormal; + projectedVertex = pos.xyz ; + planePoint = vec3( 0.000000, _SquashPlaneNormal.w , 0.000000); + planeNormal = _SquashPlaneNormal.xyz ; + projectedVertex += (dot( planeNormal, (planePoint - vec3( pos))) * planeNormal); + pos = vec4( mix( projectedVertex, pos.xyz , vec3( _SquashAmount)), 1.00000); + return pos; +} +void TerrainAnimateTree( inout vec4 pos, in float alpha ) { + vec3 bent; + pos.xyz *= _Scale.xyz ; + bent = ( _TerrainEngineBendTree * vec4( pos.xyz , 0.000000) ).xyz ; + pos.xyz = mix( pos.xyz , bent, vec3( alpha)); + pos = Squash( pos); +} +void treevertex( inout appdata_full v ) { + TerrainAnimateTree( v.vertex, v.color.w ); +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + treevertex( v); + o.hip_pack0.xy = ((v.texcoord.xy * _MainTex_ST.xy ) + _MainTex_ST.zw ); + o.vec = (( _Object2World * v.vertex ).xyz - _LightPositionRange.xyz ); + o.pos = ( gl_ModelViewProjectionMatrix * v.vertex ); + return o; +} +attribute vec4 TANGENT; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + gl_TexCoord[0] = vec4( xl_retval.vec, 0.0); + gl_TexCoord[1] = vec4( xl_retval.hip_pack0, 0.0, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Nature_Soft_Occlusion_Leaves3-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Nature_Soft_Occlusion_Leaves3-ir.txt new file mode 100644 index 000000000..62156cba2 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Nature_Soft_Occlusion_Leaves3-ir.txt @@ -0,0 +1,172 @@ +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +struct v2f_surf { + vec4 pos; + vec3 vec; + vec2 hip_pack0; +}; +attribute vec4 TANGENT; +uniform mat4 _TerrainEngineBendTree; +uniform vec4 _SquashPlaneNormal; +uniform float _SquashAmount; +uniform vec4 _Scale; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform vec4 _LightPositionRange; +vec4 Squash ( + in vec4 pos +) +{ + vec3 planeNormal; + vec3 planePoint; + vec3 projectedVertex; + vec3 tmpvar_1; + tmpvar_1 = pos.xyz; + projectedVertex = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2.xz = vec2(0.0, 0.0); + tmpvar_2.y = _SquashPlaneNormal.w; + vec3 tmpvar_3; + tmpvar_3 = tmpvar_2; + planePoint = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = _SquashPlaneNormal.xyz; + planeNormal = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = pos.xyz; + float tmpvar_6; + tmpvar_6 = dot (planeNormal, (planePoint - tmpvar_5)); + vec3 tmpvar_7; + tmpvar_7 = (projectedVertex + (tmpvar_6 * planeNormal)); + projectedVertex = tmpvar_7; + vec3 tmpvar_8; + tmpvar_8 = vec3(_SquashAmount); + vec3 tmpvar_9; + tmpvar_9 = mix (projectedVertex, pos.xyz, tmpvar_8); + vec4 tmpvar_10; + tmpvar_10.w = 1.0; + tmpvar_10.xyz = tmpvar_9.xyz; + vec4 tmpvar_11; + tmpvar_11 = tmpvar_10; + pos = tmpvar_11; + return pos; +} + +void TerrainAnimateTree ( + inout vec4 pos, + in float alpha +) +{ + vec3 bent; + vec3 tmpvar_1; + tmpvar_1 = (pos.xyz * _Scale.xyz); + pos.xyz = tmpvar_1.xyz.xyz; + vec4 tmpvar_2; + tmpvar_2.w = 0.0; + tmpvar_2.xyz = pos.xyz.xyz; + vec3 tmpvar_3; + tmpvar_3 = (_TerrainEngineBendTree * tmpvar_2).xyz; + bent = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = vec3(alpha); + vec3 tmpvar_5; + tmpvar_5 = mix (pos.xyz, bent, tmpvar_4); + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + pos.xyz = tmpvar_6.xyz.xyz; + vec4 tmpvar_7; + tmpvar_7 = Squash (pos); + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + pos = tmpvar_8; +} + +void treevertex ( + inout appdata_full v +) +{ + TerrainAnimateTree (v.vertex, v.color.w); +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + v2f_surf o; + treevertex (v); + vec2 tmpvar_1; + tmpvar_1 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + o.hip_pack0 = tmpvar_1.xy.xy; + vec3 tmpvar_2; + tmpvar_2 = ((_Object2World * v.vertex).xyz - _LightPositionRange.xyz); + o.vec = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = (gl_ModelViewProjectionMatrix * v.vertex); + o.pos = tmpvar_3; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.w = 0.0; + tmpvar_17.xyz = xl_retval.vec.xyz; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + gl_TexCoord[0] = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19.zw = vec2(0.0, 0.0); + tmpvar_19.xy = xl_retval.hip_pack0.xy; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[1] = tmpvar_20; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Nature_Soft_Occlusion_Leaves3-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Nature_Soft_Occlusion_Leaves3-out.txt new file mode 100644 index 000000000..efbeb447a --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Nature_Soft_Occlusion_Leaves3-out.txt @@ -0,0 +1,34 @@ +uniform mat4 _TerrainEngineBendTree; +uniform vec4 _SquashPlaneNormal; +uniform float _SquashAmount; +uniform vec4 _Scale; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform vec4 _LightPositionRange; +void main () +{ + vec4 pos; + pos = gl_Vertex; + pos.xyz = (gl_Vertex.xyz * _Scale.xyz); + vec4 tmpvar_1; + tmpvar_1.w = 0.0; + tmpvar_1.xyz = pos.xyz; + pos.xyz = mix (pos.xyz, (_TerrainEngineBendTree * tmpvar_1).xyz, gl_Color.www); + vec3 tmpvar_2; + tmpvar_2.xz = vec2(0.0, 0.0); + tmpvar_2.y = _SquashPlaneNormal.w; + vec4 tmpvar_3; + tmpvar_3.w = 1.0; + tmpvar_3.xyz = mix ((pos.xyz + (dot (_SquashPlaneNormal.xyz, (tmpvar_2 - pos.xyz)) * _SquashPlaneNormal.xyz)), pos.xyz, vec3(_SquashAmount)); + pos = tmpvar_3; + gl_Position = (gl_ModelViewProjectionMatrix * tmpvar_3); + vec4 tmpvar_4; + tmpvar_4.w = 0.0; + tmpvar_4.xyz = ((_Object2World * tmpvar_3).xyz - _LightPositionRange.xyz); + gl_TexCoord[0] = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5.zw = vec2(0.0, 0.0); + tmpvar_5.xy = ((gl_MultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + gl_TexCoord[1] = tmpvar_5; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Parallax_Diffuse-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Parallax_Diffuse-in.txt new file mode 100644 index 000000000..ecc2785e2 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Parallax_Diffuse-in.txt @@ -0,0 +1,189 @@ +mat3 xll_constructMat3( mat4 m) { + return mat3( vec3( m[0]), vec3( m[1]), vec3( m[2])); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; + vec3 viewDir; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 viewDir; + vec3 lightDir; + vec3 vlight; + vec4 _ShadowCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _BumpMap_ST; +uniform vec4 _MainTex_ST; +uniform mat4 _Object2World; +uniform vec4 _ProjectionParams; +uniform mat4 _World2Object; +uniform vec3 _WorldSpaceCameraPos; +uniform vec4 _WorldSpaceLightPos0; + +uniform vec4 unity_4LightAtten0; +uniform vec4 unity_4LightPosX0; +uniform vec4 unity_4LightPosY0; +uniform vec4 unity_4LightPosZ0; +uniform vec3 unity_LightColor0; +uniform vec3 unity_LightColor1; +uniform vec3 unity_LightColor2; +uniform vec3 unity_LightColor3; +uniform vec4 unity_SHAb; +uniform vec4 unity_SHAg; +uniform vec4 unity_SHAr; +uniform vec4 unity_SHBb; +uniform vec4 unity_SHBg; +uniform vec4 unity_SHBr; +uniform vec4 unity_SHC; +uniform vec4 unity_Scale; +vec3 ShadeSH9( in vec4 normal ); +vec3 Shade4PointLights( in vec4 lightPosX, in vec4 lightPosY, in vec4 lightPosZ, in vec3 lightColor0, in vec3 lightColor1, in vec3 lightColor2, in vec3 lightColor3, in vec4 lightAttenSq, in vec3 pos, in vec3 normal ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +vec3 ObjSpaceViewDir( in vec4 v ); +vec3 ObjSpaceLightDir( in vec4 v ); +vec4 ComputeScreenPos( in vec4 pos ); +v2f_surf vert_surf( in appdata_full v ); +vec3 ShadeSH9( in vec4 normal ) { + vec3 x1; + vec4 vB; + vec3 x2; + float vC; + vec3 x3; + x1.x = dot( unity_SHAr, normal); + x1.y = dot( unity_SHAg, normal); + x1.z = dot( unity_SHAb, normal); + vB = (normal.xyzz * normal.yzzx ); + x2.x = dot( unity_SHBr, vB); + x2.y = dot( unity_SHBg, vB); + x2.z = dot( unity_SHBb, vB); + vC = ((normal.x * normal.x ) - (normal.y * normal.y )); + x3 = (unity_SHC.xyz * vC); + return ((x1 + x2) + x3); +} +vec3 Shade4PointLights( in vec4 lightPosX, in vec4 lightPosY, in vec4 lightPosZ, in vec3 lightColor0, in vec3 lightColor1, in vec3 lightColor2, in vec3 lightColor3, in vec4 lightAttenSq, in vec3 pos, in vec3 normal ) { + vec4 toLightX; + vec4 toLightY; + vec4 toLightZ; + vec4 lengthSq; + vec4 ndotl; + vec4 corr; + vec4 atten; + vec4 diff; + vec3 col; + toLightX = (lightPosX - pos.x ); + toLightY = (lightPosY - pos.y ); + toLightZ = (lightPosZ - pos.z ); + lengthSq = vec4( 0.000000); + lengthSq += (toLightX * toLightX); + lengthSq += (toLightY * toLightY); + lengthSq += (toLightZ * toLightZ); + ndotl = vec4( 0.000000); + ndotl += (toLightX * normal.x ); + ndotl += (toLightY * normal.y ); + ndotl += (toLightZ * normal.z ); + corr = inversesqrt( lengthSq ); + ndotl = max( vec4( 0.000000, 0.000000, 0.000000, 0.000000), (ndotl * corr)); + atten = (1.00000 / (1.00000 + (lengthSq * lightAttenSq))); + diff = (ndotl * atten); + col = vec3( 0.000000); + col += (lightColor0 * diff.x ); + col += (lightColor1 * diff.y ); + col += (lightColor2 * diff.z ); + col += (lightColor3 * diff.w ); + return col; +} +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +vec3 ObjSpaceViewDir( in vec4 v ) { + vec3 objSpaceCameraPos; + objSpaceCameraPos = (( _World2Object * vec4( _WorldSpaceCameraPos.xyz , 1.00000) ).xyz * unity_Scale.w ); + return (objSpaceCameraPos - v.xyz ); +} +vec3 ObjSpaceLightDir( in vec4 v ) { + vec3 objSpaceLightPos; + objSpaceLightPos = ( _World2Object * _WorldSpaceLightPos0 ).xyz ; + return objSpaceLightPos.xyz ; +} +vec4 ComputeScreenPos( in vec4 pos ) { + vec4 o; + o = (pos * 0.500000); + o.xy = (vec2( o.x , (o.y * _ProjectionParams.x )) + o.w ); + o.zw = pos.zw ; + return o; +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + vec3 worldN; + vec3 binormal; + mat3 rotation; + vec3 shlight; + vec3 worldPos; + PositionFog( v.vertex, o.pos, o.fog); + o.hip_pack0.xy = ((v.texcoord.xy * _MainTex_ST.xy ) + _MainTex_ST.zw ); + o.hip_pack0.zw = ((v.texcoord.xy * _BumpMap_ST.xy ) + _BumpMap_ST.zw ); + worldN = ( xll_constructMat3( _Object2World) * (v.normal * unity_Scale.w ) ); + binormal = (cross( v.normal, v.tangent.xyz ) * v.tangent.w ); + rotation = mat3( v.tangent.x , binormal.x , v.normal.x , v.tangent.y , binormal.y , v.normal.y , v.tangent.z , binormal.z , v.normal.z ); + o.lightDir = ( rotation * ObjSpaceLightDir( v.vertex) ); + o.viewDir = ( rotation * ObjSpaceViewDir( v.vertex) ); + shlight = ShadeSH9( vec4( worldN, 1.00000)); + o.vlight = shlight; + worldPos = ( _Object2World * v.vertex ).xyz ; + o.vlight += Shade4PointLights( unity_4LightPosX0, unity_4LightPosY0, unity_4LightPosZ0, unity_LightColor0, unity_LightColor1, unity_LightColor2, unity_LightColor3, unity_4LightAtten0, worldPos, worldN); + o._ShadowCoord = ComputeScreenPos( o.pos); + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.hip_pack0); + gl_TexCoord[1] = vec4( xl_retval.viewDir, 0.0); + gl_TexCoord[2] = vec4( xl_retval.lightDir, 0.0); + gl_TexCoord[3] = vec4( xl_retval.vlight, 0.0); + gl_TexCoord[4] = vec4( xl_retval._ShadowCoord); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Parallax_Diffuse-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Parallax_Diffuse-ir.txt new file mode 100644 index 000000000..7680c076f --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Parallax_Diffuse-ir.txt @@ -0,0 +1,439 @@ +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 viewDir; + vec3 lightDir; + vec3 vlight; + vec4 _ShadowCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec4 unity_SHC; +uniform vec4 unity_SHBr; +uniform vec4 unity_SHBg; +uniform vec4 unity_SHBb; +uniform vec4 unity_SHAr; +uniform vec4 unity_SHAg; +uniform vec4 unity_SHAb; +uniform vec3 unity_LightColor3; +uniform vec3 unity_LightColor2; +uniform vec3 unity_LightColor1; +uniform vec3 unity_LightColor0; +uniform vec4 unity_4LightPosZ0; +uniform vec4 unity_4LightPosY0; +uniform vec4 unity_4LightPosX0; +uniform vec4 unity_4LightAtten0; +uniform vec4 _WorldSpaceLightPos0; +uniform vec3 _WorldSpaceCameraPos; +uniform mat4 _World2Object; +uniform vec4 _ProjectionParams; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform vec4 _BumpMap_ST; +mat3 xll_constructMat3 ( + in mat4 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = m[0].xyz; + vec3 tmpvar_2; + tmpvar_2 = m[1].xyz; + vec3 tmpvar_3; + tmpvar_3 = m[2].xyz; + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +vec3 ShadeSH9 ( + in vec4 normal +) +{ + vec3 x3; + float vC; + vec3 x2; + vec4 vB; + vec3 x1; + float tmpvar_1; + tmpvar_1 = dot (unity_SHAr, normal); + float tmpvar_2; + tmpvar_2 = tmpvar_1; + x1.x = tmpvar_2; + float tmpvar_3; + tmpvar_3 = dot (unity_SHAg, normal); + float tmpvar_4; + tmpvar_4 = tmpvar_3; + x1.y = vec2(tmpvar_4).y; + float tmpvar_5; + tmpvar_5 = dot (unity_SHAb, normal); + float tmpvar_6; + tmpvar_6 = tmpvar_5; + x1.z = vec3(tmpvar_6).z; + vec4 tmpvar_7; + tmpvar_7 = (normal.xyzz * normal.yzzx); + vB = tmpvar_7; + float tmpvar_8; + tmpvar_8 = dot (unity_SHBr, vB); + float tmpvar_9; + tmpvar_9 = tmpvar_8; + x2.x = tmpvar_9; + float tmpvar_10; + tmpvar_10 = dot (unity_SHBg, vB); + float tmpvar_11; + tmpvar_11 = tmpvar_10; + x2.y = vec2(tmpvar_11).y; + float tmpvar_12; + tmpvar_12 = dot (unity_SHBb, vB); + float tmpvar_13; + tmpvar_13 = tmpvar_12; + x2.z = vec3(tmpvar_13).z; + float tmpvar_14; + tmpvar_14 = ((normal.x * normal.x) - (normal.y * normal.y)); + vC = tmpvar_14; + vec3 tmpvar_15; + tmpvar_15 = (unity_SHC.xyz * vC); + x3 = tmpvar_15; + return ((x1 + x2) + x3); +} + +vec3 Shade4PointLights ( + in vec4 lightPosX, + in vec4 lightPosY, + in vec4 lightPosZ, + in vec3 lightColor0, + in vec3 lightColor1, + in vec3 lightColor2, + in vec3 lightColor3, + in vec4 lightAttenSq, + in vec3 pos, + in vec3 normal +) +{ + vec3 col; + vec4 diff; + vec4 atten; + vec4 corr; + vec4 ndotl; + vec4 lengthSq; + vec4 toLightZ; + vec4 toLightY; + vec4 toLightX; + vec4 tmpvar_1; + tmpvar_1 = (lightPosX - pos.x); + toLightX = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = (lightPosY - pos.y); + toLightY = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = (lightPosZ - pos.z); + toLightZ = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4 = vec4(0.0, 0.0, 0.0, 0.0); + lengthSq = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = (lengthSq + (toLightX * toLightX)); + lengthSq = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = (lengthSq + (toLightY * toLightY)); + lengthSq = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = (lengthSq + (toLightZ * toLightZ)); + lengthSq = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = vec4(0.0, 0.0, 0.0, 0.0); + ndotl = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = (ndotl + (toLightX * normal.x)); + ndotl = tmpvar_9; + vec4 tmpvar_10; + tmpvar_10 = (ndotl + (toLightY * normal.y)); + ndotl = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = (ndotl + (toLightZ * normal.z)); + ndotl = tmpvar_11; + vec4 tmpvar_12; + tmpvar_12 = inversesqrt (lengthSq); + vec4 tmpvar_13; + tmpvar_13 = tmpvar_12; + corr = tmpvar_13; + vec4 tmpvar_14; + tmpvar_14 = max (vec4(0.0, 0.0, 0.0, 0.0), (ndotl * corr)); + vec4 tmpvar_15; + tmpvar_15 = tmpvar_14; + ndotl = tmpvar_15; + vec4 tmpvar_16; + tmpvar_16 = (1.0 / (1.0 + (lengthSq * lightAttenSq))); + atten = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17 = (ndotl * atten); + diff = tmpvar_17; + vec3 tmpvar_18; + tmpvar_18 = vec3(0.0, 0.0, 0.0); + col = tmpvar_18; + vec3 tmpvar_19; + tmpvar_19 = (col + (lightColor0 * diff.x)); + col = tmpvar_19; + vec3 tmpvar_20; + tmpvar_20 = (col + (lightColor1 * diff.y)); + col = tmpvar_20; + vec3 tmpvar_21; + tmpvar_21 = (col + (lightColor2 * diff.z)); + col = tmpvar_21; + vec3 tmpvar_22; + tmpvar_22 = (col + (lightColor3 * diff.w)); + col = tmpvar_22; + return col; +} + +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +vec3 ObjSpaceViewDir ( + in vec4 v +) +{ + vec3 objSpaceCameraPos; + vec4 tmpvar_1; + tmpvar_1.w = 1.0; + tmpvar_1.xyz = _WorldSpaceCameraPos.xyz.xyz; + vec3 tmpvar_2; + tmpvar_2 = ((_World2Object * tmpvar_1).xyz * unity_Scale.w); + objSpaceCameraPos = tmpvar_2; + return (objSpaceCameraPos - v.xyz); +} + +vec3 ObjSpaceLightDir ( + in vec4 v +) +{ + vec3 objSpaceLightPos; + vec3 tmpvar_1; + tmpvar_1 = (_World2Object * _WorldSpaceLightPos0).xyz; + objSpaceLightPos = tmpvar_1; + return objSpaceLightPos.xyz; +} + +vec4 ComputeScreenPos ( + in vec4 pos +) +{ + vec4 o; + vec4 tmpvar_1; + tmpvar_1 = (pos * 0.5); + o = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2.x = o.x; + tmpvar_2.y = (o.y * _ProjectionParams.x); + vec2 tmpvar_3; + tmpvar_3 = (tmpvar_2 + o.w); + o.xy = tmpvar_3.xy.xy; + vec2 tmpvar_4; + tmpvar_4 = pos.zw; + o.zw = tmpvar_4.xxxy.zw; + return o; +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + vec3 worldPos; + vec3 shlight; + mat3 rotation; + vec3 binormal; + vec3 worldN; + v2f_surf o; + PositionFog (v.vertex, o.pos, o.fog); + vec2 tmpvar_1; + tmpvar_1 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + o.hip_pack0.xy = tmpvar_1.xy.xy; + vec2 tmpvar_2; + tmpvar_2 = ((v.texcoord.xy * _BumpMap_ST.xy) + _BumpMap_ST.zw); + o.hip_pack0.zw = tmpvar_2.xxxy.zw; + mat3 tmpvar_3; + tmpvar_3 = (xll_constructMat3 (_Object2World)); + vec3 tmpvar_4; + tmpvar_4 = (tmpvar_3 * (v.normal * unity_Scale.w)); + worldN = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = cross (v.normal, v.tangent.xyz); + vec3 tmpvar_6; + tmpvar_6 = (tmpvar_5 * v.tangent.w); + binormal = tmpvar_6; + mat3 tmpvar_7; + float tmpvar_8; + tmpvar_8 = v.tangent.x; + tmpvar_7[0].x = tmpvar_8; + float tmpvar_9; + tmpvar_9 = binormal.x; + tmpvar_7[0].y = tmpvar_9; + float tmpvar_10; + tmpvar_10 = v.normal.x; + tmpvar_7[0].z = tmpvar_10; + float tmpvar_11; + tmpvar_11 = v.tangent.y; + tmpvar_7[1].x = tmpvar_11; + float tmpvar_12; + tmpvar_12 = binormal.y; + tmpvar_7[1].y = tmpvar_12; + float tmpvar_13; + tmpvar_13 = v.normal.y; + tmpvar_7[1].z = tmpvar_13; + float tmpvar_14; + tmpvar_14 = v.tangent.z; + tmpvar_7[2].x = tmpvar_14; + float tmpvar_15; + tmpvar_15 = binormal.z; + tmpvar_7[2].y = tmpvar_15; + float tmpvar_16; + tmpvar_16 = v.normal.z; + tmpvar_7[2].z = tmpvar_16; + mat3 tmpvar_17; + tmpvar_17 = (tmpvar_7); + rotation = (tmpvar_17); + vec3 tmpvar_18; + tmpvar_18 = ObjSpaceLightDir (v.vertex); + vec3 tmpvar_19; + tmpvar_19 = (rotation * tmpvar_18); + o.lightDir = tmpvar_19; + vec3 tmpvar_20; + tmpvar_20 = ObjSpaceViewDir (v.vertex); + vec3 tmpvar_21; + tmpvar_21 = (rotation * tmpvar_20); + o.viewDir = tmpvar_21; + vec4 tmpvar_22; + tmpvar_22.w = 1.0; + tmpvar_22.xyz = worldN.xyz; + vec3 tmpvar_23; + tmpvar_23 = ShadeSH9 (tmpvar_22); + vec3 tmpvar_24; + tmpvar_24 = tmpvar_23; + shlight = tmpvar_24; + vec3 tmpvar_25; + tmpvar_25 = shlight; + o.vlight = tmpvar_25; + vec3 tmpvar_26; + tmpvar_26 = (_Object2World * v.vertex).xyz; + worldPos = tmpvar_26; + vec3 tmpvar_27; + tmpvar_27 = Shade4PointLights (unity_4LightPosX0, unity_4LightPosY0, unity_4LightPosZ0, unity_LightColor0, unity_LightColor1, unity_LightColor2, unity_LightColor3, unity_4LightAtten0, worldPos, worldN); + vec3 tmpvar_28; + tmpvar_28 = (o.vlight + tmpvar_27); + o.vlight = tmpvar_28; + vec4 tmpvar_29; + tmpvar_29 = ComputeScreenPos (o.pos); + vec4 tmpvar_30; + tmpvar_30 = tmpvar_29; + o._ShadowCoord = tmpvar_30; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = xl_retval.fog; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_FOG = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19 = xl_retval.hip_pack0.xyzw; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[0] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21.w = 0.0; + tmpvar_21.xyz = xl_retval.viewDir.xyz; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_TexCoord[1] = tmpvar_22; + vec4 tmpvar_23; + tmpvar_23.w = 0.0; + tmpvar_23.xyz = xl_retval.lightDir.xyz; + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + gl_TexCoord[2] = tmpvar_24; + vec4 tmpvar_25; + tmpvar_25.w = 0.0; + tmpvar_25.xyz = xl_retval.vlight.xyz; + vec4 tmpvar_26; + tmpvar_26 = tmpvar_25; + gl_TexCoord[3] = tmpvar_26; + vec4 tmpvar_27; + tmpvar_27 = xl_retval._ShadowCoord.xyzw; + vec4 tmpvar_28; + tmpvar_28 = tmpvar_27; + gl_TexCoord[4] = tmpvar_28; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Parallax_Diffuse-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Parallax_Diffuse-out.txt new file mode 100644 index 000000000..f89a0eb27 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Parallax_Diffuse-out.txt @@ -0,0 +1,108 @@ +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec4 unity_SHC; +uniform vec4 unity_SHBr; +uniform vec4 unity_SHBg; +uniform vec4 unity_SHBb; +uniform vec4 unity_SHAr; +uniform vec4 unity_SHAg; +uniform vec4 unity_SHAb; +uniform vec3 unity_LightColor3; +uniform vec3 unity_LightColor2; +uniform vec3 unity_LightColor1; +uniform vec3 unity_LightColor0; +uniform vec4 unity_4LightPosZ0; +uniform vec4 unity_4LightPosY0; +uniform vec4 unity_4LightPosX0; +uniform vec4 unity_4LightAtten0; +uniform vec4 _WorldSpaceLightPos0; +uniform vec3 _WorldSpaceCameraPos; +uniform mat4 _World2Object; +uniform vec4 _ProjectionParams; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform vec4 _BumpMap_ST; +void main () +{ + vec4 tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = (gl_ModelViewProjectionMatrix * gl_Vertex); + tmpvar_1.xy = ((gl_MultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + tmpvar_1.zw = ((gl_MultiTexCoord0.xy * _BumpMap_ST.xy) + _BumpMap_ST.zw); + mat3 tmpvar_3; + tmpvar_3[0] = _Object2World[0].xyz; + tmpvar_3[1] = _Object2World[1].xyz; + tmpvar_3[2] = _Object2World[2].xyz; + vec3 tmpvar_4; + tmpvar_4 = (tmpvar_3 * (gl_Normal * unity_Scale.w)); + vec3 tmpvar_5; + tmpvar_5 = (cross (gl_Normal, TANGENT.xyz) * TANGENT.w); + mat3 tmpvar_6; + tmpvar_6[0].x = TANGENT.x; + tmpvar_6[0].y = tmpvar_5.x; + tmpvar_6[0].z = gl_Normal.x; + tmpvar_6[1].x = TANGENT.y; + tmpvar_6[1].y = tmpvar_5.y; + tmpvar_6[1].z = gl_Normal.y; + tmpvar_6[2].x = TANGENT.z; + tmpvar_6[2].y = tmpvar_5.z; + tmpvar_6[2].z = gl_Normal.z; + vec4 tmpvar_7; + tmpvar_7.w = 1.0; + tmpvar_7.xyz = _WorldSpaceCameraPos; + vec4 tmpvar_8; + tmpvar_8.w = 1.0; + tmpvar_8.xyz = tmpvar_4; + vec3 x2; + vec3 x1; + x1.x = dot (unity_SHAr, tmpvar_8); + x1.y = dot (unity_SHAg, tmpvar_8); + x1.z = dot (unity_SHAb, tmpvar_8); + vec4 tmpvar_9; + tmpvar_9 = (tmpvar_4.xyzz * tmpvar_4.yzzx); + x2.x = dot (unity_SHBr, tmpvar_9); + x2.y = dot (unity_SHBg, tmpvar_9); + x2.z = dot (unity_SHBb, tmpvar_9); + vec3 tmpvar_10; + tmpvar_10 = (_Object2World * gl_Vertex).xyz; + vec4 tmpvar_11; + tmpvar_11 = (unity_4LightPosX0 - tmpvar_10.x); + vec4 tmpvar_12; + tmpvar_12 = (unity_4LightPosY0 - tmpvar_10.y); + vec4 tmpvar_13; + tmpvar_13 = (unity_4LightPosZ0 - tmpvar_10.z); + vec4 tmpvar_14; + tmpvar_14 = (((tmpvar_11 * tmpvar_11) + (tmpvar_12 * tmpvar_12)) + (tmpvar_13 * tmpvar_13)); + vec4 tmpvar_15; + tmpvar_15 = (max (vec4(0.0, 0.0, 0.0, 0.0), ((((tmpvar_11 * tmpvar_4.x) + (tmpvar_12 * tmpvar_4.y)) + (tmpvar_13 * tmpvar_4.z)) * inversesqrt (tmpvar_14))) * (1.0/((1.0 + (tmpvar_14 * unity_4LightAtten0))))); + vec4 o_i0; + vec4 tmpvar_16; + tmpvar_16 = (tmpvar_2 * 0.5); + o_i0 = tmpvar_16; + vec2 tmpvar_17; + tmpvar_17.x = tmpvar_16.x; + tmpvar_17.y = (tmpvar_16.y * _ProjectionParams.x); + o_i0.xy = (tmpvar_17 + tmpvar_16.w); + o_i0.zw = tmpvar_2.zw; + gl_Position = tmpvar_2; + vec4 tmpvar_18; + tmpvar_18.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_18.x = tmpvar_2.z; + xlv_FOG = tmpvar_18; + gl_TexCoord[0] = tmpvar_1; + vec4 tmpvar_19; + tmpvar_19.w = 0.0; + tmpvar_19.xyz = (tmpvar_6 * (((_World2Object * tmpvar_7).xyz * unity_Scale.w) - gl_Vertex.xyz)); + gl_TexCoord[1] = tmpvar_19; + vec4 tmpvar_20; + tmpvar_20.w = 0.0; + tmpvar_20.xyz = (tmpvar_6 * (_World2Object * _WorldSpaceLightPos0).xyz); + gl_TexCoord[2] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21.w = 0.0; + tmpvar_21.xyz = (((x1 + x2) + (unity_SHC.xyz * ((tmpvar_4.x * tmpvar_4.x) - (tmpvar_4.y * tmpvar_4.y)))) + ((((unity_LightColor0 * tmpvar_15.x) + (unity_LightColor1 * tmpvar_15.y)) + (unity_LightColor2 * tmpvar_15.z)) + (unity_LightColor3 * tmpvar_15.w))); + gl_TexCoord[3] = tmpvar_21; + gl_TexCoord[4] = o_i0; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Parallax_Diffuse1-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Parallax_Diffuse1-in.txt new file mode 100644 index 000000000..415b1f8fa --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Parallax_Diffuse1-in.txt @@ -0,0 +1,99 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; + vec3 viewDir; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 viewDir; + vec4 hip_screen; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _BumpMap_ST; +uniform vec4 _MainTex_ST; +uniform vec4 _ProjectionParams; +uniform mat4 _World2Object; +uniform vec3 _WorldSpaceCameraPos; + +uniform vec4 unity_Scale; +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +vec3 ObjSpaceViewDir( in vec4 v ); +vec4 ComputeScreenPos( in vec4 pos ); +v2f_surf vert_surf( in appdata_full v ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +vec3 ObjSpaceViewDir( in vec4 v ) { + vec3 objSpaceCameraPos; + objSpaceCameraPos = (( _World2Object * vec4( _WorldSpaceCameraPos.xyz , 1.00000) ).xyz * unity_Scale.w ); + return (objSpaceCameraPos - v.xyz ); +} +vec4 ComputeScreenPos( in vec4 pos ) { + vec4 o; + o = (pos * 0.500000); + o.xy = (vec2( o.x , (o.y * _ProjectionParams.x )) + o.w ); + o.zw = pos.zw ; + return o; +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + vec3 binormal; + mat3 rotation; + PositionFog( v.vertex, o.pos, o.fog); + o.hip_pack0.xy = ((v.texcoord.xy * _MainTex_ST.xy ) + _MainTex_ST.zw ); + o.hip_pack0.zw = ((v.texcoord.xy * _BumpMap_ST.xy ) + _BumpMap_ST.zw ); + o.hip_screen = ComputeScreenPos( o.pos); + binormal = (cross( v.normal, v.tangent.xyz ) * v.tangent.w ); + rotation = mat3( v.tangent.x , binormal.x , v.normal.x , v.tangent.y , binormal.y , v.normal.y , v.tangent.z , binormal.z , v.normal.z ); + o.viewDir = ( rotation * ObjSpaceViewDir( v.vertex) ); + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.hip_pack0); + gl_TexCoord[1] = vec4( xl_retval.viewDir, 0.0); + gl_TexCoord[2] = vec4( xl_retval.hip_screen); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Parallax_Diffuse1-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Parallax_Diffuse1-ir.txt new file mode 100644 index 000000000..9f7a84527 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Parallax_Diffuse1-ir.txt @@ -0,0 +1,202 @@ +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 viewDir; + vec4 hip_screen; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec3 _WorldSpaceCameraPos; +uniform mat4 _World2Object; +uniform vec4 _ProjectionParams; +uniform vec4 _MainTex_ST; +uniform vec4 _BumpMap_ST; +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +vec3 ObjSpaceViewDir ( + in vec4 v +) +{ + vec3 objSpaceCameraPos; + vec4 tmpvar_1; + tmpvar_1.w = 1.0; + tmpvar_1.xyz = _WorldSpaceCameraPos.xyz.xyz; + vec3 tmpvar_2; + tmpvar_2 = ((_World2Object * tmpvar_1).xyz * unity_Scale.w); + objSpaceCameraPos = tmpvar_2; + return (objSpaceCameraPos - v.xyz); +} + +vec4 ComputeScreenPos ( + in vec4 pos +) +{ + vec4 o; + vec4 tmpvar_1; + tmpvar_1 = (pos * 0.5); + o = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2.x = o.x; + tmpvar_2.y = (o.y * _ProjectionParams.x); + vec2 tmpvar_3; + tmpvar_3 = (tmpvar_2 + o.w); + o.xy = tmpvar_3.xy.xy; + vec2 tmpvar_4; + tmpvar_4 = pos.zw; + o.zw = tmpvar_4.xxxy.zw; + return o; +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + mat3 rotation; + vec3 binormal; + v2f_surf o; + PositionFog (v.vertex, o.pos, o.fog); + vec2 tmpvar_1; + tmpvar_1 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + o.hip_pack0.xy = tmpvar_1.xy.xy; + vec2 tmpvar_2; + tmpvar_2 = ((v.texcoord.xy * _BumpMap_ST.xy) + _BumpMap_ST.zw); + o.hip_pack0.zw = tmpvar_2.xxxy.zw; + vec4 tmpvar_3; + tmpvar_3 = ComputeScreenPos (o.pos); + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + o.hip_screen = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = cross (v.normal, v.tangent.xyz); + vec3 tmpvar_6; + tmpvar_6 = (tmpvar_5 * v.tangent.w); + binormal = tmpvar_6; + mat3 tmpvar_7; + float tmpvar_8; + tmpvar_8 = v.tangent.x; + tmpvar_7[0].x = tmpvar_8; + float tmpvar_9; + tmpvar_9 = binormal.x; + tmpvar_7[0].y = tmpvar_9; + float tmpvar_10; + tmpvar_10 = v.normal.x; + tmpvar_7[0].z = tmpvar_10; + float tmpvar_11; + tmpvar_11 = v.tangent.y; + tmpvar_7[1].x = tmpvar_11; + float tmpvar_12; + tmpvar_12 = binormal.y; + tmpvar_7[1].y = tmpvar_12; + float tmpvar_13; + tmpvar_13 = v.normal.y; + tmpvar_7[1].z = tmpvar_13; + float tmpvar_14; + tmpvar_14 = v.tangent.z; + tmpvar_7[2].x = tmpvar_14; + float tmpvar_15; + tmpvar_15 = binormal.z; + tmpvar_7[2].y = tmpvar_15; + float tmpvar_16; + tmpvar_16 = v.normal.z; + tmpvar_7[2].z = tmpvar_16; + mat3 tmpvar_17; + tmpvar_17 = (tmpvar_7); + rotation = (tmpvar_17); + vec3 tmpvar_18; + tmpvar_18 = ObjSpaceViewDir (v.vertex); + vec3 tmpvar_19; + tmpvar_19 = (rotation * tmpvar_18); + o.viewDir = tmpvar_19; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = xl_retval.fog; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_FOG = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19 = xl_retval.hip_pack0.xyzw; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[0] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21.w = 0.0; + tmpvar_21.xyz = xl_retval.viewDir.xyz; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_TexCoord[1] = tmpvar_22; + vec4 tmpvar_23; + tmpvar_23 = xl_retval.hip_screen.xyzw; + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + gl_TexCoord[2] = tmpvar_24; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Parallax_Diffuse1-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Parallax_Diffuse1-out.txt new file mode 100644 index 000000000..4e316762f --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Parallax_Diffuse1-out.txt @@ -0,0 +1,52 @@ +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec3 _WorldSpaceCameraPos; +uniform mat4 _World2Object; +uniform vec4 _ProjectionParams; +uniform vec4 _MainTex_ST; +uniform vec4 _BumpMap_ST; +void main () +{ + vec4 tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = (gl_ModelViewProjectionMatrix * gl_Vertex); + tmpvar_1.xy = ((gl_MultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + tmpvar_1.zw = ((gl_MultiTexCoord0.xy * _BumpMap_ST.xy) + _BumpMap_ST.zw); + vec4 o_i0; + vec4 tmpvar_3; + tmpvar_3 = (tmpvar_2 * 0.5); + o_i0 = tmpvar_3; + vec2 tmpvar_4; + tmpvar_4.x = tmpvar_3.x; + tmpvar_4.y = (tmpvar_3.y * _ProjectionParams.x); + o_i0.xy = (tmpvar_4 + tmpvar_3.w); + o_i0.zw = tmpvar_2.zw; + vec3 tmpvar_5; + tmpvar_5 = (cross (gl_Normal, TANGENT.xyz) * TANGENT.w); + mat3 tmpvar_6; + tmpvar_6[0].x = TANGENT.x; + tmpvar_6[0].y = tmpvar_5.x; + tmpvar_6[0].z = gl_Normal.x; + tmpvar_6[1].x = TANGENT.y; + tmpvar_6[1].y = tmpvar_5.y; + tmpvar_6[1].z = gl_Normal.y; + tmpvar_6[2].x = TANGENT.z; + tmpvar_6[2].y = tmpvar_5.z; + tmpvar_6[2].z = gl_Normal.z; + vec4 tmpvar_7; + tmpvar_7.w = 1.0; + tmpvar_7.xyz = _WorldSpaceCameraPos; + gl_Position = tmpvar_2; + vec4 tmpvar_8; + tmpvar_8.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_8.x = tmpvar_2.z; + xlv_FOG = tmpvar_8; + gl_TexCoord[0] = tmpvar_1; + vec4 tmpvar_9; + tmpvar_9.w = 0.0; + tmpvar_9.xyz = (tmpvar_6 * (((_World2Object * tmpvar_7).xyz * unity_Scale.w) - gl_Vertex.xyz)); + gl_TexCoord[1] = tmpvar_9; + gl_TexCoord[2] = o_i0; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Parallax_Diffuse2-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Parallax_Diffuse2-in.txt new file mode 100644 index 000000000..065b01e62 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Parallax_Diffuse2-in.txt @@ -0,0 +1,106 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; + vec3 viewDir; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 viewDir; + vec4 hip_screen; + vec3 hip_lmapFade; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _BumpMap_ST; +uniform vec4 _MainTex_ST; +uniform vec4 _ProjectionParams; +uniform mat4 _World2Object; +uniform vec3 _WorldSpaceCameraPos; + + +uniform vec4 unity_LightmapFade; +uniform vec4 unity_LightmapST; +uniform vec4 unity_Scale; +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +vec3 ObjSpaceViewDir( in vec4 v ); +vec4 ComputeScreenPos( in vec4 pos ); +v2f_surf vert_surf( in appdata_full v ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +vec3 ObjSpaceViewDir( in vec4 v ) { + vec3 objSpaceCameraPos; + objSpaceCameraPos = (( _World2Object * vec4( _WorldSpaceCameraPos.xyz , 1.00000) ).xyz * unity_Scale.w ); + return (objSpaceCameraPos - v.xyz ); +} +vec4 ComputeScreenPos( in vec4 pos ) { + vec4 o; + o = (pos * 0.500000); + o.xy = (vec2( o.x , (o.y * _ProjectionParams.x )) + o.w ); + o.zw = pos.zw ; + return o; +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + vec3 binormal; + mat3 rotation; + PositionFog( v.vertex, o.pos, o.fog); + o.hip_pack0.xy = ((v.texcoord.xy * _MainTex_ST.xy ) + _MainTex_ST.zw ); + o.hip_pack0.zw = ((v.texcoord.xy * _BumpMap_ST.xy ) + _BumpMap_ST.zw ); + o.hip_screen = ComputeScreenPos( o.pos); + o.hip_lmapFade.xy = ((v.texcoord1.xy * unity_LightmapST.xy ) + unity_LightmapST.zw ); + o.hip_lmapFade.z = ((( -( gl_ModelViewMatrix * v.vertex ).z ) * unity_LightmapFade.z ) + unity_LightmapFade.w ); + binormal = (cross( v.normal, v.tangent.xyz ) * v.tangent.w ); + rotation = mat3( v.tangent.x , binormal.x , v.normal.x , v.tangent.y , binormal.y , v.normal.y , v.tangent.z , binormal.z , v.normal.z ); + o.viewDir = ( rotation * ObjSpaceViewDir( v.vertex) ); + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.hip_pack0); + gl_TexCoord[1] = vec4( xl_retval.viewDir, 0.0); + gl_TexCoord[2] = vec4( xl_retval.hip_screen); + gl_TexCoord[3] = vec4( xl_retval.hip_lmapFade, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Parallax_Diffuse2-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Parallax_Diffuse2-ir.txt new file mode 100644 index 000000000..a8328b242 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Parallax_Diffuse2-ir.txt @@ -0,0 +1,217 @@ +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 viewDir; + vec4 hip_screen; + vec3 hip_lmapFade; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec4 unity_LightmapST; +uniform vec4 unity_LightmapFade; +uniform vec3 _WorldSpaceCameraPos; +uniform mat4 _World2Object; +uniform vec4 _ProjectionParams; +uniform vec4 _MainTex_ST; +uniform vec4 _BumpMap_ST; +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +vec3 ObjSpaceViewDir ( + in vec4 v +) +{ + vec3 objSpaceCameraPos; + vec4 tmpvar_1; + tmpvar_1.w = 1.0; + tmpvar_1.xyz = _WorldSpaceCameraPos.xyz.xyz; + vec3 tmpvar_2; + tmpvar_2 = ((_World2Object * tmpvar_1).xyz * unity_Scale.w); + objSpaceCameraPos = tmpvar_2; + return (objSpaceCameraPos - v.xyz); +} + +vec4 ComputeScreenPos ( + in vec4 pos +) +{ + vec4 o; + vec4 tmpvar_1; + tmpvar_1 = (pos * 0.5); + o = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2.x = o.x; + tmpvar_2.y = (o.y * _ProjectionParams.x); + vec2 tmpvar_3; + tmpvar_3 = (tmpvar_2 + o.w); + o.xy = tmpvar_3.xy.xy; + vec2 tmpvar_4; + tmpvar_4 = pos.zw; + o.zw = tmpvar_4.xxxy.zw; + return o; +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + mat3 rotation; + vec3 binormal; + v2f_surf o; + PositionFog (v.vertex, o.pos, o.fog); + vec2 tmpvar_1; + tmpvar_1 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + o.hip_pack0.xy = tmpvar_1.xy.xy; + vec2 tmpvar_2; + tmpvar_2 = ((v.texcoord.xy * _BumpMap_ST.xy) + _BumpMap_ST.zw); + o.hip_pack0.zw = tmpvar_2.xxxy.zw; + vec4 tmpvar_3; + tmpvar_3 = ComputeScreenPos (o.pos); + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + o.hip_screen = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5 = ((v.texcoord1.xy * unity_LightmapST.xy) + unity_LightmapST.zw); + o.hip_lmapFade.xy = tmpvar_5.xy.xy; + float tmpvar_6; + tmpvar_6 = ((-((gl_ModelViewMatrix * v.vertex).z) * unity_LightmapFade.z) + unity_LightmapFade.w); + o.hip_lmapFade.z = vec3(tmpvar_6).z; + vec3 tmpvar_7; + tmpvar_7 = cross (v.normal, v.tangent.xyz); + vec3 tmpvar_8; + tmpvar_8 = (tmpvar_7 * v.tangent.w); + binormal = tmpvar_8; + mat3 tmpvar_9; + float tmpvar_10; + tmpvar_10 = v.tangent.x; + tmpvar_9[0].x = tmpvar_10; + float tmpvar_11; + tmpvar_11 = binormal.x; + tmpvar_9[0].y = tmpvar_11; + float tmpvar_12; + tmpvar_12 = v.normal.x; + tmpvar_9[0].z = tmpvar_12; + float tmpvar_13; + tmpvar_13 = v.tangent.y; + tmpvar_9[1].x = tmpvar_13; + float tmpvar_14; + tmpvar_14 = binormal.y; + tmpvar_9[1].y = tmpvar_14; + float tmpvar_15; + tmpvar_15 = v.normal.y; + tmpvar_9[1].z = tmpvar_15; + float tmpvar_16; + tmpvar_16 = v.tangent.z; + tmpvar_9[2].x = tmpvar_16; + float tmpvar_17; + tmpvar_17 = binormal.z; + tmpvar_9[2].y = tmpvar_17; + float tmpvar_18; + tmpvar_18 = v.normal.z; + tmpvar_9[2].z = tmpvar_18; + mat3 tmpvar_19; + tmpvar_19 = (tmpvar_9); + rotation = (tmpvar_19); + vec3 tmpvar_20; + tmpvar_20 = ObjSpaceViewDir (v.vertex); + vec3 tmpvar_21; + tmpvar_21 = (rotation * tmpvar_20); + o.viewDir = tmpvar_21; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = xl_retval.fog; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_FOG = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19 = xl_retval.hip_pack0.xyzw; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[0] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21.w = 0.0; + tmpvar_21.xyz = xl_retval.viewDir.xyz; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_TexCoord[1] = tmpvar_22; + vec4 tmpvar_23; + tmpvar_23 = xl_retval.hip_screen.xyzw; + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + gl_TexCoord[2] = tmpvar_24; + vec4 tmpvar_25; + tmpvar_25.w = 0.0; + tmpvar_25.xyz = xl_retval.hip_lmapFade.xyz; + vec4 tmpvar_26; + tmpvar_26 = tmpvar_25; + gl_TexCoord[3] = tmpvar_26; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Parallax_Diffuse2-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Parallax_Diffuse2-out.txt new file mode 100644 index 000000000..fe06607a4 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Parallax_Diffuse2-out.txt @@ -0,0 +1,61 @@ +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec4 unity_LightmapST; +uniform vec4 unity_LightmapFade; +uniform vec3 _WorldSpaceCameraPos; +uniform mat4 _World2Object; +uniform vec4 _ProjectionParams; +uniform vec4 _MainTex_ST; +uniform vec4 _BumpMap_ST; +void main () +{ + vec4 tmpvar_1; + vec3 tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = (gl_ModelViewProjectionMatrix * gl_Vertex); + tmpvar_1.xy = ((gl_MultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + tmpvar_1.zw = ((gl_MultiTexCoord0.xy * _BumpMap_ST.xy) + _BumpMap_ST.zw); + vec4 o_i0; + vec4 tmpvar_4; + tmpvar_4 = (tmpvar_3 * 0.5); + o_i0 = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5.x = tmpvar_4.x; + tmpvar_5.y = (tmpvar_4.y * _ProjectionParams.x); + o_i0.xy = (tmpvar_5 + tmpvar_4.w); + o_i0.zw = tmpvar_3.zw; + tmpvar_2.xy = ((gl_MultiTexCoord1.xy * unity_LightmapST.xy) + unity_LightmapST.zw); + tmpvar_2.z = ((-((gl_ModelViewMatrix * gl_Vertex).z) * unity_LightmapFade.z) + unity_LightmapFade.w); + vec3 tmpvar_6; + tmpvar_6 = (cross (gl_Normal, TANGENT.xyz) * TANGENT.w); + mat3 tmpvar_7; + tmpvar_7[0].x = TANGENT.x; + tmpvar_7[0].y = tmpvar_6.x; + tmpvar_7[0].z = gl_Normal.x; + tmpvar_7[1].x = TANGENT.y; + tmpvar_7[1].y = tmpvar_6.y; + tmpvar_7[1].z = gl_Normal.y; + tmpvar_7[2].x = TANGENT.z; + tmpvar_7[2].y = tmpvar_6.z; + tmpvar_7[2].z = gl_Normal.z; + vec4 tmpvar_8; + tmpvar_8.w = 1.0; + tmpvar_8.xyz = _WorldSpaceCameraPos; + gl_Position = tmpvar_3; + vec4 tmpvar_9; + tmpvar_9.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_9.x = tmpvar_3.z; + xlv_FOG = tmpvar_9; + gl_TexCoord[0] = tmpvar_1; + vec4 tmpvar_10; + tmpvar_10.w = 0.0; + tmpvar_10.xyz = (tmpvar_7 * (((_World2Object * tmpvar_8).xyz * unity_Scale.w) - gl_Vertex.xyz)); + gl_TexCoord[1] = tmpvar_10; + gl_TexCoord[2] = o_i0; + vec4 tmpvar_11; + tmpvar_11.w = 0.0; + tmpvar_11.xyz = tmpvar_2; + gl_TexCoord[3] = tmpvar_11; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Particles_Blend-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Particles_Blend-in.txt new file mode 100644 index 000000000..85a87ed39 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Particles_Blend-in.txt @@ -0,0 +1,44 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct v2f { + vec4 vertex; + vec4 color; + vec2 texcoord; +}; +struct appdata_t { + vec4 vertex; + vec4 color; + vec2 texcoord; +}; +uniform vec4 _MainTex_ST; + +v2f vert( in appdata_t v ); +v2f vert( in appdata_t v ) { + v2f o; + o.vertex = ( gl_ModelViewProjectionMatrix * v.vertex ); + o.color = v.color; + o.texcoord = ((v.texcoord.xy * _MainTex_ST.xy ) + _MainTex_ST.zw ); + return o; +} +void main() { + v2f xl_retval; + appdata_t xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.color = vec4( gl_Color); + xlt_v.texcoord = vec2( gl_MultiTexCoord0); + xl_retval = vert( xlt_v); + gl_Position = vec4( xl_retval.vertex); + gl_FrontColor = vec4( xl_retval.color); + gl_TexCoord[0] = vec4( xl_retval.texcoord, 0.0, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Particles_Blend-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Particles_Blend-ir.txt new file mode 100644 index 000000000..fc8d292b8 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Particles_Blend-ir.txt @@ -0,0 +1,70 @@ +struct v2f { + vec4 vertex; + vec4 color; + vec2 texcoord; +}; +struct appdata_t { + vec4 vertex; + vec4 color; + vec2 texcoord; +}; +uniform vec4 _MainTex_ST; +v2f vert ( + in appdata_t v +) +{ + v2f o; + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v.vertex); + o.vertex = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = v.color; + o.color = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + o.texcoord = tmpvar_3; + return o; +} + +void main () +{ + appdata_t xlt_v; + v2f xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = gl_Color.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.color = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5 = gl_MultiTexCoord0.xy; + vec2 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.texcoord = tmpvar_6; + v2f tmpvar_7; + tmpvar_7 = vert (xlt_v); + v2f tmpvar_8; + tmpvar_8 = tmpvar_7; + xl_retval = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = xl_retval.vertex.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + gl_Position = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = xl_retval.color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + gl_FrontColor = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13.zw = vec2(0.0, 0.0); + tmpvar_13.xy = xl_retval.texcoord.xy; + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + gl_TexCoord[0] = tmpvar_14; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Particles_Blend-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Particles_Blend-out.txt new file mode 100644 index 000000000..ebe65af65 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Particles_Blend-out.txt @@ -0,0 +1,11 @@ +uniform vec4 _MainTex_ST; +void main () +{ + gl_Position = (gl_ModelViewProjectionMatrix * gl_Vertex); + gl_FrontColor = gl_Color; + vec4 tmpvar_1; + tmpvar_1.zw = vec2(0.0, 0.0); + tmpvar_1.xy = ((gl_MultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + gl_TexCoord[0] = tmpvar_1; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Bumped_Diffuse-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Bumped_Diffuse-in.txt new file mode 100644 index 000000000..fd9ecafc6 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Bumped_Diffuse-in.txt @@ -0,0 +1,91 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; + vec3 worldRefl; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 lightDir; + vec2 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _BumpMap_ST; +uniform mat4 _LightMatrix0; +uniform vec4 _MainTex_ST; +uniform mat4 _Object2World; +uniform mat4 _World2Object; +uniform vec4 _WorldSpaceLightPos0; + +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +vec3 ObjSpaceLightDir( in vec4 v ); +v2f_surf vert_surf( in appdata_full v ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +vec3 ObjSpaceLightDir( in vec4 v ) { + vec3 objSpaceLightPos; + objSpaceLightPos = ( _World2Object * _WorldSpaceLightPos0 ).xyz ; + return objSpaceLightPos.xyz ; +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + vec3 binormal; + mat3 rotation; + PositionFog( v.vertex, o.pos, o.fog); + o.hip_pack0.xy = ((v.texcoord.xy * _MainTex_ST.xy ) + _MainTex_ST.zw ); + o.hip_pack0.zw = ((v.texcoord.xy * _BumpMap_ST.xy ) + _BumpMap_ST.zw ); + binormal = (cross( v.normal, v.tangent.xyz ) * v.tangent.w ); + rotation = mat3( v.tangent.x , binormal.x , v.normal.x , v.tangent.y , binormal.y , v.normal.y , v.tangent.z , binormal.z , v.normal.z ); + o.lightDir = ( rotation * ObjSpaceLightDir( v.vertex) ); + o._LightCoord = ( _LightMatrix0 * ( _Object2World * v.vertex ) ).xy ; + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.hip_pack0); + gl_TexCoord[1] = vec4( xl_retval.lightDir, 0.0); + gl_TexCoord[2] = vec4( xl_retval._LightCoord, 0.0, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Bumped_Diffuse-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Bumped_Diffuse-ir.txt new file mode 100644 index 000000000..9f3548686 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Bumped_Diffuse-ir.txt @@ -0,0 +1,178 @@ +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 lightDir; + vec2 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 _WorldSpaceLightPos0; +uniform mat4 _World2Object; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform mat4 _LightMatrix0; +uniform vec4 _BumpMap_ST; +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +vec3 ObjSpaceLightDir ( + in vec4 v +) +{ + vec3 objSpaceLightPos; + vec3 tmpvar_1; + tmpvar_1 = (_World2Object * _WorldSpaceLightPos0).xyz; + objSpaceLightPos = tmpvar_1; + return objSpaceLightPos.xyz; +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + mat3 rotation; + vec3 binormal; + v2f_surf o; + PositionFog (v.vertex, o.pos, o.fog); + vec2 tmpvar_1; + tmpvar_1 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + o.hip_pack0.xy = tmpvar_1.xy.xy; + vec2 tmpvar_2; + tmpvar_2 = ((v.texcoord.xy * _BumpMap_ST.xy) + _BumpMap_ST.zw); + o.hip_pack0.zw = tmpvar_2.xxxy.zw; + vec3 tmpvar_3; + tmpvar_3 = cross (v.normal, v.tangent.xyz); + vec3 tmpvar_4; + tmpvar_4 = (tmpvar_3 * v.tangent.w); + binormal = tmpvar_4; + mat3 tmpvar_5; + float tmpvar_6; + tmpvar_6 = v.tangent.x; + tmpvar_5[0].x = tmpvar_6; + float tmpvar_7; + tmpvar_7 = binormal.x; + tmpvar_5[0].y = tmpvar_7; + float tmpvar_8; + tmpvar_8 = v.normal.x; + tmpvar_5[0].z = tmpvar_8; + float tmpvar_9; + tmpvar_9 = v.tangent.y; + tmpvar_5[1].x = tmpvar_9; + float tmpvar_10; + tmpvar_10 = binormal.y; + tmpvar_5[1].y = tmpvar_10; + float tmpvar_11; + tmpvar_11 = v.normal.y; + tmpvar_5[1].z = tmpvar_11; + float tmpvar_12; + tmpvar_12 = v.tangent.z; + tmpvar_5[2].x = tmpvar_12; + float tmpvar_13; + tmpvar_13 = binormal.z; + tmpvar_5[2].y = tmpvar_13; + float tmpvar_14; + tmpvar_14 = v.normal.z; + tmpvar_5[2].z = tmpvar_14; + mat3 tmpvar_15; + tmpvar_15 = (tmpvar_5); + rotation = (tmpvar_15); + vec3 tmpvar_16; + tmpvar_16 = ObjSpaceLightDir (v.vertex); + vec3 tmpvar_17; + tmpvar_17 = (rotation * tmpvar_16); + o.lightDir = tmpvar_17; + vec2 tmpvar_18; + tmpvar_18 = (_LightMatrix0 * (_Object2World * v.vertex)).xy; + o._LightCoord = tmpvar_18; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = xl_retval.fog; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_FOG = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19 = xl_retval.hip_pack0.xyzw; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[0] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21.w = 0.0; + tmpvar_21.xyz = xl_retval.lightDir.xyz; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_TexCoord[1] = tmpvar_22; + vec4 tmpvar_23; + tmpvar_23.zw = vec2(0.0, 0.0); + tmpvar_23.xy = xl_retval._LightCoord.xy; + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + gl_TexCoord[2] = tmpvar_24; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Bumped_Diffuse-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Bumped_Diffuse-out.txt new file mode 100644 index 000000000..ee11d4d75 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Bumped_Diffuse-out.txt @@ -0,0 +1,43 @@ +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 _WorldSpaceLightPos0; +uniform mat4 _World2Object; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform mat4 _LightMatrix0; +uniform vec4 _BumpMap_ST; +void main () +{ + vec4 tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = (gl_ModelViewProjectionMatrix * gl_Vertex); + tmpvar_1.xy = ((gl_MultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + tmpvar_1.zw = ((gl_MultiTexCoord0.xy * _BumpMap_ST.xy) + _BumpMap_ST.zw); + vec3 tmpvar_3; + tmpvar_3 = (cross (gl_Normal, TANGENT.xyz) * TANGENT.w); + mat3 tmpvar_4; + tmpvar_4[0].x = TANGENT.x; + tmpvar_4[0].y = tmpvar_3.x; + tmpvar_4[0].z = gl_Normal.x; + tmpvar_4[1].x = TANGENT.y; + tmpvar_4[1].y = tmpvar_3.y; + tmpvar_4[1].z = gl_Normal.y; + tmpvar_4[2].x = TANGENT.z; + tmpvar_4[2].y = tmpvar_3.z; + tmpvar_4[2].z = gl_Normal.z; + gl_Position = tmpvar_2; + vec4 tmpvar_5; + tmpvar_5.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_5.x = tmpvar_2.z; + xlv_FOG = tmpvar_5; + gl_TexCoord[0] = tmpvar_1; + vec4 tmpvar_6; + tmpvar_6.w = 0.0; + tmpvar_6.xyz = (tmpvar_4 * (_World2Object * _WorldSpaceLightPos0).xyz); + gl_TexCoord[1] = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7.zw = vec2(0.0, 0.0); + tmpvar_7.xy = (_LightMatrix0 * (_Object2World * gl_Vertex)).xy; + gl_TexCoord[2] = tmpvar_7; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Bumped_Diffuse1-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Bumped_Diffuse1-in.txt new file mode 100644 index 000000000..6c2f7d2ed --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Bumped_Diffuse1-in.txt @@ -0,0 +1,123 @@ +mat3 xll_constructMat3( mat4 m) { + return mat3( vec3( m[0]), vec3( m[1]), vec3( m[2])); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; + vec3 worldRefl; + vec3 TtoW0; + vec3 TtoW1; + vec3 TtoW2; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec4 hip_screen; + vec4 TtoW0; + vec4 TtoW1; + vec4 TtoW2; + vec3 hip_lmapFade; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _BumpMap_ST; +uniform vec4 _MainTex_ST; +uniform mat4 _Object2World; +uniform vec4 _ProjectionParams; +uniform mat4 _World2Object; +uniform vec3 _WorldSpaceCameraPos; + + +uniform vec4 unity_LightmapFade; +uniform vec4 unity_LightmapST; +uniform vec4 unity_Scale; +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +vec3 ObjSpaceViewDir( in vec4 v ); +vec4 ComputeScreenPos( in vec4 pos ); +v2f_surf vert_surf( in appdata_full v ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +vec3 ObjSpaceViewDir( in vec4 v ) { + vec3 objSpaceCameraPos; + objSpaceCameraPos = (( _World2Object * vec4( _WorldSpaceCameraPos.xyz , 1.00000) ).xyz * unity_Scale.w ); + return (objSpaceCameraPos - v.xyz ); +} +vec4 ComputeScreenPos( in vec4 pos ) { + vec4 o; + o = (pos * 0.500000); + o.xy = (vec2( o.x , (o.y * _ProjectionParams.x )) + o.w ); + o.zw = pos.zw ; + return o; +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + vec3 viewDir; + vec3 worldRefl; + vec3 binormal; + mat3 rotation; + PositionFog( v.vertex, o.pos, o.fog); + o.hip_pack0.xy = ((v.texcoord.xy * _MainTex_ST.xy ) + _MainTex_ST.zw ); + o.hip_pack0.zw = ((v.texcoord.xy * _BumpMap_ST.xy ) + _BumpMap_ST.zw ); + viewDir = ( -ObjSpaceViewDir( v.vertex) ); + worldRefl = ( xll_constructMat3( _Object2World) * viewDir ); + binormal = (cross( v.normal, v.tangent.xyz ) * v.tangent.w ); + rotation = mat3( v.tangent.x , binormal.x , v.normal.x , v.tangent.y , binormal.y , v.normal.y , v.tangent.z , binormal.z , v.normal.z ); + o.TtoW0 = (vec4( ( rotation * _Object2World[ 0 ].xyz ), worldRefl.x ) * unity_Scale.w ); + o.TtoW1 = (vec4( ( rotation * _Object2World[ 1 ].xyz ), worldRefl.y ) * unity_Scale.w ); + o.TtoW2 = (vec4( ( rotation * _Object2World[ 2 ].xyz ), worldRefl.z ) * unity_Scale.w ); + o.hip_screen = ComputeScreenPos( o.pos); + o.hip_lmapFade.xy = ((v.texcoord1.xy * unity_LightmapST.xy ) + unity_LightmapST.zw ); + o.hip_lmapFade.z = ((( -( gl_ModelViewMatrix * v.vertex ).z ) * unity_LightmapFade.z ) + unity_LightmapFade.w ); + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.hip_pack0); + gl_TexCoord[1] = vec4( xl_retval.hip_screen); + gl_TexCoord[2] = vec4( xl_retval.TtoW0); + gl_TexCoord[3] = vec4( xl_retval.TtoW1); + gl_TexCoord[4] = vec4( xl_retval.TtoW2); + gl_TexCoord[5] = vec4( xl_retval.hip_lmapFade, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Bumped_Diffuse1-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Bumped_Diffuse1-ir.txt new file mode 100644 index 000000000..cb2ed4d2d --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Bumped_Diffuse1-ir.txt @@ -0,0 +1,277 @@ +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec4 hip_screen; + vec4 TtoW0; + vec4 TtoW1; + vec4 TtoW2; + vec3 hip_lmapFade; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec4 unity_LightmapST; +uniform vec4 unity_LightmapFade; +uniform vec3 _WorldSpaceCameraPos; +uniform mat4 _World2Object; +uniform vec4 _ProjectionParams; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform vec4 _BumpMap_ST; +mat3 xll_constructMat3 ( + in mat4 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = m[0].xyz; + vec3 tmpvar_2; + tmpvar_2 = m[1].xyz; + vec3 tmpvar_3; + tmpvar_3 = m[2].xyz; + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +vec3 ObjSpaceViewDir ( + in vec4 v +) +{ + vec3 objSpaceCameraPos; + vec4 tmpvar_1; + tmpvar_1.w = 1.0; + tmpvar_1.xyz = _WorldSpaceCameraPos.xyz.xyz; + vec3 tmpvar_2; + tmpvar_2 = ((_World2Object * tmpvar_1).xyz * unity_Scale.w); + objSpaceCameraPos = tmpvar_2; + return (objSpaceCameraPos - v.xyz); +} + +vec4 ComputeScreenPos ( + in vec4 pos +) +{ + vec4 o; + vec4 tmpvar_1; + tmpvar_1 = (pos * 0.5); + o = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2.x = o.x; + tmpvar_2.y = (o.y * _ProjectionParams.x); + vec2 tmpvar_3; + tmpvar_3 = (tmpvar_2 + o.w); + o.xy = tmpvar_3.xy.xy; + vec2 tmpvar_4; + tmpvar_4 = pos.zw; + o.zw = tmpvar_4.xxxy.zw; + return o; +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + mat3 rotation; + vec3 binormal; + vec3 worldRefl; + vec3 viewDir; + v2f_surf o; + PositionFog (v.vertex, o.pos, o.fog); + vec2 tmpvar_1; + tmpvar_1 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + o.hip_pack0.xy = tmpvar_1.xy.xy; + vec2 tmpvar_2; + tmpvar_2 = ((v.texcoord.xy * _BumpMap_ST.xy) + _BumpMap_ST.zw); + o.hip_pack0.zw = tmpvar_2.xxxy.zw; + vec3 tmpvar_3; + tmpvar_3 = ObjSpaceViewDir (v.vertex); + vec3 tmpvar_4; + tmpvar_4 = -(tmpvar_3); + viewDir = tmpvar_4; + mat3 tmpvar_5; + tmpvar_5 = (xll_constructMat3 (_Object2World)); + vec3 tmpvar_6; + tmpvar_6 = (tmpvar_5 * viewDir); + worldRefl = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = cross (v.normal, v.tangent.xyz); + vec3 tmpvar_8; + tmpvar_8 = (tmpvar_7 * v.tangent.w); + binormal = tmpvar_8; + mat3 tmpvar_9; + float tmpvar_10; + tmpvar_10 = v.tangent.x; + tmpvar_9[0].x = tmpvar_10; + float tmpvar_11; + tmpvar_11 = binormal.x; + tmpvar_9[0].y = tmpvar_11; + float tmpvar_12; + tmpvar_12 = v.normal.x; + tmpvar_9[0].z = tmpvar_12; + float tmpvar_13; + tmpvar_13 = v.tangent.y; + tmpvar_9[1].x = tmpvar_13; + float tmpvar_14; + tmpvar_14 = binormal.y; + tmpvar_9[1].y = tmpvar_14; + float tmpvar_15; + tmpvar_15 = v.normal.y; + tmpvar_9[1].z = tmpvar_15; + float tmpvar_16; + tmpvar_16 = v.tangent.z; + tmpvar_9[2].x = tmpvar_16; + float tmpvar_17; + tmpvar_17 = binormal.z; + tmpvar_9[2].y = tmpvar_17; + float tmpvar_18; + tmpvar_18 = v.normal.z; + tmpvar_9[2].z = tmpvar_18; + mat3 tmpvar_19; + tmpvar_19 = (tmpvar_9); + rotation = (tmpvar_19); + vec4 tmpvar_20; + tmpvar_20.xyz = (rotation * _Object2World[0].xyz).xyz; + tmpvar_20.w = worldRefl.x; + vec4 tmpvar_21; + tmpvar_21 = (tmpvar_20 * unity_Scale.w); + o.TtoW0 = tmpvar_21; + vec4 tmpvar_22; + tmpvar_22.xyz = (rotation * _Object2World[1].xyz).xyz; + tmpvar_22.w = worldRefl.y; + vec4 tmpvar_23; + tmpvar_23 = (tmpvar_22 * unity_Scale.w); + o.TtoW1 = tmpvar_23; + vec4 tmpvar_24; + tmpvar_24.xyz = (rotation * _Object2World[2].xyz).xyz; + tmpvar_24.w = worldRefl.z; + vec4 tmpvar_25; + tmpvar_25 = (tmpvar_24 * unity_Scale.w); + o.TtoW2 = tmpvar_25; + vec4 tmpvar_26; + tmpvar_26 = ComputeScreenPos (o.pos); + vec4 tmpvar_27; + tmpvar_27 = tmpvar_26; + o.hip_screen = tmpvar_27; + vec2 tmpvar_28; + tmpvar_28 = ((v.texcoord1.xy * unity_LightmapST.xy) + unity_LightmapST.zw); + o.hip_lmapFade.xy = tmpvar_28.xy.xy; + float tmpvar_29; + tmpvar_29 = ((-((gl_ModelViewMatrix * v.vertex).z) * unity_LightmapFade.z) + unity_LightmapFade.w); + o.hip_lmapFade.z = vec3(tmpvar_29).z; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = xl_retval.fog; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_FOG = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19 = xl_retval.hip_pack0.xyzw; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[0] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21 = xl_retval.hip_screen.xyzw; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_TexCoord[1] = tmpvar_22; + vec4 tmpvar_23; + tmpvar_23 = xl_retval.TtoW0.xyzw; + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + gl_TexCoord[2] = tmpvar_24; + vec4 tmpvar_25; + tmpvar_25 = xl_retval.TtoW1.xyzw; + vec4 tmpvar_26; + tmpvar_26 = tmpvar_25; + gl_TexCoord[3] = tmpvar_26; + vec4 tmpvar_27; + tmpvar_27 = xl_retval.TtoW2.xyzw; + vec4 tmpvar_28; + tmpvar_28 = tmpvar_27; + gl_TexCoord[4] = tmpvar_28; + vec4 tmpvar_29; + tmpvar_29.w = 0.0; + tmpvar_29.xyz = xl_retval.hip_lmapFade.xyz; + vec4 tmpvar_30; + tmpvar_30 = tmpvar_29; + gl_TexCoord[5] = tmpvar_30; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Bumped_Diffuse1-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Bumped_Diffuse1-out.txt new file mode 100644 index 000000000..06434a482 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Bumped_Diffuse1-out.txt @@ -0,0 +1,76 @@ +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec4 unity_LightmapST; +uniform vec4 unity_LightmapFade; +uniform vec3 _WorldSpaceCameraPos; +uniform mat4 _World2Object; +uniform vec4 _ProjectionParams; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform vec4 _BumpMap_ST; +void main () +{ + vec4 tmpvar_1; + vec3 tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = (gl_ModelViewProjectionMatrix * gl_Vertex); + tmpvar_1.xy = ((gl_MultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + tmpvar_1.zw = ((gl_MultiTexCoord0.xy * _BumpMap_ST.xy) + _BumpMap_ST.zw); + vec4 tmpvar_4; + tmpvar_4.w = 1.0; + tmpvar_4.xyz = _WorldSpaceCameraPos; + mat3 tmpvar_5; + tmpvar_5[0] = _Object2World[0].xyz; + tmpvar_5[1] = _Object2World[1].xyz; + tmpvar_5[2] = _Object2World[2].xyz; + vec3 tmpvar_6; + tmpvar_6 = (tmpvar_5 * (gl_Vertex.xyz - ((_World2Object * tmpvar_4).xyz * unity_Scale.w))); + vec3 tmpvar_7; + tmpvar_7 = (cross (gl_Normal, TANGENT.xyz) * TANGENT.w); + mat3 tmpvar_8; + tmpvar_8[0].x = TANGENT.x; + tmpvar_8[0].y = tmpvar_7.x; + tmpvar_8[0].z = gl_Normal.x; + tmpvar_8[1].x = TANGENT.y; + tmpvar_8[1].y = tmpvar_7.y; + tmpvar_8[1].z = gl_Normal.y; + tmpvar_8[2].x = TANGENT.z; + tmpvar_8[2].y = tmpvar_7.z; + tmpvar_8[2].z = gl_Normal.z; + vec4 tmpvar_9; + tmpvar_9.xyz = (tmpvar_8 * _Object2World[0].xyz); + tmpvar_9.w = tmpvar_6.x; + vec4 tmpvar_10; + tmpvar_10.xyz = (tmpvar_8 * _Object2World[1].xyz); + tmpvar_10.w = tmpvar_6.y; + vec4 tmpvar_11; + tmpvar_11.xyz = (tmpvar_8 * _Object2World[2].xyz); + tmpvar_11.w = tmpvar_6.z; + vec4 o_i0; + vec4 tmpvar_12; + tmpvar_12 = (tmpvar_3 * 0.5); + o_i0 = tmpvar_12; + vec2 tmpvar_13; + tmpvar_13.x = tmpvar_12.x; + tmpvar_13.y = (tmpvar_12.y * _ProjectionParams.x); + o_i0.xy = (tmpvar_13 + tmpvar_12.w); + o_i0.zw = tmpvar_3.zw; + tmpvar_2.xy = ((gl_MultiTexCoord1.xy * unity_LightmapST.xy) + unity_LightmapST.zw); + tmpvar_2.z = ((-((gl_ModelViewMatrix * gl_Vertex).z) * unity_LightmapFade.z) + unity_LightmapFade.w); + gl_Position = tmpvar_3; + vec4 tmpvar_14; + tmpvar_14.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_14.x = tmpvar_3.z; + xlv_FOG = tmpvar_14; + gl_TexCoord[0] = tmpvar_1; + gl_TexCoord[1] = o_i0; + gl_TexCoord[2] = (tmpvar_9 * unity_Scale.w); + gl_TexCoord[3] = (tmpvar_10 * unity_Scale.w); + gl_TexCoord[4] = (tmpvar_11 * unity_Scale.w); + vec4 tmpvar_15; + tmpvar_15.w = 0.0; + tmpvar_15.xyz = tmpvar_2; + gl_TexCoord[5] = tmpvar_15; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Bumped_Specular-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Bumped_Specular-in.txt new file mode 100644 index 000000000..4088c79eb --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Bumped_Specular-in.txt @@ -0,0 +1,102 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; + vec3 worldRefl; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 lightDir; + vec3 viewDir; + vec3 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _BumpMap_ST; +uniform mat4 _LightMatrix0; +uniform vec4 _MainTex_ST; +uniform mat4 _Object2World; +uniform mat4 _World2Object; +uniform vec3 _WorldSpaceCameraPos; +uniform vec4 _WorldSpaceLightPos0; + +uniform vec4 unity_Scale; +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +vec3 ObjSpaceViewDir( in vec4 v ); +vec3 ObjSpaceLightDir( in vec4 v ); +v2f_surf vert_surf( in appdata_full v ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +vec3 ObjSpaceViewDir( in vec4 v ) { + vec3 objSpaceCameraPos; + objSpaceCameraPos = (( _World2Object * vec4( _WorldSpaceCameraPos.xyz , 1.00000) ).xyz * unity_Scale.w ); + return (objSpaceCameraPos - v.xyz ); +} +vec3 ObjSpaceLightDir( in vec4 v ) { + vec3 objSpaceLightPos; + objSpaceLightPos = ( _World2Object * _WorldSpaceLightPos0 ).xyz ; + return ((objSpaceLightPos.xyz * unity_Scale.w ) - v.xyz ); +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + vec3 binormal; + mat3 rotation; + PositionFog( v.vertex, o.pos, o.fog); + o.hip_pack0.xy = ((v.texcoord.xy * _MainTex_ST.xy ) + _MainTex_ST.zw ); + o.hip_pack0.zw = ((v.texcoord.xy * _BumpMap_ST.xy ) + _BumpMap_ST.zw ); + binormal = (cross( v.normal, v.tangent.xyz ) * v.tangent.w ); + rotation = mat3( v.tangent.x , binormal.x , v.normal.x , v.tangent.y , binormal.y , v.normal.y , v.tangent.z , binormal.z , v.normal.z ); + o.lightDir = ( rotation * ObjSpaceLightDir( v.vertex) ); + o.viewDir = ( rotation * ObjSpaceViewDir( v.vertex) ); + o._LightCoord = ( _LightMatrix0 * ( _Object2World * v.vertex ) ).xyz ; + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.hip_pack0); + gl_TexCoord[1] = vec4( xl_retval.lightDir, 0.0); + gl_TexCoord[2] = vec4( xl_retval.viewDir, 0.0); + gl_TexCoord[3] = vec4( xl_retval._LightCoord, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Bumped_Specular-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Bumped_Specular-ir.txt new file mode 100644 index 000000000..87f27d197 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Bumped_Specular-ir.txt @@ -0,0 +1,206 @@ +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 lightDir; + vec3 viewDir; + vec3 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform vec3 _WorldSpaceCameraPos; +uniform mat4 _World2Object; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform mat4 _LightMatrix0; +uniform vec4 _BumpMap_ST; +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +vec3 ObjSpaceViewDir ( + in vec4 v +) +{ + vec3 objSpaceCameraPos; + vec4 tmpvar_1; + tmpvar_1.w = 1.0; + tmpvar_1.xyz = _WorldSpaceCameraPos.xyz.xyz; + vec3 tmpvar_2; + tmpvar_2 = ((_World2Object * tmpvar_1).xyz * unity_Scale.w); + objSpaceCameraPos = tmpvar_2; + return (objSpaceCameraPos - v.xyz); +} + +vec3 ObjSpaceLightDir ( + in vec4 v +) +{ + vec3 objSpaceLightPos; + vec3 tmpvar_1; + tmpvar_1 = (_World2Object * _WorldSpaceLightPos0).xyz; + objSpaceLightPos = tmpvar_1; + return ((objSpaceLightPos.xyz * unity_Scale.w) - v.xyz); +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + mat3 rotation; + vec3 binormal; + v2f_surf o; + PositionFog (v.vertex, o.pos, o.fog); + vec2 tmpvar_1; + tmpvar_1 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + o.hip_pack0.xy = tmpvar_1.xy.xy; + vec2 tmpvar_2; + tmpvar_2 = ((v.texcoord.xy * _BumpMap_ST.xy) + _BumpMap_ST.zw); + o.hip_pack0.zw = tmpvar_2.xxxy.zw; + vec3 tmpvar_3; + tmpvar_3 = cross (v.normal, v.tangent.xyz); + vec3 tmpvar_4; + tmpvar_4 = (tmpvar_3 * v.tangent.w); + binormal = tmpvar_4; + mat3 tmpvar_5; + float tmpvar_6; + tmpvar_6 = v.tangent.x; + tmpvar_5[0].x = tmpvar_6; + float tmpvar_7; + tmpvar_7 = binormal.x; + tmpvar_5[0].y = tmpvar_7; + float tmpvar_8; + tmpvar_8 = v.normal.x; + tmpvar_5[0].z = tmpvar_8; + float tmpvar_9; + tmpvar_9 = v.tangent.y; + tmpvar_5[1].x = tmpvar_9; + float tmpvar_10; + tmpvar_10 = binormal.y; + tmpvar_5[1].y = tmpvar_10; + float tmpvar_11; + tmpvar_11 = v.normal.y; + tmpvar_5[1].z = tmpvar_11; + float tmpvar_12; + tmpvar_12 = v.tangent.z; + tmpvar_5[2].x = tmpvar_12; + float tmpvar_13; + tmpvar_13 = binormal.z; + tmpvar_5[2].y = tmpvar_13; + float tmpvar_14; + tmpvar_14 = v.normal.z; + tmpvar_5[2].z = tmpvar_14; + mat3 tmpvar_15; + tmpvar_15 = (tmpvar_5); + rotation = (tmpvar_15); + vec3 tmpvar_16; + tmpvar_16 = ObjSpaceLightDir (v.vertex); + vec3 tmpvar_17; + tmpvar_17 = (rotation * tmpvar_16); + o.lightDir = tmpvar_17; + vec3 tmpvar_18; + tmpvar_18 = ObjSpaceViewDir (v.vertex); + vec3 tmpvar_19; + tmpvar_19 = (rotation * tmpvar_18); + o.viewDir = tmpvar_19; + vec3 tmpvar_20; + tmpvar_20 = (_LightMatrix0 * (_Object2World * v.vertex)).xyz; + o._LightCoord = tmpvar_20; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = xl_retval.fog; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_FOG = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19 = xl_retval.hip_pack0.xyzw; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[0] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21.w = 0.0; + tmpvar_21.xyz = xl_retval.lightDir.xyz; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_TexCoord[1] = tmpvar_22; + vec4 tmpvar_23; + tmpvar_23.w = 0.0; + tmpvar_23.xyz = xl_retval.viewDir.xyz; + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + gl_TexCoord[2] = tmpvar_24; + vec4 tmpvar_25; + tmpvar_25.w = 0.0; + tmpvar_25.xyz = xl_retval._LightCoord.xyz; + vec4 tmpvar_26; + tmpvar_26 = tmpvar_25; + gl_TexCoord[3] = tmpvar_26; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Bumped_Specular-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Bumped_Specular-out.txt new file mode 100644 index 000000000..3dc712ebe --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Bumped_Specular-out.txt @@ -0,0 +1,52 @@ +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform vec3 _WorldSpaceCameraPos; +uniform mat4 _World2Object; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform mat4 _LightMatrix0; +uniform vec4 _BumpMap_ST; +void main () +{ + vec4 tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = (gl_ModelViewProjectionMatrix * gl_Vertex); + tmpvar_1.xy = ((gl_MultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + tmpvar_1.zw = ((gl_MultiTexCoord0.xy * _BumpMap_ST.xy) + _BumpMap_ST.zw); + vec3 tmpvar_3; + tmpvar_3 = (cross (gl_Normal, TANGENT.xyz) * TANGENT.w); + mat3 tmpvar_4; + tmpvar_4[0].x = TANGENT.x; + tmpvar_4[0].y = tmpvar_3.x; + tmpvar_4[0].z = gl_Normal.x; + tmpvar_4[1].x = TANGENT.y; + tmpvar_4[1].y = tmpvar_3.y; + tmpvar_4[1].z = gl_Normal.y; + tmpvar_4[2].x = TANGENT.z; + tmpvar_4[2].y = tmpvar_3.z; + tmpvar_4[2].z = gl_Normal.z; + vec4 tmpvar_5; + tmpvar_5.w = 1.0; + tmpvar_5.xyz = _WorldSpaceCameraPos; + gl_Position = tmpvar_2; + vec4 tmpvar_6; + tmpvar_6.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_6.x = tmpvar_2.z; + xlv_FOG = tmpvar_6; + gl_TexCoord[0] = tmpvar_1; + vec4 tmpvar_7; + tmpvar_7.w = 0.0; + tmpvar_7.xyz = (tmpvar_4 * (((_World2Object * _WorldSpaceLightPos0).xyz * unity_Scale.w) - gl_Vertex.xyz)); + gl_TexCoord[1] = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8.w = 0.0; + tmpvar_8.xyz = (tmpvar_4 * (((_World2Object * tmpvar_5).xyz * unity_Scale.w) - gl_Vertex.xyz)); + gl_TexCoord[2] = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9.w = 0.0; + tmpvar_9.xyz = (_LightMatrix0 * (_Object2World * gl_Vertex)).xyz; + gl_TexCoord[3] = tmpvar_9; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Bumped_Specular1-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Bumped_Specular1-in.txt new file mode 100644 index 000000000..3e3a20d48 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Bumped_Specular1-in.txt @@ -0,0 +1,78 @@ +mat3 xll_constructMat3( mat4 m) { + return mat3( vec3( m[0]), vec3( m[1]), vec3( m[2])); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; + vec3 worldRefl; +}; +struct v2f_surf { + vec4 pos; + vec2 hip_pack0; + vec3 TtoV0; + vec3 TtoV1; + vec3 TtoV2; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _BumpMap_ST; + + +v2f_surf vert_surf( in appdata_full v ); +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + vec3 binormal; + mat3 rotation; + o.pos = ( gl_ModelViewProjectionMatrix * v.vertex ); + o.hip_pack0.xy = ((v.texcoord.xy * _BumpMap_ST.xy ) + _BumpMap_ST.zw ); + binormal = (cross( v.normal, v.tangent.xyz ) * v.tangent.w ); + rotation = mat3( v.tangent.x , binormal.x , v.normal.x , v.tangent.y , binormal.y , v.normal.y , v.tangent.z , binormal.z , v.normal.z ); + o.TtoV0 = ( rotation * xll_constructMat3( gl_ModelViewMatrixInverseTranspose)[ 0 ].xyz ); + o.TtoV1 = ( rotation * xll_constructMat3( gl_ModelViewMatrixInverseTranspose)[ 1 ].xyz ); + o.TtoV2 = ( rotation * xll_constructMat3( gl_ModelViewMatrixInverseTranspose)[ 2 ].xyz ); + return o; +} +attribute vec4 TANGENT; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + gl_TexCoord[0] = vec4( xl_retval.hip_pack0, 0.0, 0.0); + gl_TexCoord[1] = vec4( xl_retval.TtoV0, 0.0); + gl_TexCoord[2] = vec4( xl_retval.TtoV1, 0.0); + gl_TexCoord[3] = vec4( xl_retval.TtoV2, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Bumped_Specular1-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Bumped_Specular1-ir.txt new file mode 100644 index 000000000..ff62ea859 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Bumped_Specular1-ir.txt @@ -0,0 +1,177 @@ +struct v2f_surf { + vec4 pos; + vec2 hip_pack0; + vec3 TtoV0; + vec3 TtoV1; + vec3 TtoV2; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +attribute vec4 TANGENT; +uniform vec4 _BumpMap_ST; +mat3 xll_constructMat3 ( + in mat4 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = m[0].xyz; + vec3 tmpvar_2; + tmpvar_2 = m[1].xyz; + vec3 tmpvar_3; + tmpvar_3 = m[2].xyz; + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + mat3 rotation; + vec3 binormal; + v2f_surf o; + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v.vertex); + o.pos = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = ((v.texcoord.xy * _BumpMap_ST.xy) + _BumpMap_ST.zw); + o.hip_pack0 = tmpvar_2.xy.xy; + vec3 tmpvar_3; + tmpvar_3 = cross (v.normal, v.tangent.xyz); + vec3 tmpvar_4; + tmpvar_4 = (tmpvar_3 * v.tangent.w); + binormal = tmpvar_4; + mat3 tmpvar_5; + float tmpvar_6; + tmpvar_6 = v.tangent.x; + tmpvar_5[0].x = tmpvar_6; + float tmpvar_7; + tmpvar_7 = binormal.x; + tmpvar_5[0].y = tmpvar_7; + float tmpvar_8; + tmpvar_8 = v.normal.x; + tmpvar_5[0].z = tmpvar_8; + float tmpvar_9; + tmpvar_9 = v.tangent.y; + tmpvar_5[1].x = tmpvar_9; + float tmpvar_10; + tmpvar_10 = binormal.y; + tmpvar_5[1].y = tmpvar_10; + float tmpvar_11; + tmpvar_11 = v.normal.y; + tmpvar_5[1].z = tmpvar_11; + float tmpvar_12; + tmpvar_12 = v.tangent.z; + tmpvar_5[2].x = tmpvar_12; + float tmpvar_13; + tmpvar_13 = binormal.z; + tmpvar_5[2].y = tmpvar_13; + float tmpvar_14; + tmpvar_14 = v.normal.z; + tmpvar_5[2].z = tmpvar_14; + mat3 tmpvar_15; + tmpvar_15 = (tmpvar_5); + rotation = (tmpvar_15); + mat3 tmpvar_16; + tmpvar_16 = (xll_constructMat3 (gl_ModelViewMatrixInverseTranspose)); + vec3 tmpvar_17; + tmpvar_17 = (rotation * tmpvar_16[0].xyz); + o.TtoV0 = tmpvar_17; + mat3 tmpvar_18; + tmpvar_18 = (xll_constructMat3 (gl_ModelViewMatrixInverseTranspose)); + vec3 tmpvar_19; + tmpvar_19 = (rotation * tmpvar_18[1].xyz); + o.TtoV1 = tmpvar_19; + mat3 tmpvar_20; + tmpvar_20 = (xll_constructMat3 (gl_ModelViewMatrixInverseTranspose)); + vec3 tmpvar_21; + tmpvar_21 = (rotation * tmpvar_20[2].xyz); + o.TtoV2 = tmpvar_21; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.zw = vec2(0.0, 0.0); + tmpvar_17.xy = xl_retval.hip_pack0.xy; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + gl_TexCoord[0] = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19.w = 0.0; + tmpvar_19.xyz = xl_retval.TtoV0.xyz; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[1] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21.w = 0.0; + tmpvar_21.xyz = xl_retval.TtoV1.xyz; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_TexCoord[2] = tmpvar_22; + vec4 tmpvar_23; + tmpvar_23.w = 0.0; + tmpvar_23.xyz = xl_retval.TtoV2.xyz; + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + gl_TexCoord[3] = tmpvar_24; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Bumped_Specular1-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Bumped_Specular1-out.txt new file mode 100644 index 000000000..244b1b9f5 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Bumped_Specular1-out.txt @@ -0,0 +1,47 @@ +attribute vec4 TANGENT; +uniform vec4 _BumpMap_ST; +void main () +{ + vec3 tmpvar_1; + tmpvar_1 = (cross (gl_Normal, TANGENT.xyz) * TANGENT.w); + mat3 tmpvar_2; + tmpvar_2[0].x = TANGENT.x; + tmpvar_2[0].y = tmpvar_1.x; + tmpvar_2[0].z = gl_Normal.x; + tmpvar_2[1].x = TANGENT.y; + tmpvar_2[1].y = tmpvar_1.y; + tmpvar_2[1].z = gl_Normal.y; + tmpvar_2[2].x = TANGENT.z; + tmpvar_2[2].y = tmpvar_1.z; + tmpvar_2[2].z = gl_Normal.z; + mat3 tmpvar_3; + tmpvar_3[0] = gl_ModelViewMatrixInverseTranspose[0].xyz; + tmpvar_3[1] = gl_ModelViewMatrixInverseTranspose[1].xyz; + tmpvar_3[2] = gl_ModelViewMatrixInverseTranspose[2].xyz; + mat3 tmpvar_4; + tmpvar_4[0] = gl_ModelViewMatrixInverseTranspose[0].xyz; + tmpvar_4[1] = gl_ModelViewMatrixInverseTranspose[1].xyz; + tmpvar_4[2] = gl_ModelViewMatrixInverseTranspose[2].xyz; + mat3 tmpvar_5; + tmpvar_5[0] = gl_ModelViewMatrixInverseTranspose[0].xyz; + tmpvar_5[1] = gl_ModelViewMatrixInverseTranspose[1].xyz; + tmpvar_5[2] = gl_ModelViewMatrixInverseTranspose[2].xyz; + gl_Position = (gl_ModelViewProjectionMatrix * gl_Vertex); + vec4 tmpvar_6; + tmpvar_6.zw = vec2(0.0, 0.0); + tmpvar_6.xy = ((gl_MultiTexCoord0.xy * _BumpMap_ST.xy) + _BumpMap_ST.zw); + gl_TexCoord[0] = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7.w = 0.0; + tmpvar_7.xyz = (tmpvar_2 * tmpvar_3[0]); + gl_TexCoord[1] = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8.w = 0.0; + tmpvar_8.xyz = (tmpvar_2 * tmpvar_4[1]); + gl_TexCoord[2] = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9.w = 0.0; + tmpvar_9.xyz = (tmpvar_2 * tmpvar_5[2]); + gl_TexCoord[3] = tmpvar_9; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Bumped_Specular2-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Bumped_Specular2-in.txt new file mode 100644 index 000000000..90b27e693 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Bumped_Specular2-in.txt @@ -0,0 +1,116 @@ +mat3 xll_constructMat3( mat4 m) { + return mat3( vec3( m[0]), vec3( m[1]), vec3( m[2])); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; + vec3 worldRefl; + vec3 TtoW0; + vec3 TtoW1; + vec3 TtoW2; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec4 hip_screen; + vec4 TtoW0; + vec4 TtoW1; + vec4 TtoW2; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _BumpMap_ST; +uniform vec4 _MainTex_ST; +uniform mat4 _Object2World; +uniform vec4 _ProjectionParams; +uniform mat4 _World2Object; +uniform vec3 _WorldSpaceCameraPos; + +uniform vec4 unity_Scale; +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +vec3 ObjSpaceViewDir( in vec4 v ); +vec4 ComputeScreenPos( in vec4 pos ); +v2f_surf vert_surf( in appdata_full v ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +vec3 ObjSpaceViewDir( in vec4 v ) { + vec3 objSpaceCameraPos; + objSpaceCameraPos = (( _World2Object * vec4( _WorldSpaceCameraPos.xyz , 1.00000) ).xyz * unity_Scale.w ); + return (objSpaceCameraPos - v.xyz ); +} +vec4 ComputeScreenPos( in vec4 pos ) { + vec4 o; + o = (pos * 0.500000); + o.xy = (vec2( o.x , (o.y * _ProjectionParams.x )) + o.w ); + o.zw = pos.zw ; + return o; +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + vec3 viewDir; + vec3 worldRefl; + vec3 binormal; + mat3 rotation; + PositionFog( v.vertex, o.pos, o.fog); + o.hip_pack0.xy = ((v.texcoord.xy * _MainTex_ST.xy ) + _MainTex_ST.zw ); + o.hip_pack0.zw = ((v.texcoord.xy * _BumpMap_ST.xy ) + _BumpMap_ST.zw ); + viewDir = ( -ObjSpaceViewDir( v.vertex) ); + worldRefl = ( xll_constructMat3( _Object2World) * viewDir ); + binormal = (cross( v.normal, v.tangent.xyz ) * v.tangent.w ); + rotation = mat3( v.tangent.x , binormal.x , v.normal.x , v.tangent.y , binormal.y , v.normal.y , v.tangent.z , binormal.z , v.normal.z ); + o.TtoW0 = (vec4( ( rotation * _Object2World[ 0 ].xyz ), worldRefl.x ) * unity_Scale.w ); + o.TtoW1 = (vec4( ( rotation * _Object2World[ 1 ].xyz ), worldRefl.y ) * unity_Scale.w ); + o.TtoW2 = (vec4( ( rotation * _Object2World[ 2 ].xyz ), worldRefl.z ) * unity_Scale.w ); + o.hip_screen = ComputeScreenPos( o.pos); + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.hip_pack0); + gl_TexCoord[1] = vec4( xl_retval.hip_screen); + gl_TexCoord[2] = vec4( xl_retval.TtoW0); + gl_TexCoord[3] = vec4( xl_retval.TtoW1); + gl_TexCoord[4] = vec4( xl_retval.TtoW2); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Bumped_Specular2-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Bumped_Specular2-ir.txt new file mode 100644 index 000000000..0a00aaccd --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Bumped_Specular2-ir.txt @@ -0,0 +1,262 @@ +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec4 hip_screen; + vec4 TtoW0; + vec4 TtoW1; + vec4 TtoW2; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec3 _WorldSpaceCameraPos; +uniform mat4 _World2Object; +uniform vec4 _ProjectionParams; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform vec4 _BumpMap_ST; +mat3 xll_constructMat3 ( + in mat4 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = m[0].xyz; + vec3 tmpvar_2; + tmpvar_2 = m[1].xyz; + vec3 tmpvar_3; + tmpvar_3 = m[2].xyz; + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +vec3 ObjSpaceViewDir ( + in vec4 v +) +{ + vec3 objSpaceCameraPos; + vec4 tmpvar_1; + tmpvar_1.w = 1.0; + tmpvar_1.xyz = _WorldSpaceCameraPos.xyz.xyz; + vec3 tmpvar_2; + tmpvar_2 = ((_World2Object * tmpvar_1).xyz * unity_Scale.w); + objSpaceCameraPos = tmpvar_2; + return (objSpaceCameraPos - v.xyz); +} + +vec4 ComputeScreenPos ( + in vec4 pos +) +{ + vec4 o; + vec4 tmpvar_1; + tmpvar_1 = (pos * 0.5); + o = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2.x = o.x; + tmpvar_2.y = (o.y * _ProjectionParams.x); + vec2 tmpvar_3; + tmpvar_3 = (tmpvar_2 + o.w); + o.xy = tmpvar_3.xy.xy; + vec2 tmpvar_4; + tmpvar_4 = pos.zw; + o.zw = tmpvar_4.xxxy.zw; + return o; +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + mat3 rotation; + vec3 binormal; + vec3 worldRefl; + vec3 viewDir; + v2f_surf o; + PositionFog (v.vertex, o.pos, o.fog); + vec2 tmpvar_1; + tmpvar_1 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + o.hip_pack0.xy = tmpvar_1.xy.xy; + vec2 tmpvar_2; + tmpvar_2 = ((v.texcoord.xy * _BumpMap_ST.xy) + _BumpMap_ST.zw); + o.hip_pack0.zw = tmpvar_2.xxxy.zw; + vec3 tmpvar_3; + tmpvar_3 = ObjSpaceViewDir (v.vertex); + vec3 tmpvar_4; + tmpvar_4 = -(tmpvar_3); + viewDir = tmpvar_4; + mat3 tmpvar_5; + tmpvar_5 = (xll_constructMat3 (_Object2World)); + vec3 tmpvar_6; + tmpvar_6 = (tmpvar_5 * viewDir); + worldRefl = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = cross (v.normal, v.tangent.xyz); + vec3 tmpvar_8; + tmpvar_8 = (tmpvar_7 * v.tangent.w); + binormal = tmpvar_8; + mat3 tmpvar_9; + float tmpvar_10; + tmpvar_10 = v.tangent.x; + tmpvar_9[0].x = tmpvar_10; + float tmpvar_11; + tmpvar_11 = binormal.x; + tmpvar_9[0].y = tmpvar_11; + float tmpvar_12; + tmpvar_12 = v.normal.x; + tmpvar_9[0].z = tmpvar_12; + float tmpvar_13; + tmpvar_13 = v.tangent.y; + tmpvar_9[1].x = tmpvar_13; + float tmpvar_14; + tmpvar_14 = binormal.y; + tmpvar_9[1].y = tmpvar_14; + float tmpvar_15; + tmpvar_15 = v.normal.y; + tmpvar_9[1].z = tmpvar_15; + float tmpvar_16; + tmpvar_16 = v.tangent.z; + tmpvar_9[2].x = tmpvar_16; + float tmpvar_17; + tmpvar_17 = binormal.z; + tmpvar_9[2].y = tmpvar_17; + float tmpvar_18; + tmpvar_18 = v.normal.z; + tmpvar_9[2].z = tmpvar_18; + mat3 tmpvar_19; + tmpvar_19 = (tmpvar_9); + rotation = (tmpvar_19); + vec4 tmpvar_20; + tmpvar_20.xyz = (rotation * _Object2World[0].xyz).xyz; + tmpvar_20.w = worldRefl.x; + vec4 tmpvar_21; + tmpvar_21 = (tmpvar_20 * unity_Scale.w); + o.TtoW0 = tmpvar_21; + vec4 tmpvar_22; + tmpvar_22.xyz = (rotation * _Object2World[1].xyz).xyz; + tmpvar_22.w = worldRefl.y; + vec4 tmpvar_23; + tmpvar_23 = (tmpvar_22 * unity_Scale.w); + o.TtoW1 = tmpvar_23; + vec4 tmpvar_24; + tmpvar_24.xyz = (rotation * _Object2World[2].xyz).xyz; + tmpvar_24.w = worldRefl.z; + vec4 tmpvar_25; + tmpvar_25 = (tmpvar_24 * unity_Scale.w); + o.TtoW2 = tmpvar_25; + vec4 tmpvar_26; + tmpvar_26 = ComputeScreenPos (o.pos); + vec4 tmpvar_27; + tmpvar_27 = tmpvar_26; + o.hip_screen = tmpvar_27; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = xl_retval.fog; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_FOG = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19 = xl_retval.hip_pack0.xyzw; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[0] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21 = xl_retval.hip_screen.xyzw; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_TexCoord[1] = tmpvar_22; + vec4 tmpvar_23; + tmpvar_23 = xl_retval.TtoW0.xyzw; + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + gl_TexCoord[2] = tmpvar_24; + vec4 tmpvar_25; + tmpvar_25 = xl_retval.TtoW1.xyzw; + vec4 tmpvar_26; + tmpvar_26 = tmpvar_25; + gl_TexCoord[3] = tmpvar_26; + vec4 tmpvar_27; + tmpvar_27 = xl_retval.TtoW2.xyzw; + vec4 tmpvar_28; + tmpvar_28 = tmpvar_27; + gl_TexCoord[4] = tmpvar_28; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Bumped_Specular2-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Bumped_Specular2-out.txt new file mode 100644 index 000000000..22aeb24ee --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Bumped_Specular2-out.txt @@ -0,0 +1,67 @@ +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec3 _WorldSpaceCameraPos; +uniform mat4 _World2Object; +uniform vec4 _ProjectionParams; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform vec4 _BumpMap_ST; +void main () +{ + vec4 tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = (gl_ModelViewProjectionMatrix * gl_Vertex); + tmpvar_1.xy = ((gl_MultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + tmpvar_1.zw = ((gl_MultiTexCoord0.xy * _BumpMap_ST.xy) + _BumpMap_ST.zw); + vec4 tmpvar_3; + tmpvar_3.w = 1.0; + tmpvar_3.xyz = _WorldSpaceCameraPos; + mat3 tmpvar_4; + tmpvar_4[0] = _Object2World[0].xyz; + tmpvar_4[1] = _Object2World[1].xyz; + tmpvar_4[2] = _Object2World[2].xyz; + vec3 tmpvar_5; + tmpvar_5 = (tmpvar_4 * (gl_Vertex.xyz - ((_World2Object * tmpvar_3).xyz * unity_Scale.w))); + vec3 tmpvar_6; + tmpvar_6 = (cross (gl_Normal, TANGENT.xyz) * TANGENT.w); + mat3 tmpvar_7; + tmpvar_7[0].x = TANGENT.x; + tmpvar_7[0].y = tmpvar_6.x; + tmpvar_7[0].z = gl_Normal.x; + tmpvar_7[1].x = TANGENT.y; + tmpvar_7[1].y = tmpvar_6.y; + tmpvar_7[1].z = gl_Normal.y; + tmpvar_7[2].x = TANGENT.z; + tmpvar_7[2].y = tmpvar_6.z; + tmpvar_7[2].z = gl_Normal.z; + vec4 tmpvar_8; + tmpvar_8.xyz = (tmpvar_7 * _Object2World[0].xyz); + tmpvar_8.w = tmpvar_5.x; + vec4 tmpvar_9; + tmpvar_9.xyz = (tmpvar_7 * _Object2World[1].xyz); + tmpvar_9.w = tmpvar_5.y; + vec4 tmpvar_10; + tmpvar_10.xyz = (tmpvar_7 * _Object2World[2].xyz); + tmpvar_10.w = tmpvar_5.z; + vec4 o_i0; + vec4 tmpvar_11; + tmpvar_11 = (tmpvar_2 * 0.5); + o_i0 = tmpvar_11; + vec2 tmpvar_12; + tmpvar_12.x = tmpvar_11.x; + tmpvar_12.y = (tmpvar_11.y * _ProjectionParams.x); + o_i0.xy = (tmpvar_12 + tmpvar_11.w); + o_i0.zw = tmpvar_2.zw; + gl_Position = tmpvar_2; + vec4 tmpvar_13; + tmpvar_13.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_13.x = tmpvar_2.z; + xlv_FOG = tmpvar_13; + gl_TexCoord[0] = tmpvar_1; + gl_TexCoord[1] = o_i0; + gl_TexCoord[2] = (tmpvar_8 * unity_Scale.w); + gl_TexCoord[3] = (tmpvar_9 * unity_Scale.w); + gl_TexCoord[4] = (tmpvar_10 * unity_Scale.w); +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Bumped_Unlit-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Bumped_Unlit-in.txt new file mode 100644 index 000000000..f967a99dd --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Bumped_Unlit-in.txt @@ -0,0 +1,79 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct v2f { + vec4 pos; + float fog; + vec2 uv; + vec2 uv2; + vec3 I; + vec3 TtoW0; + vec3 TtoW1; + vec3 TtoW2; +}; +struct appdata_tan { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; +}; +uniform vec4 _BumpMap_ST; +uniform vec4 _MainTex_ST; +uniform mat4 _Object2World; +uniform vec3 _WorldSpaceCameraPos; + +uniform vec4 unity_Scale; +vec3 WorldSpaceViewDir( in vec4 v ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +v2f vert( in appdata_tan v ); +vec3 WorldSpaceViewDir( in vec4 v ) { + return (_WorldSpaceCameraPos.xyz - ( _Object2World * v ).xyz ); +} +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +v2f vert( in appdata_tan v ) { + v2f o; + vec3 binormal; + mat3 rotation; + PositionFog( v.vertex, o.pos, o.fog); + o.uv = ((v.texcoord.xy * _MainTex_ST.xy ) + _MainTex_ST.zw ); + o.uv2 = ((v.texcoord.xy * _BumpMap_ST.xy ) + _BumpMap_ST.zw ); + o.I = ( -WorldSpaceViewDir( v.vertex) ); + binormal = (cross( v.normal, v.tangent.xyz ) * v.tangent.w ); + rotation = mat3( v.tangent.x , binormal.x , v.normal.x , v.tangent.y , binormal.y , v.normal.y , v.tangent.z , binormal.z , v.normal.z ); + o.TtoW0 = ( rotation * (_Object2World[ 0 ].xyz * unity_Scale.w ) ); + o.TtoW1 = ( rotation * (_Object2World[ 1 ].xyz * unity_Scale.w ) ); + o.TtoW2 = ( rotation * (_Object2World[ 2 ].xyz * unity_Scale.w ) ); + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f xl_retval; + appdata_tan xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xl_retval = vert( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.uv, 0.0, 0.0); + gl_TexCoord[1] = vec4( xl_retval.uv2, 0.0, 0.0); + gl_TexCoord[2] = vec4( xl_retval.I, 0.0); + gl_TexCoord[3] = vec4( xl_retval.TtoW0, 0.0); + gl_TexCoord[4] = vec4( xl_retval.TtoW1, 0.0); + gl_TexCoord[5] = vec4( xl_retval.TtoW2, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Bumped_Unlit-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Bumped_Unlit-ir.txt new file mode 100644 index 000000000..2aa3e4cd8 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Bumped_Unlit-ir.txt @@ -0,0 +1,189 @@ +struct v2f { + vec4 pos; + float fog; + vec2 uv; + vec2 uv2; + vec3 I; + vec3 TtoW0; + vec3 TtoW1; + vec3 TtoW2; +}; +struct appdata_tan { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec3 _WorldSpaceCameraPos; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform vec4 _BumpMap_ST; +vec3 WorldSpaceViewDir ( + in vec4 v +) +{ + return (_WorldSpaceCameraPos.xyz - (_Object2World * v).xyz); +} + +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +v2f vert ( + in appdata_tan v +) +{ + mat3 rotation; + vec3 binormal; + v2f o; + PositionFog (v.vertex, o.pos, o.fog); + vec2 tmpvar_1; + tmpvar_1 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + o.uv = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = ((v.texcoord.xy * _BumpMap_ST.xy) + _BumpMap_ST.zw); + o.uv2 = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = WorldSpaceViewDir (v.vertex); + vec3 tmpvar_4; + tmpvar_4 = -(tmpvar_3); + o.I = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = cross (v.normal, v.tangent.xyz); + vec3 tmpvar_6; + tmpvar_6 = (tmpvar_5 * v.tangent.w); + binormal = tmpvar_6; + mat3 tmpvar_7; + float tmpvar_8; + tmpvar_8 = v.tangent.x; + tmpvar_7[0].x = tmpvar_8; + float tmpvar_9; + tmpvar_9 = binormal.x; + tmpvar_7[0].y = tmpvar_9; + float tmpvar_10; + tmpvar_10 = v.normal.x; + tmpvar_7[0].z = tmpvar_10; + float tmpvar_11; + tmpvar_11 = v.tangent.y; + tmpvar_7[1].x = tmpvar_11; + float tmpvar_12; + tmpvar_12 = binormal.y; + tmpvar_7[1].y = tmpvar_12; + float tmpvar_13; + tmpvar_13 = v.normal.y; + tmpvar_7[1].z = tmpvar_13; + float tmpvar_14; + tmpvar_14 = v.tangent.z; + tmpvar_7[2].x = tmpvar_14; + float tmpvar_15; + tmpvar_15 = binormal.z; + tmpvar_7[2].y = tmpvar_15; + float tmpvar_16; + tmpvar_16 = v.normal.z; + tmpvar_7[2].z = tmpvar_16; + mat3 tmpvar_17; + tmpvar_17 = (tmpvar_7); + rotation = (tmpvar_17); + vec3 tmpvar_18; + tmpvar_18 = (rotation * (_Object2World[0].xyz * unity_Scale.w)); + o.TtoW0 = tmpvar_18; + vec3 tmpvar_19; + tmpvar_19 = (rotation * (_Object2World[1].xyz * unity_Scale.w)); + o.TtoW1 = tmpvar_19; + vec3 tmpvar_20; + tmpvar_20 = (rotation * (_Object2World[2].xyz * unity_Scale.w)); + o.TtoW2 = tmpvar_20; + return o; +} + +void main () +{ + appdata_tan xlt_v; + v2f xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + v2f tmpvar_9; + tmpvar_9 = vert (xlt_v); + v2f tmpvar_10; + tmpvar_10 = tmpvar_9; + xl_retval = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = xl_retval.pos.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + gl_Position = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_13.x = xl_retval.fog; + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + xlv_FOG = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15.zw = vec2(0.0, 0.0); + tmpvar_15.xy = xl_retval.uv.xy; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_TexCoord[0] = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.zw = vec2(0.0, 0.0); + tmpvar_17.xy = xl_retval.uv2.xy; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + gl_TexCoord[1] = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19.w = 0.0; + tmpvar_19.xyz = xl_retval.I.xyz; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[2] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21.w = 0.0; + tmpvar_21.xyz = xl_retval.TtoW0.xyz; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_TexCoord[3] = tmpvar_22; + vec4 tmpvar_23; + tmpvar_23.w = 0.0; + tmpvar_23.xyz = xl_retval.TtoW1.xyz; + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + gl_TexCoord[4] = tmpvar_24; + vec4 tmpvar_25; + tmpvar_25.w = 0.0; + tmpvar_25.xyz = xl_retval.TtoW2.xyz; + vec4 tmpvar_26; + tmpvar_26 = tmpvar_25; + gl_TexCoord[5] = tmpvar_26; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Bumped_Unlit-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Bumped_Unlit-out.txt new file mode 100644 index 000000000..e3d501682 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Bumped_Unlit-out.txt @@ -0,0 +1,54 @@ +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec3 _WorldSpaceCameraPos; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform vec4 _BumpMap_ST; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * gl_Vertex); + vec3 tmpvar_2; + tmpvar_2 = (cross (gl_Normal, TANGENT.xyz) * TANGENT.w); + mat3 tmpvar_3; + tmpvar_3[0].x = TANGENT.x; + tmpvar_3[0].y = tmpvar_2.x; + tmpvar_3[0].z = gl_Normal.x; + tmpvar_3[1].x = TANGENT.y; + tmpvar_3[1].y = tmpvar_2.y; + tmpvar_3[1].z = gl_Normal.y; + tmpvar_3[2].x = TANGENT.z; + tmpvar_3[2].y = tmpvar_2.z; + tmpvar_3[2].z = gl_Normal.z; + gl_Position = tmpvar_1; + vec4 tmpvar_4; + tmpvar_4.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_4.x = tmpvar_1.z; + xlv_FOG = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5.zw = vec2(0.0, 0.0); + tmpvar_5.xy = ((gl_MultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + gl_TexCoord[0] = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6.zw = vec2(0.0, 0.0); + tmpvar_6.xy = ((gl_MultiTexCoord0.xy * _BumpMap_ST.xy) + _BumpMap_ST.zw); + gl_TexCoord[1] = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7.w = 0.0; + tmpvar_7.xyz = ((_Object2World * gl_Vertex).xyz - _WorldSpaceCameraPos); + gl_TexCoord[2] = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8.w = 0.0; + tmpvar_8.xyz = (tmpvar_3 * (_Object2World[0].xyz * unity_Scale.w)); + gl_TexCoord[3] = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9.w = 0.0; + tmpvar_9.xyz = (tmpvar_3 * (_Object2World[1].xyz * unity_Scale.w)); + gl_TexCoord[4] = tmpvar_9; + vec4 tmpvar_10; + tmpvar_10.w = 0.0; + tmpvar_10.xyz = (tmpvar_3 * (_Object2World[2].xyz * unity_Scale.w)); + gl_TexCoord[5] = tmpvar_10; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Diffuse-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Diffuse-in.txt new file mode 100644 index 000000000..8e6844ed8 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Diffuse-in.txt @@ -0,0 +1,90 @@ +mat3 xll_constructMat3( mat4 m) { + return mat3( vec3( m[0]), vec3( m[1]), vec3( m[2])); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec3 worldRefl; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 normal; + vec3 lightDir; + vec4 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform mat4 _LightMatrix0; +uniform vec4 _MainTex_ST; +uniform mat4 _Object2World; +uniform vec4 _WorldSpaceLightPos0; + +uniform vec4 unity_Scale; +vec3 WorldSpaceLightDir( in vec4 v ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +v2f_surf vert_surf( in appdata_full v ); +vec3 WorldSpaceLightDir( in vec4 v ) { + vec3 worldPos; + worldPos = ( _Object2World * v ).xyz ; + return (_WorldSpaceLightPos0.xyz - worldPos); +} +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + PositionFog( v.vertex, o.pos, o.fog); + o.hip_pack0.xy = ((v.texcoord.xy * _MainTex_ST.xy ) + _MainTex_ST.zw ); + o.normal = ( xll_constructMat3( _Object2World) * (v.normal * unity_Scale.w ) ); + o.lightDir = WorldSpaceLightDir( v.vertex); + o._LightCoord = ( _LightMatrix0 * ( _Object2World * v.vertex ) ); + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.hip_pack0, 0.0, 0.0); + gl_TexCoord[1] = vec4( xl_retval.normal, 0.0); + gl_TexCoord[2] = vec4( xl_retval.lightDir, 0.0); + gl_TexCoord[3] = vec4( xl_retval._LightCoord); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Diffuse-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Diffuse-ir.txt new file mode 100644 index 000000000..c7c3395e1 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Diffuse-ir.txt @@ -0,0 +1,171 @@ +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 normal; + vec3 lightDir; + vec4 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform mat4 _LightMatrix0; +mat3 xll_constructMat3 ( + in mat4 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = m[0].xyz; + vec3 tmpvar_2; + tmpvar_2 = m[1].xyz; + vec3 tmpvar_3; + tmpvar_3 = m[2].xyz; + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +vec3 WorldSpaceLightDir ( + in vec4 v +) +{ + vec3 worldPos; + vec3 tmpvar_1; + tmpvar_1 = (_Object2World * v).xyz; + worldPos = tmpvar_1; + return (_WorldSpaceLightPos0.xyz - worldPos); +} + +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + v2f_surf o; + PositionFog (v.vertex, o.pos, o.fog); + vec2 tmpvar_1; + tmpvar_1 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + o.hip_pack0 = tmpvar_1.xy.xy; + mat3 tmpvar_2; + tmpvar_2 = (xll_constructMat3 (_Object2World)); + vec3 tmpvar_3; + tmpvar_3 = (tmpvar_2 * (v.normal * unity_Scale.w)); + o.normal = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = WorldSpaceLightDir (v.vertex); + vec3 tmpvar_5; + tmpvar_5 = tmpvar_4; + o.lightDir = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = (_LightMatrix0 * (_Object2World * v.vertex)); + o._LightCoord = tmpvar_6; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = xl_retval.fog; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_FOG = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19.zw = vec2(0.0, 0.0); + tmpvar_19.xy = xl_retval.hip_pack0.xy; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[0] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21.w = 0.0; + tmpvar_21.xyz = xl_retval.normal.xyz; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_TexCoord[1] = tmpvar_22; + vec4 tmpvar_23; + tmpvar_23.w = 0.0; + tmpvar_23.xyz = xl_retval.lightDir.xyz; + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + gl_TexCoord[2] = tmpvar_24; + vec4 tmpvar_25; + tmpvar_25 = xl_retval._LightCoord.xyzw; + vec4 tmpvar_26; + tmpvar_26 = tmpvar_25; + gl_TexCoord[3] = tmpvar_26; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Diffuse-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Diffuse-out.txt new file mode 100644 index 000000000..6605302cf --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Diffuse-out.txt @@ -0,0 +1,34 @@ +varying vec4 xlv_FOG; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform mat4 _LightMatrix0; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * gl_Vertex); + mat3 tmpvar_2; + tmpvar_2[0] = _Object2World[0].xyz; + tmpvar_2[1] = _Object2World[1].xyz; + tmpvar_2[2] = _Object2World[2].xyz; + gl_Position = tmpvar_1; + vec4 tmpvar_3; + tmpvar_3.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_3.x = tmpvar_1.z; + xlv_FOG = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4.zw = vec2(0.0, 0.0); + tmpvar_4.xy = ((gl_MultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + gl_TexCoord[0] = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5.w = 0.0; + tmpvar_5.xyz = (tmpvar_2 * (gl_Normal * unity_Scale.w)); + gl_TexCoord[1] = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6.w = 0.0; + tmpvar_6.xyz = (_WorldSpaceLightPos0.xyz - (_Object2World * gl_Vertex).xyz); + gl_TexCoord[2] = tmpvar_6; + gl_TexCoord[3] = (_LightMatrix0 * (_Object2World * gl_Vertex)); +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Diffuse1-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Diffuse1-in.txt new file mode 100644 index 000000000..eedff876e --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Diffuse1-in.txt @@ -0,0 +1,100 @@ +mat3 xll_constructMat3( mat4 m) { + return mat3( vec3( m[0]), vec3( m[1]), vec3( m[2])); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec3 worldRefl; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 worldRefl; + vec4 hip_screen; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _MainTex_ST; +uniform mat4 _Object2World; +uniform vec4 _ProjectionParams; +uniform mat4 _World2Object; +uniform vec3 _WorldSpaceCameraPos; + +uniform vec4 unity_Scale; +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +vec3 ObjSpaceViewDir( in vec4 v ); +vec4 ComputeScreenPos( in vec4 pos ); +v2f_surf vert_surf( in appdata_full v ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +vec3 ObjSpaceViewDir( in vec4 v ) { + vec3 objSpaceCameraPos; + objSpaceCameraPos = (( _World2Object * vec4( _WorldSpaceCameraPos.xyz , 1.00000) ).xyz * unity_Scale.w ); + return (objSpaceCameraPos - v.xyz ); +} +vec4 ComputeScreenPos( in vec4 pos ) { + vec4 o; + o = (pos * 0.500000); + o.xy = (vec2( o.x , (o.y * _ProjectionParams.x )) + o.w ); + o.zw = pos.zw ; + return o; +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + vec3 viewDir; + vec3 viewRefl; + PositionFog( v.vertex, o.pos, o.fog); + o.hip_pack0.xy = ((v.texcoord.xy * _MainTex_ST.xy ) + _MainTex_ST.zw ); + viewDir = ( -ObjSpaceViewDir( v.vertex) ); + viewRefl = reflect( viewDir, v.normal); + o.worldRefl = ( xll_constructMat3( _Object2World) * viewRefl ); + o.hip_screen = ComputeScreenPos( o.pos); + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.hip_pack0, 0.0, 0.0); + gl_TexCoord[1] = vec4( xl_retval.worldRefl, 0.0); + gl_TexCoord[2] = vec4( xl_retval.hip_screen); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Diffuse1-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Diffuse1-ir.txt new file mode 100644 index 000000000..182a17fe1 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Diffuse1-ir.txt @@ -0,0 +1,197 @@ +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 worldRefl; + vec4 hip_screen; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec3 _WorldSpaceCameraPos; +uniform mat4 _World2Object; +uniform vec4 _ProjectionParams; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +mat3 xll_constructMat3 ( + in mat4 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = m[0].xyz; + vec3 tmpvar_2; + tmpvar_2 = m[1].xyz; + vec3 tmpvar_3; + tmpvar_3 = m[2].xyz; + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +vec3 ObjSpaceViewDir ( + in vec4 v +) +{ + vec3 objSpaceCameraPos; + vec4 tmpvar_1; + tmpvar_1.w = 1.0; + tmpvar_1.xyz = _WorldSpaceCameraPos.xyz.xyz; + vec3 tmpvar_2; + tmpvar_2 = ((_World2Object * tmpvar_1).xyz * unity_Scale.w); + objSpaceCameraPos = tmpvar_2; + return (objSpaceCameraPos - v.xyz); +} + +vec4 ComputeScreenPos ( + in vec4 pos +) +{ + vec4 o; + vec4 tmpvar_1; + tmpvar_1 = (pos * 0.5); + o = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2.x = o.x; + tmpvar_2.y = (o.y * _ProjectionParams.x); + vec2 tmpvar_3; + tmpvar_3 = (tmpvar_2 + o.w); + o.xy = tmpvar_3.xy.xy; + vec2 tmpvar_4; + tmpvar_4 = pos.zw; + o.zw = tmpvar_4.xxxy.zw; + return o; +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + vec3 viewRefl; + vec3 viewDir; + v2f_surf o; + PositionFog (v.vertex, o.pos, o.fog); + vec2 tmpvar_1; + tmpvar_1 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + o.hip_pack0 = tmpvar_1.xy.xy; + vec3 tmpvar_2; + tmpvar_2 = ObjSpaceViewDir (v.vertex); + vec3 tmpvar_3; + tmpvar_3 = -(tmpvar_2); + viewDir = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = reflect (viewDir, v.normal); + vec3 tmpvar_5; + tmpvar_5 = tmpvar_4; + viewRefl = tmpvar_5; + mat3 tmpvar_6; + tmpvar_6 = (xll_constructMat3 (_Object2World)); + vec3 tmpvar_7; + tmpvar_7 = (tmpvar_6 * viewRefl); + o.worldRefl = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = ComputeScreenPos (o.pos); + vec4 tmpvar_9; + tmpvar_9 = tmpvar_8; + o.hip_screen = tmpvar_9; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = xl_retval.fog; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_FOG = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19.zw = vec2(0.0, 0.0); + tmpvar_19.xy = xl_retval.hip_pack0.xy; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[0] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21.w = 0.0; + tmpvar_21.xyz = xl_retval.worldRefl.xyz; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_TexCoord[1] = tmpvar_22; + vec4 tmpvar_23; + tmpvar_23 = xl_retval.hip_screen.xyzw; + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + gl_TexCoord[2] = tmpvar_24; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Diffuse1-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Diffuse1-out.txt new file mode 100644 index 000000000..fabd2bc33 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Diffuse1-out.txt @@ -0,0 +1,43 @@ +varying vec4 xlv_FOG; +uniform vec4 unity_Scale; +uniform vec3 _WorldSpaceCameraPos; +uniform mat4 _World2Object; +uniform vec4 _ProjectionParams; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * gl_Vertex); + vec4 tmpvar_2; + tmpvar_2.w = 1.0; + tmpvar_2.xyz = _WorldSpaceCameraPos; + mat3 tmpvar_3; + tmpvar_3[0] = _Object2World[0].xyz; + tmpvar_3[1] = _Object2World[1].xyz; + tmpvar_3[2] = _Object2World[2].xyz; + vec4 o_i0; + vec4 tmpvar_4; + tmpvar_4 = (tmpvar_1 * 0.5); + o_i0 = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5.x = tmpvar_4.x; + tmpvar_5.y = (tmpvar_4.y * _ProjectionParams.x); + o_i0.xy = (tmpvar_5 + tmpvar_4.w); + o_i0.zw = tmpvar_1.zw; + gl_Position = tmpvar_1; + vec4 tmpvar_6; + tmpvar_6.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_6.x = tmpvar_1.z; + xlv_FOG = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7.zw = vec2(0.0, 0.0); + tmpvar_7.xy = ((gl_MultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + gl_TexCoord[0] = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8.w = 0.0; + tmpvar_8.xyz = (tmpvar_3 * reflect ((gl_Vertex.xyz - ((_World2Object * tmpvar_2).xyz * unity_Scale.w)), gl_Normal)); + gl_TexCoord[1] = tmpvar_8; + gl_TexCoord[2] = o_i0; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Parallax_Diffuse-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Parallax_Diffuse-in.txt new file mode 100644 index 000000000..9a7ab1102 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Parallax_Diffuse-in.txt @@ -0,0 +1,103 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; + vec3 worldRefl; + vec3 viewDir; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 viewDir; + vec3 lightDir; + vec4 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _BumpMap_ST; +uniform mat4 _LightMatrix0; +uniform vec4 _MainTex_ST; +uniform mat4 _Object2World; +uniform mat4 _World2Object; +uniform vec3 _WorldSpaceCameraPos; +uniform vec4 _WorldSpaceLightPos0; + +uniform vec4 unity_Scale; +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +vec3 ObjSpaceViewDir( in vec4 v ); +vec3 ObjSpaceLightDir( in vec4 v ); +v2f_surf vert_surf( in appdata_full v ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +vec3 ObjSpaceViewDir( in vec4 v ) { + vec3 objSpaceCameraPos; + objSpaceCameraPos = (( _World2Object * vec4( _WorldSpaceCameraPos.xyz , 1.00000) ).xyz * unity_Scale.w ); + return (objSpaceCameraPos - v.xyz ); +} +vec3 ObjSpaceLightDir( in vec4 v ) { + vec3 objSpaceLightPos; + objSpaceLightPos = ( _World2Object * _WorldSpaceLightPos0 ).xyz ; + return ((objSpaceLightPos.xyz * unity_Scale.w ) - v.xyz ); +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + vec3 binormal; + mat3 rotation; + PositionFog( v.vertex, o.pos, o.fog); + o.hip_pack0.xy = ((v.texcoord.xy * _MainTex_ST.xy ) + _MainTex_ST.zw ); + o.hip_pack0.zw = ((v.texcoord.xy * _BumpMap_ST.xy ) + _BumpMap_ST.zw ); + binormal = (cross( v.normal, v.tangent.xyz ) * v.tangent.w ); + rotation = mat3( v.tangent.x , binormal.x , v.normal.x , v.tangent.y , binormal.y , v.normal.y , v.tangent.z , binormal.z , v.normal.z ); + o.lightDir = ( rotation * ObjSpaceLightDir( v.vertex) ); + o.viewDir = ( rotation * ObjSpaceViewDir( v.vertex) ); + o._LightCoord = ( _LightMatrix0 * ( _Object2World * v.vertex ) ); + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.hip_pack0); + gl_TexCoord[1] = vec4( xl_retval.viewDir, 0.0); + gl_TexCoord[2] = vec4( xl_retval.lightDir, 0.0); + gl_TexCoord[3] = vec4( xl_retval._LightCoord); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Parallax_Diffuse-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Parallax_Diffuse-ir.txt new file mode 100644 index 000000000..a7e87ecd7 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Parallax_Diffuse-ir.txt @@ -0,0 +1,205 @@ +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 viewDir; + vec3 lightDir; + vec4 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform vec3 _WorldSpaceCameraPos; +uniform mat4 _World2Object; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform mat4 _LightMatrix0; +uniform vec4 _BumpMap_ST; +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +vec3 ObjSpaceViewDir ( + in vec4 v +) +{ + vec3 objSpaceCameraPos; + vec4 tmpvar_1; + tmpvar_1.w = 1.0; + tmpvar_1.xyz = _WorldSpaceCameraPos.xyz.xyz; + vec3 tmpvar_2; + tmpvar_2 = ((_World2Object * tmpvar_1).xyz * unity_Scale.w); + objSpaceCameraPos = tmpvar_2; + return (objSpaceCameraPos - v.xyz); +} + +vec3 ObjSpaceLightDir ( + in vec4 v +) +{ + vec3 objSpaceLightPos; + vec3 tmpvar_1; + tmpvar_1 = (_World2Object * _WorldSpaceLightPos0).xyz; + objSpaceLightPos = tmpvar_1; + return ((objSpaceLightPos.xyz * unity_Scale.w) - v.xyz); +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + mat3 rotation; + vec3 binormal; + v2f_surf o; + PositionFog (v.vertex, o.pos, o.fog); + vec2 tmpvar_1; + tmpvar_1 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + o.hip_pack0.xy = tmpvar_1.xy.xy; + vec2 tmpvar_2; + tmpvar_2 = ((v.texcoord.xy * _BumpMap_ST.xy) + _BumpMap_ST.zw); + o.hip_pack0.zw = tmpvar_2.xxxy.zw; + vec3 tmpvar_3; + tmpvar_3 = cross (v.normal, v.tangent.xyz); + vec3 tmpvar_4; + tmpvar_4 = (tmpvar_3 * v.tangent.w); + binormal = tmpvar_4; + mat3 tmpvar_5; + float tmpvar_6; + tmpvar_6 = v.tangent.x; + tmpvar_5[0].x = tmpvar_6; + float tmpvar_7; + tmpvar_7 = binormal.x; + tmpvar_5[0].y = tmpvar_7; + float tmpvar_8; + tmpvar_8 = v.normal.x; + tmpvar_5[0].z = tmpvar_8; + float tmpvar_9; + tmpvar_9 = v.tangent.y; + tmpvar_5[1].x = tmpvar_9; + float tmpvar_10; + tmpvar_10 = binormal.y; + tmpvar_5[1].y = tmpvar_10; + float tmpvar_11; + tmpvar_11 = v.normal.y; + tmpvar_5[1].z = tmpvar_11; + float tmpvar_12; + tmpvar_12 = v.tangent.z; + tmpvar_5[2].x = tmpvar_12; + float tmpvar_13; + tmpvar_13 = binormal.z; + tmpvar_5[2].y = tmpvar_13; + float tmpvar_14; + tmpvar_14 = v.normal.z; + tmpvar_5[2].z = tmpvar_14; + mat3 tmpvar_15; + tmpvar_15 = (tmpvar_5); + rotation = (tmpvar_15); + vec3 tmpvar_16; + tmpvar_16 = ObjSpaceLightDir (v.vertex); + vec3 tmpvar_17; + tmpvar_17 = (rotation * tmpvar_16); + o.lightDir = tmpvar_17; + vec3 tmpvar_18; + tmpvar_18 = ObjSpaceViewDir (v.vertex); + vec3 tmpvar_19; + tmpvar_19 = (rotation * tmpvar_18); + o.viewDir = tmpvar_19; + vec4 tmpvar_20; + tmpvar_20 = (_LightMatrix0 * (_Object2World * v.vertex)); + o._LightCoord = tmpvar_20; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = xl_retval.fog; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_FOG = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19 = xl_retval.hip_pack0.xyzw; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[0] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21.w = 0.0; + tmpvar_21.xyz = xl_retval.viewDir.xyz; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_TexCoord[1] = tmpvar_22; + vec4 tmpvar_23; + tmpvar_23.w = 0.0; + tmpvar_23.xyz = xl_retval.lightDir.xyz; + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + gl_TexCoord[2] = tmpvar_24; + vec4 tmpvar_25; + tmpvar_25 = xl_retval._LightCoord.xyzw; + vec4 tmpvar_26; + tmpvar_26 = tmpvar_25; + gl_TexCoord[3] = tmpvar_26; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Parallax_Diffuse-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Parallax_Diffuse-out.txt new file mode 100644 index 000000000..cf827be05 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Parallax_Diffuse-out.txt @@ -0,0 +1,49 @@ +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform vec3 _WorldSpaceCameraPos; +uniform mat4 _World2Object; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform mat4 _LightMatrix0; +uniform vec4 _BumpMap_ST; +void main () +{ + vec4 tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = (gl_ModelViewProjectionMatrix * gl_Vertex); + tmpvar_1.xy = ((gl_MultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + tmpvar_1.zw = ((gl_MultiTexCoord0.xy * _BumpMap_ST.xy) + _BumpMap_ST.zw); + vec3 tmpvar_3; + tmpvar_3 = (cross (gl_Normal, TANGENT.xyz) * TANGENT.w); + mat3 tmpvar_4; + tmpvar_4[0].x = TANGENT.x; + tmpvar_4[0].y = tmpvar_3.x; + tmpvar_4[0].z = gl_Normal.x; + tmpvar_4[1].x = TANGENT.y; + tmpvar_4[1].y = tmpvar_3.y; + tmpvar_4[1].z = gl_Normal.y; + tmpvar_4[2].x = TANGENT.z; + tmpvar_4[2].y = tmpvar_3.z; + tmpvar_4[2].z = gl_Normal.z; + vec4 tmpvar_5; + tmpvar_5.w = 1.0; + tmpvar_5.xyz = _WorldSpaceCameraPos; + gl_Position = tmpvar_2; + vec4 tmpvar_6; + tmpvar_6.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_6.x = tmpvar_2.z; + xlv_FOG = tmpvar_6; + gl_TexCoord[0] = tmpvar_1; + vec4 tmpvar_7; + tmpvar_7.w = 0.0; + tmpvar_7.xyz = (tmpvar_4 * (((_World2Object * tmpvar_5).xyz * unity_Scale.w) - gl_Vertex.xyz)); + gl_TexCoord[1] = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8.w = 0.0; + tmpvar_8.xyz = (tmpvar_4 * (((_World2Object * _WorldSpaceLightPos0).xyz * unity_Scale.w) - gl_Vertex.xyz)); + gl_TexCoord[2] = tmpvar_8; + gl_TexCoord[3] = (_LightMatrix0 * (_Object2World * gl_Vertex)); +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Parallax_Diffuse1-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Parallax_Diffuse1-in.txt new file mode 100644 index 000000000..fcfee7b34 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Parallax_Diffuse1-in.txt @@ -0,0 +1,120 @@ +mat3 xll_constructMat3( mat4 m) { + return mat3( vec3( m[0]), vec3( m[1]), vec3( m[2])); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; + vec3 worldRefl; + vec3 viewDir; + vec3 TtoW0; + vec3 TtoW1; + vec3 TtoW2; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 viewDir; + vec4 hip_screen; + vec4 TtoW0; + vec4 TtoW1; + vec4 TtoW2; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _BumpMap_ST; +uniform vec4 _MainTex_ST; +uniform mat4 _Object2World; +uniform vec4 _ProjectionParams; +uniform mat4 _World2Object; +uniform vec3 _WorldSpaceCameraPos; + +uniform vec4 unity_Scale; +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +vec3 ObjSpaceViewDir( in vec4 v ); +vec4 ComputeScreenPos( in vec4 pos ); +v2f_surf vert_surf( in appdata_full v ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +vec3 ObjSpaceViewDir( in vec4 v ) { + vec3 objSpaceCameraPos; + objSpaceCameraPos = (( _World2Object * vec4( _WorldSpaceCameraPos.xyz , 1.00000) ).xyz * unity_Scale.w ); + return (objSpaceCameraPos - v.xyz ); +} +vec4 ComputeScreenPos( in vec4 pos ) { + vec4 o; + o = (pos * 0.500000); + o.xy = (vec2( o.x , (o.y * _ProjectionParams.x )) + o.w ); + o.zw = pos.zw ; + return o; +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + vec3 viewDir; + vec3 worldRefl; + vec3 binormal; + mat3 rotation; + PositionFog( v.vertex, o.pos, o.fog); + o.hip_pack0.xy = ((v.texcoord.xy * _MainTex_ST.xy ) + _MainTex_ST.zw ); + o.hip_pack0.zw = ((v.texcoord.xy * _BumpMap_ST.xy ) + _BumpMap_ST.zw ); + viewDir = ( -ObjSpaceViewDir( v.vertex) ); + worldRefl = ( xll_constructMat3( _Object2World) * viewDir ); + binormal = (cross( v.normal, v.tangent.xyz ) * v.tangent.w ); + rotation = mat3( v.tangent.x , binormal.x , v.normal.x , v.tangent.y , binormal.y , v.normal.y , v.tangent.z , binormal.z , v.normal.z ); + o.TtoW0 = (vec4( ( rotation * _Object2World[ 0 ].xyz ), worldRefl.x ) * unity_Scale.w ); + o.TtoW1 = (vec4( ( rotation * _Object2World[ 1 ].xyz ), worldRefl.y ) * unity_Scale.w ); + o.TtoW2 = (vec4( ( rotation * _Object2World[ 2 ].xyz ), worldRefl.z ) * unity_Scale.w ); + o.hip_screen = ComputeScreenPos( o.pos); + o.viewDir = ( rotation * ObjSpaceViewDir( v.vertex) ); + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.hip_pack0); + gl_TexCoord[1] = vec4( xl_retval.viewDir, 0.0); + gl_TexCoord[2] = vec4( xl_retval.hip_screen); + gl_TexCoord[3] = vec4( xl_retval.TtoW0); + gl_TexCoord[4] = vec4( xl_retval.TtoW1); + gl_TexCoord[5] = vec4( xl_retval.TtoW2); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Parallax_Diffuse1-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Parallax_Diffuse1-ir.txt new file mode 100644 index 000000000..049e46c56 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Parallax_Diffuse1-ir.txt @@ -0,0 +1,274 @@ +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 viewDir; + vec4 hip_screen; + vec4 TtoW0; + vec4 TtoW1; + vec4 TtoW2; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec3 _WorldSpaceCameraPos; +uniform mat4 _World2Object; +uniform vec4 _ProjectionParams; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform vec4 _BumpMap_ST; +mat3 xll_constructMat3 ( + in mat4 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = m[0].xyz; + vec3 tmpvar_2; + tmpvar_2 = m[1].xyz; + vec3 tmpvar_3; + tmpvar_3 = m[2].xyz; + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +vec3 ObjSpaceViewDir ( + in vec4 v +) +{ + vec3 objSpaceCameraPos; + vec4 tmpvar_1; + tmpvar_1.w = 1.0; + tmpvar_1.xyz = _WorldSpaceCameraPos.xyz.xyz; + vec3 tmpvar_2; + tmpvar_2 = ((_World2Object * tmpvar_1).xyz * unity_Scale.w); + objSpaceCameraPos = tmpvar_2; + return (objSpaceCameraPos - v.xyz); +} + +vec4 ComputeScreenPos ( + in vec4 pos +) +{ + vec4 o; + vec4 tmpvar_1; + tmpvar_1 = (pos * 0.5); + o = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2.x = o.x; + tmpvar_2.y = (o.y * _ProjectionParams.x); + vec2 tmpvar_3; + tmpvar_3 = (tmpvar_2 + o.w); + o.xy = tmpvar_3.xy.xy; + vec2 tmpvar_4; + tmpvar_4 = pos.zw; + o.zw = tmpvar_4.xxxy.zw; + return o; +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + mat3 rotation; + vec3 binormal; + vec3 worldRefl; + vec3 viewDir; + v2f_surf o; + PositionFog (v.vertex, o.pos, o.fog); + vec2 tmpvar_1; + tmpvar_1 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + o.hip_pack0.xy = tmpvar_1.xy.xy; + vec2 tmpvar_2; + tmpvar_2 = ((v.texcoord.xy * _BumpMap_ST.xy) + _BumpMap_ST.zw); + o.hip_pack0.zw = tmpvar_2.xxxy.zw; + vec3 tmpvar_3; + tmpvar_3 = ObjSpaceViewDir (v.vertex); + vec3 tmpvar_4; + tmpvar_4 = -(tmpvar_3); + viewDir = tmpvar_4; + mat3 tmpvar_5; + tmpvar_5 = (xll_constructMat3 (_Object2World)); + vec3 tmpvar_6; + tmpvar_6 = (tmpvar_5 * viewDir); + worldRefl = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = cross (v.normal, v.tangent.xyz); + vec3 tmpvar_8; + tmpvar_8 = (tmpvar_7 * v.tangent.w); + binormal = tmpvar_8; + mat3 tmpvar_9; + float tmpvar_10; + tmpvar_10 = v.tangent.x; + tmpvar_9[0].x = tmpvar_10; + float tmpvar_11; + tmpvar_11 = binormal.x; + tmpvar_9[0].y = tmpvar_11; + float tmpvar_12; + tmpvar_12 = v.normal.x; + tmpvar_9[0].z = tmpvar_12; + float tmpvar_13; + tmpvar_13 = v.tangent.y; + tmpvar_9[1].x = tmpvar_13; + float tmpvar_14; + tmpvar_14 = binormal.y; + tmpvar_9[1].y = tmpvar_14; + float tmpvar_15; + tmpvar_15 = v.normal.y; + tmpvar_9[1].z = tmpvar_15; + float tmpvar_16; + tmpvar_16 = v.tangent.z; + tmpvar_9[2].x = tmpvar_16; + float tmpvar_17; + tmpvar_17 = binormal.z; + tmpvar_9[2].y = tmpvar_17; + float tmpvar_18; + tmpvar_18 = v.normal.z; + tmpvar_9[2].z = tmpvar_18; + mat3 tmpvar_19; + tmpvar_19 = (tmpvar_9); + rotation = (tmpvar_19); + vec4 tmpvar_20; + tmpvar_20.xyz = (rotation * _Object2World[0].xyz).xyz; + tmpvar_20.w = worldRefl.x; + vec4 tmpvar_21; + tmpvar_21 = (tmpvar_20 * unity_Scale.w); + o.TtoW0 = tmpvar_21; + vec4 tmpvar_22; + tmpvar_22.xyz = (rotation * _Object2World[1].xyz).xyz; + tmpvar_22.w = worldRefl.y; + vec4 tmpvar_23; + tmpvar_23 = (tmpvar_22 * unity_Scale.w); + o.TtoW1 = tmpvar_23; + vec4 tmpvar_24; + tmpvar_24.xyz = (rotation * _Object2World[2].xyz).xyz; + tmpvar_24.w = worldRefl.z; + vec4 tmpvar_25; + tmpvar_25 = (tmpvar_24 * unity_Scale.w); + o.TtoW2 = tmpvar_25; + vec4 tmpvar_26; + tmpvar_26 = ComputeScreenPos (o.pos); + vec4 tmpvar_27; + tmpvar_27 = tmpvar_26; + o.hip_screen = tmpvar_27; + vec3 tmpvar_28; + tmpvar_28 = ObjSpaceViewDir (v.vertex); + vec3 tmpvar_29; + tmpvar_29 = (rotation * tmpvar_28); + o.viewDir = tmpvar_29; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = xl_retval.fog; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_FOG = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19 = xl_retval.hip_pack0.xyzw; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[0] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21.w = 0.0; + tmpvar_21.xyz = xl_retval.viewDir.xyz; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_TexCoord[1] = tmpvar_22; + vec4 tmpvar_23; + tmpvar_23 = xl_retval.hip_screen.xyzw; + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + gl_TexCoord[2] = tmpvar_24; + vec4 tmpvar_25; + tmpvar_25 = xl_retval.TtoW0.xyzw; + vec4 tmpvar_26; + tmpvar_26 = tmpvar_25; + gl_TexCoord[3] = tmpvar_26; + vec4 tmpvar_27; + tmpvar_27 = xl_retval.TtoW1.xyzw; + vec4 tmpvar_28; + tmpvar_28 = tmpvar_27; + gl_TexCoord[4] = tmpvar_28; + vec4 tmpvar_29; + tmpvar_29 = xl_retval.TtoW2.xyzw; + vec4 tmpvar_30; + tmpvar_30 = tmpvar_29; + gl_TexCoord[5] = tmpvar_30; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Parallax_Diffuse1-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Parallax_Diffuse1-out.txt new file mode 100644 index 000000000..a95262aeb --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Parallax_Diffuse1-out.txt @@ -0,0 +1,74 @@ +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec3 _WorldSpaceCameraPos; +uniform mat4 _World2Object; +uniform vec4 _ProjectionParams; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform vec4 _BumpMap_ST; +void main () +{ + vec4 tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = (gl_ModelViewProjectionMatrix * gl_Vertex); + tmpvar_1.xy = ((gl_MultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + tmpvar_1.zw = ((gl_MultiTexCoord0.xy * _BumpMap_ST.xy) + _BumpMap_ST.zw); + vec4 tmpvar_3; + tmpvar_3.w = 1.0; + tmpvar_3.xyz = _WorldSpaceCameraPos; + mat3 tmpvar_4; + tmpvar_4[0] = _Object2World[0].xyz; + tmpvar_4[1] = _Object2World[1].xyz; + tmpvar_4[2] = _Object2World[2].xyz; + vec3 tmpvar_5; + tmpvar_5 = (tmpvar_4 * (gl_Vertex.xyz - ((_World2Object * tmpvar_3).xyz * unity_Scale.w))); + vec3 tmpvar_6; + tmpvar_6 = (cross (gl_Normal, TANGENT.xyz) * TANGENT.w); + mat3 tmpvar_7; + tmpvar_7[0].x = TANGENT.x; + tmpvar_7[0].y = tmpvar_6.x; + tmpvar_7[0].z = gl_Normal.x; + tmpvar_7[1].x = TANGENT.y; + tmpvar_7[1].y = tmpvar_6.y; + tmpvar_7[1].z = gl_Normal.y; + tmpvar_7[2].x = TANGENT.z; + tmpvar_7[2].y = tmpvar_6.z; + tmpvar_7[2].z = gl_Normal.z; + vec4 tmpvar_8; + tmpvar_8.xyz = (tmpvar_7 * _Object2World[0].xyz); + tmpvar_8.w = tmpvar_5.x; + vec4 tmpvar_9; + tmpvar_9.xyz = (tmpvar_7 * _Object2World[1].xyz); + tmpvar_9.w = tmpvar_5.y; + vec4 tmpvar_10; + tmpvar_10.xyz = (tmpvar_7 * _Object2World[2].xyz); + tmpvar_10.w = tmpvar_5.z; + vec4 o_i0; + vec4 tmpvar_11; + tmpvar_11 = (tmpvar_2 * 0.5); + o_i0 = tmpvar_11; + vec2 tmpvar_12; + tmpvar_12.x = tmpvar_11.x; + tmpvar_12.y = (tmpvar_11.y * _ProjectionParams.x); + o_i0.xy = (tmpvar_12 + tmpvar_11.w); + o_i0.zw = tmpvar_2.zw; + vec4 tmpvar_13; + tmpvar_13.w = 1.0; + tmpvar_13.xyz = _WorldSpaceCameraPos; + gl_Position = tmpvar_2; + vec4 tmpvar_14; + tmpvar_14.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_14.x = tmpvar_2.z; + xlv_FOG = tmpvar_14; + gl_TexCoord[0] = tmpvar_1; + vec4 tmpvar_15; + tmpvar_15.w = 0.0; + tmpvar_15.xyz = (tmpvar_7 * (((_World2Object * tmpvar_13).xyz * unity_Scale.w) - gl_Vertex.xyz)); + gl_TexCoord[1] = tmpvar_15; + gl_TexCoord[2] = o_i0; + gl_TexCoord[3] = (tmpvar_8 * unity_Scale.w); + gl_TexCoord[4] = (tmpvar_9 * unity_Scale.w); + gl_TexCoord[5] = (tmpvar_10 * unity_Scale.w); +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Parallax_Specular-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Parallax_Specular-in.txt new file mode 100644 index 000000000..1cefcd592 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Parallax_Specular-in.txt @@ -0,0 +1,103 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; + vec3 worldRefl; + vec3 viewDir; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 viewDir; + vec3 lightDir; + vec3 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _BumpMap_ST; +uniform mat4 _LightMatrix0; +uniform vec4 _MainTex_ST; +uniform mat4 _Object2World; +uniform mat4 _World2Object; +uniform vec3 _WorldSpaceCameraPos; +uniform vec4 _WorldSpaceLightPos0; + +uniform vec4 unity_Scale; +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +vec3 ObjSpaceViewDir( in vec4 v ); +vec3 ObjSpaceLightDir( in vec4 v ); +v2f_surf vert_surf( in appdata_full v ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +vec3 ObjSpaceViewDir( in vec4 v ) { + vec3 objSpaceCameraPos; + objSpaceCameraPos = (( _World2Object * vec4( _WorldSpaceCameraPos.xyz , 1.00000) ).xyz * unity_Scale.w ); + return (objSpaceCameraPos - v.xyz ); +} +vec3 ObjSpaceLightDir( in vec4 v ) { + vec3 objSpaceLightPos; + objSpaceLightPos = ( _World2Object * _WorldSpaceLightPos0 ).xyz ; + return ((objSpaceLightPos.xyz * unity_Scale.w ) - v.xyz ); +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + vec3 binormal; + mat3 rotation; + PositionFog( v.vertex, o.pos, o.fog); + o.hip_pack0.xy = ((v.texcoord.xy * _MainTex_ST.xy ) + _MainTex_ST.zw ); + o.hip_pack0.zw = ((v.texcoord.xy * _BumpMap_ST.xy ) + _BumpMap_ST.zw ); + binormal = (cross( v.normal, v.tangent.xyz ) * v.tangent.w ); + rotation = mat3( v.tangent.x , binormal.x , v.normal.x , v.tangent.y , binormal.y , v.normal.y , v.tangent.z , binormal.z , v.normal.z ); + o.lightDir = ( rotation * ObjSpaceLightDir( v.vertex) ); + o.viewDir = ( rotation * ObjSpaceViewDir( v.vertex) ); + o._LightCoord = ( _LightMatrix0 * ( _Object2World * v.vertex ) ).xyz ; + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.hip_pack0); + gl_TexCoord[1] = vec4( xl_retval.viewDir, 0.0); + gl_TexCoord[2] = vec4( xl_retval.lightDir, 0.0); + gl_TexCoord[3] = vec4( xl_retval._LightCoord, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Parallax_Specular-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Parallax_Specular-ir.txt new file mode 100644 index 000000000..9eab39855 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Parallax_Specular-ir.txt @@ -0,0 +1,206 @@ +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 viewDir; + vec3 lightDir; + vec3 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform vec3 _WorldSpaceCameraPos; +uniform mat4 _World2Object; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform mat4 _LightMatrix0; +uniform vec4 _BumpMap_ST; +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +vec3 ObjSpaceViewDir ( + in vec4 v +) +{ + vec3 objSpaceCameraPos; + vec4 tmpvar_1; + tmpvar_1.w = 1.0; + tmpvar_1.xyz = _WorldSpaceCameraPos.xyz.xyz; + vec3 tmpvar_2; + tmpvar_2 = ((_World2Object * tmpvar_1).xyz * unity_Scale.w); + objSpaceCameraPos = tmpvar_2; + return (objSpaceCameraPos - v.xyz); +} + +vec3 ObjSpaceLightDir ( + in vec4 v +) +{ + vec3 objSpaceLightPos; + vec3 tmpvar_1; + tmpvar_1 = (_World2Object * _WorldSpaceLightPos0).xyz; + objSpaceLightPos = tmpvar_1; + return ((objSpaceLightPos.xyz * unity_Scale.w) - v.xyz); +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + mat3 rotation; + vec3 binormal; + v2f_surf o; + PositionFog (v.vertex, o.pos, o.fog); + vec2 tmpvar_1; + tmpvar_1 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + o.hip_pack0.xy = tmpvar_1.xy.xy; + vec2 tmpvar_2; + tmpvar_2 = ((v.texcoord.xy * _BumpMap_ST.xy) + _BumpMap_ST.zw); + o.hip_pack0.zw = tmpvar_2.xxxy.zw; + vec3 tmpvar_3; + tmpvar_3 = cross (v.normal, v.tangent.xyz); + vec3 tmpvar_4; + tmpvar_4 = (tmpvar_3 * v.tangent.w); + binormal = tmpvar_4; + mat3 tmpvar_5; + float tmpvar_6; + tmpvar_6 = v.tangent.x; + tmpvar_5[0].x = tmpvar_6; + float tmpvar_7; + tmpvar_7 = binormal.x; + tmpvar_5[0].y = tmpvar_7; + float tmpvar_8; + tmpvar_8 = v.normal.x; + tmpvar_5[0].z = tmpvar_8; + float tmpvar_9; + tmpvar_9 = v.tangent.y; + tmpvar_5[1].x = tmpvar_9; + float tmpvar_10; + tmpvar_10 = binormal.y; + tmpvar_5[1].y = tmpvar_10; + float tmpvar_11; + tmpvar_11 = v.normal.y; + tmpvar_5[1].z = tmpvar_11; + float tmpvar_12; + tmpvar_12 = v.tangent.z; + tmpvar_5[2].x = tmpvar_12; + float tmpvar_13; + tmpvar_13 = binormal.z; + tmpvar_5[2].y = tmpvar_13; + float tmpvar_14; + tmpvar_14 = v.normal.z; + tmpvar_5[2].z = tmpvar_14; + mat3 tmpvar_15; + tmpvar_15 = (tmpvar_5); + rotation = (tmpvar_15); + vec3 tmpvar_16; + tmpvar_16 = ObjSpaceLightDir (v.vertex); + vec3 tmpvar_17; + tmpvar_17 = (rotation * tmpvar_16); + o.lightDir = tmpvar_17; + vec3 tmpvar_18; + tmpvar_18 = ObjSpaceViewDir (v.vertex); + vec3 tmpvar_19; + tmpvar_19 = (rotation * tmpvar_18); + o.viewDir = tmpvar_19; + vec3 tmpvar_20; + tmpvar_20 = (_LightMatrix0 * (_Object2World * v.vertex)).xyz; + o._LightCoord = tmpvar_20; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = xl_retval.fog; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_FOG = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19 = xl_retval.hip_pack0.xyzw; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[0] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21.w = 0.0; + tmpvar_21.xyz = xl_retval.viewDir.xyz; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_TexCoord[1] = tmpvar_22; + vec4 tmpvar_23; + tmpvar_23.w = 0.0; + tmpvar_23.xyz = xl_retval.lightDir.xyz; + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + gl_TexCoord[2] = tmpvar_24; + vec4 tmpvar_25; + tmpvar_25.w = 0.0; + tmpvar_25.xyz = xl_retval._LightCoord.xyz; + vec4 tmpvar_26; + tmpvar_26 = tmpvar_25; + gl_TexCoord[3] = tmpvar_26; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Parallax_Specular-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Parallax_Specular-out.txt new file mode 100644 index 000000000..6d4f4e204 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Parallax_Specular-out.txt @@ -0,0 +1,52 @@ +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform vec3 _WorldSpaceCameraPos; +uniform mat4 _World2Object; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform mat4 _LightMatrix0; +uniform vec4 _BumpMap_ST; +void main () +{ + vec4 tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = (gl_ModelViewProjectionMatrix * gl_Vertex); + tmpvar_1.xy = ((gl_MultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + tmpvar_1.zw = ((gl_MultiTexCoord0.xy * _BumpMap_ST.xy) + _BumpMap_ST.zw); + vec3 tmpvar_3; + tmpvar_3 = (cross (gl_Normal, TANGENT.xyz) * TANGENT.w); + mat3 tmpvar_4; + tmpvar_4[0].x = TANGENT.x; + tmpvar_4[0].y = tmpvar_3.x; + tmpvar_4[0].z = gl_Normal.x; + tmpvar_4[1].x = TANGENT.y; + tmpvar_4[1].y = tmpvar_3.y; + tmpvar_4[1].z = gl_Normal.y; + tmpvar_4[2].x = TANGENT.z; + tmpvar_4[2].y = tmpvar_3.z; + tmpvar_4[2].z = gl_Normal.z; + vec4 tmpvar_5; + tmpvar_5.w = 1.0; + tmpvar_5.xyz = _WorldSpaceCameraPos; + gl_Position = tmpvar_2; + vec4 tmpvar_6; + tmpvar_6.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_6.x = tmpvar_2.z; + xlv_FOG = tmpvar_6; + gl_TexCoord[0] = tmpvar_1; + vec4 tmpvar_7; + tmpvar_7.w = 0.0; + tmpvar_7.xyz = (tmpvar_4 * (((_World2Object * tmpvar_5).xyz * unity_Scale.w) - gl_Vertex.xyz)); + gl_TexCoord[1] = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8.w = 0.0; + tmpvar_8.xyz = (tmpvar_4 * (((_World2Object * _WorldSpaceLightPos0).xyz * unity_Scale.w) - gl_Vertex.xyz)); + gl_TexCoord[2] = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9.w = 0.0; + tmpvar_9.xyz = (_LightMatrix0 * (_Object2World * gl_Vertex)).xyz; + gl_TexCoord[3] = tmpvar_9; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Parallax_Specular1-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Parallax_Specular1-in.txt new file mode 100644 index 000000000..3c1f34f8c --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Parallax_Specular1-in.txt @@ -0,0 +1,103 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; + vec3 worldRefl; + vec3 viewDir; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 viewDir; + vec3 lightDir; + vec2 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _BumpMap_ST; +uniform mat4 _LightMatrix0; +uniform vec4 _MainTex_ST; +uniform mat4 _Object2World; +uniform mat4 _World2Object; +uniform vec3 _WorldSpaceCameraPos; +uniform vec4 _WorldSpaceLightPos0; + +uniform vec4 unity_Scale; +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +vec3 ObjSpaceViewDir( in vec4 v ); +vec3 ObjSpaceLightDir( in vec4 v ); +v2f_surf vert_surf( in appdata_full v ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +vec3 ObjSpaceViewDir( in vec4 v ) { + vec3 objSpaceCameraPos; + objSpaceCameraPos = (( _World2Object * vec4( _WorldSpaceCameraPos.xyz , 1.00000) ).xyz * unity_Scale.w ); + return (objSpaceCameraPos - v.xyz ); +} +vec3 ObjSpaceLightDir( in vec4 v ) { + vec3 objSpaceLightPos; + objSpaceLightPos = ( _World2Object * _WorldSpaceLightPos0 ).xyz ; + return objSpaceLightPos.xyz ; +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + vec3 binormal; + mat3 rotation; + PositionFog( v.vertex, o.pos, o.fog); + o.hip_pack0.xy = ((v.texcoord.xy * _MainTex_ST.xy ) + _MainTex_ST.zw ); + o.hip_pack0.zw = ((v.texcoord.xy * _BumpMap_ST.xy ) + _BumpMap_ST.zw ); + binormal = (cross( v.normal, v.tangent.xyz ) * v.tangent.w ); + rotation = mat3( v.tangent.x , binormal.x , v.normal.x , v.tangent.y , binormal.y , v.normal.y , v.tangent.z , binormal.z , v.normal.z ); + o.lightDir = ( rotation * ObjSpaceLightDir( v.vertex) ); + o.viewDir = ( rotation * ObjSpaceViewDir( v.vertex) ); + o._LightCoord = ( _LightMatrix0 * ( _Object2World * v.vertex ) ).xy ; + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.hip_pack0); + gl_TexCoord[1] = vec4( xl_retval.viewDir, 0.0); + gl_TexCoord[2] = vec4( xl_retval.lightDir, 0.0); + gl_TexCoord[3] = vec4( xl_retval._LightCoord, 0.0, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Parallax_Specular1-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Parallax_Specular1-ir.txt new file mode 100644 index 000000000..a25b3711c --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Parallax_Specular1-ir.txt @@ -0,0 +1,206 @@ +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 viewDir; + vec3 lightDir; + vec2 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform vec3 _WorldSpaceCameraPos; +uniform mat4 _World2Object; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform mat4 _LightMatrix0; +uniform vec4 _BumpMap_ST; +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +vec3 ObjSpaceViewDir ( + in vec4 v +) +{ + vec3 objSpaceCameraPos; + vec4 tmpvar_1; + tmpvar_1.w = 1.0; + tmpvar_1.xyz = _WorldSpaceCameraPos.xyz.xyz; + vec3 tmpvar_2; + tmpvar_2 = ((_World2Object * tmpvar_1).xyz * unity_Scale.w); + objSpaceCameraPos = tmpvar_2; + return (objSpaceCameraPos - v.xyz); +} + +vec3 ObjSpaceLightDir ( + in vec4 v +) +{ + vec3 objSpaceLightPos; + vec3 tmpvar_1; + tmpvar_1 = (_World2Object * _WorldSpaceLightPos0).xyz; + objSpaceLightPos = tmpvar_1; + return objSpaceLightPos.xyz; +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + mat3 rotation; + vec3 binormal; + v2f_surf o; + PositionFog (v.vertex, o.pos, o.fog); + vec2 tmpvar_1; + tmpvar_1 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + o.hip_pack0.xy = tmpvar_1.xy.xy; + vec2 tmpvar_2; + tmpvar_2 = ((v.texcoord.xy * _BumpMap_ST.xy) + _BumpMap_ST.zw); + o.hip_pack0.zw = tmpvar_2.xxxy.zw; + vec3 tmpvar_3; + tmpvar_3 = cross (v.normal, v.tangent.xyz); + vec3 tmpvar_4; + tmpvar_4 = (tmpvar_3 * v.tangent.w); + binormal = tmpvar_4; + mat3 tmpvar_5; + float tmpvar_6; + tmpvar_6 = v.tangent.x; + tmpvar_5[0].x = tmpvar_6; + float tmpvar_7; + tmpvar_7 = binormal.x; + tmpvar_5[0].y = tmpvar_7; + float tmpvar_8; + tmpvar_8 = v.normal.x; + tmpvar_5[0].z = tmpvar_8; + float tmpvar_9; + tmpvar_9 = v.tangent.y; + tmpvar_5[1].x = tmpvar_9; + float tmpvar_10; + tmpvar_10 = binormal.y; + tmpvar_5[1].y = tmpvar_10; + float tmpvar_11; + tmpvar_11 = v.normal.y; + tmpvar_5[1].z = tmpvar_11; + float tmpvar_12; + tmpvar_12 = v.tangent.z; + tmpvar_5[2].x = tmpvar_12; + float tmpvar_13; + tmpvar_13 = binormal.z; + tmpvar_5[2].y = tmpvar_13; + float tmpvar_14; + tmpvar_14 = v.normal.z; + tmpvar_5[2].z = tmpvar_14; + mat3 tmpvar_15; + tmpvar_15 = (tmpvar_5); + rotation = (tmpvar_15); + vec3 tmpvar_16; + tmpvar_16 = ObjSpaceLightDir (v.vertex); + vec3 tmpvar_17; + tmpvar_17 = (rotation * tmpvar_16); + o.lightDir = tmpvar_17; + vec3 tmpvar_18; + tmpvar_18 = ObjSpaceViewDir (v.vertex); + vec3 tmpvar_19; + tmpvar_19 = (rotation * tmpvar_18); + o.viewDir = tmpvar_19; + vec2 tmpvar_20; + tmpvar_20 = (_LightMatrix0 * (_Object2World * v.vertex)).xy; + o._LightCoord = tmpvar_20; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = xl_retval.fog; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_FOG = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19 = xl_retval.hip_pack0.xyzw; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[0] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21.w = 0.0; + tmpvar_21.xyz = xl_retval.viewDir.xyz; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_TexCoord[1] = tmpvar_22; + vec4 tmpvar_23; + tmpvar_23.w = 0.0; + tmpvar_23.xyz = xl_retval.lightDir.xyz; + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + gl_TexCoord[2] = tmpvar_24; + vec4 tmpvar_25; + tmpvar_25.zw = vec2(0.0, 0.0); + tmpvar_25.xy = xl_retval._LightCoord.xy; + vec4 tmpvar_26; + tmpvar_26 = tmpvar_25; + gl_TexCoord[3] = tmpvar_26; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Parallax_Specular1-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Parallax_Specular1-out.txt new file mode 100644 index 000000000..1e237ae2f --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Parallax_Specular1-out.txt @@ -0,0 +1,52 @@ +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform vec3 _WorldSpaceCameraPos; +uniform mat4 _World2Object; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform mat4 _LightMatrix0; +uniform vec4 _BumpMap_ST; +void main () +{ + vec4 tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = (gl_ModelViewProjectionMatrix * gl_Vertex); + tmpvar_1.xy = ((gl_MultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + tmpvar_1.zw = ((gl_MultiTexCoord0.xy * _BumpMap_ST.xy) + _BumpMap_ST.zw); + vec3 tmpvar_3; + tmpvar_3 = (cross (gl_Normal, TANGENT.xyz) * TANGENT.w); + mat3 tmpvar_4; + tmpvar_4[0].x = TANGENT.x; + tmpvar_4[0].y = tmpvar_3.x; + tmpvar_4[0].z = gl_Normal.x; + tmpvar_4[1].x = TANGENT.y; + tmpvar_4[1].y = tmpvar_3.y; + tmpvar_4[1].z = gl_Normal.y; + tmpvar_4[2].x = TANGENT.z; + tmpvar_4[2].y = tmpvar_3.z; + tmpvar_4[2].z = gl_Normal.z; + vec4 tmpvar_5; + tmpvar_5.w = 1.0; + tmpvar_5.xyz = _WorldSpaceCameraPos; + gl_Position = tmpvar_2; + vec4 tmpvar_6; + tmpvar_6.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_6.x = tmpvar_2.z; + xlv_FOG = tmpvar_6; + gl_TexCoord[0] = tmpvar_1; + vec4 tmpvar_7; + tmpvar_7.w = 0.0; + tmpvar_7.xyz = (tmpvar_4 * (((_World2Object * tmpvar_5).xyz * unity_Scale.w) - gl_Vertex.xyz)); + gl_TexCoord[1] = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8.w = 0.0; + tmpvar_8.xyz = (tmpvar_4 * (_World2Object * _WorldSpaceLightPos0).xyz); + gl_TexCoord[2] = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9.zw = vec2(0.0, 0.0); + tmpvar_9.xy = (_LightMatrix0 * (_Object2World * gl_Vertex)).xy; + gl_TexCoord[3] = tmpvar_9; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Specular-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Specular-in.txt new file mode 100644 index 000000000..5358a1406 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Specular-in.txt @@ -0,0 +1,98 @@ +mat3 xll_constructMat3( mat4 m) { + return mat3( vec3( m[0]), vec3( m[1]), vec3( m[2])); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec3 worldRefl; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 normal; + vec3 lightDir; + vec3 viewDir; + vec4 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform mat4 _LightMatrix0; +uniform vec4 _MainTex_ST; +uniform mat4 _Object2World; +uniform vec3 _WorldSpaceCameraPos; +uniform vec4 _WorldSpaceLightPos0; + +uniform vec4 unity_Scale; +vec3 WorldSpaceViewDir( in vec4 v ); +vec3 WorldSpaceLightDir( in vec4 v ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +v2f_surf vert_surf( in appdata_full v ); +vec3 WorldSpaceViewDir( in vec4 v ) { + return (_WorldSpaceCameraPos.xyz - ( _Object2World * v ).xyz ); +} +vec3 WorldSpaceLightDir( in vec4 v ) { + vec3 worldPos; + worldPos = ( _Object2World * v ).xyz ; + return (_WorldSpaceLightPos0.xyz - worldPos); +} +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + PositionFog( v.vertex, o.pos, o.fog); + o.hip_pack0.xy = ((v.texcoord.xy * _MainTex_ST.xy ) + _MainTex_ST.zw ); + o.normal = ( xll_constructMat3( _Object2World) * (v.normal * unity_Scale.w ) ); + o.lightDir = WorldSpaceLightDir( v.vertex); + o.viewDir = WorldSpaceViewDir( v.vertex); + o._LightCoord = ( _LightMatrix0 * ( _Object2World * v.vertex ) ); + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.hip_pack0, 0.0, 0.0); + gl_TexCoord[1] = vec4( xl_retval.normal, 0.0); + gl_TexCoord[2] = vec4( xl_retval.lightDir, 0.0); + gl_TexCoord[3] = vec4( xl_retval.viewDir, 0.0); + gl_TexCoord[4] = vec4( xl_retval._LightCoord); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Specular-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Specular-ir.txt new file mode 100644 index 000000000..d25a0fef9 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Specular-ir.txt @@ -0,0 +1,191 @@ +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 normal; + vec3 lightDir; + vec3 viewDir; + vec4 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform vec3 _WorldSpaceCameraPos; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform mat4 _LightMatrix0; +mat3 xll_constructMat3 ( + in mat4 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = m[0].xyz; + vec3 tmpvar_2; + tmpvar_2 = m[1].xyz; + vec3 tmpvar_3; + tmpvar_3 = m[2].xyz; + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +vec3 WorldSpaceViewDir ( + in vec4 v +) +{ + return (_WorldSpaceCameraPos.xyz - (_Object2World * v).xyz); +} + +vec3 WorldSpaceLightDir ( + in vec4 v +) +{ + vec3 worldPos; + vec3 tmpvar_1; + tmpvar_1 = (_Object2World * v).xyz; + worldPos = tmpvar_1; + return (_WorldSpaceLightPos0.xyz - worldPos); +} + +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + v2f_surf o; + PositionFog (v.vertex, o.pos, o.fog); + vec2 tmpvar_1; + tmpvar_1 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + o.hip_pack0 = tmpvar_1.xy.xy; + mat3 tmpvar_2; + tmpvar_2 = (xll_constructMat3 (_Object2World)); + vec3 tmpvar_3; + tmpvar_3 = (tmpvar_2 * (v.normal * unity_Scale.w)); + o.normal = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = WorldSpaceLightDir (v.vertex); + vec3 tmpvar_5; + tmpvar_5 = tmpvar_4; + o.lightDir = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = WorldSpaceViewDir (v.vertex); + vec3 tmpvar_7; + tmpvar_7 = tmpvar_6; + o.viewDir = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = (_LightMatrix0 * (_Object2World * v.vertex)); + o._LightCoord = tmpvar_8; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = xl_retval.fog; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_FOG = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19.zw = vec2(0.0, 0.0); + tmpvar_19.xy = xl_retval.hip_pack0.xy; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[0] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21.w = 0.0; + tmpvar_21.xyz = xl_retval.normal.xyz; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_TexCoord[1] = tmpvar_22; + vec4 tmpvar_23; + tmpvar_23.w = 0.0; + tmpvar_23.xyz = xl_retval.lightDir.xyz; + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + gl_TexCoord[2] = tmpvar_24; + vec4 tmpvar_25; + tmpvar_25.w = 0.0; + tmpvar_25.xyz = xl_retval.viewDir.xyz; + vec4 tmpvar_26; + tmpvar_26 = tmpvar_25; + gl_TexCoord[3] = tmpvar_26; + vec4 tmpvar_27; + tmpvar_27 = xl_retval._LightCoord.xyzw; + vec4 tmpvar_28; + tmpvar_28 = tmpvar_27; + gl_TexCoord[4] = tmpvar_28; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Specular-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Specular-out.txt new file mode 100644 index 000000000..427bda0ed --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Specular-out.txt @@ -0,0 +1,39 @@ +varying vec4 xlv_FOG; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform vec3 _WorldSpaceCameraPos; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform mat4 _LightMatrix0; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * gl_Vertex); + mat3 tmpvar_2; + tmpvar_2[0] = _Object2World[0].xyz; + tmpvar_2[1] = _Object2World[1].xyz; + tmpvar_2[2] = _Object2World[2].xyz; + gl_Position = tmpvar_1; + vec4 tmpvar_3; + tmpvar_3.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_3.x = tmpvar_1.z; + xlv_FOG = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4.zw = vec2(0.0, 0.0); + tmpvar_4.xy = ((gl_MultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + gl_TexCoord[0] = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5.w = 0.0; + tmpvar_5.xyz = (tmpvar_2 * (gl_Normal * unity_Scale.w)); + gl_TexCoord[1] = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6.w = 0.0; + tmpvar_6.xyz = (_WorldSpaceLightPos0.xyz - (_Object2World * gl_Vertex).xyz); + gl_TexCoord[2] = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7.w = 0.0; + tmpvar_7.xyz = (_WorldSpaceCameraPos - (_Object2World * gl_Vertex).xyz); + gl_TexCoord[3] = tmpvar_7; + gl_TexCoord[4] = (_LightMatrix0 * (_Object2World * gl_Vertex)); +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Specular1-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Specular1-in.txt new file mode 100644 index 000000000..46682a306 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Specular1-in.txt @@ -0,0 +1,63 @@ +mat3 xll_constructMat3( mat4 m) { + return mat3( vec3( m[0]), vec3( m[1]), vec3( m[2])); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec3 worldRefl; +}; +struct v2f_surf { + vec4 pos; + vec3 normal; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; + + +v2f_surf vert_surf( in appdata_full v ); +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + o.pos = ( gl_ModelViewProjectionMatrix * v.vertex ); + o.normal = ( xll_constructMat3( gl_ModelViewMatrixInverseTranspose) * v.normal ); + return o; +} +attribute vec4 TANGENT; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + gl_TexCoord[0] = vec4( xl_retval.normal, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Specular1-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Specular1-ir.txt new file mode 100644 index 000000000..50b15335d --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Specular1-ir.txt @@ -0,0 +1,104 @@ +struct v2f_surf { + vec4 pos; + vec3 normal; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +attribute vec4 TANGENT; +mat3 xll_constructMat3 ( + in mat4 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = m[0].xyz; + vec3 tmpvar_2; + tmpvar_2 = m[1].xyz; + vec3 tmpvar_3; + tmpvar_3 = m[2].xyz; + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + v2f_surf o; + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v.vertex); + o.pos = tmpvar_1; + mat3 tmpvar_2; + tmpvar_2 = (xll_constructMat3 (gl_ModelViewMatrixInverseTranspose)); + vec3 tmpvar_3; + tmpvar_3 = (tmpvar_2 * v.normal); + o.normal = tmpvar_3; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.w = 0.0; + tmpvar_17.xyz = xl_retval.normal.xyz; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + gl_TexCoord[0] = tmpvar_18; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Specular1-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Specular1-out.txt new file mode 100644 index 000000000..ec3e493bd --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Specular1-out.txt @@ -0,0 +1,13 @@ +void main () +{ + mat3 tmpvar_1; + tmpvar_1[0] = gl_ModelViewMatrixInverseTranspose[0].xyz; + tmpvar_1[1] = gl_ModelViewMatrixInverseTranspose[1].xyz; + tmpvar_1[2] = gl_ModelViewMatrixInverseTranspose[2].xyz; + gl_Position = (gl_ModelViewProjectionMatrix * gl_Vertex); + vec4 tmpvar_2; + tmpvar_2.w = 0.0; + tmpvar_2.xyz = (tmpvar_1 * gl_Normal); + gl_TexCoord[0] = tmpvar_2; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Specular2-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Specular2-in.txt new file mode 100644 index 000000000..eedff876e --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Specular2-in.txt @@ -0,0 +1,100 @@ +mat3 xll_constructMat3( mat4 m) { + return mat3( vec3( m[0]), vec3( m[1]), vec3( m[2])); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec3 worldRefl; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 worldRefl; + vec4 hip_screen; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _MainTex_ST; +uniform mat4 _Object2World; +uniform vec4 _ProjectionParams; +uniform mat4 _World2Object; +uniform vec3 _WorldSpaceCameraPos; + +uniform vec4 unity_Scale; +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +vec3 ObjSpaceViewDir( in vec4 v ); +vec4 ComputeScreenPos( in vec4 pos ); +v2f_surf vert_surf( in appdata_full v ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +vec3 ObjSpaceViewDir( in vec4 v ) { + vec3 objSpaceCameraPos; + objSpaceCameraPos = (( _World2Object * vec4( _WorldSpaceCameraPos.xyz , 1.00000) ).xyz * unity_Scale.w ); + return (objSpaceCameraPos - v.xyz ); +} +vec4 ComputeScreenPos( in vec4 pos ) { + vec4 o; + o = (pos * 0.500000); + o.xy = (vec2( o.x , (o.y * _ProjectionParams.x )) + o.w ); + o.zw = pos.zw ; + return o; +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + vec3 viewDir; + vec3 viewRefl; + PositionFog( v.vertex, o.pos, o.fog); + o.hip_pack0.xy = ((v.texcoord.xy * _MainTex_ST.xy ) + _MainTex_ST.zw ); + viewDir = ( -ObjSpaceViewDir( v.vertex) ); + viewRefl = reflect( viewDir, v.normal); + o.worldRefl = ( xll_constructMat3( _Object2World) * viewRefl ); + o.hip_screen = ComputeScreenPos( o.pos); + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.hip_pack0, 0.0, 0.0); + gl_TexCoord[1] = vec4( xl_retval.worldRefl, 0.0); + gl_TexCoord[2] = vec4( xl_retval.hip_screen); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Specular2-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Specular2-ir.txt new file mode 100644 index 000000000..182a17fe1 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Specular2-ir.txt @@ -0,0 +1,197 @@ +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 worldRefl; + vec4 hip_screen; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec3 _WorldSpaceCameraPos; +uniform mat4 _World2Object; +uniform vec4 _ProjectionParams; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +mat3 xll_constructMat3 ( + in mat4 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = m[0].xyz; + vec3 tmpvar_2; + tmpvar_2 = m[1].xyz; + vec3 tmpvar_3; + tmpvar_3 = m[2].xyz; + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +vec3 ObjSpaceViewDir ( + in vec4 v +) +{ + vec3 objSpaceCameraPos; + vec4 tmpvar_1; + tmpvar_1.w = 1.0; + tmpvar_1.xyz = _WorldSpaceCameraPos.xyz.xyz; + vec3 tmpvar_2; + tmpvar_2 = ((_World2Object * tmpvar_1).xyz * unity_Scale.w); + objSpaceCameraPos = tmpvar_2; + return (objSpaceCameraPos - v.xyz); +} + +vec4 ComputeScreenPos ( + in vec4 pos +) +{ + vec4 o; + vec4 tmpvar_1; + tmpvar_1 = (pos * 0.5); + o = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2.x = o.x; + tmpvar_2.y = (o.y * _ProjectionParams.x); + vec2 tmpvar_3; + tmpvar_3 = (tmpvar_2 + o.w); + o.xy = tmpvar_3.xy.xy; + vec2 tmpvar_4; + tmpvar_4 = pos.zw; + o.zw = tmpvar_4.xxxy.zw; + return o; +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + vec3 viewRefl; + vec3 viewDir; + v2f_surf o; + PositionFog (v.vertex, o.pos, o.fog); + vec2 tmpvar_1; + tmpvar_1 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + o.hip_pack0 = tmpvar_1.xy.xy; + vec3 tmpvar_2; + tmpvar_2 = ObjSpaceViewDir (v.vertex); + vec3 tmpvar_3; + tmpvar_3 = -(tmpvar_2); + viewDir = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = reflect (viewDir, v.normal); + vec3 tmpvar_5; + tmpvar_5 = tmpvar_4; + viewRefl = tmpvar_5; + mat3 tmpvar_6; + tmpvar_6 = (xll_constructMat3 (_Object2World)); + vec3 tmpvar_7; + tmpvar_7 = (tmpvar_6 * viewRefl); + o.worldRefl = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = ComputeScreenPos (o.pos); + vec4 tmpvar_9; + tmpvar_9 = tmpvar_8; + o.hip_screen = tmpvar_9; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = xl_retval.fog; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_FOG = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19.zw = vec2(0.0, 0.0); + tmpvar_19.xy = xl_retval.hip_pack0.xy; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[0] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21.w = 0.0; + tmpvar_21.xyz = xl_retval.worldRefl.xyz; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_TexCoord[1] = tmpvar_22; + vec4 tmpvar_23; + tmpvar_23 = xl_retval.hip_screen.xyzw; + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + gl_TexCoord[2] = tmpvar_24; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Specular2-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Specular2-out.txt new file mode 100644 index 000000000..fabd2bc33 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Reflective_Specular2-out.txt @@ -0,0 +1,43 @@ +varying vec4 xlv_FOG; +uniform vec4 unity_Scale; +uniform vec3 _WorldSpaceCameraPos; +uniform mat4 _World2Object; +uniform vec4 _ProjectionParams; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * gl_Vertex); + vec4 tmpvar_2; + tmpvar_2.w = 1.0; + tmpvar_2.xyz = _WorldSpaceCameraPos; + mat3 tmpvar_3; + tmpvar_3[0] = _Object2World[0].xyz; + tmpvar_3[1] = _Object2World[1].xyz; + tmpvar_3[2] = _Object2World[2].xyz; + vec4 o_i0; + vec4 tmpvar_4; + tmpvar_4 = (tmpvar_1 * 0.5); + o_i0 = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5.x = tmpvar_4.x; + tmpvar_5.y = (tmpvar_4.y * _ProjectionParams.x); + o_i0.xy = (tmpvar_5 + tmpvar_4.w); + o_i0.zw = tmpvar_1.zw; + gl_Position = tmpvar_1; + vec4 tmpvar_6; + tmpvar_6.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_6.x = tmpvar_1.z; + xlv_FOG = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7.zw = vec2(0.0, 0.0); + tmpvar_7.xy = ((gl_MultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + gl_TexCoord[0] = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8.w = 0.0; + tmpvar_8.xyz = (tmpvar_3 * reflect ((gl_Vertex.xyz - ((_World2Object * tmpvar_2).xyz * unity_Scale.w)), gl_Normal)); + gl_TexCoord[1] = tmpvar_8; + gl_TexCoord[2] = o_i0; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-RenderFX_Skybox_Cubed-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-RenderFX_Skybox_Cubed-in.txt new file mode 100644 index 000000000..f3c17cd0f --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-RenderFX_Skybox_Cubed-in.txt @@ -0,0 +1,38 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct v2f { + vec4 vertex; + vec3 texcoord; +}; +struct appdata_t { + vec4 vertex; + vec3 texcoord; +}; + +v2f vert( in appdata_t v ); +v2f vert( in appdata_t v ) { + v2f o; + o.vertex = ( gl_ModelViewProjectionMatrix * v.vertex ); + o.texcoord = v.texcoord; + return o; +} +void main() { + v2f xl_retval; + appdata_t xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.texcoord = vec3( gl_MultiTexCoord0); + xl_retval = vert( xlt_v); + gl_Position = vec4( xl_retval.vertex); + gl_TexCoord[0] = vec4( xl_retval.texcoord, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-RenderFX_Skybox_Cubed-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-RenderFX_Skybox_Cubed-ir.txt new file mode 100644 index 000000000..5c28938a4 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-RenderFX_Skybox_Cubed-ir.txt @@ -0,0 +1,54 @@ +struct v2f { + vec4 vertex; + vec3 texcoord; +}; +struct appdata_t { + vec4 vertex; + vec3 texcoord; +}; +v2f vert ( + in appdata_t v +) +{ + v2f o; + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v.vertex); + o.vertex = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = v.texcoord; + o.texcoord = tmpvar_2; + return o; +} + +void main () +{ + appdata_t xlt_v; + v2f xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = gl_MultiTexCoord0.xyz; + vec3 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.texcoord = tmpvar_4; + v2f tmpvar_5; + tmpvar_5 = vert (xlt_v); + v2f tmpvar_6; + tmpvar_6 = tmpvar_5; + xl_retval = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = xl_retval.vertex.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + gl_Position = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9.w = 0.0; + tmpvar_9.xyz = xl_retval.texcoord.xyz; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + gl_TexCoord[0] = tmpvar_10; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-RenderFX_Skybox_Cubed-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-RenderFX_Skybox_Cubed-out.txt new file mode 100644 index 000000000..f33832836 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-RenderFX_Skybox_Cubed-out.txt @@ -0,0 +1,9 @@ +void main () +{ + gl_Position = (gl_ModelViewProjectionMatrix * gl_Vertex); + vec4 tmpvar_1; + tmpvar_1.w = 0.0; + tmpvar_1.xyz = gl_MultiTexCoord0.xyz; + gl_TexCoord[0] = tmpvar_1; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Self-Illumin_Bumped_Diffuse-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Self-Illumin_Bumped_Diffuse-in.txt new file mode 100644 index 000000000..8f57a7b3c --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Self-Illumin_Bumped_Diffuse-in.txt @@ -0,0 +1,92 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_Illum; + vec2 uv_BumpMap; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 lightDir; + vec4 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _BumpMap_ST; +uniform mat4 _LightMatrix0; +uniform vec4 _MainTex_ST; +uniform mat4 _Object2World; +uniform mat4 _World2Object; +uniform vec4 _WorldSpaceLightPos0; + +uniform vec4 unity_Scale; +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +vec3 ObjSpaceLightDir( in vec4 v ); +v2f_surf vert_surf( in appdata_full v ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +vec3 ObjSpaceLightDir( in vec4 v ) { + vec3 objSpaceLightPos; + objSpaceLightPos = ( _World2Object * _WorldSpaceLightPos0 ).xyz ; + return ((objSpaceLightPos.xyz * unity_Scale.w ) - v.xyz ); +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + vec3 binormal; + mat3 rotation; + PositionFog( v.vertex, o.pos, o.fog); + o.hip_pack0.xy = ((v.texcoord.xy * _MainTex_ST.xy ) + _MainTex_ST.zw ); + o.hip_pack0.zw = ((v.texcoord.xy * _BumpMap_ST.xy ) + _BumpMap_ST.zw ); + binormal = (cross( v.normal, v.tangent.xyz ) * v.tangent.w ); + rotation = mat3( v.tangent.x , binormal.x , v.normal.x , v.tangent.y , binormal.y , v.normal.y , v.tangent.z , binormal.z , v.normal.z ); + o.lightDir = ( rotation * ObjSpaceLightDir( v.vertex) ); + o._LightCoord = ( _LightMatrix0 * ( _Object2World * v.vertex ) ); + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.hip_pack0); + gl_TexCoord[1] = vec4( xl_retval.lightDir, 0.0); + gl_TexCoord[2] = vec4( xl_retval._LightCoord); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Self-Illumin_Bumped_Diffuse-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Self-Illumin_Bumped_Diffuse-ir.txt new file mode 100644 index 000000000..0bf9822ab --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Self-Illumin_Bumped_Diffuse-ir.txt @@ -0,0 +1,178 @@ +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 lightDir; + vec4 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform mat4 _World2Object; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform mat4 _LightMatrix0; +uniform vec4 _BumpMap_ST; +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +vec3 ObjSpaceLightDir ( + in vec4 v +) +{ + vec3 objSpaceLightPos; + vec3 tmpvar_1; + tmpvar_1 = (_World2Object * _WorldSpaceLightPos0).xyz; + objSpaceLightPos = tmpvar_1; + return ((objSpaceLightPos.xyz * unity_Scale.w) - v.xyz); +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + mat3 rotation; + vec3 binormal; + v2f_surf o; + PositionFog (v.vertex, o.pos, o.fog); + vec2 tmpvar_1; + tmpvar_1 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + o.hip_pack0.xy = tmpvar_1.xy.xy; + vec2 tmpvar_2; + tmpvar_2 = ((v.texcoord.xy * _BumpMap_ST.xy) + _BumpMap_ST.zw); + o.hip_pack0.zw = tmpvar_2.xxxy.zw; + vec3 tmpvar_3; + tmpvar_3 = cross (v.normal, v.tangent.xyz); + vec3 tmpvar_4; + tmpvar_4 = (tmpvar_3 * v.tangent.w); + binormal = tmpvar_4; + mat3 tmpvar_5; + float tmpvar_6; + tmpvar_6 = v.tangent.x; + tmpvar_5[0].x = tmpvar_6; + float tmpvar_7; + tmpvar_7 = binormal.x; + tmpvar_5[0].y = tmpvar_7; + float tmpvar_8; + tmpvar_8 = v.normal.x; + tmpvar_5[0].z = tmpvar_8; + float tmpvar_9; + tmpvar_9 = v.tangent.y; + tmpvar_5[1].x = tmpvar_9; + float tmpvar_10; + tmpvar_10 = binormal.y; + tmpvar_5[1].y = tmpvar_10; + float tmpvar_11; + tmpvar_11 = v.normal.y; + tmpvar_5[1].z = tmpvar_11; + float tmpvar_12; + tmpvar_12 = v.tangent.z; + tmpvar_5[2].x = tmpvar_12; + float tmpvar_13; + tmpvar_13 = binormal.z; + tmpvar_5[2].y = tmpvar_13; + float tmpvar_14; + tmpvar_14 = v.normal.z; + tmpvar_5[2].z = tmpvar_14; + mat3 tmpvar_15; + tmpvar_15 = (tmpvar_5); + rotation = (tmpvar_15); + vec3 tmpvar_16; + tmpvar_16 = ObjSpaceLightDir (v.vertex); + vec3 tmpvar_17; + tmpvar_17 = (rotation * tmpvar_16); + o.lightDir = tmpvar_17; + vec4 tmpvar_18; + tmpvar_18 = (_LightMatrix0 * (_Object2World * v.vertex)); + o._LightCoord = tmpvar_18; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = xl_retval.fog; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_FOG = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19 = xl_retval.hip_pack0.xyzw; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[0] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21.w = 0.0; + tmpvar_21.xyz = xl_retval.lightDir.xyz; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_TexCoord[1] = tmpvar_22; + vec4 tmpvar_23; + tmpvar_23 = xl_retval._LightCoord.xyzw; + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + gl_TexCoord[2] = tmpvar_24; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Self-Illumin_Bumped_Diffuse-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Self-Illumin_Bumped_Diffuse-out.txt new file mode 100644 index 000000000..e2733f88c --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Self-Illumin_Bumped_Diffuse-out.txt @@ -0,0 +1,41 @@ +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform mat4 _World2Object; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform mat4 _LightMatrix0; +uniform vec4 _BumpMap_ST; +void main () +{ + vec4 tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = (gl_ModelViewProjectionMatrix * gl_Vertex); + tmpvar_1.xy = ((gl_MultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + tmpvar_1.zw = ((gl_MultiTexCoord0.xy * _BumpMap_ST.xy) + _BumpMap_ST.zw); + vec3 tmpvar_3; + tmpvar_3 = (cross (gl_Normal, TANGENT.xyz) * TANGENT.w); + mat3 tmpvar_4; + tmpvar_4[0].x = TANGENT.x; + tmpvar_4[0].y = tmpvar_3.x; + tmpvar_4[0].z = gl_Normal.x; + tmpvar_4[1].x = TANGENT.y; + tmpvar_4[1].y = tmpvar_3.y; + tmpvar_4[1].z = gl_Normal.y; + tmpvar_4[2].x = TANGENT.z; + tmpvar_4[2].y = tmpvar_3.z; + tmpvar_4[2].z = gl_Normal.z; + gl_Position = tmpvar_2; + vec4 tmpvar_5; + tmpvar_5.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_5.x = tmpvar_2.z; + xlv_FOG = tmpvar_5; + gl_TexCoord[0] = tmpvar_1; + vec4 tmpvar_6; + tmpvar_6.w = 0.0; + tmpvar_6.xyz = (tmpvar_4 * (((_World2Object * _WorldSpaceLightPos0).xyz * unity_Scale.w) - gl_Vertex.xyz)); + gl_TexCoord[1] = tmpvar_6; + gl_TexCoord[2] = (_LightMatrix0 * (_Object2World * gl_Vertex)); +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Self-Illumin_Bumped_Specular1-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Self-Illumin_Bumped_Specular1-in.txt new file mode 100644 index 000000000..394c85d62 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Self-Illumin_Bumped_Specular1-in.txt @@ -0,0 +1,83 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_Illum; + vec2 uv_BumpMap; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec4 hip_screen; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _Illum_ST; +uniform vec4 _MainTex_ST; +uniform vec4 _ProjectionParams; + +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +vec4 ComputeScreenPos( in vec4 pos ); +v2f_surf vert_surf( in appdata_full v ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +vec4 ComputeScreenPos( in vec4 pos ) { + vec4 o; + o = (pos * 0.500000); + o.xy = (vec2( o.x , (o.y * _ProjectionParams.x )) + o.w ); + o.zw = pos.zw ; + return o; +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + PositionFog( v.vertex, o.pos, o.fog); + o.hip_pack0.xy = ((v.texcoord.xy * _MainTex_ST.xy ) + _MainTex_ST.zw ); + o.hip_pack0.zw = ((v.texcoord.xy * _Illum_ST.xy ) + _Illum_ST.zw ); + o.hip_screen = ComputeScreenPos( o.pos); + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.hip_pack0); + gl_TexCoord[1] = vec4( xl_retval.hip_screen); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Self-Illumin_Bumped_Specular1-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Self-Illumin_Bumped_Specular1-ir.txt new file mode 100644 index 000000000..bb4a8330b --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Self-Illumin_Bumped_Specular1-ir.txt @@ -0,0 +1,135 @@ +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec4 hip_screen; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 _ProjectionParams; +uniform vec4 _MainTex_ST; +uniform vec4 _Illum_ST; +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +vec4 ComputeScreenPos ( + in vec4 pos +) +{ + vec4 o; + vec4 tmpvar_1; + tmpvar_1 = (pos * 0.5); + o = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2.x = o.x; + tmpvar_2.y = (o.y * _ProjectionParams.x); + vec2 tmpvar_3; + tmpvar_3 = (tmpvar_2 + o.w); + o.xy = tmpvar_3.xy.xy; + vec2 tmpvar_4; + tmpvar_4 = pos.zw; + o.zw = tmpvar_4.xxxy.zw; + return o; +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + v2f_surf o; + PositionFog (v.vertex, o.pos, o.fog); + vec2 tmpvar_1; + tmpvar_1 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + o.hip_pack0.xy = tmpvar_1.xy.xy; + vec2 tmpvar_2; + tmpvar_2 = ((v.texcoord.xy * _Illum_ST.xy) + _Illum_ST.zw); + o.hip_pack0.zw = tmpvar_2.xxxy.zw; + vec4 tmpvar_3; + tmpvar_3 = ComputeScreenPos (o.pos); + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + o.hip_screen = tmpvar_4; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = xl_retval.fog; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_FOG = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19 = xl_retval.hip_pack0.xyzw; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[0] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21 = xl_retval.hip_screen.xyzw; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_TexCoord[1] = tmpvar_22; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Self-Illumin_Bumped_Specular1-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Self-Illumin_Bumped_Specular1-out.txt new file mode 100644 index 000000000..366846d48 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Self-Illumin_Bumped_Specular1-out.txt @@ -0,0 +1,29 @@ +varying vec4 xlv_FOG; +uniform vec4 _ProjectionParams; +uniform vec4 _MainTex_ST; +uniform vec4 _Illum_ST; +void main () +{ + vec4 tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = (gl_ModelViewProjectionMatrix * gl_Vertex); + tmpvar_1.xy = ((gl_MultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + tmpvar_1.zw = ((gl_MultiTexCoord0.xy * _Illum_ST.xy) + _Illum_ST.zw); + vec4 o_i0; + vec4 tmpvar_3; + tmpvar_3 = (tmpvar_2 * 0.5); + o_i0 = tmpvar_3; + vec2 tmpvar_4; + tmpvar_4.x = tmpvar_3.x; + tmpvar_4.y = (tmpvar_3.y * _ProjectionParams.x); + o_i0.xy = (tmpvar_4 + tmpvar_3.w); + o_i0.zw = tmpvar_2.zw; + gl_Position = tmpvar_2; + vec4 tmpvar_5; + tmpvar_5.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_5.x = tmpvar_2.z; + xlv_FOG = tmpvar_5; + gl_TexCoord[0] = tmpvar_1; + gl_TexCoord[1] = o_i0; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Self-Illumin_Diffuse1-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Self-Illumin_Diffuse1-in.txt new file mode 100644 index 000000000..44c693a19 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Self-Illumin_Diffuse1-in.txt @@ -0,0 +1,89 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_Illum; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec4 hip_screen; + vec3 hip_lmapFade; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _Illum_ST; +uniform vec4 _MainTex_ST; +uniform vec4 _ProjectionParams; + + +uniform vec4 unity_LightmapFade; +uniform vec4 unity_LightmapST; +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +vec4 ComputeScreenPos( in vec4 pos ); +v2f_surf vert_surf( in appdata_full v ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +vec4 ComputeScreenPos( in vec4 pos ) { + vec4 o; + o = (pos * 0.500000); + o.xy = (vec2( o.x , (o.y * _ProjectionParams.x )) + o.w ); + o.zw = pos.zw ; + return o; +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + PositionFog( v.vertex, o.pos, o.fog); + o.hip_pack0.xy = ((v.texcoord.xy * _MainTex_ST.xy ) + _MainTex_ST.zw ); + o.hip_pack0.zw = ((v.texcoord.xy * _Illum_ST.xy ) + _Illum_ST.zw ); + o.hip_screen = ComputeScreenPos( o.pos); + o.hip_lmapFade.xy = ((v.texcoord1.xy * unity_LightmapST.xy ) + unity_LightmapST.zw ); + o.hip_lmapFade.z = ((( -( gl_ModelViewMatrix * v.vertex ).z ) * unity_LightmapFade.z ) + unity_LightmapFade.w ); + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.hip_pack0); + gl_TexCoord[1] = vec4( xl_retval.hip_screen); + gl_TexCoord[2] = vec4( xl_retval.hip_lmapFade, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Self-Illumin_Diffuse1-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Self-Illumin_Diffuse1-ir.txt new file mode 100644 index 000000000..1c9e12c8f --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Self-Illumin_Diffuse1-ir.txt @@ -0,0 +1,150 @@ +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec4 hip_screen; + vec3 hip_lmapFade; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_LightmapST; +uniform vec4 unity_LightmapFade; +uniform vec4 _ProjectionParams; +uniform vec4 _MainTex_ST; +uniform vec4 _Illum_ST; +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +vec4 ComputeScreenPos ( + in vec4 pos +) +{ + vec4 o; + vec4 tmpvar_1; + tmpvar_1 = (pos * 0.5); + o = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2.x = o.x; + tmpvar_2.y = (o.y * _ProjectionParams.x); + vec2 tmpvar_3; + tmpvar_3 = (tmpvar_2 + o.w); + o.xy = tmpvar_3.xy.xy; + vec2 tmpvar_4; + tmpvar_4 = pos.zw; + o.zw = tmpvar_4.xxxy.zw; + return o; +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + v2f_surf o; + PositionFog (v.vertex, o.pos, o.fog); + vec2 tmpvar_1; + tmpvar_1 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + o.hip_pack0.xy = tmpvar_1.xy.xy; + vec2 tmpvar_2; + tmpvar_2 = ((v.texcoord.xy * _Illum_ST.xy) + _Illum_ST.zw); + o.hip_pack0.zw = tmpvar_2.xxxy.zw; + vec4 tmpvar_3; + tmpvar_3 = ComputeScreenPos (o.pos); + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + o.hip_screen = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5 = ((v.texcoord1.xy * unity_LightmapST.xy) + unity_LightmapST.zw); + o.hip_lmapFade.xy = tmpvar_5.xy.xy; + float tmpvar_6; + tmpvar_6 = ((-((gl_ModelViewMatrix * v.vertex).z) * unity_LightmapFade.z) + unity_LightmapFade.w); + o.hip_lmapFade.z = vec3(tmpvar_6).z; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = xl_retval.fog; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_FOG = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19 = xl_retval.hip_pack0.xyzw; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[0] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21 = xl_retval.hip_screen.xyzw; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_TexCoord[1] = tmpvar_22; + vec4 tmpvar_23; + tmpvar_23.w = 0.0; + tmpvar_23.xyz = xl_retval.hip_lmapFade.xyz; + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + gl_TexCoord[2] = tmpvar_24; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Self-Illumin_Diffuse1-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Self-Illumin_Diffuse1-out.txt new file mode 100644 index 000000000..61b5dc68f --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Self-Illumin_Diffuse1-out.txt @@ -0,0 +1,38 @@ +varying vec4 xlv_FOG; +uniform vec4 unity_LightmapST; +uniform vec4 unity_LightmapFade; +uniform vec4 _ProjectionParams; +uniform vec4 _MainTex_ST; +uniform vec4 _Illum_ST; +void main () +{ + vec4 tmpvar_1; + vec3 tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = (gl_ModelViewProjectionMatrix * gl_Vertex); + tmpvar_1.xy = ((gl_MultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + tmpvar_1.zw = ((gl_MultiTexCoord0.xy * _Illum_ST.xy) + _Illum_ST.zw); + vec4 o_i0; + vec4 tmpvar_4; + tmpvar_4 = (tmpvar_3 * 0.5); + o_i0 = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5.x = tmpvar_4.x; + tmpvar_5.y = (tmpvar_4.y * _ProjectionParams.x); + o_i0.xy = (tmpvar_5 + tmpvar_4.w); + o_i0.zw = tmpvar_3.zw; + tmpvar_2.xy = ((gl_MultiTexCoord1.xy * unity_LightmapST.xy) + unity_LightmapST.zw); + tmpvar_2.z = ((-((gl_ModelViewMatrix * gl_Vertex).z) * unity_LightmapFade.z) + unity_LightmapFade.w); + gl_Position = tmpvar_3; + vec4 tmpvar_6; + tmpvar_6.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_6.x = tmpvar_3.z; + xlv_FOG = tmpvar_6; + gl_TexCoord[0] = tmpvar_1; + gl_TexCoord[1] = o_i0; + vec4 tmpvar_7; + tmpvar_7.w = 0.0; + tmpvar_7.xyz = tmpvar_2; + gl_TexCoord[2] = tmpvar_7; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Self-Illumin_Parallax_Diffuse-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Self-Illumin_Parallax_Diffuse-in.txt new file mode 100644 index 000000000..f5c8f85ba --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Self-Illumin_Parallax_Diffuse-in.txt @@ -0,0 +1,103 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; + vec2 uv_Illum; + vec3 viewDir; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 viewDir; + vec3 lightDir; + vec4 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _BumpMap_ST; +uniform mat4 _LightMatrix0; +uniform vec4 _MainTex_ST; +uniform mat4 _Object2World; +uniform mat4 _World2Object; +uniform vec3 _WorldSpaceCameraPos; +uniform vec4 _WorldSpaceLightPos0; + +uniform vec4 unity_Scale; +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +vec3 ObjSpaceViewDir( in vec4 v ); +vec3 ObjSpaceLightDir( in vec4 v ); +v2f_surf vert_surf( in appdata_full v ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +vec3 ObjSpaceViewDir( in vec4 v ) { + vec3 objSpaceCameraPos; + objSpaceCameraPos = (( _World2Object * vec4( _WorldSpaceCameraPos.xyz , 1.00000) ).xyz * unity_Scale.w ); + return (objSpaceCameraPos - v.xyz ); +} +vec3 ObjSpaceLightDir( in vec4 v ) { + vec3 objSpaceLightPos; + objSpaceLightPos = ( _World2Object * _WorldSpaceLightPos0 ).xyz ; + return ((objSpaceLightPos.xyz * unity_Scale.w ) - v.xyz ); +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + vec3 binormal; + mat3 rotation; + PositionFog( v.vertex, o.pos, o.fog); + o.hip_pack0.xy = ((v.texcoord.xy * _MainTex_ST.xy ) + _MainTex_ST.zw ); + o.hip_pack0.zw = ((v.texcoord.xy * _BumpMap_ST.xy ) + _BumpMap_ST.zw ); + binormal = (cross( v.normal, v.tangent.xyz ) * v.tangent.w ); + rotation = mat3( v.tangent.x , binormal.x , v.normal.x , v.tangent.y , binormal.y , v.normal.y , v.tangent.z , binormal.z , v.normal.z ); + o.lightDir = ( rotation * ObjSpaceLightDir( v.vertex) ); + o.viewDir = ( rotation * ObjSpaceViewDir( v.vertex) ); + o._LightCoord = ( _LightMatrix0 * ( _Object2World * v.vertex ) ); + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.hip_pack0); + gl_TexCoord[1] = vec4( xl_retval.viewDir, 0.0); + gl_TexCoord[2] = vec4( xl_retval.lightDir, 0.0); + gl_TexCoord[3] = vec4( xl_retval._LightCoord); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Self-Illumin_Parallax_Diffuse-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Self-Illumin_Parallax_Diffuse-ir.txt new file mode 100644 index 000000000..a7e87ecd7 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Self-Illumin_Parallax_Diffuse-ir.txt @@ -0,0 +1,205 @@ +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 viewDir; + vec3 lightDir; + vec4 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform vec3 _WorldSpaceCameraPos; +uniform mat4 _World2Object; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform mat4 _LightMatrix0; +uniform vec4 _BumpMap_ST; +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +vec3 ObjSpaceViewDir ( + in vec4 v +) +{ + vec3 objSpaceCameraPos; + vec4 tmpvar_1; + tmpvar_1.w = 1.0; + tmpvar_1.xyz = _WorldSpaceCameraPos.xyz.xyz; + vec3 tmpvar_2; + tmpvar_2 = ((_World2Object * tmpvar_1).xyz * unity_Scale.w); + objSpaceCameraPos = tmpvar_2; + return (objSpaceCameraPos - v.xyz); +} + +vec3 ObjSpaceLightDir ( + in vec4 v +) +{ + vec3 objSpaceLightPos; + vec3 tmpvar_1; + tmpvar_1 = (_World2Object * _WorldSpaceLightPos0).xyz; + objSpaceLightPos = tmpvar_1; + return ((objSpaceLightPos.xyz * unity_Scale.w) - v.xyz); +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + mat3 rotation; + vec3 binormal; + v2f_surf o; + PositionFog (v.vertex, o.pos, o.fog); + vec2 tmpvar_1; + tmpvar_1 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + o.hip_pack0.xy = tmpvar_1.xy.xy; + vec2 tmpvar_2; + tmpvar_2 = ((v.texcoord.xy * _BumpMap_ST.xy) + _BumpMap_ST.zw); + o.hip_pack0.zw = tmpvar_2.xxxy.zw; + vec3 tmpvar_3; + tmpvar_3 = cross (v.normal, v.tangent.xyz); + vec3 tmpvar_4; + tmpvar_4 = (tmpvar_3 * v.tangent.w); + binormal = tmpvar_4; + mat3 tmpvar_5; + float tmpvar_6; + tmpvar_6 = v.tangent.x; + tmpvar_5[0].x = tmpvar_6; + float tmpvar_7; + tmpvar_7 = binormal.x; + tmpvar_5[0].y = tmpvar_7; + float tmpvar_8; + tmpvar_8 = v.normal.x; + tmpvar_5[0].z = tmpvar_8; + float tmpvar_9; + tmpvar_9 = v.tangent.y; + tmpvar_5[1].x = tmpvar_9; + float tmpvar_10; + tmpvar_10 = binormal.y; + tmpvar_5[1].y = tmpvar_10; + float tmpvar_11; + tmpvar_11 = v.normal.y; + tmpvar_5[1].z = tmpvar_11; + float tmpvar_12; + tmpvar_12 = v.tangent.z; + tmpvar_5[2].x = tmpvar_12; + float tmpvar_13; + tmpvar_13 = binormal.z; + tmpvar_5[2].y = tmpvar_13; + float tmpvar_14; + tmpvar_14 = v.normal.z; + tmpvar_5[2].z = tmpvar_14; + mat3 tmpvar_15; + tmpvar_15 = (tmpvar_5); + rotation = (tmpvar_15); + vec3 tmpvar_16; + tmpvar_16 = ObjSpaceLightDir (v.vertex); + vec3 tmpvar_17; + tmpvar_17 = (rotation * tmpvar_16); + o.lightDir = tmpvar_17; + vec3 tmpvar_18; + tmpvar_18 = ObjSpaceViewDir (v.vertex); + vec3 tmpvar_19; + tmpvar_19 = (rotation * tmpvar_18); + o.viewDir = tmpvar_19; + vec4 tmpvar_20; + tmpvar_20 = (_LightMatrix0 * (_Object2World * v.vertex)); + o._LightCoord = tmpvar_20; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = xl_retval.fog; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_FOG = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19 = xl_retval.hip_pack0.xyzw; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[0] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21.w = 0.0; + tmpvar_21.xyz = xl_retval.viewDir.xyz; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_TexCoord[1] = tmpvar_22; + vec4 tmpvar_23; + tmpvar_23.w = 0.0; + tmpvar_23.xyz = xl_retval.lightDir.xyz; + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + gl_TexCoord[2] = tmpvar_24; + vec4 tmpvar_25; + tmpvar_25 = xl_retval._LightCoord.xyzw; + vec4 tmpvar_26; + tmpvar_26 = tmpvar_25; + gl_TexCoord[3] = tmpvar_26; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Self-Illumin_Parallax_Diffuse-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Self-Illumin_Parallax_Diffuse-out.txt new file mode 100644 index 000000000..cf827be05 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Self-Illumin_Parallax_Diffuse-out.txt @@ -0,0 +1,49 @@ +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform vec3 _WorldSpaceCameraPos; +uniform mat4 _World2Object; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform mat4 _LightMatrix0; +uniform vec4 _BumpMap_ST; +void main () +{ + vec4 tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = (gl_ModelViewProjectionMatrix * gl_Vertex); + tmpvar_1.xy = ((gl_MultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + tmpvar_1.zw = ((gl_MultiTexCoord0.xy * _BumpMap_ST.xy) + _BumpMap_ST.zw); + vec3 tmpvar_3; + tmpvar_3 = (cross (gl_Normal, TANGENT.xyz) * TANGENT.w); + mat3 tmpvar_4; + tmpvar_4[0].x = TANGENT.x; + tmpvar_4[0].y = tmpvar_3.x; + tmpvar_4[0].z = gl_Normal.x; + tmpvar_4[1].x = TANGENT.y; + tmpvar_4[1].y = tmpvar_3.y; + tmpvar_4[1].z = gl_Normal.y; + tmpvar_4[2].x = TANGENT.z; + tmpvar_4[2].y = tmpvar_3.z; + tmpvar_4[2].z = gl_Normal.z; + vec4 tmpvar_5; + tmpvar_5.w = 1.0; + tmpvar_5.xyz = _WorldSpaceCameraPos; + gl_Position = tmpvar_2; + vec4 tmpvar_6; + tmpvar_6.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_6.x = tmpvar_2.z; + xlv_FOG = tmpvar_6; + gl_TexCoord[0] = tmpvar_1; + vec4 tmpvar_7; + tmpvar_7.w = 0.0; + tmpvar_7.xyz = (tmpvar_4 * (((_World2Object * tmpvar_5).xyz * unity_Scale.w) - gl_Vertex.xyz)); + gl_TexCoord[1] = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8.w = 0.0; + tmpvar_8.xyz = (tmpvar_4 * (((_World2Object * _WorldSpaceLightPos0).xyz * unity_Scale.w) - gl_Vertex.xyz)); + gl_TexCoord[2] = tmpvar_8; + gl_TexCoord[3] = (_LightMatrix0 * (_Object2World * gl_Vertex)); +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Self-Illumin_Parallax_Specular1-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Self-Illumin_Parallax_Specular1-in.txt new file mode 100644 index 000000000..d7226de83 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Self-Illumin_Parallax_Specular1-in.txt @@ -0,0 +1,103 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; + vec2 uv_Illum; + vec3 viewDir; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 viewDir; + vec3 lightDir; + vec3 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _BumpMap_ST; +uniform mat4 _LightMatrix0; +uniform vec4 _MainTex_ST; +uniform mat4 _Object2World; +uniform mat4 _World2Object; +uniform vec3 _WorldSpaceCameraPos; +uniform vec4 _WorldSpaceLightPos0; + +uniform vec4 unity_Scale; +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +vec3 ObjSpaceViewDir( in vec4 v ); +vec3 ObjSpaceLightDir( in vec4 v ); +v2f_surf vert_surf( in appdata_full v ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +vec3 ObjSpaceViewDir( in vec4 v ) { + vec3 objSpaceCameraPos; + objSpaceCameraPos = (( _World2Object * vec4( _WorldSpaceCameraPos.xyz , 1.00000) ).xyz * unity_Scale.w ); + return (objSpaceCameraPos - v.xyz ); +} +vec3 ObjSpaceLightDir( in vec4 v ) { + vec3 objSpaceLightPos; + objSpaceLightPos = ( _World2Object * _WorldSpaceLightPos0 ).xyz ; + return ((objSpaceLightPos.xyz * unity_Scale.w ) - v.xyz ); +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + vec3 binormal; + mat3 rotation; + PositionFog( v.vertex, o.pos, o.fog); + o.hip_pack0.xy = ((v.texcoord.xy * _MainTex_ST.xy ) + _MainTex_ST.zw ); + o.hip_pack0.zw = ((v.texcoord.xy * _BumpMap_ST.xy ) + _BumpMap_ST.zw ); + binormal = (cross( v.normal, v.tangent.xyz ) * v.tangent.w ); + rotation = mat3( v.tangent.x , binormal.x , v.normal.x , v.tangent.y , binormal.y , v.normal.y , v.tangent.z , binormal.z , v.normal.z ); + o.lightDir = ( rotation * ObjSpaceLightDir( v.vertex) ); + o.viewDir = ( rotation * ObjSpaceViewDir( v.vertex) ); + o._LightCoord = ( _LightMatrix0 * ( _Object2World * v.vertex ) ).xyz ; + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.hip_pack0); + gl_TexCoord[1] = vec4( xl_retval.viewDir, 0.0); + gl_TexCoord[2] = vec4( xl_retval.lightDir, 0.0); + gl_TexCoord[3] = vec4( xl_retval._LightCoord, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Self-Illumin_Parallax_Specular1-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Self-Illumin_Parallax_Specular1-ir.txt new file mode 100644 index 000000000..9eab39855 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Self-Illumin_Parallax_Specular1-ir.txt @@ -0,0 +1,206 @@ +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 viewDir; + vec3 lightDir; + vec3 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform vec3 _WorldSpaceCameraPos; +uniform mat4 _World2Object; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform mat4 _LightMatrix0; +uniform vec4 _BumpMap_ST; +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +vec3 ObjSpaceViewDir ( + in vec4 v +) +{ + vec3 objSpaceCameraPos; + vec4 tmpvar_1; + tmpvar_1.w = 1.0; + tmpvar_1.xyz = _WorldSpaceCameraPos.xyz.xyz; + vec3 tmpvar_2; + tmpvar_2 = ((_World2Object * tmpvar_1).xyz * unity_Scale.w); + objSpaceCameraPos = tmpvar_2; + return (objSpaceCameraPos - v.xyz); +} + +vec3 ObjSpaceLightDir ( + in vec4 v +) +{ + vec3 objSpaceLightPos; + vec3 tmpvar_1; + tmpvar_1 = (_World2Object * _WorldSpaceLightPos0).xyz; + objSpaceLightPos = tmpvar_1; + return ((objSpaceLightPos.xyz * unity_Scale.w) - v.xyz); +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + mat3 rotation; + vec3 binormal; + v2f_surf o; + PositionFog (v.vertex, o.pos, o.fog); + vec2 tmpvar_1; + tmpvar_1 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + o.hip_pack0.xy = tmpvar_1.xy.xy; + vec2 tmpvar_2; + tmpvar_2 = ((v.texcoord.xy * _BumpMap_ST.xy) + _BumpMap_ST.zw); + o.hip_pack0.zw = tmpvar_2.xxxy.zw; + vec3 tmpvar_3; + tmpvar_3 = cross (v.normal, v.tangent.xyz); + vec3 tmpvar_4; + tmpvar_4 = (tmpvar_3 * v.tangent.w); + binormal = tmpvar_4; + mat3 tmpvar_5; + float tmpvar_6; + tmpvar_6 = v.tangent.x; + tmpvar_5[0].x = tmpvar_6; + float tmpvar_7; + tmpvar_7 = binormal.x; + tmpvar_5[0].y = tmpvar_7; + float tmpvar_8; + tmpvar_8 = v.normal.x; + tmpvar_5[0].z = tmpvar_8; + float tmpvar_9; + tmpvar_9 = v.tangent.y; + tmpvar_5[1].x = tmpvar_9; + float tmpvar_10; + tmpvar_10 = binormal.y; + tmpvar_5[1].y = tmpvar_10; + float tmpvar_11; + tmpvar_11 = v.normal.y; + tmpvar_5[1].z = tmpvar_11; + float tmpvar_12; + tmpvar_12 = v.tangent.z; + tmpvar_5[2].x = tmpvar_12; + float tmpvar_13; + tmpvar_13 = binormal.z; + tmpvar_5[2].y = tmpvar_13; + float tmpvar_14; + tmpvar_14 = v.normal.z; + tmpvar_5[2].z = tmpvar_14; + mat3 tmpvar_15; + tmpvar_15 = (tmpvar_5); + rotation = (tmpvar_15); + vec3 tmpvar_16; + tmpvar_16 = ObjSpaceLightDir (v.vertex); + vec3 tmpvar_17; + tmpvar_17 = (rotation * tmpvar_16); + o.lightDir = tmpvar_17; + vec3 tmpvar_18; + tmpvar_18 = ObjSpaceViewDir (v.vertex); + vec3 tmpvar_19; + tmpvar_19 = (rotation * tmpvar_18); + o.viewDir = tmpvar_19; + vec3 tmpvar_20; + tmpvar_20 = (_LightMatrix0 * (_Object2World * v.vertex)).xyz; + o._LightCoord = tmpvar_20; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = xl_retval.fog; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_FOG = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19 = xl_retval.hip_pack0.xyzw; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[0] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21.w = 0.0; + tmpvar_21.xyz = xl_retval.viewDir.xyz; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_TexCoord[1] = tmpvar_22; + vec4 tmpvar_23; + tmpvar_23.w = 0.0; + tmpvar_23.xyz = xl_retval.lightDir.xyz; + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + gl_TexCoord[2] = tmpvar_24; + vec4 tmpvar_25; + tmpvar_25.w = 0.0; + tmpvar_25.xyz = xl_retval._LightCoord.xyz; + vec4 tmpvar_26; + tmpvar_26 = tmpvar_25; + gl_TexCoord[3] = tmpvar_26; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Self-Illumin_Parallax_Specular1-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Self-Illumin_Parallax_Specular1-out.txt new file mode 100644 index 000000000..6d4f4e204 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Self-Illumin_Parallax_Specular1-out.txt @@ -0,0 +1,52 @@ +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform vec3 _WorldSpaceCameraPos; +uniform mat4 _World2Object; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform mat4 _LightMatrix0; +uniform vec4 _BumpMap_ST; +void main () +{ + vec4 tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = (gl_ModelViewProjectionMatrix * gl_Vertex); + tmpvar_1.xy = ((gl_MultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + tmpvar_1.zw = ((gl_MultiTexCoord0.xy * _BumpMap_ST.xy) + _BumpMap_ST.zw); + vec3 tmpvar_3; + tmpvar_3 = (cross (gl_Normal, TANGENT.xyz) * TANGENT.w); + mat3 tmpvar_4; + tmpvar_4[0].x = TANGENT.x; + tmpvar_4[0].y = tmpvar_3.x; + tmpvar_4[0].z = gl_Normal.x; + tmpvar_4[1].x = TANGENT.y; + tmpvar_4[1].y = tmpvar_3.y; + tmpvar_4[1].z = gl_Normal.y; + tmpvar_4[2].x = TANGENT.z; + tmpvar_4[2].y = tmpvar_3.z; + tmpvar_4[2].z = gl_Normal.z; + vec4 tmpvar_5; + tmpvar_5.w = 1.0; + tmpvar_5.xyz = _WorldSpaceCameraPos; + gl_Position = tmpvar_2; + vec4 tmpvar_6; + tmpvar_6.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_6.x = tmpvar_2.z; + xlv_FOG = tmpvar_6; + gl_TexCoord[0] = tmpvar_1; + vec4 tmpvar_7; + tmpvar_7.w = 0.0; + tmpvar_7.xyz = (tmpvar_4 * (((_World2Object * tmpvar_5).xyz * unity_Scale.w) - gl_Vertex.xyz)); + gl_TexCoord[1] = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8.w = 0.0; + tmpvar_8.xyz = (tmpvar_4 * (((_World2Object * _WorldSpaceLightPos0).xyz * unity_Scale.w) - gl_Vertex.xyz)); + gl_TexCoord[2] = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9.w = 0.0; + tmpvar_9.xyz = (_LightMatrix0 * (_Object2World * gl_Vertex)).xyz; + gl_TexCoord[3] = tmpvar_9; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Self-Illumin_Specular1-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Self-Illumin_Specular1-in.txt new file mode 100644 index 000000000..e8f8f54b2 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Self-Illumin_Specular1-in.txt @@ -0,0 +1,63 @@ +mat3 xll_constructMat3( mat4 m) { + return mat3( vec3( m[0]), vec3( m[1]), vec3( m[2])); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_Illum; +}; +struct v2f_surf { + vec4 pos; + vec3 normal; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; + + +v2f_surf vert_surf( in appdata_full v ); +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + o.pos = ( gl_ModelViewProjectionMatrix * v.vertex ); + o.normal = ( xll_constructMat3( gl_ModelViewMatrixInverseTranspose) * v.normal ); + return o; +} +attribute vec4 TANGENT; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + gl_TexCoord[0] = vec4( xl_retval.normal, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Self-Illumin_Specular1-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Self-Illumin_Specular1-ir.txt new file mode 100644 index 000000000..50b15335d --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Self-Illumin_Specular1-ir.txt @@ -0,0 +1,104 @@ +struct v2f_surf { + vec4 pos; + vec3 normal; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +attribute vec4 TANGENT; +mat3 xll_constructMat3 ( + in mat4 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = m[0].xyz; + vec3 tmpvar_2; + tmpvar_2 = m[1].xyz; + vec3 tmpvar_3; + tmpvar_3 = m[2].xyz; + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + v2f_surf o; + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v.vertex); + o.pos = tmpvar_1; + mat3 tmpvar_2; + tmpvar_2 = (xll_constructMat3 (gl_ModelViewMatrixInverseTranspose)); + vec3 tmpvar_3; + tmpvar_3 = (tmpvar_2 * v.normal); + o.normal = tmpvar_3; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.w = 0.0; + tmpvar_17.xyz = xl_retval.normal.xyz; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + gl_TexCoord[0] = tmpvar_18; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Self-Illumin_Specular1-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Self-Illumin_Specular1-out.txt new file mode 100644 index 000000000..ec3e493bd --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Self-Illumin_Specular1-out.txt @@ -0,0 +1,13 @@ +void main () +{ + mat3 tmpvar_1; + tmpvar_1[0] = gl_ModelViewMatrixInverseTranspose[0].xyz; + tmpvar_1[1] = gl_ModelViewMatrixInverseTranspose[1].xyz; + tmpvar_1[2] = gl_ModelViewMatrixInverseTranspose[2].xyz; + gl_Position = (gl_ModelViewProjectionMatrix * gl_Vertex); + vec4 tmpvar_2; + tmpvar_2.w = 0.0; + tmpvar_2.xyz = (tmpvar_1 * gl_Normal); + gl_TexCoord[0] = tmpvar_2; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-ShowDestAlpha-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-ShowDestAlpha-in.txt new file mode 100644 index 000000000..cd75ac2ba --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-ShowDestAlpha-in.txt @@ -0,0 +1,33 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct v2f { + vec4 vertex; +}; +struct appdata_t { + vec4 vertex; +}; + +v2f vert( in appdata_t v ); +v2f vert( in appdata_t v ) { + v2f o; + o.vertex = ( gl_ModelViewProjectionMatrix * v.vertex ); + return o; +} +void main() { + v2f xl_retval; + appdata_t xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xl_retval = vert( xlt_v); + gl_Position = vec4( xl_retval.vertex); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-ShowDestAlpha-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-ShowDestAlpha-ir.txt new file mode 100644 index 000000000..d6a193652 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-ShowDestAlpha-ir.txt @@ -0,0 +1,38 @@ +struct v2f { + vec4 vertex; +}; +struct appdata_t { + vec4 vertex; +}; +v2f vert ( + in appdata_t v +) +{ + v2f o; + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v.vertex); + o.vertex = tmpvar_1; + return o; +} + +void main () +{ + appdata_t xlt_v; + v2f xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + v2f tmpvar_3; + tmpvar_3 = vert (xlt_v); + v2f tmpvar_4; + tmpvar_4 = tmpvar_3; + xl_retval = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = xl_retval.vertex.xyzw; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_5; + gl_Position = tmpvar_6; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-ShowDestAlpha-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-ShowDestAlpha-out.txt new file mode 100644 index 000000000..7f1f40e96 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-ShowDestAlpha-out.txt @@ -0,0 +1,5 @@ +void main () +{ + gl_Position = (gl_ModelViewProjectionMatrix * gl_Vertex); +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Specular-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Specular-in.txt new file mode 100644 index 000000000..ef6053569 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Specular-in.txt @@ -0,0 +1,97 @@ +mat3 xll_constructMat3( mat4 m) { + return mat3( vec3( m[0]), vec3( m[1]), vec3( m[2])); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 normal; + vec3 lightDir; + vec3 viewDir; + vec4 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform mat4 _LightMatrix0; +uniform vec4 _MainTex_ST; +uniform mat4 _Object2World; +uniform vec3 _WorldSpaceCameraPos; +uniform vec4 _WorldSpaceLightPos0; + +uniform vec4 unity_Scale; +vec3 WorldSpaceViewDir( in vec4 v ); +vec3 WorldSpaceLightDir( in vec4 v ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +v2f_surf vert_surf( in appdata_full v ); +vec3 WorldSpaceViewDir( in vec4 v ) { + return (_WorldSpaceCameraPos.xyz - ( _Object2World * v ).xyz ); +} +vec3 WorldSpaceLightDir( in vec4 v ) { + vec3 worldPos; + worldPos = ( _Object2World * v ).xyz ; + return (_WorldSpaceLightPos0.xyz - worldPos); +} +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + PositionFog( v.vertex, o.pos, o.fog); + o.hip_pack0.xy = ((v.texcoord.xy * _MainTex_ST.xy ) + _MainTex_ST.zw ); + o.normal = ( xll_constructMat3( _Object2World) * (v.normal * unity_Scale.w ) ); + o.lightDir = WorldSpaceLightDir( v.vertex); + o.viewDir = WorldSpaceViewDir( v.vertex); + o._LightCoord = ( _LightMatrix0 * ( _Object2World * v.vertex ) ); + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.hip_pack0, 0.0, 0.0); + gl_TexCoord[1] = vec4( xl_retval.normal, 0.0); + gl_TexCoord[2] = vec4( xl_retval.lightDir, 0.0); + gl_TexCoord[3] = vec4( xl_retval.viewDir, 0.0); + gl_TexCoord[4] = vec4( xl_retval._LightCoord); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Specular-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Specular-ir.txt new file mode 100644 index 000000000..d25a0fef9 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Specular-ir.txt @@ -0,0 +1,191 @@ +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 normal; + vec3 lightDir; + vec3 viewDir; + vec4 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform vec3 _WorldSpaceCameraPos; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform mat4 _LightMatrix0; +mat3 xll_constructMat3 ( + in mat4 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = m[0].xyz; + vec3 tmpvar_2; + tmpvar_2 = m[1].xyz; + vec3 tmpvar_3; + tmpvar_3 = m[2].xyz; + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +vec3 WorldSpaceViewDir ( + in vec4 v +) +{ + return (_WorldSpaceCameraPos.xyz - (_Object2World * v).xyz); +} + +vec3 WorldSpaceLightDir ( + in vec4 v +) +{ + vec3 worldPos; + vec3 tmpvar_1; + tmpvar_1 = (_Object2World * v).xyz; + worldPos = tmpvar_1; + return (_WorldSpaceLightPos0.xyz - worldPos); +} + +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + v2f_surf o; + PositionFog (v.vertex, o.pos, o.fog); + vec2 tmpvar_1; + tmpvar_1 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + o.hip_pack0 = tmpvar_1.xy.xy; + mat3 tmpvar_2; + tmpvar_2 = (xll_constructMat3 (_Object2World)); + vec3 tmpvar_3; + tmpvar_3 = (tmpvar_2 * (v.normal * unity_Scale.w)); + o.normal = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = WorldSpaceLightDir (v.vertex); + vec3 tmpvar_5; + tmpvar_5 = tmpvar_4; + o.lightDir = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = WorldSpaceViewDir (v.vertex); + vec3 tmpvar_7; + tmpvar_7 = tmpvar_6; + o.viewDir = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8 = (_LightMatrix0 * (_Object2World * v.vertex)); + o._LightCoord = tmpvar_8; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = xl_retval.fog; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_FOG = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19.zw = vec2(0.0, 0.0); + tmpvar_19.xy = xl_retval.hip_pack0.xy; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[0] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21.w = 0.0; + tmpvar_21.xyz = xl_retval.normal.xyz; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_TexCoord[1] = tmpvar_22; + vec4 tmpvar_23; + tmpvar_23.w = 0.0; + tmpvar_23.xyz = xl_retval.lightDir.xyz; + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + gl_TexCoord[2] = tmpvar_24; + vec4 tmpvar_25; + tmpvar_25.w = 0.0; + tmpvar_25.xyz = xl_retval.viewDir.xyz; + vec4 tmpvar_26; + tmpvar_26 = tmpvar_25; + gl_TexCoord[3] = tmpvar_26; + vec4 tmpvar_27; + tmpvar_27 = xl_retval._LightCoord.xyzw; + vec4 tmpvar_28; + tmpvar_28 = tmpvar_27; + gl_TexCoord[4] = tmpvar_28; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Specular-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Specular-out.txt new file mode 100644 index 000000000..427bda0ed --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Specular-out.txt @@ -0,0 +1,39 @@ +varying vec4 xlv_FOG; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform vec3 _WorldSpaceCameraPos; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform mat4 _LightMatrix0; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * gl_Vertex); + mat3 tmpvar_2; + tmpvar_2[0] = _Object2World[0].xyz; + tmpvar_2[1] = _Object2World[1].xyz; + tmpvar_2[2] = _Object2World[2].xyz; + gl_Position = tmpvar_1; + vec4 tmpvar_3; + tmpvar_3.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_3.x = tmpvar_1.z; + xlv_FOG = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4.zw = vec2(0.0, 0.0); + tmpvar_4.xy = ((gl_MultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + gl_TexCoord[0] = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5.w = 0.0; + tmpvar_5.xyz = (tmpvar_2 * (gl_Normal * unity_Scale.w)); + gl_TexCoord[1] = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6.w = 0.0; + tmpvar_6.xyz = (_WorldSpaceLightPos0.xyz - (_Object2World * gl_Vertex).xyz); + gl_TexCoord[2] = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7.w = 0.0; + tmpvar_7.xyz = (_WorldSpaceCameraPos - (_Object2World * gl_Vertex).xyz); + gl_TexCoord[3] = tmpvar_7; + gl_TexCoord[4] = (_LightMatrix0 * (_Object2World * gl_Vertex)); +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Specular1-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Specular1-in.txt new file mode 100644 index 000000000..ffc074864 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Specular1-in.txt @@ -0,0 +1,62 @@ +mat3 xll_constructMat3( mat4 m) { + return mat3( vec3( m[0]), vec3( m[1]), vec3( m[2])); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; +}; +struct v2f_surf { + vec4 pos; + vec3 normal; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; + + +v2f_surf vert_surf( in appdata_full v ); +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + o.pos = ( gl_ModelViewProjectionMatrix * v.vertex ); + o.normal = ( xll_constructMat3( gl_ModelViewMatrixInverseTranspose) * v.normal ); + return o; +} +attribute vec4 TANGENT; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + gl_TexCoord[0] = vec4( xl_retval.normal, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Specular1-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Specular1-ir.txt new file mode 100644 index 000000000..50b15335d --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Specular1-ir.txt @@ -0,0 +1,104 @@ +struct v2f_surf { + vec4 pos; + vec3 normal; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +attribute vec4 TANGENT; +mat3 xll_constructMat3 ( + in mat4 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = m[0].xyz; + vec3 tmpvar_2; + tmpvar_2 = m[1].xyz; + vec3 tmpvar_3; + tmpvar_3 = m[2].xyz; + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + v2f_surf o; + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v.vertex); + o.pos = tmpvar_1; + mat3 tmpvar_2; + tmpvar_2 = (xll_constructMat3 (gl_ModelViewMatrixInverseTranspose)); + vec3 tmpvar_3; + tmpvar_3 = (tmpvar_2 * v.normal); + o.normal = tmpvar_3; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.w = 0.0; + tmpvar_17.xyz = xl_retval.normal.xyz; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + gl_TexCoord[0] = tmpvar_18; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Specular1-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Specular1-out.txt new file mode 100644 index 000000000..ec3e493bd --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Specular1-out.txt @@ -0,0 +1,13 @@ +void main () +{ + mat3 tmpvar_1; + tmpvar_1[0] = gl_ModelViewMatrixInverseTranspose[0].xyz; + tmpvar_1[1] = gl_ModelViewMatrixInverseTranspose[1].xyz; + tmpvar_1[2] = gl_ModelViewMatrixInverseTranspose[2].xyz; + gl_Position = (gl_ModelViewProjectionMatrix * gl_Vertex); + vec4 tmpvar_2; + tmpvar_2.w = 0.0; + tmpvar_2.xyz = (tmpvar_1 * gl_Normal); + gl_TexCoord[0] = tmpvar_2; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Specular2-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Specular2-in.txt new file mode 100644 index 000000000..d531ecd7b --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Specular2-in.txt @@ -0,0 +1,86 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 hip_screen; + vec3 hip_lmapFade; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _MainTex_ST; +uniform vec4 _ProjectionParams; + + +uniform vec4 unity_LightmapFade; +uniform vec4 unity_LightmapST; +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +vec4 ComputeScreenPos( in vec4 pos ); +v2f_surf vert_surf( in appdata_full v ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +vec4 ComputeScreenPos( in vec4 pos ) { + vec4 o; + o = (pos * 0.500000); + o.xy = (vec2( o.x , (o.y * _ProjectionParams.x )) + o.w ); + o.zw = pos.zw ; + return o; +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + PositionFog( v.vertex, o.pos, o.fog); + o.hip_pack0.xy = ((v.texcoord.xy * _MainTex_ST.xy ) + _MainTex_ST.zw ); + o.hip_screen = ComputeScreenPos( o.pos); + o.hip_lmapFade.xy = ((v.texcoord1.xy * unity_LightmapST.xy ) + unity_LightmapST.zw ); + o.hip_lmapFade.z = ((( -( gl_ModelViewMatrix * v.vertex ).z ) * unity_LightmapFade.z ) + unity_LightmapFade.w ); + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.hip_pack0, 0.0, 0.0); + gl_TexCoord[1] = vec4( xl_retval.hip_screen); + gl_TexCoord[2] = vec4( xl_retval.hip_lmapFade, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Specular2-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Specular2-ir.txt new file mode 100644 index 000000000..c8752824a --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Specular2-ir.txt @@ -0,0 +1,147 @@ +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 hip_screen; + vec3 hip_lmapFade; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_LightmapST; +uniform vec4 unity_LightmapFade; +uniform vec4 _ProjectionParams; +uniform vec4 _MainTex_ST; +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +vec4 ComputeScreenPos ( + in vec4 pos +) +{ + vec4 o; + vec4 tmpvar_1; + tmpvar_1 = (pos * 0.5); + o = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2.x = o.x; + tmpvar_2.y = (o.y * _ProjectionParams.x); + vec2 tmpvar_3; + tmpvar_3 = (tmpvar_2 + o.w); + o.xy = tmpvar_3.xy.xy; + vec2 tmpvar_4; + tmpvar_4 = pos.zw; + o.zw = tmpvar_4.xxxy.zw; + return o; +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + v2f_surf o; + PositionFog (v.vertex, o.pos, o.fog); + vec2 tmpvar_1; + tmpvar_1 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + o.hip_pack0 = tmpvar_1.xy.xy; + vec4 tmpvar_2; + tmpvar_2 = ComputeScreenPos (o.pos); + vec4 tmpvar_3; + tmpvar_3 = tmpvar_2; + o.hip_screen = tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = ((v.texcoord1.xy * unity_LightmapST.xy) + unity_LightmapST.zw); + o.hip_lmapFade.xy = tmpvar_4.xy.xy; + float tmpvar_5; + tmpvar_5 = ((-((gl_ModelViewMatrix * v.vertex).z) * unity_LightmapFade.z) + unity_LightmapFade.w); + o.hip_lmapFade.z = vec3(tmpvar_5).z; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = xl_retval.fog; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_FOG = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19.zw = vec2(0.0, 0.0); + tmpvar_19.xy = xl_retval.hip_pack0.xy; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[0] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21 = xl_retval.hip_screen.xyzw; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_TexCoord[1] = tmpvar_22; + vec4 tmpvar_23; + tmpvar_23.w = 0.0; + tmpvar_23.xyz = xl_retval.hip_lmapFade.xyz; + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + gl_TexCoord[2] = tmpvar_24; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Specular2-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Specular2-out.txt new file mode 100644 index 000000000..e52b6728b --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Specular2-out.txt @@ -0,0 +1,37 @@ +varying vec4 xlv_FOG; +uniform vec4 unity_LightmapST; +uniform vec4 unity_LightmapFade; +uniform vec4 _ProjectionParams; +uniform vec4 _MainTex_ST; +void main () +{ + vec3 tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = (gl_ModelViewProjectionMatrix * gl_Vertex); + vec4 o_i0; + vec4 tmpvar_3; + tmpvar_3 = (tmpvar_2 * 0.5); + o_i0 = tmpvar_3; + vec2 tmpvar_4; + tmpvar_4.x = tmpvar_3.x; + tmpvar_4.y = (tmpvar_3.y * _ProjectionParams.x); + o_i0.xy = (tmpvar_4 + tmpvar_3.w); + o_i0.zw = tmpvar_2.zw; + tmpvar_1.xy = ((gl_MultiTexCoord1.xy * unity_LightmapST.xy) + unity_LightmapST.zw); + tmpvar_1.z = ((-((gl_ModelViewMatrix * gl_Vertex).z) * unity_LightmapFade.z) + unity_LightmapFade.w); + gl_Position = tmpvar_2; + vec4 tmpvar_5; + tmpvar_5.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_5.x = tmpvar_2.z; + xlv_FOG = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6.zw = vec2(0.0, 0.0); + tmpvar_6.xy = ((gl_MultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + gl_TexCoord[0] = tmpvar_6; + gl_TexCoord[1] = o_i0; + vec4 tmpvar_7; + tmpvar_7.w = 0.0; + tmpvar_7.xyz = tmpvar_1; + gl_TexCoord[2] = tmpvar_7; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_2UV-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_2UV-in.txt new file mode 100644 index 000000000..42b2404c9 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_2UV-in.txt @@ -0,0 +1,92 @@ +mat3 xll_constructMat3( mat4 m) { + return mat3( vec3( m[0]), vec3( m[1]), vec3( m[2])); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv2_Detail; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 normal; + vec3 lightDir; + vec4 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _Detail_ST; +uniform mat4 _LightMatrix0; +uniform vec4 _MainTex_ST; +uniform mat4 _Object2World; +uniform vec4 _WorldSpaceLightPos0; + +uniform vec4 unity_Scale; +vec3 WorldSpaceLightDir( in vec4 v ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +v2f_surf vert_surf( in appdata_full v ); +vec3 WorldSpaceLightDir( in vec4 v ) { + vec3 worldPos; + worldPos = ( _Object2World * v ).xyz ; + return (_WorldSpaceLightPos0.xyz - worldPos); +} +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + PositionFog( v.vertex, o.pos, o.fog); + o.hip_pack0.xy = ((v.texcoord.xy * _MainTex_ST.xy ) + _MainTex_ST.zw ); + o.hip_pack0.zw = ((v.texcoord1.xy * _Detail_ST.xy ) + _Detail_ST.zw ); + o.normal = ( xll_constructMat3( _Object2World) * (v.normal * unity_Scale.w ) ); + o.lightDir = WorldSpaceLightDir( v.vertex); + o._LightCoord = ( _LightMatrix0 * ( _Object2World * v.vertex ) ); + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.hip_pack0); + gl_TexCoord[1] = vec4( xl_retval.normal, 0.0); + gl_TexCoord[2] = vec4( xl_retval.lightDir, 0.0); + gl_TexCoord[3] = vec4( xl_retval._LightCoord); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_2UV-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_2UV-ir.txt new file mode 100644 index 000000000..2548683d6 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_2UV-ir.txt @@ -0,0 +1,174 @@ +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 normal; + vec3 lightDir; + vec4 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform mat4 _LightMatrix0; +uniform vec4 _Detail_ST; +mat3 xll_constructMat3 ( + in mat4 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = m[0].xyz; + vec3 tmpvar_2; + tmpvar_2 = m[1].xyz; + vec3 tmpvar_3; + tmpvar_3 = m[2].xyz; + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +vec3 WorldSpaceLightDir ( + in vec4 v +) +{ + vec3 worldPos; + vec3 tmpvar_1; + tmpvar_1 = (_Object2World * v).xyz; + worldPos = tmpvar_1; + return (_WorldSpaceLightPos0.xyz - worldPos); +} + +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + v2f_surf o; + PositionFog (v.vertex, o.pos, o.fog); + vec2 tmpvar_1; + tmpvar_1 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + o.hip_pack0.xy = tmpvar_1.xy.xy; + vec2 tmpvar_2; + tmpvar_2 = ((v.texcoord1.xy * _Detail_ST.xy) + _Detail_ST.zw); + o.hip_pack0.zw = tmpvar_2.xxxy.zw; + mat3 tmpvar_3; + tmpvar_3 = (xll_constructMat3 (_Object2World)); + vec3 tmpvar_4; + tmpvar_4 = (tmpvar_3 * (v.normal * unity_Scale.w)); + o.normal = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = WorldSpaceLightDir (v.vertex); + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + o.lightDir = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = (_LightMatrix0 * (_Object2World * v.vertex)); + o._LightCoord = tmpvar_7; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = xl_retval.fog; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_FOG = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19 = xl_retval.hip_pack0.xyzw; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[0] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21.w = 0.0; + tmpvar_21.xyz = xl_retval.normal.xyz; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_TexCoord[1] = tmpvar_22; + vec4 tmpvar_23; + tmpvar_23.w = 0.0; + tmpvar_23.xyz = xl_retval.lightDir.xyz; + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + gl_TexCoord[2] = tmpvar_24; + vec4 tmpvar_25; + tmpvar_25 = xl_retval._LightCoord.xyzw; + vec4 tmpvar_26; + tmpvar_26 = tmpvar_25; + gl_TexCoord[3] = tmpvar_26; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_2UV-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_2UV-out.txt new file mode 100644 index 000000000..0306d7504 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_2UV-out.txt @@ -0,0 +1,35 @@ +varying vec4 xlv_FOG; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform mat4 _LightMatrix0; +uniform vec4 _Detail_ST; +void main () +{ + vec4 tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = (gl_ModelViewProjectionMatrix * gl_Vertex); + tmpvar_1.xy = ((gl_MultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + tmpvar_1.zw = ((gl_MultiTexCoord1.xy * _Detail_ST.xy) + _Detail_ST.zw); + mat3 tmpvar_3; + tmpvar_3[0] = _Object2World[0].xyz; + tmpvar_3[1] = _Object2World[1].xyz; + tmpvar_3[2] = _Object2World[2].xyz; + gl_Position = tmpvar_2; + vec4 tmpvar_4; + tmpvar_4.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_4.x = tmpvar_2.z; + xlv_FOG = tmpvar_4; + gl_TexCoord[0] = tmpvar_1; + vec4 tmpvar_5; + tmpvar_5.w = 0.0; + tmpvar_5.xyz = (tmpvar_3 * (gl_Normal * unity_Scale.w)); + gl_TexCoord[1] = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6.w = 0.0; + tmpvar_6.xyz = (_WorldSpaceLightPos0.xyz - (_Object2World * gl_Vertex).xyz); + gl_TexCoord[2] = tmpvar_6; + gl_TexCoord[3] = (_LightMatrix0 * (_Object2World * gl_Vertex)); +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_2UV1-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_2UV1-in.txt new file mode 100644 index 000000000..d1cfb5fbc --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_2UV1-in.txt @@ -0,0 +1,82 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv2_Detail; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec4 hip_screen; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _Detail_ST; +uniform vec4 _MainTex_ST; +uniform vec4 _ProjectionParams; + +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +vec4 ComputeScreenPos( in vec4 pos ); +v2f_surf vert_surf( in appdata_full v ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +vec4 ComputeScreenPos( in vec4 pos ) { + vec4 o; + o = (pos * 0.500000); + o.xy = (vec2( o.x , (o.y * _ProjectionParams.x )) + o.w ); + o.zw = pos.zw ; + return o; +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + PositionFog( v.vertex, o.pos, o.fog); + o.hip_pack0.xy = ((v.texcoord.xy * _MainTex_ST.xy ) + _MainTex_ST.zw ); + o.hip_pack0.zw = ((v.texcoord1.xy * _Detail_ST.xy ) + _Detail_ST.zw ); + o.hip_screen = ComputeScreenPos( o.pos); + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.hip_pack0); + gl_TexCoord[1] = vec4( xl_retval.hip_screen); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_2UV1-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_2UV1-ir.txt new file mode 100644 index 000000000..af9d3cb0a --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_2UV1-ir.txt @@ -0,0 +1,135 @@ +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec4 hip_screen; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 _ProjectionParams; +uniform vec4 _MainTex_ST; +uniform vec4 _Detail_ST; +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +vec4 ComputeScreenPos ( + in vec4 pos +) +{ + vec4 o; + vec4 tmpvar_1; + tmpvar_1 = (pos * 0.5); + o = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2.x = o.x; + tmpvar_2.y = (o.y * _ProjectionParams.x); + vec2 tmpvar_3; + tmpvar_3 = (tmpvar_2 + o.w); + o.xy = tmpvar_3.xy.xy; + vec2 tmpvar_4; + tmpvar_4 = pos.zw; + o.zw = tmpvar_4.xxxy.zw; + return o; +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + v2f_surf o; + PositionFog (v.vertex, o.pos, o.fog); + vec2 tmpvar_1; + tmpvar_1 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + o.hip_pack0.xy = tmpvar_1.xy.xy; + vec2 tmpvar_2; + tmpvar_2 = ((v.texcoord1.xy * _Detail_ST.xy) + _Detail_ST.zw); + o.hip_pack0.zw = tmpvar_2.xxxy.zw; + vec4 tmpvar_3; + tmpvar_3 = ComputeScreenPos (o.pos); + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + o.hip_screen = tmpvar_4; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = xl_retval.fog; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_FOG = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19 = xl_retval.hip_pack0.xyzw; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[0] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21 = xl_retval.hip_screen.xyzw; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_TexCoord[1] = tmpvar_22; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_2UV1-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_2UV1-out.txt new file mode 100644 index 000000000..18a8b9afb --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_2UV1-out.txt @@ -0,0 +1,29 @@ +varying vec4 xlv_FOG; +uniform vec4 _ProjectionParams; +uniform vec4 _MainTex_ST; +uniform vec4 _Detail_ST; +void main () +{ + vec4 tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = (gl_ModelViewProjectionMatrix * gl_Vertex); + tmpvar_1.xy = ((gl_MultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + tmpvar_1.zw = ((gl_MultiTexCoord1.xy * _Detail_ST.xy) + _Detail_ST.zw); + vec4 o_i0; + vec4 tmpvar_3; + tmpvar_3 = (tmpvar_2 * 0.5); + o_i0 = tmpvar_3; + vec2 tmpvar_4; + tmpvar_4.x = tmpvar_3.x; + tmpvar_4.y = (tmpvar_3.y * _ProjectionParams.x); + o_i0.xy = (tmpvar_4 + tmpvar_3.w); + o_i0.zw = tmpvar_2.zw; + gl_Position = tmpvar_2; + vec4 tmpvar_5; + tmpvar_5.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_5.x = tmpvar_2.z; + xlv_FOG = tmpvar_5; + gl_TexCoord[0] = tmpvar_1; + gl_TexCoord[1] = o_i0; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Colored_Specular-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Colored_Specular-in.txt new file mode 100644 index 000000000..f383b7a78 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Colored_Specular-in.txt @@ -0,0 +1,108 @@ +mat3 xll_constructMat3( mat4 m) { + return mat3( vec3( m[0]), vec3( m[1]), vec3( m[2])); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct MySurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + vec3 GlossColor; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_SpecMap; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 normal; + vec3 lightDir; + vec3 viewDir; + vec4 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform mat4 _LightMatrix0; +uniform vec4 _MainTex_ST; +uniform mat4 _Object2World; +uniform vec4 _SpecMap_ST; +uniform vec3 _WorldSpaceCameraPos; +uniform vec4 _WorldSpaceLightPos0; + +uniform vec4 unity_Scale; +vec3 WorldSpaceViewDir( in vec4 v ); +vec3 WorldSpaceLightDir( in vec4 v ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +v2f_surf vert_surf( in appdata_full v ); +vec3 WorldSpaceViewDir( in vec4 v ) { + return (_WorldSpaceCameraPos.xyz - ( _Object2World * v ).xyz ); +} +vec3 WorldSpaceLightDir( in vec4 v ) { + vec3 worldPos; + worldPos = ( _Object2World * v ).xyz ; + return (_WorldSpaceLightPos0.xyz - worldPos); +} +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + PositionFog( v.vertex, o.pos, o.fog); + o.hip_pack0.xy = ((v.texcoord.xy * _MainTex_ST.xy ) + _MainTex_ST.zw ); + o.hip_pack0.zw = ((v.texcoord.xy * _SpecMap_ST.xy ) + _SpecMap_ST.zw ); + o.normal = ( xll_constructMat3( _Object2World) * (v.normal * unity_Scale.w ) ); + o.lightDir = WorldSpaceLightDir( v.vertex); + o.viewDir = WorldSpaceViewDir( v.vertex); + o._LightCoord = ( _LightMatrix0 * ( _Object2World * v.vertex ) ); + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.hip_pack0); + gl_TexCoord[1] = vec4( xl_retval.normal, 0.0); + gl_TexCoord[2] = vec4( xl_retval.lightDir, 0.0); + gl_TexCoord[3] = vec4( xl_retval.viewDir, 0.0); + gl_TexCoord[4] = vec4( xl_retval._LightCoord); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Colored_Specular-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Colored_Specular-ir.txt new file mode 100644 index 000000000..3c59b85b0 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Colored_Specular-ir.txt @@ -0,0 +1,194 @@ +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 normal; + vec3 lightDir; + vec3 viewDir; + vec4 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform vec3 _WorldSpaceCameraPos; +uniform vec4 _SpecMap_ST; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform mat4 _LightMatrix0; +mat3 xll_constructMat3 ( + in mat4 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = m[0].xyz; + vec3 tmpvar_2; + tmpvar_2 = m[1].xyz; + vec3 tmpvar_3; + tmpvar_3 = m[2].xyz; + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +vec3 WorldSpaceViewDir ( + in vec4 v +) +{ + return (_WorldSpaceCameraPos.xyz - (_Object2World * v).xyz); +} + +vec3 WorldSpaceLightDir ( + in vec4 v +) +{ + vec3 worldPos; + vec3 tmpvar_1; + tmpvar_1 = (_Object2World * v).xyz; + worldPos = tmpvar_1; + return (_WorldSpaceLightPos0.xyz - worldPos); +} + +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + v2f_surf o; + PositionFog (v.vertex, o.pos, o.fog); + vec2 tmpvar_1; + tmpvar_1 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + o.hip_pack0.xy = tmpvar_1.xy.xy; + vec2 tmpvar_2; + tmpvar_2 = ((v.texcoord.xy * _SpecMap_ST.xy) + _SpecMap_ST.zw); + o.hip_pack0.zw = tmpvar_2.xxxy.zw; + mat3 tmpvar_3; + tmpvar_3 = (xll_constructMat3 (_Object2World)); + vec3 tmpvar_4; + tmpvar_4 = (tmpvar_3 * (v.normal * unity_Scale.w)); + o.normal = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = WorldSpaceLightDir (v.vertex); + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + o.lightDir = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = WorldSpaceViewDir (v.vertex); + vec3 tmpvar_8; + tmpvar_8 = tmpvar_7; + o.viewDir = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = (_LightMatrix0 * (_Object2World * v.vertex)); + o._LightCoord = tmpvar_9; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = xl_retval.fog; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_FOG = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19 = xl_retval.hip_pack0.xyzw; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[0] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21.w = 0.0; + tmpvar_21.xyz = xl_retval.normal.xyz; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_TexCoord[1] = tmpvar_22; + vec4 tmpvar_23; + tmpvar_23.w = 0.0; + tmpvar_23.xyz = xl_retval.lightDir.xyz; + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + gl_TexCoord[2] = tmpvar_24; + vec4 tmpvar_25; + tmpvar_25.w = 0.0; + tmpvar_25.xyz = xl_retval.viewDir.xyz; + vec4 tmpvar_26; + tmpvar_26 = tmpvar_25; + gl_TexCoord[3] = tmpvar_26; + vec4 tmpvar_27; + tmpvar_27 = xl_retval._LightCoord.xyzw; + vec4 tmpvar_28; + tmpvar_28 = tmpvar_27; + gl_TexCoord[4] = tmpvar_28; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Colored_Specular-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Colored_Specular-out.txt new file mode 100644 index 000000000..7f21e8bfb --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Colored_Specular-out.txt @@ -0,0 +1,40 @@ +varying vec4 xlv_FOG; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform vec3 _WorldSpaceCameraPos; +uniform vec4 _SpecMap_ST; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform mat4 _LightMatrix0; +void main () +{ + vec4 tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = (gl_ModelViewProjectionMatrix * gl_Vertex); + tmpvar_1.xy = ((gl_MultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + tmpvar_1.zw = ((gl_MultiTexCoord0.xy * _SpecMap_ST.xy) + _SpecMap_ST.zw); + mat3 tmpvar_3; + tmpvar_3[0] = _Object2World[0].xyz; + tmpvar_3[1] = _Object2World[1].xyz; + tmpvar_3[2] = _Object2World[2].xyz; + gl_Position = tmpvar_2; + vec4 tmpvar_4; + tmpvar_4.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_4.x = tmpvar_2.z; + xlv_FOG = tmpvar_4; + gl_TexCoord[0] = tmpvar_1; + vec4 tmpvar_5; + tmpvar_5.w = 0.0; + tmpvar_5.xyz = (tmpvar_3 * (gl_Normal * unity_Scale.w)); + gl_TexCoord[1] = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6.w = 0.0; + tmpvar_6.xyz = (_WorldSpaceLightPos0.xyz - (_Object2World * gl_Vertex).xyz); + gl_TexCoord[2] = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7.w = 0.0; + tmpvar_7.xyz = (_WorldSpaceCameraPos - (_Object2World * gl_Vertex).xyz); + gl_TexCoord[3] = tmpvar_7; + gl_TexCoord[4] = (_LightMatrix0 * (_Object2World * gl_Vertex)); +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Colored_Specular1-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Colored_Specular1-in.txt new file mode 100644 index 000000000..eae0590fe --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Colored_Specular1-in.txt @@ -0,0 +1,71 @@ +mat3 xll_constructMat3( mat4 m) { + return mat3( vec3( m[0]), vec3( m[1]), vec3( m[2])); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct MySurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + vec3 GlossColor; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_SpecMap; +}; +struct v2f_surf { + vec4 pos; + vec3 normal; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; + + +v2f_surf vert_surf( in appdata_full v ); +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + o.pos = ( gl_ModelViewProjectionMatrix * v.vertex ); + o.normal = ( xll_constructMat3( gl_ModelViewMatrixInverseTranspose) * v.normal ); + return o; +} +attribute vec4 TANGENT; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + gl_TexCoord[0] = vec4( xl_retval.normal, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Colored_Specular1-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Colored_Specular1-ir.txt new file mode 100644 index 000000000..50b15335d --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Colored_Specular1-ir.txt @@ -0,0 +1,104 @@ +struct v2f_surf { + vec4 pos; + vec3 normal; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +attribute vec4 TANGENT; +mat3 xll_constructMat3 ( + in mat4 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = m[0].xyz; + vec3 tmpvar_2; + tmpvar_2 = m[1].xyz; + vec3 tmpvar_3; + tmpvar_3 = m[2].xyz; + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + v2f_surf o; + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v.vertex); + o.pos = tmpvar_1; + mat3 tmpvar_2; + tmpvar_2 = (xll_constructMat3 (gl_ModelViewMatrixInverseTranspose)); + vec3 tmpvar_3; + tmpvar_3 = (tmpvar_2 * v.normal); + o.normal = tmpvar_3; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.w = 0.0; + tmpvar_17.xyz = xl_retval.normal.xyz; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + gl_TexCoord[0] = tmpvar_18; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Colored_Specular1-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Colored_Specular1-out.txt new file mode 100644 index 000000000..ec3e493bd --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Colored_Specular1-out.txt @@ -0,0 +1,13 @@ +void main () +{ + mat3 tmpvar_1; + tmpvar_1[0] = gl_ModelViewMatrixInverseTranspose[0].xyz; + tmpvar_1[1] = gl_ModelViewMatrixInverseTranspose[1].xyz; + tmpvar_1[2] = gl_ModelViewMatrixInverseTranspose[2].xyz; + gl_Position = (gl_ModelViewProjectionMatrix * gl_Vertex); + vec4 tmpvar_2; + tmpvar_2.w = 0.0; + tmpvar_2.xyz = (tmpvar_1 * gl_Normal); + gl_TexCoord[0] = tmpvar_2; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Custom_Data-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Custom_Data-in.txt new file mode 100644 index 000000000..971e9284d --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Custom_Data-in.txt @@ -0,0 +1,94 @@ +mat3 xll_constructMat3( mat4 m) { + return mat3( vec3( m[0]), vec3( m[1]), vec3( m[2])); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +struct Input { + vec3 foo; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec3 cust_foo; + vec3 normal; + vec3 lightDir; + vec3 _LightCoord; +}; +uniform mat4 _LightMatrix0; +uniform mat4 _Object2World; +uniform vec4 _WorldSpaceLightPos0; + +uniform vec4 unity_Scale; +void vert( inout appdata_full v, out Input o ); +vec3 WorldSpaceLightDir( in vec4 v ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +v2f_surf vert_surf( in appdata_full v ); +void vert( inout appdata_full v, out Input o ) { + o.foo = ((v.normal * 0.500000) + 0.500000); +} +vec3 WorldSpaceLightDir( in vec4 v ) { + vec3 worldPos; + worldPos = ( _Object2World * v ).xyz ; + return (_WorldSpaceLightPos0.xyz - worldPos); +} +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +v2f_surf vert_surf( in appdata_full v ) { + Input customInputData; + v2f_surf o; + vert( v, customInputData); + o.cust_foo = customInputData.foo; + PositionFog( v.vertex, o.pos, o.fog); + o.normal = ( xll_constructMat3( _Object2World) * (v.normal * unity_Scale.w ) ); + o.lightDir = WorldSpaceLightDir( v.vertex); + o._LightCoord = ( _LightMatrix0 * ( _Object2World * v.vertex ) ).xyz ; + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.cust_foo, 0.0); + gl_TexCoord[1] = vec4( xl_retval.normal, 0.0); + gl_TexCoord[2] = vec4( xl_retval.lightDir, 0.0); + gl_TexCoord[3] = vec4( xl_retval._LightCoord, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Custom_Data-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Custom_Data-ir.txt new file mode 100644 index 000000000..bda6a6ce9 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Custom_Data-ir.txt @@ -0,0 +1,186 @@ +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +struct Input { + vec3 foo; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec3 cust_foo; + vec3 normal; + vec3 lightDir; + vec3 _LightCoord; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform mat4 _Object2World; +uniform mat4 _LightMatrix0; +mat3 xll_constructMat3 ( + in mat4 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = m[0].xyz; + vec3 tmpvar_2; + tmpvar_2 = m[1].xyz; + vec3 tmpvar_3; + tmpvar_3 = m[2].xyz; + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +void vert ( + inout appdata_full v, + out Input o +) +{ + vec3 tmpvar_1; + tmpvar_1 = ((v.normal * 0.5) + 0.5); + o.foo = tmpvar_1; +} + +vec3 WorldSpaceLightDir ( + in vec4 v +) +{ + vec3 worldPos; + vec3 tmpvar_1; + tmpvar_1 = (_Object2World * v).xyz; + worldPos = tmpvar_1; + return (_WorldSpaceLightPos0.xyz - worldPos); +} + +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + v2f_surf o; + Input customInputData; + vert (v, customInputData); + vec3 tmpvar_1; + tmpvar_1 = customInputData.foo; + o.cust_foo = tmpvar_1; + PositionFog (v.vertex, o.pos, o.fog); + mat3 tmpvar_2; + tmpvar_2 = (xll_constructMat3 (_Object2World)); + vec3 tmpvar_3; + tmpvar_3 = (tmpvar_2 * (v.normal * unity_Scale.w)); + o.normal = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = WorldSpaceLightDir (v.vertex); + vec3 tmpvar_5; + tmpvar_5 = tmpvar_4; + o.lightDir = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = (_LightMatrix0 * (_Object2World * v.vertex)).xyz; + o._LightCoord = tmpvar_6; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = xl_retval.fog; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_FOG = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19.w = 0.0; + tmpvar_19.xyz = xl_retval.cust_foo.xyz; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[0] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21.w = 0.0; + tmpvar_21.xyz = xl_retval.normal.xyz; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_TexCoord[1] = tmpvar_22; + vec4 tmpvar_23; + tmpvar_23.w = 0.0; + tmpvar_23.xyz = xl_retval.lightDir.xyz; + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + gl_TexCoord[2] = tmpvar_24; + vec4 tmpvar_25; + tmpvar_25.w = 0.0; + tmpvar_25.xyz = xl_retval._LightCoord.xyz; + vec4 tmpvar_26; + tmpvar_26 = tmpvar_25; + gl_TexCoord[3] = tmpvar_26; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Custom_Data-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Custom_Data-out.txt new file mode 100644 index 000000000..472e62fd4 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Custom_Data-out.txt @@ -0,0 +1,36 @@ +varying vec4 xlv_FOG; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform mat4 _Object2World; +uniform mat4 _LightMatrix0; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * gl_Vertex); + mat3 tmpvar_2; + tmpvar_2[0] = _Object2World[0].xyz; + tmpvar_2[1] = _Object2World[1].xyz; + tmpvar_2[2] = _Object2World[2].xyz; + gl_Position = tmpvar_1; + vec4 tmpvar_3; + tmpvar_3.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_3.x = tmpvar_1.z; + xlv_FOG = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4.w = 0.0; + tmpvar_4.xyz = ((gl_Normal * 0.5) + 0.5); + gl_TexCoord[0] = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5.w = 0.0; + tmpvar_5.xyz = (tmpvar_2 * (gl_Normal * unity_Scale.w)); + gl_TexCoord[1] = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6.w = 0.0; + tmpvar_6.xyz = (_WorldSpaceLightPos0.xyz - (_Object2World * gl_Vertex).xyz); + gl_TexCoord[2] = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7.w = 0.0; + tmpvar_7.xyz = (_LightMatrix0 * (_Object2World * gl_Vertex)).xyz; + gl_TexCoord[3] = tmpvar_7; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Custom_Data1-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Custom_Data1-in.txt new file mode 100644 index 000000000..fcf53d9eb --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Custom_Data1-in.txt @@ -0,0 +1,94 @@ +mat3 xll_constructMat3( mat4 m) { + return mat3( vec3( m[0]), vec3( m[1]), vec3( m[2])); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +struct Input { + vec3 foo; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec3 cust_foo; + vec3 normal; + vec3 lightDir; + vec2 _LightCoord; +}; +uniform mat4 _LightMatrix0; +uniform mat4 _Object2World; +uniform vec4 _WorldSpaceLightPos0; + +uniform vec4 unity_Scale; +void vert( inout appdata_full v, out Input o ); +vec3 WorldSpaceLightDir( in vec4 v ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +v2f_surf vert_surf( in appdata_full v ); +void vert( inout appdata_full v, out Input o ) { + o.foo = ((v.normal * 0.500000) + 0.500000); +} +vec3 WorldSpaceLightDir( in vec4 v ) { + vec3 worldPos; + worldPos = ( _Object2World * v ).xyz ; + return _WorldSpaceLightPos0.xyz ; +} +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +v2f_surf vert_surf( in appdata_full v ) { + Input customInputData; + v2f_surf o; + vert( v, customInputData); + o.cust_foo = customInputData.foo; + PositionFog( v.vertex, o.pos, o.fog); + o.normal = ( xll_constructMat3( _Object2World) * (v.normal * unity_Scale.w ) ); + o.lightDir = WorldSpaceLightDir( v.vertex); + o._LightCoord = ( _LightMatrix0 * ( _Object2World * v.vertex ) ).xy ; + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.cust_foo, 0.0); + gl_TexCoord[1] = vec4( xl_retval.normal, 0.0); + gl_TexCoord[2] = vec4( xl_retval.lightDir, 0.0); + gl_TexCoord[3] = vec4( xl_retval._LightCoord, 0.0, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Custom_Data1-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Custom_Data1-ir.txt new file mode 100644 index 000000000..d4167aa67 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Custom_Data1-ir.txt @@ -0,0 +1,186 @@ +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +struct Input { + vec3 foo; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec3 cust_foo; + vec3 normal; + vec3 lightDir; + vec2 _LightCoord; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform mat4 _Object2World; +uniform mat4 _LightMatrix0; +mat3 xll_constructMat3 ( + in mat4 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = m[0].xyz; + vec3 tmpvar_2; + tmpvar_2 = m[1].xyz; + vec3 tmpvar_3; + tmpvar_3 = m[2].xyz; + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +void vert ( + inout appdata_full v, + out Input o +) +{ + vec3 tmpvar_1; + tmpvar_1 = ((v.normal * 0.5) + 0.5); + o.foo = tmpvar_1; +} + +vec3 WorldSpaceLightDir ( + in vec4 v +) +{ + vec3 worldPos; + vec3 tmpvar_1; + tmpvar_1 = (_Object2World * v).xyz; + worldPos = tmpvar_1; + return _WorldSpaceLightPos0.xyz; +} + +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + v2f_surf o; + Input customInputData; + vert (v, customInputData); + vec3 tmpvar_1; + tmpvar_1 = customInputData.foo; + o.cust_foo = tmpvar_1; + PositionFog (v.vertex, o.pos, o.fog); + mat3 tmpvar_2; + tmpvar_2 = (xll_constructMat3 (_Object2World)); + vec3 tmpvar_3; + tmpvar_3 = (tmpvar_2 * (v.normal * unity_Scale.w)); + o.normal = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = WorldSpaceLightDir (v.vertex); + vec3 tmpvar_5; + tmpvar_5 = tmpvar_4; + o.lightDir = tmpvar_5; + vec2 tmpvar_6; + tmpvar_6 = (_LightMatrix0 * (_Object2World * v.vertex)).xy; + o._LightCoord = tmpvar_6; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = xl_retval.fog; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_FOG = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19.w = 0.0; + tmpvar_19.xyz = xl_retval.cust_foo.xyz; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[0] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21.w = 0.0; + tmpvar_21.xyz = xl_retval.normal.xyz; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_TexCoord[1] = tmpvar_22; + vec4 tmpvar_23; + tmpvar_23.w = 0.0; + tmpvar_23.xyz = xl_retval.lightDir.xyz; + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + gl_TexCoord[2] = tmpvar_24; + vec4 tmpvar_25; + tmpvar_25.zw = vec2(0.0, 0.0); + tmpvar_25.xy = xl_retval._LightCoord.xy; + vec4 tmpvar_26; + tmpvar_26 = tmpvar_25; + gl_TexCoord[3] = tmpvar_26; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Custom_Data1-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Custom_Data1-out.txt new file mode 100644 index 000000000..9bd361ecd --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Custom_Data1-out.txt @@ -0,0 +1,36 @@ +varying vec4 xlv_FOG; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform mat4 _Object2World; +uniform mat4 _LightMatrix0; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * gl_Vertex); + mat3 tmpvar_2; + tmpvar_2[0] = _Object2World[0].xyz; + tmpvar_2[1] = _Object2World[1].xyz; + tmpvar_2[2] = _Object2World[2].xyz; + gl_Position = tmpvar_1; + vec4 tmpvar_3; + tmpvar_3.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_3.x = tmpvar_1.z; + xlv_FOG = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4.w = 0.0; + tmpvar_4.xyz = ((gl_Normal * 0.5) + 0.5); + gl_TexCoord[0] = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5.w = 0.0; + tmpvar_5.xyz = (tmpvar_2 * (gl_Normal * unity_Scale.w)); + gl_TexCoord[1] = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6.w = 0.0; + tmpvar_6.xyz = _WorldSpaceLightPos0.xyz; + gl_TexCoord[2] = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7.zw = vec2(0.0, 0.0); + tmpvar_7.xy = (_LightMatrix0 * (_Object2World * gl_Vertex)).xy; + gl_TexCoord[3] = tmpvar_7; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Custom_Data2-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Custom_Data2-in.txt new file mode 100644 index 000000000..d160fef85 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Custom_Data2-in.txt @@ -0,0 +1,91 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +struct Input { + vec3 foo; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec3 cust_foo; + vec4 hip_screen; + vec3 hip_lmapFade; +}; +uniform vec4 _ProjectionParams; + + +uniform vec4 unity_LightmapFade; +uniform vec4 unity_LightmapST; +void vert( inout appdata_full v, out Input o ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +vec4 ComputeScreenPos( in vec4 pos ); +v2f_surf vert_surf( in appdata_full v ); +void vert( inout appdata_full v, out Input o ) { + o.foo = ((v.normal * 0.500000) + 0.500000); +} +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +vec4 ComputeScreenPos( in vec4 pos ) { + vec4 o; + o = (pos * 0.500000); + o.xy = (vec2( o.x , (o.y * _ProjectionParams.x )) + o.w ); + o.zw = pos.zw ; + return o; +} +v2f_surf vert_surf( in appdata_full v ) { + Input customInputData; + v2f_surf o; + vert( v, customInputData); + o.cust_foo = customInputData.foo; + PositionFog( v.vertex, o.pos, o.fog); + o.hip_screen = ComputeScreenPos( o.pos); + o.hip_lmapFade.xy = ((v.texcoord1.xy * unity_LightmapST.xy ) + unity_LightmapST.zw ); + o.hip_lmapFade.z = ((( -( gl_ModelViewMatrix * v.vertex ).z ) * unity_LightmapFade.z ) + unity_LightmapFade.w ); + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.cust_foo, 0.0); + gl_TexCoord[1] = vec4( xl_retval.hip_screen); + gl_TexCoord[2] = vec4( xl_retval.hip_lmapFade, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Custom_Data2-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Custom_Data2-ir.txt new file mode 100644 index 000000000..06225cf7b --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Custom_Data2-ir.txt @@ -0,0 +1,161 @@ +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +struct Input { + vec3 foo; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec3 cust_foo; + vec4 hip_screen; + vec3 hip_lmapFade; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_LightmapST; +uniform vec4 unity_LightmapFade; +uniform vec4 _ProjectionParams; +void vert ( + inout appdata_full v, + out Input o +) +{ + vec3 tmpvar_1; + tmpvar_1 = ((v.normal * 0.5) + 0.5); + o.foo = tmpvar_1; +} + +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +vec4 ComputeScreenPos ( + in vec4 pos +) +{ + vec4 o; + vec4 tmpvar_1; + tmpvar_1 = (pos * 0.5); + o = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2.x = o.x; + tmpvar_2.y = (o.y * _ProjectionParams.x); + vec2 tmpvar_3; + tmpvar_3 = (tmpvar_2 + o.w); + o.xy = tmpvar_3.xy.xy; + vec2 tmpvar_4; + tmpvar_4 = pos.zw; + o.zw = tmpvar_4.xxxy.zw; + return o; +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + v2f_surf o; + Input customInputData; + vert (v, customInputData); + vec3 tmpvar_1; + tmpvar_1 = customInputData.foo; + o.cust_foo = tmpvar_1; + PositionFog (v.vertex, o.pos, o.fog); + vec4 tmpvar_2; + tmpvar_2 = ComputeScreenPos (o.pos); + vec4 tmpvar_3; + tmpvar_3 = tmpvar_2; + o.hip_screen = tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = ((v.texcoord1.xy * unity_LightmapST.xy) + unity_LightmapST.zw); + o.hip_lmapFade.xy = tmpvar_4.xy.xy; + float tmpvar_5; + tmpvar_5 = ((-((gl_ModelViewMatrix * v.vertex).z) * unity_LightmapFade.z) + unity_LightmapFade.w); + o.hip_lmapFade.z = vec3(tmpvar_5).z; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = xl_retval.fog; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_FOG = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19.w = 0.0; + tmpvar_19.xyz = xl_retval.cust_foo.xyz; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[0] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21 = xl_retval.hip_screen.xyzw; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_TexCoord[1] = tmpvar_22; + vec4 tmpvar_23; + tmpvar_23.w = 0.0; + tmpvar_23.xyz = xl_retval.hip_lmapFade.xyz; + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + gl_TexCoord[2] = tmpvar_24; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Custom_Data2-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Custom_Data2-out.txt new file mode 100644 index 000000000..bf5329555 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Custom_Data2-out.txt @@ -0,0 +1,36 @@ +varying vec4 xlv_FOG; +uniform vec4 unity_LightmapST; +uniform vec4 unity_LightmapFade; +uniform vec4 _ProjectionParams; +void main () +{ + vec3 tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = (gl_ModelViewProjectionMatrix * gl_Vertex); + vec4 o_i0_i1; + vec4 tmpvar_3; + tmpvar_3 = (tmpvar_2 * 0.5); + o_i0_i1 = tmpvar_3; + vec2 tmpvar_4; + tmpvar_4.x = tmpvar_3.x; + tmpvar_4.y = (tmpvar_3.y * _ProjectionParams.x); + o_i0_i1.xy = (tmpvar_4 + tmpvar_3.w); + o_i0_i1.zw = tmpvar_2.zw; + tmpvar_1.xy = ((gl_MultiTexCoord1.xy * unity_LightmapST.xy) + unity_LightmapST.zw); + tmpvar_1.z = ((-((gl_ModelViewMatrix * gl_Vertex).z) * unity_LightmapFade.z) + unity_LightmapFade.w); + gl_Position = tmpvar_2; + vec4 tmpvar_5; + tmpvar_5.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_5.x = tmpvar_2.z; + xlv_FOG = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6.w = 0.0; + tmpvar_6.xyz = ((gl_Normal * 0.5) + 0.5); + gl_TexCoord[0] = tmpvar_6; + gl_TexCoord[1] = o_i0_i1; + vec4 tmpvar_7; + tmpvar_7.w = 0.0; + tmpvar_7.xyz = tmpvar_1; + gl_TexCoord[2] = tmpvar_7; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_DecalAddBump-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_DecalAddBump-in.txt new file mode 100644 index 000000000..8028af06d --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_DecalAddBump-in.txt @@ -0,0 +1,85 @@ +mat3 xll_constructMat3( mat4 m) { + return mat3( vec3( m[0]), vec3( m[1]), vec3( m[2])); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 normal; + vec3 lightDir; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _MainTex_ST; +uniform mat4 _Object2World; +uniform vec4 _WorldSpaceLightPos0; + +uniform vec4 unity_Scale; +vec3 WorldSpaceLightDir( in vec4 v ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +v2f_surf vert_surf( in appdata_full v ); +vec3 WorldSpaceLightDir( in vec4 v ) { + vec3 worldPos; + worldPos = ( _Object2World * v ).xyz ; + return _WorldSpaceLightPos0.xyz ; +} +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + PositionFog( v.vertex, o.pos, o.fog); + o.hip_pack0.xy = ((v.texcoord.xy * _MainTex_ST.xy ) + _MainTex_ST.zw ); + o.normal = ( xll_constructMat3( _Object2World) * (v.normal * unity_Scale.w ) ); + o.lightDir = WorldSpaceLightDir( v.vertex); + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.hip_pack0, 0.0, 0.0); + gl_TexCoord[1] = vec4( xl_retval.normal, 0.0); + gl_TexCoord[2] = vec4( xl_retval.lightDir, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_DecalAddBump-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_DecalAddBump-ir.txt new file mode 100644 index 000000000..f031a9d94 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_DecalAddBump-ir.txt @@ -0,0 +1,161 @@ +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 normal; + vec3 lightDir; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +mat3 xll_constructMat3 ( + in mat4 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = m[0].xyz; + vec3 tmpvar_2; + tmpvar_2 = m[1].xyz; + vec3 tmpvar_3; + tmpvar_3 = m[2].xyz; + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +vec3 WorldSpaceLightDir ( + in vec4 v +) +{ + vec3 worldPos; + vec3 tmpvar_1; + tmpvar_1 = (_Object2World * v).xyz; + worldPos = tmpvar_1; + return _WorldSpaceLightPos0.xyz; +} + +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + v2f_surf o; + PositionFog (v.vertex, o.pos, o.fog); + vec2 tmpvar_1; + tmpvar_1 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + o.hip_pack0 = tmpvar_1.xy.xy; + mat3 tmpvar_2; + tmpvar_2 = (xll_constructMat3 (_Object2World)); + vec3 tmpvar_3; + tmpvar_3 = (tmpvar_2 * (v.normal * unity_Scale.w)); + o.normal = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = WorldSpaceLightDir (v.vertex); + vec3 tmpvar_5; + tmpvar_5 = tmpvar_4; + o.lightDir = tmpvar_5; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = xl_retval.fog; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_FOG = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19.zw = vec2(0.0, 0.0); + tmpvar_19.xy = xl_retval.hip_pack0.xy; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[0] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21.w = 0.0; + tmpvar_21.xyz = xl_retval.normal.xyz; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_TexCoord[1] = tmpvar_22; + vec4 tmpvar_23; + tmpvar_23.w = 0.0; + tmpvar_23.xyz = xl_retval.lightDir.xyz; + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + gl_TexCoord[2] = tmpvar_24; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_DecalAddBump-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_DecalAddBump-out.txt new file mode 100644 index 000000000..5fe3954f3 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_DecalAddBump-out.txt @@ -0,0 +1,32 @@ +varying vec4 xlv_FOG; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * gl_Vertex); + mat3 tmpvar_2; + tmpvar_2[0] = _Object2World[0].xyz; + tmpvar_2[1] = _Object2World[1].xyz; + tmpvar_2[2] = _Object2World[2].xyz; + gl_Position = tmpvar_1; + vec4 tmpvar_3; + tmpvar_3.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_3.x = tmpvar_1.z; + xlv_FOG = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4.zw = vec2(0.0, 0.0); + tmpvar_4.xy = ((gl_MultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + gl_TexCoord[0] = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5.w = 0.0; + tmpvar_5.xyz = (tmpvar_2 * (gl_Normal * unity_Scale.w)); + gl_TexCoord[1] = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6.w = 0.0; + tmpvar_6.xyz = _WorldSpaceLightPos0.xyz; + gl_TexCoord[2] = tmpvar_6; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_DecalAddBump1-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_DecalAddBump1-in.txt new file mode 100644 index 000000000..26aa0c43e --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_DecalAddBump1-in.txt @@ -0,0 +1,79 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 hip_screen; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _MainTex_ST; +uniform vec4 _ProjectionParams; + +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +vec4 ComputeScreenPos( in vec4 pos ); +v2f_surf vert_surf( in appdata_full v ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +vec4 ComputeScreenPos( in vec4 pos ) { + vec4 o; + o = (pos * 0.500000); + o.xy = (vec2( o.x , (o.y * _ProjectionParams.x )) + o.w ); + o.zw = pos.zw ; + return o; +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + PositionFog( v.vertex, o.pos, o.fog); + o.hip_pack0.xy = ((v.texcoord.xy * _MainTex_ST.xy ) + _MainTex_ST.zw ); + o.hip_screen = ComputeScreenPos( o.pos); + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.hip_pack0, 0.0, 0.0); + gl_TexCoord[1] = vec4( xl_retval.hip_screen); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_DecalAddBump1-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_DecalAddBump1-ir.txt new file mode 100644 index 000000000..6b7ae345b --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_DecalAddBump1-ir.txt @@ -0,0 +1,132 @@ +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 hip_screen; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 _ProjectionParams; +uniform vec4 _MainTex_ST; +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +vec4 ComputeScreenPos ( + in vec4 pos +) +{ + vec4 o; + vec4 tmpvar_1; + tmpvar_1 = (pos * 0.5); + o = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2.x = o.x; + tmpvar_2.y = (o.y * _ProjectionParams.x); + vec2 tmpvar_3; + tmpvar_3 = (tmpvar_2 + o.w); + o.xy = tmpvar_3.xy.xy; + vec2 tmpvar_4; + tmpvar_4 = pos.zw; + o.zw = tmpvar_4.xxxy.zw; + return o; +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + v2f_surf o; + PositionFog (v.vertex, o.pos, o.fog); + vec2 tmpvar_1; + tmpvar_1 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + o.hip_pack0 = tmpvar_1.xy.xy; + vec4 tmpvar_2; + tmpvar_2 = ComputeScreenPos (o.pos); + vec4 tmpvar_3; + tmpvar_3 = tmpvar_2; + o.hip_screen = tmpvar_3; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = xl_retval.fog; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_FOG = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19.zw = vec2(0.0, 0.0); + tmpvar_19.xy = xl_retval.hip_pack0.xy; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[0] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21 = xl_retval.hip_screen.xyzw; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_TexCoord[1] = tmpvar_22; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_DecalAddBump1-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_DecalAddBump1-out.txt new file mode 100644 index 000000000..2f3f8d3dc --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_DecalAddBump1-out.txt @@ -0,0 +1,28 @@ +varying vec4 xlv_FOG; +uniform vec4 _ProjectionParams; +uniform vec4 _MainTex_ST; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * gl_Vertex); + vec4 o_i0; + vec4 tmpvar_2; + tmpvar_2 = (tmpvar_1 * 0.5); + o_i0 = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3.x = tmpvar_2.x; + tmpvar_3.y = (tmpvar_2.y * _ProjectionParams.x); + o_i0.xy = (tmpvar_3 + tmpvar_2.w); + o_i0.zw = tmpvar_1.zw; + gl_Position = tmpvar_1; + vec4 tmpvar_4; + tmpvar_4.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_4.x = tmpvar_1.z; + xlv_FOG = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5.zw = vec2(0.0, 0.0); + tmpvar_5.xy = ((gl_MultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + gl_TexCoord[0] = tmpvar_5; + gl_TexCoord[1] = o_i0; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_DecalAddBump2-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_DecalAddBump2-in.txt new file mode 100644 index 000000000..f35df46d1 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_DecalAddBump2-in.txt @@ -0,0 +1,85 @@ +mat3 xll_constructMat3( mat4 m) { + return mat3( vec3( m[0]), vec3( m[1]), vec3( m[2])); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_Decal; + vec2 uv_DecalBump; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec2 hip_lmap; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _DecalBump_ST; +uniform vec4 _Decal_ST; +uniform mat4 _Object2World; + +uniform vec4 unity_LightmapST; +uniform vec4 unity_Scale; +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +v2f_surf vert_surf( in appdata_full v ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + vec3 worldN; + vec3 binormal; + mat3 rotation; + PositionFog( v.vertex, o.pos, o.fog); + o.hip_pack0.xy = ((v.texcoord.xy * _Decal_ST.xy ) + _Decal_ST.zw ); + o.hip_pack0.zw = ((v.texcoord.xy * _DecalBump_ST.xy ) + _DecalBump_ST.zw ); + o.hip_lmap.xy = ((v.texcoord1.xy * unity_LightmapST.xy ) + unity_LightmapST.zw ); + worldN = ( xll_constructMat3( _Object2World) * (v.normal * unity_Scale.w ) ); + binormal = (cross( v.normal, v.tangent.xyz ) * v.tangent.w ); + rotation = mat3( v.tangent.x , binormal.x , v.normal.x , v.tangent.y , binormal.y , v.normal.y , v.tangent.z , binormal.z , v.normal.z ); + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.hip_pack0); + gl_TexCoord[1] = vec4( xl_retval.hip_lmap, 0.0, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_DecalAddBump2-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_DecalAddBump2-ir.txt new file mode 100644 index 000000000..f68ed4cca --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_DecalAddBump2-ir.txt @@ -0,0 +1,183 @@ +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec2 hip_lmap; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec4 unity_LightmapST; +uniform mat4 _Object2World; +uniform vec4 _Decal_ST; +uniform vec4 _DecalBump_ST; +mat3 xll_constructMat3 ( + in mat4 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = m[0].xyz; + vec3 tmpvar_2; + tmpvar_2 = m[1].xyz; + vec3 tmpvar_3; + tmpvar_3 = m[2].xyz; + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + mat3 rotation; + vec3 binormal; + vec3 worldN; + v2f_surf o; + PositionFog (v.vertex, o.pos, o.fog); + vec2 tmpvar_1; + tmpvar_1 = ((v.texcoord.xy * _Decal_ST.xy) + _Decal_ST.zw); + o.hip_pack0.xy = tmpvar_1.xy.xy; + vec2 tmpvar_2; + tmpvar_2 = ((v.texcoord.xy * _DecalBump_ST.xy) + _DecalBump_ST.zw); + o.hip_pack0.zw = tmpvar_2.xxxy.zw; + vec2 tmpvar_3; + tmpvar_3 = ((v.texcoord1.xy * unity_LightmapST.xy) + unity_LightmapST.zw); + o.hip_lmap = tmpvar_3.xy.xy; + mat3 tmpvar_4; + tmpvar_4 = (xll_constructMat3 (_Object2World)); + vec3 tmpvar_5; + tmpvar_5 = (tmpvar_4 * (v.normal * unity_Scale.w)); + worldN = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = cross (v.normal, v.tangent.xyz); + vec3 tmpvar_7; + tmpvar_7 = (tmpvar_6 * v.tangent.w); + binormal = tmpvar_7; + mat3 tmpvar_8; + float tmpvar_9; + tmpvar_9 = v.tangent.x; + tmpvar_8[0].x = tmpvar_9; + float tmpvar_10; + tmpvar_10 = binormal.x; + tmpvar_8[0].y = tmpvar_10; + float tmpvar_11; + tmpvar_11 = v.normal.x; + tmpvar_8[0].z = tmpvar_11; + float tmpvar_12; + tmpvar_12 = v.tangent.y; + tmpvar_8[1].x = tmpvar_12; + float tmpvar_13; + tmpvar_13 = binormal.y; + tmpvar_8[1].y = tmpvar_13; + float tmpvar_14; + tmpvar_14 = v.normal.y; + tmpvar_8[1].z = tmpvar_14; + float tmpvar_15; + tmpvar_15 = v.tangent.z; + tmpvar_8[2].x = tmpvar_15; + float tmpvar_16; + tmpvar_16 = binormal.z; + tmpvar_8[2].y = tmpvar_16; + float tmpvar_17; + tmpvar_17 = v.normal.z; + tmpvar_8[2].z = tmpvar_17; + mat3 tmpvar_18; + tmpvar_18 = (tmpvar_8); + rotation = (tmpvar_18); + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = xl_retval.fog; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_FOG = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19 = xl_retval.hip_pack0.xyzw; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[0] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21.zw = vec2(0.0, 0.0); + tmpvar_21.xy = xl_retval.hip_lmap.xy; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_TexCoord[1] = tmpvar_22; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_DecalAddBump2-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_DecalAddBump2-out.txt new file mode 100644 index 000000000..0a63196c8 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_DecalAddBump2-out.txt @@ -0,0 +1,23 @@ +varying vec4 xlv_FOG; +uniform vec4 unity_LightmapST; +uniform vec4 _Decal_ST; +uniform vec4 _DecalBump_ST; +void main () +{ + vec4 tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = (gl_ModelViewProjectionMatrix * gl_Vertex); + tmpvar_1.xy = ((gl_MultiTexCoord0.xy * _Decal_ST.xy) + _Decal_ST.zw); + tmpvar_1.zw = ((gl_MultiTexCoord0.xy * _DecalBump_ST.xy) + _DecalBump_ST.zw); + gl_Position = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_3.x = tmpvar_2.z; + xlv_FOG = tmpvar_3; + gl_TexCoord[0] = tmpvar_1; + vec4 tmpvar_4; + tmpvar_4.zw = vec2(0.0, 0.0); + tmpvar_4.xy = ((gl_MultiTexCoord1.xy * unity_LightmapST.xy) + unity_LightmapST.zw); + gl_TexCoord[1] = tmpvar_4; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_DecalAddBump3-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_DecalAddBump3-in.txt new file mode 100644 index 000000000..5660f2d8f --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_DecalAddBump3-in.txt @@ -0,0 +1,134 @@ +mat3 xll_constructMat3( mat4 m) { + return mat3( vec3( m[0]), vec3( m[1]), vec3( m[2])); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_Decal; + vec2 uv_DecalBump; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 lightDir; + vec3 vlight; + vec4 _ShadowCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _DecalBump_ST; +uniform vec4 _Decal_ST; +uniform mat4 _Object2World; +uniform vec4 _ProjectionParams; +uniform mat4 _World2Object; +uniform vec4 _WorldSpaceLightPos0; + +uniform vec4 unity_SHAb; +uniform vec4 unity_SHAg; +uniform vec4 unity_SHAr; +uniform vec4 unity_SHBb; +uniform vec4 unity_SHBg; +uniform vec4 unity_SHBr; +uniform vec4 unity_SHC; +uniform vec4 unity_Scale; +vec3 ShadeSH9( in vec4 normal ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +vec3 ObjSpaceLightDir( in vec4 v ); +vec4 ComputeScreenPos( in vec4 pos ); +v2f_surf vert_surf( in appdata_full v ); +vec3 ShadeSH9( in vec4 normal ) { + vec3 x1; + vec4 vB; + vec3 x2; + float vC; + vec3 x3; + x1.x = dot( unity_SHAr, normal); + x1.y = dot( unity_SHAg, normal); + x1.z = dot( unity_SHAb, normal); + vB = (normal.xyzz * normal.yzzx ); + x2.x = dot( unity_SHBr, vB); + x2.y = dot( unity_SHBg, vB); + x2.z = dot( unity_SHBb, vB); + vC = ((normal.x * normal.x ) - (normal.y * normal.y )); + x3 = (unity_SHC.xyz * vC); + return ((x1 + x2) + x3); +} +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +vec3 ObjSpaceLightDir( in vec4 v ) { + vec3 objSpaceLightPos; + objSpaceLightPos = ( _World2Object * _WorldSpaceLightPos0 ).xyz ; + return objSpaceLightPos.xyz ; +} +vec4 ComputeScreenPos( in vec4 pos ) { + vec4 o; + o = (pos * 0.500000); + o.xy = (vec2( o.x , (o.y * _ProjectionParams.x )) + o.w ); + o.zw = pos.zw ; + return o; +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + vec3 worldN; + vec3 binormal; + mat3 rotation; + vec3 shlight; + PositionFog( v.vertex, o.pos, o.fog); + o.hip_pack0.xy = ((v.texcoord.xy * _Decal_ST.xy ) + _Decal_ST.zw ); + o.hip_pack0.zw = ((v.texcoord.xy * _DecalBump_ST.xy ) + _DecalBump_ST.zw ); + worldN = ( xll_constructMat3( _Object2World) * (v.normal * unity_Scale.w ) ); + binormal = (cross( v.normal, v.tangent.xyz ) * v.tangent.w ); + rotation = mat3( v.tangent.x , binormal.x , v.normal.x , v.tangent.y , binormal.y , v.normal.y , v.tangent.z , binormal.z , v.normal.z ); + o.lightDir = ( rotation * ObjSpaceLightDir( v.vertex) ); + shlight = ShadeSH9( vec4( worldN, 1.00000)); + o.vlight = shlight; + o._ShadowCoord = ComputeScreenPos( o.pos); + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.hip_pack0); + gl_TexCoord[1] = vec4( xl_retval.lightDir, 0.0); + gl_TexCoord[2] = vec4( xl_retval.vlight, 0.0); + gl_TexCoord[3] = vec4( xl_retval._ShadowCoord); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_DecalAddBump3-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_DecalAddBump3-ir.txt new file mode 100644 index 000000000..c94e9103b --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_DecalAddBump3-ir.txt @@ -0,0 +1,306 @@ +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 lightDir; + vec3 vlight; + vec4 _ShadowCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec4 unity_SHC; +uniform vec4 unity_SHBr; +uniform vec4 unity_SHBg; +uniform vec4 unity_SHBb; +uniform vec4 unity_SHAr; +uniform vec4 unity_SHAg; +uniform vec4 unity_SHAb; +uniform vec4 _WorldSpaceLightPos0; +uniform mat4 _World2Object; +uniform vec4 _ProjectionParams; +uniform mat4 _Object2World; +uniform vec4 _Decal_ST; +uniform vec4 _DecalBump_ST; +mat3 xll_constructMat3 ( + in mat4 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = m[0].xyz; + vec3 tmpvar_2; + tmpvar_2 = m[1].xyz; + vec3 tmpvar_3; + tmpvar_3 = m[2].xyz; + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +vec3 ShadeSH9 ( + in vec4 normal +) +{ + vec3 x3; + float vC; + vec3 x2; + vec4 vB; + vec3 x1; + float tmpvar_1; + tmpvar_1 = dot (unity_SHAr, normal); + float tmpvar_2; + tmpvar_2 = tmpvar_1; + x1.x = tmpvar_2; + float tmpvar_3; + tmpvar_3 = dot (unity_SHAg, normal); + float tmpvar_4; + tmpvar_4 = tmpvar_3; + x1.y = vec2(tmpvar_4).y; + float tmpvar_5; + tmpvar_5 = dot (unity_SHAb, normal); + float tmpvar_6; + tmpvar_6 = tmpvar_5; + x1.z = vec3(tmpvar_6).z; + vec4 tmpvar_7; + tmpvar_7 = (normal.xyzz * normal.yzzx); + vB = tmpvar_7; + float tmpvar_8; + tmpvar_8 = dot (unity_SHBr, vB); + float tmpvar_9; + tmpvar_9 = tmpvar_8; + x2.x = tmpvar_9; + float tmpvar_10; + tmpvar_10 = dot (unity_SHBg, vB); + float tmpvar_11; + tmpvar_11 = tmpvar_10; + x2.y = vec2(tmpvar_11).y; + float tmpvar_12; + tmpvar_12 = dot (unity_SHBb, vB); + float tmpvar_13; + tmpvar_13 = tmpvar_12; + x2.z = vec3(tmpvar_13).z; + float tmpvar_14; + tmpvar_14 = ((normal.x * normal.x) - (normal.y * normal.y)); + vC = tmpvar_14; + vec3 tmpvar_15; + tmpvar_15 = (unity_SHC.xyz * vC); + x3 = tmpvar_15; + return ((x1 + x2) + x3); +} + +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +vec3 ObjSpaceLightDir ( + in vec4 v +) +{ + vec3 objSpaceLightPos; + vec3 tmpvar_1; + tmpvar_1 = (_World2Object * _WorldSpaceLightPos0).xyz; + objSpaceLightPos = tmpvar_1; + return objSpaceLightPos.xyz; +} + +vec4 ComputeScreenPos ( + in vec4 pos +) +{ + vec4 o; + vec4 tmpvar_1; + tmpvar_1 = (pos * 0.5); + o = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2.x = o.x; + tmpvar_2.y = (o.y * _ProjectionParams.x); + vec2 tmpvar_3; + tmpvar_3 = (tmpvar_2 + o.w); + o.xy = tmpvar_3.xy.xy; + vec2 tmpvar_4; + tmpvar_4 = pos.zw; + o.zw = tmpvar_4.xxxy.zw; + return o; +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + vec3 shlight; + mat3 rotation; + vec3 binormal; + vec3 worldN; + v2f_surf o; + PositionFog (v.vertex, o.pos, o.fog); + vec2 tmpvar_1; + tmpvar_1 = ((v.texcoord.xy * _Decal_ST.xy) + _Decal_ST.zw); + o.hip_pack0.xy = tmpvar_1.xy.xy; + vec2 tmpvar_2; + tmpvar_2 = ((v.texcoord.xy * _DecalBump_ST.xy) + _DecalBump_ST.zw); + o.hip_pack0.zw = tmpvar_2.xxxy.zw; + mat3 tmpvar_3; + tmpvar_3 = (xll_constructMat3 (_Object2World)); + vec3 tmpvar_4; + tmpvar_4 = (tmpvar_3 * (v.normal * unity_Scale.w)); + worldN = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = cross (v.normal, v.tangent.xyz); + vec3 tmpvar_6; + tmpvar_6 = (tmpvar_5 * v.tangent.w); + binormal = tmpvar_6; + mat3 tmpvar_7; + float tmpvar_8; + tmpvar_8 = v.tangent.x; + tmpvar_7[0].x = tmpvar_8; + float tmpvar_9; + tmpvar_9 = binormal.x; + tmpvar_7[0].y = tmpvar_9; + float tmpvar_10; + tmpvar_10 = v.normal.x; + tmpvar_7[0].z = tmpvar_10; + float tmpvar_11; + tmpvar_11 = v.tangent.y; + tmpvar_7[1].x = tmpvar_11; + float tmpvar_12; + tmpvar_12 = binormal.y; + tmpvar_7[1].y = tmpvar_12; + float tmpvar_13; + tmpvar_13 = v.normal.y; + tmpvar_7[1].z = tmpvar_13; + float tmpvar_14; + tmpvar_14 = v.tangent.z; + tmpvar_7[2].x = tmpvar_14; + float tmpvar_15; + tmpvar_15 = binormal.z; + tmpvar_7[2].y = tmpvar_15; + float tmpvar_16; + tmpvar_16 = v.normal.z; + tmpvar_7[2].z = tmpvar_16; + mat3 tmpvar_17; + tmpvar_17 = (tmpvar_7); + rotation = (tmpvar_17); + vec3 tmpvar_18; + tmpvar_18 = ObjSpaceLightDir (v.vertex); + vec3 tmpvar_19; + tmpvar_19 = (rotation * tmpvar_18); + o.lightDir = tmpvar_19; + vec4 tmpvar_20; + tmpvar_20.w = 1.0; + tmpvar_20.xyz = worldN.xyz; + vec3 tmpvar_21; + tmpvar_21 = ShadeSH9 (tmpvar_20); + vec3 tmpvar_22; + tmpvar_22 = tmpvar_21; + shlight = tmpvar_22; + vec3 tmpvar_23; + tmpvar_23 = shlight; + o.vlight = tmpvar_23; + vec4 tmpvar_24; + tmpvar_24 = ComputeScreenPos (o.pos); + vec4 tmpvar_25; + tmpvar_25 = tmpvar_24; + o._ShadowCoord = tmpvar_25; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = xl_retval.fog; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_FOG = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19 = xl_retval.hip_pack0.xyzw; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[0] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21.w = 0.0; + tmpvar_21.xyz = xl_retval.lightDir.xyz; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_TexCoord[1] = tmpvar_22; + vec4 tmpvar_23; + tmpvar_23.w = 0.0; + tmpvar_23.xyz = xl_retval.vlight.xyz; + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + gl_TexCoord[2] = tmpvar_24; + vec4 tmpvar_25; + tmpvar_25 = xl_retval._ShadowCoord.xyzw; + vec4 tmpvar_26; + tmpvar_26 = tmpvar_25; + gl_TexCoord[3] = tmpvar_26; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_DecalAddBump3-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_DecalAddBump3-out.txt new file mode 100644 index 000000000..6a46402f0 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_DecalAddBump3-out.txt @@ -0,0 +1,80 @@ +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec4 unity_SHC; +uniform vec4 unity_SHBr; +uniform vec4 unity_SHBg; +uniform vec4 unity_SHBb; +uniform vec4 unity_SHAr; +uniform vec4 unity_SHAg; +uniform vec4 unity_SHAb; +uniform vec4 _WorldSpaceLightPos0; +uniform mat4 _World2Object; +uniform vec4 _ProjectionParams; +uniform mat4 _Object2World; +uniform vec4 _Decal_ST; +uniform vec4 _DecalBump_ST; +void main () +{ + vec4 tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = (gl_ModelViewProjectionMatrix * gl_Vertex); + tmpvar_1.xy = ((gl_MultiTexCoord0.xy * _Decal_ST.xy) + _Decal_ST.zw); + tmpvar_1.zw = ((gl_MultiTexCoord0.xy * _DecalBump_ST.xy) + _DecalBump_ST.zw); + mat3 tmpvar_3; + tmpvar_3[0] = _Object2World[0].xyz; + tmpvar_3[1] = _Object2World[1].xyz; + tmpvar_3[2] = _Object2World[2].xyz; + vec3 tmpvar_4; + tmpvar_4 = (tmpvar_3 * (gl_Normal * unity_Scale.w)); + vec3 tmpvar_5; + tmpvar_5 = (cross (gl_Normal, TANGENT.xyz) * TANGENT.w); + mat3 tmpvar_6; + tmpvar_6[0].x = TANGENT.x; + tmpvar_6[0].y = tmpvar_5.x; + tmpvar_6[0].z = gl_Normal.x; + tmpvar_6[1].x = TANGENT.y; + tmpvar_6[1].y = tmpvar_5.y; + tmpvar_6[1].z = gl_Normal.y; + tmpvar_6[2].x = TANGENT.z; + tmpvar_6[2].y = tmpvar_5.z; + tmpvar_6[2].z = gl_Normal.z; + vec4 tmpvar_7; + tmpvar_7.w = 1.0; + tmpvar_7.xyz = tmpvar_4; + vec3 x2; + vec3 x1; + x1.x = dot (unity_SHAr, tmpvar_7); + x1.y = dot (unity_SHAg, tmpvar_7); + x1.z = dot (unity_SHAb, tmpvar_7); + vec4 tmpvar_8; + tmpvar_8 = (tmpvar_4.xyzz * tmpvar_4.yzzx); + x2.x = dot (unity_SHBr, tmpvar_8); + x2.y = dot (unity_SHBg, tmpvar_8); + x2.z = dot (unity_SHBb, tmpvar_8); + vec4 o_i0; + vec4 tmpvar_9; + tmpvar_9 = (tmpvar_2 * 0.5); + o_i0 = tmpvar_9; + vec2 tmpvar_10; + tmpvar_10.x = tmpvar_9.x; + tmpvar_10.y = (tmpvar_9.y * _ProjectionParams.x); + o_i0.xy = (tmpvar_10 + tmpvar_9.w); + o_i0.zw = tmpvar_2.zw; + gl_Position = tmpvar_2; + vec4 tmpvar_11; + tmpvar_11.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_11.x = tmpvar_2.z; + xlv_FOG = tmpvar_11; + gl_TexCoord[0] = tmpvar_1; + vec4 tmpvar_12; + tmpvar_12.w = 0.0; + tmpvar_12.xyz = (tmpvar_6 * (_World2Object * _WorldSpaceLightPos0).xyz); + gl_TexCoord[1] = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13.w = 0.0; + tmpvar_13.xyz = ((x1 + x2) + (unity_SHC.xyz * ((tmpvar_4.x * tmpvar_4.x) - (tmpvar_4.y * tmpvar_4.y)))); + gl_TexCoord[2] = tmpvar_13; + gl_TexCoord[3] = o_i0; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Diffuse_Wrapped-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Diffuse_Wrapped-in.txt new file mode 100644 index 000000000..e52d6ea38 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Diffuse_Wrapped-in.txt @@ -0,0 +1,89 @@ +mat3 xll_constructMat3( mat4 m) { + return mat3( vec3( m[0]), vec3( m[1]), vec3( m[2])); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 normal; + vec3 lightDir; + vec2 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform mat4 _LightMatrix0; +uniform vec4 _MainTex_ST; +uniform mat4 _Object2World; +uniform vec4 _WorldSpaceLightPos0; + +uniform vec4 unity_Scale; +vec3 WorldSpaceLightDir( in vec4 v ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +v2f_surf vert_surf( in appdata_full v ); +vec3 WorldSpaceLightDir( in vec4 v ) { + vec3 worldPos; + worldPos = ( _Object2World * v ).xyz ; + return _WorldSpaceLightPos0.xyz ; +} +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + PositionFog( v.vertex, o.pos, o.fog); + o.hip_pack0.xy = ((v.texcoord.xy * _MainTex_ST.xy ) + _MainTex_ST.zw ); + o.normal = ( xll_constructMat3( _Object2World) * (v.normal * unity_Scale.w ) ); + o.lightDir = WorldSpaceLightDir( v.vertex); + o._LightCoord = ( _LightMatrix0 * ( _Object2World * v.vertex ) ).xy ; + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.hip_pack0, 0.0, 0.0); + gl_TexCoord[1] = vec4( xl_retval.normal, 0.0); + gl_TexCoord[2] = vec4( xl_retval.lightDir, 0.0); + gl_TexCoord[3] = vec4( xl_retval._LightCoord, 0.0, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Diffuse_Wrapped-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Diffuse_Wrapped-ir.txt new file mode 100644 index 000000000..7e2e968cd --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Diffuse_Wrapped-ir.txt @@ -0,0 +1,172 @@ +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 normal; + vec3 lightDir; + vec2 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform mat4 _LightMatrix0; +mat3 xll_constructMat3 ( + in mat4 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = m[0].xyz; + vec3 tmpvar_2; + tmpvar_2 = m[1].xyz; + vec3 tmpvar_3; + tmpvar_3 = m[2].xyz; + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +vec3 WorldSpaceLightDir ( + in vec4 v +) +{ + vec3 worldPos; + vec3 tmpvar_1; + tmpvar_1 = (_Object2World * v).xyz; + worldPos = tmpvar_1; + return _WorldSpaceLightPos0.xyz; +} + +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + v2f_surf o; + PositionFog (v.vertex, o.pos, o.fog); + vec2 tmpvar_1; + tmpvar_1 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + o.hip_pack0 = tmpvar_1.xy.xy; + mat3 tmpvar_2; + tmpvar_2 = (xll_constructMat3 (_Object2World)); + vec3 tmpvar_3; + tmpvar_3 = (tmpvar_2 * (v.normal * unity_Scale.w)); + o.normal = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = WorldSpaceLightDir (v.vertex); + vec3 tmpvar_5; + tmpvar_5 = tmpvar_4; + o.lightDir = tmpvar_5; + vec2 tmpvar_6; + tmpvar_6 = (_LightMatrix0 * (_Object2World * v.vertex)).xy; + o._LightCoord = tmpvar_6; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = xl_retval.fog; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_FOG = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19.zw = vec2(0.0, 0.0); + tmpvar_19.xy = xl_retval.hip_pack0.xy; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[0] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21.w = 0.0; + tmpvar_21.xyz = xl_retval.normal.xyz; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_TexCoord[1] = tmpvar_22; + vec4 tmpvar_23; + tmpvar_23.w = 0.0; + tmpvar_23.xyz = xl_retval.lightDir.xyz; + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + gl_TexCoord[2] = tmpvar_24; + vec4 tmpvar_25; + tmpvar_25.zw = vec2(0.0, 0.0); + tmpvar_25.xy = xl_retval._LightCoord.xy; + vec4 tmpvar_26; + tmpvar_26 = tmpvar_25; + gl_TexCoord[3] = tmpvar_26; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Diffuse_Wrapped-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Diffuse_Wrapped-out.txt new file mode 100644 index 000000000..a99d72429 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Diffuse_Wrapped-out.txt @@ -0,0 +1,37 @@ +varying vec4 xlv_FOG; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform mat4 _LightMatrix0; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * gl_Vertex); + mat3 tmpvar_2; + tmpvar_2[0] = _Object2World[0].xyz; + tmpvar_2[1] = _Object2World[1].xyz; + tmpvar_2[2] = _Object2World[2].xyz; + gl_Position = tmpvar_1; + vec4 tmpvar_3; + tmpvar_3.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_3.x = tmpvar_1.z; + xlv_FOG = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4.zw = vec2(0.0, 0.0); + tmpvar_4.xy = ((gl_MultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + gl_TexCoord[0] = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5.w = 0.0; + tmpvar_5.xyz = (tmpvar_2 * (gl_Normal * unity_Scale.w)); + gl_TexCoord[1] = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6.w = 0.0; + tmpvar_6.xyz = _WorldSpaceLightPos0.xyz; + gl_TexCoord[2] = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7.zw = vec2(0.0, 0.0); + tmpvar_7.xy = (_LightMatrix0 * (_Object2World * gl_Vertex)).xy; + gl_TexCoord[3] = tmpvar_7; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Rim-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Rim-in.txt new file mode 100644 index 000000000..280e9a0d6 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Rim-in.txt @@ -0,0 +1,86 @@ +mat3 xll_constructMat3( mat4 m) { + return mat3( vec3( m[0]), vec3( m[1]), vec3( m[2])); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec3 viewDir; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 normal; + vec3 lightDir; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _MainTex_ST; +uniform mat4 _Object2World; +uniform vec4 _WorldSpaceLightPos0; + +uniform vec4 unity_Scale; +vec3 WorldSpaceLightDir( in vec4 v ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +v2f_surf vert_surf( in appdata_full v ); +vec3 WorldSpaceLightDir( in vec4 v ) { + vec3 worldPos; + worldPos = ( _Object2World * v ).xyz ; + return _WorldSpaceLightPos0.xyz ; +} +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + PositionFog( v.vertex, o.pos, o.fog); + o.hip_pack0.xy = ((v.texcoord.xy * _MainTex_ST.xy ) + _MainTex_ST.zw ); + o.normal = ( xll_constructMat3( _Object2World) * (v.normal * unity_Scale.w ) ); + o.lightDir = WorldSpaceLightDir( v.vertex); + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.hip_pack0, 0.0, 0.0); + gl_TexCoord[1] = vec4( xl_retval.normal, 0.0); + gl_TexCoord[2] = vec4( xl_retval.lightDir, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Rim-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Rim-ir.txt new file mode 100644 index 000000000..f031a9d94 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Rim-ir.txt @@ -0,0 +1,161 @@ +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 normal; + vec3 lightDir; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +mat3 xll_constructMat3 ( + in mat4 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = m[0].xyz; + vec3 tmpvar_2; + tmpvar_2 = m[1].xyz; + vec3 tmpvar_3; + tmpvar_3 = m[2].xyz; + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +vec3 WorldSpaceLightDir ( + in vec4 v +) +{ + vec3 worldPos; + vec3 tmpvar_1; + tmpvar_1 = (_Object2World * v).xyz; + worldPos = tmpvar_1; + return _WorldSpaceLightPos0.xyz; +} + +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + v2f_surf o; + PositionFog (v.vertex, o.pos, o.fog); + vec2 tmpvar_1; + tmpvar_1 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + o.hip_pack0 = tmpvar_1.xy.xy; + mat3 tmpvar_2; + tmpvar_2 = (xll_constructMat3 (_Object2World)); + vec3 tmpvar_3; + tmpvar_3 = (tmpvar_2 * (v.normal * unity_Scale.w)); + o.normal = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = WorldSpaceLightDir (v.vertex); + vec3 tmpvar_5; + tmpvar_5 = tmpvar_4; + o.lightDir = tmpvar_5; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = xl_retval.fog; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_FOG = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19.zw = vec2(0.0, 0.0); + tmpvar_19.xy = xl_retval.hip_pack0.xy; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[0] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21.w = 0.0; + tmpvar_21.xyz = xl_retval.normal.xyz; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_TexCoord[1] = tmpvar_22; + vec4 tmpvar_23; + tmpvar_23.w = 0.0; + tmpvar_23.xyz = xl_retval.lightDir.xyz; + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + gl_TexCoord[2] = tmpvar_24; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Rim-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Rim-out.txt new file mode 100644 index 000000000..5fe3954f3 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Rim-out.txt @@ -0,0 +1,32 @@ +varying vec4 xlv_FOG; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * gl_Vertex); + mat3 tmpvar_2; + tmpvar_2[0] = _Object2World[0].xyz; + tmpvar_2[1] = _Object2World[1].xyz; + tmpvar_2[2] = _Object2World[2].xyz; + gl_Position = tmpvar_1; + vec4 tmpvar_3; + tmpvar_3.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_3.x = tmpvar_1.z; + xlv_FOG = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4.zw = vec2(0.0, 0.0); + tmpvar_4.xy = ((gl_MultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + gl_TexCoord[0] = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5.w = 0.0; + tmpvar_5.xyz = (tmpvar_2 * (gl_Normal * unity_Scale.w)); + gl_TexCoord[1] = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6.w = 0.0; + tmpvar_6.xyz = _WorldSpaceLightPos0.xyz; + gl_TexCoord[2] = tmpvar_6; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Rim1-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Rim1-in.txt new file mode 100644 index 000000000..dd486f19a --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Rim1-in.txt @@ -0,0 +1,99 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec3 viewDir; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 viewDir; + vec4 hip_screen; + vec3 normal; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _MainTex_ST; +uniform vec4 _ProjectionParams; +uniform mat4 _World2Object; +uniform vec3 _WorldSpaceCameraPos; + +uniform vec4 unity_Scale; +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +vec3 ObjSpaceViewDir( in vec4 v ); +vec4 ComputeScreenPos( in vec4 pos ); +v2f_surf vert_surf( in appdata_full v ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +vec3 ObjSpaceViewDir( in vec4 v ) { + vec3 objSpaceCameraPos; + objSpaceCameraPos = (( _World2Object * vec4( _WorldSpaceCameraPos.xyz , 1.00000) ).xyz * unity_Scale.w ); + return (objSpaceCameraPos - v.xyz ); +} +vec4 ComputeScreenPos( in vec4 pos ) { + vec4 o; + o = (pos * 0.500000); + o.xy = (vec2( o.x , (o.y * _ProjectionParams.x )) + o.w ); + o.zw = pos.zw ; + return o; +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + vec3 binormal; + mat3 rotation; + PositionFog( v.vertex, o.pos, o.fog); + o.hip_pack0.xy = ((v.texcoord.xy * _MainTex_ST.xy ) + _MainTex_ST.zw ); + o.hip_screen = ComputeScreenPos( o.pos); + binormal = (cross( v.normal, v.tangent.xyz ) * v.tangent.w ); + rotation = mat3( v.tangent.x , binormal.x , v.normal.x , v.tangent.y , binormal.y , v.normal.y , v.tangent.z , binormal.z , v.normal.z ); + o.normal = ( rotation * (v.normal * unity_Scale.w ) ); + o.viewDir = ( rotation * ObjSpaceViewDir( v.vertex) ); + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.hip_pack0, 0.0, 0.0); + gl_TexCoord[1] = vec4( xl_retval.viewDir, 0.0); + gl_TexCoord[2] = vec4( xl_retval.hip_screen); + gl_TexCoord[3] = vec4( xl_retval.normal, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Rim1-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Rim1-ir.txt new file mode 100644 index 000000000..9adae7db5 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Rim1-ir.txt @@ -0,0 +1,209 @@ +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 viewDir; + vec4 hip_screen; + vec3 normal; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec3 _WorldSpaceCameraPos; +uniform mat4 _World2Object; +uniform vec4 _ProjectionParams; +uniform vec4 _MainTex_ST; +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +vec3 ObjSpaceViewDir ( + in vec4 v +) +{ + vec3 objSpaceCameraPos; + vec4 tmpvar_1; + tmpvar_1.w = 1.0; + tmpvar_1.xyz = _WorldSpaceCameraPos.xyz.xyz; + vec3 tmpvar_2; + tmpvar_2 = ((_World2Object * tmpvar_1).xyz * unity_Scale.w); + objSpaceCameraPos = tmpvar_2; + return (objSpaceCameraPos - v.xyz); +} + +vec4 ComputeScreenPos ( + in vec4 pos +) +{ + vec4 o; + vec4 tmpvar_1; + tmpvar_1 = (pos * 0.5); + o = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2.x = o.x; + tmpvar_2.y = (o.y * _ProjectionParams.x); + vec2 tmpvar_3; + tmpvar_3 = (tmpvar_2 + o.w); + o.xy = tmpvar_3.xy.xy; + vec2 tmpvar_4; + tmpvar_4 = pos.zw; + o.zw = tmpvar_4.xxxy.zw; + return o; +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + mat3 rotation; + vec3 binormal; + v2f_surf o; + PositionFog (v.vertex, o.pos, o.fog); + vec2 tmpvar_1; + tmpvar_1 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + o.hip_pack0 = tmpvar_1.xy.xy; + vec4 tmpvar_2; + tmpvar_2 = ComputeScreenPos (o.pos); + vec4 tmpvar_3; + tmpvar_3 = tmpvar_2; + o.hip_screen = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = cross (v.normal, v.tangent.xyz); + vec3 tmpvar_5; + tmpvar_5 = (tmpvar_4 * v.tangent.w); + binormal = tmpvar_5; + mat3 tmpvar_6; + float tmpvar_7; + tmpvar_7 = v.tangent.x; + tmpvar_6[0].x = tmpvar_7; + float tmpvar_8; + tmpvar_8 = binormal.x; + tmpvar_6[0].y = tmpvar_8; + float tmpvar_9; + tmpvar_9 = v.normal.x; + tmpvar_6[0].z = tmpvar_9; + float tmpvar_10; + tmpvar_10 = v.tangent.y; + tmpvar_6[1].x = tmpvar_10; + float tmpvar_11; + tmpvar_11 = binormal.y; + tmpvar_6[1].y = tmpvar_11; + float tmpvar_12; + tmpvar_12 = v.normal.y; + tmpvar_6[1].z = tmpvar_12; + float tmpvar_13; + tmpvar_13 = v.tangent.z; + tmpvar_6[2].x = tmpvar_13; + float tmpvar_14; + tmpvar_14 = binormal.z; + tmpvar_6[2].y = tmpvar_14; + float tmpvar_15; + tmpvar_15 = v.normal.z; + tmpvar_6[2].z = tmpvar_15; + mat3 tmpvar_16; + tmpvar_16 = (tmpvar_6); + rotation = (tmpvar_16); + vec3 tmpvar_17; + tmpvar_17 = (rotation * (v.normal * unity_Scale.w)); + o.normal = tmpvar_17; + vec3 tmpvar_18; + tmpvar_18 = ObjSpaceViewDir (v.vertex); + vec3 tmpvar_19; + tmpvar_19 = (rotation * tmpvar_18); + o.viewDir = tmpvar_19; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = xl_retval.fog; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_FOG = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19.zw = vec2(0.0, 0.0); + tmpvar_19.xy = xl_retval.hip_pack0.xy; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[0] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21.w = 0.0; + tmpvar_21.xyz = xl_retval.viewDir.xyz; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_TexCoord[1] = tmpvar_22; + vec4 tmpvar_23; + tmpvar_23 = xl_retval.hip_screen.xyzw; + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + gl_TexCoord[2] = tmpvar_24; + vec4 tmpvar_25; + tmpvar_25.w = 0.0; + tmpvar_25.xyz = xl_retval.normal.xyz; + vec4 tmpvar_26; + tmpvar_26 = tmpvar_25; + gl_TexCoord[3] = tmpvar_26; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Rim1-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Rim1-out.txt new file mode 100644 index 000000000..89d86455a --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Rim1-out.txt @@ -0,0 +1,55 @@ +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec3 _WorldSpaceCameraPos; +uniform mat4 _World2Object; +uniform vec4 _ProjectionParams; +uniform vec4 _MainTex_ST; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * gl_Vertex); + vec4 o_i0; + vec4 tmpvar_2; + tmpvar_2 = (tmpvar_1 * 0.5); + o_i0 = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3.x = tmpvar_2.x; + tmpvar_3.y = (tmpvar_2.y * _ProjectionParams.x); + o_i0.xy = (tmpvar_3 + tmpvar_2.w); + o_i0.zw = tmpvar_1.zw; + vec3 tmpvar_4; + tmpvar_4 = (cross (gl_Normal, TANGENT.xyz) * TANGENT.w); + mat3 tmpvar_5; + tmpvar_5[0].x = TANGENT.x; + tmpvar_5[0].y = tmpvar_4.x; + tmpvar_5[0].z = gl_Normal.x; + tmpvar_5[1].x = TANGENT.y; + tmpvar_5[1].y = tmpvar_4.y; + tmpvar_5[1].z = gl_Normal.y; + tmpvar_5[2].x = TANGENT.z; + tmpvar_5[2].y = tmpvar_4.z; + tmpvar_5[2].z = gl_Normal.z; + vec4 tmpvar_6; + tmpvar_6.w = 1.0; + tmpvar_6.xyz = _WorldSpaceCameraPos; + gl_Position = tmpvar_1; + vec4 tmpvar_7; + tmpvar_7.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_7.x = tmpvar_1.z; + xlv_FOG = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8.zw = vec2(0.0, 0.0); + tmpvar_8.xy = ((gl_MultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + gl_TexCoord[0] = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9.w = 0.0; + tmpvar_9.xyz = (tmpvar_5 * (((_World2Object * tmpvar_6).xyz * unity_Scale.w) - gl_Vertex.xyz)); + gl_TexCoord[1] = tmpvar_9; + gl_TexCoord[2] = o_i0; + vec4 tmpvar_10; + tmpvar_10.w = 0.0; + tmpvar_10.xyz = (tmpvar_5 * (gl_Normal * unity_Scale.w)); + gl_TexCoord[3] = tmpvar_10; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Rim2-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Rim2-in.txt new file mode 100644 index 000000000..387a516ae --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Rim2-in.txt @@ -0,0 +1,106 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec3 viewDir; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 viewDir; + vec4 hip_screen; + vec3 normal; + vec3 hip_lmapFade; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _MainTex_ST; +uniform vec4 _ProjectionParams; +uniform mat4 _World2Object; +uniform vec3 _WorldSpaceCameraPos; + + +uniform vec4 unity_LightmapFade; +uniform vec4 unity_LightmapST; +uniform vec4 unity_Scale; +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +vec3 ObjSpaceViewDir( in vec4 v ); +vec4 ComputeScreenPos( in vec4 pos ); +v2f_surf vert_surf( in appdata_full v ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +vec3 ObjSpaceViewDir( in vec4 v ) { + vec3 objSpaceCameraPos; + objSpaceCameraPos = (( _World2Object * vec4( _WorldSpaceCameraPos.xyz , 1.00000) ).xyz * unity_Scale.w ); + return (objSpaceCameraPos - v.xyz ); +} +vec4 ComputeScreenPos( in vec4 pos ) { + vec4 o; + o = (pos * 0.500000); + o.xy = (vec2( o.x , (o.y * _ProjectionParams.x )) + o.w ); + o.zw = pos.zw ; + return o; +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + vec3 binormal; + mat3 rotation; + PositionFog( v.vertex, o.pos, o.fog); + o.hip_pack0.xy = ((v.texcoord.xy * _MainTex_ST.xy ) + _MainTex_ST.zw ); + o.hip_screen = ComputeScreenPos( o.pos); + o.hip_lmapFade.xy = ((v.texcoord1.xy * unity_LightmapST.xy ) + unity_LightmapST.zw ); + o.hip_lmapFade.z = ((( -( gl_ModelViewMatrix * v.vertex ).z ) * unity_LightmapFade.z ) + unity_LightmapFade.w ); + binormal = (cross( v.normal, v.tangent.xyz ) * v.tangent.w ); + rotation = mat3( v.tangent.x , binormal.x , v.normal.x , v.tangent.y , binormal.y , v.normal.y , v.tangent.z , binormal.z , v.normal.z ); + o.normal = ( rotation * (v.normal * unity_Scale.w ) ); + o.viewDir = ( rotation * ObjSpaceViewDir( v.vertex) ); + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.hip_pack0, 0.0, 0.0); + gl_TexCoord[1] = vec4( xl_retval.viewDir, 0.0); + gl_TexCoord[2] = vec4( xl_retval.hip_screen); + gl_TexCoord[3] = vec4( xl_retval.normal, 0.0); + gl_TexCoord[4] = vec4( xl_retval.hip_lmapFade, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Rim2-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Rim2-ir.txt new file mode 100644 index 000000000..48c164c9c --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Rim2-ir.txt @@ -0,0 +1,224 @@ +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 viewDir; + vec4 hip_screen; + vec3 normal; + vec3 hip_lmapFade; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec4 unity_LightmapST; +uniform vec4 unity_LightmapFade; +uniform vec3 _WorldSpaceCameraPos; +uniform mat4 _World2Object; +uniform vec4 _ProjectionParams; +uniform vec4 _MainTex_ST; +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +vec3 ObjSpaceViewDir ( + in vec4 v +) +{ + vec3 objSpaceCameraPos; + vec4 tmpvar_1; + tmpvar_1.w = 1.0; + tmpvar_1.xyz = _WorldSpaceCameraPos.xyz.xyz; + vec3 tmpvar_2; + tmpvar_2 = ((_World2Object * tmpvar_1).xyz * unity_Scale.w); + objSpaceCameraPos = tmpvar_2; + return (objSpaceCameraPos - v.xyz); +} + +vec4 ComputeScreenPos ( + in vec4 pos +) +{ + vec4 o; + vec4 tmpvar_1; + tmpvar_1 = (pos * 0.5); + o = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2.x = o.x; + tmpvar_2.y = (o.y * _ProjectionParams.x); + vec2 tmpvar_3; + tmpvar_3 = (tmpvar_2 + o.w); + o.xy = tmpvar_3.xy.xy; + vec2 tmpvar_4; + tmpvar_4 = pos.zw; + o.zw = tmpvar_4.xxxy.zw; + return o; +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + mat3 rotation; + vec3 binormal; + v2f_surf o; + PositionFog (v.vertex, o.pos, o.fog); + vec2 tmpvar_1; + tmpvar_1 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + o.hip_pack0 = tmpvar_1.xy.xy; + vec4 tmpvar_2; + tmpvar_2 = ComputeScreenPos (o.pos); + vec4 tmpvar_3; + tmpvar_3 = tmpvar_2; + o.hip_screen = tmpvar_3; + vec2 tmpvar_4; + tmpvar_4 = ((v.texcoord1.xy * unity_LightmapST.xy) + unity_LightmapST.zw); + o.hip_lmapFade.xy = tmpvar_4.xy.xy; + float tmpvar_5; + tmpvar_5 = ((-((gl_ModelViewMatrix * v.vertex).z) * unity_LightmapFade.z) + unity_LightmapFade.w); + o.hip_lmapFade.z = vec3(tmpvar_5).z; + vec3 tmpvar_6; + tmpvar_6 = cross (v.normal, v.tangent.xyz); + vec3 tmpvar_7; + tmpvar_7 = (tmpvar_6 * v.tangent.w); + binormal = tmpvar_7; + mat3 tmpvar_8; + float tmpvar_9; + tmpvar_9 = v.tangent.x; + tmpvar_8[0].x = tmpvar_9; + float tmpvar_10; + tmpvar_10 = binormal.x; + tmpvar_8[0].y = tmpvar_10; + float tmpvar_11; + tmpvar_11 = v.normal.x; + tmpvar_8[0].z = tmpvar_11; + float tmpvar_12; + tmpvar_12 = v.tangent.y; + tmpvar_8[1].x = tmpvar_12; + float tmpvar_13; + tmpvar_13 = binormal.y; + tmpvar_8[1].y = tmpvar_13; + float tmpvar_14; + tmpvar_14 = v.normal.y; + tmpvar_8[1].z = tmpvar_14; + float tmpvar_15; + tmpvar_15 = v.tangent.z; + tmpvar_8[2].x = tmpvar_15; + float tmpvar_16; + tmpvar_16 = binormal.z; + tmpvar_8[2].y = tmpvar_16; + float tmpvar_17; + tmpvar_17 = v.normal.z; + tmpvar_8[2].z = tmpvar_17; + mat3 tmpvar_18; + tmpvar_18 = (tmpvar_8); + rotation = (tmpvar_18); + vec3 tmpvar_19; + tmpvar_19 = (rotation * (v.normal * unity_Scale.w)); + o.normal = tmpvar_19; + vec3 tmpvar_20; + tmpvar_20 = ObjSpaceViewDir (v.vertex); + vec3 tmpvar_21; + tmpvar_21 = (rotation * tmpvar_20); + o.viewDir = tmpvar_21; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = xl_retval.fog; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_FOG = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19.zw = vec2(0.0, 0.0); + tmpvar_19.xy = xl_retval.hip_pack0.xy; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[0] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21.w = 0.0; + tmpvar_21.xyz = xl_retval.viewDir.xyz; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_TexCoord[1] = tmpvar_22; + vec4 tmpvar_23; + tmpvar_23 = xl_retval.hip_screen.xyzw; + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + gl_TexCoord[2] = tmpvar_24; + vec4 tmpvar_25; + tmpvar_25.w = 0.0; + tmpvar_25.xyz = xl_retval.normal.xyz; + vec4 tmpvar_26; + tmpvar_26 = tmpvar_25; + gl_TexCoord[3] = tmpvar_26; + vec4 tmpvar_27; + tmpvar_27.w = 0.0; + tmpvar_27.xyz = xl_retval.hip_lmapFade.xyz; + vec4 tmpvar_28; + tmpvar_28 = tmpvar_27; + gl_TexCoord[4] = tmpvar_28; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Rim2-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Rim2-out.txt new file mode 100644 index 000000000..d3739189c --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Rim2-out.txt @@ -0,0 +1,64 @@ +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec4 unity_LightmapST; +uniform vec4 unity_LightmapFade; +uniform vec3 _WorldSpaceCameraPos; +uniform mat4 _World2Object; +uniform vec4 _ProjectionParams; +uniform vec4 _MainTex_ST; +void main () +{ + vec3 tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = (gl_ModelViewProjectionMatrix * gl_Vertex); + vec4 o_i0; + vec4 tmpvar_3; + tmpvar_3 = (tmpvar_2 * 0.5); + o_i0 = tmpvar_3; + vec2 tmpvar_4; + tmpvar_4.x = tmpvar_3.x; + tmpvar_4.y = (tmpvar_3.y * _ProjectionParams.x); + o_i0.xy = (tmpvar_4 + tmpvar_3.w); + o_i0.zw = tmpvar_2.zw; + tmpvar_1.xy = ((gl_MultiTexCoord1.xy * unity_LightmapST.xy) + unity_LightmapST.zw); + tmpvar_1.z = ((-((gl_ModelViewMatrix * gl_Vertex).z) * unity_LightmapFade.z) + unity_LightmapFade.w); + vec3 tmpvar_5; + tmpvar_5 = (cross (gl_Normal, TANGENT.xyz) * TANGENT.w); + mat3 tmpvar_6; + tmpvar_6[0].x = TANGENT.x; + tmpvar_6[0].y = tmpvar_5.x; + tmpvar_6[0].z = gl_Normal.x; + tmpvar_6[1].x = TANGENT.y; + tmpvar_6[1].y = tmpvar_5.y; + tmpvar_6[1].z = gl_Normal.y; + tmpvar_6[2].x = TANGENT.z; + tmpvar_6[2].y = tmpvar_5.z; + tmpvar_6[2].z = gl_Normal.z; + vec4 tmpvar_7; + tmpvar_7.w = 1.0; + tmpvar_7.xyz = _WorldSpaceCameraPos; + gl_Position = tmpvar_2; + vec4 tmpvar_8; + tmpvar_8.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_8.x = tmpvar_2.z; + xlv_FOG = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9.zw = vec2(0.0, 0.0); + tmpvar_9.xy = ((gl_MultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + gl_TexCoord[0] = tmpvar_9; + vec4 tmpvar_10; + tmpvar_10.w = 0.0; + tmpvar_10.xyz = (tmpvar_6 * (((_World2Object * tmpvar_7).xyz * unity_Scale.w) - gl_Vertex.xyz)); + gl_TexCoord[1] = tmpvar_10; + gl_TexCoord[2] = o_i0; + vec4 tmpvar_11; + tmpvar_11.w = 0.0; + tmpvar_11.xyz = (tmpvar_6 * (gl_Normal * unity_Scale.w)); + gl_TexCoord[3] = tmpvar_11; + vec4 tmpvar_12; + tmpvar_12.w = 0.0; + tmpvar_12.xyz = tmpvar_1; + gl_TexCoord[4] = tmpvar_12; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Rim_Bump-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Rim_Bump-in.txt new file mode 100644 index 000000000..6e31447bd --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Rim_Bump-in.txt @@ -0,0 +1,89 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_BumpMap; + vec3 viewDir; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 lightDir; + vec4 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _BumpMap_ST; +uniform mat4 _LightMatrix0; +uniform mat4 _Object2World; +uniform mat4 _World2Object; +uniform vec4 _WorldSpaceLightPos0; + +uniform vec4 unity_Scale; +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +vec3 ObjSpaceLightDir( in vec4 v ); +v2f_surf vert_surf( in appdata_full v ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +vec3 ObjSpaceLightDir( in vec4 v ) { + vec3 objSpaceLightPos; + objSpaceLightPos = ( _World2Object * _WorldSpaceLightPos0 ).xyz ; + return ((objSpaceLightPos.xyz * unity_Scale.w ) - v.xyz ); +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + vec3 binormal; + mat3 rotation; + PositionFog( v.vertex, o.pos, o.fog); + o.hip_pack0.xy = ((v.texcoord.xy * _BumpMap_ST.xy ) + _BumpMap_ST.zw ); + binormal = (cross( v.normal, v.tangent.xyz ) * v.tangent.w ); + rotation = mat3( v.tangent.x , binormal.x , v.normal.x , v.tangent.y , binormal.y , v.normal.y , v.tangent.z , binormal.z , v.normal.z ); + o.lightDir = ( rotation * ObjSpaceLightDir( v.vertex) ); + o._LightCoord = ( _LightMatrix0 * ( _Object2World * v.vertex ) ); + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.hip_pack0, 0.0, 0.0); + gl_TexCoord[1] = vec4( xl_retval.lightDir, 0.0); + gl_TexCoord[2] = vec4( xl_retval._LightCoord); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Rim_Bump-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Rim_Bump-ir.txt new file mode 100644 index 000000000..ae6d445be --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Rim_Bump-ir.txt @@ -0,0 +1,175 @@ +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 lightDir; + vec4 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform mat4 _World2Object; +uniform mat4 _Object2World; +uniform mat4 _LightMatrix0; +uniform vec4 _BumpMap_ST; +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +vec3 ObjSpaceLightDir ( + in vec4 v +) +{ + vec3 objSpaceLightPos; + vec3 tmpvar_1; + tmpvar_1 = (_World2Object * _WorldSpaceLightPos0).xyz; + objSpaceLightPos = tmpvar_1; + return ((objSpaceLightPos.xyz * unity_Scale.w) - v.xyz); +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + mat3 rotation; + vec3 binormal; + v2f_surf o; + PositionFog (v.vertex, o.pos, o.fog); + vec2 tmpvar_1; + tmpvar_1 = ((v.texcoord.xy * _BumpMap_ST.xy) + _BumpMap_ST.zw); + o.hip_pack0 = tmpvar_1.xy.xy; + vec3 tmpvar_2; + tmpvar_2 = cross (v.normal, v.tangent.xyz); + vec3 tmpvar_3; + tmpvar_3 = (tmpvar_2 * v.tangent.w); + binormal = tmpvar_3; + mat3 tmpvar_4; + float tmpvar_5; + tmpvar_5 = v.tangent.x; + tmpvar_4[0].x = tmpvar_5; + float tmpvar_6; + tmpvar_6 = binormal.x; + tmpvar_4[0].y = tmpvar_6; + float tmpvar_7; + tmpvar_7 = v.normal.x; + tmpvar_4[0].z = tmpvar_7; + float tmpvar_8; + tmpvar_8 = v.tangent.y; + tmpvar_4[1].x = tmpvar_8; + float tmpvar_9; + tmpvar_9 = binormal.y; + tmpvar_4[1].y = tmpvar_9; + float tmpvar_10; + tmpvar_10 = v.normal.y; + tmpvar_4[1].z = tmpvar_10; + float tmpvar_11; + tmpvar_11 = v.tangent.z; + tmpvar_4[2].x = tmpvar_11; + float tmpvar_12; + tmpvar_12 = binormal.z; + tmpvar_4[2].y = tmpvar_12; + float tmpvar_13; + tmpvar_13 = v.normal.z; + tmpvar_4[2].z = tmpvar_13; + mat3 tmpvar_14; + tmpvar_14 = (tmpvar_4); + rotation = (tmpvar_14); + vec3 tmpvar_15; + tmpvar_15 = ObjSpaceLightDir (v.vertex); + vec3 tmpvar_16; + tmpvar_16 = (rotation * tmpvar_15); + o.lightDir = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17 = (_LightMatrix0 * (_Object2World * v.vertex)); + o._LightCoord = tmpvar_17; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = xl_retval.fog; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_FOG = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19.zw = vec2(0.0, 0.0); + tmpvar_19.xy = xl_retval.hip_pack0.xy; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[0] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21.w = 0.0; + tmpvar_21.xyz = xl_retval.lightDir.xyz; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_TexCoord[1] = tmpvar_22; + vec4 tmpvar_23; + tmpvar_23 = xl_retval._LightCoord.xyzw; + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + gl_TexCoord[2] = tmpvar_24; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Rim_Bump-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Rim_Bump-out.txt new file mode 100644 index 000000000..5302b834d --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Rim_Bump-out.txt @@ -0,0 +1,40 @@ +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform mat4 _World2Object; +uniform mat4 _Object2World; +uniform mat4 _LightMatrix0; +uniform vec4 _BumpMap_ST; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * gl_Vertex); + vec3 tmpvar_2; + tmpvar_2 = (cross (gl_Normal, TANGENT.xyz) * TANGENT.w); + mat3 tmpvar_3; + tmpvar_3[0].x = TANGENT.x; + tmpvar_3[0].y = tmpvar_2.x; + tmpvar_3[0].z = gl_Normal.x; + tmpvar_3[1].x = TANGENT.y; + tmpvar_3[1].y = tmpvar_2.y; + tmpvar_3[1].z = gl_Normal.y; + tmpvar_3[2].x = TANGENT.z; + tmpvar_3[2].y = tmpvar_2.z; + tmpvar_3[2].z = gl_Normal.z; + gl_Position = tmpvar_1; + vec4 tmpvar_4; + tmpvar_4.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_4.x = tmpvar_1.z; + xlv_FOG = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5.zw = vec2(0.0, 0.0); + tmpvar_5.xy = ((gl_MultiTexCoord0.xy * _BumpMap_ST.xy) + _BumpMap_ST.zw); + gl_TexCoord[0] = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6.w = 0.0; + tmpvar_6.xyz = (tmpvar_3 * (((_World2Object * _WorldSpaceLightPos0).xyz * unity_Scale.w) - gl_Vertex.xyz)); + gl_TexCoord[1] = tmpvar_6; + gl_TexCoord[2] = (_LightMatrix0 * (_Object2World * gl_Vertex)); +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Rim_Bump1-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Rim_Bump1-in.txt new file mode 100644 index 000000000..33f731c9f --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Rim_Bump1-in.txt @@ -0,0 +1,89 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_BumpMap; + vec3 viewDir; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 lightDir; + vec3 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _BumpMap_ST; +uniform mat4 _LightMatrix0; +uniform mat4 _Object2World; +uniform mat4 _World2Object; +uniform vec4 _WorldSpaceLightPos0; + +uniform vec4 unity_Scale; +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +vec3 ObjSpaceLightDir( in vec4 v ); +v2f_surf vert_surf( in appdata_full v ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +vec3 ObjSpaceLightDir( in vec4 v ) { + vec3 objSpaceLightPos; + objSpaceLightPos = ( _World2Object * _WorldSpaceLightPos0 ).xyz ; + return ((objSpaceLightPos.xyz * unity_Scale.w ) - v.xyz ); +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + vec3 binormal; + mat3 rotation; + PositionFog( v.vertex, o.pos, o.fog); + o.hip_pack0.xy = ((v.texcoord.xy * _BumpMap_ST.xy ) + _BumpMap_ST.zw ); + binormal = (cross( v.normal, v.tangent.xyz ) * v.tangent.w ); + rotation = mat3( v.tangent.x , binormal.x , v.normal.x , v.tangent.y , binormal.y , v.normal.y , v.tangent.z , binormal.z , v.normal.z ); + o.lightDir = ( rotation * ObjSpaceLightDir( v.vertex) ); + o._LightCoord = ( _LightMatrix0 * ( _Object2World * v.vertex ) ).xyz ; + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.hip_pack0, 0.0, 0.0); + gl_TexCoord[1] = vec4( xl_retval.lightDir, 0.0); + gl_TexCoord[2] = vec4( xl_retval._LightCoord, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Rim_Bump1-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Rim_Bump1-ir.txt new file mode 100644 index 000000000..4d57353f8 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Rim_Bump1-ir.txt @@ -0,0 +1,176 @@ +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 lightDir; + vec3 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform mat4 _World2Object; +uniform mat4 _Object2World; +uniform mat4 _LightMatrix0; +uniform vec4 _BumpMap_ST; +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +vec3 ObjSpaceLightDir ( + in vec4 v +) +{ + vec3 objSpaceLightPos; + vec3 tmpvar_1; + tmpvar_1 = (_World2Object * _WorldSpaceLightPos0).xyz; + objSpaceLightPos = tmpvar_1; + return ((objSpaceLightPos.xyz * unity_Scale.w) - v.xyz); +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + mat3 rotation; + vec3 binormal; + v2f_surf o; + PositionFog (v.vertex, o.pos, o.fog); + vec2 tmpvar_1; + tmpvar_1 = ((v.texcoord.xy * _BumpMap_ST.xy) + _BumpMap_ST.zw); + o.hip_pack0 = tmpvar_1.xy.xy; + vec3 tmpvar_2; + tmpvar_2 = cross (v.normal, v.tangent.xyz); + vec3 tmpvar_3; + tmpvar_3 = (tmpvar_2 * v.tangent.w); + binormal = tmpvar_3; + mat3 tmpvar_4; + float tmpvar_5; + tmpvar_5 = v.tangent.x; + tmpvar_4[0].x = tmpvar_5; + float tmpvar_6; + tmpvar_6 = binormal.x; + tmpvar_4[0].y = tmpvar_6; + float tmpvar_7; + tmpvar_7 = v.normal.x; + tmpvar_4[0].z = tmpvar_7; + float tmpvar_8; + tmpvar_8 = v.tangent.y; + tmpvar_4[1].x = tmpvar_8; + float tmpvar_9; + tmpvar_9 = binormal.y; + tmpvar_4[1].y = tmpvar_9; + float tmpvar_10; + tmpvar_10 = v.normal.y; + tmpvar_4[1].z = tmpvar_10; + float tmpvar_11; + tmpvar_11 = v.tangent.z; + tmpvar_4[2].x = tmpvar_11; + float tmpvar_12; + tmpvar_12 = binormal.z; + tmpvar_4[2].y = tmpvar_12; + float tmpvar_13; + tmpvar_13 = v.normal.z; + tmpvar_4[2].z = tmpvar_13; + mat3 tmpvar_14; + tmpvar_14 = (tmpvar_4); + rotation = (tmpvar_14); + vec3 tmpvar_15; + tmpvar_15 = ObjSpaceLightDir (v.vertex); + vec3 tmpvar_16; + tmpvar_16 = (rotation * tmpvar_15); + o.lightDir = tmpvar_16; + vec3 tmpvar_17; + tmpvar_17 = (_LightMatrix0 * (_Object2World * v.vertex)).xyz; + o._LightCoord = tmpvar_17; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = xl_retval.fog; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_FOG = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19.zw = vec2(0.0, 0.0); + tmpvar_19.xy = xl_retval.hip_pack0.xy; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[0] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21.w = 0.0; + tmpvar_21.xyz = xl_retval.lightDir.xyz; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_TexCoord[1] = tmpvar_22; + vec4 tmpvar_23; + tmpvar_23.w = 0.0; + tmpvar_23.xyz = xl_retval._LightCoord.xyz; + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + gl_TexCoord[2] = tmpvar_24; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Rim_Bump1-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Rim_Bump1-out.txt new file mode 100644 index 000000000..9a997f0a3 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Rim_Bump1-out.txt @@ -0,0 +1,43 @@ +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform mat4 _World2Object; +uniform mat4 _Object2World; +uniform mat4 _LightMatrix0; +uniform vec4 _BumpMap_ST; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * gl_Vertex); + vec3 tmpvar_2; + tmpvar_2 = (cross (gl_Normal, TANGENT.xyz) * TANGENT.w); + mat3 tmpvar_3; + tmpvar_3[0].x = TANGENT.x; + tmpvar_3[0].y = tmpvar_2.x; + tmpvar_3[0].z = gl_Normal.x; + tmpvar_3[1].x = TANGENT.y; + tmpvar_3[1].y = tmpvar_2.y; + tmpvar_3[1].z = gl_Normal.y; + tmpvar_3[2].x = TANGENT.z; + tmpvar_3[2].y = tmpvar_2.z; + tmpvar_3[2].z = gl_Normal.z; + gl_Position = tmpvar_1; + vec4 tmpvar_4; + tmpvar_4.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_4.x = tmpvar_1.z; + xlv_FOG = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5.zw = vec2(0.0, 0.0); + tmpvar_5.xy = ((gl_MultiTexCoord0.xy * _BumpMap_ST.xy) + _BumpMap_ST.zw); + gl_TexCoord[0] = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6.w = 0.0; + tmpvar_6.xyz = (tmpvar_3 * (((_World2Object * _WorldSpaceLightPos0).xyz * unity_Scale.w) - gl_Vertex.xyz)); + gl_TexCoord[1] = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7.w = 0.0; + tmpvar_7.xyz = (_LightMatrix0 * (_Object2World * gl_Vertex)).xyz; + gl_TexCoord[2] = tmpvar_7; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_ScreenPos-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_ScreenPos-in.txt new file mode 100644 index 000000000..b31a4160a --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_ScreenPos-in.txt @@ -0,0 +1,85 @@ +mat3 xll_constructMat3( mat4 m) { + return mat3( vec3( m[0]), vec3( m[1]), vec3( m[2])); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec4 screenPos; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec3 normal; + vec3 lightDir; + vec4 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform mat4 _LightMatrix0; +uniform mat4 _Object2World; +uniform vec4 _WorldSpaceLightPos0; + +uniform vec4 unity_Scale; +vec3 WorldSpaceLightDir( in vec4 v ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +v2f_surf vert_surf( in appdata_full v ); +vec3 WorldSpaceLightDir( in vec4 v ) { + vec3 worldPos; + worldPos = ( _Object2World * v ).xyz ; + return (_WorldSpaceLightPos0.xyz - worldPos); +} +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + PositionFog( v.vertex, o.pos, o.fog); + o.normal = ( xll_constructMat3( _Object2World) * (v.normal * unity_Scale.w ) ); + o.lightDir = WorldSpaceLightDir( v.vertex); + o._LightCoord = ( _LightMatrix0 * ( _Object2World * v.vertex ) ); + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.normal, 0.0); + gl_TexCoord[1] = vec4( xl_retval.lightDir, 0.0); + gl_TexCoord[2] = vec4( xl_retval._LightCoord); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_ScreenPos-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_ScreenPos-ir.txt new file mode 100644 index 000000000..1324fdf24 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_ScreenPos-ir.txt @@ -0,0 +1,160 @@ +struct v2f_surf { + vec4 pos; + float fog; + vec3 normal; + vec3 lightDir; + vec4 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform mat4 _Object2World; +uniform mat4 _LightMatrix0; +mat3 xll_constructMat3 ( + in mat4 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = m[0].xyz; + vec3 tmpvar_2; + tmpvar_2 = m[1].xyz; + vec3 tmpvar_3; + tmpvar_3 = m[2].xyz; + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +vec3 WorldSpaceLightDir ( + in vec4 v +) +{ + vec3 worldPos; + vec3 tmpvar_1; + tmpvar_1 = (_Object2World * v).xyz; + worldPos = tmpvar_1; + return (_WorldSpaceLightPos0.xyz - worldPos); +} + +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + v2f_surf o; + PositionFog (v.vertex, o.pos, o.fog); + mat3 tmpvar_1; + tmpvar_1 = (xll_constructMat3 (_Object2World)); + vec3 tmpvar_2; + tmpvar_2 = (tmpvar_1 * (v.normal * unity_Scale.w)); + o.normal = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = WorldSpaceLightDir (v.vertex); + vec3 tmpvar_4; + tmpvar_4 = tmpvar_3; + o.lightDir = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = (_LightMatrix0 * (_Object2World * v.vertex)); + o._LightCoord = tmpvar_5; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = xl_retval.fog; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_FOG = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19.w = 0.0; + tmpvar_19.xyz = xl_retval.normal.xyz; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[0] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21.w = 0.0; + tmpvar_21.xyz = xl_retval.lightDir.xyz; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_TexCoord[1] = tmpvar_22; + vec4 tmpvar_23; + tmpvar_23 = xl_retval._LightCoord.xyzw; + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + gl_TexCoord[2] = tmpvar_24; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_ScreenPos-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_ScreenPos-out.txt new file mode 100644 index 000000000..0f5f44b75 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_ScreenPos-out.txt @@ -0,0 +1,29 @@ +varying vec4 xlv_FOG; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform mat4 _Object2World; +uniform mat4 _LightMatrix0; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * gl_Vertex); + mat3 tmpvar_2; + tmpvar_2[0] = _Object2World[0].xyz; + tmpvar_2[1] = _Object2World[1].xyz; + tmpvar_2[2] = _Object2World[2].xyz; + gl_Position = tmpvar_1; + vec4 tmpvar_3; + tmpvar_3.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_3.x = tmpvar_1.z; + xlv_FOG = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4.w = 0.0; + tmpvar_4.xyz = (tmpvar_2 * (gl_Normal * unity_Scale.w)); + gl_TexCoord[0] = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5.w = 0.0; + tmpvar_5.xyz = (_WorldSpaceLightPos0.xyz - (_Object2World * gl_Vertex).xyz); + gl_TexCoord[1] = tmpvar_5; + gl_TexCoord[2] = (_LightMatrix0 * (_Object2World * gl_Vertex)); +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_ScreenPos1-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_ScreenPos1-in.txt new file mode 100644 index 000000000..7707c4d4b --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_ScreenPos1-in.txt @@ -0,0 +1,85 @@ +mat3 xll_constructMat3( mat4 m) { + return mat3( vec3( m[0]), vec3( m[1]), vec3( m[2])); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec4 screenPos; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec3 normal; + vec3 lightDir; + vec3 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform mat4 _LightMatrix0; +uniform mat4 _Object2World; +uniform vec4 _WorldSpaceLightPos0; + +uniform vec4 unity_Scale; +vec3 WorldSpaceLightDir( in vec4 v ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +v2f_surf vert_surf( in appdata_full v ); +vec3 WorldSpaceLightDir( in vec4 v ) { + vec3 worldPos; + worldPos = ( _Object2World * v ).xyz ; + return (_WorldSpaceLightPos0.xyz - worldPos); +} +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + PositionFog( v.vertex, o.pos, o.fog); + o.normal = ( xll_constructMat3( _Object2World) * (v.normal * unity_Scale.w ) ); + o.lightDir = WorldSpaceLightDir( v.vertex); + o._LightCoord = ( _LightMatrix0 * ( _Object2World * v.vertex ) ).xyz ; + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.normal, 0.0); + gl_TexCoord[1] = vec4( xl_retval.lightDir, 0.0); + gl_TexCoord[2] = vec4( xl_retval._LightCoord, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_ScreenPos1-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_ScreenPos1-ir.txt new file mode 100644 index 000000000..6ba4142e6 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_ScreenPos1-ir.txt @@ -0,0 +1,161 @@ +struct v2f_surf { + vec4 pos; + float fog; + vec3 normal; + vec3 lightDir; + vec3 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform mat4 _Object2World; +uniform mat4 _LightMatrix0; +mat3 xll_constructMat3 ( + in mat4 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = m[0].xyz; + vec3 tmpvar_2; + tmpvar_2 = m[1].xyz; + vec3 tmpvar_3; + tmpvar_3 = m[2].xyz; + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +vec3 WorldSpaceLightDir ( + in vec4 v +) +{ + vec3 worldPos; + vec3 tmpvar_1; + tmpvar_1 = (_Object2World * v).xyz; + worldPos = tmpvar_1; + return (_WorldSpaceLightPos0.xyz - worldPos); +} + +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + v2f_surf o; + PositionFog (v.vertex, o.pos, o.fog); + mat3 tmpvar_1; + tmpvar_1 = (xll_constructMat3 (_Object2World)); + vec3 tmpvar_2; + tmpvar_2 = (tmpvar_1 * (v.normal * unity_Scale.w)); + o.normal = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = WorldSpaceLightDir (v.vertex); + vec3 tmpvar_4; + tmpvar_4 = tmpvar_3; + o.lightDir = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = (_LightMatrix0 * (_Object2World * v.vertex)).xyz; + o._LightCoord = tmpvar_5; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = xl_retval.fog; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_FOG = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19.w = 0.0; + tmpvar_19.xyz = xl_retval.normal.xyz; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[0] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21.w = 0.0; + tmpvar_21.xyz = xl_retval.lightDir.xyz; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_TexCoord[1] = tmpvar_22; + vec4 tmpvar_23; + tmpvar_23.w = 0.0; + tmpvar_23.xyz = xl_retval._LightCoord.xyz; + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + gl_TexCoord[2] = tmpvar_24; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_ScreenPos1-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_ScreenPos1-out.txt new file mode 100644 index 000000000..c53a31ae4 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_ScreenPos1-out.txt @@ -0,0 +1,32 @@ +varying vec4 xlv_FOG; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform mat4 _Object2World; +uniform mat4 _LightMatrix0; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * gl_Vertex); + mat3 tmpvar_2; + tmpvar_2[0] = _Object2World[0].xyz; + tmpvar_2[1] = _Object2World[1].xyz; + tmpvar_2[2] = _Object2World[2].xyz; + gl_Position = tmpvar_1; + vec4 tmpvar_3; + tmpvar_3.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_3.x = tmpvar_1.z; + xlv_FOG = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4.w = 0.0; + tmpvar_4.xyz = (tmpvar_2 * (gl_Normal * unity_Scale.w)); + gl_TexCoord[0] = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5.w = 0.0; + tmpvar_5.xyz = (_WorldSpaceLightPos0.xyz - (_Object2World * gl_Vertex).xyz); + gl_TexCoord[1] = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6.w = 0.0; + tmpvar_6.xyz = (_LightMatrix0 * (_Object2World * gl_Vertex)).xyz; + gl_TexCoord[2] = tmpvar_6; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_ScreenPos2-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_ScreenPos2-in.txt new file mode 100644 index 000000000..643d34ed1 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_ScreenPos2-in.txt @@ -0,0 +1,62 @@ +mat3 xll_constructMat3( mat4 m) { + return mat3( vec3( m[0]), vec3( m[1]), vec3( m[2])); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec4 screenPos; +}; +struct v2f_surf { + vec4 pos; + vec3 normal; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; + + +v2f_surf vert_surf( in appdata_full v ); +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + o.pos = ( gl_ModelViewProjectionMatrix * v.vertex ); + o.normal = ( xll_constructMat3( gl_ModelViewMatrixInverseTranspose) * v.normal ); + return o; +} +attribute vec4 TANGENT; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + gl_TexCoord[0] = vec4( xl_retval.normal, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_ScreenPos2-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_ScreenPos2-ir.txt new file mode 100644 index 000000000..50b15335d --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_ScreenPos2-ir.txt @@ -0,0 +1,104 @@ +struct v2f_surf { + vec4 pos; + vec3 normal; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +attribute vec4 TANGENT; +mat3 xll_constructMat3 ( + in mat4 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = m[0].xyz; + vec3 tmpvar_2; + tmpvar_2 = m[1].xyz; + vec3 tmpvar_3; + tmpvar_3 = m[2].xyz; + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + v2f_surf o; + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v.vertex); + o.pos = tmpvar_1; + mat3 tmpvar_2; + tmpvar_2 = (xll_constructMat3 (gl_ModelViewMatrixInverseTranspose)); + vec3 tmpvar_3; + tmpvar_3 = (tmpvar_2 * v.normal); + o.normal = tmpvar_3; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.w = 0.0; + tmpvar_17.xyz = xl_retval.normal.xyz; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + gl_TexCoord[0] = tmpvar_18; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_ScreenPos2-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_ScreenPos2-out.txt new file mode 100644 index 000000000..ec3e493bd --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_ScreenPos2-out.txt @@ -0,0 +1,13 @@ +void main () +{ + mat3 tmpvar_1; + tmpvar_1[0] = gl_ModelViewMatrixInverseTranspose[0].xyz; + tmpvar_1[1] = gl_ModelViewMatrixInverseTranspose[1].xyz; + tmpvar_1[2] = gl_ModelViewMatrixInverseTranspose[2].xyz; + gl_Position = (gl_ModelViewProjectionMatrix * gl_Vertex); + vec4 tmpvar_2; + tmpvar_2.w = 0.0; + tmpvar_2.xyz = (tmpvar_1 * gl_Normal); + gl_TexCoord[0] = tmpvar_2; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_ScreenPosAlbedo-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_ScreenPosAlbedo-in.txt new file mode 100644 index 000000000..643d34ed1 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_ScreenPosAlbedo-in.txt @@ -0,0 +1,62 @@ +mat3 xll_constructMat3( mat4 m) { + return mat3( vec3( m[0]), vec3( m[1]), vec3( m[2])); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec4 screenPos; +}; +struct v2f_surf { + vec4 pos; + vec3 normal; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; + + +v2f_surf vert_surf( in appdata_full v ); +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + o.pos = ( gl_ModelViewProjectionMatrix * v.vertex ); + o.normal = ( xll_constructMat3( gl_ModelViewMatrixInverseTranspose) * v.normal ); + return o; +} +attribute vec4 TANGENT; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + gl_TexCoord[0] = vec4( xl_retval.normal, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_ScreenPosAlbedo-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_ScreenPosAlbedo-ir.txt new file mode 100644 index 000000000..50b15335d --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_ScreenPosAlbedo-ir.txt @@ -0,0 +1,104 @@ +struct v2f_surf { + vec4 pos; + vec3 normal; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +attribute vec4 TANGENT; +mat3 xll_constructMat3 ( + in mat4 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = m[0].xyz; + vec3 tmpvar_2; + tmpvar_2 = m[1].xyz; + vec3 tmpvar_3; + tmpvar_3 = m[2].xyz; + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + v2f_surf o; + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v.vertex); + o.pos = tmpvar_1; + mat3 tmpvar_2; + tmpvar_2 = (xll_constructMat3 (gl_ModelViewMatrixInverseTranspose)); + vec3 tmpvar_3; + tmpvar_3 = (tmpvar_2 * v.normal); + o.normal = tmpvar_3; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.w = 0.0; + tmpvar_17.xyz = xl_retval.normal.xyz; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + gl_TexCoord[0] = tmpvar_18; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_ScreenPosAlbedo-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_ScreenPosAlbedo-out.txt new file mode 100644 index 000000000..ec3e493bd --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_ScreenPosAlbedo-out.txt @@ -0,0 +1,13 @@ +void main () +{ + mat3 tmpvar_1; + tmpvar_1[0] = gl_ModelViewMatrixInverseTranspose[0].xyz; + tmpvar_1[1] = gl_ModelViewMatrixInverseTranspose[1].xyz; + tmpvar_1[2] = gl_ModelViewMatrixInverseTranspose[2].xyz; + gl_Position = (gl_ModelViewProjectionMatrix * gl_Vertex); + vec4 tmpvar_2; + tmpvar_2.w = 0.0; + tmpvar_2.xyz = (tmpvar_1 * gl_Normal); + gl_TexCoord[0] = tmpvar_2; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_ScreenPosAlbedo1-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_ScreenPosAlbedo1-in.txt new file mode 100644 index 000000000..229a380f8 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_ScreenPosAlbedo1-in.txt @@ -0,0 +1,78 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec4 screenPos; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_screenPos; + vec4 hip_screen; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _ProjectionParams; + +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +vec4 ComputeScreenPos( in vec4 pos ); +v2f_surf vert_surf( in appdata_full v ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +vec4 ComputeScreenPos( in vec4 pos ) { + vec4 o; + o = (pos * 0.500000); + o.xy = (vec2( o.x , (o.y * _ProjectionParams.x )) + o.w ); + o.zw = pos.zw ; + return o; +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + PositionFog( v.vertex, o.pos, o.fog); + o.hip_screenPos = ComputeScreenPos( o.pos); + o.hip_screen = ComputeScreenPos( o.pos); + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.hip_screenPos); + gl_TexCoord[1] = vec4( xl_retval.hip_screen); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_ScreenPosAlbedo1-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_ScreenPosAlbedo1-ir.txt new file mode 100644 index 000000000..3d0bf38c6 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_ScreenPosAlbedo1-ir.txt @@ -0,0 +1,132 @@ +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_screenPos; + vec4 hip_screen; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 _ProjectionParams; +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +vec4 ComputeScreenPos ( + in vec4 pos +) +{ + vec4 o; + vec4 tmpvar_1; + tmpvar_1 = (pos * 0.5); + o = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2.x = o.x; + tmpvar_2.y = (o.y * _ProjectionParams.x); + vec2 tmpvar_3; + tmpvar_3 = (tmpvar_2 + o.w); + o.xy = tmpvar_3.xy.xy; + vec2 tmpvar_4; + tmpvar_4 = pos.zw; + o.zw = tmpvar_4.xxxy.zw; + return o; +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + v2f_surf o; + PositionFog (v.vertex, o.pos, o.fog); + vec4 tmpvar_1; + tmpvar_1 = ComputeScreenPos (o.pos); + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + o.hip_screenPos = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = ComputeScreenPos (o.pos); + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + o.hip_screen = tmpvar_4; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = xl_retval.fog; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_FOG = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19 = xl_retval.hip_screenPos.xyzw; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[0] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21 = xl_retval.hip_screen.xyzw; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_TexCoord[1] = tmpvar_22; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_ScreenPosAlbedo1-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_ScreenPosAlbedo1-out.txt new file mode 100644 index 000000000..65efadd7a --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_ScreenPosAlbedo1-out.txt @@ -0,0 +1,33 @@ +varying vec4 xlv_FOG; +uniform vec4 _ProjectionParams; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * gl_Vertex); + vec4 o_i0; + vec4 tmpvar_2; + tmpvar_2 = (tmpvar_1 * 0.5); + o_i0 = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3.x = tmpvar_2.x; + tmpvar_3.y = (tmpvar_2.y * _ProjectionParams.x); + o_i0.xy = (tmpvar_3 + tmpvar_2.w); + o_i0.zw = tmpvar_1.zw; + vec4 o_i0_i1; + vec4 tmpvar_4; + tmpvar_4 = (tmpvar_1 * 0.5); + o_i0_i1 = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5.x = tmpvar_4.x; + tmpvar_5.y = (tmpvar_4.y * _ProjectionParams.x); + o_i0_i1.xy = (tmpvar_5 + tmpvar_4.w); + o_i0_i1.zw = tmpvar_1.zw; + gl_Position = tmpvar_1; + vec4 tmpvar_6; + tmpvar_6.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_6.x = tmpvar_1.z; + xlv_FOG = tmpvar_6; + gl_TexCoord[0] = o_i0; + gl_TexCoord[1] = o_i0_i1; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Slices-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Slices-in.txt new file mode 100644 index 000000000..d26d1b393 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Slices-in.txt @@ -0,0 +1,93 @@ +mat3 xll_constructMat3( mat4 m) { + return mat3( vec3( m[0]), vec3( m[1]), vec3( m[2])); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec3 worldPos; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 worldPos; + vec3 normal; + vec3 lightDir; + vec4 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform mat4 _LightMatrix0; +uniform vec4 _MainTex_ST; +uniform mat4 _Object2World; +uniform vec4 _WorldSpaceLightPos0; + +uniform vec4 unity_Scale; +vec3 WorldSpaceLightDir( in vec4 v ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +v2f_surf vert_surf( in appdata_full v ); +vec3 WorldSpaceLightDir( in vec4 v ) { + vec3 worldPos; + worldPos = ( _Object2World * v ).xyz ; + return (_WorldSpaceLightPos0.xyz - worldPos); +} +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + PositionFog( v.vertex, o.pos, o.fog); + o.hip_pack0.xy = ((v.texcoord.xy * _MainTex_ST.xy ) + _MainTex_ST.zw ); + o.worldPos = ( _Object2World * v.vertex ).xyz ; + o.normal = ( xll_constructMat3( _Object2World) * (v.normal * unity_Scale.w ) ); + o.lightDir = WorldSpaceLightDir( v.vertex); + o._LightCoord = ( _LightMatrix0 * ( _Object2World * v.vertex ) ); + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.hip_pack0, 0.0, 0.0); + gl_TexCoord[1] = vec4( xl_retval.worldPos, 0.0); + gl_TexCoord[2] = vec4( xl_retval.normal, 0.0); + gl_TexCoord[3] = vec4( xl_retval.lightDir, 0.0); + gl_TexCoord[4] = vec4( xl_retval._LightCoord); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Slices-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Slices-ir.txt new file mode 100644 index 000000000..831e675e2 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Slices-ir.txt @@ -0,0 +1,181 @@ +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 worldPos; + vec3 normal; + vec3 lightDir; + vec4 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform mat4 _LightMatrix0; +mat3 xll_constructMat3 ( + in mat4 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = m[0].xyz; + vec3 tmpvar_2; + tmpvar_2 = m[1].xyz; + vec3 tmpvar_3; + tmpvar_3 = m[2].xyz; + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +vec3 WorldSpaceLightDir ( + in vec4 v +) +{ + vec3 worldPos; + vec3 tmpvar_1; + tmpvar_1 = (_Object2World * v).xyz; + worldPos = tmpvar_1; + return (_WorldSpaceLightPos0.xyz - worldPos); +} + +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + v2f_surf o; + PositionFog (v.vertex, o.pos, o.fog); + vec2 tmpvar_1; + tmpvar_1 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + o.hip_pack0 = tmpvar_1.xy.xy; + vec3 tmpvar_2; + tmpvar_2 = (_Object2World * v.vertex).xyz; + o.worldPos = tmpvar_2; + mat3 tmpvar_3; + tmpvar_3 = (xll_constructMat3 (_Object2World)); + vec3 tmpvar_4; + tmpvar_4 = (tmpvar_3 * (v.normal * unity_Scale.w)); + o.normal = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = WorldSpaceLightDir (v.vertex); + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + o.lightDir = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = (_LightMatrix0 * (_Object2World * v.vertex)); + o._LightCoord = tmpvar_7; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = xl_retval.fog; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_FOG = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19.zw = vec2(0.0, 0.0); + tmpvar_19.xy = xl_retval.hip_pack0.xy; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[0] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21.w = 0.0; + tmpvar_21.xyz = xl_retval.worldPos.xyz; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_TexCoord[1] = tmpvar_22; + vec4 tmpvar_23; + tmpvar_23.w = 0.0; + tmpvar_23.xyz = xl_retval.normal.xyz; + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + gl_TexCoord[2] = tmpvar_24; + vec4 tmpvar_25; + tmpvar_25.w = 0.0; + tmpvar_25.xyz = xl_retval.lightDir.xyz; + vec4 tmpvar_26; + tmpvar_26 = tmpvar_25; + gl_TexCoord[3] = tmpvar_26; + vec4 tmpvar_27; + tmpvar_27 = xl_retval._LightCoord.xyzw; + vec4 tmpvar_28; + tmpvar_28 = tmpvar_27; + gl_TexCoord[4] = tmpvar_28; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Slices-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Slices-out.txt new file mode 100644 index 000000000..d7a05196a --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Slices-out.txt @@ -0,0 +1,38 @@ +varying vec4 xlv_FOG; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform mat4 _LightMatrix0; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * gl_Vertex); + mat3 tmpvar_2; + tmpvar_2[0] = _Object2World[0].xyz; + tmpvar_2[1] = _Object2World[1].xyz; + tmpvar_2[2] = _Object2World[2].xyz; + gl_Position = tmpvar_1; + vec4 tmpvar_3; + tmpvar_3.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_3.x = tmpvar_1.z; + xlv_FOG = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4.zw = vec2(0.0, 0.0); + tmpvar_4.xy = ((gl_MultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + gl_TexCoord[0] = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5.w = 0.0; + tmpvar_5.xyz = (_Object2World * gl_Vertex).xyz; + gl_TexCoord[1] = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6.w = 0.0; + tmpvar_6.xyz = (tmpvar_2 * (gl_Normal * unity_Scale.w)); + gl_TexCoord[2] = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7.w = 0.0; + tmpvar_7.xyz = (_WorldSpaceLightPos0.xyz - (_Object2World * gl_Vertex).xyz); + gl_TexCoord[3] = tmpvar_7; + gl_TexCoord[4] = (_LightMatrix0 * (_Object2World * gl_Vertex)); +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Slices1-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Slices1-in.txt new file mode 100644 index 000000000..c9868dc46 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Slices1-in.txt @@ -0,0 +1,84 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec3 worldPos; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 worldPos; + vec4 hip_screen; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _MainTex_ST; +uniform mat4 _Object2World; +uniform vec4 _ProjectionParams; + +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +vec4 ComputeScreenPos( in vec4 pos ); +v2f_surf vert_surf( in appdata_full v ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +vec4 ComputeScreenPos( in vec4 pos ) { + vec4 o; + o = (pos * 0.500000); + o.xy = (vec2( o.x , (o.y * _ProjectionParams.x )) + o.w ); + o.zw = pos.zw ; + return o; +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + PositionFog( v.vertex, o.pos, o.fog); + o.hip_pack0.xy = ((v.texcoord.xy * _MainTex_ST.xy ) + _MainTex_ST.zw ); + o.worldPos = ( _Object2World * v.vertex ).xyz ; + o.hip_screen = ComputeScreenPos( o.pos); + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.hip_pack0, 0.0, 0.0); + gl_TexCoord[1] = vec4( xl_retval.worldPos, 0.0); + gl_TexCoord[2] = vec4( xl_retval.hip_screen); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Slices1-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Slices1-ir.txt new file mode 100644 index 000000000..1d019fc5d --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Slices1-ir.txt @@ -0,0 +1,143 @@ +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 worldPos; + vec4 hip_screen; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 _ProjectionParams; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +vec4 ComputeScreenPos ( + in vec4 pos +) +{ + vec4 o; + vec4 tmpvar_1; + tmpvar_1 = (pos * 0.5); + o = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2.x = o.x; + tmpvar_2.y = (o.y * _ProjectionParams.x); + vec2 tmpvar_3; + tmpvar_3 = (tmpvar_2 + o.w); + o.xy = tmpvar_3.xy.xy; + vec2 tmpvar_4; + tmpvar_4 = pos.zw; + o.zw = tmpvar_4.xxxy.zw; + return o; +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + v2f_surf o; + PositionFog (v.vertex, o.pos, o.fog); + vec2 tmpvar_1; + tmpvar_1 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + o.hip_pack0 = tmpvar_1.xy.xy; + vec3 tmpvar_2; + tmpvar_2 = (_Object2World * v.vertex).xyz; + o.worldPos = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = ComputeScreenPos (o.pos); + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + o.hip_screen = tmpvar_4; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = xl_retval.fog; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_FOG = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19.zw = vec2(0.0, 0.0); + tmpvar_19.xy = xl_retval.hip_pack0.xy; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[0] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21.w = 0.0; + tmpvar_21.xyz = xl_retval.worldPos.xyz; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_TexCoord[1] = tmpvar_22; + vec4 tmpvar_23; + tmpvar_23 = xl_retval.hip_screen.xyzw; + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + gl_TexCoord[2] = tmpvar_24; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Slices1-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Slices1-out.txt new file mode 100644 index 000000000..73455ea57 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Slices1-out.txt @@ -0,0 +1,33 @@ +varying vec4 xlv_FOG; +uniform vec4 _ProjectionParams; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * gl_Vertex); + vec4 o_i0; + vec4 tmpvar_2; + tmpvar_2 = (tmpvar_1 * 0.5); + o_i0 = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3.x = tmpvar_2.x; + tmpvar_3.y = (tmpvar_2.y * _ProjectionParams.x); + o_i0.xy = (tmpvar_3 + tmpvar_2.w); + o_i0.zw = tmpvar_1.zw; + gl_Position = tmpvar_1; + vec4 tmpvar_4; + tmpvar_4.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_4.x = tmpvar_1.z; + xlv_FOG = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5.zw = vec2(0.0, 0.0); + tmpvar_5.xy = ((gl_MultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + gl_TexCoord[0] = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6.w = 0.0; + tmpvar_6.xyz = (_Object2World * gl_Vertex).xyz; + gl_TexCoord[1] = tmpvar_6; + gl_TexCoord[2] = o_i0; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Slices2-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Slices2-in.txt new file mode 100644 index 000000000..811bb171c --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Slices2-in.txt @@ -0,0 +1,91 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec3 worldPos; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 worldPos; + vec4 hip_screen; + vec3 hip_lmapFade; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _MainTex_ST; +uniform mat4 _Object2World; +uniform vec4 _ProjectionParams; + + +uniform vec4 unity_LightmapFade; +uniform vec4 unity_LightmapST; +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +vec4 ComputeScreenPos( in vec4 pos ); +v2f_surf vert_surf( in appdata_full v ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +vec4 ComputeScreenPos( in vec4 pos ) { + vec4 o; + o = (pos * 0.500000); + o.xy = (vec2( o.x , (o.y * _ProjectionParams.x )) + o.w ); + o.zw = pos.zw ; + return o; +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + PositionFog( v.vertex, o.pos, o.fog); + o.hip_pack0.xy = ((v.texcoord.xy * _MainTex_ST.xy ) + _MainTex_ST.zw ); + o.worldPos = ( _Object2World * v.vertex ).xyz ; + o.hip_screen = ComputeScreenPos( o.pos); + o.hip_lmapFade.xy = ((v.texcoord1.xy * unity_LightmapST.xy ) + unity_LightmapST.zw ); + o.hip_lmapFade.z = ((( -( gl_ModelViewMatrix * v.vertex ).z ) * unity_LightmapFade.z ) + unity_LightmapFade.w ); + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.hip_pack0, 0.0, 0.0); + gl_TexCoord[1] = vec4( xl_retval.worldPos, 0.0); + gl_TexCoord[2] = vec4( xl_retval.hip_screen); + gl_TexCoord[3] = vec4( xl_retval.hip_lmapFade, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Slices2-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Slices2-ir.txt new file mode 100644 index 000000000..c0f6bb413 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Slices2-ir.txt @@ -0,0 +1,158 @@ +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 worldPos; + vec4 hip_screen; + vec3 hip_lmapFade; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_LightmapST; +uniform vec4 unity_LightmapFade; +uniform vec4 _ProjectionParams; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +vec4 ComputeScreenPos ( + in vec4 pos +) +{ + vec4 o; + vec4 tmpvar_1; + tmpvar_1 = (pos * 0.5); + o = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2.x = o.x; + tmpvar_2.y = (o.y * _ProjectionParams.x); + vec2 tmpvar_3; + tmpvar_3 = (tmpvar_2 + o.w); + o.xy = tmpvar_3.xy.xy; + vec2 tmpvar_4; + tmpvar_4 = pos.zw; + o.zw = tmpvar_4.xxxy.zw; + return o; +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + v2f_surf o; + PositionFog (v.vertex, o.pos, o.fog); + vec2 tmpvar_1; + tmpvar_1 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + o.hip_pack0 = tmpvar_1.xy.xy; + vec3 tmpvar_2; + tmpvar_2 = (_Object2World * v.vertex).xyz; + o.worldPos = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = ComputeScreenPos (o.pos); + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + o.hip_screen = tmpvar_4; + vec2 tmpvar_5; + tmpvar_5 = ((v.texcoord1.xy * unity_LightmapST.xy) + unity_LightmapST.zw); + o.hip_lmapFade.xy = tmpvar_5.xy.xy; + float tmpvar_6; + tmpvar_6 = ((-((gl_ModelViewMatrix * v.vertex).z) * unity_LightmapFade.z) + unity_LightmapFade.w); + o.hip_lmapFade.z = vec3(tmpvar_6).z; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = xl_retval.fog; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_FOG = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19.zw = vec2(0.0, 0.0); + tmpvar_19.xy = xl_retval.hip_pack0.xy; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[0] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21.w = 0.0; + tmpvar_21.xyz = xl_retval.worldPos.xyz; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_TexCoord[1] = tmpvar_22; + vec4 tmpvar_23; + tmpvar_23 = xl_retval.hip_screen.xyzw; + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + gl_TexCoord[2] = tmpvar_24; + vec4 tmpvar_25; + tmpvar_25.w = 0.0; + tmpvar_25.xyz = xl_retval.hip_lmapFade.xyz; + vec4 tmpvar_26; + tmpvar_26 = tmpvar_25; + gl_TexCoord[3] = tmpvar_26; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Slices2-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Slices2-out.txt new file mode 100644 index 000000000..1c79b9b50 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Slices2-out.txt @@ -0,0 +1,42 @@ +varying vec4 xlv_FOG; +uniform vec4 unity_LightmapST; +uniform vec4 unity_LightmapFade; +uniform vec4 _ProjectionParams; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +void main () +{ + vec3 tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = (gl_ModelViewProjectionMatrix * gl_Vertex); + vec4 o_i0; + vec4 tmpvar_3; + tmpvar_3 = (tmpvar_2 * 0.5); + o_i0 = tmpvar_3; + vec2 tmpvar_4; + tmpvar_4.x = tmpvar_3.x; + tmpvar_4.y = (tmpvar_3.y * _ProjectionParams.x); + o_i0.xy = (tmpvar_4 + tmpvar_3.w); + o_i0.zw = tmpvar_2.zw; + tmpvar_1.xy = ((gl_MultiTexCoord1.xy * unity_LightmapST.xy) + unity_LightmapST.zw); + tmpvar_1.z = ((-((gl_ModelViewMatrix * gl_Vertex).z) * unity_LightmapFade.z) + unity_LightmapFade.w); + gl_Position = tmpvar_2; + vec4 tmpvar_5; + tmpvar_5.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_5.x = tmpvar_2.z; + xlv_FOG = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6.zw = vec2(0.0, 0.0); + tmpvar_6.xy = ((gl_MultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + gl_TexCoord[0] = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7.w = 0.0; + tmpvar_7.xyz = (_Object2World * gl_Vertex).xyz; + gl_TexCoord[1] = tmpvar_7; + gl_TexCoord[2] = o_i0; + vec4 tmpvar_8; + tmpvar_8.w = 0.0; + tmpvar_8.xyz = tmpvar_1; + gl_TexCoord[3] = tmpvar_8; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Slices3-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Slices3-in.txt new file mode 100644 index 000000000..593c03428 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Slices3-in.txt @@ -0,0 +1,86 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec3 worldPos; +}; +struct v2f_surf { + vec4 pos; + vec3 _ShadowCoord0; + vec3 _ShadowCoord1; + vec3 _ShadowCoord2; + vec3 _ShadowCoord3; + vec2 _ShadowZFade; + vec3 worldPos; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _LightShadowData; +uniform mat4 _Object2World; +uniform mat4 _World2Shadow; +uniform mat4 _World2Shadow1; +uniform mat4 _World2Shadow2; +uniform mat4 _World2Shadow3; + + +v2f_surf vert_surf( in appdata_full v ); +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + float z; + vec4 wpos; + o.worldPos = ( _Object2World * v.vertex ).xyz ; + o.pos = ( gl_ModelViewProjectionMatrix * v.vertex ); + z = ( -( gl_ModelViewMatrix * v.vertex ).z ); + o._ShadowZFade.x = z; + o._ShadowZFade.y = ((z * _LightShadowData.z ) + _LightShadowData.w ); + wpos = ( _Object2World * v.vertex ); + o._ShadowCoord0 = ( _World2Shadow * wpos ).xyz ; + o._ShadowCoord1 = ( _World2Shadow1 * wpos ).xyz ; + o._ShadowCoord2 = ( _World2Shadow2 * wpos ).xyz ; + o._ShadowCoord3 = ( _World2Shadow3 * wpos ).xyz ; + return o; +} +attribute vec4 TANGENT; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + gl_TexCoord[0] = vec4( xl_retval._ShadowCoord0, 0.0); + gl_TexCoord[1] = vec4( xl_retval._ShadowCoord1, 0.0); + gl_TexCoord[2] = vec4( xl_retval._ShadowCoord2, 0.0); + gl_TexCoord[3] = vec4( xl_retval._ShadowCoord3, 0.0); + gl_TexCoord[4] = vec4( xl_retval._ShadowZFade, 0.0, 0.0); + gl_TexCoord[5] = vec4( xl_retval.worldPos, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Slices3-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Slices3-ir.txt new file mode 100644 index 000000000..2ef099c52 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Slices3-ir.txt @@ -0,0 +1,146 @@ +struct v2f_surf { + vec4 pos; + vec3 _ShadowCoord0; + vec3 _ShadowCoord1; + vec3 _ShadowCoord2; + vec3 _ShadowCoord3; + vec2 _ShadowZFade; + vec3 worldPos; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +attribute vec4 TANGENT; +uniform mat4 _World2Shadow3; +uniform mat4 _World2Shadow2; +uniform mat4 _World2Shadow1; +uniform mat4 _World2Shadow; +uniform mat4 _Object2World; +uniform vec4 _LightShadowData; +v2f_surf vert_surf ( + in appdata_full v +) +{ + vec4 wpos; + float z; + v2f_surf o; + vec3 tmpvar_1; + tmpvar_1 = (_Object2World * v.vertex).xyz; + o.worldPos = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = (gl_ModelViewProjectionMatrix * v.vertex); + o.pos = tmpvar_2; + float tmpvar_3; + tmpvar_3 = -((gl_ModelViewMatrix * v.vertex).z); + z = tmpvar_3; + float tmpvar_4; + tmpvar_4 = z; + o._ShadowZFade.x = tmpvar_4; + float tmpvar_5; + tmpvar_5 = ((z * _LightShadowData.z) + _LightShadowData.w); + o._ShadowZFade.y = vec2(tmpvar_5).y; + vec4 tmpvar_6; + tmpvar_6 = (_Object2World * v.vertex); + wpos = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = (_World2Shadow * wpos).xyz; + o._ShadowCoord0 = tmpvar_7; + vec3 tmpvar_8; + tmpvar_8 = (_World2Shadow1 * wpos).xyz; + o._ShadowCoord1 = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = (_World2Shadow2 * wpos).xyz; + o._ShadowCoord2 = tmpvar_9; + vec3 tmpvar_10; + tmpvar_10 = (_World2Shadow3 * wpos).xyz; + o._ShadowCoord3 = tmpvar_10; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.w = 0.0; + tmpvar_17.xyz = xl_retval._ShadowCoord0.xyz; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + gl_TexCoord[0] = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19.w = 0.0; + tmpvar_19.xyz = xl_retval._ShadowCoord1.xyz; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[1] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21.w = 0.0; + tmpvar_21.xyz = xl_retval._ShadowCoord2.xyz; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_TexCoord[2] = tmpvar_22; + vec4 tmpvar_23; + tmpvar_23.w = 0.0; + tmpvar_23.xyz = xl_retval._ShadowCoord3.xyz; + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + gl_TexCoord[3] = tmpvar_24; + vec4 tmpvar_25; + tmpvar_25.zw = vec2(0.0, 0.0); + tmpvar_25.xy = xl_retval._ShadowZFade.xy; + vec4 tmpvar_26; + tmpvar_26 = tmpvar_25; + gl_TexCoord[4] = tmpvar_26; + vec4 tmpvar_27; + tmpvar_27.w = 0.0; + tmpvar_27.xyz = xl_retval.worldPos.xyz; + vec4 tmpvar_28; + tmpvar_28 = tmpvar_27; + gl_TexCoord[5] = tmpvar_28; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Slices3-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Slices3-out.txt new file mode 100644 index 000000000..d99fac1d6 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_Slices3-out.txt @@ -0,0 +1,42 @@ +uniform mat4 _World2Shadow3; +uniform mat4 _World2Shadow2; +uniform mat4 _World2Shadow1; +uniform mat4 _World2Shadow; +uniform mat4 _Object2World; +uniform vec4 _LightShadowData; +void main () +{ + vec2 tmpvar_1; + float tmpvar_2; + tmpvar_2 = -((gl_ModelViewMatrix * gl_Vertex).z); + tmpvar_1.x = tmpvar_2; + tmpvar_1.y = ((tmpvar_2 * _LightShadowData.z) + _LightShadowData.w); + vec4 tmpvar_3; + tmpvar_3 = (_Object2World * gl_Vertex); + gl_Position = (gl_ModelViewProjectionMatrix * gl_Vertex); + vec4 tmpvar_4; + tmpvar_4.w = 0.0; + tmpvar_4.xyz = (_World2Shadow * tmpvar_3).xyz; + gl_TexCoord[0] = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5.w = 0.0; + tmpvar_5.xyz = (_World2Shadow1 * tmpvar_3).xyz; + gl_TexCoord[1] = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6.w = 0.0; + tmpvar_6.xyz = (_World2Shadow2 * tmpvar_3).xyz; + gl_TexCoord[2] = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7.w = 0.0; + tmpvar_7.xyz = (_World2Shadow3 * tmpvar_3).xyz; + gl_TexCoord[3] = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8.zw = vec2(0.0, 0.0); + tmpvar_8.xy = tmpvar_1; + gl_TexCoord[4] = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9.w = 0.0; + tmpvar_9.xyz = (_Object2World * gl_Vertex).xyz; + gl_TexCoord[5] = tmpvar_9; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_WorldRefl-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_WorldRefl-in.txt new file mode 100644 index 000000000..f8a0e59fe --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_WorldRefl-in.txt @@ -0,0 +1,96 @@ +mat3 xll_constructMat3( mat4 m) { + return mat3( vec3( m[0]), vec3( m[1]), vec3( m[2])); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec3 worldRefl; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec3 worldRefl; + vec3 normal; + vec3 lightDir; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform mat4 _Object2World; +uniform mat4 _World2Object; +uniform vec3 _WorldSpaceCameraPos; +uniform vec4 _WorldSpaceLightPos0; + +uniform vec4 unity_Scale; +vec3 WorldSpaceLightDir( in vec4 v ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +vec3 ObjSpaceViewDir( in vec4 v ); +v2f_surf vert_surf( in appdata_full v ); +vec3 WorldSpaceLightDir( in vec4 v ) { + vec3 worldPos; + worldPos = ( _Object2World * v ).xyz ; + return _WorldSpaceLightPos0.xyz ; +} +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +vec3 ObjSpaceViewDir( in vec4 v ) { + vec3 objSpaceCameraPos; + objSpaceCameraPos = (( _World2Object * vec4( _WorldSpaceCameraPos.xyz , 1.00000) ).xyz * unity_Scale.w ); + return (objSpaceCameraPos - v.xyz ); +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + vec3 viewDir; + vec3 viewRefl; + PositionFog( v.vertex, o.pos, o.fog); + viewDir = ( -ObjSpaceViewDir( v.vertex) ); + viewRefl = reflect( viewDir, v.normal); + o.worldRefl = ( xll_constructMat3( _Object2World) * viewRefl ); + o.normal = ( xll_constructMat3( _Object2World) * (v.normal * unity_Scale.w ) ); + o.lightDir = WorldSpaceLightDir( v.vertex); + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.worldRefl, 0.0); + gl_TexCoord[1] = vec4( xl_retval.normal, 0.0); + gl_TexCoord[2] = vec4( xl_retval.lightDir, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_WorldRefl-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_WorldRefl-ir.txt new file mode 100644 index 000000000..18a09433b --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_WorldRefl-ir.txt @@ -0,0 +1,190 @@ +struct v2f_surf { + vec4 pos; + float fog; + vec3 worldRefl; + vec3 normal; + vec3 lightDir; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform vec3 _WorldSpaceCameraPos; +uniform mat4 _World2Object; +uniform mat4 _Object2World; +mat3 xll_constructMat3 ( + in mat4 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = m[0].xyz; + vec3 tmpvar_2; + tmpvar_2 = m[1].xyz; + vec3 tmpvar_3; + tmpvar_3 = m[2].xyz; + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +vec3 WorldSpaceLightDir ( + in vec4 v +) +{ + vec3 worldPos; + vec3 tmpvar_1; + tmpvar_1 = (_Object2World * v).xyz; + worldPos = tmpvar_1; + return _WorldSpaceLightPos0.xyz; +} + +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +vec3 ObjSpaceViewDir ( + in vec4 v +) +{ + vec3 objSpaceCameraPos; + vec4 tmpvar_1; + tmpvar_1.w = 1.0; + tmpvar_1.xyz = _WorldSpaceCameraPos.xyz.xyz; + vec3 tmpvar_2; + tmpvar_2 = ((_World2Object * tmpvar_1).xyz * unity_Scale.w); + objSpaceCameraPos = tmpvar_2; + return (objSpaceCameraPos - v.xyz); +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + vec3 viewRefl; + vec3 viewDir; + v2f_surf o; + PositionFog (v.vertex, o.pos, o.fog); + vec3 tmpvar_1; + tmpvar_1 = ObjSpaceViewDir (v.vertex); + vec3 tmpvar_2; + tmpvar_2 = -(tmpvar_1); + viewDir = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = reflect (viewDir, v.normal); + vec3 tmpvar_4; + tmpvar_4 = tmpvar_3; + viewRefl = tmpvar_4; + mat3 tmpvar_5; + tmpvar_5 = (xll_constructMat3 (_Object2World)); + vec3 tmpvar_6; + tmpvar_6 = (tmpvar_5 * viewRefl); + o.worldRefl = tmpvar_6; + mat3 tmpvar_7; + tmpvar_7 = (xll_constructMat3 (_Object2World)); + vec3 tmpvar_8; + tmpvar_8 = (tmpvar_7 * (v.normal * unity_Scale.w)); + o.normal = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = WorldSpaceLightDir (v.vertex); + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + o.lightDir = tmpvar_10; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = xl_retval.fog; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_FOG = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19.w = 0.0; + tmpvar_19.xyz = xl_retval.worldRefl.xyz; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[0] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21.w = 0.0; + tmpvar_21.xyz = xl_retval.normal.xyz; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_TexCoord[1] = tmpvar_22; + vec4 tmpvar_23; + tmpvar_23.w = 0.0; + tmpvar_23.xyz = xl_retval.lightDir.xyz; + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + gl_TexCoord[2] = tmpvar_24; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_WorldRefl-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_WorldRefl-out.txt new file mode 100644 index 000000000..73fa4599e --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_WorldRefl-out.txt @@ -0,0 +1,40 @@ +varying vec4 xlv_FOG; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform vec3 _WorldSpaceCameraPos; +uniform mat4 _World2Object; +uniform mat4 _Object2World; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * gl_Vertex); + vec4 tmpvar_2; + tmpvar_2.w = 1.0; + tmpvar_2.xyz = _WorldSpaceCameraPos; + mat3 tmpvar_3; + tmpvar_3[0] = _Object2World[0].xyz; + tmpvar_3[1] = _Object2World[1].xyz; + tmpvar_3[2] = _Object2World[2].xyz; + mat3 tmpvar_4; + tmpvar_4[0] = _Object2World[0].xyz; + tmpvar_4[1] = _Object2World[1].xyz; + tmpvar_4[2] = _Object2World[2].xyz; + gl_Position = tmpvar_1; + vec4 tmpvar_5; + tmpvar_5.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_5.x = tmpvar_1.z; + xlv_FOG = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6.w = 0.0; + tmpvar_6.xyz = (tmpvar_3 * reflect ((gl_Vertex.xyz - ((_World2Object * tmpvar_2).xyz * unity_Scale.w)), gl_Normal)); + gl_TexCoord[0] = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7.w = 0.0; + tmpvar_7.xyz = (tmpvar_4 * (gl_Normal * unity_Scale.w)); + gl_TexCoord[1] = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8.w = 0.0; + tmpvar_8.xyz = _WorldSpaceLightPos0.xyz; + gl_TexCoord[2] = tmpvar_8; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_WorldRefl1-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_WorldRefl1-in.txt new file mode 100644 index 000000000..e5f10439a --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_WorldRefl1-in.txt @@ -0,0 +1,62 @@ +mat3 xll_constructMat3( mat4 m) { + return mat3( vec3( m[0]), vec3( m[1]), vec3( m[2])); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec3 worldRefl; +}; +struct v2f_surf { + vec4 pos; + vec3 normal; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; + + +v2f_surf vert_surf( in appdata_full v ); +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + o.pos = ( gl_ModelViewProjectionMatrix * v.vertex ); + o.normal = ( xll_constructMat3( gl_ModelViewMatrixInverseTranspose) * v.normal ); + return o; +} +attribute vec4 TANGENT; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + gl_TexCoord[0] = vec4( xl_retval.normal, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_WorldRefl1-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_WorldRefl1-ir.txt new file mode 100644 index 000000000..50b15335d --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_WorldRefl1-ir.txt @@ -0,0 +1,104 @@ +struct v2f_surf { + vec4 pos; + vec3 normal; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +attribute vec4 TANGENT; +mat3 xll_constructMat3 ( + in mat4 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = m[0].xyz; + vec3 tmpvar_2; + tmpvar_2 = m[1].xyz; + vec3 tmpvar_3; + tmpvar_3 = m[2].xyz; + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + v2f_surf o; + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v.vertex); + o.pos = tmpvar_1; + mat3 tmpvar_2; + tmpvar_2 = (xll_constructMat3 (gl_ModelViewMatrixInverseTranspose)); + vec3 tmpvar_3; + tmpvar_3 = (tmpvar_2 * v.normal); + o.normal = tmpvar_3; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.w = 0.0; + tmpvar_17.xyz = xl_retval.normal.xyz; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + gl_TexCoord[0] = tmpvar_18; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_WorldRefl1-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_WorldRefl1-out.txt new file mode 100644 index 000000000..ec3e493bd --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Surface_WorldRefl1-out.txt @@ -0,0 +1,13 @@ +void main () +{ + mat3 tmpvar_1; + tmpvar_1[0] = gl_ModelViewMatrixInverseTranspose[0].xyz; + tmpvar_1[1] = gl_ModelViewMatrixInverseTranspose[1].xyz; + tmpvar_1[2] = gl_ModelViewMatrixInverseTranspose[2].xyz; + gl_Position = (gl_ModelViewProjectionMatrix * gl_Vertex); + vec4 tmpvar_2; + tmpvar_2.w = 0.0; + tmpvar_2.xyz = (tmpvar_1 * gl_Normal); + gl_TexCoord[0] = tmpvar_2; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Test_CgNormals-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Test_CgNormals-in.txt new file mode 100644 index 000000000..f1f5793fe --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Test_CgNormals-in.txt @@ -0,0 +1,46 @@ +mat3 xll_constructMat3( mat4 m) { + return mat3( vec3( m[0]), vec3( m[1]), vec3( m[2])); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct v2f { + vec4 pos; + vec4 color; +}; +struct appdata_base { + vec4 vertex; + vec3 normal; + vec4 texcoord; +}; + + +v2f vert( in appdata_base v ); +v2f vert( in appdata_base v ) { + v2f o; + vec3 normal; + o.pos = ( gl_ModelViewProjectionMatrix * v.vertex ); + normal = ( xll_constructMat3( gl_ModelViewMatrixInverseTranspose) * v.normal ); + o.color = vec4( ((normal * 0.500000) + 0.500000), 1.00000); + return o; +} +void main() { + v2f xl_retval; + appdata_base xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xl_retval = vert( xlt_v); + gl_Position = vec4( xl_retval.pos); + gl_FrontColor = vec4( xl_retval.color); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Test_CgNormals-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Test_CgNormals-ir.txt new file mode 100644 index 000000000..3ef8127a9 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Test_CgNormals-ir.txt @@ -0,0 +1,91 @@ +struct v2f { + vec4 pos; + vec4 color; +}; +struct appdata_base { + vec4 vertex; + vec3 normal; + vec4 texcoord; +}; +mat3 xll_constructMat3 ( + in mat4 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = m[0].xyz; + vec3 tmpvar_2; + tmpvar_2 = m[1].xyz; + vec3 tmpvar_3; + tmpvar_3 = m[2].xyz; + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +v2f vert ( + in appdata_base v +) +{ + vec3 normal; + v2f o; + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v.vertex); + o.pos = tmpvar_1; + mat3 tmpvar_2; + tmpvar_2 = (xll_constructMat3 (gl_ModelViewMatrixInverseTranspose)); + vec3 tmpvar_3; + tmpvar_3 = (tmpvar_2 * v.normal); + normal = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4.w = 1.0; + tmpvar_4.xyz = ((normal * 0.5) + 0.5).xyz; + vec4 tmpvar_5; + tmpvar_5 = tmpvar_4; + o.color = tmpvar_5; + return o; +} + +void main () +{ + appdata_base xlt_v; + v2f xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = gl_Normal.xyz; + vec3 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.normal = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.texcoord = tmpvar_6; + v2f tmpvar_7; + tmpvar_7 = vert (xlt_v); + v2f tmpvar_8; + tmpvar_8 = tmpvar_7; + xl_retval = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = xl_retval.pos.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + gl_Position = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = xl_retval.color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + gl_FrontColor = tmpvar_12; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Test_CgNormals-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Test_CgNormals-out.txt new file mode 100644 index 000000000..4a53ccc60 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Test_CgNormals-out.txt @@ -0,0 +1,13 @@ +void main () +{ + mat3 tmpvar_1; + tmpvar_1[0] = gl_ModelViewMatrixInverseTranspose[0].xyz; + tmpvar_1[1] = gl_ModelViewMatrixInverseTranspose[1].xyz; + tmpvar_1[2] = gl_ModelViewMatrixInverseTranspose[2].xyz; + vec4 tmpvar_2; + tmpvar_2.w = 1.0; + tmpvar_2.xyz = (((tmpvar_1 * gl_Normal) * 0.5) + 0.5); + gl_Position = (gl_ModelViewProjectionMatrix * gl_Vertex); + gl_FrontColor = tmpvar_2; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Test_VertexShaderDepthTexture-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Test_VertexShaderDepthTexture-in.txt new file mode 100644 index 000000000..dcbb0e44d --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Test_VertexShaderDepthTexture-in.txt @@ -0,0 +1,47 @@ +vec4 xll_tex2Dlod(sampler2D s, vec4 coord) { + return texture2DLod( s, coord.xy, coord.w); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct v2f { + vec4 pos; + vec2 uv; +}; +struct appdata_base { + vec4 vertex; + vec3 normal; + vec4 texcoord; +}; +uniform sampler2D _CameraDepthTexture; + +v2f vert( in appdata_base v ); +v2f vert( in appdata_base v ) { + float tex; + v2f o; + tex = xll_tex2Dlod( _CameraDepthTexture, vec4( v.texcoord.xy , 0.000000, 0.000000)).x ; + v.vertex.y += ((1.00000 - float( tex)) * 3.00000); + o.pos = ( gl_ModelViewProjectionMatrix * v.vertex ); + o.uv = v.texcoord.xy ; + return o; +} +void main() { + v2f xl_retval; + appdata_base xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xl_retval = vert( xlt_v); + gl_Position = vec4( xl_retval.pos); + gl_TexCoord[0] = vec4( xl_retval.uv, 0.0, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Test_VertexShaderDepthTexture-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Test_VertexShaderDepthTexture-ir.txt new file mode 100644 index 000000000..e59ef5556 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Test_VertexShaderDepthTexture-ir.txt @@ -0,0 +1,83 @@ +struct v2f { + vec4 pos; + vec2 uv; +}; +struct appdata_base { + vec4 vertex; + vec3 normal; + vec4 texcoord; +}; +uniform sampler2D _CameraDepthTexture; +vec4 xll_tex2Dlod ( + in sampler2D s, + in vec4 coord +) +{ + vec4 tmpvar_1; + tmpvar_1 = texture2DLod (s, coord.xy, coord.w); + return tmpvar_1; +} + +v2f vert ( + in appdata_base v +) +{ + v2f o; + float tex; + vec4 tmpvar_1; + tmpvar_1.zw = vec2(0.0, 0.0); + tmpvar_1.xy = v.texcoord.xy.xy; + vec4 tmpvar_2; + tmpvar_2 = xll_tex2Dlod (_CameraDepthTexture, tmpvar_1); + float tmpvar_3; + tmpvar_3 = tmpvar_2.x; + tex = tmpvar_3; + float tmpvar_4; + tmpvar_4 = (v.vertex.y + ((1.0 - tex) * 3.0)); + v.vertex.y = vec2(tmpvar_4).y; + vec4 tmpvar_5; + tmpvar_5 = (gl_ModelViewProjectionMatrix * v.vertex); + o.pos = tmpvar_5; + vec2 tmpvar_6; + tmpvar_6 = v.texcoord.xy; + o.uv = tmpvar_6; + return o; +} + +void main () +{ + appdata_base xlt_v; + v2f xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = gl_Normal.xyz; + vec3 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.normal = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.texcoord = tmpvar_6; + v2f tmpvar_7; + tmpvar_7 = vert (xlt_v); + v2f tmpvar_8; + tmpvar_8 = tmpvar_7; + xl_retval = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = xl_retval.pos.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + gl_Position = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11.zw = vec2(0.0, 0.0); + tmpvar_11.xy = xl_retval.uv.xy; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + gl_TexCoord[0] = tmpvar_12; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Test_VertexShaderDepthTexture-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Test_VertexShaderDepthTexture-out.txt new file mode 100644 index 000000000..c11b1a4f2 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Test_VertexShaderDepthTexture-out.txt @@ -0,0 +1,16 @@ +uniform sampler2D _CameraDepthTexture; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex; + vec4 tmpvar_2; + tmpvar_2.zw = vec2(0.0, 0.0); + tmpvar_2.xy = gl_MultiTexCoord0.xy; + tmpvar_1.y = (gl_Vertex.y + ((1.0 - texture2DLod (_CameraDepthTexture, tmpvar_2.xy, 0.0).x) * 3.0)); + gl_Position = (gl_ModelViewProjectionMatrix * tmpvar_1); + vec4 tmpvar_3; + tmpvar_3.zw = vec2(0.0, 0.0); + tmpvar_3.xy = gl_MultiTexCoord0.xy; + gl_TexCoord[0] = tmpvar_3; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Test_VertexShaderTexture-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Test_VertexShaderTexture-in.txt new file mode 100644 index 000000000..0511cca4c --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Test_VertexShaderTexture-in.txt @@ -0,0 +1,47 @@ +vec4 xll_tex2Dlod(sampler2D s, vec4 coord) { + return texture2DLod( s, coord.xy, coord.w); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct v2f { + vec4 pos; + vec2 uv; +}; +struct appdata_base { + vec4 vertex; + vec3 normal; + vec4 texcoord; +}; +uniform sampler2D _MainTex; + +v2f vert( in appdata_base v ); +v2f vert( in appdata_base v ) { + vec4 tex; + v2f o; + tex = xll_tex2Dlod( _MainTex, vec4( v.texcoord.xy , 0.000000, 0.000000)); + v.vertex.y += (tex.x * 2.00000); + o.pos = ( gl_ModelViewProjectionMatrix * v.vertex ); + o.uv = v.texcoord.xy ; + return o; +} +void main() { + v2f xl_retval; + appdata_base xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xl_retval = vert( xlt_v); + gl_Position = vec4( xl_retval.pos); + gl_TexCoord[0] = vec4( xl_retval.uv, 0.0, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Test_VertexShaderTexture-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Test_VertexShaderTexture-ir.txt new file mode 100644 index 000000000..ef7878757 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Test_VertexShaderTexture-ir.txt @@ -0,0 +1,83 @@ +struct v2f { + vec4 pos; + vec2 uv; +}; +struct appdata_base { + vec4 vertex; + vec3 normal; + vec4 texcoord; +}; +uniform sampler2D _MainTex; +vec4 xll_tex2Dlod ( + in sampler2D s, + in vec4 coord +) +{ + vec4 tmpvar_1; + tmpvar_1 = texture2DLod (s, coord.xy, coord.w); + return tmpvar_1; +} + +v2f vert ( + in appdata_base v +) +{ + v2f o; + vec4 tex; + vec4 tmpvar_1; + tmpvar_1.zw = vec2(0.0, 0.0); + tmpvar_1.xy = v.texcoord.xy.xy; + vec4 tmpvar_2; + tmpvar_2 = xll_tex2Dlod (_MainTex, tmpvar_1); + vec4 tmpvar_3; + tmpvar_3 = tmpvar_2; + tex = tmpvar_3; + float tmpvar_4; + tmpvar_4 = (v.vertex.y + (tex.x * 2.0)); + v.vertex.y = vec2(tmpvar_4).y; + vec4 tmpvar_5; + tmpvar_5 = (gl_ModelViewProjectionMatrix * v.vertex); + o.pos = tmpvar_5; + vec2 tmpvar_6; + tmpvar_6 = v.texcoord.xy; + o.uv = tmpvar_6; + return o; +} + +void main () +{ + appdata_base xlt_v; + v2f xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = gl_Normal.xyz; + vec3 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.normal = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.texcoord = tmpvar_6; + v2f tmpvar_7; + tmpvar_7 = vert (xlt_v); + v2f tmpvar_8; + tmpvar_8 = tmpvar_7; + xl_retval = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = xl_retval.pos.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + gl_Position = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11.zw = vec2(0.0, 0.0); + tmpvar_11.xy = xl_retval.uv.xy; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + gl_TexCoord[0] = tmpvar_12; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Test_VertexShaderTexture-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Test_VertexShaderTexture-out.txt new file mode 100644 index 000000000..ad4a51315 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Test_VertexShaderTexture-out.txt @@ -0,0 +1,16 @@ +uniform sampler2D _MainTex; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex; + vec4 tmpvar_2; + tmpvar_2.zw = vec2(0.0, 0.0); + tmpvar_2.xy = gl_MultiTexCoord0.xy; + tmpvar_1.y = (gl_Vertex.y + (texture2DLod (_MainTex, tmpvar_2.xy, 0.0).x * 2.0)); + gl_Position = (gl_ModelViewProjectionMatrix * tmpvar_1); + vec4 tmpvar_3; + tmpvar_3.zw = vec2(0.0, 0.0); + tmpvar_3.xy = gl_MultiTexCoord0.xy; + gl_TexCoord[0] = tmpvar_3; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-TexGen_Cube_Refl-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-TexGen_Cube_Refl-in.txt new file mode 100644 index 000000000..c438ed98b --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-TexGen_Cube_Refl-in.txt @@ -0,0 +1,56 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct v2f { + vec4 vertex; + vec4 color; + vec3 texcoord; +}; +struct appdata_t { + vec4 vertex; + vec4 color; + vec3 normal; +}; +uniform mat4 _World2Object; +uniform vec3 _WorldSpaceCameraPos; + + +uniform vec4 unity_Scale; +vec3 ObjSpaceViewDir( in vec4 v ); +v2f vert( in appdata_t v ); +vec3 ObjSpaceViewDir( in vec4 v ) { + vec3 objSpaceCameraPos; + objSpaceCameraPos = (( _World2Object * vec4( _WorldSpaceCameraPos.xyz , 1.00000) ).xyz * unity_Scale.w ); + return (objSpaceCameraPos - v.xyz ); +} +v2f vert( in appdata_t v ) { + v2f o; + vec3 viewDir; + o.vertex = ( gl_ModelViewProjectionMatrix * v.vertex ); + viewDir = ( -normalize( ObjSpaceViewDir( v.vertex) ) ); + o.texcoord = reflect( viewDir, v.normal); + o.texcoord = vec3( ( gl_ModelViewMatrix * vec4( o.texcoord, 0.000000) )); + o.color = v.color; + return o; +} +void main() { + v2f xl_retval; + appdata_t xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.color = vec4( gl_Color); + xlt_v.normal = vec3( gl_Normal); + xl_retval = vert( xlt_v); + gl_Position = vec4( xl_retval.vertex); + gl_FrontColor = vec4( xl_retval.color); + gl_TexCoord[0] = vec4( xl_retval.texcoord, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-TexGen_Cube_Refl-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-TexGen_Cube_Refl-ir.txt new file mode 100644 index 000000000..c698dbbdc --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-TexGen_Cube_Refl-ir.txt @@ -0,0 +1,104 @@ +struct v2f { + vec4 vertex; + vec4 color; + vec3 texcoord; +}; +struct appdata_t { + vec4 vertex; + vec4 color; + vec3 normal; +}; +uniform vec4 unity_Scale; +uniform vec3 _WorldSpaceCameraPos; +uniform mat4 _World2Object; +vec3 ObjSpaceViewDir ( + in vec4 v +) +{ + vec3 objSpaceCameraPos; + vec4 tmpvar_1; + tmpvar_1.w = 1.0; + tmpvar_1.xyz = _WorldSpaceCameraPos.xyz.xyz; + vec3 tmpvar_2; + tmpvar_2 = ((_World2Object * tmpvar_1).xyz * unity_Scale.w); + objSpaceCameraPos = tmpvar_2; + return (objSpaceCameraPos - v.xyz); +} + +v2f vert ( + in appdata_t v +) +{ + vec3 viewDir; + v2f o; + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v.vertex); + o.vertex = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = ObjSpaceViewDir (v.vertex); + vec3 tmpvar_3; + tmpvar_3 = normalize (tmpvar_2); + vec3 tmpvar_4; + tmpvar_4 = -(tmpvar_3); + viewDir = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = reflect (viewDir, v.normal); + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + o.texcoord = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7.w = 0.0; + tmpvar_7.xyz = o.texcoord.xyz; + vec3 tmpvar_8; + tmpvar_8 = (gl_ModelViewMatrix * tmpvar_7).xyz; + vec3 tmpvar_9; + tmpvar_9 = tmpvar_8; + o.texcoord = tmpvar_9; + vec4 tmpvar_10; + tmpvar_10 = v.color; + o.color = tmpvar_10; + return o; +} + +void main () +{ + appdata_t xlt_v; + v2f xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = gl_Color.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.color = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + v2f tmpvar_7; + tmpvar_7 = vert (xlt_v); + v2f tmpvar_8; + tmpvar_8 = tmpvar_7; + xl_retval = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = xl_retval.vertex.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + gl_Position = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = xl_retval.color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + gl_FrontColor = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13.w = 0.0; + tmpvar_13.xyz = xl_retval.texcoord.xyz; + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + gl_TexCoord[0] = tmpvar_14; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-TexGen_Cube_Refl-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-TexGen_Cube_Refl-out.txt new file mode 100644 index 000000000..2f901cd0e --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-TexGen_Cube_Refl-out.txt @@ -0,0 +1,19 @@ +uniform vec4 unity_Scale; +uniform vec3 _WorldSpaceCameraPos; +uniform mat4 _World2Object; +void main () +{ + vec4 tmpvar_1; + tmpvar_1.w = 1.0; + tmpvar_1.xyz = _WorldSpaceCameraPos; + vec4 tmpvar_2; + tmpvar_2.w = 0.0; + tmpvar_2.xyz = reflect (-(normalize ((((_World2Object * tmpvar_1).xyz * unity_Scale.w) - gl_Vertex.xyz))), gl_Normal); + gl_Position = (gl_ModelViewProjectionMatrix * gl_Vertex); + gl_FrontColor = gl_Color; + vec4 tmpvar_3; + tmpvar_3.w = 0.0; + tmpvar_3.xyz = (gl_ModelViewMatrix * tmpvar_2).xyz; + gl_TexCoord[0] = tmpvar_3; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Toon_Basic-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Toon_Basic-in.txt new file mode 100644 index 000000000..4722021d7 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Toon_Basic-in.txt @@ -0,0 +1,45 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct v2f { + vec4 pos; + vec2 texcoord; + vec3 cubenormal; +}; +struct appdata { + vec4 vertex; + vec2 texcoord; + vec3 normal; +}; +uniform vec4 _MainTex_ST; + + +v2f vert( in appdata v ); +v2f vert( in appdata v ) { + v2f o; + o.pos = ( gl_ModelViewProjectionMatrix * v.vertex ); + o.texcoord = ((v.texcoord.xy * _MainTex_ST.xy ) + _MainTex_ST.zw ); + o.cubenormal = vec3( ( gl_ModelViewMatrix * vec4( v.normal, 0.000000) )); + return o; +} +void main() { + v2f xl_retval; + appdata xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.texcoord = vec2( gl_MultiTexCoord0); + xlt_v.normal = vec3( gl_Normal); + xl_retval = vert( xlt_v); + gl_Position = vec4( xl_retval.pos); + gl_TexCoord[0] = vec4( xl_retval.texcoord, 0.0, 0.0); + gl_TexCoord[1] = vec4( xl_retval.cubenormal, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Toon_Basic-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Toon_Basic-ir.txt new file mode 100644 index 000000000..b4363fe50 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Toon_Basic-ir.txt @@ -0,0 +1,76 @@ +struct v2f { + vec4 pos; + vec2 texcoord; + vec3 cubenormal; +}; +struct appdata { + vec4 vertex; + vec2 texcoord; + vec3 normal; +}; +uniform vec4 _MainTex_ST; +v2f vert ( + in appdata v +) +{ + v2f o; + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v.vertex); + o.pos = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + o.texcoord = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3.w = 0.0; + tmpvar_3.xyz = v.normal.xyz; + vec3 tmpvar_4; + tmpvar_4 = (gl_ModelViewMatrix * tmpvar_3).xyz; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_4; + o.cubenormal = tmpvar_5; + return o; +} + +void main () +{ + appdata xlt_v; + v2f xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = gl_MultiTexCoord0.xy; + vec2 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.texcoord = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + v2f tmpvar_7; + tmpvar_7 = vert (xlt_v); + v2f tmpvar_8; + tmpvar_8 = tmpvar_7; + xl_retval = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = xl_retval.pos.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + gl_Position = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11.zw = vec2(0.0, 0.0); + tmpvar_11.xy = xl_retval.texcoord.xy; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + gl_TexCoord[0] = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13.w = 0.0; + tmpvar_13.xyz = xl_retval.cubenormal.xyz; + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + gl_TexCoord[1] = tmpvar_14; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Toon_Basic-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Toon_Basic-out.txt new file mode 100644 index 000000000..fa85a3cc8 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Toon_Basic-out.txt @@ -0,0 +1,17 @@ +uniform vec4 _MainTex_ST; +void main () +{ + vec4 tmpvar_1; + tmpvar_1.w = 0.0; + tmpvar_1.xyz = gl_Normal; + gl_Position = (gl_ModelViewProjectionMatrix * gl_Vertex); + vec4 tmpvar_2; + tmpvar_2.zw = vec2(0.0, 0.0); + tmpvar_2.xy = ((gl_MultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + gl_TexCoord[0] = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3.w = 0.0; + tmpvar_3.xyz = (gl_ModelViewMatrix * tmpvar_1).xyz; + gl_TexCoord[1] = tmpvar_3; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Transparent_Bumped_Specular-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Transparent_Bumped_Specular-in.txt new file mode 100644 index 000000000..01f68b11f --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Transparent_Bumped_Specular-in.txt @@ -0,0 +1,101 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 lightDir; + vec3 viewDir; + vec3 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _BumpMap_ST; +uniform mat4 _LightMatrix0; +uniform vec4 _MainTex_ST; +uniform mat4 _Object2World; +uniform mat4 _World2Object; +uniform vec3 _WorldSpaceCameraPos; +uniform vec4 _WorldSpaceLightPos0; + +uniform vec4 unity_Scale; +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +vec3 ObjSpaceViewDir( in vec4 v ); +vec3 ObjSpaceLightDir( in vec4 v ); +v2f_surf vert_surf( in appdata_full v ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +vec3 ObjSpaceViewDir( in vec4 v ) { + vec3 objSpaceCameraPos; + objSpaceCameraPos = (( _World2Object * vec4( _WorldSpaceCameraPos.xyz , 1.00000) ).xyz * unity_Scale.w ); + return (objSpaceCameraPos - v.xyz ); +} +vec3 ObjSpaceLightDir( in vec4 v ) { + vec3 objSpaceLightPos; + objSpaceLightPos = ( _World2Object * _WorldSpaceLightPos0 ).xyz ; + return ((objSpaceLightPos.xyz * unity_Scale.w ) - v.xyz ); +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + vec3 binormal; + mat3 rotation; + PositionFog( v.vertex, o.pos, o.fog); + o.hip_pack0.xy = ((v.texcoord.xy * _MainTex_ST.xy ) + _MainTex_ST.zw ); + o.hip_pack0.zw = ((v.texcoord.xy * _BumpMap_ST.xy ) + _BumpMap_ST.zw ); + binormal = (cross( v.normal, v.tangent.xyz ) * v.tangent.w ); + rotation = mat3( v.tangent.x , binormal.x , v.normal.x , v.tangent.y , binormal.y , v.normal.y , v.tangent.z , binormal.z , v.normal.z ); + o.lightDir = ( rotation * ObjSpaceLightDir( v.vertex) ); + o.viewDir = ( rotation * ObjSpaceViewDir( v.vertex) ); + o._LightCoord = ( _LightMatrix0 * ( _Object2World * v.vertex ) ).xyz ; + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.hip_pack0); + gl_TexCoord[1] = vec4( xl_retval.lightDir, 0.0); + gl_TexCoord[2] = vec4( xl_retval.viewDir, 0.0); + gl_TexCoord[3] = vec4( xl_retval._LightCoord, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Transparent_Bumped_Specular-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Transparent_Bumped_Specular-ir.txt new file mode 100644 index 000000000..87f27d197 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Transparent_Bumped_Specular-ir.txt @@ -0,0 +1,206 @@ +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 lightDir; + vec3 viewDir; + vec3 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform vec3 _WorldSpaceCameraPos; +uniform mat4 _World2Object; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform mat4 _LightMatrix0; +uniform vec4 _BumpMap_ST; +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +vec3 ObjSpaceViewDir ( + in vec4 v +) +{ + vec3 objSpaceCameraPos; + vec4 tmpvar_1; + tmpvar_1.w = 1.0; + tmpvar_1.xyz = _WorldSpaceCameraPos.xyz.xyz; + vec3 tmpvar_2; + tmpvar_2 = ((_World2Object * tmpvar_1).xyz * unity_Scale.w); + objSpaceCameraPos = tmpvar_2; + return (objSpaceCameraPos - v.xyz); +} + +vec3 ObjSpaceLightDir ( + in vec4 v +) +{ + vec3 objSpaceLightPos; + vec3 tmpvar_1; + tmpvar_1 = (_World2Object * _WorldSpaceLightPos0).xyz; + objSpaceLightPos = tmpvar_1; + return ((objSpaceLightPos.xyz * unity_Scale.w) - v.xyz); +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + mat3 rotation; + vec3 binormal; + v2f_surf o; + PositionFog (v.vertex, o.pos, o.fog); + vec2 tmpvar_1; + tmpvar_1 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + o.hip_pack0.xy = tmpvar_1.xy.xy; + vec2 tmpvar_2; + tmpvar_2 = ((v.texcoord.xy * _BumpMap_ST.xy) + _BumpMap_ST.zw); + o.hip_pack0.zw = tmpvar_2.xxxy.zw; + vec3 tmpvar_3; + tmpvar_3 = cross (v.normal, v.tangent.xyz); + vec3 tmpvar_4; + tmpvar_4 = (tmpvar_3 * v.tangent.w); + binormal = tmpvar_4; + mat3 tmpvar_5; + float tmpvar_6; + tmpvar_6 = v.tangent.x; + tmpvar_5[0].x = tmpvar_6; + float tmpvar_7; + tmpvar_7 = binormal.x; + tmpvar_5[0].y = tmpvar_7; + float tmpvar_8; + tmpvar_8 = v.normal.x; + tmpvar_5[0].z = tmpvar_8; + float tmpvar_9; + tmpvar_9 = v.tangent.y; + tmpvar_5[1].x = tmpvar_9; + float tmpvar_10; + tmpvar_10 = binormal.y; + tmpvar_5[1].y = tmpvar_10; + float tmpvar_11; + tmpvar_11 = v.normal.y; + tmpvar_5[1].z = tmpvar_11; + float tmpvar_12; + tmpvar_12 = v.tangent.z; + tmpvar_5[2].x = tmpvar_12; + float tmpvar_13; + tmpvar_13 = binormal.z; + tmpvar_5[2].y = tmpvar_13; + float tmpvar_14; + tmpvar_14 = v.normal.z; + tmpvar_5[2].z = tmpvar_14; + mat3 tmpvar_15; + tmpvar_15 = (tmpvar_5); + rotation = (tmpvar_15); + vec3 tmpvar_16; + tmpvar_16 = ObjSpaceLightDir (v.vertex); + vec3 tmpvar_17; + tmpvar_17 = (rotation * tmpvar_16); + o.lightDir = tmpvar_17; + vec3 tmpvar_18; + tmpvar_18 = ObjSpaceViewDir (v.vertex); + vec3 tmpvar_19; + tmpvar_19 = (rotation * tmpvar_18); + o.viewDir = tmpvar_19; + vec3 tmpvar_20; + tmpvar_20 = (_LightMatrix0 * (_Object2World * v.vertex)).xyz; + o._LightCoord = tmpvar_20; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = xl_retval.fog; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_FOG = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19 = xl_retval.hip_pack0.xyzw; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[0] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21.w = 0.0; + tmpvar_21.xyz = xl_retval.lightDir.xyz; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_TexCoord[1] = tmpvar_22; + vec4 tmpvar_23; + tmpvar_23.w = 0.0; + tmpvar_23.xyz = xl_retval.viewDir.xyz; + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + gl_TexCoord[2] = tmpvar_24; + vec4 tmpvar_25; + tmpvar_25.w = 0.0; + tmpvar_25.xyz = xl_retval._LightCoord.xyz; + vec4 tmpvar_26; + tmpvar_26 = tmpvar_25; + gl_TexCoord[3] = tmpvar_26; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Transparent_Bumped_Specular-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Transparent_Bumped_Specular-out.txt new file mode 100644 index 000000000..3dc712ebe --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Transparent_Bumped_Specular-out.txt @@ -0,0 +1,52 @@ +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform vec3 _WorldSpaceCameraPos; +uniform mat4 _World2Object; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform mat4 _LightMatrix0; +uniform vec4 _BumpMap_ST; +void main () +{ + vec4 tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = (gl_ModelViewProjectionMatrix * gl_Vertex); + tmpvar_1.xy = ((gl_MultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + tmpvar_1.zw = ((gl_MultiTexCoord0.xy * _BumpMap_ST.xy) + _BumpMap_ST.zw); + vec3 tmpvar_3; + tmpvar_3 = (cross (gl_Normal, TANGENT.xyz) * TANGENT.w); + mat3 tmpvar_4; + tmpvar_4[0].x = TANGENT.x; + tmpvar_4[0].y = tmpvar_3.x; + tmpvar_4[0].z = gl_Normal.x; + tmpvar_4[1].x = TANGENT.y; + tmpvar_4[1].y = tmpvar_3.y; + tmpvar_4[1].z = gl_Normal.y; + tmpvar_4[2].x = TANGENT.z; + tmpvar_4[2].y = tmpvar_3.z; + tmpvar_4[2].z = gl_Normal.z; + vec4 tmpvar_5; + tmpvar_5.w = 1.0; + tmpvar_5.xyz = _WorldSpaceCameraPos; + gl_Position = tmpvar_2; + vec4 tmpvar_6; + tmpvar_6.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_6.x = tmpvar_2.z; + xlv_FOG = tmpvar_6; + gl_TexCoord[0] = tmpvar_1; + vec4 tmpvar_7; + tmpvar_7.w = 0.0; + tmpvar_7.xyz = (tmpvar_4 * (((_World2Object * _WorldSpaceLightPos0).xyz * unity_Scale.w) - gl_Vertex.xyz)); + gl_TexCoord[1] = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8.w = 0.0; + tmpvar_8.xyz = (tmpvar_4 * (((_World2Object * tmpvar_5).xyz * unity_Scale.w) - gl_Vertex.xyz)); + gl_TexCoord[2] = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9.w = 0.0; + tmpvar_9.xyz = (_LightMatrix0 * (_Object2World * gl_Vertex)).xyz; + gl_TexCoord[3] = tmpvar_9; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Transparent_Cutout_Bumped_Diffuse-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Transparent_Cutout_Bumped_Diffuse-in.txt new file mode 100644 index 000000000..f127eb269 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Transparent_Cutout_Bumped_Diffuse-in.txt @@ -0,0 +1,85 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 lightDir; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _BumpMap_ST; +uniform vec4 _MainTex_ST; +uniform mat4 _World2Object; +uniform vec4 _WorldSpaceLightPos0; + +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +vec3 ObjSpaceLightDir( in vec4 v ); +v2f_surf vert_surf( in appdata_full v ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +vec3 ObjSpaceLightDir( in vec4 v ) { + vec3 objSpaceLightPos; + objSpaceLightPos = ( _World2Object * _WorldSpaceLightPos0 ).xyz ; + return objSpaceLightPos.xyz ; +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + vec3 binormal; + mat3 rotation; + PositionFog( v.vertex, o.pos, o.fog); + o.hip_pack0.xy = ((v.texcoord.xy * _MainTex_ST.xy ) + _MainTex_ST.zw ); + o.hip_pack0.zw = ((v.texcoord.xy * _BumpMap_ST.xy ) + _BumpMap_ST.zw ); + binormal = (cross( v.normal, v.tangent.xyz ) * v.tangent.w ); + rotation = mat3( v.tangent.x , binormal.x , v.normal.x , v.tangent.y , binormal.y , v.normal.y , v.tangent.z , binormal.z , v.normal.z ); + o.lightDir = ( rotation * ObjSpaceLightDir( v.vertex) ); + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.hip_pack0); + gl_TexCoord[1] = vec4( xl_retval.lightDir, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Transparent_Cutout_Bumped_Diffuse-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Transparent_Cutout_Bumped_Diffuse-ir.txt new file mode 100644 index 000000000..8790fed9b --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Transparent_Cutout_Bumped_Diffuse-ir.txt @@ -0,0 +1,166 @@ +struct v2f_surf { + vec4 pos; + float fog; + vec4 hip_pack0; + vec3 lightDir; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 _WorldSpaceLightPos0; +uniform mat4 _World2Object; +uniform vec4 _MainTex_ST; +uniform vec4 _BumpMap_ST; +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +vec3 ObjSpaceLightDir ( + in vec4 v +) +{ + vec3 objSpaceLightPos; + vec3 tmpvar_1; + tmpvar_1 = (_World2Object * _WorldSpaceLightPos0).xyz; + objSpaceLightPos = tmpvar_1; + return objSpaceLightPos.xyz; +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + mat3 rotation; + vec3 binormal; + v2f_surf o; + PositionFog (v.vertex, o.pos, o.fog); + vec2 tmpvar_1; + tmpvar_1 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + o.hip_pack0.xy = tmpvar_1.xy.xy; + vec2 tmpvar_2; + tmpvar_2 = ((v.texcoord.xy * _BumpMap_ST.xy) + _BumpMap_ST.zw); + o.hip_pack0.zw = tmpvar_2.xxxy.zw; + vec3 tmpvar_3; + tmpvar_3 = cross (v.normal, v.tangent.xyz); + vec3 tmpvar_4; + tmpvar_4 = (tmpvar_3 * v.tangent.w); + binormal = tmpvar_4; + mat3 tmpvar_5; + float tmpvar_6; + tmpvar_6 = v.tangent.x; + tmpvar_5[0].x = tmpvar_6; + float tmpvar_7; + tmpvar_7 = binormal.x; + tmpvar_5[0].y = tmpvar_7; + float tmpvar_8; + tmpvar_8 = v.normal.x; + tmpvar_5[0].z = tmpvar_8; + float tmpvar_9; + tmpvar_9 = v.tangent.y; + tmpvar_5[1].x = tmpvar_9; + float tmpvar_10; + tmpvar_10 = binormal.y; + tmpvar_5[1].y = tmpvar_10; + float tmpvar_11; + tmpvar_11 = v.normal.y; + tmpvar_5[1].z = tmpvar_11; + float tmpvar_12; + tmpvar_12 = v.tangent.z; + tmpvar_5[2].x = tmpvar_12; + float tmpvar_13; + tmpvar_13 = binormal.z; + tmpvar_5[2].y = tmpvar_13; + float tmpvar_14; + tmpvar_14 = v.normal.z; + tmpvar_5[2].z = tmpvar_14; + mat3 tmpvar_15; + tmpvar_15 = (tmpvar_5); + rotation = (tmpvar_15); + vec3 tmpvar_16; + tmpvar_16 = ObjSpaceLightDir (v.vertex); + vec3 tmpvar_17; + tmpvar_17 = (rotation * tmpvar_16); + o.lightDir = tmpvar_17; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = xl_retval.fog; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_FOG = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19 = xl_retval.hip_pack0.xyzw; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[0] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21.w = 0.0; + tmpvar_21.xyz = xl_retval.lightDir.xyz; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_TexCoord[1] = tmpvar_22; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Transparent_Cutout_Bumped_Diffuse-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Transparent_Cutout_Bumped_Diffuse-out.txt new file mode 100644 index 000000000..daa189340 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Transparent_Cutout_Bumped_Diffuse-out.txt @@ -0,0 +1,37 @@ +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 _WorldSpaceLightPos0; +uniform mat4 _World2Object; +uniform vec4 _MainTex_ST; +uniform vec4 _BumpMap_ST; +void main () +{ + vec4 tmpvar_1; + vec4 tmpvar_2; + tmpvar_2 = (gl_ModelViewProjectionMatrix * gl_Vertex); + tmpvar_1.xy = ((gl_MultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + tmpvar_1.zw = ((gl_MultiTexCoord0.xy * _BumpMap_ST.xy) + _BumpMap_ST.zw); + vec3 tmpvar_3; + tmpvar_3 = (cross (gl_Normal, TANGENT.xyz) * TANGENT.w); + mat3 tmpvar_4; + tmpvar_4[0].x = TANGENT.x; + tmpvar_4[0].y = tmpvar_3.x; + tmpvar_4[0].z = gl_Normal.x; + tmpvar_4[1].x = TANGENT.y; + tmpvar_4[1].y = tmpvar_3.y; + tmpvar_4[1].z = gl_Normal.y; + tmpvar_4[2].x = TANGENT.z; + tmpvar_4[2].y = tmpvar_3.z; + tmpvar_4[2].z = gl_Normal.z; + gl_Position = tmpvar_2; + vec4 tmpvar_5; + tmpvar_5.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_5.x = tmpvar_2.z; + xlv_FOG = tmpvar_5; + gl_TexCoord[0] = tmpvar_1; + vec4 tmpvar_6; + tmpvar_6.w = 0.0; + tmpvar_6.xyz = (tmpvar_4 * (_World2Object * _WorldSpaceLightPos0).xyz); + gl_TexCoord[1] = tmpvar_6; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Transparent_Cutout_Bumped_Diffuse1-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Transparent_Cutout_Bumped_Diffuse1-in.txt new file mode 100644 index 000000000..d4dfb2f5a --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Transparent_Cutout_Bumped_Diffuse1-in.txt @@ -0,0 +1,80 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 hip_screen; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _MainTex_ST; +uniform vec4 _ProjectionParams; + +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +vec4 ComputeScreenPos( in vec4 pos ); +v2f_surf vert_surf( in appdata_full v ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +vec4 ComputeScreenPos( in vec4 pos ) { + vec4 o; + o = (pos * 0.500000); + o.xy = (vec2( o.x , (o.y * _ProjectionParams.x )) + o.w ); + o.zw = pos.zw ; + return o; +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + PositionFog( v.vertex, o.pos, o.fog); + o.hip_pack0.xy = ((v.texcoord.xy * _MainTex_ST.xy ) + _MainTex_ST.zw ); + o.hip_screen = ComputeScreenPos( o.pos); + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.hip_pack0, 0.0, 0.0); + gl_TexCoord[1] = vec4( xl_retval.hip_screen); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Transparent_Cutout_Bumped_Diffuse1-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Transparent_Cutout_Bumped_Diffuse1-ir.txt new file mode 100644 index 000000000..6b7ae345b --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Transparent_Cutout_Bumped_Diffuse1-ir.txt @@ -0,0 +1,132 @@ +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 hip_screen; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 _ProjectionParams; +uniform vec4 _MainTex_ST; +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +vec4 ComputeScreenPos ( + in vec4 pos +) +{ + vec4 o; + vec4 tmpvar_1; + tmpvar_1 = (pos * 0.5); + o = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2.x = o.x; + tmpvar_2.y = (o.y * _ProjectionParams.x); + vec2 tmpvar_3; + tmpvar_3 = (tmpvar_2 + o.w); + o.xy = tmpvar_3.xy.xy; + vec2 tmpvar_4; + tmpvar_4 = pos.zw; + o.zw = tmpvar_4.xxxy.zw; + return o; +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + v2f_surf o; + PositionFog (v.vertex, o.pos, o.fog); + vec2 tmpvar_1; + tmpvar_1 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + o.hip_pack0 = tmpvar_1.xy.xy; + vec4 tmpvar_2; + tmpvar_2 = ComputeScreenPos (o.pos); + vec4 tmpvar_3; + tmpvar_3 = tmpvar_2; + o.hip_screen = tmpvar_3; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = xl_retval.fog; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_FOG = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19.zw = vec2(0.0, 0.0); + tmpvar_19.xy = xl_retval.hip_pack0.xy; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[0] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21 = xl_retval.hip_screen.xyzw; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_TexCoord[1] = tmpvar_22; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Transparent_Cutout_Bumped_Diffuse1-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Transparent_Cutout_Bumped_Diffuse1-out.txt new file mode 100644 index 000000000..2f3f8d3dc --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Transparent_Cutout_Bumped_Diffuse1-out.txt @@ -0,0 +1,28 @@ +varying vec4 xlv_FOG; +uniform vec4 _ProjectionParams; +uniform vec4 _MainTex_ST; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * gl_Vertex); + vec4 o_i0; + vec4 tmpvar_2; + tmpvar_2 = (tmpvar_1 * 0.5); + o_i0 = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3.x = tmpvar_2.x; + tmpvar_3.y = (tmpvar_2.y * _ProjectionParams.x); + o_i0.xy = (tmpvar_3 + tmpvar_2.w); + o_i0.zw = tmpvar_1.zw; + gl_Position = tmpvar_1; + vec4 tmpvar_4; + tmpvar_4.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_4.x = tmpvar_1.z; + xlv_FOG = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5.zw = vec2(0.0, 0.0); + tmpvar_5.xy = ((gl_MultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + gl_TexCoord[0] = tmpvar_5; + gl_TexCoord[1] = o_i0; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Transparent_Cutout_Bumped_Specular-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Transparent_Cutout_Bumped_Specular-in.txt new file mode 100644 index 000000000..9d10e5ee8 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Transparent_Cutout_Bumped_Specular-in.txt @@ -0,0 +1,79 @@ +mat3 xll_constructMat3( mat4 m) { + return mat3( vec3( m[0]), vec3( m[1]), vec3( m[2])); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; +}; +struct v2f_surf { + vec4 pos; + vec4 hip_pack0; + vec3 TtoV0; + vec3 TtoV1; + vec3 TtoV2; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _BumpMap_ST; +uniform vec4 _MainTex_ST; + + +v2f_surf vert_surf( in appdata_full v ); +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + vec3 binormal; + mat3 rotation; + o.pos = ( gl_ModelViewProjectionMatrix * v.vertex ); + o.hip_pack0.xy = ((v.texcoord.xy * _MainTex_ST.xy ) + _MainTex_ST.zw ); + o.hip_pack0.zw = ((v.texcoord.xy * _BumpMap_ST.xy ) + _BumpMap_ST.zw ); + binormal = (cross( v.normal, v.tangent.xyz ) * v.tangent.w ); + rotation = mat3( v.tangent.x , binormal.x , v.normal.x , v.tangent.y , binormal.y , v.normal.y , v.tangent.z , binormal.z , v.normal.z ); + o.TtoV0 = ( rotation * xll_constructMat3( gl_ModelViewMatrixInverseTranspose)[ 0 ].xyz ); + o.TtoV1 = ( rotation * xll_constructMat3( gl_ModelViewMatrixInverseTranspose)[ 1 ].xyz ); + o.TtoV2 = ( rotation * xll_constructMat3( gl_ModelViewMatrixInverseTranspose)[ 2 ].xyz ); + return o; +} +attribute vec4 TANGENT; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + gl_TexCoord[0] = vec4( xl_retval.hip_pack0); + gl_TexCoord[1] = vec4( xl_retval.TtoV0, 0.0); + gl_TexCoord[2] = vec4( xl_retval.TtoV1, 0.0); + gl_TexCoord[3] = vec4( xl_retval.TtoV2, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Transparent_Cutout_Bumped_Specular-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Transparent_Cutout_Bumped_Specular-ir.txt new file mode 100644 index 000000000..9e934af72 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Transparent_Cutout_Bumped_Specular-ir.txt @@ -0,0 +1,180 @@ +struct v2f_surf { + vec4 pos; + vec4 hip_pack0; + vec3 TtoV0; + vec3 TtoV1; + vec3 TtoV2; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +attribute vec4 TANGENT; +uniform vec4 _MainTex_ST; +uniform vec4 _BumpMap_ST; +mat3 xll_constructMat3 ( + in mat4 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = m[0].xyz; + vec3 tmpvar_2; + tmpvar_2 = m[1].xyz; + vec3 tmpvar_3; + tmpvar_3 = m[2].xyz; + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + mat3 rotation; + vec3 binormal; + v2f_surf o; + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v.vertex); + o.pos = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + o.hip_pack0.xy = tmpvar_2.xy.xy; + vec2 tmpvar_3; + tmpvar_3 = ((v.texcoord.xy * _BumpMap_ST.xy) + _BumpMap_ST.zw); + o.hip_pack0.zw = tmpvar_3.xxxy.zw; + vec3 tmpvar_4; + tmpvar_4 = cross (v.normal, v.tangent.xyz); + vec3 tmpvar_5; + tmpvar_5 = (tmpvar_4 * v.tangent.w); + binormal = tmpvar_5; + mat3 tmpvar_6; + float tmpvar_7; + tmpvar_7 = v.tangent.x; + tmpvar_6[0].x = tmpvar_7; + float tmpvar_8; + tmpvar_8 = binormal.x; + tmpvar_6[0].y = tmpvar_8; + float tmpvar_9; + tmpvar_9 = v.normal.x; + tmpvar_6[0].z = tmpvar_9; + float tmpvar_10; + tmpvar_10 = v.tangent.y; + tmpvar_6[1].x = tmpvar_10; + float tmpvar_11; + tmpvar_11 = binormal.y; + tmpvar_6[1].y = tmpvar_11; + float tmpvar_12; + tmpvar_12 = v.normal.y; + tmpvar_6[1].z = tmpvar_12; + float tmpvar_13; + tmpvar_13 = v.tangent.z; + tmpvar_6[2].x = tmpvar_13; + float tmpvar_14; + tmpvar_14 = binormal.z; + tmpvar_6[2].y = tmpvar_14; + float tmpvar_15; + tmpvar_15 = v.normal.z; + tmpvar_6[2].z = tmpvar_15; + mat3 tmpvar_16; + tmpvar_16 = (tmpvar_6); + rotation = (tmpvar_16); + mat3 tmpvar_17; + tmpvar_17 = (xll_constructMat3 (gl_ModelViewMatrixInverseTranspose)); + vec3 tmpvar_18; + tmpvar_18 = (rotation * tmpvar_17[0].xyz); + o.TtoV0 = tmpvar_18; + mat3 tmpvar_19; + tmpvar_19 = (xll_constructMat3 (gl_ModelViewMatrixInverseTranspose)); + vec3 tmpvar_20; + tmpvar_20 = (rotation * tmpvar_19[1].xyz); + o.TtoV1 = tmpvar_20; + mat3 tmpvar_21; + tmpvar_21 = (xll_constructMat3 (gl_ModelViewMatrixInverseTranspose)); + vec3 tmpvar_22; + tmpvar_22 = (rotation * tmpvar_21[2].xyz); + o.TtoV2 = tmpvar_22; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17 = xl_retval.hip_pack0.xyzw; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + gl_TexCoord[0] = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19.w = 0.0; + tmpvar_19.xyz = xl_retval.TtoV0.xyz; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[1] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21.w = 0.0; + tmpvar_21.xyz = xl_retval.TtoV1.xyz; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_TexCoord[2] = tmpvar_22; + vec4 tmpvar_23; + tmpvar_23.w = 0.0; + tmpvar_23.xyz = xl_retval.TtoV2.xyz; + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + gl_TexCoord[3] = tmpvar_24; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Transparent_Cutout_Bumped_Specular-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Transparent_Cutout_Bumped_Specular-out.txt new file mode 100644 index 000000000..d5cca7232 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Transparent_Cutout_Bumped_Specular-out.txt @@ -0,0 +1,48 @@ +attribute vec4 TANGENT; +uniform vec4 _MainTex_ST; +uniform vec4 _BumpMap_ST; +void main () +{ + vec4 tmpvar_1; + tmpvar_1.xy = ((gl_MultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + tmpvar_1.zw = ((gl_MultiTexCoord0.xy * _BumpMap_ST.xy) + _BumpMap_ST.zw); + vec3 tmpvar_2; + tmpvar_2 = (cross (gl_Normal, TANGENT.xyz) * TANGENT.w); + mat3 tmpvar_3; + tmpvar_3[0].x = TANGENT.x; + tmpvar_3[0].y = tmpvar_2.x; + tmpvar_3[0].z = gl_Normal.x; + tmpvar_3[1].x = TANGENT.y; + tmpvar_3[1].y = tmpvar_2.y; + tmpvar_3[1].z = gl_Normal.y; + tmpvar_3[2].x = TANGENT.z; + tmpvar_3[2].y = tmpvar_2.z; + tmpvar_3[2].z = gl_Normal.z; + mat3 tmpvar_4; + tmpvar_4[0] = gl_ModelViewMatrixInverseTranspose[0].xyz; + tmpvar_4[1] = gl_ModelViewMatrixInverseTranspose[1].xyz; + tmpvar_4[2] = gl_ModelViewMatrixInverseTranspose[2].xyz; + mat3 tmpvar_5; + tmpvar_5[0] = gl_ModelViewMatrixInverseTranspose[0].xyz; + tmpvar_5[1] = gl_ModelViewMatrixInverseTranspose[1].xyz; + tmpvar_5[2] = gl_ModelViewMatrixInverseTranspose[2].xyz; + mat3 tmpvar_6; + tmpvar_6[0] = gl_ModelViewMatrixInverseTranspose[0].xyz; + tmpvar_6[1] = gl_ModelViewMatrixInverseTranspose[1].xyz; + tmpvar_6[2] = gl_ModelViewMatrixInverseTranspose[2].xyz; + gl_Position = (gl_ModelViewProjectionMatrix * gl_Vertex); + gl_TexCoord[0] = tmpvar_1; + vec4 tmpvar_7; + tmpvar_7.w = 0.0; + tmpvar_7.xyz = (tmpvar_3 * tmpvar_4[0]); + gl_TexCoord[1] = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8.w = 0.0; + tmpvar_8.xyz = (tmpvar_3 * tmpvar_5[1]); + gl_TexCoord[2] = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9.w = 0.0; + tmpvar_9.xyz = (tmpvar_3 * tmpvar_6[2]); + gl_TexCoord[3] = tmpvar_9; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Transparent_Cutout_Bumped_Specular1-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Transparent_Cutout_Bumped_Specular1-in.txt new file mode 100644 index 000000000..d4dfb2f5a --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Transparent_Cutout_Bumped_Specular1-in.txt @@ -0,0 +1,80 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec2 uv_BumpMap; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 hip_screen; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _MainTex_ST; +uniform vec4 _ProjectionParams; + +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +vec4 ComputeScreenPos( in vec4 pos ); +v2f_surf vert_surf( in appdata_full v ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +vec4 ComputeScreenPos( in vec4 pos ) { + vec4 o; + o = (pos * 0.500000); + o.xy = (vec2( o.x , (o.y * _ProjectionParams.x )) + o.w ); + o.zw = pos.zw ; + return o; +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + PositionFog( v.vertex, o.pos, o.fog); + o.hip_pack0.xy = ((v.texcoord.xy * _MainTex_ST.xy ) + _MainTex_ST.zw ); + o.hip_screen = ComputeScreenPos( o.pos); + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.hip_pack0, 0.0, 0.0); + gl_TexCoord[1] = vec4( xl_retval.hip_screen); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Transparent_Cutout_Bumped_Specular1-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Transparent_Cutout_Bumped_Specular1-ir.txt new file mode 100644 index 000000000..6b7ae345b --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Transparent_Cutout_Bumped_Specular1-ir.txt @@ -0,0 +1,132 @@ +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 hip_screen; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 _ProjectionParams; +uniform vec4 _MainTex_ST; +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +vec4 ComputeScreenPos ( + in vec4 pos +) +{ + vec4 o; + vec4 tmpvar_1; + tmpvar_1 = (pos * 0.5); + o = tmpvar_1; + vec2 tmpvar_2; + tmpvar_2.x = o.x; + tmpvar_2.y = (o.y * _ProjectionParams.x); + vec2 tmpvar_3; + tmpvar_3 = (tmpvar_2 + o.w); + o.xy = tmpvar_3.xy.xy; + vec2 tmpvar_4; + tmpvar_4 = pos.zw; + o.zw = tmpvar_4.xxxy.zw; + return o; +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + v2f_surf o; + PositionFog (v.vertex, o.pos, o.fog); + vec2 tmpvar_1; + tmpvar_1 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + o.hip_pack0 = tmpvar_1.xy.xy; + vec4 tmpvar_2; + tmpvar_2 = ComputeScreenPos (o.pos); + vec4 tmpvar_3; + tmpvar_3 = tmpvar_2; + o.hip_screen = tmpvar_3; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = xl_retval.fog; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_FOG = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19.zw = vec2(0.0, 0.0); + tmpvar_19.xy = xl_retval.hip_pack0.xy; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[0] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21 = xl_retval.hip_screen.xyzw; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_TexCoord[1] = tmpvar_22; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Transparent_Cutout_Bumped_Specular1-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Transparent_Cutout_Bumped_Specular1-out.txt new file mode 100644 index 000000000..2f3f8d3dc --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Transparent_Cutout_Bumped_Specular1-out.txt @@ -0,0 +1,28 @@ +varying vec4 xlv_FOG; +uniform vec4 _ProjectionParams; +uniform vec4 _MainTex_ST; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * gl_Vertex); + vec4 o_i0; + vec4 tmpvar_2; + tmpvar_2 = (tmpvar_1 * 0.5); + o_i0 = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3.x = tmpvar_2.x; + tmpvar_3.y = (tmpvar_2.y * _ProjectionParams.x); + o_i0.xy = (tmpvar_3 + tmpvar_2.w); + o_i0.zw = tmpvar_1.zw; + gl_Position = tmpvar_1; + vec4 tmpvar_4; + tmpvar_4.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_4.x = tmpvar_1.z; + xlv_FOG = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5.zw = vec2(0.0, 0.0); + tmpvar_5.xy = ((gl_MultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + gl_TexCoord[0] = tmpvar_5; + gl_TexCoord[1] = o_i0; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Transparent_Cutout_Diffuse-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Transparent_Cutout_Diffuse-in.txt new file mode 100644 index 000000000..f67229d82 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Transparent_Cutout_Diffuse-in.txt @@ -0,0 +1,89 @@ +mat3 xll_constructMat3( mat4 m) { + return mat3( vec3( m[0]), vec3( m[1]), vec3( m[2])); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 normal; + vec3 lightDir; + vec4 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform mat4 _LightMatrix0; +uniform vec4 _MainTex_ST; +uniform mat4 _Object2World; +uniform vec4 _WorldSpaceLightPos0; + +uniform vec4 unity_Scale; +vec3 WorldSpaceLightDir( in vec4 v ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +v2f_surf vert_surf( in appdata_full v ); +vec3 WorldSpaceLightDir( in vec4 v ) { + vec3 worldPos; + worldPos = ( _Object2World * v ).xyz ; + return (_WorldSpaceLightPos0.xyz - worldPos); +} +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + PositionFog( v.vertex, o.pos, o.fog); + o.hip_pack0.xy = ((v.texcoord.xy * _MainTex_ST.xy ) + _MainTex_ST.zw ); + o.normal = ( xll_constructMat3( _Object2World) * (v.normal * unity_Scale.w ) ); + o.lightDir = WorldSpaceLightDir( v.vertex); + o._LightCoord = ( _LightMatrix0 * ( _Object2World * v.vertex ) ); + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.hip_pack0, 0.0, 0.0); + gl_TexCoord[1] = vec4( xl_retval.normal, 0.0); + gl_TexCoord[2] = vec4( xl_retval.lightDir, 0.0); + gl_TexCoord[3] = vec4( xl_retval._LightCoord); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Transparent_Cutout_Diffuse-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Transparent_Cutout_Diffuse-ir.txt new file mode 100644 index 000000000..c7c3395e1 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Transparent_Cutout_Diffuse-ir.txt @@ -0,0 +1,171 @@ +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 normal; + vec3 lightDir; + vec4 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform mat4 _LightMatrix0; +mat3 xll_constructMat3 ( + in mat4 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = m[0].xyz; + vec3 tmpvar_2; + tmpvar_2 = m[1].xyz; + vec3 tmpvar_3; + tmpvar_3 = m[2].xyz; + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +vec3 WorldSpaceLightDir ( + in vec4 v +) +{ + vec3 worldPos; + vec3 tmpvar_1; + tmpvar_1 = (_Object2World * v).xyz; + worldPos = tmpvar_1; + return (_WorldSpaceLightPos0.xyz - worldPos); +} + +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + v2f_surf o; + PositionFog (v.vertex, o.pos, o.fog); + vec2 tmpvar_1; + tmpvar_1 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + o.hip_pack0 = tmpvar_1.xy.xy; + mat3 tmpvar_2; + tmpvar_2 = (xll_constructMat3 (_Object2World)); + vec3 tmpvar_3; + tmpvar_3 = (tmpvar_2 * (v.normal * unity_Scale.w)); + o.normal = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = WorldSpaceLightDir (v.vertex); + vec3 tmpvar_5; + tmpvar_5 = tmpvar_4; + o.lightDir = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6 = (_LightMatrix0 * (_Object2World * v.vertex)); + o._LightCoord = tmpvar_6; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = xl_retval.fog; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_FOG = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19.zw = vec2(0.0, 0.0); + tmpvar_19.xy = xl_retval.hip_pack0.xy; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[0] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21.w = 0.0; + tmpvar_21.xyz = xl_retval.normal.xyz; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_TexCoord[1] = tmpvar_22; + vec4 tmpvar_23; + tmpvar_23.w = 0.0; + tmpvar_23.xyz = xl_retval.lightDir.xyz; + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + gl_TexCoord[2] = tmpvar_24; + vec4 tmpvar_25; + tmpvar_25 = xl_retval._LightCoord.xyzw; + vec4 tmpvar_26; + tmpvar_26 = tmpvar_25; + gl_TexCoord[3] = tmpvar_26; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Transparent_Cutout_Diffuse-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Transparent_Cutout_Diffuse-out.txt new file mode 100644 index 000000000..6605302cf --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Transparent_Cutout_Diffuse-out.txt @@ -0,0 +1,34 @@ +varying vec4 xlv_FOG; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform mat4 _LightMatrix0; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * gl_Vertex); + mat3 tmpvar_2; + tmpvar_2[0] = _Object2World[0].xyz; + tmpvar_2[1] = _Object2World[1].xyz; + tmpvar_2[2] = _Object2World[2].xyz; + gl_Position = tmpvar_1; + vec4 tmpvar_3; + tmpvar_3.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_3.x = tmpvar_1.z; + xlv_FOG = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4.zw = vec2(0.0, 0.0); + tmpvar_4.xy = ((gl_MultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + gl_TexCoord[0] = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5.w = 0.0; + tmpvar_5.xyz = (tmpvar_2 * (gl_Normal * unity_Scale.w)); + gl_TexCoord[1] = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6.w = 0.0; + tmpvar_6.xyz = (_WorldSpaceLightPos0.xyz - (_Object2World * gl_Vertex).xyz); + gl_TexCoord[2] = tmpvar_6; + gl_TexCoord[3] = (_LightMatrix0 * (_Object2World * gl_Vertex)); +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Transparent_Cutout_Specular-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Transparent_Cutout_Specular-in.txt new file mode 100644 index 000000000..49cc14857 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Transparent_Cutout_Specular-in.txt @@ -0,0 +1,93 @@ +mat3 xll_constructMat3( mat4 m) { + return mat3( vec3( m[0]), vec3( m[1]), vec3( m[2])); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 normal; + vec3 lightDir; + vec3 viewDir; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform vec4 _MainTex_ST; +uniform mat4 _Object2World; +uniform vec3 _WorldSpaceCameraPos; +uniform vec4 _WorldSpaceLightPos0; + +uniform vec4 unity_Scale; +vec3 WorldSpaceViewDir( in vec4 v ); +vec3 WorldSpaceLightDir( in vec4 v ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +v2f_surf vert_surf( in appdata_full v ); +vec3 WorldSpaceViewDir( in vec4 v ) { + return (_WorldSpaceCameraPos.xyz - ( _Object2World * v ).xyz ); +} +vec3 WorldSpaceLightDir( in vec4 v ) { + vec3 worldPos; + worldPos = ( _Object2World * v ).xyz ; + return _WorldSpaceLightPos0.xyz ; +} +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + PositionFog( v.vertex, o.pos, o.fog); + o.hip_pack0.xy = ((v.texcoord.xy * _MainTex_ST.xy ) + _MainTex_ST.zw ); + o.normal = ( xll_constructMat3( _Object2World) * (v.normal * unity_Scale.w ) ); + o.lightDir = WorldSpaceLightDir( v.vertex); + o.viewDir = WorldSpaceViewDir( v.vertex); + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.hip_pack0, 0.0, 0.0); + gl_TexCoord[1] = vec4( xl_retval.normal, 0.0); + gl_TexCoord[2] = vec4( xl_retval.lightDir, 0.0); + gl_TexCoord[3] = vec4( xl_retval.viewDir, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Transparent_Cutout_Specular-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Transparent_Cutout_Specular-ir.txt new file mode 100644 index 000000000..427fe2cf4 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Transparent_Cutout_Specular-ir.txt @@ -0,0 +1,181 @@ +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 normal; + vec3 lightDir; + vec3 viewDir; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform vec3 _WorldSpaceCameraPos; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +mat3 xll_constructMat3 ( + in mat4 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = m[0].xyz; + vec3 tmpvar_2; + tmpvar_2 = m[1].xyz; + vec3 tmpvar_3; + tmpvar_3 = m[2].xyz; + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +vec3 WorldSpaceViewDir ( + in vec4 v +) +{ + return (_WorldSpaceCameraPos.xyz - (_Object2World * v).xyz); +} + +vec3 WorldSpaceLightDir ( + in vec4 v +) +{ + vec3 worldPos; + vec3 tmpvar_1; + tmpvar_1 = (_Object2World * v).xyz; + worldPos = tmpvar_1; + return _WorldSpaceLightPos0.xyz; +} + +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + v2f_surf o; + PositionFog (v.vertex, o.pos, o.fog); + vec2 tmpvar_1; + tmpvar_1 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + o.hip_pack0 = tmpvar_1.xy.xy; + mat3 tmpvar_2; + tmpvar_2 = (xll_constructMat3 (_Object2World)); + vec3 tmpvar_3; + tmpvar_3 = (tmpvar_2 * (v.normal * unity_Scale.w)); + o.normal = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = WorldSpaceLightDir (v.vertex); + vec3 tmpvar_5; + tmpvar_5 = tmpvar_4; + o.lightDir = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = WorldSpaceViewDir (v.vertex); + vec3 tmpvar_7; + tmpvar_7 = tmpvar_6; + o.viewDir = tmpvar_7; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = xl_retval.fog; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_FOG = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19.zw = vec2(0.0, 0.0); + tmpvar_19.xy = xl_retval.hip_pack0.xy; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[0] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21.w = 0.0; + tmpvar_21.xyz = xl_retval.normal.xyz; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_TexCoord[1] = tmpvar_22; + vec4 tmpvar_23; + tmpvar_23.w = 0.0; + tmpvar_23.xyz = xl_retval.lightDir.xyz; + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + gl_TexCoord[2] = tmpvar_24; + vec4 tmpvar_25; + tmpvar_25.w = 0.0; + tmpvar_25.xyz = xl_retval.viewDir.xyz; + vec4 tmpvar_26; + tmpvar_26 = tmpvar_25; + gl_TexCoord[3] = tmpvar_26; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Transparent_Cutout_Specular-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Transparent_Cutout_Specular-out.txt new file mode 100644 index 000000000..99b5ae821 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Transparent_Cutout_Specular-out.txt @@ -0,0 +1,37 @@ +varying vec4 xlv_FOG; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform vec3 _WorldSpaceCameraPos; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * gl_Vertex); + mat3 tmpvar_2; + tmpvar_2[0] = _Object2World[0].xyz; + tmpvar_2[1] = _Object2World[1].xyz; + tmpvar_2[2] = _Object2World[2].xyz; + gl_Position = tmpvar_1; + vec4 tmpvar_3; + tmpvar_3.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_3.x = tmpvar_1.z; + xlv_FOG = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4.zw = vec2(0.0, 0.0); + tmpvar_4.xy = ((gl_MultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + gl_TexCoord[0] = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5.w = 0.0; + tmpvar_5.xyz = (tmpvar_2 * (gl_Normal * unity_Scale.w)); + gl_TexCoord[1] = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6.w = 0.0; + tmpvar_6.xyz = _WorldSpaceLightPos0.xyz; + gl_TexCoord[2] = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7.w = 0.0; + tmpvar_7.xyz = (_WorldSpaceCameraPos - (_Object2World * gl_Vertex).xyz); + gl_TexCoord[3] = tmpvar_7; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Transparent_Specular-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Transparent_Specular-in.txt new file mode 100644 index 000000000..a945920fa --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Transparent_Specular-in.txt @@ -0,0 +1,97 @@ +mat3 xll_constructMat3( mat4 m) { + return mat3( vec3( m[0]), vec3( m[1]), vec3( m[2])); +} +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 normal; + vec3 lightDir; + vec3 viewDir; + vec2 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +uniform mat4 _LightMatrix0; +uniform vec4 _MainTex_ST; +uniform mat4 _Object2World; +uniform vec3 _WorldSpaceCameraPos; +uniform vec4 _WorldSpaceLightPos0; + +uniform vec4 unity_Scale; +vec3 WorldSpaceViewDir( in vec4 v ); +vec3 WorldSpaceLightDir( in vec4 v ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +v2f_surf vert_surf( in appdata_full v ); +vec3 WorldSpaceViewDir( in vec4 v ) { + return (_WorldSpaceCameraPos.xyz - ( _Object2World * v ).xyz ); +} +vec3 WorldSpaceLightDir( in vec4 v ) { + vec3 worldPos; + worldPos = ( _Object2World * v ).xyz ; + return _WorldSpaceLightPos0.xyz ; +} +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + PositionFog( v.vertex, o.pos, o.fog); + o.hip_pack0.xy = ((v.texcoord.xy * _MainTex_ST.xy ) + _MainTex_ST.zw ); + o.normal = ( xll_constructMat3( _Object2World) * (v.normal * unity_Scale.w ) ); + o.lightDir = WorldSpaceLightDir( v.vertex); + o.viewDir = WorldSpaceViewDir( v.vertex); + o._LightCoord = ( _LightMatrix0 * ( _Object2World * v.vertex ) ).xy ; + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.hip_pack0, 0.0, 0.0); + gl_TexCoord[1] = vec4( xl_retval.normal, 0.0); + gl_TexCoord[2] = vec4( xl_retval.lightDir, 0.0); + gl_TexCoord[3] = vec4( xl_retval.viewDir, 0.0); + gl_TexCoord[4] = vec4( xl_retval._LightCoord, 0.0, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Transparent_Specular-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Transparent_Specular-ir.txt new file mode 100644 index 000000000..9dc945062 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Transparent_Specular-ir.txt @@ -0,0 +1,192 @@ +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec3 normal; + vec3 lightDir; + vec3 viewDir; + vec2 _LightCoord; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform vec3 _WorldSpaceCameraPos; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform mat4 _LightMatrix0; +mat3 xll_constructMat3 ( + in mat4 m +) +{ + vec3 tmpvar_1; + tmpvar_1 = m[0].xyz; + vec3 tmpvar_2; + tmpvar_2 = m[1].xyz; + vec3 tmpvar_3; + tmpvar_3 = m[2].xyz; + mat3 tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = tmpvar_1; + tmpvar_4[0] = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_2; + tmpvar_4[1] = tmpvar_6; + vec3 tmpvar_7; + tmpvar_7 = tmpvar_3; + tmpvar_4[2] = tmpvar_7; + return tmpvar_4; +} + +vec3 WorldSpaceViewDir ( + in vec4 v +) +{ + return (_WorldSpaceCameraPos.xyz - (_Object2World * v).xyz); +} + +vec3 WorldSpaceLightDir ( + in vec4 v +) +{ + vec3 worldPos; + vec3 tmpvar_1; + tmpvar_1 = (_Object2World * v).xyz; + worldPos = tmpvar_1; + return _WorldSpaceLightPos0.xyz; +} + +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + v2f_surf o; + PositionFog (v.vertex, o.pos, o.fog); + vec2 tmpvar_1; + tmpvar_1 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + o.hip_pack0 = tmpvar_1.xy.xy; + mat3 tmpvar_2; + tmpvar_2 = (xll_constructMat3 (_Object2World)); + vec3 tmpvar_3; + tmpvar_3 = (tmpvar_2 * (v.normal * unity_Scale.w)); + o.normal = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = WorldSpaceLightDir (v.vertex); + vec3 tmpvar_5; + tmpvar_5 = tmpvar_4; + o.lightDir = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = WorldSpaceViewDir (v.vertex); + vec3 tmpvar_7; + tmpvar_7 = tmpvar_6; + o.viewDir = tmpvar_7; + vec2 tmpvar_8; + tmpvar_8 = (_LightMatrix0 * (_Object2World * v.vertex)).xy; + o._LightCoord = tmpvar_8; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = xl_retval.fog; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_FOG = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19.zw = vec2(0.0, 0.0); + tmpvar_19.xy = xl_retval.hip_pack0.xy; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[0] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21.w = 0.0; + tmpvar_21.xyz = xl_retval.normal.xyz; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_TexCoord[1] = tmpvar_22; + vec4 tmpvar_23; + tmpvar_23.w = 0.0; + tmpvar_23.xyz = xl_retval.lightDir.xyz; + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + gl_TexCoord[2] = tmpvar_24; + vec4 tmpvar_25; + tmpvar_25.w = 0.0; + tmpvar_25.xyz = xl_retval.viewDir.xyz; + vec4 tmpvar_26; + tmpvar_26 = tmpvar_25; + gl_TexCoord[3] = tmpvar_26; + vec4 tmpvar_27; + tmpvar_27.zw = vec2(0.0, 0.0); + tmpvar_27.xy = xl_retval._LightCoord.xy; + vec4 tmpvar_28; + tmpvar_28 = tmpvar_27; + gl_TexCoord[4] = tmpvar_28; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Transparent_Specular-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Transparent_Specular-out.txt new file mode 100644 index 000000000..f30052442 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Transparent_Specular-out.txt @@ -0,0 +1,42 @@ +varying vec4 xlv_FOG; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform vec3 _WorldSpaceCameraPos; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform mat4 _LightMatrix0; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * gl_Vertex); + mat3 tmpvar_2; + tmpvar_2[0] = _Object2World[0].xyz; + tmpvar_2[1] = _Object2World[1].xyz; + tmpvar_2[2] = _Object2World[2].xyz; + gl_Position = tmpvar_1; + vec4 tmpvar_3; + tmpvar_3.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_3.x = tmpvar_1.z; + xlv_FOG = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4.zw = vec2(0.0, 0.0); + tmpvar_4.xy = ((gl_MultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + gl_TexCoord[0] = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5.w = 0.0; + tmpvar_5.xyz = (tmpvar_2 * (gl_Normal * unity_Scale.w)); + gl_TexCoord[1] = tmpvar_5; + vec4 tmpvar_6; + tmpvar_6.w = 0.0; + tmpvar_6.xyz = _WorldSpaceLightPos0.xyz; + gl_TexCoord[2] = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7.w = 0.0; + tmpvar_7.xyz = (_WorldSpaceCameraPos - (_Object2World * gl_Vertex).xyz); + gl_TexCoord[3] = tmpvar_7; + vec4 tmpvar_8; + tmpvar_8.zw = vec2(0.0, 0.0); + tmpvar_8.xy = (_LightMatrix0 * (_Object2World * gl_Vertex)).xy; + gl_TexCoord[4] = tmpvar_8; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-TreeCreatorLeavesRT-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-TreeCreatorLeavesRT-in.txt new file mode 100644 index 000000000..ef7be6b86 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-TreeCreatorLeavesRT-in.txt @@ -0,0 +1,91 @@ +float xll_saturate( float x) { + return clamp( x, 0.0, 1.0); +} +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +struct v2f { + vec4 pos; + vec2 uv; + vec3 color; + vec3 backContrib; + vec3 nl; + vec3 nh; +}; +uniform vec3 _TerrainTreeLightDirections[4]; +uniform float _TranslucencyViewDependency; +uniform mat4 _World2Object; +uniform vec3 _WorldSpaceCameraPos; + + +uniform vec4 unity_Scale; +vec3 ObjSpaceViewDir( in vec4 v ); +void ExpandBillboard( in mat4 mat, inout vec4 pos, inout vec3 normal, inout vec4 tangent ); +v2f vert( in appdata_full v ); +vec3 ObjSpaceViewDir( in vec4 v ) { + vec3 objSpaceCameraPos; + objSpaceCameraPos = (( _World2Object * vec4( _WorldSpaceCameraPos.xyz , 1.00000) ).xyz * unity_Scale.w ); + return (objSpaceCameraPos - v.xyz ); +} +void ExpandBillboard( in mat4 mat, inout vec4 pos, inout vec3 normal, inout vec4 tangent ) { + float isBillboard; + vec3 norb; + vec3 tanb; + isBillboard = (1.00000 - abs( tangent.w )); + norb = vec3( normalize( ( vec4( normal, 0.000000) * mat ) )); + tanb = vec3( normalize( ( vec4( tangent.xyz , 0.000000) * mat ) )); + pos += (( vec4( normal.xy , 0.000000, 0.000000) * mat ) * isBillboard); + normal = mix( normal, norb, vec3( isBillboard)); + tangent = mix( tangent, vec4( tanb, -1.00000), vec4( isBillboard)); +} +v2f vert( in appdata_full v ) { + v2f o; + vec3 viewDir; + int j = 0; + vec3 lightDir; + float nl; + float backContrib; + vec3 h; + float nh; + ExpandBillboard( gl_ModelViewMatrixInverseTranspose, v.vertex, v.normal, v.tangent); + o.pos = ( gl_ModelViewProjectionMatrix * v.vertex ); + o.uv = v.texcoord.xy ; + viewDir = normalize( ObjSpaceViewDir( v.vertex) ); + for ( ; (j < 3); ( j++ )) { + lightDir = _TerrainTreeLightDirections[ j ]; + nl = dot( v.normal, lightDir); + backContrib = xll_saturate( dot( viewDir, ( -lightDir )) ); + backContrib = mix( xll_saturate( ( -nl ) ), backContrib, _TranslucencyViewDependency); + o.backContrib[ j ] = (backContrib * 2.00000); + nl = max( 0.000000, ((nl * 0.600000) + 0.400000)); + o.nl[ j ] = nl; + h = normalize( (lightDir + viewDir) ); + nh = max( 0.000000, dot( v.normal, h)); + o.nh[ j ] = nh; + } + o.color = vec3( v.color.w ); + return o; +} +attribute vec4 TANGENT; +void main() { + v2f xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert( xlt_v); + gl_Position = vec4( xl_retval.pos); + gl_TexCoord[0] = vec4( xl_retval.uv, 0.0, 0.0); + gl_TexCoord[1] = vec4( xl_retval.color, 0.0); + gl_TexCoord[2] = vec4( xl_retval.backContrib, 0.0); + gl_TexCoord[3] = vec4( xl_retval.nl, 0.0); + gl_TexCoord[4] = vec4( xl_retval.nh, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-TreeCreatorLeavesRT-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-TreeCreatorLeavesRT-ir.txt new file mode 100644 index 000000000..0ce51c3bc --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-TreeCreatorLeavesRT-ir.txt @@ -0,0 +1,276 @@ +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +struct v2f { + vec4 pos; + vec2 uv; + vec3 color; + vec3 backContrib; + vec3 nl; + vec3 nh; +}; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec3 _WorldSpaceCameraPos; +uniform mat4 _World2Object; +uniform float _TranslucencyViewDependency; +uniform vec3 _TerrainTreeLightDirections[4]; +float xll_saturate ( + in float x +) +{ + float tmpvar_1; + tmpvar_1 = clamp (x, 0.0, 1.0); + return tmpvar_1; +} + +vec3 ObjSpaceViewDir ( + in vec4 v +) +{ + vec3 objSpaceCameraPos; + vec4 tmpvar_1; + tmpvar_1.w = 1.0; + tmpvar_1.xyz = _WorldSpaceCameraPos.xyz.xyz; + vec3 tmpvar_2; + tmpvar_2 = ((_World2Object * tmpvar_1).xyz * unity_Scale.w); + objSpaceCameraPos = tmpvar_2; + return (objSpaceCameraPos - v.xyz); +} + +void ExpandBillboard ( + in mat4 mat, + inout vec4 pos, + inout vec3 normal, + inout vec4 tangent +) +{ + vec3 tanb; + vec3 norb; + float isBillboard; + float tmpvar_1; + tmpvar_1 = abs (tangent.w); + float tmpvar_2; + tmpvar_2 = (1.0 - tmpvar_1); + isBillboard = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3.w = 0.0; + tmpvar_3.xyz = normal.xyz; + vec4 tmpvar_4; + tmpvar_4 = normalize ((tmpvar_3 * mat)); + vec3 tmpvar_5; + tmpvar_5 = tmpvar_4.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + norb = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7.w = 0.0; + tmpvar_7.xyz = tangent.xyz.xyz; + vec4 tmpvar_8; + tmpvar_8 = normalize ((tmpvar_7 * mat)); + vec3 tmpvar_9; + tmpvar_9 = tmpvar_8.xyz; + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + tanb = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11.zw = vec2(0.0, 0.0); + tmpvar_11.xy = normal.xy.xy; + vec4 tmpvar_12; + tmpvar_12 = (pos + ((tmpvar_11 * mat) * isBillboard)); + pos = tmpvar_12; + vec3 tmpvar_13; + tmpvar_13 = vec3(isBillboard); + vec3 tmpvar_14; + tmpvar_14 = mix (normal, norb, tmpvar_13); + vec3 tmpvar_15; + tmpvar_15 = tmpvar_14; + normal = tmpvar_15; + vec4 tmpvar_16; + tmpvar_16.w = -1.0; + tmpvar_16.xyz = tanb.xyz; + vec4 tmpvar_17; + tmpvar_17 = vec4(isBillboard); + vec4 tmpvar_18; + tmpvar_18 = mix (tangent, tmpvar_16, tmpvar_17); + vec4 tmpvar_19; + tmpvar_19 = tmpvar_18; + tangent = tmpvar_19; +} + +v2f vert ( + in appdata_full v +) +{ + float nh; + vec3 h; + float backContrib; + float nl; + vec3 lightDir; + int j; + vec3 viewDir; + v2f o; + int tmpvar_1; + tmpvar_1 = 0; + j = tmpvar_1; + ExpandBillboard (gl_ModelViewMatrixInverseTranspose, v.vertex, v.normal, v.tangent); + vec4 tmpvar_2; + tmpvar_2 = (gl_ModelViewProjectionMatrix * v.vertex); + o.pos = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = v.texcoord.xy; + o.uv = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = ObjSpaceViewDir (v.vertex); + vec3 tmpvar_5; + tmpvar_5 = normalize (tmpvar_4); + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + viewDir = tmpvar_6; + while (true) { + if (!((j < 3))) { + break; + }; + vec3 tmpvar_7; + tmpvar_7 = _TerrainTreeLightDirections[j]; + lightDir = tmpvar_7; + float tmpvar_8; + tmpvar_8 = dot (v.normal, lightDir); + float tmpvar_9; + tmpvar_9 = tmpvar_8; + nl = tmpvar_9; + float tmpvar_10; + tmpvar_10 = dot (viewDir, -(lightDir)); + float tmpvar_11; + tmpvar_11 = xll_saturate (tmpvar_10); + float tmpvar_12; + tmpvar_12 = tmpvar_11; + backContrib = tmpvar_12; + float tmpvar_13; + tmpvar_13 = xll_saturate (-(nl)); + float tmpvar_14; + tmpvar_14 = mix (tmpvar_13, backContrib, _TranslucencyViewDependency); + float tmpvar_15; + tmpvar_15 = tmpvar_14; + backContrib = tmpvar_15; + float tmpvar_16; + tmpvar_16 = (backContrib * 2.0); + o.backContrib[j] = tmpvar_16; + float tmpvar_17; + tmpvar_17 = max (0.0, ((nl * 0.6) + 0.4)); + float tmpvar_18; + tmpvar_18 = tmpvar_17; + nl = tmpvar_18; + float tmpvar_19; + tmpvar_19 = nl; + o.nl[j] = tmpvar_19; + vec3 tmpvar_20; + tmpvar_20 = normalize ((lightDir + viewDir)); + vec3 tmpvar_21; + tmpvar_21 = tmpvar_20; + h = tmpvar_21; + float tmpvar_22; + tmpvar_22 = dot (v.normal, h); + float tmpvar_23; + tmpvar_23 = max (0.0, tmpvar_22); + float tmpvar_24; + tmpvar_24 = tmpvar_23; + nh = tmpvar_24; + float tmpvar_25; + tmpvar_25 = nh; + o.nh[j] = tmpvar_25; + int _post_incdec_tmp; + _post_incdec_tmp = j; + int tmpvar_26; + tmpvar_26 = (j + 1); + j = tmpvar_26; + }; + vec3 tmpvar_27; + tmpvar_27 = vec3(v.color.w); + vec3 tmpvar_28; + tmpvar_28 = tmpvar_27; + o.color = tmpvar_28; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f tmpvar_13; + tmpvar_13 = vert (xlt_v); + v2f tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.zw = vec2(0.0, 0.0); + tmpvar_17.xy = xl_retval.uv.xy; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + gl_TexCoord[0] = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19.w = 0.0; + tmpvar_19.xyz = xl_retval.color.xyz; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[1] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21.w = 0.0; + tmpvar_21.xyz = xl_retval.backContrib.xyz; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_TexCoord[2] = tmpvar_22; + vec4 tmpvar_23; + tmpvar_23.w = 0.0; + tmpvar_23.xyz = xl_retval.nl.xyz; + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + gl_TexCoord[3] = tmpvar_24; + vec4 tmpvar_25; + tmpvar_25.w = 0.0; + tmpvar_25.xyz = xl_retval.nh.xyz; + vec4 tmpvar_26; + tmpvar_26 = tmpvar_25; + gl_TexCoord[4] = tmpvar_26; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-TreeCreatorLeavesRT-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-TreeCreatorLeavesRT-out.txt new file mode 100644 index 000000000..6ee776196 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-TreeCreatorLeavesRT-out.txt @@ -0,0 +1,72 @@ +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec3 _WorldSpaceCameraPos; +uniform mat4 _World2Object; +uniform float _TranslucencyViewDependency; +uniform vec3 _TerrainTreeLightDirections[4]; +void main () +{ + vec3 viewDir; + vec3 tmpvar_1; + vec3 tmpvar_2; + vec3 tmpvar_3; + float tmpvar_4; + tmpvar_4 = (1.0 - abs (TANGENT.w)); + vec4 tmpvar_5; + tmpvar_5.w = 0.0; + tmpvar_5.xyz = gl_Normal; + vec4 tmpvar_6; + tmpvar_6.zw = vec2(0.0, 0.0); + tmpvar_6.xy = gl_Normal.xy; + vec4 tmpvar_7; + tmpvar_7 = (gl_Vertex + ((tmpvar_6 * gl_ModelViewMatrixInverseTranspose) * tmpvar_4)); + vec3 tmpvar_8; + tmpvar_8 = mix (gl_Normal, normalize ((tmpvar_5 * gl_ModelViewMatrixInverseTranspose)).xyz, vec3(tmpvar_4)); + vec4 tmpvar_9; + tmpvar_9.w = 1.0; + tmpvar_9.xyz = _WorldSpaceCameraPos; + viewDir = normalize ((((_World2Object * tmpvar_9).xyz * unity_Scale.w) - tmpvar_7.xyz)); + vec3 tmpvar_10; + tmpvar_10 = _TerrainTreeLightDirections[0]; + float tmpvar_11; + tmpvar_11 = dot (tmpvar_8, tmpvar_10); + tmpvar_1.x = (mix (clamp (-(tmpvar_11), 0.0, 1.0), clamp (dot (viewDir, -(tmpvar_10)), 0.0, 1.0), _TranslucencyViewDependency) * 2.0); + tmpvar_2.x = max (0.0, ((tmpvar_11 * 0.6) + 0.4)); + tmpvar_3.x = max (0.0, dot (tmpvar_8, normalize ((tmpvar_10 + viewDir)))); + vec3 tmpvar_12; + tmpvar_12 = _TerrainTreeLightDirections[1]; + float tmpvar_13; + tmpvar_13 = dot (tmpvar_8, tmpvar_12); + tmpvar_1.y = (mix (clamp (-(tmpvar_13), 0.0, 1.0), clamp (dot (viewDir, -(tmpvar_12)), 0.0, 1.0), _TranslucencyViewDependency) * 2.0); + tmpvar_2.y = max (0.0, ((tmpvar_13 * 0.6) + 0.4)); + tmpvar_3.y = max (0.0, dot (tmpvar_8, normalize ((tmpvar_12 + viewDir)))); + vec3 tmpvar_14; + tmpvar_14 = _TerrainTreeLightDirections[2]; + float tmpvar_15; + tmpvar_15 = dot (tmpvar_8, tmpvar_14); + tmpvar_1.z = (mix (clamp (-(tmpvar_15), 0.0, 1.0), clamp (dot (viewDir, -(tmpvar_14)), 0.0, 1.0), _TranslucencyViewDependency) * 2.0); + tmpvar_2.z = max (0.0, ((tmpvar_15 * 0.6) + 0.4)); + tmpvar_3.z = max (0.0, dot (tmpvar_8, normalize ((tmpvar_14 + viewDir)))); + gl_Position = (gl_ModelViewProjectionMatrix * tmpvar_7); + vec4 tmpvar_16; + tmpvar_16.zw = vec2(0.0, 0.0); + tmpvar_16.xy = gl_MultiTexCoord0.xy; + gl_TexCoord[0] = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.w = 0.0; + tmpvar_17.xyz = gl_Color.www; + gl_TexCoord[1] = tmpvar_17; + vec4 tmpvar_18; + tmpvar_18.w = 0.0; + tmpvar_18.xyz = tmpvar_1; + gl_TexCoord[2] = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19.w = 0.0; + tmpvar_19.xyz = tmpvar_2; + gl_TexCoord[3] = tmpvar_19; + vec4 tmpvar_20; + tmpvar_20.w = 0.0; + tmpvar_20.xyz = tmpvar_3; + gl_TexCoord[4] = tmpvar_20; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Tree_Editor_Bark_Shader-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Tree_Editor_Bark_Shader-in.txt new file mode 100644 index 000000000..82aa34ec0 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Tree_Editor_Bark_Shader-in.txt @@ -0,0 +1,171 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +struct LeafSurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + vec3 Translucency; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec4 color; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 lop_color; + vec3 lightDir; + vec3 viewDir; +}; +uniform vec4 _Color; +uniform vec4 _MainTex_ST; +uniform mat4 _Object2World; +uniform vec4 _Scale; +uniform float _SquashAmount; +uniform vec4 _SquashPlaneNormal; +uniform float _TimeX; +uniform vec4 _Wind; +uniform mat4 _World2Object; +uniform vec3 _WorldSpaceCameraPos; +uniform vec4 _WorldSpaceLightPos0; + +uniform vec4 unity_Scale; +vec4 Squash( in vec4 pos ); +vec4 TriangleWave( in vec4 x ); +vec4 SmoothCurve( in vec4 x ); +vec4 SmoothTriangleWave( in vec4 x ); +vec4 AnimateVertex( in vec4 pos, in vec3 normal, in vec4 animParams ); +void TreeVertBark( inout appdata_full v ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +vec3 ObjSpaceViewDir( in vec4 v ); +vec3 ObjSpaceLightDir( in vec4 v ); +v2f_surf vert_surf( in appdata_full v ); +vec4 Squash( in vec4 pos ) { + vec3 projectedVertex; + vec3 planePoint; + vec3 planeNormal; + projectedVertex = pos.xyz ; + planePoint = vec3( 0.000000, _SquashPlaneNormal.w , 0.000000); + planeNormal = _SquashPlaneNormal.xyz ; + projectedVertex += (dot( planeNormal, (planePoint - vec3( pos))) * planeNormal); + pos = vec4( mix( projectedVertex, pos.xyz , vec3( _SquashAmount)), 1.00000); + return pos; +} +vec4 TriangleWave( in vec4 x ) { + return abs( ((fract( (x + 0.500000) ) * 2.00000) - 1.00000) ); +} +vec4 SmoothCurve( in vec4 x ) { + return ((x * x) * (3.00000 - (2.00000 * x))); +} +vec4 SmoothTriangleWave( in vec4 x ) { + return SmoothCurve( TriangleWave( x)); +} +vec4 AnimateVertex( in vec4 pos, in vec3 normal, in vec4 animParams ) { + float fDetailAmp = 0.100000; + float fBranchAmp = 0.300000; + float fObjPhase; + float fBranchPhase; + float fVtxPhase; + vec2 vWavesIn; + vec4 vWaves; + vec2 vWavesSum; + vec3 bend; + fObjPhase = dot( _Object2World[ 3 ].xyz , vec3( 1.00000)); + fBranchPhase = (fObjPhase + animParams.x ); + fVtxPhase = dot( pos.xyz , vec3( (animParams.y + fBranchPhase))); + vWavesIn = (_TimeX + vec2( fVtxPhase, fBranchPhase)); + vWaves = ((fract( (vWavesIn.xxyy * vec4( 1.97500, 0.793000, 0.375000, 0.193000)) ) * 2.00000) - 1.00000); + vWaves = SmoothTriangleWave( vWaves); + vWavesSum = (vWaves.xz + vWaves.yw ); + bend = ((animParams.y * fDetailAmp) * normal.xyz ); + bend.y = (animParams.w * fBranchAmp); + pos.xyz += (((vWavesSum.xyx * bend) + ((_Wind.xyz * vWavesSum.y ) * animParams.w )) * _Wind.w ); + pos.xyz += (animParams.z * _Wind.xyz ); + return pos; +} +void TreeVertBark( inout appdata_full v ) { + v.vertex.xyz *= _Scale.xyz ; + v.vertex = AnimateVertex( v.vertex, v.normal, vec4( v.color.xy , v.texcoord1.xy )); + v.vertex = Squash( v.vertex); + v.color = vec4( (v.color.w * _Color.xyz ), _Color.w ); + v.normal = normalize( v.normal ); + v.tangent.xyz = normalize( v.tangent.xyz ); +} +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +vec3 ObjSpaceViewDir( in vec4 v ) { + vec3 objSpaceCameraPos; + objSpaceCameraPos = (( _World2Object * vec4( _WorldSpaceCameraPos.xyz , 1.00000) ).xyz * unity_Scale.w ); + return (objSpaceCameraPos - v.xyz ); +} +vec3 ObjSpaceLightDir( in vec4 v ) { + vec3 objSpaceLightPos; + objSpaceLightPos = ( _World2Object * _WorldSpaceLightPos0 ).xyz ; + return objSpaceLightPos.xyz ; +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + vec3 binormal; + mat3 rotation; + TreeVertBark( v); + PositionFog( v.vertex, o.pos, o.fog); + o.hip_pack0.xy = ((v.texcoord.xy * _MainTex_ST.xy ) + _MainTex_ST.zw ); + o.lop_color = v.color; + binormal = (cross( v.normal, v.tangent.xyz ) * v.tangent.w ); + rotation = mat3( v.tangent.x , binormal.x , v.normal.x , v.tangent.y , binormal.y , v.normal.y , v.tangent.z , binormal.z , v.normal.z ); + o.lightDir = ( rotation * ObjSpaceLightDir( v.vertex) ); + o.viewDir = ( rotation * ObjSpaceViewDir( v.vertex) ); + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.hip_pack0, 0.0, 0.0); + gl_FrontColor = vec4( xl_retval.lop_color); + gl_TexCoord[1] = vec4( xl_retval.lightDir, 0.0); + gl_TexCoord[2] = vec4( xl_retval.viewDir, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Tree_Editor_Bark_Shader-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Tree_Editor_Bark_Shader-ir.txt new file mode 100644 index 000000000..73c69679a --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Tree_Editor_Bark_Shader-ir.txt @@ -0,0 +1,384 @@ +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 lop_color; + vec3 lightDir; + vec3 viewDir; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform vec3 _WorldSpaceCameraPos; +uniform mat4 _World2Object; +uniform vec4 _Wind; +uniform float _TimeX; +uniform vec4 _SquashPlaneNormal; +uniform float _SquashAmount; +uniform vec4 _Scale; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform vec4 _Color; +vec4 Squash ( + in vec4 pos +) +{ + vec3 planeNormal; + vec3 planePoint; + vec3 projectedVertex; + vec3 tmpvar_1; + tmpvar_1 = pos.xyz; + projectedVertex = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2.xz = vec2(0.0, 0.0); + tmpvar_2.y = _SquashPlaneNormal.w; + vec3 tmpvar_3; + tmpvar_3 = tmpvar_2; + planePoint = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = _SquashPlaneNormal.xyz; + planeNormal = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = pos.xyz; + float tmpvar_6; + tmpvar_6 = dot (planeNormal, (planePoint - tmpvar_5)); + vec3 tmpvar_7; + tmpvar_7 = (projectedVertex + (tmpvar_6 * planeNormal)); + projectedVertex = tmpvar_7; + vec3 tmpvar_8; + tmpvar_8 = vec3(_SquashAmount); + vec3 tmpvar_9; + tmpvar_9 = mix (projectedVertex, pos.xyz, tmpvar_8); + vec4 tmpvar_10; + tmpvar_10.w = 1.0; + tmpvar_10.xyz = tmpvar_9.xyz; + vec4 tmpvar_11; + tmpvar_11 = tmpvar_10; + pos = tmpvar_11; + return pos; +} + +vec4 TriangleWave ( + in vec4 x +) +{ + vec4 tmpvar_1; + tmpvar_1 = fract ((x + 0.5)); + vec4 tmpvar_2; + tmpvar_2 = abs (((tmpvar_1 * 2.0) - 1.0)); + return tmpvar_2; +} + +vec4 SmoothCurve ( + in vec4 x +) +{ + return ((x * x) * (3.0 - (2.0 * x))); +} + +vec4 SmoothTriangleWave ( + in vec4 x +) +{ + vec4 tmpvar_1; + tmpvar_1 = TriangleWave (x); + vec4 tmpvar_2; + tmpvar_2 = SmoothCurve (tmpvar_1); + return tmpvar_2; +} + +vec4 AnimateVertex ( + in vec4 pos, + in vec3 normal, + in vec4 animParams +) +{ + vec3 bend; + vec2 vWavesSum; + vec4 vWaves; + vec2 vWavesIn; + float fVtxPhase; + float fBranchPhase; + float fObjPhase; + float fBranchAmp; + float fDetailAmp; + float tmpvar_1; + tmpvar_1 = 0.1; + fDetailAmp = tmpvar_1; + float tmpvar_2; + tmpvar_2 = 0.3; + fBranchAmp = tmpvar_2; + float tmpvar_3; + tmpvar_3 = dot (_Object2World[3].xyz, vec3(1.0, 1.0, 1.0)); + float tmpvar_4; + tmpvar_4 = tmpvar_3; + fObjPhase = tmpvar_4; + float tmpvar_5; + tmpvar_5 = (fObjPhase + animParams.x); + fBranchPhase = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = vec3((animParams.y + fBranchPhase)); + float tmpvar_7; + tmpvar_7 = dot (pos.xyz, tmpvar_6); + float tmpvar_8; + tmpvar_8 = tmpvar_7; + fVtxPhase = tmpvar_8; + vec2 tmpvar_9; + tmpvar_9.x = fVtxPhase; + tmpvar_9.y = fBranchPhase; + vec2 tmpvar_10; + tmpvar_10 = (_TimeX + tmpvar_9); + vWavesIn = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = fract ((vWavesIn.xxyy * vec4(1.975, 0.793, 0.375, 0.193))); + vec4 tmpvar_12; + tmpvar_12 = ((tmpvar_11 * 2.0) - 1.0); + vWaves = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = SmoothTriangleWave (vWaves); + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + vWaves = tmpvar_14; + vec2 tmpvar_15; + tmpvar_15 = (vWaves.xz + vWaves.yw); + vWavesSum = tmpvar_15; + vec3 tmpvar_16; + tmpvar_16 = ((animParams.y * fDetailAmp) * normal.xyz); + bend = tmpvar_16; + float tmpvar_17; + tmpvar_17 = (animParams.w * fBranchAmp); + bend.y = vec2(tmpvar_17).y; + vec3 tmpvar_18; + tmpvar_18 = (pos.xyz + (((vWavesSum.xyx * bend) + ((_Wind.xyz * vWavesSum.y) * animParams.w)) * _Wind.w)); + pos.xyz = tmpvar_18.xyz.xyz; + vec3 tmpvar_19; + tmpvar_19 = (pos.xyz + (animParams.z * _Wind.xyz)); + pos.xyz = tmpvar_19.xyz.xyz; + return pos; +} + +void TreeVertBark ( + inout appdata_full v +) +{ + vec3 tmpvar_1; + tmpvar_1 = (v.vertex.xyz * _Scale.xyz); + v.vertex.xyz = tmpvar_1.xyz.xyz; + vec4 tmpvar_2; + tmpvar_2.xy = v.color.xy.xy; + tmpvar_2.zw = v.texcoord1.xy.xy; + vec4 tmpvar_3; + tmpvar_3 = AnimateVertex (v.vertex, v.normal, tmpvar_2); + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + v.vertex = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = Squash (v.vertex); + vec4 tmpvar_6; + tmpvar_6 = tmpvar_5; + v.vertex = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7.xyz = (v.color.w * _Color.xyz).xyz; + tmpvar_7.w = _Color.w; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + v.color = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = normalize (v.normal); + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + v.normal = tmpvar_10; + vec3 tmpvar_11; + tmpvar_11 = normalize (v.tangent.xyz); + vec3 tmpvar_12; + tmpvar_12 = tmpvar_11; + v.tangent.xyz = tmpvar_12.xyz.xyz; +} + +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +vec3 ObjSpaceViewDir ( + in vec4 v +) +{ + vec3 objSpaceCameraPos; + vec4 tmpvar_1; + tmpvar_1.w = 1.0; + tmpvar_1.xyz = _WorldSpaceCameraPos.xyz.xyz; + vec3 tmpvar_2; + tmpvar_2 = ((_World2Object * tmpvar_1).xyz * unity_Scale.w); + objSpaceCameraPos = tmpvar_2; + return (objSpaceCameraPos - v.xyz); +} + +vec3 ObjSpaceLightDir ( + in vec4 v +) +{ + vec3 objSpaceLightPos; + vec3 tmpvar_1; + tmpvar_1 = (_World2Object * _WorldSpaceLightPos0).xyz; + objSpaceLightPos = tmpvar_1; + return objSpaceLightPos.xyz; +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + mat3 rotation; + vec3 binormal; + v2f_surf o; + TreeVertBark (v); + PositionFog (v.vertex, o.pos, o.fog); + vec2 tmpvar_1; + tmpvar_1 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + o.hip_pack0 = tmpvar_1.xy.xy; + vec4 tmpvar_2; + tmpvar_2 = v.color; + o.lop_color = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = cross (v.normal, v.tangent.xyz); + vec3 tmpvar_4; + tmpvar_4 = (tmpvar_3 * v.tangent.w); + binormal = tmpvar_4; + mat3 tmpvar_5; + float tmpvar_6; + tmpvar_6 = v.tangent.x; + tmpvar_5[0].x = tmpvar_6; + float tmpvar_7; + tmpvar_7 = binormal.x; + tmpvar_5[0].y = tmpvar_7; + float tmpvar_8; + tmpvar_8 = v.normal.x; + tmpvar_5[0].z = tmpvar_8; + float tmpvar_9; + tmpvar_9 = v.tangent.y; + tmpvar_5[1].x = tmpvar_9; + float tmpvar_10; + tmpvar_10 = binormal.y; + tmpvar_5[1].y = tmpvar_10; + float tmpvar_11; + tmpvar_11 = v.normal.y; + tmpvar_5[1].z = tmpvar_11; + float tmpvar_12; + tmpvar_12 = v.tangent.z; + tmpvar_5[2].x = tmpvar_12; + float tmpvar_13; + tmpvar_13 = binormal.z; + tmpvar_5[2].y = tmpvar_13; + float tmpvar_14; + tmpvar_14 = v.normal.z; + tmpvar_5[2].z = tmpvar_14; + mat3 tmpvar_15; + tmpvar_15 = (tmpvar_5); + rotation = (tmpvar_15); + vec3 tmpvar_16; + tmpvar_16 = ObjSpaceLightDir (v.vertex); + vec3 tmpvar_17; + tmpvar_17 = (rotation * tmpvar_16); + o.lightDir = tmpvar_17; + vec3 tmpvar_18; + tmpvar_18 = ObjSpaceViewDir (v.vertex); + vec3 tmpvar_19; + tmpvar_19 = (rotation * tmpvar_18); + o.viewDir = tmpvar_19; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = xl_retval.fog; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_FOG = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19.zw = vec2(0.0, 0.0); + tmpvar_19.xy = xl_retval.hip_pack0.xy; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[0] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21 = xl_retval.lop_color.xyzw; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_FrontColor = tmpvar_22; + vec4 tmpvar_23; + tmpvar_23.w = 0.0; + tmpvar_23.xyz = xl_retval.lightDir.xyz; + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + gl_TexCoord[1] = tmpvar_24; + vec4 tmpvar_25; + tmpvar_25.w = 0.0; + tmpvar_25.xyz = xl_retval.viewDir.xyz; + vec4 tmpvar_26; + tmpvar_26 = tmpvar_25; + gl_TexCoord[2] = tmpvar_26; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Tree_Editor_Bark_Shader-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Tree_Editor_Bark_Shader-out.txt new file mode 100644 index 000000000..141acd1d7 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Tree_Editor_Bark_Shader-out.txt @@ -0,0 +1,91 @@ +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform vec3 _WorldSpaceCameraPos; +uniform mat4 _World2Object; +uniform vec4 _Wind; +uniform float _TimeX; +uniform vec4 _SquashPlaneNormal; +uniform float _SquashAmount; +uniform vec4 _Scale; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform vec4 _Color; +void main () +{ + vec4 tmpvar_1; + vec4 tmpvar_2; + tmpvar_1 = gl_Vertex; + tmpvar_2 = TANGENT; + tmpvar_1.xyz = (gl_Vertex.xyz * _Scale.xyz); + vec4 pos; + pos = tmpvar_1; + vec3 bend; + float tmpvar_3; + tmpvar_3 = (dot (_Object2World[3].xyz, vec3(1.0, 1.0, 1.0)) + gl_Color.x); + vec2 tmpvar_4; + tmpvar_4.x = dot (tmpvar_1.xyz, vec3((gl_Color.y + tmpvar_3))); + tmpvar_4.y = tmpvar_3; + vec4 tmpvar_5; + tmpvar_5 = abs (((fract ((((fract (((_TimeX + tmpvar_4).xxyy * vec4(1.975, 0.793, 0.375, 0.193))) * 2.0) - 1.0) + 0.5)) * 2.0) - 1.0)); + vec4 tmpvar_6; + tmpvar_6 = ((tmpvar_5 * tmpvar_5) * (3.0 - (2.0 * tmpvar_5))); + vec2 tmpvar_7; + tmpvar_7 = (tmpvar_6.xz + tmpvar_6.yw); + bend = ((gl_Color.y * 0.1) * gl_Normal); + bend.y = (gl_MultiTexCoord1.y * 0.3); + pos.xyz = (tmpvar_1.xyz + (((tmpvar_7.xyx * bend) + ((_Wind.xyz * tmpvar_7.y) * gl_MultiTexCoord1.y)) * _Wind.w)); + pos.xyz = (pos.xyz + (gl_MultiTexCoord1.x * _Wind.xyz)); + vec3 tmpvar_8; + tmpvar_8.xz = vec2(0.0, 0.0); + tmpvar_8.y = _SquashPlaneNormal.w; + vec3 tmpvar_9; + tmpvar_9 = mix ((pos.xyz + (dot (_SquashPlaneNormal.xyz, (tmpvar_8 - pos.xyz)) * _SquashPlaneNormal.xyz)), pos.xyz, vec3(_SquashAmount)); + vec4 tmpvar_10; + tmpvar_10.w = 1.0; + tmpvar_10.xyz = tmpvar_9; + tmpvar_1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11.xyz = (gl_Color.w * _Color.xyz); + tmpvar_11.w = _Color.w; + vec3 tmpvar_12; + tmpvar_12 = normalize (gl_Normal); + tmpvar_2.xyz = normalize (TANGENT.xyz); + vec4 tmpvar_13; + tmpvar_13 = (gl_ModelViewProjectionMatrix * tmpvar_10); + vec3 tmpvar_14; + tmpvar_14 = (cross (tmpvar_12, tmpvar_2.xyz) * TANGENT.w); + mat3 tmpvar_15; + tmpvar_15[0].x = tmpvar_2.x; + tmpvar_15[0].y = tmpvar_14.x; + tmpvar_15[0].z = tmpvar_12.x; + tmpvar_15[1].x = tmpvar_2.y; + tmpvar_15[1].y = tmpvar_14.y; + tmpvar_15[1].z = tmpvar_12.y; + tmpvar_15[2].x = tmpvar_2.z; + tmpvar_15[2].y = tmpvar_14.z; + tmpvar_15[2].z = tmpvar_12.z; + vec4 tmpvar_16; + tmpvar_16.w = 1.0; + tmpvar_16.xyz = _WorldSpaceCameraPos; + gl_Position = tmpvar_13; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = tmpvar_13.z; + xlv_FOG = tmpvar_17; + vec4 tmpvar_18; + tmpvar_18.zw = vec2(0.0, 0.0); + tmpvar_18.xy = ((gl_MultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + gl_TexCoord[0] = tmpvar_18; + gl_FrontColor = tmpvar_11; + vec4 tmpvar_19; + tmpvar_19.w = 0.0; + tmpvar_19.xyz = (tmpvar_15 * (_World2Object * _WorldSpaceLightPos0).xyz); + gl_TexCoord[1] = tmpvar_19; + vec4 tmpvar_20; + tmpvar_20.w = 0.0; + tmpvar_20.xyz = (tmpvar_15 * (((_World2Object * tmpvar_16).xyz * unity_Scale.w) - tmpvar_9)); + gl_TexCoord[2] = tmpvar_20; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Tree_Editor_Bark_Shader1-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Tree_Editor_Bark_Shader1-in.txt new file mode 100644 index 000000000..98804e6fe --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Tree_Editor_Bark_Shader1-in.txt @@ -0,0 +1,175 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +struct LeafSurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + vec3 Translucency; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec4 color; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 lop_color; + vec3 lightDir; + vec3 viewDir; + vec3 _LightCoord; +}; +uniform vec4 _Color; +uniform mat4 _LightMatrix0; +uniform vec4 _MainTex_ST; +uniform mat4 _Object2World; +uniform vec4 _Scale; +uniform float _SquashAmount; +uniform vec4 _SquashPlaneNormal; +uniform float _TimeX; +uniform vec4 _Wind; +uniform mat4 _World2Object; +uniform vec3 _WorldSpaceCameraPos; +uniform vec4 _WorldSpaceLightPos0; + +uniform vec4 unity_Scale; +vec4 Squash( in vec4 pos ); +vec4 TriangleWave( in vec4 x ); +vec4 SmoothCurve( in vec4 x ); +vec4 SmoothTriangleWave( in vec4 x ); +vec4 AnimateVertex( in vec4 pos, in vec3 normal, in vec4 animParams ); +void TreeVertBark( inout appdata_full v ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +vec3 ObjSpaceViewDir( in vec4 v ); +vec3 ObjSpaceLightDir( in vec4 v ); +v2f_surf vert_surf( in appdata_full v ); +vec4 Squash( in vec4 pos ) { + vec3 projectedVertex; + vec3 planePoint; + vec3 planeNormal; + projectedVertex = pos.xyz ; + planePoint = vec3( 0.000000, _SquashPlaneNormal.w , 0.000000); + planeNormal = _SquashPlaneNormal.xyz ; + projectedVertex += (dot( planeNormal, (planePoint - vec3( pos))) * planeNormal); + pos = vec4( mix( projectedVertex, pos.xyz , vec3( _SquashAmount)), 1.00000); + return pos; +} +vec4 TriangleWave( in vec4 x ) { + return abs( ((fract( (x + 0.500000) ) * 2.00000) - 1.00000) ); +} +vec4 SmoothCurve( in vec4 x ) { + return ((x * x) * (3.00000 - (2.00000 * x))); +} +vec4 SmoothTriangleWave( in vec4 x ) { + return SmoothCurve( TriangleWave( x)); +} +vec4 AnimateVertex( in vec4 pos, in vec3 normal, in vec4 animParams ) { + float fDetailAmp = 0.100000; + float fBranchAmp = 0.300000; + float fObjPhase; + float fBranchPhase; + float fVtxPhase; + vec2 vWavesIn; + vec4 vWaves; + vec2 vWavesSum; + vec3 bend; + fObjPhase = dot( _Object2World[ 3 ].xyz , vec3( 1.00000)); + fBranchPhase = (fObjPhase + animParams.x ); + fVtxPhase = dot( pos.xyz , vec3( (animParams.y + fBranchPhase))); + vWavesIn = (_TimeX + vec2( fVtxPhase, fBranchPhase)); + vWaves = ((fract( (vWavesIn.xxyy * vec4( 1.97500, 0.793000, 0.375000, 0.193000)) ) * 2.00000) - 1.00000); + vWaves = SmoothTriangleWave( vWaves); + vWavesSum = (vWaves.xz + vWaves.yw ); + bend = ((animParams.y * fDetailAmp) * normal.xyz ); + bend.y = (animParams.w * fBranchAmp); + pos.xyz += (((vWavesSum.xyx * bend) + ((_Wind.xyz * vWavesSum.y ) * animParams.w )) * _Wind.w ); + pos.xyz += (animParams.z * _Wind.xyz ); + return pos; +} +void TreeVertBark( inout appdata_full v ) { + v.vertex.xyz *= _Scale.xyz ; + v.vertex = AnimateVertex( v.vertex, v.normal, vec4( v.color.xy , v.texcoord1.xy )); + v.vertex = Squash( v.vertex); + v.color = vec4( (v.color.w * _Color.xyz ), _Color.w ); + v.normal = normalize( v.normal ); + v.tangent.xyz = normalize( v.tangent.xyz ); +} +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +vec3 ObjSpaceViewDir( in vec4 v ) { + vec3 objSpaceCameraPos; + objSpaceCameraPos = (( _World2Object * vec4( _WorldSpaceCameraPos.xyz , 1.00000) ).xyz * unity_Scale.w ); + return (objSpaceCameraPos - v.xyz ); +} +vec3 ObjSpaceLightDir( in vec4 v ) { + vec3 objSpaceLightPos; + objSpaceLightPos = ( _World2Object * _WorldSpaceLightPos0 ).xyz ; + return ((objSpaceLightPos.xyz * unity_Scale.w ) - v.xyz ); +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + vec3 binormal; + mat3 rotation; + TreeVertBark( v); + PositionFog( v.vertex, o.pos, o.fog); + o.hip_pack0.xy = ((v.texcoord.xy * _MainTex_ST.xy ) + _MainTex_ST.zw ); + o.lop_color = v.color; + binormal = (cross( v.normal, v.tangent.xyz ) * v.tangent.w ); + rotation = mat3( v.tangent.x , binormal.x , v.normal.x , v.tangent.y , binormal.y , v.normal.y , v.tangent.z , binormal.z , v.normal.z ); + o.lightDir = ( rotation * ObjSpaceLightDir( v.vertex) ); + o.viewDir = ( rotation * ObjSpaceViewDir( v.vertex) ); + o._LightCoord = ( _LightMatrix0 * ( _Object2World * v.vertex ) ).xyz ; + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.hip_pack0, 0.0, 0.0); + gl_FrontColor = vec4( xl_retval.lop_color); + gl_TexCoord[1] = vec4( xl_retval.lightDir, 0.0); + gl_TexCoord[2] = vec4( xl_retval.viewDir, 0.0); + gl_TexCoord[3] = vec4( xl_retval._LightCoord, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Tree_Editor_Bark_Shader1-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Tree_Editor_Bark_Shader1-ir.txt new file mode 100644 index 000000000..ac29aa707 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Tree_Editor_Bark_Shader1-ir.txt @@ -0,0 +1,395 @@ +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 lop_color; + vec3 lightDir; + vec3 viewDir; + vec3 _LightCoord; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform vec3 _WorldSpaceCameraPos; +uniform mat4 _World2Object; +uniform vec4 _Wind; +uniform float _TimeX; +uniform vec4 _SquashPlaneNormal; +uniform float _SquashAmount; +uniform vec4 _Scale; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform mat4 _LightMatrix0; +uniform vec4 _Color; +vec4 Squash ( + in vec4 pos +) +{ + vec3 planeNormal; + vec3 planePoint; + vec3 projectedVertex; + vec3 tmpvar_1; + tmpvar_1 = pos.xyz; + projectedVertex = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2.xz = vec2(0.0, 0.0); + tmpvar_2.y = _SquashPlaneNormal.w; + vec3 tmpvar_3; + tmpvar_3 = tmpvar_2; + planePoint = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = _SquashPlaneNormal.xyz; + planeNormal = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = pos.xyz; + float tmpvar_6; + tmpvar_6 = dot (planeNormal, (planePoint - tmpvar_5)); + vec3 tmpvar_7; + tmpvar_7 = (projectedVertex + (tmpvar_6 * planeNormal)); + projectedVertex = tmpvar_7; + vec3 tmpvar_8; + tmpvar_8 = vec3(_SquashAmount); + vec3 tmpvar_9; + tmpvar_9 = mix (projectedVertex, pos.xyz, tmpvar_8); + vec4 tmpvar_10; + tmpvar_10.w = 1.0; + tmpvar_10.xyz = tmpvar_9.xyz; + vec4 tmpvar_11; + tmpvar_11 = tmpvar_10; + pos = tmpvar_11; + return pos; +} + +vec4 TriangleWave ( + in vec4 x +) +{ + vec4 tmpvar_1; + tmpvar_1 = fract ((x + 0.5)); + vec4 tmpvar_2; + tmpvar_2 = abs (((tmpvar_1 * 2.0) - 1.0)); + return tmpvar_2; +} + +vec4 SmoothCurve ( + in vec4 x +) +{ + return ((x * x) * (3.0 - (2.0 * x))); +} + +vec4 SmoothTriangleWave ( + in vec4 x +) +{ + vec4 tmpvar_1; + tmpvar_1 = TriangleWave (x); + vec4 tmpvar_2; + tmpvar_2 = SmoothCurve (tmpvar_1); + return tmpvar_2; +} + +vec4 AnimateVertex ( + in vec4 pos, + in vec3 normal, + in vec4 animParams +) +{ + vec3 bend; + vec2 vWavesSum; + vec4 vWaves; + vec2 vWavesIn; + float fVtxPhase; + float fBranchPhase; + float fObjPhase; + float fBranchAmp; + float fDetailAmp; + float tmpvar_1; + tmpvar_1 = 0.1; + fDetailAmp = tmpvar_1; + float tmpvar_2; + tmpvar_2 = 0.3; + fBranchAmp = tmpvar_2; + float tmpvar_3; + tmpvar_3 = dot (_Object2World[3].xyz, vec3(1.0, 1.0, 1.0)); + float tmpvar_4; + tmpvar_4 = tmpvar_3; + fObjPhase = tmpvar_4; + float tmpvar_5; + tmpvar_5 = (fObjPhase + animParams.x); + fBranchPhase = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = vec3((animParams.y + fBranchPhase)); + float tmpvar_7; + tmpvar_7 = dot (pos.xyz, tmpvar_6); + float tmpvar_8; + tmpvar_8 = tmpvar_7; + fVtxPhase = tmpvar_8; + vec2 tmpvar_9; + tmpvar_9.x = fVtxPhase; + tmpvar_9.y = fBranchPhase; + vec2 tmpvar_10; + tmpvar_10 = (_TimeX + tmpvar_9); + vWavesIn = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = fract ((vWavesIn.xxyy * vec4(1.975, 0.793, 0.375, 0.193))); + vec4 tmpvar_12; + tmpvar_12 = ((tmpvar_11 * 2.0) - 1.0); + vWaves = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = SmoothTriangleWave (vWaves); + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + vWaves = tmpvar_14; + vec2 tmpvar_15; + tmpvar_15 = (vWaves.xz + vWaves.yw); + vWavesSum = tmpvar_15; + vec3 tmpvar_16; + tmpvar_16 = ((animParams.y * fDetailAmp) * normal.xyz); + bend = tmpvar_16; + float tmpvar_17; + tmpvar_17 = (animParams.w * fBranchAmp); + bend.y = vec2(tmpvar_17).y; + vec3 tmpvar_18; + tmpvar_18 = (pos.xyz + (((vWavesSum.xyx * bend) + ((_Wind.xyz * vWavesSum.y) * animParams.w)) * _Wind.w)); + pos.xyz = tmpvar_18.xyz.xyz; + vec3 tmpvar_19; + tmpvar_19 = (pos.xyz + (animParams.z * _Wind.xyz)); + pos.xyz = tmpvar_19.xyz.xyz; + return pos; +} + +void TreeVertBark ( + inout appdata_full v +) +{ + vec3 tmpvar_1; + tmpvar_1 = (v.vertex.xyz * _Scale.xyz); + v.vertex.xyz = tmpvar_1.xyz.xyz; + vec4 tmpvar_2; + tmpvar_2.xy = v.color.xy.xy; + tmpvar_2.zw = v.texcoord1.xy.xy; + vec4 tmpvar_3; + tmpvar_3 = AnimateVertex (v.vertex, v.normal, tmpvar_2); + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + v.vertex = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = Squash (v.vertex); + vec4 tmpvar_6; + tmpvar_6 = tmpvar_5; + v.vertex = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7.xyz = (v.color.w * _Color.xyz).xyz; + tmpvar_7.w = _Color.w; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + v.color = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = normalize (v.normal); + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + v.normal = tmpvar_10; + vec3 tmpvar_11; + tmpvar_11 = normalize (v.tangent.xyz); + vec3 tmpvar_12; + tmpvar_12 = tmpvar_11; + v.tangent.xyz = tmpvar_12.xyz.xyz; +} + +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +vec3 ObjSpaceViewDir ( + in vec4 v +) +{ + vec3 objSpaceCameraPos; + vec4 tmpvar_1; + tmpvar_1.w = 1.0; + tmpvar_1.xyz = _WorldSpaceCameraPos.xyz.xyz; + vec3 tmpvar_2; + tmpvar_2 = ((_World2Object * tmpvar_1).xyz * unity_Scale.w); + objSpaceCameraPos = tmpvar_2; + return (objSpaceCameraPos - v.xyz); +} + +vec3 ObjSpaceLightDir ( + in vec4 v +) +{ + vec3 objSpaceLightPos; + vec3 tmpvar_1; + tmpvar_1 = (_World2Object * _WorldSpaceLightPos0).xyz; + objSpaceLightPos = tmpvar_1; + return ((objSpaceLightPos.xyz * unity_Scale.w) - v.xyz); +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + mat3 rotation; + vec3 binormal; + v2f_surf o; + TreeVertBark (v); + PositionFog (v.vertex, o.pos, o.fog); + vec2 tmpvar_1; + tmpvar_1 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + o.hip_pack0 = tmpvar_1.xy.xy; + vec4 tmpvar_2; + tmpvar_2 = v.color; + o.lop_color = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = cross (v.normal, v.tangent.xyz); + vec3 tmpvar_4; + tmpvar_4 = (tmpvar_3 * v.tangent.w); + binormal = tmpvar_4; + mat3 tmpvar_5; + float tmpvar_6; + tmpvar_6 = v.tangent.x; + tmpvar_5[0].x = tmpvar_6; + float tmpvar_7; + tmpvar_7 = binormal.x; + tmpvar_5[0].y = tmpvar_7; + float tmpvar_8; + tmpvar_8 = v.normal.x; + tmpvar_5[0].z = tmpvar_8; + float tmpvar_9; + tmpvar_9 = v.tangent.y; + tmpvar_5[1].x = tmpvar_9; + float tmpvar_10; + tmpvar_10 = binormal.y; + tmpvar_5[1].y = tmpvar_10; + float tmpvar_11; + tmpvar_11 = v.normal.y; + tmpvar_5[1].z = tmpvar_11; + float tmpvar_12; + tmpvar_12 = v.tangent.z; + tmpvar_5[2].x = tmpvar_12; + float tmpvar_13; + tmpvar_13 = binormal.z; + tmpvar_5[2].y = tmpvar_13; + float tmpvar_14; + tmpvar_14 = v.normal.z; + tmpvar_5[2].z = tmpvar_14; + mat3 tmpvar_15; + tmpvar_15 = (tmpvar_5); + rotation = (tmpvar_15); + vec3 tmpvar_16; + tmpvar_16 = ObjSpaceLightDir (v.vertex); + vec3 tmpvar_17; + tmpvar_17 = (rotation * tmpvar_16); + o.lightDir = tmpvar_17; + vec3 tmpvar_18; + tmpvar_18 = ObjSpaceViewDir (v.vertex); + vec3 tmpvar_19; + tmpvar_19 = (rotation * tmpvar_18); + o.viewDir = tmpvar_19; + vec3 tmpvar_20; + tmpvar_20 = (_LightMatrix0 * (_Object2World * v.vertex)).xyz; + o._LightCoord = tmpvar_20; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = xl_retval.fog; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_FOG = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19.zw = vec2(0.0, 0.0); + tmpvar_19.xy = xl_retval.hip_pack0.xy; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[0] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21 = xl_retval.lop_color.xyzw; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_FrontColor = tmpvar_22; + vec4 tmpvar_23; + tmpvar_23.w = 0.0; + tmpvar_23.xyz = xl_retval.lightDir.xyz; + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + gl_TexCoord[1] = tmpvar_24; + vec4 tmpvar_25; + tmpvar_25.w = 0.0; + tmpvar_25.xyz = xl_retval.viewDir.xyz; + vec4 tmpvar_26; + tmpvar_26 = tmpvar_25; + gl_TexCoord[2] = tmpvar_26; + vec4 tmpvar_27; + tmpvar_27.w = 0.0; + tmpvar_27.xyz = xl_retval._LightCoord.xyz; + vec4 tmpvar_28; + tmpvar_28 = tmpvar_27; + gl_TexCoord[3] = tmpvar_28; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Tree_Editor_Bark_Shader1-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Tree_Editor_Bark_Shader1-out.txt new file mode 100644 index 000000000..6507427a8 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Tree_Editor_Bark_Shader1-out.txt @@ -0,0 +1,96 @@ +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform vec3 _WorldSpaceCameraPos; +uniform mat4 _World2Object; +uniform vec4 _Wind; +uniform float _TimeX; +uniform vec4 _SquashPlaneNormal; +uniform float _SquashAmount; +uniform vec4 _Scale; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform mat4 _LightMatrix0; +uniform vec4 _Color; +void main () +{ + vec4 tmpvar_1; + vec4 tmpvar_2; + tmpvar_1 = gl_Vertex; + tmpvar_2 = TANGENT; + tmpvar_1.xyz = (gl_Vertex.xyz * _Scale.xyz); + vec4 pos; + pos = tmpvar_1; + vec3 bend; + float tmpvar_3; + tmpvar_3 = (dot (_Object2World[3].xyz, vec3(1.0, 1.0, 1.0)) + gl_Color.x); + vec2 tmpvar_4; + tmpvar_4.x = dot (tmpvar_1.xyz, vec3((gl_Color.y + tmpvar_3))); + tmpvar_4.y = tmpvar_3; + vec4 tmpvar_5; + tmpvar_5 = abs (((fract ((((fract (((_TimeX + tmpvar_4).xxyy * vec4(1.975, 0.793, 0.375, 0.193))) * 2.0) - 1.0) + 0.5)) * 2.0) - 1.0)); + vec4 tmpvar_6; + tmpvar_6 = ((tmpvar_5 * tmpvar_5) * (3.0 - (2.0 * tmpvar_5))); + vec2 tmpvar_7; + tmpvar_7 = (tmpvar_6.xz + tmpvar_6.yw); + bend = ((gl_Color.y * 0.1) * gl_Normal); + bend.y = (gl_MultiTexCoord1.y * 0.3); + pos.xyz = (tmpvar_1.xyz + (((tmpvar_7.xyx * bend) + ((_Wind.xyz * tmpvar_7.y) * gl_MultiTexCoord1.y)) * _Wind.w)); + pos.xyz = (pos.xyz + (gl_MultiTexCoord1.x * _Wind.xyz)); + vec3 tmpvar_8; + tmpvar_8.xz = vec2(0.0, 0.0); + tmpvar_8.y = _SquashPlaneNormal.w; + vec3 tmpvar_9; + tmpvar_9 = mix ((pos.xyz + (dot (_SquashPlaneNormal.xyz, (tmpvar_8 - pos.xyz)) * _SquashPlaneNormal.xyz)), pos.xyz, vec3(_SquashAmount)); + vec4 tmpvar_10; + tmpvar_10.w = 1.0; + tmpvar_10.xyz = tmpvar_9; + tmpvar_1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11.xyz = (gl_Color.w * _Color.xyz); + tmpvar_11.w = _Color.w; + vec3 tmpvar_12; + tmpvar_12 = normalize (gl_Normal); + tmpvar_2.xyz = normalize (TANGENT.xyz); + vec4 tmpvar_13; + tmpvar_13 = (gl_ModelViewProjectionMatrix * tmpvar_10); + vec3 tmpvar_14; + tmpvar_14 = (cross (tmpvar_12, tmpvar_2.xyz) * TANGENT.w); + mat3 tmpvar_15; + tmpvar_15[0].x = tmpvar_2.x; + tmpvar_15[0].y = tmpvar_14.x; + tmpvar_15[0].z = tmpvar_12.x; + tmpvar_15[1].x = tmpvar_2.y; + tmpvar_15[1].y = tmpvar_14.y; + tmpvar_15[1].z = tmpvar_12.y; + tmpvar_15[2].x = tmpvar_2.z; + tmpvar_15[2].y = tmpvar_14.z; + tmpvar_15[2].z = tmpvar_12.z; + vec4 tmpvar_16; + tmpvar_16.w = 1.0; + tmpvar_16.xyz = _WorldSpaceCameraPos; + gl_Position = tmpvar_13; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = tmpvar_13.z; + xlv_FOG = tmpvar_17; + vec4 tmpvar_18; + tmpvar_18.zw = vec2(0.0, 0.0); + tmpvar_18.xy = ((gl_MultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + gl_TexCoord[0] = tmpvar_18; + gl_FrontColor = tmpvar_11; + vec4 tmpvar_19; + tmpvar_19.w = 0.0; + tmpvar_19.xyz = (tmpvar_15 * (((_World2Object * _WorldSpaceLightPos0).xyz * unity_Scale.w) - tmpvar_9)); + gl_TexCoord[1] = tmpvar_19; + vec4 tmpvar_20; + tmpvar_20.w = 0.0; + tmpvar_20.xyz = (tmpvar_15 * (((_World2Object * tmpvar_16).xyz * unity_Scale.w) - tmpvar_9)); + gl_TexCoord[2] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21.w = 0.0; + tmpvar_21.xyz = (_LightMatrix0 * (_Object2World * tmpvar_10)).xyz; + gl_TexCoord[3] = tmpvar_21; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Tree_Editor_Leaf_Shader-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Tree_Editor_Leaf_Shader-in.txt new file mode 100644 index 000000000..886c919c5 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Tree_Editor_Leaf_Shader-in.txt @@ -0,0 +1,189 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +struct LeafSurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + vec3 Translucency; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec4 color; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 lop_color; + vec3 lightDir; + vec3 viewDir; + vec3 _LightCoord; +}; +uniform vec4 _Color; +uniform mat4 _LightMatrix0; +uniform vec4 _MainTex_ST; +uniform mat4 _Object2World; +uniform vec4 _Scale; +uniform float _SquashAmount; +uniform vec4 _SquashPlaneNormal; +uniform float _TimeX; +uniform vec4 _Wind; +uniform mat4 _World2Object; +uniform vec3 _WorldSpaceCameraPos; +uniform vec4 _WorldSpaceLightPos0; + + +uniform vec4 unity_Scale; +vec4 Squash( in vec4 pos ); +void ExpandBillboard( in mat4 mat, inout vec4 pos, inout vec3 normal, inout vec4 tangent ); +vec4 TriangleWave( in vec4 x ); +vec4 SmoothCurve( in vec4 x ); +vec4 SmoothTriangleWave( in vec4 x ); +vec4 AnimateVertex( in vec4 pos, in vec3 normal, in vec4 animParams ); +void TreeVertLeaf( inout appdata_full v ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +vec3 ObjSpaceViewDir( in vec4 v ); +vec3 ObjSpaceLightDir( in vec4 v ); +v2f_surf vert_surf( in appdata_full v ); +vec4 Squash( in vec4 pos ) { + vec3 projectedVertex; + vec3 planePoint; + vec3 planeNormal; + projectedVertex = pos.xyz ; + planePoint = vec3( 0.000000, _SquashPlaneNormal.w , 0.000000); + planeNormal = _SquashPlaneNormal.xyz ; + projectedVertex += (dot( planeNormal, (planePoint - vec3( pos))) * planeNormal); + pos = vec4( mix( projectedVertex, pos.xyz , vec3( _SquashAmount)), 1.00000); + return pos; +} +void ExpandBillboard( in mat4 mat, inout vec4 pos, inout vec3 normal, inout vec4 tangent ) { + float isBillboard; + vec3 norb; + vec3 tanb; + isBillboard = (1.00000 - abs( tangent.w )); + norb = vec3( normalize( ( vec4( normal, 0.000000) * mat ) )); + tanb = vec3( normalize( ( vec4( normal.z , 0.000000, ( -normal.x ), 0.000000) * mat ) )); + pos += (( tangent * mat ) * isBillboard); + normal = mix( normal, norb, vec3( isBillboard)); + tangent = mix( tangent, vec4( tanb, -1.00000), vec4( isBillboard)); +} +vec4 TriangleWave( in vec4 x ) { + return abs( ((fract( (x + 0.500000) ) * 2.00000) - 1.00000) ); +} +vec4 SmoothCurve( in vec4 x ) { + return ((x * x) * (3.00000 - (2.00000 * x))); +} +vec4 SmoothTriangleWave( in vec4 x ) { + return SmoothCurve( TriangleWave( x)); +} +vec4 AnimateVertex( in vec4 pos, in vec3 normal, in vec4 animParams ) { + float fDetailAmp = 0.100000; + float fBranchAmp = 0.300000; + float fObjPhase; + float fBranchPhase; + float fVtxPhase; + vec2 vWavesIn; + vec4 vWaves; + vec2 vWavesSum; + vec3 bend; + fObjPhase = dot( _Object2World[ 3 ].xyz , vec3( 1.00000)); + fBranchPhase = (fObjPhase + animParams.x ); + fVtxPhase = dot( pos.xyz , vec3( (animParams.y + fBranchPhase))); + vWavesIn = (_TimeX + vec2( fVtxPhase, fBranchPhase)); + vWaves = ((fract( (vWavesIn.xxyy * vec4( 1.97500, 0.793000, 0.375000, 0.193000)) ) * 2.00000) - 1.00000); + vWaves = SmoothTriangleWave( vWaves); + vWavesSum = (vWaves.xz + vWaves.yw ); + bend = ((animParams.y * fDetailAmp) * normal.xyz ); + bend.y = (animParams.w * fBranchAmp); + pos.xyz += (((vWavesSum.xyx * bend) + ((_Wind.xyz * vWavesSum.y ) * animParams.w )) * _Wind.w ); + pos.xyz += (animParams.z * _Wind.xyz ); + return pos; +} +void TreeVertLeaf( inout appdata_full v ) { + ExpandBillboard( gl_ModelViewMatrixInverseTranspose, v.vertex, v.normal, v.tangent); + v.vertex.xyz *= _Scale.xyz ; + v.vertex = AnimateVertex( v.vertex, v.normal, vec4( v.color.xy , v.texcoord1.xy )); + v.vertex = Squash( v.vertex); + v.color = vec4( (v.color.w * _Color.xyz ), _Color.w ); + v.normal = normalize( v.normal ); + v.tangent.xyz = normalize( v.tangent.xyz ); +} +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +vec3 ObjSpaceViewDir( in vec4 v ) { + vec3 objSpaceCameraPos; + objSpaceCameraPos = (( _World2Object * vec4( _WorldSpaceCameraPos.xyz , 1.00000) ).xyz * unity_Scale.w ); + return (objSpaceCameraPos - v.xyz ); +} +vec3 ObjSpaceLightDir( in vec4 v ) { + vec3 objSpaceLightPos; + objSpaceLightPos = ( _World2Object * _WorldSpaceLightPos0 ).xyz ; + return ((objSpaceLightPos.xyz * unity_Scale.w ) - v.xyz ); +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + vec3 binormal; + mat3 rotation; + TreeVertLeaf( v); + PositionFog( v.vertex, o.pos, o.fog); + o.hip_pack0.xy = ((v.texcoord.xy * _MainTex_ST.xy ) + _MainTex_ST.zw ); + o.lop_color = v.color; + binormal = (cross( v.normal, v.tangent.xyz ) * v.tangent.w ); + rotation = mat3( v.tangent.x , binormal.x , v.normal.x , v.tangent.y , binormal.y , v.normal.y , v.tangent.z , binormal.z , v.normal.z ); + o.lightDir = ( rotation * ObjSpaceLightDir( v.vertex) ); + o.viewDir = ( rotation * ObjSpaceViewDir( v.vertex) ); + o._LightCoord = ( _LightMatrix0 * ( _Object2World * v.vertex ) ).xyz ; + return o; +} +attribute vec4 TANGENT; +varying vec4 xlv_FOG; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_TexCoord[0] = vec4( xl_retval.hip_pack0, 0.0, 0.0); + gl_FrontColor = vec4( xl_retval.lop_color); + gl_TexCoord[1] = vec4( xl_retval.lightDir, 0.0); + gl_TexCoord[2] = vec4( xl_retval.viewDir, 0.0); + gl_TexCoord[3] = vec4( xl_retval._LightCoord, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Tree_Editor_Leaf_Shader-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Tree_Editor_Leaf_Shader-ir.txt new file mode 100644 index 000000000..d18a617a0 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Tree_Editor_Leaf_Shader-ir.txt @@ -0,0 +1,454 @@ +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +struct v2f_surf { + vec4 pos; + float fog; + vec2 hip_pack0; + vec4 lop_color; + vec3 lightDir; + vec3 viewDir; + vec3 _LightCoord; +}; +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform vec3 _WorldSpaceCameraPos; +uniform mat4 _World2Object; +uniform vec4 _Wind; +uniform float _TimeX; +uniform vec4 _SquashPlaneNormal; +uniform float _SquashAmount; +uniform vec4 _Scale; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform mat4 _LightMatrix0; +uniform vec4 _Color; +vec4 Squash ( + in vec4 pos +) +{ + vec3 planeNormal; + vec3 planePoint; + vec3 projectedVertex; + vec3 tmpvar_1; + tmpvar_1 = pos.xyz; + projectedVertex = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2.xz = vec2(0.0, 0.0); + tmpvar_2.y = _SquashPlaneNormal.w; + vec3 tmpvar_3; + tmpvar_3 = tmpvar_2; + planePoint = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = _SquashPlaneNormal.xyz; + planeNormal = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = pos.xyz; + float tmpvar_6; + tmpvar_6 = dot (planeNormal, (planePoint - tmpvar_5)); + vec3 tmpvar_7; + tmpvar_7 = (projectedVertex + (tmpvar_6 * planeNormal)); + projectedVertex = tmpvar_7; + vec3 tmpvar_8; + tmpvar_8 = vec3(_SquashAmount); + vec3 tmpvar_9; + tmpvar_9 = mix (projectedVertex, pos.xyz, tmpvar_8); + vec4 tmpvar_10; + tmpvar_10.w = 1.0; + tmpvar_10.xyz = tmpvar_9.xyz; + vec4 tmpvar_11; + tmpvar_11 = tmpvar_10; + pos = tmpvar_11; + return pos; +} + +void ExpandBillboard ( + in mat4 mat, + inout vec4 pos, + inout vec3 normal, + inout vec4 tangent +) +{ + vec3 tanb; + vec3 norb; + float isBillboard; + float tmpvar_1; + tmpvar_1 = abs (tangent.w); + float tmpvar_2; + tmpvar_2 = (1.0 - tmpvar_1); + isBillboard = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3.w = 0.0; + tmpvar_3.xyz = normal.xyz; + vec4 tmpvar_4; + tmpvar_4 = normalize ((tmpvar_3 * mat)); + vec3 tmpvar_5; + tmpvar_5 = tmpvar_4.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + norb = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7.yw = vec2(0.0, 0.0); + tmpvar_7.x = normal.z; + tmpvar_7.z = -(normal.x); + vec4 tmpvar_8; + tmpvar_8 = normalize ((tmpvar_7 * mat)); + vec3 tmpvar_9; + tmpvar_9 = tmpvar_8.xyz; + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + tanb = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = (pos + ((tangent * mat) * isBillboard)); + pos = tmpvar_11; + vec3 tmpvar_12; + tmpvar_12 = vec3(isBillboard); + vec3 tmpvar_13; + tmpvar_13 = mix (normal, norb, tmpvar_12); + vec3 tmpvar_14; + tmpvar_14 = tmpvar_13; + normal = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15.w = -1.0; + tmpvar_15.xyz = tanb.xyz; + vec4 tmpvar_16; + tmpvar_16 = vec4(isBillboard); + vec4 tmpvar_17; + tmpvar_17 = mix (tangent, tmpvar_15, tmpvar_16); + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + tangent = tmpvar_18; +} + +vec4 TriangleWave ( + in vec4 x +) +{ + vec4 tmpvar_1; + tmpvar_1 = fract ((x + 0.5)); + vec4 tmpvar_2; + tmpvar_2 = abs (((tmpvar_1 * 2.0) - 1.0)); + return tmpvar_2; +} + +vec4 SmoothCurve ( + in vec4 x +) +{ + return ((x * x) * (3.0 - (2.0 * x))); +} + +vec4 SmoothTriangleWave ( + in vec4 x +) +{ + vec4 tmpvar_1; + tmpvar_1 = TriangleWave (x); + vec4 tmpvar_2; + tmpvar_2 = SmoothCurve (tmpvar_1); + return tmpvar_2; +} + +vec4 AnimateVertex ( + in vec4 pos, + in vec3 normal, + in vec4 animParams +) +{ + vec3 bend; + vec2 vWavesSum; + vec4 vWaves; + vec2 vWavesIn; + float fVtxPhase; + float fBranchPhase; + float fObjPhase; + float fBranchAmp; + float fDetailAmp; + float tmpvar_1; + tmpvar_1 = 0.1; + fDetailAmp = tmpvar_1; + float tmpvar_2; + tmpvar_2 = 0.3; + fBranchAmp = tmpvar_2; + float tmpvar_3; + tmpvar_3 = dot (_Object2World[3].xyz, vec3(1.0, 1.0, 1.0)); + float tmpvar_4; + tmpvar_4 = tmpvar_3; + fObjPhase = tmpvar_4; + float tmpvar_5; + tmpvar_5 = (fObjPhase + animParams.x); + fBranchPhase = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = vec3((animParams.y + fBranchPhase)); + float tmpvar_7; + tmpvar_7 = dot (pos.xyz, tmpvar_6); + float tmpvar_8; + tmpvar_8 = tmpvar_7; + fVtxPhase = tmpvar_8; + vec2 tmpvar_9; + tmpvar_9.x = fVtxPhase; + tmpvar_9.y = fBranchPhase; + vec2 tmpvar_10; + tmpvar_10 = (_TimeX + tmpvar_9); + vWavesIn = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = fract ((vWavesIn.xxyy * vec4(1.975, 0.793, 0.375, 0.193))); + vec4 tmpvar_12; + tmpvar_12 = ((tmpvar_11 * 2.0) - 1.0); + vWaves = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = SmoothTriangleWave (vWaves); + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + vWaves = tmpvar_14; + vec2 tmpvar_15; + tmpvar_15 = (vWaves.xz + vWaves.yw); + vWavesSum = tmpvar_15; + vec3 tmpvar_16; + tmpvar_16 = ((animParams.y * fDetailAmp) * normal.xyz); + bend = tmpvar_16; + float tmpvar_17; + tmpvar_17 = (animParams.w * fBranchAmp); + bend.y = vec2(tmpvar_17).y; + vec3 tmpvar_18; + tmpvar_18 = (pos.xyz + (((vWavesSum.xyx * bend) + ((_Wind.xyz * vWavesSum.y) * animParams.w)) * _Wind.w)); + pos.xyz = tmpvar_18.xyz.xyz; + vec3 tmpvar_19; + tmpvar_19 = (pos.xyz + (animParams.z * _Wind.xyz)); + pos.xyz = tmpvar_19.xyz.xyz; + return pos; +} + +void TreeVertLeaf ( + inout appdata_full v +) +{ + ExpandBillboard (gl_ModelViewMatrixInverseTranspose, v.vertex, v.normal, v.tangent); + vec3 tmpvar_1; + tmpvar_1 = (v.vertex.xyz * _Scale.xyz); + v.vertex.xyz = tmpvar_1.xyz.xyz; + vec4 tmpvar_2; + tmpvar_2.xy = v.color.xy.xy; + tmpvar_2.zw = v.texcoord1.xy.xy; + vec4 tmpvar_3; + tmpvar_3 = AnimateVertex (v.vertex, v.normal, tmpvar_2); + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + v.vertex = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = Squash (v.vertex); + vec4 tmpvar_6; + tmpvar_6 = tmpvar_5; + v.vertex = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7.xyz = (v.color.w * _Color.xyz).xyz; + tmpvar_7.w = _Color.w; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + v.color = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = normalize (v.normal); + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + v.normal = tmpvar_10; + vec3 tmpvar_11; + tmpvar_11 = normalize (v.tangent.xyz); + vec3 tmpvar_12; + tmpvar_12 = tmpvar_11; + v.tangent.xyz = tmpvar_12.xyz.xyz; +} + +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +vec3 ObjSpaceViewDir ( + in vec4 v +) +{ + vec3 objSpaceCameraPos; + vec4 tmpvar_1; + tmpvar_1.w = 1.0; + tmpvar_1.xyz = _WorldSpaceCameraPos.xyz.xyz; + vec3 tmpvar_2; + tmpvar_2 = ((_World2Object * tmpvar_1).xyz * unity_Scale.w); + objSpaceCameraPos = tmpvar_2; + return (objSpaceCameraPos - v.xyz); +} + +vec3 ObjSpaceLightDir ( + in vec4 v +) +{ + vec3 objSpaceLightPos; + vec3 tmpvar_1; + tmpvar_1 = (_World2Object * _WorldSpaceLightPos0).xyz; + objSpaceLightPos = tmpvar_1; + return ((objSpaceLightPos.xyz * unity_Scale.w) - v.xyz); +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + mat3 rotation; + vec3 binormal; + v2f_surf o; + TreeVertLeaf (v); + PositionFog (v.vertex, o.pos, o.fog); + vec2 tmpvar_1; + tmpvar_1 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + o.hip_pack0 = tmpvar_1.xy.xy; + vec4 tmpvar_2; + tmpvar_2 = v.color; + o.lop_color = tmpvar_2; + vec3 tmpvar_3; + tmpvar_3 = cross (v.normal, v.tangent.xyz); + vec3 tmpvar_4; + tmpvar_4 = (tmpvar_3 * v.tangent.w); + binormal = tmpvar_4; + mat3 tmpvar_5; + float tmpvar_6; + tmpvar_6 = v.tangent.x; + tmpvar_5[0].x = tmpvar_6; + float tmpvar_7; + tmpvar_7 = binormal.x; + tmpvar_5[0].y = tmpvar_7; + float tmpvar_8; + tmpvar_8 = v.normal.x; + tmpvar_5[0].z = tmpvar_8; + float tmpvar_9; + tmpvar_9 = v.tangent.y; + tmpvar_5[1].x = tmpvar_9; + float tmpvar_10; + tmpvar_10 = binormal.y; + tmpvar_5[1].y = tmpvar_10; + float tmpvar_11; + tmpvar_11 = v.normal.y; + tmpvar_5[1].z = tmpvar_11; + float tmpvar_12; + tmpvar_12 = v.tangent.z; + tmpvar_5[2].x = tmpvar_12; + float tmpvar_13; + tmpvar_13 = binormal.z; + tmpvar_5[2].y = tmpvar_13; + float tmpvar_14; + tmpvar_14 = v.normal.z; + tmpvar_5[2].z = tmpvar_14; + mat3 tmpvar_15; + tmpvar_15 = (tmpvar_5); + rotation = (tmpvar_15); + vec3 tmpvar_16; + tmpvar_16 = ObjSpaceLightDir (v.vertex); + vec3 tmpvar_17; + tmpvar_17 = (rotation * tmpvar_16); + o.lightDir = tmpvar_17; + vec3 tmpvar_18; + tmpvar_18 = ObjSpaceViewDir (v.vertex); + vec3 tmpvar_19; + tmpvar_19 = (rotation * tmpvar_18); + o.viewDir = tmpvar_19; + vec3 tmpvar_20; + tmpvar_20 = (_LightMatrix0 * (_Object2World * v.vertex)).xyz; + o._LightCoord = tmpvar_20; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_17.x = xl_retval.fog; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + xlv_FOG = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19.zw = vec2(0.0, 0.0); + tmpvar_19.xy = xl_retval.hip_pack0.xy; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[0] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21 = xl_retval.lop_color.xyzw; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_FrontColor = tmpvar_22; + vec4 tmpvar_23; + tmpvar_23.w = 0.0; + tmpvar_23.xyz = xl_retval.lightDir.xyz; + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + gl_TexCoord[1] = tmpvar_24; + vec4 tmpvar_25; + tmpvar_25.w = 0.0; + tmpvar_25.xyz = xl_retval.viewDir.xyz; + vec4 tmpvar_26; + tmpvar_26 = tmpvar_25; + gl_TexCoord[2] = tmpvar_26; + vec4 tmpvar_27; + tmpvar_27.w = 0.0; + tmpvar_27.xyz = xl_retval._LightCoord.xyz; + vec4 tmpvar_28; + tmpvar_28 = tmpvar_27; + gl_TexCoord[3] = tmpvar_28; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Tree_Editor_Leaf_Shader-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Tree_Editor_Leaf_Shader-out.txt new file mode 100644 index 000000000..456889bd5 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Tree_Editor_Leaf_Shader-out.txt @@ -0,0 +1,114 @@ +varying vec4 xlv_FOG; +attribute vec4 TANGENT; +uniform vec4 unity_Scale; +uniform vec4 _WorldSpaceLightPos0; +uniform vec3 _WorldSpaceCameraPos; +uniform mat4 _World2Object; +uniform vec4 _Wind; +uniform float _TimeX; +uniform vec4 _SquashPlaneNormal; +uniform float _SquashAmount; +uniform vec4 _Scale; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform mat4 _LightMatrix0; +uniform vec4 _Color; +void main () +{ + vec4 tmpvar_1; + vec4 tmpvar_2; + float tmpvar_3; + tmpvar_3 = (1.0 - abs (TANGENT.w)); + vec4 tmpvar_4; + tmpvar_4.w = 0.0; + tmpvar_4.xyz = gl_Normal; + vec4 tmpvar_5; + tmpvar_5.yw = vec2(0.0, 0.0); + tmpvar_5.x = gl_Normal.z; + tmpvar_5.z = -(gl_Normal.x); + vec4 tmpvar_6; + tmpvar_6 = (gl_Vertex + ((TANGENT * gl_ModelViewMatrixInverseTranspose) * tmpvar_3)); + vec3 tmpvar_7; + tmpvar_7 = mix (gl_Normal, normalize ((tmpvar_4 * gl_ModelViewMatrixInverseTranspose)).xyz, vec3(tmpvar_3)); + vec4 tmpvar_8; + tmpvar_8.w = -1.0; + tmpvar_8.xyz = normalize ((tmpvar_5 * gl_ModelViewMatrixInverseTranspose)).xyz; + vec4 tmpvar_9; + tmpvar_9 = mix (TANGENT, tmpvar_8, vec4(tmpvar_3)); + tmpvar_1 = tmpvar_6; + tmpvar_2 = tmpvar_9; + tmpvar_1.xyz = (tmpvar_6.xyz * _Scale.xyz); + vec4 pos_i0; + pos_i0 = tmpvar_1; + vec3 bend; + float tmpvar_10; + tmpvar_10 = (dot (_Object2World[3].xyz, vec3(1.0, 1.0, 1.0)) + gl_Color.x); + vec2 tmpvar_11; + tmpvar_11.x = dot (tmpvar_1.xyz, vec3((gl_Color.y + tmpvar_10))); + tmpvar_11.y = tmpvar_10; + vec4 tmpvar_12; + tmpvar_12 = abs (((fract ((((fract (((_TimeX + tmpvar_11).xxyy * vec4(1.975, 0.793, 0.375, 0.193))) * 2.0) - 1.0) + 0.5)) * 2.0) - 1.0)); + vec4 tmpvar_13; + tmpvar_13 = ((tmpvar_12 * tmpvar_12) * (3.0 - (2.0 * tmpvar_12))); + vec2 tmpvar_14; + tmpvar_14 = (tmpvar_13.xz + tmpvar_13.yw); + bend = ((gl_Color.y * 0.1) * tmpvar_7); + bend.y = (gl_MultiTexCoord1.y * 0.3); + pos_i0.xyz = (tmpvar_1.xyz + (((tmpvar_14.xyx * bend) + ((_Wind.xyz * tmpvar_14.y) * gl_MultiTexCoord1.y)) * _Wind.w)); + pos_i0.xyz = (pos_i0.xyz + (gl_MultiTexCoord1.x * _Wind.xyz)); + vec3 tmpvar_15; + tmpvar_15.xz = vec2(0.0, 0.0); + tmpvar_15.y = _SquashPlaneNormal.w; + vec3 tmpvar_16; + tmpvar_16 = mix ((pos_i0.xyz + (dot (_SquashPlaneNormal.xyz, (tmpvar_15 - pos_i0.xyz)) * _SquashPlaneNormal.xyz)), pos_i0.xyz, vec3(_SquashAmount)); + vec4 tmpvar_17; + tmpvar_17.w = 1.0; + tmpvar_17.xyz = tmpvar_16; + tmpvar_1 = tmpvar_17; + vec4 tmpvar_18; + tmpvar_18.xyz = (gl_Color.w * _Color.xyz); + tmpvar_18.w = _Color.w; + vec3 tmpvar_19; + tmpvar_19 = normalize (tmpvar_7); + tmpvar_2.xyz = normalize (tmpvar_9.xyz); + vec4 tmpvar_20; + tmpvar_20 = (gl_ModelViewProjectionMatrix * tmpvar_17); + vec3 tmpvar_21; + tmpvar_21 = (cross (tmpvar_19, tmpvar_2.xyz) * tmpvar_9.w); + mat3 tmpvar_22; + tmpvar_22[0].x = tmpvar_2.x; + tmpvar_22[0].y = tmpvar_21.x; + tmpvar_22[0].z = tmpvar_19.x; + tmpvar_22[1].x = tmpvar_2.y; + tmpvar_22[1].y = tmpvar_21.y; + tmpvar_22[1].z = tmpvar_19.y; + tmpvar_22[2].x = tmpvar_2.z; + tmpvar_22[2].y = tmpvar_21.z; + tmpvar_22[2].z = tmpvar_19.z; + vec4 tmpvar_23; + tmpvar_23.w = 1.0; + tmpvar_23.xyz = _WorldSpaceCameraPos; + gl_Position = tmpvar_20; + vec4 tmpvar_24; + tmpvar_24.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_24.x = tmpvar_20.z; + xlv_FOG = tmpvar_24; + vec4 tmpvar_25; + tmpvar_25.zw = vec2(0.0, 0.0); + tmpvar_25.xy = ((gl_MultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + gl_TexCoord[0] = tmpvar_25; + gl_FrontColor = tmpvar_18; + vec4 tmpvar_26; + tmpvar_26.w = 0.0; + tmpvar_26.xyz = (tmpvar_22 * (((_World2Object * _WorldSpaceLightPos0).xyz * unity_Scale.w) - tmpvar_16)); + gl_TexCoord[1] = tmpvar_26; + vec4 tmpvar_27; + tmpvar_27.w = 0.0; + tmpvar_27.xyz = (tmpvar_22 * (((_World2Object * tmpvar_23).xyz * unity_Scale.w) - tmpvar_16)); + gl_TexCoord[2] = tmpvar_27; + vec4 tmpvar_28; + tmpvar_28.w = 0.0; + tmpvar_28.xyz = (_LightMatrix0 * (_Object2World * tmpvar_17)).xyz; + gl_TexCoord[3] = tmpvar_28; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Tree_Editor_Leaf_Shader1-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Tree_Editor_Leaf_Shader1-in.txt new file mode 100644 index 000000000..6ecde6ff5 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Tree_Editor_Leaf_Shader1-in.txt @@ -0,0 +1,177 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct SurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + float Specular; + float Gloss; + float Alpha; +}; +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +struct LeafSurfaceOutput { + vec3 Albedo; + vec3 Normal; + vec3 Emission; + vec3 Translucency; + float Specular; + float Gloss; + float Alpha; +}; +struct Input { + vec2 uv_MainTex; + vec4 color; +}; +struct v2f_surf { + vec4 pos; + vec3 _ShadowCoord0; + vec3 _ShadowCoord1; + vec3 _ShadowCoord2; + vec3 _ShadowCoord3; + vec2 _ShadowZFade; + vec2 hip_pack0; + vec4 lop_color; +}; +uniform vec4 _Color; +uniform vec4 _LightShadowData; +uniform vec4 _MainTex_ST; +uniform mat4 _Object2World; +uniform vec4 _Scale; +uniform float _SquashAmount; +uniform vec4 _SquashPlaneNormal; +uniform float _TimeX; +uniform vec4 _Wind; +uniform mat4 _World2Shadow; +uniform mat4 _World2Shadow1; +uniform mat4 _World2Shadow2; +uniform mat4 _World2Shadow3; + + + +vec4 Squash( in vec4 pos ); +void ExpandBillboard( in mat4 mat, inout vec4 pos, inout vec3 normal, inout vec4 tangent ); +vec4 TriangleWave( in vec4 x ); +vec4 SmoothCurve( in vec4 x ); +vec4 SmoothTriangleWave( in vec4 x ); +vec4 AnimateVertex( in vec4 pos, in vec3 normal, in vec4 animParams ); +void TreeVertLeaf( inout appdata_full v ); +v2f_surf vert_surf( in appdata_full v ); +vec4 Squash( in vec4 pos ) { + vec3 projectedVertex; + vec3 planePoint; + vec3 planeNormal; + projectedVertex = pos.xyz ; + planePoint = vec3( 0.000000, _SquashPlaneNormal.w , 0.000000); + planeNormal = _SquashPlaneNormal.xyz ; + projectedVertex += (dot( planeNormal, (planePoint - vec3( pos))) * planeNormal); + pos = vec4( mix( projectedVertex, pos.xyz , vec3( _SquashAmount)), 1.00000); + return pos; +} +void ExpandBillboard( in mat4 mat, inout vec4 pos, inout vec3 normal, inout vec4 tangent ) { + float isBillboard; + vec3 norb; + vec3 tanb; + isBillboard = (1.00000 - abs( tangent.w )); + norb = vec3( normalize( ( vec4( normal, 0.000000) * mat ) )); + tanb = vec3( normalize( ( vec4( normal.z , 0.000000, ( -normal.x ), 0.000000) * mat ) )); + pos += (( tangent * mat ) * isBillboard); + normal = mix( normal, norb, vec3( isBillboard)); + tangent = mix( tangent, vec4( tanb, -1.00000), vec4( isBillboard)); +} +vec4 TriangleWave( in vec4 x ) { + return abs( ((fract( (x + 0.500000) ) * 2.00000) - 1.00000) ); +} +vec4 SmoothCurve( in vec4 x ) { + return ((x * x) * (3.00000 - (2.00000 * x))); +} +vec4 SmoothTriangleWave( in vec4 x ) { + return SmoothCurve( TriangleWave( x)); +} +vec4 AnimateVertex( in vec4 pos, in vec3 normal, in vec4 animParams ) { + float fDetailAmp = 0.100000; + float fBranchAmp = 0.300000; + float fObjPhase; + float fBranchPhase; + float fVtxPhase; + vec2 vWavesIn; + vec4 vWaves; + vec2 vWavesSum; + vec3 bend; + fObjPhase = dot( _Object2World[ 3 ].xyz , vec3( 1.00000)); + fBranchPhase = (fObjPhase + animParams.x ); + fVtxPhase = dot( pos.xyz , vec3( (animParams.y + fBranchPhase))); + vWavesIn = (_TimeX + vec2( fVtxPhase, fBranchPhase)); + vWaves = ((fract( (vWavesIn.xxyy * vec4( 1.97500, 0.793000, 0.375000, 0.193000)) ) * 2.00000) - 1.00000); + vWaves = SmoothTriangleWave( vWaves); + vWavesSum = (vWaves.xz + vWaves.yw ); + bend = ((animParams.y * fDetailAmp) * normal.xyz ); + bend.y = (animParams.w * fBranchAmp); + pos.xyz += (((vWavesSum.xyx * bend) + ((_Wind.xyz * vWavesSum.y ) * animParams.w )) * _Wind.w ); + pos.xyz += (animParams.z * _Wind.xyz ); + return pos; +} +void TreeVertLeaf( inout appdata_full v ) { + ExpandBillboard( gl_ModelViewMatrixInverseTranspose, v.vertex, v.normal, v.tangent); + v.vertex.xyz *= _Scale.xyz ; + v.vertex = AnimateVertex( v.vertex, v.normal, vec4( v.color.xy , v.texcoord1.xy )); + v.vertex = Squash( v.vertex); + v.color = vec4( (v.color.w * _Color.xyz ), _Color.w ); + v.normal = normalize( v.normal ); + v.tangent.xyz = normalize( v.tangent.xyz ); +} +v2f_surf vert_surf( in appdata_full v ) { + v2f_surf o; + float z; + vec4 wpos; + TreeVertLeaf( v); + o.hip_pack0.xy = ((v.texcoord.xy * _MainTex_ST.xy ) + _MainTex_ST.zw ); + o.lop_color = v.color; + o.pos = ( gl_ModelViewProjectionMatrix * v.vertex ); + z = ( -( gl_ModelViewMatrix * v.vertex ).z ); + o._ShadowZFade.x = z; + o._ShadowZFade.y = ((z * _LightShadowData.z ) + _LightShadowData.w ); + wpos = ( _Object2World * v.vertex ); + o._ShadowCoord0 = ( _World2Shadow * wpos ).xyz ; + o._ShadowCoord1 = ( _World2Shadow1 * wpos ).xyz ; + o._ShadowCoord2 = ( _World2Shadow2 * wpos ).xyz ; + o._ShadowCoord3 = ( _World2Shadow3 * wpos ).xyz ; + return o; +} +attribute vec4 TANGENT; +void main() { + v2f_surf xl_retval; + appdata_full xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.tangent = vec4( TANGENT); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec4( gl_MultiTexCoord0); + xlt_v.texcoord1 = vec4( gl_MultiTexCoord1); + xlt_v.color = vec4( gl_Color); + xl_retval = vert_surf( xlt_v); + gl_Position = vec4( xl_retval.pos); + gl_TexCoord[0] = vec4( xl_retval._ShadowCoord0, 0.0); + gl_TexCoord[1] = vec4( xl_retval._ShadowCoord1, 0.0); + gl_TexCoord[2] = vec4( xl_retval._ShadowCoord2, 0.0); + gl_TexCoord[3] = vec4( xl_retval._ShadowCoord3, 0.0); + gl_TexCoord[4] = vec4( xl_retval._ShadowZFade, 0.0, 0.0); + gl_TexCoord[5] = vec4( xl_retval.hip_pack0, 0.0, 0.0); + gl_FrontColor = vec4( xl_retval.lop_color); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Tree_Editor_Leaf_Shader1-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Tree_Editor_Leaf_Shader1-ir.txt new file mode 100644 index 000000000..01d0138dc --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Tree_Editor_Leaf_Shader1-ir.txt @@ -0,0 +1,398 @@ +struct appdata_full { + vec4 vertex; + vec4 tangent; + vec3 normal; + vec4 texcoord; + vec4 texcoord1; + vec4 color; +}; +struct v2f_surf { + vec4 pos; + vec3 _ShadowCoord0; + vec3 _ShadowCoord1; + vec3 _ShadowCoord2; + vec3 _ShadowCoord3; + vec2 _ShadowZFade; + vec2 hip_pack0; + vec4 lop_color; +}; +attribute vec4 TANGENT; +uniform mat4 _World2Shadow3; +uniform mat4 _World2Shadow2; +uniform mat4 _World2Shadow1; +uniform mat4 _World2Shadow; +uniform vec4 _Wind; +uniform float _TimeX; +uniform vec4 _SquashPlaneNormal; +uniform float _SquashAmount; +uniform vec4 _Scale; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform vec4 _LightShadowData; +uniform vec4 _Color; +vec4 Squash ( + in vec4 pos +) +{ + vec3 planeNormal; + vec3 planePoint; + vec3 projectedVertex; + vec3 tmpvar_1; + tmpvar_1 = pos.xyz; + projectedVertex = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2.xz = vec2(0.0, 0.0); + tmpvar_2.y = _SquashPlaneNormal.w; + vec3 tmpvar_3; + tmpvar_3 = tmpvar_2; + planePoint = tmpvar_3; + vec3 tmpvar_4; + tmpvar_4 = _SquashPlaneNormal.xyz; + planeNormal = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = pos.xyz; + float tmpvar_6; + tmpvar_6 = dot (planeNormal, (planePoint - tmpvar_5)); + vec3 tmpvar_7; + tmpvar_7 = (projectedVertex + (tmpvar_6 * planeNormal)); + projectedVertex = tmpvar_7; + vec3 tmpvar_8; + tmpvar_8 = vec3(_SquashAmount); + vec3 tmpvar_9; + tmpvar_9 = mix (projectedVertex, pos.xyz, tmpvar_8); + vec4 tmpvar_10; + tmpvar_10.w = 1.0; + tmpvar_10.xyz = tmpvar_9.xyz; + vec4 tmpvar_11; + tmpvar_11 = tmpvar_10; + pos = tmpvar_11; + return pos; +} + +void ExpandBillboard ( + in mat4 mat, + inout vec4 pos, + inout vec3 normal, + inout vec4 tangent +) +{ + vec3 tanb; + vec3 norb; + float isBillboard; + float tmpvar_1; + tmpvar_1 = abs (tangent.w); + float tmpvar_2; + tmpvar_2 = (1.0 - tmpvar_1); + isBillboard = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3.w = 0.0; + tmpvar_3.xyz = normal.xyz; + vec4 tmpvar_4; + tmpvar_4 = normalize ((tmpvar_3 * mat)); + vec3 tmpvar_5; + tmpvar_5 = tmpvar_4.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + norb = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7.yw = vec2(0.0, 0.0); + tmpvar_7.x = normal.z; + tmpvar_7.z = -(normal.x); + vec4 tmpvar_8; + tmpvar_8 = normalize ((tmpvar_7 * mat)); + vec3 tmpvar_9; + tmpvar_9 = tmpvar_8.xyz; + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + tanb = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = (pos + ((tangent * mat) * isBillboard)); + pos = tmpvar_11; + vec3 tmpvar_12; + tmpvar_12 = vec3(isBillboard); + vec3 tmpvar_13; + tmpvar_13 = mix (normal, norb, tmpvar_12); + vec3 tmpvar_14; + tmpvar_14 = tmpvar_13; + normal = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15.w = -1.0; + tmpvar_15.xyz = tanb.xyz; + vec4 tmpvar_16; + tmpvar_16 = vec4(isBillboard); + vec4 tmpvar_17; + tmpvar_17 = mix (tangent, tmpvar_15, tmpvar_16); + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + tangent = tmpvar_18; +} + +vec4 TriangleWave ( + in vec4 x +) +{ + vec4 tmpvar_1; + tmpvar_1 = fract ((x + 0.5)); + vec4 tmpvar_2; + tmpvar_2 = abs (((tmpvar_1 * 2.0) - 1.0)); + return tmpvar_2; +} + +vec4 SmoothCurve ( + in vec4 x +) +{ + return ((x * x) * (3.0 - (2.0 * x))); +} + +vec4 SmoothTriangleWave ( + in vec4 x +) +{ + vec4 tmpvar_1; + tmpvar_1 = TriangleWave (x); + vec4 tmpvar_2; + tmpvar_2 = SmoothCurve (tmpvar_1); + return tmpvar_2; +} + +vec4 AnimateVertex ( + in vec4 pos, + in vec3 normal, + in vec4 animParams +) +{ + vec3 bend; + vec2 vWavesSum; + vec4 vWaves; + vec2 vWavesIn; + float fVtxPhase; + float fBranchPhase; + float fObjPhase; + float fBranchAmp; + float fDetailAmp; + float tmpvar_1; + tmpvar_1 = 0.1; + fDetailAmp = tmpvar_1; + float tmpvar_2; + tmpvar_2 = 0.3; + fBranchAmp = tmpvar_2; + float tmpvar_3; + tmpvar_3 = dot (_Object2World[3].xyz, vec3(1.0, 1.0, 1.0)); + float tmpvar_4; + tmpvar_4 = tmpvar_3; + fObjPhase = tmpvar_4; + float tmpvar_5; + tmpvar_5 = (fObjPhase + animParams.x); + fBranchPhase = tmpvar_5; + vec3 tmpvar_6; + tmpvar_6 = vec3((animParams.y + fBranchPhase)); + float tmpvar_7; + tmpvar_7 = dot (pos.xyz, tmpvar_6); + float tmpvar_8; + tmpvar_8 = tmpvar_7; + fVtxPhase = tmpvar_8; + vec2 tmpvar_9; + tmpvar_9.x = fVtxPhase; + tmpvar_9.y = fBranchPhase; + vec2 tmpvar_10; + tmpvar_10 = (_TimeX + tmpvar_9); + vWavesIn = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = fract ((vWavesIn.xxyy * vec4(1.975, 0.793, 0.375, 0.193))); + vec4 tmpvar_12; + tmpvar_12 = ((tmpvar_11 * 2.0) - 1.0); + vWaves = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13 = SmoothTriangleWave (vWaves); + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + vWaves = tmpvar_14; + vec2 tmpvar_15; + tmpvar_15 = (vWaves.xz + vWaves.yw); + vWavesSum = tmpvar_15; + vec3 tmpvar_16; + tmpvar_16 = ((animParams.y * fDetailAmp) * normal.xyz); + bend = tmpvar_16; + float tmpvar_17; + tmpvar_17 = (animParams.w * fBranchAmp); + bend.y = vec2(tmpvar_17).y; + vec3 tmpvar_18; + tmpvar_18 = (pos.xyz + (((vWavesSum.xyx * bend) + ((_Wind.xyz * vWavesSum.y) * animParams.w)) * _Wind.w)); + pos.xyz = tmpvar_18.xyz.xyz; + vec3 tmpvar_19; + tmpvar_19 = (pos.xyz + (animParams.z * _Wind.xyz)); + pos.xyz = tmpvar_19.xyz.xyz; + return pos; +} + +void TreeVertLeaf ( + inout appdata_full v +) +{ + ExpandBillboard (gl_ModelViewMatrixInverseTranspose, v.vertex, v.normal, v.tangent); + vec3 tmpvar_1; + tmpvar_1 = (v.vertex.xyz * _Scale.xyz); + v.vertex.xyz = tmpvar_1.xyz.xyz; + vec4 tmpvar_2; + tmpvar_2.xy = v.color.xy.xy; + tmpvar_2.zw = v.texcoord1.xy.xy; + vec4 tmpvar_3; + tmpvar_3 = AnimateVertex (v.vertex, v.normal, tmpvar_2); + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + v.vertex = tmpvar_4; + vec4 tmpvar_5; + tmpvar_5 = Squash (v.vertex); + vec4 tmpvar_6; + tmpvar_6 = tmpvar_5; + v.vertex = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7.xyz = (v.color.w * _Color.xyz).xyz; + tmpvar_7.w = _Color.w; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + v.color = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = normalize (v.normal); + vec3 tmpvar_10; + tmpvar_10 = tmpvar_9; + v.normal = tmpvar_10; + vec3 tmpvar_11; + tmpvar_11 = normalize (v.tangent.xyz); + vec3 tmpvar_12; + tmpvar_12 = tmpvar_11; + v.tangent.xyz = tmpvar_12.xyz.xyz; +} + +v2f_surf vert_surf ( + in appdata_full v +) +{ + vec4 wpos; + float z; + v2f_surf o; + TreeVertLeaf (v); + vec2 tmpvar_1; + tmpvar_1 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + o.hip_pack0 = tmpvar_1.xy.xy; + vec4 tmpvar_2; + tmpvar_2 = v.color; + o.lop_color = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = (gl_ModelViewProjectionMatrix * v.vertex); + o.pos = tmpvar_3; + float tmpvar_4; + tmpvar_4 = -((gl_ModelViewMatrix * v.vertex).z); + z = tmpvar_4; + float tmpvar_5; + tmpvar_5 = z; + o._ShadowZFade.x = tmpvar_5; + float tmpvar_6; + tmpvar_6 = ((z * _LightShadowData.z) + _LightShadowData.w); + o._ShadowZFade.y = vec2(tmpvar_6).y; + vec4 tmpvar_7; + tmpvar_7 = (_Object2World * v.vertex); + wpos = tmpvar_7; + vec3 tmpvar_8; + tmpvar_8 = (_World2Shadow * wpos).xyz; + o._ShadowCoord0 = tmpvar_8; + vec3 tmpvar_9; + tmpvar_9 = (_World2Shadow1 * wpos).xyz; + o._ShadowCoord1 = tmpvar_9; + vec3 tmpvar_10; + tmpvar_10 = (_World2Shadow2 * wpos).xyz; + o._ShadowCoord2 = tmpvar_10; + vec3 tmpvar_11; + tmpvar_11 = (_World2Shadow3 * wpos).xyz; + o._ShadowCoord3 = tmpvar_11; + return o; +} + +void main () +{ + appdata_full xlt_v; + v2f_surf xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = TANGENT.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.tangent = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec4 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xyzw; + vec4 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + vec4 tmpvar_9; + tmpvar_9 = gl_MultiTexCoord1.xyzw; + vec4 tmpvar_10; + tmpvar_10 = tmpvar_9; + xlt_v.texcoord1 = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = gl_Color.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + xlt_v.color = tmpvar_12; + v2f_surf tmpvar_13; + tmpvar_13 = vert_surf (xlt_v); + v2f_surf tmpvar_14; + tmpvar_14 = tmpvar_13; + xl_retval = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.pos.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_Position = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.w = 0.0; + tmpvar_17.xyz = xl_retval._ShadowCoord0.xyz; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + gl_TexCoord[0] = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19.w = 0.0; + tmpvar_19.xyz = xl_retval._ShadowCoord1.xyz; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[1] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21.w = 0.0; + tmpvar_21.xyz = xl_retval._ShadowCoord2.xyz; + vec4 tmpvar_22; + tmpvar_22 = tmpvar_21; + gl_TexCoord[2] = tmpvar_22; + vec4 tmpvar_23; + tmpvar_23.w = 0.0; + tmpvar_23.xyz = xl_retval._ShadowCoord3.xyz; + vec4 tmpvar_24; + tmpvar_24 = tmpvar_23; + gl_TexCoord[3] = tmpvar_24; + vec4 tmpvar_25; + tmpvar_25.zw = vec2(0.0, 0.0); + tmpvar_25.xy = xl_retval._ShadowZFade.xy; + vec4 tmpvar_26; + tmpvar_26 = tmpvar_25; + gl_TexCoord[4] = tmpvar_26; + vec4 tmpvar_27; + tmpvar_27.zw = vec2(0.0, 0.0); + tmpvar_27.xy = xl_retval.hip_pack0.xy; + vec4 tmpvar_28; + tmpvar_28 = tmpvar_27; + gl_TexCoord[5] = tmpvar_28; + vec4 tmpvar_29; + tmpvar_29 = xl_retval.lop_color.xyzw; + vec4 tmpvar_30; + tmpvar_30 = tmpvar_29; + gl_FrontColor = tmpvar_30; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Tree_Editor_Leaf_Shader1-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Tree_Editor_Leaf_Shader1-out.txt new file mode 100644 index 000000000..a882f7831 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Tree_Editor_Leaf_Shader1-out.txt @@ -0,0 +1,89 @@ +attribute vec4 TANGENT; +uniform mat4 _World2Shadow3; +uniform mat4 _World2Shadow2; +uniform mat4 _World2Shadow1; +uniform mat4 _World2Shadow; +uniform vec4 _Wind; +uniform float _TimeX; +uniform vec4 _SquashPlaneNormal; +uniform float _SquashAmount; +uniform vec4 _Scale; +uniform mat4 _Object2World; +uniform vec4 _MainTex_ST; +uniform vec4 _LightShadowData; +uniform vec4 _Color; +void main () +{ + vec2 tmpvar_1; + vec4 tmpvar_2; + float tmpvar_3; + tmpvar_3 = (1.0 - abs (TANGENT.w)); + vec4 tmpvar_4; + tmpvar_4.w = 0.0; + tmpvar_4.xyz = gl_Normal; + vec4 tmpvar_5; + tmpvar_5 = (gl_Vertex + ((TANGENT * gl_ModelViewMatrixInverseTranspose) * tmpvar_3)); + tmpvar_2 = tmpvar_5; + tmpvar_2.xyz = (tmpvar_5.xyz * _Scale.xyz); + vec4 pos_i0; + pos_i0 = tmpvar_2; + vec3 bend; + float tmpvar_6; + tmpvar_6 = (dot (_Object2World[3].xyz, vec3(1.0, 1.0, 1.0)) + gl_Color.x); + vec2 tmpvar_7; + tmpvar_7.x = dot (tmpvar_2.xyz, vec3((gl_Color.y + tmpvar_6))); + tmpvar_7.y = tmpvar_6; + vec4 tmpvar_8; + tmpvar_8 = abs (((fract ((((fract (((_TimeX + tmpvar_7).xxyy * vec4(1.975, 0.793, 0.375, 0.193))) * 2.0) - 1.0) + 0.5)) * 2.0) - 1.0)); + vec4 tmpvar_9; + tmpvar_9 = ((tmpvar_8 * tmpvar_8) * (3.0 - (2.0 * tmpvar_8))); + vec2 tmpvar_10; + tmpvar_10 = (tmpvar_9.xz + tmpvar_9.yw); + bend = ((gl_Color.y * 0.1) * mix (gl_Normal, normalize ((tmpvar_4 * gl_ModelViewMatrixInverseTranspose)).xyz, vec3(tmpvar_3))); + bend.y = (gl_MultiTexCoord1.y * 0.3); + pos_i0.xyz = (tmpvar_2.xyz + (((tmpvar_10.xyx * bend) + ((_Wind.xyz * tmpvar_10.y) * gl_MultiTexCoord1.y)) * _Wind.w)); + pos_i0.xyz = (pos_i0.xyz + (gl_MultiTexCoord1.x * _Wind.xyz)); + vec3 tmpvar_11; + tmpvar_11.xz = vec2(0.0, 0.0); + tmpvar_11.y = _SquashPlaneNormal.w; + vec4 tmpvar_12; + tmpvar_12.w = 1.0; + tmpvar_12.xyz = mix ((pos_i0.xyz + (dot (_SquashPlaneNormal.xyz, (tmpvar_11 - pos_i0.xyz)) * _SquashPlaneNormal.xyz)), pos_i0.xyz, vec3(_SquashAmount)); + tmpvar_2 = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13.xyz = (gl_Color.w * _Color.xyz); + tmpvar_13.w = _Color.w; + float tmpvar_14; + tmpvar_14 = -((gl_ModelViewMatrix * tmpvar_12).z); + tmpvar_1.x = tmpvar_14; + tmpvar_1.y = ((tmpvar_14 * _LightShadowData.z) + _LightShadowData.w); + vec4 tmpvar_15; + tmpvar_15 = (_Object2World * tmpvar_12); + gl_Position = (gl_ModelViewProjectionMatrix * tmpvar_12); + vec4 tmpvar_16; + tmpvar_16.w = 0.0; + tmpvar_16.xyz = (_World2Shadow * tmpvar_15).xyz; + gl_TexCoord[0] = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.w = 0.0; + tmpvar_17.xyz = (_World2Shadow1 * tmpvar_15).xyz; + gl_TexCoord[1] = tmpvar_17; + vec4 tmpvar_18; + tmpvar_18.w = 0.0; + tmpvar_18.xyz = (_World2Shadow2 * tmpvar_15).xyz; + gl_TexCoord[2] = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19.w = 0.0; + tmpvar_19.xyz = (_World2Shadow3 * tmpvar_15).xyz; + gl_TexCoord[3] = tmpvar_19; + vec4 tmpvar_20; + tmpvar_20.zw = vec2(0.0, 0.0); + tmpvar_20.xy = tmpvar_1; + gl_TexCoord[4] = tmpvar_20; + vec4 tmpvar_21; + tmpvar_21.zw = vec2(0.0, 0.0); + tmpvar_21.xy = ((gl_MultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + gl_TexCoord[5] = tmpvar_21; + gl_FrontColor = tmpvar_13; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Vertex_Colored-in.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Vertex_Colored-in.txt new file mode 100644 index 000000000..b97a820e7 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Vertex_Colored-in.txt @@ -0,0 +1,57 @@ +struct v2f_vertex_lit { + vec2 uv; + vec4 diff; + vec4 spec; +}; +struct v2f_img { + vec4 pos; + vec2 uv; +}; +struct appdata_img { + vec4 vertex; + vec2 texcoord; +}; +struct v2f { + vec4 pos; + float fog; + vec4 color; + vec2 texcoord; + vec3 normal; +}; +struct appdata_t { + vec4 vertex; + vec4 color; + vec3 normal; + vec2 texcoord; +}; +uniform vec4 _MainTex_ST; + +void PositionFog( in vec4 v, out vec4 pos, out float fog ); +v2f vert( in appdata_t v ); +void PositionFog( in vec4 v, out vec4 pos, out float fog ) { + pos = ( gl_ModelViewProjectionMatrix * v ); + fog = pos.z ; +} +v2f vert( in appdata_t v ) { + v2f o; + PositionFog( v.vertex, o.pos, o.fog); + o.color = v.color; + o.normal = v.normal; + o.texcoord = ((v.texcoord.xy * _MainTex_ST.xy ) + _MainTex_ST.zw ); + return o; +} +varying vec4 xlv_FOG; +void main() { + v2f xl_retval; + appdata_t xlt_v; + xlt_v.vertex = vec4( gl_Vertex); + xlt_v.color = vec4( gl_Color); + xlt_v.normal = vec3( gl_Normal); + xlt_v.texcoord = vec2( gl_MultiTexCoord0); + xl_retval = vert( xlt_v); + gl_Position = vec4( xl_retval.pos); + xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0); + gl_FrontColor = vec4( xl_retval.color); + gl_TexCoord[0] = vec4( xl_retval.texcoord, 0.0, 0.0); + gl_TexCoord[1] = vec4( xl_retval.normal, 0.0); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Vertex_Colored-ir.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Vertex_Colored-ir.txt new file mode 100644 index 000000000..c1fc4bb08 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Vertex_Colored-ir.txt @@ -0,0 +1,106 @@ +struct v2f { + vec4 pos; + float fog; + vec4 color; + vec2 texcoord; + vec3 normal; +}; +struct appdata_t { + vec4 vertex; + vec4 color; + vec3 normal; + vec2 texcoord; +}; +varying vec4 xlv_FOG; +uniform vec4 _MainTex_ST; +void PositionFog ( + in vec4 v, + out vec4 pos, + out float fog +) +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * v); + pos = tmpvar_1; + float tmpvar_2; + tmpvar_2 = pos.z; + fog = tmpvar_2; +} + +v2f vert ( + in appdata_t v +) +{ + v2f o; + PositionFog (v.vertex, o.pos, o.fog); + vec4 tmpvar_1; + tmpvar_1 = v.color; + o.color = tmpvar_1; + vec3 tmpvar_2; + tmpvar_2 = v.normal; + o.normal = tmpvar_2; + vec2 tmpvar_3; + tmpvar_3 = ((v.texcoord.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + o.texcoord = tmpvar_3; + return o; +} + +void main () +{ + appdata_t xlt_v; + v2f xl_retval; + vec4 tmpvar_1; + tmpvar_1 = gl_Vertex.xyzw; + vec4 tmpvar_2; + tmpvar_2 = tmpvar_1; + xlt_v.vertex = tmpvar_2; + vec4 tmpvar_3; + tmpvar_3 = gl_Color.xyzw; + vec4 tmpvar_4; + tmpvar_4 = tmpvar_3; + xlt_v.color = tmpvar_4; + vec3 tmpvar_5; + tmpvar_5 = gl_Normal.xyz; + vec3 tmpvar_6; + tmpvar_6 = tmpvar_5; + xlt_v.normal = tmpvar_6; + vec2 tmpvar_7; + tmpvar_7 = gl_MultiTexCoord0.xy; + vec2 tmpvar_8; + tmpvar_8 = tmpvar_7; + xlt_v.texcoord = tmpvar_8; + v2f tmpvar_9; + tmpvar_9 = vert (xlt_v); + v2f tmpvar_10; + tmpvar_10 = tmpvar_9; + xl_retval = tmpvar_10; + vec4 tmpvar_11; + tmpvar_11 = xl_retval.pos.xyzw; + vec4 tmpvar_12; + tmpvar_12 = tmpvar_11; + gl_Position = tmpvar_12; + vec4 tmpvar_13; + tmpvar_13.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_13.x = xl_retval.fog; + vec4 tmpvar_14; + tmpvar_14 = tmpvar_13; + xlv_FOG = tmpvar_14; + vec4 tmpvar_15; + tmpvar_15 = xl_retval.color.xyzw; + vec4 tmpvar_16; + tmpvar_16 = tmpvar_15; + gl_FrontColor = tmpvar_16; + vec4 tmpvar_17; + tmpvar_17.zw = vec2(0.0, 0.0); + tmpvar_17.xy = xl_retval.texcoord.xy; + vec4 tmpvar_18; + tmpvar_18 = tmpvar_17; + gl_TexCoord[0] = tmpvar_18; + vec4 tmpvar_19; + tmpvar_19.w = 0.0; + tmpvar_19.xyz = xl_retval.normal.xyz; + vec4 tmpvar_20; + tmpvar_20 = tmpvar_19; + gl_TexCoord[1] = tmpvar_20; +} + diff --git a/3rdparty/glsl-optimizer/tests/vertex/unity-Vertex_Colored-out.txt b/3rdparty/glsl-optimizer/tests/vertex/unity-Vertex_Colored-out.txt new file mode 100644 index 000000000..8c5324a2d --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/unity-Vertex_Colored-out.txt @@ -0,0 +1,22 @@ +varying vec4 xlv_FOG; +uniform vec4 _MainTex_ST; +void main () +{ + vec4 tmpvar_1; + tmpvar_1 = (gl_ModelViewProjectionMatrix * gl_Vertex); + gl_Position = tmpvar_1; + vec4 tmpvar_2; + tmpvar_2.yzw = vec3(0.0, 0.0, 0.0); + tmpvar_2.x = tmpvar_1.z; + xlv_FOG = tmpvar_2; + gl_FrontColor = gl_Color; + vec4 tmpvar_3; + tmpvar_3.zw = vec2(0.0, 0.0); + tmpvar_3.xy = ((gl_MultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw); + gl_TexCoord[0] = tmpvar_3; + vec4 tmpvar_4; + tmpvar_4.w = 0.0; + tmpvar_4.xyz = gl_Normal; + gl_TexCoord[1] = tmpvar_4; +} + diff --git a/LICENSE b/LICENSE new file mode 100644 index 000000000..ddd1deb36 --- /dev/null +++ b/LICENSE @@ -0,0 +1,22 @@ +Copyright 2010-2012 Branimir Karadzic. All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY COPYRIGHT HOLDER ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT +SHALL COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED +OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/README.md b/README.md new file mode 100644 index 000000000..4de23c84a --- /dev/null +++ b/README.md @@ -0,0 +1,37 @@ +bgfx +==== + +Rendering library. Supports OpenGL/ES 2.0 and Direct3D 9.0. + +Contact +------- + +Twitter @bkaradzic + +Web http://www.stuckingeometry.com + +License +------- + +Copyright 2010-2012 Branimir Karadzic. All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY COPYRIGHT HOLDER ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT +SHALL COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED +OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/include/bgfx.h b/include/bgfx.h new file mode 100644 index 000000000..baf12c7db --- /dev/null +++ b/include/bgfx.h @@ -0,0 +1,410 @@ +/* + * Copyright 2011-2012 Branimir Karadzic. All rights reserved. + * License: http://www.opensource.org/licenses/BSD-2-Clause + */ + +#ifndef __BGFX_H__ +#define __BGFX_H__ + +#include // uint32_t +#include // size_t + +namespace bgfx +{ +#define BGFX_STATE_DEPTH_WRITE UINT64_C(0x0000000000000001) + +#define BGFX_STATE_ALPHA_TEST UINT64_C(0x0000000000000004) +#define BGFX_STATE_ALPHA_WRITE UINT64_C(0x0000000000000008) +#define BGFX_STATE_ALPHA_MASK UINT64_C(0x000000000000000c) + +#define BGFX_STATE_DEPTH_TEST_LESS UINT64_C(0x0000000000000010) +#define BGFX_STATE_DEPTH_TEST_LEQUAL UINT64_C(0x0000000000000020) +#define BGFX_STATE_DEPTH_TEST_EQUAL UINT64_C(0x0000000000000030) +#define BGFX_STATE_DEPTH_TEST_GEQUAL UINT64_C(0x0000000000000040) +#define BGFX_STATE_DEPTH_TEST_GREATER UINT64_C(0x0000000000000050) +#define BGFX_STATE_DEPTH_TEST_NOTEQUAL UINT64_C(0x0000000000000060) +#define BGFX_STATE_DEPTH_TEST_NEVER UINT64_C(0x0000000000000070) +#define BGFX_STATE_DEPTH_TEST_ALWAYS UINT64_C(0x0000000000000080) +#define BGFX_STATE_DEPTH_TEST_SHIFT 4 +#define BGFX_STATE_DEPTH_TEST_MASK UINT64_C(0x00000000000000f0) + +#define BGFX_STATE_ALPHA_TEST_LESS UINT64_C(0x0000000000000100) +#define BGFX_STATE_ALPHA_TEST_LEQUAL UINT64_C(0x0000000000000200) +#define BGFX_STATE_ALPHA_TEST_EQUAL UINT64_C(0x0000000000000300) +#define BGFX_STATE_ALPHA_TEST_GEQUAL UINT64_C(0x0000000000000400) +#define BGFX_STATE_ALPHA_TEST_GREATER UINT64_C(0x0000000000000500) +#define BGFX_STATE_ALPHA_TEST_NOTEQUAL UINT64_C(0x0000000000000600) +#define BGFX_STATE_ALPHA_TEST_NEVER UINT64_C(0x0000000000000700) +#define BGFX_STATE_ALPHA_TEST_ALWAYS UINT64_C(0x0000000000000800) +#define BGFX_STATE_ALPHA_TEST_SHIFT 8 +#define BGFX_STATE_ALPHA_TEST_MASK UINT64_C(0x0000000000000f00) + +#define BGFX_STATE_BLEND_ZERO UINT64_C(0x0000000000001000) +#define BGFX_STATE_BLEND_ONE UINT64_C(0x0000000000002000) +#define BGFX_STATE_BLEND_SRC_COLOR UINT64_C(0x0000000000003000) +#define BGFX_STATE_BLEND_INV_SRC_COLOR UINT64_C(0x0000000000004000) +#define BGFX_STATE_BLEND_SRC_ALPHA UINT64_C(0x0000000000005000) +#define BGFX_STATE_BLEND_INV_SRC_ALPHA UINT64_C(0x0000000000006000) +#define BGFX_STATE_BLEND_DST_ALPHA UINT64_C(0x0000000000007000) +#define BGFX_STATE_BLEND_INV_DST_ALPHA UINT64_C(0x0000000000008000) +#define BGFX_STATE_BLEND_DST_COLOR UINT64_C(0x0000000000009000) +#define BGFX_STATE_BLEND_INV_DST_COLOR UINT64_C(0x000000000000a000) +#define BGFX_STATE_BLEND_SRC_ALPHA_SAT UINT64_C(0x000000000000b000) +#define BGFX_STATE_BLEND_SHIFT 12 +#define BGFX_STATE_BLEND_MASK UINT64_C(0x000000000ffff000) + +#define BGFX_STATE_CULL_CW UINT64_C(0x0000000010000000) +#define BGFX_STATE_CULL_CCW UINT64_C(0x0000000020000000) +#define BGFX_STATE_CULL_SHIFT 28 +#define BGFX_STATE_CULL_MASK UINT64_C(0x0000000030000000) + +#define BGFX_STATE_RGB_WRITE UINT64_C(0x0000000040000000) + +#define BGFX_STATE_ALPHA_REF_SHIFT 32 +#define BGFX_STATE_ALPHA_REF_MASK UINT64_C(0x000000ff00000000) + +#define BGFX_STATE_PT_LINES UINT64_C(0x0000010000000000) +#define BGFX_STATE_PT_SHIFT 40 +#define BGFX_STATE_PT_MASK UINT64_C(0x0000010000000000) + +#define BGFX_STATE_NONE UINT64_C(0x0000000000000000) +#define BGFX_STATE_MASK UINT64_C(0xffffffffffffffff) +#define BGFX_STATE_DEFAULT (0 \ + | BGFX_STATE_RGB_WRITE \ + | BGFX_STATE_ALPHA_WRITE \ + | BGFX_STATE_DEPTH_TEST_LESS \ + | BGFX_STATE_DEPTH_WRITE \ + | BGFX_STATE_CULL_CW \ + ) + +#define BGFX_CLEAR_NONE UINT8_C(0x00) +#define BGFX_CLEAR_COLOR_BIT UINT8_C(0x01) +#define BGFX_CLEAR_DEPTH_BIT UINT8_C(0x02) +#define BGFX_CLEAR_STENCIL_BIT UINT8_C(0x04) + +#define BGFX_DEBUG_NONE UINT32_C(0x00000000) +#define BGFX_DEBUG_WIREFRAME UINT32_C(0x00000001) +#define BGFX_DEBUG_IFH UINT32_C(0x00000002) +#define BGFX_DEBUG_STATS UINT32_C(0x00000004) +#define BGFX_DEBUG_TEXT UINT32_C(0x00000008) + +#define BGFX_TEXTURE_NONE UINT32_C(0x00000000) +#define BGFX_TEXTURE_U_REPEAT UINT32_C(0x00000000) +#define BGFX_TEXTURE_U_MIRROR UINT32_C(0x00000001) +#define BGFX_TEXTURE_U_CLAMP UINT32_C(0x00000002) +#define BGFX_TEXTURE_U_SHIFT 0 +#define BGFX_TEXTURE_U_MASK UINT32_C(0x00000003) +#define BGFX_TEXTURE_V_REPEAT UINT32_C(0x00000000) +#define BGFX_TEXTURE_V_MIRROR UINT32_C(0x00000010) +#define BGFX_TEXTURE_V_CLAMP UINT32_C(0x00000020) +#define BGFX_TEXTURE_V_SHIFT 4 +#define BGFX_TEXTURE_V_MASK UINT32_C(0x00000030) +#define BGFX_TEXTURE_MIN_POINT UINT32_C(0x00000100) +#define BGFX_TEXTURE_MIN_SHIFT 8 +#define BGFX_TEXTURE_MIN_MASK UINT32_C(0x00000100) +#define BGFX_TEXTURE_MAG_POINT UINT32_C(0x00001000) +#define BGFX_TEXTURE_MAG_SHIFT 12 +#define BGFX_TEXTURE_MAG_MASK UINT32_C(0x00001000) +#define BGFX_TEXTURE_MIP_POINT UINT32_C(0x00010000) +#define BGFX_TEXTURE_MIP_SHIFT 16 +#define BGFX_TEXTURE_MIP_MASK UINT32_C(0x00010000) + +#define BGFX_RENDER_TARGET_NONE UINT32_C(0x00000000) +#define BGFX_RENDER_TARGET_COLOR_RGBA UINT32_C(0x00000001) +#define BGFX_RENDER_TARGET_COLOR_R32F UINT32_C(0x00000002) +#define BGFX_RENDER_TARGET_COLOR_SHIFT 0 +#define BGFX_RENDER_TARGET_COLOR_MASK UINT32_C(0x000000ff) +#define BGFX_RENDER_TARGET_DEPTH UINT32_C(0x00000100) +#define BGFX_RENDER_TARGET_DEPTH_SHIFT 8 +#define BGFX_RENDER_TARGET_DEPTH_MASK UINT32_C(0x0000ff00) + +#define BGFX_RESET_NONE UINT32_C(0x00000000) +#define BGFX_RESET_FULLSCREEN UINT32_C(0x00000001) +#define BGFX_RESET_FULLSCREEN_FAKE UINT32_C(0x00000002) +#define BGFX_RESET_FULLSCREEN_SHIFT 0 +#define BGFX_RESET_FULLSCREEN_MASK UINT32_C(0x00000003) +#define BGFX_RESET_MSAA_X2 UINT32_C(0x00000010) +#define BGFX_RESET_MSAA_X4 UINT32_C(0x00000020) +#define BGFX_RESET_MSAA_X8 UINT32_C(0x00000030) +#define BGFX_RESET_MSAA_X16 UINT32_C(0x00000040) +#define BGFX_RESET_MSAA_SHIFT 4 +#define BGFX_RESET_MSAA_MASK UINT32_C(0x00000070) +#define BGFX_RESET_VSYNC UINT32_C(0x00000080) + +#define BGFX_INVALID_HANDLE { bgfx::invalidHandle } + + struct Attrib + { + enum Enum + { + Position = 0, + Normal, + Color0, + Color1, + Indices, + Weight, + TexCoord0, + TexCoord1, + TexCoord2, + TexCoord3, + TexCoord4, + TexCoord5, + TexCoord6, + TexCoord7, + + Count, + }; + }; + + struct AttribType + { + enum Enum + { + Uint8, + Uint16, + Float, + + Count, + }; + }; + + static const uint16_t invalidHandle = 0xffff; + + typedef struct { uint16_t idx; } FragmentShaderHandle; + typedef struct { uint16_t idx; } IndexBufferHandle; + typedef struct { uint16_t idx; } MaterialHandle; + typedef struct { uint16_t idx; } RenderTargetHandle; + typedef struct { uint16_t idx; } TextureHandle; + typedef struct { uint16_t idx; } UniformHandle; + typedef struct { uint16_t idx; } VertexBufferHandle; + typedef struct { uint16_t idx; } VertexDeclHandle; + typedef struct { uint16_t idx; } VertexShaderHandle; + + struct Memory + { + uint8_t* data; + uint32_t size; + }; + + struct DynamicIndexBuffer + { + uint8_t* data; + uint32_t size; + IndexBufferHandle handle; + uint32_t startIndex; + }; + + struct DynamicVertexBuffer + { + uint8_t* data; + uint32_t size; + uint32_t startVertex; + uint16_t stride; + VertexBufferHandle handle; + VertexDeclHandle decl; + }; + + struct ConstantType + { + enum Enum + { + Uniform1i, + Uniform1f, + End, + + Uniform1iv, + Uniform1fv, + Uniform2fv, + Uniform3fv, + Uniform4fv, + Uniform3x3fv, + Uniform4x4fv, + + Count + }; + }; + + typedef void* (*reallocFn)(void* _ptr, size_t _size); + typedef void (*freeFn)(void* _ptr); + + struct VertexDecl + { + void begin(); + void end(); + void add(Attrib::Enum _attrib, uint8_t _num, AttribType::Enum _type, bool _normalized = false); + void decode(Attrib::Enum _attrib, uint8_t& _num, AttribType::Enum& _type, bool& _normalized) const; + + uint32_t m_hash; + uint16_t m_stride; + uint16_t m_offset[Attrib::Count]; + uint8_t m_attributes[Attrib::Count]; + }; + + /// + void init(bool _createRenderThread = true, reallocFn _realloc = NULL, freeFn _free = NULL); + + /// + void shutdown(); + + /// + void reset(uint32_t _width, uint32_t _height, uint32_t _flags = BGFX_RESET_NONE); + + /// + void frame(); + + /// + const Memory* alloc(uint32_t _size); + + /// + const Memory* makeRef(void* _data, uint32_t _size); + + /// + void setDebug(uint32_t _debug); + + /// + void dbgTextClear(uint8_t _attr = 0, bool _small = false); + + /// + void dbgTextPrintf(uint16_t _x, uint16_t _y, uint8_t _attr, const char* _format, ...); + + /// + IndexBufferHandle createIndexBuffer(const Memory* _mem); + + /// + void destroyIndexBuffer(IndexBufferHandle _handle); + + /// + bool checkAvailDynamicIndexBuffer(uint16_t _num); + + /// + const DynamicIndexBuffer* allocDynamicIndexBuffer(uint16_t _num); + + /// + VertexBufferHandle createVertexBuffer(const Memory* _mem, const VertexDecl& _decl); + + /// + void destroyVertexBuffer(VertexBufferHandle _handle); + + /// + bool checkAvailDynamicVertexBuffer(uint16_t _num, const VertexDecl& _decl); + + /// + const DynamicVertexBuffer* allocDynamicVertexBuffer(uint16_t _num, const VertexDecl& _decl); + + /// + VertexShaderHandle createVertexShader(const Memory* _mem); + + /// + void destroyVertexShader(VertexShaderHandle _handle); + + /// + FragmentShaderHandle createFragmentShader(const Memory* _mem); + + /// + void destroyFragmentShader(FragmentShaderHandle _handle); + + /// + MaterialHandle createMaterial(VertexShaderHandle _vsh, FragmentShaderHandle _fsh); + + /// + void destroyMaterial(MaterialHandle _handle); + + /// + TextureHandle createTexture(const Memory* _mem, uint32_t _flags = BGFX_TEXTURE_NONE, uint16_t* _width = NULL, uint16_t* _height = NULL); + + /// + void destroyTexture(TextureHandle _handle); + + /// + RenderTargetHandle createRenderTarget(uint16_t _width, uint16_t _height, uint32_t _flags = BGFX_RENDER_TARGET_COLOR_RGBA); + + /// + void destroyRenderTarget(RenderTargetHandle _handle); + + /// + UniformHandle createUniform(const char* _name, ConstantType::Enum _type, uint16_t _num = 1); + + /// + void destroyUniform(UniformHandle _handle); + + /// + void setViewRect(uint8_t _id, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height); + + /// + void setViewRectMask(uint32_t _viewMask, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height); + + /// + void setViewClear(uint8_t _id, uint8_t _flags, uint32_t _rgba = 0x000000ff, float _depth = 1.0f, uint8_t _stencil = 0); + + /// + void setViewClearMask(uint32_t _viewMask, uint8_t _flags, uint32_t _rgba = 0x000000ff, float _depth = 1.0f, uint8_t _stencil = 0); + + /// + void setViewSeq(uint8_t _id, bool _enabled); + + /// + void setViewSeqMask(uint32_t _viewMask, bool _enabled); + + /// + void setViewRenderTarget(uint8_t _id, RenderTargetHandle _handle); + + /// + void setViewRenderTargetMask(uint32_t _viewMask, RenderTargetHandle _handle); + + /// + void setViewTransform(uint8_t _id, const void* _view, const void* _proj, uint8_t _other = 0xff); + + /// + void setViewTransformMask(uint32_t _viewMask, const void* _view, const void* _proj, uint8_t _other = 0xff); + + /// + void setState(uint64_t _state); + + /// + uint32_t setTransform(const void* _mtx, uint16_t _num = 1); + + /// + void setTransform(uint32_t _cache = 0, uint16_t _num = 1); + + /// + void setUniform(UniformHandle _handle, const void* _value, uint16_t _num = 1); + + /// + void setIndexBuffer(IndexBufferHandle _handle, uint32_t _firstIndex, uint32_t _numIndices); + + /// + void setIndexBuffer(IndexBufferHandle _handle); + + /// + void setIndexBuffer(const DynamicIndexBuffer* _ib, uint32_t _numIndices = 0xffffffff); + + /// + void setVertexBuffer(VertexBufferHandle _handle); + + /// + void setVertexBuffer(const DynamicVertexBuffer* _vb); + + /// + void setMaterial(MaterialHandle _handle); + + /// + void setTexture(uint8_t _stage, UniformHandle _sampler, TextureHandle _handle); + + /// + void setTexture(uint8_t _stage, UniformHandle _sampler, RenderTargetHandle _handle, bool _depth = false); + + /// + void submit(uint8_t _id); + + /// + void submitMask(uint32_t _viewMask); + + /// + void saveScreenShot(const char* _filePath); + + /// + void renderFrame(); + +} // namespace bgfx + +#endif // __BGFX_H__ diff --git a/premake/premake4.lua b/premake/premake4.lua new file mode 100644 index 000000000..ea56e7a86 --- /dev/null +++ b/premake/premake4.lua @@ -0,0 +1,237 @@ +-- +-- Copyright 2010-2011 Branimir Karadzic. All rights reserved. +-- License: http://www.opensource.org/licenses/BSD-2-Clause +-- + +solution "bgfx" + configurations { + "Debug", + "Release", + } + + platforms { + "x32", + "x64", + "Xbox360", + } + + language "C++" + +newoption { + trigger = "gcc", + value = "GCC", + description = "Choose GCC flavor", + allowed = { + { "mingw", "MinGW" }, + } +} + +-- Avoid error when invoking premake4 --help. +if (_ACTION == nil) then return end + +ROOT_DIR = (path.getabsolute("..") .. "/") +BUILD_DIR = (ROOT_DIR .. ".build/") +THIRD_PARTY_DIR = (ROOT_DIR .. "3rdparty/") + +local XEDK = os.getenv("XEDK") +if not XEDK then XEDK = "" end + +location (BUILD_DIR .. "projects/" .. _ACTION) + +if _ACTION == "gmake" then + + if "linux" ~= os.get() and nil == _OPTIONS["gcc"] then + print("GCC flavor must be specified!") + os.exit(1) + end + + if "mingw" == _OPTIONS["gcc"] then + premake.gcc.cc = "$(MINGW)/bin/mingw32-gcc" + premake.gcc.cxx = "$(MINGW)/bin/mingw32-g++" + premake.gcc.ar = "$(MINGW)/bin/ar" + end +end + +flags { + "StaticRuntime", + "NoMinimalRebuild", + "NoPCH", + "NativeWChar", +-- "ExtraWarnings", + "NoRTTI", + "NoExceptions", + "Symbols", +} + +includedirs { + ROOT_DIR .. "../_bx/include", +} + +configuration "Debug" + defines { + "BGFX_BUILD_DEBUG=1", + } + targetsuffix "Debug" + +configuration "Release" + defines { + "BGFX_BUILD_RELEASE=1", + } + targetsuffix "Release" + +configuration { "vs*" } + defines { + "_HAS_EXCEPTIONS=0", + "_HAS_ITERATOR_DEBUGGING=0", + "_SCL_SECURE=0", + "_CRT_SECURE_NO_WARNINGS", + "_CRT_SECURE_NO_DEPRECATE", + "__STDC_LIMIT_MACROS", + "__STDC_FORMAT_MACROS", + "__STDC_CONSTANT_MACROS", + } + +configuration { "x32", "vs*" } + defines { "WIN32" } + targetdir (BUILD_DIR .. "win32_" .. _ACTION .. "/bin") + objdir (BUILD_DIR .. "win32_" .. _ACTION .. "/obj") + includedirs { THIRD_PARTY_DIR .. "compiler/msvc" } + +configuration { "x64", "vs*" } + defines { "WIN32" } + targetdir (BUILD_DIR .. "win64_" .. _ACTION .. "/bin") + objdir (BUILD_DIR .. "win64_" .. _ACTION .. "/obj") + includedirs { THIRD_PARTY_DIR .. "compiler/msvc" } + +configuration { "x32", "mingw" } + defines { "WIN32" } + targetdir (BUILD_DIR .. "win32_mingw" .. "/bin") + objdir (BUILD_DIR .. "win32_mingw" .. "/obj") + includedirs { THIRD_PARTY_DIR .. "compiler/mingw" } + +configuration { "x64", "mingw" } + defines { "WIN32" } + targetdir (BUILD_DIR .. "win64_mingw" .. "/bin") + objdir (BUILD_DIR .. "win64_mingw" .. "/obj") + includedirs { THIRD_PARTY_DIR .. "compiler/mingw" } + +configuration { "x32", "linux" } + targetdir (BUILD_DIR .. "linux32" .. "/bin") + objdir (BUILD_DIR .. "linux32" .. "/obj") + +configuration { "x64", "linux" } + targetdir (BUILD_DIR .. "linux64" .. "/bin") + objdir (BUILD_DIR .. "linux64" .. "/obj") + +configuration { "Xbox360" } + defines { "_XBOX", "NOMINMAX" } + targetdir (BUILD_DIR .. "xbox360" .. "/bin") + objdir (BUILD_DIR .. "xbox360" .. "/obj") + includedirs { THIRD_PARTY_DIR .. "compiler/msvc" } + +configuration {} -- reset configuration + +project "bgfx" + uuid "f4c51860-ebf4-11e0-9572-0800200c9a66" + kind "StaticLib" + + includedirs { + "../include", + ROOT_DIR .. "../bx/include", + THIRD_PARTY_DIR .. "glew-1.5.4/include", + } + + files { + "../include/**.h", + "../src/**.cpp", + "../src/**.h", + } + +project "shaderc" + uuid "f3cd2e90-52a4-11e1-b86c-0800200c9a66" + kind "ConsoleApp" + + local GLSL_OPTIMIZER = (THIRD_PARTY_DIR .. "glsl-optimizer/") + + configuration { "vs*" } + includedirs { GLSL_OPTIMIZER .. "src/glsl/msvc" } + + configuration {} + + includedirs { + ROOT_DIR .. "../bx/include", + + THIRD_PARTY_DIR .. "fcpp", + + GLSL_OPTIMIZER .. "include", + GLSL_OPTIMIZER .. "include/c99", + GLSL_OPTIMIZER .. "src/mesa", + GLSL_OPTIMIZER .. "src/mapi", + GLSL_OPTIMIZER .. "src/glsl", + } + + files { + ROOT_DIR .. "tools/shaderc.cpp", + THIRD_PARTY_DIR .. "fcpp/**.h", + THIRD_PARTY_DIR .. "fcpp/cpp1.c", + THIRD_PARTY_DIR .. "fcpp/cpp2.c", + THIRD_PARTY_DIR .. "fcpp/cpp3.c", + THIRD_PARTY_DIR .. "fcpp/cpp4.c", + THIRD_PARTY_DIR .. "fcpp/cpp5.c", + THIRD_PARTY_DIR .. "fcpp/cpp6.c", + THIRD_PARTY_DIR .. "fcpp/cpp6.c", + + GLSL_OPTIMIZER .. "src/mesa/**.c", + GLSL_OPTIMIZER .. "src/glsl/**.cpp", + GLSL_OPTIMIZER .. "src/mesa/**.h", + GLSL_OPTIMIZER .. "src/glsl/**.c", + GLSL_OPTIMIZER .. "src/glsl/**.cpp", + GLSL_OPTIMIZER .. "src/glsl/**.h", + } + + excludes { + GLSL_OPTIMIZER .. "src/glsl/glcpp/glcpp.c", + GLSL_OPTIMIZER .. "src/glsl/glcpp/tests/**", + GLSL_OPTIMIZER .. "src/glsl/main.cpp", + GLSL_OPTIMIZER .. "src/glsl/builtin_stubs.cpp", + } + + links { + "d3dx9", + } + +--project "shadows" +-- uuid "ff2c8450-ebf4-11e0-9572-0800200c9a66" +-- kind "ConsoleApp" + +-- includedirs { +-- ROOT_DIR .. "include", +-- } + +-- files { +-- ROOT_DIR .. "examples/common/**", +-- ROOT_DIR .. "examples/shadows/shadows.**" +-- } + +-- links { +-- "bgfx", +-- } + +project "ddsdump" + uuid "838801ee-7bc3-11e1-9f19-eae7d36e7d26" + kind "ConsoleApp" + + includedirs { + ROOT_DIR .. "../bx/include", + ROOT_DIR .. "include", + ROOT_DIR .. "src", + } + + files { + ROOT_DIR .. "src/dds.*", + ROOT_DIR .. "tools/ddsdump.cpp", + } + + links { + "bgfx", + } diff --git a/src/bgfx.cpp b/src/bgfx.cpp new file mode 100644 index 000000000..22219d261 --- /dev/null +++ b/src/bgfx.cpp @@ -0,0 +1,927 @@ +/* + * Copyright 2011-2012 Branimir Karadzic. All rights reserved. + * License: http://www.opensource.org/licenses/BSD-2-Clause + */ + +#include "bgfx_p.h" + +BX_NO_INLINE void* bgfxReallocStub(void* _ptr, size_t _size) +{ + void* ptr = ::realloc(_ptr, _size); + BX_CHECK(NULL != ptr, "Out of memory!"); +// BX_TRACE("alloc %d, %p", _size, ptr); + return ptr; +} + +BX_NO_INLINE void bgfxFreeStub(void* _ptr) +{ +// BX_TRACE("free %p", _ptr); + ::free(_ptr); +} + +namespace bgfx +{ +#define BGFX_MAIN_THREAD_MAGIC 0x78666762 + +#if BGFX_CONFIG_MULTITHREADED +# define BGFX_MAIN_THREAD() BX_CHECK(BGFX_MAIN_THREAD_MAGIC == s_threadIndex, "Must be called from main thread.") +# define BGFX_RENDER_THREAD() BX_CHECK(BGFX_MAIN_THREAD_MAGIC != s_threadIndex, "Must be called from render thread.") +#else +# define BGFX_MAIN_THREAD() +# define BGFX_RENDER_THREAD() +#endif // BGFX_CONFIG_MULTITHREADED + + reallocFn g_realloc = bgfxReallocStub; + freeFn g_free = bgfxFreeStub; + + static BX_THREAD uint32_t s_threadIndex = 0; + static Context s_ctx; + + inline void vec_mul_mtx(float* __restrict _result, const float* __restrict _vec, const float* __restrict _mat) + { + _result[0] = _vec[0] * _mat[ 0] + _vec[1] * _mat[4] + _vec[2] * _mat[ 8] + _vec[3] * _mat[12]; + _result[1] = _vec[0] * _mat[ 1] + _vec[1] * _mat[5] + _vec[2] * _mat[ 9] + _vec[3] * _mat[13]; + _result[2] = _vec[0] * _mat[ 2] + _vec[1] * _mat[6] + _vec[2] * _mat[10] + _vec[3] * _mat[14]; + _result[3] = _vec[0] * _mat[ 3] + _vec[1] * _mat[7] + _vec[2] * _mat[11] + _vec[3] * _mat[15]; + } + + void matrix_mul(float* __restrict _result, const float* __restrict _a, const float* __restrict _b) + { + vec_mul_mtx(&_result[ 0], &_a[ 0], _b); + vec_mul_mtx(&_result[ 4], &_a[ 4], _b); + vec_mul_mtx(&_result[ 8], &_a[ 8], _b); + vec_mul_mtx(&_result[12], &_a[12], _b); + } + + void matrix_ortho(float* _result, float _left, float _right, float _bottom, float _top, float _near, float _far) + { + const float aa = 2.0f/(_right - _left); + const float bb = 2.0f/(_top - _bottom); + const float cc = 1.0f/(_far - _near); + const float dd = (_left + _right)/(_left - _right); + const float ee = (_top + _bottom)/(_bottom - _top); + const float ff = _near / (_near - _far); + + memset(_result, 0, sizeof(float)*16); + _result[0] = aa; + _result[5] = bb; + _result[10] = cc; + _result[12] = dd; + _result[13] = ee; + _result[14] = ff; + _result[15] = 1.0f; + } + +#define RADIX_BITS 11 +#define RADIX_PASSES 6 +#define RADIX_HISTOGRAM_SIZE (1<>shift)&RADIX_BIT_MASK; + ++histogram[index]; + } + + uint16_t offset = 0; + for (uint32_t ii = 0; ii < RADIX_HISTOGRAM_SIZE; ++ii) + { + uint16_t count = histogram[ii]; + histogram[ii] = offset; + offset += count; + } + + for (uint32_t ii = 0; ii < _size; ++ii) + { + uint64_t key = _keys[ii]; + uint16_t index = (key>>shift)&RADIX_BIT_MASK; + uint16_t dest = histogram[index]++; + _tempKeys[dest] = key; + + uint16_t value = _values[ii]; + _tempValues[dest] = value; + } + + uint64_t* swapKeys = _tempKeys; + _tempKeys = _keys; + _keys = swapKeys; + + uint16_t* swapValues = _tempValues; + _tempValues = _values; + _values = swapValues; + + shift += RADIX_BITS; + } + } + + void saveTga(const char* _filePath, uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _data) + { + FILE* file = fopen(_filePath, "wb"); + if ( NULL != file ) + { + putc(0, file); + putc(0, file); + putc(2, file); // uncompressed RGBA + putc(0, file); + putc(0, file); + putc(0, file); + putc(0, file); + putc(0, file); + putc(0, file); + putc(0, file); // x origin + putc(0, file); + putc(0, file); // y origin + putc( _width&0xff, file); + putc( (_width>>8)&0xff, file); + putc( _height&0xff, file); + putc( (_height>>8)&0xff, file); + putc(32, file); + putc(32, file); + + uint8_t* data = (uint8_t*)_data; + for (uint32_t yy = 0; yy < _height; ++yy) + { + fwrite(data, _width*4, 1, file); + data += _pitch; + } + + fclose(file); + } + } + +#include "charset.h" + + void charsetFillTexture(const uint8_t* _charset, uint8_t* _rgba, uint32_t _height, uint32_t _pitch, uint32_t _bpp) + { + for (uint32_t ii = 0; ii < 256; ++ii) + { + uint8_t* pix = &_rgba[ii*8*_bpp]; + for (uint32_t yy = 0; yy < _height; ++yy) + { + for (uint32_t xx = 0; xx < 8; ++xx) + { + uint8_t bit = 1<<(7-xx); + memset(&pix[xx*_bpp], _charset[ii*_height+yy]&bit ? 255 : 0, _bpp); + } + + pix += _pitch; + } + } + } + + static const uint32_t numCharsPerBatch = 1024; + static const uint32_t numBatchVertices = numCharsPerBatch*4; + static const uint32_t numBatchIndices = numCharsPerBatch*6; + + void TextVideoMemBlitter::init() + { + m_decl.begin(); + m_decl.add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float); + m_decl.add(bgfx::Attrib::Color0, 4, bgfx::AttribType::Uint8); + m_decl.add(bgfx::Attrib::Color1, 4, bgfx::AttribType::Uint8); + m_decl.add(bgfx::Attrib::TexCoord0, 2, bgfx::AttribType::Float); + m_decl.end(); + + uint16_t width = 2048; + uint16_t height = 24; + uint8_t bpp = 1; + uint32_t pitch = width*bpp; + + const bgfx::Memory* mem; + + mem = alloc(pitch*height+16); + + StreamWrite stream(mem->data, mem->size); + uint32_t magic = BGFX_MAGIC; + stream.write(magic); + stream.write(width); + stream.write(height); + stream.write(bpp); + uint8_t numMips = 1; + stream.write(numMips); + stream.align(16); + uint8_t* rgba = stream.getDataPtr(); + charsetFillTexture(vga8x8, rgba, 8, pitch, bpp); + charsetFillTexture(vga8x16, &rgba[8*pitch], 16, pitch, bpp); + m_texture = s_ctx.createTexture(mem, BGFX_TEXTURE_MIN_POINT|BGFX_TEXTURE_MAG_POINT|BGFX_TEXTURE_MIP_POINT, NULL, NULL); + +#if BGFX_CONFIG_RENDERER_DIRECT3D + mem = bgfx::alloc(sizeof(vs_debugfont_hlsl)+1); + memcpy(mem->data, vs_debugfont_hlsl, mem->size-1); +#else + mem = bgfx::alloc(sizeof(vs_debugfont_glsl)+1); + memcpy(mem->data, vs_debugfont_glsl, mem->size-1); +#endif // BGFX_CONFIG_RENDERER_ + mem->data[mem->size-1] = '\0'; + bgfx::VertexShaderHandle vsh = bgfx::createVertexShader(mem); + +#if BGFX_CONFIG_RENDERER_DIRECT3D + mem = bgfx::alloc(sizeof(fs_debugfont_hlsl)+1); + memcpy(mem->data, fs_debugfont_hlsl, mem->size-1); +#else + mem = bgfx::alloc(sizeof(fs_debugfont_glsl)+1); + memcpy(mem->data, fs_debugfont_glsl, mem->size-1); +#endif // BGFX_CONFIG_RENDERER_ + mem->data[mem->size-1] = '\0'; + bgfx::FragmentShaderHandle fsh = bgfx::createFragmentShader(mem); + + m_material = bgfx::createMaterial(vsh, fsh); + + m_vb = s_ctx.createDynamicVertexBuffer(numBatchVertices*m_decl.m_stride, &m_decl); + m_ib = s_ctx.createDynamicIndexBuffer(numBatchIndices*2); + } + + void TextVideoMemBlitter::blit(const TextVideoMem& _mem) + { + struct FontVertex + { + float m_x; + float m_y; + float m_z; + uint32_t m_fg; + uint32_t m_bg; + float m_u; + float m_v; + }; + + static uint32_t palette[16] = + { + 0x0, + 0xff0000cc, + 0xff069a4e, + 0xff00a0c4, + 0xffa46534, + 0xff7b5075, + 0xff9a9806, + 0xffcfd7d3, + 0xff535755, + 0xff2929ef, + 0xff34e28a, + 0xff4fe9fc, + 0xffcf9f72, + 0xffa87fad, + 0xffe2e234, + 0xffeceeee, + }; + + uint32_t yy = 0; + uint32_t xx = 0; + + const float texelWidth = 1.0f/2048.0f; + const float texelWidthHalf = texelWidth*0.5f; + const float texelHeight = 1.0f/24.0f; + const float texelHeightHalf = texelHeight*0.5f; + const float utop = (_mem.m_small ? 0.0f : 8.0f)*texelHeight - texelHeightHalf; + const float ubottom = (_mem.m_small ? 8.0f : 24.0f)*texelHeight - texelHeightHalf; + const float fontHeight = (_mem.m_small ? 8.0f : 16.0f); + + setup(); + + for (;xx < _mem.m_width && yy < _mem.m_height;) + { + FontVertex* vertex = (FontVertex*)m_vb->data; + uint16_t* indices = (uint16_t*)m_ib->data; + uint32_t startVertex = 0; + uint32_t numIndices = 0; + + for (; yy < _mem.m_height && numIndices < numBatchIndices; ++yy) + { + xx = xx < _mem.m_width ? xx : 0; + const uint8_t* line = &_mem.m_mem[(yy*_mem.m_width+xx)*2]; + + for (; xx < _mem.m_width && numIndices < numBatchIndices; ++xx) + { + uint8_t ch = line[0]; + uint8_t attr = line[1]; + + if (0 != (ch|attr) + && (' ' != ch || 0 != (attr&0xf0) ) ) + { + uint32_t fg = palette[attr&0xf]; + uint32_t bg = palette[(attr>>4)&0xf]; + + FontVertex vert[4] = + { + { (xx )*8.0f, (yy )*fontHeight, 0.0f, fg, bg, (ch )*8.0f*texelWidth - texelWidthHalf, utop }, + { (xx+1)*8.0f, (yy )*fontHeight, 0.0f, fg, bg, (ch+1)*8.0f*texelWidth - texelWidthHalf, utop }, + { (xx+1)*8.0f, (yy+1)*fontHeight, 0.0f, fg, bg, (ch+1)*8.0f*texelWidth - texelWidthHalf, ubottom }, + { (xx )*8.0f, (yy+1)*fontHeight, 0.0f, fg, bg, (ch )*8.0f*texelWidth - texelWidthHalf, ubottom }, + }; + + memcpy(vertex, vert, sizeof(vert) ); + vertex += 4; + + indices[0] = startVertex+0; + indices[1] = startVertex+1; + indices[2] = startVertex+2; + indices[3] = startVertex+2; + indices[4] = startVertex+3; + indices[5] = startVertex+0; + + startVertex += 4; + indices += 6; + + numIndices += 6; + } + + line += 2; + } + + if (numIndices >= numBatchIndices) + { + break; + } + } + + render(numIndices); + } + } + + TextVideoMemBlitter g_textVideoMemBlitter; + + static const char* s_predefinedName[PredefinedUniform::Count] = + { + "u_viewRect", + "u_viewTexel", + "u_view", + "u_viewProj", + "u_viewProjX", + "u_model", + "u_modelViewProj", + "u_modelViewProjX", + "u_alphaRef", + }; + + PredefinedUniform::Enum nameToPredefinedUniformEnum(const char* _name) + { + for (uint32_t ii = 0; ii < PredefinedUniform::Count; ++ii) + { + if (0 == strcmp(_name, s_predefinedName[ii]) ) + { + return PredefinedUniform::Enum(ii); + } + } + + return PredefinedUniform::Count; + } + + void Frame::submit(uint8_t _id) + { + if (m_discard) + { + m_discard = false; + return; + } + + if (BGFX_CONFIG_MAX_DRAW_CALLS-1 <= m_num) + { + ++m_numDropped; + return; + } + + m_key.m_view = _id; + m_key.m_seq = s_ctx.m_seq[_id] & s_ctx.m_seqMask[_id]; + s_ctx.m_seq[_id]++; + uint64_t key = m_key.encode(); + m_sortKeys[m_num] = key; + m_sortValues[m_num] = m_numRenderStates; + ++m_num; + + m_state.m_constEnd = m_constantBuffer->getPos(); + m_state.m_flags |= m_flags; + m_renderState[m_numRenderStates] = m_state; + ++m_numRenderStates; + m_state.clear(); + m_flags = BGFX_STATE_NONE; + } + + void Frame::submitMask(uint32_t _viewMask) + { + if (m_discard) + { + m_discard = false; + return; + } + + if (BGFX_CONFIG_MAX_DRAW_CALLS-1 <= m_num) + { + m_numDropped += uint32_cntbits(_viewMask); + return; + } + + for (uint32_t id = 0, viewMask = _viewMask, ntz = uint32_cnttz(_viewMask); 0 != viewMask; viewMask >>= 1, id += 1, ntz = uint32_cnttz(viewMask) ) + { + viewMask >>= ntz; + id += ntz; + + m_key.m_view = id; + m_key.m_seq = s_ctx.m_seq[id] & s_ctx.m_seqMask[id]; + s_ctx.m_seq[id]++; + uint64_t key = m_key.encode(); + m_sortKeys[m_num] = key; + m_sortValues[m_num] = m_numRenderStates; + ++m_num; + } + + m_state.m_constEnd = m_constantBuffer->getPos(); + m_state.m_flags |= m_flags; + m_renderState[m_numRenderStates] = m_state; + ++m_numRenderStates; + m_state.clear(); + m_flags = BGFX_STATE_NONE; + } + + void Frame::sort() + { + radixSort(m_sortKeys, s_ctx.m_tempKeys, m_sortValues, s_ctx.m_tempValues, m_num); + } + + void init(bool _createRenderThread, reallocFn _realloc, freeFn _free) + { + if (NULL != _realloc + && NULL != _free) + { + g_realloc = _realloc; + g_free = _free; + } + + s_threadIndex = BGFX_MAIN_THREAD_MAGIC; + s_ctx.init(_createRenderThread); + } + + void shutdown() + { + BGFX_MAIN_THREAD(); + s_ctx.shutdown(); + } + + void reset(uint32_t _width, uint32_t _height, uint32_t _flags) + { + BGFX_MAIN_THREAD(); + s_ctx.reset(_width, _height, _flags); + } + + void frame() + { + BGFX_MAIN_THREAD(); + s_ctx.frame(); + } + + void renderFrame() + { + if (s_ctx.m_initialized) + { + BGFX_RENDER_THREAD(); + s_ctx.renderFrame(); + } + } + + static const uint32_t s_attribTypeSize[AttribType::Count] = + { + 1, + 2, + 4, + }; + + void VertexDecl::begin() + { + m_hash = 0; + m_stride = 0; + memset(m_attributes, 0xff, sizeof(m_attributes) ); + memset(m_offset, 0, sizeof(m_offset) ); + } + + void VertexDecl::end() + { + m_hash = hash(m_attributes, sizeof(m_attributes) ); + } + + void VertexDecl::add(Attrib::Enum _attrib, uint8_t _num, AttribType::Enum _type, bool _normalized) + { + const uint8_t encoded_norm = (_normalized&1)<<6; + const uint8_t encoded_type = (_type&3)<<3; + const uint8_t encoded_num = (_num-1)&3; + + m_attributes[_attrib] = encoded_norm|encoded_type|encoded_num; + m_offset[_attrib] = m_stride; + m_stride += s_attribTypeSize[_type]*_num; + } + + void VertexDecl::decode(Attrib::Enum _attrib, uint8_t& _num, AttribType::Enum& _type, bool& _normalized) const + { + uint8_t val = m_attributes[_attrib]; + _num = (val&3)+1; + _type = AttribType::Enum((val>>3)&3); + _normalized = !!(val&(1<<6) ); + } + + const char* getAttribName(Attrib::Enum _attr) + { + static const char* attrName[Attrib::Count] = + { + "Attrib::Position", + "Attrib::Normal", + "Attrib::Color0", + "Attrib::Color1", + "Attrib::Indices", + "Attrib::Weights", + "Attrib::TexCoord0", + "Attrib::TexCoord1", + "Attrib::TexCoord2", + "Attrib::TexCoord3", + "Attrib::TexCoord4", + "Attrib::TexCoord5", + "Attrib::TexCoord6", + "Attrib::TexCoord7", + }; + + return attrName[_attr]; + } + + void dump(const VertexDecl& _decl) + { +#if BGFX_DEBUG + BX_TRACE("vertexdecl %08x (%08x), stride %d" + , _decl.m_hash + , hash(_decl.m_attributes, sizeof(_decl.m_attributes) ) + , _decl.m_stride + ); + + for (uint32_t attr = 0; attr < Attrib::Count; ++attr) + { + if (0xff != _decl.m_attributes[attr]) + { + uint8_t num; + AttribType::Enum type; + bool normalized; + _decl.decode(Attrib::Enum(attr), num, type, normalized); + + BX_TRACE("\tattr %d - %s, num %d, type %d, norm %d, offset %d" + , attr + , getAttribName(Attrib::Enum(attr) ) + , num + , type + , normalized + , _decl.m_offset[attr] + ); + } + } +#endif // BGFX_DEBUG + } + + const uint32_t g_constantTypeSize[ConstantType::Count] = + { + sizeof(int32_t), + sizeof(float), + 0, + 1*sizeof(int32_t), + 1*sizeof(float), + 2*sizeof(float), + 3*sizeof(float), + 4*sizeof(float), + 3*3*sizeof(float), + 4*4*sizeof(float), + }; + + void ConstantBuffer::writeUniform(ConstantType::Enum _type, uint16_t _loc, const void* _value, uint16_t _num) + { + uint32_t opcode = encodeOpcode(_type, _loc, _num, true); + write(opcode); + write(_value, g_constantTypeSize[_type]*_num); + } + + void ConstantBuffer::writeUniformRef(ConstantType::Enum _type, uint16_t _loc, const void* _value, uint16_t _num) + { + uint32_t opcode = encodeOpcode(_type, _loc, _num, false); + write(opcode); + write(&_value, sizeof(void*) ); + } + + void Context::init(bool _createRenderThread) + { + BX_TRACE("init"); + +#if BX_PLATFORM_WINDOWS + m_window.init(); +#endif // BX_PLATFORM_WINDOWS + +#if BGFX_CONFIG_MULTITHREADED + if (_createRenderThread) + { +# if BX_PLATFORM_WINDOWS|BX_PLATFORM_XBOX360 + CreateThread(NULL, 16<<10, renderThread, NULL, 0, NULL); +# endif // BX_PLATFORM_WINDOWS|BX_PLATFORM_XBOX360 + } +#endif // BGFX_CONFIG_MULTITHREADED + + memset(m_rt, 0xff, sizeof(m_rt) ); + memset(m_clear, 0, sizeof(m_clear) ); + memset(m_rect, 0, sizeof(m_rect) ); + memset(m_seq, 0, sizeof(m_seq) ); + memset(m_seqMask, 0, sizeof(m_seqMask) ); + + gameSemPost(); + m_initialized = true; + + getCommandBuffer(CommandBuffer::RendererInit); + + g_textVideoMemBlitter.init(); + + m_submit->m_dynamicVb = createDynamicVertexBuffer(BGFX_CONFIG_DYNAMIC_VERTEX_BUFFER_SIZE); + m_submit->m_dynamicIb = createDynamicIndexBuffer(BGFX_CONFIG_DYNAMIC_INDEX_BUFFER_SIZE); + frame(); + m_submit->m_dynamicVb = createDynamicVertexBuffer(BGFX_CONFIG_DYNAMIC_VERTEX_BUFFER_SIZE); + m_submit->m_dynamicIb = createDynamicIndexBuffer(BGFX_CONFIG_DYNAMIC_INDEX_BUFFER_SIZE); + frame(); + } + + void Context::shutdown() + { + BX_TRACE("shutdown"); + + getCommandBuffer(CommandBuffer::RendererShutdown); + frame(); + m_initialized = false; + } + + const Memory* alloc(uint32_t _size) + { + Memory* mem = (Memory*)g_realloc(NULL, sizeof(Memory) + _size); + mem->size = _size; + mem->data = (uint8_t*)mem + sizeof(Memory); + return mem; + } + + const Memory* makeRef(void* _data, uint32_t _size) + { + Memory* mem = (Memory*)g_realloc(NULL, sizeof(Memory) ); + mem->size = _size; + mem->data = (uint8_t*)_data; + return mem; + } + + void free(Memory* _mem) + { + g_free(_mem); + } + + void setDebug(uint32_t _debug) + { + s_ctx.m_debug = _debug; + } + + void dbgTextClear(uint8_t _attr, bool _small) + { + s_ctx.dbgTextClear(_attr, _small); + } + + void dbgTextPrintf(uint16_t _x, uint16_t _y, uint8_t _attr, const char* _format, ...) + { + va_list argList; + va_start(argList, _format); + s_ctx.dbgTextPrintfVargs(_x, _y, _attr, _format, argList); + va_end(argList); + } + + IndexBufferHandle createIndexBuffer(const Memory* _mem) + { + return s_ctx.createIndexBuffer(_mem); + } + + void destroyIndexBuffer(IndexBufferHandle _handle) + { + s_ctx.destroyIndexBuffer(_handle); + } + + bool checkAvailDynamicIndexBuffer(uint16_t _num) + { + return s_ctx.m_submit->checkAvailDynamicIndexBuffer(_num); + } + + const DynamicIndexBuffer* allocDynamicIndexBuffer(uint16_t _num) + { + return s_ctx.allocDynamicIndexBuffer(_num); + } + + VertexBufferHandle createVertexBuffer(const Memory* _mem, const VertexDecl& _decl) + { + return s_ctx.createVertexBuffer(_mem, _decl); + } + + void destroyVertexBuffer(VertexBufferHandle _handle) + { + s_ctx.destroyVertexBuffer(_handle); + } + + bool checkAvailDynamicVertexBuffer(uint16_t _num, const VertexDecl& _decl) + { + return s_ctx.m_submit->checkAvailDynamicVertexBuffer(_num, _decl.m_stride); + } + + const DynamicVertexBuffer* allocDynamicVertexBuffer(uint16_t _num, const VertexDecl& _decl) + { + return s_ctx.allocDynamicVertexBuffer(_num, _decl); + } + + VertexShaderHandle createVertexShader(const Memory* _mem) + { + return s_ctx.createVertexShader(_mem); + } + + void destroyVertexShader(VertexShaderHandle _handle) + { + s_ctx.destroyVertexShader(_handle); + } + + FragmentShaderHandle createFragmentShader(const Memory* _mem) + { + return s_ctx.createFragmentShader(_mem); + } + + void destroyFragmentShader(FragmentShaderHandle _handle) + { + s_ctx.destroyFragmentShader(_handle); + } + + MaterialHandle createMaterial(VertexShaderHandle _vsh, FragmentShaderHandle _fsh) + { + return s_ctx.createMaterial(_vsh, _fsh); + } + + void destroyMaterial(MaterialHandle _handle) + { + s_ctx.destroyMaterial(_handle); + } + + TextureHandle createTexture(const Memory* _mem, uint32_t _flags, uint16_t* _width, uint16_t* _height) + { + return s_ctx.createTexture(_mem, _flags, _width, _height); + } + + void destroyTexture(TextureHandle _handle) + { + s_ctx.destroyTexture(_handle); + } + + RenderTargetHandle createRenderTarget(uint16_t _width, uint16_t _height, uint32_t _flags) + { + return s_ctx.createRenderTarget(_width, _height, _flags); + } + + void destroyRenderTarget(RenderTargetHandle _handle) + { + s_ctx.destroyRenderTarget(_handle); + } + + UniformHandle createUniform(const char* _name, ConstantType::Enum _type, uint16_t _num) + { + return s_ctx.createUniform(_name, _type, _num); + } + + void destroyUniform(UniformHandle _handle) + { + s_ctx.destroyUniform(_handle); + } + + void setViewRect(uint8_t _id, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height) + { + s_ctx.setViewRect(_id, _x, _y, _width, _height); + } + + void setViewRectMask(uint32_t _viewMask, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height) + { + s_ctx.setViewRectMask(_viewMask, _x, _y, _width, _height); + } + + void setViewClear(uint8_t _id, uint8_t _flags, uint32_t _rgba, float _depth, uint8_t _stencil) + { + s_ctx.setViewClear(_id, _flags, _rgba, _depth, _stencil); + } + + void setViewClearMask(uint32_t _viewMask, uint8_t _flags, uint32_t _rgba, float _depth, uint8_t _stencil) + { + s_ctx.setViewClearMask(_viewMask, _flags, _rgba, _depth, _stencil); + } + + void setViewSeq(uint8_t _id, bool _enabled) + { + s_ctx.setViewSeq(_id, _enabled); + } + + void setViewSeqMask(uint32_t _viewMask, bool _enabled) + { + s_ctx.setViewSeqMask(_viewMask, _enabled); + } + + void setViewRenderTarget(uint8_t _id, RenderTargetHandle _handle) + { + s_ctx.setViewRenderTarget(_id, _handle); + } + + void setViewRenderTargetMask(uint32_t _mask, RenderTargetHandle _handle) + { + s_ctx.setViewRenderTargetMask(_mask, _handle); + } + + void setViewTransform(uint8_t _id, const void* _view, const void* _proj, uint8_t _other) + { + s_ctx.m_submit->setViewTransform(_id, _view, _proj, _other); + } + + void setViewTransformMask(uint32_t _viewMask, const void* _view, const void* _proj, uint8_t _other) + { + s_ctx.m_submit->setViewTransformMask(_viewMask, _view, _proj, _other); + } + + void setState(uint64_t _state) + { + s_ctx.m_submit->setState(_state); + } + + uint32_t setTransform(const void* _mtx, uint16_t _num) + { + return s_ctx.m_submit->setTransform(_mtx, _num); + } + + void setTransform(uint32_t _cache, uint16_t _num) + { + s_ctx.m_submit->setTransform(_cache, _num); + } + + void setUniform(UniformHandle _handle, const void* _value, uint16_t _num) + { + s_ctx.setUniform(_handle, _value, _num); + } + + void setUniform(MaterialHandle _material, UniformHandle _handle, const void* _value) + { + s_ctx.setUniform(_material, _handle, _value); + } + + void setIndexBuffer(IndexBufferHandle _handle, uint32_t _firstIndex, uint32_t _numIndices) + { + s_ctx.m_submit->setIndexBuffer(_handle, _firstIndex, _numIndices); + } + + void setIndexBuffer(IndexBufferHandle _handle) + { + s_ctx.m_submit->setIndexBuffer(_handle, BGFX_DRAW_WHOLE_INDEX_BUFFER, 0); + } + + void setIndexBuffer(const DynamicIndexBuffer* _ib, uint32_t _numIndices) + { + uint32_t numIndices = uint32_min(_numIndices, _ib->size/2); + s_ctx.m_submit->setIndexBuffer(_ib, numIndices); + } + + void setVertexBuffer(VertexBufferHandle _handle) + { + s_ctx.m_submit->setVertexBuffer(_handle); + } + + void setVertexBuffer(const DynamicVertexBuffer* _vb) + { + s_ctx.m_submit->setVertexBuffer(_vb); + } + + void setMaterial(MaterialHandle _handle) + { + s_ctx.m_submit->setMaterial(_handle); + } + + void setTexture(uint8_t _stage, UniformHandle _sampler, TextureHandle _handle) + { + s_ctx.m_submit->setTexture(_stage, _sampler, _handle); + } + + void setTexture(uint8_t _stage, UniformHandle _sampler, RenderTargetHandle _handle, bool _depth) + { + s_ctx.m_submit->setTexture(_stage, _sampler, _handle, _depth); + } + + void submit(uint8_t _id) + { + s_ctx.m_submit->submit(_id); + } + + void submitMask(uint32_t _viewMask) + { + s_ctx.m_submit->submitMask(_viewMask); + } + + void saveScreenShot(const char* _filePath) + { + uint32_t len = (uint32_t)strlen(_filePath)+1; + const Memory* mem = alloc(len); + memcpy(mem->data, _filePath, mem->size); + return s_ctx.saveScreenShot(mem); + } +} diff --git a/src/bgfx_p.h b/src/bgfx_p.h new file mode 100644 index 000000000..7a6182b43 --- /dev/null +++ b/src/bgfx_p.h @@ -0,0 +1,2482 @@ +/* + * Copyright 2011-2012 Branimir Karadzic. All rights reserved. + * License: http://www.opensource.org/licenses/BSD-2-Clause + */ + +#ifndef __BGFX_P_H__ +#define __BGFX_P_H__ + +#include "bgfx.h" +#include +#include // va_list +#include +#include +#include +#include + +extern void dbgPrintf(const char* _format, ...); +extern void dbgPrintfData(const void* _data, uint32_t _size, const char* _format, ...); + +#define BGFX_DEBUG 0 + +#if BGFX_DEBUG +# define BX_TRACE(_format, ...) \ + do { \ + dbgPrintf(BX_FILE_LINE_LITERAL "BGFX " _format "\n", ##__VA_ARGS__); \ + } while(0) + +# define BX_CHECK(_condition, _format, ...) \ + do { \ + if (!(_condition) ) \ + { \ + BX_TRACE(BX_FILE_LINE_LITERAL "CHECK " _format, ##__VA_ARGS__); \ + bx::debugBreak(); \ + } \ + } while(0) +#endif // 0 + +#define BX_NAMESPACE 1 +#include +#include +#include +#include +#include +#include +#include +#include + +#if BX_PLATFORM_WINDOWS +# include +extern HWND bgfxHwnd; +#elif BX_PLATFORM_XBOX360 +# include +#endif // BX_PLATFORM_WINDOWS + +#ifndef MAKEFOURCC +# define MAKEFOURCC(_a, _b, _c, _d) (0 \ + | ( (uint32_t)(_a) \ + | ( (uint32_t)(_b) << 8) \ + | ( (uint32_t)(_c) << 16) \ + | ( (uint32_t)(_d) << 24) \ + ) ) +#endif // MAKEFOURCC + +#include "dds.h" + +#define BGFX_MAGIC MAKEFOURCC('B','G','F','X') + +namespace std +{ + namespace tr1 + { + } + + using namespace tr1; +} // namespace std + +#include +#include + +#ifndef BGFX_CONFIG_RENDERER_DIRECT3D +# define BGFX_CONFIG_RENDERER_DIRECT3D (BX_PLATFORM_WINDOWS|BX_PLATFORM_XBOX360) +#endif // BGFX_CONFIG_RENDERER_DIRECT3D + +#ifndef BGFX_CONFIG_RENDERER_OPENGL +# define BGFX_CONFIG_RENDERER_OPENGL 0 +#endif // BGFX_CONFIG_RENDERER_OPENGL + +#ifndef BGFX_CONFIG_RENDERER_OPENGLES +# define BGFX_CONFIG_RENDERER_OPENGLES (BX_PLATFORM_NACL|BX_PLATFORM_ANDROID|BX_PLATFORM_LINUX) +#endif // BGFX_CONFIG_RENDERER_OPENGLES + +#ifndef BGFX_CONFIG_RENDERER_NULL +# define BGFX_CONFIG_RENDERER_NULL (!(BGFX_CONFIG_RENDERER_DIRECT3D|BGFX_CONFIG_RENDERER_OPENGL|BGFX_CONFIG_RENDERER_OPENGLES) ) +#endif // BGFX_CONFIG_RENDERER_NULL + +#ifndef BGFX_CONFIG_MULTITHREADED +# define BGFX_CONFIG_MULTITHREADED ( (BX_PLATFORM_WINDOWS|BX_PLATFORM_XBOX360|BX_PLATFORM_NACL|BX_PLATFORM_LINUX)&(!BGFX_CONFIG_RENDERER_NULL) ) +#endif // BGFX_CONFIG_MULTITHREADED + +#ifndef BGFX_CONFIG_MAX_DRAW_CALLS +# define BGFX_CONFIG_MAX_DRAW_CALLS (8<<10) +#endif // BGFX_CONFIG_MAX_DRAW_CALLS + +#ifndef BGFX_CONFIG_MAX_MATRIX_CACHE +# define BGFX_CONFIG_MAX_MATRIX_CACHE (16<<10) +#endif // BGFX_CONFIG_MAX_MATRIX_CACHE + +#ifndef BGFX_CONFIG_MAX_VIEWS +# define BGFX_CONFIG_MAX_VIEWS 32 +#endif // BGFX_CONFIG_MAX_VIEWS + +#ifndef BGFX_CONFIG_MAX_INDEX_BUFFERS +# define BGFX_CONFIG_MAX_INDEX_BUFFERS (4<<10) +#endif // BGFX_CONFIG_MAX_INDEX_BUFFERS + +#ifndef BGFX_CONFIG_MAX_VERTEX_DECLS +# define BGFX_CONFIG_MAX_VERTEX_DECLS 64 +#endif // BGFX_CONFIG_MAX_VERTEX_DECLS + +#ifndef BGFX_CONFIG_MAX_VERTEX_BUFFERS +# define BGFX_CONFIG_MAX_VERTEX_BUFFERS (4<<10) +#endif // BGFX_CONFIG_MAX_VERTEX_BUFFERS + +#ifndef BGFX_CONFIG_MAX_VERTEX_SHADERS +# define BGFX_CONFIG_MAX_VERTEX_SHADERS 256 +#endif // BGFX_CONFIG_MAX_VERTEX_SHADERS + +#ifndef BGFX_CONFIG_MAX_FRAGMENT_SHADERS +# define BGFX_CONFIG_MAX_FRAGMENT_SHADERS 256 +#endif // BGFX_CONFIG_MAX_FRAGMENT_SHADERS + +#ifndef BGFX_CONFIG_MAX_MATERIALS +# define BGFX_CONFIG_MAX_MATERIALS 512 +#endif // BGFX_CONFIG_MAX_MATERIALS + +#ifndef BGFX_CONFIG_MAX_PROGRAMS +# define BGFX_CONFIG_MAX_PROGRAMS (4<<10) +#endif // BGFX_CONFIG_MAX_PROGRAMS + +#ifndef BGFX_CONFIG_MAX_TEXTURES +# define BGFX_CONFIG_MAX_TEXTURES (4<<10) +#endif // BGFX_CONFIG_MAX_TEXTURES + +#ifndef BGFX_CONFIG_MAX_RENDER_TARGETS +# define BGFX_CONFIG_MAX_RENDER_TARGETS 64 +#endif // BGFX_CONFIG_MAX_RENDER_TARGETS + +#ifndef BGFX_CONFIG_MAX_UNIFORMS +# define BGFX_CONFIG_MAX_UNIFORMS 512 +#endif // BGFX_CONFIG_MAX_CONSTANTS + +#ifndef BGFX_CONFIG_MAX_COMMAND_BUFFER_SIZE +# define BGFX_CONFIG_MAX_COMMAND_BUFFER_SIZE (64<<10) +#endif // BGFX_CONFIG_MAX_COMMAND_BUFFER_SIZE + +#ifndef BGFX_CONFIG_DYNAMIC_VERTEX_BUFFER_SIZE +# define BGFX_CONFIG_DYNAMIC_VERTEX_BUFFER_SIZE (6<<20) +#endif // BGFX_DYNAMIC_VERTEX_BUFFER_SIZE + +#ifndef BGFX_CONFIG_DYNAMIC_INDEX_BUFFER_SIZE +# define BGFX_CONFIG_DYNAMIC_INDEX_BUFFER_SIZE (2<<20) +#endif // BGFX_CONFIG_DYNAMIC_INDEX_BUFFER_SIZE + +#ifndef BGFX_CONFIG_MAX_CONSTANT_BUFFER_SIZE +# define BGFX_CONFIG_MAX_CONSTANT_BUFFER_SIZE (512<<10) +#endif // BGFX_CONFIG_MAX_CONSTANT_BUFFER_SIZE + +#if BGFX_CONFIG_MULTITHREADED +# include +#endif // BGFX_CONFIG_MULTITHREADED + +#include +#include + +#define BGFX_DRAW_WHOLE_INDEX_BUFFER 0xffffffff + +#define BGFX_DEFAULT_WIDTH 1280 +#define BGFX_DEFAULT_HEIGHT 720 + +#define BGFX_STATE_TEX0 UINT64_C(0x0100000000000000) +#define BGFX_STATE_TEX1 UINT64_C(0x0200000000000000) +#define BGFX_STATE_TEX2 UINT64_C(0x0400000000000000) +#define BGFX_STATE_TEX3 UINT64_C(0x0800000000000000) +#define BGFX_STATE_TEX4 UINT64_C(0x1000000000000000) +#define BGFX_STATE_TEX_MASK UINT64_C(0x1f00000000000000) +#define BGFX_STATE_TEX_COUNT 5 + +#define BGFX_SAMPLER_NONE UINT16_C(0x0000) +#define BGFX_SAMPLER_RENDERTARGET_COLOR UINT16_C(0x0001) +#define BGFX_SAMPLER_RENDERTARGET_DEPTH UINT16_C(0x0002) +#define BGFX_SAMPLER_TYPE_MASK UINT16_C(0x0003) + +namespace bgfx +{ + extern const uint32_t g_constantTypeSize[ConstantType::Count]; + extern reallocFn g_realloc; + extern freeFn g_free; + extern void free(Memory* _mem); + extern void saveTga(const char* _filePath, uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _data); + extern const char* getAttribName(Attrib::Enum _attr); + + inline uint32_t uint16_min(uint16_t _a, uint16_t _b) + { + return _a > _b ? _b : _a; + } + + inline uint32_t hash(const void* _data, uint32_t _size) + { + HashMurmur2A murmur; + murmur.begin(); + murmur.add(_data, (int)_size); + return murmur.end(); + } + + inline uint32_t gcd(uint32_t _a, uint32_t _b) + { + do + { + uint32_t tmp = _a % _b; + _a = _b; + _b = tmp; + } + while (_b); + + return _a; + } + + inline uint32_t lcm(uint32_t _a, uint32_t _b) + { + return _a * (_b / gcd(_a, _b) ); + } + + inline uint32_t strideAlign(uint32_t _offset, uint32_t _stride) + { + const uint32_t mod = uint32_mod(_offset, _stride); + const uint32_t add = uint32_sub(_stride, mod); + const uint32_t mask = uint32_cmpeq(mod, 0); + const uint32_t tmp = uint32_selb(mask, 0, add); + const uint32_t result = uint32_add(_offset, tmp); + + return result; + } + + inline uint32_t strideAlign16(uint32_t _offset, uint32_t _stride) + { + uint32_t align = lcm(16, _stride); + return _offset+align-(_offset%align); + } + + inline uint32_t strideAlign256(uint32_t _offset, uint32_t _stride) + { + uint32_t align = lcm(256, _stride); + return _offset+align-(_offset%align); + } + + void dump(const VertexDecl& _decl); + + struct TextVideoMem + { + TextVideoMem() + { + resize(); + } + + ~TextVideoMem() + { + g_free(m_mem); + } + + void resize(bool _small = false, uint16_t _width = BGFX_DEFAULT_WIDTH, uint16_t _height = BGFX_DEFAULT_HEIGHT) + { + m_small = _small; + m_width = uint32_max(1, _width/8); + m_height = uint32_max(1, _height/(_small ? 8 : 16) ); + m_size = m_width * m_height * 2; + + m_mem = (uint8_t*)g_realloc(m_mem, m_size); + + clear(); + } + + void clear() + { + memset(m_mem, 0, m_size); + } + + void printfVargs(uint16_t _x, uint16_t _y, uint8_t _attr, const char* _format, va_list _argList) + { + if (_x < m_width && _y < m_height) + { + char* temp = (char*)alloca(m_width); + + uint32_t num = vsnprintf(temp, m_width, _format, _argList); + + uint8_t* mem = &m_mem[(_y*m_width+_x)*2]; + for (uint32_t ii = 0, xx = _x; ii < num && xx < m_width; ++ii, ++xx) + { + mem[0] = temp[ii]; + mem[1] = _attr; + mem += 2; + } + } + } + + void printf(uint16_t _x, uint16_t _y, uint8_t _attr, const char* _format, ...) + { + va_list argList; + va_start(argList, _format); + printfVargs(_x, _y, _attr, _format, argList); + va_end(argList); + } + + uint8_t* m_mem; + uint32_t m_size; + uint16_t m_width; + uint16_t m_height; + bool m_small; + }; + + struct TextVideoMemBlitter + { + void init(); + void blit(const TextVideoMem& _mem); + void setup(); + void render(uint32_t _numIndices); + + bgfx::TextureHandle m_texture; + DynamicVertexBuffer* m_vb; + DynamicIndexBuffer* m_ib; + bgfx::VertexDecl m_decl; + bgfx::MaterialHandle m_material; + }; + + extern TextVideoMemBlitter g_textVideoMemBlitter; + + struct PredefinedUniform + { + enum Enum + { + ViewRect, + ViewTexel, + View, + ViewProj, + ViewProjX, + Model, + ModelViewProj, + ModelViewProjX, + AlphaRef, + Count + }; + + uint8_t m_type; + uint16_t m_loc; + }; + + PredefinedUniform::Enum nameToPredefinedUniformEnum(const char* _name); + + class StreamRead + { + public: + StreamRead(const void* _data, uint32_t _size) + : m_data( (uint8_t*)_data) + , m_size(_size) + , m_pos(0) + { + } + + ~StreamRead() + { + } + + void skip(uint32_t _size) + { + BX_CHECK(m_size-m_pos >= _size, "Available %d, requested %d.", m_size-m_pos, _size); + m_pos += _size; + } + + void read(void* _data, uint32_t _size) + { + BX_CHECK(m_size-m_pos >= _size, "Available %d, requested %d.", m_size-m_pos, _size); + memcpy(_data, &m_data[m_pos], _size); + m_pos += _size; + } + + template + void read(Ty& _value) + { + read(&_value, sizeof(Ty) ); + } + + const uint8_t* getDataPtr() const + { + return &m_data[m_pos]; + } + + uint32_t getPos() const + { + return m_pos; + } + + void align(uint16_t _align) + { + m_pos = strideAlign(m_pos, _align); + } + + private: + const uint8_t* m_data; + uint32_t m_size; + uint32_t m_pos; + }; + + class StreamWrite + { + public: + StreamWrite(void* _data, uint32_t _size) + : m_data( (uint8_t*)_data) + , m_size(_size) + , m_pos(0) + { + } + + ~StreamWrite() + { + } + + void write(void* _data, uint32_t _size) + { + BX_CHECK(m_size-m_pos >= _size, "Write out of bounds. Available %d, requested %d.", m_size-m_pos, _size); + memcpy(&m_data[m_pos], _data, _size); + m_pos += _size; + } + + template + void write(Ty& _value) + { + write(&_value, sizeof(Ty) ); + } + + uint8_t* getDataPtr() const + { + return &m_data[m_pos]; + } + + uint32_t getPos() const + { + return m_pos; + } + + void align(uint16_t _align) + { + m_pos = strideAlign(m_pos, _align); + } + + private: + uint8_t* m_data; + uint32_t m_size; + uint32_t m_pos; + }; + + struct CommandBuffer + { + CommandBuffer() + : m_pos(0) + , m_size(BGFX_CONFIG_MAX_COMMAND_BUFFER_SIZE) + { + finish(); + } + + enum Enum + { + RendererInit, + CreateVertexDecl, + CreateIndexBuffer, + CreateDynamicIndexBuffer, + CreateVertexBuffer, + CreateDynamicVertexBuffer, + CreateVertexShader, + CreateFragmentShader, + CreateMaterial, + CreateTexture, + CreateRenderTarget, + CreateUniform, + End, + RendererShutdown, + DestroyVertexDecl, + DestroyIndexBuffer, + DestroyDynamicIndexBuffer, + DestroyVertexBuffer, + DestroyDynamicVertexBuffer, + DestroyVertexShader, + DestroyFragmentShader, + DestroyMaterial, + DestroyTexture, + DestroyRenderTarget, + DestroyUniform, + SaveScreenShot, + }; + + void write(const void* _data, uint32_t _size) + { + BX_CHECK(m_pos < m_size, ""); + memcpy(&m_buffer[m_pos], _data, _size); + m_pos += _size; + } + + template + void write(const Type& _in) + { + write(reinterpret_cast(&_in), sizeof(Type) ); + } + + void read(void* _data, uint32_t _size) + { + BX_CHECK(m_pos < m_size, ""); + memcpy(_data, &m_buffer[m_pos], _size); + m_pos += _size; + } + + template + void read(Type& _in) + { + read(reinterpret_cast(&_in), sizeof(Type) ); + } + + void reset() + { + m_pos = 0; + } + + void finish() + { + uint8_t cmd = End; + write(cmd); + m_pos = 0; + } + + uint32_t m_pos; + uint32_t m_size; + uint8_t m_buffer[BGFX_CONFIG_MAX_COMMAND_BUFFER_SIZE]; + + private: + CommandBuffer(const CommandBuffer&); + void operator=(const CommandBuffer&); + }; + + struct SortKey + { + uint64_t encode() + { + // | 3 2 1 0| + // |fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210| + // | vvvvvsssssssssssttmmmmmmmmmdddddddddddddddddddddddd| + // | ^ ^ ^ ^ ^| + // | | | | | || + + uint64_t tmp0 = m_depth; + uint64_t tmp1 = uint64_t(m_material)<<0x18; + uint64_t tmp2 = uint64_t(m_trans)<<0x21; + uint64_t tmp3 = uint64_t(m_seq)<<0x23; + uint64_t tmp4 = uint64_t(m_view)<<0x2e; + uint64_t key = tmp0|tmp1|tmp2|tmp3|tmp4; + return key; + } + + void decode(uint64_t _key) + { + m_depth = _key&0xffffffff; + m_material = (_key>>0x18)&(BGFX_CONFIG_MAX_MATERIALS-1); + m_trans = (_key>>0x21)&0x3; + m_seq = (_key>>0x23)&0x7ff; + m_view = (_key>>0x2e)&(BGFX_CONFIG_MAX_VIEWS-1); + } + + void reset() + { + m_depth = 0; + m_material = 0; + m_seq = 0; + m_view = 0; + m_trans = 0; + } + + int32_t m_depth; + uint16_t m_material; + uint16_t m_seq; + uint8_t m_view; + uint8_t m_trans; + }; + + struct Clear + { + uint32_t m_rgba; + float m_depth; + uint8_t m_stencil; + uint8_t m_flags; + }; + + struct Rect + { + uint16_t m_x; + uint16_t m_y; + uint16_t m_width; + uint16_t m_height; + }; + + BX_ALIGN_STRUCT_16(struct) Matrix4 + { + float val[16]; + + void setIdentity() + { + memset(val, 0, sizeof(val) ); + val[0] = val[5] = val[10] = val[15] = 1.0f; + } + }; + + void matrix_mul(float* __restrict _result, const float* __restrict _a, const float* __restrict _b); + void matrix_ortho(float* _result, float _left, float _right, float _bottom, float _top, float _near, float _far); + + struct MatrixCache + { + MatrixCache() + : m_num(1) + { + m_cache[0].setIdentity(); + } + + void reset() + { + m_num = 1; + } + + uint32_t add(const void* _mtx, uint16_t _num) + { + if (NULL != _mtx) + { + BX_CHECK(m_num+_num < BGFX_CONFIG_MAX_MATRIX_CACHE, "Matrix cache overflow. %d (max: %d)", m_num+_num, BGFX_CONFIG_MAX_MATRIX_CACHE); + + uint32_t num = uint32_min(BGFX_CONFIG_MAX_MATRIX_CACHE-m_num, _num); + uint32_t first = m_num; + memcpy(&m_cache[m_num], _mtx, sizeof(Matrix4)*num); + m_num += num; + return first; + } + + return 0; + } + + Matrix4 m_cache[BGFX_CONFIG_MAX_MATRIX_CACHE]; + uint32_t m_num; + }; + + struct Sampler + { + uint16_t m_idx; + uint16_t m_flags; + }; + + struct Constant + { + ConstantType::Enum m_type; + uint16_t m_num; + }; + +#define CONSTANT_OPCODE_MASK(_bits) ( (1<<_bits)-1) + +#define CONSTANT_OPCODE_TYPE_BITS 8 +#define CONSTANT_OPCODE_TYPE_MASK CONSTANT_OPCODE_MASK(CONSTANT_OPCODE_TYPE_BITS) +#define CONSTANT_OPCODE_LOC_BITS 10 +#define CONSTANT_OPCODE_LOC_MASK CONSTANT_OPCODE_MASK(CONSTANT_OPCODE_LOC_BITS) +#define CONSTANT_OPCODE_NUM_BITS 10 +#define CONSTANT_OPCODE_NUM_MASK CONSTANT_OPCODE_MASK(CONSTANT_OPCODE_NUM_BITS) +#define CONSTANT_OPCODE_COPY_BITS 1 +#define CONSTANT_OPCODE_COPY_MASK CONSTANT_OPCODE_MASK(CONSTANT_OPCODE_COPY_BITS) + +#define BGFX_UNIFORM_FUNCTIONBIT UINT8_C(0x40) +#define BGFX_UNIFORM_FRAGMENTBIT UINT8_C(0x80) +#define BGFX_UNIFORM_TYPEMASK UINT8_C(0x3f) + + class ConstantBuffer + { + public: + static ConstantBuffer* create(uint32_t _size) + { + uint32_t size = BX_ALIGN_16(uint32_max(_size, sizeof(ConstantBuffer) ) ); + void* data = g_realloc(NULL, size); + return ::new(data) ConstantBuffer(_size); + } + + static void destroy(ConstantBuffer* _constantBuffer) + { + _constantBuffer->~ConstantBuffer(); + g_free(_constantBuffer); + } + + static uint32_t encodeOpcode(ConstantType::Enum _type, uint16_t _loc, uint16_t _num, uint16_t _copy) + { + uint32_t opcode = 0; + + opcode <<= CONSTANT_OPCODE_TYPE_BITS; + opcode |= _type&CONSTANT_OPCODE_TYPE_MASK; + + opcode <<= CONSTANT_OPCODE_LOC_BITS; + opcode |= _loc&CONSTANT_OPCODE_LOC_MASK; + + opcode <<= CONSTANT_OPCODE_NUM_BITS; + opcode |= _num&CONSTANT_OPCODE_NUM_MASK; + + opcode <<= CONSTANT_OPCODE_COPY_BITS; + opcode |= _copy&CONSTANT_OPCODE_COPY_MASK; + + return opcode; + } + + static void decodeOpcode(uint32_t _opcode, ConstantType::Enum& _type, uint16_t& _loc, uint16_t& _num, uint16_t& _copy) + { + uint32_t copy; + uint32_t num; + uint32_t loc; + + copy = _opcode&CONSTANT_OPCODE_COPY_MASK; + _opcode >>= CONSTANT_OPCODE_COPY_BITS; + + num = _opcode&CONSTANT_OPCODE_NUM_MASK; + _opcode >>= CONSTANT_OPCODE_NUM_BITS; + + loc = _opcode&CONSTANT_OPCODE_LOC_MASK; + _opcode >>= CONSTANT_OPCODE_LOC_BITS; + + _type = (ConstantType::Enum)(_opcode&CONSTANT_OPCODE_TYPE_MASK); + _opcode >>= CONSTANT_OPCODE_TYPE_BITS; + + _copy = (uint16_t)copy; + _num = (uint16_t)num; + _loc = (uint16_t)loc; + } + + void write(const void* _data, uint32_t _size) + { + BX_CHECK(m_pos + _size < m_size, "Write would go out of bounds. pos %d + size %d > max size: %d).", m_pos, _size, m_size); + + if (m_pos + _size < m_size) + { + memcpy(&m_buffer[m_pos], _data, _size); + m_pos += _size; + } + } + + void write(uint32_t _value) + { + write(&_value, sizeof(uint32_t) ); + } + + const char* read(uint32_t _size) + { + BX_CHECK(m_pos < m_size, "Out of bounds %d (size: %d).", m_pos, m_size); + const char* result = &m_buffer[m_pos]; + m_pos += _size; + return result; + } + + uint32_t read() + { + const char* result = read(sizeof(uint32_t) ); + return *( (uint32_t*)result); + } + + bool isEmpty() const + { + return 0 == m_pos; + } + + uint32_t getPos() const + { + return m_pos; + } + + void reset(uint32_t _pos = 0) + { + m_pos = _pos; + } + + void finish() + { + write(ConstantType::End); + m_pos = 0; + } + + void writeUniform(ConstantType::Enum _type, uint16_t _loc, const void* _value, uint16_t _num = 1); + void writeUniformRef(ConstantType::Enum _type, uint16_t _loc, const void* _value, uint16_t _num = 1); + void commit(bool _force); + + private: + ConstantBuffer(uint32_t _size) + : m_size(_size-sizeof(m_buffer) ) + , m_pos(0) + { + BX_TRACE("ConstantBuffer %d, %d", _size, m_size); + finish(); + } + + ~ConstantBuffer() + { + } + + uint32_t m_size; + uint32_t m_pos; + char m_buffer[8]; + }; + + typedef const void* (*UniformFn)(const void* _data); + + struct UniformInfo + { + const void* m_data; + UniformFn m_func; + }; + + class UniformRegistry + { + public: + UniformRegistry() + { + } + + ~UniformRegistry() + { + } + + const UniformInfo* find(const char* _name) const + { + UniformHashMap::const_iterator it = m_uniforms.find(_name); + if (it != m_uniforms.end() ) + { + return &it->second; + } + + return NULL; + } + + const UniformInfo& reg(const char* _name, const void* _data, UniformFn _func = NULL) + { + UniformHashMap::const_iterator it = m_uniforms.find(_name); + if (it == m_uniforms.end() ) + { + UniformInfo info; + info.m_data = _data; + info.m_func = _func; + + std::pair result = m_uniforms.insert(UniformHashMap::value_type(_name, info) ); + return result.first->second; + } + + return it->second; + } + + private: + typedef std::unordered_map UniformHashMap; + UniformHashMap m_uniforms; + }; + + struct RenderState + { + void reset() + { + m_constEnd = 0; + clear(); + } + + void clear() + { + m_constBegin = m_constEnd; + m_flags = BGFX_STATE_DEFAULT; + m_matrix = 0; + m_startIndex = BGFX_DRAW_WHOLE_INDEX_BUFFER; + m_numIndices = 0; + m_startVertex = 0; + m_numVertices = UINT32_C(0xffffffff); + m_num = 1; + m_vertexBuffer.idx = bgfx::invalidHandle; + m_vertexDecl.idx = bgfx::invalidHandle; + m_indexBuffer.idx = bgfx::invalidHandle; + + for (uint32_t ii = 0; ii < BGFX_STATE_TEX_COUNT; ++ii) + { + m_sampler[ii].m_idx = bgfx::invalidHandle; + m_sampler[ii].m_flags = BGFX_SAMPLER_NONE; + } + } + + uint64_t m_flags; + uint32_t m_constBegin; + uint32_t m_constEnd; + uint32_t m_matrix; + uint32_t m_startIndex; + uint32_t m_numIndices; + uint32_t m_startVertex; + uint32_t m_numVertices; + uint16_t m_num; + + VertexBufferHandle m_vertexBuffer; + VertexDeclHandle m_vertexDecl; + IndexBufferHandle m_indexBuffer; + Sampler m_sampler[BGFX_STATE_TEX_COUNT]; + }; + + struct Resolution + { + Resolution() + : m_width(BGFX_DEFAULT_WIDTH) + , m_height(BGFX_DEFAULT_HEIGHT) + , m_flags(BGFX_RESET_NONE) + { + } + + uint32_t m_width; + uint32_t m_height; + uint32_t m_flags; + }; + + struct Frame + { + BX_CACHE_LINE_ALIGN_MARKER(); + + Frame() + { + m_constantBuffer = ConstantBuffer::create(BGFX_CONFIG_MAX_CONSTANT_BUFFER_SIZE); + reset(); + } + + ~Frame() + { + ConstantBuffer::destroy(m_constantBuffer); + } + + void reset() + { + m_state.reset(); + m_matrixCache.reset(); + m_key.reset(); + m_num = 0; + m_numRenderStates = 0; + m_numDropped = 0; + m_iboffset = 0; + m_vboffset = 0; + m_cmdPre.reset(); + m_cmdPost.reset(); + m_constantBuffer->reset(); + m_discard = false; + resetFreeHandles(); + } + + void finish() + { + m_cmdPre.finish(); + m_cmdPost.finish(); + m_constantBuffer->finish(); + + if (0 < m_numDropped) + { + BX_TRACE("Too many draw calls: %d, dropped %d (max: %d)", m_num+m_numDropped, m_numDropped, BGFX_CONFIG_MAX_DRAW_CALLS); + } + } + + void setViewTransform(uint8_t _id, const void* _view, const void* _proj, uint8_t _other) + { + if (BGFX_CONFIG_MAX_VIEWS > _other) + { + m_other[_id] = _other; + } + else + { + m_other[_id] = _id; + } + + if (NULL != _view) + { + memcpy(m_view[_id].val, _view, sizeof(Matrix4) ); + } + else + { + m_view[_id].setIdentity(); + } + + if (NULL != _proj) + { + memcpy(m_proj[_id].val, _proj, sizeof(Matrix4) ); + } + else + { + m_view[_id].setIdentity(); + } + } + + void setViewTransformMask(uint32_t _viewMask, const void* _view, const void* _proj, uint8_t _other) + { + for (uint32_t id = 0, viewMask = _viewMask, ntz = uint32_cnttz(_viewMask); 0 != viewMask; viewMask >>= 1, id += 1, ntz = uint32_cnttz(viewMask) ) + { + viewMask >>= ntz; + id += ntz; + + setViewTransform(id, _view, _proj, _other); + } + } + + void setState(uint64_t _state) + { + uint8_t blend = ( (_state&BGFX_STATE_BLEND_MASK)>>BGFX_STATE_BLEND_SHIFT)&0xff; + m_key.m_trans = "\x0\x1\x1\x2\x2\x1\x2\x1\x2\x1\x1\x1\x1\x1\x1\x1\x1"[( (blend)&0xf) + (!!blend)]; + m_state.m_flags = _state; + } + + uint32_t setTransform(const void* _mtx, uint16_t _num) + { + m_state.m_matrix = m_matrixCache.add(_mtx, _num); + m_state.m_num = _num; + + return m_state.m_matrix; + } + + void setTransform(uint32_t _cache, uint16_t _num) + { + m_state.m_matrix = _cache; + m_state.m_num = _num; + } + + void setIndexBuffer(IndexBufferHandle _handle, uint32_t _firstIndex, uint32_t _numIndices) + { + m_state.m_startIndex = _firstIndex; + m_state.m_numIndices = _numIndices; + m_state.m_indexBuffer = _handle; + } + + void setIndexBuffer(const DynamicIndexBuffer* _ib, uint32_t _numIndices) + { + m_state.m_indexBuffer = _ib->handle; + m_state.m_startIndex = _ib->startIndex; + m_state.m_numIndices = _numIndices; + m_discard = 0 == _numIndices; + g_free(const_cast(_ib) ); + } + + void setVertexBuffer(VertexBufferHandle _handle) + { + BX_CHECK(_handle.idx < BGFX_CONFIG_MAX_VERTEX_BUFFERS, "Invalid vertex buffer handle. %d (< %d)", _handle.idx, BGFX_CONFIG_MAX_VERTEX_BUFFERS); + m_state.m_startVertex = 0; + m_state.m_numVertices = UINT32_C(0xffffffff); + m_state.m_vertexBuffer = _handle; + } + + void setVertexBuffer(const DynamicVertexBuffer* _vb) + { + m_state.m_startVertex = _vb->startVertex; + m_state.m_numVertices = _vb->size/_vb->stride; + m_state.m_vertexBuffer = _vb->handle; + m_state.m_vertexDecl = _vb->decl; + g_free(const_cast(_vb) ); + } + + void setMaterial(MaterialHandle _handle) + { + BX_CHECK(invalidHandle != _handle.idx, "Can't set material with invalid handle."); + m_key.m_material = _handle.idx; + } + + void setTexture(uint8_t _stage, UniformHandle _sampler, TextureHandle _handle) + { + m_flags |= BGFX_STATE_TEX0<<_stage; + Sampler& sampler = m_state.m_sampler[_stage]; + sampler.m_idx = _handle.idx; + sampler.m_flags = BGFX_SAMPLER_NONE; + + if (bgfx::invalidHandle != _sampler.idx) + { + uint32_t stage = _stage; + setUniform(_sampler, &stage); + } + } + + void setTexture(uint8_t _stage, UniformHandle _sampler, RenderTargetHandle _handle, bool _depth) + { + m_flags |= BGFX_STATE_TEX0<<_stage; + Sampler& sampler = m_state.m_sampler[_stage]; + sampler.m_idx = _handle.idx; + sampler.m_flags = _depth ? BGFX_SAMPLER_RENDERTARGET_DEPTH : BGFX_SAMPLER_RENDERTARGET_COLOR; + + if (bgfx::invalidHandle != _sampler.idx) + { + uint32_t stage = _stage; + setUniform(_sampler, &stage); + } + } + + void submit(uint8_t _id); + void submitMask(uint32_t _viewMask); + void sort(); + + bool checkAvailDynamicIndexBuffer(uint16_t _num) + { + uint32_t offset = m_iboffset; + uint32_t iboffset = offset + _num*sizeof(uint16_t); + iboffset = uint32_min(iboffset, BGFX_CONFIG_DYNAMIC_INDEX_BUFFER_SIZE); + uint32_t num = (iboffset-offset)/sizeof(uint16_t); + return num == _num; + } + + uint32_t allocDynamicIndexBuffer(uint16_t& _num) + { + uint32_t offset = m_iboffset; + m_iboffset = offset + _num*sizeof(uint16_t); + m_iboffset = uint32_min(m_iboffset, BGFX_CONFIG_DYNAMIC_INDEX_BUFFER_SIZE); + _num = uint16_t( (m_iboffset-offset)/sizeof(uint16_t) ); + return offset; + } + + bool checkAvailDynamicVertexBuffer(uint16_t _num, uint16_t _stride) + { + uint32_t offset = strideAlign(m_vboffset, _stride); + uint32_t vboffset = offset + _num * _stride; + vboffset = uint32_min(vboffset, BGFX_CONFIG_DYNAMIC_VERTEX_BUFFER_SIZE); + uint32_t num = (vboffset-offset)/_stride; + return num == _num; + } + + uint32_t allocDynamicVertexBuffer(uint16_t& _num, uint16_t _stride) + { + uint32_t offset = strideAlign(m_vboffset, _stride); + m_vboffset = offset + _num * _stride; + m_vboffset = uint32_min(m_vboffset, BGFX_CONFIG_DYNAMIC_VERTEX_BUFFER_SIZE); + _num = uint16_t( (m_vboffset-offset)/_stride); + return offset; + } + + void writeConstant(ConstantType::Enum _type, UniformHandle _handle, const void* _value, uint16_t _num) + { + m_constantBuffer->writeUniform(_type, _handle.idx, _value, _num); + } + + void free(IndexBufferHandle _handle) + { + m_freeIndexBufferHandle[m_numFreeIndexBufferHandles] = _handle; + ++m_numFreeIndexBufferHandles; + } + + void free(VertexDeclHandle _handle) + { + m_freeVertexDeclHandle[m_numFreeVertexDeclHandles] = _handle; + ++m_numFreeVertexDeclHandles; + } + + void free(VertexBufferHandle _handle) + { + m_freeVertexBufferHandle[m_numFreeVertexBufferHandles] = _handle; + ++m_numFreeVertexBufferHandles; + } + + void free(VertexShaderHandle _handle) + { + m_freeVertexShaderHandle[m_numFreeVertexShaderHandles] = _handle; + ++m_numFreeVertexShaderHandles; + } + + void free(FragmentShaderHandle _handle) + { + m_freeFragmentShaderHandle[m_numFreeFragmentShaderHandles] = _handle; + ++m_numFreeFragmentShaderHandles; + } + + void free(MaterialHandle _handle) + { + m_freeMaterialHandle[m_numFreeMaterialHandles] = _handle; + ++m_numFreeMaterialHandles; + } + + void free(TextureHandle _handle) + { + m_freeTextureHandle[m_numFreeTextureHandles] = _handle; + ++m_numFreeTextureHandles; + } + + void free(RenderTargetHandle _handle) + { + m_freeRenderTargetHandle[m_numFreeRenderTargetHandles] = _handle; + ++m_numFreeRenderTargetHandles; + } + + void free(UniformHandle _handle) + { + m_freeUniformHandle[m_numFreeUniformHandles] = _handle; + ++m_numFreeUniformHandles; + } + + void resetFreeHandles() + { + m_numFreeIndexBufferHandles = 0; + m_numFreeVertexDeclHandles = 0; + m_numFreeVertexBufferHandles = 0; + m_numFreeVertexShaderHandles = 0; + m_numFreeFragmentShaderHandles = 0; + m_numFreeFragmentShaderHandles = 0; + m_numFreeMaterialHandles = 0; + m_numFreeTextureHandles = 0; + m_numFreeRenderTargetHandles = 0; + m_numFreeUniformHandles = 0; + } + + SortKey m_key; + + RenderTargetHandle m_rt[BGFX_CONFIG_MAX_VIEWS]; + Clear m_clear[BGFX_CONFIG_MAX_VIEWS]; + Rect m_rect[BGFX_CONFIG_MAX_VIEWS]; + Matrix4 m_view[BGFX_CONFIG_MAX_VIEWS]; + Matrix4 m_proj[BGFX_CONFIG_MAX_VIEWS]; + uint8_t m_other[BGFX_CONFIG_MAX_VIEWS]; + + uint64_t m_sortKeys[BGFX_CONFIG_MAX_DRAW_CALLS]; + uint16_t m_sortValues[BGFX_CONFIG_MAX_DRAW_CALLS]; + RenderState m_renderState[BGFX_CONFIG_MAX_DRAW_CALLS]; + RenderState m_state; + uint64_t m_flags; + + ConstantBuffer* m_constantBuffer; + + uint16_t m_num; + uint16_t m_numRenderStates; + uint16_t m_numDropped; + + MatrixCache m_matrixCache; + + uint32_t m_iboffset; + uint32_t m_vboffset; + DynamicIndexBuffer* m_dynamicIb; + DynamicVertexBuffer* m_dynamicVb; + + Resolution m_resolution; + uint32_t m_debug; + + CommandBuffer m_cmdPre; + CommandBuffer m_cmdPost; + + uint16_t m_numFreeIndexBufferHandles; + uint16_t m_numFreeVertexDeclHandles; + uint16_t m_numFreeVertexBufferHandles; + uint16_t m_numFreeVertexShaderHandles; + uint16_t m_numFreeFragmentShaderHandles; + uint16_t m_numFreeMaterialHandles; + uint16_t m_numFreeTextureHandles; + uint16_t m_numFreeRenderTargetHandles; + uint16_t m_numFreeUniformHandles; + + IndexBufferHandle m_freeIndexBufferHandle[BGFX_CONFIG_MAX_INDEX_BUFFERS]; + VertexDeclHandle m_freeVertexDeclHandle[BGFX_CONFIG_MAX_VERTEX_DECLS]; + VertexBufferHandle m_freeVertexBufferHandle[BGFX_CONFIG_MAX_VERTEX_BUFFERS]; + VertexShaderHandle m_freeVertexShaderHandle[BGFX_CONFIG_MAX_VERTEX_SHADERS]; + FragmentShaderHandle m_freeFragmentShaderHandle[BGFX_CONFIG_MAX_FRAGMENT_SHADERS]; + MaterialHandle m_freeMaterialHandle[BGFX_CONFIG_MAX_MATERIALS]; + TextureHandle m_freeTextureHandle[BGFX_CONFIG_MAX_TEXTURES]; + RenderTargetHandle m_freeRenderTargetHandle[BGFX_CONFIG_MAX_RENDER_TARGETS]; + UniformHandle m_freeUniformHandle[BGFX_CONFIG_MAX_UNIFORMS]; + + int64_t m_waitSubmit; + int64_t m_waitRender; + + bool m_discard; + }; + + struct MaterialRef + { + MaterialRef() + { + } + + MaterialHandle find(uint32_t _hash) + { + MaterialMap::const_iterator it = m_materialMap.find(_hash); + if (it != m_materialMap.end() ) + { + return it->second; + } + + MaterialHandle result = BGFX_INVALID_HANDLE; + return result; + } + + void add(MaterialHandle _handle, uint32_t _hash) + { + m_materialMap.insert(std::make_pair(_hash, _handle) ); + } + + typedef std::unordered_map MaterialMap; + MaterialMap m_materialMap; + }; + + struct VertexDeclRef + { + VertexDeclRef() + { + memset(m_vertexDeclRef, 0, sizeof(m_vertexDeclRef) ); + memset(m_vertexBufferRef, 0xff, sizeof(m_vertexBufferRef) ); + } + + VertexDeclHandle find(uint32_t _hash) + { + VertexDeclMap::const_iterator it = m_vertexDeclMap.find(_hash); + if (it != m_vertexDeclMap.end() ) + { + return it->second; + } + + VertexDeclHandle result = BGFX_INVALID_HANDLE; + return result; + } + + void add(VertexBufferHandle _handle, VertexDeclHandle _declHandle, uint32_t _hash) + { + m_vertexBufferRef[_handle.idx] = _declHandle; + m_vertexDeclRef[_declHandle.idx]++; + m_vertexDeclMap.insert(std::make_pair(_hash, _declHandle) ); + } + + VertexDeclHandle release(VertexBufferHandle _handle) + { + VertexDeclHandle declHandle = m_vertexBufferRef[_handle.idx]; + m_vertexDeclRef[declHandle.idx]--; + + if (0 != m_vertexDeclRef[declHandle.idx]) + { + VertexDeclHandle invalid = BGFX_INVALID_HANDLE; + return invalid; + } + + return declHandle; + } + + typedef std::unordered_map VertexDeclMap; + VertexDeclMap m_vertexDeclMap; + uint16_t m_vertexDeclRef[BGFX_CONFIG_MAX_VERTEX_DECLS]; + VertexDeclHandle m_vertexBufferRef[BGFX_CONFIG_MAX_VERTEX_BUFFERS]; + }; + +#if BX_PLATFORM_WINDOWS || BX_PLATFORM_XBOX360 + DWORD WINAPI renderThread(LPVOID _arg); +#endif // BX_PLATFORM_ + + struct Context + { + Context() + : m_render(&m_frame[0]) + , m_submit(&m_frame[1]) + , m_indexBufferHandle(BGFX_CONFIG_MAX_INDEX_BUFFERS) + , m_vertexDeclHandle(BGFX_CONFIG_MAX_VERTEX_DECLS) + , m_vertexBufferHandle(BGFX_CONFIG_MAX_VERTEX_BUFFERS) + , m_vertexShaderHandle(BGFX_CONFIG_MAX_VERTEX_SHADERS) + , m_fragmentShaderHandle(BGFX_CONFIG_MAX_FRAGMENT_SHADERS) + , m_materialHandle(BGFX_CONFIG_MAX_MATERIALS) + , m_textureHandle(BGFX_CONFIG_MAX_TEXTURES) + , m_renderTargetHandle(BGFX_CONFIG_MAX_RENDER_TARGETS) + , m_uniformHandle(BGFX_CONFIG_MAX_UNIFORMS) + , m_frames(0) + , m_debug(BGFX_DEBUG_NONE) + , m_initialized(false) + , m_rendererInitialized(false) + { + } + + ~Context() + { + } + + // game thread + void init(bool _createRenderThread); + void shutdown(); + + void frame() + { + // wait for render thread to finish + renderSemWait(); + + swap(); + + // release render thread + gameSemPost(); + +#if !BGFX_CONFIG_MULTITHREADED + renderFrame(); +#endif // BGFX_CONFIG_MULTITHREADED + } + + CommandBuffer& getCommandBuffer(CommandBuffer::Enum _cmd) + { + CommandBuffer& cmdbuf = _cmd < CommandBuffer::End ? m_submit->m_cmdPre : m_submit->m_cmdPost; + uint8_t cmd = (uint8_t)_cmd; + cmdbuf.write(cmd); + return cmdbuf; + } + + void reset(uint32_t _width, uint32_t _height, uint32_t _flags) + { + m_resolution.m_width = _width; + m_resolution.m_height = _height; + m_resolution.m_flags = _flags&(~BGFX_RESET_FULLSCREEN_FAKE); + + memset(m_rt, 0xff, sizeof(m_rt) ); + +#if BX_PLATFORM_WINDOWS + uint32_t fullscreen = (_flags&BGFX_RESET_FULLSCREEN_MASK)>>BGFX_RESET_FULLSCREEN_SHIFT; + m_window.adjust(_width, _height, BGFX_RESET_FULLSCREEN_FAKE != fullscreen); +#endif // BX_PLATFORM_WINDOWS + } + + void dbgTextClear(uint8_t _attr, bool _small) + { + } + + void dbgTextPrintfVargs(uint16_t _x, uint16_t _y, uint8_t _attr, const char* _format, va_list _argList) + { + } + + IndexBufferHandle createIndexBuffer(const Memory* _mem) + { + IndexBufferHandle handle = { m_indexBufferHandle.alloc() }; + CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::CreateIndexBuffer); + cmdbuf.write(handle); + cmdbuf.write(_mem); + return handle; + } + + void destroyIndexBuffer(IndexBufferHandle _handle) + { + CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::DestroyIndexBuffer); + cmdbuf.write(_handle); + m_submit->free(_handle); + } + + DynamicIndexBuffer* createDynamicIndexBuffer(uint32_t _size) + { + IndexBufferHandle handle = { m_indexBufferHandle.alloc() }; + CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::CreateDynamicIndexBuffer); + cmdbuf.write(handle); + cmdbuf.write(_size); + + DynamicIndexBuffer* ib = (DynamicIndexBuffer*)g_realloc(NULL, sizeof(DynamicIndexBuffer)+_size); + ib->data = (uint8_t*)&ib[1]; + ib->size = _size; + ib->handle = handle; + + return ib; + } + + void destroyDynamicIndexBuffer(DynamicIndexBuffer* _ib) + { + CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::DestroyDynamicIndexBuffer); + cmdbuf.write(_ib->handle); + + m_submit->free(_ib->handle); + g_free(const_cast(_ib) ); + } + + const DynamicIndexBuffer* allocDynamicIndexBuffer(uint16_t _num) + { + uint32_t offset = m_submit->allocDynamicIndexBuffer(_num); + + DynamicIndexBuffer& dib = *m_submit->m_dynamicIb; + + DynamicIndexBuffer* ib = (DynamicIndexBuffer*)g_realloc(NULL, sizeof(DynamicIndexBuffer) ); + ib->data = &dib.data[offset]; + ib->size = _num * sizeof(uint16_t); + ib->handle = dib.handle; + ib->startIndex = offset/sizeof(uint16_t); + + return ib; + } + + VertexDeclHandle findVertexDecl(const VertexDecl& _decl) + { + VertexDeclHandle declHandle = m_declRef.find(_decl.m_hash); + + if (bgfx::invalidHandle == declHandle.idx) + { + VertexDeclHandle temp = { m_vertexDeclHandle.alloc() }; + declHandle = temp; + CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::CreateVertexDecl); + cmdbuf.write(declHandle); + cmdbuf.write(_decl); + } + + return declHandle; + } + + VertexBufferHandle createVertexBuffer(const Memory* _mem, const VertexDecl& _decl) + { + VertexBufferHandle handle = { m_vertexBufferHandle.alloc() }; + + VertexDeclHandle declHandle = findVertexDecl(_decl); + m_declRef.add(handle, declHandle, _decl.m_hash); + + CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::CreateVertexBuffer); + cmdbuf.write(handle); + cmdbuf.write(_mem); + cmdbuf.write(declHandle); + return handle; + } + + void destroyVertexBuffer(VertexBufferHandle _handle) + { + VertexDeclHandle declHandle = m_declRef.release(_handle); + if (bgfx::invalidHandle != declHandle.idx) + { + CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::DestroyVertexDecl); + cmdbuf.write(declHandle); + } + + CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::DestroyVertexBuffer); + cmdbuf.write(_handle); + m_submit->free(_handle); + } + + DynamicVertexBuffer* createDynamicVertexBuffer(uint32_t _size, const VertexDecl* _decl = NULL) + { + VertexBufferHandle handle = { m_vertexBufferHandle.alloc() }; + + uint16_t stride = 0; + VertexDeclHandle declHandle = BGFX_INVALID_HANDLE; + + if (NULL != _decl) + { + declHandle = findVertexDecl(*_decl); + m_declRef.add(handle, declHandle, _decl->m_hash); + + stride = _decl->m_stride; + } + + CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::CreateDynamicVertexBuffer); + cmdbuf.write(handle); + cmdbuf.write(_size); + + DynamicVertexBuffer* vb = (DynamicVertexBuffer*)g_realloc(NULL, sizeof(DynamicVertexBuffer)+_size); + vb->data = (uint8_t*)&vb[1]; + vb->size = _size; + vb->startVertex = 0; + vb->stride = stride; + vb->handle = handle; + vb->decl = declHandle; + + return vb; + } + + void destroyDynamicVertexBuffer(DynamicVertexBuffer* _vb) + { + CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::DestroyDynamicVertexBuffer); + cmdbuf.write(_vb->handle); + + m_submit->free(_vb->handle); + g_free(const_cast(_vb) ); + } + + const DynamicVertexBuffer* allocDynamicVertexBuffer(uint16_t _num, const VertexDecl& _decl) + { + VertexDeclHandle declHandle = m_declRef.find(_decl.m_hash); + + DynamicVertexBuffer& dvb = *m_submit->m_dynamicVb; + + if (bgfx::invalidHandle == declHandle.idx) + { + VertexDeclHandle temp = { m_vertexDeclHandle.alloc() }; + declHandle = temp; + CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::CreateVertexDecl); + cmdbuf.write(declHandle); + cmdbuf.write(_decl); + m_declRef.add(dvb.handle, declHandle, _decl.m_hash); + } + + uint32_t offset = m_submit->allocDynamicVertexBuffer(_num, _decl.m_stride); + + DynamicVertexBuffer* vb = (DynamicVertexBuffer*)g_realloc(NULL, sizeof(DynamicVertexBuffer) ); + vb->data = &dvb.data[offset]; + vb->size = _num * _decl.m_stride; + vb->startVertex = offset/_decl.m_stride; + vb->stride = _decl.m_stride; + vb->handle = dvb.handle; + vb->decl = declHandle; + + return vb; + } + + VertexShaderHandle createVertexShader(const Memory* _mem) + { + VertexShaderHandle handle = { m_vertexShaderHandle.alloc() }; + CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::CreateVertexShader); + cmdbuf.write(handle); + cmdbuf.write(_mem); + return handle; + } + + void destroyVertexShader(VertexShaderHandle _handle) + { + CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::DestroyVertexShader); + cmdbuf.write(_handle); + m_submit->free(_handle); + } + + FragmentShaderHandle createFragmentShader(const Memory* _mem) + { + FragmentShaderHandle handle = { m_fragmentShaderHandle.alloc() }; + CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::CreateFragmentShader); + cmdbuf.write(handle); + cmdbuf.write(_mem); + return handle; + } + + void destroyFragmentShader(FragmentShaderHandle _handle) + { + CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::DestroyFragmentShader); + cmdbuf.write(_handle); + m_submit->free(_handle); + } + + MaterialHandle createMaterial(VertexShaderHandle _vsh, FragmentShaderHandle _fsh) + { + MaterialHandle handle; +// uint32_t hash = _vsh.idx<<16 | _fsh.idx; +// +// MaterialHandle handle = m_materialRef.find(hash); +// +// if (bgfx::invalidHandle != handle.idx) +// { +// return handle; +// } +// + handle.idx = m_materialHandle.alloc(); +// m_materialRef.add(handle, hash); + + CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::CreateMaterial); + cmdbuf.write(handle); + cmdbuf.write(_vsh); + cmdbuf.write(_fsh); + return handle; + } + + void destroyMaterial(MaterialHandle _handle) + { + CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::DestroyMaterial); + cmdbuf.write(_handle); + m_submit->free(_handle); + } + + TextureHandle createTexture(const Memory* _mem, uint32_t _flags, uint16_t* _width, uint16_t* _height) + { + if (NULL != _width + || NULL != _height) + { + int width = 0; + int height = 0; + + Dds dds; + if (parseDds(dds, _mem) ) + { + width = dds.m_width; + height = dds.m_height; + } + + if (NULL != _width) + { + *_width = (uint16_t)width; + } + + if (NULL != _height) + { + *_height = (uint16_t)height; + } + } + + TextureHandle handle = { m_textureHandle.alloc() }; + CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::CreateTexture); + cmdbuf.write(handle); + cmdbuf.write(_mem); + cmdbuf.write(_flags); + return handle; + } + + void destroyTexture(TextureHandle _handle) + { + CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::DestroyTexture); + cmdbuf.write(_handle); + m_submit->free(_handle); + } + + RenderTargetHandle createRenderTarget(uint16_t _width, uint16_t _height, uint32_t _flags) + { + RenderTargetHandle handle = { m_renderTargetHandle.alloc() }; + + CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::CreateRenderTarget); + cmdbuf.write(handle); + cmdbuf.write(_width); + cmdbuf.write(_height); + cmdbuf.write(_flags); + return handle; + } + + void destroyRenderTarget(RenderTargetHandle _handle) + { + CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::DestroyRenderTarget); + cmdbuf.write(_handle); + m_submit->free(_handle); + } + + UniformHandle createUniform(const char* _name, ConstantType::Enum _type, uint16_t _num) + { + BX_CHECK(PredefinedUniform::Count == nameToPredefinedUniformEnum(_name), "%s is predefined uniform name.", _name); + + UniformHandle handle = { m_uniformHandle.alloc() }; + + Constant& constant = m_constant[handle.idx]; + constant.m_type = _type; + constant.m_num = _num; + + CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::CreateUniform); + cmdbuf.write(handle); + cmdbuf.write(_type); + cmdbuf.write(_num); + uint8_t len = (uint8_t)strlen(_name); + cmdbuf.write(len); + cmdbuf.write(_name, len); + return handle; + } + + void destroyUniform(UniformHandle _handle) + { + CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::DestroyUniform); + cmdbuf.write(_handle); + m_submit->free(_handle); + } + + void saveScreenShot(const Memory* _mem) + { + CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::SaveScreenShot); + cmdbuf.write(_mem); + } + + void setUniform(UniformHandle _handle, const void* _value, uint16_t _num) + { + Constant& constant = m_constant[_handle.idx]; + BX_CHECK(constant.m_num >= _num, "Truncated uniform update. %d (max: %d)", _num, constant.m_num); + m_submit->writeConstant(constant.m_type, _handle, _value, uint16_min(constant.m_num, _num) ); + } + + void setUniform(MaterialHandle _material, UniformHandle _handle, const void* _value) + { + BX_CHECK(false, "NOT IMPLEMENTED!"); + } + + void setViewRect(uint8_t _id, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height) + { + Rect& rect = m_rect[_id]; + rect.m_x = _x; + rect.m_y = _y; + rect.m_width = _width; + rect.m_height = _height; + } + + void setViewRectMask(uint32_t _viewMask, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height) + { + for (uint32_t id = 0, viewMask = _viewMask, ntz = uint32_cnttz(_viewMask); 0 != viewMask; viewMask >>= 1, id += 1, ntz = uint32_cnttz(viewMask) ) + { + viewMask >>= ntz; + id += ntz; + + setViewRect(id, _x, _y, _width, _height); + } + } + + void setViewClear(uint8_t _id, uint8_t _flags, uint32_t _rgba, float _depth, uint8_t _stencil) + { + Clear& clear = m_clear[_id]; + clear.m_flags = _flags; + clear.m_rgba = _rgba; + clear.m_depth = _depth; + clear.m_stencil = _stencil; + } + + void setViewClearMask(uint32_t _viewMask, uint8_t _flags, uint32_t _rgba, float _depth, uint8_t _stencil) + { + for (uint32_t id = 0, viewMask = _viewMask, ntz = uint32_cnttz(_viewMask); 0 != viewMask; viewMask >>= 1, id += 1, ntz = uint32_cnttz(viewMask) ) + { + viewMask >>= ntz; + id += ntz; + + setViewClear(id, _flags, _rgba, _depth, _stencil); + } + } + + void setViewSeq(uint8_t _id, bool _enabled) + { + m_seqMask[_id] = _enabled ? 0xffff : 0x0; + } + + void setViewSeqMask(uint32_t _viewMask, bool _enabled) + { + uint16_t mask = _enabled ? 0xffff : 0x0; + for (uint32_t id = 0, viewMask = _viewMask, ntz = uint32_cnttz(_viewMask); 0 != viewMask; viewMask >>= 1, id += 1, ntz = uint32_cnttz(viewMask) ) + { + viewMask >>= ntz; + id += ntz; + + m_seqMask[id] = mask; + } + } + + void setViewRenderTarget(uint8_t _id, RenderTargetHandle _handle) + { + m_rt[_id] = _handle; + } + + void setViewRenderTargetMask(uint32_t _viewMask, RenderTargetHandle _handle) + { + for (uint32_t id = 0, viewMask = _viewMask, ntz = uint32_cnttz(_viewMask); 0 != viewMask; viewMask >>= 1, id += 1, ntz = uint32_cnttz(viewMask) ) + { + viewMask >>= ntz; + id += ntz; + + m_rt[id] = _handle; + } + } + + void dumpViewStats() + { +#if 0 // BGFX_DEBUG + for (uint8_t view = 0; view < BGFX_CONFIG_MAX_VIEWS; ++view) + { + if (0 < m_seq[view]) + { + BX_TRACE("%d: %d", view, m_seq[view]); + } + } +#endif // BGFX_DEBUG + } + + void freeAllHandles(Frame* _frame) + { + for (uint16_t ii = 0, num = _frame->m_numFreeIndexBufferHandles; ii < num; ++ii) + { + m_indexBufferHandle.free(_frame->m_freeIndexBufferHandle[ii].idx); + } + + for (uint16_t ii = 0, num = _frame->m_numFreeVertexDeclHandles; ii < num; ++ii) + { + m_vertexDeclHandle.free(_frame->m_freeVertexDeclHandle[ii].idx); + } + + for (uint16_t ii = 0, num = _frame->m_numFreeVertexBufferHandles; ii < num; ++ii) + { + m_vertexBufferHandle.free(_frame->m_freeVertexBufferHandle[ii].idx); + } + + for (uint16_t ii = 0, num = _frame->m_numFreeVertexShaderHandles; ii < num; ++ii) + { + m_vertexShaderHandle.free(_frame->m_freeVertexShaderHandle[ii].idx); + } + + for (uint16_t ii = 0, num = _frame->m_numFreeFragmentShaderHandles; ii < num; ++ii) + { + m_fragmentShaderHandle.free(_frame->m_freeFragmentShaderHandle[ii].idx); + } + + for (uint16_t ii = 0, num = _frame->m_numFreeMaterialHandles; ii < num; ++ii) + { + m_materialHandle.free(_frame->m_freeMaterialHandle[ii].idx); + } + + for (uint16_t ii = 0, num = _frame->m_numFreeTextureHandles; ii < num; ++ii) + { + m_textureHandle.free(_frame->m_freeTextureHandle[ii].idx); + } + + for (uint16_t ii = 0, num = _frame->m_numFreeRenderTargetHandles; ii < num; ++ii) + { + m_renderTargetHandle.free(_frame->m_freeRenderTargetHandle[ii].idx); + } + + for (uint16_t ii = 0, num = _frame->m_numFreeUniformHandles; ii < num; ++ii) + { + m_uniformHandle.free(_frame->m_freeUniformHandle[ii].idx); + } + } + + void swap() + { + m_submit->m_resolution = m_resolution; + m_submit->m_debug = m_debug; + memcpy(m_submit->m_rt, m_rt, sizeof(m_rt) ); + memcpy(m_submit->m_clear, m_clear, sizeof(m_clear) ); + memcpy(m_submit->m_rect, m_rect, sizeof(m_rect) ); + m_submit->finish(); + + dumpViewStats(); + + freeAllHandles(m_render); + + memset(m_seq, 0, sizeof(m_seq) ); + Frame* temp = m_render; + m_render = m_submit; + m_submit = temp; + m_frames++; + m_submit->reset(); + } + + void flip(); + + // render thread + void renderFrame() + { +#if BX_PLATFORM_NACL +// on NaCl swap buffers generates callback and this is handled inside callback +#else + if (m_rendererInitialized) + { + flip(); + } +#endif // BX_PLATFORM_ + + gameSemWait(); + + rendererExecCommands(m_render->m_cmdPre); + if (m_rendererInitialized) + { + rendererSubmit(); + } + rendererExecCommands(m_render->m_cmdPost); + + renderSemPost(); + } + + void rendererInit(); + void rendererShutdown(); + void rendererCreateIndexBuffer(IndexBufferHandle _handle, Memory* _mem); + void rendererDestroyIndexBuffer(IndexBufferHandle _handle); + void rendererCreateDynamicIndexBuffer(IndexBufferHandle _handle, uint32_t _size); + void rendererDestroyDynamicIndexBuffer(IndexBufferHandle _handle); + void rendererCreateVertexBuffer(VertexBufferHandle _handle, Memory* _mem, VertexDeclHandle _declHandle); + void rendererDestroyVertexBuffer(VertexBufferHandle _handle); + void rendererCreateDynamicVertexBuffer(VertexBufferHandle _handle, uint32_t _size); + void rendererDestroyDynamicVertexBuffer(VertexBufferHandle _handle); + void rendererCreateVertexDecl(VertexDeclHandle _handle, const VertexDecl& _decl); + void rendererDestroyVertexDecl(VertexDeclHandle _handle); + void rendererCreateVertexShader(VertexShaderHandle _handle, Memory* _mem); + void rendererDestroyVertexShader(VertexShaderHandle _handle); + void rendererCreateFragmentShader(FragmentShaderHandle _handle, Memory* _mem); + void rendererDestroyFragmentShader(FragmentShaderHandle _handle); + void rendererCreateMaterial(MaterialHandle _handle, VertexShaderHandle _vsh, FragmentShaderHandle _fsh); + void rendererDestroyMaterial(FragmentShaderHandle _handle); + void rendererCreateTexture(TextureHandle _handle, Memory* _mem, uint32_t _flags); + void rendererDestroyTexture(TextureHandle _handle); + void rendererCreateRenderTarget(RenderTargetHandle _handle, uint16_t _width, uint16_t _height, uint32_t _flags); + void rendererDestroyRenderTarget(RenderTargetHandle _handle); + void rendererCreateUniform(UniformHandle _handle, ConstantType::Enum _type, uint16_t _num, const char* _name); + void rendererDestroyUniform(UniformHandle _handle); + void rendererSaveScreenShot(Memory* _mem); + void rendererUpdateUniform(uint16_t _loc, const void* _data, uint32_t _size); + + void rendererUpdateUniforms(ConstantBuffer* _constantBuffer, uint32_t _begin, uint32_t _end) + { + _constantBuffer->reset(_begin); + while (_constantBuffer->getPos() < _end) + { + uint32_t opcode = _constantBuffer->read(); + + if (ConstantType::End == opcode) + { + break; + } + + ConstantType::Enum type; + uint16_t loc; + uint16_t num; + uint16_t copy; + ConstantBuffer::decodeOpcode(opcode, type, loc, num, copy); + + const char* data; + uint32_t size = g_constantTypeSize[type]*num; + data = _constantBuffer->read(size); + rendererUpdateUniform(loc, data, size); + } + } + + void rendererExecCommands(CommandBuffer& _cmdbuf) + { + _cmdbuf.reset(); + + bool end = false; + + do + { + uint8_t command; + _cmdbuf.read(command); + + switch (command) + { + case CommandBuffer::RendererInit: + { + rendererInit(); + m_rendererInitialized = true; + } + break; + + case CommandBuffer::RendererShutdown: + { + rendererShutdown(); + m_rendererInitialized = false; + } + break; + + case CommandBuffer::CreateIndexBuffer: + { + IndexBufferHandle handle; + _cmdbuf.read(handle); + + Memory* mem; + _cmdbuf.read(mem); + + rendererCreateIndexBuffer(handle, mem); + + free(mem); + } + break; + + case CommandBuffer::DestroyIndexBuffer: + { + IndexBufferHandle handle; + _cmdbuf.read(handle); + + rendererDestroyIndexBuffer(handle); + } + break; + + case CommandBuffer::CreateDynamicIndexBuffer: + { + IndexBufferHandle handle; + _cmdbuf.read(handle); + + uint32_t size; + _cmdbuf.read(size); + + rendererCreateDynamicIndexBuffer(handle, size); + } + break; + + case CommandBuffer::DestroyDynamicIndexBuffer: + { + IndexBufferHandle handle; + _cmdbuf.read(handle); + + rendererDestroyDynamicIndexBuffer(handle); + } + break; + + case CommandBuffer::CreateVertexDecl: + { + VertexDeclHandle handle; + _cmdbuf.read(handle); + + VertexDecl decl; + _cmdbuf.read(decl); + + rendererCreateVertexDecl(handle, decl); + } + break; + + case CommandBuffer::DestroyVertexDecl: + { + VertexDeclHandle handle; + _cmdbuf.read(handle); + + rendererDestroyVertexDecl(handle); + } + break; + + case CommandBuffer::CreateVertexBuffer: + { + VertexBufferHandle handle; + _cmdbuf.read(handle); + + Memory* mem; + _cmdbuf.read(mem); + + VertexDeclHandle declHandle; + _cmdbuf.read(declHandle); + + rendererCreateVertexBuffer(handle, mem, declHandle); + + free(mem); + } + break; + + case CommandBuffer::DestroyVertexBuffer: + { + VertexBufferHandle handle; + _cmdbuf.read(handle); + + rendererDestroyVertexBuffer(handle); + } + break; + + case CommandBuffer::CreateDynamicVertexBuffer: + { + VertexBufferHandle handle; + _cmdbuf.read(handle); + + uint32_t size; + _cmdbuf.read(size); + + rendererCreateDynamicVertexBuffer(handle, size); + } + break; + + case CommandBuffer::DestroyDynamicVertexBuffer: + { + VertexBufferHandle handle; + _cmdbuf.read(handle); + + rendererDestroyDynamicVertexBuffer(handle); + } + break; + + case CommandBuffer::CreateVertexShader: + { + VertexShaderHandle handle; + _cmdbuf.read(handle); + + Memory* mem; + _cmdbuf.read(mem); + + rendererCreateVertexShader(handle, mem); + + free(mem); + } + break; + + case CommandBuffer::DestroyVertexShader: + { + VertexShaderHandle handle; + _cmdbuf.read(handle); + + rendererDestroyVertexShader(handle); + } + break; + + case CommandBuffer::CreateFragmentShader: + { + FragmentShaderHandle handle; + _cmdbuf.read(handle); + + Memory* mem; + _cmdbuf.read(mem); + + rendererCreateFragmentShader(handle, mem); + + free(mem); + } + break; + + case CommandBuffer::DestroyFragmentShader: + { + FragmentShaderHandle handle; + _cmdbuf.read(handle); + + rendererDestroyFragmentShader(handle); + } + break; + + case CommandBuffer::CreateMaterial: + { + MaterialHandle handle; + _cmdbuf.read(handle); + + VertexShaderHandle vsh; + _cmdbuf.read(vsh); + + FragmentShaderHandle fsh; + _cmdbuf.read(fsh); + + rendererCreateMaterial(handle, vsh, fsh); + } + break; + + case CommandBuffer::DestroyMaterial: + { + FragmentShaderHandle handle; + _cmdbuf.read(handle); + + rendererDestroyMaterial(handle); + } + break; + + case CommandBuffer::CreateTexture: + { + TextureHandle handle; + _cmdbuf.read(handle); + + Memory* mem; + _cmdbuf.read(mem); + + uint32_t flags; + _cmdbuf.read(flags); + + rendererCreateTexture(handle, mem, flags); + + free(mem); + } + break; + + case CommandBuffer::DestroyTexture: + { + TextureHandle handle; + _cmdbuf.read(handle); + + rendererDestroyTexture(handle); + } + break; + + case CommandBuffer::CreateRenderTarget: + { + RenderTargetHandle handle; + _cmdbuf.read(handle); + + uint16_t width; + _cmdbuf.read(width); + + uint16_t height; + _cmdbuf.read(height); + + uint32_t flags; + _cmdbuf.read(flags); + + rendererCreateRenderTarget(handle, width, height, flags); + } + break; + + case CommandBuffer::DestroyRenderTarget: + { + RenderTargetHandle handle; + _cmdbuf.read(handle); + + rendererDestroyRenderTarget(handle); + } + break; + + case CommandBuffer::CreateUniform: + { + UniformHandle handle; + _cmdbuf.read(handle); + + ConstantType::Enum type; + _cmdbuf.read(type); + + uint16_t num; + _cmdbuf.read(num); + + uint8_t len; + _cmdbuf.read(len); + + char name[256]; + _cmdbuf.read(name, len); + name[len] = '\0'; + + rendererCreateUniform(handle, type, num, name); + } + break; + + case CommandBuffer::DestroyUniform: + { + UniformHandle handle; + _cmdbuf.read(handle); + + rendererDestroyUniform(handle); + } + break; + + case CommandBuffer::SaveScreenShot: + { + Memory* mem; + _cmdbuf.read(mem); + + rendererSaveScreenShot(mem); + + free(mem); + } + break; + + case CommandBuffer::End: + end = true; + break; + + default: + BX_CHECK(false, "WTF!"); + break; + } + } while (!end); + } + + void rendererSubmit(); + +#if BGFX_CONFIG_MULTITHREADED + void gameSemPost() + { +// BX_TRACE("game post"); + m_gameSem.post(); + } + + void gameSemWait() + { +// BX_TRACE("game wait"); + int64_t start = bx::getHPCounter(); + m_gameSem.wait(); + m_render->m_waitSubmit = bx::getHPCounter()-start; + } + + void renderSemPost() + { +// BX_TRACE("render post"); + m_renderSem.post(); + } + + void renderSemWait() + { +// BX_TRACE("render wait"); + int64_t start = bx::getHPCounter(); + m_renderSem.wait(); + m_submit->m_waitRender = bx::getHPCounter() - start; + } + + Semaphore m_renderSem; + Semaphore m_gameSem; +#else + void gameSemPost() + { + } + + void gameSemWait() + { + } + + void renderSemPost() + { + } + + void renderSemWait() + { + } +#endif // BGFX_CONFIG_MULTITHREADED + + Frame m_frame[2]; + Frame* m_render; + Frame* m_submit; + + uint64_t m_tempKeys[BGFX_CONFIG_MAX_DRAW_CALLS]; + uint16_t m_tempValues[BGFX_CONFIG_MAX_DRAW_CALLS]; + + HandleAlloc m_indexBufferHandle; + HandleAlloc m_vertexDeclHandle; + HandleAlloc m_vertexBufferHandle; + HandleAlloc m_vertexShaderHandle; + HandleAlloc m_fragmentShaderHandle; + HandleAlloc m_materialHandle; + HandleAlloc m_textureHandle; + HandleAlloc m_renderTargetHandle; + HandleAlloc m_uniformHandle; + + MaterialRef m_materialRef; + VertexDeclRef m_declRef; + + RenderTargetHandle m_rt[BGFX_CONFIG_MAX_VIEWS]; + Clear m_clear[BGFX_CONFIG_MAX_VIEWS]; + Rect m_rect[BGFX_CONFIG_MAX_VIEWS]; + Constant m_constant[BGFX_CONFIG_MAX_UNIFORMS]; + uint16_t m_seq[BGFX_CONFIG_MAX_VIEWS]; + uint16_t m_seqMask[BGFX_CONFIG_MAX_VIEWS]; + + Resolution m_resolution; + uint32_t m_frames; + uint32_t m_debug; + +#if BX_PLATFORM_WINDOWS + struct Window + { + Window() + : m_frame(true) + { + } + + void init() + { + if (NULL == bgfxHwnd) + { + bgfxHwnd = CreateWindow( "EDIT" + , NULL + , WS_OVERLAPPEDWINDOW|WS_VISIBLE + , 0 + , 0 + , BGFX_DEFAULT_WIDTH + , BGFX_DEFAULT_HEIGHT + , 0 + , 0 + , 0 + , 0 + ); + } + } + + void adjust(uint32_t _width, uint32_t _height, bool _windowFrame) + { + + ShowWindow(bgfxHwnd, SW_SHOWNORMAL); + RECT rect; + RECT newrect = {0, 0, (LONG)_width, (LONG)_height}; + DWORD style = WS_POPUP|WS_SYSMENU; + + if (m_frame) + { + GetWindowRect(bgfxHwnd, &m_rect); + m_style = GetWindowLong(bgfxHwnd, GWL_STYLE); + } + + if (_windowFrame) + { + rect = m_rect; + style = m_style; + } + else + { +#if defined(__MINGW32__) + rect = m_rect; + style = m_style; +#else + HMONITOR monitor = MonitorFromWindow(bgfxHwnd, MONITOR_DEFAULTTONEAREST); + MONITORINFO mi; + mi.cbSize = sizeof(mi); + GetMonitorInfo(monitor, &mi); + newrect = mi.rcMonitor; + rect = mi.rcMonitor; +#endif // !defined(__MINGW__) + } + + SetWindowLong(bgfxHwnd, GWL_STYLE, style); + AdjustWindowRect(&newrect, style, FALSE); + UpdateWindow(bgfxHwnd); + + if (rect.left == -32000 + || rect.top == -32000) + { + rect.left = 0; + rect.top = 0; + } + + SetWindowPos(bgfxHwnd + , HWND_TOP + , rect.left + , rect.top + , (newrect.right-newrect.left) + , (newrect.bottom-newrect.top) + , SWP_SHOWWINDOW + ); + + ShowWindow(bgfxHwnd, SW_RESTORE); + + m_frame = _windowFrame; + } + + RECT m_rect; + DWORD m_style; + bool m_frame; + }; + + Window m_window; +#endif // BX_PLATFORM_WINDOWS + + bool m_initialized; + bool m_rendererInitialized; + }; + +} // namespace bgfx + +#endif // __BGFX_P_H__ diff --git a/src/charset.h b/src/charset.h new file mode 100644 index 000000000..3b37ba909 --- /dev/null +++ b/src/charset.h @@ -0,0 +1,734 @@ +/* + * Copyright 2011-2012 Branimir Karadzic. All rights reserved. + * License: http://www.opensource.org/licenses/BSD-2-Clause + */ + +static const uint8_t vga8x8[256*8] = +{ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x7e, 0x81, 0xa5, 0x81, 0xbd, 0x99, 0x81, 0x7e, + 0x7e, 0xff, 0xdb, 0xff, 0xc3, 0xe7, 0xff, 0x7e, + 0x6c, 0xfe, 0xfe, 0xfe, 0x7c, 0x38, 0x10, 0x00, + 0x10, 0x38, 0x7c, 0xfe, 0x7c, 0x38, 0x10, 0x00, + 0x38, 0x7c, 0x38, 0xfe, 0xfe, 0x92, 0x10, 0x7c, + 0x00, 0x10, 0x38, 0x7c, 0xfe, 0x7c, 0x38, 0x7c, + 0x00, 0x00, 0x18, 0x3c, 0x3c, 0x18, 0x00, 0x00, + 0xff, 0xff, 0xe7, 0xc3, 0xc3, 0xe7, 0xff, 0xff, + 0x00, 0x3c, 0x66, 0x42, 0x42, 0x66, 0x3c, 0x00, + 0xff, 0xc3, 0x99, 0xbd, 0xbd, 0x99, 0xc3, 0xff, + 0x0f, 0x07, 0x0f, 0x7d, 0xcc, 0xcc, 0xcc, 0x78, + 0x3c, 0x66, 0x66, 0x66, 0x3c, 0x18, 0x7e, 0x18, + 0x3f, 0x33, 0x3f, 0x30, 0x30, 0x70, 0xf0, 0xe0, + 0x7f, 0x63, 0x7f, 0x63, 0x63, 0x67, 0xe6, 0xc0, + 0x99, 0x5a, 0x3c, 0xe7, 0xe7, 0x3c, 0x5a, 0x99, + 0x80, 0xe0, 0xf8, 0xfe, 0xf8, 0xe0, 0x80, 0x00, + 0x02, 0x0e, 0x3e, 0xfe, 0x3e, 0x0e, 0x02, 0x00, + 0x18, 0x3c, 0x7e, 0x18, 0x18, 0x7e, 0x3c, 0x18, + 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x66, 0x00, + 0x7f, 0xdb, 0xdb, 0x7b, 0x1b, 0x1b, 0x1b, 0x00, + 0x3e, 0x63, 0x38, 0x6c, 0x6c, 0x38, 0x86, 0xfc, + 0x00, 0x00, 0x00, 0x00, 0x7e, 0x7e, 0x7e, 0x00, + 0x18, 0x3c, 0x7e, 0x18, 0x7e, 0x3c, 0x18, 0xff, + 0x18, 0x3c, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x00, + 0x18, 0x18, 0x18, 0x18, 0x7e, 0x3c, 0x18, 0x00, + 0x00, 0x18, 0x0c, 0xfe, 0x0c, 0x18, 0x00, 0x00, + 0x00, 0x30, 0x60, 0xfe, 0x60, 0x30, 0x00, 0x00, + 0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xfe, 0x00, 0x00, + 0x00, 0x24, 0x66, 0xff, 0x66, 0x24, 0x00, 0x00, + 0x00, 0x18, 0x3c, 0x7e, 0xff, 0xff, 0x00, 0x00, + 0x00, 0xff, 0xff, 0x7e, 0x3c, 0x18, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x18, 0x3c, 0x3c, 0x18, 0x18, 0x00, 0x18, 0x00, + 0x6c, 0x6c, 0x6c, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x6c, 0x6c, 0xfe, 0x6c, 0xfe, 0x6c, 0x6c, 0x00, + 0x18, 0x7e, 0xc0, 0x7c, 0x06, 0xfc, 0x18, 0x00, + 0x00, 0xc6, 0xcc, 0x18, 0x30, 0x66, 0xc6, 0x00, + 0x38, 0x6c, 0x38, 0x76, 0xdc, 0xcc, 0x76, 0x00, + 0x30, 0x30, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x18, 0x30, 0x60, 0x60, 0x60, 0x30, 0x18, 0x00, + 0x60, 0x30, 0x18, 0x18, 0x18, 0x30, 0x60, 0x00, + 0x00, 0x66, 0x3c, 0xff, 0x3c, 0x66, 0x00, 0x00, + 0x00, 0x18, 0x18, 0x7e, 0x18, 0x18, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x30, + 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, + 0x06, 0x0c, 0x18, 0x30, 0x60, 0xc0, 0x80, 0x00, + 0x7c, 0xce, 0xde, 0xf6, 0xe6, 0xc6, 0x7c, 0x00, + 0x30, 0x70, 0x30, 0x30, 0x30, 0x30, 0xfc, 0x00, + 0x78, 0xcc, 0x0c, 0x38, 0x60, 0xcc, 0xfc, 0x00, + 0x78, 0xcc, 0x0c, 0x38, 0x0c, 0xcc, 0x78, 0x00, + 0x1c, 0x3c, 0x6c, 0xcc, 0xfe, 0x0c, 0x1e, 0x00, + 0xfc, 0xc0, 0xf8, 0x0c, 0x0c, 0xcc, 0x78, 0x00, + 0x38, 0x60, 0xc0, 0xf8, 0xcc, 0xcc, 0x78, 0x00, + 0xfc, 0xcc, 0x0c, 0x18, 0x30, 0x30, 0x30, 0x00, + 0x78, 0xcc, 0xcc, 0x78, 0xcc, 0xcc, 0x78, 0x00, + 0x78, 0xcc, 0xcc, 0x7c, 0x0c, 0x18, 0x70, 0x00, + 0x00, 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x00, + 0x00, 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x30, + 0x18, 0x30, 0x60, 0xc0, 0x60, 0x30, 0x18, 0x00, + 0x00, 0x00, 0x7e, 0x00, 0x7e, 0x00, 0x00, 0x00, + 0x60, 0x30, 0x18, 0x0c, 0x18, 0x30, 0x60, 0x00, + 0x3c, 0x66, 0x0c, 0x18, 0x18, 0x00, 0x18, 0x00, + 0x7c, 0xc6, 0xde, 0xde, 0xdc, 0xc0, 0x7c, 0x00, + 0x30, 0x78, 0xcc, 0xcc, 0xfc, 0xcc, 0xcc, 0x00, + 0xfc, 0x66, 0x66, 0x7c, 0x66, 0x66, 0xfc, 0x00, + 0x3c, 0x66, 0xc0, 0xc0, 0xc0, 0x66, 0x3c, 0x00, + 0xf8, 0x6c, 0x66, 0x66, 0x66, 0x6c, 0xf8, 0x00, + 0xfe, 0x62, 0x68, 0x78, 0x68, 0x62, 0xfe, 0x00, + 0xfe, 0x62, 0x68, 0x78, 0x68, 0x60, 0xf0, 0x00, + 0x3c, 0x66, 0xc0, 0xc0, 0xce, 0x66, 0x3a, 0x00, + 0xcc, 0xcc, 0xcc, 0xfc, 0xcc, 0xcc, 0xcc, 0x00, + 0x78, 0x30, 0x30, 0x30, 0x30, 0x30, 0x78, 0x00, + 0x1e, 0x0c, 0x0c, 0x0c, 0xcc, 0xcc, 0x78, 0x00, + 0xe6, 0x66, 0x6c, 0x78, 0x6c, 0x66, 0xe6, 0x00, + 0xf0, 0x60, 0x60, 0x60, 0x62, 0x66, 0xfe, 0x00, + 0xc6, 0xee, 0xfe, 0xfe, 0xd6, 0xc6, 0xc6, 0x00, + 0xc6, 0xe6, 0xf6, 0xde, 0xce, 0xc6, 0xc6, 0x00, + 0x38, 0x6c, 0xc6, 0xc6, 0xc6, 0x6c, 0x38, 0x00, + 0xfc, 0x66, 0x66, 0x7c, 0x60, 0x60, 0xf0, 0x00, + 0x7c, 0xc6, 0xc6, 0xc6, 0xd6, 0x7c, 0x0e, 0x00, + 0xfc, 0x66, 0x66, 0x7c, 0x6c, 0x66, 0xe6, 0x00, + 0x7c, 0xc6, 0xe0, 0x78, 0x0e, 0xc6, 0x7c, 0x00, + 0xfc, 0xb4, 0x30, 0x30, 0x30, 0x30, 0x78, 0x00, + 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xfc, 0x00, + 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x78, 0x30, 0x00, + 0xc6, 0xc6, 0xc6, 0xc6, 0xd6, 0xfe, 0x6c, 0x00, + 0xc6, 0xc6, 0x6c, 0x38, 0x6c, 0xc6, 0xc6, 0x00, + 0xcc, 0xcc, 0xcc, 0x78, 0x30, 0x30, 0x78, 0x00, + 0xfe, 0xc6, 0x8c, 0x18, 0x32, 0x66, 0xfe, 0x00, + 0x78, 0x60, 0x60, 0x60, 0x60, 0x60, 0x78, 0x00, + 0xc0, 0x60, 0x30, 0x18, 0x0c, 0x06, 0x02, 0x00, + 0x78, 0x18, 0x18, 0x18, 0x18, 0x18, 0x78, 0x00, + 0x10, 0x38, 0x6c, 0xc6, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, + 0x30, 0x30, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0x76, 0x00, + 0xe0, 0x60, 0x60, 0x7c, 0x66, 0x66, 0xdc, 0x00, + 0x00, 0x00, 0x78, 0xcc, 0xc0, 0xcc, 0x78, 0x00, + 0x1c, 0x0c, 0x0c, 0x7c, 0xcc, 0xcc, 0x76, 0x00, + 0x00, 0x00, 0x78, 0xcc, 0xfc, 0xc0, 0x78, 0x00, + 0x38, 0x6c, 0x64, 0xf0, 0x60, 0x60, 0xf0, 0x00, + 0x00, 0x00, 0x76, 0xcc, 0xcc, 0x7c, 0x0c, 0xf8, + 0xe0, 0x60, 0x6c, 0x76, 0x66, 0x66, 0xe6, 0x00, + 0x30, 0x00, 0x70, 0x30, 0x30, 0x30, 0x78, 0x00, + 0x0c, 0x00, 0x1c, 0x0c, 0x0c, 0xcc, 0xcc, 0x78, + 0xe0, 0x60, 0x66, 0x6c, 0x78, 0x6c, 0xe6, 0x00, + 0x70, 0x30, 0x30, 0x30, 0x30, 0x30, 0x78, 0x00, + 0x00, 0x00, 0xcc, 0xfe, 0xfe, 0xd6, 0xd6, 0x00, + 0x00, 0x00, 0xb8, 0xcc, 0xcc, 0xcc, 0xcc, 0x00, + 0x00, 0x00, 0x78, 0xcc, 0xcc, 0xcc, 0x78, 0x00, + 0x00, 0x00, 0xdc, 0x66, 0x66, 0x7c, 0x60, 0xf0, + 0x00, 0x00, 0x76, 0xcc, 0xcc, 0x7c, 0x0c, 0x1e, + 0x00, 0x00, 0xdc, 0x76, 0x62, 0x60, 0xf0, 0x00, + 0x00, 0x00, 0x7c, 0xc0, 0x70, 0x1c, 0xf8, 0x00, + 0x10, 0x30, 0xfc, 0x30, 0x30, 0x34, 0x18, 0x00, + 0x00, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, + 0x00, 0x00, 0xcc, 0xcc, 0xcc, 0x78, 0x30, 0x00, + 0x00, 0x00, 0xc6, 0xc6, 0xd6, 0xfe, 0x6c, 0x00, + 0x00, 0x00, 0xc6, 0x6c, 0x38, 0x6c, 0xc6, 0x00, + 0x00, 0x00, 0xcc, 0xcc, 0xcc, 0x7c, 0x0c, 0xf8, + 0x00, 0x00, 0xfc, 0x98, 0x30, 0x64, 0xfc, 0x00, + 0x1c, 0x30, 0x30, 0xe0, 0x30, 0x30, 0x1c, 0x00, + 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x00, + 0xe0, 0x30, 0x30, 0x1c, 0x30, 0x30, 0xe0, 0x00, + 0x76, 0xdc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x10, 0x38, 0x6c, 0xc6, 0xc6, 0xfe, 0x00, + 0x7c, 0xc6, 0xc0, 0xc6, 0x7c, 0x0c, 0x06, 0x7c, + 0x00, 0xcc, 0x00, 0xcc, 0xcc, 0xcc, 0x76, 0x00, + 0x1c, 0x00, 0x78, 0xcc, 0xfc, 0xc0, 0x78, 0x00, + 0x7e, 0x81, 0x3c, 0x06, 0x3e, 0x66, 0x3b, 0x00, + 0xcc, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0x76, 0x00, + 0xe0, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0x76, 0x00, + 0x30, 0x30, 0x78, 0x0c, 0x7c, 0xcc, 0x76, 0x00, + 0x00, 0x00, 0x7c, 0xc6, 0xc0, 0x78, 0x0c, 0x38, + 0x7e, 0x81, 0x3c, 0x66, 0x7e, 0x60, 0x3c, 0x00, + 0xcc, 0x00, 0x78, 0xcc, 0xfc, 0xc0, 0x78, 0x00, + 0xe0, 0x00, 0x78, 0xcc, 0xfc, 0xc0, 0x78, 0x00, + 0xcc, 0x00, 0x70, 0x30, 0x30, 0x30, 0x78, 0x00, + 0x7c, 0x82, 0x38, 0x18, 0x18, 0x18, 0x3c, 0x00, + 0xe0, 0x00, 0x70, 0x30, 0x30, 0x30, 0x78, 0x00, + 0xc6, 0x10, 0x7c, 0xc6, 0xfe, 0xc6, 0xc6, 0x00, + 0x30, 0x30, 0x00, 0x78, 0xcc, 0xfc, 0xcc, 0x00, + 0x1c, 0x00, 0xfc, 0x60, 0x78, 0x60, 0xfc, 0x00, + 0x00, 0x00, 0x7f, 0x0c, 0x7f, 0xcc, 0x7f, 0x00, + 0x3e, 0x6c, 0xcc, 0xfe, 0xcc, 0xcc, 0xce, 0x00, + 0x78, 0x84, 0x00, 0x78, 0xcc, 0xcc, 0x78, 0x00, + 0x00, 0xcc, 0x00, 0x78, 0xcc, 0xcc, 0x78, 0x00, + 0x00, 0xe0, 0x00, 0x78, 0xcc, 0xcc, 0x78, 0x00, + 0x78, 0x84, 0x00, 0xcc, 0xcc, 0xcc, 0x76, 0x00, + 0x00, 0xe0, 0x00, 0xcc, 0xcc, 0xcc, 0x76, 0x00, + 0x00, 0xcc, 0x00, 0xcc, 0xcc, 0x7c, 0x0c, 0xf8, + 0xc3, 0x18, 0x3c, 0x66, 0x66, 0x3c, 0x18, 0x00, + 0xcc, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0x78, 0x00, + 0x18, 0x18, 0x7e, 0xc0, 0xc0, 0x7e, 0x18, 0x18, + 0x38, 0x6c, 0x64, 0xf0, 0x60, 0xe6, 0xfc, 0x00, + 0xcc, 0xcc, 0x78, 0x30, 0xfc, 0x30, 0xfc, 0x30, + 0xf8, 0xcc, 0xcc, 0xfa, 0xc6, 0xcf, 0xc6, 0xc3, + 0x0e, 0x1b, 0x18, 0x3c, 0x18, 0x18, 0xd8, 0x70, + 0x1c, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0x76, 0x00, + 0x38, 0x00, 0x70, 0x30, 0x30, 0x30, 0x78, 0x00, + 0x00, 0x1c, 0x00, 0x78, 0xcc, 0xcc, 0x78, 0x00, + 0x00, 0x1c, 0x00, 0xcc, 0xcc, 0xcc, 0x76, 0x00, + 0x00, 0xf8, 0x00, 0xb8, 0xcc, 0xcc, 0xcc, 0x00, + 0xfc, 0x00, 0xcc, 0xec, 0xfc, 0xdc, 0xcc, 0x00, + 0x3c, 0x6c, 0x6c, 0x3e, 0x00, 0x7e, 0x00, 0x00, + 0x38, 0x6c, 0x6c, 0x38, 0x00, 0x7c, 0x00, 0x00, + 0x18, 0x00, 0x18, 0x18, 0x30, 0x66, 0x3c, 0x00, + 0x00, 0x00, 0x00, 0xfc, 0xc0, 0xc0, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xfc, 0x0c, 0x0c, 0x00, 0x00, + 0xc6, 0xcc, 0xd8, 0x36, 0x6b, 0xc2, 0x84, 0x0f, + 0xc3, 0xc6, 0xcc, 0xdb, 0x37, 0x6d, 0xcf, 0x03, + 0x18, 0x00, 0x18, 0x18, 0x3c, 0x3c, 0x18, 0x00, + 0x00, 0x33, 0x66, 0xcc, 0x66, 0x33, 0x00, 0x00, + 0x00, 0xcc, 0x66, 0x33, 0x66, 0xcc, 0x00, 0x00, + 0x22, 0x88, 0x22, 0x88, 0x22, 0x88, 0x22, 0x88, + 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, + 0xdb, 0xf6, 0xdb, 0x6f, 0xdb, 0x7e, 0xd7, 0xed, + 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, + 0x18, 0x18, 0x18, 0x18, 0xf8, 0x18, 0x18, 0x18, + 0x18, 0x18, 0xf8, 0x18, 0xf8, 0x18, 0x18, 0x18, + 0x36, 0x36, 0x36, 0x36, 0xf6, 0x36, 0x36, 0x36, + 0x00, 0x00, 0x00, 0x00, 0xfe, 0x36, 0x36, 0x36, + 0x00, 0x00, 0xf8, 0x18, 0xf8, 0x18, 0x18, 0x18, + 0x36, 0x36, 0xf6, 0x06, 0xf6, 0x36, 0x36, 0x36, + 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, + 0x00, 0x00, 0xfe, 0x06, 0xf6, 0x36, 0x36, 0x36, + 0x36, 0x36, 0xf6, 0x06, 0xfe, 0x00, 0x00, 0x00, + 0x36, 0x36, 0x36, 0x36, 0xfe, 0x00, 0x00, 0x00, + 0x18, 0x18, 0xf8, 0x18, 0xf8, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xf8, 0x18, 0x18, 0x18, + 0x18, 0x18, 0x18, 0x18, 0x1f, 0x00, 0x00, 0x00, + 0x18, 0x18, 0x18, 0x18, 0xff, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xff, 0x18, 0x18, 0x18, + 0x18, 0x18, 0x18, 0x18, 0x1f, 0x18, 0x18, 0x18, + 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, + 0x18, 0x18, 0x18, 0x18, 0xff, 0x18, 0x18, 0x18, + 0x18, 0x18, 0x1f, 0x18, 0x1f, 0x18, 0x18, 0x18, + 0x36, 0x36, 0x36, 0x36, 0x37, 0x36, 0x36, 0x36, + 0x36, 0x36, 0x37, 0x30, 0x3f, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x3f, 0x30, 0x37, 0x36, 0x36, 0x36, + 0x36, 0x36, 0xf7, 0x00, 0xff, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xff, 0x00, 0xf7, 0x36, 0x36, 0x36, + 0x36, 0x36, 0x37, 0x30, 0x37, 0x36, 0x36, 0x36, + 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, + 0x36, 0x36, 0xf7, 0x00, 0xf7, 0x36, 0x36, 0x36, + 0x18, 0x18, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, + 0x36, 0x36, 0x36, 0x36, 0xff, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xff, 0x00, 0xff, 0x18, 0x18, 0x18, + 0x00, 0x00, 0x00, 0x00, 0xff, 0x36, 0x36, 0x36, + 0x36, 0x36, 0x36, 0x36, 0x3f, 0x00, 0x00, 0x00, + 0x18, 0x18, 0x1f, 0x18, 0x1f, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x1f, 0x18, 0x1f, 0x18, 0x18, 0x18, + 0x00, 0x00, 0x00, 0x00, 0x3f, 0x36, 0x36, 0x36, + 0x36, 0x36, 0x36, 0x36, 0xff, 0x36, 0x36, 0x36, + 0x18, 0x18, 0xff, 0x18, 0xff, 0x18, 0x18, 0x18, + 0x18, 0x18, 0x18, 0x18, 0xf8, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x1f, 0x18, 0x18, 0x18, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, + 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, + 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, + 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x76, 0xdc, 0xc8, 0xdc, 0x76, 0x00, + 0x00, 0x78, 0xcc, 0xf8, 0xcc, 0xf8, 0xc0, 0xc0, + 0x00, 0xfc, 0xcc, 0xc0, 0xc0, 0xc0, 0xc0, 0x00, + 0x00, 0x00, 0xfe, 0x6c, 0x6c, 0x6c, 0x6c, 0x00, + 0xfc, 0xcc, 0x60, 0x30, 0x60, 0xcc, 0xfc, 0x00, + 0x00, 0x00, 0x7e, 0xd8, 0xd8, 0xd8, 0x70, 0x00, + 0x00, 0x66, 0x66, 0x66, 0x66, 0x7c, 0x60, 0xc0, + 0x00, 0x76, 0xdc, 0x18, 0x18, 0x18, 0x18, 0x00, + 0xfc, 0x30, 0x78, 0xcc, 0xcc, 0x78, 0x30, 0xfc, + 0x38, 0x6c, 0xc6, 0xfe, 0xc6, 0x6c, 0x38, 0x00, + 0x38, 0x6c, 0xc6, 0xc6, 0x6c, 0x6c, 0xee, 0x00, + 0x1c, 0x30, 0x18, 0x7c, 0xcc, 0xcc, 0x78, 0x00, + 0x00, 0x00, 0x7e, 0xdb, 0xdb, 0x7e, 0x00, 0x00, + 0x06, 0x0c, 0x7e, 0xdb, 0xdb, 0x7e, 0x60, 0xc0, + 0x38, 0x60, 0xc0, 0xf8, 0xc0, 0x60, 0x38, 0x00, + 0x78, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x00, + 0x00, 0x7e, 0x00, 0x7e, 0x00, 0x7e, 0x00, 0x00, + 0x18, 0x18, 0x7e, 0x18, 0x18, 0x00, 0x7e, 0x00, + 0x60, 0x30, 0x18, 0x30, 0x60, 0x00, 0xfc, 0x00, + 0x18, 0x30, 0x60, 0x30, 0x18, 0x00, 0xfc, 0x00, + 0x0e, 0x1b, 0x1b, 0x18, 0x18, 0x18, 0x18, 0x18, + 0x18, 0x18, 0x18, 0x18, 0x18, 0xd8, 0xd8, 0x70, + 0x18, 0x18, 0x00, 0x7e, 0x00, 0x18, 0x18, 0x00, + 0x00, 0x76, 0xdc, 0x00, 0x76, 0xdc, 0x00, 0x00, + 0x38, 0x6c, 0x6c, 0x38, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, + 0x0f, 0x0c, 0x0c, 0x0c, 0xec, 0x6c, 0x3c, 0x1c, + 0x58, 0x6c, 0x6c, 0x6c, 0x6c, 0x00, 0x00, 0x00, + 0x70, 0x98, 0x30, 0x60, 0xf8, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +}; + +static const uint8_t vga8x16[256*16] = +{ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x7e, 0x81, 0xa5, 0x81, 0x81, 0xbd, 0x99, 0x81, 0x81, 0x7e, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x7e, 0xff, 0xdb, 0xff, 0xff, 0xc3, 0xe7, 0xff, 0xff, 0x7e, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x6c, 0xfe, 0xfe, 0xfe, 0xfe, 0x7c, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x7c, 0xfe, 0x7c, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x18, 0x3c, 0x3c, 0xe7, 0xe7, 0xe7, 0x99, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x18, 0x3c, 0x7e, 0xff, 0xff, 0x7e, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x3c, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe7, 0xc3, 0xc3, 0xe7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x66, 0x42, 0x42, 0x66, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xc3, 0x99, 0xbd, 0xbd, 0x99, 0xc3, 0xff, 0xff, 0xff, 0xff, 0xff, + 0x00, 0x00, 0x1e, 0x0e, 0x1a, 0x32, 0x78, 0xcc, 0xcc, 0xcc, 0xcc, 0x78, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x3c, 0x66, 0x66, 0x66, 0x66, 0x3c, 0x18, 0x7e, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x3f, 0x33, 0x3f, 0x30, 0x30, 0x30, 0x30, 0x70, 0xf0, 0xe0, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x7f, 0x63, 0x7f, 0x63, 0x63, 0x63, 0x63, 0x67, 0xe7, 0xe6, 0xc0, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x18, 0x18, 0xdb, 0x3c, 0xe7, 0x3c, 0xdb, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfe, 0xf8, 0xf0, 0xe0, 0xc0, 0x80, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x02, 0x06, 0x0e, 0x1e, 0x3e, 0xfe, 0x3e, 0x1e, 0x0e, 0x06, 0x02, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x18, 0x3c, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x7e, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x7f, 0xdb, 0xdb, 0xdb, 0x7b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x7c, 0xc6, 0x60, 0x38, 0x6c, 0xc6, 0xc6, 0x6c, 0x38, 0x0c, 0xc6, 0x7c, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xfe, 0xfe, 0xfe, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x18, 0x3c, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x7e, 0x3c, 0x18, 0x7e, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x18, 0x3c, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x7e, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x0c, 0xfe, 0x0c, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x60, 0xfe, 0x60, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xc0, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x6c, 0xfe, 0x6c, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x38, 0x7c, 0x7c, 0xfe, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xfe, 0xfe, 0x7c, 0x7c, 0x38, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x18, 0x3c, 0x3c, 0x3c, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x66, 0x66, 0x66, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x6c, 0x6c, 0xfe, 0x6c, 0x6c, 0x6c, 0xfe, 0x6c, 0x6c, 0x00, 0x00, 0x00, 0x00, + 0x18, 0x18, 0x7c, 0xc6, 0xc2, 0xc0, 0x7c, 0x06, 0x86, 0xc6, 0x7c, 0x18, 0x18, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xc2, 0xc6, 0x0c, 0x18, 0x30, 0x60, 0xc6, 0x86, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x38, 0x6c, 0x6c, 0x38, 0x76, 0xdc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x30, 0x30, 0x30, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x0c, 0x18, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x18, 0x0c, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x30, 0x18, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x18, 0x30, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x3c, 0xff, 0x3c, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x7e, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x30, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x02, 0x06, 0x0c, 0x18, 0x30, 0x60, 0xc0, 0x80, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xce, 0xd6, 0xd6, 0xe6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x18, 0x38, 0x78, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x7e, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x7c, 0xc6, 0x06, 0x0c, 0x18, 0x30, 0x60, 0xc0, 0xc6, 0xfe, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x7c, 0xc6, 0x06, 0x06, 0x3c, 0x06, 0x06, 0x06, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x0c, 0x1c, 0x3c, 0x6c, 0xcc, 0xfe, 0x0c, 0x0c, 0x0c, 0x1e, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xfe, 0xc0, 0xc0, 0xc0, 0xfc, 0x0e, 0x06, 0x06, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x38, 0x60, 0xc0, 0xc0, 0xfc, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xfe, 0xc6, 0x06, 0x06, 0x0c, 0x18, 0x30, 0x30, 0x30, 0x30, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0x7e, 0x06, 0x06, 0x06, 0x0c, 0x78, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x18, 0x18, 0x30, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x06, 0x0c, 0x18, 0x30, 0x60, 0x30, 0x18, 0x0c, 0x06, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x60, 0x30, 0x18, 0x0c, 0x06, 0x0c, 0x18, 0x30, 0x60, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0x0c, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xde, 0xde, 0xde, 0xdc, 0xc0, 0x7c, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x10, 0x38, 0x6c, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xfc, 0x66, 0x66, 0x66, 0x7c, 0x66, 0x66, 0x66, 0x66, 0xfc, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x3c, 0x66, 0xc2, 0xc0, 0xc0, 0xc0, 0xc0, 0xc2, 0x66, 0x3c, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xf8, 0x6c, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x6c, 0xf8, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xfe, 0x66, 0x62, 0x68, 0x78, 0x68, 0x60, 0x62, 0x66, 0xfe, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xfe, 0x66, 0x62, 0x68, 0x78, 0x68, 0x60, 0x60, 0x60, 0xf0, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x3c, 0x66, 0xc2, 0xc0, 0xc0, 0xde, 0xc6, 0xc6, 0x66, 0x3a, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x3c, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x1e, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0xcc, 0xcc, 0xcc, 0x78, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xe6, 0x66, 0x6c, 0x6c, 0x78, 0x78, 0x6c, 0x66, 0x66, 0xe6, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xf0, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x62, 0x66, 0xfe, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xc6, 0xee, 0xfe, 0xfe, 0xd6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xc6, 0xe6, 0xf6, 0xfe, 0xde, 0xce, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x38, 0x6c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x6c, 0x38, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xfc, 0x66, 0x66, 0x66, 0x7c, 0x60, 0x60, 0x60, 0x60, 0xf0, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xd6, 0xde, 0x7c, 0x0c, 0x0e, 0x00, 0x00, + 0x00, 0x00, 0xfc, 0x66, 0x66, 0x66, 0x7c, 0x6c, 0x66, 0x66, 0x66, 0xe6, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0x60, 0x38, 0x0c, 0x06, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x7e, 0x7e, 0x5a, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x6c, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xd6, 0xd6, 0xfe, 0x6c, 0x6c, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xc6, 0xc6, 0x6c, 0x6c, 0x38, 0x38, 0x6c, 0x6c, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x3c, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xfe, 0xc6, 0x86, 0x0c, 0x18, 0x30, 0x60, 0xc2, 0xc6, 0xfe, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x3c, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x3c, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x80, 0xc0, 0xe0, 0x70, 0x38, 0x1c, 0x0e, 0x06, 0x02, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x3c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x3c, 0x00, 0x00, 0x00, 0x00, + 0x10, 0x38, 0x6c, 0xc6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, + 0x30, 0x30, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xe0, 0x60, 0x60, 0x78, 0x6c, 0x66, 0x66, 0x66, 0x66, 0xdc, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0xc0, 0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x1c, 0x0c, 0x0c, 0x3c, 0x6c, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x38, 0x6c, 0x64, 0x60, 0xf0, 0x60, 0x60, 0x60, 0x60, 0xf0, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x7c, 0x0c, 0xcc, 0x78, 0x00, + 0x00, 0x00, 0xe0, 0x60, 0x60, 0x6c, 0x76, 0x66, 0x66, 0x66, 0x66, 0xe6, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x18, 0x18, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x06, 0x06, 0x00, 0x0e, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x66, 0x66, 0x3c, 0x00, + 0x00, 0x00, 0xe0, 0x60, 0x60, 0x66, 0x6c, 0x78, 0x78, 0x6c, 0x66, 0xe6, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xec, 0xfe, 0xd6, 0xd6, 0xd6, 0xd6, 0xd6, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xdc, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xdc, 0x66, 0x66, 0x66, 0x66, 0x66, 0x7c, 0x60, 0x60, 0xf0, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x7c, 0x0c, 0x0c, 0x1e, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xdc, 0x76, 0x62, 0x60, 0x60, 0x60, 0xf0, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0x60, 0x38, 0x0c, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x10, 0x30, 0x30, 0xfc, 0x30, 0x30, 0x30, 0x30, 0x36, 0x1c, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xd6, 0xd6, 0xfe, 0x6c, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0x6c, 0x38, 0x38, 0x38, 0x6c, 0xc6, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7e, 0x06, 0x0c, 0xf8, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xcc, 0x18, 0x30, 0x60, 0xc6, 0xfe, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x0e, 0x18, 0x18, 0x18, 0x70, 0x18, 0x18, 0x18, 0x18, 0x0e, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x70, 0x18, 0x18, 0x18, 0x0e, 0x18, 0x18, 0x18, 0x18, 0x70, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x76, 0xdc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x6c, 0xc6, 0xc6, 0xc6, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x3c, 0x66, 0xc2, 0xc0, 0xc0, 0xc0, 0xc2, 0x66, 0x3c, 0x0c, 0x06, 0x7c, 0x00, 0x00, + 0x00, 0x00, 0xcc, 0xcc, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x0c, 0x18, 0x30, 0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x10, 0x38, 0x6c, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xcc, 0xcc, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x60, 0x30, 0x18, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x38, 0x6c, 0x38, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x3c, 0x66, 0x60, 0x60, 0x66, 0x3c, 0x0c, 0x06, 0x3c, 0x00, 0x00, 0x00, + 0x00, 0x10, 0x38, 0x6c, 0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xc6, 0xc6, 0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x60, 0x30, 0x18, 0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x66, 0x66, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x18, 0x3c, 0x66, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x60, 0x30, 0x18, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xc6, 0xc6, 0x10, 0x38, 0x6c, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00, + 0x38, 0x6c, 0x38, 0x00, 0x38, 0x6c, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00, + 0x18, 0x30, 0x60, 0x00, 0xfe, 0x66, 0x60, 0x7c, 0x60, 0x60, 0x66, 0xfe, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0x76, 0x36, 0x7e, 0xd8, 0xd8, 0x6e, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x3e, 0x6c, 0xcc, 0xcc, 0xfe, 0xcc, 0xcc, 0xcc, 0xcc, 0xce, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x10, 0x38, 0x6c, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xc6, 0xc6, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x60, 0x30, 0x18, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x30, 0x78, 0xcc, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x60, 0x30, 0x18, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xc6, 0xc6, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7e, 0x06, 0x0c, 0x78, 0x00, + 0x00, 0xc6, 0xc6, 0x00, 0x38, 0x6c, 0xc6, 0xc6, 0xc6, 0xc6, 0x6c, 0x38, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xc6, 0xc6, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x18, 0x18, 0x3c, 0x66, 0x60, 0x60, 0x60, 0x66, 0x3c, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x38, 0x6c, 0x64, 0x60, 0xf0, 0x60, 0x60, 0x60, 0x60, 0xe6, 0xfc, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x66, 0x66, 0x3c, 0x18, 0x7e, 0x18, 0x7e, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xf8, 0xcc, 0xcc, 0xf8, 0xc4, 0xcc, 0xde, 0xcc, 0xcc, 0xcc, 0xc6, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x0e, 0x1b, 0x18, 0x18, 0x18, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x18, 0xd8, 0x70, 0x00, 0x00, + 0x00, 0x18, 0x30, 0x60, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x0c, 0x18, 0x30, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x18, 0x30, 0x60, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x18, 0x30, 0x60, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x76, 0xdc, 0x00, 0xdc, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, + 0x76, 0xdc, 0x00, 0xc6, 0xe6, 0xf6, 0xfe, 0xde, 0xce, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x3c, 0x6c, 0x6c, 0x3e, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x38, 0x6c, 0x6c, 0x38, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x30, 0x30, 0x00, 0x30, 0x30, 0x60, 0xc0, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xc0, 0xc0, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x06, 0x06, 0x06, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xc0, 0xc0, 0xc2, 0xc6, 0xcc, 0x18, 0x30, 0x60, 0xce, 0x93, 0x06, 0x0c, 0x1f, 0x00, 0x00, + 0x00, 0xc0, 0xc0, 0xc2, 0xc6, 0xcc, 0x18, 0x30, 0x66, 0xce, 0x9a, 0x3f, 0x06, 0x0f, 0x00, 0x00, + 0x00, 0x00, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x3c, 0x3c, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x33, 0x66, 0xcc, 0x66, 0x33, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0x66, 0x33, 0x66, 0xcc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, + 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, + 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, + 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, + 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xf8, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, + 0x18, 0x18, 0x18, 0x18, 0x18, 0xf8, 0x18, 0xf8, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, + 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xf6, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x18, 0xf8, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, + 0x36, 0x36, 0x36, 0x36, 0x36, 0xf6, 0x06, 0xf6, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, + 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x06, 0xf6, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, + 0x36, 0x36, 0x36, 0x36, 0x36, 0xf6, 0x06, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x18, 0x18, 0x18, 0x18, 0x18, 0xf8, 0x18, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, + 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, + 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1f, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xff, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, + 0x18, 0x18, 0x18, 0x18, 0x18, 0x1f, 0x18, 0x1f, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, + 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x37, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, + 0x36, 0x36, 0x36, 0x36, 0x36, 0x37, 0x30, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x30, 0x37, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, + 0x36, 0x36, 0x36, 0x36, 0x36, 0xf7, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xf7, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, + 0x36, 0x36, 0x36, 0x36, 0x36, 0x37, 0x30, 0x37, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x36, 0x36, 0x36, 0x36, 0x36, 0xf7, 0x00, 0xf7, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, + 0x18, 0x18, 0x18, 0x18, 0x18, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, + 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x18, 0x18, 0x18, 0x18, 0x18, 0x1f, 0x18, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x18, 0x1f, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, + 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xff, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, + 0x18, 0x18, 0x18, 0x18, 0x18, 0xff, 0x18, 0xff, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, + 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, + 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xdc, 0xd8, 0xd8, 0xd8, 0xdc, 0x76, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xc6, 0xfc, 0xc6, 0xc6, 0xfc, 0xc0, 0xc0, 0xc0, 0x00, 0x00, + 0x00, 0x00, 0xfe, 0xc6, 0xc6, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x80, 0xfe, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xfe, 0xc6, 0x60, 0x30, 0x18, 0x30, 0x60, 0xc6, 0xfe, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0xd8, 0xd8, 0xd8, 0xd8, 0xd8, 0x70, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x7c, 0x60, 0x60, 0xc0, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x76, 0xdc, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x7e, 0x18, 0x3c, 0x66, 0x66, 0x66, 0x3c, 0x18, 0x7e, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x38, 0x6c, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0x6c, 0x38, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x38, 0x6c, 0xc6, 0xc6, 0xc6, 0x6c, 0x6c, 0x6c, 0x6c, 0xee, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x1e, 0x30, 0x18, 0x0c, 0x3e, 0x66, 0x66, 0x66, 0x66, 0x3c, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0xdb, 0xdb, 0xdb, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x03, 0x06, 0x7e, 0xcf, 0xdb, 0xf3, 0x7e, 0x60, 0xc0, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x1c, 0x30, 0x60, 0x60, 0x7c, 0x60, 0x60, 0x60, 0x30, 0x1c, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x7e, 0x18, 0x18, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x30, 0x18, 0x0c, 0x06, 0x0c, 0x18, 0x30, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x0c, 0x18, 0x30, 0x60, 0x30, 0x18, 0x0c, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x0e, 0x1b, 0x1b, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, + 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xd8, 0xd8, 0xd8, 0x70, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x7e, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xdc, 0x00, 0x76, 0xdc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x38, 0x6c, 0x6c, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x0f, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0xec, 0x6c, 0x6c, 0x3c, 0x1c, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xd8, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x70, 0x98, 0x30, 0x60, 0xc8, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +}; + +static const uint8_t vs_debugfont_hlsl[418] = +{ + 0x01,0x00,0x0f,'u', '_', 'm', 'o', 'd', + 'e', 'l', 'V', 'i', 'e', 'w', 'P', 'r', + 'o', 'j', 0x09,0x01,0x00,0x00,0x04,0x00, + 0x88,0x01,0x00,0x03,0xfe,0xff,0xfe,0xff, + '#', 0x00,'C', 'T', 'A', 'B', 0x1c,0x00, + 0x00,0x00,'W', 0x00,0x00,0x00,0x00,0x03, + 0xfe,0xff,0x01,0x00,0x00,0x00,0x1c,0x00, + 0x00,0x00,0x00,0x81,0x00,0x00,'P', 0x00, + 0x00,0x00,'0', 0x00,0x00,0x00,0x02,0x00, + 0x00,0x00,0x04,0x00,0x00,0x00,'@', 0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,'u', '_', + 'm', 'o', 'd', 'e', 'l', 'V', 'i', 'e', + 'w', 'P', 'r', 'o', 'j', 0x00,0x03,0x00, + 0x03,0x00,0x04,0x00,0x04,0x00,0x01,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,'v', 's', + '_', '3', '_', '0', 0x00,'M', 'i', 'c', + 'r', 'o', 's', 'o', 'f', 't', ' ', '(', + 'R', ')', ' ', 'H', 'L', 'S', 'L', ' ', + 'S', 'h', 'a', 'd', 'e', 'r', ' ', 'C', + 'o', 'm', 'p', 'i', 'l', 'e', 'r', ' ', + '9', '.', '2', '9', '.', '9', '5', '2', + '.', '3', '1', '1', '1', 0x00,'Q', 0x00, + 0x00,0x05,0x04,0x00,0x0f,0xa0,0x81,0x80, + 0x80,';', 0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x1f,0x00, + 0x00,0x02,0x00,0x00,0x00,0x80,0x00,0x00, + 0x0f,0x90,0x1f,0x00,0x00,0x02,0x0a,0x00, + 0x00,0x80,0x01,0x00,0x0f,0x90,0x1f,0x00, + 0x00,0x02,0x0a,0x00,0x01,0x80,0x02,0x00, + 0x0f,0x90,0x1f,0x00,0x00,0x02,0x05,0x00, + 0x00,0x80,0x03,0x00,0x0f,0x90,0x1f,0x00, + 0x00,0x02,0x00,0x00,0x00,0x80,0x00,0x00, + 0x0f,0xe0,0x1f,0x00,0x00,0x02,0x0a,0x00, + 0x00,0x80,0x01,0x00,0x0f,0xe0,0x1f,0x00, + 0x00,0x02,0x0a,0x00,0x01,0x80,0x02,0x00, + 0x0f,0xe0,0x1f,0x00,0x00,0x02,0x05,0x00, + 0x00,0x80,0x03,0x00,0x03,0xe0,0x05,0x00, + 0x00,0x03,0x00,0x00,0x0f,0x80,0x01,0x00, + 0xe4,0xa0,0x00,0x00,'U', 0x90,0x04,0x00, + 0x00,0x04,0x00,0x00,0x0f,0x80,0x00,0x00, + 0xe4,0xa0,0x00,0x00,0x00,0x90,0x00,0x00, + 0xe4,0x80,0x04,0x00,0x00,0x04,0x00,0x00, + 0x0f,0x80,0x02,0x00,0xe4,0xa0,0x00,0x00, + 0xaa,0x90,0x00,0x00,0xe4,0x80,0x04,0x00, + 0x00,0x04,0x00,0x00,0x0f,0xe0,0x03,0x00, + 0xe4,0xa0,0x00,0x00,0xff,0x90,0x00,0x00, + 0xe4,0x80,0x05,0x00,0x00,0x03,0x01,0x00, + 0x0f,0xe0,0x04,0x00,0x00,0xa0,0x01,0x00, + 0xe4,0x90,0x05,0x00,0x00,0x03,0x02,0x00, + 0x0f,0xe0,0x04,0x00,0x00,0xa0,0x02,0x00, + 0xe4,0x90,0x01,0x00,0x00,0x02,0x03,0x00, + 0x03,0xe0,0x03,0x00,0xe4,0x90,0xff,0xff, + 0x00,0x00 +}; + +static const uint8_t fs_debugfont_hlsl[344] = +{ + 0x00,0x00,'T', 0x01,0x00,0x03,0xff,0xff, + 0xfe,0xff,'"', 0x00,'C', 'T', 'A', 'B', + 0x1c,0x00,0x00,0x00,'S', 0x00,0x00,0x00, + 0x00,0x03,0xff,0xff,0x01,0x00,0x00,0x00, + 0x1c,0x00,0x00,0x00,0x00,0x81,0x00,0x00, + 'L', 0x00,0x00,0x00,'0', 0x00,0x00,0x00, + 0x03,0x00,0x00,0x00,0x01,0x00,0x02,0x00, + '<', 0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 'u', '_', 't', 'e', 'x', 'C', 'o', 'l', + 'o', 'r', 0x00,0xab,0x04,0x00,0x0c,0x00, + 0x01,0x00,0x01,0x00,0x01,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,'p', 's', '_', '3', + '_', '0', 0x00,'M', 'i', 'c', 'r', 'o', + 's', 'o', 'f', 't', ' ', '(', 'R', ')', + ' ', 'H', 'L', 'S', 'L', ' ', 'S', 'h', + 'a', 'd', 'e', 'r', ' ', 'C', 'o', 'm', + 'p', 'i', 'l', 'e', 'r', ' ', '9', '.', + '2', '9', '.', '9', '5', '2', '.', '3', + '1', '1', '1', 0x00,'Q', 0x00,0x00,0x05, + 0x00,0x00,0x0f,0xa0,0x81,0x80,0x80,0xbb, + 0x00,0x00,0x00,0x80,0x00,0x00,0x80,0xbf, + 0x00,0x00,0x00,0x00,0x1f,0x00,0x00,0x02, + 0x0a,0x00,0x00,0x80,0x00,0x00,0x0f,0x90, + 0x1f,0x00,0x00,0x02,0x0a,0x00,0x01,0x80, + 0x01,0x00,0x0f,0x90,0x1f,0x00,0x00,0x02, + 0x05,0x00,0x00,0x80,0x02,0x00,0x03,0x90, + 0x1f,0x00,0x00,0x02,0x00,0x00,0x00,0x90, + 0x00,0x08,0x0f,0xa0,'B', 0x00,0x00,0x03, + 0x00,0x00,0x0f,0x80,0x02,0x00,0xe4,0x90, + 0x00,0x08,0xe4,0xa0,0x01,0x00,0x00,0x02, + 0x01,0x00,0x0f,0x80,0x01,0x00,0xe4,0x90, + 0x02,0x00,0x00,0x03,0x01,0x00,0x0f,0x80, + 0x01,0x00,0xe4,0x81,0x00,0x00,0xe4,0x90, + 0x04,0x00,0x00,0x04,0x00,0x00,0x0f,0x80, + 0x00,0x00,0x00,0x80,0x01,0x00,0xe4,0x80, + 0x01,0x00,0xe4,0x90,0x02,0x00,0x00,0x03, + 0x01,0x00,0x01,0x80,0x00,0x00,0xff,0x80, + 0x00,0x00,0x00,0xa0,'X', 0x00,0x00,0x04, + 0x01,0x00,0x0f,0x80,0x01,0x00,0x00,0x80, + 0x00,0x00,'U', 0xa0,0x00,0x00,0xaa,0xa0, + 'A', 0x00,0x00,0x01,0x01,0x00,0x0f,0x80, + 0x01,0x00,0x00,0x02,0x00,0x08,0x0f,0x80, + 0x00,0x00,0xe4,0x80,0xff,0xff,0x00,0x00 +}; + +static const uint8_t vs_debugfont_glsl[462] = +{ + 'p', 'r', 'e', 'c', 'i', 's', 'i', 'o', + 'n', ' ', 'h', 'i', 'g', 'h', 'p', ' ', + 'f', 'l', 'o', 'a', 't', ';', 0x0a,0x0a, + 'u', 'n', 'i', 'f', 'o', 'r', 'm', ' ', + 'm', 'a', 't', '4', ' ', 'u', '_', 'm', + 'o', 'd', 'e', 'l', 'V', 'i', 'e', 'w', + 'P', 'r', 'o', 'j', ';', 0x0a,'v', 'a', + 'r', 'y', 'i', 'n', 'g', ' ', 'v', 'e', + 'c', '4', ' ', 'v', '_', 'c', 'o', 'l', + 'o', 'r', '1', ';', 0x0a,'v', 'a', 'r', + 'y', 'i', 'n', 'g', ' ', 'v', 'e', 'c', + '4', ' ', 'v', '_', 'c', 'o', 'l', 'o', + 'r', ';', 0x0a,'v', 'a', 'r', 'y', 'i', + 'n', 'g', ' ', 'v', 'e', 'c', '2', ' ', + 'v', '_', 't', 'e', 'x', 'c', 'o', 'o', + 'r', 'd', '0', ';', 0x0a,'a', 't', 't', + 'r', 'i', 'b', 'u', 't', 'e', ' ', 'v', + 'e', 'c', '2', ' ', 'a', '_', 't', 'e', + 'x', 'c', 'o', 'o', 'r', 'd', '0', ';', + 0x0a,'a', 't', 't', 'r', 'i', 'b', 'u', + 't', 'e', ' ', 'v', 'e', 'c', '4', ' ', + 'a', '_', 'c', 'o', 'l', 'o', 'r', '1', + ';', 0x0a,'a', 't', 't', 'r', 'i', 'b', + 'u', 't', 'e', ' ', 'v', 'e', 'c', '4', + ' ', 'a', '_', 'c', 'o', 'l', 'o', 'r', + ';', 0x0a,'a', 't', 't', 'r', 'i', 'b', + 'u', 't', 'e', ' ', 'v', 'e', 'c', '3', + ' ', 'a', '_', 'p', 'o', 's', 'i', 't', + 'i', 'o', 'n', ';', 0x0a,'v', 'o', 'i', + 'd', ' ', 'm', 'a', 'i', 'n', ' ', '(', + ')', 0x0a,'{', 0x0a,' ', ' ', 'v', 'e', + 'c', '4', ' ', 't', 'm', 'p', 'v', 'a', + 'r', '_', '1', ';', 0x0a,' ', ' ', 't', + 'm', 'p', 'v', 'a', 'r', '_', '1', '.', + 'w', ' ', '=', ' ', '1', '.', '0', ';', + 0x0a,' ', ' ', 't', 'm', 'p', 'v', 'a', + 'r', '_', '1', '.', 'x', 'y', 'z', ' ', + '=', ' ', 'a', '_', 'p', 'o', 's', 'i', + 't', 'i', 'o', 'n', ';', 0x0a,' ', ' ', + 'g', 'l', '_', 'P', 'o', 's', 'i', 't', + 'i', 'o', 'n', ' ', '=', ' ', '(', 'u', + '_', 'm', 'o', 'd', 'e', 'l', 'V', 'i', + 'e', 'w', 'P', 'r', 'o', 'j', ' ', '*', + ' ', 't', 'm', 'p', 'v', 'a', 'r', '_', + '1', ')', ';', 0x0a,' ', ' ', 'v', '_', + 't', 'e', 'x', 'c', 'o', 'o', 'r', 'd', + '0', ' ', '=', ' ', 'a', '_', 't', 'e', + 'x', 'c', 'o', 'o', 'r', 'd', '0', ';', + 0x0a,' ', ' ', 'v', '_', 'c', 'o', 'l', + 'o', 'r', ' ', '=', ' ', '(', 'a', '_', + 'c', 'o', 'l', 'o', 'r', ' ', '*', ' ', + '0', '.', '0', '0', '3', '9', '2', '1', + '5', '7', ')', ';', 0x0a,' ', ' ', 'v', + '_', 'c', 'o', 'l', 'o', 'r', '1', ' ', + '=', ' ', '(', 'a', '_', 'c', 'o', 'l', + 'o', 'r', '1', ' ', '*', ' ', '0', '.', + '0', '0', '3', '9', '2', '1', '5', '7', + ')', ';', 0x0a,'}', 0x0a,0x0a +}; + +static const uint8_t fs_debugfont_glsl[320] = +{ + 'p', 'r', 'e', 'c', 'i', 's', 'i', 'o', + 'n', ' ', 'h', 'i', 'g', 'h', 'p', ' ', + 'f', 'l', 'o', 'a', 't', ';', 0x0a,0x0a, + 'u', 'n', 'i', 'f', 'o', 'r', 'm', ' ', + 's', 'a', 'm', 'p', 'l', 'e', 'r', '2', + 'D', ' ', 'u', '_', 't', 'e', 'x', 'C', + 'o', 'l', 'o', 'r', ';', 0x0a,'v', 'a', + 'r', 'y', 'i', 'n', 'g', ' ', 'v', 'e', + 'c', '4', ' ', 'v', '_', 'c', 'o', 'l', + 'o', 'r', '1', ';', 0x0a,'v', 'a', 'r', + 'y', 'i', 'n', 'g', ' ', 'v', 'e', 'c', + '4', ' ', 'v', '_', 'c', 'o', 'l', 'o', + 'r', ';', 0x0a,'v', 'a', 'r', 'y', 'i', + 'n', 'g', ' ', 'v', 'e', 'c', '2', ' ', + 'v', '_', 't', 'e', 'x', 'c', 'o', 'o', + 'r', 'd', '0', ';', 0x0a,'v', 'o', 'i', + 'd', ' ', 'm', 'a', 'i', 'n', ' ', '(', + ')', 0x0a,'{', 0x0a,' ', ' ', 'v', 'e', + 'c', '4', ' ', 't', 'm', 'p', 'v', 'a', + 'r', '_', '1', ';', 0x0a,' ', ' ', 't', + 'm', 'p', 'v', 'a', 'r', '_', '1', ' ', + '=', ' ', 'm', 'i', 'x', ' ', '(', 'v', + '_', 'c', 'o', 'l', 'o', 'r', '1', ',', + ' ', 'v', '_', 'c', 'o', 'l', 'o', 'r', + ',', ' ', 't', 'e', 'x', 't', 'u', 'r', + 'e', '2', 'D', ' ', '(', 'u', '_', 't', + 'e', 'x', 'C', 'o', 'l', 'o', 'r', ',', + ' ', 'v', '_', 't', 'e', 'x', 'c', 'o', + 'o', 'r', 'd', '0', ')', '.', 'x', 'x', + 'x', 'x', ')', ';', 0x0a,' ', ' ', 'i', + 'f', ' ', '(', '(', 't', 'm', 'p', 'v', + 'a', 'r', '_', '1', '.', 'w', ' ', '<', + ' ', '0', '.', '0', '0', '3', '9', '2', + '1', '5', '7', ')', ')', ' ', '{', 0x0a, + ' ', ' ', ' ', ' ', 'd', 'i', 's', 'c', + 'a', 'r', 'd', ';', 0x0a,' ', ' ', '}', + ';', 0x0a,' ', ' ', 'g', 'l', '_', 'F', + 'r', 'a', 'g', 'C', 'o', 'l', 'o', 'r', + ' ', '=', ' ', 't', 'm', 'p', 'v', 'a', + 'r', '_', '1', ';', 0x0a,'}', 0x0a,0x0a +}; diff --git a/src/dds.cpp b/src/dds.cpp new file mode 100644 index 000000000..9a56ab02d --- /dev/null +++ b/src/dds.cpp @@ -0,0 +1,489 @@ +/* + * Copyright 2011-2012 Branimir Karadzic. All rights reserved. + * License: http://www.opensource.org/licenses/BSD-2-Clause + */ + +#include "bgfx_p.h" +#include "dds.h" + +namespace bgfx +{ + +#define DDS_MAGIC MAKEFOURCC('D','D','S',' ') +#define DDS_HEADER_SIZE 124 +#define DDS_IMAGE_DATA_OFFSET (DDS_HEADER_SIZE + 4) + +#define DDS_DXT1 MAKEFOURCC('D', 'X', 'T', '1') +#define DDS_DXT2 MAKEFOURCC('D', 'X', 'T', '2') +#define DDS_DXT3 MAKEFOURCC('D', 'X', 'T', '3') +#define DDS_DXT4 MAKEFOURCC('D', 'X', 'T', '4') +#define DDS_DXT5 MAKEFOURCC('D', 'X', 'T', '5') + +#define DDSD_CAPS 0x00000001 +#define DDSD_HEIGHT 0x00000002 +#define DDSD_WIDTH 0x00000004 +#define DDSD_PITCH 0x00000008 +#define DDSD_PIXELFORMAT 0x00001000 +#define DDSD_MIPMAPCOUNT 0x00020000 +#define DDSD_LINEARSIZE 0x00080000 +#define DDSD_DEPTH 0x00800000 + +#define DDPF_ALPHAPIXELS 0x00000001 +#define DDPF_ALPHA 0x00000002 +#define DDPF_FOURCC 0x00000004 +#define DDPF_INDEXED 0x00000020 +#define DDPF_RGB 0x00000040 +#define DDPF_YUV 0x00000200 +#define DDPF_LUMINANCE 0x00020000 + +#define DDSCAPS_COMPLEX 0x00000008 +#define DDSCAPS_TEXTURE 0x00001000 +#define DDSCAPS_MIPMAP 0x00400000 + +#define DDSCAPS2_CUBEMAP 0x00000200 +#define DDSCAPS2_CUBEMAP_POSITIVEX 0x00000400 +#define DDSCAPS2_CUBEMAP_NEGATIVEX 0x00000800 +#define DDSCAPS2_CUBEMAP_POSITIVEY 0x00001000 +#define DDSCAPS2_CUBEMAP_NEGATIVEY 0x00002000 +#define DDSCAPS2_CUBEMAP_POSITIVEZ 0x00004000 +#define DDSCAPS2_CUBEMAP_NEGATIVEZ 0x00008000 +#define DDSCAPS2_VOLUME 0x00200000 + +bool isDds(const Memory* _mem) +{ + StreamRead stream(_mem->data, _mem->size); + + uint32_t magic; + stream.read(magic); + + return DDS_MAGIC == magic; +} + +uint32_t bitRangeConvert(uint32_t _in, uint32_t _from, uint32_t _to) +{ + uint32_t tmp0 = uint32_sll(1, _to); + uint32_t tmp1 = uint32_sll(1, _from); + uint32_t tmp2 = uint32_dec(tmp0); + uint32_t tmp3 = uint32_dec(tmp1); + uint32_t tmp4 = uint32_mul(_in, tmp2); + uint32_t tmp5 = uint32_add(tmp3, tmp4); + uint32_t tmp6 = uint32_srl(tmp5, _from); + uint32_t tmp7 = uint32_add(tmp5, tmp6); + uint32_t result = uint32_srl(tmp7, _from); + + return result; +} + +void decodeBlockDxt(uint8_t _dst[16*4], const uint8_t _src[8]) +{ + uint8_t colors[4*3]; + + uint32_t c0 = _src[0] | (_src[1] << 8); + colors[0] = bitRangeConvert( (c0>> 0)&0x1f, 5, 8); + colors[1] = bitRangeConvert( (c0>> 5)&0x3f, 6, 8); + colors[2] = bitRangeConvert( (c0>>11)&0x1f, 5, 8); + + uint32_t c1 = _src[2] | (_src[3] << 8); + colors[3] = bitRangeConvert( (c1>> 0)&0x1f, 5, 8); + colors[4] = bitRangeConvert( (c1>> 5)&0x3f, 6, 8); + colors[5] = bitRangeConvert( (c1>>11)&0x1f, 5, 8); + + colors[6] = (2*colors[0] + colors[3]) / 3; + colors[7] = (2*colors[1] + colors[4]) / 3; + colors[8] = (2*colors[2] + colors[5]) / 3; + + colors[ 9] = (colors[0] + 2*colors[3]) / 3; + colors[10] = (colors[1] + 2*colors[4]) / 3; + colors[11] = (colors[2] + 2*colors[5]) / 3; + + for (uint32_t ii = 0, next = 8*4; ii < 16*4; ii += 4, next += 2) + { + int idx = ( (_src[next>>3] >> (next & 7)) & 3) * 3; + _dst[ii+0] = colors[idx+0]; + _dst[ii+1] = colors[idx+1]; + _dst[ii+2] = colors[idx+2]; + } +} + +void decodeBlockDxt1(uint8_t _dst[16*4], const uint8_t _src[8]) +{ + uint8_t colors[4*4]; + + uint32_t c0 = _src[0] | (_src[1] << 8); + colors[0] = bitRangeConvert( (c0>> 0)&0x1f, 5, 8); + colors[1] = bitRangeConvert( (c0>> 5)&0x3f, 6, 8); + colors[2] = bitRangeConvert( (c0>>11)&0x1f, 5, 8); + colors[3] = 255; + + uint32_t c1 = _src[2] | (_src[3] << 8); + colors[4] = bitRangeConvert( (c1>> 0)&0x1f, 5, 8); + colors[5] = bitRangeConvert( (c1>> 5)&0x3f, 6, 8); + colors[6] = bitRangeConvert( (c1>>11)&0x1f, 5, 8); + colors[7] = 255; + + if (c0 > c1) + { + colors[ 8] = (2*colors[0] + colors[4]) / 3; + colors[ 9] = (2*colors[1] + colors[5]) / 3; + colors[10] = (2*colors[2] + colors[6]) / 3; + colors[11] = 255; + + colors[12] = (colors[0] + 2*colors[4]) / 3; + colors[13] = (colors[1] + 2*colors[5]) / 3; + colors[14] = (colors[2] + 2*colors[6]) / 3; + colors[15] = 255; + } + else + { + colors[ 8] = (colors[0] + colors[4]) / 2; + colors[ 9] = (colors[1] + colors[5]) / 2; + colors[10] = (colors[2] + colors[6]) / 2; + colors[11] = 255; + + colors[12] = 0; + colors[13] = 0; + colors[14] = 0; + colors[15] = 0; + } + + for (uint32_t ii = 0, next = 8*4; ii < 16*4; ii += 4, next += 2) + { + int idx = ( (_src[next>>3] >> (next & 7)) & 3) * 4; + _dst[ii+0] = colors[idx+0]; + _dst[ii+1] = colors[idx+1]; + _dst[ii+2] = colors[idx+2]; + _dst[ii+3] = colors[idx+3]; + } +} + +void decodeBlockDxt23A(uint8_t _dst[16*4], const uint8_t _src[8]) +{ + for (uint32_t ii = 3, next = 0; ii < 16*4; ii += 4, next += 4) + { + uint32_t c0 = (_src[next>>3] >> (next&7) ) & 0xf; + _dst[ii] = bitRangeConvert(c0, 4, 8); + } +} + +void decodeBlockDxt45A(uint8_t _dst[16*4], const uint8_t _src[8]) +{ + uint8_t alpha[8]; + alpha[0] = _src[0]; + alpha[1] = _src[1]; + + if (alpha[0] > alpha[1]) + { + alpha[2] = (6*alpha[0] + 1*alpha[1]) / 7; + alpha[3] = (5*alpha[0] + 2*alpha[1]) / 7; + alpha[4] = (4*alpha[0] + 3*alpha[1]) / 7; + alpha[5] = (3*alpha[0] + 4*alpha[1]) / 7; + alpha[6] = (2*alpha[0] + 5*alpha[1]) / 7; + alpha[7] = (1*alpha[0] + 6*alpha[1]) / 7; + } + else + { + alpha[2] = (4*alpha[0] + 1*alpha[1]) / 5; + alpha[3] = (3*alpha[0] + 2*alpha[1]) / 5; + alpha[4] = (2*alpha[0] + 3*alpha[1]) / 5; + alpha[5] = (1*alpha[0] + 4*alpha[1]) / 5; + alpha[6] = 0; + alpha[7] = 255; + } + + for (uint32_t ii = 3, next = 8*2; ii < 16*4; ii += 4, ++next) + { + uint32_t bit = (_src[next>>3] >> (next&7) ) & 1; + uint32_t idx = bit; + ++next; + + bit = (_src[next>>3] >> (next&7) ) & 1; + idx += bit << 1; + ++next; + + bit = (_src[next>>3] >> (next&7) ) & 1; + idx += bit << 2; + + _dst[ii] = alpha[idx & 7]; + } +} + +uint32_t Mip::getDecodedSize() const +{ + return m_width*m_height*4; +} + +void Mip::decode(uint8_t* _dst) +{ + const uint8_t* src = m_data; + + if (0 != m_type) + { + uint32_t width = m_width/4; + uint32_t height = m_height/4; + uint32_t pitch = m_width*4; + + uint8_t temp[16*4]; + + switch (m_type) + { + case 1: + for (uint32_t yy = 0; yy < height; ++yy) + { + for (uint32_t xx = 0; xx < width; ++xx) + { + decodeBlockDxt1(temp, src); + src += 8; + + uint8_t* dst = &_dst[(yy*pitch+xx*4)*4]; + memcpy(dst, temp, 16); + memcpy(&dst[pitch], &temp[16], 16); + memcpy(&dst[2*pitch], &temp[32], 16); + memcpy(&dst[3*pitch], &temp[48], 16); + } + } + break; + + case 2: + for (uint32_t yy = 0; yy < height; ++yy) + { + for (uint32_t xx = 0; xx < width; ++xx) + { + decodeBlockDxt23A(temp, src); + src += 8; + decodeBlockDxt(temp, src); + src += 8; + + uint8_t* dst = &_dst[(yy*pitch+xx*4)*4]; + memcpy(dst, temp, 16); + memcpy(&dst[pitch], &temp[16], 16); + memcpy(&dst[2*pitch], &temp[32], 16); + memcpy(&dst[3*pitch], &temp[48], 16); + } + } + break; + + case 3: + for (uint32_t yy = 0; yy < height; ++yy) + { + for (uint32_t xx = 0; xx < width; ++xx) + { + decodeBlockDxt45A(temp, src); + src += 8; + decodeBlockDxt(temp, src); + src += 8; + + uint8_t* dst = &_dst[(yy*pitch+xx*4)*4]; + memcpy(dst, temp, 16); + memcpy(&dst[pitch], &temp[16], 16); + memcpy(&dst[2*pitch], &temp[32], 16); + memcpy(&dst[3*pitch], &temp[48], 16); + } + } + break; + } + } + else + { + uint32_t width = m_width; + uint32_t height = m_height; + uint32_t pitch = m_width*4; + + if (m_hasAlpha) + { + for (uint32_t yy = 0; yy < height; ++yy) + { + uint8_t* dst = &_dst[yy*pitch]; + + for (uint32_t xx = 0; xx < width; ++xx) + { + memcpy(dst, src, 4); + dst += 4; + src += 4; + } + } + } + else + { + for (uint32_t yy = 0; yy < height; ++yy) + { + uint8_t* dst = &_dst[yy*pitch]; + + for (uint32_t xx = 0; xx < width; ++xx) + { + memcpy(dst, src, 3); + dst[3] = 255; + dst += 4; + src += 3; + } + } + } + } +} + +bool parseDds(Dds& _dds, const Memory* _mem) +{ + StreamRead stream(_mem->data, _mem->size); + + uint32_t magic; + stream.read(magic); + + if (DDS_MAGIC != magic) + { + return false; + } + + uint32_t headerSize; + stream.read(headerSize); + + if (headerSize < DDS_HEADER_SIZE) + { + return false; + } + + uint32_t flags; + stream.read(flags); + + if ( (flags & (DDSD_CAPS|DDSD_HEIGHT|DDSD_WIDTH|DDSD_PIXELFORMAT) ) != (DDSD_CAPS|DDSD_HEIGHT|DDSD_WIDTH|DDSD_PIXELFORMAT) ) + { + return false; + } + + uint32_t height; + stream.read(height); + + uint32_t width; + stream.read(width); + + uint32_t pitch; + stream.read(pitch); + + uint32_t depth; + stream.read(depth); + + uint32_t mips; + stream.read(mips); + + stream.skip(44); // reserved + + stream.skip(4); // pixel format size + + uint32_t pixelFlags; + stream.read(pixelFlags); + + uint32_t fourcc; + stream.read(fourcc); + + uint32_t rgbCount; + stream.read(rgbCount); + + uint32_t rbitmask; + stream.read(rbitmask); + + uint32_t gbitmask; + stream.read(gbitmask); + + uint32_t bbitmask; + stream.read(bbitmask); + + uint32_t abitmask; + stream.read(abitmask); + + uint32_t caps[4]; + stream.read(caps); + + if ( (caps[0] & DDSCAPS_TEXTURE) == 0) + { + return false; + } + + stream.skip(4); // reserved + + uint8_t blockSize = 1; + uint8_t type = 0; + bool hasAlpha = pixelFlags & DDPF_ALPHAPIXELS; + + if (pixelFlags & DDPF_FOURCC) + { + switch (fourcc) + { + case DDS_DXT1: + type = 1; + blockSize = 8; + break; + + case DDS_DXT2: + case DDS_DXT3: + type = 2; + blockSize = 16; + break; + + case DDS_DXT4: + case DDS_DXT5: + type = 3; + blockSize = 16; + break; + } + } + else + { + blockSize *= hasAlpha ? 4 : 3; + } + + _dds.m_width = width; + _dds.m_height = height; + _dds.m_depth = depth; + _dds.m_blockSize = blockSize; + _dds.m_numMips = (caps[0] & DDSCAPS_MIPMAP) ? mips : 1; + _dds.m_type = type; + _dds.m_hasAlpha = hasAlpha; + + return true; +} + +bool getRawImageData(const Dds& _dds, uint8_t _index, const Memory* _mem, Mip& _mip) +{ + uint32_t width = _dds.m_width; + uint32_t height = _dds.m_height; + uint32_t blockSize = _dds.m_blockSize; + uint32_t offset = DDS_IMAGE_DATA_OFFSET; + uint8_t type = _dds.m_type; + bool hasAlpha = _dds.m_hasAlpha; + + for (uint8_t ii = 0, num = _dds.m_numMips; ii < num; ++ii) + { + width = uint32_max(1, width); + height = uint32_max(1, height); + + uint32_t size = width*height*blockSize; + if (0 != type) + { + width = uint32_max(1, (width + 3)>>2); + height = uint32_max(1, (height + 3)>>2); + size = width*height*blockSize; + + width <<= 2; + height <<= 2; + } + + if (ii == _index) + { + _mip.m_width = width; + _mip.m_height = height; + _mip.m_blockSize = blockSize; + _mip.m_size = size; + _mip.m_data = _mem->data + offset; + _mip.m_type = type; + _mip.m_hasAlpha = hasAlpha; + return true; + } + + offset += size; + + width >>= 1; + height >>= 1; + } + + return false; +} + +} // namespace bgfx diff --git a/src/dds.h b/src/dds.h new file mode 100644 index 000000000..eed8e6dfb --- /dev/null +++ b/src/dds.h @@ -0,0 +1,44 @@ +/* + * Copyright 2011-2012 Branimir Karadzic. All rights reserved. + * License: http://www.opensource.org/licenses/BSD-2-Clause + */ + +#ifndef __DDS_H__ +#define __DDS_H__ + +#include + +namespace bgfx +{ + struct Dds + { + uint32_t m_width; + uint32_t m_height; + uint32_t m_depth; + uint8_t m_blockSize; + uint8_t m_numMips; + uint8_t m_type; + bool m_hasAlpha; + }; + + struct Mip + { + uint32_t m_width; + uint32_t m_height; + uint32_t m_blockSize; + uint32_t m_size; + uint8_t m_type; + bool m_hasAlpha; + const uint8_t* m_data; + + uint32_t getDecodedSize() const; + void decode(uint8_t* _dst); + }; + + bool isDds(const Memory* _mem); + bool parseDds(Dds& _dds, const Memory* _mem); + bool getRawImageData(const Dds& _dds, uint8_t _index, const Memory* _mem, Mip& _mip); + +} // namespace bgfx + +#endif // __DDS_H__ diff --git a/src/renderer_d3d9.cpp b/src/renderer_d3d9.cpp new file mode 100644 index 000000000..5c76fb3c5 --- /dev/null +++ b/src/renderer_d3d9.cpp @@ -0,0 +1,1865 @@ +/* + * Copyright 2011-2012 Branimir Karadzic. All rights reserved. + * License: http://www.opensource.org/licenses/BSD-2-Clause + */ + +#include "bgfx_p.h" + +#if BGFX_CONFIG_RENDERER_DIRECT3D +# include "renderer_d3d9.h" + +namespace bgfx +{ + static const D3DPRIMITIVETYPE s_primType[] = + { + D3DPT_TRIANGLELIST, + D3DPT_LINELIST, + }; + + static const uint32_t s_primNumVerts[] = + { + 3, + 2, + }; + + static const D3DMULTISAMPLE_TYPE s_msaa[] = + { + D3DMULTISAMPLE_NONE, + D3DMULTISAMPLE_2_SAMPLES, + D3DMULTISAMPLE_4_SAMPLES, + D3DMULTISAMPLE_8_SAMPLES, + D3DMULTISAMPLE_16_SAMPLES, + }; + + static const D3DBLEND s_blendFactor[] = + { + (D3DBLEND)0, // ignored + D3DBLEND_ZERO, + D3DBLEND_ONE, + D3DBLEND_SRCCOLOR, + D3DBLEND_INVSRCCOLOR, + D3DBLEND_SRCALPHA, + D3DBLEND_INVSRCALPHA, + D3DBLEND_DESTALPHA, + D3DBLEND_INVDESTALPHA, + D3DBLEND_DESTCOLOR, + D3DBLEND_INVDESTCOLOR, + D3DBLEND_SRCALPHASAT, + }; + + static const D3DCMPFUNC s_depthFunc[] = + { + (D3DCMPFUNC)0, // ignored + D3DCMP_LESS, + D3DCMP_LESSEQUAL, + D3DCMP_EQUAL, + D3DCMP_GREATEREQUAL, + D3DCMP_GREATER, + D3DCMP_NOTEQUAL, + D3DCMP_NEVER, + D3DCMP_ALWAYS, + }; + + static const D3DCULL s_cullMode[] = + { + D3DCULL_NONE, + D3DCULL_CW, + D3DCULL_CCW, + }; + + static const D3DFORMAT s_colorFormat[] = + { + D3DFMT_UNKNOWN, // ignored + D3DFMT_A8R8G8B8, + D3DFMT_R32F, + }; + + static const D3DFORMAT s_depthFormat[] = + { + D3DFMT_UNKNOWN, // ignored + D3DFMT_D24S8, + }; + + static const D3DTEXTUREADDRESS s_textureAddress[] = + { + D3DTADDRESS_WRAP, + D3DTADDRESS_MIRROR, + D3DTADDRESS_CLAMP, + }; + + static const D3DTEXTUREFILTERTYPE s_textureFilter[] = + { + D3DTEXF_LINEAR, + D3DTEXF_POINT, + D3DTEXF_ANISOTROPIC, + }; + + struct RendererContext + { + RendererContext() + : m_initialized(false) + , m_fmtNULL(false) + , m_fmtDF16(false) + , m_fmtDF24(false) + , m_fmtINTZ(false) + , m_fmtRAWZ(false) + , m_flags(BGFX_RESET_NONE) + { + } + + void init() + { + // http://msdn.microsoft.com/en-us/library/windows/desktop/bb172588%28v=vs.85%29.aspx + memset(&m_params, 0, sizeof(m_params) ); + m_params.BackBufferWidth = BGFX_DEFAULT_WIDTH; + m_params.BackBufferHeight = BGFX_DEFAULT_HEIGHT; + m_params.BackBufferFormat = D3DFMT_X8R8G8B8; + m_params.BackBufferCount = 1; + m_params.MultiSampleType = s_msaa[(m_flags&BGFX_RESET_MSAA_MASK)>>BGFX_RESET_MSAA_SHIFT]; + m_params.MultiSampleQuality = 0; + m_params.EnableAutoDepthStencil = TRUE; + m_params.AutoDepthStencilFormat = D3DFMT_D24S8; + m_params.Flags = D3DPRESENTFLAG_DISCARD_DEPTHSTENCIL; +#if BX_PLATFORM_WINDOWS + m_params.FullScreen_RefreshRateInHz = 0; + m_params.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; + m_params.SwapEffect = D3DSWAPEFFECT_DISCARD; + m_params.hDeviceWindow = bgfxHwnd; + m_params.Windowed = true; + + RECT rect; + GetWindowRect(bgfxHwnd, &rect); + m_params.BackBufferWidth = rect.right-rect.left; + m_params.BackBufferHeight = rect.bottom-rect.top; + + m_d3d9dll = LoadLibrary("d3d9.dll"); + BX_CHECK(m_d3d9dll, "Module d3d9.dll not found."); + + m_D3DPERF_SetMarker = (D3DPERF_SetMarkerFunc)GetProcAddress(m_d3d9dll, "D3DPERF_SetMarker"); + m_D3DPERF_BeginEvent = (D3DPERF_BeginEventFunc)GetProcAddress(m_d3d9dll, "D3DPERF_BeginEvent"); + m_D3DPERF_EndEvent = (D3DPERF_EndEventFunc)GetProcAddress(m_d3d9dll, "D3DPERF_EndEvent"); + +#if BGFX_CONFIG_RENDERER_DIRECT3D_EX + Direct3DCreate9ExFunc direct3DCreate9Ex = (Direct3DCreate9ExFunc)GetProcAddress(m_d3d9dll, "Direct3DCreate9Ex"); + BX_CHECK(direct3DCreate9Ex, "Function Direct3DCreate9Ex not found."); + DX_CHECK(direct3DCreate9Ex(D3D_SDK_VERSION, &m_d3d9) ); +#else + Direct3DCreate9Func direct3DCreate9 = (Direct3DCreate9Func)GetProcAddress(m_d3d9dll, "Direct3DCreate9"); + BX_CHECK(direct3DCreate9, "Function Direct3DCreate9 not found."); + m_d3d9 = direct3DCreate9(D3D_SDK_VERSION); +#endif // defined(D3D_DISABLE_9EX) + + uint32_t behaviorFlags[] = + { + D3DCREATE_HARDWARE_VERTEXPROCESSING|D3DCREATE_PUREDEVICE, + D3DCREATE_MIXED_VERTEXPROCESSING, + D3DCREATE_SOFTWARE_VERTEXPROCESSING, + }; + + for (uint32_t ii = 0; ii < countof(behaviorFlags) && NULL == m_device; ++ii) + { +#if BGFX_CONFIG_RENDERER_DIRECT3D_EX + DX_CHECK(m_d3d9->CreateDeviceEx(D3DADAPTER_DEFAULT + , D3DDEVTYPE_HAL + , bgfxHwnd + , behaviorFlags[ii] + , &m_params + , NULL + , &m_device + ) ); +#else + DX_CHECK(m_d3d9->CreateDevice(D3DADAPTER_DEFAULT + , D3DDEVTYPE_HAL + , bgfxHwnd + , behaviorFlags[ii] + , &m_params + , &m_device + ) ); +#endif // BGFX_CONFIG_RENDERER_DIRECT3D_EX + } + + m_fmtNULL = SUCCEEDED(m_d3d9->CheckDeviceFormat(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_TEXTURE, D3DFMT_NULL) ); + m_fmtDF16 = SUCCEEDED(m_d3d9->CheckDeviceFormat(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_TEXTURE, D3DFMT_DF16) ); + m_fmtDF24 = SUCCEEDED(m_d3d9->CheckDeviceFormat(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_TEXTURE, D3DFMT_DF24) ); + m_fmtINTZ = SUCCEEDED(m_d3d9->CheckDeviceFormat(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_TEXTURE, D3DFMT_INTZ) ); + m_fmtRAWZ = SUCCEEDED(m_d3d9->CheckDeviceFormat(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_TEXTURE, D3DFMT_RAWZ) ); + + m_fmtDepth = D3DFMT_D24S8; + +#elif BX_PLATFORM_XBOX360 + m_params.PresentationInterval = D3DPRESENT_INTERVAL_ONE; + m_params.DisableAutoBackBuffer = FALSE; + m_params.DisableAutoFrontBuffer = FALSE; + m_params.FrontBufferFormat = D3DFMT_X8R8G8B8; + m_params.FrontBufferColorSpace = D3DCOLORSPACE_RGB; + + m_d3d9 = Direct3DCreate9(D3D_SDK_VERSION); + BX_TRACE("Creating D3D9 %p", m_d3d9); + + XVIDEO_MODE videoMode; + XGetVideoMode(&videoMode); + if (!videoMode.fIsWideScreen) + { + m_params.Flags |= D3DPRESENTFLAG_NO_LETTERBOX; + } + + BX_TRACE("Creating device"); + DX_CHECK(m_d3d9->CreateDevice(D3DADAPTER_DEFAULT + , D3DDEVTYPE_HAL + , NULL + , D3DCREATE_HARDWARE_VERTEXPROCESSING|D3DCREATE_BUFFER_2_FRAMES + , &m_params + , &m_device + ) ); + + BX_TRACE("Device %p", m_device); + + m_fmtDepth = D3DFMT_D24FS8; +#endif // BX_PLATFORM_WINDOWS + + postReset(); + + m_initialized = true; + } + + void shutdown() + { + DX_RELEASE(m_device, 0); + DX_RELEASE(m_d3d9, 0); + +#if BX_PLATFORM_WINDOWS + FreeLibrary(m_d3d9dll); +#endif // BX_PLATFORM_WINDOWS + } + + void updateResolution(const Resolution& _resolution) + { + if (m_params.BackBufferWidth != _resolution.m_width + || m_params.BackBufferHeight != _resolution.m_height + || m_flags != _resolution.m_flags) + { + m_flags = _resolution.m_flags; + + m_textVideoMem.resize(false, _resolution.m_width, _resolution.m_height); + +#if BX_PLATFORM_WINDOWS + D3DDEVICE_CREATION_PARAMETERS dcp; + DX_CHECK(m_device->GetCreationParameters(&dcp) ); + + D3DDISPLAYMODE dm; + DX_CHECK(m_d3d9->GetAdapterDisplayMode(dcp.AdapterOrdinal, &dm) ); + + m_params.BackBufferFormat = dm.Format; +#endif // BX_PLATFORM_WINDOWS + + m_params.BackBufferWidth = _resolution.m_width; + m_params.BackBufferHeight = _resolution.m_height; + m_params.FullScreen_RefreshRateInHz = BGFX_RESET_FULLSCREEN == (m_flags&BGFX_RESET_FULLSCREEN_MASK) ? 60 : 0; + m_params.PresentationInterval = !!(m_flags&BGFX_RESET_VSYNC) ? D3DPRESENT_INTERVAL_ONE : D3DPRESENT_INTERVAL_IMMEDIATE; + + D3DMULTISAMPLE_TYPE msaa = s_msaa[(m_flags&BGFX_RESET_MSAA_MASK)>>BGFX_RESET_MSAA_SHIFT]; + HRESULT hr = m_d3d9->CheckDeviceMultiSampleType(D3DADAPTER_DEFAULT + , D3DDEVTYPE_HAL + , m_params.BackBufferFormat + , m_params.Windowed + , msaa + , NULL + ); + + m_params.MultiSampleType = SUCCEEDED(hr) ? msaa : D3DMULTISAMPLE_NONE; + + preReset(); + DX_CHECK(m_device->Reset(&m_params) ); + postReset(); + } + } + + void setRenderTarget(RenderTargetHandle _rt) + { + if (_rt.idx == bgfx::invalidHandle) + { + DX_CHECK(m_device->SetRenderTarget(0, m_backBufferColor) ); + DX_CHECK(m_device->SetDepthStencilSurface(m_backBufferDepthStencil) ); + } + else + { + RenderTarget& renderTarget = m_renderTargets[_rt.idx]; + DX_CHECK(m_device->SetRenderTarget(0, renderTarget.m_color) ); + DX_CHECK(m_device->SetDepthStencilSurface(NULL != renderTarget.m_depth ? renderTarget.m_depth : m_backBufferDepthStencil) ); + } + } + + void setShaderConstantF(uint8_t _flags, uint16_t _regIndex, const float* _val, uint16_t _numRegs) + { + if (_flags&BGFX_UNIFORM_FRAGMENTBIT) + { + DX_CHECK(m_device->SetPixelShaderConstantF(_regIndex, _val, _numRegs) ); + } + else + { + DX_CHECK(m_device->SetVertexShaderConstantF(_regIndex, _val, _numRegs) ); + } + } + + void reset() + { + preReset(); + + HRESULT hr; + + do + { + hr = m_device->Reset(&m_params); + } while (FAILED(hr) ); + + postReset(); + } + + bool isLost(HRESULT _hr) const + { + return D3DERR_DEVICELOST == _hr + || D3DERR_DRIVERINTERNALERROR == _hr +#if !defined(D3D_DISABLE_9EX) + || D3DERR_DEVICEHUNG == _hr + || D3DERR_DEVICEREMOVED == _hr +#endif // !defined(D3D_DISABLE_9EX) + ; + } + + void flip() + { +#if BGFX_CONFIG_RENDERER_DIRECT3D_EX + DX_CHECK(m_device->WaitForVBlank(0) ); +#endif // BGFX_CONFIG_RENDERER_DIRECT3D_EX + + HRESULT hr; + hr = m_device->Present(NULL, NULL, NULL, NULL); + +#if BX_PLATFORM_WINDOWS + if (isLost(hr) ) + { + do + { + do + { + hr = m_device->TestCooperativeLevel(); + } + while (D3DERR_DEVICENOTRESET != hr); + + reset(); + hr = m_device->TestCooperativeLevel(); + } + while (FAILED(hr) ); + } + else if (FAILED(hr) ) + { + BX_TRACE("Present failed with err 0x%08x.", hr); + } +#endif // BX_PLATFORM_ + } + + void preReset() + { + for (uint32_t stage = 0; stage < BGFX_STATE_TEX_COUNT; ++stage) + { + DX_CHECK(m_device->SetTexture(stage, NULL) ); + } + + DX_CHECK(m_device->SetRenderTarget(0, m_backBufferColor) ); + DX_CHECK(m_device->SetDepthStencilSurface(m_backBufferDepthStencil) ); + DX_CHECK(m_device->SetVertexShader(NULL) ); + DX_CHECK(m_device->SetPixelShader(NULL) ); + DX_CHECK(m_device->SetStreamSource(0, NULL, 0, 0) ); + DX_CHECK(m_device->SetIndices(NULL) ); + + DX_RELEASE(m_backBufferColor, 0); + DX_RELEASE(m_backBufferDepthStencil, 0); + + for (uint32_t ii = 0; ii < countof(m_indexBuffers); ++ii) + { + m_indexBuffers[ii].preReset(); + } + + for (uint32_t ii = 0; ii < countof(m_vertexBuffers); ++ii) + { + m_vertexBuffers[ii].preReset(); + } + + for (uint32_t ii = 0; ii < countof(m_renderTargets); ++ii) + { + m_renderTargets[ii].preReset(); + } + } + + void postReset() + { + DX_CHECK(m_device->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &m_backBufferColor) ); + DX_CHECK(m_device->GetDepthStencilSurface(&m_backBufferDepthStencil) ); + + for (uint32_t ii = 0; ii < countof(m_indexBuffers); ++ii) + { + m_indexBuffers[ii].postReset(); + } + + for (uint32_t ii = 0; ii < countof(m_vertexBuffers); ++ii) + { + m_vertexBuffers[ii].postReset(); + } + + for (uint32_t ii = 0; ii < countof(m_renderTargets); ++ii) + { + m_renderTargets[ii].postReset(); + } + } + + void saveScreenShot(Memory* _mem) + { +#if BX_PLATFORM_WINDOWS + IDirect3DSurface9* surface; + D3DDEVICE_CREATION_PARAMETERS dcp; + DX_CHECK(m_device->GetCreationParameters(&dcp) ); + + D3DDISPLAYMODE dm; + DX_CHECK(m_d3d9->GetAdapterDisplayMode(dcp.AdapterOrdinal, &dm) ); + + DX_CHECK(m_device->CreateOffscreenPlainSurface(dm.Width + , dm.Height + , D3DFMT_A8R8G8B8 + , D3DPOOL_SCRATCH + , &surface + , NULL + ) ); + + DX_CHECK(m_device->GetFrontBufferData(0, surface) ); + + D3DLOCKED_RECT rect; + DX_CHECK(surface->LockRect(&rect + , NULL + , D3DLOCK_NO_DIRTY_UPDATE|D3DLOCK_NOSYSLOCK|D3DLOCK_READONLY + ) ); + + RECT rc; + GetClientRect(bgfxHwnd, &rc); + POINT point; + point.x = rc.left; + point.y = rc.top; + ClientToScreen(bgfxHwnd, &point); + uint8_t* data = (uint8_t*)rect.pBits; + uint32_t bpp = rect.Pitch/dm.Width; + saveTga( (const char*)_mem->data, m_params.BackBufferWidth, m_params.BackBufferHeight, rect.Pitch, &data[point.y*rect.Pitch+point.x*bpp]); + + DX_CHECK(surface->UnlockRect() ); + DX_RELEASE(surface, 0); +#endif // BX_PLATFORM_WINDOWS + } + +#if BX_PLATFORM_WINDOWS + D3DPERF_SetMarkerFunc m_D3DPERF_SetMarker; + D3DPERF_BeginEventFunc m_D3DPERF_BeginEvent; + D3DPERF_EndEventFunc m_D3DPERF_EndEvent; +#endif // BX_PLATFORM_WINDOWS + +#if BGFX_CONFIG_RENDERER_DIRECT3D_EX + IDirect3D9Ex* m_d3d9; + IDirect3DDevice9Ex* m_device; +#else + IDirect3D9* m_d3d9; + IDirect3DDevice9* m_device; +#endif // BGFX_CONFIG_RENDERER_DIRECT3D_EX + + IDirect3DSurface9* m_backBufferColor; + IDirect3DSurface9* m_backBufferDepthStencil; + + HMODULE m_d3d9dll; + D3DPRESENT_PARAMETERS m_params; + uint32_t m_flags; + + bool m_initialized; + bool m_fmtNULL; + bool m_fmtDF16; + bool m_fmtDF24; + bool m_fmtINTZ; + bool m_fmtRAWZ; + + D3DFORMAT m_fmtDepth; + + IndexBuffer m_indexBuffers[BGFX_CONFIG_MAX_INDEX_BUFFERS]; + VertexBuffer m_vertexBuffers[BGFX_CONFIG_MAX_VERTEX_BUFFERS]; + Shader m_vertexShaders[BGFX_CONFIG_MAX_VERTEX_SHADERS]; + Shader m_fragmentShaders[BGFX_CONFIG_MAX_FRAGMENT_SHADERS]; + Material m_materials[BGFX_CONFIG_MAX_MATERIALS]; + Texture m_textures[BGFX_CONFIG_MAX_TEXTURES]; + VertexDeclaration m_vertexDecls[BGFX_CONFIG_MAX_VERTEX_DECLS]; + RenderTarget m_renderTargets[BGFX_CONFIG_MAX_RENDER_TARGETS]; + UniformRegistry m_uniformReg; + void* m_uniforms[BGFX_CONFIG_MAX_UNIFORMS]; + + TextVideoMem m_textVideoMem; + }; + + static RendererContext s_renderCtx; + + void IndexBuffer::create(uint32_t _size, void* _data) + { + m_size = _size; + m_dynamic = NULL == _data; + + uint32_t usage = D3DUSAGE_WRITEONLY; + D3DPOOL pool = D3DPOOL_MANAGED; + + if (m_dynamic) + { + usage |= D3DUSAGE_DYNAMIC; + pool = D3DPOOL_DEFAULT; + } + + DX_CHECK(s_renderCtx.m_device->CreateIndexBuffer(m_size + , usage + , D3DFMT_INDEX16 + , pool + , &m_ptr + , NULL + ) ); + + if (NULL != _data) + { + update(_size, _data); + } + } + + void IndexBuffer::preReset() + { + if (m_dynamic) + { + DX_RELEASE(m_ptr, 0); + } + } + + void IndexBuffer::postReset() + { + if (m_dynamic) + { + DX_CHECK(s_renderCtx.m_device->CreateIndexBuffer(m_size + , D3DUSAGE_WRITEONLY|D3DUSAGE_DYNAMIC + , D3DFMT_INDEX16 + , D3DPOOL_DEFAULT + , &m_ptr + , NULL + ) ); + } + } + + void VertexBuffer::create(uint32_t _size, void* _data, VertexDeclHandle _declHandle) + { + m_size = _size; + m_decl = _declHandle; + m_dynamic = NULL == _data; + + uint32_t usage = D3DUSAGE_WRITEONLY; + D3DPOOL pool = D3DPOOL_MANAGED; + + if (m_dynamic) + { + usage |= D3DUSAGE_DYNAMIC; + pool = D3DPOOL_DEFAULT; + } + + DX_CHECK(s_renderCtx.m_device->CreateVertexBuffer(m_size + , usage + , 0 + , pool + , &m_ptr + , NULL + ) ); + + if (NULL != _data) + { + update(_size, _data); + } + } + + void VertexBuffer::preReset() + { + if (m_dynamic) + { + DX_RELEASE(m_ptr, 0); + } + } + + void VertexBuffer::postReset() + { + if (m_dynamic) + { + DX_CHECK(s_renderCtx.m_device->CreateVertexBuffer(m_size + , D3DUSAGE_WRITEONLY|D3DUSAGE_DYNAMIC + , 0 + , D3DPOOL_DEFAULT + , &m_ptr + , NULL + ) ); + } + } + + static const D3DVERTEXELEMENT9 s_attrib[Attrib::Count+1] = + { + {0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0}, + {0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 0}, + {0, 0, D3DDECLTYPE_UBYTE4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 0}, + {0, 0, D3DDECLTYPE_UBYTE4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 1}, + {0, 0, D3DDECLTYPE_UBYTE4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_BLENDINDICES, 0}, + {0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_BLENDWEIGHT, 0}, + {0, 0, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0}, + {0, 0, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 1}, + {0, 0, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 2}, + {0, 0, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 3}, + {0, 0, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 4}, + {0, 0, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 5}, + {0, 0, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 6}, + {0, 0, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 7}, + D3DDECL_END() + }; + + void VertexDeclaration::create(const VertexDecl& _decl) + { + memcpy(&m_decl, &_decl, sizeof(VertexDecl) ); + dump(m_decl); + + D3DVERTEXELEMENT9 vertexElements[Attrib::Count+1]; + D3DVERTEXELEMENT9* elem = vertexElements; + + for (uint32_t attr = 0; attr < Attrib::Count; ++attr) + { + if (0xff != _decl.m_attributes[attr]) + { + uint8_t num; + AttribType::Enum type; + bool normalized; + _decl.decode(Attrib::Enum(attr), num, type, normalized); + + memcpy(elem, &s_attrib[attr], sizeof(D3DVERTEXELEMENT9) ); + + D3DDECLTYPE declType = D3DDECLTYPE(elem->Type); + + switch (type) + { + case AttribType::Uint8: + if (normalized) + { + declType = D3DDECLTYPE_UBYTE4N; + } + else + { + declType = D3DDECLTYPE_UBYTE4; + } + break; + + case AttribType::Uint16: + if (normalized) + { + switch (num) + { + default: + case 2: + declType = D3DDECLTYPE_SHORT2N; + break; + + case 4: + declType = D3DDECLTYPE_SHORT4N; + break; + } + } + else + { + switch (num) + { + default: + case 2: + declType = D3DDECLTYPE_SHORT2; + break; + + case 4: + declType = D3DDECLTYPE_SHORT4; + break; + } + } + break; + + case AttribType::Float: + switch (num) + { + case 1: + declType = D3DDECLTYPE_FLOAT1; + break; + + case 2: + declType = D3DDECLTYPE_FLOAT2; + break; + + default: + case 3: + declType = D3DDECLTYPE_FLOAT3; + break; + + case 4: + declType = D3DDECLTYPE_FLOAT4; + break; + } + + break; + + default: + BX_CHECK(false, "Invalid attrib type."); + break; + } + + elem->Type = declType; + elem->Offset = _decl.m_offset[attr]; + ++elem; + + BX_TRACE("\tattr %d, num %d, type %d, norm %d, offset %d" + , attr + , num + , type + , normalized + , _decl.m_offset[attr] + ); + } + } + + memcpy(elem, &s_attrib[Attrib::Count], sizeof(D3DVERTEXELEMENT9) ); + + DX_CHECK(s_renderCtx.m_device->CreateVertexDeclaration(vertexElements, &m_ptr) ); + } + + void Shader::create(bool _fragment, const Memory* _mem) + { + m_constantBuffer = ConstantBuffer::create(1024); + + StreamRead stream(_mem->data, _mem->size); + uint16_t count; + stream.read(count); + + m_numPredefined = 0; + + BX_TRACE("Shader consts %d", count); + + uint8_t fragmentBit = _fragment ? BGFX_UNIFORM_FRAGMENTBIT : 0; + + for (uint32_t ii = 0; ii < count; ++ii) + { + uint8_t nameSize; + stream.read(nameSize); + + char name[256]; + stream.read(&name, nameSize); + name[nameSize] = '\0'; + + uint8_t type; + stream.read(type); + + uint8_t num; + stream.read(num); + + uint16_t regIndex; + stream.read(regIndex); + + uint16_t regCount; + stream.read(regCount); + + BX_TRACE("\t%s, type %2d, num %2d, r.index %3d, r.count %2d" + , name + , type + , num + , regIndex + , regCount + ); + + const void* data = NULL; + PredefinedUniform::Enum predefined = nameToPredefinedUniformEnum(name); + if (PredefinedUniform::Count != predefined) + { + m_predefined[m_numPredefined].m_loc = regIndex; + m_predefined[m_numPredefined].m_type = predefined|fragmentBit; + m_numPredefined++; + } + else + { + const UniformInfo* info = s_renderCtx.m_uniformReg.find(name); + if (NULL != info) + { + data = info->m_data; + m_constantBuffer->writeUniformRef( (ConstantType::Enum)(type|fragmentBit), regIndex, data, regCount); + BX_TRACE("store %s %p", name, data); + } + } + } + + uint16_t shaderSize; + stream.read(shaderSize); + + m_constantBuffer->finish(); + + const DWORD* code = (const DWORD*)stream.getDataPtr(); + + if (_fragment) + { + DX_CHECK(s_renderCtx.m_device->CreatePixelShader(code, (IDirect3DPixelShader9**)&m_ptr) ); + } + else + { + DX_CHECK(s_renderCtx.m_device->CreateVertexShader(code, (IDirect3DVertexShader9**)&m_ptr) ); + } + } + + void Texture::create(const Memory* _mem, uint32_t _flags) + { + m_tau = s_textureAddress[(_flags&BGFX_TEXTURE_U_MASK)>>BGFX_TEXTURE_U_SHIFT]; + m_tav = s_textureAddress[(_flags&BGFX_TEXTURE_V_MASK)>>BGFX_TEXTURE_V_SHIFT]; + m_minFilter = s_textureFilter[(_flags&BGFX_TEXTURE_MIN_MASK)>>BGFX_TEXTURE_MIN_SHIFT]; + m_magFilter = s_textureFilter[(_flags&BGFX_TEXTURE_MAG_MASK)>>BGFX_TEXTURE_MAG_SHIFT]; + m_mipFilter = s_textureFilter[(_flags&BGFX_TEXTURE_MIP_MASK)>>BGFX_TEXTURE_MIP_SHIFT]; + + Dds dds; + + if (parseDds(dds, _mem) ) + { + D3DFORMAT typefmt[4] = + { + D3DFMT_X8R8G8B8, + D3DFMT_DXT1, + D3DFMT_DXT3, + D3DFMT_DXT5, + }; + + D3DFORMAT fmt = typefmt[dds.m_type]; + + bool decompress = false; + + if (decompress + || (0 == dds.m_type && dds.m_hasAlpha) ) + { + fmt = D3DFMT_A8R8G8B8; + } + + DX_CHECK(s_renderCtx.m_device->CreateTexture(dds.m_width + , dds.m_height + , dds.m_numMips + , 0 + , fmt + , D3DPOOL_MANAGED + , &m_ptr + , NULL + ) ); + + if (decompress + || 0 == dds.m_type) + { + uint32_t width = dds.m_width; + uint32_t height = dds.m_height; + + for (uint32_t lod = 0, num = dds.m_numMips; lod < num; ++lod) + { + width = uint32_max(1, width); + height = uint32_max(1, height); + + Mip mip; + if (getRawImageData(dds, lod, _mem, mip) ) + { + D3DLOCKED_RECT rect; + DX_CHECK(m_ptr->LockRect(lod, &rect, NULL, 0) ); + uint8_t* bits = (uint8_t*)rect.pBits; + + if (width != mip.m_width + || height != mip.m_height) + { + uint8_t* temp = (uint8_t*)g_realloc(NULL, mip.m_width*mip.m_height*4); + mip.decode(temp); + uint32_t srcpitch = mip.m_width*4; + uint32_t dstpitch = rect.Pitch; + + for (uint32_t yy = 0; yy < height; ++yy) + { + uint8_t* src = &temp[yy*srcpitch]; + uint8_t* dst = &bits[yy*dstpitch]; + + for (uint32_t xx = 0; xx < width; ++xx) + { + memcpy(dst, src, 4); + dst += 4; + src += 4; + } + } + + g_free(temp); + } + else + { + mip.decode(bits); + } + + DX_CHECK(m_ptr->UnlockRect(lod) ); + } + + width >>= 1; + height >>= 1; + } + } + else + { + for (uint32_t ii = 0, num = dds.m_numMips; ii < num; ++ii) + { + Mip mip; + if (getRawImageData(dds, ii, _mem, mip) ) + { + D3DLOCKED_RECT rect; + DX_CHECK(m_ptr->LockRect(ii, &rect, NULL, 0) ); + uint8_t* dst = (uint8_t*)rect.pBits; + memcpy(dst, mip.m_data, mip.m_size); + DX_CHECK(m_ptr->UnlockRect(ii) ); + } + } + } + } + else + { + StreamRead stream(_mem->data, _mem->size); + + uint32_t magic; + stream.read(magic); + + if (BGFX_MAGIC == magic) + { + uint16_t width; + stream.read(width); + + uint16_t height; + stream.read(height); + + uint8_t bpp; + stream.read(bpp); + + uint8_t numMips; + stream.read(numMips); + + stream.align(16); + + DX_CHECK(s_renderCtx.m_device->CreateTexture(width + , height + , numMips + , 0 + , 1 == bpp ? D3DFMT_L8 : D3DFMT_A8R8G8B8 + , D3DPOOL_MANAGED + , &m_ptr + , NULL + ) ); + + for (uint8_t mip = 0; mip < numMips; ++mip) + { + width = uint32_max(width, 1); + height = uint32_max(height, 1); + + D3DLOCKED_RECT rect; + DX_CHECK(m_ptr->LockRect(mip, &rect, NULL, 0) ); + uint8_t* dst = (uint8_t*)rect.pBits; + stream.read(dst, width*height*bpp); + DX_CHECK(m_ptr->UnlockRect(mip) ); + + width >>= 1; + height >>= 1; + } + } + else + { + // + } + } + } + + void Texture::commit(uint8_t _stage) + { + DX_CHECK(s_renderCtx.m_device->SetSamplerState(_stage, D3DSAMP_MINFILTER, m_minFilter) ); + DX_CHECK(s_renderCtx.m_device->SetSamplerState(_stage, D3DSAMP_MAGFILTER, m_magFilter) ); + DX_CHECK(s_renderCtx.m_device->SetSamplerState(_stage, D3DSAMP_MIPFILTER, m_mipFilter) ); + DX_CHECK(s_renderCtx.m_device->SetSamplerState(_stage, D3DSAMP_ADDRESSU, m_tau) ); + DX_CHECK(s_renderCtx.m_device->SetSamplerState(_stage, D3DSAMP_ADDRESSV, m_tav) ); + DX_CHECK(s_renderCtx.m_device->SetTexture(_stage, m_ptr) ); + } + + void RenderTarget::create(uint16_t _width, uint16_t _height, uint32_t _flags) + { + m_width = _width; + m_height = _height; + m_flags = _flags; + + createTextures(); + } + + void RenderTarget::createTextures() + { + if (0 != m_flags) + { + uint32_t colorFormat = (m_flags&BGFX_RENDER_TARGET_COLOR_MASK)>>BGFX_RENDER_TARGET_COLOR_SHIFT; + uint32_t depthFormat = (m_flags&BGFX_RENDER_TARGET_DEPTH_MASK)>>BGFX_RENDER_TARGET_DEPTH_SHIFT; + + if (0 < colorFormat) + { + DX_CHECK(s_renderCtx.m_device->CreateTexture(m_width + , m_height + , 1 + , D3DUSAGE_RENDERTARGET + , s_colorFormat[colorFormat] + , D3DPOOL_DEFAULT + , &m_colorTexture + , NULL + ) ); + + DX_CHECK(m_colorTexture->GetSurfaceLevel(0, &m_color) ); + } + + if (0 < depthFormat) + { + DX_CHECK(s_renderCtx.m_device->CreateTexture(m_width + , m_height + , 1 + , D3DUSAGE_DEPTHSTENCIL + , s_depthFormat[depthFormat] // s_renderCtx.m_fmtDepth + , D3DPOOL_DEFAULT + , &m_depthTexture + , NULL + ) ); + + DX_CHECK(m_depthTexture->GetSurfaceLevel(0, &m_depth)) ; + } + } + } + + void RenderTarget::destroyTextures() + { + if (0 != m_flags) + { + uint32_t colorFormat = (m_flags&BGFX_RENDER_TARGET_COLOR_MASK)>>BGFX_RENDER_TARGET_COLOR_SHIFT; + uint32_t depthFormat = (m_flags&BGFX_RENDER_TARGET_DEPTH_MASK)>>BGFX_RENDER_TARGET_DEPTH_SHIFT; + + if (0 < colorFormat) + { + DX_RELEASE(m_color, 1); + DX_RELEASE(m_colorTexture, 0); + } + + if (0 < depthFormat) + { + DX_RELEASE(m_depth, 1); + DX_RELEASE(m_depthTexture, 0); + } + } + } + + void RenderTarget::commit(uint8_t _stage) + { + DX_CHECK(s_renderCtx.m_device->SetSamplerState(_stage, D3DSAMP_MINFILTER, D3DTEXF_LINEAR) ); + DX_CHECK(s_renderCtx.m_device->SetSamplerState(_stage, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR) ); + DX_CHECK(s_renderCtx.m_device->SetSamplerState(_stage, D3DSAMP_MIPFILTER, D3DTEXF_POINT) ); + DX_CHECK(s_renderCtx.m_device->SetSamplerState(_stage, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP) ); + DX_CHECK(s_renderCtx.m_device->SetSamplerState(_stage, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP) ); + DX_CHECK(s_renderCtx.m_device->SetTexture(_stage, m_colorTexture) ); + } + + static bool s_exit = false; + + DWORD WINAPI renderThread(LPVOID _arg) + { + while (!s_exit) + { + renderFrame(); + } + + s_exit = false; + + return EXIT_SUCCESS; + } + + void ConstantBuffer::commit(bool _force) + { + reset(); + + do + { + uint32_t opcode = read(); + + if (ConstantType::End == opcode) + { + break; + } + + ConstantType::Enum type; + uint16_t loc; + uint16_t num; + uint16_t copy; + decodeOpcode(opcode, type, loc, num, copy); + + const char* data; + if (copy) + { + data = read(g_constantTypeSize[type]*num); + } + else + { + memcpy(&data, read(sizeof(void*) ), sizeof(void*) ); + } + +#define CASE_IMPLEMENT_UNIFORM(_uniform, _glsuffix, _dxsuffix, _type) \ + case ConstantType::_uniform: \ + { \ + _type* value = (_type*)data; \ + s_renderCtx.m_device->SetVertexShaderConstant##_dxsuffix(loc, value, num); \ + } \ + break; \ + \ + case ConstantType::_uniform|BGFX_UNIFORM_FRAGMENTBIT: \ + { \ + _type* value = (_type*)data; \ + s_renderCtx.m_device->SetPixelShaderConstant##_dxsuffix(loc, value, num); \ + } \ + break; + + switch ((int32_t)type) + { + CASE_IMPLEMENT_UNIFORM(Uniform1i, 1iv, I, int); + CASE_IMPLEMENT_UNIFORM(Uniform1f, 1fv, F, float); + CASE_IMPLEMENT_UNIFORM(Uniform1iv, 1iv, I, int); + CASE_IMPLEMENT_UNIFORM(Uniform1fv, 1fv, F, float); + CASE_IMPLEMENT_UNIFORM(Uniform2fv, 2fv, F, float); + CASE_IMPLEMENT_UNIFORM(Uniform3fv, 3fv, F, float); + CASE_IMPLEMENT_UNIFORM(Uniform4fv, 4fv, F, float); + CASE_IMPLEMENT_UNIFORM(Uniform3x3fv, Matrix3fv, F, float); + CASE_IMPLEMENT_UNIFORM(Uniform4x4fv, Matrix4fv, F, float); + + case ConstantType::End: + break; + + default: + BX_TRACE("%4d: INVALID 0x%08x, t %d, l %d, n %d, c %d", m_pos, opcode, type, loc, num, copy); + break; + } + +#undef CASE_IMPLEMENT_UNIFORM + + } while (true); + } + + void TextVideoMemBlitter::setup() + { + uint32_t width = s_renderCtx.m_params.BackBufferWidth; + uint32_t height = s_renderCtx.m_params.BackBufferHeight; + + RenderTargetHandle rt = BGFX_INVALID_HANDLE; + s_renderCtx.setRenderTarget(rt); + + D3DVIEWPORT9 vp; + vp.X = 0; + vp.Y = 0; + vp.Width = width; + vp.Height = height; + vp.MinZ = 0.0f; + vp.MaxZ = 1.0f; + DX_CHECK(s_renderCtx.m_device->SetViewport(&vp) ); + + DX_CHECK(s_renderCtx.m_device->SetRenderState(D3DRS_ZENABLE, FALSE) ); + DX_CHECK(s_renderCtx.m_device->SetRenderState(D3DRS_ZFUNC, D3DCMP_ALWAYS) ); + DX_CHECK(s_renderCtx.m_device->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE) ); + DX_CHECK(s_renderCtx.m_device->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE) ); + DX_CHECK(s_renderCtx.m_device->SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATER) ); + DX_CHECK(s_renderCtx.m_device->SetRenderState(D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_RED|D3DCOLORWRITEENABLE_GREEN|D3DCOLORWRITEENABLE_BLUE) ); + DX_CHECK(s_renderCtx.m_device->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID) ); + + Material& material = s_renderCtx.m_materials[m_material.idx]; + s_renderCtx.m_device->SetVertexShader( (IDirect3DVertexShader9*)material.m_vsh->m_ptr); + s_renderCtx.m_device->SetPixelShader( (IDirect3DPixelShader9*)material.m_fsh->m_ptr); + + VertexBuffer& vb = s_renderCtx.m_vertexBuffers[m_vb->handle.idx]; + VertexDeclaration& vertexDecl = s_renderCtx.m_vertexDecls[m_vb->decl.idx]; + DX_CHECK(s_renderCtx.m_device->SetStreamSource(0, vb.m_ptr, 0, vertexDecl.m_decl.m_stride) ); + DX_CHECK(s_renderCtx.m_device->SetVertexDeclaration(vertexDecl.m_ptr) ); + + IndexBuffer& ib = s_renderCtx.m_indexBuffers[m_ib->handle.idx]; + DX_CHECK(s_renderCtx.m_device->SetIndices(ib.m_ptr) ); + + float proj[16]; + matrix_ortho(proj, 0.0f, (float)width, (float)height, 0.0f, 0.0f, 1000.0f); + + PredefinedUniform& predefined = material.m_predefined[0]; + uint8_t flags = predefined.m_type&BGFX_UNIFORM_FRAGMENTBIT; + s_renderCtx.setShaderConstantF(flags, predefined.m_loc, proj, 4); + + s_renderCtx.m_textures[m_texture.idx].commit(0); + } + + void TextVideoMemBlitter::render(uint32_t _numIndices) + { + uint32_t numVertices = _numIndices*4/6; + s_renderCtx.m_indexBuffers[m_ib->handle.idx].update(_numIndices*2, m_ib->data); + s_renderCtx.m_vertexBuffers[m_vb->handle.idx].update(numVertices*m_decl.m_stride, m_vb->data); + + DX_CHECK(s_renderCtx.m_device->DrawIndexedPrimitive(D3DPT_TRIANGLELIST + , 0 + , 0 + , numVertices + , 0 + , _numIndices/3 + ) ); + } + + void Context::flip() + { + s_renderCtx.flip(); + } + + void Context::rendererInit() + { + s_renderCtx.init(); + } + + void Context::rendererShutdown() + { + s_renderCtx.shutdown(); + s_exit = true; + } + + void Context::rendererCreateIndexBuffer(IndexBufferHandle _handle, Memory* _mem) + { + s_renderCtx.m_indexBuffers[_handle.idx].create(_mem->size, _mem->data); + } + + void Context::rendererDestroyIndexBuffer(IndexBufferHandle _handle) + { + s_renderCtx.m_indexBuffers[_handle.idx].destroy(); + } + + void Context::rendererCreateDynamicIndexBuffer(IndexBufferHandle _handle, uint32_t _size) + { + s_renderCtx.m_indexBuffers[_handle.idx].create(_size, NULL); + } + + void Context::rendererDestroyDynamicIndexBuffer(IndexBufferHandle _handle) + { + s_renderCtx.m_indexBuffers[_handle.idx].destroy(); + } + + void Context::rendererCreateVertexDecl(VertexDeclHandle _handle, const VertexDecl& _decl) + { + s_renderCtx.m_vertexDecls[_handle.idx].create(_decl); + } + + void Context::rendererDestroyVertexDecl(VertexDeclHandle _handle) + { + s_renderCtx.m_vertexDecls[_handle.idx].destroy(); + } + + void Context::rendererCreateVertexBuffer(VertexBufferHandle _handle, Memory* _mem, VertexDeclHandle _declHandle) + { + s_renderCtx.m_vertexBuffers[_handle.idx].create(_mem->size, _mem->data, _declHandle); + } + + void Context::rendererDestroyVertexBuffer(VertexBufferHandle _handle) + { + s_renderCtx.m_vertexBuffers[_handle.idx].destroy(); + } + + void Context::rendererCreateDynamicVertexBuffer(VertexBufferHandle _handle, uint32_t _size) + { + VertexDeclHandle decl = BGFX_INVALID_HANDLE; + s_renderCtx.m_vertexBuffers[_handle.idx].create(_size, NULL, decl); + } + + void Context::rendererDestroyDynamicVertexBuffer(VertexBufferHandle _handle) + { + s_renderCtx.m_vertexBuffers[_handle.idx].destroy(); + } + + void Context::rendererCreateVertexShader(VertexShaderHandle _handle, Memory* _mem) + { + s_renderCtx.m_vertexShaders[_handle.idx].create(false, _mem); + } + + void Context::rendererDestroyVertexShader(VertexShaderHandle _handle) + { + s_renderCtx.m_vertexShaders[_handle.idx].destroy(); + } + + void Context::rendererCreateFragmentShader(FragmentShaderHandle _handle, Memory* _mem) + { + s_renderCtx.m_fragmentShaders[_handle.idx].create(true, _mem); + } + + void Context::rendererDestroyFragmentShader(FragmentShaderHandle _handle) + { + s_renderCtx.m_fragmentShaders[_handle.idx].destroy(); + } + + void Context::rendererCreateMaterial(MaterialHandle _handle, VertexShaderHandle _vsh, FragmentShaderHandle _fsh) + { + s_renderCtx.m_materials[_handle.idx].create(s_renderCtx.m_vertexShaders[_vsh.idx], s_renderCtx.m_fragmentShaders[_fsh.idx]); + } + + void Context::rendererDestroyMaterial(FragmentShaderHandle _handle) + { + s_renderCtx.m_materials[_handle.idx].destroy(); + } + + void Context::rendererCreateTexture(TextureHandle _handle, Memory* _mem, uint32_t _flags) + { + s_renderCtx.m_textures[_handle.idx].create(_mem, _flags); + } + + void Context::rendererDestroyTexture(TextureHandle _handle) + { + s_renderCtx.m_textures[_handle.idx].destroy(); + } + + void Context::rendererCreateRenderTarget(RenderTargetHandle _handle, uint16_t _width, uint16_t _height, uint32_t _flags) + { + s_renderCtx.m_renderTargets[_handle.idx].create(_width, _height, _flags); + } + + void Context::rendererDestroyRenderTarget(RenderTargetHandle _handle) + { + s_renderCtx.m_renderTargets[_handle.idx].destroy(); + } + + void Context::rendererCreateUniform(UniformHandle _handle, ConstantType::Enum _type, uint16_t _num, const char* _name) + { + uint32_t size = g_constantTypeSize[_type]*_num; + void* data = g_realloc(NULL, size); + s_renderCtx.m_uniforms[_handle.idx] = data; + s_renderCtx.m_uniformReg.reg(_name, s_renderCtx.m_uniforms[_handle.idx]); + } + + void Context::rendererDestroyUniform(UniformHandle _handle) + { + g_free(s_renderCtx.m_uniforms[_handle.idx]); + } + + void Context::rendererSaveScreenShot(Memory* _mem) + { + s_renderCtx.saveScreenShot(_mem); + } + + void Context::rendererUpdateUniform(uint16_t _loc, const void* _data, uint32_t _size) + { + memcpy(s_renderCtx.m_uniforms[_loc], _data, _size); + } + + void Context::rendererSubmit() + { + PIX_BEGINEVENT(D3DCOLOR_RGBA(0xff, 0x00, 0x00, 0xff), "rendererSubmit"); + + s_renderCtx.updateResolution(m_render->m_resolution); + + s_renderCtx.m_device->BeginScene(); + + if (0 < m_render->m_iboffset) + { + DynamicIndexBuffer* ib = m_render->m_dynamicIb; + s_renderCtx.m_indexBuffers[ib->handle.idx].update(m_render->m_iboffset, ib->data); + } + + if (0 < m_render->m_vboffset) + { + DynamicVertexBuffer* vb = m_render->m_dynamicVb; + s_renderCtx.m_vertexBuffers[vb->handle.idx].update(m_render->m_vboffset, vb->data); + } + + m_render->sort(); + + RenderState currentState; + currentState.reset(); + currentState.m_flags = BGFX_STATE_NONE; + + Matrix4 viewProj[BGFX_CONFIG_MAX_VIEWS]; + for (uint32_t ii = 0; ii < BGFX_CONFIG_MAX_VIEWS; ++ii) + { + matrix_mul(viewProj[ii].val, m_render->m_view[ii].val, m_render->m_proj[ii].val); + } + + DX_CHECK(s_renderCtx.m_device->SetRenderState(D3DRS_FILLMODE, m_render->m_debug&BGFX_DEBUG_WIREFRAME ? D3DFILL_WIREFRAME : D3DFILL_SOLID) ); + uint16_t materialIdx = bgfx::invalidHandle; + SortKey key; + uint8_t view = 0xff; + RenderTargetHandle rt = BGFX_INVALID_HANDLE; + float alphaRef = 0.0f; + D3DPRIMITIVETYPE primType = D3DPT_TRIANGLELIST; + uint32_t primNumVerts = 3; + + uint32_t statsNumPrims = 0; + uint32_t statsNumIndices = 0; + + int64_t elapsed = -bx::getHPCounter(); + + if (0 == (m_render->m_debug&BGFX_DEBUG_IFH) ) + { + for (uint32_t item = 0, numItems = m_render->m_num; item < numItems; ++item) + { + key.decode(m_render->m_sortKeys[item]); + const RenderState& state = m_render->m_renderState[m_render->m_sortValues[item] ]; + + const uint64_t newFlags = state.m_flags; + uint64_t changedFlags = currentState.m_flags ^ state.m_flags; + currentState.m_flags = newFlags; + + if (key.m_view != view) + { + currentState.clear(); + changedFlags = BGFX_STATE_MASK; + currentState.m_flags = newFlags; + + PIX_ENDEVENT(); + PIX_BEGINEVENT(D3DCOLOR_RGBA(0xff, 0x00, 0x00, 0xff), "view"); + + view = key.m_view; + materialIdx = bgfx::invalidHandle; + + if (m_render->m_rt[view].idx != rt.idx) + { + rt = m_render->m_rt[view]; + s_renderCtx.setRenderTarget(rt); + } + + Rect& rect = m_render->m_rect[view]; + + D3DVIEWPORT9 vp; + vp.X = rect.m_x; + vp.Y = rect.m_y; + vp.Width = rect.m_width; + vp.Height = rect.m_height; + vp.MinZ = 0.0f; + vp.MaxZ = 1.0f; + DX_CHECK(s_renderCtx.m_device->SetViewport(&vp) ); + + Clear& clear = m_render->m_clear[view]; + + if (BGFX_CLEAR_NONE != clear.m_flags) + { + D3DCOLOR color; + DWORD flags = 0; + + if (BGFX_CLEAR_COLOR_BIT & clear.m_flags) + { + flags |= D3DCLEAR_TARGET; + uint32_t rgba = clear.m_rgba; + color = D3DCOLOR_RGBA(rgba>>24, (rgba>>16)&0xff, (rgba>>8)&0xff, rgba&0xff); + DX_CHECK(s_renderCtx.m_device->SetRenderState(D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_RED|D3DCOLORWRITEENABLE_GREEN|D3DCOLORWRITEENABLE_BLUE|D3DCOLORWRITEENABLE_ALPHA) ); + } + + if (BGFX_CLEAR_DEPTH_BIT & clear.m_flags) + { + flags |= D3DCLEAR_ZBUFFER; + DX_CHECK(s_renderCtx.m_device->SetRenderState(D3DRS_ZWRITEENABLE, TRUE) ); + } + + if (BGFX_CLEAR_STENCIL_BIT & clear.m_flags) + { + flags |= D3DCLEAR_STENCIL; + } + + if (0 != flags) + { + RECT rc; + rc.left = rect.m_x; + rc.top = rect.m_y; + rc.right = rect.m_x + rect.m_width; + rc.bottom = rect.m_y + rect.m_height; + DX_CHECK(s_renderCtx.m_device->SetRenderState(D3DRS_SCISSORTESTENABLE, TRUE) ); + DX_CHECK(s_renderCtx.m_device->SetScissorRect(&rc) ); + DX_CHECK(s_renderCtx.m_device->Clear(0, NULL, flags, color, clear.m_depth, clear.m_stencil) ); + DX_CHECK(s_renderCtx.m_device->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE) ); + } + } + + DX_CHECK(s_renderCtx.m_device->SetRenderState(D3DRS_ZENABLE, TRUE) ); + DX_CHECK(s_renderCtx.m_device->SetRenderState(D3DRS_ZFUNC, D3DCMP_LESS) ); + DX_CHECK(s_renderCtx.m_device->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE) ); + DX_CHECK(s_renderCtx.m_device->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE) ); + DX_CHECK(s_renderCtx.m_device->SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATER) ); + } + + if ( (BGFX_STATE_CULL_MASK|BGFX_STATE_DEPTH_WRITE|BGFX_STATE_DEPTH_TEST_MASK + |BGFX_STATE_ALPHA_MASK|BGFX_STATE_ALPHA_WRITE|BGFX_STATE_RGB_WRITE + |BGFX_STATE_BLEND_MASK|BGFX_STATE_ALPHA_REF_MASK|BGFX_STATE_PT_MASK) & changedFlags) + { + if (BGFX_STATE_CULL_MASK & changedFlags) + { + uint32_t cull = (newFlags&BGFX_STATE_CULL_MASK)>>BGFX_STATE_CULL_SHIFT; + DX_CHECK(s_renderCtx.m_device->SetRenderState(D3DRS_CULLMODE, s_cullMode[cull]) ); + } + + if (BGFX_STATE_DEPTH_WRITE & changedFlags) + { + DX_CHECK(s_renderCtx.m_device->SetRenderState(D3DRS_ZWRITEENABLE, !!(BGFX_STATE_DEPTH_WRITE & newFlags) ) ); + } + + if (BGFX_STATE_DEPTH_TEST_MASK & changedFlags) + { + uint32_t func = (newFlags&BGFX_STATE_DEPTH_TEST_MASK)>>BGFX_STATE_DEPTH_TEST_SHIFT; + DX_CHECK(s_renderCtx.m_device->SetRenderState(D3DRS_ZENABLE, 0 != func) ); + + if (0 != func) + { + DX_CHECK(s_renderCtx.m_device->SetRenderState(D3DRS_ZFUNC, s_depthFunc[func]) ); + } + } + + if ( (BGFX_STATE_ALPHA_TEST|BGFX_STATE_ALPHA_REF_MASK) & changedFlags) + { + uint32_t ref = (newFlags&BGFX_STATE_ALPHA_REF_MASK)>>BGFX_STATE_ALPHA_REF_SHIFT; + alphaRef = ref/255.0f; + DX_CHECK(s_renderCtx.m_device->SetRenderState(D3DRS_ALPHAREF, ref) ); + DX_CHECK(s_renderCtx.m_device->SetRenderState(D3DRS_ALPHATESTENABLE, !!(BGFX_STATE_ALPHA_TEST & newFlags) ) ); + } + + if ( (BGFX_STATE_ALPHA_WRITE|BGFX_STATE_RGB_WRITE) & changedFlags) + { + uint32_t writeEnable = (newFlags&BGFX_STATE_ALPHA_WRITE) ? D3DCOLORWRITEENABLE_ALPHA : 0; + writeEnable |= (newFlags&BGFX_STATE_RGB_WRITE) ? D3DCOLORWRITEENABLE_RED|D3DCOLORWRITEENABLE_GREEN|D3DCOLORWRITEENABLE_BLUE : 0; + DX_CHECK(s_renderCtx.m_device->SetRenderState(D3DRS_COLORWRITEENABLE, writeEnable) ); + } + + if (BGFX_STATE_BLEND_MASK & changedFlags) + { + bool alphaBlendEnabled = !!(BGFX_STATE_BLEND_MASK & newFlags); + DX_CHECK(s_renderCtx.m_device->SetRenderState(D3DRS_ALPHABLENDENABLE, alphaBlendEnabled) ); +// DX_CHECK(s_renderCtx.m_device->SetRenderState(D3DRS_SEPARATEALPHABLENDENABLE, alphaBlendEnabled) ); + + if (alphaBlendEnabled) + { + uint32_t blend = (newFlags&BGFX_STATE_BLEND_MASK)>>BGFX_STATE_BLEND_SHIFT; + uint32_t src = blend&0xf; + uint32_t dst = (blend>>4)&0xf; + + DX_CHECK(s_renderCtx.m_device->SetRenderState(D3DRS_SRCBLEND, s_blendFactor[src]) ); + DX_CHECK(s_renderCtx.m_device->SetRenderState(D3DRS_DESTBLEND, s_blendFactor[dst]) ); +// DX_CHECK(s_renderCtx.m_device->SetRenderState(D3DRS_SRCBLENDALPHA, D3DBLEND_SRCALPHA) ); +// DX_CHECK(s_renderCtx.m_device->SetRenderState(D3DRS_DESTBLENDALPHA, D3DBLEND_INVSRCALPHA) ); + } + } + + uint8_t primIndex = uint8_t( (newFlags&BGFX_STATE_PT_MASK)>>BGFX_STATE_PT_SHIFT); + primType = s_primType[primIndex]; + primNumVerts = s_primNumVerts[primIndex]; + } + + bool materialChanged = false; + bool constantsChanged = state.m_constBegin < state.m_constEnd; + rendererUpdateUniforms(m_render->m_constantBuffer, state.m_constBegin, state.m_constEnd); + + if (key.m_material != materialIdx) + { + materialIdx = key.m_material; + + if (bgfx::invalidHandle == materialIdx) + { + s_renderCtx.m_device->SetVertexShader(NULL); + s_renderCtx.m_device->SetPixelShader(NULL); + } + else + { + Material& material = s_renderCtx.m_materials[materialIdx]; + s_renderCtx.m_device->SetVertexShader( (IDirect3DVertexShader9*)material.m_vsh->m_ptr); + s_renderCtx.m_device->SetPixelShader( (IDirect3DPixelShader9*)material.m_fsh->m_ptr); + } + + materialChanged = + constantsChanged = true; + } + + if (bgfx::invalidHandle != materialIdx) + { + Material& material = s_renderCtx.m_materials[materialIdx]; + + if (constantsChanged) + { + Material& material = s_renderCtx.m_materials[materialIdx]; + material.m_vsh->m_constantBuffer->commit(materialChanged); + material.m_fsh->m_constantBuffer->commit(materialChanged); + } + + for (uint32_t ii = 0, num = material.m_numPredefined; ii < num; ++ii) + { + PredefinedUniform& predefined = material.m_predefined[ii]; + uint8_t flags = predefined.m_type&BGFX_UNIFORM_FRAGMENTBIT; + switch (predefined.m_type&(~BGFX_UNIFORM_FRAGMENTBIT) ) + { + case PredefinedUniform::ViewRect: + { + float rect[4]; + rect[0] = m_render->m_rect[view].m_x; + rect[1] = m_render->m_rect[view].m_y; + rect[2] = m_render->m_rect[view].m_width; + rect[3] = m_render->m_rect[view].m_height; + + s_renderCtx.setShaderConstantF(flags, predefined.m_loc, &rect[0], 1); + } + break; + + case PredefinedUniform::ViewTexel: + { + float rect[4]; + rect[0] = 1.0f/float(m_render->m_rect[view].m_width); + rect[1] = 1.0f/float(m_render->m_rect[view].m_height); + + s_renderCtx.setShaderConstantF(flags, predefined.m_loc, &rect[0], 1); + } + break; + + case PredefinedUniform::View: + { + s_renderCtx.setShaderConstantF(flags, predefined.m_loc, m_render->m_view[view].val, 4); + } + break; + + case PredefinedUniform::ViewProj: + { + s_renderCtx.setShaderConstantF(flags, predefined.m_loc, viewProj[view].val, 4); + } + break; + + case PredefinedUniform::Model: + { + const Matrix4& model = m_render->m_matrixCache.m_cache[state.m_matrix]; + s_renderCtx.setShaderConstantF(flags, predefined.m_loc, model.val, state.m_num*4); + } + break; + + case PredefinedUniform::ModelViewProj: + { + Matrix4 modelViewProj; + const Matrix4& model = m_render->m_matrixCache.m_cache[state.m_matrix]; + matrix_mul(modelViewProj.val, model.val, viewProj[view].val); + s_renderCtx.setShaderConstantF(flags, predefined.m_loc, modelViewProj.val, 4); + } + break; + + case PredefinedUniform::ModelViewProjX: + { + const Matrix4& model = m_render->m_matrixCache.m_cache[state.m_matrix]; + + static const BX_ALIGN_STRUCT_16(float) s_bias[16] = + { + 0.5f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.5f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.5f, 0.0f, + 0.5f, 0.5f, 0.5f, 1.0f, + }; + + uint8_t other = m_render->m_other[view]; + Matrix4 viewProjBias; + matrix_mul(viewProjBias.val, viewProj[other].val, s_bias); + + Matrix4 modelViewProj; + matrix_mul(modelViewProj.val, model.val, viewProjBias.val); + + s_renderCtx.setShaderConstantF(flags, predefined.m_loc, modelViewProj.val, 4); + } + break; + + case PredefinedUniform::ViewProjX: + { + static const BX_ALIGN_STRUCT_16(float) s_bias[16] = + { + 0.5f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.5f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.5f, 0.0f, + 0.5f, 0.5f, 0.5f, 1.0f, + }; + + uint8_t other = m_render->m_other[view]; + Matrix4 viewProjBias; + matrix_mul(viewProjBias.val, viewProj[other].val, s_bias); + + s_renderCtx.setShaderConstantF(flags, predefined.m_loc, viewProjBias.val, 4); + } + break; + + case PredefinedUniform::AlphaRef: + { + s_renderCtx.setShaderConstantF(flags, predefined.m_loc, &alphaRef, 1); + } + break; + + default: + BX_CHECK(false, "predefined %d not handled", predefined.m_type); + break; + } + } + } + +// if (BGFX_STATE_TEX_MASK & changedFlags) + { + uint64_t flag = BGFX_STATE_TEX0; + for (uint32_t stage = 0; stage < BGFX_STATE_TEX_COUNT; ++stage) + { + const Sampler& sampler = state.m_sampler[stage]; + Sampler& current = currentState.m_sampler[stage]; + if (current.m_idx != sampler.m_idx + || current.m_flags != sampler.m_flags + || materialChanged) + { + if (bgfx::invalidHandle != sampler.m_idx) + { + switch (sampler.m_flags&BGFX_SAMPLER_TYPE_MASK) + { + case 0: + s_renderCtx.m_textures[sampler.m_idx].commit(stage); + break; + + case 1: + s_renderCtx.m_renderTargets[sampler.m_idx].commit(stage); + break; + + case 2: +// id = s_renderCtx.m_renderTargets[sampler.m_idx].m_depth.m_id; + break; + } + } + else + { + DX_CHECK(s_renderCtx.m_device->SetTexture(stage, NULL) ); + } + } + + current = sampler; + flag <<= 1; + } + } + + if (currentState.m_vertexBuffer.idx != state.m_vertexBuffer.idx || materialChanged) + { + currentState.m_vertexBuffer = state.m_vertexBuffer; + + uint16_t handle = state.m_vertexBuffer.idx; + if (bgfx::invalidHandle != handle) + { + VertexBuffer& vb = s_renderCtx.m_vertexBuffers[handle]; + + uint16_t decl = vb.m_decl.idx == bgfx::invalidHandle ? state.m_vertexDecl.idx : vb.m_decl.idx; + VertexDeclaration& vertexDecl = s_renderCtx.m_vertexDecls[decl]; + DX_CHECK(s_renderCtx.m_device->SetStreamSource(0, vb.m_ptr, 0, vertexDecl.m_decl.m_stride) ); + DX_CHECK(s_renderCtx.m_device->SetVertexDeclaration(vertexDecl.m_ptr) ); + } + else + { + DX_CHECK(s_renderCtx.m_device->SetStreamSource(0, NULL, 0, 0) ); + } + } + + if (currentState.m_indexBuffer.idx != state.m_indexBuffer.idx) + { + currentState.m_indexBuffer = state.m_indexBuffer; + + uint16_t handle = state.m_indexBuffer.idx; + if (bgfx::invalidHandle != handle) + { + IndexBuffer& ib = s_renderCtx.m_indexBuffers[handle]; + DX_CHECK(s_renderCtx.m_device->SetIndices(ib.m_ptr) ); + } + else + { + DX_CHECK(s_renderCtx.m_device->SetIndices(NULL) ); + } + } + + if (bgfx::invalidHandle != state.m_indexBuffer.idx) + { + uint32_t numVertices = state.m_numVertices; + if (UINT32_C(0xffffffff) == numVertices) + { + VertexBuffer& vb = s_renderCtx.m_vertexBuffers[currentState.m_vertexBuffer.idx]; + uint16_t decl = vb.m_decl.idx == bgfx::invalidHandle ? state.m_vertexDecl.idx : vb.m_decl.idx; + VertexDeclaration& vertexDecl = s_renderCtx.m_vertexDecls[decl]; + numVertices = vb.m_size/vertexDecl.m_decl.m_stride; + } + + uint32_t numIndices; + uint32_t numPrims = 0; + + if (BGFX_DRAW_WHOLE_INDEX_BUFFER == state.m_startIndex) + { + numIndices = s_renderCtx.m_indexBuffers[state.m_indexBuffer.idx].m_size/2; + numPrims = numIndices/primNumVerts; + + DX_CHECK(s_renderCtx.m_device->DrawIndexedPrimitive(primType + , state.m_startVertex + , 0 + , numVertices + , 0 + , numPrims + ) ); + } + else if (primNumVerts <= state.m_numIndices) + { + numIndices = state.m_numIndices; + numPrims = numIndices/primNumVerts; + + DX_CHECK(s_renderCtx.m_device->DrawIndexedPrimitive(primType + , state.m_startVertex + , 0 + , numVertices + , state.m_startIndex + , numPrims + ) ); + } + + statsNumPrims += numPrims; + statsNumIndices += numIndices; + } + } + + PIX_ENDEVENT(); + } + + int64_t now = bx::getHPCounter(); + elapsed += now; + + static int64_t last = now; + int64_t frameTime = now - last; + last = now; + + if (m_render->m_debug & (BGFX_DEBUG_IFH|BGFX_DEBUG_STATS) ) + { + PIX_BEGINEVENT(D3DCOLOR_RGBA(0x40, 0x40, 0x40, 0xff), "debug"); + + TextVideoMem& tvm = s_renderCtx.m_textVideoMem; + + static int64_t next = now; + + if (now >= next) + { + next = now + bx::getHPFrequency(); + double freq = double(bx::getHPFrequency() ); + double toMs = 1000.0/freq; + + tvm.clear(); + uint16_t pos = 10; + tvm.printf(10, pos++, 0x8e, " Frame: %3.4f [ms] / %3.2f", frameTime*toMs, freq/frameTime); + tvm.printf(10, pos++, 0x8e, " Draw calls: %4d / %3.4f [ms]", m_render->m_num, elapsed*toMs); + tvm.printf(10, pos++, 0x8e, " Prims: %7d", statsNumPrims); + tvm.printf(10, pos++, 0x8e, " Indices: %7d", statsNumIndices); + tvm.printf(10, pos++, 0x8e, " DVB size: %7d", m_render->m_vboffset); + tvm.printf(10, pos++, 0x8e, " DIB size: %7d", m_render->m_iboffset); + + uint8_t attr[2] = { 0x89, 0x8a }; + uint8_t attrIndex = m_render->m_waitSubmit < m_render->m_waitRender; + + tvm.printf(10, pos++, attr[attrIndex&1], "Submit wait: %3.4f [ms]", m_render->m_waitSubmit*toMs); + tvm.printf(10, pos++, attr[(attrIndex+1)&1], "Render wait: %3.4f [ms]", m_render->m_waitRender*toMs); + } + + g_textVideoMemBlitter.blit(tvm); + + PIX_ENDEVENT(); + } + + s_renderCtx.m_device->EndScene(); + } +} + +#endif // BGFX_CONFIG_RENDERER_DIRECT3D diff --git a/src/renderer_d3d9.h b/src/renderer_d3d9.h new file mode 100644 index 000000000..7e7b27cad --- /dev/null +++ b/src/renderer_d3d9.h @@ -0,0 +1,317 @@ +/* + * Copyright 2011-2012 Branimir Karadzic. All rights reserved. + * License: http://www.opensource.org/licenses/BSD-2-Clause + */ + +#ifndef __RENDERER_D3D9_H__ +#define __RENDERER_D3D9_H__ + +#define BGFX_CONFIG_RENDERER_DIRECT3D_EX (BX_PLATFORM_WINDOWS && 0) + +#if BX_PLATFORM_WINDOWS +# if !BGFX_CONFIG_RENDERER_DIRECT3D_EX +# define D3D_DISABLE_9EX +# endif // !BGFX_CONFIG_RENDERER_DIRECT3D_EX +# include + +# ifndef D3DFMT_NULL +# define D3DFMT_NULL ( (D3DFORMAT)MAKEFOURCC('N','U','L','L') ) +# endif // D3DFMT_NULL + +# ifndef D3DFMT_DF16 +# define D3DFMT_DF16 ( (D3DFORMAT)MAKEFOURCC('D','F','1','6') ) +# endif // D3DFMT_DF16 + +# ifndef D3DFMT_DF24 +# define D3DFMT_DF24 ( (D3DFORMAT)MAKEFOURCC('D','F','2','4') ) +# endif // D3DFMT_DF24 + +# ifndef D3DFMT_INTZ +# define D3DFMT_INTZ ( (D3DFORMAT)MAKEFOURCC('I','N','T','Z') ) +# endif // D3DFMT_INTZ + +# ifndef D3DFMT_RAWZ +# define D3DFMT_RAWZ ( (D3DFORMAT)MAKEFOURCC('R','A','W','Z') ) +# endif // D3DFMT_RAWZ + +# if BGFX_CONFIG_RENDERER_DIRECT3D_EX +typedef HRESULT (WINAPI *Direct3DCreate9ExFunc)(UINT SDKVersion, IDirect3D9Ex**); +# else +typedef IDirect3D9* (WINAPI *Direct3DCreate9Func)(UINT SDKVersion); +# endif // BGFX_CONFIG_RENDERER_DIRECT3D_EX + +typedef int (WINAPI *D3DPERF_BeginEventFunc)(D3DCOLOR col, LPCWSTR wszName); +typedef int (WINAPI *D3DPERF_EndEventFunc)(); +typedef void (WINAPI *D3DPERF_SetMarkerFunc)(D3DCOLOR col, LPCWSTR wszName); +typedef void (WINAPI *D3DPERF_SetRegionFunc)(D3DCOLOR col, LPCWSTR wszName); +typedef BOOL (WINAPI *D3DPERF_QueryRepeatFrameFunc)(); +typedef void (WINAPI *D3DPERF_SetOptionsFunc)(DWORD dwOptions); +typedef DWORD (WINAPI *D3DPERF_GetStatusFunc)(); + +# define _PIX_SETMARKER(_col, _name) s_renderCtx.m_D3DPERF_SetMarker(_col, L#_name) +# define _PIX_BEGINEVENT(_col, _name) s_renderCtx.m_D3DPERF_BeginEvent(_col, L#_name) +# define _PIX_ENDEVENT() s_renderCtx.m_D3DPERF_EndEvent() + +#elif BX_PLATFORM_XBOX360 +# include +# define D3DUSAGE_DYNAMIC 0 // not supported on X360 +# define D3DLOCK_DISCARD 0 // not supported on X360 +# define D3DERR_DEVICEHUNG D3DERR_DEVICELOST // not supported on X360 +# define D3DERR_DEVICEREMOVED D3DERR_DEVICELOST // not supported on X360 +# define D3DMULTISAMPLE_8_SAMPLES D3DMULTISAMPLE_4_SAMPLES +# define D3DMULTISAMPLE_16_SAMPLES D3DMULTISAMPLE_4_SAMPLES + +# define _PIX_SETMARKER(_col, _name) +# define _PIX_BEGINEVENT(_col, _name) +# define _PIX_ENDEVENT() +#endif // BX_PLATFORM_ + +namespace bgfx +{ +# define _DX_CHECK(_call) \ + do { \ + HRESULT __hr__ = _call; \ + BX_CHECK(SUCCEEDED(__hr__), #_call " FAILED 0x%08x\n", (uint32_t)__hr__); \ + } while (0) + +#if BGFX_DEBUG +# define DX_CHECK(_call) _DX_CHECK(_call) +# define PIX_SETMARKER(_col, _name) _PIX_SETMARKER(_col, _name) +# define PIX_BEGINEVENT(_col, _name) _PIX_BEGINEVENT(_col, _name) +# define PIX_ENDEVENT() _PIX_ENDEVENT() +#else +# define DX_CHECK(_call) _call +# define PIX_SETMARKER(_col, _name) +# define PIX_BEGINEVENT(_col, _name) +# define PIX_ENDEVENT() +#endif // BGFX_DEBUG + +#define DX_RELEASE(_ptr, _expected) \ + do { \ + if (NULL != _ptr) \ + { \ + ULONG count = _ptr->Release(); \ + BX_CHECK(_expected == count, "RefCount is %d (expected %d).", count, _expected); \ + _ptr = NULL; \ + } \ + } while (0) + + struct IndexBuffer + { + IndexBuffer() + : m_ptr(NULL) + , m_dynamic(false) + { + } + + void create(uint32_t _size, void* _data); + void update(uint32_t _size, void* _data) + { + void* buffer; + DX_CHECK(m_ptr->Lock(0 + , _size + , &buffer + , m_dynamic?D3DLOCK_DISCARD/*|D3DLOCK_NOOVERWRITE*/:0 + ) ); + + memcpy(buffer, _data, _size); + + m_ptr->Unlock(); + } + + void destroy() + { + if (NULL != m_ptr) + { + DX_RELEASE(m_ptr, 0); + m_dynamic = false; + } + } + + void preReset(); + void postReset(); + + IDirect3DIndexBuffer9* m_ptr; + uint32_t m_size; + bool m_dynamic; + }; + + struct VertexBuffer + { + VertexBuffer() + : m_ptr(NULL) + , m_dynamic(false) + { + } + + void create(uint32_t _size, void* _data, VertexDeclHandle _declHandle); + void update(uint32_t _size, void* _data) + { + void* buffer; + DX_CHECK(m_ptr->Lock(0 + , _size + , &buffer + , m_dynamic?D3DLOCK_DISCARD/*|D3DLOCK_NOOVERWRITE*/:0 + ) ); + + memcpy(buffer, _data, _size); + + m_ptr->Unlock(); + } + + void destroy() + { + if (NULL != m_ptr) + { + DX_RELEASE(m_ptr, 0); + m_dynamic = false; + } + } + + void preReset(); + void postReset(); + + IDirect3DVertexBuffer9* m_ptr; + uint32_t m_size; + VertexDeclHandle m_decl; + bool m_dynamic; + }; + + struct VertexDeclaration + { + void create(const VertexDecl& _decl); + + void destroy() + { + DX_RELEASE(m_ptr, 0); + } + + IDirect3DVertexDeclaration9* m_ptr; + VertexDecl m_decl; + }; + + struct Shader + { + Shader() + : m_ptr(NULL) + { + } + + void create(bool _fragment, const Memory* _mem); + DWORD* getShaderCode(uint8_t _fragmentBit, const Memory* _mem); + + void destroy() + { + ConstantBuffer::destroy(m_constantBuffer); + m_constantBuffer = NULL; + m_numPredefined = 0; + + DX_RELEASE(m_ptr, 0); + } + + IUnknown* m_ptr; + ConstantBuffer* m_constantBuffer; + PredefinedUniform m_predefined[PredefinedUniform::Count]; + uint8_t m_numPredefined; + }; + + struct Material + { + void create(const Shader& _vsh, const Shader& _fsh) + { + BX_CHECK(NULL != _vsh.m_ptr, "Vertex shader doesn't exist."); + m_vsh = &_vsh; + + BX_CHECK(NULL != _fsh.m_ptr, "Fragment shader doesn't exist."); + m_fsh = &_fsh; + + memcpy(&m_predefined[0], _vsh.m_predefined, _vsh.m_numPredefined*sizeof(PredefinedUniform) ); + memcpy(&m_predefined[_vsh.m_numPredefined], _fsh.m_predefined, _fsh.m_numPredefined*sizeof(PredefinedUniform) ); + m_numPredefined = _vsh.m_numPredefined + _fsh.m_numPredefined; + } + + void destroy() + { + m_numPredefined = 0; + m_vsh = NULL; + m_fsh = NULL; + } + + const Shader* m_vsh; + const Shader* m_fsh; + + PredefinedUniform m_predefined[PredefinedUniform::Count*2]; + uint8_t m_numPredefined; + }; + + struct Texture + { + Texture() + : m_ptr(NULL) + { + } + + void create(const Memory* _mem, uint32_t _flags); + + void destroy() + { + DX_RELEASE(m_ptr, 0); + } + + void commit(uint8_t _stage); + + IDirect3DTexture9* m_ptr; + D3DTEXTUREFILTERTYPE m_minFilter; + D3DTEXTUREFILTERTYPE m_magFilter; + D3DTEXTUREFILTERTYPE m_mipFilter; + D3DTEXTUREADDRESS m_tau; + D3DTEXTUREADDRESS m_tav; + }; + + struct RenderTarget + { + RenderTarget() + : m_colorTexture(NULL) + , m_color(NULL) + , m_depthTexture(NULL) + , m_depth(NULL) + , m_width(0) + , m_height(0) + , m_flags(0) + { + } + + void create(uint16_t _width, uint16_t _height, uint32_t _flags); + void createTextures(); + void destroyTextures(); + + void destroy() + { + destroyTextures(); + m_flags = 0; + } + + void preReset() + { + destroyTextures(); + } + + void postReset() + { + createTextures(); + } + + void commit(uint8_t _stage); + + IDirect3DTexture9* m_colorTexture; + IDirect3DSurface9* m_color; + IDirect3DTexture9* m_depthTexture; + IDirect3DSurface9* m_depth; + uint16_t m_width; + uint16_t m_height; + uint32_t m_flags; + }; + +} // namespace bgfx + +#endif // __RENDERER_D3D9_H__ diff --git a/src/renderer_gl.cpp b/src/renderer_gl.cpp new file mode 100644 index 000000000..b375b7ef5 --- /dev/null +++ b/src/renderer_gl.cpp @@ -0,0 +1,1730 @@ +/* + * Copyright 2011-2012 Branimir Karadzic. All rights reserved. + * License: http://www.opensource.org/licenses/BSD-2-Clause + */ + +#include "bgfx_p.h" + +#if BGFX_CONFIG_RENDERER_OPENGLES +# include "renderer_gl.h" +# include +# include + +#if BX_PLATFORM_WINDOWS +# define glClearDepthf(_depth) glClearDepth(_depth) +#endif // BX_PLATFROM_WINDOWS + +namespace bgfx +{ + struct RendererContext + { + RendererContext() + : m_dxtSupport(false) + { + memset(&m_resolution, 0, sizeof(m_resolution) ); + } + + void updateResolution(const Resolution& _resolution) + { + if (m_resolution.m_width != _resolution.m_width + || m_resolution.m_height != _resolution.m_height + || m_resolution.m_flags != _resolution.m_flags) + { + m_textVideoMem.resize(false, _resolution.m_width, _resolution.m_height); + + m_resolution = _resolution; +#if BX_PLATFORM_NACL + extern void naclSetRenderContextSize(uint32_t _width, uint32_t _height); + naclSetRenderContextSize(_resolution.m_width, _resolution.m_height); +#endif // BX_PLATFORM_NACL + } + } + + IndexBuffer m_indexBuffers[BGFX_CONFIG_MAX_INDEX_BUFFERS]; + VertexBuffer m_vertexBuffers[BGFX_CONFIG_MAX_VERTEX_BUFFERS]; + Shader m_vertexShaders[BGFX_CONFIG_MAX_VERTEX_SHADERS]; + Shader m_fragmentShaders[BGFX_CONFIG_MAX_FRAGMENT_SHADERS]; + Material m_materials[BGFX_CONFIG_MAX_MATERIALS]; + Texture m_textures[BGFX_CONFIG_MAX_TEXTURES]; + VertexDecl m_vertexDecls[BGFX_CONFIG_MAX_VERTEX_DECLS]; + RenderTarget m_renderTargets[BGFX_CONFIG_MAX_RENDER_TARGETS]; + UniformRegistry m_uniformReg; + void* m_uniforms[BGFX_CONFIG_MAX_UNIFORMS]; + + TextVideoMem m_textVideoMem; + + Resolution m_resolution; + bool m_dxtSupport; + }; + + RendererContext s_renderCtx; + + struct Extension + { + enum Enum + { + GL_EXT_texture_format_BGRA8888, + GL_EXT_texture_compression_dxt1, + GL_CHROMIUM_texture_compression_dxt3, + GL_CHROMIUM_texture_compression_dxt5, + GL_OES_standard_derivatives, + + Count + }; + + const char* m_name; + bool m_supported; + }; + + static Extension s_extension[Extension::Count] = + { + { "GL_EXT_texture_format_BGRA8888", false }, + { "GL_EXT_texture_compression_dxt1", false }, + { "GL_CHROMIUM_texture_compression_dxt3", false }, + { "GL_CHROMIUM_texture_compression_dxt5", false }, + { "GL_OES_standard_derivatives", false }, + }; + + static const GLenum s_primType[] = + { + GL_TRIANGLES, + GL_LINES, + }; + + static const uint32_t s_primNumVerts[] = + { + 3, + 2, + }; + + static const char* s_attribName[Attrib::Count] = + { + "a_position", + "a_normal", + "a_color", + "a_color1", + "a_indices", + "a_weight", + "a_texcoord0", + "a_texcoord1", + "a_texcoord2", + "a_texcoord3", + "a_texcoord4", + "a_texcoord5", + "a_texcoord6", + "a_texcoord7", + }; + + static const GLenum s_attribType[AttribType::Count] = + { + GL_UNSIGNED_BYTE, + GL_UNSIGNED_SHORT, + GL_FLOAT, + }; + + static const GLenum s_blendFactor[] = + { + 0, // ignored + GL_ZERO, + GL_ONE, + GL_SRC_COLOR, + GL_ONE_MINUS_SRC_COLOR, + GL_SRC_ALPHA, + GL_ONE_MINUS_SRC_ALPHA, + GL_DST_ALPHA, + GL_ONE_MINUS_DST_ALPHA, + GL_DST_COLOR, + GL_ONE_MINUS_DST_COLOR, + GL_SRC_ALPHA_SATURATE, + }; + + static const GLenum s_depthFunc[] = + { + 0, // ignored + GL_LESS, + GL_LEQUAL, + GL_EQUAL, + GL_GEQUAL, + GL_GREATER, + GL_NOTEQUAL, + GL_NEVER, + GL_ALWAYS, + }; + + // Specifies the internal format of the texture. + // Must be one of the following symbolic constants: + // GL_ALPHA, GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA. + static const GLenum s_colorFormat[] = + { + 0, // ignored + GL_RGBA, + GL_RGBA, + }; + + static const GLenum s_depthFormat[] = + { + 0, // ignored + 0, + }; + + static const GLenum s_textureAddress[] = + { + GL_REPEAT, + GL_MIRRORED_REPEAT, + GL_CLAMP_TO_EDGE, + }; + + static const GLenum s_textureFilter[] = + { + GL_LINEAR, + GL_NEAREST, + }; + + const char* glslTypeName(GLuint _type) + { +#define GLSL_TYPE(_ty) case _ty: return #_ty + + switch (_type) + { + GLSL_TYPE(GL_FLOAT); + GLSL_TYPE(GL_FLOAT_VEC2); + GLSL_TYPE(GL_FLOAT_VEC3); + GLSL_TYPE(GL_FLOAT_VEC4); + GLSL_TYPE(GL_FLOAT_MAT2); + GLSL_TYPE(GL_FLOAT_MAT3); + GLSL_TYPE(GL_FLOAT_MAT4); +// GLSL_TYPE(GL_FLOAT_MAT2x3); +// GLSL_TYPE(GL_FLOAT_MAT2x4); +// GLSL_TYPE(GL_FLOAT_MAT3x2); +// GLSL_TYPE(GL_FLOAT_MAT3x4); +// GLSL_TYPE(GL_FLOAT_MAT4x2); +// GLSL_TYPE(GL_FLOAT_MAT4x3); +// GLSL_TYPE(GL_SAMPLER_1D); + GLSL_TYPE(GL_SAMPLER_2D); +// GLSL_TYPE(GL_SAMPLER_3D); + GLSL_TYPE(GL_SAMPLER_CUBE); +// GLSL_TYPE(GL_SAMPLER_1D_SHADOW); +// GLSL_TYPE(GL_SAMPLER_2D_SHADOW); + } + +#undef GLSL_TYPE + + return "UNKNOWN GLSL TYPE!"; + } + + const char* glEnumName(GLenum _enum) + { +#define GLENUM(_ty) case _ty: return #_ty + + switch (_enum) + { + GLENUM(GL_TEXTURE); + GLENUM(GL_RENDERBUFFER); + } + +#undef GLENUM + + return "UNKNOWN GLENUM!"; + } + + ConstantType::Enum convertGlType(GLenum _type) + { + switch (_type) + { + case GL_FLOAT: + return ConstantType::Uniform1fv; + + case GL_FLOAT_VEC2: + return ConstantType::Uniform2fv; + + case GL_FLOAT_VEC3: + return ConstantType::Uniform3fv; + + case GL_FLOAT_VEC4: + return ConstantType::Uniform4fv; + + case GL_FLOAT_MAT2: + break; + + case GL_FLOAT_MAT3: + return ConstantType::Uniform3x3fv; + + case GL_FLOAT_MAT4: + return ConstantType::Uniform4x4fv; + +// case GL_FLOAT_MAT2x3: +// case GL_FLOAT_MAT2x4: +// case GL_FLOAT_MAT3x2: +// case GL_FLOAT_MAT3x4: +// case GL_FLOAT_MAT4x2: +// case GL_FLOAT_MAT4x3: +// break; + + case GL_SAMPLER_2D: + case GL_SAMPLER_CUBE: +// case GL_SAMPLER_1D: +// case GL_SAMPLER_3D: +// case GL_SAMPLER_1D_SHADOW: +// case GL_SAMPLER_2D_SHADOW: + return ConstantType::Uniform1iv; + }; + + return ConstantType::End; + } + + void Material::init() + { + GLint activeAttribs; + GLint activeUniforms; + + GL_CHECK(glGetProgramiv(m_id, GL_ACTIVE_ATTRIBUTES, &activeAttribs) ); + GL_CHECK(glGetProgramiv(m_id, GL_ACTIVE_UNIFORMS, &activeUniforms) ); + + GLint max0, max1; + GL_CHECK(glGetProgramiv(m_id, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &max0) ); + GL_CHECK(glGetProgramiv(m_id, GL_ACTIVE_UNIFORM_MAX_LENGTH, &max1) ); + + GLint maxLength = uint32_max(max0, max1); + char* name = (char*)g_realloc(NULL, maxLength + 1); + + BX_TRACE("Program %d", m_id); + BX_TRACE("Attributes:"); + for (int32_t ii = 0; ii < activeAttribs; ++ii) + { + GLint size; + GLenum type; + + GL_CHECK(glGetActiveAttrib(m_id, ii, maxLength + 1, NULL, &size, &type, name) ); + BX_TRACE("\t%s %s is at location %d" + , glslTypeName(type) + , name + , glGetAttribLocation(m_id, name) + ); + } + + m_numPredefined = 0; + m_constantBuffer = ConstantBuffer::create(1024); + m_numSamplers = 0; + + BX_TRACE("Uniforms:"); + for (int32_t ii = 0; ii < activeUniforms; ++ii) + { + GLint num; + GLenum gltype; + + GL_CHECK(glGetActiveUniform(m_id, ii, maxLength + 1, NULL, &num, &gltype, name) ); + GLint loc = glGetUniformLocation(m_id, name); + + int offset = 0; + char* array = strchr(name, '['); + if (NULL != array) + { + BX_TRACE("--- %s", name); + *array = '\0'; + array++; + char* end = strchr(array, ']'); + *end = '\0'; + offset = atoi(array); + } + + if (GL_SAMPLER_2D == gltype) + { + BX_TRACE("Sampler %d at %d.", m_numSamplers, loc); + m_sampler[m_numSamplers] = loc; + m_numSamplers++; + } + + const void* data = NULL; + PredefinedUniform::Enum predefined = nameToPredefinedUniformEnum(name); + if (PredefinedUniform::Count != predefined) + { + m_predefined[m_numPredefined].m_loc = loc; + m_predefined[m_numPredefined].m_type = predefined; + m_numPredefined++; + } + else + { + const UniformInfo* info = s_renderCtx.m_uniformReg.find(name); + if (NULL != info) + { + data = info->m_data; + ConstantType::Enum type = convertGlType(gltype); + m_constantBuffer->writeUniformRef(type, loc, data, num); + BX_TRACE("store %s %p", name, data); + } + } + + BX_TRACE("\tuniform %s %s%s is at location %d, size %d (%p), offset %d" + , glslTypeName(gltype) + , name + , PredefinedUniform::Count != predefined ? "*" : "" + , loc + , num + , data + , offset + ); + } + + m_constantBuffer->finish(); + + g_free(name); + + memset(m_attributes, 0xff, sizeof(m_attributes) ); + uint32_t used = 0; + for (uint32_t ii = 0; ii < Attrib::Count; ++ii) + { + GLuint loc = glGetAttribLocation(m_id, s_attribName[ii]); + if ( GLuint(-1) != loc ) + { + BX_TRACE("attr %s: %d", s_attribName[ii], loc); + m_attributes[ii] = loc; + m_used[used++] = ii; + } + } + m_used[used] = Attrib::Count; + } + + void Material::bindAttributes(const VertexDecl& _vertexDecl, uint32_t _baseVertex) + { + uint32_t enabled = 0; + for (uint32_t ii = 0; Attrib::Count != m_used[ii]; ++ii) + { + Attrib::Enum attr = Attrib::Enum(m_used[ii]); + GLuint loc = m_attributes[attr]; + + uint8_t num; + AttribType::Enum type; + bool normalized; + _vertexDecl.decode(attr, num, type, normalized); + + if (0xffff != loc + && 0xff != _vertexDecl.m_attributes[attr]) + { + GL_CHECK(glEnableVertexAttribArray(loc) ); + enabled |= 1<>BGFX_TEXTURE_U_SHIFT]) ); + GL_CHECK(glTexParameteri(m_target, GL_TEXTURE_WRAP_T, s_textureAddress[(_flags&BGFX_TEXTURE_V_MASK)>>BGFX_TEXTURE_V_SHIFT]) ); + GL_CHECK(glTexParameteri(m_target, GL_TEXTURE_MIN_FILTER, s_textureFilter[(_flags&BGFX_TEXTURE_MIN_MASK)>>BGFX_TEXTURE_MIN_SHIFT]) ); + GL_CHECK(glTexParameteri(m_target, GL_TEXTURE_MAG_FILTER, s_textureFilter[(_flags&BGFX_TEXTURE_MAG_MASK)>>BGFX_TEXTURE_MAG_SHIFT]) ); + + Dds dds; + + if (parseDds(dds, _mem) ) + { + GLenum typefmt[4] = + { + GL_RGBA, + GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, + GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, + GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, + }; + + GL_CHECK(glTexParameteri(m_target, GL_TEXTURE_MIN_FILTER, 1 < dds.m_numMips ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR) ); + + GLenum fmt = typefmt[dds.m_type]; + + uint32_t width = dds.m_width; + uint32_t height = dds.m_height; + + if (!s_renderCtx.m_dxtSupport + || 0 == dds.m_type) + { + fmt = s_extension[Extension::GL_EXT_texture_format_BGRA8888].m_supported ? GL_BGRA_EXT : GL_RGBA; + + for (uint32_t lod = 0, num = dds.m_numMips; lod < num; ++lod) + { + width = uint32_max(1, width); + height = uint32_max(1, height); + + Mip mip; + if (getRawImageData(dds, lod, _mem, mip) ) + { + uint8_t* bits = (uint8_t*)g_realloc(NULL, mip.m_width*mip.m_height*4); + + mip.decode(bits); + uint32_t dstpitch = width*4; + + if (GL_RGBA == fmt) + { + for (uint32_t yy = 0; yy < height; ++yy) + { + uint8_t* dst = &bits[yy*dstpitch]; + + for (uint32_t xx = 0; xx < width; ++xx) + { + uint8_t tmp = dst[0]; + dst[0] = dst[2]; + dst[2] = tmp; + dst += 4; + } + } + } + + GL_CHECK(glTexImage2D(m_target + , lod + , fmt + , width + , height + , 0 + , fmt + , GL_UNSIGNED_BYTE + , bits + ) ); + + g_free(bits); + } + + width >>= 1; + height >>= 1; + } + } + else + { + for (uint32_t ii = 0, num = dds.m_numMips; ii < num; ++ii) + { + width = uint32_max(1, width); + height = uint32_max(1, height); + + Mip mip; + if (getRawImageData(dds, ii, _mem, mip) ) + { + GL_CHECK(glCompressedTexImage2D(m_target + , ii + , fmt + , width + , height + , 0 + , mip.m_size + , mip.m_data + ) ); + } + + width >>= 1; + height >>= 1; + } + } + + } + else + { + StreamRead stream(_mem->data, _mem->size); + + uint32_t magic; + stream.read(magic); + + if (BGFX_MAGIC == magic) + { + uint16_t width; + stream.read(width); + + uint16_t height; + stream.read(height); + + uint8_t bpp; + stream.read(bpp); + + uint8_t numMips; + stream.read(numMips); + + stream.align(16); + + GL_CHECK(glTexParameteri(m_target, GL_TEXTURE_MIN_FILTER, 1 < dds.m_numMips ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR) ); + + for (uint8_t mip = 0; mip < numMips; ++mip) + { + width = uint32_max(width, 1); + height = uint32_max(height, 1); + + const uint8_t* data = stream.getDataPtr(); + stream.skip(width*height*bpp); + + GL_CHECK(glTexImage2D(m_target + , mip + , 1 == bpp ? GL_LUMINANCE : GL_RGBA + , width + , height + , 0 + , 1 == bpp ? GL_LUMINANCE : GL_RGBA + , GL_UNSIGNED_BYTE + , data + ) ); + + width >>= 1; + height >>= 1; + } + } + else + { + // + } + } + + GL_CHECK(glBindTexture(m_target, 0) ); + } + + void Texture::createColor(uint32_t _width, uint32_t _height) + { + GLenum internalFormat = /*_fp ? GL_RGBA16F_ARB :*/ GL_RGBA; + GLenum type = /*_fp ? GL_HALF_FLOAT_ARB :*/ GL_UNSIGNED_BYTE; + m_target = /*0 != _depth ? GL_TEXTURE_3D :*/ GL_TEXTURE_2D; + + GL_CHECK(glGenTextures(1, &m_id) ); + BX_CHECK(0 != m_id, "Failed to generate texture id."); + GL_CHECK(glBindTexture(m_target, m_id) ); + GL_CHECK(glTexParameteri(m_target, GL_TEXTURE_MIN_FILTER, GL_LINEAR) ); + GL_CHECK(glTexParameteri(m_target, GL_TEXTURE_MAG_FILTER, GL_LINEAR) ); + GL_CHECK(glTexParameteri(m_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE) ); + GL_CHECK(glTexParameteri(m_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE) ); + + GL_CHECK(glTexImage2D(m_target + , 0 + , internalFormat + , _width + , _height + , 0 + , GL_RGBA + , type + , NULL + ) ); + + GL_CHECK(glBindTexture(m_target, 0) ); + } + + void Texture::createDepth(uint32_t _width, uint32_t _height) + { + m_target = GL_TEXTURE_2D; + + GL_CHECK(glGenTextures(1, &m_id) ); + BX_CHECK(0 != m_id, "Failed to generate texture id."); + GL_CHECK(glBindTexture(m_target, m_id) ); +// glTexParameteri(m_target, GL_TEXTURE_COMPARE_MODE, GL_NONE); +// glTexParameteri(m_target, GL_DEPTH_TEXTURE_MODE, GL_NONE); + GL_CHECK(glTexParameteri(m_target, GL_TEXTURE_MIN_FILTER, GL_LINEAR) ); + GL_CHECK(glTexParameteri(m_target, GL_TEXTURE_MAG_FILTER, GL_LINEAR) ); + GL_CHECK(glTexParameteri(m_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE) ); + GL_CHECK(glTexParameteri(m_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE) ); + + // OpenGL ES 2.0 doesn't support GL_DEPTH_COMPONENT... this will fail. + GL_CHECK(glTexImage2D(m_target + , 0 + , GL_DEPTH_COMPONENT + , _width + , _height + , 0 + , GL_DEPTH_COMPONENT + , GL_FLOAT + , NULL + ) ); + + GL_CHECK(glBindTexture(m_target, 0) ); + } + + void Texture::destroy() + { + if (0 != m_id) + { + GL_CHECK(glBindTexture(m_target, 0) ); + GL_CHECK(glDeleteTextures(1, &m_id) ); + m_id = 0; + } + } + + void RenderTarget::create(uint16_t _width, uint16_t _height, uint32_t _flags) + { + BX_TRACE("Create render target %dx%d 0x%02x", _width, _height, _flags); + + m_width = _width; + m_height = _height; + + uint32_t colorFormat = (_flags&BGFX_RENDER_TARGET_COLOR_MASK)>>BGFX_RENDER_TARGET_COLOR_SHIFT; + uint32_t depthFormat = (_flags&BGFX_RENDER_TARGET_DEPTH_MASK)>>BGFX_RENDER_TARGET_DEPTH_SHIFT; + + if (0 < colorFormat) + { + m_color.createColor(_width, _height); + } + +#if 0 // GLES can't create texture with depth texture format... + if (0 < depthFormat) + { + m_depth.createDepth(_width, _height); + } +#endif // + + GL_CHECK(glGenFramebuffers(1, &m_fbo) ); + BX_CHECK(0 != m_fbo, "Failed to generate framebuffer id."); + GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER, m_fbo) ); + + if (0 < colorFormat) + { + GL_CHECK(glFramebufferTexture2D(GL_FRAMEBUFFER + , GL_COLOR_ATTACHMENT0 + , GL_TEXTURE_2D + , m_color.m_id + , 0 + ) ); + } + + if (0 < depthFormat) + { + if (0 < colorFormat) + { + GL_CHECK(glGenRenderbuffers(1, &m_rbo) ); + BX_CHECK(0 != m_rbo, "Failed to generate renderbuffer id."); + GL_CHECK(glBindRenderbuffer(GL_RENDERBUFFER, m_rbo) ); + GL_CHECK(glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, _width, _height) ); + GL_CHECK(glBindRenderbuffer(GL_RENDERBUFFER, 0) ); + + GL_CHECK(glFramebufferRenderbuffer(GL_FRAMEBUFFER + , GL_DEPTH_ATTACHMENT + , GL_RENDERBUFFER + , m_rbo + ) ); + } + else + { + GL_CHECK(glFramebufferTexture2D(GL_FRAMEBUFFER + , GL_DEPTH_ATTACHMENT + , GL_TEXTURE_2D + , m_depth.m_id + , 0 + ) ); + } + } + + BX_CHECK(GL_FRAMEBUFFER_COMPLETE == glCheckFramebufferStatus(GL_FRAMEBUFFER) + , "glCheckFramebufferStatus failed 0x%08x" + , glCheckFramebufferStatus(GL_FRAMEBUFFER) + ); + + GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER, 0) ); + } + + void RenderTarget::destroy() + { + GL_CHECK(glDeleteFramebuffers(1, &m_fbo) ); + + if (0 != m_rbo) + { + GL_CHECK(glDeleteRenderbuffers(1, &m_rbo) ); + } + + m_color.destroy(); + m_depth.destroy(); + } + + void ConstantBuffer::commit(bool _force) + { + reset(); + + do + { + uint32_t opcode = read(); + + if (ConstantType::End == opcode) + { + break; + } + + ConstantType::Enum type; + uint16_t loc; + uint16_t num; + uint16_t copy; + decodeOpcode(opcode, type, loc, num, copy); + + const char* data; + if (copy) + { + data = read(g_constantTypeSize[type]*num); + } + else + { + memcpy(&data, read(sizeof(void*) ), sizeof(void*) ); + } + +#define CASE_IMPLEMENT_UNIFORM(_uniform, _glsuffix, _dxsuffix, _type) \ + case ConstantType::_uniform: \ + { \ + _type* value = (_type*)data; \ + GL_CHECK(glUniform##_glsuffix(loc, num, value) ); \ + } \ + break; + +#define CASE_IMPLEMENT_UNIFORM_T(_uniform, _glsuffix, _dxsuffix, _type) \ + case ConstantType::_uniform: \ + { \ + _type* value = (_type*)data; \ + GL_CHECK(glUniform##_glsuffix(loc, num, GL_FALSE, value) ); \ + } \ + break; + + switch (type) + { +// case ConstantType::Uniform1iv: +// { +// int* value = (int*)data; +// BX_TRACE("Uniform1iv sampler %d, loc %d (num %d, copy %d)", *value, loc, num, copy); +// GL_CHECK(glUniform1iv(loc, num, value) ); +// } +// break; +// + + CASE_IMPLEMENT_UNIFORM(Uniform1i, 1iv, I, int); + CASE_IMPLEMENT_UNIFORM(Uniform1f, 1fv, F, float); + CASE_IMPLEMENT_UNIFORM(Uniform1iv, 1iv, I, int); + CASE_IMPLEMENT_UNIFORM(Uniform1fv, 1fv, F, float); + CASE_IMPLEMENT_UNIFORM(Uniform2fv, 2fv, F, float); + CASE_IMPLEMENT_UNIFORM(Uniform3fv, 3fv, F, float); + CASE_IMPLEMENT_UNIFORM(Uniform4fv, 4fv, F, float); + CASE_IMPLEMENT_UNIFORM_T(Uniform3x3fv, Matrix3fv, F, float); + CASE_IMPLEMENT_UNIFORM_T(Uniform4x4fv, Matrix4fv, F, float); + + case ConstantType::End: + break; + + default: + BX_TRACE("%4d: INVALID 0x%08x, t %d, l %d, n %d, c %d", m_pos, opcode, type, loc, num, copy); + break; + } + +#undef CASE_IMPLEMENT_UNIFORM +#undef CASE_IMPLEMENT_UNIFORM_T + + } while (true); + } + +#if BX_PLATFORM_WINDOWS + HDC g_hdc; + HGLRC g_hglrc; +#endif // BX_PLATFORM_WINDOWS + + void initGl(uint32_t _width, uint32_t _height) + { +#if BX_PLATFORM_WINDOWS + static PIXELFORMATDESCRIPTOR pfd = + { + sizeof(PIXELFORMATDESCRIPTOR), + 1, + PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL|PFD_DOUBLEBUFFER, + PFD_TYPE_RGBA, + 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 16, 0, 0, + PFD_MAIN_PLANE, + 0, 0, 0, 0 + }; + + g_hdc = GetDC(hwnd); + + int pixelFormat = ChoosePixelFormat(g_hdc, &pfd); + BX_CHECK(0 != pixelFormat, "ChoosePixelFormat failed!"); + + int result; + result = SetPixelFormat(g_hdc, pixelFormat, &pfd); + BX_CHECK(0 != result, "SetPixelFormat failed!"); + + g_hglrc = wglCreateContext(g_hdc); + BX_CHECK(NULL != g_hglrc, "wglCreateContext failed!"); + + result = wglMakeCurrent(g_hdc, g_hglrc); + BX_CHECK(0 != result, "wglMakeCurrent failed!"); + + glewInit(); +#endif // BX_PLATFORM_WINDOWS + } + + static bool s_exit = false; + +#if BX_PLATFORM_WINDOWS + DWORD WINAPI renderThread(LPVOID _arg) + { + wglMakeCurrent(g_hdc, g_hglrc); + + while (!s_exit) + { + renderFrame(); + } + + s_exit = false; + + return EXIT_SUCCESS; + } +#endif // BX_PLATFORM_WINDOWS + + void TextVideoMemBlitter::setup() + { + uint32_t width = s_renderCtx.m_resolution.m_width; + uint32_t height = s_renderCtx.m_resolution.m_height; + + GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER, 0) ); + GL_CHECK(glViewport(0, 0, width, height) ); + + GL_CHECK(glDisable(GL_DEPTH_TEST) ); + GL_CHECK(glDepthFunc(GL_ALWAYS) ); + GL_CHECK(glDisable(GL_CULL_FACE) ); + GL_CHECK(glDisable(GL_BLEND) ); + GL_CHECK(glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE) ); + + Material& material = s_renderCtx.m_materials[m_material.idx]; + GL_CHECK(glUseProgram(material.m_id) ); + + float proj[16]; + matrix_ortho(proj, 0.0f, (float)width, (float)height, 0.0f, 0.0f, 1000.0f); + + PredefinedUniform& predefined = material.m_predefined[0]; + + GL_CHECK(glUniformMatrix4fv(predefined.m_loc + , 1 + , GL_FALSE + , proj + ) ); + + GL_CHECK(glBindTexture(GL_TEXTURE_2D, s_renderCtx.m_textures[m_texture.idx].m_id) ); + } + + void TextVideoMemBlitter::render(uint32_t _numIndices) + { + uint32_t numVertices = _numIndices*4/6; + s_renderCtx.m_indexBuffers[m_ib->handle.idx].update(_numIndices*2, m_ib->data); + s_renderCtx.m_vertexBuffers[m_vb->handle.idx].update(numVertices*m_decl.m_stride, m_vb->data); + + VertexBuffer& vb = s_renderCtx.m_vertexBuffers[m_vb->handle.idx]; + GL_CHECK(glBindBuffer(GL_ARRAY_BUFFER, vb.m_id) ); + + IndexBuffer& ib = s_renderCtx.m_indexBuffers[m_ib->handle.idx]; + GL_CHECK(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ib.m_id) ); + + Material& material = s_renderCtx.m_materials[m_material.idx]; + material.bindAttributes(m_decl, 0); + + GL_CHECK(glDrawElements(GL_TRIANGLES + , _numIndices + , GL_UNSIGNED_SHORT + , (void*)0 + ) ); + } + + void Context::flip() + { +#if BX_PLATFORM_WINDOWS + wglMakeCurrent(g_hdc, g_hglrc); + SwapBuffers(g_hdc); +#endif // BX_PLATFORM_WINDOWS + } + + GLint glGet(GLenum _pname) + { + GLint result; + GL_CHECK(glGetIntegerv(_pname, &result) ); + return result; + } + + void Context::rendererInit() + { +#if BGFX_DEBUG + GLint numCmpFormats; + GL_CHECK(glGetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS, &numCmpFormats) ); + + BX_TRACE("GL_NUM_COMPRESSED_TEXTURE_FORMATS %d", numCmpFormats); + + GLint* formats = (GLint*)alloca(sizeof(GLint)*numCmpFormats); + glGetIntegerv(GL_COMPRESSED_TEXTURE_FORMATS, formats); + + for (GLint ii = 0; ii < numCmpFormats; ++ii) + { + BX_TRACE("\t%3d: %8x", ii, formats[ii]); + } + +# define GL_GET(_pname, _min) BX_TRACE(#_pname " %d (min: %d)", glGet(_pname), _min) + + GL_GET(GL_MAX_FRAGMENT_UNIFORM_VECTORS, 16); + GL_GET(GL_MAX_VERTEX_UNIFORM_VECTORS, 128); + GL_GET(GL_MAX_VARYING_VECTORS, 8); + GL_GET(GL_MAX_VERTEX_ATTRIBS, 8); + GL_GET(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, 8); + GL_GET(GL_MAX_CUBE_MAP_TEXTURE_SIZE, 16); + GL_GET(GL_MAX_TEXTURE_IMAGE_UNITS, 8); + GL_GET(GL_MAX_TEXTURE_SIZE, 64); + GL_GET(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, 0); + GL_GET(GL_MAX_RENDERBUFFER_SIZE, 1); +#endif // BGFX_DEBUG + + const char* extensions = (const char*)glGetString(GL_EXTENSIONS); + + char name[1024]; + const char* pos = extensions; + const char* end = extensions + strlen(extensions); + while (pos < end) + { + uint32_t len; + const char* space = strchr(pos, ' '); + if (NULL != space) + { + len = uint32_min(sizeof(name), (uint32_t)(space - pos) ); + } + else + { + len = uint32_min(sizeof(name), strlen(pos) ); + } + + strncpy(name, pos, len); + name[len] = '\0'; + + bool supported = false; + for (uint32_t ii = 0; ii < Extension::Count; ++ii) + { + Extension& extension = s_extension[ii]; + if (!extension.m_supported) + { + if (0 == strcmp(name, extension.m_name) ) + { + extension.m_supported = true; + supported = true; + break; + } + } + } + + BX_TRACE("GL_EXTENSION%s: %s", supported ? " (supported)" : "", name); + + pos += len+1; + } + + s_renderCtx.m_dxtSupport = false //true + && s_extension[Extension::GL_EXT_texture_compression_dxt1].m_supported + && s_extension[Extension::GL_CHROMIUM_texture_compression_dxt3].m_supported + && s_extension[Extension::GL_CHROMIUM_texture_compression_dxt5].m_supported + ; + } + + void Context::rendererShutdown() + { + s_exit = true; + } + + void Context::rendererCreateIndexBuffer(IndexBufferHandle _handle, Memory* _mem) + { + s_renderCtx.m_indexBuffers[_handle.idx].create(_mem->size, _mem->data); + } + + void Context::rendererDestroyIndexBuffer(IndexBufferHandle _handle) + { + s_renderCtx.m_indexBuffers[_handle.idx].destroy(); + } + + void Context::rendererCreateDynamicIndexBuffer(IndexBufferHandle _handle, uint32_t _size) + { + s_renderCtx.m_indexBuffers[_handle.idx].create(_size, NULL); + } + + void Context::rendererDestroyDynamicIndexBuffer(IndexBufferHandle _handle) + { + s_renderCtx.m_indexBuffers[_handle.idx].destroy(); + } + + void Context::rendererCreateVertexDecl(VertexDeclHandle _handle, const VertexDecl& _decl) + { + VertexDecl& decl = s_renderCtx.m_vertexDecls[_handle.idx]; + memcpy(&decl, &_decl, sizeof(VertexDecl) ); + dump(decl); + } + + void Context::rendererDestroyVertexDecl(VertexDeclHandle _handle) + { + } + + void Context::rendererCreateVertexBuffer(VertexBufferHandle _handle, Memory* _mem, VertexDeclHandle _declHandle) + { + s_renderCtx.m_vertexBuffers[_handle.idx].create(_mem->size, _mem->data, _declHandle); + } + + void Context::rendererDestroyVertexBuffer(VertexBufferHandle _handle) + { + s_renderCtx.m_vertexBuffers[_handle.idx].destroy(); + } + + void Context::rendererCreateDynamicVertexBuffer(VertexBufferHandle _handle, uint32_t _size) + { + VertexDeclHandle decl = BGFX_INVALID_HANDLE; + s_renderCtx.m_vertexBuffers[_handle.idx].create(_size, NULL, decl); + } + + void Context::rendererDestroyDynamicVertexBuffer(VertexBufferHandle _handle) + { + s_renderCtx.m_vertexBuffers[_handle.idx].destroy(); + } + + void Context::rendererCreateVertexShader(VertexShaderHandle _handle, Memory* _mem) + { + s_renderCtx.m_vertexShaders[_handle.idx].create(GL_VERTEX_SHADER, _mem->data); + } + + void Context::rendererDestroyVertexShader(VertexShaderHandle _handle) + { + s_renderCtx.m_vertexShaders[_handle.idx].destroy(); + } + + void Context::rendererCreateFragmentShader(FragmentShaderHandle _handle, Memory* _mem) + { + s_renderCtx.m_fragmentShaders[_handle.idx].create(GL_FRAGMENT_SHADER, _mem->data); + } + + void Context::rendererDestroyFragmentShader(FragmentShaderHandle _handle) + { + s_renderCtx.m_fragmentShaders[_handle.idx].destroy(); + } + + void Context::rendererCreateMaterial(MaterialHandle _handle, VertexShaderHandle _vsh, FragmentShaderHandle _fsh) + { + s_renderCtx.m_materials[_handle.idx].create(s_renderCtx.m_vertexShaders[_vsh.idx], s_renderCtx.m_fragmentShaders[_fsh.idx]); + } + + void Context::rendererDestroyMaterial(FragmentShaderHandle _handle) + { + s_renderCtx.m_materials[_handle.idx].destroy(); + } + + void Context::rendererCreateTexture(TextureHandle _handle, Memory* _mem, uint32_t _flags) + { + s_renderCtx.m_textures[_handle.idx].create(_mem, _flags); + } + + void Context::rendererDestroyTexture(TextureHandle _handle) + { + s_renderCtx.m_textures[_handle.idx].destroy(); + } + + void Context::rendererCreateRenderTarget(RenderTargetHandle _handle, uint16_t _width, uint16_t _height, uint32_t _flags) + { + s_renderCtx.m_renderTargets[_handle.idx].create(_width, _height, _flags); + } + + void Context::rendererDestroyRenderTarget(RenderTargetHandle _handle) + { + s_renderCtx.m_renderTargets[_handle.idx].destroy(); + } + + void Context::rendererCreateUniform(UniformHandle _handle, ConstantType::Enum _type, uint16_t _num, const char* _name) + { + uint32_t size = g_constantTypeSize[_type]*_num; + void* data = g_realloc(NULL, size); + s_renderCtx.m_uniforms[_handle.idx] = data; + s_renderCtx.m_uniformReg.reg(_name, s_renderCtx.m_uniforms[_handle.idx]); + } + + void Context::rendererDestroyUniform(UniformHandle _handle) + { + g_free(s_renderCtx.m_uniforms[_handle.idx]); + } + + void Context::rendererSaveScreenShot(Memory* _mem) + { +// glReadPixels(0, 0, m_render->m_width, m_render->m_height, GL_RGBA, GL_UNSIGNED_BYTE, temp); + } + + void Context::rendererUpdateUniform(uint16_t _loc, const void* _data, uint32_t _size) + { + memcpy(s_renderCtx.m_uniforms[_loc], _data, _size); + } + + void Context::rendererSubmit() + { + s_renderCtx.updateResolution(m_render->m_resolution); + + if (0 < m_render->m_iboffset) + { + DynamicIndexBuffer* ib = m_render->m_dynamicIb; + s_renderCtx.m_indexBuffers[ib->handle.idx].update(m_render->m_iboffset, ib->data); + } + + if (0 < m_render->m_vboffset) + { + DynamicVertexBuffer* vb = m_render->m_dynamicVb; + s_renderCtx.m_vertexBuffers[vb->handle.idx].update(m_render->m_vboffset, vb->data); + } + + m_render->sort(); + + RenderState currentState; + currentState.reset(); + currentState.m_flags = BGFX_STATE_NONE; + + Matrix4 viewProj[BGFX_CONFIG_MAX_VIEWS]; + for (uint32_t ii = 0; ii < BGFX_CONFIG_MAX_VIEWS; ++ii) + { + matrix_mul(viewProj[ii].val, m_render->m_view[ii].val, m_render->m_proj[ii].val); + } + + uint16_t materialIdx = bgfx::invalidHandle; + SortKey key; + uint8_t view = 0xff; + RenderTargetHandle rt = BGFX_INVALID_HANDLE; + int32_t height = m_render->m_resolution.m_height; + float alphaRef = 0.0f; + GLenum primType = m_render->m_debug&BGFX_DEBUG_WIREFRAME ? GL_LINES : GL_TRIANGLES; + uint32_t primNumVerts = 3; + uint32_t baseVertex = 0; + + GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER, 0) ); + + uint32_t statsNumPrims = 0; + uint32_t statsNumIndices = 0; + + int64_t elapsed = -bx::getHPCounter(); + + if (0 == (m_render->m_debug&BGFX_DEBUG_IFH) ) + { + for (uint32_t item = 0, numItems = m_render->m_num; item < numItems; ++item) + { + key.decode(m_render->m_sortKeys[item]); + const RenderState& state = m_render->m_renderState[m_render->m_sortValues[item] ]; + + const uint64_t newFlags = state.m_flags; + uint64_t changedFlags = currentState.m_flags ^ state.m_flags; + currentState.m_flags = newFlags; + + if (key.m_view != view) + { + GL_CHECK(glFlush() ); + + currentState.clear(); + changedFlags = BGFX_STATE_MASK; + currentState.m_flags = newFlags; + + view = key.m_view; + materialIdx = bgfx::invalidHandle; + + if (m_render->m_rt[view].idx != rt.idx) + { + rt = m_render->m_rt[view]; + + if (rt.idx == bgfx::invalidHandle) + { + GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER, 0) ); + height = m_render->m_resolution.m_height; + } + else + { + RenderTarget& renderTarget = s_renderCtx.m_renderTargets[rt.idx]; + GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER, renderTarget.m_fbo) ); + height = renderTarget.m_height; + } + } + + Rect& rect = m_render->m_rect[view]; + + GL_CHECK(glViewport(rect.m_x, height-rect.m_height-rect.m_y, rect.m_width, rect.m_height) ); + + Clear& clear = m_render->m_clear[view]; + + if (BGFX_CLEAR_NONE != clear.m_flags) + { + GLuint flags = 0; + if (BGFX_CLEAR_COLOR_BIT & clear.m_flags) + { + flags |= GL_COLOR_BUFFER_BIT; + uint32_t rgba = clear.m_rgba; + float rr = (rgba>>24)/255.0f; + float gg = ( (rgba>>16)&0xff)/255.0f; + float bb = ( (rgba>>8)&0xff)/255.0f; + float aa = (rgba&0xff)/255.0f; + GL_CHECK(glClearColor(rr, gg, bb, aa) ); + GL_CHECK(glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE) ); + } + + if (BGFX_CLEAR_DEPTH_BIT & clear.m_flags) + { + flags |= GL_DEPTH_BUFFER_BIT; + GL_CHECK(glClearDepthf(clear.m_depth) ); + GL_CHECK(glDepthMask(GL_TRUE) ); + } + + if (BGFX_CLEAR_STENCIL_BIT & clear.m_flags) + { + flags |= GL_STENCIL_BUFFER_BIT; + GL_CHECK(glClearStencil(clear.m_stencil) ); + } + + if (0 != flags) + { + GL_CHECK(glEnable(GL_SCISSOR_TEST) ); + GL_CHECK(glScissor(rect.m_x, height-rect.m_height-rect.m_y, rect.m_width, rect.m_height) ); + GL_CHECK(glClear(flags) ); + GL_CHECK(glDisable(GL_SCISSOR_TEST) ); + } + } + + GL_CHECK(glEnable(GL_DEPTH_TEST) ); + GL_CHECK(glDepthFunc(GL_LESS) ); + GL_CHECK(glEnable(GL_CULL_FACE) ); + GL_CHECK(glDisable(GL_BLEND) ); + } + + if ( (BGFX_STATE_CULL_MASK|BGFX_STATE_DEPTH_WRITE|BGFX_STATE_DEPTH_TEST_MASK + |BGFX_STATE_ALPHA_MASK|BGFX_STATE_ALPHA_WRITE|BGFX_STATE_RGB_WRITE + |BGFX_STATE_BLEND_MASK|BGFX_STATE_ALPHA_REF_MASK|BGFX_STATE_PT_MASK) & changedFlags) + { + if (BGFX_STATE_CULL_MASK & changedFlags) + { + if (BGFX_STATE_CULL_CW & newFlags) + { + GL_CHECK(glEnable(GL_CULL_FACE) ); + GL_CHECK(glCullFace(GL_BACK) ); + } + else if (BGFX_STATE_CULL_CCW & newFlags) + { + GL_CHECK(glEnable(GL_CULL_FACE) ); + GL_CHECK(glCullFace(GL_FRONT) ); + } + else + { + GL_CHECK(glDisable(GL_CULL_FACE) ); + } + } + + if (BGFX_STATE_DEPTH_WRITE & changedFlags) + { + GL_CHECK(glDepthMask(!!(BGFX_STATE_DEPTH_WRITE & newFlags) ) ); + } + + if (BGFX_STATE_DEPTH_TEST_MASK & changedFlags) + { + uint32_t func = (newFlags&BGFX_STATE_DEPTH_TEST_MASK)>>BGFX_STATE_DEPTH_TEST_SHIFT; + + if (0 != func) + { + GL_CHECK(glEnable(GL_DEPTH_TEST) ); + GL_CHECK(glDepthFunc(s_depthFunc[func]) ); + } + else + { + GL_CHECK(glDisable(GL_DEPTH_TEST) ); + } + } + + if ( (BGFX_STATE_ALPHA_TEST|BGFX_STATE_ALPHA_REF_MASK) & changedFlags) + { + uint32_t ref = (newFlags&BGFX_STATE_ALPHA_REF_MASK)>>BGFX_STATE_ALPHA_REF_SHIFT; + alphaRef = ref/255.0f; + +#if BGFX_CONFIG_RENDERER_OPENGLES +#else + if (BGFX_STATE_ALPHA_TEST & newFlags) + { + GL_CHECK(glEnable(GL_ALPHA_TEST) ); + else + { + GL_CHECK(glDisable(GL_ALPHA_TEST) ); + } +#endif // BGFX_CONFIG_RENDERER_OPENGLES + } + + if ( (BGFX_STATE_ALPHA_WRITE|BGFX_STATE_RGB_WRITE) & changedFlags) + { + GLboolean alpha = !!(newFlags&BGFX_STATE_ALPHA_WRITE); + GLboolean rgb = !!(newFlags&BGFX_STATE_RGB_WRITE); + GL_CHECK(glColorMask(rgb, rgb, rgb, alpha) ); + } + + if (BGFX_STATE_BLEND_MASK & changedFlags) + { + if (BGFX_STATE_BLEND_MASK & newFlags) + { + uint32_t blend = (newFlags&BGFX_STATE_BLEND_MASK)>>BGFX_STATE_BLEND_SHIFT; + uint32_t src = blend&0xf; + uint32_t dst = (blend>>4)&0xf; + GL_CHECK(glEnable(GL_BLEND) ); + GL_CHECK(glBlendFunc(s_blendFactor[src], s_blendFactor[dst]) ); + } + else + { + GL_CHECK(glDisable(GL_BLEND) ); + } + } + + uint8_t primIndex = uint8_t( (newFlags&BGFX_STATE_PT_MASK)>>BGFX_STATE_PT_SHIFT); + primType = m_render->m_debug&BGFX_DEBUG_WIREFRAME ? GL_LINES : s_primType[primIndex]; + primNumVerts = s_primNumVerts[primIndex]; + } + + bool materialChanged = false; + bool constantsChanged = state.m_constBegin < state.m_constEnd; + bool bindAttribs = false; + rendererUpdateUniforms(m_render->m_constantBuffer, state.m_constBegin, state.m_constEnd); + + if (key.m_material != materialIdx) + { + materialIdx = key.m_material; + GLuint id = bgfx::invalidHandle == materialIdx ? 0 : s_renderCtx.m_materials[materialIdx].m_id; + GL_CHECK(glUseProgram(id) ); + materialChanged = + constantsChanged = + bindAttribs = true; + } + + if (bgfx::invalidHandle != materialIdx) + { + Material& material = s_renderCtx.m_materials[materialIdx]; + + if (constantsChanged) + { + material.m_constantBuffer->commit(materialChanged); + } + + for (uint32_t ii = 0, num = material.m_numPredefined; ii < num; ++ii) + { + PredefinedUniform& predefined = material.m_predefined[ii]; + switch (predefined.m_type) + { + case PredefinedUniform::ViewRect: + { + float rect[4]; + rect[0] = m_render->m_rect[view].m_x; + rect[1] = m_render->m_rect[view].m_y; + rect[2] = m_render->m_rect[view].m_width; + rect[3] = m_render->m_rect[view].m_height; + + GL_CHECK(glUniform4fv(predefined.m_loc + , 1 + , &rect[0] + ) ); + } + break; + + case PredefinedUniform::ViewTexel: + { + float rect[4]; + rect[0] = 1.0f/float(m_render->m_rect[view].m_width); + rect[1] = 1.0f/float(m_render->m_rect[view].m_height); + + GL_CHECK(glUniform4fv(predefined.m_loc + , 1 + , &rect[0] + ) ); + } + break; + + case PredefinedUniform::View: + { + GL_CHECK(glUniformMatrix4fv(predefined.m_loc + , 1 + , GL_FALSE + , m_render->m_view[view].val + ) ); + } + break; + + case PredefinedUniform::ViewProj: + { + GL_CHECK(glUniformMatrix4fv(predefined.m_loc + , 1 + , GL_FALSE + , viewProj[view].val + ) ); + } + break; + + case PredefinedUniform::Model: + { + const Matrix4& model = m_render->m_matrixCache.m_cache[state.m_matrix]; + GL_CHECK(glUniformMatrix4fv(predefined.m_loc + , state.m_num + , GL_FALSE + , model.val + ) ); + } + break; + + case PredefinedUniform::ModelViewProj: + { + Matrix4 modelViewProj; + const Matrix4& model = m_render->m_matrixCache.m_cache[state.m_matrix]; + matrix_mul(modelViewProj.val, model.val, viewProj[view].val); + + GL_CHECK(glUniformMatrix4fv(predefined.m_loc + , 1 + , GL_FALSE + , modelViewProj.val + ) ); + } + break; + + case PredefinedUniform::ModelViewProjX: + { + const Matrix4& model = m_render->m_matrixCache.m_cache[state.m_matrix]; + + static const BX_ALIGN_STRUCT_16(float) s_bias[16] = + { + 0.5f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.5f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.5f, 0.0f, + 0.5f, 0.5f, 0.5f, 1.0f, + }; + + uint8_t other = m_render->m_other[view]; + Matrix4 viewProjBias; + matrix_mul(viewProjBias.val, viewProj[other].val, s_bias); + + Matrix4 modelViewProj; + matrix_mul(modelViewProj.val, model.val, viewProjBias.val); + + GL_CHECK(glUniformMatrix4fv(predefined.m_loc + , 1 + , GL_FALSE + , modelViewProj.val + ) ); + } + break; + + case PredefinedUniform::ViewProjX: + { + static const BX_ALIGN_STRUCT_16(float) s_bias[16] = + { + 0.5f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.5f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.5f, 0.0f, + 0.5f, 0.5f, 0.5f, 1.0f, + }; + + uint8_t other = m_render->m_other[view]; + Matrix4 viewProjBias; + matrix_mul(viewProjBias.val, viewProj[other].val, s_bias); + + GL_CHECK(glUniformMatrix4fv(predefined.m_loc + , 1 + , GL_FALSE + , viewProjBias.val + ) ); + } + break; + + case PredefinedUniform::AlphaRef: + { + GL_CHECK(glUniform1f(predefined.m_loc, alphaRef) ); + } + break; + + case PredefinedUniform::Count: + break; + } + } + +// if (BGFX_STATE_TEX_MASK & changedFlags) + { + uint64_t flag = BGFX_STATE_TEX0; + for (uint32_t stage = 0; stage < BGFX_STATE_TEX_COUNT; ++stage) + { + const Sampler& sampler = state.m_sampler[stage]; + Sampler& current = currentState.m_sampler[stage]; + if (current.m_idx != sampler.m_idx + || current.m_flags != sampler.m_flags + || materialChanged) + { + GL_CHECK(glActiveTexture(GL_TEXTURE0+stage) ); + if (bgfx::invalidHandle != sampler.m_idx) + { + GLuint id = 0; + switch (sampler.m_flags&BGFX_SAMPLER_TYPE_MASK) + { + case 0: + id = s_renderCtx.m_textures[sampler.m_idx].m_id; + break; + + case 1: + id = s_renderCtx.m_renderTargets[sampler.m_idx].m_color.m_id; + break; + + case 2: + id = s_renderCtx.m_renderTargets[sampler.m_idx].m_depth.m_id; + break; + } + + GL_CHECK(glBindTexture(GL_TEXTURE_2D, id) ); + // GL_CHECK(glUniform1i(material.m_sampler[stage], stage) ); + } + } + + current = sampler; + flag <<= 1; + } + + GL_CHECK(glActiveTexture(GL_TEXTURE0) ); + } + + if (currentState.m_vertexBuffer.idx != state.m_vertexBuffer.idx || materialChanged) + { + currentState.m_vertexBuffer = state.m_vertexBuffer; + + uint16_t handle = state.m_vertexBuffer.idx; + if (bgfx::invalidHandle != handle) + { + VertexBuffer& vb = s_renderCtx.m_vertexBuffers[handle]; + GL_CHECK(glBindBuffer(GL_ARRAY_BUFFER, vb.m_id) ); + bindAttribs = true; + } + else + { + GL_CHECK(glBindBuffer(GL_ARRAY_BUFFER, 0) ); + } + } + + if (currentState.m_indexBuffer.idx != state.m_indexBuffer.idx) + { + currentState.m_indexBuffer = state.m_indexBuffer; + + uint16_t handle = state.m_indexBuffer.idx; + if (bgfx::invalidHandle != handle) + { + IndexBuffer& ib = s_renderCtx.m_indexBuffers[handle]; + GL_CHECK(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ib.m_id) ); + } + else + { + GL_CHECK(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0) ); + } + } + + if (bgfx::invalidHandle != state.m_indexBuffer.idx) + { + if (baseVertex != state.m_startVertex + || bindAttribs) + { + baseVertex = state.m_startVertex; + VertexBuffer& vb = s_renderCtx.m_vertexBuffers[state.m_vertexBuffer.idx]; + uint16_t decl = vb.m_decl.idx == bgfx::invalidHandle ? state.m_vertexDecl.idx : vb.m_decl.idx; + s_renderCtx.m_materials[materialIdx].bindAttributes(s_renderCtx.m_vertexDecls[decl], state.m_startVertex); + } + + uint32_t numIndices = state.m_numIndices; + uint32_t numPrims = 0; + + if (BGFX_DRAW_WHOLE_INDEX_BUFFER == state.m_startIndex) + { + numIndices = s_renderCtx.m_indexBuffers[state.m_indexBuffer.idx].m_size/2; + numPrims = numIndices/primNumVerts; + + GL_CHECK(glDrawElements(primType + , s_renderCtx.m_indexBuffers[state.m_indexBuffer.idx].m_size/2 + , GL_UNSIGNED_SHORT + , (void*)0 + ) ); + } + else if (primNumVerts <= state.m_numIndices) + { + GL_CHECK(glDrawElements(primType + , numIndices + , GL_UNSIGNED_SHORT + , (void*)(uintptr_t)(state.m_startIndex*2) + ) ); + } + + statsNumPrims += numPrims; + statsNumIndices += numIndices; + } + } + } + } + + int64_t now = bx::getHPCounter(); + elapsed += now; + + static int64_t last = now; + double frameTime = now - last; + last = now; + + if (m_render->m_debug & (BGFX_DEBUG_IFH|BGFX_DEBUG_STATS) ) + { + TextVideoMem& tvm = s_renderCtx.m_textVideoMem; + + static int64_t next = now; + + if (now >= next) + { + next = now + bx::getHPFrequency(); + double freq = double(bx::getHPFrequency() ); + double toMs = 1000.0/freq; + + tvm.clear(); + uint16_t pos = 10; + tvm.printf(10, pos++, 0x8e, " Frame: %3.4f [ms] / %3.2f", double(frameTime)*toMs, freq/frameTime); + tvm.printf(10, pos++, 0x8e, " Draw calls: %4d / %3.4f [ms]", m_render->m_num, double(elapsed)*toMs); + tvm.printf(10, pos++, 0x8e, " Prims: %7d", statsNumPrims); + tvm.printf(10, pos++, 0x8e, " Indices: %7d", statsNumIndices); + tvm.printf(10, pos++, 0x8e, " DVB size: %7d", m_render->m_vboffset); + tvm.printf(10, pos++, 0x8e, " DIB size: %7d", m_render->m_iboffset); + + uint8_t attr[2] = { 0x89, 0x8a }; + uint8_t attrIndex = m_render->m_waitSubmit < m_render->m_waitRender; + + tvm.printf(10, pos++, attr[attrIndex&1], "Submit wait: %3.4f [ms]", double(m_render->m_waitSubmit)*toMs); + tvm.printf(10, pos++, attr[(attrIndex+1)&1], "Render wait: %3.4f [ms]", double(m_render->m_waitRender)*toMs); + } + + g_textVideoMemBlitter.blit(tvm); + } + + GL_CHECK(glFlush() ); + } +} + +#endif // BGFX_CONFIG_RENDERER_OPENGLES diff --git a/src/renderer_gl.h b/src/renderer_gl.h new file mode 100644 index 000000000..da4f0588b --- /dev/null +++ b/src/renderer_gl.h @@ -0,0 +1,258 @@ +/* + * Copyright 2011-2012 Branimir Karadzic. All rights reserved. + * License: http://www.opensource.org/licenses/BSD-2-Clause + */ + +#ifndef __RENDERER_GL_H__ +#define __RENDERER_GL_H__ + +#if BX_PLATFORM_NACL || BX_PLATFORM_ANDROID +# include +#elif BX_PLATFORM_WINDOWS +# include + +# define GLEW_STATIC +# include +#elif BX_PLATFORM_LINUX +# include +#endif // BX_PLATFORM_ + +#ifndef GL_BGRA_EXT +# define GL_BGRA_EXT 0x80E1 +#endif // GL_BGRA_EXT + +#ifndef GL_COMPRESSED_RGB_S3TC_DXT1_EXT +# define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 +#endif // GL_COMPRESSED_RGB_S3TC_DXT1_EXT + +#ifndef GL_COMPRESSED_RGBA_S3TC_DXT1_EXT +# define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 +#endif // GL_COMPRESSED_RGBA_S3TC_DXT1_EXT + +#ifndef GL_COMPRESSED_RGBA_S3TC_DXT3_EXT +# define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 +#endif // GL_COMPRESSED_RGBA_S3TC_DXT3_EXT + +#ifndef GL_COMPRESSED_RGBA_S3TC_DXT5_EXT +# define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 +#endif // GL_COMPRESSED_RGBA_S3TC_DXT5_EXT + +#ifndef GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES +# define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES 0x8B8B +#endif // GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES + +namespace bgfx +{ +# define _GL_CHECK(_call) \ + do { \ + /*BX_TRACE(#_call);*/ \ + _call; \ + GLenum err = glGetError(); \ + BX_CHECK(0 == err, #_call "; glError 0x%x %d", err, err); \ + } while (0) + +#if BGFX_DEBUG +# define GL_CHECK(_call) _call // _GL_CHECK(_call) +#else +# define GL_CHECK(_call) _call +#endif // BGFX_DEBUG + + struct ConstantBuffer; + + struct IndexBuffer + { + void create(uint32_t _size, void* _data) + { + m_size = _size; + + GL_CHECK(glGenBuffers(1, &m_id) ); + BX_CHECK(0 != m_id, "Failed to generate buffer id."); + GL_CHECK(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_id) ); + GL_CHECK(glBufferData(GL_ELEMENT_ARRAY_BUFFER + , _size + , _data + , (NULL==_data)?GL_DYNAMIC_DRAW:GL_STATIC_DRAW + ) ); + GL_CHECK(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0) ); + } + + void update(uint32_t _size, void* _data) + { + GL_CHECK(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_id) ); + GL_CHECK(glBufferSubData(GL_ELEMENT_ARRAY_BUFFER + , 0 + , _size + , _data + ) ); + GL_CHECK(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0) ); + } + + void destroy() + { + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); + glDeleteBuffers(1, &m_id); + } + + GLuint m_id; + uint32_t m_size; + }; + + struct VertexBuffer + { + void create(uint32_t _size, void* _data, VertexDeclHandle _declHandle) + { + m_size = _size; + m_decl = _declHandle; + + GL_CHECK(glGenBuffers(1, &m_id) ); + BX_CHECK(0 != m_id, "Failed to generate buffer id."); + GL_CHECK(glBindBuffer(GL_ARRAY_BUFFER, m_id) ); + GL_CHECK(glBufferData(GL_ARRAY_BUFFER + , _size + , _data + , (NULL==_data)?GL_DYNAMIC_DRAW:GL_STATIC_DRAW + ) ); + GL_CHECK(glBindBuffer(GL_ARRAY_BUFFER, 0) ); + } + + void update(uint32_t _size, void* _data) + { + GL_CHECK(glBindBuffer(GL_ARRAY_BUFFER, m_id) ); + GL_CHECK(glBufferSubData(GL_ARRAY_BUFFER + , 0 + , _size + , _data + ) ); + GL_CHECK(glBindBuffer(GL_ARRAY_BUFFER, 0) ); + } + + void destroy() + { + GL_CHECK(glBindBuffer(GL_ARRAY_BUFFER, 0) ); + GL_CHECK(glDeleteBuffers(1, &m_id) ); + } + + GLuint m_id; + uint32_t m_size; + VertexDeclHandle m_decl; + }; + + struct Texture + { + Texture() + : m_id(0) + , m_target(GL_TEXTURE_2D) + { + } + + void create(const Memory* _mem, uint32_t _flags); + void createColor(uint32_t _width, uint32_t _height); + void createDepth(uint32_t _width, uint32_t _height); + void destroy(); + + GLuint m_id; + GLenum m_target; + }; + + struct Shader + { + void create(GLenum _type, const uint8_t* _code) + { + m_id = glCreateShader(_type); + m_type = _type; + + if (0 != m_id) + { + GL_CHECK(glShaderSource(m_id, 1, (const GLchar**)&_code, NULL) ); + GL_CHECK(glCompileShader(m_id) ); + + GLint compiled = 0; + GL_CHECK(glGetShaderiv(m_id, GL_COMPILE_STATUS, &compiled) ); + + if (0 == compiled) + { + char log[1024]; + GL_CHECK(glGetShaderInfoLog(m_id, sizeof(log), NULL, log) ); + BX_TRACE("Failed to compile shader. %d: %s", compiled, log); + BX_TRACE("\n####\n%s\n####", _code); + + GL_CHECK(glDeleteShader(m_id) ); + } + } + } + + void destroy() + { + GL_CHECK(glDeleteShader(m_id) ); + } + + GLuint m_id; + GLenum m_type; + }; + + struct RenderTarget + { + void create(uint16_t _width, uint16_t _height, uint32_t _flags); + void destroy(); + + GLsizei m_width; + GLsizei m_height; + Texture m_color; + Texture m_depth; + GLuint m_fbo; + GLuint m_rbo; + }; + + struct Material + { + void create(const Shader& _vsh, const Shader& _fsh) + { + m_id = glCreateProgram(); + BX_TRACE("material create: %d: %d, %d", m_id, _vsh.m_id, _fsh.m_id); + + GL_CHECK(glAttachShader(m_id, _vsh.m_id) ); + GL_CHECK(glAttachShader(m_id, _fsh.m_id) ); + GL_CHECK(glLinkProgram(m_id) ); + + GLint linked = 0; + GL_CHECK(glGetProgramiv(m_id, GL_LINK_STATUS, &linked) ); + + if (0 == linked) + { + char log[1024]; + GL_CHECK(glGetProgramInfoLog(m_id, sizeof(log), NULL, log) ); + BX_TRACE("%d: %s", linked, log); + + GL_CHECK(glDeleteProgram(m_id) ); + return; + } + + init(); + } + + void destroy() + { + GL_CHECK(glUseProgram(0) ); + GL_CHECK(glDeleteProgram(m_id) ); + } + + void init(); + void bindAttributes(const VertexDecl& _vertexDecl, uint32_t _baseVertex = 0); + + GLuint m_id; + + uint8_t m_used[Attrib::Count+1]; // dense + uint16_t m_attributes[Attrib::Count]; // sparse + uint32_t m_enabled; + + GLuint m_sampler[BGFX_CONFIG_MAX_TEXTURES]; + uint8_t m_numSamplers; + + ConstantBuffer* m_constantBuffer; + PredefinedUniform m_predefined[PredefinedUniform::Count]; + uint8_t m_numPredefined; + }; + +} // namespace bgfx + +#endif // __RENDERER_GL_H__ diff --git a/src/renderer_null.cpp b/src/renderer_null.cpp new file mode 100644 index 000000000..56dc4e23c --- /dev/null +++ b/src/renderer_null.cpp @@ -0,0 +1,136 @@ +/* + * Copyright 2011-2012 Branimir Karadzic. All rights reserved. + * License: http://www.opensource.org/licenses/BSD-2-Clause + */ + +#include "bgfx_p.h" + +#if BGFX_CONFIG_RENDERER_NULL + +namespace bgfx +{ + static bool s_exit = false; + + void ConstantBuffer::commit(bool _force) + { + } + + void TextVideoMemBlitter::setup() + { + } + + void TextVideoMemBlitter::render(uint32_t _numIndices) + { + } + + void Context::flip() + { + } + + void Context::rendererInit() + { + } + + void Context::rendererShutdown() + { + s_exit = true; + } + + void Context::rendererCreateIndexBuffer(IndexBufferHandle _handle, Memory* _mem) + { + } + + void Context::rendererDestroyIndexBuffer(IndexBufferHandle _handle) + { + } + + void Context::rendererCreateDynamicIndexBuffer(IndexBufferHandle _handle, uint32_t _size) + { + } + + void Context::rendererDestroyDynamicIndexBuffer(IndexBufferHandle _handle) + { + } + + void Context::rendererCreateVertexDecl(VertexDeclHandle _handle, const VertexDecl& _decl) + { + } + + void Context::rendererDestroyVertexDecl(VertexDeclHandle _handle) + { + } + + void Context::rendererCreateVertexBuffer(VertexBufferHandle _handle, Memory* _mem, VertexDeclHandle _declHandle) + { + } + + void Context::rendererDestroyVertexBuffer(VertexBufferHandle _handle) + { + } + + void Context::rendererCreateDynamicVertexBuffer(VertexBufferHandle _handle, uint32_t _size) + { + } + + void Context::rendererDestroyDynamicVertexBuffer(VertexBufferHandle _handle) + { + } + + void Context::rendererCreateVertexShader(VertexShaderHandle _handle, Memory* _mem) + { + } + + void Context::rendererDestroyVertexShader(VertexShaderHandle _handle) + { + } + + void Context::rendererCreateFragmentShader(FragmentShaderHandle _handle, Memory* _mem) + { + } + + void Context::rendererDestroyFragmentShader(FragmentShaderHandle _handle) + { + } + + void Context::rendererCreateMaterial(MaterialHandle _handle, VertexShaderHandle _vsh, FragmentShaderHandle _fsh) + { + } + + void Context::rendererDestroyMaterial(FragmentShaderHandle _handle) + { + } + + void Context::rendererCreateTexture(TextureHandle _handle, Memory* _mem, uint32_t _flags) + { + } + + void Context::rendererDestroyTexture(TextureHandle _handle) + { + } + + void Context::rendererCreateRenderTarget(RenderTargetHandle _handle, uint16_t _width, uint16_t _height, uint32_t _flags) + { + } + + void Context::rendererDestroyRenderTarget(RenderTargetHandle _handle) + { + } + + void Context::rendererCreateUniform(UniformHandle _handle, ConstantType::Enum _type, uint16_t _num, const char* _name) + { + } + + void Context::rendererDestroyUniform(UniformHandle _handle) + { + } + + void Context::rendererSaveScreenShot(Memory* _mem) + { + } + + void Context::rendererSubmit() + { + } +} + +#endif // BGFX_CONFIG_RENDERER_NULL diff --git a/tools/ddsdump.cpp b/tools/ddsdump.cpp new file mode 100644 index 000000000..8a8024220 --- /dev/null +++ b/tools/ddsdump.cpp @@ -0,0 +1,123 @@ +/* + * Copyright 2011-2012 Branimir Karadzic. All rights reserved. + */ + +#include +#include +#include + +#include "bgfx_p.h" +using namespace bgfx; + +#include "dds.h" + +#if 0 +# define BX_TRACE(_format, ...) fprintf(stderr, "" _format "\n", ##__VA_ARGS__) +#endif // DEBUG + +#define BX_NAMESPACE 1 +#include +#include +#include + +HWND bgfxHwnd; + +long int fsize(FILE* _file) +{ + long int pos = ftell(_file); + fseek(_file, 0L, SEEK_END); + long int size = ftell(_file); + fseek(_file, pos, SEEK_SET); + return size; +} + +int main(int _argc, const char* _argv[]) +{ + CommandLine cmdLine(_argc, _argv); + + FILE* file = fopen(_argv[1], "rb"); + uint32_t size = fsize(file); + const Memory* mem = bgfx::alloc(size); + fread(mem->data, 1, size, file); + fclose(file); + + Dds dds; + + if (parseDds(dds, mem) ) + { + bool decompress = cmdLine.hasArg('d'); + + if (decompress + || 0 == dds.m_type) + { + uint32_t width = dds.m_width; + uint32_t height = dds.m_height; + + for (uint32_t lod = 0, num = dds.m_numMips; lod < num; ++lod) + { + width = uint32_max(1, width); + height = uint32_max(1, height); + + Mip mip; + if (getRawImageData(dds, lod, mem, mip) ) + { + uint32_t dstpitch = width*4; + uint8_t* bits = (uint8_t*)malloc(dstpitch*height); + + if (width != mip.m_width + || height != mip.m_height) + { + uint8_t* temp = (uint8_t*)realloc(NULL, mip.m_width*mip.m_height*4); + mip.decode(temp); + uint32_t srcpitch = mip.m_width*4; + + for (uint32_t yy = 0; yy < height; ++yy) + { + uint8_t* src = &temp[yy*srcpitch]; + uint8_t* dst = &bits[yy*dstpitch]; + + for (uint32_t xx = 0; xx < width; ++xx) + { + memcpy(dst, src, 4); + dst += 4; + src += 4; + } + } + + free(temp); + } + else + { + mip.decode(bits); + } + + char filePath[256]; + _snprintf(filePath, sizeof(filePath), "mip%d.tga", lod); + + bgfx::saveTga(filePath, width, height, dstpitch, bits); + free(bits); + } + + width >>= 1; + height >>= 1; + } + } + else + { + for (uint32_t lod = 0, num = dds.m_numMips; lod < num; ++lod) + { + Mip mip; + if (getRawImageData(dds, lod, mem, mip) ) + { + char filePath[256]; + _snprintf(filePath, sizeof(filePath), "mip%d.bin", lod); + file = fopen(filePath, "wb"); + fwrite(mip.m_data, 1, mip.m_size, file); + fclose(file); + } + } + } + } + + return EXIT_FAILURE; +} diff --git a/tools/shaderc.cpp b/tools/shaderc.cpp new file mode 100644 index 000000000..ff4b480bd --- /dev/null +++ b/tools/shaderc.cpp @@ -0,0 +1,664 @@ +/* + * Copyright 2011-2012 Branimir Karadzic. All rights reserved. + */ + +#include +#include +#include +#include +#include +#include + +#include "glsl_optimizer.h" + +#define MAX_TAGS 256 +extern "C" { +# include +} // extern "C" + +#if 0 +# define BX_TRACE(_format, ...) fprintf(stderr, "" _format "\n", ##__VA_ARGS__) +#endif // DEBUG + +#define BX_NAMESPACE 1 +#include + +#if BX_PLATFORM_LINUX +# define _stricmp strcasecmp +#endif // BX_PLATFORM_LINUX + +#include +#include +#include +#include + +#if BX_PLATFORM_WINDOWS +# include +#endif // BX_PLATFORM_WINDOWS + +long int fsize(FILE* _file) +{ + long int pos = ftell(_file); + fseek(_file, 0L, SEEK_END); + long int size = ftell(_file); + fseek(_file, pos, SEEK_SET); + return size; +} + +struct ConstantType +{ + enum Enum + { + Uniform1i, + Uniform1f, + End, + + Uniform1iv, + Uniform1fv, + Uniform2fv, + Uniform3fv, + Uniform4fv, + Uniform3x3fv, + Uniform4x4fv, + + Count, + TypeMask = 0x7f, + FragmentBit = 0x80 + }; +}; + +static const char* s_constantTypeName[ConstantType::Count] = +{ + "int", + "float", + NULL, + "int", + "float", + "float2", + "float3", + "float4", + "float3x3", + "float4x4", +}; + +struct Uniform +{ + std::string name; + ConstantType::Enum type; + uint8_t num; + uint16_t regIndex; + uint16_t regCount; +}; +typedef std::vector UniformArray; + +#if BX_PLATFORM_WINDOWS +struct ConstRemap +{ + ConstantType::Enum id; + D3DXPARAMETER_CLASS paramClass; + D3DXPARAMETER_TYPE paramType; + uint32_t paramBytes; +}; + +static const ConstRemap s_constRemap[7] = +{ + { ConstantType::Uniform1iv, D3DXPC_SCALAR, D3DXPT_INT, 4 }, + { ConstantType::Uniform1fv, D3DXPC_SCALAR, D3DXPT_FLOAT, 4 }, + { ConstantType::Uniform2fv, D3DXPC_VECTOR, D3DXPT_FLOAT, 8 }, + { ConstantType::Uniform3fv, D3DXPC_VECTOR, D3DXPT_FLOAT, 12 }, + { ConstantType::Uniform4fv, D3DXPC_VECTOR, D3DXPT_FLOAT, 16 }, + { ConstantType::Uniform3x3fv, D3DXPC_MATRIX_COLUMNS, D3DXPT_FLOAT, 36 }, + { ConstantType::Uniform4x4fv, D3DXPC_MATRIX_COLUMNS, D3DXPT_FLOAT, 64 }, +}; + +ConstantType::Enum findConstantType(const D3DXCONSTANT_DESC& constDesc) +{ + uint32_t count = sizeof(s_constRemap)/sizeof(ConstRemap); + for (uint32_t ii = 0; ii < count; ++ii) + { + const ConstRemap& remap = s_constRemap[ii]; + + if (remap.paramClass == constDesc.Class + && remap.paramType == constDesc.Type + && (constDesc.Bytes%remap.paramBytes) == 0) + { + return remap.id; + } + } + + return ConstantType::Count; +} + +static uint32_t s_optimizationLevel[4] = +{ + D3DXSHADER_OPTIMIZATION_LEVEL0, + D3DXSHADER_OPTIMIZATION_LEVEL1, + D3DXSHADER_OPTIMIZATION_LEVEL2, + D3DXSHADER_OPTIMIZATION_LEVEL3, +}; +#endif // BX_PLATFORM_WINDOWS + +class Stream +{ +public: + Stream(FILE* _file, bool _bigEndian = false) + : m_file(_file) + , m_bigEndian(_bigEndian) + { + } + + ~Stream() + { + } + + void close() + { + m_file = NULL; + } + + void write(const char* _str) + { + if (NULL != m_file) + { + fwrite(_str, strlen(_str), 1, m_file); + } + } + + void write(const void* _data, size_t _size) + { + if (NULL != m_file) + { + fwrite(_data, _size, 1, m_file); + } + } + + template + void write(Ty _value) + { + Ty temp = m_bigEndian ? bx::bigEndian(_value) : _value; + write(&temp, sizeof(Ty) ); + } + +private: + FILE* m_file; + bool m_bigEndian; +}; + +bool compileGLSLShader(CommandLine& _cmdLine, const std::string& _code, const char* _outFilePath) +{ + const glslopt_shader_type type = (0 == _stricmp(_cmdLine.findOption('\0', "type"), "fragment") ) ? kGlslOptShaderFragment : kGlslOptShaderVertex; + + glslopt_ctx* ctx = glslopt_initialize(false); + + glslopt_shader* shader = glslopt_optimize(ctx, type, _code.c_str(), 0); + + if( !glslopt_get_status(shader) ) + { + fprintf(stderr, "Error %s\n%s\n", _code.c_str(), glslopt_get_log(shader) ); + glslopt_cleanup(ctx); + return false; + } + + const char* optimizedShader = glslopt_get_output(shader); + + FILE* out = fopen(_outFilePath, "wb"); + if (NULL == out) + { + fprintf(stderr, "Unable to open output file '%s'.", _outFilePath); + glslopt_cleanup(ctx); + return false; + } + + Stream stream(out); + stream.write("precision highp float;\n\n"); + stream.write(optimizedShader, strlen(optimizedShader) ); + uint8_t nul = 0; + stream.write(nul); + stream.close(); + fclose(out); + + glslopt_cleanup(ctx); + + return true; +} + +bool compileHLSLShader(CommandLine& _cmdLine, const std::string& _code, const char* _outFilePath) +{ +#if BX_PLATFORM_WINDOWS + const char* profile = _cmdLine.findOption('p'); + if (NULL == profile) + { + printf("Shader profile must be specified.\n"); + return false; + } + + bool bigEndian = _cmdLine.hasArg('\0', "xbox360"); + + uint32_t flags = 0; + flags |= _cmdLine.hasArg('\0', "debug") ? D3DXSHADER_DEBUG : 0; + flags |= _cmdLine.hasArg('\0', "avoid-flow-control") ? D3DXSHADER_AVOID_FLOW_CONTROL : 0; + flags |= _cmdLine.hasArg('\0', "no-preshader") ? D3DXSHADER_NO_PRESHADER : 0; + flags |= _cmdLine.hasArg('\0', "partial-precision") ? D3DXSHADER_PARTIALPRECISION : 0; + flags |= _cmdLine.hasArg('\0', "prefer-flow-control") ? D3DXSHADER_PREFER_FLOW_CONTROL : 0; + + uint32_t optimization = 3; + if (_cmdLine.hasArg(optimization, 'O') ) + { + optimization = bx::uint32_min(optimization, countof(s_optimizationLevel)-1); + flags |= s_optimizationLevel[optimization]; + } + else + { + flags |= D3DXSHADER_SKIPOPTIMIZATION; + } + + BX_TRACE("Profile: %s", profile); + BX_TRACE("Flags: 0x%08x", flags); + BX_TRACE("Big Endian: %s", bigEndian?"true":"false"); + + LPD3DXBUFFER code; + LPD3DXBUFFER errorMsg; + LPD3DXCONSTANTTABLE constantTable; + + HRESULT hr = D3DXCompileShader(_code.c_str() + , _code.size() + , NULL + , NULL + , "main" + , profile + , flags + , &code + , &errorMsg + , &constantTable + ); + if (FAILED(hr) ) + { + fprintf(stderr, "0x%08x: %s\n", hr, errorMsg->GetBufferPointer() ); + return false; + } + + D3DXCONSTANTTABLE_DESC desc; + hr = constantTable->GetDesc(&desc); + if (FAILED(hr) ) + { + fprintf(stderr, "Error 0x%08x\n", hr); + return false; + } + + BX_TRACE("Creator: %s 0x%08x", desc.Creator, desc.Version); + BX_TRACE("Num constants: %d", desc.Constants); + BX_TRACE("# cl ty RxC S By Name"); + + UniformArray uniforms; + + for (uint32_t ii = 0; ii < desc.Constants; ++ii) + { + D3DXHANDLE handle = constantTable->GetConstant(NULL, ii); + D3DXCONSTANT_DESC constDesc; + uint32_t count; + constantTable->GetConstantDesc(handle, &constDesc, &count); + BX_TRACE("%3d %2d %2d [%dx%d] %d %3d %s[%d] c%d (%d)" + , ii + , constDesc.Class + , constDesc.Type + , constDesc.Rows + , constDesc.Columns + , constDesc.StructMembers + , constDesc.Bytes + , constDesc.Name + , constDesc.Elements + , constDesc.RegisterIndex + , constDesc.RegisterCount + ); + + ConstantType::Enum type = findConstantType(constDesc); + if (ConstantType::Count != type) + { + Uniform un; + un.name = '$' == constDesc.Name[0] ? constDesc.Name+1 : constDesc.Name; + un.type = type; + un.num = constDesc.Elements; + un.regIndex = constDesc.RegisterIndex; + un.regCount = constDesc.RegisterCount; + uniforms.push_back(un); + } + } + + FILE* out = fopen(_outFilePath, "wb"); + if (NULL == out) + { + fprintf(stderr, "Unable to open output file '%s'.", _outFilePath); + return false; + } + + Stream stream(out, bigEndian); + + uint16_t count = (uint16_t)uniforms.size(); + stream.write(count); + + uint32_t fragmentBit = profile[0] == 'p' ? ConstantType::FragmentBit : 0; + for (UniformArray::const_iterator it = uniforms.begin(); it != uniforms.end(); ++it) + { + const Uniform& un = *it; + uint8_t nameSize = (uint8_t)un.name.size(); + stream.write(nameSize); + stream.write(un.name.c_str(), nameSize); + stream.write(un.type|fragmentBit); + stream.write(un.num); + stream.write(un.regIndex); + stream.write(un.regCount); + + BX_TRACE("%s, %s, %d, %d, %d" + , un.name.c_str() + , s_constantTypeName[un.type] + , un.num + , un.regIndex + , un.regCount + ); + } + + uint16_t shaderSize = (uint16_t)code->GetBufferSize(); + stream.write(shaderSize); + stream.write(code->GetBufferPointer(), shaderSize); + uint8_t nul = 0; + stream.write(nul); + stream.close(); + fclose(out); + + if (NULL != code) + { + code->Release(); + } + + if (NULL != errorMsg) + { + errorMsg->Release(); + } + + if (NULL != constantTable) + { + constantTable->Release(); + } + + return true; +#else + fprintf(stderr, "HLSL compiler is not supported on this platform.\n"); + return false; +#endif // BX_PLATFORM_WINDOWS +} + +struct Preprocessor +{ + Preprocessor(const char* _filePath) + : m_tagptr(m_tags) + , m_scratchPos(0) + , m_fgetsPos(0) + { + m_filePath = scratch(_filePath); + + m_tagptr->tag = FPPTAG_USERDATA; + m_tagptr->data = this; + m_tagptr++; + + m_tagptr->tag = FPPTAG_INPUT; + m_tagptr->data = (void*)fppInput; + m_tagptr++; + + m_tagptr->tag = FPPTAG_OUTPUT; + m_tagptr->data = (void*)fppOutput; + m_tagptr++; + + m_tagptr->tag = FPPTAG_ERROR; + m_tagptr->data = (void*)fppError; + m_tagptr++; + + m_tagptr->tag = FPPTAG_IGNOREVERSION; + m_tagptr->data = (void*)0; + m_tagptr++; + + m_tagptr->tag = FPPTAG_LINE; + m_tagptr->data = (void*)0; + m_tagptr++; + + m_tagptr->tag = FPPTAG_INPUT_NAME; + m_tagptr->data = m_filePath; + m_tagptr++; + + m_default = "#define lowp\n#define mediump\n#define highp\n"; + } + + void setDefine(const char* _define) + { + m_tagptr->tag = FPPTAG_DEFINE; + m_tagptr->data = scratch(_define); + m_tagptr++; + } + + void setDefaultDefine(const char* _name) + { + char temp[1024]; + _snprintf(temp, countof(temp) + , "#ifndef %s\n" + "# define %s 0\n" + "#endif // %s\n" + "\n" + , _name + , _name + , _name + ); + + m_default += temp; + } + + bool run() + { + m_fgetsPos = 0; + + FILE* file = fopen(m_filePath, "r"); + long int size = fsize(file); + + char* input = new char[size+1]; + fread(input, size, 1, file); + input[size] = '\0'; + + m_input = m_default; + m_input += input; + + fclose(file); + + fppTag* tagptr = m_tagptr; + + tagptr->tag = FPPTAG_END; + tagptr->data = 0; + tagptr++; + + int result = fppPreProcess(m_tags); + + return 0 == result; + } + + char* fgets(char* _buffer, int _size) + { + int ii = 0; + for (char ch = m_input[m_fgetsPos]; m_fgetsPos < m_input.size() && ii < _size-1; ch = m_input[++m_fgetsPos]) + { + _buffer[ii++] = ch; + + if (ch == '\n' || ii == _size) + { + _buffer[ii] = '\0'; + m_fgetsPos++; + return _buffer; + } + } + + return NULL; + } + + static char* fppInput(char* _buffer, int _size, void* _userData) + { + Preprocessor* thisClass = (Preprocessor*)_userData; + return thisClass->fgets(_buffer, _size); + } + + static void fppOutput(int _ch, void* _userData) + { + Preprocessor* thisClass = (Preprocessor*)_userData; + thisClass->m_preprocessed += _ch; + } + + static void fppError(void* _userData, char* _format, va_list _vargs) + { + vfprintf(stderr, _format, _vargs); + } + + char* scratch(const char* _str) + { + char* result = &m_scratch[m_scratchPos]; + strcpy(result, _str); + m_scratchPos += strlen(_str)+1; + + return result; + } + + fppTag m_tags[MAX_TAGS]; + fppTag* m_tagptr; + + char* m_filePath; + std::string m_default; + std::string m_input; + std::string m_preprocessed; + char m_scratch[16<<10]; + uint32_t m_scratchPos; + uint32_t m_fgetsPos; +}; + +int main(int _argc, const char* _argv[]) +{ + CommandLine cmdLine(_argc, _argv); + + const char* filePath = cmdLine.findOption('f'); + if (NULL == filePath) + { + fprintf(stderr, "Shader file name must be specified.\n"); + return 1; + } + + const char* outFilePath = cmdLine.findOption('o'); + if (NULL == outFilePath) + { + fprintf(stderr, "Output file name must be specified.\n"); + return 1; + } + + const char* type = cmdLine.findOption('\0', "type"); + if (NULL == type) + { + fprintf(stderr, "Must specify shader type."); + return 1; + } + + const char* platform = cmdLine.findOption('\0', "platform"); + if (NULL == platform) + { + fprintf(stderr, "Must specify platform.\n"); + return 1; + } + + bool preprocessOnly = cmdLine.hasArg("preprocess"); + + Preprocessor preprocessor(filePath); + + preprocessor.setDefaultDefine("BX_PLATFORM_ANDROID"); + preprocessor.setDefaultDefine("BX_PLATFORM_NACL"); + preprocessor.setDefaultDefine("BX_PLATFORM_WINDOWS"); + preprocessor.setDefaultDefine("BX_PLATFORM_XBOX360"); + preprocessor.setDefaultDefine("BGFX_SHADER_LANGUAGE_GLSL"); + preprocessor.setDefaultDefine("BGFX_SHADER_LANGUAGE_HLSL"); + preprocessor.setDefaultDefine("BGFX_SHADER_TYPE_FRAGMENT"); + preprocessor.setDefaultDefine("BGFX_SHADER_TYPE_VERTEX"); + + bool glsl = false; + + if (0 == _stricmp(platform, "android") ) + { + preprocessor.setDefine("BX_PLATFORM_ANDROID=1"); + preprocessor.setDefine("BGFX_SHADER_LANGUAGE_GLSL=1"); + glsl = true; + } + else if (0 == _stricmp(platform, "nacl") ) + { + preprocessor.setDefine("BX_PLATFORM_NACL=1"); + preprocessor.setDefine("BGFX_SHADER_LANGUAGE_GLSL=1"); + glsl = true; + } + else if (0 == _stricmp(platform, "windows") ) + { + preprocessor.setDefine("BX_PLATFORM_WINDOWS=1"); + preprocessor.setDefine("BGFX_SHADER_LANGUAGE_HLSL=1"); + } + else if (0 == _stricmp(platform, "xbox360") ) + { + preprocessor.setDefine("BX_PLATFORM_XBOX360=1"); + preprocessor.setDefine("BGFX_SHADER_LANGUAGE_HLSL=1"); + } + else + { + fprintf(stderr, "Unknown platform %s?!", platform); + return 1; + } + + if (0 == _stricmp(type, "fragment") ) + { + preprocessor.setDefine("BGFX_SHADER_TYPE_FRAGMENT=1"); + } + else + { + preprocessor.setDefine("BGFX_SHADER_TYPE_VERTEX=1"); + } + + if (preprocessor.run() ) + { + BX_TRACE("Input file: %s", filePath); + BX_TRACE("Output file: %s", outFilePath); + + if (preprocessOnly) + { + FILE* out = fopen(outFilePath, "wb"); + if (NULL == out) + { + fprintf(stderr, "Unable to open output file '%s'.", outFilePath); + return false; + } + + Stream stream(out); + if (glsl) + { + stream.write("precision highp float;\n\n"); + } + stream.write(preprocessor.m_preprocessed.c_str(), preprocessor.m_preprocessed.size() ); + stream.close(); + fclose(out); + + return EXIT_SUCCESS; + } + + if (glsl) + { + if (compileGLSLShader(cmdLine, preprocessor.m_preprocessed, outFilePath) ) + { + return EXIT_SUCCESS; + } + } + else + { + if (compileHLSLShader(cmdLine, preprocessor.m_preprocessed, outFilePath) ) + { + return EXIT_SUCCESS; + } + } + } + + fprintf(stderr, "Failed to build shader.\n"); + return EXIT_FAILURE; +}