├── .gitignore ├── 3rdparty ├── catch.hpp ├── glew │ ├── LICENSE.txt │ ├── glew.vcxproj │ ├── glew.vcxproj.filters │ ├── include │ │ └── GL │ │ │ ├── eglew.h │ │ │ ├── glew.h │ │ │ ├── glxew.h │ │ │ └── wglew.h │ └── src │ │ └── glew.c ├── glfw │ ├── ALTERATIONS.txt │ ├── COPYING.txt │ ├── glfw.vcxproj │ ├── glfw.vcxproj.filters │ ├── include │ │ └── GLFW │ │ │ ├── glfw3.h │ │ │ └── glfw3native.h │ └── src │ │ ├── context.c │ │ ├── egl_context.c │ │ ├── egl_context.h │ │ ├── init.c │ │ ├── input.c │ │ ├── internal.h │ │ ├── monitor.c │ │ ├── vulkan.c │ │ ├── wgl_context.c │ │ ├── wgl_context.h │ │ ├── win32_init.c │ │ ├── win32_joystick.c │ │ ├── win32_joystick.h │ │ ├── win32_monitor.c │ │ ├── win32_platform.h │ │ ├── win32_time.c │ │ ├── win32_tls.c │ │ ├── win32_window.c │ │ └── window.c ├── glslang │ ├── OGLCompilersDLL │ │ ├── InitializeDll.cpp │ │ └── InitializeDll.h │ ├── SPIRV │ │ ├── GLSL.ext.AMD.h │ │ ├── GLSL.ext.KHR.h │ │ ├── GLSL.ext.NV.h │ │ ├── GLSL.std.450.h │ │ ├── GlslangToSpv.cpp │ │ ├── GlslangToSpv.h │ │ ├── InReadableOrder.cpp │ │ ├── Logger.cpp │ │ ├── Logger.h │ │ ├── SPVRemapper.cpp │ │ ├── SPVRemapper.h │ │ ├── SpvBuilder.cpp │ │ ├── SpvBuilder.h │ │ ├── bitutils.h │ │ ├── disassemble.cpp │ │ ├── disassemble.h │ │ ├── doc.cpp │ │ ├── doc.h │ │ ├── hex_float.h │ │ ├── spirv.hpp │ │ └── spvIR.h │ ├── StandAlone │ │ ├── ResourceLimits.cpp │ │ └── ResourceLimits.h │ ├── glslang.vcxproj │ ├── glslang.vcxproj.filters │ ├── glslang │ │ ├── GenericCodeGen │ │ │ ├── CodeGen.cpp │ │ │ └── Link.cpp │ │ ├── Include │ │ │ ├── BaseTypes.h │ │ │ ├── Common.h │ │ │ ├── ConstantUnion.h │ │ │ ├── InfoSink.h │ │ │ ├── InitializeGlobals.h │ │ │ ├── PoolAlloc.h │ │ │ ├── ResourceLimits.h │ │ │ ├── ShHandle.h │ │ │ ├── Types.h │ │ │ ├── arrays.h │ │ │ ├── intermediate.h │ │ │ └── revision.h │ │ ├── MachineIndependent │ │ │ ├── Constant.cpp │ │ │ ├── InfoSink.cpp │ │ │ ├── Initialize.cpp │ │ │ ├── Initialize.h │ │ │ ├── IntermTraverse.cpp │ │ │ ├── Intermediate.cpp │ │ │ ├── LiveTraverser.h │ │ │ ├── ParseContextBase.cpp │ │ │ ├── ParseHelper.cpp │ │ │ ├── ParseHelper.h │ │ │ ├── PoolAlloc.cpp │ │ │ ├── RemoveTree.cpp │ │ │ ├── RemoveTree.h │ │ │ ├── Scan.cpp │ │ │ ├── Scan.h │ │ │ ├── ScanContext.h │ │ │ ├── ShaderLang.cpp │ │ │ ├── SymbolTable.cpp │ │ │ ├── SymbolTable.h │ │ │ ├── Versions.cpp │ │ │ ├── Versions.h │ │ │ ├── gl_types.h │ │ │ ├── glslang_tab.cpp │ │ │ ├── glslang_tab.cpp.h │ │ │ ├── intermOut.cpp │ │ │ ├── iomapper.cpp │ │ │ ├── iomapper.h │ │ │ ├── limits.cpp │ │ │ ├── linkValidate.cpp │ │ │ ├── localintermediate.h │ │ │ ├── parseConst.cpp │ │ │ ├── parseVersions.h │ │ │ ├── preprocessor │ │ │ │ ├── Pp.cpp │ │ │ │ ├── PpAtom.cpp │ │ │ │ ├── PpContext.cpp │ │ │ │ ├── PpContext.h │ │ │ │ ├── PpMemory.cpp │ │ │ │ ├── PpScanner.cpp │ │ │ │ ├── PpSymbols.cpp │ │ │ │ ├── PpTokens.cpp │ │ │ │ └── PpTokens.h │ │ │ ├── propagateNoContraction.cpp │ │ │ ├── propagateNoContraction.h │ │ │ ├── reflection.cpp │ │ │ └── reflection.h │ │ ├── OSDependent │ │ │ ├── Unix │ │ │ │ └── ossource.cpp │ │ │ ├── Windows │ │ │ │ └── ossource.cpp │ │ │ └── osinclude.h │ │ └── Public │ │ │ └── ShaderLang.h │ └── hlsl │ │ ├── hlslAttributes.cpp │ │ ├── hlslAttributes.h │ │ ├── hlslGrammar.cpp │ │ ├── hlslGrammar.h │ │ ├── hlslOpMap.cpp │ │ ├── hlslOpMap.h │ │ ├── hlslParseHelper.cpp │ │ ├── hlslParseHelper.h │ │ ├── hlslParseables.cpp │ │ ├── hlslParseables.h │ │ ├── hlslScanContext.cpp │ │ ├── hlslScanContext.h │ │ ├── hlslTokenStream.cpp │ │ ├── hlslTokenStream.h │ │ └── hlslTokens.h ├── stb │ ├── stb_image.h │ └── stb_truetype.h └── zlib │ ├── FAQ │ ├── README │ ├── include │ ├── crc32.h │ ├── deflate.h │ ├── gzguts.h │ ├── inffast.h │ ├── inffixed.h │ ├── inflate.h │ ├── inftrees.h │ ├── trees.h │ ├── zconf.h │ ├── zlib.h │ └── zutil.h │ ├── src │ ├── adler32.c │ ├── compress.c │ ├── crc32.c │ ├── deflate.c │ ├── gzclose.c │ ├── gzlib.c │ ├── gzread.c │ ├── gzwrite.c │ ├── infback.c │ ├── inffast.c │ ├── inflate.c │ ├── inftrees.c │ ├── trees.c │ ├── uncompr.c │ └── zutil.c │ ├── zlib.vcxproj │ └── zlib.vcxproj.filters ├── README.md ├── UNLICENSE ├── example-game ├── assets │ ├── ATTRIBUTIONS.txt │ ├── akai-albedo.jpg │ ├── akai-normal.jpg │ ├── cube-mesh.fbx │ ├── helmet-albedo.jpg │ ├── helmet-mesh.fbx │ ├── helmet-metallic.jpg │ ├── helmet-normal.jpg │ ├── helmet-roughness.jpg │ ├── map_2_fire.png │ ├── map_2_island.jpg │ ├── map_2_objects.jpg │ ├── map_2_terrain.jpg │ ├── metal.frag │ ├── mutant-albedo.jpg │ ├── mutant-mesh.fbx │ ├── mutant-normal.jpg │ ├── negx.jpg │ ├── negy.jpg │ ├── negz.jpg │ ├── posx.jpg │ ├── posy.jpg │ ├── posz.jpg │ ├── sands location.mtl │ ├── sands location.obj │ ├── scene.glsl │ ├── shader.frag │ ├── skinned.vert │ ├── skybox.frag │ ├── skybox.vert │ └── static.vert ├── example-game.cpp ├── example-game.vcxproj └── example-game.vcxproj.filters ├── example-pbr ├── assets │ ├── ATTRIBUTIONS.txt │ ├── factory-catwalk.hdr │ ├── monument-valley.hdr │ └── shiodome-stairs.hdr ├── example-pbr.cpp ├── example-pbr.vcxproj ├── example-pbr.vcxproj.filters ├── pbr.cpp └── pbr.h ├── example-rts ├── assets │ ├── ATTRIBUTIONS.txt │ ├── add.frag │ ├── cf105.jpg │ ├── cf105.obj │ ├── f44a.jpg │ ├── f44a.obj │ ├── glow.frag │ ├── hgauss.frag │ ├── hipass.frag │ ├── image.frag │ ├── image.vert │ ├── particle.frag │ ├── particle.png │ ├── particle.vert │ ├── sample.frag │ ├── scene.glsl │ ├── shader.frag │ ├── static.vert │ └── vgauss.frag ├── example-rts.cpp ├── example-rts.vcxproj ├── example-rts.vcxproj.filters ├── rts-game.cpp └── rts-game.h ├── include-engine-tests ├── include-engine-tests.cpp ├── include-engine-tests.vcxproj └── include-engine-tests.vcxproj.filters ├── include-engine.sln └── include-engine ├── data-types.cpp ├── data-types.h ├── fbx.cpp ├── fbx.h ├── include-engine.vcxproj ├── include-engine.vcxproj.filters ├── linalg.h ├── load.cpp ├── load.h ├── renderer.cpp ├── renderer.h ├── sprite.cpp ├── sprite.h ├── utility.cpp └── utility.h /.gitignore: -------------------------------------------------------------------------------- 1 | bin 2 | lib 3 | obj 4 | /.vs 5 | *.spv -------------------------------------------------------------------------------- /3rdparty/glew/LICENSE.txt: -------------------------------------------------------------------------------- 1 | The OpenGL Extension Wrangler Library 2 | Copyright (C) 2002-2007, Milan Ikits 3 | Copyright (C) 2002-2007, Marcelo E. Magallon 4 | Copyright (C) 2002, Lev Povalahev 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | * Redistributions of source code must retain the above copyright notice, 11 | this list of conditions and the following disclaimer. 12 | * Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | * The name of the author may be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 22 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 28 | THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | 31 | Mesa 3-D graphics library 32 | Version: 7.0 33 | 34 | Copyright (C) 1999-2007 Brian Paul All Rights Reserved. 35 | 36 | Permission is hereby granted, free of charge, to any person obtaining a 37 | copy of this software and associated documentation files (the "Software"), 38 | to deal in the Software without restriction, including without limitation 39 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 40 | and/or sell copies of the Software, and to permit persons to whom the 41 | Software is furnished to do so, subject to the following conditions: 42 | 43 | The above copyright notice and this permission notice shall be included 44 | in all copies or substantial portions of the Software. 45 | 46 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 47 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 48 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 49 | BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 50 | AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 51 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 52 | 53 | 54 | Copyright (c) 2007 The Khronos Group Inc. 55 | 56 | Permission is hereby granted, free of charge, to any person obtaining a 57 | copy of this software and/or associated documentation files (the 58 | "Materials"), to deal in the Materials without restriction, including 59 | without limitation the rights to use, copy, modify, merge, publish, 60 | distribute, sublicense, and/or sell copies of the Materials, and to 61 | permit persons to whom the Materials are furnished to do so, subject to 62 | the following conditions: 63 | 64 | The above copyright notice and this permission notice shall be included 65 | in all copies or substantial portions of the Materials. 66 | 67 | THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 68 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 69 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 70 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 71 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 72 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 73 | MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. 74 | -------------------------------------------------------------------------------- /3rdparty/glew/glew.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | include 6 | 7 | 8 | include 9 | 10 | 11 | include 12 | 13 | 14 | include 15 | 16 | 17 | 18 | 19 | {b5b11958-8478-41f9-8f12-d82bb1ca478b} 20 | 21 | 22 | {0cc5a212-2fd8-4b69-895a-836c940a62c1} 23 | 24 | 25 | 26 | 27 | src 28 | 29 | 30 | -------------------------------------------------------------------------------- /3rdparty/glfw/ALTERATIONS.txt: -------------------------------------------------------------------------------- 1 | These sources were taken from GLFW 3.2.1. 2 | 3 | They are unmodified except to remove files which are not necessary to build on Windows. -------------------------------------------------------------------------------- /3rdparty/glfw/COPYING.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2002-2006 Marcus Geelnard 2 | Copyright (c) 2006-2016 Camilla Berglund 3 | 4 | This software is provided 'as-is', without any express or implied 5 | warranty. In no event will the authors be held liable for any damages 6 | arising from the use of this software. 7 | 8 | Permission is granted to anyone to use this software for any purpose, 9 | including commercial applications, and to alter it and redistribute it 10 | freely, subject to the following restrictions: 11 | 12 | 1. The origin of this software must not be misrepresented; you must not 13 | claim that you wrote the original software. If you use this software 14 | in a product, an acknowledgment in the product documentation would 15 | be appreciated but is not required. 16 | 17 | 2. Altered source versions must be plainly marked as such, and must not 18 | be misrepresented as being the original software. 19 | 20 | 3. This notice may not be removed or altered from any source 21 | distribution. 22 | 23 | -------------------------------------------------------------------------------- /3rdparty/glfw/glfw.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | src 6 | 7 | 8 | src 9 | 10 | 11 | src 12 | 13 | 14 | src 15 | 16 | 17 | src 18 | 19 | 20 | src 21 | 22 | 23 | src 24 | 25 | 26 | src 27 | 28 | 29 | src 30 | 31 | 32 | src 33 | 34 | 35 | src 36 | 37 | 38 | src 39 | 40 | 41 | src 42 | 43 | 44 | src 45 | 46 | 47 | 48 | 49 | src 50 | 51 | 52 | src 53 | 54 | 55 | src 56 | 57 | 58 | src 59 | 60 | 61 | src 62 | 63 | 64 | include 65 | 66 | 67 | include 68 | 69 | 70 | 71 | 72 | {433e8b0a-3f04-43ca-85a5-2216aea58746} 73 | 74 | 75 | {ac7f7ad3-7eda-4136-a3af-4632107e0084} 76 | 77 | 78 | -------------------------------------------------------------------------------- /3rdparty/glfw/src/win32_joystick.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.2 Win32 - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2006-2016 Camilla Berglund 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | 27 | #ifndef _glfw3_win32_joystick_h_ 28 | #define _glfw3_win32_joystick_h_ 29 | 30 | #define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE \ 31 | _GLFWjoystickWin32 win32_js[GLFW_JOYSTICK_LAST + 1] 32 | 33 | // Joystick element (axis, button or slider) 34 | // 35 | typedef struct _GLFWjoyobjectWin32 36 | { 37 | int offset; 38 | int type; 39 | } _GLFWjoyobjectWin32; 40 | 41 | // Win32-specific per-joystick data 42 | // 43 | typedef struct _GLFWjoystickWin32 44 | { 45 | GLFWbool present; 46 | float* axes; 47 | int axisCount; 48 | unsigned char* buttons; 49 | int buttonCount; 50 | _GLFWjoyobjectWin32* objects; 51 | int objectCount; 52 | char* name; 53 | IDirectInputDevice8W* device; 54 | DWORD index; 55 | GUID guid; 56 | } _GLFWjoystickWin32; 57 | 58 | 59 | void _glfwInitJoysticksWin32(void); 60 | void _glfwTerminateJoysticksWin32(void); 61 | void _glfwDetectJoystickConnectionWin32(void); 62 | void _glfwDetectJoystickDisconnectionWin32(void); 63 | 64 | #endif // _glfw3_win32_joystick_h_ 65 | -------------------------------------------------------------------------------- /3rdparty/glfw/src/win32_time.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.2 Win32 - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2002-2006 Marcus Geelnard 5 | // Copyright (c) 2006-2016 Camilla Berglund 6 | // 7 | // This software is provided 'as-is', without any express or implied 8 | // warranty. In no event will the authors be held liable for any damages 9 | // arising from the use of this software. 10 | // 11 | // Permission is granted to anyone to use this software for any purpose, 12 | // including commercial applications, and to alter it and redistribute it 13 | // freely, subject to the following restrictions: 14 | // 15 | // 1. The origin of this software must not be misrepresented; you must not 16 | // claim that you wrote the original software. If you use this software 17 | // in a product, an acknowledgment in the product documentation would 18 | // be appreciated but is not required. 19 | // 20 | // 2. Altered source versions must be plainly marked as such, and must not 21 | // be misrepresented as being the original software. 22 | // 23 | // 3. This notice may not be removed or altered from any source 24 | // distribution. 25 | // 26 | //======================================================================== 27 | 28 | #include "internal.h" 29 | 30 | 31 | ////////////////////////////////////////////////////////////////////////// 32 | ////// GLFW internal API ////// 33 | ////////////////////////////////////////////////////////////////////////// 34 | 35 | // Initialise timer 36 | // 37 | void _glfwInitTimerWin32(void) 38 | { 39 | uint64_t frequency; 40 | 41 | if (QueryPerformanceFrequency((LARGE_INTEGER*) &frequency)) 42 | { 43 | _glfw.win32_time.hasPC = GLFW_TRUE; 44 | _glfw.win32_time.frequency = frequency; 45 | } 46 | else 47 | { 48 | _glfw.win32_time.hasPC = GLFW_FALSE; 49 | _glfw.win32_time.frequency = 1000; 50 | } 51 | } 52 | 53 | 54 | ////////////////////////////////////////////////////////////////////////// 55 | ////// GLFW platform API ////// 56 | ////////////////////////////////////////////////////////////////////////// 57 | 58 | uint64_t _glfwPlatformGetTimerValue(void) 59 | { 60 | if (_glfw.win32_time.hasPC) 61 | { 62 | uint64_t value; 63 | QueryPerformanceCounter((LARGE_INTEGER*) &value); 64 | return value; 65 | } 66 | else 67 | return (uint64_t) _glfw_timeGetTime(); 68 | } 69 | 70 | uint64_t _glfwPlatformGetTimerFrequency(void) 71 | { 72 | return _glfw.win32_time.frequency; 73 | } 74 | 75 | -------------------------------------------------------------------------------- /3rdparty/glfw/src/win32_tls.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.2 Win32 - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2002-2006 Marcus Geelnard 5 | // Copyright (c) 2006-2016 Camilla Berglund 6 | // 7 | // This software is provided 'as-is', without any express or implied 8 | // warranty. In no event will the authors be held liable for any damages 9 | // arising from the use of this software. 10 | // 11 | // Permission is granted to anyone to use this software for any purpose, 12 | // including commercial applications, and to alter it and redistribute it 13 | // freely, subject to the following restrictions: 14 | // 15 | // 1. The origin of this software must not be misrepresented; you must not 16 | // claim that you wrote the original software. If you use this software 17 | // in a product, an acknowledgment in the product documentation would 18 | // be appreciated but is not required. 19 | // 20 | // 2. Altered source versions must be plainly marked as such, and must not 21 | // be misrepresented as being the original software. 22 | // 23 | // 3. This notice may not be removed or altered from any source 24 | // distribution. 25 | // 26 | //======================================================================== 27 | 28 | #include "internal.h" 29 | 30 | 31 | ////////////////////////////////////////////////////////////////////////// 32 | ////// GLFW internal API ////// 33 | ////////////////////////////////////////////////////////////////////////// 34 | 35 | GLFWbool _glfwInitThreadLocalStorageWin32(void) 36 | { 37 | _glfw.win32_tls.context = TlsAlloc(); 38 | if (_glfw.win32_tls.context == TLS_OUT_OF_INDEXES) 39 | { 40 | _glfwInputError(GLFW_PLATFORM_ERROR, 41 | "Win32: Failed to allocate TLS index"); 42 | return GLFW_FALSE; 43 | } 44 | 45 | _glfw.win32_tls.allocated = GLFW_TRUE; 46 | return GLFW_TRUE; 47 | } 48 | 49 | void _glfwTerminateThreadLocalStorageWin32(void) 50 | { 51 | if (_glfw.win32_tls.allocated) 52 | TlsFree(_glfw.win32_tls.context); 53 | } 54 | 55 | 56 | ////////////////////////////////////////////////////////////////////////// 57 | ////// GLFW platform API ////// 58 | ////////////////////////////////////////////////////////////////////////// 59 | 60 | void _glfwPlatformSetCurrentContext(_GLFWwindow* context) 61 | { 62 | TlsSetValue(_glfw.win32_tls.context, context); 63 | } 64 | 65 | _GLFWwindow* _glfwPlatformGetCurrentContext(void) 66 | { 67 | return TlsGetValue(_glfw.win32_tls.context); 68 | } 69 | 70 | -------------------------------------------------------------------------------- /3rdparty/glslang/OGLCompilersDLL/InitializeDll.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2002-2005 3Dlabs Inc. Ltd. 3 | // All rights reserved. 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions 7 | // are met: 8 | // 9 | // Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following 14 | // disclaimer in the documentation and/or other materials provided 15 | // with the distribution. 16 | // 17 | // Neither the name of 3Dlabs Inc. Ltd. nor the names of its 18 | // contributors may be used to endorse or promote products derived 19 | // from this software without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 24 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 25 | // COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 26 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 27 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 31 | // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | // POSSIBILITY OF SUCH DAMAGE. 33 | // 34 | 35 | #define SH_EXPORTING 36 | 37 | #include 38 | 39 | #include "InitializeDll.h" 40 | #include "../glslang/Include/InitializeGlobals.h" 41 | 42 | #include "../glslang/Public/ShaderLang.h" 43 | 44 | namespace glslang { 45 | 46 | OS_TLSIndex ThreadInitializeIndex = OS_INVALID_TLS_INDEX; 47 | 48 | bool InitProcess() 49 | { 50 | glslang::GetGlobalLock(); 51 | 52 | if (ThreadInitializeIndex != OS_INVALID_TLS_INDEX) { 53 | // 54 | // Function is re-entrant. 55 | // 56 | 57 | glslang::ReleaseGlobalLock(); 58 | return true; 59 | } 60 | 61 | ThreadInitializeIndex = OS_AllocTLSIndex(); 62 | 63 | if (ThreadInitializeIndex == OS_INVALID_TLS_INDEX) { 64 | assert(0 && "InitProcess(): Failed to allocate TLS area for init flag"); 65 | 66 | glslang::ReleaseGlobalLock(); 67 | return false; 68 | } 69 | 70 | if (! InitializePoolIndex()) { 71 | assert(0 && "InitProcess(): Failed to initialize global pool"); 72 | 73 | glslang::ReleaseGlobalLock(); 74 | return false; 75 | } 76 | 77 | if (! InitThread()) { 78 | assert(0 && "InitProcess(): Failed to initialize thread"); 79 | 80 | glslang::ReleaseGlobalLock(); 81 | return false; 82 | } 83 | 84 | glslang::ReleaseGlobalLock(); 85 | return true; 86 | } 87 | 88 | 89 | bool InitThread() 90 | { 91 | // 92 | // This function is re-entrant 93 | // 94 | if (ThreadInitializeIndex == OS_INVALID_TLS_INDEX) { 95 | assert(0 && "InitThread(): Process hasn't been initalised."); 96 | return false; 97 | } 98 | 99 | if (OS_GetTLSValue(ThreadInitializeIndex) != 0) 100 | return true; 101 | 102 | InitializeMemoryPools(); 103 | 104 | if (! OS_SetTLSValue(ThreadInitializeIndex, (void *)1)) { 105 | assert(0 && "InitThread(): Unable to set init flag."); 106 | return false; 107 | } 108 | 109 | return true; 110 | } 111 | 112 | 113 | bool DetachThread() 114 | { 115 | bool success = true; 116 | 117 | if (ThreadInitializeIndex == OS_INVALID_TLS_INDEX) 118 | return true; 119 | 120 | // 121 | // Function is re-entrant and this thread may not have been initialized. 122 | // 123 | if (OS_GetTLSValue(ThreadInitializeIndex) != 0) { 124 | if (!OS_SetTLSValue(ThreadInitializeIndex, (void *)0)) { 125 | assert(0 && "DetachThread(): Unable to clear init flag."); 126 | success = false; 127 | } 128 | 129 | FreeGlobalPools(); 130 | 131 | } 132 | 133 | return success; 134 | } 135 | 136 | bool DetachProcess() 137 | { 138 | bool success = true; 139 | 140 | if (ThreadInitializeIndex == OS_INVALID_TLS_INDEX) 141 | return true; 142 | 143 | ShFinalize(); 144 | 145 | success = DetachThread(); 146 | 147 | FreePoolIndex(); 148 | 149 | OS_FreeTLSIndex(ThreadInitializeIndex); 150 | ThreadInitializeIndex = OS_INVALID_TLS_INDEX; 151 | 152 | return success; 153 | } 154 | 155 | } // end namespace glslang 156 | -------------------------------------------------------------------------------- /3rdparty/glslang/OGLCompilersDLL/InitializeDll.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2002-2005 3Dlabs Inc. Ltd. 3 | // All rights reserved. 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions 7 | // are met: 8 | // 9 | // Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following 14 | // disclaimer in the documentation and/or other materials provided 15 | // with the distribution. 16 | // 17 | // Neither the name of 3Dlabs Inc. Ltd. nor the names of its 18 | // contributors may be used to endorse or promote products derived 19 | // from this software without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 24 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 25 | // COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 26 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 27 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 31 | // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | // POSSIBILITY OF SUCH DAMAGE. 33 | // 34 | #ifndef __INITIALIZEDLL_H 35 | #define __INITIALIZEDLL_H 36 | 37 | #include "../glslang/OSDependent/osinclude.h" 38 | 39 | namespace glslang { 40 | 41 | bool InitProcess(); 42 | bool InitThread(); 43 | bool DetachThread(); 44 | bool DetachProcess(); 45 | 46 | } // end namespace glslang 47 | 48 | #endif // __INITIALIZEDLL_H 49 | 50 | -------------------------------------------------------------------------------- /3rdparty/glslang/SPIRV/GLSL.ext.AMD.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2014-2016 The Khronos Group Inc. 3 | ** 4 | ** Permission is hereby granted, free of charge, to any person obtaining a copy 5 | ** of this software and/or associated documentation files (the "Materials"), 6 | ** to deal in the Materials without restriction, including without limitation 7 | ** the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | ** and/or sell copies of the Materials, and to permit persons to whom the 9 | ** Materials are furnished to do so, subject to the following conditions: 10 | ** 11 | ** The above copyright notice and this permission notice shall be included in 12 | ** all copies or substantial portions of the Materials. 13 | ** 14 | ** MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS KHRONOS 15 | ** STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS SPECIFICATIONS AND 16 | ** HEADER INFORMATION ARE LOCATED AT https://www.khronos.org/registry/ 17 | ** 18 | ** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 19 | ** OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 | ** THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | ** FROM,OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS 24 | ** IN THE MATERIALS. 25 | */ 26 | 27 | #ifndef GLSLextAMD_H 28 | #define GLSLextAMD_H 29 | 30 | enum BuiltIn; 31 | enum Decoration; 32 | enum Op; 33 | 34 | static const int GLSLextAMDVersion = 100; 35 | static const int GLSLextAMDRevision = 2; 36 | 37 | // SPV_AMD_shader_ballot 38 | static const char* const E_SPV_AMD_shader_ballot = "SPV_AMD_shader_ballot"; 39 | 40 | static const Op OpGroupIAddNonUniformAMD = static_cast(5000); 41 | static const Op OpGroupFAddNonUniformAMD = static_cast(5001); 42 | static const Op OpGroupFMinNonUniformAMD = static_cast(5002); 43 | static const Op OpGroupUMinNonUniformAMD = static_cast(5003); 44 | static const Op OpGroupSMinNonUniformAMD = static_cast(5004); 45 | static const Op OpGroupFMaxNonUniformAMD = static_cast(5005); 46 | static const Op OpGroupUMaxNonUniformAMD = static_cast(5006); 47 | static const Op OpGroupSMaxNonUniformAMD = static_cast(5007); 48 | 49 | enum ShaderBallotAMD { 50 | ShaderBallotBadAMD = 0, // Don't use 51 | 52 | SwizzleInvocationsAMD = 1, 53 | SwizzleInvocationsMaskedAMD = 2, 54 | WriteInvocationAMD = 3, 55 | MbcntAMD = 4, 56 | 57 | ShaderBallotCountAMD 58 | }; 59 | 60 | // SPV_AMD_shader_trinary_minmax 61 | static const char* const E_SPV_AMD_shader_trinary_minmax = "SPV_AMD_shader_trinary_minmax"; 62 | 63 | enum ShaderTrinaryMinMaxAMD { 64 | ShaderTrinaryMinMaxBadAMD = 0, // Don't use 65 | 66 | FMin3AMD = 1, 67 | UMin3AMD = 2, 68 | SMin3AMD = 3, 69 | FMax3AMD = 4, 70 | UMax3AMD = 5, 71 | SMax3AMD = 6, 72 | FMid3AMD = 7, 73 | UMid3AMD = 8, 74 | SMid3AMD = 9, 75 | 76 | ShaderTrinaryMinMaxCountAMD 77 | }; 78 | 79 | // SPV_AMD_shader_explicit_vertex_parameter 80 | static const char* const E_SPV_AMD_shader_explicit_vertex_parameter = "SPV_AMD_shader_explicit_vertex_parameter"; 81 | 82 | static const BuiltIn BuiltInBaryCoordNoPerspAMD = static_cast(4992); 83 | static const BuiltIn BuiltInBaryCoordNoPerspCentroidAMD = static_cast(4993); 84 | static const BuiltIn BuiltInBaryCoordNoPerspSampleAMD = static_cast(4994); 85 | static const BuiltIn BuiltInBaryCoordSmoothAMD = static_cast(4995); 86 | static const BuiltIn BuiltInBaryCoordSmoothCentroidAMD = static_cast(4996); 87 | static const BuiltIn BuiltInBaryCoordSmoothSampleAMD = static_cast(4997); 88 | static const BuiltIn BuiltInBaryCoordPullModelAMD = static_cast(4998); 89 | 90 | static const Decoration DecorationExplicitInterpAMD = static_cast(4999); 91 | 92 | enum ShaderExplicitVertexParameterAMD { 93 | ShaderExplicitVertexParameterBadAMD = 0, // Don't use 94 | 95 | InterpolateAtVertexAMD = 1, 96 | 97 | ShaderExplicitVertexParameterCountAMD 98 | }; 99 | 100 | // SPV_AMD_gcn_shader 101 | static const char* const E_SPV_AMD_gcn_shader = "SPV_AMD_gcn_shader"; 102 | 103 | enum GcnShaderAMD { 104 | GcnShaderBadAMD = 0, // Don't use 105 | 106 | CubeFaceIndexAMD = 1, 107 | CubeFaceCoordAMD = 2, 108 | TimeAMD = 3, 109 | 110 | GcnShaderCountAMD 111 | }; 112 | 113 | // SPV_AMD_gpu_shader_half_float 114 | static const char* const E_SPV_AMD_gpu_shader_half_float = "SPV_AMD_gpu_shader_half_float"; 115 | 116 | #endif // #ifndef GLSLextAMD_H 117 | -------------------------------------------------------------------------------- /3rdparty/glslang/SPIRV/GLSL.ext.KHR.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2014-2016 The Khronos Group Inc. 3 | ** 4 | ** Permission is hereby granted, free of charge, to any person obtaining a copy 5 | ** of this software and/or associated documentation files (the "Materials"), 6 | ** to deal in the Materials without restriction, including without limitation 7 | ** the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | ** and/or sell copies of the Materials, and to permit persons to whom the 9 | ** Materials are furnished to do so, subject to the following conditions: 10 | ** 11 | ** The above copyright notice and this permission notice shall be included in 12 | ** all copies or substantial portions of the Materials. 13 | ** 14 | ** MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS KHRONOS 15 | ** STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS SPECIFICATIONS AND 16 | ** HEADER INFORMATION ARE LOCATED AT https://www.khronos.org/registry/ 17 | ** 18 | ** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 19 | ** OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 | ** THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | ** FROM,OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS 24 | ** IN THE MATERIALS. 25 | */ 26 | 27 | #ifndef GLSLextKHR_H 28 | #define GLSLextKHR_H 29 | 30 | enum BuiltIn; 31 | enum Op; 32 | enum Capability; 33 | 34 | static const int GLSLextKHRVersion = 100; 35 | static const int GLSLextKHRRevision = 1; 36 | 37 | static const char* const E_SPV_KHR_shader_ballot = "SPV_KHR_shader_ballot"; 38 | static const char* const E_SPV_KHR_subgroup_vote = "SPV_KHR_subgroup_vote"; 39 | static const char* const E_SPV_KHR_device_group = "SPV_KHR_device_group"; 40 | static const char* const E_SPV_KHR_multiview = "SPV_KHR_multiview"; 41 | static const char* const E_SPV_KHR_shader_draw_parameters = "SPV_KHR_shader_draw_parameters"; 42 | 43 | #endif // #ifndef GLSLextKHR_H 44 | -------------------------------------------------------------------------------- /3rdparty/glslang/SPIRV/GLSL.ext.NV.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2014-2017 The Khronos Group Inc. 3 | ** 4 | ** Permission is hereby granted, free of charge, to any person obtaining a copy 5 | ** of this software and/or associated documentation files (the "Materials"), 6 | ** to deal in the Materials without restriction, including without limitation 7 | ** the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | ** and/or sell copies of the Materials, and to permit persons to whom the 9 | ** Materials are furnished to do so, subject to the following conditions: 10 | ** 11 | ** The above copyright notice and this permission notice shall be included in 12 | ** all copies or substantial portions of the Materials. 13 | ** 14 | ** MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS KHRONOS 15 | ** STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS SPECIFICATIONS AND 16 | ** HEADER INFORMATION ARE LOCATED AT https://www.khronos.org/registry/ 17 | ** 18 | ** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 19 | ** OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 | ** THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | ** FROM,OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS 24 | ** IN THE MATERIALS. 25 | */ 26 | 27 | #ifndef GLSLextNV_H 28 | #define GLSLextNV_H 29 | 30 | enum BuiltIn; 31 | enum Decoration; 32 | enum Op; 33 | enum Capability; 34 | 35 | static const int GLSLextNVVersion = 100; 36 | static const int GLSLextNVRevision = 5; 37 | 38 | //SPV_NV_sample_mask_override_coverage 39 | const char* const E_SPV_NV_sample_mask_override_coverage = "SPV_NV_sample_mask_override_coverage"; 40 | 41 | //SPV_NV_geometry_shader_passthrough 42 | const char* const E_SPV_NV_geometry_shader_passthrough = "SPV_NV_geometry_shader_passthrough"; 43 | 44 | //SPV_NV_viewport_array2 45 | const char* const E_SPV_NV_viewport_array2 = "SPV_NV_viewport_array2"; 46 | const char* const E_ARB_shader_viewport_layer_array = "SPV_ARB_shader_viewport_layer_array"; 47 | 48 | //SPV_NV_stereo_view_rendering 49 | const char* const E_SPV_NV_stereo_view_rendering = "SPV_NV_stereo_view_rendering"; 50 | 51 | //SPV_NVX_multiview_per_view_attributes 52 | const char* const E_SPV_NVX_multiview_per_view_attributes = "SPV_NVX_multiview_per_view_attributes"; 53 | 54 | #endif // #ifndef GLSLextNV_H -------------------------------------------------------------------------------- /3rdparty/glslang/SPIRV/GLSL.std.450.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2014-2016 The Khronos Group Inc. 3 | ** 4 | ** Permission is hereby granted, free of charge, to any person obtaining a copy 5 | ** of this software and/or associated documentation files (the "Materials"), 6 | ** to deal in the Materials without restriction, including without limitation 7 | ** the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | ** and/or sell copies of the Materials, and to permit persons to whom the 9 | ** Materials are furnished to do so, subject to the following conditions: 10 | ** 11 | ** The above copyright notice and this permission notice shall be included in 12 | ** all copies or substantial portions of the Materials. 13 | ** 14 | ** MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS KHRONOS 15 | ** STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS SPECIFICATIONS AND 16 | ** HEADER INFORMATION ARE LOCATED AT https://www.khronos.org/registry/ 17 | ** 18 | ** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 19 | ** OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 | ** THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | ** FROM,OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS 24 | ** IN THE MATERIALS. 25 | */ 26 | 27 | #ifndef GLSLstd450_H 28 | #define GLSLstd450_H 29 | 30 | static const int GLSLstd450Version = 100; 31 | static const int GLSLstd450Revision = 1; 32 | 33 | enum GLSLstd450 { 34 | GLSLstd450Bad = 0, // Don't use 35 | 36 | GLSLstd450Round = 1, 37 | GLSLstd450RoundEven = 2, 38 | GLSLstd450Trunc = 3, 39 | GLSLstd450FAbs = 4, 40 | GLSLstd450SAbs = 5, 41 | GLSLstd450FSign = 6, 42 | GLSLstd450SSign = 7, 43 | GLSLstd450Floor = 8, 44 | GLSLstd450Ceil = 9, 45 | GLSLstd450Fract = 10, 46 | 47 | GLSLstd450Radians = 11, 48 | GLSLstd450Degrees = 12, 49 | GLSLstd450Sin = 13, 50 | GLSLstd450Cos = 14, 51 | GLSLstd450Tan = 15, 52 | GLSLstd450Asin = 16, 53 | GLSLstd450Acos = 17, 54 | GLSLstd450Atan = 18, 55 | GLSLstd450Sinh = 19, 56 | GLSLstd450Cosh = 20, 57 | GLSLstd450Tanh = 21, 58 | GLSLstd450Asinh = 22, 59 | GLSLstd450Acosh = 23, 60 | GLSLstd450Atanh = 24, 61 | GLSLstd450Atan2 = 25, 62 | 63 | GLSLstd450Pow = 26, 64 | GLSLstd450Exp = 27, 65 | GLSLstd450Log = 28, 66 | GLSLstd450Exp2 = 29, 67 | GLSLstd450Log2 = 30, 68 | GLSLstd450Sqrt = 31, 69 | GLSLstd450InverseSqrt = 32, 70 | 71 | GLSLstd450Determinant = 33, 72 | GLSLstd450MatrixInverse = 34, 73 | 74 | GLSLstd450Modf = 35, // second operand needs an OpVariable to write to 75 | GLSLstd450ModfStruct = 36, // no OpVariable operand 76 | GLSLstd450FMin = 37, 77 | GLSLstd450UMin = 38, 78 | GLSLstd450SMin = 39, 79 | GLSLstd450FMax = 40, 80 | GLSLstd450UMax = 41, 81 | GLSLstd450SMax = 42, 82 | GLSLstd450FClamp = 43, 83 | GLSLstd450UClamp = 44, 84 | GLSLstd450SClamp = 45, 85 | GLSLstd450FMix = 46, 86 | GLSLstd450IMix = 47, // Reserved 87 | GLSLstd450Step = 48, 88 | GLSLstd450SmoothStep = 49, 89 | 90 | GLSLstd450Fma = 50, 91 | GLSLstd450Frexp = 51, // second operand needs an OpVariable to write to 92 | GLSLstd450FrexpStruct = 52, // no OpVariable operand 93 | GLSLstd450Ldexp = 53, 94 | 95 | GLSLstd450PackSnorm4x8 = 54, 96 | GLSLstd450PackUnorm4x8 = 55, 97 | GLSLstd450PackSnorm2x16 = 56, 98 | GLSLstd450PackUnorm2x16 = 57, 99 | GLSLstd450PackHalf2x16 = 58, 100 | GLSLstd450PackDouble2x32 = 59, 101 | GLSLstd450UnpackSnorm2x16 = 60, 102 | GLSLstd450UnpackUnorm2x16 = 61, 103 | GLSLstd450UnpackHalf2x16 = 62, 104 | GLSLstd450UnpackSnorm4x8 = 63, 105 | GLSLstd450UnpackUnorm4x8 = 64, 106 | GLSLstd450UnpackDouble2x32 = 65, 107 | 108 | GLSLstd450Length = 66, 109 | GLSLstd450Distance = 67, 110 | GLSLstd450Cross = 68, 111 | GLSLstd450Normalize = 69, 112 | GLSLstd450FaceForward = 70, 113 | GLSLstd450Reflect = 71, 114 | GLSLstd450Refract = 72, 115 | 116 | GLSLstd450FindILsb = 73, 117 | GLSLstd450FindSMsb = 74, 118 | GLSLstd450FindUMsb = 75, 119 | 120 | GLSLstd450InterpolateAtCentroid = 76, 121 | GLSLstd450InterpolateAtSample = 77, 122 | GLSLstd450InterpolateAtOffset = 78, 123 | 124 | GLSLstd450NMin = 79, 125 | GLSLstd450NMax = 80, 126 | GLSLstd450NClamp = 81, 127 | 128 | GLSLstd450Count 129 | }; 130 | 131 | #endif // #ifndef GLSLstd450_H 132 | -------------------------------------------------------------------------------- /3rdparty/glslang/SPIRV/GlslangToSpv.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2014 LunarG, Inc. 3 | // 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions 8 | // are met: 9 | // 10 | // Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // 13 | // Redistributions in binary form must reproduce the above 14 | // copyright notice, this list of conditions and the following 15 | // disclaimer in the documentation and/or other materials provided 16 | // with the distribution. 17 | // 18 | // Neither the name of 3Dlabs Inc. Ltd. nor the names of its 19 | // contributors may be used to endorse or promote products derived 20 | // from this software without specific prior written permission. 21 | // 22 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 25 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 26 | // COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 27 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 28 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 30 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 32 | // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | // POSSIBILITY OF SUCH DAMAGE. 34 | 35 | #if _MSC_VER >= 1900 36 | #pragma warning(disable : 4464) // relative include path contains '..' 37 | #endif 38 | 39 | #include "../glslang/Include/intermediate.h" 40 | 41 | #include 42 | #include 43 | 44 | #include "Logger.h" 45 | 46 | namespace glslang { 47 | 48 | void GetSpirvVersion(std::string&); 49 | void GlslangToSpv(const glslang::TIntermediate& intermediate, std::vector& spirv); 50 | void GlslangToSpv(const glslang::TIntermediate& intermediate, std::vector& spirv, spv::SpvBuildLogger* logger); 51 | void OutputSpvBin(const std::vector& spirv, const char* baseName); 52 | void OutputSpvHex(const std::vector& spirv, const char* baseName, const char* varName); 53 | 54 | } 55 | -------------------------------------------------------------------------------- /3rdparty/glslang/SPIRV/InReadableOrder.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2016 Google, Inc. 3 | // 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions 8 | // are met: 9 | // 10 | // Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // 13 | // Redistributions in binary form must reproduce the above 14 | // copyright notice, this list of conditions and the following 15 | // disclaimer in the documentation and/or other materials provided 16 | // with the distribution. 17 | // 18 | // Neither the name of 3Dlabs Inc. Ltd. nor the names of its 19 | // contributors may be used to endorse or promote products derived 20 | // from this software without specific prior written permission. 21 | // 22 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 25 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 26 | // COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 27 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 28 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 30 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 32 | // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | // POSSIBILITY OF SUCH DAMAGE. 34 | 35 | // The SPIR-V spec requires code blocks to appear in an order satisfying the 36 | // dominator-tree direction (ie, dominator before the dominated). This is, 37 | // actually, easy to achieve: any pre-order CFG traversal algorithm will do it. 38 | // Because such algorithms visit a block only after traversing some path to it 39 | // from the root, they necessarily visit the block's idom first. 40 | // 41 | // But not every graph-traversal algorithm outputs blocks in an order that 42 | // appears logical to human readers. The problem is that unrelated branches may 43 | // be interspersed with each other, and merge blocks may come before some of the 44 | // branches being merged. 45 | // 46 | // A good, human-readable order of blocks may be achieved by performing 47 | // depth-first search but delaying merge nodes until after all their branches 48 | // have been visited. This is implemented below by the inReadableOrder() 49 | // function. 50 | 51 | #include "spvIR.h" 52 | 53 | #include 54 | #include 55 | 56 | using spv::Block; 57 | using spv::Id; 58 | 59 | namespace { 60 | // Traverses CFG in a readable order, invoking a pre-set callback on each block. 61 | // Use by calling visit() on the root block. 62 | class ReadableOrderTraverser { 63 | public: 64 | explicit ReadableOrderTraverser(std::function callback) : callback_(callback) {} 65 | // Visits the block if it hasn't been visited already and isn't currently 66 | // being delayed. Invokes callback(block), then descends into its 67 | // successors. Delays merge-block and continue-block processing until all 68 | // the branches have been completed. 69 | void visit(Block* block) 70 | { 71 | assert(block); 72 | if (visited_[block] || delayed_[block]) 73 | return; 74 | callback_(block); 75 | visited_[block] = true; 76 | Block* mergeBlock = nullptr; 77 | Block* continueBlock = nullptr; 78 | auto mergeInst = block->getMergeInstruction(); 79 | if (mergeInst) { 80 | Id mergeId = mergeInst->getIdOperand(0); 81 | mergeBlock = block->getParent().getParent().getInstruction(mergeId)->getBlock(); 82 | delayed_[mergeBlock] = true; 83 | if (mergeInst->getOpCode() == spv::OpLoopMerge) { 84 | Id continueId = mergeInst->getIdOperand(1); 85 | continueBlock = 86 | block->getParent().getParent().getInstruction(continueId)->getBlock(); 87 | delayed_[continueBlock] = true; 88 | } 89 | } 90 | const auto successors = block->getSuccessors(); 91 | for (auto it = successors.cbegin(); it != successors.cend(); ++it) 92 | visit(*it); 93 | if (continueBlock) { 94 | delayed_[continueBlock] = false; 95 | visit(continueBlock); 96 | } 97 | if (mergeBlock) { 98 | delayed_[mergeBlock] = false; 99 | visit(mergeBlock); 100 | } 101 | } 102 | 103 | private: 104 | std::function callback_; 105 | // Whether a block has already been visited or is being delayed. 106 | std::unordered_map visited_, delayed_; 107 | }; 108 | } 109 | 110 | void spv::inReadableOrder(Block* root, std::function callback) 111 | { 112 | ReadableOrderTraverser(callback).visit(root); 113 | } 114 | -------------------------------------------------------------------------------- /3rdparty/glslang/SPIRV/Logger.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2016 Google, Inc. 3 | // 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions 8 | // are met: 9 | // 10 | // Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // 13 | // Redistributions in binary form must reproduce the above 14 | // copyright notice, this list of conditions and the following 15 | // disclaimer in the documentation and/or other materials provided 16 | // with the distribution. 17 | // 18 | // Neither the name of Google Inc. nor the names of its 19 | // contributors may be used to endorse or promote products derived 20 | // from this software without specific prior written permission. 21 | // 22 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 25 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 26 | // COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 27 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 28 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 30 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 32 | // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | // POSSIBILITY OF SUCH DAMAGE. 34 | 35 | #include "Logger.h" 36 | 37 | #include 38 | #include 39 | #include 40 | 41 | namespace spv { 42 | 43 | void SpvBuildLogger::tbdFunctionality(const std::string& f) 44 | { 45 | if (std::find(std::begin(tbdFeatures), std::end(tbdFeatures), f) == std::end(tbdFeatures)) 46 | tbdFeatures.push_back(f); 47 | } 48 | 49 | void SpvBuildLogger::missingFunctionality(const std::string& f) 50 | { 51 | if (std::find(std::begin(missingFeatures), std::end(missingFeatures), f) == std::end(missingFeatures)) 52 | missingFeatures.push_back(f); 53 | } 54 | 55 | std::string SpvBuildLogger::getAllMessages() const { 56 | std::ostringstream messages; 57 | for (auto it = tbdFeatures.cbegin(); it != tbdFeatures.cend(); ++it) 58 | messages << "TBD functionality: " << *it << "\n"; 59 | for (auto it = missingFeatures.cbegin(); it != missingFeatures.cend(); ++it) 60 | messages << "Missing functionality: " << *it << "\n"; 61 | for (auto it = warnings.cbegin(); it != warnings.cend(); ++it) 62 | messages << "warning: " << *it << "\n"; 63 | for (auto it = errors.cbegin(); it != errors.cend(); ++it) 64 | messages << "error: " << *it << "\n"; 65 | return messages.str(); 66 | } 67 | 68 | } // end spv namespace 69 | -------------------------------------------------------------------------------- /3rdparty/glslang/SPIRV/Logger.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2016 Google, Inc. 3 | // 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions 8 | // are met: 9 | // 10 | // Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // 13 | // Redistributions in binary form must reproduce the above 14 | // copyright notice, this list of conditions and the following 15 | // disclaimer in the documentation and/or other materials provided 16 | // with the distribution. 17 | // 18 | // Neither the name of Google Inc. nor the names of its 19 | // contributors may be used to endorse or promote products derived 20 | // from this software without specific prior written permission. 21 | // 22 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 25 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 26 | // COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 27 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 28 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 30 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 32 | // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | // POSSIBILITY OF SUCH DAMAGE. 34 | 35 | #ifndef GLSLANG_SPIRV_LOGGER_H 36 | #define GLSLANG_SPIRV_LOGGER_H 37 | 38 | #include 39 | #include 40 | 41 | namespace spv { 42 | 43 | // A class for holding all SPIR-V build status messages, including 44 | // missing/TBD functionalities, warnings, and errors. 45 | class SpvBuildLogger { 46 | public: 47 | SpvBuildLogger() {} 48 | 49 | // Registers a TBD functionality. 50 | void tbdFunctionality(const std::string& f); 51 | // Registers a missing functionality. 52 | void missingFunctionality(const std::string& f); 53 | 54 | // Logs a warning. 55 | void warning(const std::string& w) { warnings.push_back(w); } 56 | // Logs an error. 57 | void error(const std::string& e) { errors.push_back(e); } 58 | 59 | // Returns all messages accumulated in the order of: 60 | // TBD functionalities, missing functionalities, warnings, errors. 61 | std::string getAllMessages() const; 62 | 63 | private: 64 | SpvBuildLogger(const SpvBuildLogger&); 65 | 66 | std::vector tbdFeatures; 67 | std::vector missingFeatures; 68 | std::vector warnings; 69 | std::vector errors; 70 | }; 71 | 72 | } // end spv namespace 73 | 74 | #endif // GLSLANG_SPIRV_LOGGER_H 75 | -------------------------------------------------------------------------------- /3rdparty/glslang/SPIRV/bitutils.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2016 The Khronos Group Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef LIBSPIRV_UTIL_BITUTILS_H_ 16 | #define LIBSPIRV_UTIL_BITUTILS_H_ 17 | 18 | #include 19 | #include 20 | 21 | namespace spvutils { 22 | 23 | // Performs a bitwise copy of source to the destination type Dest. 24 | template 25 | Dest BitwiseCast(Src source) { 26 | Dest dest; 27 | static_assert(sizeof(source) == sizeof(dest), 28 | "BitwiseCast: Source and destination must have the same size"); 29 | std::memcpy(&dest, &source, sizeof(dest)); 30 | return dest; 31 | } 32 | 33 | // SetBits returns an integer of type with bits set 34 | // for position through , counting from the least 35 | // significant bit. In particular when Num == 0, no positions are set to 1. 36 | // A static assert will be triggered if First + Num > sizeof(T) * 8, that is, 37 | // a bit that will not fit in the underlying type is set. 38 | template 39 | struct SetBits { 40 | static_assert(First < sizeof(T) * 8, 41 | "Tried to set a bit that is shifted too far."); 42 | const static T get = (T(1) << First) | SetBits::get; 43 | }; 44 | 45 | template 46 | struct SetBits { 47 | const static T get = T(0); 48 | }; 49 | 50 | // This is all compile-time so we can put our tests right here. 51 | static_assert(SetBits::get == uint32_t(0x00000000), 52 | "SetBits failed"); 53 | static_assert(SetBits::get == uint32_t(0x00000001), 54 | "SetBits failed"); 55 | static_assert(SetBits::get == uint32_t(0x80000000), 56 | "SetBits failed"); 57 | static_assert(SetBits::get == uint32_t(0x00000006), 58 | "SetBits failed"); 59 | static_assert(SetBits::get == uint32_t(0xc0000000), 60 | "SetBits failed"); 61 | static_assert(SetBits::get == uint32_t(0x7FFFFFFF), 62 | "SetBits failed"); 63 | static_assert(SetBits::get == uint32_t(0xFFFFFFFF), 64 | "SetBits failed"); 65 | static_assert(SetBits::get == uint32_t(0xFFFF0000), 66 | "SetBits failed"); 67 | 68 | static_assert(SetBits::get == uint64_t(0x0000000000000001LL), 69 | "SetBits failed"); 70 | static_assert(SetBits::get == uint64_t(0x8000000000000000LL), 71 | "SetBits failed"); 72 | static_assert(SetBits::get == uint64_t(0xc000000000000000LL), 73 | "SetBits failed"); 74 | static_assert(SetBits::get == uint64_t(0x0000000080000000LL), 75 | "SetBits failed"); 76 | static_assert(SetBits::get == uint64_t(0x00000000FFFF0000LL), 77 | "SetBits failed"); 78 | 79 | } // namespace spvutils 80 | 81 | #endif // LIBSPIRV_UTIL_BITUTILS_H_ 82 | -------------------------------------------------------------------------------- /3rdparty/glslang/SPIRV/disassemble.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2014-2015 LunarG, Inc. 3 | // 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions 8 | // are met: 9 | // 10 | // Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // 13 | // Redistributions in binary form must reproduce the above 14 | // copyright notice, this list of conditions and the following 15 | // disclaimer in the documentation and/or other materials provided 16 | // with the distribution. 17 | // 18 | // Neither the name of 3Dlabs Inc. Ltd. nor the names of its 19 | // contributors may be used to endorse or promote products derived 20 | // from this software without specific prior written permission. 21 | // 22 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 25 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 26 | // COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 27 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 28 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 30 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 32 | // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | // POSSIBILITY OF SUCH DAMAGE. 34 | 35 | // 36 | // Disassembler for SPIR-V. 37 | // 38 | 39 | #pragma once 40 | #ifndef disassembler_H 41 | #define disassembler_H 42 | 43 | #include 44 | #include 45 | 46 | namespace spv { 47 | 48 | void Disassemble(std::ostream& out, const std::vector&); 49 | 50 | }; // end namespace spv 51 | 52 | #endif // disassembler_H 53 | -------------------------------------------------------------------------------- /3rdparty/glslang/StandAlone/ResourceLimits.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2016 Google, Inc. 3 | // 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions 8 | // are met: 9 | // 10 | // Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // 13 | // Redistributions in binary form must reproduce the above 14 | // copyright notice, this list of conditions and the following 15 | // disclaimer in the documentation and/or other materials provided 16 | // with the distribution. 17 | // 18 | // Neither the name of Google Inc. nor the names of its 19 | // contributors may be used to endorse or promote products derived 20 | // from this software without specific prior written permission. 21 | // 22 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 25 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 26 | // COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 27 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 28 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 30 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 32 | // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | // POSSIBILITY OF SUCH DAMAGE. 34 | 35 | #ifndef _STAND_ALONE_RESOURCE_LIMITS_INCLUDED_ 36 | #define _STAND_ALONE_RESOURCE_LIMITS_INCLUDED_ 37 | 38 | #include 39 | 40 | #include "../glslang/Include/ResourceLimits.h" 41 | 42 | namespace glslang { 43 | 44 | // These are the default resources for TBuiltInResources, used for both 45 | // - parsing this string for the case where the user didn't supply one, 46 | // - dumping out a template for user construction of a config file. 47 | extern const TBuiltInResource DefaultTBuiltInResource; 48 | 49 | // Returns the DefaultTBuiltInResource as a human-readable string. 50 | std::string GetDefaultTBuiltInResourceString(); 51 | 52 | // Decodes the resource limits from |config| to |resources|. 53 | void DecodeResourceLimits(TBuiltInResource* resources, char* config); 54 | 55 | } // end namespace glslang 56 | 57 | #endif // _STAND_ALONE_RESOURCE_LIMITS_INCLUDED_ 58 | -------------------------------------------------------------------------------- /3rdparty/glslang/glslang/GenericCodeGen/CodeGen.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2002-2005 3Dlabs Inc. Ltd. 3 | // All rights reserved. 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions 7 | // are met: 8 | // 9 | // Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following 14 | // disclaimer in the documentation and/or other materials provided 15 | // with the distribution. 16 | // 17 | // Neither the name of 3Dlabs Inc. Ltd. nor the names of its 18 | // contributors may be used to endorse or promote products derived 19 | // from this software without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 24 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 25 | // COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 26 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 27 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 31 | // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | // POSSIBILITY OF SUCH DAMAGE. 33 | // 34 | 35 | #include "../Include/Common.h" 36 | #include "../Include/ShHandle.h" 37 | #include "../MachineIndependent/Versions.h" 38 | 39 | // 40 | // Here is where real machine specific high-level data would be defined. 41 | // 42 | class TGenericCompiler : public TCompiler { 43 | public: 44 | TGenericCompiler(EShLanguage l, int dOptions) : TCompiler(l, infoSink), debugOptions(dOptions) { } 45 | virtual bool compile(TIntermNode* root, int version = 0, EProfile profile = ENoProfile); 46 | TInfoSink infoSink; 47 | int debugOptions; 48 | }; 49 | 50 | // 51 | // This function must be provided to create the actual 52 | // compile object used by higher level code. It returns 53 | // a subclass of TCompiler. 54 | // 55 | TCompiler* ConstructCompiler(EShLanguage language, int debugOptions) 56 | { 57 | return new TGenericCompiler(language, debugOptions); 58 | } 59 | 60 | // 61 | // Delete the compiler made by ConstructCompiler 62 | // 63 | void DeleteCompiler(TCompiler* compiler) 64 | { 65 | delete compiler; 66 | } 67 | 68 | // 69 | // Generate code from the given parse tree 70 | // 71 | bool TGenericCompiler::compile(TIntermNode* /*root*/, int /*version*/, EProfile /*profile*/) 72 | { 73 | haveValidObjectCode = true; 74 | 75 | return haveValidObjectCode; 76 | } 77 | -------------------------------------------------------------------------------- /3rdparty/glslang/glslang/GenericCodeGen/Link.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2002-2005 3Dlabs Inc. Ltd. 3 | // All rights reserved. 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions 7 | // are met: 8 | // 9 | // Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following 14 | // disclaimer in the documentation and/or other materials provided 15 | // with the distribution. 16 | // 17 | // Neither the name of 3Dlabs Inc. Ltd. nor the names of its 18 | // contributors may be used to endorse or promote products derived 19 | // from this software without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 24 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 25 | // COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 26 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 27 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 31 | // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | // POSSIBILITY OF SUCH DAMAGE. 33 | // 34 | 35 | // 36 | // The top level algorithms for linking multiple 37 | // shaders together. 38 | // 39 | #include "../Include/Common.h" 40 | #include "../Include/ShHandle.h" 41 | 42 | // 43 | // Actual link object, derived from the shader handle base classes. 44 | // 45 | class TGenericLinker : public TLinker { 46 | public: 47 | TGenericLinker(EShExecutable e, int dOptions) : TLinker(e, infoSink), debugOptions(dOptions) { } 48 | bool link(TCompilerList&, TUniformMap*) { return true; } 49 | void getAttributeBindings(ShBindingTable const **) const { } 50 | TInfoSink infoSink; 51 | int debugOptions; 52 | }; 53 | 54 | // 55 | // The internal view of a uniform/float object exchanged with the driver. 56 | // 57 | class TUniformLinkedMap : public TUniformMap { 58 | public: 59 | TUniformLinkedMap() { } 60 | virtual int getLocation(const char*) { return 0; } 61 | }; 62 | 63 | TShHandleBase* ConstructLinker(EShExecutable executable, int debugOptions) 64 | { 65 | return new TGenericLinker(executable, debugOptions); 66 | } 67 | 68 | void DeleteLinker(TShHandleBase* linker) 69 | { 70 | delete linker; 71 | } 72 | 73 | TUniformMap* ConstructUniformMap() 74 | { 75 | return new TUniformLinkedMap(); 76 | } 77 | 78 | void DeleteUniformMap(TUniformMap* map) 79 | { 80 | delete map; 81 | } 82 | 83 | TShHandleBase* ConstructBindings() 84 | { 85 | return 0; 86 | } 87 | 88 | void DeleteBindingList(TShHandleBase* bindingList) 89 | { 90 | delete bindingList; 91 | } 92 | -------------------------------------------------------------------------------- /3rdparty/glslang/glslang/Include/InitializeGlobals.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2002-2005 3Dlabs Inc. Ltd. 3 | // All rights reserved. 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions 7 | // are met: 8 | // 9 | // Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following 14 | // disclaimer in the documentation and/or other materials provided 15 | // with the distribution. 16 | // 17 | // Neither the name of 3Dlabs Inc. Ltd. nor the names of its 18 | // contributors may be used to endorse or promote products derived 19 | // from this software without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 24 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 25 | // COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 26 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 27 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 31 | // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | // POSSIBILITY OF SUCH DAMAGE. 33 | // 34 | 35 | #ifndef __INITIALIZE_GLOBALS_INCLUDED_ 36 | #define __INITIALIZE_GLOBALS_INCLUDED_ 37 | 38 | namespace glslang { 39 | 40 | void InitializeMemoryPools(); 41 | void FreeGlobalPools(); 42 | bool InitializePoolIndex(); 43 | void FreePoolIndex(); 44 | 45 | } // end namespace glslang 46 | 47 | #endif // __INITIALIZE_GLOBALS_INCLUDED_ 48 | -------------------------------------------------------------------------------- /3rdparty/glslang/glslang/Include/revision.h: -------------------------------------------------------------------------------- 1 | // This header is generated by the make-revision script. 2 | // For the version, it uses the latest git tag followed by the number of commits. 3 | // For the date, it uses the current date (when then script is run). 4 | 5 | #define GLSLANG_REVISION "Overload400-PrecQual.1958" 6 | #define GLSLANG_DATE "31-Mar-2017" 7 | -------------------------------------------------------------------------------- /3rdparty/glslang/glslang/MachineIndependent/InfoSink.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2002-2005 3Dlabs Inc. Ltd. 3 | // All rights reserved. 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions 7 | // are met: 8 | // 9 | // Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following 14 | // disclaimer in the documentation and/or other materials provided 15 | // with the distribution. 16 | // 17 | // Neither the name of 3Dlabs Inc. Ltd. nor the names of its 18 | // contributors may be used to endorse or promote products derived 19 | // from this software without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 24 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 25 | // COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 26 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 27 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 31 | // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | // POSSIBILITY OF SUCH DAMAGE. 33 | // 34 | 35 | #include "../Include/InfoSink.h" 36 | 37 | #include 38 | 39 | namespace glslang { 40 | 41 | void TInfoSinkBase::append(const char* s) 42 | { 43 | if (outputStream & EString) { 44 | if (s == nullptr) 45 | sink.append("(null)"); 46 | else { 47 | checkMem(strlen(s)); 48 | sink.append(s); 49 | } 50 | } 51 | 52 | //#ifdef _WIN32 53 | // if (outputStream & EDebugger) 54 | // OutputDebugString(s); 55 | //#endif 56 | 57 | if (outputStream & EStdOut) 58 | fprintf(stdout, "%s", s); 59 | } 60 | 61 | void TInfoSinkBase::append(int count, char c) 62 | { 63 | if (outputStream & EString) { 64 | checkMem(count); 65 | sink.append(count, c); 66 | } 67 | 68 | //#ifdef _WIN32 69 | // if (outputStream & EDebugger) { 70 | // char str[2]; 71 | // str[0] = c; 72 | // str[1] = '\0'; 73 | // OutputDebugString(str); 74 | // } 75 | //#endif 76 | 77 | if (outputStream & EStdOut) 78 | fprintf(stdout, "%c", c); 79 | } 80 | 81 | void TInfoSinkBase::append(const TPersistString& t) 82 | { 83 | if (outputStream & EString) { 84 | checkMem(t.size()); 85 | sink.append(t); 86 | } 87 | 88 | //#ifdef _WIN32 89 | // if (outputStream & EDebugger) 90 | // OutputDebugString(t.c_str()); 91 | //#endif 92 | 93 | if (outputStream & EStdOut) 94 | fprintf(stdout, "%s", t.c_str()); 95 | } 96 | 97 | void TInfoSinkBase::append(const TString& t) 98 | { 99 | if (outputStream & EString) { 100 | checkMem(t.size()); 101 | sink.append(t.c_str()); 102 | } 103 | 104 | //#ifdef _WIN32 105 | // if (outputStream & EDebugger) 106 | // OutputDebugString(t.c_str()); 107 | //#endif 108 | 109 | if (outputStream & EStdOut) 110 | fprintf(stdout, "%s", t.c_str()); 111 | } 112 | 113 | } // end namespace glslang 114 | -------------------------------------------------------------------------------- /3rdparty/glslang/glslang/MachineIndependent/Initialize.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2002-2005 3Dlabs Inc. Ltd. 3 | // Copyright (C) 2013-2016 LunarG, Inc. 4 | // 5 | // All rights reserved. 6 | // 7 | // Redistribution and use in source and binary forms, with or without 8 | // modification, are permitted provided that the following conditions 9 | // are met: 10 | // 11 | // Redistributions of source code must retain the above copyright 12 | // notice, this list of conditions and the following disclaimer. 13 | // 14 | // Redistributions in binary form must reproduce the above 15 | // copyright notice, this list of conditions and the following 16 | // disclaimer in the documentation and/or other materials provided 17 | // with the distribution. 18 | // 19 | // Neither the name of 3Dlabs Inc. Ltd. nor the names of its 20 | // contributors may be used to endorse or promote products derived 21 | // from this software without specific prior written permission. 22 | // 23 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | // COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 28 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 29 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 30 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 33 | // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34 | // POSSIBILITY OF SUCH DAMAGE. 35 | // 36 | 37 | #ifndef _INITIALIZE_INCLUDED_ 38 | #define _INITIALIZE_INCLUDED_ 39 | 40 | #include "../Include/ResourceLimits.h" 41 | #include "../Include/Common.h" 42 | #include "../Include/ShHandle.h" 43 | #include "SymbolTable.h" 44 | #include "Versions.h" 45 | 46 | namespace glslang { 47 | 48 | // 49 | // This is made to hold parseable strings for almost all the built-in 50 | // functions and variables for one specific combination of version 51 | // and profile. (Some still need to be added programmatically.) 52 | // This is a base class for language-specific derivations, which 53 | // can be used for language independent builtins. 54 | // 55 | // The strings are organized by 56 | // commonBuiltins: intersection of all stages' built-ins, processed just once 57 | // stageBuiltins[]: anything a stage needs that's not in commonBuiltins 58 | // 59 | class TBuiltInParseables { 60 | public: 61 | POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator()) 62 | TBuiltInParseables(); 63 | virtual ~TBuiltInParseables(); 64 | virtual void initialize(int version, EProfile, const SpvVersion& spvVersion) = 0; 65 | virtual void initialize(const TBuiltInResource& resources, int version, EProfile, const SpvVersion& spvVersion, EShLanguage) = 0; 66 | virtual const TString& getCommonString() const { return commonBuiltins; } 67 | virtual const TString& getStageString(EShLanguage language) const { return stageBuiltins[language]; } 68 | 69 | virtual void identifyBuiltIns(int version, EProfile profile, const SpvVersion& spvVersion, EShLanguage language, TSymbolTable& symbolTable) = 0; 70 | 71 | virtual void identifyBuiltIns(int version, EProfile profile, const SpvVersion& spvVersion, EShLanguage language, TSymbolTable& symbolTable, const TBuiltInResource &resources) = 0; 72 | 73 | protected: 74 | TString commonBuiltins; 75 | TString stageBuiltins[EShLangCount]; 76 | }; 77 | 78 | // 79 | // This is a GLSL specific derivation of TBuiltInParseables. To present a stable 80 | // interface and match other similar code, it is called TBuiltIns, rather 81 | // than TBuiltInParseablesGlsl. 82 | // 83 | class TBuiltIns : public TBuiltInParseables { 84 | public: 85 | POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator()) 86 | TBuiltIns(); 87 | virtual ~TBuiltIns(); 88 | void initialize(int version, EProfile, const SpvVersion& spvVersion); 89 | void initialize(const TBuiltInResource& resources, int version, EProfile, const SpvVersion& spvVersion, EShLanguage); 90 | 91 | void identifyBuiltIns(int version, EProfile profile, const SpvVersion& spvVersion, EShLanguage language, TSymbolTable& symbolTable); 92 | 93 | void identifyBuiltIns(int version, EProfile profile, const SpvVersion& spvVersion, EShLanguage language, TSymbolTable& symbolTable, const TBuiltInResource &resources); 94 | 95 | protected: 96 | void add2ndGenerationSamplingImaging(int version, EProfile profile, const SpvVersion& spvVersion); 97 | void addSubpassSampling(TSampler, TString& typeName, int version, EProfile profile); 98 | void addQueryFunctions(TSampler, TString& typeName, int version, EProfile profile); 99 | void addImageFunctions(TSampler, TString& typeName, int version, EProfile profile); 100 | void addSamplingFunctions(TSampler, TString& typeName, int version, EProfile profile); 101 | void addGatherFunctions(TSampler, TString& typeName, int version, EProfile profile); 102 | 103 | // Helpers for making textual representations of the permutations 104 | // of texturing/imaging functions. 105 | const char* postfixes[5]; 106 | const char* prefixes[EbtNumTypes]; 107 | int dimMap[EsdNumDims]; 108 | }; 109 | 110 | } // end namespace glslang 111 | 112 | #endif // _INITIALIZE_INCLUDED_ 113 | -------------------------------------------------------------------------------- /3rdparty/glslang/glslang/MachineIndependent/RemoveTree.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2002-2005 3Dlabs Inc. Ltd. 3 | // Copyright (C) 2013 LunarG, Inc. 4 | // 5 | // All rights reserved. 6 | // 7 | // Redistribution and use in source and binary forms, with or without 8 | // modification, are permitted provided that the following conditions 9 | // are met: 10 | // 11 | // Redistributions of source code must retain the above copyright 12 | // notice, this list of conditions and the following disclaimer. 13 | // 14 | // Redistributions in binary form must reproduce the above 15 | // copyright notice, this list of conditions and the following 16 | // disclaimer in the documentation and/or other materials provided 17 | // with the distribution. 18 | // 19 | // Neither the name of 3Dlabs Inc. Ltd. nor the names of its 20 | // contributors may be used to endorse or promote products derived 21 | // from this software without specific prior written permission. 22 | // 23 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | // COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 28 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 29 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 30 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 33 | // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34 | // POSSIBILITY OF SUCH DAMAGE. 35 | // 36 | 37 | #include "../Include/intermediate.h" 38 | #include "RemoveTree.h" 39 | 40 | namespace glslang { 41 | 42 | // 43 | // Code to recursively delete the intermediate tree. 44 | // 45 | struct TRemoveTraverser : TIntermTraverser { 46 | TRemoveTraverser() : TIntermTraverser(false, false, true, false) {} 47 | 48 | virtual void visitSymbol(TIntermSymbol* node) 49 | { 50 | delete node; 51 | } 52 | 53 | virtual bool visitBinary(TVisit /* visit*/ , TIntermBinary* node) 54 | { 55 | delete node; 56 | 57 | return true; 58 | } 59 | 60 | virtual bool visitUnary(TVisit /* visit */, TIntermUnary* node) 61 | { 62 | delete node; 63 | 64 | return true; 65 | } 66 | 67 | virtual bool visitAggregate(TVisit /* visit*/ , TIntermAggregate* node) 68 | { 69 | delete node; 70 | 71 | return true; 72 | } 73 | 74 | virtual bool visitSelection(TVisit /* visit*/ , TIntermSelection* node) 75 | { 76 | delete node; 77 | 78 | return true; 79 | } 80 | 81 | virtual bool visitSwitch(TVisit /* visit*/ , TIntermSwitch* node) 82 | { 83 | delete node; 84 | 85 | return true; 86 | } 87 | 88 | virtual void visitConstantUnion(TIntermConstantUnion* node) 89 | { 90 | delete node; 91 | } 92 | 93 | virtual bool visitLoop(TVisit /* visit*/ , TIntermLoop* node) 94 | { 95 | delete node; 96 | 97 | return true; 98 | } 99 | 100 | virtual bool visitBranch(TVisit /* visit*/ , TIntermBranch* node) 101 | { 102 | delete node; 103 | 104 | return true; 105 | } 106 | }; 107 | 108 | // 109 | // Entry point. 110 | // 111 | void RemoveAllTreeNodes(TIntermNode* root) 112 | { 113 | TRemoveTraverser it; 114 | 115 | root->traverse(&it); 116 | } 117 | 118 | } // end namespace glslang 119 | -------------------------------------------------------------------------------- /3rdparty/glslang/glslang/MachineIndependent/RemoveTree.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2002-2005 3Dlabs Inc. Ltd. 3 | // All rights reserved. 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions 7 | // are met: 8 | // 9 | // Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following 14 | // disclaimer in the documentation and/or other materials provided 15 | // with the distribution. 16 | // 17 | // Neither the name of 3Dlabs Inc. Ltd. nor the names of its 18 | // contributors may be used to endorse or promote products derived 19 | // from this software without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 24 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 25 | // COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 26 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 27 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 31 | // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | // POSSIBILITY OF SUCH DAMAGE. 33 | // 34 | 35 | namespace glslang { 36 | 37 | void RemoveAllTreeNodes(TIntermNode*); 38 | 39 | } // end namespace glslang 40 | -------------------------------------------------------------------------------- /3rdparty/glslang/glslang/MachineIndependent/ScanContext.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2013 LunarG, Inc. 3 | // 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions 8 | // are met: 9 | // 10 | // Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // 13 | // Redistributions in binary form must reproduce the above 14 | // copyright notice, this list of conditions and the following 15 | // disclaimer in the documentation and/or other materials provided 16 | // with the distribution. 17 | // 18 | // Neither the name of 3Dlabs Inc. Ltd. nor the names of its 19 | // contributors may be used to endorse or promote products derived 20 | // from this software without specific prior written permission. 21 | // 22 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 25 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 26 | // COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 27 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 28 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 30 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 32 | // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | // POSSIBILITY OF SUCH DAMAGE. 34 | // 35 | 36 | // 37 | // This holds context specific to the GLSL scanner, which 38 | // sits between the preprocessor scanner and parser. 39 | // 40 | 41 | #include "ParseHelper.h" 42 | 43 | namespace glslang { 44 | 45 | class TPpContext; 46 | class TPpToken; 47 | class TParserToken; 48 | 49 | class TScanContext { 50 | public: 51 | explicit TScanContext(TParseContextBase& pc) : parseContext(pc), afterType(false), field(false) { } 52 | virtual ~TScanContext() { } 53 | 54 | static void fillInKeywordMap(); 55 | static void deleteKeywordMap(); 56 | 57 | int tokenize(TPpContext*, TParserToken&); 58 | 59 | protected: 60 | TScanContext(TScanContext&); 61 | TScanContext& operator=(TScanContext&); 62 | 63 | int tokenizeIdentifier(); 64 | int identifierOrType(); 65 | int reservedWord(); 66 | int identifierOrReserved(bool reserved); 67 | int es30ReservedFromGLSL(int version); 68 | int nonreservedKeyword(int esVersion, int nonEsVersion); 69 | int precisionKeyword(); 70 | int matNxM(); 71 | int dMat(); 72 | int firstGenerationImage(bool inEs310); 73 | int secondGenerationImage(); 74 | 75 | TParseContextBase& parseContext; 76 | bool afterType; // true if we've recognized a type, so can only be looking for an identifier 77 | bool field; // true if we're on a field, right after a '.' 78 | TSourceLoc loc; 79 | TParserToken* parserToken; 80 | TPpToken* ppToken; 81 | 82 | const char* tokenText; 83 | int keyword; 84 | }; 85 | 86 | } // end namespace glslang 87 | -------------------------------------------------------------------------------- /3rdparty/glslang/glslang/MachineIndependent/iomapper.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2016 LunarG, Inc. 3 | // 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions 8 | // are met: 9 | // 10 | // Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // 13 | // Redistributions in binary form must reproduce the above 14 | // copyright notice, this list of conditions and the following 15 | // disclaimer in the documentation and/or other materials provided 16 | // with the distribution. 17 | // 18 | // Neither the name of 3Dlabs Inc. Ltd. nor the names of its 19 | // contributors may be used to endorse or promote products derived 20 | // from this software without specific prior written permission. 21 | // 22 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 25 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 26 | // COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 27 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 28 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 30 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 32 | // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | // POSSIBILITY OF SUCH DAMAGE. 34 | // 35 | 36 | #ifndef _IOMAPPER_INCLUDED 37 | #define _IOMAPPER_INCLUDED 38 | 39 | #include "../Public/ShaderLang.h" 40 | 41 | // 42 | // A reflection database and its interface, consistent with the OpenGL API reflection queries. 43 | // 44 | 45 | class TInfoSink; 46 | 47 | namespace glslang { 48 | 49 | class TIntermediate; 50 | 51 | // I/O mapper 52 | class TIoMapper { 53 | public: 54 | TIoMapper() {} 55 | virtual ~TIoMapper() {} 56 | 57 | // grow the reflection stage by stage 58 | bool addStage(EShLanguage, TIntermediate&, TInfoSink&, TIoMapResolver*); 59 | }; 60 | 61 | } // end namespace glslang 62 | 63 | #endif // _IOMAPPER_INCLUDED 64 | -------------------------------------------------------------------------------- /3rdparty/glslang/glslang/MachineIndependent/preprocessor/PpContext.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2002-2005 3Dlabs Inc. Ltd. 3 | // Copyright (C) 2013 LunarG, Inc. 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions 8 | // are met: 9 | // 10 | // Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // 13 | // Redistributions in binary form must reproduce the above 14 | // copyright notice, this list of conditions and the following 15 | // disclaimer in the documentation and/or other materials provided 16 | // with the distribution. 17 | // 18 | // Neither the name of 3Dlabs Inc. Ltd. nor the names of its 19 | // contributors may be used to endorse or promote products derived 20 | // from this software without specific prior written permission. 21 | // 22 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 25 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 26 | // COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 27 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 28 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 30 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 32 | // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | // POSSIBILITY OF SUCH DAMAGE. 34 | // 35 | /****************************************************************************\ 36 | Copyright (c) 2002, NVIDIA Corporation. 37 | 38 | NVIDIA Corporation("NVIDIA") supplies this software to you in 39 | consideration of your agreement to the following terms, and your use, 40 | installation, modification or redistribution of this NVIDIA software 41 | constitutes acceptance of these terms. If you do not agree with these 42 | terms, please do not use, install, modify or redistribute this NVIDIA 43 | software. 44 | 45 | In consideration of your agreement to abide by the following terms, and 46 | subject to these terms, NVIDIA grants you a personal, non-exclusive 47 | license, under NVIDIA's copyrights in this original NVIDIA software (the 48 | "NVIDIA Software"), to use, reproduce, modify and redistribute the 49 | NVIDIA Software, with or without modifications, in source and/or binary 50 | forms; provided that if you redistribute the NVIDIA Software, you must 51 | retain the copyright notice of NVIDIA, this notice and the following 52 | text and disclaimers in all such redistributions of the NVIDIA Software. 53 | Neither the name, trademarks, service marks nor logos of NVIDIA 54 | Corporation may be used to endorse or promote products derived from the 55 | NVIDIA Software without specific prior written permission from NVIDIA. 56 | Except as expressly stated in this notice, no other rights or licenses 57 | express or implied, are granted by NVIDIA herein, including but not 58 | limited to any patent rights that may be infringed by your derivative 59 | works or by other works in which the NVIDIA Software may be 60 | incorporated. No hardware is licensed hereunder. 61 | 62 | THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT 63 | WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, 64 | INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE, 65 | NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR 66 | ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER 67 | PRODUCTS. 68 | 69 | IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, 70 | INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 71 | TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 72 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY 73 | OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE 74 | NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, 75 | TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF 76 | NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 77 | \****************************************************************************/ 78 | 79 | #include 80 | 81 | #include "PpContext.h" 82 | 83 | namespace glslang { 84 | 85 | TPpContext::TPpContext(TParseContextBase& pc, const std::string& rootFileName, TShader::Includer& inclr) : 86 | preamble(0), strings(0), previous_token('\n'), parseContext(pc), includer(inclr), inComment(false), 87 | rootFileName(rootFileName), 88 | currentSourceFile(rootFileName) 89 | { 90 | ifdepth = 0; 91 | for (elsetracker = 0; elsetracker < maxIfNesting; elsetracker++) 92 | elseSeen[elsetracker] = false; 93 | elsetracker = 0; 94 | } 95 | 96 | TPpContext::~TPpContext() 97 | { 98 | delete [] preamble; 99 | 100 | // free up the inputStack 101 | while (! inputStack.empty()) 102 | popInput(); 103 | } 104 | 105 | void TPpContext::setInput(TInputScanner& input, bool versionWillBeError) 106 | { 107 | assert(inputStack.size() == 0); 108 | 109 | pushInput(new tStringInput(this, input)); 110 | 111 | errorOnVersion = versionWillBeError; 112 | versionSeen = false; 113 | } 114 | 115 | } // end namespace glslang 116 | -------------------------------------------------------------------------------- /3rdparty/glslang/glslang/MachineIndependent/preprocessor/PpMemory.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2002-2005 3Dlabs Inc. Ltd. 3 | // Copyright (C) 2013 LunarG, Inc. 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions 8 | // are met: 9 | // 10 | // Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // 13 | // Redistributions in binary form must reproduce the above 14 | // copyright notice, this list of conditions and the following 15 | // disclaimer in the documentation and/or other materials provided 16 | // with the distribution. 17 | // 18 | // Neither the name of 3Dlabs Inc. Ltd. nor the names of its 19 | // contributors may be used to endorse or promote products derived 20 | // from this software without specific prior written permission. 21 | // 22 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 25 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 26 | // COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 27 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 28 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 30 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 32 | // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | // POSSIBILITY OF SUCH DAMAGE. 34 | // 35 | /****************************************************************************\ 36 | Copyright (c) 2002, NVIDIA Corporation. 37 | 38 | NVIDIA Corporation("NVIDIA") supplies this software to you in 39 | consideration of your agreement to the following terms, and your use, 40 | installation, modification or redistribution of this NVIDIA software 41 | constitutes acceptance of these terms. If you do not agree with these 42 | terms, please do not use, install, modify or redistribute this NVIDIA 43 | software. 44 | 45 | In consideration of your agreement to abide by the following terms, and 46 | subject to these terms, NVIDIA grants you a personal, non-exclusive 47 | license, under NVIDIA's copyrights in this original NVIDIA software (the 48 | "NVIDIA Software"), to use, reproduce, modify and redistribute the 49 | NVIDIA Software, with or without modifications, in source and/or binary 50 | forms; provided that if you redistribute the NVIDIA Software, you must 51 | retain the copyright notice of NVIDIA, this notice and the following 52 | text and disclaimers in all such redistributions of the NVIDIA Software. 53 | Neither the name, trademarks, service marks nor logos of NVIDIA 54 | Corporation may be used to endorse or promote products derived from the 55 | NVIDIA Software without specific prior written permission from NVIDIA. 56 | Except as expressly stated in this notice, no other rights or licenses 57 | express or implied, are granted by NVIDIA herein, including but not 58 | limited to any patent rights that may be infringed by your derivative 59 | works or by other works in which the NVIDIA Software may be 60 | incorporated. No hardware is licensed hereunder. 61 | 62 | THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT 63 | WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, 64 | INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE, 65 | NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR 66 | ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER 67 | PRODUCTS. 68 | 69 | IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, 70 | INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 71 | TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 72 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY 73 | OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE 74 | NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, 75 | TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF 76 | NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 77 | \****************************************************************************/ 78 | 79 | namespace glslang { 80 | 81 | } // end namespace glslang 82 | -------------------------------------------------------------------------------- /3rdparty/glslang/glslang/MachineIndependent/preprocessor/PpSymbols.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2002-2005 3Dlabs Inc. Ltd. 3 | // Copyright (C) 2013 LunarG, Inc. 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions 8 | // are met: 9 | // 10 | // Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // 13 | // Redistributions in binary form must reproduce the above 14 | // copyright notice, this list of conditions and the following 15 | // disclaimer in the documentation and/or other materials provided 16 | // with the distribution. 17 | // 18 | // Neither the name of 3Dlabs Inc. Ltd. nor the names of its 19 | // contributors may be used to endorse or promote products derived 20 | // from this software without specific prior written permission. 21 | // 22 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 25 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 26 | // COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 27 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 28 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 30 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 32 | // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | // POSSIBILITY OF SUCH DAMAGE. 34 | // 35 | /****************************************************************************\ 36 | Copyright (c) 2002, NVIDIA Corporation. 37 | 38 | NVIDIA Corporation("NVIDIA") supplies this software to you in 39 | consideration of your agreement to the following terms, and your use, 40 | installation, modification or redistribution of this NVIDIA software 41 | constitutes acceptance of these terms. If you do not agree with these 42 | terms, please do not use, install, modify or redistribute this NVIDIA 43 | software. 44 | 45 | In consideration of your agreement to abide by the following terms, and 46 | subject to these terms, NVIDIA grants you a personal, non-exclusive 47 | license, under NVIDIA's copyrights in this original NVIDIA software (the 48 | "NVIDIA Software"), to use, reproduce, modify and redistribute the 49 | NVIDIA Software, with or without modifications, in source and/or binary 50 | forms; provided that if you redistribute the NVIDIA Software, you must 51 | retain the copyright notice of NVIDIA, this notice and the following 52 | text and disclaimers in all such redistributions of the NVIDIA Software. 53 | Neither the name, trademarks, service marks nor logos of NVIDIA 54 | Corporation may be used to endorse or promote products derived from the 55 | NVIDIA Software without specific prior written permission from NVIDIA. 56 | Except as expressly stated in this notice, no other rights or licenses 57 | express or implied, are granted by NVIDIA herein, including but not 58 | limited to any patent rights that may be infringed by your derivative 59 | works or by other works in which the NVIDIA Software may be 60 | incorporated. No hardware is licensed hereunder. 61 | 62 | THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT 63 | WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, 64 | INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE, 65 | NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR 66 | ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER 67 | PRODUCTS. 68 | 69 | IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, 70 | INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 71 | TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 72 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY 73 | OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE 74 | NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, 75 | TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF 76 | NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 77 | \****************************************************************************/ 78 | -------------------------------------------------------------------------------- /3rdparty/glslang/glslang/MachineIndependent/propagateNoContraction.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2015-2016 Google, Inc. 3 | // 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions 8 | // are met: 9 | // 10 | // Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // 13 | // Redistributions in binary form must reproduce the above 14 | // copyright notice, this list of conditions and the following 15 | // disclaimer in the documentation and/or other materials provided 16 | // with the distribution. 17 | // 18 | // Neither the name of Google Inc. nor the names of its 19 | // contributors may be used to endorse or promote products derived 20 | // from this software without specific prior written permission. 21 | // 22 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 25 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 26 | // COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 27 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 28 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 30 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 32 | // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | // POSSIBILITY OF SUCH DAMAGE. 34 | 35 | // 36 | // Visit the nodes in the glslang intermediate tree representation to 37 | // propagate 'noContraction' qualifier. 38 | // 39 | 40 | #include "../Include/intermediate.h" 41 | 42 | namespace glslang { 43 | 44 | // Propagates the 'precise' qualifier for objects (objects marked with 45 | // 'noContraction' qualifier) from the shader source specified 'precise' 46 | // variables to all the involved objects, and add 'noContraction' qualifier for 47 | // the involved arithmetic operations. 48 | // Note that the same qualifier: 'noContraction' is used in both object nodes 49 | // and arithmetic operation nodes, but has different meaning. For object nodes, 50 | // 'noContraction' means the object is 'precise'; and for arithmetic operation 51 | // nodes, it means the operation should not be contracted. 52 | void PropagateNoContraction(const glslang::TIntermediate& intermediate); 53 | }; 54 | -------------------------------------------------------------------------------- /3rdparty/glslang/glslang/OSDependent/Windows/ossource.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2002-2005 3Dlabs Inc. Ltd. 3 | // All rights reserved. 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions 7 | // are met: 8 | // 9 | // Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following 14 | // disclaimer in the documentation and/or other materials provided 15 | // with the distribution. 16 | // 17 | // Neither the name of 3Dlabs Inc. Ltd. nor the names of its 18 | // contributors may be used to endorse or promote products derived 19 | // from this software without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 24 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 25 | // COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 26 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 27 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 31 | // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | // POSSIBILITY OF SUCH DAMAGE. 33 | // 34 | 35 | #include "../osinclude.h" 36 | 37 | #define STRICT 38 | #define VC_EXTRALEAN 1 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | 46 | // 47 | // This file contains the Window-OS-specific functions 48 | // 49 | 50 | #if !(defined(_WIN32) || defined(_WIN64)) 51 | #error Trying to build a windows specific file in a non windows build. 52 | #endif 53 | 54 | namespace glslang { 55 | 56 | inline OS_TLSIndex ToGenericTLSIndex (DWORD handle) 57 | { 58 | return (OS_TLSIndex)((uintptr_t)handle + 1); 59 | } 60 | 61 | inline DWORD ToNativeTLSIndex (OS_TLSIndex nIndex) 62 | { 63 | return (DWORD)((uintptr_t)nIndex - 1); 64 | } 65 | 66 | // 67 | // Thread Local Storage Operations 68 | // 69 | OS_TLSIndex OS_AllocTLSIndex() 70 | { 71 | DWORD dwIndex = TlsAlloc(); 72 | if (dwIndex == TLS_OUT_OF_INDEXES) { 73 | assert(0 && "OS_AllocTLSIndex(): Unable to allocate Thread Local Storage"); 74 | return OS_INVALID_TLS_INDEX; 75 | } 76 | 77 | return ToGenericTLSIndex(dwIndex); 78 | } 79 | 80 | bool OS_SetTLSValue(OS_TLSIndex nIndex, void *lpvValue) 81 | { 82 | if (nIndex == OS_INVALID_TLS_INDEX) { 83 | assert(0 && "OS_SetTLSValue(): Invalid TLS Index"); 84 | return false; 85 | } 86 | 87 | if (TlsSetValue(ToNativeTLSIndex(nIndex), lpvValue)) 88 | return true; 89 | else 90 | return false; 91 | } 92 | 93 | void* OS_GetTLSValue(OS_TLSIndex nIndex) 94 | { 95 | assert(nIndex != OS_INVALID_TLS_INDEX); 96 | return TlsGetValue(ToNativeTLSIndex(nIndex)); 97 | } 98 | 99 | bool OS_FreeTLSIndex(OS_TLSIndex nIndex) 100 | { 101 | if (nIndex == OS_INVALID_TLS_INDEX) { 102 | assert(0 && "OS_SetTLSValue(): Invalid TLS Index"); 103 | return false; 104 | } 105 | 106 | if (TlsFree(ToNativeTLSIndex(nIndex))) 107 | return true; 108 | else 109 | return false; 110 | } 111 | 112 | HANDLE GlobalLock; 113 | 114 | void InitGlobalLock() 115 | { 116 | GlobalLock = CreateMutex(0, false, 0); 117 | } 118 | 119 | void GetGlobalLock() 120 | { 121 | WaitForSingleObject(GlobalLock, INFINITE); 122 | } 123 | 124 | void ReleaseGlobalLock() 125 | { 126 | ReleaseMutex(GlobalLock); 127 | } 128 | 129 | unsigned int __stdcall EnterGenericThread (void* entry) 130 | { 131 | return ((TThreadEntrypoint)entry)(0); 132 | } 133 | 134 | void* OS_CreateThread(TThreadEntrypoint entry) 135 | { 136 | return (void*)_beginthreadex(0, 0, EnterGenericThread, (void*)entry, 0, 0); 137 | } 138 | 139 | void OS_WaitForAllThreads(void* threads, int numThreads) 140 | { 141 | WaitForMultipleObjects(numThreads, (HANDLE*)threads, true, INFINITE); 142 | } 143 | 144 | void OS_Sleep(int milliseconds) 145 | { 146 | Sleep(milliseconds); 147 | } 148 | 149 | //#define DUMP_COUNTERS 150 | 151 | void OS_DumpMemoryCounters() 152 | { 153 | #ifdef DUMP_COUNTERS 154 | PROCESS_MEMORY_COUNTERS counters; 155 | GetProcessMemoryInfo(GetCurrentProcess(), &counters, sizeof(counters)); 156 | printf("Working set size: %d\n", counters.WorkingSetSize); 157 | #else 158 | printf("Recompile with DUMP_COUNTERS defined to see counters.\n"); 159 | #endif 160 | } 161 | 162 | } // namespace glslang 163 | -------------------------------------------------------------------------------- /3rdparty/glslang/glslang/OSDependent/osinclude.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2002-2005 3Dlabs Inc. Ltd. 3 | // All rights reserved. 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions 7 | // are met: 8 | // 9 | // Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following 14 | // disclaimer in the documentation and/or other materials provided 15 | // with the distribution. 16 | // 17 | // Neither the name of 3Dlabs Inc. Ltd. nor the names of its 18 | // contributors may be used to endorse or promote products derived 19 | // from this software without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 24 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 25 | // COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 26 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 27 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 31 | // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | // POSSIBILITY OF SUCH DAMAGE. 33 | // 34 | 35 | #ifndef __OSINCLUDE_H 36 | #define __OSINCLUDE_H 37 | 38 | namespace glslang { 39 | 40 | // 41 | // Thread Local Storage Operations 42 | // 43 | typedef void* OS_TLSIndex; 44 | #define OS_INVALID_TLS_INDEX ((void*)0) 45 | 46 | OS_TLSIndex OS_AllocTLSIndex(); 47 | bool OS_SetTLSValue(OS_TLSIndex nIndex, void *lpvValue); 48 | bool OS_FreeTLSIndex(OS_TLSIndex nIndex); 49 | void* OS_GetTLSValue(OS_TLSIndex nIndex); 50 | 51 | void InitGlobalLock(); 52 | void GetGlobalLock(); 53 | void ReleaseGlobalLock(); 54 | 55 | typedef unsigned int (*TThreadEntrypoint)(void*); 56 | void* OS_CreateThread(TThreadEntrypoint); 57 | void OS_WaitForAllThreads(void* threads, int numThreads); 58 | 59 | void OS_CleanupThreadData(void); 60 | void OS_Sleep(int milliseconds); 61 | 62 | void OS_DumpMemoryCounters(); 63 | 64 | } // end namespace glslang 65 | 66 | #endif // __OSINCLUDE_H 67 | -------------------------------------------------------------------------------- /3rdparty/glslang/hlsl/hlslAttributes.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2016 LunarG, Inc. 3 | // 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions 8 | // are met: 9 | // 10 | // Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // 13 | // Redistributions in binary form must reproduce the above 14 | // copyright notice, this list of conditions and the following 15 | // disclaimer in the documentation and/or other materials provided 16 | // with the distribution. 17 | // 18 | // Neither the name of Google, Inc., nor the names of its 19 | // contributors may be used to endorse or promote products derived 20 | // from this software without specific prior written permission. 21 | // 22 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 25 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 26 | // COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 27 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 28 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 30 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 32 | // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | // POSSIBILITY OF SUCH DAMAGE. 34 | // 35 | 36 | #include "hlslAttributes.h" 37 | #include 38 | #include 39 | 40 | namespace glslang { 41 | // Map the given string to an attribute enum from TAttributeType, 42 | // or EatNone if invalid. 43 | TAttributeType TAttributeMap::attributeFromName(const TString& name) 44 | { 45 | // These are case insensitive. 46 | TString lowername(name); 47 | std::transform(lowername.begin(), lowername.end(), lowername.begin(), ::tolower); 48 | 49 | if (lowername == "allow_uav_condition") 50 | return EatAllow_uav_condition; 51 | else if (lowername == "branch") 52 | return EatBranch; 53 | else if (lowername == "call") 54 | return EatCall; 55 | else if (lowername == "domain") 56 | return EatDomain; 57 | else if (lowername == "earlydepthstencil") 58 | return EatEarlyDepthStencil; 59 | else if (lowername == "fastopt") 60 | return EatFastOpt; 61 | else if (lowername == "flatten") 62 | return EatFlatten; 63 | else if (lowername == "forcecase") 64 | return EatForceCase; 65 | else if (lowername == "instance") 66 | return EatInstance; 67 | else if (lowername == "maxtessfactor") 68 | return EatMaxTessFactor; 69 | else if (lowername == "maxvertexcount") 70 | return EatMaxVertexCount; 71 | else if (lowername == "numthreads") 72 | return EatNumThreads; 73 | else if (lowername == "outputcontrolpoints") 74 | return EatOutputControlPoints; 75 | else if (lowername == "outputtopology") 76 | return EatOutputTopology; 77 | else if (lowername == "partitioning") 78 | return EatPartitioning; 79 | else if (lowername == "patchconstantfunc") 80 | return EatPatchConstantFunc; 81 | else if (lowername == "unroll") 82 | return EatUnroll; 83 | else 84 | return EatNone; 85 | } 86 | 87 | // Look up entry, inserting if it's not there, and if name is a valid attribute name 88 | // as known by attributeFromName. 89 | TAttributeType TAttributeMap::setAttribute(const TString* name, TIntermAggregate* value) 90 | { 91 | if (name == nullptr) 92 | return EatNone; 93 | 94 | const TAttributeType attr = attributeFromName(*name); 95 | 96 | if (attr != EatNone) 97 | attributes[attr] = value; 98 | 99 | return attr; 100 | } 101 | 102 | // Look up entry (const version), and return aggregate node. This cannot change the map. 103 | const TIntermAggregate* TAttributeMap::operator[](TAttributeType attr) const 104 | { 105 | const auto entry = attributes.find(attr); 106 | 107 | return (entry == attributes.end()) ? nullptr : entry->second; 108 | } 109 | 110 | } // end namespace glslang 111 | -------------------------------------------------------------------------------- /3rdparty/glslang/hlsl/hlslAttributes.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2016 LunarG, Inc. 3 | // 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions 8 | // are met: 9 | // 10 | // Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // 13 | // Redistributions in binary form must reproduce the above 14 | // copyright notice, this list of conditions and the following 15 | // disclaimer in the documentation and/or other materials provided 16 | // with the distribution. 17 | // 18 | // Neither the name of Google, Inc., nor the names of its 19 | // contributors may be used to endorse or promote products derived 20 | // from this software without specific prior written permission. 21 | // 22 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 25 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 26 | // COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 27 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 28 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 30 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 32 | // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | // POSSIBILITY OF SUCH DAMAGE. 34 | // 35 | 36 | #ifndef HLSLATTRIBUTES_H_ 37 | #define HLSLATTRIBUTES_H_ 38 | 39 | #include 40 | #include 41 | #include "hlslScanContext.h" 42 | #include "../glslang/Include/Common.h" 43 | 44 | namespace glslang { 45 | enum TAttributeType { 46 | EatNone, 47 | EatAllow_uav_condition, 48 | EatBranch, 49 | EatCall, 50 | EatDomain, 51 | EatEarlyDepthStencil, 52 | EatFastOpt, 53 | EatFlatten, 54 | EatForceCase, 55 | EatInstance, 56 | EatMaxTessFactor, 57 | EatNumThreads, 58 | EatMaxVertexCount, 59 | EatOutputControlPoints, 60 | EatOutputTopology, 61 | EatPartitioning, 62 | EatPatchConstantFunc, 63 | EatPatchSize, 64 | EatUnroll, 65 | }; 66 | } 67 | 68 | namespace std { 69 | // Allow use of TAttributeType enum in hash_map without calling code having to cast. 70 | template <> struct hash { 71 | std::size_t operator()(glslang::TAttributeType attr) const { 72 | return std::hash()(int(attr)); 73 | } 74 | }; 75 | } // end namespace std 76 | 77 | namespace glslang { 78 | class TIntermAggregate; 79 | 80 | class TAttributeMap { 81 | public: 82 | // Search for and potentially add the attribute into the map. Return the 83 | // attribute type enum for it, if found, else EatNone. 84 | TAttributeType setAttribute(const TString* name, TIntermAggregate* value); 85 | 86 | // Const lookup: search for (but do not modify) the attribute in the map. 87 | const TIntermAggregate* operator[](TAttributeType) const; 88 | 89 | protected: 90 | // Find an attribute enum given its name. 91 | static TAttributeType attributeFromName(const TString&); 92 | 93 | std::unordered_map attributes; 94 | }; 95 | 96 | class TFunctionDeclarator { 97 | public: 98 | TFunctionDeclarator() : function(nullptr), body(nullptr) { } 99 | TSourceLoc loc; 100 | TFunction* function; 101 | TAttributeMap attributes; 102 | TVector* body; 103 | }; 104 | 105 | } // end namespace glslang 106 | 107 | 108 | #endif // HLSLATTRIBUTES_H_ 109 | -------------------------------------------------------------------------------- /3rdparty/glslang/hlsl/hlslOpMap.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2016 Google, Inc. 3 | // 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions 8 | // are met: 9 | // 10 | // Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // 13 | // Redistributions in binary form must reproduce the above 14 | // copyright notice, this list of conditions and the following 15 | // disclaimer in the documentation and/or other materials provided 16 | // with the distribution. 17 | // 18 | // Neither the name of Google, Inc., nor the names of its 19 | // contributors may be used to endorse or promote products derived 20 | // from this software without specific prior written permission. 21 | // 22 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 25 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 26 | // COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 27 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 28 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 30 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 32 | // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | // POSSIBILITY OF SUCH DAMAGE. 34 | // 35 | 36 | #ifndef HLSLOPMAP_H_ 37 | #define HLSLOPMAP_H_ 38 | 39 | #include "hlslScanContext.h" 40 | 41 | namespace glslang { 42 | 43 | enum PrecedenceLevel { 44 | PlBad, 45 | PlLogicalOr, 46 | PlLogicalXor, 47 | PlLogicalAnd, 48 | PlBitwiseOr, 49 | PlBitwiseXor, 50 | PlBitwiseAnd, 51 | PlEquality, 52 | PlRelational, 53 | PlShift, 54 | PlAdd, 55 | PlMul 56 | }; 57 | 58 | class HlslOpMap { 59 | public: 60 | static TOperator assignment(EHlslTokenClass op); 61 | static TOperator binary(EHlslTokenClass op); 62 | static TOperator preUnary(EHlslTokenClass op); 63 | static TOperator postUnary(EHlslTokenClass op); 64 | static PrecedenceLevel precedenceLevel(TOperator); 65 | }; 66 | 67 | } // end namespace glslang 68 | 69 | #endif // HLSLOPMAP_H_ 70 | -------------------------------------------------------------------------------- /3rdparty/glslang/hlsl/hlslParseables.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2016 LunarG, Inc. 3 | // 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions 8 | // are met: 9 | // 10 | // Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // 13 | // Redistributions in binary form must reproduce the above 14 | // copyright notice, this list of conditions and the following 15 | // disclaimer in the documentation and/or other materials provided 16 | // with the distribution. 17 | // 18 | // Neither the name of 3Dlabs Inc. Ltd. nor the names of its 19 | // contributors may be used to endorse or promote products derived 20 | // from this software without specific prior written permission. 21 | // 22 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 25 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 26 | // COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 27 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 28 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 30 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 32 | // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | // POSSIBILITY OF SUCH DAMAGE. 34 | // 35 | 36 | #ifndef _HLSLPARSEABLES_INCLUDED_ 37 | #define _HLSLPARSEABLES_INCLUDED_ 38 | 39 | #include "../glslang/MachineIndependent/Initialize.h" 40 | 41 | namespace glslang { 42 | 43 | // 44 | // This is an HLSL specific derivation of TBuiltInParseables. See comment 45 | // above TBuiltInParseables for details. 46 | // 47 | class TBuiltInParseablesHlsl : public TBuiltInParseables { 48 | public: 49 | POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator()) 50 | TBuiltInParseablesHlsl(); 51 | void initialize(int version, EProfile, const SpvVersion& spvVersion); 52 | void initialize(const TBuiltInResource& resources, int version, EProfile, const SpvVersion& spvVersion, EShLanguage); 53 | 54 | void identifyBuiltIns(int version, EProfile profile, const SpvVersion& spvVersion, EShLanguage language, TSymbolTable& symbolTable); 55 | 56 | void identifyBuiltIns(int version, EProfile profile, const SpvVersion& spvVersion, EShLanguage language, TSymbolTable& symbolTable, const TBuiltInResource &resources); 57 | 58 | private: 59 | void createMatTimesMat(); 60 | }; 61 | 62 | } // end namespace glslang 63 | 64 | #endif // _HLSLPARSEABLES_INCLUDED_ 65 | -------------------------------------------------------------------------------- /3rdparty/glslang/hlsl/hlslScanContext.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2016 Google, Inc. 3 | // 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions 8 | // are met: 9 | // 10 | // Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // 13 | // Redistributions in binary form must reproduce the above 14 | // copyright notice, this list of conditions and the following 15 | // disclaimer in the documentation and/or other materials provided 16 | // with the distribution. 17 | // 18 | // Neither the name of Google, Inc., nor the names of its 19 | // contributors may be used to endorse or promote products derived 20 | // from this software without specific prior written permission. 21 | // 22 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 25 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 26 | // COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 27 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 28 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 30 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 32 | // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | // POSSIBILITY OF SUCH DAMAGE. 34 | // 35 | 36 | // 37 | // This holds context specific to the HLSL scanner, which 38 | // sits between the preprocessor scanner and HLSL parser. 39 | // 40 | 41 | #ifndef HLSLSCANCONTEXT_H_ 42 | #define HLSLSCANCONTEXT_H_ 43 | 44 | #include "../glslang/MachineIndependent/ParseHelper.h" 45 | #include "hlslTokens.h" 46 | 47 | namespace glslang { 48 | 49 | class TPpContext; 50 | class TPpToken; 51 | 52 | 53 | // 54 | // Everything needed to fully describe a token. 55 | // 56 | struct HlslToken { 57 | HlslToken() : string(nullptr) { loc.init(); } 58 | TSourceLoc loc; // location of token in the source 59 | EHlslTokenClass tokenClass; // what kind of token it is 60 | union { // what data the token holds 61 | glslang::TString *string; // for identifiers 62 | int i; // for literals 63 | unsigned int u; 64 | bool b; 65 | double d; 66 | }; 67 | }; 68 | 69 | // 70 | // The state of scanning and translating raw tokens to slightly richer 71 | // semantics, like knowing if an identifier is an existing symbol, or 72 | // user-defined type. 73 | // 74 | class HlslScanContext { 75 | public: 76 | HlslScanContext(TParseContextBase& parseContext, TPpContext& ppContext) 77 | : parseContext(parseContext), ppContext(ppContext) { } 78 | virtual ~HlslScanContext() { } 79 | 80 | static void fillInKeywordMap(); 81 | static void deleteKeywordMap(); 82 | 83 | void tokenize(HlslToken&); 84 | glslang::TBuiltInVariable mapSemantic(const char*); 85 | 86 | protected: 87 | HlslScanContext(HlslScanContext&); 88 | HlslScanContext& operator=(HlslScanContext&); 89 | 90 | EHlslTokenClass tokenizeClass(HlslToken&); 91 | EHlslTokenClass tokenizeIdentifier(); 92 | EHlslTokenClass identifierOrType(); 93 | EHlslTokenClass reservedWord(); 94 | EHlslTokenClass identifierOrReserved(bool reserved); 95 | EHlslTokenClass nonreservedKeyword(int version); 96 | 97 | TParseContextBase& parseContext; 98 | TPpContext& ppContext; 99 | TSourceLoc loc; 100 | TPpToken* ppToken; 101 | HlslToken* parserToken; 102 | 103 | const char* tokenText; 104 | EHlslTokenClass keyword; 105 | }; 106 | 107 | } // end namespace glslang 108 | 109 | #endif // HLSLSCANCONTEXT_H_ 110 | -------------------------------------------------------------------------------- /3rdparty/glslang/hlsl/hlslTokenStream.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2016 Google, Inc. 3 | // 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions 8 | // are met: 9 | // 10 | // Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // 13 | // Redistributions in binary form must reproduce the above 14 | // copyright notice, this list of conditions and the following 15 | // disclaimer in the documentation and/or other materials provided 16 | // with the distribution. 17 | // 18 | // Neither the name of Google, Inc., nor the names of its 19 | // contributors may be used to endorse or promote products derived 20 | // from this software without specific prior written permission. 21 | // 22 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 25 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 26 | // COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 27 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 28 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 30 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 32 | // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | // POSSIBILITY OF SUCH DAMAGE. 34 | // 35 | 36 | #include "hlslTokenStream.h" 37 | 38 | namespace glslang { 39 | 40 | void HlslTokenStream::pushPreToken(const HlslToken& tok) 41 | { 42 | assert(preTokenStackSize < tokenBufferSize); 43 | preTokenStack[preTokenStackSize++] = tok; 44 | } 45 | 46 | HlslToken HlslTokenStream::popPreToken() 47 | { 48 | assert(preTokenStackSize > 0); 49 | 50 | return preTokenStack[--preTokenStackSize]; 51 | } 52 | 53 | void HlslTokenStream::pushTokenBuffer(const HlslToken& tok) 54 | { 55 | tokenBuffer[tokenBufferPos] = tok; 56 | tokenBufferPos = (tokenBufferPos+1) % tokenBufferSize; 57 | } 58 | 59 | HlslToken HlslTokenStream::popTokenBuffer() 60 | { 61 | // Back up 62 | tokenBufferPos = (tokenBufferPos+tokenBufferSize-1) % tokenBufferSize; 63 | 64 | return tokenBuffer[tokenBufferPos]; 65 | } 66 | 67 | // 68 | // Make a new source of tokens, not from the source, but from an 69 | // already pre-processed token stream. 70 | // 71 | // This interrupts current token processing which must be restored 72 | // later. Some simplifying assumptions are made (and asserted). 73 | // 74 | void HlslTokenStream::pushTokenStream(const TVector* tokens) 75 | { 76 | // not yet setup to interrupt a stream that has been receded 77 | // and not yet reconsumed 78 | assert(preTokenStackSize == 0); 79 | 80 | // save current state 81 | currentTokenStack.push_back(token); 82 | 83 | // set up new token stream 84 | tokenStreamStack.push_back(tokens); 85 | 86 | // start position at first token: 87 | token = (*tokens)[0]; 88 | tokenPosition.push_back(0); 89 | } 90 | 91 | // Undo pushTokenStream(), see above 92 | void HlslTokenStream::popTokenStream() 93 | { 94 | tokenStreamStack.pop_back(); 95 | tokenPosition.pop_back(); 96 | token = currentTokenStack.back(); 97 | currentTokenStack.pop_back(); 98 | } 99 | 100 | // Load 'token' with the next token in the stream of tokens. 101 | void HlslTokenStream::advanceToken() 102 | { 103 | pushTokenBuffer(token); 104 | if (preTokenStackSize > 0) 105 | token = popPreToken(); 106 | else { 107 | if (tokenStreamStack.size() == 0) 108 | scanner.tokenize(token); 109 | else { 110 | ++tokenPosition.back(); 111 | if (tokenPosition.back() >= (int)tokenStreamStack.back()->size()) 112 | token.tokenClass = EHTokNone; 113 | else 114 | token = (*tokenStreamStack.back())[tokenPosition.back()]; 115 | } 116 | } 117 | } 118 | 119 | void HlslTokenStream::recedeToken() 120 | { 121 | pushPreToken(token); 122 | token = popTokenBuffer(); 123 | } 124 | 125 | // Return the current token class. 126 | EHlslTokenClass HlslTokenStream::peek() const 127 | { 128 | return token.tokenClass; 129 | } 130 | 131 | // Return true, without advancing to the next token, if the current token is 132 | // the expected (passed in) token class. 133 | bool HlslTokenStream::peekTokenClass(EHlslTokenClass tokenClass) const 134 | { 135 | return peek() == tokenClass; 136 | } 137 | 138 | // Return true and advance to the next token if the current token is the 139 | // expected (passed in) token class. 140 | bool HlslTokenStream::acceptTokenClass(EHlslTokenClass tokenClass) 141 | { 142 | if (peekTokenClass(tokenClass)) { 143 | advanceToken(); 144 | return true; 145 | } 146 | 147 | return false; 148 | } 149 | 150 | } // end namespace glslang 151 | -------------------------------------------------------------------------------- /3rdparty/glslang/hlsl/hlslTokenStream.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2016 Google, Inc. 3 | // 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions 8 | // are met: 9 | // 10 | // Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // 13 | // Redistributions in binary form must reproduce the above 14 | // copyright notice, this list of conditions and the following 15 | // disclaimer in the documentation and/or other materials provided 16 | // with the distribution. 17 | // 18 | // Neither the name of Google, Inc., nor the names of its 19 | // contributors may be used to endorse or promote products derived 20 | // from this software without specific prior written permission. 21 | // 22 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 25 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 26 | // COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 27 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 28 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 30 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 32 | // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | // POSSIBILITY OF SUCH DAMAGE. 34 | // 35 | 36 | #ifndef HLSLTOKENSTREAM_H_ 37 | #define HLSLTOKENSTREAM_H_ 38 | 39 | #include "hlslScanContext.h" 40 | 41 | namespace glslang { 42 | 43 | class HlslTokenStream { 44 | public: 45 | explicit HlslTokenStream(HlslScanContext& scanner) 46 | : scanner(scanner), preTokenStackSize(0), tokenBufferPos(0) { } 47 | virtual ~HlslTokenStream() { } 48 | 49 | public: 50 | void advanceToken(); 51 | void recedeToken(); 52 | bool acceptTokenClass(EHlslTokenClass); 53 | EHlslTokenClass peek() const; 54 | bool peekTokenClass(EHlslTokenClass) const; 55 | glslang::TBuiltInVariable mapSemantic(const char* upperCase) { return scanner.mapSemantic(upperCase); } 56 | 57 | void pushTokenStream(const TVector* tokens); 58 | void popTokenStream(); 59 | 60 | protected: 61 | HlslToken token; // the token we are currently looking at, but have not yet accepted 62 | 63 | private: 64 | HlslTokenStream(); 65 | HlslTokenStream& operator=(const HlslTokenStream&); 66 | 67 | HlslScanContext& scanner; // lexical scanner, to get next token from source file 68 | TVector*> tokenStreamStack; // for getting the next token from an existing vector of tokens 69 | TVector tokenPosition; 70 | TVector currentTokenStack; 71 | 72 | // This is the number of tokens we can recedeToken() over. 73 | static const int tokenBufferSize = 2; 74 | 75 | // Previously scanned tokens, returned for future advances, 76 | // so logically in front of the token stream. 77 | // Is logically a stack; needs last in last out semantics. 78 | // Currently implemented as a stack of size 2. 79 | HlslToken preTokenStack[tokenBufferSize]; 80 | int preTokenStackSize; 81 | void pushPreToken(const HlslToken&); 82 | HlslToken popPreToken(); 83 | 84 | // Previously scanned tokens, not yet returned for future advances, 85 | // but available for that. 86 | // Is logically a fifo for normal advances, and a stack for recession. 87 | // Currently implemented with an intrinsic size of 2. 88 | HlslToken tokenBuffer[tokenBufferSize]; 89 | int tokenBufferPos; 90 | void pushTokenBuffer(const HlslToken&); 91 | HlslToken popTokenBuffer(); 92 | }; 93 | 94 | } // end namespace glslang 95 | 96 | #endif // HLSLTOKENSTREAM_H_ 97 | -------------------------------------------------------------------------------- /3rdparty/zlib/README: -------------------------------------------------------------------------------- 1 | ZLIB DATA COMPRESSION LIBRARY 2 | 3 | zlib 1.2.11 is a general purpose data compression library. All the code is 4 | thread safe. The data format used by the zlib library is described by RFCs 5 | (Request for Comments) 1950 to 1952 in the files 6 | http://tools.ietf.org/html/rfc1950 (zlib format), rfc1951 (deflate format) and 7 | rfc1952 (gzip format). 8 | 9 | All functions of the compression library are documented in the file zlib.h 10 | (volunteer to write man pages welcome, contact zlib@gzip.org). A usage example 11 | of the library is given in the file test/example.c which also tests that 12 | the library is working correctly. Another example is given in the file 13 | test/minigzip.c. The compression library itself is composed of all source 14 | files in the root directory. 15 | 16 | To compile all files and run the test program, follow the instructions given at 17 | the top of Makefile.in. In short "./configure; make test", and if that goes 18 | well, "make install" should work for most flavors of Unix. For Windows, use 19 | one of the special makefiles in win32/ or contrib/vstudio/ . For VMS, use 20 | make_vms.com. 21 | 22 | Questions about zlib should be sent to , or to Gilles Vollant 23 | for the Windows DLL version. The zlib home page is 24 | http://zlib.net/ . Before reporting a problem, please check this site to 25 | verify that you have the latest version of zlib; otherwise get the latest 26 | version and check whether the problem still exists or not. 27 | 28 | PLEASE read the zlib FAQ http://zlib.net/zlib_faq.html before asking for help. 29 | 30 | Mark Nelson wrote an article about zlib for the Jan. 1997 31 | issue of Dr. Dobb's Journal; a copy of the article is available at 32 | http://marknelson.us/1997/01/01/zlib-engine/ . 33 | 34 | The changes made in version 1.2.11 are documented in the file ChangeLog. 35 | 36 | Unsupported third party contributions are provided in directory contrib/ . 37 | 38 | zlib is available in Java using the java.util.zip package, documented at 39 | http://java.sun.com/developer/technicalArticles/Programming/compression/ . 40 | 41 | A Perl interface to zlib written by Paul Marquess is available 42 | at CPAN (Comprehensive Perl Archive Network) sites, including 43 | http://search.cpan.org/~pmqs/IO-Compress-Zlib/ . 44 | 45 | A Python interface to zlib written by A.M. Kuchling is 46 | available in Python 1.5 and later versions, see 47 | http://docs.python.org/library/zlib.html . 48 | 49 | zlib is built into tcl: http://wiki.tcl.tk/4610 . 50 | 51 | An experimental package to read and write files in .zip format, written on top 52 | of zlib by Gilles Vollant , is available in the 53 | contrib/minizip directory of zlib. 54 | 55 | 56 | Notes for some targets: 57 | 58 | - For Windows DLL versions, please see win32/DLL_FAQ.txt 59 | 60 | - For 64-bit Irix, deflate.c must be compiled without any optimization. With 61 | -O, one libpng test fails. The test works in 32 bit mode (with the -n32 62 | compiler flag). The compiler bug has been reported to SGI. 63 | 64 | - zlib doesn't work with gcc 2.6.3 on a DEC 3000/300LX under OSF/1 2.1 it works 65 | when compiled with cc. 66 | 67 | - On Digital Unix 4.0D (formely OSF/1) on AlphaServer, the cc option -std1 is 68 | necessary to get gzprintf working correctly. This is done by configure. 69 | 70 | - zlib doesn't work on HP-UX 9.05 with some versions of /bin/cc. It works with 71 | other compilers. Use "make test" to check your compiler. 72 | 73 | - gzdopen is not supported on RISCOS or BEOS. 74 | 75 | - For PalmOs, see http://palmzlib.sourceforge.net/ 76 | 77 | 78 | Acknowledgments: 79 | 80 | The deflate format used by zlib was defined by Phil Katz. The deflate and 81 | zlib specifications were written by L. Peter Deutsch. Thanks to all the 82 | people who reported problems and suggested various improvements in zlib; they 83 | are too numerous to cite here. 84 | 85 | Copyright notice: 86 | 87 | (C) 1995-2017 Jean-loup Gailly and Mark Adler 88 | 89 | This software is provided 'as-is', without any express or implied 90 | warranty. In no event will the authors be held liable for any damages 91 | arising from the use of this software. 92 | 93 | Permission is granted to anyone to use this software for any purpose, 94 | including commercial applications, and to alter it and redistribute it 95 | freely, subject to the following restrictions: 96 | 97 | 1. The origin of this software must not be misrepresented; you must not 98 | claim that you wrote the original software. If you use this software 99 | in a product, an acknowledgment in the product documentation would be 100 | appreciated but is not required. 101 | 2. Altered source versions must be plainly marked as such, and must not be 102 | misrepresented as being the original software. 103 | 3. This notice may not be removed or altered from any source distribution. 104 | 105 | Jean-loup Gailly Mark Adler 106 | jloup@gzip.org madler@alumni.caltech.edu 107 | 108 | If you use the zlib library in a product, we would appreciate *not* receiving 109 | lengthy legal documents to sign. The sources are provided for free but without 110 | warranty of any kind. The library has been entirely written by Jean-loup 111 | Gailly and Mark Adler; it does not include third-party code. 112 | 113 | If you redistribute modified sources, we would appreciate that you include in 114 | the file ChangeLog history information documenting your changes. Please read 115 | the FAQ for more information on the distribution of modified source versions. 116 | -------------------------------------------------------------------------------- /3rdparty/zlib/include/inffast.h: -------------------------------------------------------------------------------- 1 | /* inffast.h -- header to use inffast.c 2 | * Copyright (C) 1995-2003, 2010 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* WARNING: this file should *not* be used by applications. It is 7 | part of the implementation of the compression library and is 8 | subject to change. Applications should only use zlib.h. 9 | */ 10 | 11 | void ZLIB_INTERNAL inflate_fast OF((z_streamp strm, unsigned start)); 12 | -------------------------------------------------------------------------------- /3rdparty/zlib/include/inftrees.h: -------------------------------------------------------------------------------- 1 | /* inftrees.h -- header to use inftrees.c 2 | * Copyright (C) 1995-2005, 2010 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* WARNING: this file should *not* be used by applications. It is 7 | part of the implementation of the compression library and is 8 | subject to change. Applications should only use zlib.h. 9 | */ 10 | 11 | /* Structure for decoding tables. Each entry provides either the 12 | information needed to do the operation requested by the code that 13 | indexed that table entry, or it provides a pointer to another 14 | table that indexes more bits of the code. op indicates whether 15 | the entry is a pointer to another table, a literal, a length or 16 | distance, an end-of-block, or an invalid code. For a table 17 | pointer, the low four bits of op is the number of index bits of 18 | that table. For a length or distance, the low four bits of op 19 | is the number of extra bits to get after the code. bits is 20 | the number of bits in this code or part of the code to drop off 21 | of the bit buffer. val is the actual byte to output in the case 22 | of a literal, the base length or distance, or the offset from 23 | the current table to the next table. Each entry is four bytes. */ 24 | typedef struct { 25 | unsigned char op; /* operation, extra bits, table bits */ 26 | unsigned char bits; /* bits in this part of the code */ 27 | unsigned short val; /* offset in table or code value */ 28 | } code; 29 | 30 | /* op values as set by inflate_table(): 31 | 00000000 - literal 32 | 0000tttt - table link, tttt != 0 is the number of table index bits 33 | 0001eeee - length or distance, eeee is the number of extra bits 34 | 01100000 - end of block 35 | 01000000 - invalid code 36 | */ 37 | 38 | /* Maximum size of the dynamic table. The maximum number of code structures is 39 | 1444, which is the sum of 852 for literal/length codes and 592 for distance 40 | codes. These values were found by exhaustive searches using the program 41 | examples/enough.c found in the zlib distribtution. The arguments to that 42 | program are the number of symbols, the initial root table size, and the 43 | maximum bit length of a code. "enough 286 9 15" for literal/length codes 44 | returns returns 852, and "enough 30 6 15" for distance codes returns 592. 45 | The initial root table size (9 or 6) is found in the fifth argument of the 46 | inflate_table() calls in inflate.c and infback.c. If the root table size is 47 | changed, then these maximum sizes would be need to be recalculated and 48 | updated. */ 49 | #define ENOUGH_LENS 852 50 | #define ENOUGH_DISTS 592 51 | #define ENOUGH (ENOUGH_LENS+ENOUGH_DISTS) 52 | 53 | /* Type of code to build for inflate_table() */ 54 | typedef enum { 55 | CODES, 56 | LENS, 57 | DISTS 58 | } codetype; 59 | 60 | int ZLIB_INTERNAL inflate_table OF((codetype type, unsigned short FAR *lens, 61 | unsigned codes, code FAR * FAR *table, 62 | unsigned FAR *bits, unsigned short FAR *work)); 63 | -------------------------------------------------------------------------------- /3rdparty/zlib/src/compress.c: -------------------------------------------------------------------------------- 1 | /* compress.c -- compress a memory buffer 2 | * Copyright (C) 1995-2005, 2014, 2016 Jean-loup Gailly, Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* @(#) $Id$ */ 7 | 8 | #define ZLIB_INTERNAL 9 | #include "zlib.h" 10 | 11 | /* =========================================================================== 12 | Compresses the source buffer into the destination buffer. The level 13 | parameter has the same meaning as in deflateInit. sourceLen is the byte 14 | length of the source buffer. Upon entry, destLen is the total size of the 15 | destination buffer, which must be at least 0.1% larger than sourceLen plus 16 | 12 bytes. Upon exit, destLen is the actual size of the compressed buffer. 17 | 18 | compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough 19 | memory, Z_BUF_ERROR if there was not enough room in the output buffer, 20 | Z_STREAM_ERROR if the level parameter is invalid. 21 | */ 22 | int ZEXPORT compress2 (dest, destLen, source, sourceLen, level) 23 | Bytef *dest; 24 | uLongf *destLen; 25 | const Bytef *source; 26 | uLong sourceLen; 27 | int level; 28 | { 29 | z_stream stream; 30 | int err; 31 | const uInt max = (uInt)-1; 32 | uLong left; 33 | 34 | left = *destLen; 35 | *destLen = 0; 36 | 37 | stream.zalloc = (alloc_func)0; 38 | stream.zfree = (free_func)0; 39 | stream.opaque = (voidpf)0; 40 | 41 | err = deflateInit(&stream, level); 42 | if (err != Z_OK) return err; 43 | 44 | stream.next_out = dest; 45 | stream.avail_out = 0; 46 | stream.next_in = (z_const Bytef *)source; 47 | stream.avail_in = 0; 48 | 49 | do { 50 | if (stream.avail_out == 0) { 51 | stream.avail_out = left > (uLong)max ? max : (uInt)left; 52 | left -= stream.avail_out; 53 | } 54 | if (stream.avail_in == 0) { 55 | stream.avail_in = sourceLen > (uLong)max ? max : (uInt)sourceLen; 56 | sourceLen -= stream.avail_in; 57 | } 58 | err = deflate(&stream, sourceLen ? Z_NO_FLUSH : Z_FINISH); 59 | } while (err == Z_OK); 60 | 61 | *destLen = stream.total_out; 62 | deflateEnd(&stream); 63 | return err == Z_STREAM_END ? Z_OK : err; 64 | } 65 | 66 | /* =========================================================================== 67 | */ 68 | int ZEXPORT compress (dest, destLen, source, sourceLen) 69 | Bytef *dest; 70 | uLongf *destLen; 71 | const Bytef *source; 72 | uLong sourceLen; 73 | { 74 | return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION); 75 | } 76 | 77 | /* =========================================================================== 78 | If the default memLevel or windowBits for deflateInit() is changed, then 79 | this function needs to be updated. 80 | */ 81 | uLong ZEXPORT compressBound (sourceLen) 82 | uLong sourceLen; 83 | { 84 | return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + 85 | (sourceLen >> 25) + 13; 86 | } 87 | -------------------------------------------------------------------------------- /3rdparty/zlib/src/gzclose.c: -------------------------------------------------------------------------------- 1 | /* gzclose.c -- zlib gzclose() function 2 | * Copyright (C) 2004, 2010 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | #include "gzguts.h" 7 | 8 | /* gzclose() is in a separate file so that it is linked in only if it is used. 9 | That way the other gzclose functions can be used instead to avoid linking in 10 | unneeded compression or decompression routines. */ 11 | int ZEXPORT gzclose(file) 12 | gzFile file; 13 | { 14 | #ifndef NO_GZCOMPRESS 15 | gz_statep state; 16 | 17 | if (file == NULL) 18 | return Z_STREAM_ERROR; 19 | state = (gz_statep)file; 20 | 21 | return state->mode == GZ_READ ? gzclose_r(file) : gzclose_w(file); 22 | #else 23 | return gzclose_r(file); 24 | #endif 25 | } 26 | -------------------------------------------------------------------------------- /3rdparty/zlib/src/uncompr.c: -------------------------------------------------------------------------------- 1 | /* uncompr.c -- decompress a memory buffer 2 | * Copyright (C) 1995-2003, 2010, 2014, 2016 Jean-loup Gailly, Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* @(#) $Id$ */ 7 | 8 | #define ZLIB_INTERNAL 9 | #include "zlib.h" 10 | 11 | /* =========================================================================== 12 | Decompresses the source buffer into the destination buffer. *sourceLen is 13 | the byte length of the source buffer. Upon entry, *destLen is the total size 14 | of the destination buffer, which must be large enough to hold the entire 15 | uncompressed data. (The size of the uncompressed data must have been saved 16 | previously by the compressor and transmitted to the decompressor by some 17 | mechanism outside the scope of this compression library.) Upon exit, 18 | *destLen is the size of the decompressed data and *sourceLen is the number 19 | of source bytes consumed. Upon return, source + *sourceLen points to the 20 | first unused input byte. 21 | 22 | uncompress returns Z_OK if success, Z_MEM_ERROR if there was not enough 23 | memory, Z_BUF_ERROR if there was not enough room in the output buffer, or 24 | Z_DATA_ERROR if the input data was corrupted, including if the input data is 25 | an incomplete zlib stream. 26 | */ 27 | int ZEXPORT uncompress2 (dest, destLen, source, sourceLen) 28 | Bytef *dest; 29 | uLongf *destLen; 30 | const Bytef *source; 31 | uLong *sourceLen; 32 | { 33 | z_stream stream; 34 | int err; 35 | const uInt max = (uInt)-1; 36 | uLong len, left; 37 | Byte buf[1]; /* for detection of incomplete stream when *destLen == 0 */ 38 | 39 | len = *sourceLen; 40 | if (*destLen) { 41 | left = *destLen; 42 | *destLen = 0; 43 | } 44 | else { 45 | left = 1; 46 | dest = buf; 47 | } 48 | 49 | stream.next_in = (z_const Bytef *)source; 50 | stream.avail_in = 0; 51 | stream.zalloc = (alloc_func)0; 52 | stream.zfree = (free_func)0; 53 | stream.opaque = (voidpf)0; 54 | 55 | err = inflateInit(&stream); 56 | if (err != Z_OK) return err; 57 | 58 | stream.next_out = dest; 59 | stream.avail_out = 0; 60 | 61 | do { 62 | if (stream.avail_out == 0) { 63 | stream.avail_out = left > (uLong)max ? max : (uInt)left; 64 | left -= stream.avail_out; 65 | } 66 | if (stream.avail_in == 0) { 67 | stream.avail_in = len > (uLong)max ? max : (uInt)len; 68 | len -= stream.avail_in; 69 | } 70 | err = inflate(&stream, Z_NO_FLUSH); 71 | } while (err == Z_OK); 72 | 73 | *sourceLen -= len + stream.avail_in; 74 | if (dest != buf) 75 | *destLen = stream.total_out; 76 | else if (stream.total_out && err == Z_BUF_ERROR) 77 | left = 1; 78 | 79 | inflateEnd(&stream); 80 | return err == Z_STREAM_END ? Z_OK : 81 | err == Z_NEED_DICT ? Z_DATA_ERROR : 82 | err == Z_BUF_ERROR && left + stream.avail_out ? Z_DATA_ERROR : 83 | err; 84 | } 85 | 86 | int ZEXPORT uncompress (dest, destLen, source, sourceLen) 87 | Bytef *dest; 88 | uLongf *destLen; 89 | const Bytef *source; 90 | uLong sourceLen; 91 | { 92 | return uncompress2(dest, destLen, source, &sourceLen); 93 | } 94 | -------------------------------------------------------------------------------- /3rdparty/zlib/zlib.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {5670ae78-05f7-4e8b-99c2-d1abf5f0e108} 6 | 7 | 8 | {6e53bfe6-39e9-4ab6-90d3-422e0a2deaed} 9 | 10 | 11 | 12 | 13 | include 14 | 15 | 16 | include 17 | 18 | 19 | include 20 | 21 | 22 | include 23 | 24 | 25 | include 26 | 27 | 28 | include 29 | 30 | 31 | include 32 | 33 | 34 | include 35 | 36 | 37 | include 38 | 39 | 40 | include 41 | 42 | 43 | include 44 | 45 | 46 | 47 | 48 | src 49 | 50 | 51 | src 52 | 53 | 54 | src 55 | 56 | 57 | src 58 | 59 | 60 | src 61 | 62 | 63 | src 64 | 65 | 66 | src 67 | 68 | 69 | src 70 | 71 | 72 | src 73 | 74 | 75 | src 76 | 77 | 78 | src 79 | 80 | 81 | src 82 | 83 | 84 | src 85 | 86 | 87 | src 88 | 89 | 90 | src 91 | 92 | 93 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # include-engine 2 | ### `#include ` 3 | 4 | This repository was inspired by a conversation I had with [Stan Melax](https://github.com/melax) the other day, in which he lamented that game engines were so heavyweight and it wasn't possible to simply `#include ` or `#include `. While these game engines provide a wealth of services to kickstart the development of your game, you essentially give up control over the lifetime of your application and wind up writing most of your scripts inside a sandboxed environment (Unity's C# APIs or Unreal's Blueprint system). 5 | 6 | This project will therefore strive to provide game engine-like services while allowing the programmer to remain in control of the main loop of their program. Note that this project is extremely early and is unlikely to be tremendously useful to anyone in its present state. In particular, you should assume that **NONE** of the functionality listed below has been implemented in any form. 7 | 8 | ### Rough design goals 9 | 10 | The application owns the main loop, and therefore, `#include ` will have no concept of game object hierarchies, entity-component systems, scene graphs or scripting languages. The application programmer chooses whichever data structures they want to represent their game world, and can code the game logic directly in C++ or in any scripting language they feel like integrating. The world can be as structured or unstructured, as explicit or procedural as the programmer desires. 11 | 12 | Instead, I envision `#include ` as a collection of lightweight, composable, "immediate-mode" subsystems. For instance, the renderer will not retain any notion of the scene from frame to frame. When you are ready to draw a frame, you will traverse your game's data structures in whatever manner is most convenient, and issue draw calls, which may reference both long-lived assets and transient data generated for that frame only. The renderer will provide automatic services such as reordering of draw calls for depth ordering, transparent objects, etc., as well as automatic resubmission of draw calls to render shadowmaps, depth prepasses, and the lighting pass, but the data structures required to do so will only live for the lifetime of the frame. This means that your world can change drastically from frame to frame, or even be entirely procedural, without needing to worry about the overhead of spawning and destroying rendergraph objects. In cases where you DO need to retain state from frame to frame, such as the current state of a particle system, we will provide data types to carry that state, which your code will be expected to pass to the renderer on an as-needed basis. 13 | 14 | The rough feature set I'm aiming for would look something like this: 15 | 16 | - Support for loading many different asset formats (textures, models, shaders, fonts, etc.) 17 | - A library of pure functions for analyzing, manipulating, and transforming assets and other data structures 18 | - An "immediate mode plus" renderer targeting a Vulkan backend 19 | - An immediate mode GUI subsystem for building tools and editors 20 | - A flexible asset packaging system that can be used to author packages at runtime and optimize load times 21 | 22 | The idea is that you should be able to quickly pull in some assets and start rendering 3D scenes, and that as your game evolves, you can author your tools and editors by coding against the same framework. 23 | 24 | ### Target Environment 25 | 26 | - The engine itself will be written in C++17 and aim to compile cleanly on Visual Studio 2017, GCC, and Clang. 27 | - The engine will consume shaders in SPIR-V and will initially target Vulkan on Windows and Linux. A Metal backend for OS X support is a possibility once the renderer API crystalizes. 28 | - Platform specific window creation and input handling will use GLFW windows created with the `GLFW_NO_CLIENT` hint. 29 | - We will link against the C++ standard library, use RTTI and throw exceptions. Deal with it. 30 | -------------------------------------------------------------------------------- /UNLICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to -------------------------------------------------------------------------------- /example-game/assets/ATTRIBUTIONS.txt: -------------------------------------------------------------------------------- 1 | The listed files are the original work of the following authors, graciously made available under the terms of their respective licenses. Note that in some cases these files have been reduced in size or quality to save space. I strongly encourage interested parties to view the full quality files in their original locations. 2 | 3 | mutant-mesh.fbx, mutant-albedo.jpg, mutant-normal.jpg, akai-albedo.jpg, akai-normal.jpg 4 | Jincho by Antoine Pavia is licensed under Creative Commons Attribution 5 | https://sketchfab.com/models/9a49e336092d4e5aacc01aba739f601a 6 | 7 | helmet-mesh.fbx, helmet-albedo.jpg, helmet-normal.jpg, helmet-metallic.jpg, helmet-roughness.jpg 8 | Simple Steel Helmet (Game Model) by Michael Makivic is licensed under Creative Commons Attribution 9 | https://sketchfab.com/models/1603f60804c941cba0ffeacea20a7f32 10 | 11 | sands location.obj, sands location.mtl, map_2_island.jpg, map_2_objects.jpg, map_2_terrain.jpg 12 | Sands Location by Bocharova is licensed under Creative Commons Attribution - Noncommercial 13 | https://sketchfab.com/models/f35b8eb1e72f42699ec34069489ac654 14 | 15 | negx.jpg, negy.jpg, negz.jpg, posx.jpg, posy.jpg, posz.jpg 16 | Maskonaive 2 by Emil Persson, aka Humus 17 | Creative Commons Attribution 3.0 Unported 18 | http://www.humus.name 19 | -------------------------------------------------------------------------------- /example-game/assets/akai-albedo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgorsten/include-engine/67af882e24beba73ad44621397993e1b6818cf5b/example-game/assets/akai-albedo.jpg -------------------------------------------------------------------------------- /example-game/assets/akai-normal.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgorsten/include-engine/67af882e24beba73ad44621397993e1b6818cf5b/example-game/assets/akai-normal.jpg -------------------------------------------------------------------------------- /example-game/assets/helmet-albedo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgorsten/include-engine/67af882e24beba73ad44621397993e1b6818cf5b/example-game/assets/helmet-albedo.jpg -------------------------------------------------------------------------------- /example-game/assets/helmet-mesh.fbx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgorsten/include-engine/67af882e24beba73ad44621397993e1b6818cf5b/example-game/assets/helmet-mesh.fbx -------------------------------------------------------------------------------- /example-game/assets/helmet-metallic.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgorsten/include-engine/67af882e24beba73ad44621397993e1b6818cf5b/example-game/assets/helmet-metallic.jpg -------------------------------------------------------------------------------- /example-game/assets/helmet-normal.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgorsten/include-engine/67af882e24beba73ad44621397993e1b6818cf5b/example-game/assets/helmet-normal.jpg -------------------------------------------------------------------------------- /example-game/assets/helmet-roughness.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgorsten/include-engine/67af882e24beba73ad44621397993e1b6818cf5b/example-game/assets/helmet-roughness.jpg -------------------------------------------------------------------------------- /example-game/assets/map_2_fire.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgorsten/include-engine/67af882e24beba73ad44621397993e1b6818cf5b/example-game/assets/map_2_fire.png -------------------------------------------------------------------------------- /example-game/assets/map_2_island.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgorsten/include-engine/67af882e24beba73ad44621397993e1b6818cf5b/example-game/assets/map_2_island.jpg -------------------------------------------------------------------------------- /example-game/assets/map_2_objects.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgorsten/include-engine/67af882e24beba73ad44621397993e1b6818cf5b/example-game/assets/map_2_objects.jpg -------------------------------------------------------------------------------- /example-game/assets/map_2_terrain.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgorsten/include-engine/67af882e24beba73ad44621397993e1b6818cf5b/example-game/assets/map_2_terrain.jpg -------------------------------------------------------------------------------- /example-game/assets/metal.frag: -------------------------------------------------------------------------------- 1 | #version 450 2 | #extension GL_ARB_separate_shader_objects : enable 3 | #extension GL_GOOGLE_include_directive : enable 4 | #include "scene.glsl" 5 | 6 | layout(set=2, binding=1) uniform sampler2D u_albedo; 7 | layout(set=2, binding=2) uniform sampler2D u_normal; 8 | layout(set=2, binding=3) uniform sampler2D u_metallic; 9 | 10 | layout(location = 0) in vec3 position; 11 | layout(location = 1) in vec3 color; 12 | layout(location = 2) in vec3 normal; 13 | layout(location = 3) in vec2 texcoord; 14 | layout(location = 4) in vec3 tangent; 15 | layout(location = 5) in vec3 bitangent; 16 | 17 | layout(location = 0) out vec4 f_color; 18 | 19 | void main() 20 | { 21 | vec3 eye_vec = normalize(u_eye_position - position); 22 | vec3 albedo = texture(u_albedo, texcoord).rgb * color; 23 | vec3 tan_normal = normalize(texture(u_normal, texcoord).xyz*2-1); 24 | vec3 normal_vec = normalize(normalize(tangent)*tan_normal.x + normalize(bitangent)*tan_normal.y + normalize(normal)*tan_normal.z); 25 | vec3 refl_vec = normal_vec*(dot(eye_vec, normal_vec)*2) - eye_vec; 26 | vec3 refl_light = albedo * sample_environment(refl_vec)*2; 27 | 28 | vec3 light = u_ambient_light; 29 | 30 | vec3 light_vec = u_light_direction; 31 | light += albedo * u_light_color * max(dot(normal_vec, light_vec), 0); 32 | vec3 half_vec = normalize(light_vec + eye_vec); 33 | light += u_light_color * pow(max(dot(normal_vec, half_vec), 0), 128); 34 | 35 | float metallic = texture(u_metallic, texcoord).r; 36 | f_color = vec4(light*(1-metallic) + refl_light*metallic, 1); 37 | } -------------------------------------------------------------------------------- /example-game/assets/mutant-albedo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgorsten/include-engine/67af882e24beba73ad44621397993e1b6818cf5b/example-game/assets/mutant-albedo.jpg -------------------------------------------------------------------------------- /example-game/assets/mutant-normal.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgorsten/include-engine/67af882e24beba73ad44621397993e1b6818cf5b/example-game/assets/mutant-normal.jpg -------------------------------------------------------------------------------- /example-game/assets/negx.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgorsten/include-engine/67af882e24beba73ad44621397993e1b6818cf5b/example-game/assets/negx.jpg -------------------------------------------------------------------------------- /example-game/assets/negy.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgorsten/include-engine/67af882e24beba73ad44621397993e1b6818cf5b/example-game/assets/negy.jpg -------------------------------------------------------------------------------- /example-game/assets/negz.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgorsten/include-engine/67af882e24beba73ad44621397993e1b6818cf5b/example-game/assets/negz.jpg -------------------------------------------------------------------------------- /example-game/assets/posx.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgorsten/include-engine/67af882e24beba73ad44621397993e1b6818cf5b/example-game/assets/posx.jpg -------------------------------------------------------------------------------- /example-game/assets/posy.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgorsten/include-engine/67af882e24beba73ad44621397993e1b6818cf5b/example-game/assets/posy.jpg -------------------------------------------------------------------------------- /example-game/assets/posz.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgorsten/include-engine/67af882e24beba73ad44621397993e1b6818cf5b/example-game/assets/posz.jpg -------------------------------------------------------------------------------- /example-game/assets/sands location.mtl: -------------------------------------------------------------------------------- 1 | newmtl initialShadingGroup 2 | illum 4 3 | Kd 0.50 0.50 0.50 4 | Ka 0.00 0.00 0.00 5 | Tf 1.00 1.00 1.00 6 | Ni 1.00 7 | newmtl map_1:lambert3SG 8 | illum 4 9 | Kd 0.00 0.00 0.00 10 | Ka 0.00 0.00 0.00 11 | Tf 1.00 1.00 1.00 12 | map_Kd map_1_grass.tga 13 | Ni 1.00 14 | newmtl map_1:layeredTexture1SG 15 | illum 4 16 | Kd 0.00 0.00 0.00 17 | Ka 0.44 0.44 0.44 18 | Tf 1.00 1.00 1.00 19 | Ni 1.00 20 | newmtl map_1:map_0001:blinn1SG 21 | illum 4 22 | Kd 0.70 0.70 0.70 23 | Ka 0.00 0.00 0.00 24 | Tf 1.00 1.00 1.00 25 | Ni 1.00 26 | newmtl map_1:map_0001:blinn2SG 27 | illum 4 28 | Kd 0.32 0.26 0.06 29 | Ka 0.00 0.00 0.00 30 | Tf 1.00 1.00 1.00 31 | Ni 1.00 32 | Ks 0.50 0.50 0.50 33 | newmtl map_1:map_0001:lambert2SG 34 | illum 4 35 | Kd 0.19 0.37 0.07 36 | Ka 0.00 0.00 0.00 37 | Tf 1.00 1.00 1.00 38 | Ni 1.00 39 | newmtl map_1:map_0001:lambert3SG 40 | illum 4 41 | Kd 0.23 0.16 0.09 42 | Ka 0.00 0.00 0.00 43 | Tf 1.00 1.00 1.00 44 | Ni 1.00 45 | newmtl map_1:map_0001:lambert4SG 46 | illum 4 47 | Kd 0.47 0.41 0.26 48 | Ka 0.00 0.00 0.00 49 | Tf 1.00 1.00 1.00 50 | Ni 1.00 51 | newmtl map_1:map_0001:lambert5SG 52 | illum 4 53 | Kd 0.05 0.23 0.23 54 | Ka 0.00 0.00 0.00 55 | Tf 1.00 1.00 1.00 56 | Ni 1.00 57 | newmtl map_1:map_0001:lambert6SG 58 | illum 4 59 | Kd 0.15 0.22 0.06 60 | Ka 0.00 0.00 0.00 61 | Tf 1.00 1.00 1.00 62 | Ni 1.00 63 | newmtl map_1:map_0001:lambert7SG 64 | illum 4 65 | Kd 0.50 0.50 0.50 66 | Ka 0.00 0.00 0.00 67 | Tf 0.00 1.00 1.00 68 | Ni 1.00 69 | newmtl map_2_island1 70 | illum 4 71 | Kd 0.00 0.00 0.00 72 | Ka 0.00 0.00 0.00 73 | Tf 1.00 1.00 1.00 74 | map_Kd map_island.tga 75 | Ni 1.00 76 | newmtl map_2_object1 77 | illum 4 78 | Kd 0.00 0.00 0.00 79 | Ka 0.00 0.00 0.00 80 | Tf 1.00 1.00 1.00 81 | map_Kd map_objects.tga 82 | Ni 1.00 83 | newmtl map_2_terrain1 84 | illum 4 85 | Kd 0.00 0.00 0.00 86 | Ka 0.00 0.00 0.00 87 | Tf 1.00 1.00 1.00 88 | map_Kd map_terrain.tga 89 | Ni 1.00 90 | newmtl map_4:blinn6SG 91 | illum 4 92 | Kd 0.00 0.00 0.00 93 | Ka 0.00 0.00 0.00 94 | Tf 1.00 1.00 1.00 95 | map_Kd grass.tga 96 | Ni 1.00 97 | Ks 0.50 0.50 0.50 98 | Ns 0.06 99 | newmtl map_4:lambert4SG 100 | illum 4 101 | Kd 0.00 0.00 0.00 102 | Ka 0.00 0.00 0.00 103 | Tf 1.00 1.00 1.00 104 | Ni 1.00 105 | newmtl map_4:lambert5SG 106 | illum 4 107 | Kd 0.00 0.00 0.00 108 | Ka 0.00 0.00 0.00 109 | Tf 1.00 1.00 1.00 110 | map_Kd map_2_fire.TGA 111 | Ni 1.00 112 | newmtl map_4:object 113 | illum 4 114 | Kd 0.00 0.00 0.00 115 | Ka 0.00 0.00 0.00 116 | Tf 1.00 1.00 1.00 117 | map_Kd object.tga 118 | Ni 1.00 119 | Ks 0.50 0.50 0.50 120 | Ns 0.06 121 | -------------------------------------------------------------------------------- /example-game/assets/scene.glsl: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Per-scene uniforms: Used to define the lighting environment in which all scene rendering occurs // 3 | ///////////////////////////////////////////////////////////////////////////////////////////////////// 4 | 5 | layout(set=0, binding=0) uniform PerScene 6 | { 7 | mat4 u_cubemap_xform; 8 | vec3 u_ambient_light; 9 | vec3 u_light_direction; 10 | vec3 u_light_color; 11 | }; 12 | layout(set=0, binding=1) uniform samplerCube u_env; 13 | 14 | vec3 sample_environment(vec3 direction) 15 | { 16 | return texture(u_env, (u_cubemap_xform * vec4(direction,0)).xyz).rgb; 17 | } 18 | 19 | //////////////////////////////////////////////////////////////////////////// 20 | // Per-view uniforms: Used to define the world-to-viewport transformation // 21 | //////////////////////////////////////////////////////////////////////////// 22 | 23 | layout(set=1, binding=0) uniform PerView 24 | { 25 | mat4 u_view_proj_matrix; 26 | mat4 u_rotation_only_view_proj_matrix; 27 | vec3 u_eye_position; 28 | }; -------------------------------------------------------------------------------- /example-game/assets/shader.frag: -------------------------------------------------------------------------------- 1 | #version 450 2 | #extension GL_ARB_separate_shader_objects : enable 3 | #extension GL_GOOGLE_include_directive : enable 4 | #include "scene.glsl" 5 | 6 | layout(set=2, binding=1) uniform sampler2D u_albedo; 7 | layout(set=2, binding=2) uniform sampler2D u_normal; 8 | layout(set=2, binding=3) uniform sampler2D u_metallic; 9 | 10 | layout(location = 0) in vec3 position; 11 | layout(location = 1) in vec3 color; 12 | layout(location = 2) in vec3 normal; 13 | layout(location = 3) in vec2 texcoord; 14 | layout(location = 4) in vec3 tangent; 15 | layout(location = 5) in vec3 bitangent; 16 | 17 | layout(location = 0) out vec4 f_color; 18 | 19 | void main() 20 | { 21 | vec3 eye_vec = normalize(u_eye_position - position); 22 | vec3 albedo = texture(u_albedo, texcoord).rgb * color; 23 | vec3 tan_normal = normalize(texture(u_normal, texcoord).xyz*2-1); 24 | vec3 normal_vec = normalize(normalize(tangent)*tan_normal.x + normalize(bitangent)*tan_normal.y + normalize(normal)*tan_normal.z); 25 | 26 | vec3 light = u_ambient_light; 27 | 28 | vec3 light_vec = u_light_direction; 29 | light += albedo * u_light_color * max(dot(normal_vec, light_vec), 0); 30 | vec3 half_vec = normalize(light_vec + eye_vec); 31 | light += u_light_color * pow(max(dot(normal_vec, half_vec), 0), 128); 32 | 33 | f_color = vec4(light,1); 34 | } -------------------------------------------------------------------------------- /example-game/assets/skinned.vert: -------------------------------------------------------------------------------- 1 | #version 450 2 | #extension GL_ARB_separate_shader_objects : enable 3 | #extension GL_GOOGLE_include_directive : enable 4 | #include "scene.glsl" 5 | 6 | layout(set=2, binding=0) uniform PerSkinnedObject 7 | { 8 | mat4 u_bone_matrices[64]; 9 | }; 10 | 11 | layout(location = 0) in vec3 v_position; 12 | layout(location = 1) in vec3 v_color; 13 | layout(location = 2) in vec3 v_normal; 14 | layout(location = 3) in vec2 v_texcoord; 15 | layout(location = 4) in vec3 v_tangent; 16 | layout(location = 5) in vec3 v_bitangent; 17 | 18 | layout(location = 6) in uvec4 v_bone_indices; 19 | layout(location = 7) in vec4 v_bone_weights; 20 | 21 | layout(location = 0) out vec3 position; 22 | layout(location = 1) out vec3 color; 23 | layout(location = 2) out vec3 normal; 24 | layout(location = 3) out vec2 texcoord; 25 | layout(location = 4) out vec3 tangent; 26 | layout(location = 5) out vec3 bitangent; 27 | out gl_PerVertex { vec4 gl_Position; }; 28 | 29 | void main() 30 | { 31 | mat4 model_matrix = u_bone_matrices[v_bone_indices.x] * v_bone_weights.x 32 | + u_bone_matrices[v_bone_indices.y] * v_bone_weights.y 33 | + u_bone_matrices[v_bone_indices.z] * v_bone_weights.z 34 | + u_bone_matrices[v_bone_indices.w] * v_bone_weights.w; 35 | position = (model_matrix * vec4(v_position, 1)).xyz; 36 | color = v_color; 37 | normal = normalize((model_matrix * vec4(v_normal, 0)).xyz); 38 | texcoord = v_texcoord; 39 | tangent = normalize((model_matrix * vec4(v_tangent, 0)).xyz); 40 | bitangent = normalize((model_matrix * vec4(v_bitangent, 0)).xyz); 41 | gl_Position = u_view_proj_matrix * vec4(position, 1); 42 | } -------------------------------------------------------------------------------- /example-game/assets/skybox.frag: -------------------------------------------------------------------------------- 1 | #version 450 2 | #extension GL_ARB_separate_shader_objects : enable 3 | #extension GL_GOOGLE_include_directive : enable 4 | #include "scene.glsl" 5 | 6 | layout(location = 0) in vec3 direction; 7 | 8 | layout(location = 0) out vec4 f_color; 9 | 10 | void main() 11 | { 12 | f_color = vec4(sample_environment(direction), 1); 13 | } -------------------------------------------------------------------------------- /example-game/assets/skybox.vert: -------------------------------------------------------------------------------- 1 | #version 450 2 | #extension GL_ARB_separate_shader_objects : enable 3 | #extension GL_GOOGLE_include_directive : enable 4 | #include "scene.glsl" 5 | 6 | layout(location = 0) in vec3 v_position; 7 | 8 | layout(location = 0) out vec3 direction; 9 | out gl_PerVertex { vec4 gl_Position; }; 10 | 11 | void main() 12 | { 13 | direction = v_position; 14 | gl_Position = u_rotation_only_view_proj_matrix * vec4(v_position, 1); 15 | } -------------------------------------------------------------------------------- /example-game/assets/static.vert: -------------------------------------------------------------------------------- 1 | #version 450 2 | #extension GL_ARB_separate_shader_objects : enable 3 | #extension GL_GOOGLE_include_directive : enable 4 | #include "scene.glsl" 5 | 6 | layout(set=2, binding=0) uniform PerObject 7 | { 8 | mat4 u_model_matrix; 9 | }; 10 | 11 | layout(location = 0) in vec3 v_position; 12 | layout(location = 1) in vec3 v_color; 13 | layout(location = 2) in vec3 v_normal; 14 | layout(location = 3) in vec2 v_texcoord; 15 | layout(location = 4) in vec3 v_tangent; 16 | layout(location = 5) in vec3 v_bitangent; 17 | 18 | layout(location = 0) out vec3 position; 19 | layout(location = 1) out vec3 color; 20 | layout(location = 2) out vec3 normal; 21 | layout(location = 3) out vec2 texcoord; 22 | layout(location = 4) out vec3 tangent; 23 | layout(location = 5) out vec3 bitangent; 24 | out gl_PerVertex { vec4 gl_Position; }; 25 | 26 | void main() 27 | { 28 | position = (u_model_matrix * vec4(v_position, 1)).xyz; 29 | color = v_color; 30 | normal = normalize((u_model_matrix * vec4(v_normal, 0)).xyz); 31 | texcoord = v_texcoord; 32 | tangent = normalize((u_model_matrix * vec4(v_tangent, 0)).xyz); 33 | bitangent = normalize((u_model_matrix * vec4(v_bitangent, 0)).xyz); 34 | gl_Position = u_view_proj_matrix * vec4(position, 1); 35 | } -------------------------------------------------------------------------------- /example-game/example-game.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | {e78330ba-19d6-41bd-8894-f8437d0bc732} 9 | 10 | 11 | 12 | 13 | shaders 14 | 15 | 16 | shaders 17 | 18 | 19 | shaders 20 | 21 | 22 | shaders 23 | 24 | 25 | shaders 26 | 27 | 28 | shaders 29 | 30 | 31 | shaders 32 | 33 | 34 | -------------------------------------------------------------------------------- /example-pbr/assets/ATTRIBUTIONS.txt: -------------------------------------------------------------------------------- 1 | The listed files are the original work of the following authors, graciously made available under the terms of their respective licenses. Note that in some cases these files have been reduced in size or quality to save space. I strongly encourage interested parties to view the full quality files in their original locations. 2 | 3 | Assets: monument-valley.hdr, factory-catwalk.hdr, shiodome-stairs.hdr 4 | Author: Blochi 5 | Source: http://www.hdrlabs.com/sibl/archive.html 6 | License: Creative Commons Attribution-Noncommercial-Share Alike 3.0 License 7 | -------------------------------------------------------------------------------- /example-pbr/assets/factory-catwalk.hdr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgorsten/include-engine/67af882e24beba73ad44621397993e1b6818cf5b/example-pbr/assets/factory-catwalk.hdr -------------------------------------------------------------------------------- /example-pbr/assets/monument-valley.hdr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgorsten/include-engine/67af882e24beba73ad44621397993e1b6818cf5b/example-pbr/assets/monument-valley.hdr -------------------------------------------------------------------------------- /example-pbr/assets/shiodome-stairs.hdr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgorsten/include-engine/67af882e24beba73ad44621397993e1b6818cf5b/example-pbr/assets/shiodome-stairs.hdr -------------------------------------------------------------------------------- /example-pbr/example-pbr.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /example-pbr/pbr.h: -------------------------------------------------------------------------------- 1 | #ifndef PBR_H 2 | #define PBR_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include "linalg.h" 9 | using namespace linalg::aliases; 10 | 11 | #define GLEW_STATIC 12 | #include "GL/glew.h" 13 | #include "GLFW/glfw3.h" 14 | #pragma comment(lib, "opengl32.lib") 15 | 16 | extern std::string_view preamble; 17 | extern std::string_view pbr_lighting; 18 | 19 | class gl_program 20 | { 21 | GLuint program = 0; 22 | public: 23 | gl_program() = default; 24 | gl_program(std::initializer_list shader_stages); 25 | gl_program(gl_program && r) : gl_program() { *this = std::move(r); } 26 | ~gl_program(); 27 | 28 | void use() const; 29 | std::optional get_uniform_location(const char * name) const; 30 | 31 | void bind_texture(GLint location, GLuint texture) const; 32 | void bind_texture(const char * name, GLuint texture) const { if(auto loc = get_uniform_location(name)) bind_texture(*loc, texture); } 33 | 34 | void uniform(GLint location, float scalar); 35 | void uniform(GLint location, const float2 & vec); 36 | void uniform(GLint location, const float3 & vec); 37 | void uniform(GLint location, const float4 & vec); 38 | void uniform(GLint location, const float4x4 & mat); 39 | template void uniform(const char * name, const T & value) { if(auto loc = get_uniform_location(name)) uniform(*loc, value); } 40 | 41 | gl_program & operator = (gl_program && r) { std::swap(program, r.program); return *this; } 42 | }; 43 | 44 | GLuint compile_shader(GLenum type, std::initializer_list sources); 45 | 46 | class pbr_tools 47 | { 48 | mutable gl_program spheremap_skybox_prog; 49 | mutable gl_program cubemap_skybox_prog; 50 | mutable gl_program irradiance_prog; 51 | mutable gl_program reflectance_prog; 52 | mutable gl_program brdf_integration_prog; 53 | public: 54 | pbr_tools(); 55 | 56 | GLuint convert_spheremap_to_cubemap(GLenum internal_format, GLsizei width, GLuint spheremap) const; 57 | GLuint compute_irradiance_map(GLuint cubemap) const; 58 | GLuint compute_reflectance_map(GLuint cubemap) const; 59 | GLuint compute_brdf_integration_map() const; 60 | 61 | void draw_skybox(GLuint cubemap, const float4x4 & skybox_view_proj_matrix) const; 62 | }; 63 | 64 | #endif -------------------------------------------------------------------------------- /example-rts/assets/ATTRIBUTIONS.txt: -------------------------------------------------------------------------------- 1 | The listed files are the original work of the following authors, graciously made available under the terms of their respective licenses. Note that in some cases these files have been reduced in size or quality to save space. I strongly encourage interested parties to view the full quality files in their original locations. 2 | 3 | f44a.obj, f44a.jpg 4 | F-44A Rapier by Hangar.b.productions is licensed under Creative Commons Attribution 5 | https://sketchfab.com/models/802caa376536497786a8c95344da884a# 6 | 7 | cf105.obj, cf105.jpg 8 | CF-105 Scimitar by Hangar.b.productions is licensed under Creative Commons Attribution 9 | https://sketchfab.com/models/1b5e955948f94a04b0353634a0affb1a 10 | 11 | particle.png 12 | From NeHe OpenGL Tutorial 09, by Jeff Molofee 13 | http://nehe.gamedev.net/tutorial/moving_bitmaps_in_3d_space/17001/ -------------------------------------------------------------------------------- /example-rts/assets/add.frag: -------------------------------------------------------------------------------- 1 | #version 450 2 | #extension GL_ARB_separate_shader_objects : enable 3 | #extension GL_GOOGLE_include_directive : enable 4 | 5 | layout(set=0, binding=0) uniform sampler2D u_texture0; 6 | layout(set=0, binding=1) uniform sampler2D u_texture1; 7 | 8 | layout(location = 0) in vec2 texcoord; 9 | 10 | layout(location = 0) out vec4 f_color; 11 | 12 | void main() 13 | { 14 | f_color = texture(u_texture0, texcoord) + texture(u_texture1, texcoord); 15 | } -------------------------------------------------------------------------------- /example-rts/assets/cf105.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgorsten/include-engine/67af882e24beba73ad44621397993e1b6818cf5b/example-rts/assets/cf105.jpg -------------------------------------------------------------------------------- /example-rts/assets/f44a.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgorsten/include-engine/67af882e24beba73ad44621397993e1b6818cf5b/example-rts/assets/f44a.jpg -------------------------------------------------------------------------------- /example-rts/assets/glow.frag: -------------------------------------------------------------------------------- 1 | #version 450 2 | #extension GL_ARB_separate_shader_objects : enable 3 | #extension GL_GOOGLE_include_directive : enable 4 | #include "scene.glsl" 5 | 6 | layout(location = 1) in vec3 color; 7 | 8 | layout(location = 0) out vec4 f_color; 9 | 10 | void main() 11 | { 12 | f_color = vec4(color,1); 13 | } -------------------------------------------------------------------------------- /example-rts/assets/hgauss.frag: -------------------------------------------------------------------------------- 1 | #version 450 2 | #extension GL_ARB_separate_shader_objects : enable 3 | #extension GL_GOOGLE_include_directive : enable 4 | 5 | layout(set=0, binding=0) uniform sampler2D u_texture; 6 | 7 | layout(location = 0) in vec2 texcoord; 8 | 9 | layout(location = 0) out vec4 f_color; 10 | 11 | void main() 12 | { 13 | vec2 step = vec2(1.0/textureSize(u_texture,0).x,0); 14 | f_color = texture(u_texture, texcoord-step*3) * ( 1.0/64) 15 | + texture(u_texture, texcoord-step*2) * ( 6.0/64) 16 | + texture(u_texture, texcoord-step*1) * (15.0/64) 17 | + texture(u_texture, texcoord+step*0) * (20.0/64) 18 | + texture(u_texture, texcoord+step*1) * (15.0/64) 19 | + texture(u_texture, texcoord+step*2) * ( 6.0/64) 20 | + texture(u_texture, texcoord+step*3) * ( 1.0/64); 21 | } -------------------------------------------------------------------------------- /example-rts/assets/hipass.frag: -------------------------------------------------------------------------------- 1 | #version 450 2 | #extension GL_ARB_separate_shader_objects : enable 3 | #extension GL_GOOGLE_include_directive : enable 4 | 5 | layout(set=0, binding=0) uniform sampler2D u_texture; 6 | 7 | layout(location = 0) in vec2 texcoord; 8 | 9 | layout(location = 0) out vec4 f_color; 10 | 11 | void main() 12 | { 13 | f_color = max(texture(u_texture, texcoord)-1, 0); 14 | } -------------------------------------------------------------------------------- /example-rts/assets/image.frag: -------------------------------------------------------------------------------- 1 | #version 450 2 | #extension GL_ARB_separate_shader_objects : enable 3 | #extension GL_GOOGLE_include_directive : enable 4 | 5 | layout(set=0, binding=0) uniform sampler2D u_texture; 6 | 7 | layout(location = 0) in vec2 texcoord; 8 | layout(location = 1) in vec4 color; 9 | 10 | layout(location = 0) out vec4 f_color; 11 | 12 | void main() 13 | { 14 | f_color = color*vec4(1,1,1,texture(u_texture, texcoord).r); 15 | } -------------------------------------------------------------------------------- /example-rts/assets/image.vert: -------------------------------------------------------------------------------- 1 | #version 450 2 | #extension GL_ARB_separate_shader_objects : enable 3 | #extension GL_GOOGLE_include_directive : enable 4 | 5 | layout(location = 0) in vec2 v_position; 6 | layout(location = 1) in vec2 v_texcoord; 7 | layout(location = 2) in vec4 v_color; 8 | 9 | layout(location = 0) out vec2 texcoord; 10 | layout(location = 1) out vec4 color; 11 | out gl_PerVertex { vec4 gl_Position; }; 12 | 13 | void main() 14 | { 15 | gl_Position = vec4(v_position, 0, 1); 16 | texcoord = v_texcoord; 17 | color = v_color; 18 | } -------------------------------------------------------------------------------- /example-rts/assets/particle.frag: -------------------------------------------------------------------------------- 1 | #version 450 2 | #extension GL_ARB_separate_shader_objects : enable 3 | #extension GL_GOOGLE_include_directive : enable 4 | #include "scene.glsl" 5 | 6 | layout(set=2, binding=0) uniform sampler2D u_texture; 7 | 8 | layout(location = 0) in vec2 texcoord; 9 | layout(location = 1) in vec3 color; 10 | 11 | layout(location = 0) out vec4 f_color; 12 | 13 | void main() 14 | { 15 | f_color = texture(u_texture, texcoord) * vec4(color, 1); 16 | } -------------------------------------------------------------------------------- /example-rts/assets/particle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgorsten/include-engine/67af882e24beba73ad44621397993e1b6818cf5b/example-rts/assets/particle.png -------------------------------------------------------------------------------- /example-rts/assets/particle.vert: -------------------------------------------------------------------------------- 1 | #version 450 2 | #extension GL_ARB_separate_shader_objects : enable 3 | #extension GL_GOOGLE_include_directive : enable 4 | #include "scene.glsl" 5 | 6 | layout(location = 0) in vec3 v_offset; 7 | layout(location = 1) in vec2 v_texcoord; 8 | layout(location = 2) in vec3 i_position; 9 | layout(location = 3) in float i_size; 10 | layout(location = 4) in vec3 i_color; 11 | 12 | layout(location = 0) out vec2 texcoord; 13 | layout(location = 1) out vec3 color; 14 | out gl_PerVertex { vec4 gl_Position; }; 15 | 16 | void main() 17 | { 18 | vec3 position = i_position + (u_eye_x_axis*v_offset.x + u_eye_y_axis*v_offset.y)*i_size; 19 | texcoord = v_texcoord; 20 | color = i_color; 21 | gl_Position = u_view_proj_matrix * vec4(position, 1); 22 | } -------------------------------------------------------------------------------- /example-rts/assets/sample.frag: -------------------------------------------------------------------------------- 1 | #version 450 2 | #extension GL_ARB_separate_shader_objects : enable 3 | #extension GL_GOOGLE_include_directive : enable 4 | 5 | layout(set=0, binding=0) uniform sampler2D u_texture; 6 | 7 | layout(location = 0) in vec2 texcoord; 8 | 9 | layout(location = 0) out vec4 f_color; 10 | 11 | void main() 12 | { 13 | f_color = texture(u_texture, texcoord); 14 | } -------------------------------------------------------------------------------- /example-rts/assets/scene.glsl: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // Per-scene uniforms: Used to define the lighting environment in which all scene rendering occurs // 3 | ///////////////////////////////////////////////////////////////////////////////////////////////////// 4 | 5 | struct point_light 6 | { 7 | vec3 position; 8 | vec3 color; 9 | }; 10 | 11 | layout(set=0, binding=0) uniform PerScene 12 | { 13 | mat4 u_shadow_map_matrix; 14 | vec3 u_shadow_light_pos; 15 | vec3 u_ambient_light; 16 | vec3 u_light_direction; 17 | vec3 u_light_color; 18 | point_light u_point_lights[64]; 19 | int u_num_point_lights; 20 | }; 21 | layout(set=0, binding=1) uniform sampler2DShadow u_shadow_map; 22 | 23 | //////////////////////////////////////////////////////////////////////////// 24 | // Per-view uniforms: Used to define the world-to-viewport transformation // 25 | //////////////////////////////////////////////////////////////////////////// 26 | 27 | layout(set=1, binding=0) uniform PerView 28 | { 29 | mat4 u_view_proj_matrix; 30 | vec3 u_eye_position; 31 | vec3 u_eye_x_axis; 32 | vec3 u_eye_y_axis; 33 | }; -------------------------------------------------------------------------------- /example-rts/assets/shader.frag: -------------------------------------------------------------------------------- 1 | #version 450 2 | #extension GL_ARB_separate_shader_objects : enable 3 | #extension GL_GOOGLE_include_directive : enable 4 | #include "scene.glsl" 5 | 6 | layout(set=2, binding=0) uniform PerObject 7 | { 8 | mat4 u_model_matrix; 9 | vec3 u_emissive_mtl; 10 | }; 11 | layout(set=2, binding=1) uniform sampler2D u_albedo; 12 | 13 | layout(location = 0) in vec3 position; 14 | layout(location = 1) in vec3 color; 15 | layout(location = 2) in vec3 normal; 16 | layout(location = 3) in vec2 texcoord; 17 | layout(location = 4) in vec3 tangent; 18 | layout(location = 5) in vec3 bitangent; 19 | 20 | layout(location = 0) out vec4 f_color; 21 | 22 | void main() 23 | { 24 | vec3 eye_vec = normalize(u_eye_position - position); 25 | vec3 albedo = texture(u_albedo, texcoord).rgb * color; 26 | vec3 normal_vec = normalize(normal); 27 | 28 | vec3 light = u_ambient_light + u_emissive_mtl; 29 | 30 | // directional light (using shadow map) 31 | { 32 | float lit = textureProj(u_shadow_map, u_shadow_map_matrix * vec4(position, 1)).r; 33 | vec3 light_vec = normalize(u_shadow_light_pos - position); //u_light_direction; 34 | float diffuse = max(dot(normal_vec, light_vec), 0) * lit; 35 | light += albedo * u_light_color * diffuse; 36 | } 37 | 38 | for(int i=0; i 2 | 3 | 4 | 5 | {f92d6ba4-fdff-4171-bb8e-2635778959a0} 6 | 7 | 8 | {9d175d6f-ca37-43c0-a2b8-d3908f41be17} 9 | 10 | 11 | {c778ee4b-8956-46a6-90ab-2f1cd758b5fa} 12 | 13 | 14 | 15 | 16 | shaders\scene 17 | 18 | 19 | shaders\post 20 | 21 | 22 | shaders\post 23 | 24 | 25 | shaders\post 26 | 27 | 28 | shaders\post 29 | 30 | 31 | shaders\post 32 | 33 | 34 | shaders\scene 35 | 36 | 37 | shaders\scene 38 | 39 | 40 | shaders\scene 41 | 42 | 43 | shaders\scene 44 | 45 | 46 | shaders\scene 47 | 48 | 49 | shaders\post 50 | 51 | 52 | shaders\post 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /example-rts/rts-game.h: -------------------------------------------------------------------------------- 1 | #ifndef RTS_GAME_H 2 | #define RTS_GAME_H 3 | 4 | #include "renderer.h" 5 | #include 6 | 7 | namespace game 8 | { 9 | constexpr coord_system coords {coord_axis::east, coord_axis::north, coord_axis::up}; 10 | constexpr float3 team_colors[] {{0.5f,0.5f,0.0f}, {0.2f,0.2f,1.0f}}; 11 | 12 | struct unit 13 | { 14 | int owner; 15 | int hp; 16 | float2 position; 17 | float2 direction; 18 | float cooldown; 19 | 20 | float3 get_position() const { return {position,0.5f}; } 21 | float3 get_direction() const { return {direction,0}; } 22 | quatf get_orientation() const { return rotation_quat(coords.get_axis(coord_axis::north), get_direction()); } 23 | float_pose get_pose() const { return {get_orientation(), get_position()}; } 24 | float4x4 get_model_matrix() const { return pose_matrix(get_pose()); } 25 | }; 26 | 27 | struct bullet 28 | { 29 | int owner; 30 | float2 position; 31 | float2 target; 32 | 33 | float3 get_position() const { return {position,0.75f}; } 34 | float3 get_direction() const { return {normalize(target-position),0}; } 35 | quatf get_orientation() const { return rotation_quat(coords.get_axis(coord_axis::north), get_direction()); } 36 | float_pose get_pose() const { return {get_orientation(), get_position()}; } 37 | float4x4 get_model_matrix() const { return pose_matrix(get_pose()); } 38 | }; 39 | 40 | struct particle 41 | { 42 | float3 position, velocity, color; 43 | float life; 44 | }; 45 | 46 | struct flash 47 | { 48 | float3 position; 49 | float3 color; 50 | float life; 51 | }; 52 | 53 | struct state 54 | { 55 | std::mt19937 rng; 56 | std::vector units; 57 | std::vector bullets; 58 | std::vector particles; 59 | std::vector flashes; 60 | 61 | state(); 62 | void advance(float timestep); 63 | }; 64 | 65 | // Immutable GPU resources used during rendering 66 | struct resources 67 | { 68 | std::shared_ptr standard_mtl; 69 | std::shared_ptr glow_mtl; 70 | std::shared_ptr particle_mtl; 71 | std::shared_ptr terrain_mesh; 72 | std::shared_ptr unit0_mesh; 73 | std::shared_ptr unit1_mesh; 74 | std::shared_ptr bullet_mesh; 75 | std::shared_ptr particle_mesh; 76 | std::shared_ptr terrain_tex; 77 | std::shared_ptr unit0_tex; 78 | std::shared_ptr unit1_tex; 79 | std::shared_ptr bullet_tex; 80 | std::shared_ptr particle_tex; 81 | std::shared_ptr linear_sampler; 82 | 83 | resources(renderer & r, std::shared_ptr contract); 84 | }; 85 | 86 | // Uniforms which are constant for the entire scene 87 | struct point_light 88 | { 89 | alignas(16) float3 u_position; 90 | alignas(16) float3 u_color; 91 | }; 92 | 93 | struct per_scene_uniforms 94 | { 95 | alignas(16) float4x4 shadow_map_matrix; 96 | alignas(16) float3 shadow_light_pos; 97 | alignas(16) float3 ambient_light; 98 | alignas(16) float3 light_direction; 99 | alignas(16) float3 light_color; 100 | alignas(16) point_light u_point_lights[64]; 101 | alignas(16) int u_num_point_lights; 102 | }; 103 | 104 | // Uniforms which are constant within a single viewport 105 | struct per_view_uniforms 106 | { 107 | alignas(16) float4x4 view_proj_matrix; 108 | alignas(16) float3 eye_position; 109 | alignas(16) float3 eye_x_axis; 110 | alignas(16) float3 eye_y_axis; 111 | }; 112 | 113 | // Uniforms which are constant within a single draw call 114 | struct per_static_object 115 | { 116 | alignas(16) float4x4 model_matrix; 117 | alignas(16) float3 emissive_mtl; 118 | }; 119 | 120 | void draw(draw_list & list, per_scene_uniforms & ps, const resources & r, const state & s); 121 | } 122 | 123 | #endif -------------------------------------------------------------------------------- /include-engine-tests/include-engine-tests.cpp: -------------------------------------------------------------------------------- 1 | #include "linalg.h" 2 | using namespace linalg::aliases; 3 | 4 | #define CATCH_CONFIG_MAIN 5 | #include "catch.hpp" 6 | 7 | template void require_approx_equal(const linalg::vec & a, const linalg::vec & b) 8 | { 9 | REQUIRE(a.x == Approx(b.x)); 10 | REQUIRE(a.y == Approx(b.y)); 11 | REQUIRE(a.z == Approx(b.z)); 12 | } 13 | /* 14 | template void test_transform(const Transform & t, bool is_rigid, bool is_scale_preserving) 15 | { 16 | // Start by transforming three points using the supplied transformation 17 | const float3 p0 {1,2,3}, p1 {4,-5,2}, p2 {-3,1,-4}; 18 | const float3 pp0 = transform_point(t, p0); 19 | const float3 pp1 = transform_point(t, p1); 20 | const float3 pp2 = transform_point(t, p2); 21 | 22 | // Test transform_vector(...) 23 | const float3 e1 = p1 - p0, e2 = p2 - p0, n = normalize(cross(e1, e2)); 24 | const float3 ee1 = pp1 - pp0, ee2 = pp2 - pp0, nn = normalize(cross(ee1, ee2)); 25 | require_approx_equal(transform_vector(t, e1), ee1); 26 | require_approx_equal(transform_vector(t, e2), ee2); 27 | 28 | // Test transform_tangent(...) 29 | require_approx_equal(transform_tangent(t, normalize(e1)), normalize(ee1)); 30 | require_approx_equal(transform_tangent(t, normalize(e2)), normalize(ee2)); 31 | 32 | // Test transform_normal(...) 33 | require_approx_equal(transform_normal(t, n), nn); 34 | 35 | if(is_rigid) 36 | { 37 | // Test transform_quat(...) 38 | const quatf q = rotation_quat(float3{0,0,1}, 1.0f); 39 | const quatf qq = transform_quat(t, q); 40 | require_approx_equal(qrot(qq, ee1), transform_vector(t, qrot(q, e1))); 41 | require_approx_equal(qrot(qq, ee2), transform_vector(t, qrot(q, e2))); 42 | 43 | // Test transform_matrix(...) 44 | const float4x4 m {{1,0,0,0},{0,0,1,0},{0,1,0,0},{0,0,0,1}}; 45 | const float4x4 mm = transform_matrix(t, m); 46 | require_approx_equal(transform_vector(mm, ee1), transform_vector(t, transform_vector(m, e1))); 47 | require_approx_equal(transform_vector(mm, ee2), transform_vector(t, transform_vector(m, e2))); 48 | } 49 | 50 | if(is_scale_preserving) 51 | { 52 | // Test transform_scaling(...) 53 | const float3 s {1,1,2}; 54 | const float3 ss = transform_scaling(t, s); 55 | require_approx_equal(ss * ee1, transform_vector(t, s * e1)); 56 | require_approx_equal(ss * ee2, transform_vector(t, s * e2)); 57 | } 58 | } 59 | 60 | TEST_CASE("transform functions", "[transform]") 61 | { 62 | // Test a transform which apply non-uniform scales in one axis 63 | test_transform(float3x3{{1,0,0},{0,2,0},{0,0,1}}, false, false); 64 | test_transform(float3x3{{2,0,0},{0,3,0},{0,0,4}}, false, false); 65 | test_transform(float4x4{{-5,0,0,0},{0,1,0,0},{0,0,1,0},{0,0,0,1}}, false, false); 66 | 67 | // Test rigid transforms 68 | test_transform(rotation_matrix(normalize(quatf{1,2,3,4})) * translation_matrix(float3{2,5,3}), true, false); 69 | test_transform(float_pose{normalize(quatf{8,0,0,6}), {1,2,3}}, true, false); 70 | test_transform(float_pose{normalize(quatf{3,1,4,2}), {4,1,2}}, true, false); 71 | 72 | // Test transform which rearranges axes, some of which involve a handedness transform 73 | test_transform(float3x3{{1,0,0},{0,0,-1},{0,1,0}}, true, true); // rotation 74 | test_transform(float3x3{{1,0,0},{0,0,1},{0,1,0}}, true, true); // mirror 75 | test_transform(float4x4{{0,0,1,0},{0,1,0,0},{-1,0,0,0},{0,0,0,1}}, true, true); // rotation 76 | test_transform(float4x4{{0,1,0,0},{0,0,1,0},{1,0,0,0},{0,0,0,1}}, true, true); // rotation 77 | test_transform(float4x4{{-1,0,0,0},{0,1,0,0},{0,0,1,0},{0,0,0,1}}, true, true); // mirror 78 | } 79 | */ -------------------------------------------------------------------------------- /include-engine-tests/include-engine-tests.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /include-engine/data-types.cpp: -------------------------------------------------------------------------------- 1 | #include "data-types.h" 2 | #include 3 | 4 | size_t compute_image_size(int2 dims, VkFormat format) 5 | { 6 | if(format <= VK_FORMAT_UNDEFINED) throw std::logic_error("unknown format"); 7 | if(format <= VK_FORMAT_R4G4_UNORM_PACK8) return product(dims)*1; 8 | if(format <= VK_FORMAT_A1R5G5B5_UNORM_PACK16) return product(dims)*2; 9 | if(format <= VK_FORMAT_R8_SRGB) return product(dims)*1; 10 | if(format <= VK_FORMAT_R8G8_SRGB) return product(dims)*2; 11 | if(format <= VK_FORMAT_B8G8R8_SRGB) return product(dims)*3; 12 | if(format <= VK_FORMAT_A2B10G10R10_SINT_PACK32) return product(dims)*4; 13 | if(format <= VK_FORMAT_R16_SFLOAT) return product(dims)*2; 14 | if(format <= VK_FORMAT_R16G16_SFLOAT) return product(dims)*4; 15 | if(format <= VK_FORMAT_R16G16B16_SFLOAT) return product(dims)*6; 16 | if(format <= VK_FORMAT_R16G16B16A16_SFLOAT) return product(dims)*8; 17 | if(format <= VK_FORMAT_R32_SFLOAT) return product(dims)*4; 18 | if(format <= VK_FORMAT_R32G32_SFLOAT) return product(dims)*8; 19 | if(format <= VK_FORMAT_R32G32B32_SFLOAT) return product(dims)*12; 20 | if(format <= VK_FORMAT_R32G32B32A32_SFLOAT) return product(dims)*16; 21 | if(format <= VK_FORMAT_E5B9G9R9_UFLOAT_PACK32) return product(dims)*4; 22 | throw std::logic_error("unknown format"); 23 | } 24 | 25 | image::image(int2 dims, VkFormat format) : dims{dims}, format{format} 26 | { 27 | auto p = std::malloc(compute_image_size(dims,format)); 28 | if(!p) throw std::bad_alloc(); 29 | pixels.reset(reinterpret_cast(p)); 30 | } 31 | 32 | image::image(int2 dims, VkFormat format, std::unique_ptr pixels) : dims{dims}, format{format}, pixels{move(pixels)} 33 | { 34 | 35 | } -------------------------------------------------------------------------------- /include-engine/fbx.h: -------------------------------------------------------------------------------- 1 | #ifndef FBX_H 2 | #define FBX_H 3 | 4 | #include "data-types.h" 5 | 6 | namespace fbx 7 | { 8 | // Abstract syntax tree of an FBX file, maps to both binary and textual representations 9 | namespace ast 10 | { 11 | struct boolean 12 | { 13 | uint8_t byte; 14 | explicit operator bool() const { return static_cast(byte & 1); } 15 | }; 16 | 17 | using property_variant = std::variant 18 | < 19 | boolean, // type 'C' 20 | int16_t, // type 'Y' 21 | int32_t, // type 'I' 22 | int64_t, // type 'L' 23 | float, // type 'F' 24 | double, // type 'D' 25 | std::vector, // type 'b' 26 | std::vector, // type 'y' 27 | std::vector, // type 'i' 28 | std::vector, // type 'l' 29 | std::vector, // type 'f' 30 | std::vector, // type 'd' 31 | std::string, // type 'S' 32 | std::vector // type 'R' 33 | >; 34 | 35 | class property 36 | { 37 | property_variant contents; 38 | 39 | struct size_visitor 40 | { 41 | template size_t operator() (const std::vector & v) { return v.size(); } 42 | size_t operator() (...) { return 1; } 43 | }; 44 | 45 | template struct element_visitor 46 | { 47 | size_t index; 48 | template U operator() (const std::vector & v) { return operator()(v[index]); } 49 | template U operator() (const T & n) { return static_cast(n); } 50 | U operator() (const std::string & s) { return {}; } 51 | U operator() (const boolean & b) { return b ? U{1} : U{0}; } 52 | }; 53 | public: 54 | property(property_variant && contents) : contents{move(contents)} {} 55 | 56 | size_t size() const { return std::visit(size_visitor{}, contents); } 57 | template U get(size_t i=0) const { return std::visit(element_visitor{i}, contents); } 58 | const std::string & get_string() const { return std::get(contents); } 59 | void print(std::ostream & out) const; 60 | }; 61 | 62 | struct node 63 | { 64 | std::string name; 65 | std::vector properties; 66 | std::vector children; 67 | }; 68 | 69 | struct document 70 | { 71 | uint32_t version; 72 | std::vector nodes; 73 | }; 74 | 75 | document load(std::istream & in); 76 | } 77 | 78 | ///////////////////// 79 | // FBX Scene Graph // 80 | ///////////////////// 81 | 82 | std::vector load_meshes(const ast::document & doc); 83 | } 84 | 85 | std::ostream & operator << (std::ostream & out, const fbx::ast::boolean & b); 86 | std::ostream & operator << (std::ostream & out, const fbx::ast::property & p); 87 | std::ostream & operator << (std::ostream & out, const fbx::ast::node & n); 88 | 89 | #endif 90 | -------------------------------------------------------------------------------- /include-engine/include-engine.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /include-engine/load.h: -------------------------------------------------------------------------------- 1 | #ifndef LOAD_H 2 | #define LOAD_H 3 | 4 | #include "data-types.h" 5 | 6 | std::vector load_binary_file(const char * filename); 7 | std::vector load_text_file(const char * filename); 8 | 9 | image generate_single_color_image(const byte4 & color); 10 | image load_image(const char * filename, bool is_linear); 11 | 12 | mesh generate_fullscreen_quad(); 13 | mesh generate_box_mesh(const float3 & bmin, const float3 & bmax); 14 | mesh apply_vertex_color(mesh m, const float3 & color); 15 | mesh invert_faces(mesh m); 16 | std::vector load_meshes_from_fbx(coord_system target, const char * filename); 17 | mesh load_mesh_from_obj(coord_system target, const char * filename); 18 | shader_info load_shader_info_from_spirv(array_view words); 19 | 20 | class shader_compiler 21 | { 22 | std::unique_ptr impl; 23 | public: 24 | shader_compiler(); 25 | ~shader_compiler(); 26 | 27 | std::vector compile_glsl(VkShaderStageFlagBits stage, const char * filename); 28 | }; 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /include-engine/sprite.h: -------------------------------------------------------------------------------- 1 | #ifndef SPRITE_H 2 | #define SPRITE_H 3 | 4 | #include "renderer.h" 5 | 6 | struct rect 7 | { 8 | int x0, y0, x1, y1; 9 | 10 | int width() const { return x1 - x0; } 11 | int height() const { return y1 - y0; } 12 | int2 dims() const { return {width(), height()}; } 13 | float aspect_ratio() const { return (float)width()/height(); } 14 | 15 | rect adjusted(int dx0, int dy0, int dx1, int dy1) const { return {x0+dx0, y0+dy0, x1+dx1, y1+dy1}; } 16 | 17 | rect take_x0(int x) { rect r {x0, y0, x0+x, y1}; x0 = r.x1; return r; } 18 | rect take_x1(int x) { rect r {x1-x, y0, x1, y1}; x1 = r.x0; return r; } 19 | rect take_y0(int y) { rect r {x0, y0, x1, y0+y}; y0 = r.y1; return r; } 20 | rect take_y1(int y) { rect r {x0, y1-y, x1, y1}; y1 = r.y0; return r; } 21 | }; 22 | 23 | // sprite_sheet is a simple class which packs a collection of 2D images into a single atlas texture 24 | struct sprite 25 | { 26 | image img; // The contents of the sprite 27 | int border; // Number of pixels from the edge of the image which are not considered part of the sprite (but should be copied to the atlas anyway) 28 | float s0, t0, s1, t1; // The subrect of this sprite within the texture atlas 29 | }; 30 | struct sprite_sheet 31 | { 32 | image sheet; 33 | std::shared_ptr texture; 34 | std::vector sprites; 35 | 36 | size_t add_sprite(image img, int border); 37 | void prepare_sheet(); 38 | }; 39 | 40 | // font_face rasterizes a collection of text glyphs into a sprite_sheet 41 | struct glyph_info 42 | { 43 | size_t sprite_index; 44 | int2 offset; 45 | int advance; 46 | }; 47 | struct font_face 48 | { 49 | sprite_sheet & sheet; 50 | std::map glyphs; 51 | 52 | font_face(sprite_sheet & sheet, const char * filepath, float pixel_height); 53 | }; 54 | 55 | // gui_sprites rasterizes a collection of useful shapes into a sprite_sheet 56 | struct gui_sprites 57 | { 58 | sprite_sheet & sheet; 59 | size_t solid_pixel; 60 | std::map corner_sprites; 61 | 62 | gui_sprites(sprite_sheet & sheet); 63 | }; 64 | 65 | struct image_vertex { float2 position, texcoord; float4 color; }; 66 | struct gui_context 67 | { 68 | gui_sprites & sprites; 69 | draw_list & list; 70 | uint2 dims; 71 | uint32_t num_quads; 72 | 73 | gui_context(gui_sprites & sprites, draw_list & list, const uint2 & dims); 74 | 75 | void begin_frame(); 76 | 77 | void draw_sprite_sheet(const int2 & p); 78 | void draw_sprite(const rect & r, float s0, float t0, float s1, float t1, const float4 & color); 79 | 80 | void draw_rect(const rect & r, const float4 & color); 81 | void draw_rounded_rect(rect r, int radius, const float4 & color); 82 | void draw_partial_rounded_rect(rect r, int radius, const float4 & color, bool tl, bool tr, bool bl, bool br); 83 | 84 | void draw_text(const font_face & font, const float4 & color, int x, int y, std::string_view text); 85 | void draw_shadowed_text(const font_face & font, const float4 & color, int x, int y, std::string_view text); 86 | void end_frame(const scene_material & mtl, const sampler & samp); 87 | }; 88 | 89 | #endif 90 | -------------------------------------------------------------------------------- /include-engine/utility.cpp: -------------------------------------------------------------------------------- 1 | #include "utility.h" 2 | 3 | ///////////////// 4 | // fail_fast() // 5 | ///////////////// 6 | 7 | #include 8 | #include 9 | 10 | void fail_fast() 11 | { 12 | if(IsDebuggerPresent()) DebugBreak(); 13 | std::cerr << "fail_fast() called." << std::endl; 14 | std::exit(EXIT_FAILURE); 15 | } -------------------------------------------------------------------------------- /include-engine/utility.h: -------------------------------------------------------------------------------- 1 | #ifndef UTILITY_H 2 | #define UTILITY_H 3 | 4 | [[noreturn]] void fail_fast(); 5 | 6 | template struct narrower 7 | { 8 | const T & value; 9 | operator T () const { return value; } 10 | template operator U () const 11 | { 12 | U narrowed_value = static_cast(value); 13 | if(value != narrowed_value) fail_fast(); 14 | return narrowed_value; 15 | } 16 | }; 17 | template narrower narrow(const T & value) 18 | { 19 | return {value}; 20 | } 21 | 22 | #endif 23 | --------------------------------------------------------------------------------