Repository navigation
feat(heap): buffer views bound directly on Metal 3, uniform blocks on GL without storage - #15
Merged
Merged
Conversation
…L shaders on the bound tier openOMSI's OpenGL variants of its modules (gl_backend(): arrays and lamps in textures, roof map as float, the basic set) are in tests/openomsi_gl, and openomsi_shaders takes them on a GL device. On ANGLE over Metal (OpenGL ES 3.0) 16 of 17 compiled; the sky failed: naga's GLSL writer refused textureLoad from the scene's depth (the screen-space clouds' cloud_covered), so the cloud pipelines would fail on OpenGL with Enhanced graphics. naga (MX_PATCHES.md): a depth texture loaded from and never sampled is a sampler2D read with texelFetch(..).x; a multisampled one is fetched from its sampler2DMS. Now all 17 compile on ANGLE, conformance 29/29 there. CI: conformance and openOMSI's GL shaders on Mesa llvmpipe (EGL under Xvfb), OpenGL ES and desktop.
DXC took some 15 s over openOMSI's scene module on WARP, and every start of the game paid it again. mx_shader::disk_cache keeps the bytecode keyed by the HLSL, entry point, profile, flags and the compiler's build (DXC's version, DLL size and whether dxil.dll signs; FXC's DLL), in %LOCALAPPDATA%\mX\shaders or MX_SHADER_CACHE (0: off). Entries carry the key's length and a second hash and a checksum of the code, are written through a temporary file renamed into place, and the folder is kept under 512 MB, oldest first. Direct3D 12 compiles through it (behind the in-memory cache), Direct3D 11's FXC too. CI on Windows runs openOMSI's shaders into an empty cache and again from it.
…oltenVK under sync validation, lavapipe and WARP in CI)
…fragment shader OpenGL ES links no program without a fragment shader, so every depth-only pipeline (shadow maps, openOMSI's "shadow clear") failed there: openOMSI's renderer could not be made on ANGLE. wgpu-hal adds an empty one too. Conformance: depth_only_pipelines_draw_without_a_fragment_stage (fails without the fix on ANGLE, passes on Metal and GL).
…ures read back Mesa (llvmpipe, OpenGL ES 3.2) in CI found two more: - An indirect draw with a first instance drew at instance 0: OpenGL ES's indirect commands have no first instance (reservedMustBeZero), and without draw parameters the shader adds it from a uniform a GPU-side draw cannot set. Without draw parameters indirect draws now go the way of ES 3.0's: the arguments read back and drawn directly. - copy_texture_to_buffer of a compressed texture panicked. The blocks are now copied with glCopyImageSubData (GL 4.3, ES 3.2) into an RG32UI / RGBA32UI texture, a texel a block, and read back from it.
… the mip's real size WebGPU's copy size is whole blocks (4x4 into a 2x2 or 1x1 mip); GL refuses a region past the mip's edge, and the small mips of compressed textures were never written (Mesa in CI: compressed_small_mips_take_whole_blocks).
…where shaders read gl_BaseInstance With draw parameters (GL 4.6, ARB_shader_draw_parameters) the shader's instance index is gl_InstanceID + gl_BaseInstance, but draws went through glDrawArraysInstanced / glDrawElementsInstanced, which leave the base instance 0: every draw with instances starting past 0 drew as instance 0 (Mesa desktop GL in CI: render bundles, occlusion queries). They now use the base-instance draws (GL 4.2) there.
…m blocks where a stage has no storage - Metal 3: a draw's heap buffer views chosen by its immediates are bound to buffer slots as its textures are (msl::write_direct with buffers), not reached through the argument buffer; read-only views of a fixed size go to Metal's constant address space, as a root uniform buffer's (bound::views_as_uniforms). - OpenGL without storage buffers in a stage (3.3, ES 3.0, most ES 3.1 fragment stages): those views are read as uniform blocks and bound with glBindBufferRange(UNIFORM_BUFFER); read-only views can be made there now, their offsets aligned for uniform buffers. - fragments_read_heap_buffers_chosen_by_immediates runs on every device; a GLSL test for the uniform blocks.
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.
Built on #14 (feat/openomsi-gl-shaders): merge that first, this PR's diff then shrinks to its own commit.
For openOMSI's renderer to read a frame's data (camera, lights, instance arrays) through the heap instead of root bind groups without losing speed or devices:
msl::write_directwith buffers: the bound tier's path), not loaded from the argument buffer each access. Read-only views of a fixed size are lowered to Metal'sconstantaddress space (bound::views_as_uniforms), where Apple GPUs read uniforms fastest, as root uniform buffers are.stage_with(.., uniform_views),Class::UniformBufferslots,glBindBufferRange(GL_UNIFORM_BUFFER)); read-only buffer views can be created there, offsets aligned for both buffer kinds. Writable views still need GL 4.3 / ES 3.1.Tested on an M4: conformance 30/30 on Metal 3, Metal 2 (
MX_METAL_BOUND=1), under Metal's API and shader validation, and on ANGLE (ES 3.0), wherefragments_read_heap_buffers_chosen_by_immediatesnow runs instead of being skipped;openomsi_shaderspasses; mx-shader unit tests incl. a new GLSL one; clippy clean.