Skip to content

Add a way to detect the target and generate native code #82

@SirLynix

Description

@SirLynix

The idea is to implement #63 but in another way:

fn main()
{
    const if (target(spirv))
    {
        // target is spirv
    }

    const if (target(glsl, 430))
    {
        // target is GLSL 4.3
        const if (target_ext("GL_EXT_shader_samples_identical"))
        {
            // GL_EXT_shader_samples_identical is supported
        }
    }
}

now that feature is mostly useless without a way to inject GLSL/SPIR-V/WGSL/... directly, a bit like asm blocks in C. However I'm not sure about the syntax.

const if (target(glsl) && target_ext("GL_MESA_shader_integer_functions"))
{
    // ?
}

I think the best way would be to have a special kind of function, maybe something like

[cond(target(glsl) && target_ext("GL_MESA_shader_integer_functions"))]
[asm(glsl)]
fn bitcount(value: i32) -> i32
{
    // GLSL code, value being available to it
    /// return bitCount(value);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions