dvd logo remove

This commit is contained in:
Dmitry Sergeev
2026-09-13 17:40:33 +03:00
parent 669dbf9fbb
commit 362ff2718e
8 changed files with 12 additions and 476 deletions
+9 -49
View File
@@ -35,8 +35,6 @@ type WGPUGenerator struct {
out *wgpu.Buffer
host *wgpu.Buffer
uniform *wgpu.Buffer
logo *wgpu.Buffer
logoPlane []uint32
params []byte
width int
height int
@@ -49,14 +47,6 @@ var _ FrameGenerator = (*WGPUGenerator)(nil)
// WGPUOption customizes NewWGPUGenerator.
type WGPUOption func(*WGPUGenerator)
// WithLogo attaches a packed logo plane (see BuildLogoPlane) as read-only
// storage binding 2 for kernels that sample it (v210_dvd_logo.wgsl).
func WithLogo(plane []uint32) WGPUOption {
return func(g *WGPUGenerator) {
g.logoPlane = plane
}
}
func NewWGPUGenerator(width, height uint, kernelPath string, opts ...WGPUOption) (*WGPUGenerator, error) {
g := &WGPUGenerator{
width: int(width),
@@ -121,48 +111,22 @@ func NewWGPUGenerator(width, height uint, kernelPath string, opts ...WGPUOption)
g.Close()
return nil, fmt.Errorf("wgpu: write params: %w", err)
}
bglEntries := []gputypes.BindGroupLayoutEntry{
{Binding: 0, Visibility: wgpu.ShaderStageCompute, Buffer: &gputypes.BufferBindingLayout{Type: gputypes.BufferBindingTypeStorage}},
{Binding: 1, Visibility: wgpu.ShaderStageCompute, Buffer: &gputypes.BufferBindingLayout{Type: gputypes.BufferBindingTypeUniform}},
}
bgEntries := []wgpu.BindGroupEntry{
{Binding: 0, Buffer: g.out, Size: g.frameSize},
{Binding: 1, Buffer: g.uniform, Size: uint64(len(g.params))},
}
if g.logoPlane != nil {
logoBytes := make([]byte, 4*len(g.logoPlane))
for i, v := range g.logoPlane {
binary.LittleEndian.PutUint32(logoBytes[4*i:], v)
}
if g.logo, err = g.device.CreateBuffer(&wgpu.BufferDescriptor{
Label: "v210-logo", Size: uint64(len(logoBytes)),
Usage: wgpu.BufferUsageStorage | wgpu.BufferUsageCopyDst,
}); err != nil {
g.Close()
return nil, fmt.Errorf("wgpu: logo buffer: %w", err)
}
if err := g.queue.WriteBuffer(g.logo, 0, logoBytes); err != nil {
g.Close()
return nil, fmt.Errorf("wgpu: write logo: %w", err)
}
bglEntries = append(bglEntries, gputypes.BindGroupLayoutEntry{
Binding: 2, Visibility: wgpu.ShaderStageCompute,
Buffer: &gputypes.BufferBindingLayout{Type: gputypes.BufferBindingTypeReadOnlyStorage},
})
bgEntries = append(bgEntries, wgpu.BindGroupEntry{
Binding: 2, Buffer: g.logo, Size: uint64(len(logoBytes)),
})
}
if g.bgl, err = g.device.CreateBindGroupLayout(&wgpu.BindGroupLayoutDescriptor{
Label: "v210-bgl",
Entries: bglEntries,
Label: "v210-bgl",
Entries: []gputypes.BindGroupLayoutEntry{
{Binding: 0, Visibility: wgpu.ShaderStageCompute, Buffer: &gputypes.BufferBindingLayout{Type: gputypes.BufferBindingTypeStorage}},
{Binding: 1, Visibility: wgpu.ShaderStageCompute, Buffer: &gputypes.BufferBindingLayout{Type: gputypes.BufferBindingTypeUniform}},
},
}); err != nil {
g.Close()
return nil, fmt.Errorf("wgpu: bind group layout: %w", err)
}
if g.bg, err = g.device.CreateBindGroup(&wgpu.BindGroupDescriptor{
Label: "v210-bg", Layout: g.bgl,
Entries: bgEntries,
Entries: []wgpu.BindGroupEntry{
{Binding: 0, Buffer: g.out, Size: g.frameSize},
{Binding: 1, Buffer: g.uniform, Size: uint64(len(g.params))},
},
}); err != nil {
g.Close()
return nil, fmt.Errorf("wgpu: bind group: %w", err)
@@ -254,10 +218,6 @@ func (g *WGPUGenerator) Close() error {
g.uniform.Release()
g.uniform = nil
}
if g.logo != nil {
g.logo.Release()
g.logo = nil
}
if g.host != nil {
g.host.Release()
g.host = nil