mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 19:28:57 +01:00
internal/restorable: compile shaders in parallel
This commit is contained in:
parent
1b4f68d775
commit
71492554a7
@ -17,6 +17,8 @@ package restorable
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"golang.org/x/sync/errgroup"
|
||||||
|
|
||||||
"github.com/hajimehoshi/ebiten/v2/internal/builtinshader"
|
"github.com/hajimehoshi/ebiten/v2/internal/builtinshader"
|
||||||
"github.com/hajimehoshi/ebiten/v2/internal/graphics"
|
"github.com/hajimehoshi/ebiten/v2/internal/graphics"
|
||||||
"github.com/hajimehoshi/ebiten/v2/internal/graphicscommand"
|
"github.com/hajimehoshi/ebiten/v2/internal/graphicscommand"
|
||||||
@ -54,18 +56,24 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
{
|
var wg errgroup.Group
|
||||||
|
wg.Go(func() error {
|
||||||
ir, err := graphics.CompileShader([]byte(builtinshader.Shader(builtinshader.FilterNearest, builtinshader.AddressUnsafe, false)))
|
ir, err := graphics.CompileShader([]byte(builtinshader.Shader(builtinshader.FilterNearest, builtinshader.AddressUnsafe, false)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(fmt.Sprintf("restorable: compiling the nearest shader failed: %v", err))
|
return fmt.Errorf("restorable: compiling the nearest shader failed: %w", err)
|
||||||
}
|
}
|
||||||
NearestFilterShader = NewShader(ir)
|
NearestFilterShader = NewShader(ir)
|
||||||
}
|
return nil
|
||||||
{
|
})
|
||||||
|
wg.Go(func() error {
|
||||||
ir, err := graphics.CompileShader([]byte(builtinshader.Shader(builtinshader.FilterLinear, builtinshader.AddressUnsafe, false)))
|
ir, err := graphics.CompileShader([]byte(builtinshader.Shader(builtinshader.FilterLinear, builtinshader.AddressUnsafe, false)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(fmt.Sprintf("restorable: compiling the linear shader failed: %v", err))
|
return fmt.Errorf("restorable: compiling the linear shader failed: %w", err)
|
||||||
}
|
}
|
||||||
LinearFilterShader = NewShader(ir)
|
LinearFilterShader = NewShader(ir)
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
if err := wg.Wait(); err != nil {
|
||||||
|
panic(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user