gpu/internal/driver: rename gpu/backend

There are no longer any importers of package backend outside of
gioui.org/gpu. Move it internally, and rename it to the slightly more
specific "driver" while we're at it.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2021-03-06 10:21:08 +01:00
parent 2c7aba9e7c
commit c799452c57
15 changed files with 379 additions and 379 deletions
+14 -14
View File
@@ -12,7 +12,7 @@ import (
"runtime"
"testing"
"gioui.org/gpu/backend"
"gioui.org/gpu/internal/driver"
"gioui.org/internal/f32color"
"gioui.org/internal/unsafe"
)
@@ -42,7 +42,7 @@ func TestSimpleShader(t *testing.T) {
}
defer p.Release()
b.BindProgram(p)
b.DrawArrays(backend.DrawModeTriangles, 0, 3)
b.DrawArrays(driver.DrawModeTriangles, 0, 3)
img := screenshot(t, fbo, sz)
if got := img.RGBAAt(0, 0); got != clearColExpect {
t.Errorf("got color %v, expected %v", got, clearColExpect)
@@ -65,7 +65,7 @@ func TestInputShader(t *testing.T) {
}
defer p.Release()
b.BindProgram(p)
buf, err := b.NewImmutableBuffer(backend.BufferBindingVertices,
buf, err := b.NewImmutableBuffer(driver.BufferBindingVertices,
unsafe.BytesView([]float32{
0, .5, .5, 1,
-.5, -.5, .5, 1,
@@ -77,9 +77,9 @@ func TestInputShader(t *testing.T) {
}
defer buf.Release()
b.BindVertexBuffer(buf, 4*4, 0)
layout, err := b.NewInputLayout(shader_input_vert, []backend.InputDesc{
layout, err := b.NewInputLayout(shader_input_vert, []driver.InputDesc{
{
Type: backend.DataTypeFloat,
Type: driver.DataTypeFloat,
Size: 4,
Offset: 0,
},
@@ -89,7 +89,7 @@ func TestInputShader(t *testing.T) {
}
defer layout.Release()
b.BindInputLayout(layout)
b.DrawArrays(backend.DrawModeTriangles, 0, 3)
b.DrawArrays(driver.DrawModeTriangles, 0, 3)
img := screenshot(t, fbo, sz)
if got := img.RGBAAt(0, 0); got != clearColExpect {
t.Errorf("got color %v, expected %v", got, clearColExpect)
@@ -125,7 +125,7 @@ func TestFramebuffers(t *testing.T) {
}
}
func setupFBO(t *testing.T, b backend.Device, size image.Point) backend.Framebuffer {
func setupFBO(t *testing.T, b driver.Device, size image.Point) driver.Framebuffer {
fbo := newFBO(t, b, size)
b.BindFramebuffer(fbo)
// ClearColor accepts linear RGBA colors, while 8-bit colors
@@ -137,12 +137,12 @@ func setupFBO(t *testing.T, b backend.Device, size image.Point) backend.Framebuf
return fbo
}
func newFBO(t *testing.T, b backend.Device, size image.Point) backend.Framebuffer {
func newFBO(t *testing.T, b driver.Device, size image.Point) driver.Framebuffer {
fboTex, err := b.NewTexture(
backend.TextureFormatSRGB,
driver.TextureFormatSRGB,
size.X, size.Y,
backend.FilterNearest, backend.FilterNearest,
backend.BufferBindingFramebuffer,
driver.FilterNearest, driver.FilterNearest,
driver.BufferBindingFramebuffer,
)
if err != nil {
t.Fatal(err)
@@ -161,7 +161,7 @@ func newFBO(t *testing.T, b backend.Device, size image.Point) backend.Framebuffe
return fbo
}
func newBackend(t *testing.T) backend.Device {
func newBackend(t *testing.T) driver.Device {
ctx, err := newContext()
if err != nil {
t.Skipf("no context available: %v", err)
@@ -170,7 +170,7 @@ func newBackend(t *testing.T) backend.Device {
if err := ctx.MakeCurrent(); err != nil {
t.Fatal(err)
}
b, err := backend.NewDevice(ctx.API())
b, err := driver.NewDevice(ctx.API())
if err != nil {
t.Fatal(err)
}
@@ -184,7 +184,7 @@ func newBackend(t *testing.T) backend.Device {
return b
}
func screenshot(t *testing.T, fbo backend.Framebuffer, size image.Point) *image.RGBA {
func screenshot(t *testing.T, fbo driver.Framebuffer, size image.Point) *image.RGBA {
img := image.NewRGBA(image.Rectangle{Max: size})
err := fbo.ReadPixels(
image.Rectangle{
+8 -8
View File
@@ -10,7 +10,7 @@ import (
"runtime"
"gioui.org/gpu"
"gioui.org/gpu/backend"
"gioui.org/gpu/internal/driver"
"gioui.org/op"
)
@@ -18,10 +18,10 @@ import (
type Window struct {
size image.Point
ctx context
backend backend.Device
backend driver.Device
gpu gpu.GPU
fboTex backend.Texture
fbo backend.Framebuffer
fboTex driver.Texture
fbo driver.Framebuffer
}
type context interface {
@@ -43,16 +43,16 @@ func NewWindow(width, height int) (*Window, error) {
}
err = contextDo(ctx, func() error {
api := ctx.API()
dev, err := backend.NewDevice(api)
dev, err := driver.NewDevice(api)
if err != nil {
return err
}
dev.Viewport(0, 0, width, height)
fboTex, err := dev.NewTexture(
backend.TextureFormatSRGB,
driver.TextureFormatSRGB,
width, height,
backend.FilterNearest, backend.FilterNearest,
backend.BufferBindingFramebuffer,
driver.FilterNearest, driver.FilterNearest,
driver.BufferBindingFramebuffer,
)
if err != nil {
return nil
+5 -5
View File
@@ -2,19 +2,19 @@
package headless
import "gioui.org/gpu/backend"
import "gioui.org/gpu/internal/driver"
var (
shader_input_vert = backend.ShaderSources{
shader_input_vert = driver.ShaderSources{
Name: "input.vert",
Inputs: []backend.InputLocation{{Name: "position", Location: 0, Semantic: "POSITION", SemanticIndex: 0, Type: 0x0, Size: 4}},
Inputs: []driver.InputLocation{{Name: "position", Location: 0, Semantic: "POSITION", SemanticIndex: 0, Type: 0x0, Size: 4}},
GLSL100ES: "\nattribute vec4 position;\n\nvoid main()\n{\n gl_Position = position;\n}\n\n",
GLSL300ES: "#version 300 es\n\nlayout(location = 0) in vec4 position;\n\nvoid main()\n{\n gl_Position = position;\n}\n\n",
GLSL130: "#version 130\n\nin vec4 position;\n\nvoid main()\n{\n gl_Position = position;\n}\n\n",
GLSL150: "#version 150\n\nin vec4 position;\n\nvoid main()\n{\n gl_Position = position;\n}\n\n",
HLSL: []byte{0x44, 0x58, 0x42, 0x43, 0x35, 0xe9, 0xae, 0x29, 0x96, 0x7e, 0x7c, 0xe6, 0x40, 0xb0, 0x4e, 0x29, 0xd9, 0x98, 0x51, 0x7c, 0x1, 0x0, 0x0, 0x0, 0x10, 0x2, 0x0, 0x0, 0x6, 0x0, 0x0, 0x0, 0x38, 0x0, 0x0, 0x0, 0x9c, 0x0, 0x0, 0x0, 0xe0, 0x0, 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x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xf, 0xf, 0x0, 0x0, 0x50, 0x4f, 0x53, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x0, 0xab, 0xab, 0xab, 0x4f, 0x53, 0x47, 0x4e, 0x2c, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0, 0x20, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xf, 0x0, 0x0, 0x0, 0x53, 0x56, 0x5f, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x0},
}
shader_simple_frag = backend.ShaderSources{
shader_simple_frag = driver.ShaderSources{
Name: "simple.frag",
GLSL100ES: "precision mediump float;\nprecision highp int;\n\nvoid main()\n{\n gl_FragData[0] = vec4(0.25, 0.550000011920928955078125, 0.75, 1.0);\n}\n\n",
GLSL300ES: "#version 300 es\nprecision mediump float;\nprecision highp int;\n\nlayout(location = 0) out vec4 fragColor;\n\nvoid main()\n{\n fragColor = vec4(0.25, 0.550000011920928955078125, 0.75, 1.0);\n}\n\n",
@@ -22,7 +22,7 @@ var (
GLSL150: "#version 150\n\nout vec4 fragColor;\n\nvoid main()\n{\n fragColor = vec4(0.25, 0.550000011920928955078125, 0.75, 1.0);\n}\n\n",
HLSL: []byte{0x44, 0x58, 0x42, 0x43, 0xf5, 0x46, 0xde, 0x66, 0x24, 0x29, 0xa8, 0xbb, 0x56, 0xea, 0x73, 0xb5, 0x6b, 0x73, 0x12, 0x72, 0x1, 0x0, 0x0, 0x0, 0xdc, 0x1, 0x0, 0x0, 0x6, 0x0, 0x0, 0x0, 0x38, 0x0, 0x0, 0x0, 0x90, 0x0, 0x0, 0x0, 0xd0, 0x0, 0x0, 0x0, 0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x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xf, 0x0, 0x0, 0x0, 0x53, 0x56, 0x5f, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x0, 0xab, 0xab},
}
shader_simple_vert = backend.ShaderSources{
shader_simple_vert = driver.ShaderSources{
Name: "simple.vert",
GLSL100ES: "\nvoid main()\n{\n float x;\n float y;\n if (gl_VertexID == 0)\n {\n x = 0.0;\n y = 0.5;\n }\n else\n {\n if (gl_VertexID == 1)\n {\n x = 0.5;\n y = -0.5;\n }\n else\n {\n x = -0.5;\n y = -0.5;\n }\n }\n gl_Position = vec4(x, y, 0.5, 1.0);\n}\n\n",
GLSL300ES: "#version 300 es\n\nvoid main()\n{\n float x;\n float y;\n if (gl_VertexID == 0)\n {\n x = 0.0;\n y = 0.5;\n }\n else\n {\n if (gl_VertexID == 1)\n {\n x = 0.5;\n y = -0.5;\n }\n else\n {\n x = -0.5;\n y = -0.5;\n }\n }\n gl_Position = vec4(x, y, 0.5, 1.0);\n}\n\n",