concinnity-core 0.19.2

Runtime vocabulary for the Concinnity engine: GPU layouts, ECS components, registry, CPU kernels
Documentation
// Declarations shared by the fullscreen post passes, spliced into a shader at
// its POST_COMMON marker (see slang_source.rs). Not a standalone program: it
// declares no entry point and no resources, so it never appears in a backend's
// program table. Nothing here may spell the marker itself -- the splice would
// reintroduce it into the assembled source.

// Dimensions of a combined texture-sampler, as out parameters.
//
// slangc mis-lowers GetDimensions on a combined type for HLSL: it splits the
// type and then passes the sampler as the first argument
// (`tex.GetDimensions(samp, w, h)`), which no HLSL overload takes, so the DXIL
// leg fails in dxc. Spelling the call here fixes the argument list. A split
// pair occupies two operand slots, so `$0` is the texture, `$1` the sampler it
// dropped, and the out parameters land at `$2` and `$3`.
void combined_dims(Sampler2D<float4> s, out uint w, out uint h)
{
    __target_switch
    {
    case hlsl:
        __intrinsic_asm "$0.GetDimensions($2, $3)";
    default:
        s.GetDimensions(w, h);
    }
}

// Texture dimensions of a combined texture-sampler.
//
// The Metal target reads them through inline MSL because slangc mis-lowers
// GetDimensions on a combined type there too, in its own way: it emits an
// assignment into the sampler operand (`(*(src_sampler)) =
// src_texture.get_width(0)`), which the Metal compiler rejects outright. The
// resource rides as a parameter so the inline form can reference it.
float2 combined_size(Sampler2D<float4> s)
{
    __target_switch
    {
    case metal:
        __intrinsic_asm "float2($0.get_width(), $0.get_height())";
    default:
        uint w, h;
        combined_dims(s, w, h);
        return float2(float(w), float(h));
    }
}