Skip to content

Conversation

pow2clk
Copy link
Contributor

@pow2clk pow2clk commented Jun 5, 2025

There were two problems with processing the status parameter with the reword of the buffer load code. The first was that the status was not being passed down to the load instruction generation for aggregate types in any shader model version. The second was that the status retrieval from the resret returned by the raw buffer loads was using the wrong index for native vectors supported by shader model 6.9.

The status Value was not getting passed all the way down to the load instruction generation for aggregate types because the refactored helper constructor would always set it to null. It needs to be explicitly stated since by that point, the original call instruction it came from has been lost amidst subsequent GEPs, bitcasts, and/or loads that aggregate types (arrays and structs) will use on the results of the original call instruction to get the exact element required.

This changes the constructor to take an optional status parameter allowing the locations where it might be set to pass it along. In other cases, it will be null and be appropriately ignored.

Modified aggregate tests to verify this behavior. This required keeping track of the return of the last load operation involved in a raw buffer load, which made arrays more complicated. Rather than give them their own CHECK prefix, I lumped them in with large matrices requiring three loads. This did require making all the array lengths 3 to match. The loss in test variability is worth the convenience as there is no known distinction when it comes to array sizes over 1.

The status retrieval from the ResRet returned by the raw buffer loads was using the wrong index for native vectors supported by shader model 6.9. Adjusting the index according to the opcode ensures that the index will be correct.

This also required a change to validation that allows checkAccessFullyMapped to operate on the second element extracted from a ResRet where applicable and some corresponding null tolerance in related code.

Adds status retrieving overloads to the relevant load/store tests for sm6.9, aggregates, and other loads though the last category exhibited no issues. At least I got some statuses right!

Fixes #7508

Greg Roth added 2 commits June 5, 2025 14:41
The status Value was not getting passed all the way down to the load instruction generation for aggregate types because the helper constructor would always set it to null. It needs to be explicitly stated since by that point, the original call instruction it came from has been lost amidst subsequent GEPs, bitcasts, and/or loads that aggregate types (arrays and structs) will use on the results of the original call instruction to get the exact element required.

This changes the constructor to take an optional status parameter allowing the locations where it might be set to pass it along. In other cases, it will be null and be appropriately ignored.

Modified aggregate tests to verify this behavior. This required keeping track of the return of the last load operation involved in a raw buffer load, which made arrays more complicated. Rather than give them their own CHECK prefix, I lumped them in with large matrices requiring three loads. This did require making all the array lengths 3 to match. The loss in test variability is worth the convenience as there is no known distinction when it comes to array sizes over 1.
The status retrieval from the resret returned by the raw buffer loads was using the wrong index for native vectors supported by shader model 6.9. Adjusting the index by the opcode ensures that the index will be correct.

This also required a change to validation that allows checkAccessFullyMapped to operate on the second element extracted from a resret where applicable and some corresponding null tolerance in related code.

Adds status retrieving overloads to the relevant load/store tests.

Fixes microsoft#7508
Greg Roth added 2 commits June 16, 2025 15:57
I guess only MSVC doesn't have uint alias? Unintended anyway.
Copy link
Collaborator

@V-FEXrt V-FEXrt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Greg Roth added 2 commits June 23, 2025 16:26
These might have confused the checks for multi stores where relevant. By adding the checks, the number of stores must be as expected and there will be no missed failures.
Changed the usage to logical && to skip the immediate conversion usage which wasn't that distinct.
@pow2clk pow2clk merged commit e07be1c into microsoft:main Jun 25, 2025
12 checks passed
@github-project-automation github-project-automation bot moved this from New to Done in HLSL Roadmap Jun 25, 2025
@pow2clk pow2clk deleted the status-fixes branch June 25, 2025 20:33
pow2clk pushed a commit to pow2clk/DirectXShaderCompiler that referenced this pull request Jun 25, 2025
…ft#7513)

There were two problems with processing the status parameter with the
reword of the buffer load code. The first was that the status was not
being passed down to the load instruction generation for aggregate types
in any shader model version. The second was that the status retrieval
from the resret returned by the raw buffer loads was using the wrong
index for native vectors supported by shader model 6.9.

The status Value was not getting passed all the way down to the load
instruction generation for aggregate types because the refactored helper
constructor would always set it to null. It needs to be explicitly
stated since by that point, the original call instruction it came from
has been lost amidst subsequent GEPs, bitcasts, and/or loads that
aggregate types (arrays and structs) will use on the results of the
original call instruction to get the exact element required.

This changes the constructor to take an optional status parameter
allowing the locations where it might be set to pass it along. In other
cases, it will be null and be appropriately ignored.

Modified aggregate tests to verify this behavior. This required keeping
track of the return of the last load operation involved in a raw buffer
load, which made arrays more complicated. Rather than give them their
own CHECK prefix, I lumped them in with large matrices requiring three
loads. This did require making all the array lengths 3 to match. The
loss in test variability is worth the convenience as there is no known
distinction when it comes to array sizes over 1.

The status retrieval from the ResRet returned by the raw buffer loads
was using the wrong index for native vectors supported by shader model
6.9. Adjusting the index according to the opcode ensures that the index
will be correct.

This also required a change to validation that allows
checkAccessFullyMapped to operate on the second element extracted from a
ResRet where applicable and some corresponding null tolerance in related
code.

Adds status retrieving overloads to the relevant load/store tests for
sm6.9, aggregates, and other loads though the last category exhibited no
issues. At least I got some statuses right!

Fixes microsoft#7508

(cherry picked from commit e07be1c)
pow2clk pushed a commit that referenced this pull request Jun 25, 2025
Cherry-picked to release-1.8.2505 from #7513

There were two problems with processing the status parameter with the
rework of the buffer load code. The first was that the status was not
being passed down to the load instruction generation for aggregate types
in any shader model version. The second was that the status retrieval
from the resret returned by the raw buffer loads was using the wrong
index for native vectors supported by shader model 6.9.

The status Value was not getting passed all the way down to the load
instruction generation for aggregate types because the refactored helper
constructor would always set it to null. It needs to be explicitly
stated since by that point, the original call instruction it came from
has been lost amidst subsequent GEPs, bitcasts, and/or loads that
aggregate types (arrays and structs) will use on the results of the
original call instruction to get the exact element required.

This changes the constructor to take an optional status parameter
allowing the locations where it might be set to pass it along. In other
cases, it will be null and be appropriately ignored.

Modified aggregate tests to verify this behavior. This required keeping
track of the return of the last load operation involved in a raw buffer
load, which made arrays more complicated. Rather than give them their
own CHECK prefix, I lumped them in with large matrices requiring three
loads. This did require making all the array lengths 3 to match. The
loss in test variability is worth the convenience as there is no known
distinction when it comes to array sizes over 1.

The status retrieval from the ResRet returned by the raw buffer loads
was using the wrong index for native vectors supported by shader model
6.9. Adjusting the index according to the opcode ensures that the index
will be correct.

This also required a change to validation that allows
checkAccessFullyMapped to operate on the second element extracted from a
ResRet where applicable and some corresponding null tolerance in related
code.

Adds status retrieving overloads to the relevant load/store tests for
sm6.9, aggregates, and other loads though the last category exhibited no
issues. At least I got some statuses right!

Fixes #7508

(cherry picked from commit e07be1c)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[SM6.9] compiler crash with Load with status
4 participants