diff --git a/internal/graphicsdriver/directx/graphics11_windows.go b/internal/graphicsdriver/directx/graphics11_windows.go index 807009046..53035b2f6 100644 --- a/internal/graphicsdriver/directx/graphics11_windows.go +++ b/internal/graphicsdriver/directx/graphics11_windows.go @@ -24,7 +24,6 @@ import ( "github.com/hajimehoshi/ebiten/v2/internal/graphics" "github.com/hajimehoshi/ebiten/v2/internal/graphicsdriver" "github.com/hajimehoshi/ebiten/v2/internal/shaderir" - "github.com/hajimehoshi/ebiten/v2/internal/shaderir/hlsl" ) var inputElementDescsForDX11 = []_D3D11_INPUT_ELEMENT_DESC{ @@ -482,8 +481,7 @@ func (g *graphics11) MaxImageSize() int { } func (g *graphics11) NewShader(program *shaderir.Program) (graphicsdriver.Shader, error) { - vs, ps, offsets := hlsl.Compile(program) - vsh, psh, err := compileShader(vs, ps) + vsh, psh, offsets, err := compileShader(program) if err != nil { return nil, err } diff --git a/internal/graphicsdriver/directx/graphics12_windows.go b/internal/graphicsdriver/directx/graphics12_windows.go index 69740b90e..dae2f9c7f 100644 --- a/internal/graphicsdriver/directx/graphics12_windows.go +++ b/internal/graphicsdriver/directx/graphics12_windows.go @@ -25,7 +25,6 @@ import ( "github.com/hajimehoshi/ebiten/v2/internal/graphicsdriver" "github.com/hajimehoshi/ebiten/v2/internal/microsoftgdk" "github.com/hajimehoshi/ebiten/v2/internal/shaderir" - "github.com/hajimehoshi/ebiten/v2/internal/shaderir/hlsl" ) type resourceWithSize struct { @@ -1064,8 +1063,7 @@ func (g *graphics12) MaxImageSize() int { } func (g *graphics12) NewShader(program *shaderir.Program) (graphicsdriver.Shader, error) { - vs, ps, offsets := hlsl.Compile(program) - vsh, psh, err := compileShader(vs, ps) + vsh, psh, offsets, err := compileShader(program) if err != nil { return nil, err } diff --git a/internal/graphicsdriver/directx/shader_windows.go b/internal/graphicsdriver/directx/shader_windows.go index 3c3b7509a..cd197e28e 100644 --- a/internal/graphicsdriver/directx/shader_windows.go +++ b/internal/graphicsdriver/directx/shader_windows.go @@ -21,11 +21,13 @@ import ( "github.com/hajimehoshi/ebiten/v2/internal/graphics" "github.com/hajimehoshi/ebiten/v2/internal/shaderir" + "github.com/hajimehoshi/ebiten/v2/internal/shaderir/hlsl" ) var vertexShaderCache = map[string]*_ID3DBlob{} -func compileShader(vs, ps string) (vsh, psh *_ID3DBlob, ferr error) { +func compileShader(program *shaderir.Program) (vsh, psh *_ID3DBlob, uniformOffsets []int, ferr error) { + vs, ps, offsets := hlsl.Compile(program) var flag uint32 = uint32(_D3DCOMPILE_OPTIMIZATION_LEVEL3) defer func() { @@ -74,10 +76,10 @@ func compileShader(vs, ps string) (vsh, psh *_ID3DBlob, ferr error) { }) if err := wg.Wait(); err != nil { - return nil, nil, err + return nil, nil, nil, err } - return + return vsh, psh, offsets, nil } func constantBufferSize(uniformTypes []shaderir.Type, uniformOffsets []int) int {