Commit Graph

66 Commits

Author SHA1 Message Date
Jeff Bolz
ca04c2a16a
Fix nonsemantic debuginfo line attribution for cooperative matrix
* Generate debuginfo for coopmat types, treating them as an opaque composite. Restore the debug source location after calling convertGlslangToSpvType, fixes the line info in this unit test

* Add a cooperative matrix test case, based on the shader from https://github.com/jeffbolznv/vk_cooperative_matrix_perf/blob/master/shaders/shmem.comp
2024-09-30 13:53:27 -04:00
arcady-lunarg
7c3c50ea94
spirv: Add a postprocessing pass to fix up uses of OpSampledImage
SPIR-V requires that any instruction using the result of an
OpSampledImage instruction be in the same block as the OpSampledImage.
This is hard to guarantee in code generation but easy to fix after the
fact, by simply inserting a new OpSampledImage before the user of its
result if needed, with the new instruction having the same operands as
the original OpSampledImage.
This change adds a new pass to spv::Builder::postProcess that does this.
This might leave the original OpSampledImage instructions "orphaned"
with no users of their result ID, but dead code elimination would take
care of those further down the line.
2024-05-20 13:25:55 -04:00
Herman Semenov
2db79056b4 Maximum optimization inserts using reserve() for operands 2024-04-11 15:10:58 -04:00
Qingyuan Zheng
30661abd9c
Clean up the debug line info tracking and generation.
- Correctly populate the field `currentFileId` with the presence of include directive
- Support lazy OpLine/OpDebugLine generation only when a real instruction is added instead of a debug location is set
- Improve the debug location tracking to per-block instead of just per-builder
- A few bug fixes related to debug source info
2024-02-09 10:27:40 -08:00
Chao Chen
979423d84f Add correct line number to OpDebugFunction and OpDebugScope for function:
1. Pull OpDebugFunction, OpDebugScope and OpDebugVariable for params out
   of makeFunctionEntry.
2. Put above in a separate function called setupDebugFunctionEntry,
   which also accept line number and set it correctly in builder.
3. Call setupDebugFunctionEntry in makeFunction. Also special case
   handle entry function since it's created ealier elsewhere.
2023-10-24 13:37:19 -07:00
Nathaniel Cesario
4c57db1595 Add --no-link option
Adds the --no-link option which outputs the compiled shader binaries
without linking them. This is a first step towards allowing users to
create SPIR-v binary, non-executable libraries.

When using the --no-link option, all functions are decorated with the
Export linkage attribute.
2023-09-18 17:31:05 -04:00
Arcady Goldmints-Orlov
3ebb72cc74 Add an assert that ID operands are non-zero
Zero is not a valid ID value and the SPIR-V emitter library should never
be emitting instructions with ID values of 0.
2023-06-27 13:49:14 -04:00
Allan MacKinnon
a5bf69936d [glslang] Strip trailing whitespace
There are many other files in the repo that have trailing whitespace
but this PR only cleans `glslang/SPIRV` and `glslang/Standalone`.
2023-05-22 12:04:40 -06:00
Jeremy Hayes
7a914ce926 Implement NonSemantic.Shader.DebugInfo.100
See https://github.com/KhronosGroup/SPIRV-Registry.
2022-08-26 16:17:54 -06:00
Qingyuan Zheng
61d244145d avoid using make_unique for c++11 compatibility 2022-05-31 10:40:25 -07:00
Qingyuan Zheng
b6df89b470 use unique_ptr to avoid calling deleted move ctor 2022-05-30 23:08:50 -07:00
Qingyuan Zheng
279c28e70a generate OpLine before OpFunction 2022-05-23 23:05:43 -07:00
Marius Hillenbrand
78ce7e567f Fix encoding/decoding of string literals for big-endian systems
Per SPIR-V spec, a string literal's UTF-8 octets are encoded packed into
words with little-endian convention. Explicitly perform that encoding
instead of assuming that the host system is little-endian.

Note that this change requires corresponding fixes in SPIRV-Tools.

