Skip to content

hello example shows pink screen on macOS #48

@blagodus

Description

@blagodus

hello example shows pink screen on macOS

Platform: macOS
Build command: CGO_ENABLED=0 go build .

Steps to reproduce

  1. Clone the repo
  2. cd examples/hello
  3. CGO_ENABLED=0 go build . && ./hello

Result

Pink screen. See attached screenshot.

Image

Console output

2026/03/13 19:17:21 render: ensure pipelines: SDF pipeline: compile sdf_render shader: metal: failed to compile MSL: program_source:87:26: error: cannot reserve 'buffer' resource location at index 0
    constant ClipParams& clip [[buffer(0)]]) {
                         ^
program_source:129:26: error: cannot reserve 'buffer' resource location at index 0
    constant ClipParams& clip [[buffer(0)]]) {
                         ^
 | Error Domain=MTLLibraryErrorDomain Code=3 "program_source:87:26: error: cannot reserve 'buffer' resource location at index 0
    constant ClipParams& clip [[buffer(0)]]) {
                         ^
program_source:129:26: error: cannot reserve 'buffer' resource location at index 0
    constant ClipParams& clip [[buffer(0)]]) {
                         ^
" UserInfo={NSLocalizedDescription=program_source:87:26: error: cannot reserve 'buffer' resource location at index 0
    constant ClipParams& clip [[buffer(0)]]) {
                         ^
program_source:129:26: error: cannot reserve 'buffer' resource location at index 0
    constant ClipParams& clip [[buffer(0)]]) {
                         ^
} | {
    NSLocalizedDescription = "program_source:87:26: error: cannot reserve 'buffer' resource location at index 0\n    constant ClipParams& clip [[buffer(0)]]) {\n                         ^\nprogram_source:129:26: error: cannot reserve 'buffer' resource location at index 0\n    constant ClipParams& clip [[buffer(0)]]) {\n                         ^\n";
}
MSL:
#include <metal_stdlib>
#include <simd/simd.h>

using metal::uint;

struct Uniforms {
    metal::float2 viewport;
    metal::float2 _pad;
};

struct VertexInput {
    metal::float2 position_;
    metal::float2 local;
    float shape_kind;
    float param1;
    float param2;
    float param3;
    float half_stroke;
    float is_stroked;
    metal::float4 color_;
};

struct VertexOutput {
    metal::float4 clip_position;
    metal::float2 local;
    float shape_kind;
    float param1;
    float param2;
    float param3;
    float half_stroke;
    float is_stroked;
    metal::float4 color_;
};

struct ClipParams {
    metal::float4 clip_rect;
    float clip_radius;
    float clip_enabled;
    metal::float2 _pad;
};

// Safe division helper (handles zero divisor)
template <typename T, typename D>
T _naga_div(T lhs, D rhs) {
    D nz = D(rhs != D(0));
    return lhs / (nz * rhs + D(!nz));
}

// Safe modulo helper (handles zero divisor)
template <typename T, typename D>
T _naga_mod(T lhs, D rhs) {
    D nz = D(rhs != D(0));
    return lhs % (nz * rhs + D(!nz));
}

float rrect_clip_coverage(metal::float2 frag_pos,
    constant ClipParams& clip) {

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions