Skip to content

Resource constructors proposal #197

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

hekota
Copy link
Member

@hekota hekota commented Mar 28, 2025

Proposal for resource classes constructors.

Fixes #209

Copy link
Collaborator

@damyanp damyanp left a comment

Choose a reason for hiding this comment

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

So I've tried to understand this, and maybe I've been reading it too quickly, but I don't understand how any of these non-default constructors would get called?

@hekota
Copy link
Member Author

hekota commented Mar 28, 2025

So I've tried to understand this, and maybe I've been reading it too quickly, but I don't understand how any of these non-default constructors would get called?

Right, I did not mention that. Only the default constructor call gets generated automatically by Clang. The others will be set up by Sema after processing the resource binding attribute, or a lack of it. Basically it will be changing:

RWBuffer<float> A : register(u3)
into
RWBuffer<float> A(Binding(0,3,1,0));

@damyanp
Copy link
Collaborator

damyanp commented Mar 28, 2025

Ah, thanks, that helps!

The others will be set up by Sema after processing the resource binding attribute, or a lack of it.

What will Sema use to identify things that need to be fixed up in this way?

@hekota
Copy link
Member Author

hekota commented Mar 28, 2025

What will Sema use to identify things that need to be fixed up in this way?

Sema detects whether a global variable is resource class by checking if the first field of the declaration is a resource handle.

We already have `__builtin_hlsl_resource_getpointer` and we should follow the same pattern for other buildins related to resources. Renaming the builtins to:

`__builtin_hlsl_resource_createpoisonhandle`
`__builtin_hlsl_resource_createhandlefrombinding`
`__builtin_hlsl_resource_createhandlefromimplicitbinding`
Copy link
Collaborator

@bob80905 bob80905 left a comment

Choose a reason for hiding this comment

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

Looks good to my untrained eye

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

[HLSL] Design of constructors for resource handle initialization
3 participants