fix(render3d): nothing draws into a BC7 texture - sampler binding binds, and compressed images get no mips

Metal aborted a net.sh guest ("MTLPixelFormatBC7_RGBAUnorm is not color renderable"): the crash
report's main thread was in vkQueueSubmit from gvk_once_end, MoltenVK encoding a vkCmdBlitImage
through a render pipeline. water.ludic bound its reflection by sampler name and then asked the
BOUND texture for mips - on Vulkan the bound texture was not the reflection but the last one
bound, since 23.3 a BC7 kit texture. gpu_bind_sampler now makes its texture the bound one, as
OpenGL did (and water binds it explicitly); gvk_tex_mips and gvk_mips_now skip compressed images;
gvk_pass_begin leaves out a compressed colour attachment and says so.

tests/net.sh passes (main e515bd87 built against it; host and guest agree on 196 animals, the
people, the board and the lost hiker).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-28 10:34:23 +03:00
parent f1049953c4
commit 1447304dd7
6 changed files with 40 additions and 0 deletions

View file

@ -324,6 +324,10 @@ function water_draw(render3d_st: mut Render3dState, depth_tex: int) -> void {
# bind on its own unit first: generating the mip chain re-binds the texture on the active unit,
# and it must not displace the depth texture the shader reads for the shore
r3d_bind_2d(render3d_st, p, "u_refl", 1, render3d_st.water_refl.color); ron = 1.0
# the parameter and the chain are the BOUND texture's, and binding a sampler by name does not
# bind it: without this they went to whatever was bound last - a BC7 kit texture since 23.3,
# which the mip blits then drew into (Metal: "BC7 is not color renderable")
gpu_tex_bind(render3d_st, GPU_TEX2D, render3d_st.water_refl.color)
gpu_tex_param(render3d_st, GPU_TEX2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR)
gpu_tex_mips(render3d_st, GPU_TEX2D)
}