ebiten: add BenchmarkBuiltinShader

This commit is contained in:
Hajime Hoshi 2024-10-27 00:12:56 +09:00
parent 6cf235daef
commit 04c9a802a7
2 changed files with 15 additions and 0 deletions

View File

@ -14,6 +14,12 @@
package ebiten package ebiten
import "github.com/hajimehoshi/ebiten/v2/internal/builtinshader"
var ( var (
ImageToBytes = imageToBytes ImageToBytes = imageToBytes
) )
func BuiltinShader(filter builtinshader.Filter, address builtinshader.Address, useColorM bool) *Shader {
return builtinShader(filter, address, useColorM)
}

View File

@ -22,6 +22,7 @@ import (
"testing" "testing"
"github.com/hajimehoshi/ebiten/v2" "github.com/hajimehoshi/ebiten/v2"
"github.com/hajimehoshi/ebiten/v2/internal/builtinshader"
) )
func TestShaderFill(t *testing.T) { func TestShaderFill(t *testing.T) {
@ -2818,3 +2819,11 @@ func Fragment(dstPos vec4, srcPos vec2, color vec4) vec4 {
} }
} }
} }
func BenchmarkBuiltinShader(b *testing.B) {
// Create a shader to cache the shader compilation result.
_ = ebiten.BuiltinShader(builtinshader.FilterNearest, builtinshader.AddressUnsafe, false)
for i := 0; i < b.N; i++ {
_ = ebiten.BuiltinShader(builtinshader.FilterNearest, builtinshader.AddressUnsafe, false)
}
}