edubart/sokol_gp

Metal not working?

Quentie opened this issue · 3 comments

Hi @edubart thanks for this nice lib.
Unfortunately SOKOL_METAL rendering seems broken for me while SOKOL_GLCORE33 seems to work just fine :(

Steps to reproduce:

  1. I did copy https://github.com/edubart/sokol_gp#quick-usage-example into an empty xcode macOS project as an main.m Objective-C file.
  2. Changed head of file to:
// main.m
#define SOKOL_IMPL
// #define SOKOL_GLCORE33 // This works just fine
#define SOKOL_METAL // BUG: Metal breaks with current sokol_gp plus
#include "sokol_gfx.h"
...
  1. Bug:

Screenshot 2022-02-15 at 22 42 21

The Sokol GP code does not use custom depth stencil format when creating a pipeline, it lets Sokol choose the default depth format when creating a pipeline, so that error is strange. Looks like could be a bug in Sokol GFX or Sokol App.

Sokol GP has been tested and confirmed to work with Metal and Sokol GFX before, but without Sokol App.

Seems like this line is problematic on Metal:

sgdesc.context.depth_format = SG_PIXELFORMAT_NONE; // We don't need a depth frame buffer for 2D.

You could comment it and see if it works. The underlying issue here is that Sokol App does not support disabling depth and stencil buffer (not needed in 2D), I guess we need to leave it enabled anyway in Sokol GFX context when using Sokol App so things can work on Metal.

I've removed that line from the demos in commit 4a15519.

Let me know if things workout fine there.

@edubart Works like a charm. Thanks a lot!