diff options
| author | Andre Weissflog <floooh@gmail.com> | 2024-02-10 15:32:51 +0100 |
|---|---|---|
| committer | Andre Weissflog <floooh@gmail.com> | 2024-02-10 15:32:51 +0100 |
| commit | 73b5ed982b786a9dec86557d5052c95fde7bbb04 (patch) | |
| tree | 0fd3dff409975aef53a4cd2f047723f7777f0542 | |
| parent | 5fe244ea585a432806e8f2aeeab9e4b9003af921 (diff) | |
| parent | a40c4460c9383228726efcb9f5b96abc996ba0fe (diff) | |
Merge branch 'master' into issue904-pass-cleanup
| -rw-r--r-- | CHANGELOG.md | 25 | ||||
| -rw-r--r-- | bindgen/gen_rust.py | 2 | ||||
| -rw-r--r-- | sokol_app.h | 21 | ||||
| -rw-r--r-- | sokol_gfx.h | 20 | ||||
| -rw-r--r-- | sokol_time.h | 2 | ||||
| -rw-r--r-- | tests/functional/sokol_gfx_test.c | 2 | ||||
| -rw-r--r-- | util/sokol_debugtext.h | 8 | ||||
| -rw-r--r-- | util/sokol_gfx_imgui.h | 2 | ||||
| -rw-r--r-- | util/sokol_gl.h | 2 | ||||
| -rw-r--r-- | util/sokol_imgui.h | 2 | ||||
| -rw-r--r-- | util/sokol_nuklear.h | 2 | ||||
| -rw-r--r-- | util/sokol_spine.h | 2 |
12 files changed, 65 insertions, 25 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 42a7d712..ad5f8e5c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,24 @@ ## Updates +#### 31-Jan-2024: + +- sokol_app.h macOS: merged a workaround for the application window not being focused + if the init callback takes a while (not reproducible on my M1 Mac with latest Sonoma, + but might fix the issue for older Macs, and the change seems harmless enough - + sokol_app.h essentially sends a focusEvent to itself) + + Related issue: https://github.com/floooh/sokol/issues/757 + Implemented in PR: https://github.com/floooh/sokol/pull/982 + + Many thanks to @zoo-3d for investigating the issue and the PR! + +#### 28-Jan-2024: + +- sokol_app.h web: the canvas resize callback is now unregistered on cleanup. + + Related issue: https://github.com/floooh/sokol/issues/983 and PR: https://github.com/floooh/sokol/pull/984 + Many thanks to @edubart! + #### 27-Jan-2024 - sokol_app.h web: The HTML5 event bubbling changes introduced in the 02-Jan-2024 @@ -299,7 +318,7 @@ The major topic of this update is the 'finalized' WebGPU support in sokol_gfx.h `sg_frame_stats` returned by the new sokol_gfx.h function `sg_query_frame_stats()`. - The sokol-samples repository gained 3 new samples: - - cubemap-jpeg-sapp.c (load a cubemap from seperate JPEG files) + - cubemap-jpeg-sapp.c (load a cubemap from separate JPEG files) - cubemaprt-sapp.c (render into cubemap faces - this demo actually existed a while but wasn't "official" so far) - drawcallperf-sapp.c (a sample to explore the performance overhead of sg_apply_bindings, sg_apply_uniforms and sg_draw) @@ -871,7 +890,7 @@ GLES2/WebGL1 support has been removed from the sokol headers (now that A new header ```sokol_log.h``` has been added to provide a standard logging callback implementation which provides logging output on all platforms to stderr and/or platform specific logging facilities. ```sokol_log.h``` only uses fputs() and platform specific logging function instead - of fprintf() to preverse some executable size. + of fprintf() to preserve some executable size. **QUESTION**: Why are the sokol headers now silent, unless a logging callback is installed? This is mainly because a standard logging function which does something meaningful on all @@ -1356,7 +1375,7 @@ so that it's easier to publish new bindings after updates to the sokol headers). of uniform block members. The default (SG_UNIFORMLAYOUT_NATIVE) keeps the same behaviour, so existing code shouldn't need to be changed. With the packing rule SG_UNIFORMLAYOUT_STD140 the uniform block interior is expected to be - layed out according to the OpenGL std140 packing rule. + laid out according to the OpenGL std140 packing rule. - Note that the SG_UNIFORMLAYOUT_STD140 only allows a subset of the actual std140 packing rule: arrays are only allowed for the types vec4, int4 and mat4. This is because the uniform data must still be compatible with diff --git a/bindgen/gen_rust.py b/bindgen/gen_rust.py index 9349152b..af83789b 100644 --- a/bindgen/gen_rust.py +++ b/bindgen/gen_rust.py @@ -600,7 +600,7 @@ def gen_consts(decl, prefix): for item in decl["items"]: # # TODO: What type should these constants have? Currently giving all `usize` - # unless specifically overriden by `special_constant_types` + # unless specifically overridden by `special_constant_types` # item_name = check_override(item["name"]) diff --git a/sokol_app.h b/sokol_app.h index 6c998c55..f55e57fd 100644 --- a/sokol_app.h +++ b/sokol_app.h @@ -1624,7 +1624,7 @@ typedef struct sapp_allocator { _SAPP_LOGITEM_XMACRO(ANDROID_NATIVE_ACTIVITY_DONE, "NativeActivity done") \ _SAPP_LOGITEM_XMACRO(ANDROID_NATIVE_ACTIVITY_ONCREATE, "NativeActivity onCreate") \ _SAPP_LOGITEM_XMACRO(ANDROID_CREATE_THREAD_PIPE_FAILED, "failed to create thread pipe") \ - _SAPP_LOGITEM_XMACRO(ANDROID_NATIVE_ACTIVITY_CREATE_SUCCESS, "NativeActivity sucessfully created") \ + _SAPP_LOGITEM_XMACRO(ANDROID_NATIVE_ACTIVITY_CREATE_SUCCESS, "NativeActivity successfully created") \ _SAPP_LOGITEM_XMACRO(WGPU_SWAPCHAIN_CREATE_SURFACE_FAILED, "wgpu: failed to create surface for swapchain") \ _SAPP_LOGITEM_XMACRO(WGPU_SWAPCHAIN_CREATE_SWAPCHAIN_FAILED, "wgpu: failed to create swapchain object") \ _SAPP_LOGITEM_XMACRO(WGPU_SWAPCHAIN_CREATE_DEPTH_STENCIL_TEXTURE_FAILED, "wgpu: failed to create depth-stencil texture for swapchain") \ @@ -1812,7 +1812,7 @@ SOKOL_APP_API_DECL sapp_desc sapp_query_desc(void); SOKOL_APP_API_DECL void sapp_request_quit(void); /* cancel a pending quit (when SAPP_EVENTTYPE_QUIT_REQUESTED has been received) */ SOKOL_APP_API_DECL void sapp_cancel_quit(void); -/* initiate a "hard quit" (quit application without sending SAPP_EVENTTYPE_QUIT_REQUSTED) */ +/* initiate a "hard quit" (quit application without sending SAPP_EVENTTYPE_QUIT_REQUESTED) */ SOKOL_APP_API_DECL void sapp_quit(void); /* call from inside event callback to consume the current event (don't forward to platform) */ SOKOL_APP_API_DECL void sapp_consume_event(void); @@ -3951,6 +3951,20 @@ _SOKOL_PRIVATE void _sapp_macos_frame(void) { [_sapp.macos.window makeKeyAndOrderFront:nil]; _sapp_macos_update_dimensions(); [NSEvent setMouseCoalescingEnabled:NO]; + + // workaround for window not being focused during a long init callback + // for details see: https://github.com/floooh/sokol/pull/982 + // also see: https://gitlab.gnome.org/GNOME/gtk/-/issues/2342 + NSEvent *focusevent = [NSEvent otherEventWithType:NSEventTypeAppKitDefined + location:NSZeroPoint + modifierFlags:0x40 + timestamp:0 + windowNumber:0 + context:nil + subtype:NSEventSubtypeApplicationActivated + data1:0 + data2:0]; + [NSApp postEvent:focusevent atStart:YES]; } - (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication*)sender { @@ -5821,6 +5835,9 @@ _SOKOL_PRIVATE void _sapp_emsc_unregister_eventhandlers(void) { emscripten_set_pointerlockerror_callback(EMSCRIPTEN_EVENT_TARGET_DOCUMENT, 0, true, 0); emscripten_set_focus_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, 0, true, 0); emscripten_set_blur_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, 0, true, 0); + if (!_sapp.desc.html5_canvas_resize) { + emscripten_set_resize_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, 0, true, 0); + } sapp_js_remove_beforeunload_listener(); if (_sapp.clipboard.enabled) { sapp_js_remove_clipboard_listener(); diff --git a/sokol_gfx.h b/sokol_gfx.h index 822c2e7b..ee56f77e 100644 --- a/sokol_gfx.h +++ b/sokol_gfx.h @@ -720,7 +720,7 @@ texture-sample-type with the correct sampler-type). For GLSL an additional 'combined-image-sampler name' must be provided because 'OpenGL style GLSL' cannot handle separate texture and sampler objects, but still - groups them into a tradtional GLSL 'sampler object'. + groups them into a traditional GLSL 'sampler object'. Compatibility rules for image-sample-type vs sampler-type are as follows: @@ -2892,7 +2892,7 @@ typedef struct sg_pipeline_desc { sg_make_pass() function. A pass object contains 1..4 color attachments, 0..4 msaa-resolve - attachemnts, and none or one depth-stencil attachment. + attachments, and none or one depth-stencil attachment. Each attachment consists of an image, and two additional indices describing which subimage the pass will render into: one mipmap index, and if the image @@ -3621,7 +3621,7 @@ typedef enum sg_log_item { the more likely are cache slot collisions which will cause a BindGroups object to be destroyed and a new one created. Use the information returned by sg_query_stats() to check - if this is a frequent occurence, and increase the cache size as + if this is a frequent occurrence, and increase the cache size as needed (the default is 1024). NOTE: wgpu_bindgroups_cache_size must be a power-of-2 number! .context.wgpu.device @@ -3887,7 +3887,7 @@ typedef struct sg_d3d11_sampler_info { typedef struct sg_d3d11_shader_info { const void* vs_cbufs[SG_MAX_SHADERSTAGE_UBS]; // ID3D11Buffer* (vertex stage constant buffers) - const void* fs_cbufs[SG_MAX_SHADERSTAGE_UBS]; // ID3D11BUffer* (fragment stage constant buffers) + const void* fs_cbufs[SG_MAX_SHADERSTAGE_UBS]; // ID3D11Buffer* (fragment stage constant buffers) const void* vs; // ID3D11VertexShader* const void* fs; // ID3D11PixelShader* } sg_d3d11_shader_info; @@ -4023,7 +4023,7 @@ SOKOL_GFX_API_DECL const void* sg_wgpu_device(void); SOKOL_GFX_API_DECL const void* sg_wgpu_queue(void); // WebGPU: return this frame's WGPUCommandEncoder SOKOL_GFX_API_DECL const void* sg_wgpu_command_encoder(void); -// WebGPU: return WGPURenderPassEncoder of currrent pass +// WebGPU: return WGPURenderPassEncoder of current pass SOKOL_GFX_API_DECL const void* sg_wgpu_render_pass_encoder(void); // WebGPU: get internal buffer resource objects SOKOL_GFX_API_DECL sg_wgpu_buffer_info sg_wgpu_query_buffer_info(sg_buffer buf); @@ -5342,7 +5342,7 @@ typedef struct { } _sg_mtl_attachments_t; typedef _sg_mtl_attachments_t _sg_attachments_t; -// resouce binding state cache +// resource binding state cache typedef struct { const _sg_pipeline_t* cur_pipeline; sg_pipeline cur_pipeline_id; @@ -8295,7 +8295,7 @@ _SOKOL_PRIVATE sg_resource_state _sg_gl_create_attachments(_sg_attachments_t* at _sg_gl_fb_attach_texture(&atts->gl.colors[i], &atts->cmn.colors[i], gl_att_type); } } - // attach depth-stencil attachement + // attach depth-stencil attachment if (atts->gl.depth_stencil.image) { const GLenum gl_att = _sg_gl_depth_stencil_attachment_type(&atts->gl.depth_stencil); const _sg_image_t* ds_img = atts->gl.depth_stencil.image; @@ -11777,7 +11777,7 @@ _SOKOL_PRIVATE void _sg_mtl_copy_image_data(const _sg_image_t* img, __unsafe_unr } } -// initialize MTLTextureDescritor with common attributes +// initialize MTLTextureDescriptor with common attributes _SOKOL_PRIVATE bool _sg_mtl_init_texdesc_common(MTLTextureDescriptor* mtl_desc, _sg_image_t* img) { mtl_desc.textureType = _sg_mtl_texture_type(img->cmn.type); mtl_desc.pixelFormat = _sg_mtl_pixel_format(img->cmn.pixel_format); @@ -11808,7 +11808,7 @@ _SOKOL_PRIVATE bool _sg_mtl_init_texdesc_common(MTLTextureDescriptor* mtl_desc, return true; } -// initialize MTLTextureDescritor with rendertarget attributes +// initialize MTLTextureDescriptor with rendertarget attributes _SOKOL_PRIVATE void _sg_mtl_init_texdesc_rt(MTLTextureDescriptor* mtl_desc, _sg_image_t* img) { SOKOL_ASSERT(img->cmn.render_target); _SOKOL_UNUSED(img); @@ -11816,7 +11816,7 @@ _SOKOL_PRIVATE void _sg_mtl_init_texdesc_rt(MTLTextureDescriptor* mtl_desc, _sg_ mtl_desc.resourceOptions = MTLResourceStorageModePrivate; } -// initialize MTLTextureDescritor with MSAA attributes +// initialize MTLTextureDescriptor with MSAA attributes _SOKOL_PRIVATE void _sg_mtl_init_texdesc_rt_msaa(MTLTextureDescriptor* mtl_desc, _sg_image_t* img) { SOKOL_ASSERT(img->cmn.sample_count > 1); mtl_desc.usage = MTLTextureUsageRenderTarget; diff --git a/sokol_time.h b/sokol_time.h index 2d4d4563..fd766d8e 100644 --- a/sokol_time.h +++ b/sokol_time.h @@ -296,7 +296,7 @@ SOKOL_API_IMPL uint64_t stm_round_to_common_refresh_rate(uint64_t ticks) { } i++; } - // fallthough: didn't fit into any buckets + // fallthrough: didn't fit into any buckets return ticks; } diff --git a/tests/functional/sokol_gfx_test.c b/tests/functional/sokol_gfx_test.c index c5bff77b..9dfa9108 100644 --- a/tests/functional/sokol_gfx_test.c +++ b/tests/functional/sokol_gfx_test.c @@ -1432,7 +1432,7 @@ UTEST(sokol_gfx, commit_listener_add_remove_add) { sg_shutdown(); } -UTEST(sokol_gfx, commit_listener_remove_non_existant) { +UTEST(sokol_gfx, commit_listener_remove_non_existent) { reset_commit_listener(); setup(&(sg_desc){0}); const sg_commit_listener l0 = { diff --git a/util/sokol_debugtext.h b/util/sokol_debugtext.h index 09da6019..cec06946 100644 --- a/util/sokol_debugtext.h +++ b/util/sokol_debugtext.h @@ -148,7 +148,7 @@ - to render characters at 16x16 physical pixels: - sdtx_canvas(sapp_width()/2.0f, sapp_heigth()/2.0f); + sdtx_canvas(sapp_width()/2.0f, sapp_height()/2.0f); Do *not* use integer math here, since this will not look nice when the render target size isn't divisible by 2. @@ -3777,6 +3777,8 @@ static sdtx_context_desc_t _sdtx_context_desc_defaults(const sdtx_context_desc_t res.tab_width = _sdtx_def(res.tab_width, _SDTX_DEFAULT_TAB_WIDTH); // keep pixel format attrs are passed as is into pipeline creation SOKOL_ASSERT(res.char_buf_size > 0); + SOKOL_ASSERT(!isnan(res.canvas_width)); + SOKOL_ASSERT(!isnan(res.canvas_height)); SOKOL_ASSERT(res.canvas_width > 0.0f); SOKOL_ASSERT(res.canvas_height > 0.0f); return res; @@ -4133,7 +4135,7 @@ static void _sdtx_render_char(_sdtx_context_t* ctx, uint8_t c) { const float x1 = x0 + ctx->glyph_size.x; const float y1 = y0 + ctx->glyph_size.y; - // glyph width and heigth in font texture space + // glyph width and height in font texture space // NOTE: the '+1' and '-2' fixes texture bleeding into the neighboring font texture cell const uint16_t uvw = 0x10000 / 0x100; const uint16_t uvh = 0x10000 / SDTX_MAX_FONTS; @@ -4336,6 +4338,8 @@ SOKOL_API_IMPL void sdtx_font(int font_index) { SOKOL_API_IMPL void sdtx_canvas(float w, float h) { SOKOL_ASSERT(_SDTX_INIT_COOKIE == _sdtx.init_cookie); + SOKOL_ASSERT(!isnan(w)); + SOKOL_ASSERT(!isnan(h)); SOKOL_ASSERT((w > 0.0f) && (h > 0.0f)); _sdtx_context_t* ctx = _sdtx.cur_ctx; if (ctx) { diff --git a/util/sokol_gfx_imgui.h b/util/sokol_gfx_imgui.h index b409ebee..9473742e 100644 --- a/util/sokol_gfx_imgui.h +++ b/util/sokol_gfx_imgui.h @@ -3789,7 +3789,7 @@ _SOKOL_PRIVATE void _sg_imgui_draw_pass_panel(sg_imgui_t* ctx, sg_pass pass) { } if (pass_ui->desc.depth_stencil_attachment.image.id != SG_INVALID_ID) { igSeparator(); - igText("Depth-Stencil Attachemnt:"); + igText("Depth-Stencil Attachment:"); _sg_imgui_draw_pass_attachment(ctx, &pass_ui->desc.depth_stencil_attachment, &pass_ui->ds_image_scale); } } else { diff --git a/util/sokol_gl.h b/util/sokol_gl.h index 88a62bad..997ddea3 100644 --- a/util/sokol_gl.h +++ b/util/sokol_gl.h @@ -453,7 +453,7 @@ sgl_set_context(ctx); - The currently active context will implicitely be used by most sokol-gl functions + The currently active context will implicitly be used by most sokol-gl functions which don't take an explicit context handle as argument. To switch back to the default context, pass the global constant SGL_DEFAULT_CONTEXT: diff --git a/util/sokol_imgui.h b/util/sokol_imgui.h index 59c150b3..93b697fa 100644 --- a/util/sokol_imgui.h +++ b/util/sokol_imgui.h @@ -1991,7 +1991,7 @@ static void _simgui_pool_free_index(_simgui_pool_t* pool, int slot_index) { SOKOL_ASSERT(pool->queue_top <= (pool->size-1)); } -/* initiailize a pool slot: +/* initialize a pool slot: - bump the slot's generation counter - create a resource id from the generation counter and slot index - set the slot's id to this id diff --git a/util/sokol_nuklear.h b/util/sokol_nuklear.h index 25293252..04e73eac 100644 --- a/util/sokol_nuklear.h +++ b/util/sokol_nuklear.h @@ -1917,7 +1917,7 @@ static void _snk_pool_free_index(_snk_pool_t* pool, int slot_index) { SOKOL_ASSERT(pool->queue_top <= (pool->size-1)); } -/* initiailize a pool slot: +/* initialize a pool slot: - bump the slot's generation counter - create a resource id from the generation counter and slot index - set the slot's id to this id diff --git a/util/sokol_spine.h b/util/sokol_spine.h index 48295a20..f76d2bf4 100644 --- a/util/sokol_spine.h +++ b/util/sokol_spine.h @@ -3192,7 +3192,7 @@ static void _sspine_pool_free_index(_sspine_pool_t* pool, int slot_index) { SOKOL_ASSERT(pool->queue_top <= (pool->size-1)); } -/* initiailize a pool slot: +/* initialize a pool slot: - bump the slot's generation counter - create a resource id from the generation counter and slot index - set the slot's id to this id |