Skip to content

Commit

Permalink
Add attributes to key
Browse files Browse the repository at this point in the history
  • Loading branch information
STREGA committed Oct 4, 2023
1 parent c34de4f commit 5c79107
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ class MetalRenderer: RendererBackend {
struct ShaderKey: Hashable {
let vshID: VertexShader.ID
let fshID: FragmentShader.ID
init(vsh: VertexShader, fsh: FragmentShader) {
let attributes: ContiguousArray<CodeGenerator.InputAttribute>
init(vsh: VertexShader, fsh: FragmentShader, attributes: ContiguousArray<CodeGenerator.InputAttribute>) {
self.vshID = vsh.id
self.fshID = fsh.id
self.attributes = attributes
}
}
struct MetalShader {
Expand Down Expand Up @@ -332,13 +334,13 @@ extension MetalRenderer {
geometries: [MetalGeometry],
flags: DrawFlags
) -> MetalShader {
let key = ShaderKey(vsh: vsh, fsh: fsh)
let attributes = MetalGeometry.shaderAttributes(from: geometries)
let key = ShaderKey(vsh: vsh, fsh: fsh, attributes: attributes)
if let existing = _shaders[key] {
return existing
}
do {
let generator = MSLCodeGenerator()
let attributes = MetalGeometry.shaderAttributes(from: geometries)
let source = try generator.generateShaderCode(
vertexShader: vsh,
fragmentShader: fsh,
Expand Down

0 comments on commit 5c79107

Please sign in to comment.