<feed xmlns='http://www.w3.org/2005/Atom'>
<title>llvm-project.git/clang/lib/Sema/SemaHLSL.cpp, branch main</title>
<subtitle>Unnamed repository; edit this file 'description' to name the repository.
</subtitle>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/'/>
<entry>
<title>[HLSL] Add Load overload with status (#166449)</title>
<updated>2025-11-21T18:11:38+00:00</updated>
<author>
<name>Joshua Batista</name>
<email>jbatista@microsoft.com</email>
</author>
<published>2025-11-21T18:11:38+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=fea070b610e0dc08447be60db7f13c150b2892d5'/>
<id>fea070b610e0dc08447be60db7f13c150b2892d5</id>
<content type='text'>
This PR adds a Load method for resources, which takes an additional
parameter by reference, status. It fills the status parameter with a 1
or 0, depending on whether or not the resource access was mapped.
CheckAccessFullyMapped is also added as an intrinsic, and called in the
production of this status bit.
Only addresses DXIL for the below issue:
https://github.com/llvm/llvm-project/issues/138910
Also only addresses the DXIL variant for the below issue:
https://github.com/llvm/llvm-project/issues/99204</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This PR adds a Load method for resources, which takes an additional
parameter by reference, status. It fills the status parameter with a 1
or 0, depending on whether or not the resource access was mapped.
CheckAccessFullyMapped is also added as an intrinsic, and called in the
production of this status bit.
Only addresses DXIL for the below issue:
https://github.com/llvm/llvm-project/issues/138910
Also only addresses the DXIL variant for the below issue:
https://github.com/llvm/llvm-project/issues/99204</pre>
</div>
</content>
</entry>
<entry>
<title>[HLSL][TableGen] Add `__hlsl_resource_t` to known built-in function types (#163465)</title>
<updated>2025-11-19T22:56:49+00:00</updated>
<author>
<name>Helena Kotas</name>
<email>hekotas@microsoft.com</email>
</author>
<published>2025-11-19T22:56:49+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=19fe9b477b570fd395a161638c59e66b35d1a9ac'/>
<id>19fe9b477b570fd395a161638c59e66b35d1a9ac</id>
<content type='text'>
This change adds resource handle type `__hlsl_resource_t` to the list of types recognized in the Clang's built-in functions prototype string.

HLSL has built-in resource classes and some of them have many methods, such as
[Texture2D](https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/sm5-object-texture2d).
Most of these methods will be implemented by built-in functions that will take resource handle as an argument. This change enables us to move from generic `void(...)` prototype string for these methods and explicit argument checking in `SemaHLSL.cpp` to a prototype string with explicit argument types. Argument checking in `SemaHLSL.cpp` can be reduced to handle just the rules that cannot be expressed in the prototype string (for example verifying that the offset value in `__builtin_hlsl_buffer_update_counter` is `1` or `-1`).

In order to make this work, we now allow conversions from attributed resource handle type such as `__hlsl_resource_t [[hlsl::resource_class(UAV)]] [[hlsl::contained_type(float)]]` to a plain non-attributed `__hlsl_resource_t` type.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This change adds resource handle type `__hlsl_resource_t` to the list of types recognized in the Clang's built-in functions prototype string.

HLSL has built-in resource classes and some of them have many methods, such as
[Texture2D](https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/sm5-object-texture2d).
Most of these methods will be implemented by built-in functions that will take resource handle as an argument. This change enables us to move from generic `void(...)` prototype string for these methods and explicit argument checking in `SemaHLSL.cpp` to a prototype string with explicit argument types. Argument checking in `SemaHLSL.cpp` can be reduced to handle just the rules that cannot be expressed in the prototype string (for example verifying that the offset value in `__builtin_hlsl_buffer_update_counter` is `1` or `-1`).

In order to make this work, we now allow conversions from attributed resource handle type such as `__hlsl_resource_t [[hlsl::resource_class(UAV)]] [[hlsl::contained_type(float)]]` to a plain non-attributed `__hlsl_resource_t` type.</pre>
</div>
</content>
</entry>
<entry>
<title>[HLSL] Add initial support for output semantics (#168095)</title>
<updated>2025-11-19T13:51:46+00:00</updated>
<author>
<name>Nathan Gauër</name>
<email>brioche@google.com</email>
</author>
<published>2025-11-19T13:51:46+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=2fc42c7163142d74e2e8ce5549f5d0142fccd89f'/>
<id>2fc42c7163142d74e2e8ce5549f5d0142fccd89f</id>
<content type='text'>
This commits adds the first part of the output semantics. It only
considers return values (and sret), but does not handle `inout` or `out`
parameters yet.
Those missing bits will reuse the same code, but will require additional
testing &amp; some fixups, so planning on adding them separately.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This commits adds the first part of the output semantics. It only
considers return values (and sret), but does not handle `inout` or `out`
parameters yet.
Those missing bits will reuse the same code, but will require additional
testing &amp; some fixups, so planning on adding them separately.</pre>
</div>
</content>
</entry>
<entry>
<title>[HLSL] Implement ddx/ddy_coarse intrinsics (#164831)</title>
<updated>2025-11-18T15:41:07+00:00</updated>
<author>
<name>Alexander Johnston</name>
<email>alexander.javen.johnston@gmail.com</email>
</author>
<published>2025-11-18T15:41:07+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=ed60cd2563ca6ee474f76487857dd5fd56b83925'/>
<id>ed60cd2563ca6ee474f76487857dd5fd56b83925</id>
<content type='text'>
Closes https://github.com/llvm/llvm-project/issues/99097
Closes https://github.com/llvm/llvm-project/issues/99100

As ddx and ddy are near identical implementations I've combined them in
this PR. This aims to unblock
https://github.com/llvm/llvm-project/pull/161378

---------

Co-authored-by: Alexander Johnston &lt;alexander.johnston@amd.com&gt;</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Closes https://github.com/llvm/llvm-project/issues/99097
Closes https://github.com/llvm/llvm-project/issues/99100

As ddx and ddy are near identical implementations I've combined them in
this PR. This aims to unblock
https://github.com/llvm/llvm-project/pull/161378

---------

Co-authored-by: Alexander Johnston &lt;alexander.johnston@amd.com&gt;</pre>
</div>
</content>
</entry>
<entry>
<title>Reapply "[HLSL] Rework semantic handling as attributes"  (#167862)</title>
<updated>2025-11-13T13:09:15+00:00</updated>
<author>
<name>Nathan Gauër</name>
<email>brioche@google.com</email>
</author>
<published>2025-11-13T13:09:15+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=78554d9e8437c88058e6ab8b95d10eaebb8c3ca9'/>
<id>78554d9e8437c88058e6ab8b95d10eaebb8c3ca9</id>
<content type='text'>
Last PR had asan failures due to bad use of a Twine instead of an
std::string.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Last PR had asan failures due to bad use of a Twine instead of an
std::string.</pre>
</div>
</content>
</entry>
<entry>
<title>Revert "[HLSL] Rework semantic handling as attributes #166796" (#167759)</title>
<updated>2025-11-12T21:19:34+00:00</updated>
<author>
<name>Nathan Gauër</name>
<email>brioche@google.com</email>
</author>
<published>2025-11-12T21:19:34+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=1d2429b5acad7c3e562e85a6b90fa962f868162d'/>
<id>1d2429b5acad7c3e562e85a6b90fa962f868162d</id>
<content type='text'>
Reverting 2 commits from the mainline. The origin of the issue, and the
tentative fix-forward.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Reverting 2 commits from the mainline. The origin of the issue, and the
tentative fix-forward.</pre>
</div>
</content>
</entry>
<entry>
<title>[clang][HLSL] Fix crash issue due to Twine usage</title>
<updated>2025-11-12T19:55:15+00:00</updated>
<author>
<name>Michael Liao</name>
<email>michael.hliao@gmail.com</email>
</author>
<published>2025-11-12T19:43:42+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=cc54ee854f8a081861eb75ad788934705fc54878'/>
<id>cc54ee854f8a081861eb75ad788934705fc54878</id>
<content type='text'>
- Dangling pointer (from std::string) is created and trigger crash on
  some Linux distributions under different build types.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
- Dangling pointer (from std::string) is created and trigger crash on
  some Linux distributions under different build types.
</pre>
</div>
</content>
</entry>
<entry>
<title>[HLSL] Rework semantic handling as attributes (#166796)</title>
<updated>2025-11-12T17:54:38+00:00</updated>
<author>
<name>Nathan Gauër</name>
<email>brioche@google.com</email>
</author>
<published>2025-11-12T17:54:38+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=dba85079c73c67f0235b4c7b9d23c045cd56d476'/>
<id>dba85079c73c67f0235b4c7b9d23c045cd56d476</id>
<content type='text'>
Previously, we had 2 level of attributes:
 - HLSLUnparsedSemantic
 - N attributes, one for each known system semantic.

The first was assigned during parsing, and carried no other meaning than
"there is a semantic token". It was then converted to one of the N
attributes later during Sema.
Those attributes also carried informations like "is indexable" or "is
index explicit".

This had a few issues:
- there was no difference between a semantic attribute applied to a
decl, and the effective semantic in the entrypoint use context.
 - having the indexable bit was not useful.
 - semantic constraints checks were split between .td files and sema.

Also, existing implementation had effective attributes attached to the
type decl or parameters, meaning struct decl reuse across entrypoints of
in a nested type was not supported, even if legal in HLSL.

This PR tried to simplifies semantic attribute by having 3 attributes:

 - HLSLUnpasedSemantic
 - HLSLParsedSemantic
 - HLSLAppliedSemantic

Initial parsing emits an `HLSLUnparsedSemantic`. We simply say "here is
an HLSL semantic token", but we don't do any semantic check.

Then, Sema does initial validation and transforms an UnparseSemantic
into a ParsedSemantic. This validates a system semantic is known, or
that the associated type is valid (like uint3 for a ThreadIndex).

Then, once we parse an actual shader entrypoint, we can know how
semantics are used in a real context. This step emits a list of
AppliedSemantic. Those are the actual semantic in use for this specific
entrypoint.
Those attributes are attached to each entrypoint parameter, as a flat
list matching the semantic structure flattening HLSL defines. At this
stage of sema, index collision or other stage compabitility checkes are
carried.

This allows codegen to simply iterate over this list and emit the proper
DXIL or SPIR-V codegen.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Previously, we had 2 level of attributes:
 - HLSLUnparsedSemantic
 - N attributes, one for each known system semantic.

The first was assigned during parsing, and carried no other meaning than
"there is a semantic token". It was then converted to one of the N
attributes later during Sema.
Those attributes also carried informations like "is indexable" or "is
index explicit".

This had a few issues:
- there was no difference between a semantic attribute applied to a
decl, and the effective semantic in the entrypoint use context.
 - having the indexable bit was not useful.
 - semantic constraints checks were split between .td files and sema.

Also, existing implementation had effective attributes attached to the
type decl or parameters, meaning struct decl reuse across entrypoints of
in a nested type was not supported, even if legal in HLSL.

This PR tried to simplifies semantic attribute by having 3 attributes:

 - HLSLUnpasedSemantic
 - HLSLParsedSemantic
 - HLSLAppliedSemantic

Initial parsing emits an `HLSLUnparsedSemantic`. We simply say "here is
an HLSL semantic token", but we don't do any semantic check.

Then, Sema does initial validation and transforms an UnparseSemantic
into a ParsedSemantic. This validates a system semantic is known, or
that the associated type is valid (like uint3 for a ThreadIndex).

Then, once we parse an actual shader entrypoint, we can know how
semantics are used in a real context. This step emits a list of
AppliedSemantic. Those are the actual semantic in use for this specific
entrypoint.
Those attributes are attached to each entrypoint parameter, as a flat
list matching the semantic structure flattening HLSL defines. At this
stage of sema, index collision or other stage compabitility checkes are
carried.

This allows codegen to simply iterate over this list and emit the proper
DXIL or SPIR-V codegen.</pre>
</div>
</content>
</entry>
<entry>
<title>[HLSL] Add internal linkage attribute to resources (#166844)</title>
<updated>2025-11-10T18:25:59+00:00</updated>
<author>
<name>Helena Kotas</name>
<email>hekotas@microsoft.com</email>
</author>
<published>2025-11-10T18:25:59+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=6d1831361fad0df0b1a36e4ff028de54cb05a6bb'/>
<id>6d1831361fad0df0b1a36e4ff028de54cb05a6bb</id>
<content type='text'>
HLSL resources should not be externally visible from the module. We made sure of this by marking them `static` as soon as they were declared. However, this prevents us fixing issue #166458 because there is no way to know if a resource has been explicitly marked `static` by the user, and can therefore be assigned to.

This change moves from making all resources `static` to adding Clang internal linkage attribute to all non-static resource declarations as a global scope.

No explicit test added this change. There is a number of existing HLSL codegen tests that already verify that the resource globals are emitted as `internal global`.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
HLSL resources should not be externally visible from the module. We made sure of this by marking them `static` as soon as they were declared. However, this prevents us fixing issue #166458 because there is no way to know if a resource has been explicitly marked `static` by the user, and can therefore be assigned to.

This change moves from making all resources `static` to adding Clang internal linkage attribute to all non-static resource declarations as a global scope.

No explicit test added this change. There is a number of existing HLSL codegen tests that already verify that the resource globals are emitted as `internal global`.</pre>
</div>
</content>
</entry>
<entry>
<title>[HLSL] Add support for user semantics (#153424)</title>
<updated>2025-11-06T14:36:17+00:00</updated>
<author>
<name>Nathan Gauër</name>
<email>brioche@google.com</email>
</author>
<published>2025-11-06T14:36:17+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=b8a814e4fce292a24449702de07d0705f5045c0b'/>
<id>b8a814e4fce292a24449702de07d0705f5045c0b</id>
<content type='text'>
This commit adds support for HLSL input semantics. User semantics are
all semantics not starting with `SV_`.
Those semantics ends up with a Location assignment in SPIR-V.

Note: user semantics means Location, but the opposite is not true.
Depending on the stage, some system semantics can rely on a Location
index. This is not implemented in this PR.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This commit adds support for HLSL input semantics. User semantics are
all semantics not starting with `SV_`.
Those semantics ends up with a Location assignment in SPIR-V.

Note: user semantics means Location, but the opposite is not true.
Depending on the stage, some system semantics can rely on a Location
index. This is not implemented in this PR.</pre>
</div>
</content>
</entry>
</feed>
