-
Notifications
You must be signed in to change notification settings - Fork 851
[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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
882adcb
add and test new subobj attr
bob80905 2746a23
var rename
bob80905 f51d6f4
add basic object kinds to semahlsl h, use to avoid string comps
bob80905 bd4b7ab
dont pass arbasicobjkinds around
bob80905 07642c8
address Tex
bob80905 30e3a2b
constrain attr values
bob80905 4aa9ac6
address tex, improve test
bob80905 a6301d6
assert if hitgroup matters only
bob80905 7eca1ca
more static casting
bob80905 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,7 @@ | |
| #include "clang/AST/DeclTemplate.h" | ||
| #include "clang/AST/Type.h" | ||
| #include "clang/Sema/AttributeList.h" // conceptually ParsedAttributes | ||
| #include "clang/Sema/SemaHLSL.h" // ArBasicObject kind enums | ||
| #include "llvm/ADT/StringSwitch.h" | ||
|
|
||
| using namespace clang; | ||
|
|
@@ -692,60 +693,38 @@ bool GetHLSLSubobjectKind(clang::QualType type, | |
| return false; | ||
| } | ||
|
|
||
| StringRef name = RT->getDecl()->getName(); | ||
| switch (name.size()) { | ||
| case 17: | ||
| return name == "StateObjectConfig" | ||
| ? (subobjectKind = DXIL::SubobjectKind::StateObjectConfig, | ||
| true) | ||
| : false; | ||
| case 18: | ||
| return name == "LocalRootSignature" | ||
| ? (subobjectKind = DXIL::SubobjectKind::LocalRootSignature, | ||
| true) | ||
| : false; | ||
| case 19: | ||
| return name == "GlobalRootSignature" | ||
| ? (subobjectKind = DXIL::SubobjectKind::GlobalRootSignature, | ||
| true) | ||
| : false; | ||
| case 29: | ||
| return name == "SubobjectToExportsAssociation" | ||
| ? (subobjectKind = | ||
| DXIL::SubobjectKind::SubobjectToExportsAssociation, | ||
| true) | ||
| : false; | ||
| case 22: | ||
| return name == "RaytracingShaderConfig" | ||
| ? (subobjectKind = DXIL::SubobjectKind::RaytracingShaderConfig, | ||
| true) | ||
| : false; | ||
| case 24: | ||
| return name == "RaytracingPipelineConfig" | ||
| ? (subobjectKind = | ||
| DXIL::SubobjectKind::RaytracingPipelineConfig, | ||
| true) | ||
| : false; | ||
| case 25: | ||
| return name == "RaytracingPipelineConfig1" | ||
| ? (subobjectKind = | ||
| DXIL::SubobjectKind::RaytracingPipelineConfig1, | ||
| true) | ||
| : false; | ||
| case 16: | ||
| if (name == "TriangleHitGroup") { | ||
| subobjectKind = DXIL::SubobjectKind::HitGroup; | ||
| hgType = DXIL::HitGroupType::Triangle; | ||
| return true; | ||
| } | ||
| return false; | ||
| case 27: | ||
| if (name == "ProceduralPrimitiveHitGroup") { | ||
| subobjectKind = DXIL::SubobjectKind::HitGroup; | ||
| hgType = DXIL::HitGroupType::ProceduralPrimitive; | ||
| return true; | ||
| } | ||
| return false; | ||
| HLSLSubObjectAttr *Attr = RD->getAttr<HLSLSubObjectAttr>(); | ||
|
|
||
| switch (Attr->getSubObjKindUint()) { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
| case ArBasicKind::AR_OBJECT_STATE_OBJECT_CONFIG: | ||
| subobjectKind = DXIL::SubobjectKind::StateObjectConfig; | ||
| return true; | ||
| case ArBasicKind::AR_OBJECT_LOCAL_ROOT_SIGNATURE: | ||
| subobjectKind = DXIL::SubobjectKind::LocalRootSignature; | ||
| return true; | ||
| case ArBasicKind::AR_OBJECT_GLOBAL_ROOT_SIGNATURE: | ||
| subobjectKind = DXIL::SubobjectKind::GlobalRootSignature; | ||
| return true; | ||
| case ArBasicKind::AR_OBJECT_SUBOBJECT_TO_EXPORTS_ASSOC: | ||
| subobjectKind = DXIL::SubobjectKind::SubobjectToExportsAssociation; | ||
| return true; | ||
| case ArBasicKind::AR_OBJECT_RAYTRACING_SHADER_CONFIG: | ||
| subobjectKind = DXIL::SubobjectKind::RaytracingShaderConfig; | ||
| return true; | ||
| case ArBasicKind::AR_OBJECT_RAYTRACING_PIPELINE_CONFIG: | ||
| subobjectKind = DXIL::SubobjectKind::RaytracingPipelineConfig; | ||
| return true; | ||
| case ArBasicKind::AR_OBJECT_RAYTRACING_PIPELINE_CONFIG1: | ||
| subobjectKind = DXIL::SubobjectKind::RaytracingPipelineConfig1; | ||
| return true; | ||
| case ArBasicKind::AR_OBJECT_TRIANGLE_HIT_GROUP: | ||
| subobjectKind = DXIL::SubobjectKind::HitGroup; | ||
| hgType = DXIL::HitGroupType::Triangle; | ||
| return true; | ||
| case ArBasicKind::AR_OBJECT_PROCEDURAL_PRIMITIVE_HIT_GROUP: | ||
| subobjectKind = DXIL::SubobjectKind::HitGroup; | ||
| hgType = DXIL::HitGroupType::ProceduralPrimitive; | ||
| return true; | ||
| } | ||
| } | ||
| return false; | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.