Fixes #202
2021-11-08 14:12:01 +01:00
Jesse Hall
74e8f05b9f
Implement GL_EXT_terminate_invocation (#2454)
* Implement GL_EXT_terminate_invocation.

* terminateInvocation: declare the SPV extension

* Update test results for spirv-tools and bison version bumps

Co-authored-by: John Kessenich <cepheus@frii.com>
2020-11-09 09:30:01 -07:00
Rémi Verschelde
69d0c1acc2
Remove executable bits from code/data files (#2420) 2020-10-12 10:08:47 -06:00
John Kessenich
435dd8028b SPV: RelaxedPrecision: Generalize fix #2293 to cover more operations.
This simplifies and enforces use of precision in many more places,
to help avoid accidental loss of RelaxedPrecision through intermediate
operations. Known fixes are:
- ?:
- function return values with mis-matched precision
- precision of function return values when a copy was needed to fix types
2020-06-30 02:44:52 -06:00
John Kessenich
4df10335e6 SPV: Partially address #2293: correct "const in" precision matching.
Track whether formal parameters declare reduced precision and match
that with arguments, and if they differ, make a copy to promote the
precision.
2020-06-26 08:37:06 -06:00
John Kessenich
1fff362355 Build warning: Fix #2167: Remove nested reuse of 'unreachable'. 2020-04-01 00:46:57 -06:00
Ryan Harrison
0552c0acc8 Remove std::move that is breaking chromium roll
This is causing the following error:

moving a temporary object prevents copy elision
[-Werror,-Wpessimizing-move]
2019-11-04 16:23:11 -05:00
John Kessenich
31c3370d83 Bump up the generator version, which is exposed in SPV test results. 2019-11-02 21:26:40 -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
Shahbaz Youssefi
6cca0e983e Remove extraneous semicolons
They cause a warning (-Wextra-semi) that can lead to a compile error
(-Werror).
2019-06-25 13:20:16 -04:00
Jeff Bolz
4605e2ed2b Implement GL_NV_cooperative_matrix 2019-02-25 23:42:59 -06:00
Jeff Bolz
9f2aec49e9 GL_EXT_buffer_reference 2019-01-07 12:36:13 -06:00
John Kessenich
b23d232ec5 Licensing. Fixes #958. Add licenes file and update copyrights. 2018-12-14 10:47:35 -07:00
John Kessenich
97068d8b30
Merge pull request #1465 from otakuto/remove-execute-permissions
Remove execute permissions
2018-08-31 08:14:47 -07:00
John Kessenich
31aa3d6019 SPV: only declare the pure 8/16-bit capabilities when needed.
Only when operations stray outside the 8/16-bit storage-capabilities
are the general (pure 8/16-bit) capabilities needed.
2018-08-16 15:54:21 -06:00
John Kessenich
149afc3930 SPV: More corrections of <id> versus "immediate" operands. 2018-08-14 13:31:43 -06:00
John Kessenich
228e964bcc SPV: Correct SPIR-V operands for <id> versus immediate. 2018-08-13 21:37:59 -06:00
otakuto
d03da06ac1 Remove execute permissions 2018-08-07 03:16:20 +09:00
John Kessenich
d3ed90be3a Fix #944: Convert argument type to match formal parameter type. 2018-05-04 11:43:03 -06:00
John Kessenich
2505057af8 SPV: Memory model: Reduce set of memory-semantic bits requested for "all". 2017-12-16 00:34:08 -07:00
John Kessenich
8297936dd6 SPV: Change barrier emission to conform to Khronos decisions.
The memory model group agreed to these definitions for how
to map GLSL barrier, memoryBarrier, etc. With HLSL following suit.
2017-12-16 00:30:10 -07:00
LoopDawg
2baa774259 Linux build warning fix
* Remove complaint about unused function parameter in resolveUniformLocation()
* Remove complaint about defined but not used variable in spvIR.h
2017-08-31 18:09:58 -06:00
John Kessenich
121853f4df SPV: Add OpSource shader source code and file name. 2017-05-31 17:14:15 -06:00
John Kessenich
3778979cd4 HLSL: non-static member functions: track and find active anonymous 'this' scopes and members.
Thanks to @steve-lunarg for his input and discussions on handling member functions.
2017-03-21 23:56:40 -06:00
John Kessenich
927608b393 Non-functional: White space after "//", mostly for copyrights. 2017-01-06 12:34:14 -07:00
John Kessenich
ecba76fe73 Non-Functional: Whitespace, comments, replace accidentally deleted comment.
- 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
2017-01-06 11:24:14 -07:00
John Kessenich
4016e38bea Build: Switch to Rev. 6 of headers, removing "BadValue" enum stuff.
Note: Technically, this is glslang's modified private copy of official headers.
Official headers will appear in other places, like
https://github.com/KhronosGroup/SPIRV-Headers.
2016-07-15 11:55:34 -06:00
John Kessenich
c51287d744 SPV: Update to spec. decisions (and issue #205) for barrier().
A barrier (ESSL/GLSL) or OpControlBarrier when in a tessellation control
shader also means doing memory synchronization for output variables.
2016-06-14 19:50:26 -06:00
John Kessenich
d3d3ce7160 Comments only. 2016-05-06 13:06:11 -06:00
qining
da39733f28 Remove decoration of undefined IDs
Fix issue #185 by removing OpDecorate instructions whose target IDs are
defined in unreachable blocks and thus not dumped in the generated
SPIR-V code.
2016-03-09 19:54:03 -05:00
John Kessenich
4889167430 SPV: Use a more accurate MemorySemanticsAllMemory mask. 2016-01-22 10:15:03 -07:00
Dejan Mircevski
ed55bcd9f8 Don't remove SPIR-V blocks before codegen.
A removed block releases its instructions, so Module::idToInstruction
suddenly contains dangling references.  The original motivation for
block removal was to skip some unreachable blocks, but that's already
achieved by InReadableOrder.cpp.

Also updated stale comments.
2016-01-19 21:18:14 -05:00
Dejan Mircevski
e7f6cac1bd Merge branch 'topo' into loopgen-after-readable-order 2016-01-19 16:47:41 -05:00
Dejan Mircevski
34bc6c3896 Explicitly initialize Instruction::block. 2016-01-19 14:08:32 -05:00
Dejan Mircevski
fa242904b0 Make Instruction::getBlock() const. 2016-01-19 11:31:55 -05:00
Dejan Mircevski
377f0cab26 Fix merge issues. 2016-01-19 10:17:33 -05:00
Dejan Mircevski
38d039d063 Rework inReadableOrder() as a recursive descent.
Add a test for unreachable merge block.

Update test results with the new order: mainly delaying merge blocks and
removing unreachable ones.
2016-01-19 10:14:50 -05:00
Dejan Mircevski
44bfb0d0cd Implement inReadableOrder(). 2016-01-19 10:11:34 -05:00