refactoring finished

This commit is contained in:
Dmitry Sergeev
2026-09-17 20:42:38 +03:00
parent de4dfcf101
commit e30cb7a168
11 changed files with 92 additions and 48 deletions
+2 -8
View File
@@ -6,7 +6,6 @@ import (
"context"
"encoding/binary"
"fmt"
"os"
"time"
"github.com/gogpu/gputypes"
@@ -47,7 +46,7 @@ var _ FrameGenerator = (*WGPUGenerator)(nil)
// WGPUOption customizes NewWGPUGenerator.
type WGPUOption func(*WGPUGenerator)
func NewWGPUGenerator(width, height uint, kernelPath string, opts ...WGPUOption) (*WGPUGenerator, error) {
func NewWGPUGenerator(width, height uint, wgsl string, opts ...WGPUOption) (*WGPUGenerator, error) {
g := &WGPUGenerator{
width: int(width),
height: int(height),
@@ -75,13 +74,8 @@ func NewWGPUGenerator(width, height uint, kernelPath string, opts ...WGPUOption)
}
g.queue = g.device.Queue()
wgsl, err := os.ReadFile(kernelPath)
if err != nil {
g.Close()
return nil, fmt.Errorf("wgpu: read kernel: %w", err)
}
if g.shader, err = g.device.CreateShaderModule(&wgpu.ShaderModuleDescriptor{
Label: "v210-shader", WGSL: string(wgsl),
Label: "v210-shader", WGSL: wgsl,
}); err != nil {
g.Close()
return nil, fmt.Errorf("wgpu: shader: %w", err)