-
Notifications
You must be signed in to change notification settings - Fork 807
[SER] Diagnose HitObject in unsupported declaration contexts #7376
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Generalize long vector diagnostics code to HitObjects. - Diagnose unsupported use of HitObject in globals, entry params/returns and various other shader-kind-specific contexts. - Create HitObject variants from the invalid-longvec-decls*.hlsl tests to make sure all cases are covered. Specification: https://github.com/microsoft/hlsl-specs/blob/main/proposals/0027-shader-execution-reordering.md Bug: microsoft#7234 [SER] Diagnose and validate illegal use of HitObject in unsupported contexts
tex3d
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mainly, I don't think we should be adding as much special-case code for HitObject, where the code should be the same for other object types, such as detecting whether we have an intangible HLSL object type inside another type decl. HitObject should be considered one of a variety of intangible HLSL object types that are handled uniformly in a bunch of contexts.
But also, combining the HitObject diagnostic with the long vector one is a bit confusing, as the contexts that disallow HitObject, and other intangible objects generally, are different than the contexts that disallow long vectors. This is conceptually a different rule.
and err_hlsl_objectintemplateargument
|
This is a major update. Changes:
|
pow2clk
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So that's a lot of nitpicks from me. @tex3d still needs to reset his feedback for this to go in. As far as I can tell, the feedback he gave has mostly been responded to, but could further be addressed by merging the loose ContainsLongVector checks into DiagnoseTypeElements and its implementor functions, which I would also prefer.
tools/clang/test/SemaHLSL/hlsl/objects/HitObject/hitobject_traceinvoke_payload_udt.hlsl
Show resolved
Hide resolved
tools/clang/test/SemaHLSL/hlsl/types/invalid-hitobject-decls-struct.hlsl
Outdated
Show resolved
Hide resolved
|
A large chunk of my nitpicks become moot if ContainsLongVec is merged as the TODO comment suggests. |
Co-authored-by: Greg Roth <[email protected]>
Co-authored-by: Greg Roth <[email protected]>
Co-authored-by: Greg Roth <[email protected]>
Co-authored-by: Greg Roth <[email protected]>
Co-authored-by: Greg Roth <[email protected]>
Co-authored-by: Greg Roth <[email protected]>
Co-authored-by: Greg Roth <[email protected]>
Co-authored-by: Greg Roth <[email protected]>
…truct.hlsl Co-authored-by: Greg Roth <[email protected]>
Co-authored-by: Greg Roth <[email protected]>
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
Co-authored-by: Greg Roth <[email protected]>
Co-authored-by: Greg Roth <[email protected]>
Thanks for the review. I've folded the |
pow2clk
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! I have just a couple of nits you might consider if you end up making another iteration of this. I'm not sure why it says a merge resolution is required. When I tried to inspect the conflict, it showed zero conflicts.
|
|
||
| /// \brief Whether this class contains at least one member or base | ||
| /// class containing an HLSL vector longer than 4 elements. | ||
| bool HasHLSLLongVector : 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I confess I didn't anticpate that merging the longvector check with the other type checks would result in removing this bit, but I see how it follows and I don't object.
| const TypeDiagContext DiagContext = TypeDiagContext::TessellationPatches; | ||
| if (DiagnoseTypeElements(*m_sema, argLoc.getLocation(), arg.getAsType(), | ||
| TypeDiagContext::TessellationPatches)) | ||
| DiagContext, DiagContext)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As frequently as the pattern of both objects and long vectors having the same context occurs, it may make sense to have an overload of DiagnoseTypeElements that takes a single context that is propagated to both for the longer overload, but I won't insist on it if there are no other commits to be made to this PR that change might be packaged with.
| case AR_TOBJ_OBJECT: | ||
| Empty = false; | ||
| if (AllowObjectInContext(Ty, DiagContext)) | ||
| if (!CheckObjects || AllowObjectInContext(Ty, ObjDiagContext)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't expect and after review didn't observe any cases where the call to this would result in CheckObjects being false. There's nothing wrong with handling the condition in the interest of making it more robust, but I wanted to confirm I had that right.
|
|
||
| // Disallow long vecs from $Global cbuffers. | ||
| if (!isStatic && !isGroupShared && !IS_BASIC_OBJECT(basicKind)) | ||
| LongVecDiagContext = TypeDiagContext::CBuffersOrTBuffers; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was imagining else if (!IS_BASIC_OBJECT(basicKind)) as the final else if after the else if (isStatic) on line 15378 which would result in something more concise, but I won't insist. If you make another change to the PR, you might consider that consolidation.
This reverts commit 1b8af76.
- Recurse bases in IsHLSLCopyableAnnotatableRecord - Don't skip DiagnoseTypeElements for templated Load/Store - Don't skip existing Payload diagnostics when DiagnoseTypeElements fails - Update tests, including moving fields pointed to by notes to beginning to avoid shifting fixed location references when modifying test cases
pow2clk
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Better diagnostics overall!
damyanp
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving based on previous approvals before the most recent change.
Specification: https://github.com/microsoft/hlsl-specs/blob/main/proposals/0027-shader-execution-reordering.md
Closes #7234 [SER] Diagnose and validate illegal use of HitObject in unsupported contexts (discussed offline)