From d38c78d7ac0fb4cbf43e72bb1f47df091f43f0a9 Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Wed, 11 Aug 2021 16:11:26 +0200 Subject: [PATCH] gpu,gpu/internal: move InputDesc back from gioui.org/shader module It was moved to gioui.org/shader by mistake. Signed-off-by: Elias Naur --- gpu/compute.go | 4 ++-- gpu/gpu.go | 2 +- gpu/headless/driver_test.go | 2 +- gpu/internal/d3d11/d3d11_windows.go | 2 +- gpu/internal/driver/driver.go | 10 +++++++++- gpu/internal/opengl/opengl.go | 4 ++-- gpu/path.go | 4 ++-- 7 files changed, 18 insertions(+), 10 deletions(-) diff --git a/gpu/compute.go b/gpu/compute.go index 4e700943..e65e1005 100644 --- a/gpu/compute.go +++ b/gpu/compute.go @@ -422,7 +422,7 @@ func newCompute(ctx driver.Device) (*compute, error) { pipe, err := ctx.NewPipeline(driver.PipelineDesc{ VertexShader: copyVert, FragmentShader: copyFrag, - VertexLayout: []shader.InputDesc{ + VertexLayout: []driver.InputDesc{ {Type: shader.DataTypeFloat, Size: 2, Offset: 0}, {Type: shader.DataTypeFloat, Size: 2, Offset: 4 * 2}, }, @@ -457,7 +457,7 @@ func newCompute(ctx driver.Device) (*compute, error) { pipe, err = ctx.NewPipeline(driver.PipelineDesc{ VertexShader: materialVert, FragmentShader: materialFrag, - VertexLayout: []shader.InputDesc{ + VertexLayout: []driver.InputDesc{ {Type: shader.DataTypeFloat, Size: 2, Offset: 0}, {Type: shader.DataTypeFloat, Size: 2, Offset: 4 * 2}, }, diff --git a/gpu/gpu.go b/gpu/gpu.go index 185162b1..fc6f8188 100644 --- a/gpu/gpu.go +++ b/gpu/gpu.go @@ -580,7 +580,7 @@ func createColorPrograms(b driver.Device, vsSrc shader.Sources, fsSrc [3]shader. SrcFactor: driver.BlendFactorOne, DstFactor: driver.BlendFactorOneMinusSrcAlpha, } - layout := []shader.InputDesc{ + layout := []driver.InputDesc{ {Type: shader.DataTypeFloat, Size: 2, Offset: 0}, {Type: shader.DataTypeFloat, Size: 2, Offset: 4 * 2}, } diff --git a/gpu/headless/driver_test.go b/gpu/headless/driver_test.go index 5ec5a197..fb646942 100644 --- a/gpu/headless/driver_test.go +++ b/gpu/headless/driver_test.go @@ -77,7 +77,7 @@ func TestInputShader(t *testing.T) { } defer vsh.Release() defer fsh.Release() - layout := []shader.InputDesc{ + layout := []driver.InputDesc{ { Type: shader.DataTypeFloat, Size: 4, diff --git a/gpu/internal/d3d11/d3d11_windows.go b/gpu/internal/d3d11/d3d11_windows.go index 7c38116b..3a0bb4bb 100644 --- a/gpu/internal/d3d11/d3d11_windows.go +++ b/gpu/internal/d3d11/d3d11_windows.go @@ -274,7 +274,7 @@ func (b *Backend) NewFramebuffer(tex driver.Texture) (driver.Framebuffer, error) return fbo, nil } -func (b *Backend) newInputLayout(vertexShader shader.Sources, layout []shader.InputDesc) (*d3d11.InputLayout, error) { +func (b *Backend) newInputLayout(vertexShader shader.Sources, layout []driver.InputDesc) (*d3d11.InputLayout, error) { if len(vertexShader.Inputs) != len(layout) { return nil, fmt.Errorf("NewInputLayout: got %d inputs, expected %d", len(layout), len(vertexShader.Inputs)) } diff --git a/gpu/internal/driver/driver.go b/gpu/internal/driver/driver.go index 547d34a1..719f39f2 100644 --- a/gpu/internal/driver/driver.go +++ b/gpu/internal/driver/driver.go @@ -60,11 +60,19 @@ type Pipeline interface { type PipelineDesc struct { VertexShader VertexShader FragmentShader FragmentShader - VertexLayout []shader.InputDesc + VertexLayout []InputDesc BlendDesc BlendDesc PixelFormat TextureFormat } +// InputDesc describes a vertex attribute as laid out in a Buffer. +type InputDesc struct { + Type shader.DataType + Size int + + Offset int +} + type BlendDesc struct { Enable bool SrcFactor, DstFactor BlendFactor diff --git a/gpu/internal/opengl/opengl.go b/gpu/internal/opengl/opengl.go index 00d2c8ff..4a5be8eb 100644 --- a/gpu/internal/opengl/opengl.go +++ b/gpu/internal/opengl/opengl.go @@ -115,7 +115,7 @@ type framebuffer struct { type pipeline struct { prog *program inputs []shader.InputLocation - layout []shader.InputDesc + layout []driver.InputDesc blend driver.BlendDesc } @@ -157,7 +157,7 @@ type uniformLocation struct { type inputLayout struct { inputs []shader.InputLocation - layout []shader.InputDesc + layout []driver.InputDesc } // textureTriple holds the type settings for diff --git a/gpu/path.go b/gpu/path.go index e638f7de..cc6adb04 100644 --- a/gpu/path.go +++ b/gpu/path.go @@ -187,14 +187,14 @@ func newStenciler(ctx driver.Device) *stenciler { if err != nil { panic(err) } - progLayout := []shader.InputDesc{ + progLayout := []driver.InputDesc{ {Type: shader.DataTypeFloat, Size: 1, Offset: int(unsafe.Offsetof((*(*vertex)(nil)).Corner))}, {Type: shader.DataTypeFloat, Size: 1, Offset: int(unsafe.Offsetof((*(*vertex)(nil)).MaxY))}, {Type: shader.DataTypeFloat, Size: 2, Offset: int(unsafe.Offsetof((*(*vertex)(nil)).FromX))}, {Type: shader.DataTypeFloat, Size: 2, Offset: int(unsafe.Offsetof((*(*vertex)(nil)).CtrlX))}, {Type: shader.DataTypeFloat, Size: 2, Offset: int(unsafe.Offsetof((*(*vertex)(nil)).ToX))}, } - iprogLayout := []shader.InputDesc{ + iprogLayout := []driver.InputDesc{ {Type: shader.DataTypeFloat, Size: 2, Offset: 0}, {Type: shader.DataTypeFloat, Size: 2, Offset: 4 * 2}, }