package generator import ( "path/filepath" "testing" ) func TestWGPUSMPTEPattern(t *testing.T) { const width, height = 1920, 1080 g, err := NewWGPUGenerator(width, height, filepath.Join("..", "..", "kernels", "static", "smpteBars.wgsl")) if err != nil { t.Fatalf("init: %v", err) } defer g.Close() buf := make([]byte, width*height*8/3) if err := g.GenerateFrame(buf, 0); err != nil { t.Fatalf("GenerateFrame: %v", err) } if err := g.GenerateFrame(buf, 1); err != nil { t.Fatalf("GenerateFrame 2: %v", err) } tests := []struct { name string x, y int wantY, wantCb, wantCr uint32 }{ {"top left gray flank", 100, 100, 414, 512, 512}, {"top white bar", 300, 100, 721, 512, 512}, {"top green bar", 960, 100, 534, 253, 207}, {"top right gray flank", 1800, 100, 414, 512, 512}, {"section 2 cyan flank", 100, 650, 754, 615, 64}, {"section 2 minus I", 300, 650, 244, 612, 395}, {"section 2 white", 600, 650, 721, 512, 512}, {"section 2 blue flank", 1800, 650, 127, 960, 471}, {"section 3 yellow flank", 100, 750, 877, 64, 553}, {"section 3 plus Q", 300, 750, 141, 697, 606}, {"section 3 red flank", 1800, 750, 250, 409, 960}, {"bottom gray flank", 100, 900, 195, 512, 512}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { y, cb, cr := sampleV210(buf, width, tt.x, tt.y) if y != tt.wantY || cb != tt.wantCb || cr != tt.wantCr { t.Fatalf("pixel (%d,%d): got %d/%d/%d, want %d/%d/%d", tt.x, tt.y, y, cb, cr, tt.wantY, tt.wantCb, tt.wantCr) } }) } }