-
Notifications
You must be signed in to change notification settings - Fork 787
[Sema] Add and test new Subobject Attribute #7258
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
RecordDecl *RD = RT->getDecl(); | ||
if (!RD->hasAttr<HLSLSubObjectAttr>()) { | ||
return false; | ||
} |
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.
Given that you've added the attribute now, it would be pretty easy to avoid the string compares by adding a parameter to it containing an integer representation of the Subobjectkind similar to how HLSLResourceAttr does. The callers of CreateSubobjectStateObjectConfig and friends that call StartSubObjectDecl have the AR_OBJECT enums, which indicate which DXIL:SubobjectKind they need. It would be pretty easy to plumb it down and apply it to the attr.
tools/clang/lib/Sema/SemaHLSL.cpp
Outdated
static CXXRecordDecl *StartSubobjectDecl(ASTContext &context, | ||
const char *name) { | ||
static CXXRecordDecl *StartSubobjectDecl(ASTContext &context, const char *name, | ||
ArBasicKind kind) { |
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'm afraid this isn't quite what I had in mind. If you pass in the correct DXIL::SubobjectKind type into StartsSubObjectDecl even if you have to cast it to a uint from:
CreateSubobjectStateObjectConfig
CreateSubobjectRootSignature
CreateSubobjectSubobjectToExportsSassoc
CreateSubobjectRaytracingShaderConfig
CreateSubobjectRaytracingShaderConfig1
CreateSubobjectTriangleHitGroup
CreateSubobjectProceuralPrimitiveHitGroup
I think each of these know what SubobjectKind they're going to require, so there's no need to let the AR_OBJECT types escape SemaHLSL.cpp.
tools/clang/lib/AST/HlslTypes.cpp
Outdated
return false; | ||
HLSLSubObjectAttr *Attr = RD->getAttr<HLSLSubObjectAttr>(); | ||
|
||
switch (Attr->getSubObjKindUint()) { |
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.
Just to make sure of clarity here. I expected the argument to be the DXIL::SubobjectKind enum rather than the AR_OBJECTs which wouldn't require any conversion here apart from casting it back to the enum type.
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.
Thanks for indulging me!
tools/clang/test/HLSLFileCheck/shader_targets/raytracing/subobjects_attr.hlsl
Outdated
Show resolved
Hide resolved
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.
LGTM!
This PR adds and tests a new subobject attribute. It will be useful for checking if a given decl is a subobject decl. This functionality will be used in #7239
We need an attribute in order to determine whether to check its initializer for availability attributes or not.
Fixes #7257