Files
openchamber-android-native/third_party/mygo/ui/shader/gpu_windows_test.go
T
OpenChamber 6c0ee61750 feat: port the client to MyGo native UI (0.3.0)
Switch from Asuka to MyGo, keeping the API client and the feature set:

- servers: saved servers, passwordless and password login, proxy,
  self-signed certificates, per-server device tokens (Keystore), connect
  form, instance list sheet with switch/disconnect
- sessions: virtualized list, search, new session, rename/archive/delete,
  running indicator, event stream keeps it live
- chat: pushed window with system back bar, streaming Markdown via
  ui/markdown, reasoning and tool rows with image previews, footer menu
  (read aloud via a Kotlin TTS plugin, copy, fork), user message menu
  (copy, revert, fork), context usage ring and detail sheet, attachments
  (photos/files via the document picker), permissions
- release builds allow plain http:// LAN servers (Go's net/http dials
  directly, no cleartext manifest needed)
- a local fork of MyGo (third_party/mygo) lowers the Android host's
  minSdk to 24 (Android 7.0); Go 1.27.4 via mise

Version 0.3.0.
2026-11-18 13:22:59 +08:00

94 lines
2.7 KiB
Go

package shader
import (
"testing"
"github.com/egoist/mygo/internal/gpu/d3d11"
"github.com/egoist/mygo/internal/gpu/gputest"
)
// TestDirect3D checks that Direct3D 11 draws a shader, its uniforms and
// its images, a bitmap and a canvas, as the CPU does.
func TestDirect3D(t *testing.T) {
s := MustCompile(testSource)
if _, err := d3d11.CompileEffect(s.fx.HLSL.Source); err != nil {
t.Fatal(err)
}
sc := testScene(s)
pix, stride, err := d3d11.RenderOffscreen(sc)
if err != nil {
t.Skip("no Direct3D:", err)
}
gputest.Compare(t, "ui-shader-d3d11", pix, stride, sc)
}
// TestDirect3DBools checks that Direct3D reads bool uniforms as the CPU
// does.
func TestDirect3DBools(t *testing.T) {
sc := boolScene()
pix, stride, err := d3d11.RenderOffscreen(sc)
if err != nil {
t.Skip("no Direct3D:", err)
}
gputest.Compare(t, "ui-shader-d3d11-bools", pix, stride, sc)
}
// TestDirect3DDfdy checks that dfdy grows downward on Direct3D 11.
func TestDirect3DDfdy(t *testing.T) {
pix, stride, err := d3d11.RenderOffscreen(dfdyScene())
if err != nil {
t.Skip("no Direct3D:", err)
}
checkDfdy(t, pix, stride)
}
// TestDirect3DMasked checks that Direct3D fills mask glyphs with a shader,
// as text and paths, as the CPU does.
func TestDirect3DMasked(t *testing.T) {
sc := maskedScene(MustCompile(maskedSource))
pix, stride, err := d3d11.RenderOffscreen(sc)
if err != nil {
t.Skip("no Direct3D:", err)
}
gputest.Compare(t, "ui-shader-d3d11-masked", pix, stride, sc)
}
// TestDirect3DEffect checks that Direct3D draws an effect's shader from
// its content, as the CPU does.
func TestDirect3DEffect(t *testing.T) {
for name, sc := range effectScenes(MustCompile(effectSource)) {
pix, stride, err := d3d11.RenderOffscreen(sc)
if err != nil {
t.Skip("no Direct3D:", err)
}
gputest.Compare(t, "ui-shader-d3d11-effect-"+name, pix, stride, sc)
}
}
// TestDirect3DBackdrop checks that Direct3D gives a shader its backdrop,
// as the CPU does.
func TestDirect3DBackdrop(t *testing.T) {
for name, sc := range backdropCases() {
pix, stride, err := d3d11.RenderOffscreen(sc)
if err != nil {
t.Skip("no Direct3D:", err)
}
gputest.Compare(t, "ui-shader-d3d11-backdrop-"+name, pix, stride, sc)
}
}
// TestDirect3DInstances checks that Direct3D 11 draws the quads of one
// draw (DrawInstances), each with its data and index, as the CPU does.
func TestDirect3DInstances(t *testing.T) {
s := MustCompile(instancesSource)
if _, err := d3d11.CompileEffect(s.fx.HLSL.Source); err != nil {
t.Fatal(err)
}
sc := instancesScene(s)
pix, stride, err := d3d11.RenderOffscreen(sc)
if err != nil {
t.Skip("no Direct3D:", err)
}
gputest.Compare(t, "ui-shader-d3d11-instances", pix, stride, sc)
}