@@ -167,7 +167,8 @@ MTLBlendOperation toMTLBlendOperation(BlendOperation operation)
167167{
168168 struct
169169 {
170- void * program;
170+ size_t vertexShaderHash;
171+ size_t fragmentShaderHash;
171172 unsigned int vertexLayoutInfo[32 ];
172173 backend::PixelFormat colorAttachment;
173174 backend::PixelFormat depthAttachment;
@@ -185,7 +186,9 @@ MTLBlendOperation toMTLBlendOperation(BlendOperation operation)
185186 memset (&hashMe, 0 , sizeof (hashMe));
186187 const auto & blendDescriptor = pipelineDescirptor.blendDescriptor ;
187188 getAttachmentFormat (renderPassDescriptor, _colorAttachmentsFormat[0 ], _depthAttachmentFormat, _stencilAttachmentFormat);
188- hashMe.program = pipelineDescirptor.programState ->getProgram ();
189+ auto program = static_cast <ProgramMTL*>(pipelineDescirptor.programState ->getProgram ());
190+ hashMe.vertexShaderHash = program->getVertexShader ()->getHashValue ();
191+ hashMe.fragmentShaderHash = program->getFragmentShader ()->getHashValue ();
189192 hashMe.colorAttachment = _colorAttachmentsFormat[0 ];
190193 hashMe.depthAttachment = _depthAttachmentFormat;
191194 hashMe.stencilAttachment =_stencilAttachmentFormat;
@@ -215,8 +218,8 @@ MTLBlendOperation toMTLBlendOperation(BlendOperation operation)
215218 ((unsigned int )attribute.needToBeNormallized & 0x1 );
216219 }
217220
218- NSUInteger hash = XXH32 ((const void *)&hashMe, sizeof (hashMe), 0 );
219- NSNumber * key = [[ NSNumber numberWithUnsignedInteger: hash] autorelease ] ;
221+ unsigned int hash = XXH32 ((const void *)&hashMe, sizeof (hashMe), 0 );
222+ NSNumber * key = @( hash) ;
220223 id obj = [_mtlRenderPipelineStateCache objectForKey: key];
221224 if (obj != nil )
222225 {
0 commit comments