@@ -339,13 +339,31 @@ module ShaderProgram =
339339 let hash = pickler.ComputeHash value
340340 hash.Hash |> Guid |> string
341341
342- let ofEffectKey ( key : EffectCacheKey ) =
343- let colors = key.layout.ColorAttachments |> Map.map ( fun _ att -> string att.Name)
344- let depth = key.layout.DepthStencilAttachment
345- if key.layout.LayerCount > 1 then
346- getHash ( key.effect.Id, key.topology, colors, depth, key.layout.LayerCount, key.layout.PerLayerUniforms, FShadeConfig.depthRange)
347- else
348- getHash ( key.effect.Id, colors, depth, FShadeConfig.depthRange)
342+ type private ShaderSignature =
343+ { id : string
344+ debug : bool
345+ optimized : bool
346+ outputs : Map < int , string * TextureFormat >
347+ layered : Set < string >
348+ layerCount : int
349+ depthRange : Range1d }
350+
351+ let ofEffectKey ( device : Device ) ( key : EffectCacheKey ) =
352+ let signature =
353+ let outputs = key.layout.ColorAttachments |> Map.map ( fun _ att -> string att.Name, att.Format)
354+
355+ { id = key.effect.Id
356+ debug = device.DebugConfig.GenerateShaderDebugInfo
357+ optimized = device.DebugConfig.OptimizeShaders
358+ outputs = outputs
359+ layered = key.layout.PerLayerUniforms
360+ layerCount = key.layout.LayerCount
361+ depthRange = FShadeConfig.depthRange }
362+
363+ getHash signature
364+
365+ let ofEffectId ( device : Device ) ( id : string ) =
366+ getHash ( id, device.DebugConfig.GenerateShaderDebugInfo, device.DebugConfig.OptimizeShaders)
349367
350368 let ofString ( value : string ) =
351369 getHash value
@@ -590,7 +608,7 @@ module ShaderProgram =
590608 match device.ShaderCachePath with
591609 | Some shaderCachePath ->
592610 let cacheFile =
593- let name = FileCacheName.ofEffectKey key
611+ let name = FileCacheName.ofEffectKey device key
594612 Path.Combine( shaderCachePath, name + " .effect" )
595613
596614 match tryRead None cacheFile device with
0 commit comments