Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,36 @@ jobs:
- name: Test + 100% coverage gate
run: go test -race -coverprofile=cover.out ./... && go run . cover.out

# upscale/gpu is a module of its own (Metal and Vulkan bindings). A runner has
# no GPU, so its device tests skip, visibly (go test -v prints each SKIP); what
# runs everywhere is the shader compile, the fake-device tests of the Vulkan
# sequencing, and the build on the two platforms that have a backend.
gpu:
name: upscale/gpu (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
defaults:
run:
working-directory: upscale/gpu
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- uses: actions/setup-go@d8cbb8045d7f43706b9177cceb36c1f91a6644d5 # v7
with:
go-version: '1.27.4'
- name: gofmt
run: |
unformatted=$(gofmt -l .)
if [ -n "$unformatted" ]; then
echo "::error::these files are not gofmt-clean:"; echo "$unformatted"
exit 1
fi
- run: go build ./...
- run: go vet ./...
- run: go test -v -count=1 ./...

# The media module on 32-bit. A job of its own on Linux, not a step guarded by
# `if: runner.os` in the matrix above: buildscan reads that step as a 32-bit
# build on every OS of the matrix, including darwin/386, which does not exist.
Expand Down
53 changes: 53 additions & 0 deletions upscale/gpu/bench_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package gpu

import (
"image"
"testing"

"github.com/go-avkit/avkit/upscale"
)

// benchSrc is upscale's benchmark source: 4:2:0 YCbCr.
func benchSrc(w, h int) *image.YCbCr {
m := image.NewYCbCr(image.Rect(0, 0, w, h), image.YCbCrSubsampleRatio420)
for y := 0; y < h; y++ {
for x := 0; x < w; x++ {
m.Y[y*m.YStride+x] = uint8(x*3 + y*5 + (x*y)>>6)
}
}
for i := range m.Cb {
m.Cb[i], m.Cr[i] = uint8(i), uint8(255-i)
}
return m
}

// BenchmarkGPU720to1080 is a 1280x720 YCbCr 4:2:0 frame to 1920x1080 RGBA at
// sharpness 0.2, on the GPU. "frame" is everything Upscale does (conversion
// and upload, both kernels, readback into dst); "dispatch" is the two kernels
// and the wait alone, on a frame already uploaded.
func BenchmarkGPU720to1080(b *testing.B) {
s := openOrSkip(b, &upscale.Options{Sharpness: 0.2})
defer s.Close()
src := benchSrc(1280, 720)
dst := image.NewRGBA(image.Rect(0, 0, 1920, 1080))
if err := s.Upscale(dst, src); err != nil { // the first frame allocates
b.Fatal(err)
}
b.Run("frame", func(b *testing.B) {
b.SetBytes(1920 * 1080)
for b.Loop() {
if err := s.Upscale(dst, src); err != nil {
b.Fatal(err)
}
}
})
b.Run("dispatch", func(b *testing.B) {
p := s.params(1280, 720, 1920, 1080, false)
b.SetBytes(1920 * 1080)
for b.Loop() {
if err := s.b.run(&p); err != nil {
b.Fatal(err)
}
}
})
}
Loading
Loading