mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08:54 +01:00
Revert "internal/shaderlister: compile shaders"
This reverts commit 848e30e0e7
.
Reason: test failures
This commit is contained in:
parent
848e30e0e7
commit
ab954c9c6e
@ -30,16 +30,8 @@ import (
|
||||
|
||||
"golang.org/x/tools/go/ast/inspector"
|
||||
"golang.org/x/tools/go/packages"
|
||||
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/graphics"
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/shaderir/glsl"
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/shaderir/hlsl"
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/shaderir/msl"
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/shaderir/pssl"
|
||||
)
|
||||
|
||||
var flagTarget = flag.String("target", "", "shader compilation targets separated by comma (e.g. 'glsl,glsles,hlsl,msl')")
|
||||
|
||||
func main() {
|
||||
if err := xmain(); err != nil {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
@ -51,40 +43,11 @@ type Shader struct {
|
||||
Package string
|
||||
File string
|
||||
Source string
|
||||
GLSL *GLSL `json:",omitempty"`
|
||||
GLSLES *GLSLES `json:",omitempty"`
|
||||
HLSL *HLSL `json:",omitempty"`
|
||||
MSL *MSL `json:",omitempty"`
|
||||
PSSL *PSSL `json:",omitempty"`
|
||||
}
|
||||
|
||||
type GLSL struct {
|
||||
Vertex string
|
||||
Fragment string
|
||||
}
|
||||
|
||||
type GLSLES struct {
|
||||
Vertex string
|
||||
Fragment string
|
||||
}
|
||||
|
||||
type HLSL struct {
|
||||
Vertex string
|
||||
Pixel string
|
||||
}
|
||||
|
||||
type MSL struct {
|
||||
Shader string
|
||||
}
|
||||
|
||||
type PSSL struct {
|
||||
Vertex string
|
||||
Pixel string
|
||||
}
|
||||
|
||||
func xmain() error {
|
||||
flag.Usage = func() {
|
||||
fmt.Fprintln(os.Stderr, "shaderlister [-target=TARGET] [package]")
|
||||
fmt.Fprintln(os.Stderr, "shaderlister [package]")
|
||||
os.Exit(2)
|
||||
}
|
||||
flag.Parse()
|
||||
@ -99,16 +62,10 @@ func xmain() error {
|
||||
return err
|
||||
}
|
||||
|
||||
targets := strings.Split(*flagTarget, ",")
|
||||
for i := range targets {
|
||||
targets[i] = strings.TrimSpace(targets[i])
|
||||
}
|
||||
|
||||
// Collect shader information.
|
||||
// Even if no shader is found, the output should be a JSON array. Start with an empty slice, not nil.
|
||||
shaders := []Shader{}
|
||||
|
||||
var visitErr error
|
||||
packages.Visit(pkgs, func(pkg *packages.Package) bool {
|
||||
path := pkg.PkgPath
|
||||
// A standard library should not have a directive for shaders. Skip them.
|
||||
@ -119,61 +76,9 @@ func xmain() error {
|
||||
if strings.HasPrefix(path, "golang.org/x/") {
|
||||
return true
|
||||
}
|
||||
|
||||
origN := len(shaders)
|
||||
shaders = appendShaderSources(shaders, pkg)
|
||||
|
||||
// Compile shaders.
|
||||
for i, shader := range shaders[origN:] {
|
||||
ir, err := graphics.CompileShader([]byte(shader.Source))
|
||||
if err != nil {
|
||||
visitErr = fmt.Errorf("compiling shader failed: %w", err)
|
||||
return false
|
||||
}
|
||||
|
||||
for _, target := range targets {
|
||||
switch target {
|
||||
case "glsl":
|
||||
vs, fs := glsl.Compile(ir, glsl.GLSLVersionDefault)
|
||||
shaders[origN+i].GLSL = &GLSL{
|
||||
Vertex: vs,
|
||||
Fragment: fs,
|
||||
}
|
||||
case "glsles":
|
||||
vs, fs := glsl.Compile(ir, glsl.GLSLVersionES300)
|
||||
shaders[origN+i].GLSLES = &GLSLES{
|
||||
Vertex: vs,
|
||||
Fragment: fs,
|
||||
}
|
||||
case "hlsl":
|
||||
vs, ps, _ := hlsl.Compile(ir)
|
||||
shaders[origN+i].HLSL = &HLSL{
|
||||
Vertex: vs,
|
||||
Pixel: ps,
|
||||
}
|
||||
case "msl":
|
||||
s := msl.Compile(ir)
|
||||
shaders[origN+i].MSL = &MSL{
|
||||
Shader: s,
|
||||
}
|
||||
case "pssl":
|
||||
vs, ps := pssl.Compile(ir)
|
||||
shaders[origN+i].PSSL = &PSSL{
|
||||
Vertex: vs,
|
||||
Pixel: ps,
|
||||
}
|
||||
default:
|
||||
visitErr = fmt.Errorf("unsupported target: %s", target)
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}, nil)
|
||||
if visitErr != nil {
|
||||
return visitErr
|
||||
}
|
||||
|
||||
w := bufio.NewWriter(os.Stdout)
|
||||
enc := json.NewEncoder(w)
|
||||
|
Loading…
Reference in New Issue
Block a user