Skip to content

Commit

Permalink
internal/shaderlister: add SourceHash
Browse files Browse the repository at this point in the history
  • Loading branch information
hajimehoshi committed Nov 17, 2024
1 parent 53687aa commit 960189b
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions internal/shaderlister/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,15 @@ func main() {
}

type Shader struct {
Package string
File string
Source string
GLSL *GLSL `json:",omitempty"`
GLSLES *GLSLES `json:",omitempty"`
HLSL *HLSL `json:",omitempty"`
MSL *MSL `json:",omitempty"`
PSSL *PSSL `json:",omitempty"`
Package string
File string
Source string
SourceHash string
GLSL *GLSL `json:",omitempty"`
GLSLES *GLSLES `json:",omitempty"`
HLSL *HLSL `json:",omitempty"`
MSL *MSL `json:",omitempty"`
PSSL *PSSL `json:",omitempty"`
}

type GLSL struct {
Expand Down Expand Up @@ -125,6 +126,17 @@ func xmain() error {
origN := len(shaders)
shaders = appendShaderSources(shaders, pkg)

// Add source hashes.
for i := range shaders[origN:] {
shader := &shaders[i]
hash, err := graphics.CalcSourceHash([]byte(shader.Source))
if err != nil {
visitErr = err
return false
}
shader.SourceHash = hash.String()
}

// Compile shaders.
if len(targets) == 0 {
return true
Expand Down

0 comments on commit 960189b

Please sign in to comment.