internal/shaderlister: add SourceHash

This commit is contained in:
Hajime Hoshi 2024-11-17 15:44:51 +09:00
parent 53687aafb0
commit 960189b051

View File

@ -48,14 +48,15 @@ func main() {
} }
type Shader struct { type Shader struct {
Package string Package string
File string File string
Source string Source string
GLSL *GLSL `json:",omitempty"` SourceHash string
GLSLES *GLSLES `json:",omitempty"` GLSL *GLSL `json:",omitempty"`
HLSL *HLSL `json:",omitempty"` GLSLES *GLSLES `json:",omitempty"`
MSL *MSL `json:",omitempty"` HLSL *HLSL `json:",omitempty"`
PSSL *PSSL `json:",omitempty"` MSL *MSL `json:",omitempty"`
PSSL *PSSL `json:",omitempty"`
} }
type GLSL struct { type GLSL struct {
@ -125,6 +126,17 @@ func xmain() error {
origN := len(shaders) origN := len(shaders)
shaders = appendShaderSources(shaders, pkg) 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. // Compile shaders.
if len(targets) == 0 { if len(targets) == 0 {
return true return true