MTLRenderCommandEncoder's setfragmenttexture does not update texture.

Hi, I have 7 rects with 7 different textures. I use single RenderCommandEncoder to bind each rect's texture to 0th index of my fragment function by calling setfragmenttexture as given below:

[ renderCommandEncoder setfragmenttexture:rects[i].mtltexture atIndex:0]

Then what happens rects[0], rects[1] get rendered with rects[0]'s texture and rects[2], rects[3] get rendered with rects[1]'s texture and so on.

While each rect must be rendered with own texture because I set it everytime in loop correctly. But it is not happening. I am not able to understand why setfragmenttexture is not updating correct texture. Please help me what could be the issue here ?

Replies

Hi guarav2289, I would suggest taking a look at our GPU tooling in Xcode. This WWDC session explains how to use GPU Frame capture. It might give you insight in what is happening in a frame in your application.

If the problem still occurs and it seems to be a Metal issue, please file a Feedback Assistant ticket with:

  • The macOS and/or iOS version version that was used for both development and running the application.
  • The Xcode version used for development.
  • If possible, a sample project that reproduces the issue for you.

If you file a ticket, please share the Feedback Assistant ID here.

  • Thanks for reply. anyway I found the issue in my code and fixed then after it is working fine. issue was that I am having single vertex buffer for my 7 rects and I was setting vertex offset for each rect because I know from where my rect's vertex data start in vertex buffer. same offset setting I am doing for index buffer of the 7 rects while calling drawindexedprimitives. when I removed offset setting in vertex buffer and always set it to 0 then it worked correctly.

  • one more thing my app is Xamarin based that links a static library written in c++,objective-c code so when I attach my Xamarin app process with Xcode then GPU capture frame feature is disabled . GPU frame capture only works when app is written in Xcode only not in xamarin using visual studio Mac . I really want to see GPU frame for my Xamarin app so please tell me any other way or any other tool for it.

  • Unfortunately we cannot offer support for Xamarin based apps but we do have APIs in Metal that allow frame capture to be done programmatically. This article explains how to use it.