Comments (5)
This isn't supported unfortunately. I had started to explore this idea in this abandondend multiwindow branch: https://github.com/floooh/sokol/tree/sapp-multiwindow, but was running into a lot of problems driving multiple MTKView in sokol_app.h in the same frame loop, the whole thing simply became too brittle before I gave up.
The sokol_gfx.h implementation would basically use the incomplete sg_context stuff (which currently only works for multiple GL contexts) and associate a context with each CAMetalLayer swapchain. But I also don't like this whole context idea anymore, it just doesn't quite fit into a "post-GL-API".
If I would ever revisit that idea, I would try to use regular pass objects instead which render into offscreen render targets, and then "somehow" blit those offscreen render targets into the various CAMetalLayer surfaces.
But this is definitely not at the top of the priority queue at the moment.
from sokol.
PS: if you're adventurous, you could try running multiple default-passes in one frame (like in this multiwindow-glfw sample: https://github.com/floooh/sokol-samples/blob/4e65abf8266911b124df931b674b65a6ec8fc4dd/glfw/multiwindow-glfw.c#L174-L199, but in the renderpass_descriptor_cb
and drawable_cb
callbacks which are passed into sokol-gfx the sg_setup()
function, return a different MTLRenderPassDescriptor
and MTLDrawable
object for each default pass, so that each default pass renders into a different MTLDrawable obtained from a CAMetalLayer object.
For this to work you need to abandon sokol_app.h completely and only use sokol_gfx.h with your own window system glue.
from sokol.
We're not using sokol_app.h, so the drawable_cb
approach may work for us. Thank you.
I was kind of curious why renderpass_descriptor_cb
exists though. Is it just for use with MTKView? Is there ever a situation that its implementation would be anything other than:
const void* get_render_pass_descriptor(void) {
MTLRenderPassDescriptor *pass = [MTLRenderPassDescriptor renderPassDescriptor];
pass.colorAttachments[0].texture = currentDrawable.texture;
return pass;
}
(please ignore the fact that pass
isn't retained anywhere, and that multiple calls to this function would create additional passes :) )
from sokol.
Yes, mainly because MTKView has a currentRenderPassDescriptor
convenience method.
In sokol-gfx I'm just expecting such a pre-configured render-pass-descriptor for the default pass because it also references all the resources needed for handling things like MSAA antialiasing in the default pass (the alternative would be to pass the currentDrawable along with a matching depth-stencil texture and optionally multi-sampled texture to sokol-gfx, and sokol-gfx would then setup its own render pass descriptor (like it happens for offscreen passes).
Without MTKView, you can just create the RenderPassDescriptor similar to your code snippet, but you also need to take care of the depth-stencil texture and MSAA texture and configure the RenderPassDescriptor as described here under 'Discussion': https://developer.apple.com/documentation/metalkit/mtkview/1536024-currentrenderpassdescriptor?language=objc
from sokol.
...this should now also be fixed with #985.
from sokol.
Related Issues (20)
- [sokol_imgui] Manage ImDrawCallback_ResetRenderState HOT 3
- [sokol_gfx] Array of struct uniform HOT 1
- WebGPU samples currently broken. HOT 1
- Regression: swapchains with depth (not depth/stencil) buffers currently broken in Metal. HOT 2
- [sokol_app] A call to GetIntegerv in _sapp_wgl_create_context leaves the stack corrupted HOT 8
- Dear ImGui touch input broken on mobile browsers HOT 11
- sokol_app.h html5: event bubbling followup fixes... HOT 1
- Ability to label command encoders HOT 8
- Possible bug in #define _SAPP_CLEAR_ARC_STRUCT(type, item) HOT 1
- Difference between sokol_app events `KEY_DOWN` and `CHAR` HOT 4
- WebGL2: Emsdk 3.1.52 no longer enables ETC2 and ASTC extensions by default. HOT 1
- Redundant buffer bindings on metal when only changing vertex buffer offset
- Use retained command buffer in sokol_gfx HOT 4
- sokol_app.h: Resize callback is never unregistered giving javascript errors HOT 3
- Mutliple `sg_apply_uniforms` in a pipeline influence other render target HOT 4
- fullscreen working every other time on gnome HOT 1
- Can't Set Float Uniform Variable HOT 3
- WebGPU backend broke in sg_make_pipeline() HOT 1
- [sokol_app] Status of clipboard support on X11? HOT 2
- The WebGL renderer does not produce the same output as the GLES renderer after updating to samplers. HOT 23
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sokol.