diff --git a/export_test.go b/export_test.go index affa4ce57..cb0d08767 100644 --- a/export_test.go +++ b/export_test.go @@ -14,6 +14,12 @@ package ebiten +import "github.com/hajimehoshi/ebiten/v2/internal/builtinshader" + var ( ImageToBytes = imageToBytes ) + +func BuiltinShader(filter builtinshader.Filter, address builtinshader.Address, useColorM bool) *Shader { + return builtinShader(filter, address, useColorM) +} diff --git a/shader_test.go b/shader_test.go index e49eab1f4..954838ee5 100644 --- a/shader_test.go +++ b/shader_test.go @@ -22,6 +22,7 @@ import ( "testing" "github.com/hajimehoshi/ebiten/v2" + "github.com/hajimehoshi/ebiten/v2/internal/builtinshader" ) 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) + } +}