mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08:54 +01:00
internal/shaderir: rename TextureNum to TextureCount
This commit is contained in:
parent
88e5d5e059
commit
88fe3d1287
@ -180,7 +180,7 @@ func (p *ParseError) Error() string {
|
|||||||
return strings.Join(p.errs, "\n")
|
return strings.Join(p.errs, "\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
func Compile(fs *token.FileSet, f *ast.File, vertexEntry, fragmentEntry string, textureNum int) (*shaderir.Program, error) {
|
func Compile(fs *token.FileSet, f *ast.File, vertexEntry, fragmentEntry string, textureCount int) (*shaderir.Program, error) {
|
||||||
s := &compileState{
|
s := &compileState{
|
||||||
fs: fs,
|
fs: fs,
|
||||||
vertexEntry: vertexEntry,
|
vertexEntry: vertexEntry,
|
||||||
@ -198,7 +198,7 @@ func Compile(fs *token.FileSet, f *ast.File, vertexEntry, fragmentEntry string,
|
|||||||
|
|
||||||
// TODO: Make a call graph and reorder the elements.
|
// TODO: Make a call graph and reorder the elements.
|
||||||
|
|
||||||
s.ir.TextureNum = textureNum
|
s.ir.TextureCount = textureCount
|
||||||
return &s.ir, nil
|
return &s.ir, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,12 +128,12 @@ func Compile(p *shaderir.Program, version GLSLVersion) (vertexShader, fragmentSh
|
|||||||
{
|
{
|
||||||
vslines = append(vslines, strings.Split(VertexPrelude(version), "\n")...)
|
vslines = append(vslines, strings.Split(VertexPrelude(version), "\n")...)
|
||||||
vslines = append(vslines, "", "{{.Structs}}")
|
vslines = append(vslines, "", "{{.Structs}}")
|
||||||
if len(p.Uniforms) > 0 || p.TextureNum > 0 || len(p.Attributes) > 0 || len(p.Varyings) > 0 {
|
if len(p.Uniforms) > 0 || p.TextureCount > 0 || len(p.Attributes) > 0 || len(p.Varyings) > 0 {
|
||||||
vslines = append(vslines, "")
|
vslines = append(vslines, "")
|
||||||
for i, t := range p.Uniforms {
|
for i, t := range p.Uniforms {
|
||||||
vslines = append(vslines, fmt.Sprintf("uniform %s;", c.varDecl(p, &t, fmt.Sprintf("U%d", i))))
|
vslines = append(vslines, fmt.Sprintf("uniform %s;", c.varDecl(p, &t, fmt.Sprintf("U%d", i))))
|
||||||
}
|
}
|
||||||
for i := 0; i < p.TextureNum; i++ {
|
for i := 0; i < p.TextureCount; i++ {
|
||||||
vslines = append(vslines, fmt.Sprintf("uniform sampler2D T%d;", i))
|
vslines = append(vslines, fmt.Sprintf("uniform sampler2D T%d;", i))
|
||||||
}
|
}
|
||||||
for i, t := range p.Attributes {
|
for i, t := range p.Attributes {
|
||||||
@ -225,12 +225,12 @@ func Compile(p *shaderir.Program, version GLSLVersion) (vertexShader, fragmentSh
|
|||||||
{
|
{
|
||||||
fslines = append(fslines, strings.Split(FragmentPrelude(version), "\n")...)
|
fslines = append(fslines, strings.Split(FragmentPrelude(version), "\n")...)
|
||||||
fslines = append(fslines, "", "{{.Structs}}")
|
fslines = append(fslines, "", "{{.Structs}}")
|
||||||
if len(p.Uniforms) > 0 || p.TextureNum > 0 || len(p.Varyings) > 0 {
|
if len(p.Uniforms) > 0 || p.TextureCount > 0 || len(p.Varyings) > 0 {
|
||||||
fslines = append(fslines, "")
|
fslines = append(fslines, "")
|
||||||
for i, t := range p.Uniforms {
|
for i, t := range p.Uniforms {
|
||||||
fslines = append(fslines, fmt.Sprintf("uniform %s;", c.varDecl(p, &t, fmt.Sprintf("U%d", i))))
|
fslines = append(fslines, fmt.Sprintf("uniform %s;", c.varDecl(p, &t, fmt.Sprintf("U%d", i))))
|
||||||
}
|
}
|
||||||
for i := 0; i < p.TextureNum; i++ {
|
for i := 0; i < p.TextureCount; i++ {
|
||||||
fslines = append(fslines, fmt.Sprintf("uniform sampler2D T%d;", i))
|
fslines = append(fslines, fmt.Sprintf("uniform sampler2D T%d;", i))
|
||||||
}
|
}
|
||||||
for i, t := range p.Varyings {
|
for i, t := range p.Varyings {
|
||||||
|
@ -111,9 +111,9 @@ func Compile(p *shaderir.Program) (string, []int) {
|
|||||||
}
|
}
|
||||||
lines = append(lines, "}")
|
lines = append(lines, "}")
|
||||||
}
|
}
|
||||||
if p.TextureNum > 0 {
|
if p.TextureCount > 0 {
|
||||||
lines = append(lines, "")
|
lines = append(lines, "")
|
||||||
for i := 0; i < p.TextureNum; i++ {
|
for i := 0; i < p.TextureCount; i++ {
|
||||||
lines = append(lines, fmt.Sprintf("Texture2D T%[1]d : register(t%[1]d);", i))
|
lines = append(lines, fmt.Sprintf("Texture2D T%[1]d : register(t%[1]d);", i))
|
||||||
}
|
}
|
||||||
lines = append(lines, "SamplerState samp : register(s0);")
|
lines = append(lines, "SamplerState samp : register(s0);")
|
||||||
|
@ -109,7 +109,7 @@ func Compile(p *shaderir.Program, vertex, fragment string) (shader string) {
|
|||||||
lines[len(lines)-1] += ","
|
lines[len(lines)-1] += ","
|
||||||
lines = append(lines, fmt.Sprintf("\tconstant %s [[buffer(%d)]]", c.varDecl(p, &u, fmt.Sprintf("U%d", i), true), i+1))
|
lines = append(lines, fmt.Sprintf("\tconstant %s [[buffer(%d)]]", c.varDecl(p, &u, fmt.Sprintf("U%d", i), true), i+1))
|
||||||
}
|
}
|
||||||
for i := 0; i < p.TextureNum; i++ {
|
for i := 0; i < p.TextureCount; i++ {
|
||||||
lines[len(lines)-1] += ","
|
lines[len(lines)-1] += ","
|
||||||
lines = append(lines, fmt.Sprintf("\ttexture2d<float> T%[1]d [[texture(%[1]d)]]", i))
|
lines = append(lines, fmt.Sprintf("\ttexture2d<float> T%[1]d [[texture(%[1]d)]]", i))
|
||||||
}
|
}
|
||||||
@ -131,7 +131,7 @@ func Compile(p *shaderir.Program, vertex, fragment string) (shader string) {
|
|||||||
lines[len(lines)-1] += ","
|
lines[len(lines)-1] += ","
|
||||||
lines = append(lines, fmt.Sprintf("\tconstant %s [[buffer(%d)]]", c.varDecl(p, &u, fmt.Sprintf("U%d", i), true), i+1))
|
lines = append(lines, fmt.Sprintf("\tconstant %s [[buffer(%d)]]", c.varDecl(p, &u, fmt.Sprintf("U%d", i), true), i+1))
|
||||||
}
|
}
|
||||||
for i := 0; i < p.TextureNum; i++ {
|
for i := 0; i < p.TextureCount; i++ {
|
||||||
lines[len(lines)-1] += ","
|
lines[len(lines)-1] += ","
|
||||||
lines = append(lines, fmt.Sprintf("\ttexture2d<float> T%[1]d [[texture(%[1]d)]]", i))
|
lines = append(lines, fmt.Sprintf("\ttexture2d<float> T%[1]d [[texture(%[1]d)]]", i))
|
||||||
}
|
}
|
||||||
@ -220,7 +220,7 @@ func (c *compileContext) function(p *shaderir.Program, f *shaderir.Func, prototy
|
|||||||
for i, u := range p.Uniforms {
|
for i, u := range p.Uniforms {
|
||||||
args = append(args, "constant "+c.varDecl(p, &u, fmt.Sprintf("U%d", i), true))
|
args = append(args, "constant "+c.varDecl(p, &u, fmt.Sprintf("U%d", i), true))
|
||||||
}
|
}
|
||||||
for i := 0; i < p.TextureNum; i++ {
|
for i := 0; i < p.TextureCount; i++ {
|
||||||
args = append(args, fmt.Sprintf("texture2d<float> T%d", i))
|
args = append(args, fmt.Sprintf("texture2d<float> T%d", i))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -388,7 +388,7 @@ func (c *compileContext) block(p *shaderir.Program, topBlock, block *shaderir.Bl
|
|||||||
for i := range p.Uniforms {
|
for i := range p.Uniforms {
|
||||||
args = append(args, fmt.Sprintf("U%d", i))
|
args = append(args, fmt.Sprintf("U%d", i))
|
||||||
}
|
}
|
||||||
for i := 0; i < p.TextureNum; i++ {
|
for i := 0; i < p.TextureCount; i++ {
|
||||||
args = append(args, fmt.Sprintf("T%d", i))
|
args = append(args, fmt.Sprintf("T%d", i))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ import (
|
|||||||
type Program struct {
|
type Program struct {
|
||||||
UniformNames []string
|
UniformNames []string
|
||||||
Uniforms []Type
|
Uniforms []Type
|
||||||
TextureNum int
|
TextureCount int
|
||||||
Attributes []Type
|
Attributes []Type
|
||||||
Varyings []Type
|
Varyings []Type
|
||||||
Funcs []Func
|
Funcs []Func
|
||||||
|
Loading…
Reference in New Issue
Block a user