[spirv] Update doc and SPIRV-Tools (#1088)

Add explanation of legalization, optimization, validation in doc.
This commit is contained in:
Lei Zhang 2018-02-21 14:12:01 -05:00 коммит произвёл GitHub
Родитель 4221a698e1
Коммит 5c4ca12efc
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 53 добавлений и 1 удалений

Просмотреть файл

@ -286,6 +286,58 @@ interface variables:
main([[vk::location(N)]] float4 input: A) : B
{ ... }
Legalization, optimization, validation
--------------------------------------
After initial translation of the HLSL source code, SPIR-V CodeGen will further
conduct legalization (if needed), optimization (if requested), and validation
(if not turned off). All these three stages are outsourced to `SPIRV-Tools <https://github.com/KhronosGroup/SPIRV-Tools>`_.
Here are the options controlling these stages:
* ``-fcgl``: turn off legalization and optimization
* ``-Od``: turn off optimization
* ``-Vd``: turn off validation
Legalization
~~~~~~~~~~~~
HLSL is a fairly permissive language considering the flexibility it provides for
manipulating resource objects. The developer can create local copies, pass
them around as function parameters and return values, as long as after certain
transformations (function inlining, constant evaluation and propagating, dead
code elimination, etc.), the compiler can remove all temporary copies and
pinpoint all uses to unique global resource objects.
Resulting from the above property of HLSL, if we translate into SPIR-V for
Vulkan literally from the input HLSL source code, we will sometimes generate
illegal SPIR-V. Certain transformations are needed to legalize the literally
translated SPIR-V. Performing such transformations at the frontend AST level
is cumbersome or impossible (e.g., function inlining). They are better to be
conducted at SPIR-V level. Therefore, legalization is delegated to SPIRV-Tools.
Specifically, we need to legalize the following HLSL source code patterns:
* Using resource types in struct types
* Creating aliases of global resource objects
* Control flows invovling the above cases
Legalization transformations will not run unless the above patterns are
encountered in the source code.
Optimization
~~~~~~~~~~~~
Optimization is also delegated to SPIRV-Tools. Right now there are no difference
between optimization levels greater than zero; they will all invoke the same
optimization recipe. This may change in the future.
Validation
~~~~~~~~~~
Validation is turned on by default as the last stage of SPIR-V CodeGen. Failing
validation, which indicates there is a CodeGen bug, will trigger a fatal error.
Please file an issue if you see that.
HLSL Types
==========

2
external/SPIRV-Tools поставляемый

@ -1 +1 @@
Subproject commit 6c75050136a2657dac4501ca16d447852fc69e5f
Subproject commit 01760d2f0f6422b330ea99dd67da72230ef2bbd7