Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[SPIRV] Implements vk::BufferPointer proposal #7163

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

Conversation

danbrown-amd
Copy link
Contributor

Implements vk::BufferPointer proposal.
Closes #6489.

@danbrown-amd danbrown-amd requested a review from a team as a code owner February 27, 2025 00:16
Copy link
Contributor

github-actions bot commented Feb 28, 2025

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

@s-perron s-perron requested review from Keenuts and s-perron February 28, 2025 01:22
Copy link
Collaborator

@Keenuts Keenuts left a comment

Choose a reason for hiding this comment

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

I need to look more, early feedback

Comment on lines +547 to +556
/// <summary>Adds a constructor declaration to the specified class
/// record.</summary> <param name="context">ASTContext that owns
/// declarations.</param> <param name="recordDecl">Record declaration in which
/// to add constructor.</param> <param name="resultType">Result type for
/// constructor.</param> <param name="paramTypes">Types for constructor
/// parameters.</param> <param name="paramNames">Names for constructor
/// parameters.</param> <param name="declarationName">Name for
/// constructor.</param> <param name="isConst">Whether the constructor is a
/// const function.</param> <returns>The method declaration for the
/// constructor.</returns>
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit:
Is doxygen still generatable? (Couldn't make it work).
If no, might be more readable to have a normal comment.

}

QualType GetVKBufferPointerBufferType(clang::QualType type) {
return GetHLSLResourceTemplateParamType(type);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why does this doesn't check the namespaceDecl?

Would it be useful to have the following:
a static std::optional<QualType> MaybeGetVKBufferPointerBufferType(QualType T) which does the RecordType, ClassTemplateSpec, NamespaceDecl checks, and returns the QualType is all pass, and then use this to implement the 3 functions here?

IsVKBufferPointerType(T) { return MaybeGet(T).has_value(); }
GetVKBufferPointerType(T) { return MaybeGet(T).value(); }
GetVKBufferPointerAlignment(T) { return MaybeGet(T)->getTemplateArgs()[1].getAsIntegral()...; }

@@ -200,6 +203,7 @@ void CapabilityVisitor::addCapabilityForType(const SpirvType *type,
}
// Pointer type
else if (const auto *ptrType = dyn_cast<SpirvPointerType>(type)) {
sc = ptrType->getStorageClass();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shall this assert sc == ptrType->getStorageClass() instead? Is there a valid case for calling this function with the wrong sc?

@@ -3387,6 +3420,10 @@ class HLSLExternalSource : public ExternalSemaSource {
case LICOMPTYPE_VOID:
paramTypes.push_back(context.VoidTy);
break;
case LICOMPTYPE_VK_BUFFER_POINTER:
paramTypes.push_back(context.getTypeDeclType(
m_objectTypeDecls[AR_OBJECT_VK_BUFFER_POINTER]));
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is not supposed to work, the index is larger than the array size. Seems like you need to get the index first from the g_ArBasicKindsAsTypes array no?
(this also means this path is not tested)

float4 g_vSomeConstantB;
};

typedef vk::BufferPointer<Globals_s> Globals_p;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like doing this crashes the compiler:

typedef vk::BufferPointer<Globals_p> Globals_pp;;

PushConstant_t {
    Globals_pp bda;
}

bda.Get().Get().g_testFloat4

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
Status: New
Development

Successfully merging this pull request may close these issues.

[SPIR-V][Feature Request] Implement Buffer Pointers in HLSL With vk::BufferPointer
2 participants