diff --git a/MobileGL/MG_Util/SelfTest/DriverBugProbes.cpp b/MobileGL/MG_Util/SelfTest/DriverBugProbes.cpp index 5e8b8cd0..59fea401 100644 --- a/MobileGL/MG_Util/SelfTest/DriverBugProbes.cpp +++ b/MobileGL/MG_Util/SelfTest/DriverBugProbes.cpp @@ -1701,18 +1701,13 @@ namespace MobileGL::MG_Util::SelfTest { namespace { Optional ProbeLayeredBlitDestinationBug(const GLESFunctionsTable& gl) { if (!BlitIgnoresDestinationArrayLayer(gl)) return std::nullopt; - return DriverBugFinding{"glBlitFramebuffer ignores the destination array layer", DriverBugVerdict::Fixed, - "a glBlitFramebuffer whose DRAW framebuffer attaches a non-zero array layer with " - "glFramebufferTextureLayer writes to layer 0 instead, and raises no error doing " - "it. Measured here on the color aspect; the depth aspect behaves the same way on " - "the device this was characterized on. The layer is honored everywhere else on " - "the same driver - the blit's own SOURCE layer is read correctly, which is this " - "probe's control - so neither layered attachments nor blitting is withdrawn. " - "MobileGL performs such a blit with glCopyImageSubData instead, which takes the " - "destination layer explicitly and honors it here, and applies that substitute to " - "the depth and stencil aspects as well; a blit that scales, flips, changes format, " - "resolves samples or is clipped by the scissor cannot be expressed as a copy and " - "is still handed to the driver"}; + return DriverBugFinding{ + "glBlitFramebuffer ignores the destination array layer", DriverBugVerdict::Fixed, + "Blits silently write to array layer zero when a different destination layer " + "is attached. The probe confirms this for color, and the same behavior has been " + "observed for depth. Source-layer selection works. MobileGL uses " + "glCopyImageSubData for compatible color, depth and stencil blits. The driver " + "still handles scaling, flipping, format conversion, resolves and scissor clipping."}; } // ===================== EXPLICIT VERTEX INPUT LOCATION CEILING ===================== @@ -2544,130 +2539,99 @@ namespace MobileGL::MG_Util::SelfTest { Optional ProbeExplicitVertexInputLocationCeilingBug(const GLESFunctionsTable& gl) { const VertexInputLocationCeilingMeasurement& measurement = ExplicitVertexInputLocationCeiling(gl); if (!measurement.detected) return std::nullopt; - String detail = format("GL_MAX_VERTEX_ATTRIBS is {} but the ESSL compiler refuses " - "layout(location = N) on a vertex input for every N at or above {} - so {} of " - "the {} attributes advertised cannot be declared at all", - measurement.advertisedMaxVertexAttribs, measurement.usableLocations, - measurement.advertisedMaxVertexAttribs - measurement.usableLocations, - measurement.advertisedMaxVertexAttribs); + String detail = format("The driver advertises {} vertex inputs, but the ESSL compiler rejects explicit " + "locations at or above {}.", + measurement.advertisedMaxVertexAttribs, measurement.usableLocations); if (!measurement.driverMessage.empty()) { - detail += format(" - the driver says \"{}\"", measurement.driverMessage); + detail += format(" The driver reported \"{}\".", measurement.driverMessage); } detail += measurement.bindAttribLocationReachesAdvertisedMax - ? format(". The same driver ACCEPTS glBindAttribLocation({}) on an unqualified " - "input and resolves it correctly, so the attributes are there and only " - "the layout qualifier is capped", + ? format(" glBindAttribLocation can still bind an unqualified input at location {}.", measurement.advertisedMaxVertexAttribs - 1) - : ". glBindAttribLocation does not reach those locations either, so the " - "attributes appear genuinely absent rather than merely unspellable"; - detail += format(". MobileGL emits its vertex inputs as layout qualifiers, so it advertises the " - "{} locations it can actually deliver rather than the {} the driver claims. An " - "application asking for more used to be handed a count it could not build a " - "shader against, which failed at the stage compile with no way back", - measurement.usableLocations, measurement.advertisedMaxVertexAttribs); + : " glBindAttribLocation cannot reach the highest advertised location either."; + detail += format(" MobileGL reports {} usable locations because it emits explicit locations.", + measurement.usableLocations); return DriverBugFinding{"Vertex input layout(location) capped below GL_MAX_VERTEX_ATTRIBS", DriverBugVerdict::Fixed, Move(detail)}; } Optional ProbeGeometryWriteAfterEmitBug(const GLESFunctionsTable& gl) { if (!GeometryStageSsboWriteAfterEmitDropped(gl)) return std::nullopt; - String detail = "the driver silently discards shader storage buffer writes a geometry shader " - "issues after its last EmitVertex()/EndPrimitive(); the identical write issued " - "BEFORE the emit lands, for both point and triangle geometry shaders. "; + String detail = "The driver drops geometry shader storage writes after the last vertex emission. " + "Writes before emission succeed for points and triangles. "; // The repair follows the knob, so the row describes what this process does. if (MG_Config::Features.EsprytDeferGeometryEmits == MG_Config::QuirkOverride::ForceOff) { - detail += "THE REPAIR IS DISABLED in this process (MOBILEGL_ESPRYT_DEFER_GEOMETRY_EMITS), so a " - "geometry shader that writes after emitting loses those writes"; + detail += "MOBILEGL_ESPRYT_DEFER_GEOMETRY_EMITS disables the workaround in this process."; return DriverBugFinding{"Geometry-stage storage writes after EmitVertex", DriverBugVerdict::Unfixable, Move(detail)}; } - detail += "DirectGLES defers every EmitVertex()/EndPrimitive() of a geometry stage that writes " - "memory: the outputs are snapshotted at each emit and the vertices replayed after the " - "shader body returns (DeferGeometryEmitsPass), so every write lands before any emit; " - "override with MOBILEGL_ESPRYT_DEFER_GEOMETRY_EMITS"; + detail += "DirectGLES saves vertex outputs and replays emission after the shader finishes. " + "MOBILEGL_ESPRYT_DEFER_GEOMETRY_EMITS controls this workaround."; return DriverBugFinding{"Geometry-stage storage writes after EmitVertex", DriverBugVerdict::Fixed, Move(detail)}; } Optional ProbeStaleSharedMemoryLoadBug(const GLESFunctionsTable& gl) { if (!SharedMemoryLoadsGoStale(gl)) return std::nullopt; - String detail = "the ES compiler treats ordinary loads from shared variables as pure: two reads of one " - "shared word separated by a store and barrier() (memoryBarrierShared() too) return the " - "first value, and a read can move past a later store; atomicAdd(x, 0u) reads of the same " - "words stay in place. "; + String detail = "Ordinary shared-memory reads can reuse stale values across barrier() or " + "memoryBarrierShared() and can move past a later store. Atomic reads stay ordered. "; if (MG_Config::Features.EsprytAtomicSubgroupScratch == MG_Config::QuirkOverride::ForceOff) { - detail += "THE REPAIR IS DISABLED in this process (MOBILEGL_ESPRYT_ATOMIC_SUBGROUP_SCRATCH), so " - "an emulated subgroup operation can see the lanes of an earlier one"; + detail += "MOBILEGL_ESPRYT_ATOMIC_SUBGROUP_SCRATCH disables the workaround, so emulated subgroup " + "operations can read values from earlier operations."; return DriverBugFinding{"Shared-memory loads go stale across barrier()", DriverBugVerdict::Unfixable, Move(detail)}; } - detail += "DirectGLES's subgroup emulation reads its workgroup scratch through atomic loads " - "(EmulateSubgroupsPass), so emulated subgroup operations see every lane's current value; " - "an application's own shared-memory code is passed through as written; override with " - "MOBILEGL_ESPRYT_ATOMIC_SUBGROUP_SCRATCH"; + detail += "DirectGLES uses atomic reads for emulated subgroup scratch. Application shared-memory code " + "runs as written. MOBILEGL_ESPRYT_ATOMIC_SUBGROUP_SCRATCH controls this workaround."; return DriverBugFinding{"Shared-memory loads go stale across barrier()", DriverBugVerdict::Fixed, Move(detail)}; } Optional ProbeEmptyImageUnitBug(const GLESFunctionsTable& gl) { if (!EmptyImageUnitsReadNonzero(gl)) return std::nullopt; - String detail = "a load through an image unit with no texture bound returns alpha 1 where GL 4.6 8.26 " - "says every channel is 0. "; + String detail = + "An unbound image unit reads alpha 1. OpenGL 4.6 section 8.26 specifies zero in all channels. "; if (MG_Config::Features.EsprytInvalidImagePlaceholder == MG_Config::QuirkOverride::ForceOff) { - detail += "THE REPAIR IS DISABLED in this process (MOBILEGL_ESPRYT_INVALID_IMAGE_PLACEHOLDER), so " - "a load through an invalid image unit reads alpha 1"; + detail += "MOBILEGL_ESPRYT_INVALID_IMAGE_PLACEHOLDER disables the workaround in this process."; return DriverBugFinding{"Empty image units read nonzero", DriverBugVerdict::Unfixable, Move(detail)}; } - detail += "DirectGLES binds an image unit whose texture lacks the bound level to a zeroed 1x1 texture " - "of the bind's shape, so its loads read 0 (a store through that unit can still be read back " - "through the same unit at texel 0 within one pass); a unit the application left empty stays " - "empty; override with MOBILEGL_ESPRYT_INVALID_IMAGE_PLACEHOLDER"; + detail += "DirectGLES substitutes a zeroed 1x1 texture of the bound image type when the level is missing. " + "Texel zero can retain writes within the same pass. Unbound units stay empty. " + "MOBILEGL_ESPRYT_INVALID_IMAGE_PLACEHOLDER controls this workaround."; return DriverBugFinding{"Empty image units read nonzero", DriverBugVerdict::Fixed, Move(detail)}; } Optional ProbeR32FMultisampleSwizzleBug(const GLESFunctionsTable& gl) { if (!R32FMultisampleSwizzleCorrupted(gl)) return std::nullopt; return DriverBugFinding{"R32F multisample fetch through a swizzled alpha", DriverBugVerdict::Unfixable, - "texelFetch() on an R32F GL_TEXTURE_2D_MULTISAMPLE texture whose " - "GL_TEXTURE_SWIZZLE_A is not the default returns uninitialized memory - a " - "different value every run - for any sample index other than 0, from the SECOND " - "such program in the context onward. The identical fetch with the default alpha " - "swizzle, at sample index 0, or through .x instead of .w is correct, so neither " - "R32F multisample targets nor texture swizzles are withdrawn. No substitute was " - "adopted: widening every R32F multisample target to RG32F would sidestep it and " - "doubles multisample memory, which was declined. A shader that fetches a non-zero " - "sample through a swizzled alpha cannot be relied on here"}; + "With a nondefault alpha swizzle, texelFetch reads uninitialized alpha for " + "nonzero samples starting with the second such program in the context. " + "Sample zero, red-channel reads and the default swizzle work. R32F multisampling " + "and swizzles remain available. Widening to RG32F would double storage."}; } Optional ProbeImageLocationPerNameBug(const GLESFunctionsTable& gl) { const ImageLocationBudgetMeasurement& measurement = ImageLocationPerNameBudget(gl); if (!measurement.detected) return std::nullopt; - String detail = format("this driver's image-location budget is charged per distinct uniform NAME, not per " - "image unit: a vertex+geometry+fragment program declaring {} image uniform(s) per " - "stage links when all three stages share one set of names ({} distinct) and is " - "rejected when each stage names its own copies ({} distinct), with the same " - "bindings, the same qualifiers and the same stores either way", + String detail = format("The driver counts distinct image uniform names. With {} uniforms per stage " + "across vertex, geometry and fragment stages, linking succeeds with {} shared " + "names and fails with {} stage-specific names. Bindings, qualifiers and stores " + "are identical.", measurement.perStageImageUniforms, measurement.controlDistinctNames, measurement.subjectDistinctNames); if (!measurement.driverMessage.empty()) { - detail += format(" - the driver says \"{}\"", measurement.driverMessage); + detail += format(" The driver reported \"{}\".", measurement.driverMessage); } - detail += ". MobileGL names a repaired image uniform after the REPAIR rather than after the " - "stage, so stages that use an image alike keep one shared name and stay merged; " - "applications never see the link failure"; + detail += " MobileGL shares the same uniform name across stages when they use the same image repair."; return DriverBugFinding{"Image locations charged per uniform name", DriverBugVerdict::Fixed, Move(detail)}; } Optional ProbeCrossStageImageQualifierMergeBug(const GLESFunctionsTable& gl) { if (!CrossStageImageQualifierMergeDropsWrites(gl)) return std::nullopt; return DriverBugFinding{"Cross-stage image qualifier merge discards writes", DriverBugVerdict::Fixed, - "an image declared `coherent writeonly` in one stage and `coherent readonly` in " - "another under the SAME name is merged into one uniform whose writing stage's " - "imageStore()s are then silently discarded - every fragment reads the " - "pre-store value. The identical shader pair with the two halves renamed keeps " - "every store, which is what proves the stage's image writes work and only the " - "merge is at fault. MobileGL renames the two halves (mg_imageWo_ / mg_imageRo_) so " - "the driver cannot merge them, and application behavior is correct"}; + "The driver merges same-name coherent read-only and write-only images across " + "stages and drops the stores. MobileGL gives the two uniforms distinct names, " + "which preserves the writes."}; } Optional ProbeImageCoherencyResidualBug(const GLESFunctionsTable& gl) { @@ -2678,18 +2642,12 @@ namespace MobileGL::MG_Util::SelfTest { }; return DriverBugFinding{ "Image write-to-read ordering within one invocation", DriverBugVerdict::Unfixable, - format("an imageLoad() does not observe the imageStore() that precedes it in the same " - "fragment invocation for {} of {} texels ({:.2f}%) under the STRONGEST shape " - "ESSL offers - a `coherent volatile` readonly/writeonly pair on one binding " - "with both memoryBarrierImage() and memoryBarrier() between the store and the " - "read - which is what leaves nothing to substitute. The shape MobileGL emits " - "today (`coherent` plus memoryBarrierImage()) misses {} ({:.2f}%) on this " - "driver. The same dependency split across two draws with a glMemoryBarrier and " - "a glFinish between them is clean, so writes do become visible; it is the " - "ordering inside one invocation that is not honored. MobileGL keeps the " - "coherent pair and the barrier - without them every texel is wrong - and a " - "shader that reads back its own image write within one invocation cannot be " - "relied on here", + format("An image read after a write in the same fragment invocation returned stale data for {} of {} " + "texels ({:.2f}%) even with coherent volatile declarations and both image and general memory " + "barriers. " + "MobileGL's coherent declarations and image barrier missed {} texels ({:.2f}%). " + "Removing them caused all texels to fail. Separate draws synchronized with glMemoryBarrier " + "and glFinish read back every write.", measurement.mismatchedTexels, measurement.totalTexels, percentOf(measurement.mismatchedTexels), measurement.emittedShapeMismatchedTexels, percentOf(measurement.emittedShapeMismatchedTexels))}; } @@ -2697,21 +2655,12 @@ namespace MobileGL::MG_Util::SelfTest { Optional ProbeLocatedIoBlockPayloadBug(const GLESFunctionsTable& gl) { const LocatedIoBlockMeasurement& measurement = LocatedIoBlocksLosePayload(gl); if (!measurement.detected) return std::nullopt; - String detail = "an inter-stage interface block that carries an explicit layout(location = N) " - "delivers NOTHING once a geometry (or tessellation) stage is in the pipeline: the " - "stages compile, the program links with an empty info log, the draw raises no " - "error, and the consuming stage reads zeroes. The byte-identical program with the " - "qualifier removed from the blocks carries its payload correctly, which is what " - "makes this a LOCATION defect rather than an interface-block one - blocks " - "themselves work here"; + String detail = "With tessellation or geometry stages, an explicit interface block location causes " + "the consumer to read zeros even though compilation, linking and drawing succeed. " + "The payload arrives when the location qualifier is removed."; detail += measurement.alsoAffectsVertexToFragment - ? ". A located block between a VERTEX and a FRAGMENT stage is lost on " - "this driver too, so the defect is wider than the repair below " - "reaches: MobileGL only drops the qualifier for programs that have a " - "tessellation or geometry stage, and a located block in a plain " - "vertex+fragment program is still emitted as the application wrote it" - : ". A located block between a VERTEX and a FRAGMENT stage is delivered " - "correctly on the same driver, which is what scopes the repair"; + ? " Located blocks also fail in vertex-to-fragment programs, outside the workaround's scope." + : " Located blocks work in vertex-to-fragment programs."; // The repair can be switched off from the environment, and a report that said // "Fixed" while the strip was disabled would be describing a build nobody is // running. The verdict follows what this process will actually do, not what the @@ -2719,15 +2668,11 @@ namespace MobileGL::MG_Util::SelfTest { const Bool repairDisabled = MG_Config::Features.EsprytUnlocatedIoBlocks == MG_Config::QuirkOverride::ForceOff; if (repairDisabled) { - detail += ". THE REPAIR IS DISABLED in this process: MOBILEGL_ESPRYT_UNLOCATED_IO_BLOCKS " - "is set to force located blocks ON, so DirectGLES emits the location " - "qualifier the driver cannot honor and the payload is lost. Unset the " - "variable to get the repair back"; + detail += " MOBILEGL_ESPRYT_UNLOCATED_IO_BLOCKS forces the faulty qualifiers on. " + "The workaround is inactive."; } else { - detail += ". MobileGL emits a tessellation/geometry program's interface blocks with no " - "location qualifier at all (StripIoBlockLocationsPass) and lets ES match them " - "by block name and member sequence, which it does; the locations were invented " - "by the cross-stage IO resolver rather than written by the application"; + detail += " MobileGL removes generated block locations in tessellation and geometry programs. " + "The driver then matches blocks by name and member order."; } return DriverBugFinding{"Located inter-stage interface blocks carry no payload", (repairDisabled || measurement.alsoAffectsVertexToFragment) @@ -2746,28 +2691,18 @@ namespace MobileGL::MG_Util::SelfTest { // its Auto default - which is also what the widening itself consults, so the row // and the behavior cannot disagree. const Bool widened = MG_Config::Features.EsprytWidenPacked16Storage != MG_Config::QuirkOverride::ForceOff; - String detail = "the driver stores SOME 16-bit packed images (RGB565 / RGB5_A1 / RGBA4) with the " - "R/G/B/A fields packed from the other end of the word - which allocations get the " - "*_REV layout depends on shape and context history (measured here on a 30x30x12 " - "three-level 2D array, every level of it) - so a glCopyImageSubData, a raw " - "texel-block move, between a mirrored allocation and a plain one lands the fields " - "reversed (a 5551 word 0x0047 arrives as 0x8C20). Uploads and readbacks of the " - "same image are clean - the driver decodes its own layout consistently, which is " - "this probe's second control - so only the raw-copy path ever crosses the two " - "layouts. "; + String detail = "The driver reverses the packed fields of some RGB565, RGB5_A1 and RGBA4 allocations. " + "This depends on image shape and context history. The probe found it at all three levels " + "of a 30x30x12 array. A raw glCopyImageSubData between different layouts changed a " + "RGB5_A1 word from 0x0047 to 0x8C20. Uploads and readbacks within one image succeed. "; if (widened) { - detail += "MobileGL stores these three formats as 8-bit-per-channel ES storage on this " - "driver instead (GL_RGB8 / GL_RGBA8, the storage their canonical shadow " - "already holds and the client word round-trips through exactly), so no " - "16-bit packed image is left for a copy to disagree about, at twice the " - "memory for images of those formats; override with " - "MOBILEGL_ESPRYT_WIDEN_PACKED16_STORAGE"; + detail += "MobileGL uses RGB8 or RGBA8 storage to preserve exact packed values at twice the " + "storage cost. MOBILEGL_ESPRYT_WIDEN_PACKED16_STORAGE controls storage widening."; return DriverBugFinding{ "glCopyImageSubData mirrors 16-bit packed texels between differently-laid-out images", DriverBugVerdict::Fixed, detail}; } - detail += "MOBILEGL_ESPRYT_WIDEN_PACKED16_STORAGE=0 keeps the native narrow storage, so such " - "copies are left exactly as the driver delivers them, mirrored words included"; + detail += "MOBILEGL_ESPRYT_WIDEN_PACKED16_STORAGE=0 keeps native storage and leaves raw copies affected."; return DriverBugFinding{ "glCopyImageSubData mirrors 16-bit packed texels between differently-laid-out images", DriverBugVerdict::Unfixable, detail}; @@ -2810,22 +2745,15 @@ namespace MobileGL::MG_Util::SelfTest { using namespace MG_Backend::DirectVulkan; if (EvaluateWireDepthResolveProbe(measurement) != WireDepthResolveProbeVerdict::RenderPassResolveBroken) return std::nullopt; - String detail = - "a render pass whose subpass carries a VK_KHR_depth_stencil_resolve attachment (SAMPLE_ZERO) and " - "records no draw leaves its single-sample resolve target unwritten, while MobileGL's shader " - "resolve pass fed the same multisample inputs resolves them correctly - measured here on 4x4 " - "4-sample images cleared to depth 0.25 / stencil 0x5A over a depth 0.75 / stencil 0xA5 " - "sentinel: "; + String detail = "A draw-free SAMPLE_ZERO render pass leaves the resolve target unwritten. " + "The shader control resolves the same 4x4, 4-sample images (depth 0.25 and stencil 0x5A " + "over depth 0.75 and stencil 0xA5). "; detail += DescribeWireDepthResolveProbe(measurement); - detail += ". On the split, inproc and tcp transports a multisample depth/stencil resolve " - "(glBlitFramebuffer out of a multisample framebuffer) therefore takes the shader pass " - "first - sample 0 fetched and written through gl_FragDepth / gl_FragStencilRefARB - and " - "keeps the render pass only as the fallback for what the shader cannot write; the " - "monolith transport never records that render pass"; + detail += ". Split, inproc and TCP transports try the sample-zero shader resolve first and use the " + "render pass for any aspect the shader cannot write. The monolith transport skips this pass."; if (!shaderStencilExport) { - detail += ". THIS DEVICE HAS NO VK_EXT_shader_stencil_export, so a fragment shader cannot write " - "the stencil aspect: a STENCIL resolve still falls back to the render pass and reads " - "back unwritten. Depth is repaired, stencil is not"; + detail += " Without VK_EXT_shader_stencil_export, the shader resolves depth only. Stencil still uses " + "the faulty render pass and remains unwritten."; } return DriverBugFinding{"Depth/stencil render-pass resolve writes nothing", shaderStencilExport ? DriverBugVerdict::Fixed : DriverBugVerdict::Unfixable, @@ -2865,14 +2793,13 @@ namespace MobileGL::MG_Util::SelfTest { MGLOG_I("Driver POST: E5B9G9R9 transfer probe verdict=%s: %s", WireE5TransferProbeVerdictName(verdict), DescribeWireE5TransferProbe(measurement).c_str()); if (verdict != WireE5TransferProbeVerdict::TransferReadNormalizes) return std::nullopt; - String detail = "vkCmdCopyImageToBuffer out of a 30x30 VK_FORMAT_E5B9G9R9_UFLOAT_PACK32 image returns " - "non-canonical shared-exponent words re-encoded (same value, different bits), while a " - "compute shader reading the same image through an R32_UINT view returns every stored " - "word: "; + String detail = "vkCmdCopyImageToBuffer changes the encoding of noncanonical E5B9G9R9 texels in a " + "30x30 image without changing their values. A compute shader with an R32_UINT view " + "preserves the bits. "; detail += DescribeWireE5TransferProbe(measurement); - detail += ". GL moves RGB9_E5 blocks bit-exactly (glGetTexImage with UNSIGNED_INT_5_9_9_9_REV, " - "glCopyImageSubData), so Magma reads such textures through that shader into an R32_UINT " - "twin and copies the twin instead (MOBILEGL_MAGMA_E5_RAW_READS=0 turns it off)"; + detail += ". Magma copies an R32_UINT intermediate to preserve RGB9_E5 bits during packed " + "glGetTexImage readbacks and glCopyImageSubData copies. " + "MOBILEGL_MAGMA_E5_RAW_READS=0 disables the intermediate."; return DriverBugFinding{"E5B9G9R9 transfer reads canonicalize shared exponents", DriverBugVerdict::Fixed, Move(detail)}; } @@ -2888,12 +2815,11 @@ namespace MobileGL::MG_Util::SelfTest { MGLOG_I("Driver POST: slice copy probe verdict=%s: %s", WireCopySliceProbeVerdictName(verdict), DescribeWireCopySliceProbe(measurement).c_str()); if (verdict != WireCopySliceProbeVerdict::CrossFormatSlicesDropped) return std::nullopt; - String detail = - "a vkCmdCopyImage region between a 2D array and a 3D image of DIFFERENT (size-compatible) " - "formats moves only its first slice, while the same copy as one region per slice is exact: "; + String detail = "A vkCmdCopyImage region between a 2D array and a 3D image of different " + "size-compatible formats copies only the first slice. One region per slice works. "; detail += DescribeWireCopySliceProbe(measurement); - detail += ". Magma splits such glCopyImageSubData calls one slice per region " - "(MOBILEGL_MAGMA_SPLIT_SLICE_COPIES=0 turns it off)"; + detail += ". Magma emits one region per slice for these glCopyImageSubData calls. " + "MOBILEGL_MAGMA_SPLIT_SLICE_COPIES=0 disables this split."; return DriverBugFinding{"Cross-format 2D-array <-> 3D image copies drop slices", DriverBugVerdict::Fixed, Move(detail)}; } @@ -2909,12 +2835,11 @@ namespace MobileGL::MG_Util::SelfTest { MGLOG_I("Driver POST: discard state probe verdict=%s: %s", WireDiscardStateProbeVerdictName(verdict), DescribeWireDiscardStateProbe(measurement).c_str()); if (verdict != WireDiscardStateProbeVerdict::DiscardDrawDropsState) return std::nullopt; - String detail = - "a draw with a rasterizerDiscardEnable pipeline drops the dynamic viewport/scissor, so a later " - "draw that inherits them draws nothing, while after a rasterizing draw it does: "; + String detail = "A rasterizer-discard draw drops the dynamic viewport and scissor state. The next " + "draw produces no fragments if it inherits that state. "; detail += DescribeWireDiscardStateProbe(measurement); - detail += ". Magma sets the dynamic state again after every discard draw " - "(MOBILEGL_MAGMA_REEMIT_STATE_AFTER_DISCARD=0 turns it off)"; + detail += ". Magma reissues viewport and scissor state after each discard draw. " + "MOBILEGL_MAGMA_REEMIT_STATE_AFTER_DISCARD=0 disables state reissue."; return DriverBugFinding{"Rasterizer-discard draws drop dynamic viewport/scissor", DriverBugVerdict::Fixed, Move(detail)}; } diff --git a/MobileGL/MG_Util/SelfTest/DriverPost.cpp b/MobileGL/MG_Util/SelfTest/DriverPost.cpp index d0c761e9..34621d7d 100644 --- a/MobileGL/MG_Util/SelfTest/DriverPost.cpp +++ b/MobileGL/MG_Util/SelfTest/DriverPost.cpp @@ -65,13 +65,10 @@ namespace MobileGL::MG_Util::SelfTest { String AppendFp64AdvertisementNote(String detail) { if (MG_Config::Features.AdvertiseFp64) { return Move(detail) + - ". GL_ARB_gpu_shader_fp64 IS advertised (MOBILEGL_ADVERTISE_FP64): an application " - "that checks the string will believe it has 64-bit precision, which is true only " - "where the row above says native"; + ". MOBILEGL_ADVERTISE_FP64 enables GL_ARB_gpu_shader_fp64. Full precision requires native fp64."; } return Move(detail) + - ". GL_ARB_gpu_shader_fp64 is not advertised by default; set MOBILEGL_ADVERTISE_FP64=1 " - "to advertise it anyway"; + ". GL_ARB_gpu_shader_fp64 is hidden by default. MOBILEGL_ADVERTISE_FP64 controls exposure."; } // ===================== THE ROW VERDICT TAXONOMY ===================== @@ -622,19 +619,11 @@ namespace MobileGL::MG_Util::SelfTest { // fp64 directly at all. What it has is a complete substitute - the shaders build and // run - which is exactly what WARN means. builder.Warn("fp64", AppendFp64AdvertisementNote( - "demoted to fp32 - ESSL has no 64-bit float type, so every double / " - "dvec / dmat in a shader is narrowed to 32 bits before transpilation " - "(DemoteFloat64Pass). Such shaders COMPILE AND RUN, at single " - "precision; a block containing a double is re-laid-out for the " - "narrowed members, so an application that hard-codes std140 offsets " - "computed for doubles must query them instead")); + "ESSL has no fp64 type. MobileGL narrows shader values to fp32 and recalculates " + "buffer block layouts.")); builder.Warn("64-bit vertex attributes", - "narrowed to float32 (ES has no GL_DOUBLE vertex format, and after the fp64 " - "demotion above there is no 64-bit shader input left to feed either); " - "glVertexAttribLFormat / glVertexArrayAttribLFormat succeed, their state is " - "queryable, and an ENABLED 64-bit array IS fetched - the source doubles are " - "deinterleaved into a float32 stream at draw, so values outside float32's " - "range or precision are rounded rather than exact"); + "MobileGL converts GL_DOUBLE vertex arrays to float32 at draw time. " + "glVertexAttribLFormat and glVertexArrayAttribLFormat retain their GL state."); if (glesFuncs.glPatchParameteri != nullptr) { builder.Pass("Tessellation patch parameters", "glPatchParameteri present (GL_PATCH_VERTICES reaches the driver)"); @@ -669,10 +658,9 @@ namespace MobileGL::MG_Util::SelfTest { "SNORM render target keeps its own encoding instead of a float substitute)"); } else { builder.Warn("GL_EXT_render_snorm", - "not supported; signed-normalized formats are texture-only, so every SNORM " - "render target is stored as a float (8-bit -> *16F, 16-bit -> *32F, which " - "is the narrowest float that still holds a 16-bit SNORM channel exactly) " - "and its fragment outputs are clamped to [-1,1] in software"); + "The driver cannot render to signed-normalized formats. MobileGL stores 8-bit SNORM " + "channels as 16-bit floats and 16-bit SNORM channels as 32-bit floats to preserve " + "precision. MobileGL clamps fragment outputs between -1 and 1."); } // FAIL, not WARN: ES 3.x core makes every float format texture-only, and every Iris // shaderpack renders into at least GL_R11F_G11F_B10F (Complementary's colortex0, BSL's @@ -680,8 +668,7 @@ namespace MobileGL::MG_Util::SelfTest { // is not renderable either - so shaderpacks cannot work at all on such a driver. if (caps.SupportsColorBufferFloat) { builder.Pass("GL_EXT_color_buffer_float", - "supported (GL_R11F_G11F_B10F / GL_RGBA16F / GL_RGBA32F are " - "color-renderable, which is what every shaderpack renders into)"); + "GL_R11F_G11F_B10F, GL_RGBA16F, and GL_RGBA32F are color-renderable."); } else if (caps.SupportsColorBufferHalfFloat) { builder.Warn("GL_EXT_color_buffer_float", "not supported, but GL_EXT_color_buffer_half_float is; 16-bit float render " @@ -689,9 +676,8 @@ namespace MobileGL::MG_Util::SelfTest { "that lands on it) do not"); } else { builder.Fail("GL_EXT_color_buffer_float", - "not supported, and neither is GL_EXT_color_buffer_half_float; no floating-point " - "format is color-renderable on this driver, so no shaderpack can create its " - "render targets (Iris reports GL_FRAMEBUFFER_UNSUPPORTED and refuses to load)"); + "Neither GL_EXT_color_buffer_float nor GL_EXT_color_buffer_half_float is available. " + "The driver exposes no floating-point color-renderable format."); } // WARN and never FAIL when it is absent: this is the HOST driver's ability to @@ -705,10 +691,9 @@ namespace MobileGL::MG_Util::SelfTest { builder.Pass("Driver GL_KHR_parallel_shader_compile", "supported; the device driver can also compile the translated ESSL off-thread"); } else { - builder.Warn("Driver GL_KHR_parallel_shader_compile", - "not supported; the device driver compiles the translated ESSL on the calling " - "thread. MobileGL's own compile pool substitutes for the expensive half of the " - "work (GLSL -> SPIR-V -> ESSL) and is unaffected, so loads still overlap"); + builder.Warn( + "Driver GL_KHR_parallel_shader_compile", + "The driver compiles ESSL on the calling thread. MobileGL translates shaders in parallel."); } if (caps.IndirectDrawInstanceIdIncludesBaseInstance) { @@ -733,11 +718,10 @@ namespace MobileGL::MG_Util::SelfTest { const MG_External::GLESFunctionsTable& glesFuncs) { const String disabledNote = TimerQueryDisabledNote(); if (!caps.SupportsDisjointTimerQuery) { - builder.FailOptional("Timer queries", - "GL_EXT_disjoint_timer_query not supported; there is no way to time " - "GPU work from the client, so glBeginQuery(GL_TIME_ELAPSED) has " - "nothing to stand in for it and Minecraft's F3 GPU% will not show" + - disabledNote); + builder.FailOptional( + "Timer queries", + "GL_EXT_disjoint_timer_query is unavailable. MobileGL has no GL_TIME_ELAPSED fallback." + + disabledNote); return; } // Every emit carries the extension-presence fact the old standalone @@ -1091,7 +1075,7 @@ namespace MobileGL::MG_Util::SelfTest { MG_Util::TextureFormatProcessor::NormalizePixelFormat( MG_Util::ConvertTextureInternalFormatToGLEnum(probedFormat), renderTargetOptions, &widenedInternalFormat, nullptr, nullptr); - append(widenedList, name + " -> " + MG_Util::ConvertGLEnumToString(widenedInternalFormat)); + append(widenedList, name + " to " + MG_Util::ConvertGLEnumToString(widenedInternalFormat)); continue; } append(unusableList, name); @@ -1105,7 +1089,7 @@ namespace MobileGL::MG_Util::SelfTest { } if (!unusableList.empty()) { if (!detail.empty()) detail += "; "; - detail += "NOT renderable and not substitutable: " + unusableList; + detail += "not renderable and no substitute available: " + unusableList; } // The verdict deliberately does NOT track "every probed format came out usable". @@ -1146,7 +1130,7 @@ namespace MobileGL::MG_Util::SelfTest { } else if (!widenedList.empty()) { builder.Warn("Three-channel color attachments", detail + " - the substitution costs the extra alpha channel's memory and is " - "hidden from the application by an ALPHA->ONE swizzle"); + "hidden from the application by a swizzle that sets alpha to one"); } else { builder.Pass("Three-channel color attachments", detail); } @@ -1641,8 +1625,8 @@ namespace MobileGL::MG_Util::SelfTest { if (!HasVkExtension(deviceExtensions, VK_EXT_TRANSFORM_FEEDBACK_EXTENSION_NAME) || getFeatures2 == nullptr || getProperties2 == nullptr) { - fail("VK_EXT_transform_feedback is unavailable, so the backend has no GPU counter for " - "GL_PRIMITIVES_GENERATED at all - with or without a capture"); + fail("Without VK_EXT_transform_feedback, the backend has no GPU counter for " + "GL_PRIMITIVES_GENERATED, even during capture."); return; } VkPhysicalDeviceTransformFeedbackFeaturesEXT xfbFeatures{}; @@ -1658,9 +1642,8 @@ namespace MobileGL::MG_Util::SelfTest { properties2.pNext = &xfbProperties; getProperties2(physicalDevice, &properties2); if (xfbFeatures.transformFeedback != VK_TRUE || xfbProperties.transformFeedbackQueries != VK_TRUE) { - fail("the device has VK_EXT_transform_feedback but no usable stream queries " - "(transformFeedbackQueries = false); GL_PRIMITIVES_GENERATED and " - "GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN queries answer 0"); + fail("VK_EXT_transform_feedback does not provide usable stream queries on this device. " + "GL_PRIMITIVES_GENERATED and GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN return 0."); return; } @@ -1810,33 +1793,33 @@ namespace MobileGL::MG_Util::SelfTest { // Before any return below: the guard above owns the device and must know. probeFenceWaitTimedOut = measurement.fenceWaitTimedOut; if (!measurement.ran) { - fail(format("the probe could not run ({}); the renderer's bring-up probe decides the " - "reroute independently", - measurement.failureReason)); + fail(format( + "The probe could not run ({}). The renderer tests independently whether to use a substitute.", + measurement.failureReason)); return; } const auto shapeFacts = [](const char* name, const PrimitivesGeneratedNoXfbShapeMeasurement& shape) { if (!shape.drawn) { - return format("{} not drawn (no tessellationShader)", name); + return format("The probe skipped {} because tessellationShader is unavailable.", name); } - String facts = format("{}: stream answered {} of {} expected", name, shape.streamGenerated, - shape.expectedPrimitives); + String facts = format("For {}, the stream query counted {} of {} expected primitives", name, + shape.streamGenerated, shape.expectedPrimitives); if (shape.primitivesGeneratedExtMeasured) { - facts += format(", dedicated query answered {}", shape.primitivesGeneratedExt); + facts += format(", and the dedicated query counted {}", shape.primitivesGeneratedExt); } if (shape.statisticsMeasured) { - facts += format(", statistics control answered {}", shape.statisticsClippingInput); + facts += format(", and the statistics query counted {}", shape.statisticsClippingInput); } if (!shape.primitivesGeneratedExtMeasured && !shape.statisticsMeasured) { - facts += ", no control (neither VK_EXT_primitives_generated_query with its " - "discard feature nor pipelineStatisticsQuery is available)"; + facts += ". Neither a dedicated query with discard support nor a pipeline statistics query was " + "available"; } - return facts; + return facts + "."; }; - const String facts = shapeFacts("triangles", measurement.trianglesPlain) + "; " + - shapeFacts("triangles under discard", measurement.trianglesDiscard) + "; " + - shapeFacts("patches under discard", measurement.patchesDiscard); + const String facts = shapeFacts("triangles", measurement.trianglesPlain) + " " + + shapeFacts("triangles with rasterizer discard", measurement.trianglesDiscard) + " " + + shapeFacts("patches with rasterizer discard", measurement.patchesDiscard); const auto statisticsExactOn = [](const PrimitivesGeneratedNoXfbShapeMeasurement& shape) { return shape.statisticsMeasured && shape.statisticsClippingInput == shape.expectedPrimitives; @@ -1870,54 +1853,41 @@ namespace MobileGL::MG_Util::SelfTest { // whether THIS driver's substitute covers it instead of assuming it does not. const auto describeCtsShape = [&]() -> String { if (!measurement.patchesDiscard.drawn) { - return "the CTS's tessellator-measuring shape (a PATCHES draw under discard) could " - "not be measured here - this device has no tessellationShader - so whether " - "the substitute covers it is unknown"; + return "The probe could not verify the CTS tessellation case because tessellationShader is " + "unavailable."; } return statisticsExactOn(measurement.patchesDiscard) - ? "the CTS's tessellator-measuring shape (a PATCHES draw under discard) is " - "NOT among them: the substitute answers it exactly, so those tests are " - "repaired" - : "the CTS's tessellator-measuring shape (a PATCHES draw under discard) is " - "among them, so those tests stay broken on this driver"; + ? "The substitute counts the CTS tessellation case correctly." + : "The substitute fails the CTS tessellation probe."; }; switch (EvaluatePrimitivesGeneratedNoXfbVerdict(measurement)) { case PrimitivesGeneratedNoXfbVerdict::StreamCounts: - builder.Pass(RowName, "the stream query counts a draw made with no capture span open, as " - "VK_EXT_transform_feedback defines (" + - facts + ")"); + builder.Pass(RowName, "The stream query counts primitives without active transform feedback, as " + "VK_EXT_transform_feedback specifies. " + + facts); return; case PrimitivesGeneratedNoXfbVerdict::PrimitivesGeneratedExtSubstitute: - builder.Warn(RowName, "the stream query answers 0 for a draw made with no capture span open - " - "the shape the CTS measures the tessellator with - while a " - "VK_QUERY_TYPE_PRIMITIVES_GENERATED_EXT query around an identical replay answers " - "exactly right, rasterizer discard included, so the renderer " - "accumulates GL_PRIMITIVES_GENERATED for such draws through the " - "dedicated query instead (one extra query slot per XFB-inactive draw " - "inside a GENERATED span; " + - facts + ")"); + builder.Warn(RowName, + "The stream query returns 0 without active transform feedback. The renderer uses " + "VK_QUERY_TYPE_PRIMITIVES_GENERATED_EXT to count these draws correctly, including " + "draws with rasterizer discard. Each draw counted by GL_PRIMITIVES_GENERATED uses one " + "extra query slot. " + + facts); return; case PrimitivesGeneratedNoXfbVerdict::StatisticsSubstitute: - builder.Warn(RowName, - "the stream query answers 0 for a draw made with no capture span open - " - "the shape the CTS measures the tessellator with - while a " - "clipping-invocations statistics query around an identical replay answers exactly " - "right, rasterizer discard included, so the renderer accumulates " - "GL_PRIMITIVES_GENERATED for such draws through a pipeline-statistics " - "pool instead (one extra query slot per XFB-inactive draw inside a " - "GENERATED span; " + - facts + ")"); + builder.Warn(RowName, "The stream query returns 0 without active transform feedback. The renderer uses " + "a clipping-invocations query to count these draws correctly, including draws " + "with rasterizer discard. Each draw counted by GL_PRIMITIVES_GENERATED uses one " + "extra query slot. " + + facts); return; case PrimitivesGeneratedNoXfbVerdict::StatisticsSubstitutePlainOnly: - fail("the stream query answers 0 for a draw made with no capture span open, and the " - "clipping-invocations statistics substitute counts the plain draw exactly but " - "misses " + + fail("The clipping-invocations query counts the plain draw correctly but misses " + describeMissedStatisticsShapes() + - " - each of them a shape the stream query answered 0 for as well, so the renderer " - "reroutes XFB-inactive draws (repairing every shape the substitute answers, at no " - "cost to the rest, which is what the verdict requires); " + - describeCtsShape() + " (" + facts + ")"); + ". The stream query also returned 0 for those draws. The renderer uses the substitute without " + "active transform feedback. " + + describeCtsShape()); return; case PrimitivesGeneratedNoXfbVerdict::Unfixable: { // Two ways to land here, and the report must not conflate them: no @@ -1940,28 +1910,22 @@ namespace MobileGL::MG_Util::SelfTest { noteDowngrade("triangles under rasterizer discard", measurement.trianglesDiscard); noteDowngrade("patches under rasterizer discard", measurement.patchesDiscard); if (statisticsExactOn(measurement.trianglesPlain) && !downgradeShapes.empty()) { - fail("the stream query answers 0 for a draw made with no capture span open, and the " - "clipping-invocations statistics substitute repairs the plain draw but is wrong " - "on " + - downgradeShapes + - ", which the stream query answers exactly - rerouting every XFB-inactive draw " - "would trade a correct count for a wrong one, so MobileGL arms nothing and the " - "capture-less query keeps the driver's answers (" + - facts + ")"); + fail("The clipping-invocations query would replace correct stream counts for " + downgradeShapes + + " with incorrect counts. MobileGL keeps the stream query, which returns 0 for the plain " + "draw without active transform feedback. " + + facts); return; } - fail("the stream query answers 0 for a draw made with no capture span open and the " - "device offers no working statistics substitute; an application sizing a capture " - "buffer from GL_PRIMITIVES_GENERATED gets 0 (" + - facts + ")"); + fail("The stream query returns 0 without active transform feedback. No statistics substitute passed. " + + facts); return; } case PrimitivesGeneratedNoXfbVerdict::Inconclusive: break; } - fail("the probe reached no verdict - the answers fit neither the defect nor health, and " - "MobileGL declines to repair a driver it does not understand (" + - facts + ")"); + fail("The probe could not determine whether the stream query works without active transform feedback. " + "MobileGL keeps the driver query. " + + facts); } // Native iterationRP compute witness. This deliberately uses a separate @@ -2009,9 +1973,7 @@ namespace MobileGL::MG_Util::SelfTest { // WARN, not FAIL: there is nothing to witness on a device with no native // subgroup contract, and the renderer takes its non-subgroup iteration path, // which produces the same image. - builder.Warn(RowName, eligibility.detail + - "; the renderer takes its non-subgroup iteration path instead, which " - "renders the same thing without the first-reduction shortcut"); + builder.Warn(RowName, eligibility.detail + ". MobileGL uses its non-subgroup iteration path."); return; } if (eligibility.eligibility == IterationRPWitnessEligibility::FailInadequateLimits) { @@ -2524,12 +2486,12 @@ namespace MobileGL::MG_Util::SelfTest { // fallback costs a buffer queue the headless path does not need, and because // this used to abort the process instead. if (HasVkExtension(instanceExtensions, VK_EXT_HEADLESS_SURFACE_EXTENSION_NAME)) { - builder.Pass("Headless surface", format("{} present; windowless contexts get a real headless surface", - VK_EXT_HEADLESS_SURFACE_EXTENSION_NAME)); + builder.Pass("Headless surface", + format("Windowless contexts use {}.", VK_EXT_HEADLESS_SURFACE_EXTENSION_NAME)); } else { builder.Warn("Headless surface", - format("{} absent; a windowless (pbuffer) context falls back to an AImageReader " - "ANativeWindow, which needs libmediandk.so and an extra buffer queue", + format("Without {}, pbuffer contexts use an AImageReader ANativeWindow. This requires " + "libmediandk.so and an extra buffer queue.", VK_EXT_HEADLESS_SURFACE_EXTENSION_NAME)); } @@ -2736,20 +2698,21 @@ namespace MobileGL::MG_Util::SelfTest { multiDrawExtUsable = multiDrawFeatures.multiDraw == VK_TRUE; } if (multiDrawExtUsable) { - builder.Pass("VK_EXT_multi_draw", - "supported; a glMultiDraw* batch runs as one vkCmdDrawMulti(Indexed)EXT"); + builder.Pass( + "VK_EXT_multi_draw", + "The backend submits each batch in one vkCmdDrawMultiEXT or vkCmdDrawMultiIndexedEXT call."); } else { - builder.Warn("VK_EXT_multi_draw", - "unsupported; glMultiDraw* batches take the indirect or unrolled tier " - "instead, with identical output"); + builder.Warn("VK_EXT_multi_draw", "MobileGL falls back to indirect or individual draws."); } const char* resolvedTier = multiDrawExtUsable ? "ext" : features.multiDrawIndirect == VK_TRUE ? "indirect" : "unroll"; - String tierDetail = format("default tier \"{}\" (chain: ext -> indirect -> unroll)", resolvedTier); + String tierDetail = format("The default tier is {}. MobileGL prefers the extension, then indirect draws, " + "then individual draws.", + resolvedTier); const MG_Config::MultiDrawMode multiDrawMode = MG_Config::Features.MagmaMultiDrawMode; if (multiDrawMode != MG_Config::MultiDrawMode::Auto) { - tierDetail += format("; MOBILEGL_MAGMA_MULTIDRAW_MODE={} caps it (clamped to device support)", + tierDetail += format(" MOBILEGL_MAGMA_MULTIDRAW_MODE caps the tier at {}, subject to device support.", multiDrawMode == MG_Config::MultiDrawMode::Ext ? "ext" : multiDrawMode == MG_Config::MultiDrawMode::Indirect ? "indirect" : "unroll"); @@ -2758,9 +2721,7 @@ namespace MobileGL::MG_Util::SelfTest { if (multiDrawExtUsable) { builder.Pass("Multi-draw dispatch tier", tierDetail); } else { - builder.Warn("Multi-draw dispatch tier", - tierDetail + "; the batch is replayed rather than handed over whole, which " - "renders the same thing for more commands"); + builder.Warn("Multi-draw dispatch tier", tierDetail + " The fallback can submit more commands."); } } if (features.vertexPipelineStoresAndAtomics == VK_TRUE) { @@ -2858,33 +2819,22 @@ namespace MobileGL::MG_Util::SelfTest { // and Mali both report VK_FALSE, so the demoted row is what a real phone prints; lavapipe // reports VK_TRUE and gets real doubles. if (features.shaderFloat64 == VK_TRUE) { - builder.Pass("fp64", AppendFp64AdvertisementNote( - "native (device shaderFloat64 = supported) - every double / dvec / dmat in " - "a shader keeps its declared width, blocks keep the layout glslang computed " - "for them, and glUniform*d stores 8-byte components. The one exception is a " - "VERTEX stage that declares a 64-bit float INPUT: there is no 64-bit vertex " - "FETCH here, so such a program is narrowed whole exactly as it would be on a " - "device without the feature")); + builder.Pass("fp64", + AppendFp64AdvertisementNote( + "The device supports shaderFloat64. MobileGL preserves fp64 unless the vertex stage " + "declares a 64-bit floating-point input, which triggers program-wide demotion.")); } else { // WARN rather than PASS: the device does not support fp64 at all here, and what // stands in for it is a MobileGL pass that narrows the shader. It runs, at single // precision - the definition of a substitute. - builder.Warn("fp64", AppendFp64AdvertisementNote( - "demoted to fp32 (device shaderFloat64 = unsupported) - every double / dvec " - "/ dmat in a shader is narrowed to 32 bits before pipeline creation, so such " - "shaders BUILD AND RUN at single precision instead of failing to create a " - "shader module. A block containing a double is re-laid-out for the narrowed " - "members, so an application that hard-codes std140 offsets computed for " - "doubles must query them instead")); + builder.Warn("fp64", + AppendFp64AdvertisementNote( + "The device does not support shaderFloat64. MobileGL narrows shader values to fp32 " + "before pipeline creation and recalculates buffer block layouts.")); } builder.Warn("64-bit vertex attributes", - "narrowed to float32 on every device, whatever the row above says: there is no " - "VK_FORMAT_R64*_SFLOAT vertex fetch here, and the format is chosen from the VAO " - "attribute, which does not know what type the shader declared - which is why a " - "vertex stage with a 64-bit float INPUT is narrowed whole even where fp64 is native. " - "glVertexAttribLFormat succeeds, its state is queryable, and an ENABLED 64-bit array " - "IS fetched - the source doubles are deinterleaved into a float32 stream at draw, so " - "values outside float32's range or precision are rounded rather than exact"); + "MobileGL converts 64-bit vertex arrays to float32 at draw time, including on devices with " + "shaderFloat64. A 64-bit floating-point vertex input triggers program-wide fp64 demotion."); Bool shaderDrawParameters = false; if (vkGetPhysicalDeviceFeatures2Fn != nullptr && properties.apiVersion >= VK_API_VERSION_1_1) { @@ -2900,7 +2850,7 @@ namespace MobileGL::MG_Util::SelfTest { shaderDrawParameters = true; } if (shaderDrawParameters) { - builder.Pass("shaderDrawParameters", "gl_DrawID/gl_BaseVertex/gl_BaseInstance shaders supported"); + builder.Pass("shaderDrawParameters", "Shaders can read gl_DrawID, gl_BaseVertex, and gl_BaseInstance."); } else { builder.FailOptional("shaderDrawParameters", "unavailable; a shader reading gl_DrawID, gl_BaseVertex or " diff --git a/MobileGL/MG_Util/SelfTest/DriverPostIterationRPWitness.cpp b/MobileGL/MG_Util/SelfTest/DriverPostIterationRPWitness.cpp index ddfb6af9..2d4ef8b7 100644 --- a/MobileGL/MG_Util/SelfTest/DriverPostIterationRPWitness.cpp +++ b/MobileGL/MG_Util/SelfTest/DriverPostIterationRPWitness.cpp @@ -138,44 +138,44 @@ namespace MobileGL::MG_Util::SelfTest { const std::uint32_t numSubgroups = output.numSubgroups; if (numSubgroups < 2u || numSubgroups > kIterationRPWitnessMaxSubgroups) { std::ostringstream detail; - detail << "topology: canonical gl_NumSubgroups=" << numSubgroups << " is outside [2, 32]"; + detail << "The workgroup reported " << numSubgroups << " subgroups. The probe requires 2 to 32."; return Failure(IterationRPWitnessValidationFailure::Topology, detail.str()); } if ((output.topologyFlags & IterationRPWitnessNonuniformNumSubgroups) != 0u) { return Failure(IterationRPWitnessValidationFailure::Topology, - "topology: gl_NumSubgroups differed across workgroup"); + "gl_NumSubgroups differed across workgroup invocations."); } if ((output.topologyFlags & IterationRPWitnessInvalidNumSubgroups) != 0u) { return Failure(IterationRPWitnessValidationFailure::Topology, - "topology: an invocation reported gl_NumSubgroups outside [2, 32]"); + "One invocation reported a subgroup count outside the supported range of 2 to 32."); } if ((output.topologyFlags & IterationRPWitnessInvalidSubgroupId) != 0u) { return Failure(IterationRPWitnessValidationFailure::Topology, - "topology: an invocation reported an invalid gl_SubgroupID"); + "One invocation reported an invalid gl_SubgroupID."); } if ((output.topologyFlags & IterationRPWitnessInvalidSubgroupLane) != 0u) { return Failure(IterationRPWitnessValidationFailure::Topology, - "topology: an invocation reported an invalid subgroup lane"); + "One invocation reported an invalid subgroup lane."); } if ((output.topologyFlags & ~(IterationRPWitnessNonuniformNumSubgroups | IterationRPWitnessInvalidNumSubgroups | IterationRPWitnessInvalidSubgroupId | IterationRPWitnessInvalidSubgroupLane)) != 0u) { std::ostringstream detail; - detail << "topology: unknown topology flags 0x" << std::hex << output.topologyFlags; + detail << "The probe reported unknown topology flags 0x" << std::hex << output.topologyFlags; return Failure(IterationRPWitnessValidationFailure::Topology, detail.str()); } const std::uint32_t expectedMask = ExpectedSeenSubgroupMask(numSubgroups); if (output.seenSubgroupMask != expectedMask) { std::ostringstream detail; - detail << "topology: seen subgroup-ID mask was 0x" << std::hex << output.seenSubgroupMask << ", expected 0x" + detail << "The seen subgroup-ID mask was 0x" << std::hex << output.seenSubgroupMask << ", expected 0x" << expectedMask; return Failure(IterationRPWitnessValidationFailure::Topology, detail.str()); } const std::uint32_t expectedLoopLength = ComputeIterationRPWitnessLoopLength(numSubgroups); if (output.loopLength != expectedLoopLength) { std::ostringstream detail; - detail << "topology: loopLength was " << std::dec << output.loopLength << ", expected " - << expectedLoopLength; + detail << "The reduction ran for " << std::dec << output.loopLength << " iterations. The probe expected " + << expectedLoopLength << '.'; return Failure(IterationRPWitnessValidationFailure::Topology, detail.str()); } for (std::uint32_t subgroup = 0u; subgroup < numSubgroups; ++subgroup) { diff --git a/android-plugin/app/src/main/java/top/mobilegl/plugin/NavBar.java b/android-plugin/app/src/main/java/top/mobilegl/plugin/NavBar.java index 84853c0a..7909d541 100644 --- a/android-plugin/app/src/main/java/top/mobilegl/plugin/NavBar.java +++ b/android-plugin/app/src/main/java/top/mobilegl/plugin/NavBar.java @@ -35,8 +35,8 @@ public final class NavBar { LinearLayout bar = new LinearLayout(activity); bar.setOrientation(LinearLayout.HORIZONTAL); bar.setBackgroundColor(COLOR_BAR); - addTab(activity, bar, "POST", PostActivity.class, currentTab == TAB_POST); - addTab(activity, bar, "Render Server", ServerControlActivity.class, currentTab == TAB_SERVER); + addTab(activity, bar, "Diagnostics", PostActivity.class, currentTab == TAB_POST); + addTab(activity, bar, "Server", ServerControlActivity.class, currentTab == TAB_SERVER); root.addView(bar, new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, dp(activity, BAR_HEIGHT_DP))); return root; diff --git a/android-plugin/app/src/main/java/top/mobilegl/plugin/PostActivity.java b/android-plugin/app/src/main/java/top/mobilegl/plugin/PostActivity.java index 55a13898..5f469491 100644 --- a/android-plugin/app/src/main/java/top/mobilegl/plugin/PostActivity.java +++ b/android-plugin/app/src/main/java/top/mobilegl/plugin/PostActivity.java @@ -98,7 +98,7 @@ public final class PostActivity extends Activity { setContentView(NavBar.wrap(this, scrollView, NavBar.TAB_POST)); addText("MobileGL Driver POST", 20, COLOR_TEXT, true, 0); - statusView = addText("Running self-test...", 14, COLOR_INFO, false, dp(8)); + statusView = addText("Checking drivers…", 14, COLOR_INFO, false, dp(8)); progressBar = new ProgressBar(this, null, android.R.attr.progressBarStyleHorizontal); progressBar.setIndeterminate(true); @@ -119,8 +119,6 @@ public final class PostActivity extends Activity { postInFlight = true; startWorker = true; } - // else: a probe is already in flight; leave "Running self-test..." - // showing and wait for delivery to this (the current) activity. } if (renderNow) { renderCachedResult(); @@ -174,7 +172,7 @@ public final class PostActivity extends Activity { Button button = benchButtons.get(backendType); if (button != null) { button.setEnabled(false); - button.setText("Bench running... (can take a minute)"); + button.setText("Benchmark running…"); } LinearLayout container = benchResultContainers.get(backendType); if (container != null) { @@ -191,7 +189,7 @@ public final class PostActivity extends Activity { Button button = benchButtons.get(backendType); if (button != null) { button.setEnabled(true); - button.setText("Run Bench"); + button.setText("Run benchmark"); } LinearLayout container = benchResultContainers.get(backendType); if (container == null) { @@ -202,7 +200,7 @@ public final class PostActivity extends Activity { JSONObject root = new JSONObject(json); String error = root.optString("error", ""); if (!error.isEmpty()) { - container.addView(makeText("Bench failed: " + error, 12, COLOR_FAIL, false)); + container.addView(makeText("Benchmark failed: " + error, 12, COLOR_FAIL, false)); return; } container.addView(makeText(root.optString("renderer", ""), 11, COLOR_INFO, false)); @@ -228,7 +226,7 @@ public final class PostActivity extends Activity { container.addView(view); } } catch (JSONException error) { - container.addView(makeText("Bench result unparsable: " + error, 12, COLOR_FAIL, false)); + container.addView(makeText("Could not read benchmark result: " + error, 12, COLOR_FAIL, false)); } } @@ -317,7 +315,9 @@ public final class PostActivity extends Activity { failure = cachedFailure; } if (failure != null) { - showError("Driver POST failed: " + failure); + showError("Could not start driver diagnostics."); + addDisclosure(contentLayout, "Error details", dp(4)) + .addView(makeText(failure.toString(), 12, COLOR_DETAIL, false)); return; } renderReport(json); @@ -325,34 +325,37 @@ public final class PostActivity extends Activity { private void renderReport(String json) { if (json == null || json.isEmpty()) { - showError("Driver POST returned an empty report."); + showError("No diagnostics report was returned."); return; } JSONObject root; try { root = new JSONObject(json); } catch (JSONException error) { - showError("Failed to parse POST report: " + error.getMessage() + "\n\n" + json); + showError("Could not read the diagnostics report."); + addRawJsonSection(json); return; } String nativeError = root.optString("error", ""); if (!nativeError.isEmpty()) { - showError(nativeError); + showError("Driver diagnostics failed."); addRawJsonSection(json); return; } JSONArray backends = extractBackends(root); - if (backends.length() == 0) { - showError("POST report contains no backend sections:\n\n" + json); - return; - } - statusView.setText("Self-test complete."); + boolean hasBackend = false; for (int i = 0; i < backends.length(); ++i) { JSONObject backend = backends.optJSONObject(i); if (backend != null) { renderBackendSection(backend); + hasBackend = true; } } + if (hasBackend) { + statusView.setVisibility(View.GONE); + } else { + showError("No backend results were reported."); + } addRawJsonSection(json); } @@ -381,88 +384,56 @@ public final class PostActivity extends Activity { private void renderBackendSection(JSONObject backend) { String name = backend.optString("backend", backend.optString("name", "Unknown backend")); - addText(sectionTitle(name), 16, COLOR_TEXT, true, dp(20)); - - if (!backend.optBoolean("available", true)) { - addText("Driver not present / not probeable", 12, COLOR_INFO, false, dp(4)); - return; - } - - String verdict = backend.optString("verdict", "UNKNOWN"); - addText("Verdict: " + verdict, 14, verdictColor(verdict), true, dp(4)); - - String renderer = backend.optString("renderer", ""); - if (!renderer.isEmpty()) { - addText(renderer, 12, COLOR_INFO, false, dp(2)); - } - - addBenchControls(name); + boolean available = backend.optBoolean("available", true); + String verdict = available ? backend.optString("verdict", "Unknown") : "Unavailable"; + addText(sectionTitle(name) + " · " + verdict, 16, verdictColor(verdict), true, dp(16)); JSONArray checks = backend.optJSONArray("checks"); + JSONArray bugs = backend.optJSONArray("knownDriverBugs"); + LinearLayout issues = newColumn(); + LinearLayout otherChecks = newColumn(); if (checks != null) { - LinearLayout table = new LinearLayout(this); - table.setOrientation(LinearLayout.VERTICAL); - LinearLayout.LayoutParams tableParams = new LinearLayout.LayoutParams( - LinearLayout.LayoutParams.MATCH_PARENT, - LinearLayout.LayoutParams.WRAP_CONTENT - ); - tableParams.topMargin = dp(6); - contentLayout.addView(table, tableParams); - int rowIndex = 0; for (int i = 0; i < checks.length(); ++i) { JSONObject check = checks.optJSONObject(i); if (check == null) { continue; } - addCheckRow(table, check, rowIndex++); + String status = check.optString("status", "INFO"); + boolean issue = "WARN".equalsIgnoreCase(status) || "FAIL".equalsIgnoreCase(status); + addCheckRow(issue ? issues : otherChecks, check.optString("name", "Unnamed check"), status, + check.optString("detail", check.optString("message", ""))); } } - - renderKnownDriverBugs(backend.optJSONArray("knownDriverBugs")); - renderFormatCapabilities(backend.optJSONObject("formatCapabilities")); - } - - /** - * The "Known Driver Bugs" section: core functionality this driver advertises, accepts, - * and then does not perform. Separate from the capability checks above because it answers - * a different question and uses its own vocabulary. - * - * Only bugs the device actually HAS are reported, so a clean driver renders no section at - * all rather than a list of reassurances - which is why the verdicts are FIXED (a MobileGL - * quirk makes application behaviour correct anyway) and UNFIXABLE (no substitute; the - * one-liner says what MobileGL does defensively), never PASS/FAIL. - */ - private void renderKnownDriverBugs(JSONArray bugs) { - if (bugs == null || bugs.length() == 0) { - return; + if (bugs != null) { + for (int i = 0; i < bugs.length(); ++i) { + JSONObject bug = bugs.optJSONObject(i); + if (bug == null) { + continue; + } + String status = bug.optString("verdict", "UNFIXABLE"); + addCheckRow("FIXED".equalsIgnoreCase(status) ? otherChecks : issues, + bug.optString("name", "Unnamed driver bug"), status, bug.optString("detail", "")); + } + } + if (issues.getChildCount() != 0) { + contentLayout.addView(issues); } - addText("Known driver bugs", 14, COLOR_TEXT, true, dp(16)); - LinearLayout table = new LinearLayout(this); - table.setOrientation(LinearLayout.VERTICAL); - LinearLayout.LayoutParams tableParams = new LinearLayout.LayoutParams( - LinearLayout.LayoutParams.MATCH_PARENT, - LinearLayout.LayoutParams.WRAP_CONTENT - ); - tableParams.topMargin = dp(6); - contentLayout.addView(table, tableParams); - int rowIndex = 0; - for (int i = 0; i < bugs.length(); ++i) { - JSONObject bug = bugs.optJSONObject(i); - if (bug == null) { - continue; + String renderer = backend.optString("renderer", ""); + String backendType = available ? backendTypeForSection(name) : null; + JSONObject formats = backend.optJSONObject("formatCapabilities"); + if (!renderer.isEmpty() || otherChecks.getChildCount() != 0 || formats != null || backendType != null) { + LinearLayout details = addDisclosure(contentLayout, "Details", dp(4)); + if (!renderer.isEmpty()) { + details.addView(makeText(renderer, 12, COLOR_INFO, false)); } - // addCheckRow renders name + chip + collapsible detail, which is exactly this - // section's shape; the chip text is the verdict rather than a status. - JSONObject row = new JSONObject(); - try { - row.put("name", bug.optString("name", "unnamed bug")); - row.put("status", bug.optString("verdict", "UNFIXABLE")); - row.put("detail", bug.optString("detail", "")); - } catch (JSONException ignored) { - continue; + renderFormatCapabilities(details, formats); + if (backendType != null) { + addBenchControls(details, backendType); + } + if (otherChecks.getChildCount() != 0) { + addDisclosure(details, "Other checks", dp(4)).addView(otherChecks); } - addCheckRow(table, row, rowIndex++); } } @@ -485,13 +456,9 @@ public final class PostActivity extends Activity { * runs the Minecraft-shaped MG_Benchmark cases through the full MobileGL stack * on this backend, in a throwaway service process (see BenchService). */ - private void addBenchControls(String sectionName) { - final String backendType = backendTypeForSection(sectionName); - if (backendType == null) { - return; - } + private void addBenchControls(LinearLayout parent, String backendType) { Button button = new Button(this); - button.setText("Run Bench"); + button.setText("Run benchmark"); button.setAllCaps(false); button.setTextSize(TypedValue.COMPLEX_UNIT_SP, 13); button.setOnClickListener(v -> startBench(backendType)); @@ -500,7 +467,7 @@ public final class PostActivity extends Activity { LinearLayout.LayoutParams.WRAP_CONTENT ); buttonParams.topMargin = dp(6); - contentLayout.addView(button, buttonParams); + parent.addView(button, buttonParams); benchButtons.put(backendType, button); LinearLayout results = new LinearLayout(this); @@ -510,7 +477,7 @@ public final class PostActivity extends Activity { LinearLayout.LayoutParams.WRAP_CONTENT ); resultParams.topMargin = dp(4); - contentLayout.addView(results, resultParams); + parent.addView(results, resultParams); benchResultContainers.put(backendType, results); } @@ -519,15 +486,12 @@ public final class PostActivity extends Activity { * a non-empty detail get a collapse indicator and toggle the detail text on tap; * rows without detail show no indicator and are not tappable. */ - private void addCheckRow(LinearLayout table, JSONObject check, int rowIndex) { - String status = check.optString("status", "INFO"); - String checkName = check.optString("name", "unnamed check"); - String detail = check.optString("detail", check.optString("message", "")); + private void addCheckRow(LinearLayout table, String checkName, String status, String detail) { boolean hasDetail = !detail.isEmpty(); LinearLayout row = new LinearLayout(this); row.setOrientation(LinearLayout.VERTICAL); - row.setBackgroundColor(rowIndex % 2 == 0 ? COLOR_ROW_EVEN : COLOR_ROW_ODD); + row.setBackgroundColor(table.getChildCount() % 2 == 0 ? COLOR_ROW_EVEN : COLOR_ROW_ODD); table.addView(row, new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT @@ -543,7 +507,8 @@ public final class PostActivity extends Activity { LinearLayout.LayoutParams.WRAP_CONTENT )); - TextView indicatorView = makeText(hasDetail ? INDICATOR_COLLAPSED : "", 12, COLOR_INFO, false); + String indicator = hasDetail ? INDICATOR_COLLAPSED : ""; + TextView indicatorView = makeText(indicator, 12, COLOR_INFO, false); line.addView(indicatorView, new LinearLayout.LayoutParams( dp(16), LinearLayout.LayoutParams.WRAP_CONTENT @@ -570,8 +535,9 @@ public final class PostActivity extends Activity { return; } - TextView detailView = makeText(detail, 11, COLOR_DETAIL, false); - detailView.setPadding(dp(24), 0, dp(8), dp(8)); + TextView detailView = makeText(detail, 13, COLOR_DETAIL, false); + detailView.setTypeface(Typeface.DEFAULT); + detailView.setPadding(dp(24), 0, dp(12), dp(10)); detailView.setVisibility(View.GONE); row.addView(detailView, new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, @@ -586,24 +552,22 @@ public final class PostActivity extends Activity { } /** Adds one initially-collapsed capability matrix for every reported target. */ - private void renderFormatCapabilities(JSONObject formatCapabilities) { - addText("Format capabilities", 14, COLOR_TEXT, true, dp(16)); + private void renderFormatCapabilities(LinearLayout parent, JSONObject formatCapabilities) { if (formatCapabilities == null) { - addText("Format capability table unavailable.", 12, COLOR_INFO, false, dp(4)); return; } JSONArray capabilities = formatCapabilities.optJSONArray("capabilities"); JSONArray targets = formatCapabilities.optJSONArray("targets"); if (capabilities == null || capabilities.length() == 0 || targets == null || targets.length() == 0) { - addText("Format capability table is empty.", 12, COLOR_INFO, false, dp(4)); return; } + LinearLayout formats = addDisclosure(parent, "Format capabilities", dp(6)); for (int targetIndex = 0; targetIndex < targets.length(); ++targetIndex) { JSONObject target = targets.optJSONObject(targetIndex); if (target != null) { - addFormatTargetTable(target, capabilities); + addFormatTargetTable(formats, target, capabilities); } } } @@ -612,7 +576,7 @@ public final class PostActivity extends Activity { * Adds a target header whose table is created only while expanded. Removing the * table again on collapse avoids retaining all status cells for both backends. */ - private void addFormatTargetTable(JSONObject target, JSONArray capabilities) { + private void addFormatTargetTable(LinearLayout parent, JSONObject target, JSONArray capabilities) { String targetName = target.optString("name", "Unknown target"); JSONArray rows = target.optJSONArray("rows"); int formatCount = rows == null ? 0 : rows.length(); @@ -624,7 +588,7 @@ public final class PostActivity extends Activity { LinearLayout.LayoutParams.WRAP_CONTENT ); sectionParams.topMargin = dp(6); - contentLayout.addView(section, sectionParams); + parent.addView(section, sectionParams); TextView toggleView = makeText( INDICATOR_COLLAPSED + " " + targetName + " (" + formatCount + " formats)", @@ -757,22 +721,35 @@ public final class PostActivity extends Activity { row.addView(cell, params); } - /** Adds the collapsed "Raw report" toggle plus the (initially hidden) raw JSON dump. */ private void addRawJsonSection(String json) { - TextView toggleView = addText(INDICATOR_COLLAPSED + " Raw report (tap to expand)", 12, COLOR_INFO, true, dp(24)); - toggleView.setMinimumHeight(dp(44)); - toggleView.setGravity(Gravity.CENTER_VERTICAL); + LinearLayout details = addDisclosure(contentLayout, "Raw report", dp(12)); + details.addView(makeText(json, 10, COLOR_INFO, false)); + } - TextView rawView = addText(json, 10, COLOR_INFO, false, dp(4)); - rawView.setVisibility(View.GONE); + private LinearLayout addDisclosure(LinearLayout parent, String label, int margin) { + TextView toggle = makeText(INDICATOR_COLLAPSED + " " + label, 12, COLOR_TEXT, true); + toggle.setMinimumHeight(dp(44)); + toggle.setGravity(Gravity.CENTER_VERTICAL); + LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, + LinearLayout.LayoutParams.WRAP_CONTENT); + params.topMargin = margin; + parent.addView(toggle, params); - toggleView.setOnClickListener(view -> { - boolean expanded = rawView.getVisibility() == View.VISIBLE; - rawView.setVisibility(expanded ? View.GONE : View.VISIBLE); - toggleView.setText(expanded - ? INDICATOR_COLLAPSED + " Raw report (tap to expand)" - : INDICATOR_EXPANDED + " Raw report (tap to collapse)"); + LinearLayout section = newColumn(); + section.setVisibility(View.GONE); + parent.addView(section); + toggle.setOnClickListener(view -> { + boolean expanded = section.getVisibility() == View.VISIBLE; + section.setVisibility(expanded ? View.GONE : View.VISIBLE); + toggle.setText((expanded ? INDICATOR_COLLAPSED : INDICATOR_EXPANDED) + " " + label); }); + return section; + } + + private LinearLayout newColumn() { + LinearLayout column = new LinearLayout(this); + column.setOrientation(LinearLayout.VERTICAL); + return column; } private static String sectionTitle(String backendName) { @@ -793,6 +770,7 @@ public final class PostActivity extends Activity { case "DEGRADED": return COLOR_WARN; case "UNSUPPORTED": + case "UNAVAILABLE": return COLOR_FAIL; default: return COLOR_INFO; @@ -823,9 +801,8 @@ public final class PostActivity extends Activity { private void showError(String message) { Log.e(TAG, message); - statusView.setText("Self-test failed."); + statusView.setText(message); statusView.setTextColor(COLOR_FAIL); - addText(message, 12, COLOR_FAIL, false, dp(8)); } private TextView addText(String text, int sizeSp, int color, boolean bold, int topMarginPx) { diff --git a/android-plugin/app/src/main/java/top/mobilegl/plugin/ServerControlActivity.java b/android-plugin/app/src/main/java/top/mobilegl/plugin/ServerControlActivity.java index f2f4d2bd..edac0e10 100644 --- a/android-plugin/app/src/main/java/top/mobilegl/plugin/ServerControlActivity.java +++ b/android-plugin/app/src/main/java/top/mobilegl/plugin/ServerControlActivity.java @@ -11,6 +11,7 @@ import android.os.Bundle; import android.text.InputType; import android.util.Log; import android.util.TypedValue; +import android.view.View; import android.view.inputmethod.EditorInfo; import android.widget.Button; import android.widget.CheckBox; @@ -75,32 +76,44 @@ public final class ServerControlActivity extends Activity { setContentView(NavBar.wrap(this, scrollView, NavBar.TAB_SERVER)); contentLayout.addView(makeText("MobileGL Render Server", 20, COLOR_TEXT, true)); + listenField = addField(contentLayout, "Listen address", DEFAULT_ENDPOINT, dp(12)); + listenField.setHint("tcp://host:port or @name"); + LinearLayout tokenRow = new LinearLayout(this); + tokenRow.setGravity(android.view.Gravity.CENTER_VERTICAL); + tokenField = addField(contentLayout, "Access token", "", dp(8)); + tokenField.setHint("16+ bytes for remote access"); + contentLayout.removeView(tokenField); + contentLayout.addView(tokenRow); + tokenRow.addView(tokenField, new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT, 1)); - TextView hint = makeText( - "Starts the render server. Offscreen (default): the supervisor " - + "(libMobileGLServer.so --serve) runs as a foreground service. On-screen " - + "window: the server runs in a display Activity that renders the client's " - + "frames onto this screen (clients opt in with MOBILEGL_IPC_SURFACE=server). " - + "Endpoint forms: tcp://host:port for remote clients, @name for an " - + "on-device abstract socket, or a filesystem path (relative to the app's " - + "files dir) for on-device clients. Non-loopback TCP requires a token of at " - + "least " + MIN_TOKEN_BYTES + " bytes; unix endpoints need none, but GL programs " - + "from other apps (Termux, adb shell) reach the server through its broker, which " - + "needs one (see the launch command below). Extra env " - + "uses the KEY=VALUE;KEY grammar (e.g. MOBILEGL_BACKEND_TYPE=DirectVulkan). " - + "One server per device: the two modes replace each other.", - 12, COLOR_INFO, false); - LinearLayout.LayoutParams hintParams = new LinearLayout.LayoutParams( - LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); - hintParams.topMargin = dp(8); - contentLayout.addView(hint, hintParams); + Button generate = new Button(this); + generate.setText("Generate"); + generate.setAllCaps(false); + generate.setTextSize(TypedValue.COMPLEX_UNIT_SP, 13); + generate.setOnClickListener(v -> { + byte[] bytes = new byte[16]; + new java.security.SecureRandom().nextBytes(bytes); + StringBuilder hex = new StringBuilder(); + for (byte b : bytes) + hex.append(String.format(Locale.ROOT, "%02x", b & 0xff)); + tokenField.setText(hex.toString()); + }); + tokenRow.addView(generate); - listenField = addField(contentLayout, "Listen endpoint", DEFAULT_ENDPOINT, dp(16)); - tokenField = addField(contentLayout, "Auth token (empty = loopback only)", "", dp(8)); - envField = addField(contentLayout, "Extra env (optional)", "", dp(8)); + Button advanced = new Button(this); + advanced.setText("Advanced settings"); + advanced.setAllCaps(false); + contentLayout.addView(advanced); + LinearLayout advancedFields = new LinearLayout(this); + advancedFields.setOrientation(LinearLayout.VERTICAL); + advancedFields.setVisibility(View.GONE); + contentLayout.addView(advancedFields); + envField = addField(advancedFields, "Environment variables", "", 0); + envField.setHint("KEY=VALUE;KEY"); + advanced.setOnClickListener(v -> toggleSection(advanced, advancedFields, "Advanced settings")); onScreenBox = new CheckBox(this); - onScreenBox.setText("On-screen window (render client frames onto this screen)"); + onScreenBox.setText("Show output on screen"); onScreenBox.setTextColor(COLOR_TEXT); onScreenBox.setTextSize(TypedValue.COMPLEX_UNIT_SP, 13); LinearLayout.LayoutParams boxParams = new LinearLayout.LayoutParams( @@ -141,7 +154,7 @@ public final class ServerControlActivity extends Activity { addExternalClientSection(contentLayout); if (isServerRunning()) { - setStatus("A server is running (started outside this screen).", COLOR_WARN); + setStatus("Running", COLOR_WARN); } else { setStatus("Stopped.", COLOR_INFO); } @@ -384,42 +397,35 @@ public final class ServerControlActivity extends Activity { // helper class, the broker component, and how the token travels (the environment, never argv). private TextView launchCommandView; + private Button copyLaunchButton; private void addExternalClientSection(LinearLayout parent) { - TextView title = makeText("Same-device GL programs (Termux, adb shell, other apps)", 14, COLOR_TEXT, true); - LinearLayout.LayoutParams titleParams = new LinearLayout.LayoutParams( - LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); - titleParams.topMargin = dp(20); - parent.addView(title, titleParams); + Button localClients = new Button(this); + localClients.setText("Local clients"); + localClients.setAllCaps(false); + parent.addView(localClients); + LinearLayout details = new LinearLayout(this); + details.setOrientation(LinearLayout.VERTICAL); + details.setVisibility(View.GONE); + parent.addView(details); + localClients.setOnClickListener(v -> toggleSection(localClients, details, "Local clients")); launchCommandView = makeText("", 12, COLOR_INFO, false); launchCommandView.setTextIsSelectable(true); LinearLayout.LayoutParams commandParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); commandParams.topMargin = dp(8); - parent.addView(launchCommandView, commandParams); + details.addView(launchCommandView, commandParams); LinearLayout row = new LinearLayout(this); row.setOrientation(LinearLayout.HORIZONTAL); LinearLayout.LayoutParams rowParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); rowParams.topMargin = dp(8); - parent.addView(row, rowParams); - - Button generate = new Button(this); - generate.setText("Generate token"); - generate.setAllCaps(false); - generate.setTextSize(TypedValue.COMPLEX_UNIT_SP, 13); - generate.setOnClickListener(v -> { - byte[] bytes = new byte[16]; - new java.security.SecureRandom().nextBytes(bytes); - StringBuilder hex = new StringBuilder(); - for (byte b : bytes) hex.append(String.format(Locale.ROOT, "%02x", b & 0xff)); - tokenField.setText(hex.toString()); - }); - row.addView(generate); + details.addView(row, rowParams); Button copy = new Button(this); + copyLaunchButton = copy; copy.setText("Copy launch command"); copy.setAllCaps(false); copy.setTextSize(TypedValue.COMPLEX_UNIT_SP, 13); @@ -431,8 +437,7 @@ public final class ServerControlActivity extends Activity { android.content.ClipboardManager clipboard = getSystemService(android.content.ClipboardManager.class); clipboard.setPrimaryClip(android.content.ClipData.newPlainText("MobileGL launch command", launchCommand(tokenField.getText().toString()))); - setStatus("Launch command copied (it carries the token: paste it only where you run the program).", - COLOR_INFO); + android.widget.Toast.makeText(this, "Command copied", android.widget.Toast.LENGTH_SHORT).show(); }); tokenField.addTextChangedListener(new android.text.TextWatcher() { @@ -453,19 +458,15 @@ public final class ServerControlActivity extends Activity { if (launchCommandView == null) return; String token = tokenField.getText().toString(); boolean usable = token.getBytes().length >= ExternalClientBroker.MIN_TOKEN_BYTES; - StringBuilder text = new StringBuilder(); - if (!usable) { - text.append("Needs an Auth token of at least ").append(ExternalClientBroker.MIN_TOKEN_BYTES) - .append(" bytes (Generate token), then start the server offscreen.\n\n"); - } - text.append(launchCommand(usable ? token : "")).append("\n\n") - .append("Broker: ").append(getPackageName()).append('/').append(ExternalClientBroker.class.getName()) - .append("\nThe token travels in the environment (MOBILEGL_IPC_TOKEN, or MOBILEGL_IPC_TOKEN_FILE=)") - .append(", never on the command line. The program runs over shared memory, off the one cpu core") - .append(" the server's render thread takes (--keep-affinity to opt out); the server keeps") - .append(" running as a foreground service. Battery: set both this app and the client's app to") - .append(" \"No restrictions\"."); - launchCommandView.setText(text.toString()); + launchCommandView.setText(usable ? launchCommand("") + : "Generate a token, then start the server with on-screen output off."); + copyLaunchButton.setEnabled(usable); + } + + private void toggleSection(Button button, LinearLayout section, String title) { + boolean opening = section.getVisibility() != View.VISIBLE; + section.setVisibility(opening ? View.VISIBLE : View.GONE); + button.setText(opening ? "Hide " + title.toLowerCase(Locale.ROOT) : title); } /** {host, port} for tcp://host:port, or null. */