Commit Graph

9274 Commits

Author SHA1 Message Date
Branimir Karadžić
ac6aa47b41 Metal/WebGPU: clearQuad — don't enable stencil ops when FB has no stencil. Closes #3310. (#3733) 2026-06-07 05:59:27 +00:00
Branimir Karadžić
9dc9749b53 Metal: Skip nextDrawable for occluded windows. Fixes #3601. (#3732) 2026-06-07 04:07:47 +00:00
Branimir Karadžić
2962f60576 GL, Metal: Honor stream vertex layout override when computing auto vertex count. Follow up to PR #3250. (#3731) 2026-06-06 20:51:45 -07:00
falia18
34fa33c40b D3D12: fix D3D12_VERTEX_BUFFER_VIEW stride when both vertex layout handles are valid (#3250) 2026-06-06 20:39:08 -07:00
Branimir Karadžić
81b63b81c9 Unified ChunkedScratchBuffer implementation. (#3730) 2026-06-07 03:29:09 +00:00
Branimir Karadžić
91805892e9 Unified StateCache implementation. (#3729) 2026-06-06 18:19:56 -07:00
Branimir Karadžić
11151de78d Added setTexture view API. (#3728) 2026-06-06 17:34:02 +00:00
Branimir Karadžić
69615a9a51 Fixed shaderc infinite loop on varying.def missing ';' + handle line comments. (#3727) 2026-06-06 05:29:00 +00:00
Branimir Karadžić
6e0d61bf30 Added star history Global Rank. (#3726) 2026-06-02 17:28:17 +00:00
Branimir Karadžić
5a1b2bbc9e Metal: Fix null deref in render encoder and processArguments. (#3725) 2026-06-02 17:20:57 +00:00
Branimir Karadžić
b0f61277f5 D3D12/WebGPU: Support cubemap/2d-array auto mip generation. Issue #3441. (#3724) 2026-06-02 05:40:36 +00:00
Branimir Karadžić
7b8927049a Fix updateTexture2D pitch handling for compressed textures. Fixed #3705. (#3722) 2026-06-02 04:22:46 +00:00
Jaziel Guerrero
0d4141d03a Updated C3 binding script to generate C3 binding based on C3 v0.8.0 (#3720) 2026-05-28 20:38:35 -07:00
Branimir Karadžić
5f85da1e59 Added .ktx2 support. (#3721) 2026-05-28 20:38:10 -07:00
Branimir Karadžić
ccd0d04c9e Metal: Guard against null vertexAttributes for shaders with no inputs. (#3719) 2026-05-28 17:04:05 +00:00
Branimir Karadžić
ba17ab3825 Added webp support. (#3718) 2026-05-27 05:03:03 +00:00
Branimir Karadžić
7d03e160fa Fix MSAA + mipmaps combination on D3D11/D3D12/Vulkan/Metal. (#3717) 2026-05-21 22:53:17 +00:00
Branimir Karadžić
526b886105 Metal: Fix maxFrameLatency setting. (#3715) 2026-05-21 06:19:41 +00:00
Branimir Karadžić
0158b15c23 Metal: Fixed freeze when BGFX_FRAME_FLUSH is used. (#3714) 2026-05-21 06:18:36 +00:00
Branimir Karadžić
f17b06fc00 Metal: Clamp texture update rect to destination mip extent. (#3713) 2026-05-21 05:26:06 +00:00
Branimir Karadžić
651985d860 Metal: Warn about drawable size mismatch. (#3712) 2026-05-20 19:33:01 -07:00
Branimir Karadžić
de332e5937 VK: Fixed VK_EXT_swapchain_maintenance1 missing instance exp deps, and timer query inside render pass. (#3711)
* Fixed dynamic frame vsync on RADV.

* Fix timer query inside render pass.
2026-05-17 23:51:31 +00:00
Branimir Karadžić
d4c91be81d Cleanup. (#3710) 2026-05-17 16:43:20 +00:00
Branimir Karadžić
4997ad09ed Metal: Dynamic frame VSync to match #3706. (#3709) 2026-05-17 16:23:00 +00:00
Vincent Bousquet
a8250ceaf9 Lighter per frame VSync on/off for D3D11, D3D12 & Vulkan (#3706) 2026-05-17 15:44:33 +00:00
Branimir Karadžić
9849fe96cb CI: Remove osx-x64. (#3703) 2026-05-04 07:54:11 -07:00
Branimir Karadžić
4a8489a549 Match CI with bx. (#3702) 2026-05-03 18:39:29 -07:00
Branimir Karadžić
87c1929d71 Fix zero-vertex regression in setVertexBuffer. (#3701) 2026-05-03 15:33:51 -07:00
Branimir Karadžić
65f9425d8c Updated to new SIMD. (#3699) 2026-05-03 18:51:10 +00:00
Branimir Karadžić
b7d5c2572c Metal: Improve feature detection. (#3697) 2026-05-02 04:44:31 +00:00
Kyle Emmerich
7abefde6bd Metal: Honor BGFX_RESET_DEPTH_CLAMP via setDepthClipMode:. (#3696)
The flag was already in `maskFlags` but never wired to any rasterizer
state, so it was a no-op on Metal. Set MTLDepthClipModeClamp on each
render command encoder when requested. Capability-gated: macOS always,
Apple-GPU platforms gated by GPUFamilyApple4+.
2026-05-02 03:35:39 +00:00
Ernes Budiman
5761ae09e4 Update README.md (#3695)
Add Match Morphosis game into readme
2026-04-29 14:35:50 +00:00
Branimir Karadžić
58faaadf1c VK: Split FrameBufferVK::acquire into swap-chain acquire + markDirty(). (#3694) 2026-04-27 18:32:53 +00:00
attilaz
b2a7d94d57 Update renderer_vk.cpp (#3693)
Fix PROFILE_SCOPE typo
2026-04-27 14:22:28 +00:00
Branimir Karadžić
331783cf9a Renamed bx::uint32_min/max/clamp/cntlz/cnttz/mod to typed equivalents. (#3692) 2026-04-27 04:19:08 +00:00
ShuangLiu1992
43fbfaba41 docs: clarify readTexture's READ_BACK flag is CPU-only (#3691)
Per maintainer feedback, distill the @attention block down to the
essence: it's a texture for CPU readback, and can't be a GPU resource
at the same time. Add a one-line pointer to examples/30-picking for
the rendered-content case rather than spelling out the blit-to-staging
sequence inline.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-26 15:42:53 +00:00
ShuangLiu1992
cceedb60cf Fix: reset s_renderFrameCalled in bgfx::shutdown() to allow re-init (#3690)
bgfx::renderFrame() sets s_renderFrameCalled = true on its first call
(line 1541) and never clears it. bgfx::shutdown() resets s_threadIndex
to 0 (line 3958) but leaves s_renderFrameCalled sticky, which means
that on a 2nd renderFrame after shutdown the gate at line 1534 still
runs BGFX_CHECK_RENDER_THREAD(). That assertion checks
(s_ctx != NULL && single-threaded) || (~BGFX_API_THREAD_MAGIC == s_threadIndex);
both branches fail post-shutdown (s_ctx is NULL, s_threadIndex is 0),
and the assertion fires in debug builds — blocking re-init of the
bgfx context within the same process.

Adding the symmetric s_renderFrameCalled reset to shutdown() makes
shutdown leave bgfx in the same state as a fresh process, so a
subsequent renderFrame()+init() pair behaves like the first one.

Verified locally: a downstream test that constructs an SDL+bgfx
context, runs a frame, destroys it, then constructs another from the
same thread now passes in debug builds with this patch (it asserts at
line 1536 without it).
2026-04-25 20:15:29 -07:00
Gary Hsu
ac54f48d4d Fix UBSan undefined-behavior hits in bgfx_p.h (#3688)
* Default-initialize SortKey members to eliminate UBSan bool hit

SortKey data members had no initializers; the only initialization path
was an explicit reset() call. Reading m_hasAlphaRef (bool) before
reset() ran surfaced under BabylonNative's -fno-sanitize-recover=all
UBSan as 'load of value 190, which is not a valid value for type bool'.
Integer siblings had the same hazard, but UBSan only flags bools.

Add in-class default initializers matching reset()'s values. Zero
runtime cost where reset() immediately follows. No API/ABI change.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Avoid shift-by-width UB in BitMaskToIndexIteratorT

UBSan on macOS flags the shifts at bgfx_p.h:854 and :862. bx::countTrailingZeros returns the type width (e.g. 32 for uint32_t) when its argument is zero, and that value was fed directly into the shift operator, producing shift-by-width UB.

Guard each shift against a zero mask so the width-valued ntz is never used as a shift exponent. Behavior is preserved for every input that previously avoided UB, and callers see isDone() == true in exactly the same iterations as before.

* Address review feedback: tighter BitMask ternary + SortKey reset() in EncoderImpl ctor

Per review on bkaradzic/bgfx#3688:

- BitMask: use branchless ternary (0 == _mask ? 0 : _mask >> ntz) in place of early-return guard.

- SortKey: drop in-class default initializers; initialize via m_key.reset() in EncoderImpl() ctor, which is the narrower location where the UB read originates.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-24 21:48:41 +00:00
Branimir Karadžić
461622ab26 Metal: Fixed dynamic buffer alignment. Fixed #3684. (#3685) 2026-04-23 16:38:20 +00:00
Branimir Karadžić
d6458ee253 Metal: Fixed depth/stencil store action on the main swap chain when using MSAA. (#3683) 2026-04-22 16:34:12 -07:00
Branimir Karadžić
50bf41b224 Fixed stremMask check. (#3682) 2026-04-21 11:21:40 -07:00
Branimir Karadžić
e528e9d880 Fixed stremMask check. (#3681) 2026-04-21 11:15:04 -07:00
Branimir Karadžić
633ceb1247 VertexLayout: Fix bad remap table. (#3680) 2026-04-21 11:11:04 -07:00
Branimir Karadžić
c9e98db704 Cleanup. (#3679) 2026-04-21 03:58:53 +00:00
Branimir Karadžić
6294e59293 Metal: Fixed instancing mapping. (#3678) 2026-04-21 03:51:39 +00:00
Branimir Karadžić
8a22a19d2e Metal: Check if framebuffer has depth before setting depth state. (#3677) 2026-04-21 00:27:07 +00:00
Branimir Karadžić
78076b02eb WebGPU: Fixed formats. (#3676) 2026-04-19 16:35:06 -07:00
unravel-dev
4212c8ed27 Fix BGFX_RESET_VSYNC not affecting secondary swap chains on D3D11, Vulkan, OpenGL (#3675)
Toggling BGFX_RESET_VSYNC via bgfx::reset() only updated the main/init swap
chain. Secondary swap chains created through createFrameBuffer(nwh, ...) kept
their initial vsync state, leaving framerate capped at refresh rate. D3D12
already handled this correctly.

D3D11: forward present flags to FrameBufferD3D11::present so it can pass
DXGI_PRESENT_ALLOW_TEARING alongside syncInterval=0. Compute presentFlags once
in flip() and reuse for both secondary framebuffers and the main swap chain.

Vulkan: in updateResolution, iterate m_windows and call FrameBufferVK::update
on each valid secondary framebuffer so SwapChainVK::update sees the new
BGFX_RESET_VSYNC and recreates the swapchain with the correct present mode.

OpenGL (WGL/EGL): wglSwapIntervalEXT is per-context, eglSwapInterval is
per-surface. Cache the desired interval in GlContext::m_swapInterval and
re-apply it in makeCurrent() whenever a different context/surface becomes
current, so secondary SwapChainGL instances pick up the current value. Also
honor the initial BGFX_RESET_VSYNC flag in create() instead of hard-coding 0.
2026-04-19 22:35:57 +00:00
Branimir Karadžić
4481b9b46b Cleanup. (#3674) 2026-04-19 16:49:37 +00:00
Vincent Bousquet
d0def7d137 DX12: use discard instead of sequential flip (#3667) 2026-04-19 16:46:31 +00:00