1
0
mirror of https://github.com/libretro/RetroArch synced 2024-07-08 12:15:49 +00:00

Merge commit '9ae607553558a37047b4ce50b5aca91908ad9c4e' as 'deps/SPIRV-Cross'

This commit is contained in:
Brad Parker 2016-12-20 13:17:07 -05:00
commit 88f915dadd
221 changed files with 25271 additions and 0 deletions

167
deps/SPIRV-Cross/.clang-format vendored Executable file
View File

@ -0,0 +1,167 @@
# The style used for all options not specifically set in the configuration.
BasedOnStyle: LLVM
# The extra indent or outdent of access modifiers, e.g. public:.
AccessModifierOffset: -4
# If true, aligns escaped newlines as far left as possible. Otherwise puts them into the right-most column.
AlignEscapedNewlinesLeft: true
# If true, aligns trailing comments.
AlignTrailingComments: false
# Allow putting all parameters of a function declaration onto the next line even if BinPackParameters is false.
AllowAllParametersOfDeclarationOnNextLine: false
# Allows contracting simple braced statements to a single line.
AllowShortBlocksOnASingleLine: false
# If true, short case labels will be contracted to a single line.
AllowShortCaseLabelsOnASingleLine: false
# Dependent on the value, int f() { return 0; } can be put on a single line. Possible values: None, Inline, All.
AllowShortFunctionsOnASingleLine: None
# If true, if (a) return; can be put on a single line.
AllowShortIfStatementsOnASingleLine: false
# If true, while (true) continue; can be put on a single line.
AllowShortLoopsOnASingleLine: false
# If true, always break after function definition return types.
AlwaysBreakAfterDefinitionReturnType: false
# If true, always break before multiline string literals.
AlwaysBreakBeforeMultilineStrings: false
# If true, always break after the template<...> of a template declaration.
AlwaysBreakTemplateDeclarations: true
# If false, a function call's arguments will either be all on the same line or will have one line each.
BinPackArguments: true
# If false, a function declaration's or function definition's parameters will either all be on the same line
# or will have one line each.
BinPackParameters: true
# The way to wrap binary operators. Possible values: None, NonAssignment, All.
BreakBeforeBinaryOperators: None
# The brace breaking style to use. Possible values: Attach, Linux, Stroustrup, Allman, GNU.
BreakBeforeBraces: Allman
# If true, ternary operators will be placed after line breaks.
BreakBeforeTernaryOperators: false
# Always break constructor initializers before commas and align the commas with the colon.
BreakConstructorInitializersBeforeComma: true
# The column limit. A column limit of 0 means that there is no column limit.
ColumnLimit: 120
# A regular expression that describes comments with special meaning, which should not be split into lines or otherwise changed.
CommentPragmas: '^ *'
# If the constructor initializers don't fit on a line, put each initializer on its own line.
ConstructorInitializerAllOnOneLineOrOnePerLine: false
# The number of characters to use for indentation of constructor initializer lists.
ConstructorInitializerIndentWidth: 4
# Indent width for line continuations.
ContinuationIndentWidth: 4
# If true, format braced lists as best suited for C++11 braced lists.
Cpp11BracedListStyle: false
# Disables formatting at all.
DisableFormat: false
# A vector of macros that should be interpreted as foreach loops instead of as function calls.
#ForEachMacros: ''
# Indent case labels one level from the switch statement.
# When false, use the same indentation level as for the switch statement.
# Switch statement body is always indented one level more than case labels.
IndentCaseLabels: false
# The number of columns to use for indentation.
IndentWidth: 4
# Indent if a function definition or declaration is wrapped after the type.
IndentWrappedFunctionNames: false
# If true, empty lines at the start of blocks are kept.
KeepEmptyLinesAtTheStartOfBlocks: true
# Language, this format style is targeted at. Possible values: None, Cpp, Java, JavaScript, Proto.
Language: Cpp
# The maximum number of consecutive empty lines to keep.
MaxEmptyLinesToKeep: 1
# The indentation used for namespaces. Possible values: None, Inner, All.
NamespaceIndentation: None
# The penalty for breaking a function call after "call(".
PenaltyBreakBeforeFirstCallParameter: 19
# The penalty for each line break introduced inside a comment.
PenaltyBreakComment: 300
# The penalty for breaking before the first <<.
PenaltyBreakFirstLessLess: 120
# The penalty for each line break introduced inside a string literal.
PenaltyBreakString: 1000
# The penalty for each character outside of the column limit.
PenaltyExcessCharacter: 1000000
# Penalty for putting the return type of a function onto its own line.
PenaltyReturnTypeOnItsOwnLine: 1000000000
# Pointer and reference alignment style. Possible values: Left, Right, Middle.
PointerAlignment: Right
# If true, a space may be inserted after C style casts.
SpaceAfterCStyleCast: false
# If false, spaces will be removed before assignment operators.
SpaceBeforeAssignmentOperators: true
# Defines in which cases to put a space before opening parentheses. Possible values: Never, ControlStatements, Always.
SpaceBeforeParens: ControlStatements
# If true, spaces may be inserted into '()'.
SpaceInEmptyParentheses: false
# The number of spaces before trailing line comments (// - comments).
SpacesBeforeTrailingComments: 1
# If true, spaces will be inserted after '<' and before '>' in template argument lists.
SpacesInAngles: false
# If true, spaces may be inserted into C style casts.
SpacesInCStyleCastParentheses: false
# If true, spaces are inserted inside container literals (e.g. ObjC and Javascript array and dict literals).
SpacesInContainerLiterals: false
# If true, spaces will be inserted after '(' and before ')'.
SpacesInParentheses: false
# If true, spaces will be inserted after '[' and befor']'.
SpacesInSquareBrackets: false
# Format compatible with this standard, e.g. use A<A<int> > instead of A<A<int>> for LS_Cpp03. Possible values: Cpp03, Cpp11, Auto.
Standard: Cpp11
# The number of columns used for tab stops.
TabWidth: 4
# The way to use tab characters in the resulting file. Possible values: Never, ForIndentation, Always.
UseTab: ForIndentation
# Do not reflow comments
ReflowComments: false

17
deps/SPIRV-Cross/.gitignore vendored Normal file
View File

@ -0,0 +1,17 @@
*.o
*.d
*.txt
/test
/spirv-cross
*.spv
/obj
/msvc/x64
/msvc/Debug
/msvc/Release
*.suo
*.sdf
*.opensdf
*.shader
*.a
!CMakeLists.txt

26
deps/SPIRV-Cross/.travis.yml vendored Normal file
View File

@ -0,0 +1,26 @@
language: cpp
os:
- linux
- osx
# Use Ubuntu 14.04 LTS (Trusty) as the Linux testing environment.
sudo: required
dist: trusty
# We check out glslang at a specific revision to avoid test output mismatches
env:
- GLSLANG_REV=b56f4ac72c57f5c50f14ddb0bf1f78eaaef21c2b
before_script:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install python3; fi
- git clone https://github.com/KhronosGroup/glslang.git glslang
- git clone https://github.com/KhronosGroup/SPIRV-Tools SPIRV-Tools
- git clone https://github.com/KhronosGroup/SPIRV-Headers.git SPIRV-Tools/external/spirv-headers
script:
- git -C glslang checkout $GLSLANG_REV
- cd glslang && cmake . && make -j2 && cd ..
- cd SPIRV-Tools && cmake . && make -j2 && cd ..
- make -j2
- PATH=./glslang/StandAlone:./SPIRV-Tools/tools:$PATH
- ./test_shaders.py shaders

98
deps/SPIRV-Cross/CMakeLists.txt vendored Normal file
View File

