Skip to content

Commit

Permalink
internal/shaderlister: bug fix: wrong shader hash
Browse files Browse the repository at this point in the history
Updates #3157
  • Loading branch information
hajimehoshi committed Feb 8, 2025
1 parent 5b551bb commit 3666920
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion internal/shaderlister/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func xmain() error {

// Add source hashes.
for i := range shaders[origN:] {
shader := &shaders[i]
shader := &shaders[origN+i]
hash, err := graphics.CalcSourceHash([]byte(shader.Source))
if err != nil {
visitErr = err
Expand Down
16 changes: 13 additions & 3 deletions internal/shaderlister/shaderlister_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import (
"slices"
"strings"
"testing"

"github.com/hajimehoshi/ebiten/v2/internal/graphics"
)

func hasGoCommand() bool {
Expand All @@ -46,9 +48,10 @@ func TestRun(t *testing.T) {
}

type shader struct {
Package string
File string
Source string
Package string
File string
Source string
SourceHash string
}
var shaders []shader
if err := json.Unmarshal(out, &shaders); err != nil {
Expand All @@ -70,6 +73,13 @@ func TestRun(t *testing.T) {
if s.File == "" {
t.Errorf("s.File is empty: %v", s)
}
hash, err := graphics.CalcSourceHash([]byte(s.Source))
if err != nil {
t.Fatal(err)
}
if got, want := s.SourceHash, hash.String(); got != want {
t.Errorf("s.SourceHash: got: %q, want: %q", got, want)
}
if got, want := s.Source, fmt.Sprintf("shader %d", i+1); got != want {
t.Errorf("s.Source: got: %q, want: %q", got, want)
}
Expand Down

0 comments on commit 3666920

Please sign in to comment.