Skip to content

Entry point specialisation logic lacks support for variadic generics #8110

@daljit46

Description

@daljit46

Currently, the compilation API does not currently support specializing a shader entry point that uses variadic generics (e.g., <each T : IInterface>).
When attempting to specialize such an entry point, IEntryPoint::getSpecializationParamCount() returns 0. Any subsequent call to IEntryPoint::specialize() with type arguments fails, as the API expects zero arguments.

To reproduce this define a shader with a variadic generic entry point:

    interface ISomeInterface {}
    struct MyOperation1 : ISomeInterface {}
    struct MyOperation2 : ISomeInterface {}

    [shader("compute")]
    [numthreads(1, 1, 1)]
    void main<each Operation : ISomeInterface>()
    {
        // ...
    }

On the C++ side:

    Slang::ComPtr<slang::IComponentType> entryPoint = ... // Get the "main" entry point
    // This will return 0
    int paramCount = entryPoint->getSpecializationParamCount();

    std::array<slang::SpecializationArg, 1> specializationArgs =
    {
        {
            slang::SpecializationArg::Kind::Type,
            slangModule->getLayout()->findTypeByName("HighQuality")
        }
    };
    Slang::ComPtr<slang::IComponentType> specializedEntryPoint;
    // The following attempt to specialize will fail
    Slang::ComPtr<slang::IBlob> diagnosticsBlob;
    SlangResult result = entryPoint->specialize(specializationArgs.data(), specializationArgs.size(),  specializedEntryPoint.writeRef(), diagnosticsBlob.writeRef());

The specialize call fails with the following error:

error 38025: expected 0 specialization arguments (1 provided)

It was pointed out to me on Discord by @csyonghe that this is because the specialisation API doesn't support variadic generics yet.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions