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

4579 Коммитов

Автор SHA1 Сообщение Дата
Antonio Maiorano 773b012727
Fix invalid IR from scalarrepl-param-hlsl in ReplaceConstantWithInst (#6556)
ReplaceConstantWithInst(C, V) replaces uses of C in the current function
with V. If such a use C is an instruction I, the it replaces uses of C
in I with V. However, this function did not make sure to only perform
this replacement if V dominates I. As a result, it may end up replacing
uses of C in instructions before the definition of V.

The fix is to lazily compute the dominator tree in
ReplaceConstantWithInst so that we can guard the replacement with that
dominance check.
2024-05-06 16:55:20 -04:00
Natalie Chouinard 7db2fc129a
[SPIR-V] Implement WaveMatch intrinsic function (#6546)
Adds support for the `WaveMatch()` intrinsic function from Shader Model
6.5 using the `OpGroupNonUniformPartitionNV` instruction from the
`SPV_NV_shader_subgroup_partitioned` extension.

SPIRV-Tools bumped to include:
https://github.com/KhronosGroup/SPIRV-Tools/pull/5648

Fixes #6545
2024-05-06 15:45:12 +00:00
Xiang Li af955d601d
[DOC] Add doc about string function attribute in DXIL. (#6579)
This patch adds documentation about string function attribute in DXIL.
2024-05-03 12:20:14 -07:00
Jeff Noyle 381750e25b
PIX: Cope with arbitrary <32 integer widths in debugger pass (#6551)
Who knew codegen could generate i25 as part of a switch argument? Not
me!
2024-05-02 13:36:48 -07:00
Natalie Chouinard 4f4bb42089
Bump submodules (#6577)
Update SPIRV-Headers and SPIRV-Tools submodules.
2024-05-02 17:03:11 +00:00
Chris B e7b78ff9c9
Backport `-Wdouble-promotion` from Clang 3.8 (#6574)
This adds the Clang 3.8 `-Wdouble-promotion` warning group to DXC. This
is added as part of the mitigations for the HLSL 202x conforming
literals feature which (among other things) changes the conversion rank
of unsuffixed literal values.

Resolves #6571
2024-04-30 20:00:59 -05:00
Chris B 0c4509960b
[202x] Implementaiton of conforming literals (#6572)
This change implements the conforming literals proposal as documented in
proposal 0017:


https://github.com/microsoft/hlsl-specs/blob/main/proposals/0017-conform
ing-literals.md

Fixes #6537

---------

Co-authored-by: Damyan Pepper <damyanp@microsoft.com>
2024-04-30 16:11:05 -05:00
Xiang Li 00cd8233d5
[DxilOp] Allow generation of illegal DXIL operations. (#6543)
This change removes the IsOverloadLegal check in OP::GetOpFunc.

It will permit the generation of illegal DXIL operations. Subsequently,
the validation should catch these illegal DXIL operations if they are
not optimized later in SimplifyDxilCall.


Fixes #6410
2024-04-26 20:52:46 +00:00
dependabot[bot] 643523a5d8
Bump black from 23.9.1 to 24.3.0 in /utils/git (#6438)
Bumps [black](https://github.com/psf/black) from 23.9.1 to 24.3.0.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/psf/black/releases">black's
releases</a>.</em></p>
<blockquote>
<h2>24.3.0</h2>
<h3>Highlights</h3>
<p>This release is a milestone: it fixes Black's first CVE security
vulnerability. If you
run Black on untrusted input, or if you habitually put thousands of
leading tab
characters in your docstrings, you are strongly encouraged to upgrade
immediately to fix
<a
href="https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2024-21503">CVE-2024-21503</a>.</p>
<p>This release also fixes a bug in Black's AST safety check that
allowed Black to make
incorrect changes to certain f-strings that are valid in Python 3.12 and
higher.</p>
<h3>Stable style</h3>
<ul>
<li>Don't move comments along with delimiters, which could cause crashes
(<a
href="https://redirect.github.com/psf/black/issues/4248">#4248</a>)</li>
<li>Strengthen AST safety check to catch more unsafe changes to strings.
Previous versions
of Black would incorrectly format the contents of certain unusual
f-strings containing
nested strings with the same quote type. Now, Black will crash on such
strings until
support for the new f-string syntax is implemented. (<a
href="https://redirect.github.com/psf/black/issues/4270">#4270</a>)</li>
<li>Fix a bug where line-ranges exceeding the last code line would not
work as expected
(<a
href="https://redirect.github.com/psf/black/issues/4273">#4273</a>)</li>
</ul>
<h3>Performance</h3>
<ul>
<li>Fix catastrophic performance on docstrings that contain large
numbers of leading tab
characters. This fixes
<a
href="https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2024-21503">CVE-2024-21503</a>.
(<a
href="https://redirect.github.com/psf/black/issues/4278">#4278</a>)</li>
</ul>
<h3>Documentation</h3>
<ul>
<li>Note what happens when <code>--check</code> is used with
<code>--quiet</code> (<a
href="https://redirect.github.com/psf/black/issues/4236">#4236</a>)</li>
</ul>
<h2>24.2.0</h2>
<h3>Stable style</h3>
<ul>
<li>Fixed a bug where comments where mistakenly removed along with
redundant parentheses
(<a
href="https://redirect.github.com/psf/black/issues/4218">#4218</a>)</li>
</ul>
<h3>Preview style</h3>
<ul>
<li>Move the <code>hug_parens_with_braces_and_square_brackets</code>
feature to the unstable style
due to an outstanding crash and proposed formatting tweaks (<a
href="https://redirect.github.com/psf/black/issues/4198">#4198</a>)</li>
<li>Fixed a bug where base expressions caused inconsistent formatting of
** in tenary
expression (<a
href="https://redirect.github.com/psf/black/issues/4154">#4154</a>)</li>
<li>Checking for newline before adding one on docstring that is almost
at the line limit
(<a
href="https://redirect.github.com/psf/black/issues/4185">#4185</a>)</li>
<li>Remove redundant parentheses in <code>case</code> statement
<code>if</code> guards (<a
href="https://redirect.github.com/psf/black/issues/4214">#4214</a>).</li>
</ul>
<h3>Configuration</h3>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/psf/black/blob/main/CHANGES.md">black's
changelog</a>.</em></p>
<blockquote>
<h2>24.3.0</h2>
<h3>Highlights</h3>
<p>This release is a milestone: it fixes Black's first CVE security
vulnerability. If you
run Black on untrusted input, or if you habitually put thousands of
leading tab
characters in your docstrings, you are strongly encouraged to upgrade
immediately to fix
<a
href="https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2024-21503">CVE-2024-21503</a>.</p>
<p>This release also fixes a bug in Black's AST safety check that
allowed Black to make
incorrect changes to certain f-strings that are valid in Python 3.12 and
higher.</p>
<h3>Stable style</h3>
<ul>
<li>Don't move comments along with delimiters, which could cause crashes
(<a
href="https://redirect.github.com/psf/black/issues/4248">#4248</a>)</li>
<li>Strengthen AST safety check to catch more unsafe changes to strings.
Previous versions
of Black would incorrectly format the contents of certain unusual
f-strings containing
nested strings with the same quote type. Now, Black will crash on such
strings until
support for the new f-string syntax is implemented. (<a
href="https://redirect.github.com/psf/black/issues/4270">#4270</a>)</li>
<li>Fix a bug where line-ranges exceeding the last code line would not
work as expected
(<a
href="https://redirect.github.com/psf/black/issues/4273">#4273</a>)</li>
</ul>
<h3>Performance</h3>
<ul>
<li>Fix catastrophic performance on docstrings that contain large
numbers of leading tab
characters. This fixes
<a
href="https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2024-21503">CVE-2024-21503</a>.
(<a
href="https://redirect.github.com/psf/black/issues/4278">#4278</a>)</li>
</ul>
<h3>Documentation</h3>
<ul>
<li>Note what happens when <code>--check</code> is used with
<code>--quiet</code> (<a
href="https://redirect.github.com/psf/black/issues/4236">#4236</a>)</li>
</ul>
<h2>24.2.0</h2>
<h3>Stable style</h3>
<ul>
<li>Fixed a bug where comments where mistakenly removed along with
redundant parentheses
(<a
href="https://redirect.github.com/psf/black/issues/4218">#4218</a>)</li>
</ul>
<h3>Preview style</h3>
<ul>
<li>Move the <code>hug_parens_with_braces_and_square_brackets</code>
feature to the unstable style
due to an outstanding crash and proposed formatting tweaks (<a
href="https://redirect.github.com/psf/black/issues/4198">#4198</a>)</li>
<li>Fixed a bug where base expressions caused inconsistent formatting of
** in tenary
expression (<a
href="https://redirect.github.com/psf/black/issues/4154">#4154</a>)</li>
<li>Checking for newline before adding one on docstring that is almost
at the line limit
(<a
href="https://redirect.github.com/psf/black/issues/4185">#4185</a>)</li>
<li>Remove redundant parentheses in <code>case</code> statement
<code>if</code> guards (<a
href="https://redirect.github.com/psf/black/issues/4214">#4214</a>).</li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="552baf8229"><code>552baf8</code></a>
Prepare release 24.3.0 (<a
href="https://redirect.github.com/psf/black/issues/4279">#4279</a>)</li>
<li><a
href="f000936726"><code>f000936</code></a>
Fix catastrophic performance in lines_with_leading_tabs_expanded() (<a
href="https://redirect.github.com/psf/black/issues/4278">#4278</a>)</li>
<li><a
href="7b5a657285"><code>7b5a657</code></a>
Fix --line-ranges behavior when ranges are at EOF (<a
href="https://redirect.github.com/psf/black/issues/4273">#4273</a>)</li>
<li><a
href="1abcffc818"><code>1abcffc</code></a>
Use regex where we ignore case on windows (<a
href="https://redirect.github.com/psf/black/issues/4252">#4252</a>)</li>
<li><a
href="719e67462c"><code>719e674</code></a>
Fix 4227: Improve documentation for --quiet --check (<a
href="https://redirect.github.com/psf/black/issues/4236">#4236</a>)</li>
<li><a
href="e5510afc06"><code>e5510af</code></a>
update plugin url for Thonny (<a
href="https://redirect.github.com/psf/black/issues/4259">#4259</a>)</li>
<li><a
href="6af7d11096"><code>6af7d11</code></a>
Fix AST safety check false negative (<a
href="https://redirect.github.com/psf/black/issues/4270">#4270</a>)</li>
<li><a
href="f03ee113c9"><code>f03ee11</code></a>
Ensure <code>blib2to3.pygram</code> is initialized before use (<a
href="https://redirect.github.com/psf/black/issues/4224">#4224</a>)</li>
<li><a
href="e4bfedbec2"><code>e4bfedb</code></a>
fix: Don't move comments while splitting delimiters (<a
href="https://redirect.github.com/psf/black/issues/4248">#4248</a>)</li>
<li><a
href="d0287e1f75"><code>d0287e1</code></a>
Make trailing comma logic more concise (<a
href="https://redirect.github.com/psf/black/issues/4202">#4202</a>)</li>
<li>Additional commits viewable in <a
href="https://github.com/psf/black/compare/23.9.1...24.3.0">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=black&package-manager=pip&previous-version=23.9.1&new-version=24.3.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)
You can disable automated security fix PRs for this repo from the
[Security Alerts
page](https://github.com/microsoft/DirectXShaderCompiler/network/alerts).

</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-04-26 17:39:21 +00:00
Tex Riddell dbb9c9757a
Fix auto-dxilver logic in FileCheckerTest (#6368)
In FileCheckerTest.cpp, the -T target of a %dxc part is checked for
compatibility. However, if you use -Vd, it skips the version check for
the validator. This isn't quite right since the validator version will
be set from the attached validator, unless you explicitly set
-validator-version or use -select-validator internal. Also, if
-validator-version is explicitly set, we should check the validator
against that version, not just the one based on shader model.

This change fixes the initial check logic to only skip validator check
when using -select-validator internal or -validator-version. It also
checks against an explicitly requested -validator-version when an
external validator will be used.

Fixes #6367
2024-04-25 09:51:51 -07:00
Tex Riddell a932cf4b35
Add diag for new Barrier intrinsic on SM < 6.8 (#6558)
Tests are split between one containing cases that could potentially be
translated to legacy barrier op in the future, and a test without
translatable barrier ops.

Part of #6538.
2024-04-25 09:44:07 -07:00
Greg Roth 1c66c4d798
Disable non-legacy cbuffer flags (#6559)
These flags had some effect on load code generation, but never worked
right and were not tested in the DXC compiler let alone with drivers.
This removes any notion of the flags beyond option processing and
produces a warning message that the flag is not supported and will be
ignored. The flags are both not listed in help anymore either. A simple
OptionsTest and lit test verify that the warning message is produced for either
flag and existing tests that used the flag are updated or removed.

Incidentally fixed the capitalization of an existing options warning message.

Fixes #6306
2024-04-23 11:59:49 -07:00
Xiang Li aa6db9b4f0
[Sema] Report warning when mix packoffset with nonpackoffset (#6553)
Check mix packoffset elements with nonpackoffset elements in a cbuffer
at Sema::ActOnFinishHLSLBuffer. Also check packoffset for aggregate
type.

Fixes #3724
2024-04-23 10:31:06 -07:00
Adam Yang 4242b576ed
Fixed crash in loop unroll caused by bug in structurize loop exits (#6548)
Fixed a bug in `hlsl::RemoveUnstructuredLoopExits` where when a new
exiting block is created from splitting, it was added to the current
loop being processed, when it could also part of an inner loop. Not
adding the new block to inner loops that it's part of makes the inner
loops malformed, and causes crash.

This fix adds the new block to the inner most loop that it should be
part of. Also adds the `StructurizeLoopExits` option to `loop-unroll`
pass, which was missing before.
2024-04-23 00:17:48 +00:00
dependabot[bot] 7cf175f89b
Bump idna from 3.4 to 3.7 in /utils/git (#6525)
Bumps [idna](https://github.com/kjd/idna) from 3.4 to 3.7.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/kjd/idna/releases">idna's
releases</a>.</em></p>
<blockquote>
<h2>v3.7</h2>
<h2>What's Changed</h2>
<ul>
<li>Fix issue where specially crafted inputs to encode() could take
exceptionally long amount of time to process. [CVE-2024-3651]</li>
</ul>
<p>Thanks to Guido Vranken for reporting the issue.</p>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/kjd/idna/compare/v3.6...v3.7">https://github.com/kjd/idna/compare/v3.6...v3.7</a></p>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/kjd/idna/blob/master/HISTORY.rst">idna's
changelog</a>.</em></p>
<blockquote>
<p>3.7 (2024-04-11)
++++++++++++++++</p>
<ul>
<li>Fix issue where specially crafted inputs to encode() could
take exceptionally long amount of time to process. [CVE-2024-3651]</li>
</ul>
<p>Thanks to Guido Vranken for reporting the issue.</p>
<p>3.6 (2023-11-25)
++++++++++++++++</p>
<ul>
<li>Fix regression to include tests in source distribution.</li>
</ul>
<p>3.5 (2023-11-24)
++++++++++++++++</p>
<ul>
<li>Update to Unicode 15.1.0</li>
<li>String codec name is now &quot;idna2008&quot; as overriding the
system codec
&quot;idna&quot; was not working.</li>
<li>Fix typing error for codec encoding</li>
<li>&quot;setup.cfg&quot; has been added for this release due to some
downstream
lack of adherence to PEP 517. Should be removed in a future release
so please prepare accordingly.</li>
<li>Removed reliance on a symlink for the &quot;idna-data&quot; tool to
comport
with PEP 517 and the Python Packaging User Guide for sdist
archives.</li>
<li>Added security reporting protocol for project</li>
</ul>
<p>Thanks Jon Ribbens, Diogo Teles Sant'Anna, Wu Tingfeng for
contributions
to this release.</p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="1d365e17e1"><code>1d365e1</code></a>
Release v3.7</li>
<li><a
href="c1b3154939"><code>c1b3154</code></a>
Merge pull request <a
href="https://redirect.github.com/kjd/idna/issues/172">#172</a> from
kjd/optimize-contextj</li>
<li><a
href="0394ec76ff"><code>0394ec7</code></a>
Merge branch 'master' into optimize-contextj</li>
<li><a
href="cd58a23173"><code>cd58a23</code></a>
Merge pull request <a
href="https://redirect.github.com/kjd/idna/issues/152">#152</a> from
elliotwutingfeng/dev</li>
<li><a
href="5beb28b9dd"><code>5beb28b</code></a>
More efficient resolution of joiner contexts</li>
<li><a
href="1b121483ed"><code>1b12148</code></a>
Update ossf/scorecard-action to v2.3.1</li>
<li><a
href="d516b874c3"><code>d516b87</code></a>
Update Github actions/checkout to v4</li>
<li><a
href="c095c75943"><code>c095c75</code></a>
Merge branch 'master' into dev</li>
<li><a
href="60a0a4cb61"><code>60a0a4c</code></a>
Fix typo in GitHub Actions workflow key</li>
<li><a
href="5918a0ef80"><code>5918a0e</code></a>
Merge branch 'master' into dev</li>
<li>Additional commits viewable in <a
href="https://github.com/kjd/idna/compare/v3.4...v3.7">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=idna&package-manager=pip&previous-version=3.4&new-version=3.7)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)
You can disable automated security fix PRs for this repo from the
[Security Alerts
page](https://github.com/microsoft/DirectXShaderCompiler/network/alerts).

</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-04-22 10:50:03 -07:00
Jannik Silvanus e2f0b98440
Don't reuse WaveGetLaneIndex result across thread repacking points (#5607)
Wave intrinsics such as `WaveGetLaneIndex()` are invalidated at DXR
thread repacking
points such as `CallShader()`. We were however reusing the result of
`WaveGetLaneIndex()`.

Fix this by marking it as `Readonly` instead of `Readnone`.

Add a test case that also covers other wave intrisics, which are handled
correctly.

Fixes #5034.

---------

Co-authored-by: Jannik Silvanus <jasilvanus@users.noreply.github.com>
2024-04-18 13:02:34 -07:00
dependabot[bot] 07ce880349
Bump urllib3 from 2.0.6 to 2.0.7 in /utils/git (#5886)
Bumps urllib3 from 2.0.6 to 2.0.7.

Sourced from urllib3's releases
2024-04-18 09:36:50 -07:00
Natalie Chouinard 02beb55550
[SPIR-V] Warn when wave size is used (#6542)
Specifying a wave size is not supported in Vulkan SPIR-V, so warn when
it is used in a shader.
2024-04-18 16:04:01 +00:00
Natalie Chouinard c3115dd943
[SPIR-V] Scope Atomic ops on Workgroup memory (#6527)
Set the scope of atomic operation on Workgroup-shared variables to the
Workgroup rather than the Device.

Fixes #6508
2024-04-18 09:33:36 -04:00
Natalie Chouinard 9ee056e597
[SPIR-V] Remove bitcast from float->int conversion (#6533)
OpConvertFToU and FToS convert numerically from floating point to
integer, with rounding toward 0.0, matching the defined behavior of HLSL
without any need for an initial bitwidth conversion from floating point
to floating point, which can result in incorrect rounding behavior (see
#6501).

Note that behavior is undefined if the target type is not wide enough to
hold the converted value, however this was also true with an initial
bitcast (because an N-bit FP can hold values outside the range of an
N-bit int), and I can't come up with any case where an intial truncation
would result in correct defined behavior where this straight conversion
would be undefined since the precision will inevitably be lost anyways.

Fixes #6501
2024-04-18 09:31:45 -04:00
Nathan Gauër dda80a98c4
[SPIR-V] Emulate OpBitFieldExtract for type != i32 (#6500)
This is a follow up to #6491 which adds emulation for OpBitField*Extract
This is required because Vulkan requires OpBitField*Extract operands to
be 32-bit integers.

Fixes #6327

---------

Signed-off-by: Nathan Gauër <brioche@google.com>
2024-04-18 13:36:44 +02:00
Nathan Gauër 1e59ce9185
[SPIR-V] Fix debug instruction with cbuffer + FXC (#6531)
When the requested constant buffer layout is DX, some type lowering can
become complex (Nx1 matrices for ex). To simplify the lowering, the
backend "clones" those variables:
 - on one end, we expose the correct layout
- but then, we copy this to a local variable to have a different layout
compatible with the operations we usually do on such types.

This means the type can sometimes be an HybridStructType, which is not
completely lowered, or a normal lowerer SPIR-V type. Both should be
allowed, but some codepaths had to be updated to reflect this.

---------

Signed-off-by: Nathan Gauër <brioche@google.com>
2024-04-18 13:36:37 +02:00
Natalie Chouinard 690ec7cd7d
[SPIR-V] Fix mesh payload global variable for VK_EXT_mesh_shaders (#6526)
The existing logic from `VK_NV_mesh_shader` was incorrectly adapted for
the `VK_EXT_mesh_shader` implementation when it comes to the handling of
payloads as in/out variables. Because `TaskPayloadWorkgroupEXT` must be
applied to a single global `OpVariable` for each task/mesh shader, the
struct should not be flattened. Further, Location assignment is not
necessary for these input and output variables, so the usual reason for
flattening structs does not apply.

This change now removes the inner struct member global variables and
ensures the parent payload is decorated with `TaskPayloadWorkgroupEXT`.
Note that for amplification/task shaders, the payload variable is
created with the `groupshared` decl, and then its storage class needs to
be updated when that variable is used as a parameter to the
`DispatchMesh` call, as described in:
https://docs.vulkan.org/spec/latest/proposals/proposals/VK_EXT_mesh_shader.html#_hlsl_changes

Tested with new validation checks from:
https://github.com/KhronosGroup/SPIRV-Tools/pull/5640

Fixes #5981
2024-04-17 13:00:41 -04:00
Cooper Partin 3546bde202
Increase filter time value for failing ftime-trace-granularity test (#6532)
ftime-trace-granularity test was failing in test runs due to the
configured time filter value being too small. The latest test run was
recording duration times of 322308 which is larger than the test's
specified filter value of 99999 causing timings to not be filtered out.

The test is now updated to have a filter value of 999999, which should
properly filter out timings.

Fixes #6528

---------

Co-authored-by: Cooper Partin <coopp@ntdev.microsoft.com>
2024-04-15 16:04:33 -07:00
Cassandra Beckley d60dffef1a
[SPIR-V] Implement SpirvType and SpirvOpaqueType (#6156)
Implements hlsl-specs proposal 0011, adding `vk::SpirvType` and
`vk::SpirvOpaqueType` templates which allow users to define and use
SPIR-V level types.
2024-04-15 20:58:49 +00:00
David Neto dc84d72d18
Fix recursive zero replacement bottoming out in scalars. (#6516)
During memcpy replacement, the scalarrepl-param-hlsl pass will replace
certain uses of a zero-initialized global variable. The pass uses a
recursive algorithm to replace uses of that global by a zero value. The
current code expects the recursion to bottom out in an aggregate type.
But it can bottom out in a scalar integer or scalar float.

This patch fixes the scalar cases.

Lit-based pass tests are included.
2024-04-12 11:02:20 -04:00
Chris B b065a0d9c5
Add CODEOWNERS to main (#6520)
In release branches we've added enforcement of AskMode where approval is
required before merging. This just adds the requisite file to the `main`
branch so that it will appear in future release branches. It DOES NOT
apply the branch protection policy, which is a setting controlled in
GitHub.

There is no policy change to contributions to main with this change.
2024-04-10 18:29:05 -05:00
Tex Riddell fe393e09d7
Add barrier MemoryTypeFlags and SemanticFlags diagnostics (#6513)
Context-specific diagnostics are warnings with DefaultError, since in
theory they could be dead code at this stage.

There were some changes to existing Sema diagnostic hooks along the way.

SemaHLSLDiagnoseTU.cpp - HLSLMethodCallDiagnoseVisitor
- extend to non-method calls and pass CallExpr
- instead of skipping when call reached from multiple entry/export
functions, pass locallyVisited flag for skipping of redundant diags not
dependent on entry properties.
- use llvm::SmallPtrSet for DiagnosticCalls
- capture launch type for entry and pass it down

Replace DiagnoseHLSLMethodCall hook with CheckHLSLFunctionCall:

Move hook into Sema::CheckFunctionCall in SemaChecking.cpp to be general
to either a function call or a method call.
Refactor existing code in DiagnoseHLSLMethodCall into
CheckFinishedCrossGroupSharingCall called in the hook for this method.
Add CheckBarrierCall for context-free flag validity check, called by
CheckHLSLFunctionCall.

Refactor CalculateLOD checking into more generic parts, dispatched based
on IntrinsicOp from top-level DiagnoseReachableHLSLCall function.

Switch to using new note: "entry function defined here", instead of
"declared here".

Fix intrinsic checking to use IsBuiltinTable on the intrinsic
attribute's group.

**Preparation Changes**
While these could be broken out, the barrier diagnostic changes are
dependent on them, and testing for some of these is dependent on the
other parts of the barrier diagnostic changes.

Correct errors in tests, check MaxRecords for EmptyNodeOutput in AST
Note that Barrier(..., 3) means SemanticFlags: GroupSync | GroupScope.
These are only valid in a shader with a visible group, and GroupSync on
memory with at least group scope, so they have been changed to 0 in
specific cases in these tests.

Make DiagnoseSVForLaunchType a static function, add FIXME notes.

Use StringRef for IsBuiltinTable, compare strings instead of pointers.

Fix FileCheckerTest for -verify output.

New ShaderModel::HasVisibleGroup uses ShaderKind and NodeLaunchType to
determine whether shader type has a visible group.
2024-04-10 14:44:37 -07:00
Antonio Maiorano fa39b3984f
Replace dynamic_cast with virtual call (#6515)
Make TextDiagnosticPrinter::setPrefix a virtual function in base class
DiagnosticConsumer. This allows us to avoid using dynamic_cast in
BackendConsumer::DxilDiagHandler, required for codebases that do not
enable RTTI. This is also the only place in the codebase that uses RTTI
(AFAICT).
2024-04-10 20:10:49 +00:00
Cooper Partin 422a60e6d0
Update locale setting logic to support UTF-8 only for Apple and Linux distros (#6488)
This commit fixes the setlocale( ) logic to include the UTF-8 supported
string value for Mariner distros.

It also introduces a new RAII class `ScopedLocale' which ensure that the
locale setting is set/reset during string conversion operations.

Fixes: #6201

---------

Co-authored-by: Cooper Partin <coopp@ntdev.microsoft.com>
Co-authored-by: cooppunix <cooppunix&mariner.com>
2024-04-10 10:04:32 -07:00
Nathan Gauër 0781ded87b
[SPIR-V] Emulate OpBitFieldInsert for type != i32 (#6491)
SPIR-V supported OpBitFieldInsert on all integer types. But Vulkan
requires the operands to be 32bit integers.
This means we need to emulate this instruction for types other then i32.

This PR only adds emulation for OpBitFieldInsert. The next PR will add
support for emulating OpBitFieldExtract,

Related to #6327

---------

Signed-off-by: Nathan Gauër <brioche@google.com>
2024-04-09 14:06:37 +02:00
Xiang Li 8b5b6c6add
[ClangCL] fix x86 only warning (#6504)
SIZE_T is unsigned long for x86 while size_t is unsigned int for x86.
Cast SIZE_T to size_t to avoid integer mismatch warning.
2024-04-08 12:26:38 -07:00
Helena Kotas 14ec4b49d4
DerivativesTest: Remove invalid thread group size test cases (#6496)
Invalid thread group size testing is included in the compiler/validator
tests (PR #6332, commit 696a13a). It does not belong in the execution
tests because is it not verifying the driver execution results. The
shaders with invalid thread group sizes fail validation and cannot be
executed.

Also fixing compile warning and override defines in the derivatives test
HLSL code.

Note that the test is incorrectly using the term `dispatch size` instead
of `thread group size`.

Fixes internal bug #49806539. Reported from RITP pass.

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-04-04 17:37:39 -07:00
Nathan Gauër aa4d3746e0
[SPIR-V] fix silent failure if disassembly fails (#6490)
When codegen is broken, and spirv-dis fails, DXC doesn't return any
error, and simply displays nothing, and returns 0.

Signed-off-by: Nathan Gauër <brioche@google.com>
2024-04-04 10:42:56 +02:00
Helena Kotas 5e0bb1452b
Set supported validator version on DXC/disable_paq.hlsl (#6493)
This test is failing in the internal validator back-compat suite because
the feature is not supported on older validators.
2024-04-03 18:03:41 -07:00
Xiang Li 8322cabfc0
[ClangCL] fix clang-cl build warning. (#6492)
Fix sign-compare warnings.
2024-04-03 12:20:49 -07:00
Nathan Gauër 27b87b7593
[SPIR-V][Sema] Requires nointerpolation on GetAttributeAtVertex param #0 (#6453)
This commit adds new sema checks for SPIR-V to restrict the scope of the
feature: the `nointerpolation` attribute is now required on all
parameters used in GetAttributeAtVertex, and doesn't propagage magically
to parent/child functions.

The current accepted cases this now blocks were mostly broken later in
the codegen, so this should be an acceptable 'regression'.

Related to #6220
Fixes #6384, #6383, #6382

---------

Signed-off-by: Nathan Gauër <brioche@google.com>
2024-04-03 16:17:33 +00:00
Xiang Li 06e706cf6e
[Test] skip test for older validator which check different value. (#6477)
Error message was updated in #6196 which cause test fail on older
validator.

Since this issue is only caused by error message update, the validation
itself is still the same.
The compiler didn't generate anything that behaves badly with older
validators.

So just limit these tests to sm6.8+ to make it work on older validator.
2024-03-29 21:13:51 +00:00
Helena Kotas dd981450f3
dxexp: add support for mesh shaders, derivatives in mesh/amp shaders and wave matrix (#6355)
These features were not included in the dxexp output and they are
important to query for HLK test reports.

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-03-29 12:15:56 -07:00
Nathan Gauër a9b5e725aa
[SPIR-V] Fix crash in GetAttributeAtVertex impl. (#6459)
Some SPIR-V types are not direct translations of an AST type, hence they
don't have an AST type attached to it.
The code didn't checked for this possibility when visiting all
variables.

Fixes #2955

Signed-off-by: Nathan Gauër <brioche@google.com>
2024-03-29 11:25:00 +01:00
Nathan Gauër bb9ec0fb56
[SPIR-V] Fix struct size computation with bitfields (#6471)
The struct size & alignment computations were wrong when
bitfields were in use. This was due to a mismatch between size
computations at the AST level, and at the SPIR-V level.

This commit adds logic to correctly compute bitfields offsets on
an AST struct.

**note: there are 2 commits in this PR, one that moves code around with
no change, and one that adds the logic. To help you review.**

Fixes #5648

---------

Signed-off-by: Nathan Gauër <brioche@google.com>
2024-03-29 11:21:37 +01:00
Cassandra Beckley 7e40ead3c7
[SPIR-V] Fix test runline (#6474)
Our internal tests were failing due to this.
2024-03-29 11:13:46 +01:00
Nathan Gauër 3aabc019ec
[Sema] Move outputcontrolpoints check to Sema (#6460)
DXIL had a check in the backend for those values.
Moving it to Sema to share it between DXIL and SPIR-V.

Fixes #6387

Signed-off-by: Nathan Gauër <brioche@google.com>
2024-03-29 11:13:31 +01:00
Fumitoshi Ukai 773246eddc
fix #include path separator from backslash to slash (#6379)
backslash is not portable, so use slash instead.
2024-03-28 09:34:03 -07:00
Greg Roth dd14fe5a53
Allow disabling payload access qualifiers in 6.8+ (#6468)
The original payload access qualifiers change disallowed disabling them
on 6.8+ versions. This wasn't an intended feature of 6.8. We'd prefer to
maintain the ability to disable these when needed to avoid issues that
might crop up.

This change extends respect of the disable-payload-qualifiers flag for
all versions. It rewords the warning that is produced when they are
encountered when disabled to be more applicable. Tests are also added to
verify that the implicit enabling in 6.7+ works in the basic cases and
also that disabling in the 6.7+ cases works as well.

Fixes #6462

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-03-28 01:38:05 -07:00
Nathan Gauër 4386e4b851
[SPIR-V] Fix bitfields with RWStructured & Push-constants (#6463)
When implementing bitfields, we miss a code path which lowered the AST
type to the SPIR-V type, and thus failed to propagate the bitfield
information.
This commit addresses that.

Fixes #6409

Signed-off-by: Nathan Gauër <brioche@google.com>
2024-03-27 11:44:21 +01:00
Helena Kotas e2fb8b33b2
Remove -spirv from new HLSL Sema tests (#6467)
These are semantic verification tests, the `-spir-v` option is not
necessary.
It also breaks our internal test passes for builds that do include
SPIR-V backend.
2024-03-26 22:35:14 +00:00
Antonio Maiorano 63ebbb1430
Fix ASAN use-after-free on unreferenced self-assignment of struct instance (#6466)
When deleting an unused memcpy, ScalarReplAggregatesHLSL was attempting
to delete both the target and the source of the memcpy without first
checking if they were both same, resulting in a double-delete.
2024-03-26 21:48:40 +00:00
Fumitoshi Ukai e4fa1c5184
fix non-portable include path (#6380)
d3dcommon.h seems to be canonical path name in Win SDK

Windows Kits/10/Include/10.0.22621.0/um/d3dcommon.h

so use d3dcommon.h rather than D3Dcommon.h
2024-03-26 09:44:44 -07:00
Natalie Chouinard b451a409e1
[SPIR-V] Implement dot2add intrinsic function (#6445)
Add support for the Shader Model 6.4 intrinsic dot2add which was missing
from the SPIR-V backend.

Fixes #6442
2024-03-26 15:43:46 +00:00