diff --git a/gpu/gpu.go b/gpu/gpu.go index 78bdcf6a..a23f914e 100644 --- a/gpu/gpu.go +++ b/gpu/gpu.go @@ -9,6 +9,7 @@ package gpu import ( "encoding/binary" + "errors" "fmt" "image" "image/color" @@ -360,6 +361,9 @@ func New(api API) (GPU, error) { defer d.EndFrame() forceCompute := os.Getenv("GIORENDERER") == "forcecompute" feats := d.Caps().Features + if !feats.Has(driver.FeatureSRGB) { + return nil, errors.New("gpu: no sRGB texture formats found") + } switch { case !forceCompute && feats.Has(driver.FeatureFloatRenderTargets): return newGPU(d) diff --git a/gpu/internal/d3d11/d3d11_windows.go b/gpu/internal/d3d11/d3d11_windows.go index c63dffde..60506ea7 100644 --- a/gpu/internal/d3d11/d3d11_windows.go +++ b/gpu/internal/d3d11/d3d11_windows.go @@ -128,6 +128,7 @@ func newDirect3D11Device(api driver.Direct3D11) (driver.Device, error) { ctx: dev.GetImmediateContext(), caps: driver.Caps{ MaxTextureSize: 2048, // 9.1 maximum + Features: driver.FeatureSRGB, }, depthStates: make(map[depthState]*d3d11.DepthStencilState), blendStates: make(map[blendState]*d3d11.BlendState), diff --git a/gpu/internal/driver/driver.go b/gpu/internal/driver/driver.go index e1547f92..a7e58f60 100644 --- a/gpu/internal/driver/driver.go +++ b/gpu/internal/driver/driver.go @@ -212,6 +212,7 @@ const ( FeatureTimers Features = 1 << iota FeatureFloatRenderTargets FeatureCompute + FeatureSRGB ) const ( diff --git a/gpu/internal/opengl/opengl.go b/gpu/internal/opengl/opengl.go index dc628f0c..5ce3e2cb 100644 --- a/gpu/internal/opengl/opengl.go +++ b/gpu/internal/opengl/opengl.go @@ -182,10 +182,7 @@ func newOpenGLDevice(api driver.OpenGL) (driver.Device, error) { return nil, err } floatTriple, ffboErr := floatTripleFor(f, ver, exts) - srgbaTriple, err := srgbaTripleFor(ver, exts) - if err != nil { - return nil, err - } + srgbaTriple, srgbErr := srgbaTripleFor(ver, exts) gles30 := gles && ver[0] >= 3 gles31 := gles && (ver[0] > 3 || (ver[0] == 3 && ver[1] >= 1)) gl40 := !gles && ver[0] >= 4 @@ -199,6 +196,9 @@ func newOpenGLDevice(api driver.OpenGL) (driver.Device, error) { srgbaTriple: srgbaTriple, } b.feats.BottomLeftOrigin = true + if srgbErr == nil { + b.feats.Features |= driver.FeatureSRGB + } if ffboErr == nil { b.feats.Features |= driver.FeatureFloatRenderTargets }