-
Notifications
You must be signed in to change notification settings - Fork 0
/
pipeline_text.go
57 lines (49 loc) · 1.13 KB
/
pipeline_text.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package main
import (
_ "embed"
"github.com/rajveermalviya/go-webgpu/wgpu"
)
type TextPipeline struct {
Pipeline
}
//go:embed shaders/text.wgsl
var text_shader_src string
func NewTextPipeline(state *State) (*TextPipeline, error) {
pipeline, err := NewPipeline(state, "Text", text_shader_src,
[]wgpu.BindGroupLayoutEntry{
{ // texture
Binding: 0,
Visibility: wgpu.ShaderStage_Fragment,
Texture: wgpu.TextureBindingLayout{
Multisampled: false,
ViewDimension: wgpu.TextureViewDimension_2D,
SampleType: wgpu.TextureSampleType_Float,
},
},
{ // sampler
Binding: 1,
Visibility: wgpu.ShaderStage_Fragment,
Sampler: wgpu.SamplerBindingLayout{
Type: wgpu.SamplerBindingType_Filtering,
},
},
{ // text attributes
Binding: 2,
Visibility: wgpu.ShaderStage_Vertex,
Buffer: wgpu.BufferBindingLayout{
Type: wgpu.BufferBindingType_Uniform,
},
},
},
[]wgpu.VertexBufferLayout{},
)
if err != nil {
return nil, err
}
return &TextPipeline{
Pipeline: *pipeline,
}, nil
}
func (pipeline *TextPipeline) Release() {
pipeline.Pipeline.Release()
}