Comments (4)
There's a pretty big performance overhead with memory-managed command buffers unfortunately.
Best we could do is to add a Metal-specific config flag to sg_setup() which then just replaces the commandBufferWithUnretainedReferences
with commandBuffer
.
(e.g. next to mtl_force_managed_storage_mode
a mtl_use_retained_command_buffers
)
I would keep the resource life-time-extension code in place though even when retained command buffers are used to not have the two code paths diverge too much.
PS: that second retained command buffer I added in #762 didn't actually solve the problem in some cases btw. It might be that swapchain resources are already released by the command buffer before the swapchain code in MTKView is done with them (see #872)
from sokol.
Note: this will be fixed as 'drive-by-fix' in #985 via a new runtime config item sg_desc.mtl_use_command_buffer_with_retained_references
.
from sokol.
What is the overhead due to? Is it more than an increment and decrement of the refcount for each resource?
from sokol.
Here's an old blog post (2016), in a stress-test the overhead (measured in the Instruments CPU profiler) for refcounting (time spent in objc_retain and objc_release calls relative to all other executed code) dropped from 20% (!) to 7% just by switching to commandBufferWithUnretainedReferences
(the remaining 7% overhead could then be completely eliminated by only updating buffer offsets instead of "rebinding" buffers for each uniform update - those remaining 7% were mainly a side effect of using ARC though):
https://floooh.github.io/2016/01/14/metal-arc.html
If you just do a couple hundred draw calls, the refcounting overhead shouldn't matter much though (relative to the frame time at least).
(those findings were also the main reason why I changed the sokol headers to not require ARC anymore, because ARC needs so much hand holding to keep performance under control that manual refcounting is actually less hassle).
from sokol.
Related Issues (20)
- test
- Sokol Fetch Http response 200 is reported as an error HOT 7
- [sokol_gfx d3d11] update_image is wrong for 3d textures HOT 10
- Offscreen with alpha background. Is it possible? HOT 4
- [webgpu] Bindgroups cache breaks down with init/uninit pattern.
- macOS huge memory usage when window minimized HOT 1
- Questions regarding default GL version HOT 5
- App Window Size on Android HOT 3
- Default value _sg_gl_uniform_t::gl_loc when uniform_desc's name isn't given in sokol_gfx HOT 1
- sokol_gfx.h: wrong define in log related to SOKOL_TRACE_HOOKS HOT 1
- WebGPU TextureView validation error HOT 6
- sokol_fetch on Android
- partial updates to buffers/textures (e.g. offset and size args to glBufferSubData, glTexSubImage) HOT 1
- Right shift is recognized as "invalid key" on Windows. HOT 9
- SAPP_EVENT_CHAR for Space is fired when Ctrl+Space is pressed. HOT 2
- Key events on Linux always use the **first** keyboard layout in the system's keyboard layout list. HOT 1
- Continuous Bind Slots Restriction Unnecessary? HOT 3
- Feature request: Please drop the direct use of int, short, etc in favour of int_least32_t, int_least16_t HOT 9
- attributeless rendering support HOT 2
- WebGL Offscreen rending is broken in Chrome v127 on Mac M1 and MacOS 14.5. HOT 22
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.