Skip to content

[HLSL] Apply hlsl resource attributes to the resource type rather than the handle member #104861

Closed
@bogner

Description

@bogner

Currently resource attributes are attached on the resource handle field inside the resource class, like so:

template <typename T> class RWBuffer {
  // ...
  [[hlsl::resource(...)]]
  [[hlsl::resource_class(uav)]]
  __hlsl_resource_t handle;
};

This does not really work for codegen when it gets to the __hlsl_resource_t type conversion. The conversion method gets only the resource type itself and does not have access to the field attributes. We'd like the attributes to be attached to the resource's handle type instead so that codegen can determine the correct llvm target type:

template <typename T> class RWBuffer {
  __hlsl_resource_t  [[hlsl::resource(...)]] [[hlsl::resource_class(uav)]] handle;
};

or better yet

using rwbuf_t = __hlsl_resource_t [[hlsl::resource(...)]] [[hlsl::resource_class(uav)]];
template <typename T> class RWBuffer {
  rwbuf_t handle;
};

Note that this is not blocked by the introduction of the intangible handle type - resources already have a void *Handle member, and we can simply attach these attributes there.

AC:
All of the HLSL resource attributes are attached to the handle type
Diagnostic and backend logic that refers to these attributes continues to work
Existing tests are updated to conform to this approach
Utility functions to find information about resource types continue to work

Metadata

Metadata

Assignees

Labels

HLSLHLSL Language Supportclang:frontendLanguage frontend issues, e.g. anything involving "Sema"

Type

No type

Projects

Status

Closed

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions