Repository navigation
zink: GL 3.3 on Mali without dualSrcBlend or packed 10/10/10/2 vertex formats - #67
Merged
Merged
Conversation
utkarshdalal
force-pushed
the
zink-gl33-mali-lowering
branch
2 times, most recently
from
November 20, 2026 07:29
766b725 to
41fd5c2
Compare
added 2 commits
November 20, 2026 13:39
…ks them Mali drivers do not list the A2B10G10R10/A2R10G10B10 UNORM, SNORM, USCALED and SSCALED formats as vertex buffer formats, so GL_ARB_vertex_type_2_10_10_10_rev and with it GL 3.3 were missing. Without optimal_keys, such an attribute is now declared as R32_UINT at the same offset and stride, and the vertex shader key records which attributes need unpacking and how (channel order, signedness, normalization). A compile pass replaces the float input with a uint input and unpacks it. Formats the driver supports keep the native path, and with optimal_keys (the only mode that uses pipeline libraries or shader objects) nothing changes.
… dualSrcBlend Mali drivers report dualSrcBlend = false, so GL_ARB_blend_func_extended and with it GL 3.3 were missing. They do have coherent framebuffer fetch (VK_EXT_rasterization_order_attachment_access). When the driver has no dualSrcBlend but has coherent fetch, and zink runs without optimal_keys and without dynamic blend state, zink now reports one dual-source render target: - A fragment shader that writes a dual-source color is marked as an fbfetch shader when it is created, so its programs get the input attachment layout, the rasterization-order render pass and per-sample shading for multisampled targets no matter when the blend state arrives. - A blend state that uses src1 factors on color 0 turns hardware blending off for color 0 (write mask kept) and puts the equation into a new part of the fragment shader key. That variant gathers both color 0 outputs, applies alpha-to-coverage (per sample, from the source alpha) and alpha-to-one, and runs nir_lower_blend with the destination read through fbfetch. The blend constant comes from a new push constant. The clamp follows cbuf 0: unorm and sRGB (blended in linear through the sRGB view), snorm, or none for float; integer buffers are not blended. - A shader that writes no dual-source color while such a blend state is bound gets the hardware blend with src1 factors reading zero. Drivers with dualSrcBlend keep the native path. With optimal_keys (and so pipeline libraries and shader objects) or full dynamic blend state, or without coherent fetch, the cap stays 0.
utkarshdalal
force-pushed
the
zink-gl33-mali-lowering
branch
from
November 20, 2026 08:09
41fd5c2 to
2bc9b7a
Compare
utkarshdalal
marked this pull request as ready for review
November 20, 2026 11:45
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On Mali-G615 (r44p1, Vulkan 1.3.247) and Mali-G68 (r38p1, Vulkan 1.3.219), with the wrapper's depth clip emulation from #66, zink now reaches GL 3.2 core, but a 3.3 core context still fails. Two GL 3.3 requirements are missing:
GL_ARB_blend_func_extended: the driver reportsdualSrcBlend = false, so zink reports no dual-source render target.GL_ARB_vertex_type_2_10_10_10_rev: the driver does not list the A2B10G10R10 / A2R10G10B10 UNORM, SNORM, USCALED and SSCALED formats as vertex buffer formats, and zink's attribute decomposition only handles array formats.On these devices zink runs without optimal keys, without graphics pipeline libraries or shader objects, without dynamic vertex input or extended dynamic state, and with legacy render passes. The driver has coherent framebuffer fetch (
VK_EXT_rasterization_order_attachment_access).Change
Two commits, one per extension. Both apply only when the driver lacks the feature; drivers that have it keep the native path.
Packed 10/10/10/2 vertex formats. An attribute in one of the eight formats the driver lacks is declared as
R32_UINTat the same offset and stride (pipeline vertex input and dynamic vertex input alike). The vertex shader key records which attributes are packed and whether each is BGRA, signed or scaled. A compile pass swaps the float input for a uint input and unpacks it: 10-bit fields at bits 0/10/20 and the 2-bit field at bit 30, red in the low bits for the RGBA formats and blue for the BGRA ones, UNORM as x/1023 and a/3, SNORM sign-extended and clamped at -1, SCALED converted as integers. This is only offered without optimal keys, because the shader key it needs only exists there. Pipeline libraries and shader objects require optimal keys, so they never see it.Dual-source blending through framebuffer fetch. The cap is reported as 1 only when all of these hold: no
dualSrcBlend, coherent fetch, no optimal keys, and no full dynamic blend state. Otherwise it stays 0, and with only non-coherent fetch it stays 0 too.nir_lower_blendreading the destination through fbfetch, and writes the blended color. The blend constant comes from a new push constant.Testing
zink-gl33-mali-lowering-shipped-base. That branch is c1567e9 (the shipped base) + glx/xlib: count the alpha channel in GLX_BUFFER_SIZE (Tomb Raider I-III under gamescope) #58's fix + these two commits, ending at9b8c6bf6f8, plus one build-only commit on its tip (ce0beecdce2:idep_xmlconfigon the libgl-xlib target and the Android memfd path inanon_file.c, the same changes the 20261104 build used). The two commits there are identical to the two on this branch (git range-diffshows no change). Recipe: the "Two Mesas: glamor's and the guest's" section of the gamescopeandroid/README.md(NDK 27.3 + termux aarch64 sysroot,-Dglx=xlib, zink only,-fno-emulated-tls).NEEDEDmatches the shipped library and_glapi_tls_Contextis ELF TLS. The library reportsMesa 24.3.0-devel (git-9b8c6bf6f8). It is repacked asextra_libs-20261120.tzstfrom the shipped archive with onlyusr/lib/libGL.so.1.5.0replaced: archive sha2566f4914c0fa005b167270f26a2f176ff9a851b741f9fe3b3f969459d93e4644bc, libGL sha25645b8577a62f682e8947ff17168d042d8de605ee68d467cf7b27568a9e25e3687.macOS-CI,macos-11) waits for a runner that no longer exists.Device results
Run on BrowserStack devices with the wrapper from #66 (
wrapper-gamenative-20261120.tzst, sha2564443e109...43ff) and the guest libGL from #67 (extra_libs-20261120.tzst, sha2566f4914c0...44bc, reportsgit-9b8c6bf6f8), X11, xlib zink, no version or extension overrides. A WGL test program requests each context version, then draws and reads pixels back: depth clamp on and off (19 cases), all eight packed 10/10/10/2 vertex formats with plain, instanced and interleaved layouts (59 cases), and dual-source blending with every src1 factor and equation, constant color, color masks, sRGB, RGBA16F, RGB565, the default framebuffer, overlapping primitives in one draw, 4x MSAA and alpha-to-coverage (63 cases). The testbed's GL texture suite runs as a second step.wrapper-gamenative-20261027withextra_libs-20261104.dualSrcBlend, no rasterization order attachment access and no queue timestamps (GL_ARB_timer_query).GL_ARB_viewport_array,maxViewportsis 1).Found during these runs and not caused by these changes (both reproduce with the shipped parts):
glReadPixels(GL_DEPTH_COMPONENT, GL_FLOAT)on a 24-bit depth renderbuffer, later draws to that framebuffer no longer show in readbacks. Integer reads, other depth formats and a new framebuffer work.Adreno 740 (Retroid Pocket 6), new libGL: with Turnip, OpenGL 4.6, packed formats 59/59, dual-source 63/63, depth clamp 19/19, and Balatro renders its menu and exits cleanly. With the Qualcomm system driver the version rises from 3.2 to 4.5, because that driver lacks the four SCALED packed formats. On that driver every draw whose vertex shader has two or more inputs reads wrong values, with the shipped libGL too (same values in both), so its failures there are not from this change.
Not covered: on the Mali, PowerVR and Xclipse devices only the test programs ran, no game. The GL 4.0 features that are now reachable on Mali (tessellation, doubles) were not drawn.