Граф коммитов

147 Коммитов

Автор SHA1 Сообщение Дата
alelenv 04a84f05a5
Add support for SPV_KHR_ray_tracing. (#2780)
* Add support for SPV_KHR_ray_tracing.

* Target KHR RT extension by default

* Reupdate documentation

* Add missing asterix

* Another typo
2020-03-23 13:37:54 -05:00
Ehsan 9b9615d5b3
[spirv] Ensure loop unroll is run before descriptor scalar replacement. (#2417) 2019-08-22 13:40:35 -05:00
Ehsan 922ef652fa
[spirv] Add option to flatten array of resources. (#2397)
* [spirv] Add option to flatten array of resources.

Current SPIR-V code generation uses 1 binding number for an array of
resources (e.g. an array of textures). However, the DX side uses one
binding number per array element. The newly added
'-fspv-flatten-resource-arrays' changes the SPIR-V backend behavior to
use one binding number per array element, and uses spirv-opt to flatten
the array.

TODO: Add a test where the array is passed around.
TODO: Test this works with steven's PR and proper results are produced.

* [spirv] Update tests to include array of samplers.

* [spirv] Take early exit condition out of the loop.

* [spirv] Add documentation for the new cmd option.

* [spirv] Invoke CreateDescriptorScalarReplacementPass when needed.

* [spirv] address code review comments.
2019-08-14 09:45:01 -04:00
Sahil Parmar 83c1bf8e92 [spirv] Add mesh/amplification shader tests for use of buffers and fn calls (#2390)
- Also cleans up SPIR-V.rst documentation issues.
2019-08-06 11:12:42 -04:00
Sahil Parmar 968fe41136 Merged PR 116: Add support for HLSL Meshlets
This PR adds support for new HLSL mesh and amplification shaders.
2019-07-11 20:19:23 +00:00
JasperNV 4f487432ad [spirv] Add support for SV_ShadingRate as a PS input (#2226)
* Add support for SV_ShadingRate as a PS input

Solves a portion of #2208.

* Fix small typo in error message
2019-06-06 17:15:21 -04:00
Ehsan 101730c57b
[spirv] Respect the -auto-binding-space option in SPIR-V backend (#2211)
* [spirv] Respect the -auto-binding-space option in SPIR-V backend.

* [spirv] Use default space if vk::binding doesn't provide dset.

* Address code review comments.
2019-06-04 09:35:04 -04:00
alelenv b830b09bc5 [spirv] Add support for [[vk::shader_record_nv]] (#2179)
* Add support for [[vk::shader_record_nv]]

* Fixes after first review of ehsannas.
2019-05-16 00:36:28 -04:00
Ehsan 5648e43f18
[spirv] Command line option for providing $Globals binding. (#2156) 2019-05-01 18:28:14 -04:00
alelenv e58ecd4c2f Add support to convert DXR HLSL to SPV_NV_ray_tracing (#1920)
* Add support to convert DXR HLSL to SPV_NV_ray_tracing

* Fix multiple typos and cleanup using clang-format.

* Update tests to verify transpose and custom matrix type
Update tests to add multple entry functions of same shader stage

* Replace ExecutionModel class with ShaderModel::Kind

- This change removes ExecutionModel class and relies on ShaderModel::Kind to track current entry point shader stage
- Also instead of declaring it in SpirvEmitter, DeclResultIdMapper & GlPerVertex, we declare it only once in common object SpirvContext

* Dont create a stageVar for raytracing interface variables.

* Don't perform 'new' memory allocation for FunctionInfo object

This change also -
- removes invalid "SpirvEmitter::" from function declarations in SpirvEmitter class.
- fix build errors by adding a default constructor in FunctionInfo struct to allow functionInfoMap allocate an empty object for no search results.

* Fix some more typos and fomatting errors.

* Update RST with raytracing stage info

* In SpirvContext.h, replace unsigned by uint32_t

* Test add ascii art and fixup grammar mistakes.

* Use placement new to allocate FunctionInfo objects.

Also bundle the insertion into functionInfoMap and workQueue together.

* Remove outdated comment.

* Update RST with intrinsic mapping and typo fixes.

* Some more wording fixes to RST for raytracing.

* Accidently broke table in RST due to missing '-'

* Add tick marks for supported stages in RST

* Final clang-format formatting fixes.

* Add missing labels to flowchart and spacing.
2019-02-27 09:58:59 -05:00
Ehsan ebb720ced3
[spirv] Support HLSL 'register(c#)' annotation. (#1912) 2019-02-12 10:07:20 -05:00
Lei Zhang 7a2a95e36c
[spirv] Add support for VK_EXT_scalar_block_layout (#1716)
Ref: https://github.com/KhronosGroup/Vulkan-Docs/issues/854
2018-11-20 11:24:57 -05:00
Steven Perron fe2d48b984 Add the HLSL-spirv cookbook. (#1618)
Add a document to give examples of what HLSL code patterns will generate
valid Vulkan SPIR-V.
2018-10-22 14:22:44 -04:00
Lei Zhang 2ecc36b382
[spirv] Add doc about supported extensions 2018-10-01 14:47:11 -04:00
Lei Zhang d0fcff32fd
[spirv] Fix doc about half translation (#1539) 2018-09-11 14:49:20 -04:00
Lei Zhang 81b3451b4a
[spirv] Add mechanism for fine-grained control of debug info (#1518)
Added a new command-line option: -fspv-debug=<category>, where
category can be file, source, line, and tool, to give developers
fine-grained control of what debug information they want in
the generated SPIR-V code.
2018-08-29 11:11:30 -04:00
Lei Zhang 4d6e2cfc64
[spirv] Fix array index out of bound in doc (#1516) 2018-08-27 19:40:11 -04:00
Lei Zhang 05cda8da2a
[spirv] Add support for -fvk-bind-register (#1480)
format: -fvk-bind-register <type-number> <space> <binding> <set>

Also created a short alias for it: -vkbr.

This option gives the ultimate manual control of descriptor
assignment. It requires:

* All resources are annotated with :register() in the source code
* -fvk-bind-register is specified for every resource

It overrules all other mechanisms.
It cannot be used together with -fvk-{u|b|s|t}-shift.
2018-08-03 07:36:18 -04:00
Lei Zhang 474954a6ea
[spirv] Update mapping manual w.r.t. debugging and options (#1475) 2018-08-01 10:49:51 -04:00
Ehsan 90103b38c2
[spirv] Expose -Oconfig for running custom optimizer recipes (#1466) 2018-07-31 13:49:19 -04:00
Ehsan f9882c84a7
[spirv] Support for post_depth_coverage extension. (#1461) 2018-07-27 17:16:41 -04:00
Lei Zhang f40667e931
[spirv] Rename -fvk-invert-w to -fvk-use-dx-position-w (#1448) 2018-07-24 20:46:14 -04:00
Lei Zhang dbc67dc4f4
[spirv] -fvk-invert-w in non-PS stages is no-op (#1441)
Allow using -fvk-invert-w in non-PS stages and make it a no-op.
2018-07-21 06:57:55 -04:00
Lei Zhang ef6c9eff15
[spirv] Add -fvk-invert-w (#1429)
This option reciprocates (multiplicatively inverts) SV_Position.w
after reading it from stage input in PS. This is used to accommodate
the difference between Vulkan and DirectX.
2018-07-19 10:34:51 -04:00
Ehsan 18545516b0
[spirv] Handle CalculateLevelOfDetailUnclamped. (#1400) 2018-07-04 15:55:21 -04:00
Lei Zhang ed29623d9a
[spirv] Handle nested structs for [[vk::offset]] (#1399)
Also update the SPIR-V doc about [[vk::offset]
2018-07-04 10:58:35 -04:00
Lei Zhang 8c6d72a2a7
[spirv] Add option to ignore warnings on features without Vulkan support (#1289)
Added -Wno-vk-ignored-features to suppress warnings on features
that are ignored because of no Vulkan support. Examples include
cbuffer member initializer.
2018-05-16 14:32:30 -04:00
Lei Zhang babfc756c3
[spirv] Convert to use 2 as the depth value for OpTypeImage (#1261)
2 means no indication as to whether this is a depth or non-depth
image.

Reverted "Hack OpSampledImage for depth-comparison sampling".

This reverts commit 0f165c6483.
2018-05-11 10:57:26 -04:00
Lei Zhang 4dd7aee306
[spirv] Add doc about synchronization intrinsics (#1263) 2018-05-08 13:18:28 -04:00
Lei Zhang a1a33a4199
[spirv] Convert to use stand-alone variables for gl_PerVertex (#1259)
It's actually a spec reading issue that it seems we cannot
have stand-alone variables for Position, PointSize, ClipDistance,
or CullDistance in HS/DS/GS.

Removed all code regarding Position and PointSize from GlPerVertex.
We still need to keep GlPerVertex aroudn to handle ClipDistance
and CullDistance though.
2018-05-07 10:21:20 -04:00
Lei Zhang 2095fef62c
[spirv] Add support for arrays of structured/byte buffers (#1257)
They are translated into, of course, (runtime) arrays of
structured/byte buffers.
2018-05-03 13:36:09 -04:00
Lei Zhang 9b856626d6
[spirv] Add support for dual-source blending (#1251)
In HLSL, dual-source color blending is enabled only via API;
the shader needs no special marks: it only writes SV_Target0
& SV_Target1 like normal.

But in Vulkan, to enable dual-source blending, the shader need
to mark the two participating output variables with Index = 0
and Index = 1, respectively.

So we introduce a new attribute, vk::index(), to let developers
to specify the index of an output variable so dual-source
blending can be enabled.

See Vulkan spec "26.1.2. Dual-Source Blending".
2018-04-26 16:02:12 -04:00
Lei Zhang 23be4804b6
[spirv] Remove -fvk-ignore-unused-resources (#1246) 2018-04-24 14:47:28 -04:00
Lei Zhang 4491a30fba
[spirv] Support non-constant offsets in .Gather*() methods (#1232)
They are emulated via 4 separate OpImage*Gather instructions.
2018-04-16 17:21:02 -04:00
Lei Zhang 4ac938cc5b
[spirv] Clarify doc about SPIR-V target environment (#1230) 2018-04-16 17:16:07 -04:00
Lei Zhang a4491dd439
[spirv] Support shifting all sets with -fvk-*-shift N all (#1224) 2018-04-13 15:40:44 -04:00
Lei Zhang 0a8b8c4e1d
[spirv] Rename -fvk-use-glsl-layout to -fvk-use-gl-layout (#1206)
GLSL as a shading language does not define the layout rules for
std140/std430; the OpenGL graphics environment defines that.

This is also more consistent with -fvk-use-dx-layout.
2018-04-10 10:25:26 -04:00
Lei Zhang 99c142be0b
[spirv] Add support for DX layout rules (#1198)
These layout rules can be turned on with -fvk-use-dx-layout.
For both cbuffer/tbuffer and structured buffers.
2018-04-08 12:50:57 -04:00
Ehsan 68984b316a
[spirv] Specify "KHR" to enable all KHR extensions (#1195) 2018-04-03 15:21:23 -04:00
Ehsan 2a0b7c49fd
[spirv] Add -fspv-target-env command line option. (#1187)
* [spirv] Add -fspv-target-env command line option.

The valid values for this option currently are:
vulkan1.0
vulkan1.1

If no target environment is specified, vulkan1.0 is used as default.
2018-04-03 09:12:51 -04:00
Lei Zhang 241d32c810
[spirv] Allow explicitly controlling SPIR-V extensions (#1151)
Added FeatureManager to record all extensions specified from
the command-line and emit error if trying to use one not permitted.

Added command-line option -fspv-extension= to specify
whitelisted extensions.
2018-03-27 17:42:16 -04:00
Ehsan c66c37cfa1
[spirv] Add support for DeviceIndex builtin. (#1171) 2018-03-23 10:40:02 -04:00
Lei Zhang 66a8998f87
[spirv] Translate SV_InnerCoverage into FullyCoveredEXT (#1165)
Fixes https://github.com/Microsoft/DirectXShaderCompiler/issues/999
2018-03-22 10:08:43 -04:00
Lei Zhang 9b0167be56
[spirv] Add support for :packoffset() (#1156) 2018-03-20 12:18:31 -04:00
Lei Zhang 0d8a15a61a
[spirv] Better reflection support via new extensions (#1111)
This commit uses the HlslCounterBufferGOOGLE decoration to link
the main RW/Append/Consume StructuredBuffer with its associated
counter buffer. It also uses HLSLSemanticGOOGLE to decorate
stage IO variables with their semantic strings from the source code.
2018-03-17 13:05:31 -04:00
Lei Zhang cfd787a18e
[spirv] Cull RHS of shift operations (#1148)
In SPIR-V, if shifting a value by an amount that is greater than
the value's bitwidth, the result is undefined.

FXC and DXC/DXIL performs a bitwise and over the RHS of the shift
operation to only consider its (n - 1) least significant bits,
where n is the bitwidth of LHS.
2018-03-16 20:19:20 -04:00
Lei Zhang f6f79e744d
[spirv] Emit OpSource debug instruction (#1145) 2018-03-16 13:40:00 -04:00
Lei Zhang e3662ff353
[spirv] Collect global non-resource variables into $Globals (#1138)
This commit changes the behavior of how to handle externally-visiable
non-resource-type stand-alone variables. Previously they are emitted
as stand-alone SPIR-V variables. Now they are grouped into a cbuffer
that named as $Globals. This is more aligned with how DirectX handles
them.
2018-03-14 11:15:14 -04:00
Lei Zhang c133d935eb
[spirv] Support SM6.0 wave ops using Vulkan 1.1 (#1118)
Support promoting to SPIR-V 1.3 when necessary

Support SM6.0 wave query and vote ops

* WaveIsFirstLane
* WaveGetLaneCount
* WaveGetLaneIndex
* WaveActiveAnyTrue
* WaveActiveAllTrue
* WaveActiveBallot

Support SM6.0 wave reduction ops

* WaveActiveAllEqual
* WaveActiveCountBits
* WaveActiveSum
* WaveActiveProduct
* WaveActiveBitAnd
* WaveActiveBitOr
* WaveActiveBitXor
* WaveActiveMin
* WaveActiveMax

Support SM6.0 wave scan/prefix ops

* WavePrefixSum
* WavePrefixProduct
* WavePrefixCountBits

Support SM6.0 wave broadcast ops

* WaveReadLaneAt
* WaveReadLaneFirst

Support SM6.0 quad-wide shuffle ops

*  QuadReadAcrossX
*  QuadReadAcrossY
*  QuadReadAcrossDiagonal
*  QuadReadLaneAt
2018-03-13 15:24:48 -04:00
Lei Zhang c859bb040f
[spirv] Support SPV_KHR_shader_draw_parameters (#1127)
Added support for the following SPIR-V builtins exposed in
SPV_KHR_shader_draw_parameters:
* BaseVertex
* BaseInstance
* DrawIndex
2018-03-13 10:07:54 -04:00