Skip to content

Add type annotations for missing HLSL object cases - #6227

Draft
Tex Riddell (tex3d) wants to merge 4 commits into
microsoft:mainfrom
tex3d:add-missing-type-annotations
Draft

Tex Riddell (tex3d) wants to merge 4 commits into
microsoft:mainfrom
tex3d:add-missing-type-annotations

Conversation

@tex3d

@tex3d Tex Riddell (tex3d) commented Jan 31, 2024 •

Copy link
Copy Markdown
Contributor
  • Node Object method return types
  • Type template arguments

TODO: Add tests

Fixes: #5357

- Node Object method return types
- Type template arguments
case clang::TemplateArgument::ArgKind::Type: {
auto argTy = arg.getAsType();
unsigned arrayEltSize = 0;
AddTypeAnnotation(argTy, dxilTypeSys, arrayEltSize);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'm curious why this hasn't come up before for other templated types.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think most of the time, the type gets added through another path, such as a local variable being assigned to the result of an operation which returns the templated type.

An incomplete type indicates an unused type, so it should not require a type annotation.

The incomplete type case is hit due to new code annotating object method return types.  If the return type is an incomplete type, the method must never be called, the type is never completed, and the type annotation cannot be created.
Remove the workaround for missing node record type annotation for NodeOutput retrieved from NodeOutputArray.
@github-actions

github-actions Bot commented Mar 7, 2024 •

Copy link
Copy Markdown
Contributor

✅ With the latest revision this PR passed the C/C++ code formatter.

Otherwise cases where structs are materialized later will be missed, such as for the subscript operator.

No need to iterate object methods now.  In AddTypeAnnotation, we expect the annotation for RecordType to already have been created.

Adjust `!IsHLSLStructuredBufferType(Ty) && IsHLSLResourceType(Ty)` case:
- No annotation needed for resource object unless structured buffer type, all resource objects return 0 for CB size.
- Previously, structured buffer case went through RecordType case in AddTypeAnnotation, but now it's created elsewhere, so that's unnecessary.

Updated test sensitive to type annotation ordering, since now inner annotations will be added first now.
@tex3d
Tex Riddell (tex3d) force-pushed the add-missing-type-annotations branch from 26f1b49 to 6cdb14e Compare March 7, 2024 06:57

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: New

Development

Successfully merging this pull request may close these issues.

Ensure type annotations are added for reference returning intrinsics/operators

2 participants