mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-22 06:15:58 +00:00
fix(venus): lower the guest's SPIR-V to 1.3 for the phone's shader compiler (#2587)
* fix(venus): lower the guest's SPIR-V to 1.3 for the phone's shader compiler * fix(venus): lower SPIR-V to 1.3 for Mali drivers * fix(venus): keep the SPIR-V cap valid and scoped to active layers Cap inline compute pipeline code too, leave the shader hooks off when the layer is turned off, strip clip and cull distances only where they are emulated, and leave modules alone whose capabilities, decorations or OpSelect results need a newer version or an undeclared extension. * fix(venus): keep application pipeline chains read-only and check non-semantic imports Inline stage code is handed to the driver through a copy of the stage's pNext chain instead of being written into the application's create info, pipeline hooks return VK_ERROR_OUT_OF_HOST_MEMORY when their allocations fail, and a NonSemantic import is only lowered to SPIR-V 1.3 when the module declares SPV_KHR_non_semantic_info. * fix(venus): preserve valid pipeline and shader behavior * fix(venus): lower compatible read-only shader parameters * fix(venus): install SPIR-V 1.3 lowering hooks on Vulkan 1.2+ devices or emulated gaps
This commit is contained in:
1 parent
bc11653c15
commit
6de3c59d7c
7 files changed
+1183
-101
No files matched your search
@@ -128,10 +128,32 @@ What it does, per feature:
|
||||
- Pipelines and `vkCmdSetColorBlendEquationEXT` both.
|
||||
- Why alpha: output 0's color is the paint, its alpha is the usual coverage. Per-channel coverage collapses to one value; blending stays plain alpha blending, not tinted by the paint.
|
||||
|
||||
The SPIR-V version the driver gets:
|
||||
- The phone's own driver compiles the guest's SPIR-V, and its compiler is old: on the MT6897
|
||||
Mali-G615 (r44p1, "Vulkan 1.3.247") it dies with a null read in `cmpbe_v2_compile_multiple_shaders`
|
||||
while compiling a pipeline, and the render server dies with it, so every guest client that
|
||||
draws loses its device.
|
||||
- Zink writes SPIR-V 1.6 for any Vulkan 1.3 device (`zink_screen.c`: `spirv_version` from the
|
||||
device's version), and SPIR-V 1.4 changed the entry point's interface: it has to list every
|
||||
global variable, not only the input and output ones.
|
||||
- The layer therefore lowers every module to SPIR-V 1.3 before the driver sees it: the version
|
||||
word, the interface list (back to the input and output variables) and `OpTerminateInvocation`
|
||||
(SPIR-V 1.6's name for `OpKill`). This covers shader modules, and code given inline to
|
||||
graphics and compute pipelines.
|
||||
- A module that uses something 1.3 cannot express is left alone and the layer says so in its
|
||||
log: a `ShaderViewportIndex` capability, the Vulkan memory model, `OpCopyLogical`, an
|
||||
`OpSelect` of a structure or array, the newer loop controls and image operands, or a
|
||||
capability, decoration or instruction that became core later without the extension 1.3
|
||||
needs for it (`ShaderNonUniform` without `SPV_EXT_descriptor_indexing`).
|
||||
- The version cap runs on every device the layer is active on; clip and cull distances are
|
||||
only taken out where the layer emulates them. `DROIDDECK_MALI_COMPAT=0` turns both off.
|
||||
- This is what Dawn ("Disable SPIR-V 1.4 on Android ARM"), ANGLE (`supportsSPIRV14`) and naga
|
||||
(`AVOID_SPIRV_COPY_LOGICAL`) do for a proprietary compiler they cannot trust.
|
||||
|
||||
Files:
|
||||
- `layer.c`: loader plumbing, feature and limit reporting, device creation, the hook table.
|
||||
- `pipeline.c`: pipelines, shader modules, viewports.
|
||||
- `spirv.c`: the SPIR-V rewriter for clip and cull distances and the second blend source.
|
||||
- `spirv.c`: the SPIR-V rewriter for clip and cull distances and the second blend source, and the version cap.
|
||||
- `bc.c`: BC formats, images and uploads.
|
||||
- `VkLayer_droiddeck_mali_compat.json`: implicit layer manifest.
|
||||
|
||||
@@ -149,6 +171,7 @@ How it ships:
|
||||
Not done yet:
|
||||
- Unit tests for the clip and cull distance rewriter. It is untested beyond DXVK's shaders, and unknown whether Silksong's shaders used clip distances at all.
|
||||
- The dual-source rewrite has them: `tools/tests/test_mali_compat_layer.py`.
|
||||
- The version cap has them: `tools/tests/test_mali_compat_spirv.py`.
|
||||
- Performance: BC decoding on the CPU makes loads slow. A compute-shader decoder would be the next step.
|
||||
|
||||
## Changes on the branch
|
||||
|
||||
Reference in new issue
Block a user