Skip to content

NZSLC: Add precompiled binaries for options #18

@SirLynix

Description

@SirLynix

One drawback of NZSL is its massive use of options, which prevent the early generation of GLSL and SPIR-V.

Something we could do to help with this is to give NZSLC (compiler) a set of options values that could be precompiled and embedded into a file (.nzslb? another file?).

For example:

[nzsl_version("1.0")]
module;

option HasDiffuseTexture: bool = false;
option HasAlphaTexture: bool = false;
option AlphaTest: bool = false;

option PosLocation: i32;
option UvLocation: i32 = -1;

We could imagine an additional file giving all options values to precompile:

{
    "targets": [
        {
            "type": "glsl",
            "version": 330
        },
        {
            "type": "glsl-es",
            "version": 330
        },
        {
            "type": "spv",
            "version": 100
        }
    ],
    "option_values": {
        "HasDiffuseTexture": [false, true],
        "HasAlphaTexture": [false, true],
        "AlphaTest": [false, true]
    },
    "variants": [
        {
            "options": {
                "ColorLocation": 0,
                "UvLocation": 1
            }
        },
        {
            "options": {
                "ColorLocation": 1,
                "UvLocation": 0
            }
        }
    ]
}

this would lead to the generation of 16 variations per shading language (so a total of 48 here), each variation would be associated with a hash of its option values.

Perhaps we could also give options a range of acceptable values:

[range(0,1)] option PosLocation: i32;
[range(0,1)] option UvLocation: i32 = -1;

which would allow NZSLC to know which variations are allowed without even a variant list file (however this could result in a lot of variations very quickly).

What do you think?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestquestionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions