Commit Graph

45 Commits

Author SHA1 Message Date
ahagan
b5aae62731 Add whitelist filtering for debug comments in SPIRV-Remap. 2022-05-11 12:08:25 -04:00
Rémi Verschelde
69d0c1acc2
Remove executable bits from code/data files (#2420) 2020-10-12 10:08:47 -06:00
Shahbaz Youssefi
1ef2e250fc
Use GLSLANG_ANGLE to strip features to what ANGLE requires
This change strips a few features similar to GLSLANG_WEB but doesn't
remove every detail like the latter.  It also hardcodes profile/version
to core/450.

In particular, TBuiltIns::initialize is specialized to remove most of
what is not supported or won't be supported by ANGLE.  The result of
this function is parsed with TParseContext::parseShaderStrings which is
a performance bottleneck.

This change shaves about 300KB off of ANGLE's binary size and reduces
the cost of SetupBuiltinSymbolTable to nearly a sixth.

Signed-off-by: Shahbaz Youssefi <ShabbyX@gmail.com>
2020-07-31 12:44:49 -04:00
John Kessenich
4f32f93d7e Revert "Merge pull request #2330 from ShabbyX/optimize_for_angle"
This reverts commit 1ee5d1c0bb, reversing
changes made to 906d48a7e8.
2020-07-13 03:39:08 -06:00
Shahbaz Youssefi
8c49d15fbf
Use GLSLANG_ANGLE to strip features to what ANGLE requires
This change strips a few features similar to GLSLANG_WEB but doesn't
remove every detail like the latter.  It also hardcodes profile/version
to core/450.

In particular, TBuiltIns::initialize is specialized to remove most of
what is not supported or won't be supported by ANGLE.  The result of
this function is parsed with TParseContext::parseShaderStrings which is
a performance bottleneck.

This change shaves about 300KB off of ANGLE's binary size and reduces
the cost of SetupBuiltinSymbolTable to nearly a sixth.

Signed-off-by: Shahbaz Youssefi <ShabbyX@gmail.com>
2020-07-08 15:33:20 -04:00
John Kessenich
f6facfa189 Tests: More broadly use automapping binding/location.
This adds or changes binding/location decorations in 100s of shaders.
It also allows more output (spv.register.autoassign.rangetest.frag)
due to allowing ioMap() to fail.
2020-07-01 06:40:13 -06:00
David Neto
8c3d5b4b6c SPIR-V: Aggressively prune unreachable merge, continue target
More aggressively prune unreachable code as follows.
When no control flow edges reach a merge block or continue target:
- delete their contents so that:
  - a merge block becomes OpLabel, then OpUnreachable
  - a continue target becomes OpLabel, then an OpBranch back to the
    loop header
- any basic block which is dominated by such a merge block or continue
  target is removed as well.
- decorations targeting the removed instructions are removed.

Enables the SPIR-V builder post-processing step the GLSLANG_WEB case.
2019-10-29 15:33:54 -04:00
John Kessenich
b9197c812e Web: Make switched methods all be non-virtual, more web-dependent code,
added a few more HLSL flag tests.  This was mostly focused on the SPV generator.
Saves about 17K.
2019-08-20 23:21:56 -06:00
John Kessenich
b6d3ee5aca Web: Turn off bracket-style attributes, reflection, and IO mapping. 2019-08-20 23:21:55 -06:00
John Kessenich
cfea59d357 SPV 1.4: Add testing infrastructure for SPV 1.4 tests.
This includes the test for the first feature of OpEntryPoint.
2019-05-10 00:02:45 -06:00
Rémi Verschelde
ebfd91a719 Remove Unix executable permission from text files 2018-12-10 10:49:16 +01:00
John Kessenich
bd1c1831d5 Manually merge ClemensRognerSD-dx9-sampler and resolve conflicts. 2018-12-07 18:38:26 -07:00
greg-lunarg
5d43c4aac7 SPV: Fix #1575, fix #1593: Support HLSL #line
SPIR-V OpLines now contain filenames from HLSL-style #lines.
2018-12-07 17:36:33 -07:00
Alan Baker
ed777b0fbd Modify testing to only record validation pass/fail
* Changed unit tests to only record known the validation pass/fail
status
 * errors are output as part of the failure message if the result is
 unexpected
 * can turn off validation for each test individually
* Moved some SPV_KHR_vulkan_memory_model tests to be compiled for Vulkan
1.1
2018-12-07 13:58:46 -05:00
John Kessenich
c340425bb2 SPV: Add option for controling when the SPIRV-Tools validator is used. 2018-08-23 15:29:08 -06:00
John Kessenich
717c80a9de SPV: Isolate SPIRV-tools glue to its own file. 2018-08-23 15:17:10 -06:00
GregF
fb03a55e0f Only print legalization warning if optimizer disabled 2018-03-29 13:17:54 -06:00
John Kessenich
7cec64fc42 Non functional: add EshTargetClientVersion alias for EShTargetClientVersion.
Fixes #1304.
2018-03-22 23:54:04 -06:00
John Kessenich
66011cb2c2 SPV: Implement Vulkan 1.1 features and extensions. 2018-03-06 16:12:04 -07:00
John Kessenich
9c9c4e90df GLSL/SPV: Fix #1196: Require resources to have layout(binding=X). 2018-02-22 11:47:41 -07:00
GregF
cd1f169c6a Enable HLSL legalization
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.
2017-09-27 15:06:05 -06:00
t.jung
baf570efa5 Pure Texture to Sampled Texture Transform
Adds a transformation step to the post processing step.
Two modes are available:
1) keep
- Keeps samplers, textures and sampled textures as is
2) transform pure texture into sampled texture and remove pure samplers
- removes all pure samplers
- transforms all pure textures into its sampled counter part

Change-Id: If54972e8052961db66c23f4b7e719d363cf6edbd
2017-05-29 18:29:45 +02:00
John Kessenich
71facdf435 SPV: Give error on not assigning locations to I/O.
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.
2017-05-18 15:07:05 -06:00
steve-lunarg
932bb5cc4e Add reflection queries for thread local size and ssbo auto-binding
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.
2017-02-22 09:40:28 -07:00
John Kessenich
facde2c804 PP #include: address PR feedback. 2017-01-06 16:48:18 -07:00
John Kessenich
63204c2501 External interface change: PP: Full <> and "" semantics for the Includer.
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
2017-01-06 15:08:54 -07:00
steve-lunarg
9088be4c07 Add UAV (image) binding offset and HLSL register support
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.
2016-11-01 14:44:54 -06:00
David Neto
1d3a966106 Gtests can be run on another source tree
The gtest executable accepts a --test-root option to specify
a root directory for test files.  It defaults to the Test directory
in the source tree from which the executable is built.

For example, this lets us run test exectuables built with MinGW on Linux
on a Windows machine with its own copy of the source tree.
2016-10-05 10:28:32 -04:00
steve-lunarg
cf43e66125 Fix defects in uniform array flattening
Fix for two defects as follows:

- The IO mapping traverser was not setting inVisit, and would skip some AST nodes.
  Depending on the order of nodes, this could have prevented the binding from
  showing up in the generated SPIR-V.

- If a uniform array was flattened, each of the flattened scalars from the array
  is still a (now-scalar) uniform.  It was being converted to a temporary.
2016-09-22 15:58:06 -06:00
steve-lunarg
e0b9debda2 Flatten uniform arrays
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.
2016-09-22 08:47:48 -06:00
steve-lunarg
7f7c2ed780 HLSL: Add location offsets per resource type
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.
2016-09-20 20:31:27 -06:00
steve-lunarg
a8456415b8 WIP: SPV Remapper: add remapper test framework 2016-08-25 10:46:51 -06:00
John Kessenich
2c6038ecf1 Merge branch 'cpp-headers' 2016-08-11 10:01:13 -06:00
John Kessenich
0a6fb85494 Infrastructure: Make shared symbol-table cache complete, delete work around.
Fixes issue #370 and replaces PR #371.
2016-08-09 19:15:17 -06:00
John Kessenich
66ec80e01b Build: C++ headers: Replace PR #366 with a more directed version. 2016-08-05 14:04:23 -06:00
John Kessenich
a86836ede2 Front-end: Fix known crashes by early exit on error (issue #29, issue #34, issue #35).
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.
2016-07-09 14:53:11 -06:00
John Kessenich
7f349c73db Build: Remove causes of pedantic warnings. Addresses issue #352 and PR #242. 2016-07-08 22:09:10 -06:00
Lei Zhang
1b141728a6 Test compiling shaders with given resource limits using GTest. 2016-05-19 14:18:21 -04:00
Lei Zhang
8a9b1ee3b4 Rename DefaultResourceLimits.* to ResourceLimits.*. 2016-05-19 13:53:16 -04:00
Lei Zhang
2f1ee4525d Run link tests in the GTest framework. 2016-05-18 21:45:39 -04:00
Lei Zhang
fc697cc938 Fix several comments in GTest fixture. 2016-05-17 16:45:37 -04:00
Lei Zhang
d6f0ed2c81 Add support for testing file-based HLSL source code in GTest. 2016-05-16 12:51:13 -04:00
Lei Zhang
17535f7d55 Create a new logger class for all messages w.r.t. SPIR-V build. 2016-05-05 10:15:06 -04:00
Lei Zhang
09caf12bec Avoid printing to stdout directly in library functions.
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.
2016-05-05 10:15:06 -04:00
Lei Zhang
414eb60482 Link in Google Test framework.
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.
2016-03-31 10:31:30 -04:00