This patch makes the validator accept *.<stage name>.[g/h]lsl pattern
for file names.
This patch preserves previous behavior (i.e. *.vert/*.frag/etc. in file
names still work).
Adds command line options:
--invert-y
--iy
(synonyms) which invert position.Y on vertex shader output. Handles these cases:
* Direct single variable return
* Member of direct returned struct
* Single variable output parameter
* Member of struct output parameter
API:
// Enables position.Y output negation in vertex shader
void TShader::setInvertY(bool invert);
Fixes#1173
Per feedback on PR #1111, this reverses the order of the parameters for the setShiftBinding API.
It is now:
void TShader::setShiftBindingForSet(TResourceType res, unsigned int base, unsigned int set);
This PR adds the ability to provide per-descriptor-set IO mapping shift
values. If a particular binding does not land into a per-set value,
then it falls back to the prior behavior (global shifts per resource class).
Because there were already 6 copies of many different methods and internal
variables and functions, and this PR would have added 6 more, a new API is
introduced to cut down on replication and present a cleaner interface.
For the global (non-set-specific) API, the old entry points still exist
for backward compatibility, but are phrased internally in terms of the
following.
// Resource type for IO resolver
enum TResourceType {
EResSampler,
EResTexture,
EResImage,
EResUbo,
EResSsbo,
EResUav,
EResCount
};
Methods on TShader:
void setShiftBinding(TResourceType res, unsigned int base);
void setShiftBindingForSet(TResourceType res, unsigned int set, unsigned int base);
The first method replaces the 6 prior entry points of various spellings, which
exist now in depreciated form. The second provides per-resource-set functionality.
Both accept an enum from the list above.
From the command line, the existing options can accept either a single shift value as
before, or a series of 1 or more [set offset] pairs. Both can be provided, as in:
... --stb 20 --stb 2 25 3 30 ...
which will use the offset 20 for anything except descriptor set 2 (which uses 25) and
3 (which uses 30).
Also added known-good mechanism to fetch latest validated spirv-tools.
Also added -Od and -Os to disable optimizer and optimize for size.
Fetching spirv-tools is optional for both glsl and hlsl. Legalization
of hlsl is done by default if spirv-opt is present at cmake time.
Optimization for glsl is currently done through the option -Os.
Legalization testing is currently only done on four existing shaders.
A separate baseLegalResults directory holds those results. All previous
testing is done with the optimizer disabled.
--resource-set-binding has a mode which allows per-register assignments of
bindings and descriptor sets on the command line, and another accepting a
single descriptor set value to assign to all variables.
The former worked, but the latter would crash when assigning the values.
This fixes it, and makes the former case a bit more robust against premature
termination of the pre-register values, which must come in (regname,set,binding)
triples.
This also allows the form "--resource-set-binding stage setnum", which was
mentioned in the usage message, but did not parse.
The operation of the per-register form of this option is unchanged.
ShaderCompUnit was poorly done, a mix of a list of things and hard
coding to a single thing. This makes it all a true list.
File data was greatly simplified to be a single string, no longer
supporting breaking a single file into multiple strings.
Also, provides an option to auto-assign locations.
Existing tests use this option, to avoid the error message,
however, it is not fully implemented yet.
When glslang is built with some other build system and lumped/unity builds are used,
without the checks this would get “macro is being redefined” warnings/errors.
This reverts commit cfc69d95af.
* Change CMAKE_INSTALL_PREFIX default on Windows in order
to prevent permission denied errors when trying to install
to "Program Files".
* Use `GNUInstallDirs` in order to respect GNU conventions.
This is especially important for multi-arch/multi-lib setups.
* Specify position independent mode building properly, without
using the historic hack of adding `-fPIC` as a definition.
This makes the build system more portable.
* Only detect C++ (and not C) to slightly speed up configuring.
* Specify C++11 mode using modern CMake idioms.
* Fix some whitespace issues.
Adds --hlsl-iomap option to perform IO mapping in HLSL register space.
--shift-cbuffer-binding is now a synonym for --shift-ubo-binding.
The idea way to do this seems to be passing in a dedicated IO resolver, but
that would require more intrusive restructuring, so maybe best for its
own PR.
The TDefaultHlslIoResolver class and the former TDefaultIoResolver class
share quite a bit of mechanism in a common base class.
TODO: tbuffers are landing in the wrong register class, which needs some
investigation. They're either wrong upstream, or the detection in the
resolver is wrong.
C++11 features remove the dependencies from OS specific code. Changes:
- Making WorkList class to have its own mutex instead of the OS specific
global one. The new mutex is the one from std library. The OS specific
code is also removed.
- Using the C++11 std library to handle threads in StandAlone
application
and enabling concurrent processing on non-windows platforms.
- converting the global variable Worklist into local variable workList.
New command line option --shift-ssbo-binding mirrors --shift-ubo-binding, etc.
New reflection query getLocalSize(int dim) queries local size, e.g, CS threads.
Makes it easier to include glslang in a larger CMake project---instead
of having to call `target_link_libraries(glslang OSDependent OGLCompiler
HLSL)`, for example, you only need to call
`target_link_libraries(glslang)` and it will pull in the helpers it
needs.
This is also better in terms of cleaning up the "public interface",
of sorts, for building glslang: end-users probably shouldn't need to
know or be explicitly dependent on internal targets.
Any previous use would only be for "", which would probably mean changing
include(...) -> includeLocal(...)
See comments about includeLocal() being an additional search over
includeSystem(), not a superset search.
This also removed ForbidIncluder, as
- the message in ForbidIncluder was redundant: error results were
already returned to the caller, which then gives the error it
wants to
- there is a trivial default implementation that a subclass can
override any subset of (I still like abstract base classes though)
- trying to get less implementation out of the interface file anyway
- fixed ParseHelper.cpp newlines (crlf -> lf)
- removed trailing white space in most source files
- fix some spelling issues
- extra blank lines
- tabs to spaces
- replace #include comment about no location
Use "--source-entrypoint name" on the command line, or the
TShader::setSourceEntryPoint(char*) API.
When the name given to the above interfaces is detected in the
shader source, it will be renamed to the entry point name supplied
to the -e option or the TShader::setEntryPoint() method.
This PR adds:
1. The "u" register class for RW* objects.
2. --shift-image-bindings (== --sib), analogous to --shift-texture-bindings etc.
3. Case insensitive reg classes.
4. Tests for above.
Previously the uniform array flattening feature would trigger on loose
uniform arrays of any basic type (e.g, floats). This PR restricts it
to sampler and texture arrays. Other arrays would end up in their own
uniform block (anonymous or otherwise). (Atomic counter arrays might be an
exception, but those are not currently flattened).
This checkin adds a --flatten-uniform-arrays option which can break
uniform arrays of samplers, textures, or UBOs up into individual
scalars named (e.g) myarray[0], myarray[1], etc. These appear as
individual linkage objects.
Code notes:
- shouldFlatten internally calls shouldFlattenIO, and shouldFlattenUniform,
but is the only flattening query directly called.
- flattenVariable will handle structs or arrays (but not yet arrayed structs;
this is tested an an error is generated).
- There's some error checking around unhandled situations. E.g, flattening
uniform arrays with initializer lists is not implemented.
- This piggybacks on as much of the existing mechanism for struct flattening
as it can. E.g, it uses the same flattenMap, and the same
flattenAccess() method.
- handleAssign() has been generalized to cope with either structs or arrays.
- Extended test infrastructure to test flattening ability.
This PR adds the ability to offset sampler, texture, and UBO bindings
from provided base bindings, and to auto-number bindings that are not
provided with explicit register numbers. The mechanism works as
follows:
- Offsets may be given on the command line for all stages, or
individually for one or more single stages, in which case the
offset will be auto-selected according to the stage being
compiled. There is also an API to set them. The new command line
options are --shift-sampler-binding, --shift-texture-binding, and
--shift-UBO-binding.
- Uniforms which are not given explicit bindings in the source code
are auto-numbered if and only if they are in live code as
determined by the algorithm used to build the reflection
database, and the --auto-map-bindings option is given. This auto-numbering
avoids using any binding slots which were explicitly provided in
the code, whether or not that explicit use was live. E.g, "uniform
Texture1D foo : register(t3);" with --shift-texture-binding 10 will
reserve binding 13, whether or not foo is used in live code.
- Shorter synonyms for the command line options are available. See
the --help output.
The testing infrastructure is slightly extended to allow use of the
binding offset API, and two new tests spv.register.(no)autoassign.frag are
added for comparing the resulting SPIR-V.
Added -C option to request cascading errors. By default, will exit early,
to avoid all error-recovery-based crashes.
This works by simulating end-of-file in input on first error, so no
need for exception handling, or stack unwinding, or any complex error
checking/handling to get out of the stack.
This adds solution folders that properly group gtest/glslang/hlsl.
This also marks gtest options as advanced so they don't show up
in cmake-gui by default.
Previously GlslangToSpv() reported missing/TBD functionalities
by directly writing to stdout using printf. That could cause
problems to callers of GlslangToSpv(). This patch cleans up
the error reporting logic in GlslangToSpv(), TGlslangToSpvTraverser,
and spv::Builder a little bit to use ostringstream.
Also fixed the usage of GlslangToSpv() in GTest fixtures to
capture warnings/errors reported when translating AST to SPIR-V.
The existing test harness is a homemade shell script. All the tests
and the expected results are written in plain text files. The harness
just reads in a test, invoke the glslangValidator binary on it, and
compare the result with the golden file. All tests are kinda
integration tests.
This patch add Google Test as an external project, which provides a
new harness for reading shader source files, compile to SPIR-V, and
then compare with the expected output.
This plumbs both the current file path and the include depth
back up to the includer. This allows the includer to properly
support relative paths.
This also replaces the string copy that was done during include
with a zero-copy method of accomplishing the same thing. This
prevents extra copies of entire files.
Separating file I/O from compile/link lets the compile/link be done
repeatedly in a loop for testing and measuring of performance and
memory footprint, including seeing memory growth over time for
functional-level memory-leak testing.
While the older compile-only mode already had this functionality,
and typically showed no memory leaks, SPIR-V uses the link path,
has pending "TODO" for memory freeing, and this shows several
kilobytes of leaking per compile-link. Most likely, pending
merge request 131 will address much of this.
Using platform-neutral osinclude.h makes it easier to substitute
implementation when necessary and eliminates some variability between
build configurations.
* Linux folder has been renamed to Unix, to match defines and so that it
compiles on OS X.
* This removes the need for a per-platform include search path for the
right OS folder
* This also moves bison generated files into the source tree, so that
include of glslang_tab.cpp.h and includes from glslang_tab.cpp work
the same way.
The new make-revision script regenerates glslang/Include/revision.h,
used as it always has been, but made with a git-tag version and the
the number of commits on master.
I have a pre-commit hook that will automatically do this on master,
likely often enough to work in practice, without needing pull requests
to include it.
When an include directive is recognized by the preprocessor, it
executes a callback on the filepath argument to obtain the file
contents. That way the compilation client can deal with the file
system, include paths, etc.
Currently only accepts quoted filepaths -- no angle brackets yet.
- the built-in constants
- built-in variable declarations, some dependent on gl_MaxPatchVertices
- layout qualifier for vertices (shared with geometry shader max_vertices)
- layout qualifiers for vertex spacing, vertex order, point mode, and primitive type
- link semantics for layout qualifiers
Still TBD:
- patch qualifier and arrayed input handling
- sizing of gl_out[]
- additional semantic checking
- supporting the extension on version 150
git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@24468 e7fa87d3-cd2b-0410-9028-fcbf551c1848
- the new C++ style interface now stands on its own, with the addition of glslang::InitializeProcess() and glslang::FinalizeProcess()
- more "global" pool names from a decade ago are fixed to be thread names
- StandAlone.cpp fully uses one of the old-style interface or new C++ style interface
git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@23851 e7fa87d3-cd2b-0410-9028-fcbf551c1848
Added the built-in functions EmitVertex(), EndPrimitive(), barrier(), memoryBarrier(), memoryBarrierAtomicCounter(), memoryBarrierBuffer(), memoryBarrierImage(), memoryBarrierShared(), and groupMemoryBarrier().
Have not added any new built-in variables.
Also changed the linear performance relateToOperator() to a high-performance version.
git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@22659 e7fa87d3-cd2b-0410-9028-fcbf551c1848