Comments (1)
Currently the only way to change SG_NUM_INFLIGHT_FRAMES is to patch the sokol header, I did it this way because that value unfortunately leaks into the public API (for instance here:
Line 2291 in d4ac122
This public API 'leakage' is also why it must be a comptime constant and can't be provided in sg_desc at startup.
If you decide to make this a preprocessor define which can be provided from the outside, you'll need to make sure that all places which include the header (not just the implementation) see the same define (so it should probably be provided on the compiler command line by the build system instead of relying on a #define
in code before the header is included.
Also make sure to check that this change doesn't increase frame latency.
Apart from that, as far as I can see the sokol_gfx.h 'frame management' code is identical with that Apple example code (except that kMaxInflightBuffers
is 2 instead of 3), but whether this longer 'pipeline' also increases latency depends on the CAMetalLayer swap strategy: if it works like Vulkan's FIFO
strategy it would increase latency, if it works like Mailbox
strategy, it would not, because if two frames are waiting for presentation it would pick the most recent one and discard the other.
Currently I don't want to make this change in the 'official' header though, because I don't like this 'NUM_INFLIGHT_FRAMES' constant in the first place. A "proper" fix would be to have a MAX_INFLIGHT_FRAMES
constant that cannot be changed and is set to something 'big enough for all use cases' like 4 and use that in the public API structs, while the actual num_inflight_frames
would be provided in sg_desc and must be <= MAX_INFLIGHT_FRAMES.
(PS: if you're 'workload' comfortably fits into the 8.333ms frame budget (for 120Hz), triple buffering shouldn't be needed, because then the CPU side always has enough wiggle room to provide the next frame in time before the next presentation needs to happen, and TBH I don't quite understand from that article why 3 buffers would be needed (instead of just 2) to prevent the GPU and CPU from trampling on each others feet (the GPU will read one buffer, while the CPU writes the next, and since the CPU is usually ready before the next vsync, the buffer that was just written by the CPU will already be ready at the start of the next frame for the GPU to read).
...but anyway, if you see any advantages with NUM_INFLIGHT_FRAMES = 3
let me know and we can figure something out :)
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.