From d80992fc66e96eb22a37edd5ba04344af213a92e Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Sun, 22 Aug 2021 09:18:41 +0200 Subject: [PATCH] go.*,gpu: don't (badly) re-implement Go module versioning Changes to the gioui.org/shader module are generally breaking changes, which means that a particular version of gioui.org must be build with a particular version of gioui.org/shader. Until now, the gpu package checked the module version against an expected version and would fail at runtime if there's a mismatch. This change replaces all that complexity with a simple procedural change: bump the module major version of gioui.org/shader at each such incompatible change. It doesn't matter that we'll eventually reach gioui.org/v1234/shader; the module is internal and won't break clients. Signed-off-by: Elias Naur --- go.mod | 2 +- go.sum | 4 ++-- gpu/gpu.go | 26 -------------------------- 3 files changed, 3 insertions(+), 29 deletions(-) diff --git a/go.mod b/go.mod index 6c668253..9640d834 100644 --- a/go.mod +++ b/go.mod @@ -10,5 +10,5 @@ require ( require ( gioui.org/cpu v0.0.0-20210817075930-8d6a761490d2 - gioui.org/shader v0.0.0-20210821080300-98542fa6d725 + gioui.org/shader v1.0.0 ) diff --git a/go.sum b/go.sum index 7780c6ab..75444e20 100644 --- a/go.sum +++ b/go.sum @@ -4,8 +4,8 @@ dmitri.shuralyov.com/gpu/mtl v0.0.0-20201218220906-28db891af037/go.mod h1:H6x//7 gioui.org/cpu v0.0.0-20210808092351-bfe733dd3334/go.mod h1:A8M0Cn5o+vY5LTMlnRoK3O5kG+rH0kWfJjeKd9QpBmQ= gioui.org/cpu v0.0.0-20210817075930-8d6a761490d2 h1:AGDDxsJE1RpcXTAxPG2B4jrwVUJGFDjINIPi1jtO6pc= gioui.org/cpu v0.0.0-20210817075930-8d6a761490d2/go.mod h1:A8M0Cn5o+vY5LTMlnRoK3O5kG+rH0kWfJjeKd9QpBmQ= -gioui.org/shader v0.0.0-20210821080300-98542fa6d725 h1:ddHaYaimcj8hcqW8mNTrQOj9G8C4dkyjx9LV5h/loew= -gioui.org/shader v0.0.0-20210821080300-98542fa6d725/go.mod h1:mWdiME581d/kV7/iEhLmUgUK5iZ09XR5XpduXzbePVM= +gioui.org/shader v1.0.0 h1:nrcMavMhFE6Z8E25+7bI9nUZ2hFRP7/npSf6j53SlD0= +gioui.org/shader v1.0.0/go.mod h1:mWdiME581d/kV7/iEhLmUgUK5iZ09XR5XpduXzbePVM= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= diff --git a/gpu/gpu.go b/gpu/gpu.go index 8e5374df..768559a2 100644 --- a/gpu/gpu.go +++ b/gpu/gpu.go @@ -9,14 +9,12 @@ package gpu import ( "encoding/binary" - "errors" "fmt" "image" "image/color" "math" "os" "reflect" - "runtime/debug" "time" "unsafe" @@ -134,10 +132,6 @@ type imageOp struct { place placement } -// shaderModuleVersion is the exact version of gioui.org/shader expected by -// this package. Shader programs are not backwards or forwards compatible. -const shaderModuleVersion = "v0.0.0-20210821080300-98542fa6d725" - func decodeStrokeOp(data []byte) clip.StrokeStyle { _ = data[4] if opconst.OpType(data[0]) != opconst.TypeStroke { @@ -358,9 +352,6 @@ const ( ) func New(api API) (GPU, error) { - if err := verifyShaderModule(); err != nil { - return nil, err - } d, err := driver.NewDevice(api) if err != nil { return nil, err @@ -387,23 +378,6 @@ func newGPU(ctx driver.Device) (*gpu, error) { return g, nil } -func verifyShaderModule() error { - mod, ok := debug.ReadBuildInfo() - if !ok { - // No module support; hopefully the version matches. - return nil - } - for _, m := range mod.Deps { - if m.Path == "gioui.org/shader" { - if got := m.Version; got != shaderModuleVersion { - return fmt.Errorf("gpu: module gioui.org/shader is version %q, expected %q", got, shaderModuleVersion) - } - return nil - } - } - return errors.New("gpu: module version for gioui.org/shader not found") -} - func (g *gpu) init(ctx driver.Device) error { g.ctx = ctx g.renderer = newRenderer(ctx)