Conversation
Detect SPIR-V endianness from the magic number
…pProcAddr Do NOT fall back to ogles2vk_LookupProcAddr()
…ormat 37, VMA limits
ogles2_vk: fix proc-addr ABI, SPIR-V endianness, varying linkage, VkFormat 37, VMA limits
|
Thanks Andrea. After review I've landed two of the three commits on a new ✅ Accepted onto
⏸ Held — The diagnosis is right: returning
The fix is to expand the Happy to take a revised commit from you, or I'll do it and credit you. No rush. 🛠 Not taken
Follow-up Closing this PR — the curated set lives on |
The ICD's vkGetDeviceProcAddr must return raw (non-APICALL) C-ABI function pointers — the application calls them directly as PFN_vkXxx with no Self in r3. ogles2vk_LookupRawProcAddr previously listed only ~25 functions and fell back to ogles2vk_LookupProcAddr, which returns APICALL trampolines. Those trampolines expect Self in r3, so calling them as raw PFN_vkXxx slides every argument by one register slot — manifesting as NULL pCreateInfo/pSwapchain inside the ICD when an application resolved e.g. vkCreateSwapchainKHR through vkGetDeviceProcAddr. This is the bug PR #1 commit 2 ("Do NOT fall back to ogles2vk_LookupProcAddr") correctly diagnosed but incorrectly fixed: replacing the fallback with NULL regressed the five WSI swapchain entry points (and ~165 others) that lived only in the DISPATCH table. Expand the ogles2_icd RAW table to mirror the full DISPATCH table — each entry now points at the underlying non-_t_ function. Then drop the trampoline fallback in favour of returning NULL. Also extend software_icd's RAW table to cover the four WSI surface queries and five swapchain entry points that were similarly missing. Co-authored-by: Andrea Palmate' <andrea.palmate@gmail.com>
Add inline source-code references to #1 and afxgroup (Andrea Palmate') in the comments above the expanded RAW tables and the new WSI entries — he diagnosed the underlying ABI bug.
vulkan.library, software_vk.library, ogles2_vk.library all advance from 1.2 (21.03.2026) to 1.3 (11.05.2026). The release groups together the curated parts of afxgroup's PR #1 (endianness, varying linkage, VMA limits, VkFormat 37, D() macros) with the proc-addr ABI fix that expands the RAW lookup tables to mirror DISPATCH. Verified: ELF MSB headers intact on all three, version strings land correctly in the built binaries.
Unfortunately this will break the code. vkCreateSwapchainKHR is an example where everything was started. In a piece of code I have I was getting an error because swap chain was not created correctly because the parameters passed to the underlying functions where NULL except for the first one (that most probably is wrong because it should be the interface pointer). And you have the same behavior in the software rendering where NULL is returned instead of using trampoline functions. Regeard debug. I've forgot to add it to CFLAGS too and swap the order. I will fix it |
|
Heads up — the curated set from this PR shipped as part of v1.3 ( Specifically merged from your work, with
Followed up with FIFO vsync handling ( Specifically for the ABI bug: there's now a Thanks again for the diagnosis and the persistence on the v2 review — your hands-on observations were what made the difference. |
Integrate the afxgroup collaborator PRs (#1-3) into main alongside the existing software_icd fixes: - SPIR-V endianness auto-detect from the magic word (accept BE or LE streams). - ogles2_vk: do not fall back to ogles2vk_LookupProcAddr() (returns APICALL trampolines, not raw PFN_vkXxx) - return NULL for unknown names instead. - ogles2_vk: proc-addr ABI, varying linkage, VkFormat 37, VMA-limits fixes. Conflicts resolved keeping BOTH sides: the software_vk shader-module ref-count (UAF) fix + the Vulkan Y-down viewport convention, AND the ogles2_vk vsync/ glFinish (FIFO present pacing) work, AND the afxgroup changes. Merged software ICD builds clean; ogles2vk_exec.c syntax-checks (ogles2vk_main.c needs the Warp3DNova GPU SDK header, absent from the CI image). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Detect SPIR-V endianness from the magic number and swap only when needed. Per the Vulkan spec, the magic word may be supplied in either endianness — the driver must accept both. The previous unconditional byte-swap was wrong for callers that already produce host-byte-order SPIR-V (e.g. uint32_t array literals compiled on a big-endian host like ImGui's _glsl_shader*_spv on PowerPC). Reading the first word as raw bytes gives us a byte-order-independent way to decide.
Added a software_icd makefile when not using docker