@ -0,0 +1,98 @@
# Copyright 2016 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
cmake_minimum_required(VERSION 2.8)
project(SPIRV-Cross)
enable_testing()
option(SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS "Instead of throwing exceptions assert" OFF)
if(${CMAKE_GENERATOR} MATCHES "Makefile")
if(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
message(FATAL_ERROR "Build out of tree to avoid overwriting Makefile")
endif()
endif()
add_library(spirv-cross-core STATIC
${CMAKE_CURRENT_SOURCE_DIR}/GLSL.std.450.h
${CMAKE_CURRENT_SOURCE_DIR}/spirv_common.hpp
${CMAKE_CURRENT_SOURCE_DIR}/spirv.hpp
${CMAKE_CURRENT_SOURCE_DIR}/spirv_cross.hpp
${CMAKE_CURRENT_SOURCE_DIR}/spirv_cross.cpp
${CMAKE_CURRENT_SOURCE_DIR}/spirv_cfg.hpp
${CMAKE_CURRENT_SOURCE_DIR}/spirv_cfg.cpp)
add_library(spirv-cross-glsl STATIC
${CMAKE_CURRENT_SOURCE_DIR}/spirv_glsl.cpp
${CMAKE_CURRENT_SOURCE_DIR}/spirv_glsl.hpp)
add_library(spirv-cross-cpp STATIC
${CMAKE_CURRENT_SOURCE_DIR}/spirv_cpp.hpp
${CMAKE_CURRENT_SOURCE_DIR}/spirv_cpp.cpp)
add_library(spirv-cross-msl STATIC
${CMAKE_CURRENT_SOURCE_DIR}/spirv_msl.hpp
${CMAKE_CURRENT_SOURCE_DIR}/spirv_msl.cpp)
add_executable(spirv-cross main.cpp)
target_link_libraries(spirv-cross spirv-cross-glsl spirv-cross-cpp spirv-cross-msl spirv-cross-core)
target_link_libraries(spirv-cross-glsl spirv-cross-core)
target_link_libraries(spirv-cross-msl spirv-cross-glsl)
target_link_libraries(spirv-cross-cpp spirv-cross-glsl)
target_include_directories(spirv-cross-core PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
set(spirv-compiler-options "")
set(spirv-compiler-defines "")
if(SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS)
set(spirv-compiler-defines ${spirv-compiler-defines} SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS)
endif()
# To specify special debug or optimization options, use
# -DCMAKE_CXX_COMPILE_FLAGS
# However, we require the C++11 dialect.
if (NOT "${MSVC}")
set(spirv-compiler-options ${spirv-compiler-options} -std=c++11 -Wall -Wextra -Werror -Wshadow)
set(spirv-compiler-defines ${spirv-compiler-defines} __STDC_LIMIT_MACROS)
if(SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS)
set(spirv-compiler-options ${spirv-compiler-options} -fno-exceptions)
endif()
endif()
target_compile_options(spirv-cross-core PRIVATE ${spirv-compiler-options})
target_compile_options(spirv-cross-glsl PRIVATE ${spirv-compiler-options})
target_compile_options(spirv-cross-msl PRIVATE ${spirv-compiler-options})
target_compile_options(spirv-cross-cpp PRIVATE ${spirv-compiler-options})
target_compile_options(spirv-cross PRIVATE ${spirv-compiler-options})
target_compile_definitions(spirv-cross-core PRIVATE ${spirv-compiler-defines})
target_compile_definitions(spirv-cross-glsl PRIVATE ${spirv-compiler-defines})
target_compile_definitions(spirv-cross-msl PRIVATE ${spirv-compiler-defines})
target_compile_definitions(spirv-cross-cpp PRIVATE ${spirv-compiler-defines})
target_compile_definitions(spirv-cross PRIVATE ${spirv-compiler-defines})
# Set up tests, using only the simplest modes of the test_shaders
# script. You have to invoke the script manually to:
# - Update the reference files
# - Get cycle counts from malisc
# - Keep failing outputs
find_package(PythonInterp)
if(${PYTHONINTERP_FOUND} AND ${PYTHON_VERSION_MAJOR} GREATER 2)
add_test(NAME spirv-cross-test
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_shaders.py
${CMAKE_CURRENT_SOURCE_DIR}/shaders)
else()
message(WARNING "Testing disabled. Could not find python3. If you have python3 installed try running "
"cmake with -DPYTHON_EXECUTABLE:FILEPATH=/path/to/python3 to help it find the executable")
endif()

131
deps/SPIRV-Cross/GLSL.std.450.h vendored Normal file
View File

@ -0,0 +1,131 @@
/*
** Copyright (c) 2014-2016 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a copy
** of this software and/or associated documentation files (the "Materials"),
** to deal in the Materials without restriction, including without limitation
** the rights to use, copy, modify, merge, publish, distribute, sublicense,
** and/or sell copies of the Materials, and to permit persons to whom the
** Materials are furnished to do so, subject to the following conditions:
**
** The above copyright notice and this permission notice shall be included in
** all copies or substantial portions of the Materials.
**
** MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS KHRONOS
** STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS SPECIFICATIONS AND
** HEADER INFORMATION ARE LOCATED AT https://www.khronos.org/registry/
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
** OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
** THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
** FROM,OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS
** IN THE MATERIALS.
*/
#ifndef GLSLstd450_H
#define GLSLstd450_H
static const int GLSLstd450Version = 100;
static const int GLSLstd450Revision = 3;
enum GLSLstd450 {
GLSLstd450Bad = 0, // Don't use
GLSLstd450Round = 1,
GLSLstd450RoundEven = 2,
GLSLstd450Trunc = 3,
GLSLstd450FAbs = 4,
GLSLstd450SAbs = 5,
GLSLstd450FSign = 6,
GLSLstd450SSign = 7,
GLSLstd450Floor = 8,
GLSLstd450Ceil = 9,
GLSLstd450Fract = 10,
GLSLstd450Radians = 11,
GLSLstd450Degrees = 12,
GLSLstd450Sin = 13,
GLSLstd450Cos = 14,
GLSLstd450Tan = 15,
GLSLstd450Asin = 16,
GLSLstd450Acos = 17,
GLSLstd450Atan = 18,
GLSLstd450Sinh = 19,
GLSLstd450Cosh = 20,
GLSLstd450Tanh = 21,
GLSLstd450Asinh = 22,
GLSLstd450Acosh = 23,
GLSLstd450Atanh = 24,
GLSLstd450Atan2 = 25,
GLSLstd450Pow = 26,
GLSLstd450Exp = 27,
GLSLstd450Log = 28,
GLSLstd450Exp2 = 29,
GLSLstd450Log2 = 30,
GLSLstd450Sqrt = 31,
GLSLstd450InverseSqrt = 32,
GLSLstd450Determinant = 33,
GLSLstd450MatrixInverse = 34,
GLSLstd450Modf = 35, // second operand needs an OpVariable to write to
GLSLstd450ModfStruct = 36, // no OpVariable operand
GLSLstd450FMin = 37,
GLSLstd450UMin = 38,
GLSLstd450SMin = 39,
GLSLstd450FMax = 40,
GLSLstd450UMax = 41,
GLSLstd450SMax = 42,
GLSLstd450FClamp = 43,
GLSLstd450UClamp = 44,
GLSLstd450SClamp = 45,
GLSLstd450FMix = 46,
GLSLstd450IMix = 47, // Reserved
GLSLstd450Step = 48,
GLSLstd450SmoothStep = 49,
GLSLstd450Fma = 50,
GLSLstd450Frexp = 51, // second operand needs an OpVariable to write to
GLSLstd450FrexpStruct = 52, // no OpVariable operand
GLSLstd450Ldexp = 53,
GLSLstd450PackSnorm4x8 = 54,
GLSLstd450PackUnorm4x8 = 55,
GLSLstd450PackSnorm2x16 = 56,
GLSLstd450PackUnorm2x16 = 57,
GLSLstd450PackHalf2x16 = 58,
GLSLstd450PackDouble2x32 = 59,
GLSLstd450UnpackSnorm2x16 = 60,
GLSLstd450UnpackUnorm2x16 = 61,
GLSLstd450UnpackHalf2x16 = 62,
GLSLstd450UnpackSnorm4x8 = 63,
GLSLstd450UnpackUnorm4x8 = 64,
GLSLstd450UnpackDouble2x32 = 65,
GLSLstd450Length = 66,
GLSLstd450Distance = 67,
GLSLstd450Cross = 68,
GLSLstd450Normalize = 69,
GLSLstd450FaceForward = 70,
GLSLstd450Reflect = 71,
GLSLstd450Refract = 72,
GLSLstd450FindILsb = 73,
GLSLstd450FindSMsb = 74,
GLSLstd450FindUMsb = 75,
GLSLstd450InterpolateAtCentroid = 76,
GLSLstd450InterpolateAtSample = 77,
GLSLstd450InterpolateAtOffset = 78,
GLSLstd450NMin = 79,
GLSLstd450NMax = 80,
GLSLstd450NClamp = 81,
GLSLstd450Count
};
#endif // #ifndef GLSLstd450_H

202
deps/SPIRV-Cross/LICENSE vendored Normal file
View File

@ -0,0 +1,202 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

41
deps/SPIRV-Cross/Makefile vendored Normal file
View File

@ -0,0 +1,41 @@
TARGET := spirv-cross
SOURCES := $(wildcard spirv_*.cpp)
CLI_SOURCES := main.cpp
OBJECTS := $(SOURCES:.cpp=.o)
CLI_OBJECTS := $(CLI_SOURCES:.cpp=.o)
STATIC_LIB := lib$(TARGET).a
DEPS := $(OBJECTS:.o=.d) $(CLI_OBJECTS:.o=.d)
CXXFLAGS += -std=c++11 -Wall -Wextra -Wshadow -D__STDC_LIMIT_MACROS
ifeq ($(DEBUG), 1)
CXXFLAGS += -O0 -g
else
CXXFLAGS += -O2 -DNDEBUG
endif
ifeq ($(SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS), 1)
CXXFLAGS += -DSPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS -fno-exceptions
endif
all: $(TARGET)
-include $(DEPS)
$(TARGET): $(CLI_OBJECTS) $(STATIC_LIB)
$(CXX) -o $@ $(CLI_OBJECTS) $(STATIC_LIB) $(LDFLAGS)
$(STATIC_LIB): $(OBJECTS)
$(AR) rcs $@ $(OBJECTS)
%.o: %.cpp
$(CXX) -c -o $@ $< $(CXXFLAGS) -MMD
clean:
rm -f $(TARGET) $(OBJECTS) $(CLI_OBJECTS) $(STATIC_LIB) $(DEPS)
.PHONY: clean

217
deps/SPIRV-Cross/README.md vendored Normal file
View File

@ -0,0 +1,217 @@
# SPIRV-Cross
SPIRV-Cross is a tool designed for parsing and converting SPIR-V to other shader languages.
[![Build Status](https://travis-ci.org/KhronosGroup/SPIRV-Cross.svg?branch=master)](https://travis-ci.org/KhronosGroup/SPIRV-Cross)
## Features
- Convert SPIR-V to readable, usable and efficient GLSL
- Convert SPIR-V to readable, usable and efficient Metal Shading Language (MSL) [EXPERIMENTAL]
- Convert SPIR-V to debuggable C++ [EXPERIMENTAL]
- Reflection API to simplify the creation of Vulkan pipeline layouts
- Reflection API to modify and tweak OpDecorations
- Supports "all" of vertex, fragment, tessellation, geometry and compute shaders.
SPIRV-Cross tries hard to emit readable and clean output from the SPIR-V.
The goal is to emit GLSL or MSL that looks like it was written by a human and not awkward IR/assembly-like code.
NOTE: Individual features are expected to be mostly complete, but it is possible that certain obscure GLSL features are not yet supported.
However, most missing features are expected to be "trivial" improvements at this stage.
## Building
SPIRV-Cross has been tested on Linux, OSX and Windows.
The make and CMake build flavors offer the option to treat exceptions as assertions. To disable exceptions for make just append SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS=1 to the command line. For CMake append -DSPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS=ON. By default exceptions are enabled.
### Linux and macOS
Just run `make` on the command line. A recent GCC (4.8+) or Clang (3.x+) compiler is required as SPIRV-Cross uses C++11 extensively.
### Windows
MinGW-w64 based compilation works with `make`, and an MSVC 2013 solution is also included.
## Usage
### Using the C++ API
To perform reflection and convert to other shader languages you can use the SPIRV-Cross API.
For example:
```
#include "spirv_glsl.hpp"
#include <vector>
#include <utility>
extern std::vector<uint32_t> load_spirv_file();
int main()
{
// Read SPIR-V from disk or similar.
std::vector<uint32_t> spirv_binary = load_spirv_file();
spirv_cross::CompilerGLSL glsl(std::move(spirv_binary));
// The SPIR-V is now parsed, and we can perform reflection on it.
spirv_cross::ShaderResources resources = glsl.get_shader_resources();
// Get all sampled images in the shader.
for (auto &resource : resources.sampled_images)
{
unsigned set = glsl.get_decoration(resource.id, spv::DecorationDescriptorSet);
unsigned binding = glsl.get_decoration(resource.id, spv::DecorationBinding);
printf("Image %s at set = %u, binding = %u\n", resource.name.c_str(), set, binding);
// Modify the decoration to prepare it for GLSL.
glsl.unset_decoration(resource.id, spv::DecorationDescriptorSet);
// Some arbitrary remapping if we want.
glsl.set_decoration(resource.id, spv::DecorationBinding, set * 16 + binding);
}
// Set some options.
spirv_cross::CompilerGLSL::Options options;
options.version = 310;
options.es = true;
glsl.set_options(options);
// Compile to GLSL, ready to give to GL driver.
std::string source = glsl.compile();
}
```
#### Integrating SPIRV-Cross in a custom build system
To add SPIRV-Cross to your own codebase, just copy the source and header files from root directory
and build the relevant .cpp files you need. Make sure to build with C++11 support, e.g. `-std=c++11` in GCC and Clang.
Alternatively, the Makefile generates a libspirv-cross.a static library during build that can be linked in.
### Creating a SPIR-V file from GLSL with glslang
```
glslangValidator -H -V -o test.spv test.frag
```
### Converting a SPIR-V file to GLSL ES
```
glslangValidator -H -V -o test.spv shaders/comp/basic.comp
./spirv-cross --version 310 --es test.spv
```
#### Converting to desktop GLSL
```
glslangValidator -H -V -o test.spv shaders/comp/basic.comp
./spirv-cross --version 330 test.spv --output test.comp
```
#### Disable prettifying optimizations
```
glslangValidator -H -V -o test.spv shaders/comp/basic.comp
./spirv-cross --version 310 --es test.spv --output test.comp --force-temporary
```
### Using shaders generated from C++ backend
Please see `samples/cpp` where some GLSL shaders are compiled to SPIR-V, decompiled to C++ and run with test data.
Reading through the samples should explain how to use the C++ interface.
A simple Makefile is included to build all shaders in the directory.
### Using SPIRV-Cross to output GLSL shaders from glslang HLSL
#### Entry point
When using SPIR-V shaders compiled from HLSL, there are some extra things you need to take care of.
First make sure that the entry point is used correctly.
If you forget to set the entry point correctly in glslangValidator (-e MyFancyEntryPoint),
you will likely encounter this error message:
```
Cannot end a function before ending the current block.
Likely cause: If this SPIR-V was created from glslang HLSL, make sure the entry point is valid.
```
#### Separate image samplers
Another thing you need to remember is when using samplers and textures in HLSL these are separable, and not directly compatible with GLSL. If you need to use this with desktop GL/GLES, you need to call `Compiler::build_combined_image_samplers` first before calling `Compiler::compile`, or you will get an exception.
```
// From main.cpp
// Builds a mapping for all combinations of images and samplers.
compiler->build_combined_image_samplers();
// Give the remapped combined samplers new names.
// Here you can also set up decorations if you want (binding = #N).
for (auto &remap : compiler->get_combined_image_samplers())
{
compiler->set_name(remap.combined_id, join("SPIRV_Cross_Combined", compiler->get_name(remap.image_id),
compiler->get_name(remap.sampler_id)));
}
```
If your target is Vulkan GLSL, `--vulkan-semantics` will emit separate image samplers as you'd expect.
The command line client does this automatically, but if you're calling the library, you'll need to do this yourself.
## Contributing
Contributions to SPIRV-Cross are welcome. See Testing and Licensing sections for details.
### Testing
SPIRV-Cross maintains a test suite of shaders with reference output of how the output looks after going through a roundtrip through
glslangValidator then back through SPIRV-Cross again. The reference files are stored inside the repository in order to be able to track regressions.
All pull requests should ensure that test output does not change unexpectedly. This can be tested with `./test_shaders.py shaders`.
However, when improving SPIRV-Cross there are of course legitimate cases where reference output should change.
In these cases, run `./test_shaders.py shaders --update` to update the reference files and include these changes as part of the pull request.
Always make sure you are running up to date glslangValidator as well as SPIRV-Tools when updating reference files.
In short, the master branch should always be able to run `./test_shaders.py shaders` without failure.
When adding support for new features to SPIRV-Cross, a new shader and reference file should be added which covers usage of the new shader features in question.
### Licensing
Contributors of new files should add a copyright header at the top of every new source code file with their copyright
along with the Apache 2.0 licensing stub.
### Formatting
SPIRV-Cross uses `clang-format` to automatically format code.
Please use `clang-format` with the style sheet found in `.clang-format` to automatically format code before submitting a pull request.
To make things easy, the `format_all.sh` script can be used to format all
source files in the library. In this directory, run the following from the
command line:
./format_all.sh
## ABI concerns
### SPIR-V headers
The current repository uses the latest SPIR-V and GLSL.std.450 headers.
SPIR-V files created from older headers could have ABI issues.
## Regression testing
In shaders/ a collection of shaders are maintained for purposes of regression testing.
The current reference output is contained in reference/.
`./test_shaders.py shaders` can be run to perform regression testing.
See `./test_shaders.py --help` for more.
### Updating regression tests
When legitimate changes are found, use `--update` flag to update regression files.
Otherwise, `./test_shaders.py` will fail with error code.
### Mali Offline Compiler cycle counts
To obtain a CSV of static shader cycle counts before and after going through spirv-cross, add
`--malisc` flag to `./test_shaders`. This requires the Mali Offline Compiler to be installed in PATH.

7
deps/SPIRV-Cross/format_all.sh vendored Executable file
View File

@ -0,0 +1,7 @@
#!/bin/bash
for file in spirv_*.{cpp,hpp} include/spirv_cross/*.{hpp,h} samples/cpp/*.cpp main.cpp
do
echo "Formatting file: $file ..."
clang-format -style=file -i $file
done

View File

@ -0,0 +1,79 @@
/*
* Copyright 2015-2016 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef SPIRV_CROSS_BARRIER_HPP
#define SPIRV_CROSS_BARRIER_HPP
#include <atomic>
#include <thread>
namespace spirv_cross
{
class Barrier
{
public:
Barrier()
{
count.store(0);
iteration.store(0);
}
void set_release_divisor(unsigned divisor)
{
this->divisor = divisor;
}
static inline void memoryBarrier()
{
std::atomic_thread_fence(std::memory_order_seq_cst);
}
void reset_counter()
{
count.store(0);
iteration.store(0);
}
void wait()
{
unsigned target_iteration = iteration.load(std::memory_order_relaxed) + 1;
// Overflows cleanly.
unsigned target_count = divisor * target_iteration;
// Barriers don't enforce memory ordering.
// Be as relaxed about the barrier as we possibly can!
unsigned c = count.fetch_add(1u, std::memory_order_relaxed);
if (c + 1 == target_count)
{
iteration.store(target_iteration, std::memory_order_relaxed);
}
else
{
// If we have more threads than the CPU, don't hog the CPU for very long periods of time.
while (iteration.load(std::memory_order_relaxed) != target_iteration)
std::this_thread::yield();
}
}
private:
unsigned divisor = 1;
std::atomic<unsigned> count;
std::atomic<unsigned> iteration;
};
}
#endif

View File

@ -0,0 +1,126 @@
/*
* Copyright 2015-2016 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef SPIRV_CROSS_EXTERNAL_INTERFACE_H
#define SPIRV_CROSS_EXTERNAL_INTERFACE_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stddef.h>
typedef struct spirv_cross_shader spirv_cross_shader_t;
struct spirv_cross_interface
{
spirv_cross_shader_t *(*construct)(void);
void (*destruct)(spirv_cross_shader_t *thiz);
void (*invoke)(spirv_cross_shader_t *thiz);
};
void spirv_cross_set_stage_input(spirv_cross_shader_t *thiz, unsigned location, void *data, size_t size);
void spirv_cross_set_stage_output(spirv_cross_shader_t *thiz, unsigned location, void *data, size_t size);
void spirv_cross_set_push_constant(spirv_cross_shader_t *thiz, void *data, size_t size);
void spirv_cross_set_uniform_constant(spirv_cross_shader_t *thiz, unsigned location, void *data, size_t size);
void spirv_cross_set_resource(spirv_cross_shader_t *thiz, unsigned set, unsigned binding, void **data, size_t size);
const struct spirv_cross_interface *spirv_cross_get_interface(void);
typedef enum spirv_cross_builtin {
SPIRV_CROSS_BUILTIN_POSITION = 0,
SPIRV_CROSS_BUILTIN_FRAG_COORD = 1,
SPIRV_CROSS_BUILTIN_WORK_GROUP_ID = 2,
SPIRV_CROSS_BUILTIN_NUM_WORK_GROUPS = 3,
SPIRV_CROSS_NUM_BUILTINS
} spirv_cross_builtin;
void spirv_cross_set_builtin(spirv_cross_shader_t *thiz, spirv_cross_builtin builtin, void *data, size_t size);
#define SPIRV_CROSS_NUM_DESCRIPTOR_SETS 4
#define SPIRV_CROSS_NUM_DESCRIPTOR_BINDINGS 16
#define SPIRV_CROSS_NUM_STAGE_INPUTS 16
#define SPIRV_CROSS_NUM_STAGE_OUTPUTS 16
#define SPIRV_CROSS_NUM_UNIFORM_CONSTANTS 32
enum spirv_cross_format
{
SPIRV_CROSS_FORMAT_R8_UNORM = 0,
SPIRV_CROSS_FORMAT_R8G8_UNORM = 1,
SPIRV_CROSS_FORMAT_R8G8B8_UNORM = 2,
SPIRV_CROSS_FORMAT_R8G8B8A8_UNORM = 3,
SPIRV_CROSS_NUM_FORMATS
};
enum spirv_cross_wrap
{
SPIRV_CROSS_WRAP_CLAMP_TO_EDGE = 0,
SPIRV_CROSS_WRAP_REPEAT = 1,
SPIRV_CROSS_NUM_WRAP
};
enum spirv_cross_filter
{
SPIRV_CROSS_FILTER_NEAREST = 0,
SPIRV_CROSS_FILTER_LINEAR = 1,
SPIRV_CROSS_NUM_FILTER
};
enum spirv_cross_mipfilter
{
SPIRV_CROSS_MIPFILTER_BASE = 0,
SPIRV_CROSS_MIPFILTER_NEAREST = 1,
SPIRV_CROSS_MIPFILTER_LINEAR = 2,
SPIRV_CROSS_NUM_MIPFILTER
};
struct spirv_cross_miplevel
{
const void *data;
unsigned width, height;
size_t stride;
};
struct spirv_cross_sampler_info
{
const struct spirv_cross_miplevel *mipmaps;
unsigned num_mipmaps;
enum spirv_cross_format format;
enum spirv_cross_wrap wrap_s;
enum spirv_cross_wrap wrap_t;
enum spirv_cross_filter min_filter;
enum spirv_cross_filter mag_filter;
enum spirv_cross_mipfilter mip_filter;
};
typedef struct spirv_cross_sampler_2d spirv_cross_sampler_2d_t;
spirv_cross_sampler_2d_t *spirv_cross_create_sampler_2d(const struct spirv_cross_sampler_info *info);
void spirv_cross_destroy_sampler_2d(spirv_cross_sampler_2d_t *samp);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,62 @@
/*
* Copyright 2015-2016 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef SPIRV_CROSS_IMAGE_HPP
#define SPIRV_CROSS_IMAGE_HPP
#ifndef GLM_SWIZZLE
#define GLM_SWIZZLE
#endif
#ifndef GLM_FORCE_RADIANS
#define GLM_FORCE_RADIANS
#endif
#include <glm/glm.hpp>
namespace spirv_cross
{
template <typename T>
struct image2DBase
{
virtual ~image2DBase() = default;
inline virtual T load(glm::ivec2 coord)
{
return T(0, 0, 0, 1);
}
inline virtual void store(glm::ivec2 coord, const T &v)
{
}
};
typedef image2DBase<glm::vec4> image2D;
typedef image2DBase<glm::ivec4> iimage2D;
typedef image2DBase<glm::uvec4> uimage2D;
template <typename T>
inline T imageLoad(const image2DBase<T> &image, glm::ivec2 coord)
{
return image.load(coord);
}
template <typename T>
void imageStore(image2DBase<T> &image, glm::ivec2 coord, const T &value)
{
image.store(coord, value);
}
}
#endif

View File

@ -0,0 +1,603 @@
/*
* Copyright 2015-2016 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef SPIRV_CROSS_INTERNAL_INTERFACE_HPP
#define SPIRV_CROSS_INTERNAL_INTERFACE_HPP
// This file must only be included by the shader generated by spirv-cross!
#ifndef GLM_SWIZZLE
#define GLM_SWIZZLE
#endif
#ifndef GLM_FORCE_RADIANS
#define GLM_FORCE_RADIANS
#endif
#include <glm/glm.hpp>
#include "barrier.hpp"
#include "external_interface.h"
#include "image.hpp"
#include "sampler.hpp"
#include "thread_group.hpp"
#include <assert.h>
#include <stdint.h>
namespace internal
{
// Adaptor helpers to adapt GLSL access chain syntax to C++.
// Don't bother with arrays of arrays on uniforms ...
// Would likely need horribly complex variadic template munging.
template <typename T>
struct Interface
{
enum
{
ArraySize = 1,
Size = sizeof(T)
};
Interface()
: ptr(0)
{
}
T &get()
{
assert(ptr);
return *ptr;
}
T *ptr;
};
// For array types, return a pointer instead.
template <typename T, unsigned U>
struct Interface<T[U]>
{
enum
{
ArraySize = U,
Size = U * sizeof(T)
};
Interface()
: ptr(0)
{
}
T *get()
{
assert(ptr);
return ptr;
}
T *ptr;
};
// For case when array size is 1, avoid double dereference.
template <typename T>
struct PointerInterface
{
enum
{
ArraySize = 1,
Size = sizeof(T *)
};
enum
{
PreDereference = true
};
PointerInterface()
: ptr(0)
{
}
T &get()
{
assert(ptr);
return *ptr;
}
T *ptr;
};
// Automatically converts a pointer down to reference to match GLSL syntax.
template <typename T>
struct DereferenceAdaptor
{
DereferenceAdaptor(T **ptr)
: ptr(ptr)
{
}
T &operator[](unsigned index) const
{
return *(ptr[index]);
}
T **ptr;
};
// We can't have a linear array of T* since T* can be an abstract type in case of samplers.
// We also need a list of pointers since we can have run-time length SSBOs.
template <typename T, unsigned U>
struct PointerInterface<T[U]>
{
enum
{
ArraySize = U,
Size = sizeof(T *) * U
};
enum
{
PreDereference = false
};
PointerInterface()
: ptr(0)
{
}
DereferenceAdaptor<T> get()
{
assert(ptr);
return DereferenceAdaptor<T>(ptr);
}
T **ptr;
};
// Resources can be more abstract and be unsized,
// so we need to have an array of pointers for those cases.
template <typename T>
struct Resource : PointerInterface<T>
{
};
// POD with no unknown sizes, so we can express these as flat arrays.
template <typename T>
struct UniformConstant : Interface<T>
{
};
template <typename T>
struct StageInput : Interface<T>
{
};
template <typename T>
struct StageOutput : Interface<T>
{
};
template <typename T>
struct PushConstant : Interface<T>
{
};
}
struct spirv_cross_shader
{
struct PPSize
{
PPSize()
: ptr(0)
, size(0)
{
}
void **ptr;
size_t size;
};
struct PPSizeResource
{
PPSizeResource()
: ptr(0)
, size(0)
, pre_dereference(false)
{
}
void **ptr;
size_t size;
bool pre_dereference;
};
PPSizeResource resources[SPIRV_CROSS_NUM_DESCRIPTOR_SETS][SPIRV_CROSS_NUM_DESCRIPTOR_BINDINGS];
PPSize stage_inputs[SPIRV_CROSS_NUM_STAGE_INPUTS];
PPSize stage_outputs[SPIRV_CROSS_NUM_STAGE_OUTPUTS];
PPSize uniform_constants[SPIRV_CROSS_NUM_UNIFORM_CONSTANTS];
PPSize push_constant;
PPSize builtins[SPIRV_CROSS_NUM_BUILTINS];
template <typename U>
void register_builtin(spirv_cross_builtin builtin, const U &value)
{
assert(!builtins[builtin].ptr);
builtins[builtin].ptr = (void **)&value.ptr;
builtins[builtin].size = sizeof(*value.ptr) * U::ArraySize;
}
void set_builtin(spirv_cross_builtin builtin, void *data, size_t size)
{
assert(builtins[builtin].ptr);
assert(size >= builtins[builtin].size);
*builtins[builtin].ptr = data;
}
template <typename U>
void register_resource(const internal::Resource<U> &value, unsigned set, unsigned binding)
{
assert(set < SPIRV_CROSS_NUM_DESCRIPTOR_SETS);
assert(binding < SPIRV_CROSS_NUM_DESCRIPTOR_BINDINGS);
assert(!resources[set][binding].ptr);
resources[set][binding].ptr = (void **)&value.ptr;
resources[set][binding].size = internal::Resource<U>::Size;
resources[set][binding].pre_dereference = internal::Resource<U>::PreDereference;
}
template <typename U>
void register_stage_input(const internal::StageInput<U> &value, unsigned location)
{
assert(location < SPIRV_CROSS_NUM_STAGE_INPUTS);
assert(!stage_inputs[location].ptr);
stage_inputs[location].ptr = (void **)&value.ptr;
stage_inputs[location].size = internal::StageInput<U>::Size;
}
template <typename U>
void register_stage_output(const internal::StageOutput<U> &value, unsigned location)
{
assert(location < SPIRV_CROSS_NUM_STAGE_OUTPUTS);
assert(!stage_outputs[location].ptr);
stage_outputs[location].ptr = (void **)&value.ptr;
stage_outputs[location].size = internal::StageOutput<U>::Size;
}
template <typename U>
void register_uniform_constant(const internal::UniformConstant<U> &value, unsigned location)
{
assert(location < SPIRV_CROSS_NUM_UNIFORM_CONSTANTS);
assert(!uniform_constants[location].ptr);
uniform_constants[location].ptr = (void **)&value.ptr;
uniform_constants[location].size = internal::UniformConstant<U>::Size;
}
template <typename U>
void register_push_constant(const internal::PushConstant<U> &value)
{
assert(!push_constant.ptr);
push_constant.ptr = (void **)&value.ptr;
push_constant.size = internal::PushConstant<U>::Size;
}
void set_stage_input(unsigned location, void *data, size_t size)
{
assert(location < SPIRV_CROSS_NUM_STAGE_INPUTS);
assert(stage_inputs[location].ptr);
assert(size >= stage_inputs[location].size);
*stage_inputs[location].ptr = data;
}
void set_stage_output(unsigned location, void *data, size_t size)
{
assert(location < SPIRV_CROSS_NUM_STAGE_OUTPUTS);
assert(stage_outputs[location].ptr);
assert(size >= stage_outputs[location].size);
*stage_outputs[location].ptr = data;
}
void set_uniform_constant(unsigned location, void *data, size_t size)
{
assert(location < SPIRV_CROSS_NUM_UNIFORM_CONSTANTS);
assert(uniform_constants[location].ptr);
assert(size >= uniform_constants[location].size);
*uniform_constants[location].ptr = data;
}
void set_push_constant(void *data, size_t size)
{
assert(push_constant.ptr);
assert(size >= push_constant.size);
*push_constant.ptr = data;
}
void set_resource(unsigned set, unsigned binding, void **data, size_t size)
{
assert(set < SPIRV_CROSS_NUM_DESCRIPTOR_SETS);
assert(binding < SPIRV_CROSS_NUM_DESCRIPTOR_BINDINGS);
assert(resources[set][binding].ptr);
assert(size >= resources[set][binding].size);
// We're using the regular PointerInterface, dereference ahead of time.
if (resources[set][binding].pre_dereference)
*resources[set][binding].ptr = *data;
else
*resources[set][binding].ptr = data;
}
};
namespace spirv_cross
{
template <typename T>
struct BaseShader : spirv_cross_shader
{
void invoke()
{
static_cast<T *>(this)->main();
}
};
struct FragmentResources
{
internal::StageOutput<glm::vec4> gl_FragCoord;
void init(spirv_cross_shader &s)
{
s.register_builtin(SPIRV_CROSS_BUILTIN_FRAG_COORD, gl_FragCoord);
}
#define gl_FragCoord __res->gl_FragCoord.get()
};
template <typename T, typename Res>
struct FragmentShader : BaseShader<FragmentShader<T, Res>>
{
inline void main()
{
impl.main();
}
FragmentShader()
{
resources.init(*this);
impl.__res = &resources;
}
T impl;
Res resources;
};
struct VertexResources
{
internal::StageOutput<glm::vec4> gl_Position;
void init(spirv_cross_shader &s)
{
s.register_builtin(SPIRV_CROSS_BUILTIN_POSITION, gl_Position);
}
#define gl_Position __res->gl_Position.get()
};
template <typename T, typename Res>
struct VertexShader : BaseShader<VertexShader<T, Res>>
{
inline void main()
{
impl.main();
}
VertexShader()
{
resources.init(*this);
impl.__res = &resources;
}
T impl;
Res resources;
};
struct TessEvaluationResources
{
inline void init(spirv_cross_shader &)
{
}
};
template <typename T, typename Res>
struct TessEvaluationShader : BaseShader<TessEvaluationShader<T, Res>>
{
inline void main()
{
impl.main();
}
TessEvaluationShader()
{
resources.init(*this);
impl.__res = &resources;
}
T impl;
Res resources;
};
struct TessControlResources
{
inline void init(spirv_cross_shader &)
{
}
};
template <typename T, typename Res>
struct TessControlShader : BaseShader<TessControlShader<T, Res>>
{
inline void main()
{
impl.main();
}
TessControlShader()
{
resources.init(*this);
impl.__res = &resources;
}
T impl;
Res resources;
};
struct GeometryResources
{
inline void init(spirv_cross_shader &)
{
}
};
template <typename T, typename Res>
struct GeometryShader : BaseShader<GeometryShader<T, Res>>
{
inline void main()
{
impl.main();
}
GeometryShader()
{
resources.init(*this);
impl.__res = &resources;
}
T impl;
Res resources;
};
struct ComputeResources
{
internal::StageInput<glm::uvec3> gl_WorkGroupID__;
internal::StageInput<glm::uvec3> gl_NumWorkGroups__;
void init(spirv_cross_shader &s)
{
s.register_builtin(SPIRV_CROSS_BUILTIN_WORK_GROUP_ID, gl_WorkGroupID__);
s.register_builtin(SPIRV_CROSS_BUILTIN_NUM_WORK_GROUPS, gl_NumWorkGroups__);
}
#define gl_WorkGroupID __res->gl_WorkGroupID__.get()
#define gl_NumWorkGroups __res->gl_NumWorkGroups__.get()
Barrier barrier__;
#define barrier() __res->barrier__.wait()
};
struct ComputePrivateResources
{
uint32_t gl_LocalInvocationIndex__;
#define gl_LocalInvocationIndex __priv_res.gl_LocalInvocationIndex__
glm::uvec3 gl_LocalInvocationID__;
#define gl_LocalInvocationID __priv_res.gl_LocalInvocationID__
glm::uvec3 gl_GlobalInvocationID__;
#define gl_GlobalInvocationID __priv_res.gl_GlobalInvocationID__
};
template <typename T, typename Res, unsigned WorkGroupX, unsigned WorkGroupY, unsigned WorkGroupZ>
struct ComputeShader : BaseShader<ComputeShader<T, Res, WorkGroupX, WorkGroupY, WorkGroupZ>>
{
inline void main()
{
resources.barrier__.reset_counter();
for (unsigned z = 0; z < WorkGroupZ; z++)
for (unsigned y = 0; y < WorkGroupY; y++)
for (unsigned x = 0; x < WorkGroupX; x++)
impl[z][y][x].__priv_res.gl_GlobalInvocationID__ =
glm::uvec3(WorkGroupX, WorkGroupY, WorkGroupZ) * resources.gl_WorkGroupID__.get() +
glm::uvec3(x, y, z);
group.run();
group.wait();
}
ComputeShader()
: group(&impl[0][0][0])
{
resources.init(*this);
resources.barrier__.set_release_divisor(WorkGroupX * WorkGroupY * WorkGroupZ);
unsigned i = 0;
for (unsigned z = 0; z < WorkGroupZ; z++)
{
for (unsigned y = 0; y < WorkGroupY; y++)
{
for (unsigned x = 0; x < WorkGroupX; x++)
{
impl[z][y][x].__priv_res.gl_LocalInvocationID__ = glm::uvec3(x, y, z);
impl[z][y][x].__priv_res.gl_LocalInvocationIndex__ = i++;
impl[z][y][x].__res = &resources;
}
}
}
}
T impl[WorkGroupZ][WorkGroupY][WorkGroupX];
ThreadGroup<T, WorkGroupX * WorkGroupY * WorkGroupZ> group;
Res resources;
};
inline void memoryBarrierShared()
{
Barrier::memoryBarrier();
}
inline void memoryBarrier()
{
Barrier::memoryBarrier();
}
// TODO: Rest of the barriers.
// Atomics
template <typename T>
inline T atomicAdd(T &v, T a)
{
static_assert(sizeof(std::atomic<T>) == sizeof(T), "Cannot cast properly to std::atomic<T>.");
// We need explicit memory barriers in GLSL to enfore any ordering.
// FIXME: Can we really cast this? There is no other way I think ...
return std::atomic_fetch_add_explicit(reinterpret_cast<std::atomic<T> *>(&v), a, std::memory_order_relaxed);
}
}
void spirv_cross_set_stage_input(spirv_cross_shader_t *shader, unsigned location, void *data, size_t size)
{
shader->set_stage_input(location, data, size);
}
void spirv_cross_set_stage_output(spirv_cross_shader_t *shader, unsigned location, void *data, size_t size)
{
shader->set_stage_output(location, data, size);
}
void spirv_cross_set_uniform_constant(spirv_cross_shader_t *shader, unsigned location, void *data, size_t size)
{
shader->set_uniform_constant(location, data, size);
}
void spirv_cross_set_resource(spirv_cross_shader_t *shader, unsigned set, unsigned binding, void **data, size_t size)
{
shader->set_resource(set, binding, data, size);
}
void spirv_cross_set_push_constant(spirv_cross_shader_t *shader, void *data, size_t size)
{
shader->set_push_constant(data, size);
}
void spirv_cross_set_builtin(spirv_cross_shader_t *shader, spirv_cross_builtin builtin, void *data, size_t size)
{
shader->set_builtin(builtin, data, size);
}
#endif

View File

@ -0,0 +1,105 @@
/*
* Copyright 2015-2016 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef SPIRV_CROSS_SAMPLER_HPP
#define SPIRV_CROSS_SAMPLER_HPP
#include <vector>
namespace spirv_cross
{
struct spirv_cross_sampler_2d
{
inline virtual ~spirv_cross_sampler_2d()
{
}
};
template <typename T>
struct sampler2DBase : spirv_cross_sampler_2d
{
sampler2DBase(const spirv_cross_sampler_info *info)
{
mips.insert(mips.end(), info->mipmaps, info->mipmaps + info->num_mipmaps);
format = info->format;
wrap_s = info->wrap_s;
wrap_t = info->wrap_t;
min_filter = info->min_filter;
mag_filter = info->mag_filter;
mip_filter = info->mip_filter;
}
inline virtual T sample(glm::vec2 uv, float bias)
{
return sampleLod(uv, bias);
}
inline virtual T sampleLod(glm::vec2 uv, float lod)
{
if (mag_filter == SPIRV_CROSS_FILTER_NEAREST)
{
uv.x = wrap(uv.x, wrap_s, mips[0].width);
uv.y = wrap(uv.y, wrap_t, mips[0].height);
glm::vec2 uv_full = uv * glm::vec2(mips[0].width, mips[0].height);
int x = int(uv_full.x);
int y = int(uv_full.y);
return sample(x, y, 0);
}
else
{
return T(0, 0, 0, 1);
}
}
inline float wrap(float v, spirv_cross_wrap wrap, unsigned size)
{
switch (wrap)
{
case SPIRV_CROSS_WRAP_REPEAT:
return v - glm::floor(v);
case SPIRV_CROSS_WRAP_CLAMP_TO_EDGE:
{
float half = 0.5f / size;
return glm::clamp(v, half, 1.0f - half);
}
default:
return 0.0f;
}
}
std::vector<spirv_cross_miplevel> mips;
spirv_cross_format format;
spirv_cross_wrap wrap_s;
spirv_cross_format wrap_t;
spirv_cross_filter min_filter;
spirv_cross_filter mag_filter;
spirv_cross_mipfilter mip_filter;
};
typedef sampler2DBase<glm::vec4> sampler2D;
typedef sampler2DBase<glm::ivec4> isampler2D;
typedef sampler2DBase<glm::uvec4> usampler2D;
template <typename T>
inline T texture(const sampler2DBase<T> &samp, const glm::vec2 &uv, float bias = 0.0f)
{
return samp.sample(uv, bias);
}
}
#endif

View File

@ -0,0 +1,113 @@
/*
* Copyright 2015-2016 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef SPIRV_CROSS_THREAD_GROUP_HPP
#define SPIRV_CROSS_THREAD_GROUP_HPP
#include <condition_variable>
#include <mutex>
#include <thread>
namespace spirv_cross
{
template <typename T, unsigned Size>
class ThreadGroup
{
public:
ThreadGroup(T *impl)
{
for (unsigned i = 0; i < Size; i++)
workers[i].start(&impl[i]);
}
void run()
{
for (auto &worker : workers)
worker.run();
}
void wait()
{
for (auto &worker : workers)
worker.wait();
}
private:
struct Thread
{
enum State
{
Idle,
Running,
Dying
};
State state = Idle;
void start(T *impl)
{
worker = std::thread([impl, this] {
for (;;)
{
{
std::unique_lock<std::mutex> l{ lock };
cond.wait(l, [this] { return state != Idle; });
if (state == Dying)
break;
}
impl->main();
std::lock_guard<std::mutex> l{ lock };
state = Idle;
cond.notify_one();
}
});
}
void wait()
{
std::unique_lock<std::mutex> l{ lock };
cond.wait(l, [this] { return state == Idle; });
}
void run()
{
std::lock_guard<std::mutex> l{ lock };
state = Running;
cond.notify_one();
}
~Thread()
{
if (worker.joinable())
{
{
std::lock_guard<std::mutex> l{ lock };
state = Dying;
cond.notify_one();
}
worker.join();
}
}
std::thread worker;
std::condition_variable cond;
std::mutex lock;
};
Thread workers[Size];
};
}
#endif

12
deps/SPIRV-Cross/jni/Android.mk vendored Normal file
View File

@ -0,0 +1,12 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_CFLAGS += -std=c++11 -Wall -Wextra
LOCAL_MODULE := spirv-cross
LOCAL_SRC_FILES := ../spirv_cfg.cpp ../spirv_cross.cpp ../spirv_glsl.cpp ../spirv_msl.cpp ../spirv_cpp.cpp
LOCAL_CPP_FEATURES := exceptions
LOCAL_ARM_MODE := arm
LOCAL_CFLAGS := -D__STDC_LIMIT_MACROS
include $(BUILD_STATIC_LIBRARY)

2
deps/SPIRV-Cross/jni/Application.mk vendored Normal file
View File

@ -0,0 +1,2 @@
APP_STL := c++_static
APP_ABI := armeabi-v7a

712
deps/SPIRV-Cross/main.cpp vendored Normal file
View File

@ -0,0 +1,712 @@
/*
* Copyright 2015-2016 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "spirv_cpp.hpp"
#include "spirv_msl.hpp"
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <functional>
#include <limits>
#include <memory>
#include <stdexcept>
#include <unordered_map>
#include <unordered_set>
using namespace spv;
using namespace spirv_cross;
using namespace std;
#ifdef SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS
#define THROW(x) \
do \
{ \
fprintf(stderr, "%s.", x); \
exit(1); \
} while (0)
#else
#define THROW(x) runtime_error(x)
#endif
struct CLIParser;
struct CLICallbacks
{
void add(const char *cli, const function<void(CLIParser &)> &func)
{
callbacks[cli] = func;
}
unordered_map<string, function<void(CLIParser &)>> callbacks;
function<void()> error_handler;
function<void(const char *)> default_handler;
};
struct CLIParser
{
CLIParser(CLICallbacks cbs_, int argc_, char *argv_[])
: cbs(move(cbs_))
, argc(argc_)
, argv(argv_)
{
}
bool parse()
{
#ifndef SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS
try
#endif
{
while (argc && !ended_state)
{
const char *next = *argv++;
argc--;
if (*next != '-' && cbs.default_handler)
{
cbs.default_handler(next);
}
else
{
auto itr = cbs.callbacks.find(next);
if (itr == ::end(cbs.callbacks))
{
THROW("Invalid argument");
}
itr->second(*this);
}
}
return true;
}
#ifndef SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS
catch (...)
{
if (cbs.error_handler)
{
cbs.error_handler();
}
return false;
}
#endif
}
void end()
{
ended_state = true;
}
uint32_t next_uint()
{
if (!argc)
{
THROW("Tried to parse uint, but nothing left in arguments");
}
uint32_t val = stoul(*argv);
if (val > numeric_limits<uint32_t>::max())
{
THROW("next_uint() out of range");
}
argc--;
argv++;
return val;
}
double next_double()
{
if (!argc)
{
THROW("Tried to parse double, but nothing left in arguments");
}
double val = stod(*argv);
argc--;
argv++;
return val;
}
const char *next_string()
{
if (!argc)
{
THROW("Tried to parse string, but nothing left in arguments");
}
const char *ret = *argv;
argc--;
argv++;
return ret;
}
CLICallbacks cbs;
int argc;
char **argv;
bool ended_state = false;
};
static vector<uint32_t> read_spirv_file(const char *path)
{
FILE *file = fopen(path, "rb");
if (!file)
{
fprintf(stderr, "Failed to open SPIRV file: %s\n", path);
return {};
}
fseek(file, 0, SEEK_END);
long len = ftell(file) / sizeof(uint32_t);
rewind(file);
vector<uint32_t> spirv(len);
if (fread(spirv.data(), sizeof(uint32_t), len, file) != size_t(len))
spirv.clear();
fclose(file);
return spirv;
}
static bool write_string_to_file(const char *path, const char *string)
{
FILE *file = fopen(path, "w");
if (!file)
{
fprintf(file, "Failed to write file: %s\n", path);
return false;
}
fprintf(file, "%s", string);
fclose(file);
return true;
}
static void print_resources(const Compiler &compiler, const char *tag, const vector<Resource> &resources)
{
fprintf(stderr, "%s\n", tag);
fprintf(stderr, "=============\n\n");
for (auto &res : resources)
{
auto &type = compiler.get_type(res.type_id);
auto mask = compiler.get_decoration_mask(res.id);
// If we don't have a name, use the fallback for the type instead of the variable
// for SSBOs and UBOs since those are the only meaningful names to use externally.
// Push constant blocks are still accessed by name and not block name, even though they are technically Blocks.
bool is_push_constant = compiler.get_storage_class(res.id) == StorageClassPushConstant;
bool is_block = (compiler.get_decoration_mask(type.self) &
((1ull << DecorationBlock) | (1ull << DecorationBufferBlock))) != 0;
bool is_sized_block = is_block && (compiler.get_storage_class(res.id) == StorageClassUniform ||
compiler.get_storage_class(res.id) == StorageClassUniformConstant);
uint32_t fallback_id = !is_push_constant && is_block ? res.base_type_id : res.id;
uint32_t block_size = 0;
if (is_sized_block)
block_size = compiler.get_declared_struct_size(compiler.get_type(res.base_type_id));
string array;
for (auto arr : type.array)
array = join("[", arr ? convert_to_string(arr) : "", "]") + array;
fprintf(stderr, " ID %03u : %s%s", res.id,
!res.name.empty() ? res.name.c_str() : compiler.get_fallback_name(fallback_id).c_str(), array.c_str());
if (mask & (1ull << DecorationLocation))
fprintf(stderr, " (Location : %u)", compiler.get_decoration(res.id, DecorationLocation));
if (mask & (1ull << DecorationDescriptorSet))
fprintf(stderr, " (Set : %u)", compiler.get_decoration(res.id, DecorationDescriptorSet));
if (mask & (1ull << DecorationBinding))
fprintf(stderr, " (Binding : %u)", compiler.get_decoration(res.id, DecorationBinding));
if (mask & (1ull << DecorationInputAttachmentIndex))
fprintf(stderr, " (Attachment : %u)", compiler.get_decoration(res.id, DecorationInputAttachmentIndex));
if (is_sized_block)
fprintf(stderr, " (BlockSize : %u bytes)", block_size);
fprintf(stderr, "\n");
}
fprintf(stderr, "=============\n\n");
}
static const char *execution_model_to_str(spv::ExecutionModel model)
{
switch (model)
{
case spv::ExecutionModelVertex:
return "vertex";
case spv::ExecutionModelTessellationControl:
return "tessellation control";
case ExecutionModelTessellationEvaluation:
return "tessellation evaluation";
case ExecutionModelGeometry:
return "geometry";
case ExecutionModelFragment:
return "fragment";
case ExecutionModelGLCompute:
return "compute";
default:
return "???";
}
}
static void print_resources(const Compiler &compiler, const ShaderResources &res)
{
uint64_t modes = compiler.get_execution_mode_mask();
fprintf(stderr, "Entry points:\n");
auto entry_points = compiler.get_entry_points();
for (auto &e : entry_points)
fprintf(stderr, " %s (%s)\n", e.c_str(), execution_model_to_str(compiler.get_entry_point(e).model));
fprintf(stderr, "\n");
fprintf(stderr, "Execution modes:\n");
for (unsigned i = 0; i < 64; i++)
{
if (!(modes & (1ull << i)))
continue;
auto mode = static_cast<ExecutionMode>(i);
uint32_t arg0 = compiler.get_execution_mode_argument(mode, 0);
uint32_t arg1 = compiler.get_execution_mode_argument(mode, 1);
uint32_t arg2 = compiler.get_execution_mode_argument(mode, 2);
switch (static_cast<ExecutionMode>(i))
{
case ExecutionModeInvocations:
fprintf(stderr, " Invocations: %u\n", arg0);
break;
case ExecutionModeLocalSize:
fprintf(stderr, " LocalSize: (%u, %u, %u)\n", arg0, arg1, arg2);
break;
case ExecutionModeOutputVertices:
fprintf(stderr, " OutputVertices: %u\n", arg0);
break;
#define CHECK_MODE(m) \
case ExecutionMode##m: \
fprintf(stderr, " %s\n", #m); \
break
CHECK_MODE(SpacingEqual);
CHECK_MODE(SpacingFractionalEven);
CHECK_MODE(SpacingFractionalOdd);
CHECK_MODE(VertexOrderCw);
CHECK_MODE(VertexOrderCcw);
CHECK_MODE(PixelCenterInteger);
CHECK_MODE(OriginUpperLeft);
CHECK_MODE(OriginLowerLeft);
CHECK_MODE(EarlyFragmentTests);
CHECK_MODE(PointMode);
CHECK_MODE(Xfb);
CHECK_MODE(DepthReplacing);
CHECK_MODE(DepthGreater);
CHECK_MODE(DepthLess);
CHECK_MODE(DepthUnchanged);
CHECK_MODE(LocalSizeHint);
CHECK_MODE(InputPoints);
CHECK_MODE(InputLines);
CHECK_MODE(InputLinesAdjacency);
CHECK_MODE(Triangles);
CHECK_MODE(InputTrianglesAdjacency);
CHECK_MODE(Quads);
CHECK_MODE(Isolines);
CHECK_MODE(OutputPoints);
CHECK_MODE(OutputLineStrip);
CHECK_MODE(OutputTriangleStrip);
CHECK_MODE(VecTypeHint);
CHECK_MODE(ContractionOff);
default:
break;
}
}
fprintf(stderr, "\n");
print_resources(compiler, "subpass inputs", res.subpass_inputs);
print_resources(compiler, "inputs", res.stage_inputs);
print_resources(compiler, "outputs", res.stage_outputs);
print_resources(compiler, "textures", res.sampled_images);
print_resources(compiler, "separate images", res.separate_images);
print_resources(compiler, "separate samplers", res.separate_samplers);
print_resources(compiler, "images", res.storage_images);
print_resources(compiler, "ssbos", res.storage_buffers);
print_resources(compiler, "ubos", res.uniform_buffers);
print_resources(compiler, "push", res.push_constant_buffers);
print_resources(compiler, "counters", res.atomic_counters);
}
static void print_push_constant_resources(const Compiler &compiler, const vector<Resource> &res)
{
for (auto &block : res)
{
auto ranges = compiler.get_active_buffer_ranges(block.id);
fprintf(stderr, "Active members in buffer: %s\n",
!block.name.empty() ? block.name.c_str() : compiler.get_fallback_name(block.id).c_str());
fprintf(stderr, "==================\n\n");
for (auto &range : ranges)
{
const auto &name = compiler.get_member_name(block.base_type_id, range.index);
fprintf(stderr, "Member #%3u (%s): Offset: %4u, Range: %4u\n", range.index,
!name.empty() ? name.c_str() : compiler.get_fallback_member_name(range.index).c_str(),
unsigned(range.offset), unsigned(range.range));
}
fprintf(stderr, "==================\n\n");
}
}
static void print_spec_constants(const Compiler &compiler)
{
auto spec_constants = compiler.get_specialization_constants();
fprintf(stderr, "Specialization constants\n");
fprintf(stderr, "==================\n\n");
for (auto &c : spec_constants)
fprintf(stderr, "ID: %u, Spec ID: %u\n", c.id, c.constant_id);
fprintf(stderr, "==================\n\n");
}
struct PLSArg
{
PlsFormat format;
string name;
};
struct Remap
{
string src_name;
string dst_name;
unsigned components;
};
struct VariableTypeRemap
{
string variable_name;
string new_variable_type;
};
struct CLIArguments
{
const char *input = nullptr;
const char *output = nullptr;
const char *cpp_interface_name = nullptr;
uint32_t version = 0;
bool es = false;
bool set_version = false;
bool set_es = false;
bool dump_resources = false;
bool force_temporary = false;
bool flatten_ubo = false;
bool fixup = false;
vector<PLSArg> pls_in;
vector<PLSArg> pls_out;
vector<Remap> remaps;
vector<string> extensions;
vector<VariableTypeRemap> variable_type_remaps;
string entry;
uint32_t iterations = 1;
bool cpp = false;
bool metal = false;
bool vulkan_semantics = false;
bool remove_unused = false;
bool cfg_analysis = true;
};
static void print_help()
{
fprintf(stderr, "Usage: spirv-cross [--output <output path>] [SPIR-V file] [--es] [--no-es] [--no-cfg-analysis] "
"[--version <GLSL "
"version>] [--dump-resources] [--help] [--force-temporary] [--cpp] [--cpp-interface-name <name>] "
"[--metal] [--vulkan-semantics] [--flatten-ubo] [--fixup-clipspace] [--iterations iter] [--pls-in "
"format input-name] [--pls-out format output-name] [--remap source_name target_name components] "
"[--extension ext] [--entry name] [--remove-unused-variables] "
"[--remap-variable-type <variable_name> <new_variable_type>]\n");
}
static bool remap_generic(Compiler &compiler, const vector<Resource> &resources, const Remap &remap)
{
auto itr =
find_if(begin(resources), end(resources), [&remap](const Resource &res) { return res.name == remap.src_name; });
if (itr != end(resources))
{
compiler.set_remapped_variable_state(itr->id, true);
compiler.set_name(itr->id, remap.dst_name);
compiler.set_subpass_input_remapped_components(itr->id, remap.components);
return true;
}
else
return false;
}
static vector<PlsRemap> remap_pls(const vector<PLSArg> &pls_variables, const vector<Resource> &resources,
const vector<Resource> *secondary_resources)
{
vector<PlsRemap> ret;
for (auto &pls : pls_variables)
{
bool found = false;
for (auto &res : resources)
{
if (res.name == pls.name)
{
ret.push_back({ res.id, pls.format });
found = true;
break;
}
}
if (!found && secondary_resources)
{
for (auto &res : *secondary_resources)
{
if (res.name == pls.name)
{
ret.push_back({ res.id, pls.format });
found = true;
break;
}
}
}
if (!found)
fprintf(stderr, "Did not find stage input/output/target with name \"%s\".\n", pls.name.c_str());
}
return ret;
}
static PlsFormat pls_format(const char *str)
{
if (!strcmp(str, "r11f_g11f_b10f"))
return PlsR11FG11FB10F;
else if (!strcmp(str, "r32f"))
return PlsR32F;
else if (!strcmp(str, "rg16f"))
return PlsRG16F;
else if (!strcmp(str, "rg16"))
return PlsRG16;
else if (!strcmp(str, "rgb10_a2"))
return PlsRGB10A2;
else if (!strcmp(str, "rgba8"))
return PlsRGBA8;
else if (!strcmp(str, "rgba8i"))
return PlsRGBA8I;
else if (!strcmp(str, "rgba8ui"))
return PlsRGBA8UI;
else if (!strcmp(str, "rg16i"))
return PlsRG16I;
else if (!strcmp(str, "rgb10_a2ui"))
return PlsRGB10A2UI;
else if (!strcmp(str, "rg16ui"))
return PlsRG16UI;
else if (!strcmp(str, "r32ui"))
return PlsR32UI;
else
return PlsNone;
}
int main(int argc, char *argv[])
{
CLIArguments args;
CLICallbacks cbs;
cbs.add("--help", [](CLIParser &parser) {
print_help();
parser.end();
});
cbs.add("--output", [&args](CLIParser &parser) { args.output = parser.next_string(); });
cbs.add("--es", [&args](CLIParser &) {
args.es = true;
args.set_es = true;
});
cbs.add("--no-es", [&args](CLIParser &) {
args.es = false;
args.set_es = true;
});
cbs.add("--version", [&args](CLIParser &parser) {
args.version = parser.next_uint();
args.set_version = true;
});
cbs.add("--no-cfg-analysis", [&args](CLIParser &) { args.cfg_analysis = false; });
cbs.add("--dump-resources", [&args](CLIParser &) { args.dump_resources = true; });
cbs.add("--force-temporary", [&args](CLIParser &) { args.force_temporary = true; });
cbs.add("--flatten-ubo", [&args](CLIParser &) { args.flatten_ubo = true; });
cbs.add("--fixup-clipspace", [&args](CLIParser &) { args.fixup = true; });
cbs.add("--iterations", [&args](CLIParser &parser) { args.iterations = parser.next_uint(); });
cbs.add("--cpp", [&args](CLIParser &) { args.cpp = true; });
cbs.add("--cpp-interface-name", [&args](CLIParser &parser) { args.cpp_interface_name = parser.next_string(); });
cbs.add("--metal", [&args](CLIParser &) { args.metal = true; });
cbs.add("--vulkan-semantics", [&args](CLIParser &) { args.vulkan_semantics = true; });
cbs.add("--extension", [&args](CLIParser &parser) { args.extensions.push_back(parser.next_string()); });
cbs.add("--entry", [&args](CLIParser &parser) { args.entry = parser.next_string(); });
cbs.add("--remap", [&args](CLIParser &parser) {
string src = parser.next_string();
string dst = parser.next_string();
uint32_t components = parser.next_uint();
args.remaps.push_back({ move(src), move(dst), components });
});
cbs.add("--remap-variable-type", [&args](CLIParser &parser) {
string var_name = parser.next_string();
string new_type = parser.next_string();
args.variable_type_remaps.push_back({ move(var_name), move(new_type) });
});
cbs.add("--pls-in", [&args](CLIParser &parser) {
auto fmt = pls_format(parser.next_string());
auto name = parser.next_string();
args.pls_in.push_back({ move(fmt), move(name) });
});
cbs.add("--pls-out", [&args](CLIParser &parser) {
auto fmt = pls_format(parser.next_string());
auto name = parser.next_string();
args.pls_out.push_back({ move(fmt), move(name) });
});
cbs.add("--remove-unused-variables", [&args](CLIParser &) { args.remove_unused = true; });
cbs.default_handler = [&args](const char *value) { args.input = value; };
cbs.error_handler = [] { print_help(); };
CLIParser parser{ move(cbs), argc - 1, argv + 1 };
if (!parser.parse())
{
return EXIT_FAILURE;
}
else if (parser.ended_state)
{
return EXIT_SUCCESS;
}
if (!args.input)
{
fprintf(stderr, "Didn't specify input file.\n");
print_help();
return EXIT_FAILURE;
}
unique_ptr<CompilerGLSL> compiler;
bool combined_image_samplers = false;
if (args.cpp)
{
compiler = unique_ptr<CompilerGLSL>(new CompilerCPP(read_spirv_file(args.input)));
if (args.cpp_interface_name)
static_cast<CompilerCPP *>(compiler.get())->set_interface_name(args.cpp_interface_name);
}
else if (args.metal)
compiler = unique_ptr<CompilerMSL>(new CompilerMSL(read_spirv_file(args.input)));
else
{
combined_image_samplers = !args.vulkan_semantics;
compiler = unique_ptr<CompilerGLSL>(new CompilerGLSL(read_spirv_file(args.input)));
}
if (!args.variable_type_remaps.empty())
{
auto remap_cb = [&](const SPIRType &, const string &name, string &out) -> void {
for (const VariableTypeRemap &remap : args.variable_type_remaps)
if (name == remap.variable_name)
out = remap.new_variable_type;
};
compiler->set_variable_type_remap_callback(move(remap_cb));
}
if (!args.entry.empty())
compiler->set_entry_point(args.entry);
if (!args.set_version && !compiler->get_options().version)
{
fprintf(stderr, "Didn't specify GLSL version and SPIR-V did not specify language.\n");
print_help();
return EXIT_FAILURE;
}
CompilerGLSL::Options opts = compiler->get_options();
if (args.set_version)
opts.version = args.version;
if (args.set_es)
opts.es = args.es;
opts.force_temporary = args.force_temporary;
opts.vulkan_semantics = args.vulkan_semantics;
opts.vertex.fixup_clipspace = args.fixup;
opts.cfg_analysis = args.cfg_analysis;
compiler->set_options(opts);
ShaderResources res;
if (args.remove_unused)
{
auto active = compiler->get_active_interface_variables();
res = compiler->get_shader_resources(active);
compiler->set_enabled_interface_variables(move(active));
}
else
res = compiler->get_shader_resources();
if (args.flatten_ubo)
for (auto &ubo : res.uniform_buffers)
compiler->flatten_interface_block(ubo.id);
auto pls_inputs = remap_pls(args.pls_in, res.stage_inputs, &res.subpass_inputs);
auto pls_outputs = remap_pls(args.pls_out, res.stage_outputs, nullptr);
compiler->remap_pixel_local_storage(move(pls_inputs), move(pls_outputs));
for (auto &ext : args.extensions)
compiler->require_extension(ext);
for (auto &remap : args.remaps)
{
if (remap_generic(*compiler, res.stage_inputs, remap))
continue;
if (remap_generic(*compiler, res.stage_outputs, remap))
continue;
if (remap_generic(*compiler, res.subpass_inputs, remap))
continue;
}
if (args.dump_resources)
{
print_resources(*compiler, res);
print_push_constant_resources(*compiler, res.push_constant_buffers);
print_spec_constants(*compiler);
}
if (combined_image_samplers)
{
compiler->build_combined_image_samplers();
// Give the remapped combined samplers new names.
for (auto &remap : compiler->get_combined_image_samplers())
{
compiler->set_name(remap.combined_id, join("SPIRV_Cross_Combined", compiler->get_name(remap.image_id),
compiler->get_name(remap.sampler_id)));
}
}
string glsl;
for (uint32_t i = 0; i < args.iterations; i++)
glsl = compiler->compile();
if (args.output)
write_string_to_file(args.output, glsl.c_str());
else
printf("%s", glsl.c_str());
}

28
deps/SPIRV-Cross/msvc/SPIRV-Cross.sln vendored Normal file
View File

@ -0,0 +1,28 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Express 2013 for Windows Desktop
VisualStudioVersion = 12.0.31101.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SPIRV-Cross", "SPIRV-Cross.vcxproj", "{977E3701-1A21-4425-B7E5-6BDF5EA062CD}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Release|Win32 = Release|Win32
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{977E3701-1A21-4425-B7E5-6BDF5EA062CD}.Debug|Win32.ActiveCfg = Debug|Win32
{977E3701-1A21-4425-B7E5-6BDF5EA062CD}.Debug|Win32.Build.0 = Debug|Win32
{977E3701-1A21-4425-B7E5-6BDF5EA062CD}.Debug|x64.ActiveCfg = Debug|x64
{977E3701-1A21-4425-B7E5-6BDF5EA062CD}.Debug|x64.Build.0 = Debug|x64
{977E3701-1A21-4425-B7E5-6BDF5EA062CD}.Release|Win32.ActiveCfg = Release|Win32
{977E3701-1A21-4425-B7E5-6BDF5EA062CD}.Release|Win32.Build.0 = Release|Win32
{977E3701-1A21-4425-B7E5-6BDF5EA062CD}.Release|x64.ActiveCfg = Release|x64
{977E3701-1A21-4425-B7E5-6BDF5EA062CD}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,146 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{977E3701-1A21-4425-B7E5-6BDF5EA062CD}</ProjectGuid>
<RootNamespace>SPIRV-Cross</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\main.cpp" />
<ClCompile Include="..\spirv_cpp.cpp" />
<ClCompile Include="..\spirv_cross.cpp" />
<ClCompile Include="..\spirv_glsl.cpp" />
<ClCompile Include="..\spirv_msl.cpp" />
<ClCompile Include="..\spirv_cfg.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\GLSL.std.450.h" />
<ClInclude Include="..\spirv_common.hpp" />
<ClInclude Include="..\spirv_cpp.hpp" />
<ClInclude Include="..\spirv_cross.hpp" />
<ClInclude Include="..\spirv_glsl.hpp" />
<ClInclude Include="..\spirv.hpp" />
<ClInclude Include="..\spirv_msl.hpp" />
<ClInclude Include="..\spirv_cfg.hpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,63 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\spirv_cross.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\spirv_glsl.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\spirv_cpp.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\spirv_msl.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\spirv_cfg.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\GLSL.std.450.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\spirv_cross.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\spirv_glsl.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\spirv.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\spirv_common.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\spirv_cpp.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\spirv_msl.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\spirv_cfg.hpp">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@ -0,0 +1,27 @@
#version 310 es
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
layout(binding = 0, std430) restrict buffer _3
{
ivec4 _0;
uvec4 _1;
} _5;
layout(binding = 1, std430) restrict buffer _4
{
uvec4 _0;
ivec4 _1;
} _6;
void main()
{
_6._0 = _5._1 + uvec4(_5._0);
_6._0 = uvec4(_5._0) + _5._1;
_6._0 = _5._1 + _5._1;
_6._0 = uvec4(_5._0 + _5._0);
_6._1 = ivec4(_5._1 + _5._1);
_6._1 = _5._0 + _5._0;
_6._1 = ivec4(_5._1) + _5._0;
_6._1 = _5._0 + ivec4(_5._1);
}

View File

@ -0,0 +1,31 @@
#version 310 es
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
layout(binding = 0, std430) buffer _3
{
ivec4 _0;
uvec4 _1;
} _5;
layout(binding = 1, std430) buffer _4
{
uvec4 _0;
ivec4 _1;
} _6;
void main()
{
bvec4 _34 = equal(ivec4(_5._1), _5._0);
bvec4 _35 = equal(_5._0, ivec4(_5._1));
bvec4 _36 = equal(_5._1, _5._1);
bvec4 _37 = equal(_5._0, _5._0);
_6._0 = mix(uvec4(0u), uvec4(1u), _34);
_6._0 = mix(uvec4(0u), uvec4(1u), _35);
_6._0 = mix(uvec4(0u), uvec4(1u), _36);
_6._0 = mix(uvec4(0u), uvec4(1u), _37);
_6._1 = mix(ivec4(0), ivec4(1), _34);
_6._1 = mix(ivec4(0), ivec4(1), _35);
_6._1 = mix(ivec4(0), ivec4(1), _36);
_6._1 = mix(ivec4(0), ivec4(1), _37);
}

View File

@ -0,0 +1,27 @@
#version 310 es
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
layout(binding = 0, std430) buffer _3
{
ivec4 _0;
uvec4 _1;
} _5;
layout(binding = 1, std430) buffer _4
{
uvec4 _0;
ivec4 _1;
} _6;
void main()
{
_6._0 = uvec4(ivec4(_5._1) >> _5._0);
_6._0 = uvec4(_5._0 >> ivec4(_5._1));
_6._0 = uvec4(ivec4(_5._1) >> ivec4(_5._1));
_6._0 = uvec4(_5._0 >> _5._0);
_6._1 = ivec4(_5._1) >> ivec4(_5._1);
_6._1 = _5._0 >> _5._0;
_6._1 = ivec4(_5._1) >> _5._0;
_6._1 = _5._0 >> ivec4(_5._1);
}

View File

@ -0,0 +1,27 @@
#version 310 es
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
layout(binding = 0, std430) buffer _3
{
ivec4 _0;
uvec4 _1;
} _5;
layout(binding = 1, std430) buffer _4
{
uvec4 _0;
ivec4 _1;
} _6;
void main()
{
_6._0 = uvec4(ivec4(_5._1) / _5._0);
_6._0 = uvec4(_5._0 / ivec4(_5._1));
_6._0 = uvec4(ivec4(_5._1) / ivec4(_5._1));
_6._0 = uvec4(_5._0 / _5._0);
_6._1 = ivec4(_5._1) / ivec4(_5._1);
_6._1 = _5._0 / _5._0;
_6._1 = ivec4(_5._1) / _5._0;
_6._1 = _5._0 / ivec4(_5._1);
}

View File

@ -0,0 +1,27 @@
#version 310 es
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
layout(binding = 0, std430) buffer _3
{
ivec4 _0;
uvec4 _1;
} _5;
layout(binding = 1, std430) buffer _4
{
uvec4 _0;
ivec4 _1;
} _6;
void main()
{
_6._0 = _5._1 >> uvec4(_5._0);
_6._0 = uvec4(_5._0) >> _5._1;
_6._0 = _5._1 >> _5._1;
_6._0 = uvec4(_5._0) >> uvec4(_5._0);
_6._1 = ivec4(_5._1 >> _5._1);
_6._1 = ivec4(uvec4(_5._0) >> uvec4(_5._0));
_6._1 = ivec4(_5._1 >> uvec4(_5._0));
_6._1 = ivec4(uvec4(_5._0) >> _5._1);
}

View File

@ -0,0 +1,27 @@
#version 310 es
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
layout(binding = 0, std430) buffer _3
{
ivec4 _0;
uvec4 _1;
} _5;
layout(binding = 1, std430) buffer _4
{
uvec4 _0;
ivec4 _1;
} _6;
void main()
{
_6._0 = _5._1 / uvec4(_5._0);
_6._0 = uvec4(_5._0) / _5._1;
_6._0 = _5._1 / _5._1;
_6._0 = uvec4(_5._0) / uvec4(_5._0);
_6._1 = ivec4(_5._1 / _5._1);
_6._1 = ivec4(uvec4(_5._0) / uvec4(_5._0));
_6._1 = ivec4(_5._1 / uvec4(_5._0));
_6._1 = ivec4(uvec4(_5._0) / _5._1);
}

View File

@ -0,0 +1,27 @@
#version 310 es
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
layout(binding = 0, std430) restrict buffer _6
{
ivec4 _0;
uvec4 _1;
} _8;
layout(binding = 1, std430) restrict buffer _7
{
uvec4 _0;
ivec4 _1;
} _9;
void main()
{
_9._0 = _8._1 + uvec4(_8._0);
_9._0 = uvec4(_8._0) + _8._1;
_9._0 = _8._1 + _8._1;
_9._0 = uvec4(_8._0 + _8._0);
_9._1 = ivec4(_8._1 + _8._1);
_9._1 = _8._0 + _8._0;
_9._1 = ivec4(_8._1) + _8._0;
_9._1 = _8._0 + ivec4(_8._1);
}

View File

@ -0,0 +1,37 @@
#version 310 es
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
struct alias
{
vec3 alias[100];
};
struct alias_1
{
vec4 alias;
vec2 alias_1[10];
alias alias_2[2];
};
struct alias_2
{
vec4 alias;
alias_1 alias_1;
};
layout(binding = 0, std430) buffer _10
{
alias_2 alias;
} alias_3;
layout(binding = 1, std140) buffer _15
{
alias_2 alias;
} alias_4;
void main()
{
alias_2 alias_5 = alias_3.alias;
alias_4.alias = alias_5;
}

View File

@ -0,0 +1,19 @@
#version 310 es
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
layout(binding = 0, std430) buffer SSBO0
{
float scalar;
vec2 vec2_val;
vec3 vec3_val;
vec4 vec4_val;
} _4;
void main()
{
_4.scalar = unpackHalf2x16(packHalf2x16(vec2(_4.scalar))).x;
_4.vec2_val = unpackHalf2x16(packHalf2x16(_4.vec2_val));
_4.vec3_val = vec3(unpackHalf2x16(packHalf2x16(_4.vec3_val.xy)), unpackHalf2x16(packHalf2x16(_4.vec3_val.zz)).x);
_4.vec4_val = vec4(unpackHalf2x16(packHalf2x16(_4.vec4_val.xy)), unpackHalf2x16(packHalf2x16(_4.vec4_val.zw)));
}

View File

@ -0,0 +1,15 @@
#version 450
in float v0;
in float v1;
out float FragColor;
void main()
{
float a = v0;
float b = v1;
float _17 = a;
a = v1;
FragColor = (_17 + b) * b;
}

View File

@ -0,0 +1,49 @@
#version 310 es
#extension GL_OES_shader_image_atomic : require
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
layout(binding = 2, std430) buffer SSBO
{
uint u32;
int i32;
} ssbo;
layout(binding = 0, r32ui) uniform highp uimage2D uImage;
layout(binding = 1, r32i) uniform highp iimage2D iImage;
void main()
{
uint _19 = imageAtomicAdd(uImage, ivec2(1, 5), 1u);
uint _27 = imageAtomicAdd(uImage, ivec2(1, 5), 1u);
imageStore(iImage, ivec2(1, 6), ivec4(int(_27)));
uint _32 = imageAtomicOr(uImage, ivec2(1, 5), 1u);
uint _34 = imageAtomicXor(uImage, ivec2(1, 5), 1u);
uint _36 = imageAtomicAnd(uImage, ivec2(1, 5), 1u);
uint _38 = imageAtomicMin(uImage, ivec2(1, 5), 1u);
uint _40 = imageAtomicMax(uImage, ivec2(1, 5), 1u);
uint _44 = imageAtomicCompSwap(uImage, ivec2(1, 5), 10u, 2u);
int _47 = imageAtomicAdd(iImage, ivec2(1, 6), 1);
int _49 = imageAtomicOr(iImage, ivec2(1, 6), 1);
int _51 = imageAtomicXor(iImage, ivec2(1, 6), 1);
int _53 = imageAtomicAnd(iImage, ivec2(1, 6), 1);
int _55 = imageAtomicMin(iImage, ivec2(1, 6), 1);
int _57 = imageAtomicMax(iImage, ivec2(1, 6), 1);
int _61 = imageAtomicCompSwap(iImage, ivec2(1, 5), 10, 2);
uint _68 = atomicAdd(ssbo.u32, 1u);
uint _70 = atomicOr(ssbo.u32, 1u);
uint _72 = atomicXor(ssbo.u32, 1u);
uint _74 = atomicAnd(ssbo.u32, 1u);
uint _76 = atomicMin(ssbo.u32, 1u);
uint _78 = atomicMax(ssbo.u32, 1u);
uint _80 = atomicExchange(ssbo.u32, 1u);
uint _82 = atomicCompSwap(ssbo.u32, 10u, 2u);
int _85 = atomicAdd(ssbo.i32, 1);
int _87 = atomicOr(ssbo.i32, 1);
int _89 = atomicXor(ssbo.i32, 1);
int _91 = atomicAnd(ssbo.i32, 1);
int _93 = atomicMin(ssbo.i32, 1);
int _95 = atomicMax(ssbo.i32, 1);
int _97 = atomicExchange(ssbo.i32, 1);
int _99 = atomicCompSwap(ssbo.i32, 10, 2);
}

View File

@ -0,0 +1,39 @@
#version 310 es
layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in;
layout(binding = 4, std140) uniform UBO
{
vec4 uInvSize;
vec4 uScale;
} _46;
layout(binding = 0) uniform mediump sampler2D uHeight;
layout(binding = 1) uniform mediump sampler2D uDisplacement;
layout(binding = 2, rgba16f) uniform mediump writeonly image2D iHeightDisplacement;
layout(binding = 3, rgba16f) uniform mediump writeonly image2D iGradJacobian;
mediump float jacobian(mediump vec2 dDdx, mediump vec2 dDdy)
{
return ((1.0 + dDdx.x) * (1.0 + dDdy.y)) - (dDdx.y * dDdy.x);
}
void main()
{
vec4 uv = (vec2(gl_GlobalInvocationID.xy) * _46.uInvSize.xy).xyxy + (_46.uInvSize * 0.5);
float h = textureLod(uHeight, uv.xy, 0.0).x;
float x0 = textureLodOffset(uHeight, uv.xy, 0.0, ivec2(-1, 0)).x;
float x1 = textureLodOffset(uHeight, uv.xy, 0.0, ivec2(1, 0)).x;
float y0 = textureLodOffset(uHeight, uv.xy, 0.0, ivec2(0, -1)).x;
float y1 = textureLodOffset(uHeight, uv.xy, 0.0, ivec2(0, 1)).x;
vec2 grad = (_46.uScale.xy * 0.5) * vec2(x1 - x0, y1 - y0);
vec2 displacement = textureLod(uDisplacement, uv.zw, 0.0).xy * 1.2000000476837158203125;
vec2 dDdx = (textureLodOffset(uDisplacement, uv.zw, 0.0, ivec2(1, 0)).xy - textureLodOffset(uDisplacement, uv.zw, 0.0, ivec2(-1, 0)).xy) * 0.60000002384185791015625;
vec2 dDdy = (textureLodOffset(uDisplacement, uv.zw, 0.0, ivec2(0, 1)).xy - textureLodOffset(uDisplacement, uv.zw, 0.0, ivec2(0, -1)).xy) * 0.60000002384185791015625;
vec2 param = dDdx * _46.uScale.z;
vec2 param_1 = dDdy * _46.uScale.z;
float j = jacobian(param, param_1);
displacement = vec2(0.0);
imageStore(iHeightDisplacement, ivec2(gl_GlobalInvocationID.xy), vec4(h, displacement, 0.0));
imageStore(iGradJacobian, ivec2(gl_GlobalInvocationID.xy), vec4(grad, j, 0.0));
}

View File

@ -0,0 +1,29 @@
#version 310 es
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
layout(binding = 0, std430) buffer SSBO
{
vec4 in_data[];
} _23;
layout(binding = 1, std430) buffer SSBO2
{
vec4 out_data[];
} _45;
layout(binding = 2, std430) buffer SSBO3
{
uint counter;
} _48;
void main()
{
uint ident = gl_GlobalInvocationID.x;
vec4 idata = _23.in_data[ident];
if (dot(idata, vec4(1.0, 5.0, 6.0, 2.0)) > 8.19999980926513671875)
{
uint _52 = atomicAdd(_48.counter, 1u);
_45.out_data[_52] = idata;
}
}

View File

@ -0,0 +1,19 @@
#version 310 es
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
layout(binding = 1, std430) buffer SSBO1
{
ivec4 outputs[];
} _21;
layout(binding = 0, std430) buffer SSBO0
{
ivec4 inputs[];
} _27;
void main()
{
uint ident = gl_GlobalInvocationID.x;
_21.outputs[ident] = mix(ivec4(0), ivec4(1), notEqual((_27.inputs[ident] & ivec4(3)), ivec4(uvec4(0u))));
}

View File

@ -0,0 +1,81 @@
#version 310 es
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
layout(binding = 0, std430) buffer SSBO
{
float data;
} _11;
void test()
{
float m;
if (_11.data != 0.0)
{
float tmp = 10.0;
_11.data = tmp;
}
else
{
float tmp_1 = 15.0;
_11.data = tmp_1;
}
if (_11.data != 0.0)
{
float e;
if (_11.data != 5.0)
{
if (_11.data != 6.0)
{
e = 10.0;
}
}
else
{
e = 20.0;
}
}
switch (int(_11.data))
{
case 0:
{
float tmp_2 = 20.0;
_11.data = tmp_2;
break;
}
case 1:
{
float tmp_3 = 30.0;
_11.data = tmp_3;
break;
}
}
float f;
switch (int(_11.data))
{
case 0:
{
f = 30.0;
break;
}
case 1:
{
f = 40.0;
break;
}
}
float h;
for (int i = 0; i < 20; i++, h += 10.0)
{
}
_11.data = h;
do
{
} while (m != 20.0);
_11.data = m;
}
void main()
{
test();
}

View File

@ -0,0 +1,38 @@
#version 310 es
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
struct Composite
{
vec4 a[2];
vec4 b[2];
};
layout(binding = 0, std430) buffer SSBO0
{
vec4 as[];
} _41;
layout(binding = 1, std430) buffer SSBO1
{
vec4 bs[];
} _55;
vec4 summe(vec4 values[3][2])
{
return ((values[0][0] + values[2][1]) + values[0][1]) + values[1][0];
}
void main()
{
vec4 values[2] = vec4[](_41.as[gl_GlobalInvocationID.x], _55.bs[gl_GlobalInvocationID.x]);
vec4 const_values[2] = vec4[](vec4(10.0), vec4(30.0));
vec4 copy_values[2] = const_values;
vec4 copy_values2[2] = values;
vec4 param[3][2] = vec4[][](values, copy_values, copy_values2);
_41.as[gl_GlobalInvocationID.x] = summe(param);
Composite c = Composite(values, copy_values);
float arrayofarray[2][3] = float[][](float[](1.0, 1.0, 1.0), float[](2.0, 2.0, 2.0));
float b = 10.0;
float values_scalar[4] = float[](b, b, b, b);
}

View File

@ -0,0 +1,29 @@
#version 310 es
layout(local_size_x = 4, local_size_y = 1, local_size_z = 1) in;
layout(binding = 0, std430) buffer SSBO
{
float in_data[];
} _22;
layout(binding = 1, std430) buffer SSBO2
{
float out_data[];
} _38;
layout(binding = 2, std430) buffer SSBO3
{
uint count;
} _41;
void main()
{
uint ident = gl_GlobalInvocationID.x;
float idata = _22.in_data[ident];
if (idata > 12.0)
{
uint _45 = atomicAdd(_41.count, 1u);
_38.out_data[_45] = idata;
}
}

View File

@ -0,0 +1,21 @@
#version 310 es
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
layout(binding = 0, std430) buffer SSBO
{
vec4 data;
int index;
} _13;
void main()
{
vec4 d = _13.data;
_13.data = vec4(d.x, d.yz + vec2(10.0), d.w);
_13.data = (d + d) + d;
_13.data = (d.yz + vec2(10.0)).xxyy;
float t = (d.yz + vec2(10.0)).y;
_13.data = vec4(t);
t = (d.zw + vec2(10.0))[_13.index];
_13.data = vec4(t);
}

View File

@ -0,0 +1,29 @@
#version 310 es
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
layout(binding = 0, std430) buffer SSBO
{
mat4 mvp;
vec4 in_data[];
} _28;
layout(binding = 1, std430) buffer SSBO2
{
vec4 out_data[];
} _52;
int i;
void main()
{
uint ident = gl_GlobalInvocationID.x;
i = 0;
vec4 idat = _28.in_data[ident];
do
{
idat = _28.mvp * idat;
i++;
} while (i < 16);
_52.out_data[ident] = idat;
}

View File

@ -0,0 +1,96 @@
#version 310 es
layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in;
layout(binding = 0, std430) buffer Distribution
{
vec2 distribution[];
} _190;
layout(binding = 2, std140) uniform UBO
{
vec4 uModTime;
} _218;
layout(binding = 1, std430) buffer HeightmapFFT
{
uint heights[];
} _276;
uvec2 workaround_mix(uvec2 a, uvec2 b, bvec2 sel)
{
uint _137;
if (sel.x)
{
_137 = b.x;
}
else
{
_137 = a.x;
}
uint _147 = _137;
uint _148;
if (sel.y)
{
_148 = b.y;
}
else
{
_148 = a.y;
}
return uvec2(_147, _148);
}
vec2 alias(vec2 i, vec2 N)
{
return mix(i, i - N, greaterThan(i, N * 0.5));
}
vec2 cmul(vec2 a, vec2 b)
{
vec2 r3 = a.yx;
vec2 r1 = b.xx;
vec2 R0 = a * r1;
vec2 r2 = b.yy;
vec2 R1 = r2 * r3;
return R0 + vec2(-R1.x, R1.y);
}
uint pack2(vec2 v)
{
return packHalf2x16(v);
}
void generate_heightmap()
{
uvec2 N = uvec2(64u, 1u) * gl_NumWorkGroups.xy;
uvec2 i = gl_GlobalInvocationID.xy;
uvec2 param = N - i;
uvec2 param_1 = uvec2(0u);
bvec2 param_2 = equal(i, uvec2(0u));
uvec2 wi = workaround_mix(param, param_1, param_2);
vec2 a = _190.distribution[(i.y * N.x) + i.x];
vec2 b = _190.distribution[(wi.y * N.x) + wi.x];
vec2 param_3 = vec2(i);
vec2 param_4 = vec2(N);
vec2 k = _218.uModTime.xy * alias(param_3, param_4);
float k_len = length(k);
float w = sqrt(9.81000041961669921875 * k_len) * _218.uModTime.z;
float cw = cos(w);
float sw = sin(w);
vec2 param_5 = a;
vec2 param_6 = vec2(cw, sw);
a = cmul(param_5, param_6);
vec2 param_7 = b;
vec2 param_8 = vec2(cw, sw);
b = cmul(param_7, param_8);
b = vec2(b.x, -b.y);
vec2 res = a + b;
vec2 param_9 = res;
_276.heights[(i.y * N.x) + i.x] = pack2(param_9);
}
void main()
{
generate_heightmap();
}

View File

@ -0,0 +1,12 @@
#version 310 es
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
layout(binding = 0, rgba8) uniform mediump readonly image2D uImageIn;
layout(binding = 1, rgba8) uniform mediump writeonly image2D uImageOut;
void main()
{
vec4 v = imageLoad(uImageIn, ivec2(gl_GlobalInvocationID.xy) + imageSize(uImageIn));
imageStore(uImageOut, ivec2(gl_GlobalInvocationID.xy), v);
}

View File

@ -0,0 +1,65 @@
#version 310 es
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
struct Foo
{
vec4 a;
vec4 b;
vec4 c;
vec4 d;
};
layout(binding = 1, std430) buffer SSBO2
{
vec4 data[];
} indata;
layout(binding = 0, std430) buffer SSBO
{
vec4 data[];
} outdata;
layout(binding = 2, std430) buffer SSBO3
{
Foo foos[];
} foobar;
void baz(out Foo foo)
{
uint ident = gl_GlobalInvocationID.x;
foo.a = indata.data[(4u * ident) + 0u];
foo.b = indata.data[(4u * ident) + 1u];
foo.c = indata.data[(4u * ident) + 2u];
foo.d = indata.data[(4u * ident) + 3u];
}
void meow(inout Foo foo)
{
foo.a += vec4(10.0);
foo.b += vec4(20.0);
foo.c += vec4(30.0);
foo.d += vec4(40.0);
}
vec4 bar(Foo foo)
{
return ((foo.a + foo.b) + foo.c) + foo.d;
}
void main()
{
Foo param;
baz(param);
Foo foo = param;
Foo param_1 = foo;
meow(param_1);
foo = param_1;
Foo param_2 = foo;
Foo param_3;
param_3.a = foobar.foos[gl_GlobalInvocationID.x].a;
param_3.b = foobar.foos[gl_GlobalInvocationID.x].b;
param_3.c = foobar.foos[gl_GlobalInvocationID.x].c;
param_3.d = foobar.foos[gl_GlobalInvocationID.x].d;
outdata.data[gl_GlobalInvocationID.x] = bar(param_2) + bar(param_3);
}

View File

@ -0,0 +1,19 @@
#version 310 es
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
layout(binding = 0, std430) buffer SSBO
{
vec4 out_data[];
} _27;
void main()
{
vec4 v;
v.x = 10.0;
v.y = 30.0;
v.z = 70.0;
v.w = 90.0;
_27.out_data[gl_GlobalInvocationID.x] = v;
_27.out_data[gl_GlobalInvocationID.x].y = 20.0;
}

View File

@ -0,0 +1,105 @@
#version 310 es
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
layout(binding = 0, std430) buffer SSBO
{
mat4 mvp;
vec4 in_data[];
} _24;
layout(binding = 1, std430) buffer SSBO2
{
vec4 out_data[];
} _177;
void main()
{
uint ident = gl_GlobalInvocationID.x;
vec4 idat = _24.in_data[ident];
int k = 0;
uint i = 0u;
if (idat.y == 20.0)
{
do
{
k *= 2;
i++;
} while (i < ident);
}
switch (k)
{
case 10:
{
for (;;)
{
i++;
if (i > 10u)
{
break;
}
continue;
}
break;
}
default:
{
for (;;)
{
i += 2u;
if (i > 20u)
{
break;
}
continue;
}
break;
}
}
while (k < 10)
{
idat *= 2.0;
k++;
}
for (uint i_1 = 0u; i_1 < 16u; i_1++, k++)
{
for (uint j = 0u; j < 30u; j++)
{
idat = _24.mvp * idat;
}
}
k = 0;
for (;;)
{
k++;
if (k > 10)
{
k += 2;
}
else
{
k += 3;
continue;
}
k += 10;
continue;
}
k = 0;
do
{
k++;
} while (k > 10);
int l = 0;
for (;;)
{
if (l == 5)
{
l++;
continue;
}
idat += vec4(1.0);
l++;
continue;
}
_177.out_data[ident] = idat;
}

View File

@ -0,0 +1,14 @@
#version 310 es
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
layout(binding = 1, std430) buffer SSBO2
{
mat3 out_data[];
} _22;
void main()
{
uint ident = gl_GlobalInvocationID.x;
_22.out_data[ident] = mat3(vec3(10.0), vec3(20.0), vec3(40.0));
}

View File

@ -0,0 +1,24 @@
#version 310 es
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
layout(binding = 0, std430) buffer SSBO
{
vec4 in_data[];
} _23;
layout(binding = 1, std430) buffer SSBO2
{
vec4 out_data[];
} _33;
void main()
{
uint ident = gl_GlobalInvocationID.x;
vec4 v = mod(_23.in_data[ident], _33.out_data[ident]);
_33.out_data[ident] = v;
uvec4 vu = floatBitsToUint(_23.in_data[ident]) % floatBitsToUint(_33.out_data[ident]);
_33.out_data[ident] = uintBitsToFloat(vu);
ivec4 vi = floatBitsToInt(_23.in_data[ident]) % floatBitsToInt(_33.out_data[ident]);
_33.out_data[ident] = intBitsToFloat(vi);
}

View File

@ -0,0 +1,22 @@
#version 310 es
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
layout(binding = 0, std430) buffer SSBO
{
vec4 in_data[];
} _23;
layout(binding = 1, std430) buffer SSBO2
{
vec4 out_data[];
} _35;
void main()
{
uint ident = gl_GlobalInvocationID.x;
vec4 i;
vec4 _31 = modf(_23.in_data[ident], i);
vec4 v = _31;
_35.out_data[ident] = v;
}

View File

@ -0,0 +1,34 @@
#version 310 es
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
layout(binding = 1, std430) buffer SSBO2
{
vec4 out_data[];
} _27;
void main()
{
uint ident = gl_GlobalInvocationID.x;
if (ident == 2u)
{
_27.out_data[ident] = vec4(20.0);
}
else
{
if (ident == 4u)
{
_27.out_data[ident] = vec4(10.0);
return;
}
}
for (int i = 0; i < 20; i++)
{
if (i == 10)
{
break;
}
return;
}
_27.out_data[ident] = vec4(10.0);
}

View File

@ -0,0 +1,25 @@
#version 310 es
layout(local_size_x = 4, local_size_y = 1, local_size_z = 1) in;
layout(binding = 0, std430) buffer SSBO
{
float in_data[];
} _22;
layout(binding = 1, std430) buffer SSBO2
{
float out_data[];
} _44;
shared float sShared[4];
void main()
{
uint ident = gl_GlobalInvocationID.x;
float idata = _22.in_data[ident];
sShared[gl_LocalInvocationIndex] = idata;
memoryBarrierShared();
barrier();
_44.out_data[ident] = sShared[(4u - gl_LocalInvocationIndex) - 1u];
}

View File

@ -0,0 +1,14 @@
#version 310 es
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
layout(binding = 0, std430) buffer SSBO
{
vec4 data[];
} ssbos[2];
void main()
{
uint ident = gl_GlobalInvocationID.x;
ssbos[1].data[ident] = ssbos[0].data[ident];
}

View File

@ -0,0 +1,24 @@
#version 310 es
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
struct Foo
{
mat4 m;
};
layout(binding = 1, std430) buffer SSBO2
{
Foo out_data[];
} _23;
layout(binding = 0, std430) buffer SSBO
{
Foo in_data[];
} _30;
void main()
{
uint ident = gl_GlobalInvocationID.x;
_23.out_data[ident].m = _30.in_data[ident].m * _30.in_data[ident].m;
}

View File

@ -0,0 +1,96 @@
#version 310 es
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
struct S0
{
vec2 a[1];
float b;
};
struct S1
{
vec3 a;
float b;
};
struct S2
{
vec3 a[1];
float b;
};
struct S3
{
vec2 a;
float b;
};
struct S4
{
vec2 c;
};
struct Content
{
S0 m0s[1];
S1 m1s[1];
S2 m2s[1];
S0 m0;
S1 m1;
S2 m2;
S3 m3;
float m4;
S4 m3s[8];
};
layout(binding = 1, std430) buffer SSBO1
{
Content content;
Content content1[2];
Content content2;
mat2 m0;
mat2 m1;
mat2x3 m2[4];
mat3x2 m3;
layout(row_major) mat2 m4;
layout(row_major) mat2 m5[9];
layout(row_major) mat2x3 m6[4][2];
layout(row_major) mat3x2 m7;
float array[];
} ssbo_430;
layout(binding = 0, std140) buffer SSBO0
{
Content content;
Content content1[2];
Content content2;
float array[];
} ssbo_140;
void main()
{
ssbo_430.content.m0s[0].a[0] = ssbo_140.content.m0s[0].a[0];
ssbo_430.content.m0s[0].b = ssbo_140.content.m0s[0].b;
ssbo_430.content.m1s[0].a = ssbo_140.content.m1s[0].a;
ssbo_430.content.m1s[0].b = ssbo_140.content.m1s[0].b;
ssbo_430.content.m2s[0].a[0] = ssbo_140.content.m2s[0].a[0];
ssbo_430.content.m2s[0].b = ssbo_140.content.m2s[0].b;
ssbo_430.content.m0.a[0] = ssbo_140.content.m0.a[0];
ssbo_430.content.m0.b = ssbo_140.content.m0.b;
ssbo_430.content.m1.a = ssbo_140.content.m1.a;
ssbo_430.content.m1.b = ssbo_140.content.m1.b;
ssbo_430.content.m2.a[0] = ssbo_140.content.m2.a[0];
ssbo_430.content.m2.b = ssbo_140.content.m2.b;
ssbo_430.content.m3.a = ssbo_140.content.m3.a;
ssbo_430.content.m3.b = ssbo_140.content.m3.b;
ssbo_430.content.m4 = ssbo_140.content.m4;
ssbo_430.content.m3s[0].c = ssbo_140.content.m3s[0].c;
ssbo_430.content.m3s[1].c = ssbo_140.content.m3s[1].c;
ssbo_430.content.m3s[2].c = ssbo_140.content.m3s[2].c;
ssbo_430.content.m3s[3].c = ssbo_140.content.m3s[3].c;
ssbo_430.content.m3s[4].c = ssbo_140.content.m3s[4].c;
ssbo_430.content.m3s[5].c = ssbo_140.content.m3s[5].c;
ssbo_430.content.m3s[6].c = ssbo_140.content.m3s[6].c;
ssbo_430.content.m3s[7].c = ssbo_140.content.m3s[7].c;
}

View File

@ -0,0 +1,49 @@
#version 310 es
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
layout(binding = 0, std430) buffer SSBO
{
mat4 mvp;
vec4 in_data[];
} _24;
layout(binding = 1, std430) buffer SSBO2
{
vec4 out_data[];
} _89;
void main()
{
uint ident = gl_GlobalInvocationID.x;
vec4 idat = _24.in_data[ident];
int k = 0;
for (;;)
{
int _39 = k;
int _40 = _39 + 1;
k = _40;
if (_40 < 10)
{
idat *= 2.0;
k++;
continue;
}
else
{
break;
}
}
for (uint i = 0u; i < 16u; i++, k++)
{
for (uint j = 0u; j < 30u; j++)
{
idat = _24.mvp * idat;
}
}
do
{
k++;
} while (k > 10);
_89.out_data[ident] = idat;
}

View File

@ -0,0 +1,49 @@
#version 310 es
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
struct S0
{
vec4 a;
};
struct S1
{
vec4 a;
};
layout(binding = 0, std430) buffer SSBO0
{
S0 s0s[];
} _36;
layout(binding = 1, std430) buffer SSBO1
{
S1 s1s[];
} _55;
layout(binding = 2, std430) buffer SSBO2
{
vec4 outputs[];
} _66;
vec4 overload(S0 s0)
{
return s0.a;
}
vec4 overload(S1 s1)
{
return s1.a;
}
void main()
{
S0 s0;
s0.a = _36.s0s[gl_GlobalInvocationID.x].a;
S1 s1;
s1.a = _55.s1s[gl_GlobalInvocationID.x].a;
S0 param = s0;
S1 param_1 = s1;
_66.outputs[gl_GlobalInvocationID.x] = overload(param) + overload(param_1);
}

View File

@ -0,0 +1,18 @@
#version 310 es
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
layout(binding = 0, std430) buffer SSBO2
{
uint outputs[];
} _10;
layout(binding = 0, std430) buffer SSBO
{
uint inputs[];
} _23;
void main()
{
_10.outputs[gl_GlobalInvocationID.x] = _23.inputs[gl_GlobalInvocationID.x] / 29u;
}

View File

@ -0,0 +1,84 @@
#version 450
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
struct M0
{
double v;
dvec2 b[2];
dmat2x3 c;
dmat3x2 d;
};
layout(binding = 0, std430) buffer SSBO0
{
dvec4 a;
M0 m0;
dmat4 b;
} ssbo_0;
layout(binding = 1, std430) buffer SSBO1
{
dmat4 a;
dvec4 b;
M0 m0;
} ssbo_1;
layout(binding = 2, std430) buffer SSBO2
{
double a[4];
dvec2 b[4];
} ssbo_2;
layout(binding = 3, std140) buffer SSBO3
{
double a[4];
dvec2 b[4];
} ssbo_3;
void main()
{
ssbo_0.a += dvec4(10.0lf, 20.0lf, 30.0lf, 40.0lf);
ssbo_0.a += dvec4(20.0lf);
dvec4 a = ssbo_0.a;
dmat4 amat = ssbo_0.b;
ssbo_0.a = abs(a);
ssbo_0.a = sign(a);
ssbo_0.a = floor(a);
ssbo_0.a = trunc(a);
ssbo_0.a = round(a);
ssbo_0.a = roundEven(a);
ssbo_0.a = ceil(a);
ssbo_0.a = fract(a);
ssbo_0.a = mod(a, dvec4(20.0lf));
ssbo_0.a = mod(a, a);
ssbo_0.a = min(a, a);
ssbo_0.a = max(a, a);
ssbo_0.a = clamp(a, a, a);
ssbo_0.a = mix(a, a, a);
ssbo_0.a = step(a, a);
ssbo_0.a = smoothstep(a, a, a);
bvec4 b = isnan(a);
bvec4 c = isinf(a);
double f = packDouble2x32(uvec2(10u, 40u));
uvec2 g = unpackDouble2x32(f);
double d = length(a);
d = distance(a, a);
d = dot(a, a);
dvec3 e = cross(a.xyz, a.yzw);
a = faceforward(a, a, a);
a = reflect(a, a);
a = refract(a, a, a.x);
dmat4 l = dmat4(amat[0] * amat[0], amat[1] * amat[1], amat[2] * amat[2], amat[3] * amat[3]);
l = outerProduct(a, a);
l = transpose(l);
double m = determinant(l);
l = inverse(l);
bvec4 k = lessThan(a, a);
k = lessThanEqual(a, a);
k = greaterThan(a, a);
k = greaterThanEqual(a, a);
ssbo_1.b.x += 1.0lf;
ssbo_2.b[0].x += 1.0lf;
ssbo_3.b[0].x += 1.0lf;
}

View File

@ -0,0 +1,47 @@
#version 450
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
layout(binding = 0, rgba32f) uniform readonly writeonly image2D uImg00;
layout(binding = 1, rgba16f) uniform readonly writeonly image2D uImg01;
layout(binding = 2, rg32f) uniform readonly writeonly image2D uImg02;
layout(binding = 3, rg16f) uniform readonly writeonly image2D uImg03;
layout(binding = 4, r11f_g11f_b10f) uniform readonly writeonly image2D uImg04;
layout(binding = 5, r32f) uniform readonly writeonly image2D uImg05;
layout(binding = 6, r16f) uniform readonly writeonly image2D uImg06;
layout(binding = 7, rgba16) uniform readonly writeonly image2D uImg07;
layout(binding = 8, rgb10_a2) uniform readonly writeonly image2D uImg08;
layout(binding = 9, rgba8) uniform readonly writeonly image2D uImg09;
layout(binding = 10, rg16) uniform readonly writeonly image2D uImg10;
layout(binding = 11, rg8) uniform readonly writeonly image2D uImg11;
layout(binding = 12, r16) uniform readonly writeonly image2D uImg12;
layout(binding = 13, r8) uniform readonly writeonly image2D uImg13;
layout(binding = 14, rgba16_snorm) uniform readonly writeonly image2D uImg14;
layout(binding = 15, rgba8_snorm) uniform readonly writeonly image2D uImg15;
layout(binding = 16, rg16_snorm) uniform readonly writeonly image2D uImg16;
layout(binding = 17, rg8_snorm) uniform readonly writeonly image2D uImg17;
layout(binding = 18, r16_snorm) uniform readonly writeonly image2D uImg18;
layout(binding = 19, r8_snorm) uniform readonly writeonly image2D uImg19;
layout(binding = 20, rgba32i) uniform readonly writeonly iimage2D uImage20;
layout(binding = 21, rgba16i) uniform readonly writeonly iimage2D uImage21;
layout(binding = 22, rgba8i) uniform readonly writeonly iimage2D uImage22;
layout(binding = 23, rg32i) uniform readonly writeonly iimage2D uImage23;
layout(binding = 24, rg16i) uniform readonly writeonly iimage2D uImage24;
layout(binding = 25, rg8i) uniform readonly writeonly iimage2D uImage25;
layout(binding = 26, r32i) uniform readonly writeonly iimage2D uImage26;
layout(binding = 27, r16i) uniform readonly writeonly iimage2D uImage27;
layout(binding = 28, r8i) uniform readonly writeonly iimage2D uImage28;
layout(binding = 29, rgba32ui) uniform readonly writeonly uimage2D uImage29;
layout(binding = 30, rgba16ui) uniform readonly writeonly uimage2D uImage30;
layout(binding = 31, rgb10_a2ui) uniform readonly writeonly uimage2D uImage31;
layout(binding = 32, rgba8ui) uniform readonly writeonly uimage2D uImage32;
layout(binding = 33, rg32ui) uniform readonly writeonly uimage2D uImage33;
layout(binding = 34, rg16ui) uniform readonly writeonly uimage2D uImage34;
layout(binding = 35, rg8ui) uniform readonly writeonly uimage2D uImage35;
layout(binding = 36, r32ui) uniform readonly writeonly uimage2D uImage36;
layout(binding = 37, r16ui) uniform readonly writeonly uimage2D uImage37;
layout(binding = 38, r8ui) uniform readonly writeonly uimage2D uImage38;
void main()
{
}

View File

@ -0,0 +1,52 @@
#version 450
#extension GL_ARB_gpu_shader_int64 : require
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
struct M0
{
int64_t v;
i64vec2 b[2];
uint64_t c;
uint64_t d[5];
};
layout(binding = 0, std430) buffer SSBO0
{
i64vec4 a;
M0 m0;
} ssbo_0;
layout(binding = 1, std430) buffer SSBO1
{
u64vec4 b;
M0 m0;
} ssbo_1;
layout(binding = 2, std430) buffer SSBO2
{
int64_t a[4];
i64vec2 b[4];
} ssbo_2;
layout(binding = 3, std140) buffer SSBO3
{
int64_t a[4];
i64vec2 b[4];
} ssbo_3;
void main()
{
ssbo_0.a += i64vec4(10l, 20l, 30l, 40l);
ssbo_1.b += u64vec4(999999999999999999ul, 8888888888888888ul, 77777777777777777ul, 6666666666666666ul);
ssbo_0.a += i64vec4(20l);
ssbo_0.a = abs(ssbo_0.a + i64vec4(ssbo_1.b));
ssbo_0.a += i64vec4(1l);
ssbo_1.b += u64vec4(i64vec4(1l));
ssbo_0.a -= i64vec4(1l);
ssbo_1.b -= u64vec4(i64vec4(1l));
ssbo_1.b = doubleBitsToUint64(int64BitsToDouble(ssbo_0.a));
ssbo_0.a = doubleBitsToInt64(uint64BitsToDouble(ssbo_1.b));
ssbo_2.a[0] += 1l;
ssbo_3.a[0] += 2l;
}

View File

@ -0,0 +1,13 @@
#version 450
layout(binding = 0, rgba8) uniform image2DMS uImage;
layout(binding = 1, rgba8) uniform image2DMSArray uImageArray;
void main()
{
vec4 a = imageLoad(uImage, ivec2(1, 2), 2);
vec4 b = imageLoad(uImageArray, ivec3(1, 2, 4), 3);
imageStore(uImage, ivec2(2, 3), 1, a);
imageStore(uImageArray, ivec3(2, 3, 7), 1, b);
}

View File

@ -0,0 +1,21 @@
#version 450
layout(location = 0) out vec4 FragColor;
in VertexData
{
layout(location = 0) flat float f;
layout(location = 1) centroid vec4 g;
layout(location = 2) flat int h;
layout(location = 3) float i;
} vin;
layout(location = 4) in flat float f;
layout(location = 5) in centroid vec4 g;
layout(location = 6) in flat int h;
layout(location = 7) in sample float i;
void main()
{
FragColor = ((((((vec4(vin.f) + vin.g) + vec4(float(vin.h))) + vec4(vin.i)) + vec4(f)) + g) + vec4(float(h))) + vec4(i);
}

View File

@ -0,0 +1,11 @@
#version 450
layout(binding = 0) uniform sampler2D uSampler;
layout(location = 0) out vec4 FragColor;
void main()
{
FragColor = vec4(float(textureQueryLevels(uSampler)));
}

View File

@ -0,0 +1,12 @@
#version 450
layout(binding = 0) uniform sampler2D uSampler;
layout(location = 0) out vec4 FragColor;
layout(location = 0) in vec2 vTexCoord;
void main()
{
FragColor = textureQueryLod(uSampler, vTexCoord).xyxy;
}

View File

@ -0,0 +1,14 @@
#version 450
layout(binding = 0) uniform sampler2DMS uSampler;
layout(binding = 1) uniform sampler2DMSArray uSamplerArray;
layout(binding = 2, rgba8) uniform readonly writeonly image2DMS uImage;
layout(binding = 3, rgba8) uniform readonly writeonly image2DMSArray uImageArray;
layout(location = 0) out vec4 FragColor;
void main()
{
FragColor = vec4(float(((textureSamples(uSampler) + textureSamples(uSamplerArray)) + imageSamples(uImage)) + imageSamples(uImageArray)));
}

View File

@ -0,0 +1,27 @@
#version 450
out VertexData
{
layout(location = 0) flat float f;
layout(location = 1) centroid vec4 g;
layout(location = 2) flat int h;
layout(location = 3) float i;
} vout;
layout(location = 4) out flat float f;
layout(location = 5) out centroid vec4 g;
layout(location = 6) out flat int h;
layout(location = 7) out float i;
void main()
{
vout.f = 10.0;
vout.g = vec4(20.0);
vout.h = 20;
vout.i = 30.0;
f = 10.0;
g = vec4(20.0);
h = 20;
i = 30.0;
}

View File

@ -0,0 +1,15 @@
#version 310 es
precision mediump float;
precision highp int;
layout(binding = 0) uniform mediump sampler2D uTex;
layout(location = 0) out vec4 FragColor;
in vec4 vColor;
in vec2 vTex;
void main()
{
FragColor = vColor * texture(uTex, vTex);
}

View File

@ -0,0 +1,15 @@
#version 310 es
precision mediump float;
precision highp int;
layout(binding = 0) uniform mediump sampler2D Texture;
layout(location = 0) in vec2 vTexCoord;
layout(location = 0) out vec4 FragColor;
void main()
{
float f = texture(Texture, vTexCoord).x;
FragColor = vec4(f * f);
}

View File

@ -0,0 +1,28 @@
#version 310 es
precision mediump float;
precision highp int;
struct Foobar
{
float a;
float b;
};
layout(location = 0) out vec4 FragColor;
layout(location = 0) in mediump flat int index;
vec4 resolve(Foobar f)
{
return vec4(f.a + f.b);
}
void main()
{
highp vec4 indexable[3] = vec4[](vec4(1.0), vec4(2.0), vec4(3.0));
highp vec4 indexable_1[2][2] = vec4[][](vec4[](vec4(1.0), vec4(2.0)), vec4[](vec4(8.0), vec4(10.0)));
Foobar param = Foobar(10.0, 20.0);
Foobar indexable_2[2] = Foobar[](Foobar(10.0, 40.0), Foobar(90.0, 70.0));
Foobar param_1 = indexable_2[index];
FragColor = ((indexable[index] + (indexable_1[index][index + 1])) + resolve(param)) + resolve(param_1);
}

View File

@ -0,0 +1,30 @@
#version 310 es
precision mediump float;
precision highp int;
struct Structy
{
vec4 c;
};
layout(location = 0) out vec4 FragColor;
void foo2(out Structy f)
{
f.c = vec4(10.0);
}
Structy foo()
{
Structy param;
foo2(param);
Structy f = param;
return f;
}
void main()
{
Structy s = foo();
FragColor = s.c;
}

View File

@ -0,0 +1,52 @@
#version 310 es
precision mediump float;
precision highp int;
layout(location = 0) out mediump int FragColor;
void main()
{
FragColor = 16;
for (mediump int i = 0; i < 25; i++)
{
FragColor += 10;
}
for (mediump int i_1 = 1, j = 4; i_1 < 30; i_1++, j += 4)
{
FragColor += 11;
}
mediump int k = 0;
for (; k < 20; k++)
{
FragColor += 12;
}
k += 3;
FragColor += k;
mediump int l;
if (k == 40)
{
l = 0;
for (; l < 40; l++)
{
FragColor += 13;
}
return;
}
else
{
l = k;
FragColor += l;
}
mediump ivec2 i_2 = ivec2(0);
for (; i_2.x < 10; i_2.x += 4)
{
FragColor += i_2.y;
}
mediump int o = k;
for (mediump int m = k; m < 40; m++)
{
FragColor += m;
}
FragColor += o;
}

View File

@ -0,0 +1,62 @@
#version 310 es
precision mediump float;
precision highp int;
layout(binding = 4, std140) uniform GlobalPSData
{
vec4 g_CamPos;
vec4 g_SunDir;
vec4 g_SunColor;
vec4 g_ResolutionParams;
vec4 g_TimeParams;
vec4 g_FogColor_Distance;
} _56;
layout(binding = 2) uniform mediump sampler2D TexNormalmap;
layout(location = 3) out vec4 LightingOut;
layout(location = 2) out vec4 NormalOut;
layout(location = 1) out vec4 SpecularOut;
layout(location = 0) out vec4 AlbedoOut;
layout(location = 0) in vec2 TexCoord;
layout(location = 1) in vec3 EyeVec;
float saturate(float x)
{
return clamp(x, 0.0, 1.0);
}
void Resolve(vec3 Albedo, vec3 Normal, float Roughness, float Metallic)
{
LightingOut = vec4(0.0);
NormalOut = vec4((Normal * 0.5) + vec3(0.5), 0.0);
SpecularOut = vec4(Roughness, Metallic, 0.0, 0.0);
AlbedoOut = vec4(Albedo, 1.0);
}
void main()
{
vec3 Normal = (texture(TexNormalmap, TexCoord).xyz * 2.0) - vec3(1.0);
Normal = normalize(Normal);
highp float param = length(EyeVec) / 1000.0;
vec2 scatter_uv;
scatter_uv.x = saturate(param);
vec3 nEye = normalize(EyeVec);
scatter_uv.y = 0.0;
vec3 Color = vec3(0.100000001490116119384765625, 0.300000011920928955078125, 0.100000001490116119384765625);
vec3 grass = vec3(0.100000001490116119384765625, 0.300000011920928955078125, 0.100000001490116119384765625);
vec3 dirt = vec3(0.100000001490116119384765625);
vec3 snow = vec3(0.800000011920928955078125);
float grass_snow = smoothstep(0.0, 0.1500000059604644775390625, (_56.g_CamPos.y + EyeVec.y) / 200.0);
vec3 base = mix(grass, snow, vec3(grass_snow));
float edge = smoothstep(0.699999988079071044921875, 0.75, Normal.y);
Color = mix(dirt, base, vec3(edge));
Color *= Color;
float Roughness = 1.0 - (edge * grass_snow);
highp vec3 param_1 = Color;
highp vec3 param_2 = Normal;
highp float param_3 = Roughness;
highp float param_4 = 0.0;
Resolve(param_1, param_2, param_3, param_4);
}

View File

@ -0,0 +1,38 @@
#version 310 es
precision mediump float;
precision highp int;
layout(location = 0) out vec4 FragColor;
layout(location = 0) in vec4 vIn0;
layout(location = 1) in vec4 vIn1;
layout(location = 2) in float vIn2;
layout(location = 3) in float vIn3;
void main()
{
bvec4 l = bvec4(false, true, false, false);
FragColor = mix(vIn0, vIn1, l);
bool f = true;
FragColor = vec4(mix(vIn2, vIn3, f));
highp vec4 _35;
if (f)
{
_35 = vIn0;
}
else
{
_35 = vIn1;
}
FragColor = _35;
highp float _44;
if (f)
{
_44 = vIn2;
}
else
{
_44 = vIn3;
}
FragColor = vec4(_44);
}

View File

@ -0,0 +1,21 @@
#version 310 es
precision mediump float;
precision highp int;
layout(location = 0) out vec4 PLSOut0;
layout(location = 0) in vec4 PLSIn0;
layout(location = 1) out vec4 PLSOut1;
layout(location = 1) in vec4 PLSIn1;
layout(location = 2) out vec4 PLSOut2;
in vec4 PLSIn2;
layout(location = 3) out vec4 PLSOut3;
in vec4 PLSIn3;
void main()
{
PLSOut0 = PLSIn0 * 2.0;
PLSOut1 = PLSIn1 * 6.0;
PLSOut2 = PLSIn2 * 7.0;
PLSOut3 = PLSIn3 * 4.0;
}

View File

@ -0,0 +1,14 @@
#version 310 es
precision mediump float;
precision highp int;
layout(binding = 0) uniform mediump sampler2DMS uSampler;
layout(location = 0) out vec4 FragColor;
void main()
{
ivec2 coord = ivec2(gl_FragCoord.xy);
FragColor = ((texelFetch(uSampler, coord, 0) + texelFetch(uSampler, coord, 1)) + texelFetch(uSampler, coord, 2)) + texelFetch(uSampler, coord, 3);
}

View File

@ -0,0 +1,21 @@
#version 310 es
precision mediump float;
precision highp int;
layout(binding = 0) uniform mediump sampler2D uTex;
layout(location = 0) out vec4 FragColor;
in vec4 vColor;
in vec2 vTex;
vec4 sample_texture(mediump sampler2D tex, vec2 uv)
{
return texture(tex, uv);
}
void main()
{
highp vec2 param = vTex;
FragColor = vColor * sample_texture(uTex, param);
}

View File

@ -0,0 +1,20 @@
#version 310 es
precision mediump float;
precision highp int;
layout(location = 0) uniform mediump sampler2D samp;
layout(location = 0) out vec4 FragColor;
layout(location = 2) in vec2 vUV;
layout(location = 1) in vec3 vNormal;
void main()
{
FragColor = vec4(texture(samp, vUV).xyz, 1.0);
FragColor = vec4(texture(samp, vUV).xz, 1.0, 4.0);
FragColor = vec4(texture(samp, vUV).xx, texture(samp, vUV + vec2(0.100000001490116119384765625)).yy);
FragColor = vec4(vNormal, 1.0);
FragColor = vec4(vNormal + vec3(1.7999999523162841796875), 1.0);
FragColor = vec4(vUV, vUV + vec2(1.7999999523162841796875));
}

View File

@ -0,0 +1,26 @@
#version 310 es
precision mediump float;
precision highp int;
struct Str
{
mat4 foo;
};
layout(binding = 0, std140) uniform UBO1
{
layout(row_major) Str foo;
} ubo1;
layout(binding = 1, std140) uniform UBO2
{
Str foo;
} ubo0;
layout(location = 0) out vec4 FragColor;
void main()
{
FragColor = ubo1.foo.foo[0] + ubo0.foo.foo[0];
}

View File

@ -0,0 +1,26 @@
#version 310 es
#extension GL_EXT_geometry_shader : require
layout(invocations = 4, triangles) in;
layout(max_vertices = 3, triangle_strip) out;
out vec3 vNormal;
in VertexData
{
vec3 normal;
} vin[3];
void main()
{
gl_Position = gl_in[0].gl_Position;
vNormal = vin[0].normal + vec3(float(gl_InvocationID));
EmitVertex();
gl_Position = gl_in[1].gl_Position;
vNormal = vin[1].normal + vec3(4.0 * float(gl_InvocationID));
EmitVertex();
gl_Position = gl_in[2].gl_Position;
vNormal = vin[2].normal + vec3(2.0 * float(gl_InvocationID));
EmitVertex();
EndPrimitive();
}

View File

@ -0,0 +1,26 @@
#version 310 es
#extension GL_EXT_geometry_shader : require
layout(lines_adjacency) in;
layout(max_vertices = 3, line_strip) out;
out vec3 vNormal;
in VertexData
{
vec3 normal;
} vin[4];
void main()
{
gl_Position = gl_in[0].gl_Position;
vNormal = vin[0].normal;
EmitVertex();
gl_Position = gl_in[1].gl_Position;
vNormal = vin[1].normal;
EmitVertex();
gl_Position = gl_in[2].gl_Position;
vNormal = vin[2].normal;
EmitVertex();
EndPrimitive();
}

View File

@ -0,0 +1,23 @@
#version 310 es
#extension GL_EXT_geometry_shader : require
layout(lines) in;
layout(max_vertices = 2, line_strip) out;
out vec3 vNormal;
in VertexData
{
vec3 normal;
} vin[2];
void main()
{
gl_Position = gl_in[0].gl_Position;
vNormal = vin[0].normal;
EmitVertex();
gl_Position = gl_in[1].gl_Position;
vNormal = vin[1].normal;
EmitVertex();
EndPrimitive();
}

View File

@ -0,0 +1,26 @@
#version 310 es
#extension GL_EXT_geometry_shader : require
layout(points) in;
layout(max_vertices = 3, points) out;
out vec3 vNormal;
in VertexData
{
vec3 normal;
} vin[1];
void main()
{
gl_Position = gl_in[0].gl_Position;
vNormal = vin[0].normal;
EmitVertex();
gl_Position = gl_in[0].gl_Position;
vNormal = vin[0].normal;
EmitVertex();
gl_Position = gl_in[0].gl_Position;
vNormal = vin[0].normal;
EmitVertex();
EndPrimitive();
}

View File

@ -0,0 +1,26 @@
#version 310 es
#extension GL_EXT_geometry_shader : require
layout(triangles) in;
layout(max_vertices = 3, triangle_strip) out;
out vec3 vNormal;
in VertexData
{
vec3 normal;
} vin[3];
void main()
{
gl_Position = gl_in[0].gl_Position;
vNormal = vin[0].normal;
EmitVertex();
gl_Position = gl_in[1].gl_Position;
vNormal = vin[1].normal;
EmitVertex();
gl_Position = gl_in[2].gl_Position;
vNormal = vin[2].normal;
EmitVertex();
EndPrimitive();
}

View File

@ -0,0 +1,26 @@
#version 310 es
#extension GL_EXT_geometry_shader : require
layout(triangles_adjacency) in;
layout(max_vertices = 3, triangle_strip) out;
out vec3 vNormal;
in VertexData
{
vec3 normal;
} vin[6];
void main()
{
gl_Position = gl_in[0].gl_Position;
vNormal = vin[0].normal;
EmitVertex();
gl_Position = gl_in[1].gl_Position;
vNormal = vin[1].normal;
EmitVertex();
gl_Position = gl_in[2].gl_Position;
vNormal = vin[2].normal;
EmitVertex();
EndPrimitive();
}

View File

@ -0,0 +1,26 @@
#version 310 es
#extension GL_EXT_geometry_shader : require
layout(triangles) in;
layout(max_vertices = 3, triangle_strip) out;
out vec3 vNormal;
in VertexData
{
vec3 normal;
} vin[3];
void main()
{
gl_Position = gl_in[0].gl_Position;
vNormal = vin[0].normal;
EmitVertex();
gl_Position = gl_in[1].gl_Position;
vNormal = vin[1].normal;
EmitVertex();
gl_Position = gl_in[2].gl_Position;
vNormal = vin[2].normal;
EmitVertex();
EndPrimitive();
}

View File

@ -0,0 +1,17 @@
#version 310 es
#extension GL_EXT_tessellation_shader : require
layout(vertices = 1) out;
out patch vec3 vFoo;
void main()
{
gl_TessLevelInner[0] = 8.8999996185302734375;
gl_TessLevelInner[1] = 6.900000095367431640625;
gl_TessLevelOuter[0] = 8.8999996185302734375;
gl_TessLevelOuter[1] = 6.900000095367431640625;
gl_TessLevelOuter[2] = 3.900000095367431640625;
gl_TessLevelOuter[3] = 4.900000095367431640625;
vFoo = vec3(1.0);
}

View File

@ -0,0 +1,117 @@
#version 310 es
#extension GL_EXT_tessellation_shader : require
layout(vertices = 1) out;
layout(std140) uniform UBO
{
vec4 uScale;
vec3 uCamPos;
vec2 uPatchSize;
vec2 uMaxTessLevel;
float uDistanceMod;
vec4 uFrustum[6];
} _41;
out patch vec2 vOutPatchPosBase;
out patch vec4 vPatchLods;
in vec2 vPatchPosBase[32];
bool frustum_cull(vec2 p0)
{
vec2 min_xz = (p0 - vec2(10.0)) * _41.uScale.xy;
vec2 max_xz = ((p0 + _41.uPatchSize) + vec2(10.0)) * _41.uScale.xy;
vec3 bb_min = vec3(min_xz.x, -10.0, min_xz.y);
vec3 bb_max = vec3(max_xz.x, 10.0, max_xz.y);
vec3 center = (bb_min + bb_max) * 0.5;
float radius = 0.5 * length(bb_max - bb_min);
vec3 f0 = vec3(dot(_41.uFrustum[0], vec4(center, 1.0)), dot(_41.uFrustum[1], vec4(center, 1.0)), dot(_41.uFrustum[2], vec4(center, 1.0)));
vec3 f1 = vec3(dot(_41.uFrustum[3], vec4(center, 1.0)), dot(_41.uFrustum[4], vec4(center, 1.0)), dot(_41.uFrustum[5], vec4(center, 1.0)));
vec3 _199 = f0;
bool _205 = any(lessThanEqual(_199, vec3(-radius)));
bool _215;
if (!_205)
{
_215 = any(lessThanEqual(f1, vec3(-radius)));
}
else
{
_215 = _205;
}
return !_215;
}
float lod_factor(vec2 pos_)
{
vec2 pos = pos_ * _41.uScale.xy;
vec3 dist_to_cam = _41.uCamPos - vec3(pos.x, 0.0, pos.y);
float level = log2((length(dist_to_cam) + 9.9999997473787516355514526367188e-05) * _41.uDistanceMod);
return clamp(level, 0.0, _41.uMaxTessLevel.x);
}
vec4 tess_level(vec4 lod)
{
return exp2(-lod) * _41.uMaxTessLevel.y;
}
float tess_level(float lod)
{
return _41.uMaxTessLevel.y * exp2(-lod);
}
void compute_tess_levels(vec2 p0)
{
vOutPatchPosBase = p0;
vec2 param = p0 + (vec2(-0.5) * _41.uPatchSize);
float l00 = lod_factor(param);
vec2 param_1 = p0 + (vec2(0.5, -0.5) * _41.uPatchSize);
float l10 = lod_factor(param_1);
vec2 param_2 = p0 + (vec2(1.5, -0.5) * _41.uPatchSize);
float l20 = lod_factor(param_2);
vec2 param_3 = p0 + (vec2(-0.5, 0.5) * _41.uPatchSize);
float l01 = lod_factor(param_3);
vec2 param_4 = p0 + (vec2(0.5) * _41.uPatchSize);
float l11 = lod_factor(param_4);
vec2 param_5 = p0 + (vec2(1.5, 0.5) * _41.uPatchSize);
float l21 = lod_factor(param_5);
vec2 param_6 = p0 + (vec2(-0.5, 1.5) * _41.uPatchSize);
float l02 = lod_factor(param_6);
vec2 param_7 = p0 + (vec2(0.5, 1.5) * _41.uPatchSize);
float l12 = lod_factor(param_7);
vec2 param_8 = p0 + (vec2(1.5) * _41.uPatchSize);
float l22 = lod_factor(param_8);
vec4 lods = vec4(dot(vec4(l01, l11, l02, l12), vec4(0.25)), dot(vec4(l00, l10, l01, l11), vec4(0.25)), dot(vec4(l10, l20, l11, l21), vec4(0.25)), dot(vec4(l11, l21, l12, l22), vec4(0.25)));
vPatchLods = lods;
vec4 outer_lods = min(lods, lods.yzwx);
vec4 param_9 = outer_lods;
vec4 levels = tess_level(param_9);
gl_TessLevelOuter[0] = levels.x;
gl_TessLevelOuter[1] = levels.y;
gl_TessLevelOuter[2] = levels.z;
gl_TessLevelOuter[3] = levels.w;
float min_lod = min(min(lods.x, lods.y), min(lods.z, lods.w));
float param_10 = min(min_lod, l11);
float inner = tess_level(param_10);
gl_TessLevelInner[0] = inner;
gl_TessLevelInner[1] = inner;
}
void main()
{
vec2 p0 = vPatchPosBase[0];
vec2 param = p0;
if (!frustum_cull(param))
{
gl_TessLevelOuter[0] = -1.0;
gl_TessLevelOuter[1] = -1.0;
gl_TessLevelOuter[2] = -1.0;
gl_TessLevelOuter[3] = -1.0;
gl_TessLevelInner[0] = -1.0;
gl_TessLevelInner[1] = -1.0;
}
else
{
vec2 param_1 = p0;
compute_tess_levels(param_1);
}
}

View File

@ -0,0 +1,9 @@
#version 310 es
#extension GL_EXT_tessellation_shader : require
layout(triangles, ccw, fractional_even_spacing) in;
void main()
{
gl_Position = vec4(1.0);
}

View File

@ -0,0 +1,9 @@
#version 310 es
#extension GL_EXT_tessellation_shader : require
layout(triangles, cw, fractional_even_spacing) in;
void main()
{
gl_Position = vec4(1.0);
}

View File

@ -0,0 +1,9 @@
#version 310 es
#extension GL_EXT_tessellation_shader : require
layout(triangles, cw, equal_spacing) in;
void main()
{
gl_Position = vec4(1.0);
}

View File

@ -0,0 +1,9 @@
#version 310 es
#extension GL_EXT_tessellation_shader : require
layout(triangles, cw, fractional_even_spacing) in;
void main()
{
gl_Position = vec4(1.0);
}

View File

@ -0,0 +1,9 @@
#version 310 es
#extension GL_EXT_tessellation_shader : require
layout(triangles, cw, fractional_odd_spacing) in;
void main()
{
gl_Position = vec4(1.0);
}

View File

@ -0,0 +1,9 @@
#version 310 es
#extension GL_EXT_tessellation_shader : require
layout(isolines, point_mode, fractional_even_spacing) in;
void main()
{
gl_Position = vec4(1.0);
}

View File

@ -0,0 +1,9 @@
#version 310 es
#extension GL_EXT_tessellation_shader : require
layout(triangles, cw, fractional_even_spacing) in;
void main()
{
gl_Position = vec4(1.0);
}

View File

@ -0,0 +1,61 @@
#version 310 es
#extension GL_EXT_tessellation_shader : require
layout(quads, cw, fractional_even_spacing) in;
layout(binding = 1, std140) uniform UBO
{
mat4 uMVP;
vec4 uScale;
vec2 uInvScale;
vec3 uCamPos;
vec2 uPatchSize;
vec2 uInvHeightmapSize;
} _31;
layout(binding = 0) uniform mediump sampler2D uHeightmapDisplacement;
in patch vec2 vOutPatchPosBase;
in patch vec4 vPatchLods;
out vec4 vGradNormalTex;
out vec3 vWorld;
vec2 lerp_vertex(vec2 tess_coord)
{
return vOutPatchPosBase + (tess_coord * _31.uPatchSize);
}
mediump vec2 lod_factor(vec2 tess_coord)
{
mediump vec2 x = mix(vPatchLods.yx, vPatchLods.zw, vec2(tess_coord.x));
mediump float level = mix(x.x, x.y, tess_coord.y);
mediump float floor_level = floor(level);
mediump float fract_level = level - floor_level;
return vec2(floor_level, fract_level);
}
mediump vec3 sample_height_displacement(vec2 uv, vec2 off, mediump vec2 lod)
{
return mix(textureLod(uHeightmapDisplacement, uv + (off * 0.5), lod.x).xyz, textureLod(uHeightmapDisplacement, uv + (off * 1.0), lod.x + 1.0).xyz, vec3(lod.y));
}
void main()
{
vec2 tess_coord = gl_TessCoord.xy;
vec2 param = tess_coord;
vec2 pos = lerp_vertex(param);
vec2 param_1 = tess_coord;
mediump vec2 lod = lod_factor(param_1);
vec2 tex = pos * _31.uInvHeightmapSize;
pos *= _31.uScale.xy;
mediump float delta_mod = exp2(lod.x);
vec2 off = _31.uInvHeightmapSize * delta_mod;
vGradNormalTex = vec4(tex + (_31.uInvHeightmapSize * 0.5), tex * _31.uScale.zw);
vec2 param_2 = tex;
vec2 param_3 = off;
vec2 param_4 = lod;
vec3 height_displacement = sample_height_displacement(param_2, param_3, param_4);
pos += height_displacement.yz;
vWorld = vec3(pos.x, height_displacement.x, pos.y);
gl_Position = _31.uMVP * vec4(vWorld, 1.0);
}

View File

@ -0,0 +1,17 @@
#version 310 es
layout(std140) uniform UBO
{
mat4 uMVP;
} _16;
in vec4 aVertex;
out vec3 vNormal;
in vec3 aNormal;
void main()
{
gl_Position = _16.uMVP * aVertex;
vNormal = aNormal;
}

View File

@ -0,0 +1,110 @@
#version 310 es
struct PatchData
{
vec4 Position;
vec4 LODs;
};
layout(binding = 0, std140) uniform GlobalVSData
{
vec4 g_ViewProj_Row0;
vec4 g_ViewProj_Row1;
vec4 g_ViewProj_Row2;
vec4 g_ViewProj_Row3;
vec4 g_CamPos;
vec4 g_CamRight;
vec4 g_CamUp;
vec4 g_CamFront;
vec4 g_SunDir;
vec4 g_SunColor;
vec4 g_TimeParams;
vec4 g_ResolutionParams;
vec4 g_CamAxisRight;
vec4 g_FogColor_Distance;
vec4 g_ShadowVP_Row0;
vec4 g_ShadowVP_Row1;
vec4 g_ShadowVP_Row2;
vec4 g_ShadowVP_Row3;
} _58;
layout(binding = 0, std140) uniform PerPatch
{
PatchData Patches[256];
} _284;
layout(binding = 2, std140) uniform GlobalGround
{
vec4 GroundScale;
vec4 GroundPosition;
vec4 InvGroundSize_PatchScale;
} _381;
layout(binding = 1) uniform mediump sampler2D TexLOD;
layout(binding = 0) uniform mediump sampler2D TexHeightmap;
layout(location = 1) in vec4 LODWeights;
uniform int SPIRV_Cross_BaseInstance;
layout(location = 0) in vec2 Position;
layout(location = 1) out vec3 EyeVec;
layout(location = 0) out vec2 TexCoord;
vec2 warp_position()
{
float vlod = dot(LODWeights, _284.Patches[(gl_InstanceID + SPIRV_Cross_BaseInstance)].LODs);
vlod = mix(vlod, _284.Patches[(gl_InstanceID + SPIRV_Cross_BaseInstance)].Position.w, all(equal(LODWeights, vec4(0.0))));
float floor_lod = floor(vlod);
float fract_lod = vlod - floor_lod;
uint ufloor_lod = uint(floor_lod);
uvec2 uPosition = uvec2(Position);
uvec2 mask = (uvec2(1u) << uvec2(ufloor_lod, ufloor_lod + 1u)) - uvec2(1u);
uint _332;
if (uPosition.x < 32u)
{
_332 = mask.x;
}
else
{
_332 = 0u;
}
uint _342 = _332;
uint _343;
if (uPosition.y < 32u)
{
_343 = mask.y;
}
else
{
_343 = 0u;
}
uvec2 rounding = uvec2(_342, _343);
vec4 lower_upper_snapped = vec4((uPosition + rounding).xyxy & ~mask.xxyy);
return mix(lower_upper_snapped.xy, lower_upper_snapped.zw, vec2(fract_lod));
}
vec2 lod_factor(vec2 uv)
{
float level = textureLod(TexLOD, uv, 0.0).x * 7.96875;
float floor_level = floor(level);
float fract_level = level - floor_level;
return vec2(floor_level, fract_level);
}
void main()
{
vec2 PatchPos = _284.Patches[(gl_InstanceID + SPIRV_Cross_BaseInstance)].Position.xz * _381.InvGroundSize_PatchScale.zw;
vec2 WarpedPos = warp_position();
vec2 VertexPos = PatchPos + WarpedPos;
vec2 NormalizedPos = VertexPos * _381.InvGroundSize_PatchScale.xy;
vec2 param = NormalizedPos;
vec2 lod = lod_factor(param);
vec2 Offset = _381.InvGroundSize_PatchScale.xy * exp2(lod.x);
float Elevation = mix(textureLod(TexHeightmap, NormalizedPos + (Offset * 0.5), lod.x).x, textureLod(TexHeightmap, NormalizedPos + (Offset * 1.0), lod.x + 1.0).x, lod.y);
vec3 WorldPos = vec3(NormalizedPos.x, Elevation, NormalizedPos.y);
WorldPos *= _381.GroundScale.xyz;
WorldPos += _381.GroundPosition.xyz;
EyeVec = WorldPos - _58.g_CamPos.xyz;
TexCoord = NormalizedPos + (_381.InvGroundSize_PatchScale.xy * 0.5);
gl_Position = (((_58.g_ViewProj_Row0 * WorldPos.x) + (_58.g_ViewProj_Row1 * WorldPos.y)) + (_58.g_ViewProj_Row2 * WorldPos.z)) + _58.g_ViewProj_Row3;
}

View File

@ -0,0 +1,133 @@
#version 310 es
struct PatchData
{
vec4 Position;
vec4 LODs;
};
layout(binding = 0, std140) uniform GlobalVSData
{
vec4 g_ViewProj_Row0;
vec4 g_ViewProj_Row1;
vec4 g_ViewProj_Row2;
vec4 g_ViewProj_Row3;
vec4 g_CamPos;
vec4 g_CamRight;
vec4 g_CamUp;
vec4 g_CamFront;
vec4 g_SunDir;
vec4 g_SunColor;
vec4 g_TimeParams;
vec4 g_ResolutionParams;
vec4 g_CamAxisRight;
vec4 g_FogColor_Distance;
vec4 g_ShadowVP_Row0;
vec4 g_ShadowVP_Row1;
vec4 g_ShadowVP_Row2;
vec4 g_ShadowVP_Row3;
} _58;
layout(binding = 0, std140) uniform Offsets
{
PatchData Patches[256];
} _284;
layout(binding = 4, std140) uniform GlobalOcean
{
vec4 OceanScale;
vec4 OceanPosition;
vec4 InvOceanSize_PatchScale;
vec4 NormalTexCoordScale;
} _405;
layout(binding = 1) uniform mediump sampler2D TexLOD;
layout(binding = 0) uniform mediump sampler2D TexDisplacement;
layout(location = 1) in vec4 LODWeights;
uniform int SPIRV_Cross_BaseInstance;
layout(location = 0) in vec4 Position;
layout(location = 0) out vec3 EyeVec;
layout(location = 1) out vec4 TexCoord;
vec2 warp_position()
{
float vlod = dot(LODWeights, _284.Patches[(gl_InstanceID + SPIRV_Cross_BaseInstance)].LODs);
vlod = mix(vlod, _284.Patches[(gl_InstanceID + SPIRV_Cross_BaseInstance)].Position.w, all(equal(LODWeights, vec4(0.0))));
float floor_lod = floor(vlod);
float fract_lod = vlod - floor_lod;
uint ufloor_lod = uint(floor_lod);
uvec4 uPosition = uvec4(Position);
uvec2 mask = (uvec2(1u) << uvec2(ufloor_lod, ufloor_lod + 1u)) - uvec2(1u);
uint _333;
if (uPosition.x < 32u)
{
_333 = mask.x;
}
else
{
_333 = 0u;
}
uvec4 rounding;
rounding.x = _333;
uint _345;
if (uPosition.y < 32u)
{
_345 = mask.x;
}
else
{
_345 = 0u;
}
rounding.y = _345;
uint _356;
if (uPosition.x < 32u)
{
_356 = mask.y;
}
else
{
_356 = 0u;
}
rounding.z = _356;
uint _368;
if (uPosition.y < 32u)
{
_368 = mask.y;
}
else
{
_368 = 0u;
}
rounding.w = _368;
vec4 lower_upper_snapped = vec4((uPosition.xyxy + rounding) & ~mask.xxyy);
return mix(lower_upper_snapped.xy, lower_upper_snapped.zw, vec2(fract_lod));
}
vec2 lod_factor(vec2 uv)
{
float level = textureLod(TexLOD, uv, 0.0).x * 7.96875;
float floor_level = floor(level);
float fract_level = level - floor_level;
return vec2(floor_level, fract_level);
}
void main()
{
vec2 PatchPos = _284.Patches[(gl_InstanceID + SPIRV_Cross_BaseInstance)].Position.xz * _405.InvOceanSize_PatchScale.zw;
vec2 WarpedPos = warp_position();
vec2 VertexPos = PatchPos + WarpedPos;
vec2 NormalizedPos = VertexPos * _405.InvOceanSize_PatchScale.xy;
vec2 NormalizedTex = NormalizedPos * _405.NormalTexCoordScale.zw;
vec2 param = NormalizedPos;
vec2 lod = lod_factor(param);
vec2 Offset = (_405.InvOceanSize_PatchScale.xy * exp2(lod.x)) * _405.NormalTexCoordScale.zw;
vec3 Displacement = mix(textureLod(TexDisplacement, NormalizedTex + (Offset * 0.5), lod.x).yxz, textureLod(TexDisplacement, NormalizedTex + (Offset * 1.0), lod.x + 1.0).yxz, vec3(lod.y));
vec3 WorldPos = vec3(NormalizedPos.x, 0.0, NormalizedPos.y) + Displacement;
WorldPos *= _405.OceanScale.xyz;
WorldPos += _405.OceanPosition.xyz;
EyeVec = WorldPos - _58.g_CamPos.xyz;
TexCoord = vec4(NormalizedTex, NormalizedTex * _405.NormalTexCoordScale.xy) + ((_405.InvOceanSize_PatchScale.xyxy * 0.5) * _405.NormalTexCoordScale.zwzw);
gl_Position = (((_58.g_ViewProj_Row0 * WorldPos.x) + (_58.g_ViewProj_Row1 * WorldPos.y)) + (_58.g_ViewProj_Row2 * WorldPos.z)) + _58.g_ViewProj_Row3;
}

View File

@ -0,0 +1,11 @@
#version 310 es
#extension GL_OES_texture_buffer : require
layout(binding = 4) uniform highp samplerBuffer uSamp;
layout(binding = 5, rgba32f) uniform highp readonly imageBuffer uSampo;
void main()
{
gl_Position = texelFetch(uSamp, 10) + imageLoad(uSampo, 100);
}

View File

@ -0,0 +1,17 @@
#version 310 es
layout(binding = 0, std140) uniform UBO
{
mat4 mvp;
} _16;
in vec4 aVertex;
out vec3 vNormal;
in vec3 aNormal;
void main()
{
gl_Position = _16.mvp * aVertex;
vNormal = aNormal;
}

View File

@ -0,0 +1,48 @@
#version 310 es
precision mediump float;
precision highp int;
uniform mediump sampler2D SPIRV_Cross_CombineduTexture0uSampler0;
uniform mediump sampler2D SPIRV_Cross_CombineduTexture1uSampler1;
uniform mediump sampler2D SPIRV_Cross_CombineduTexture1uSampler0;
uniform mediump sampler2D SPIRV_Cross_CombineduTexture0uSampler1;
layout(location = 0) in vec2 vTex;
layout(location = 0) out vec4 FragColor;
vec4 sample_dual(mediump sampler2D SPIRV_Cross_Combinedtexsamp)
{
return texture(SPIRV_Cross_Combinedtexsamp, vTex);
}
vec4 sample_duals()
{
vec4 a = sample_dual(SPIRV_Cross_CombineduTexture0uSampler0);
vec4 b = sample_dual(SPIRV_Cross_CombineduTexture1uSampler1);
return a + b;
}
vec4 sample_global_tex(mediump sampler2D SPIRV_Cross_CombineduTexture0samp, mediump sampler2D SPIRV_Cross_CombineduTexture1samp)
{
vec4 a = texture(SPIRV_Cross_CombineduTexture0samp, vTex);
vec4 b = sample_dual(SPIRV_Cross_CombineduTexture1samp);
return a + b;
}
vec4 sample_global_sampler(mediump sampler2D SPIRV_Cross_CombinedtexuSampler0, mediump sampler2D SPIRV_Cross_CombinedtexuSampler1)
{
vec4 a = texture(SPIRV_Cross_CombinedtexuSampler0, vTex);
vec4 b = sample_dual(SPIRV_Cross_CombinedtexuSampler1);
return a + b;
}
void main()
{
vec4 c0 = sample_duals();
vec4 c1 = sample_global_tex(SPIRV_Cross_CombineduTexture0uSampler0, SPIRV_Cross_CombineduTexture1uSampler0);
vec4 c2 = sample_global_tex(SPIRV_Cross_CombineduTexture0uSampler1, SPIRV_Cross_CombineduTexture1uSampler1);
vec4 c3 = sample_global_sampler(SPIRV_Cross_CombineduTexture0uSampler0, SPIRV_Cross_CombineduTexture0uSampler1);
vec4 c4 = sample_global_sampler(SPIRV_Cross_CombineduTexture1uSampler0, SPIRV_Cross_CombineduTexture1uSampler1);
FragColor = (((c0 + c1) + c2) + c3) + c4;
}

Some files were not shown because too many files have changed in this diff Show More