Repository navigation
openOMSI's OpenGL shaders on the bound tier; textureLoad from depth in GLSL; DX shader cache on disk - #14
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.
# Conflicts: # crates/mx-shader/src/glsl.rs
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.
openOMSI assembles its shader modules differently on OpenGL (
gl_backend()): the scene's arrays and lamps read from textures, the roof map read as a float texture, the basic set for weak drivers. Until nowopenomsi_shadersskipped the bound tier. This PR adds those GL variants and tests them on GL.crates/mx/tests/openomsi_gl: openOMSI's 17 OpenGL modules (from openOMSIfc59155ad, see the README there).openomsi_shadersuses them on a GL device. Other bound tiers (Metal 2, Direct3D 11) take the native set, as openOMSI does on them.MX_PATCHES.md): naga's GLSL writer refusedtextureLoadfrom a depth texture. That broke the sky module: the screen-space clouds read the scene's depth (cloud_covered), so on OpenGL the cloud pipelines would fail with Enhanced graphics on. Now a depth texture that is only loaded from, never sampled, is declared assampler2Dand read withtexelFetch(..).x. A multisampled one is read from itssampler2DMS. A depth texture that is also sampled with a comparison still gets the error. Unit test inmx-shader(validated with glslangValidator, GLSL ES 3.10 and GL 4.30, plus ES 3.00).Checked on an M4:
MX_EGL_LIBRARY=VS Code's libEGL): 17/17 openOMSI GL modules compile (before the naga fix: 16, the sky failed). Conformance 29/29.MX_METAL_BOUND=1): the native set compiles (ray tracing skipped).Compiled shaders on disk (Direct3D 12 and 11)
DXC took about 15 s over openOMSI's scene module on WARP, and every start of the game paid that again.
mx_shader::disk_cachekeeps the bytecode keyed by the HLSL, entry point, profile, flags and the compiler's build: DXC's version, the DLL's size, and whetherdxil.dllsigns the output. The cache lives in%LOCALAPPDATA%\mX\shaders, or whereverMX_SHADER_CACHEpoints (0turns it off).mx-shaderrun on every platform. On Windows, CI runs openOMSI's shaders twice: once into an empty cache, then again from it.cargo clippy -p mx-dx12 -p mx-dx11 --target x86_64-pc-windows-msvc -- -D warnings. Not yet run on Windows hardware; CI on WARP is the first run.mx-gl: depth-only pipelines on OpenGL ES
I ran openOMSI's own renderer GPU tests on this branch over ANGLE (
--config patch.…pointing openOMSI at the local mX; nothing changed in openOMSI). The renderer could not be created: the "shadow clear" pipeline has no fragment stage, and OpenGL ES won't link a program without one. mx-gl now attaches an empty fragment shader, which is what wgpu-hal does. New conformance testdepth_only_pipelines_draw_without_a_fragment_stage: it fails on ANGLE without the fix and passes on Metal and GL with it. After the fix,enhanced_respects_material_ambientpasses on mX GL. That test builds the whole renderer with Enhanced, including the cloud pass that relies on the naga fix above.CI on WARP, shader cache: the scene module goes from 14.0 s in DXC to 0.15 s read from the cache, and openOMSI's whole set from 40.6 s to 0.7 s.
mx-gl: what Mesa (llvmpipe, OpenGL ES 3.2) found in CI
reservedMustBeZero). Without draw parameters, the shader adds the first instance from a uniform, and a GPU-side draw can't set that uniform. Without draw parameters, indirect draws now take the same route as on ES 3.0: the arguments are read back and the draw is issued directly. openOMSI makes no indirect draws.copy_texture_to_bufferof a compressed texture panicked. Now each layer's blocks are copied withglCopyImageSubData(GL 4.3 / ES 3.2) into anRG32UI/RGBA32UItexture, one texel per block, and read back from there.gl_BaseInstance, and plainglDraw*Instancedcalls leave it at 0. They now use the base-instance draws (GL 4.2). This broke render bundles and occlusion queries on GL 4.5.CI now runs green on Mesa llvmpipe both as OpenGL ES 3.2 and as desktop GL 4.5 core: 30/30 conformance, and 17/17 of openOMSI's GL modules.
Not done: openOMSI's renderer GPU tests on mX GL (ANGLE ES 3.0) give 48 passed and 42 failed, all on picture checks. Some of those features are absent on GL anyway (puddles, ray tracing, MetalFX, lamp sight, GPU timers). The rest haven't been sorted yet into GL-path differences versus mX bugs; that needs a wgpu-GL baseline of the same tests.