mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 07:35:40 +00:00
gpu/internal/opengl: reduce number of glsl shader variants
With the use of uniform buffers gone, we don't need the glsl 3.00 es variant any longer. We only support desktop OpenGL on macOS which is guaranteed to be at least version 3.2, so we don't need the glsl 1.30 variant either. Remove a test that depended on gl_VertexID which is not support in glsl 1.00 es. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -42,47 +42,6 @@ func TestFramebufferClear(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestSimpleShader(t *testing.T) {
|
||||
b := newDriver(t)
|
||||
sz := image.Point{X: 800, Y: 600}
|
||||
vsh, fsh, err := newShaders(b, gio.Shader_simple_vert, gio.Shader_simple_frag)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer vsh.Release()
|
||||
defer fsh.Release()
|
||||
fbo := newFBO(t, b, sz)
|
||||
p, err := b.NewPipeline(driver.PipelineDesc{
|
||||
VertexShader: vsh,
|
||||
FragmentShader: fsh,
|
||||
PixelFormat: driver.TextureFormatSRGBA,
|
||||
Topology: driver.TopologyTriangles,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer p.Release()
|
||||
d := driver.LoadDesc{
|
||||
ClearColor: f32color.LinearFromSRGB(clearCol),
|
||||
Action: driver.LoadActionClear,
|
||||
}
|
||||
b.BeginRenderPass(fbo, d)
|
||||
b.Viewport(0, 0, sz.X, sz.Y)
|
||||
b.BindPipeline(p)
|
||||
b.DrawArrays(0, 3)
|
||||
b.EndRenderPass()
|
||||
img := screenshot(t, b, fbo, sz)
|
||||
if got := img.RGBAAt(0, 0); got != clearColExpect {
|
||||
t.Errorf("got color %v, expected %v", got, clearColExpect)
|
||||
}
|
||||
// Just off the center to catch inverted triangles.
|
||||
cx, cy := 300, 400
|
||||
shaderCol := f32color.RGBA{R: .25, G: .55, B: .75, A: 1.0}
|
||||
if got, exp := img.RGBAAt(cx, cy), shaderCol.SRGB(); got != f32color.NRGBAToRGBA(exp) {
|
||||
t.Errorf("got color %v, expected %v", got, f32color.NRGBAToRGBA(exp))
|
||||
}
|
||||
}
|
||||
|
||||
func TestInputShader(t *testing.T) {
|
||||
b := newDriver(t)
|
||||
sz := image.Point{X: 800, Y: 600}
|
||||
|
||||
@@ -888,18 +888,10 @@ func (b *Backend) NewFragmentShader(src shader.Sources) (driver.FragmentShader,
|
||||
}
|
||||
|
||||
func (b *Backend) glslFor(src shader.Sources) string {
|
||||
if b.glver[0] < 3 {
|
||||
if b.gles {
|
||||
return src.GLSL100ES
|
||||
}
|
||||
// OpenGL (ES) 3.0.
|
||||
switch {
|
||||
case b.gles:
|
||||
return src.GLSL300ES
|
||||
case b.glver[0] >= 4 || b.glver[1] >= 2:
|
||||
// OpenGL 3.2 Core only accepts glsl 1.50 or newer.
|
||||
} else {
|
||||
return src.GLSL150
|
||||
default:
|
||||
return src.GLSL130
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user