Hello,
Im am currently creating a metal renderer for our games.
I keep getting a crash that happens a few random seconds after the game has been running.
The exception occurs in [MTLRenderCommandEncoder setVertexBuffer]
{
....
[activePass.rce setVertexBuffer:hmm->getMetalVertexBuffer() offset:0 atIndex:0];
....
}
When debugging with zombie objects i get this output:
Thread 1: EXC_BREAKPOINT (code=1, subcode=0x21c47b6f4)
*** -[MTLDebugDepthStencilState isEqual:]: message sent to deallocated instance 0x2805bbe80
The depth stencil state of the render encoder seems to be getting dealocated.
The depth stencil state is being set directly with this code:
{
depthStencilDescriptor = [MTLDepthStencilDescriptor new];
[depthStencilDescriptor setDepthWriteEnabled: bDepthWrite];
[depthStencilDescriptor setDepthCompareFunction: bDepthTest ? metalDepthCompareFunc : MTLCompareFunctionAlways];
[activePass.rce setDepthStencilState:[metalDevice newDepthStencilStateWithDescriptor:depthStencilDescriptor]];
}
The code is contained in a c++ class compiled as objective-c++
activePass is defined as:
struct sPassInfo
{
public:
id rce;
MTLRenderPassDescriptor *pd;
zRenderPass rp;
};
Has anyone had any memory related problems with metal while compiling it as c++?
Any information would be appreciated, thanks ^_^