mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-11-26 19:22:16 +09:00
Compare commits
7
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
94d729c493 | ||
|
|
926e54e28c | ||
|
|
c025f9c4e8 | ||
|
|
99afafd7cf | ||
|
|
b897556750 | ||
|
|
639ae0f636 | ||
|
|
10deb9cea4 |
No files matched your search
Vendored
+1
-1
Submodule 3rdparty/glslang updated: 892c1e3fe5...d3c70bb6a1.
@@ -480,7 +480,6 @@ set(SOURCE_FILES
|
||||
MobileGL/MG_Impl/GLImpl/RenderState/GL_RenderState.cpp
|
||||
MobileGL/MG_Impl/GLImpl/Framebuffer/Validators.cpp
|
||||
MobileGL/MG_Impl/GLImpl/Framebuffer/GL_Framebuffer.cpp
|
||||
MobileGL/MG_Impl/GLImpl/Framebuffer/GL_FramebufferMultiview.cpp
|
||||
MobileGL/MG_Impl/GLImpl/Program/GL_Program.cpp
|
||||
MobileGL/MG_Impl/GLImpl/Program/GL_ShaderObjectsARB.cpp
|
||||
MobileGL/MG_Impl/GLImpl/Program/ProgramInterface.cpp
|
||||
|
||||
+1
-2
@@ -31,8 +31,7 @@ Commands below use `python3`. On Windows, run `python` instead.
|
||||
- A file directly in `MobileGL/` uses `MobileGL`, and a submodule uses its path (`3rdparty/glslang`).
|
||||
- List every scope the commit touches, comma-separated: `(MG_Backend/DirectGLES, MG_Test/Wire)`. A commit that touches more than three scopes skips this check: summarize the touched areas yourself, for example `(...)`.
|
||||
- `python3 scripts/check_text_hygiene.py scope` prints the scope for the staged changes.
|
||||
- **No** planning ids (phase or decision codes such as `P13` or `ID-54`), local paths or non-English text anywhere in the message.
|
||||
- Name an external project only to credit a non-trivial technique taken from it, with a link to the source. A common technique needs no attribution.
|
||||
- **No** planning ids (phase or decision codes such as `P13` or `ID-54`), local paths, external project names or non-English text anywhere in the message.
|
||||
- **Merges** use `[Merge] (area): what the merge takes`. The scope is free text there. Write the subject yourself, since git's default merge message fails the check. The commits a merge brings in are not checked again.
|
||||
- **Reverts** use `[Fix] (Scope): revert <the reverted subject>`.
|
||||
|
||||
|
||||
@@ -103,11 +103,6 @@ namespace MobileGL {
|
||||
// GL_EXT_clip_control on DirectGLES. DirectVulkan applies clip control in its own
|
||||
// position fixup and does not read this.
|
||||
Bool ClipControl = false;
|
||||
// GL_OVR_multiview and GL_OVR_multiview2. DirectGLES: each where the driver has that
|
||||
// same extension (and, for the first, glFramebufferTextureMultiviewOVR). DirectVulkan:
|
||||
// both where the device was created with the multiview feature.
|
||||
Bool Multiview = false;
|
||||
Bool Multiview2 = false;
|
||||
};
|
||||
|
||||
// Coarse GPU vendor identity for gating device-specific quirks. Detected from the
|
||||
@@ -416,9 +411,6 @@ namespace MobileGL {
|
||||
Int MaxFragmentShadingRateAttachmentTexelHeight = 0;
|
||||
Int MaxFragmentShadingRateAttachmentTexelAspectRatio = 0;
|
||||
Int MaxFragmentShadingRateAttachmentLayers = 0;
|
||||
// GL_MAX_VIEWS_OVR. Zero means no multiview, which is also why GL_OVR_multiview is not
|
||||
// advertised then; a backend that has it reports at least the spec minimum of 2.
|
||||
Int MaxViews = 0;
|
||||
|
||||
static constexpr Bool IsSamplePositionCount(Int samples) {
|
||||
return samples >= 2 && samples <= kMaxSamplePositionCount && (samples & (samples - 1)) == 0;
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ namespace MobileGL::MG_Config {
|
||||
inline const String ProjectName = "MobileGL";
|
||||
inline const String CoreName = "MobileGL Core";
|
||||
inline const String CoreVendor = "MobileGL-Dev (BZLZHH, Swung0x48, Tungsten)";
|
||||
inline const Version CoreVersion = {26, 11, 0, "-dev", VersionType::Development};
|
||||
inline const Version CoreVersion = {26, 11, 0, "-alpha.1", VersionType::Unstable};
|
||||
inline const VersionStringFormatAttrib DefaultVersionStringFormatAttrib = {2, 2, 0, true, true};
|
||||
inline const Uint64 CacheVersion = 0;
|
||||
|
||||
|
||||
@@ -903,9 +903,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
capabilities.SupportsTextureView, capabilities.SupportsTextureCubeMapArray,
|
||||
AdvertisedFeatureSupport{.TessellationShader = capabilities.SupportsTessellationShader,
|
||||
.CullDistance = capabilities.MaxCullDistances > 0,
|
||||
.ClipControl = capabilities.SupportsClipControl,
|
||||
.Multiview = capabilities.SupportsMultiview,
|
||||
.Multiview2 = capabilities.SupportsMultiview2});
|
||||
.ClipControl = capabilities.SupportsClipControl});
|
||||
// Exactly what InitCapabilities forwards into the dynamic parameters: the base
|
||||
// extension and _primitive when the driver has them, _attachment not yet.
|
||||
auto& extensions = MutableRendererInfo().RendererGLInfo.Extensions;
|
||||
@@ -1587,14 +1585,6 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
if (features.ClipControl) {
|
||||
extensions.push_back(E_GL_ARB_clip_control);
|
||||
}
|
||||
// Multiview attachments go to the driver's glFramebufferTextureMultiviewOVR and
|
||||
// gl_ViewID_OVR to its own built-in, so each string follows the driver's.
|
||||
if (features.Multiview) {
|
||||
extensions.push_back(E_GL_OVR_multiview);
|
||||
if (features.Multiview2) {
|
||||
extensions.push_back(E_GL_OVR_multiview2);
|
||||
}
|
||||
}
|
||||
// Minecraft 26.3 checks this prerequisite before it even considers
|
||||
// GL_ARB_multi_draw_indirect. ES 3.1 supplies both single-draw entry points; the loader
|
||||
// folds the version and pointer checks into SupportsDrawIndirect.
|
||||
@@ -2032,7 +2022,6 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
// the device answers every query. The attachment is not forwarded yet, so it is not
|
||||
// claimed, whatever the driver offers.
|
||||
m_dynamicParameters.SupportsFragmentShadingRate = m_GLESCapabilities.SupportsFragmentShadingRate;
|
||||
m_dynamicParameters.MaxViews = m_GLESCapabilities.SupportsMultiview ? m_GLESCapabilities.MaxViews : 0;
|
||||
m_dynamicParameters.SupportsPrimitiveFragmentShadingRate =
|
||||
m_GLESCapabilities.SupportsFragmentShadingRatePrimitive;
|
||||
m_dynamicParameters.SupportsAttachmentFragmentShadingRate = false;
|
||||
|
||||
@@ -911,7 +911,8 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
BufferImpl::SyncNeccessaryBuffers(currentVAO, vaoTwin, vaoConfigVersion, syncBit & DrawSyncBit::IndexBuffer,
|
||||
syncBit & DrawSyncBit::IndirectBuffer);
|
||||
// The draw's integer arrays and the program's narrow-integer seeds (NarrowIntegerSeeds.h).
|
||||
IntegerAttributePlan integerPlan = ResolveIntegerAttributePlanForDraw(MG_Pipe::MGPipeApplier().DrawProgram);
|
||||
const MG_Pipe::MGPipeHandle programCso = MG_Pipe::MGPipeApplier().DrawProgram;
|
||||
IntegerAttributePlan integerPlan = ResolveIntegerAttributePlanForDraw(programCso);
|
||||
VertexArrayImpl::SyncCurrentVAOFromRecords(vaoTwin, integerPlan);
|
||||
TextureImpl::SyncNeccessaryTextures(textureKeys);
|
||||
// A draw reads and writes through its image units too, so the unit bindings have to be
|
||||
@@ -929,8 +930,8 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
// at all; the remaining uses of it below are the two callees' own, and both have a
|
||||
// handle arm of their own. P5e (pa) finished it: the pull itself is gone on that arm and
|
||||
// `currentProgram` is a null SharedPtr there, which this branch never reaches for.
|
||||
PrgramImpl::SyncCurrentProgramByHandle(MG_Pipe::MGPipeApplier().DrawProgram, true, &integerPlan);
|
||||
if (DropRefusedNarrowIntegerSeeds(integerPlan, MG_Pipe::MGPipeApplier().DrawProgram))
|
||||
const auto* programRecord = PrgramImpl::SyncCurrentProgramByHandle(programCso, true, &integerPlan);
|
||||
if (DropRefusedNarrowIntegerSeeds(integerPlan, programCso))
|
||||
VertexArrayImpl::SyncCurrentVAOFromRecords(vaoTwin, integerPlan);
|
||||
RenderStateImpl::SyncRenderState();
|
||||
|
||||
@@ -951,11 +952,11 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
// a conjunction over four callees; this one is served by the record whenever the PROGRAM
|
||||
// family is on the handle arm, which includes the mixed A/B where the texture bits are
|
||||
// off and `currentProgram` above is therefore still a real object.
|
||||
VertexArrayImpl::SyncCurrentVertexAttributeValues(vaoTwin, MG_Pipe::MGPipeApplier().DrawProgram);
|
||||
VertexArrayImpl::SyncCurrentVertexAttributeValues(vaoTwin, programCso);
|
||||
|
||||
BindCurrentTextures(textureKeys, currentProgram);
|
||||
BindCurrentProgramWithResources(currentProgram, textureKeys, MG_Pipe::MGPipeApplier().DrawProgram);
|
||||
PushNarrowIntegerWidthsForDraw(integerPlan, MG_Pipe::MGPipeApplier().DrawProgram);
|
||||
BindCurrentProgramWithResources(currentProgram, textureKeys, programCso, programRecord);
|
||||
PushNarrowIntegerWidthsForDraw(integerPlan, programCso);
|
||||
|
||||
// Last: opening the capture span needs the program current and the capture
|
||||
// buffers bound, and ES rejects most binding changes once it is open.
|
||||
@@ -1368,19 +1369,9 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
// (its note says so). The parameter stays for the monolith arm, which is ruling ID-81: that
|
||||
// build keeps this function's frontend text token for token.
|
||||
void BindCurrentProgramWithResources(const SharedPtr<MG_State::GLState::ProgramObject>& currentProgram,
|
||||
const TextureImpl::DrawTextureSyncKeys& keys,
|
||||
MG_Pipe::MGPipeHandle programCso) {
|
||||
// P5e (pg): THE HANDLE ARM'S GATE, from the record rather than from the object. Hoisted
|
||||
// out of the `if` below because the whole body's entry condition is "the program linked
|
||||
// and has SPIR-V", and on this arm both answers are fields of the descriptor
|
||||
// (Desc.LinkStatus is ID-88's, Desc.SpirvStatus P4a's).
|
||||
const MG_Pipe::MGPipeShaderCsoRecord* programRecord = nullptr;
|
||||
programRecord = PrgramImpl::FindShaderCsoRecord(programCso);
|
||||
if (programRecord != nullptr && (programRecord->Desc.LinkStatus == 0 || programRecord->Desc.SpirvStatus == 0)) {
|
||||
programRecord = nullptr;
|
||||
}
|
||||
const Bool programUsable = programRecord != nullptr;
|
||||
if (programUsable) {
|
||||
const TextureImpl::DrawTextureSyncKeys& keys, MG_Pipe::MGPipeHandle programCso,
|
||||
const MG_Pipe::MGPipeShaderCsoRecord* programRecord) {
|
||||
if (programRecord != nullptr) {
|
||||
#ifdef TRACY_ENABLE
|
||||
ZoneScopedNC("BindCurrentProgram", TRACY_ZONECOLOR_BACKEND);
|
||||
#endif
|
||||
|
||||
@@ -1045,8 +1045,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
const auto& color = record.Color[i];
|
||||
if (color.Res == record.ReadSurface.Res && color.Kind == record.ReadSurface.Kind &&
|
||||
color.Layered == record.ReadSurface.Layered && color.Level == record.ReadSurface.Level &&
|
||||
color.NumViews == record.ReadSurface.NumViews && color.Layer == record.ReadSurface.Layer &&
|
||||
color.UploadTarget == record.ReadSurface.UploadTarget) {
|
||||
color.Layer == record.ReadSurface.Layer && color.UploadTarget == record.ReadSurface.UploadTarget) {
|
||||
return static_cast<FramebufferAttachmentType>(static_cast<Int>(FramebufferAttachmentType::Color0) +
|
||||
static_cast<Int>(i));
|
||||
}
|
||||
|
||||
@@ -107,16 +107,8 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
// MGPipeApplier().DispatchProgram, which set_dispatch_program carried. A compute-only
|
||||
// pipeline has no draw program at all, which is why the two applier fields are separate.
|
||||
const MG_Pipe::MGPipeHandle dispatchCso = MG_Pipe::MGPipeApplier().DispatchProgram;
|
||||
PrgramImpl::SyncCurrentProgramByHandle(dispatchCso, false);
|
||||
|
||||
// The same gate as the frontend one below, from the record: a dispatch of a program
|
||||
// the frontend reports unlinked, or one whose SPIR-V never arrived, binds nothing.
|
||||
const auto* const record = PrgramImpl::FindShaderCsoRecord(dispatchCso);
|
||||
if (record == nullptr || record->Desc.LinkStatus == 0 || record->Desc.SpirvStatus == 0) {
|
||||
g_GLESFuncs.glUseProgram(0);
|
||||
PrgramImpl::g_lastUsedBackendProgramId = 0;
|
||||
return;
|
||||
}
|
||||
const auto* programRecord = PrgramImpl::SyncCurrentProgramByHandle(dispatchCso, false);
|
||||
if (programRecord == nullptr) return;
|
||||
|
||||
// Compute shaders sample textures through the same unit bindings as draws
|
||||
// (e.g. Flywheel's depth-pyramid downsample reads the depth attachment on
|
||||
@@ -125,7 +117,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
// Compute programs need the same per-program resource sync as draws:
|
||||
// uniform-block bindings and sampler units only exist through the API
|
||||
// because layout(binding) is stripped from the transpiled ESSL.
|
||||
BindCurrentProgramWithResources(currentProgram, textureKeys, dispatchCso);
|
||||
BindCurrentProgramWithResources(currentProgram, textureKeys, dispatchCso, programRecord);
|
||||
}
|
||||
|
||||
Bool UpdateTextureBindingAtTarget(GLenum target) {
|
||||
|
||||
@@ -582,8 +582,10 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
const Bool widenedColorClear =
|
||||
widenedDrawBuffers != 0 && FramebufferImpl::g_integerColorDrawBufferMask == 0;
|
||||
GLint clearDrawFbo = 0;
|
||||
g_GLESFuncs.glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &clearDrawFbo);
|
||||
if ((outOfRange || widenedColorClear) && clearDrawFbo != 0) {
|
||||
if (outOfRange || widenedColorClear) {
|
||||
g_GLESFuncs.glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &clearDrawFbo);
|
||||
}
|
||||
if (clearDrawFbo != 0) {
|
||||
GLint maxDrawBuffers = 0;
|
||||
GLint clearedCount = 0;
|
||||
GLint firstDb = -1;
|
||||
|
||||
@@ -387,9 +387,9 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
const MG_Pipe::MGPipeShaderCsoRecord* ResolveGlobalConstantsRecordForHandle(MG_Pipe::MGPipeHandle handle,
|
||||
Uint uboSize);
|
||||
|
||||
// `plan` (a draw's) arms the program's narrow-integer seeds when it needs them.
|
||||
void SyncCurrentProgramByHandle(MG_Pipe::MGPipeHandle cso, Bool forDraw,
|
||||
const IntegerAttributePlan* plan = nullptr);
|
||||
// Returns the validated record for resource binding in the same draw or dispatch.
|
||||
const MG_Pipe::MGPipeShaderCsoRecord* SyncCurrentProgramByHandle(MG_Pipe::MGPipeHandle cso, Bool forDraw,
|
||||
const IntegerAttributePlan* plan = nullptr);
|
||||
} // namespace PrgramImpl
|
||||
|
||||
// Defined with the surface registry, below.
|
||||
@@ -398,8 +398,8 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
void BindCurrentFBO(FramebufferTarget target);
|
||||
|
||||
void BindCurrentProgramWithResources(const SharedPtr<MG_State::GLState::ProgramObject>& currentProgram,
|
||||
const TextureImpl::DrawTextureSyncKeys& keys,
|
||||
MG_Pipe::MGPipeHandle programCso);
|
||||
const TextureImpl::DrawTextureSyncKeys& keys, MG_Pipe::MGPipeHandle programCso,
|
||||
const MG_Pipe::MGPipeShaderCsoRecord* programRecord);
|
||||
void BindCurrentTextures(const TextureImpl::DrawTextureSyncKeys& keys,
|
||||
const SharedPtr<MG_State::GLState::ProgramObject>& currentProgram);
|
||||
|
||||
@@ -504,8 +504,8 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
void BindCurrentTextures();
|
||||
|
||||
void BindCurrentProgramWithResources(const SharedPtr<MG_State::GLState::ProgramObject>& currentProgram,
|
||||
const TextureImpl::DrawTextureSyncKeys& keys,
|
||||
MG_Pipe::MGPipeHandle programCso);
|
||||
const TextureImpl::DrawTextureSyncKeys& keys, MG_Pipe::MGPipeHandle programCso,
|
||||
const MG_Pipe::MGPipeShaderCsoRecord* programRecord);
|
||||
|
||||
PrgramImpl::BackendProgramObjectImpl* GetCurrentBackendProgram();
|
||||
|
||||
|
||||
@@ -1434,7 +1434,8 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
// and the clamp masks, the broadcast count, ImageUnitFormatsStillMatch and the three
|
||||
// patch clauses are unchanged - they are backend globals, fb's row and VALUE rows of the
|
||||
// residual block, none of which this family owns.
|
||||
void SyncCurrentProgramByHandle(MG_Pipe::MGPipeHandle cso, Bool forDraw, const IntegerAttributePlan* plan) {
|
||||
const MG_Pipe::MGPipeShaderCsoRecord* SyncCurrentProgramByHandle(MG_Pipe::MGPipeHandle cso, Bool forDraw,
|
||||
const IntegerAttributePlan* plan) {
|
||||
#ifdef TRACY_ENABLE
|
||||
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
||||
#endif
|
||||
@@ -1453,7 +1454,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
if (record == nullptr || record->Desc.LinkStatus == 0 || record->Desc.SpirvStatus == 0) {
|
||||
g_GLESFuncs.glUseProgram(0);
|
||||
g_lastUsedBackendProgramId = 0;
|
||||
return;
|
||||
return nullptr;
|
||||
}
|
||||
// REFUSED at a draw, record-only at a dispatch: see the policy's own note.
|
||||
ResolveFragColorBroadcastCount(forDraw ? BroadcastCountPolicy::RefuseFallback
|
||||
@@ -1466,7 +1467,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
// than a draw with somebody else's shader.
|
||||
g_GLESFuncs.glUseProgram(0);
|
||||
g_lastUsedBackendProgramId = 0;
|
||||
return;
|
||||
return record;
|
||||
}
|
||||
// Sticky for the twin's lifetime: a draw that needs the seeds rebuilds the program once.
|
||||
if (plan != nullptr && plan->NeedsSeeds()) twin->NarrowIntegerSeeds().wanted = true;
|
||||
@@ -1488,6 +1489,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
}
|
||||
g_currentDrawProgramHandle = cso;
|
||||
g_currentDrawBackendProgram = twin;
|
||||
return record;
|
||||
}
|
||||
} // namespace PrgramImpl
|
||||
} // namespace MobileGL::MG_Backend::DirectGLES
|
||||
@@ -450,7 +450,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
// and the serials are handed out to every native context of every session in turn, so the
|
||||
// highest signaled serial says nothing about an older fence of another context still
|
||||
// pending. A serial is complete when no live fence at or below it is pending.
|
||||
void PollFrameFences() {
|
||||
void PollFrameFences(const FrameFence* signaled = nullptr) {
|
||||
if (!g_GLESFuncs.glGetSynciv) return;
|
||||
Uint64 lowestPending = ~Uint64{0};
|
||||
for (FrameFence& slot : g_frameFenceRing) {
|
||||
@@ -460,8 +460,10 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
continue;
|
||||
}
|
||||
GLint status = GL_SIGNALED;
|
||||
GLsizei length = 0;
|
||||
g_GLESFuncs.glGetSynciv(slot.sync, GL_SYNC_STATUS, 1, &length, &status);
|
||||
if (&slot != signaled) {
|
||||
GLsizei length = 0;
|
||||
g_GLESFuncs.glGetSynciv(slot.sync, GL_SYNC_STATUS, 1, &length, &status);
|
||||
}
|
||||
if (status == GL_SIGNALED) {
|
||||
if (g_GLESFuncs.glDeleteSync) g_GLESFuncs.glDeleteSync(slot.sync);
|
||||
slot.sync = nullptr;
|
||||
@@ -639,6 +641,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
} else if (g_EGLFuncs.eglSwapBuffers != nullptr) {
|
||||
mglSwapped = g_EGLFuncs.eglSwapBuffers(g_Display, drawSurface);
|
||||
}
|
||||
if (mglSwapped == EGL_TRUE) TextureImpl::EndDrawTextureBatch();
|
||||
NoteDrawSurfaceMoved(); // a window surface takes a new size at its swap
|
||||
if (drawSurface != EGL_NO_SURFACE) {
|
||||
const std::lock_guard<std::mutex> lock(g_nativeRegistryMutex);
|
||||
@@ -653,6 +656,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
// the same bound on the ES driver: after presenting S, wait for S+1-N to complete. The
|
||||
// platform's own queueBuffer throttle already waits for S-1, so only N = 1 is stricter
|
||||
// than what Android does by itself; larger N is the same contract stated, not a change.
|
||||
const FrameFence* signaled = nullptr;
|
||||
const Uint32 framesInFlight = MG_Config::Features.FramesInFlight;
|
||||
if (presentedSerial != 0 && framesInFlight != 0 && framesInFlight < static_cast<Uint32>(kFrameFenceRingDepth) &&
|
||||
g_GLESFuncs.glClientWaitSync && presentedSerial + 1 > framesInFlight) {
|
||||
@@ -660,11 +664,15 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
const FrameFence& oldest = g_frameFenceRing[target % kFrameFenceRingDepth];
|
||||
if (oldest.sync && oldest.serial == target && oldest.contextGeneration == g_syncContextGeneration) {
|
||||
constexpr Uint64 kFramesInFlightWaitNs = 1000ull * 1000 * 1000;
|
||||
(void)g_GLESFuncs.glClientWaitSync(oldest.sync, GL_SYNC_FLUSH_COMMANDS_BIT, kFramesInFlightWaitNs);
|
||||
const GLenum status =
|
||||
g_GLESFuncs.glClientWaitSync(oldest.sync, GL_SYNC_FLUSH_COMMANDS_BIT, kFramesInFlightWaitNs);
|
||||
if (status == GL_ALREADY_SIGNALED || status == GL_CONDITION_SATISFIED) {
|
||||
signaled = &oldest;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (canFence) PollFrameFences();
|
||||
if (canFence) PollFrameFences(signaled);
|
||||
|
||||
// After the watermark advanced: retire grown-away ring stores and record the
|
||||
// frame's ring high-water marks for slot reclamation.
|
||||
|
||||
@@ -7,9 +7,50 @@
|
||||
// End of Source File Header
|
||||
|
||||
#include "DirectGLESInternal.h"
|
||||
#include "DrawTextureReads.h"
|
||||
|
||||
namespace MobileGL::MG_Backend::DirectGLES {
|
||||
namespace TextureImpl {
|
||||
namespace {
|
||||
PerNativeContext<DrawTextureReads> g_drawTextureReads;
|
||||
} // namespace
|
||||
|
||||
void NoteDrawTextureFramebuffer(Uint framebuffer) {
|
||||
if (CurrentNativeContextSerial() != 0) g_drawTextureReads.Current().BindFramebuffer(framebuffer);
|
||||
}
|
||||
|
||||
void DeleteDrawTextureFramebuffer(Uint framebuffer) {
|
||||
if (CurrentNativeContextSerial() != 0) g_drawTextureReads.Current().DeleteFramebuffer(framebuffer);
|
||||
}
|
||||
|
||||
void EndDrawTextureBatch() {
|
||||
if (CurrentNativeContextSerial() != 0) g_drawTextureReads.Current().EndBatch();
|
||||
}
|
||||
|
||||
Bool WasTextureReadInDrawBatch(MG_Pipe::MGPipeHandle storage) {
|
||||
return CurrentNativeContextSerial() != 0 && g_drawTextureReads.Current().WasRead(storage.Slot, storage.Gen);
|
||||
}
|
||||
|
||||
void NoteDrawTextureReads() {
|
||||
if (CurrentNativeContextSerial() == 0) return;
|
||||
auto& reads = g_drawTextureReads.Current();
|
||||
const auto& state = MG_Pipe::MGPipeApplier();
|
||||
if (!reads.NeedsSamplerWalk(state.ContextSerial, state.SamplerViewsSerial)) return;
|
||||
|
||||
const SizeT end = std::min<SizeT>(static_cast<SizeT>(state.SamplerViewStart) + state.SamplerViewCount,
|
||||
state.BoundSamplerViews.size());
|
||||
for (SizeT unit = state.SamplerViewStart; unit < end; ++unit) {
|
||||
const auto* texture = PipeTextureRecordForHandle(state.BoundSamplerViews[unit].Texture);
|
||||
if (!texture) continue;
|
||||
// A sampler view and an update to its parent address the same texture storage.
|
||||
if (const auto* storage = PipeTextureStorageRecordForRecord(*texture)) {
|
||||
const auto handle = storage->Desc.Resource;
|
||||
reads.NoteRead(handle.Slot, handle.Gen);
|
||||
}
|
||||
}
|
||||
reads.RecordSamplerWalk(state.ContextSerial, state.SamplerViewsSerial);
|
||||
}
|
||||
|
||||
// Identity snapshot of what one texture unit has bound: the object in every binding
|
||||
// slot plus the unit's sampler object. This - not the context's texture bind
|
||||
// generation - is what the per-draw texture memos key on: the generation also bumps
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
// MobileGL - MobileGL/MG_Backend/DirectGLES/DrawTextureReads.h
|
||||
// Copyright (c) 2025-2026 MobileGL-Dev
|
||||
// Licensed under the GNU Lesser General Public License v3.0:
|
||||
// https://www.gnu.org/licenses/gpl-3.0.txt
|
||||
// https://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
// SPDX-License-Identifier: LGPL-3.0-only
|
||||
// End of Source File Header
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
namespace MobileGL::MG_Backend::DirectGLES::TextureImpl {
|
||||
// One instance per native context. Slot generations distinguish reused texture names,
|
||||
// and batch stamps let us discard a batch without walking its texture slots.
|
||||
class DrawTextureReads {
|
||||
public:
|
||||
void BindFramebuffer(std::uint32_t framebuffer) {
|
||||
if (m_drawFramebuffer == framebuffer) return;
|
||||
m_drawFramebuffer = framebuffer;
|
||||
EndBatch();
|
||||
}
|
||||
|
||||
void DeleteFramebuffer(std::uint32_t framebuffer) {
|
||||
if (framebuffer == m_drawFramebuffer) BindFramebuffer(0);
|
||||
}
|
||||
|
||||
void EndBatch() {
|
||||
m_recordedSamplers = false;
|
||||
if (++m_batch == 0) {
|
||||
m_reads.clear();
|
||||
m_batch = 1;
|
||||
}
|
||||
}
|
||||
|
||||
bool NeedsSamplerWalk(std::uint64_t context, std::uint64_t views) const {
|
||||
return m_drawFramebuffer != 0 && (!m_recordedSamplers || context != m_context || views != m_views);
|
||||
}
|
||||
|
||||
void RecordSamplerWalk(std::uint64_t context, std::uint64_t views) {
|
||||
m_recordedSamplers = true;
|
||||
m_context = context;
|
||||
m_views = views;
|
||||
}
|
||||
|
||||
void NoteRead(std::uint32_t slot, std::uint32_t generation) {
|
||||
if (slot >= m_reads.size()) m_reads.resize(static_cast<std::size_t>(slot) + 1);
|
||||
m_reads[slot] = Stamp(generation);
|
||||
}
|
||||
|
||||
bool WasRead(std::uint32_t slot, std::uint32_t generation) const {
|
||||
return m_drawFramebuffer != 0 && slot < m_reads.size() && m_reads[slot] == Stamp(generation);
|
||||
}
|
||||
|
||||
private:
|
||||
std::uint64_t Stamp(std::uint32_t generation) const { return (std::uint64_t{m_batch} << 32) | generation; }
|
||||
|
||||
std::uint32_t m_drawFramebuffer = 0;
|
||||
std::uint32_t m_batch = 1;
|
||||
bool m_recordedSamplers = false;
|
||||
std::uint64_t m_context = 0;
|
||||
std::uint64_t m_views = 0;
|
||||
std::vector<std::uint64_t> m_reads;
|
||||
};
|
||||
} // namespace MobileGL::MG_Backend::DirectGLES::TextureImpl
|
||||
@@ -272,11 +272,16 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
// re-pushes index 0's state. Takes the count so it can do nothing at all in the common case.
|
||||
void EndViewportRoutingPasses(Uint passCount);
|
||||
|
||||
namespace TextureImpl {
|
||||
void NoteDrawTextureReads();
|
||||
} // namespace TextureImpl
|
||||
|
||||
// Issue one draw, replayed once per viewport-routing pass. Every application-visible draw
|
||||
// entry point wraps its native glDraw* call in this; the internal blit and clear helpers
|
||||
// deliberately do not, because they bind their own programs, which never route.
|
||||
template <typename IssueDraw>
|
||||
inline void ForEachViewportRoutingPass(IssueDraw&& issue) {
|
||||
TextureImpl::NoteDrawTextureReads();
|
||||
const Uint passCount = BeginViewportRoutingPasses();
|
||||
for (Uint pass = 0; pass < passCount; ++pass) {
|
||||
if (passCount > 1) {
|
||||
@@ -1878,15 +1883,11 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
Uint64 m_sharedImageId = 0;
|
||||
SharedImageImpl::EglImageRef m_sharedImage;
|
||||
#endif
|
||||
// Whether the driver texture may hold texels the shadow never saw. Set the first time
|
||||
// anything other than a texel upload can write it - an application framebuffer
|
||||
// attachment, a writable image binding, a copy or blit into it, a driver-side mipmap
|
||||
// generation - and never cleared. Until then the driver holds, outside a level's
|
||||
// pending writes, exactly the shadow bytes it was last sent, so those writes may go up
|
||||
// as their union box (one unpack-ring job, which is what Mali needs); from then on
|
||||
// only the texels the client wrote may go up, since the shadow is stale everywhere
|
||||
// else. See SyncMipmapsToBackend.
|
||||
// Once a framebuffer, image binding, copy, or mipmap generation may write this texture,
|
||||
// the CPU shadow can be stale. Upload only the texels the client wrote from then on.
|
||||
Bool m_driverMayHoldGpuWrites = false;
|
||||
// Retry the packed path when the texture's storage changes.
|
||||
Bool m_packedUploadRejected = false;
|
||||
// Latches the "this driver has no buffer textures" report to once per texture. The
|
||||
// report is emitted from the respecify path, which bails before recording the state
|
||||
// it was asked to apply - so without the latch the texture stays permanently dirty
|
||||
@@ -2106,6 +2107,10 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
// issued since the last one. Sampled access from a draw does not take it: that is the
|
||||
// order every driver keeps on its own, and it is the per-draw hot path.
|
||||
void NoteInPlaceTextureUpload();
|
||||
void NoteDrawTextureFramebuffer(Uint framebuffer);
|
||||
void DeleteDrawTextureFramebuffer(Uint framebuffer);
|
||||
void EndDrawTextureBatch();
|
||||
Bool WasTextureReadInDrawBatch(MG_Pipe::MGPipeHandle storage);
|
||||
// The barrier bits owed for the uploads noted since the last call (0 when none), and
|
||||
// the note cleared: the caller issues them, folded into any barrier of its own.
|
||||
GLbitfield TakeInPlaceTextureUploadBarrierBits();
|
||||
@@ -2673,8 +2678,6 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
// build's (ProgramBuildSource), so the pull build compiles the very same text
|
||||
// against a ProgramObject and G1's byte identity survives.
|
||||
Uint GetExternalIndex() const { return Identity; }
|
||||
// GL_OVR_multiview's num_views of the vertex stage, 0 without one.
|
||||
Int GetVertexNumViews() const { return Link ? Link->vsNumViews : 0; }
|
||||
Bool GetLinkStatus() const { return Linked; }
|
||||
Bool GetSpirvStatus() const { return SpirvUsable; }
|
||||
Bool GetSpirvValidationEnabled() const { return SpirvValidationEnabled; }
|
||||
|
||||
@@ -2741,16 +2741,9 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
}
|
||||
} // namespace
|
||||
|
||||
// Bump-allocate `size` bytes out of `ring`.
|
||||
//
|
||||
// Fast path: a live store under the current context with room before both
|
||||
// the wrap boundary and the in-flight tail. Touches no GL and probes no
|
||||
// frame marks - callers sit behind the ring's availability gate, so the
|
||||
// context checks have already run for this draw/upload. `tail` may be stale
|
||||
// here (marks are only retired on Present and on the slow path); staleness
|
||||
// is conservative - the in-flight span reads too large, the check fails,
|
||||
// and the slow path retires marks and re-tries.
|
||||
Bool RingAllocate(PersistentRing& ring, SizeT size, SizeT& outOffset) {
|
||||
// Allocate within the mapped ring without GL calls or polling fences. A stale tail
|
||||
// accounts for extra bytes in flight, so it can only make this check more conservative.
|
||||
static Bool TryAllocateMappedRing(PersistentRing& ring, SizeT size, SizeT& outOffset) {
|
||||
if (size == 0) return false;
|
||||
auto& store = ring.store;
|
||||
if (store.id != 0 && store.contextGeneration == g_bufferContextGeneration) {
|
||||
@@ -2770,7 +2763,12 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return RingAllocateSlow(ring, size, outOffset);
|
||||
return false;
|
||||
}
|
||||
|
||||
Bool RingAllocate(PersistentRing& ring, SizeT size, SizeT& outOffset) {
|
||||
return TryAllocateMappedRing(ring, size, outOffset) ||
|
||||
(size != 0 && RingAllocateSlow(ring, size, outOffset));
|
||||
}
|
||||
|
||||
Bool RingAllocateSlow(PersistentRing& ring, SizeT size, SizeT& outOffset) {
|
||||
@@ -2969,6 +2967,10 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
return RingAllocate(UnpackRing(), size, outOffset);
|
||||
}
|
||||
|
||||
Bool TryAllocateMappedUnpackRing(SizeT size, SizeT& outOffset) {
|
||||
return size <= kUnpackRingMaxBytes && TryAllocateMappedRing(UnpackRing(), size, outOffset);
|
||||
}
|
||||
|
||||
void* UnpackRingMappedPtr() {
|
||||
return UnpackRing().store.mappedPtr;
|
||||
}
|
||||
|
||||
@@ -46,6 +46,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
NoteFramebufferIdDeleted(m_backendFBOId);
|
||||
if (m_contextGeneration == g_backendContextGeneration && g_GLESFuncs.glDeleteFramebuffers) {
|
||||
g_GLESFuncs.glDeleteFramebuffers(1, &m_backendFBOId);
|
||||
TextureImpl::DeleteDrawTextureFramebuffer(m_backendFBOId);
|
||||
}
|
||||
m_backendFBOId = 0;
|
||||
}
|
||||
@@ -83,6 +84,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
if (bindsDraw) {
|
||||
g_driverFBOBindings[drawIdx] = id;
|
||||
g_driverFBOBindingKnown[drawIdx] = true;
|
||||
if (!drawMatches) TextureImpl::NoteDrawTextureFramebuffer(id);
|
||||
}
|
||||
if (bindsRead) {
|
||||
g_driverFBOBindings[readIdx] = id;
|
||||
@@ -409,21 +411,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
// texture behind the staged shadow's back (the frontend arm's note, by handle).
|
||||
TextureImpl::NoteDriverSideTextureWriteByHandle(surface.Res);
|
||||
const auto uploadTarget = static_cast<TextureUploadTarget>(surface.UploadTarget);
|
||||
if (surface.NumViews != 0) {
|
||||
// GL_OVR_multiview. The frontend only builds one where the driver has the
|
||||
// extension, but the record is the untrusted half: a multiview surface on a
|
||||
// driver without the entry point is refused by name, never called through.
|
||||
if (!g_GLESCapabilities.SupportsMultiview) {
|
||||
MGLOG_E_ONCE("MGPipe: attachment surface {%u, %u} is multiview, but this driver has no "
|
||||
"GL_OVR_multiview - refusing to attach it",
|
||||
surface.Res.Slot, surface.Res.Gen);
|
||||
return false;
|
||||
}
|
||||
g_GLESFuncs.glFramebufferTextureMultiviewOVR(
|
||||
glFBOTarget, glBackendAttachment, backendTextureObject->GetBackendTextureId(),
|
||||
static_cast<GLint>(surface.Level), static_cast<GLint>(surface.Layer),
|
||||
static_cast<GLsizei>(surface.NumViews));
|
||||
} else if (surface.Layered != 0) {
|
||||
if (surface.Layered != 0) {
|
||||
g_GLESFuncs.glFramebufferTexture(glFBOTarget, glBackendAttachment,
|
||||
backendTextureObject->GetBackendTextureId(),
|
||||
static_cast<GLint>(surface.Level));
|
||||
@@ -594,7 +582,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
const auto& color = record.Color[i];
|
||||
if (color.Res == record.ReadSurface.Res && color.Kind == record.ReadSurface.Kind &&
|
||||
color.Layered == record.ReadSurface.Layered && color.Level == record.ReadSurface.Level &&
|
||||
color.NumViews == record.ReadSurface.NumViews && color.Layer == record.ReadSurface.Layer &&
|
||||
color.Layer == record.ReadSurface.Layer &&
|
||||
color.UploadTarget == record.ReadSurface.UploadTarget) {
|
||||
pushedReadBuf = static_cast<FramebufferAttachmentType>(
|
||||
static_cast<Int>(FramebufferAttachmentType::Color0) + static_cast<Int>(i));
|
||||
|
||||
@@ -382,6 +382,10 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
|
||||
Bool UnpackRingAllocate(SizeT size, SizeT& outOffset);
|
||||
|
||||
// Only use space in the current mapping. Optional uploads can fall back
|
||||
// immediately when the ring would have to grow or wait.
|
||||
Bool TryAllocateMappedUnpackRing(SizeT size, SizeT& outOffset);
|
||||
|
||||
void* UnpackRingMappedPtr();
|
||||
|
||||
Uint UnpackRingBufferId();
|
||||
|
||||
@@ -1371,14 +1371,6 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
}
|
||||
}
|
||||
|
||||
// After every validating pass: the module that comes back names ViewIndex without the
|
||||
// capability, which only SPIRV-Cross reads (see StripMultiviewCapabilityForEssl).
|
||||
Vector<unsigned int> multiviewStrippedSpirv;
|
||||
if (MG_Util::ShaderTranspiler::ShaderCompiler::StripMultiviewCapabilityForEssl(*effectiveSpirv,
|
||||
multiviewStrippedSpirv)) {
|
||||
effectiveSpirv = &multiviewStrippedSpirv;
|
||||
}
|
||||
|
||||
MG_Util::ShaderTranspiler::SpvcSession spvcSession(*effectiveSpirv,
|
||||
MG_Util::ShaderTranspiler::SessionUsageBit::Transpile);
|
||||
|
||||
@@ -2163,9 +2155,6 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
!(ViewportArrayEmulationEnabled() && programRoutesViewportIndex) &&
|
||||
source.find("gl_ViewportIndex") != String::npos;
|
||||
source = RequestViewportArrayExtension(std::move(source), needsViewportArrayExtension);
|
||||
// GL_OVR_multiview's directive and num_views, which the memoized ESSL leaves out.
|
||||
source = RequestMultiviewExtension(std::move(source), glShaderType, src.GetVertexNumViews(),
|
||||
g_GLESCapabilities.SupportsMultiview2);
|
||||
|
||||
// The fourth header-level rewrite, and the same shape as the third: ESSL has no
|
||||
// gl_PointSize in a tessellation or geometry stage at ANY version - 320 makes the
|
||||
|
||||
@@ -7,6 +7,9 @@
|
||||
// End of Source File Header
|
||||
|
||||
#include "ManagersInternal.h"
|
||||
#include "DirectGLESInternal.h"
|
||||
#include <MG_Util/Texture/PackedTextureUpload.h>
|
||||
#include <MG_Util/Texture/TextureUploadBoxes.h>
|
||||
|
||||
namespace MobileGL::MG_Backend::DirectGLES {
|
||||
namespace TextureImpl {
|
||||
@@ -97,6 +100,149 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
return reinterpret_cast<const void*>(static_cast<std::uintptr_t>(offset));
|
||||
}
|
||||
|
||||
namespace {
|
||||
static Bool SplitMipUpload(const MG_Pipe::MGPipeResourceRecord::PendingUpload& pending,
|
||||
const IntVec3& levelSize, MG_State::GLState::MipmapDirtyRegion* boxes) {
|
||||
using namespace MG_Util::TextureUploadBoxes;
|
||||
const auto& bounds = pending.UnionBox;
|
||||
if (bounds.X < 0 || bounds.Y < 0 || bounds.Z != 0 || bounds.D != 1 || bounds.X >= levelSize.x() ||
|
||||
bounds.Y >= levelSize.y() || bounds.W > static_cast<Uint>(levelSize.x() - bounds.X) ||
|
||||
bounds.H > static_cast<Uint>(levelSize.y() - bounds.Y)) {
|
||||
return false;
|
||||
}
|
||||
const Box unionBox{bounds.X, bounds.Y, bounds.X + static_cast<Int>(bounds.W),
|
||||
bounds.Y + static_cast<Int>(bounds.H)};
|
||||
if (!WorthSearching(unionBox, pending.Regions.size())) return false;
|
||||
std::array<Box, MaxRegions> regions;
|
||||
for (SizeT i = 0; i < pending.Regions.size(); ++i) {
|
||||
const auto& region = pending.Regions[i];
|
||||
if (region.X < unionBox.left || region.X >= unionBox.right || region.Y < unionBox.top ||
|
||||
region.Y >= unionBox.bottom || region.Z != 0 || region.D != 1 || region.W == 0 ||
|
||||
region.H == 0 || region.W > static_cast<Uint>(unionBox.right - region.X) ||
|
||||
region.H > static_cast<Uint>(unionBox.bottom - region.Y)) {
|
||||
return false;
|
||||
}
|
||||
regions[i] = {region.X, region.Y, region.X + static_cast<Int>(region.W),
|
||||
region.Y + static_cast<Int>(region.H)};
|
||||
}
|
||||
const auto split = Split(unionBox, regions, pending.Regions.size());
|
||||
if (!split) return false;
|
||||
for (SizeT i = 0; i < split->size(); ++i) {
|
||||
const auto& box = (*split)[i];
|
||||
boxes[i] = {IntVec3{box.left, box.top, 0}, IntVec3{box.right, box.bottom, 1}};
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
struct PackedUploadPage {
|
||||
GLuint texture = 0;
|
||||
Uint generation = 0;
|
||||
Uint64 context = 0;
|
||||
Uint64 retireSerial = 0;
|
||||
};
|
||||
|
||||
// The names live in the share group, while reuse is restricted to the
|
||||
// EGL context that submitted the copies. Any retired context's page
|
||||
// can be deleted the next time a shared context acquires its slot.
|
||||
struct PackedUploadPages final : PerNativeContextBase {
|
||||
std::mutex mutex;
|
||||
std::array<PackedUploadPage, 4> pages;
|
||||
|
||||
void ForgetContext(Uint64 context) override {
|
||||
const std::lock_guard<std::mutex> lock(mutex);
|
||||
for (auto& page : pages) {
|
||||
if (page.context == context) page.context = 0;
|
||||
}
|
||||
}
|
||||
|
||||
PackedUploadPage* FindIdle(Uint64 context) {
|
||||
const Uint64 completed = CompletedFrameSerial();
|
||||
PackedUploadPage* vacant = nullptr;
|
||||
for (auto& page : pages) {
|
||||
if (page.generation != g_backendContextGeneration) page = {};
|
||||
if (page.context == context && page.retireSerial <= completed) return &page;
|
||||
if (page.context == 0 && vacant == nullptr) vacant = &page;
|
||||
}
|
||||
return vacant;
|
||||
}
|
||||
};
|
||||
|
||||
enum class PackedUploadResult {
|
||||
Unavailable,
|
||||
Rejected,
|
||||
Committed
|
||||
};
|
||||
|
||||
static PackedUploadResult SubmitPackedUpload(const MG_Util::PackedTextureUpload::Batch& batch,
|
||||
GLuint destination, Uint64 unionTexels) {
|
||||
const Uint64 context = CurrentNativeContextSerial();
|
||||
if (context == 0) return PackedUploadResult::Unavailable;
|
||||
static PackedUploadPages pool;
|
||||
const std::unique_lock<std::mutex> lock(pool.mutex, std::try_to_lock);
|
||||
if (!lock.owns_lock()) return PackedUploadResult::Unavailable;
|
||||
auto* page = pool.FindIdle(context);
|
||||
if (page == nullptr) return PackedUploadResult::Unavailable;
|
||||
|
||||
SizeT offset = 0;
|
||||
if (!BufferImpl::TryAllocateMappedUnpackRing(batch.ByteSize(), offset)) {
|
||||
return PackedUploadResult::Unavailable;
|
||||
}
|
||||
auto* mapping = static_cast<Uint8*>(BufferImpl::UnpackRingMappedPtr());
|
||||
MG_Util::PackedTextureUpload::WritePage(batch, mapping + offset);
|
||||
|
||||
DrainDriverErrors("packed texture upload");
|
||||
if (page->context != context) {
|
||||
if (page->texture != 0) g_GLESFuncs.glDeleteTextures(1, &page->texture);
|
||||
*page = {0, g_backendContextGeneration, context, 0};
|
||||
g_GLESFuncs.glGenTextures(1, &page->texture);
|
||||
if (page->texture == 0) {
|
||||
*page = {};
|
||||
return PackedUploadResult::Rejected;
|
||||
}
|
||||
g_GLESFuncs.glBindTexture(GL_TEXTURE_2D, page->texture);
|
||||
g_GLESFuncs.glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, MG_Util::PackedTextureUpload::PageSide,
|
||||
MG_Util::PackedTextureUpload::PageSide);
|
||||
g_GLESFuncs.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
g_GLESFuncs.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
if (g_GLESFuncs.glGetError() != GL_NO_ERROR) {
|
||||
g_GLESFuncs.glBindTexture(GL_TEXTURE_2D, destination);
|
||||
g_GLESFuncs.glDeleteTextures(1, &page->texture);
|
||||
*page = {};
|
||||
return PackedUploadResult::Rejected;
|
||||
}
|
||||
} else {
|
||||
g_GLESFuncs.glBindTexture(GL_TEXTURE_2D, page->texture);
|
||||
}
|
||||
|
||||
// SyncMipmapsToBackend has the destination bound on the temp unit.
|
||||
// Restore that raw binding before returning to the cached GL state.
|
||||
BufferImpl::BindPixelUnpackBufferId(BufferImpl::UnpackRingBufferId());
|
||||
g_GLESFuncs.glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, batch.width, batch.height, GL_RGBA,
|
||||
GL_UNSIGNED_BYTE, UnpackRingPixelOffset(offset));
|
||||
BufferImpl::BindPixelUnpackBufferId(0);
|
||||
g_GLESFuncs.glBindTexture(GL_TEXTURE_2D, destination);
|
||||
page->retireSerial = CurrentFrameSerial() + 1;
|
||||
if (g_GLESFuncs.glGetError() != GL_NO_ERROR) return PackedUploadResult::Rejected;
|
||||
if (MG_Util::PipeStats::Enabled()) {
|
||||
MG_Util::PipeStats::AddBytes(MG_Util::PipeStats::ByteClass::StageTexture, batch.ByteSize());
|
||||
}
|
||||
|
||||
for (SizeT i = 0; i < batch.count; ++i) {
|
||||
const auto& region = batch.regions[i];
|
||||
const auto& source = batch.offsets[i];
|
||||
g_GLESFuncs.glCopyImageSubData(page->texture, GL_TEXTURE_2D, 0, source.x, source.y, 0, destination,
|
||||
GL_TEXTURE_2D, region.level, region.x, region.y, 0, region.width,
|
||||
region.height, 1);
|
||||
}
|
||||
if (g_GLESFuncs.glGetError() != GL_NO_ERROR) return PackedUploadResult::Rejected;
|
||||
MGLOG_I_ONCE(
|
||||
"Packed texture upload: %zu regions, %zu packed bytes, %llu bounding-box bytes", batch.count,
|
||||
batch.ByteSize(),
|
||||
static_cast<unsigned long long>(unionTexels * MG_Util::PackedTextureUpload::BytesPerTexel));
|
||||
return PackedUploadResult::Committed;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
static Uint GetNormFallbackComponentCount(TextureInternalFormat format) {
|
||||
switch (format) {
|
||||
case TextureInternalFormat::R8Snorm:
|
||||
@@ -755,6 +901,69 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
(pushedStorage != nullptr ? static_cast<TextureStorageType>(pushedStorage->Desc.StorageKind) \
|
||||
: (obj)->GetStorageType())
|
||||
|
||||
static PackedUploadResult TryPackedMipUpload(MG_State::GLState::TextureObjectMipmap* textureMipmapObject,
|
||||
const MG_Pipe::MGPipeResourceRecord* pushedStorage,
|
||||
MG_Pipe::MGPipeHandle pushedRes, TextureUploadTarget uploadTarget,
|
||||
SizeT mipmapCount, GLuint destination) {
|
||||
using namespace MG_Util::PackedTextureUpload;
|
||||
Batch batch;
|
||||
Uint64 unionTexels = 0;
|
||||
const auto targetCode = static_cast<Uint16>(uploadTarget);
|
||||
for (SizeT level = 0; level < mipmapCount; ++level) {
|
||||
const auto levelCode = static_cast<Uint16>(level);
|
||||
const auto* pending = FindPipeTextureUpload(*pushedStorage, targetCode, levelCode);
|
||||
if (pending == nullptr) continue;
|
||||
if (pending->Regions.empty() || pending->Regions.size() > MaxRegions - batch.count) {
|
||||
return PackedUploadResult::Unavailable;
|
||||
}
|
||||
const auto size = MGB_LEVEL_TEXEL_SIZE(textureMipmapObject, uploadTarget, level);
|
||||
if (size.x() <= 0 || size.y() <= 0 || size.z() > 1 ||
|
||||
MGB_LEVEL_BYTE_SIZE(textureMipmapObject, uploadTarget, level) !=
|
||||
static_cast<Uint64>(size.x()) * size.y() * BytesPerTexel) {
|
||||
return PackedUploadResult::Unavailable;
|
||||
}
|
||||
if (MGB_STAGED_TEXTURE_LIVE &&
|
||||
!MG_Record::ServerStagedTexture().IsCovered(MG_Record::StagedTextureStore::KeyForHandle(pushedRes),
|
||||
targetCode, levelCode)) {
|
||||
return PackedUploadResult::Unavailable;
|
||||
}
|
||||
const auto* pixels = static_cast<const Uint8*>(
|
||||
MGB_LEVEL_TEXELS(textureMipmapObject, uploadTarget, level, "packed-dirty-level"));
|
||||
if (pixels == nullptr) return PackedUploadResult::Unavailable;
|
||||
const SizeT pitch = static_cast<SizeT>(size.x()) * BytesPerTexel;
|
||||
for (const auto& region : pending->Regions) {
|
||||
if (region.Z != 0 || region.D != 1 || region.W == 0 || region.H == 0 || region.W > PageSide ||
|
||||
region.H > PageSide || region.X < 0 || region.Y < 0 || region.X >= size.x() ||
|
||||
region.Y >= size.y() || region.W > static_cast<Uint>(size.x() - region.X) ||
|
||||
region.H > static_cast<Uint>(size.y() - region.Y)) {
|
||||
return PackedUploadResult::Unavailable;
|
||||
}
|
||||
// Read the final shadow using level coordinates. Carried offsets can address smaller slabs.
|
||||
batch.regions[batch.count++] = {pixels + region.Y * pitch + region.X * BytesPerTexel,
|
||||
pitch,
|
||||
static_cast<int>(level),
|
||||
region.X,
|
||||
region.Y,
|
||||
static_cast<int>(region.W),
|
||||
static_cast<int>(region.H)};
|
||||
}
|
||||
unionTexels += static_cast<Uint64>(pending->UnionBox.W) * pending->UnionBox.H;
|
||||
}
|
||||
|
||||
if (!Pack(batch, unionTexels)) return PackedUploadResult::Unavailable;
|
||||
const auto result = SubmitPackedUpload(batch, destination, unionTexels);
|
||||
if (result == PackedUploadResult::Committed) {
|
||||
// The copies rewrite storage the driver already holds, like any in-place level upload.
|
||||
NoteInPlaceTextureUpload();
|
||||
for (SizeT level = 0; level < mipmapCount; ++level) {
|
||||
if (FindPipeTextureUpload(*pushedStorage, targetCode, static_cast<Uint16>(level)) != nullptr) {
|
||||
MGB_LEVEL_UPLOAD_DONE(textureMipmapObject, uploadTarget, level);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void BackendTextureObject::SyncMipmapsToBackend(
|
||||
const SharedPtr<MG_State::GLState::ITextureObject>& stateTextureObject) {
|
||||
// P5e (tx2): null IS the by-handle arm once a handle has been noted on this twin;
|
||||
@@ -1038,7 +1247,9 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
const auto mipmapCount = MGB_STORAGE_LEVELS(textureMipmapObject);
|
||||
currentTextureInfo.mipmapLevels = mipmapCount;
|
||||
|
||||
Bool needsRegeneration = !m_isInitialized || (currentTextureInfo != m_prevTextureInfo);
|
||||
const Bool stableStorage = m_isInitialized && currentTextureInfo == m_prevTextureInfo;
|
||||
Bool needsRegeneration = !stableStorage;
|
||||
if (needsRegeneration) m_packedUploadRejected = false;
|
||||
if (needsRegeneration && m_backendStorageImmutable) {
|
||||
RecreateBackendTexture();
|
||||
Bind(target);
|
||||
@@ -1439,6 +1650,26 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
ApplyImageBindableStorageWidening(imageWidening, &glInternalFormat, &glFormat, &glType);
|
||||
const auto& uploadTargets = MGB_UPLOAD_TARGETS(textureMipmapObject);
|
||||
ScopedDefaultUnpackState unpackState;
|
||||
// Update sampled storage directly to avoid stalling the current offscreen batch on a PBO.
|
||||
const Bool useClientUnpack = stableStorage && WasTextureReadInDrawBatch(pushedRes);
|
||||
// Pack the small writes across all dirty mip levels before their
|
||||
// per-level union boxes can pull in untouched atlas texels. The packed
|
||||
// copies write the destination on the GPU too, so sampled storage skips them.
|
||||
if (stableStorage && !useClientUnpack && !m_driverMayHoldGpuWrites && !m_packedUploadRejected &&
|
||||
!m_imageBindableStorageRequired && target == GL_TEXTURE_2D &&
|
||||
(glInternalFormat == GL_RGBA8 || glInternalFormat == GL_RGBA) && glFormat == GL_RGBA &&
|
||||
glType == GL_UNSIGNED_BYTE && pushedStorage != nullptr && uploadTargets.size() == 1 &&
|
||||
g_GLESFuncs.glCopyImageSubData && g_GLESFuncs.glTexStorage2D &&
|
||||
BufferImpl::UnpackRingAvailable()) {
|
||||
const auto result = TryPackedMipUpload(textureMipmapObject, pushedStorage, pushedRes,
|
||||
uploadTargets.front(), mipmapCount, m_backendTextureId);
|
||||
if (result == PackedUploadResult::Rejected) {
|
||||
// Replay all regions from the shadow after a rejected copy.
|
||||
DrainDriverErrors("packed texture upload fallback");
|
||||
m_packedUploadRejected = true;
|
||||
MGLOG_D("Packed texture upload rejected for texture %u", m_backendTextureId);
|
||||
}
|
||||
}
|
||||
// Per-level scratch of the exact-footprint path, hoisted to reuse capacity.
|
||||
Vector<MG_State::GLState::MipmapDirtyRegion> dirtyFootprint;
|
||||
Vector<UnpackStagingBlock> stagingBlockOverflow;
|
||||
@@ -1707,7 +1938,9 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
MG_State::GLState::MipmapDirtyRegion
|
||||
dirtyRects[MG_State::GLState::MipmapStorage::kMaxDirtyRects];
|
||||
SizeT dirtyRectCount = 0;
|
||||
if (subRectEligible) {
|
||||
const Bool ringUsable = BufferImpl::UnpackRingAvailable();
|
||||
// A client-memory upload keeps the scatter refinement, ring or not.
|
||||
if (subRectEligible && (!ringUsable || useClientUnpack)) {
|
||||
if (pendingUpload != nullptr) {
|
||||
// RegionCount == 0 is LEGAL and means "the union box is the
|
||||
// whole story" (D-D3), which is the same statement the
|
||||
@@ -1751,23 +1984,26 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
dirtyRectCount = textureMipmapObject->GetStorageDirtyRects(
|
||||
uploadTarget, level, dirtyRects,
|
||||
MG_State::GLState::MipmapStorage::kMaxDirtyRects);
|
||||
// The scatter refinement pays only on the client-pointer path,
|
||||
// where fewer bytes mean less driver-side copying. Through the
|
||||
// unpack ring every glTexSubImage is a GPU copy job (Mali), so
|
||||
// ~100 sprite rects become ~100 jobs whose fixed cost dwarfs
|
||||
// the union box's extra bytes - measured +6 ms/frame of GPU
|
||||
// time in MC's animated-atlas ticks. One box, one job.
|
||||
if (BufferImpl::UnpackRingAvailable()) {
|
||||
dirtyRectCount = 0;
|
||||
}
|
||||
}
|
||||
// Everything above - the union box, the ring's one-box rule, the rect
|
||||
// list with its merges, fold and 3/4 cut-off - may upload shadow texels
|
||||
// the client did not write, which is only harmless while the driver
|
||||
// still holds those texels as they were last uploaded. Once it may hold
|
||||
// GPU writes, the level goes up as exactly the texels written, one box
|
||||
// (one ring job) each, whatever that costs: more boxes, and a union box
|
||||
// that spans the whole level no longer means a whole-level upload.
|
||||
// Bound the unpack-ring fallback to two jobs per level. The
|
||||
// boxes may include gaps, so require an authoritative CPU shadow.
|
||||
const Bool splitBoxUpload =
|
||||
ringUsable && !useClientUnpack && regionsAddressable && stableStorage &&
|
||||
!m_driverMayHoldGpuWrites && !m_imageBindableStorageRequired &&
|
||||
target == GL_TEXTURE_2D &&
|
||||
(glInternalFormat == GL_RGBA8 || glInternalFormat == GL_RGBA) && glFormat == GL_RGBA &&
|
||||
glType == GL_UNSIGNED_BYTE && bpp == 4 && texelSize.z() == 1 && mipData != nullptr &&
|
||||
uploadData == mipData && levelRowBytes == static_cast<SizeT>(texelSize.x()) * bpp &&
|
||||
levelSliceBytes == static_cast<SizeT>(texelSize.y()) * levelRowBytes &&
|
||||
pendingUpload != nullptr &&
|
||||
(!MGB_STAGED_TEXTURE_LIVE ||
|
||||
MG_Record::ServerStagedTexture().IsCovered(
|
||||
MG_Record::StagedTextureStore::KeyForHandle(pushedRes),
|
||||
static_cast<Uint16>(uploadTarget), static_cast<Uint16>(level))) &&
|
||||
SplitMipUpload(*pendingUpload, texelSize, dirtyRects);
|
||||
if (splitBoxUpload) dirtyRectCount = 2;
|
||||
// A union or split can include untouched texels while the shadow is authoritative.
|
||||
// Once the GPU may have written the texture, upload only the exact client footprint.
|
||||
const MG_State::GLState::MipmapDirtyRegion* uploadRects = dirtyRects;
|
||||
SizeT uploadRectCount = dirtyRectCount;
|
||||
if (m_driverMayHoldGpuWrites && regionsAddressable) {
|
||||
@@ -1816,19 +2052,15 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
// is the level shadow itself and never a conversion buffer: since dev's 8966d5c2 a converted
|
||||
// level is sub-rect eligible too, and its rects are cut at the conversion's bpp (rectUploadPtr).
|
||||
//
|
||||
// THREE USE SITES, AND THE FIRST OF THEM IS UNREACHABLE (N-5's second half, and the correction
|
||||
// to what esprytobj-v2.md m-1 claimed): dirtyRectCount is forced to 0 whenever
|
||||
// UnpackRingAvailable(), and the staging-block loop that takes MGB_RECT_SRC_PTR(r, rect) first
|
||||
// requires `ringUsable && dirtyRectCount >= 2`. The two conditions cannot both hold. That shape
|
||||
// is pre-existing (the ring/scatter decision, not this package's), so the loop is left as it
|
||||
// stands and the count is corrected here instead of the loop being deleted underneath it.
|
||||
// A pair of bounding boxes need not start at the corresponding recorded region's origin.
|
||||
// Read those boxes by coordinate, including when ring staging falls back to a client pointer.
|
||||
//
|
||||
// A MACRO AND NOT A SECOND LAMBDA, for DV-9's measured reason: this function's nine ErrorLopper
|
||||
// lambdas are mangled ...::$_N BY POSITION, so one more renumbers every one of them and moves
|
||||
// the PULL build's symbol set, whose admitted-change set is EMPTY. The pull expansion is the
|
||||
// pre-P4a call with one pair of parentheses. #undef'd with the rest.
|
||||
#define MGB_RECT_SRC_PTR(idx, rect) \
|
||||
((pendingUpload != nullptr && pendingOffsetsAgree && carriedLayoutApplies && \
|
||||
((!splitBoxUpload && pendingUpload != nullptr && pendingOffsetsAgree && carriedLayoutApplies && \
|
||||
static_cast<SizeT>(idx) < pendingUpload->Regions.size()) \
|
||||
? static_cast<const Uint8*>(uploadData) + \
|
||||
static_cast<SizeT>(pendingUpload->Regions[static_cast<SizeT>(idx)].SrcOffset) \
|
||||
@@ -1864,8 +2096,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
UnpackStagingBlock stagingBlockArray[MG_State::GLState::MipmapStorage::kMaxDirtyRects];
|
||||
UnpackStagingBlock* stagingBlocks = stagingBlockArray;
|
||||
SizeT stagingBlockCount = 0;
|
||||
const Bool ringUsable = BufferImpl::UnpackRingAvailable();
|
||||
if (!ringUsable) {
|
||||
if (!ringUsable || useClientUnpack) {
|
||||
// Nothing to plan: every branch below keeps the client
|
||||
// pointer and its ROW_LENGTH striding, unchanged.
|
||||
} else if (perRectUpload) {
|
||||
@@ -1925,11 +2156,11 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
// separately from the bytes on purpose: SSIM is blind to it
|
||||
// and the +6 ms/frame Mali cliff was a shape regression, not
|
||||
// a byte regression (plan section 7.3).
|
||||
const Bool rectShape = subRectEligible && dirtyRectCount >= 2;
|
||||
const Bool rectShape = perRectUpload;
|
||||
Uint64 shippedBytes = 0;
|
||||
if (rectShape) {
|
||||
for (SizeT r = 0; r < dirtyRectCount; ++r) {
|
||||
const auto& rect = dirtyRects[r];
|
||||
for (SizeT r = 0; r < uploadRectCount; ++r) {
|
||||
const auto& rect = uploadRects[r];
|
||||
shippedBytes += static_cast<Uint64>(rect.hi.x() - rect.lo.x()) *
|
||||
static_cast<Uint64>(rect.hi.y() - rect.lo.y()) *
|
||||
static_cast<Uint64>(std::max(rect.hi.z() - rect.lo.z(), 1)) *
|
||||
@@ -1940,7 +2171,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
static_cast<Uint64>(regionSize.x()) * static_cast<Uint64>(regionSize.y()) *
|
||||
static_cast<Uint64>(std::max(regionSize.z(), 1)) * static_cast<Uint64>(bpp);
|
||||
} else {
|
||||
shippedBytes = static_cast<Uint64>(byteSize);
|
||||
shippedBytes = static_cast<Uint64>(uploadBytes == 0 ? byteSize : uploadBytes);
|
||||
}
|
||||
MG_Util::PipeStats::AddBytes(MG_Util::PipeStats::ByteClass::StageTexture, shippedBytes);
|
||||
MG_Util::PipeStats::AddCalls(MG_Util::PipeStats::CallClass::TextureUploadEmissions, 1);
|
||||
@@ -1949,7 +2180,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
: MG_Util::PipeStats::CallClass::TextureUploadBoxEmissions,
|
||||
1);
|
||||
MG_Util::PipeStats::AddCalls(MG_Util::PipeStats::CallClass::TextureUploadJobs,
|
||||
rectShape ? static_cast<Uint64>(dirtyRectCount) : 1u);
|
||||
rectShape ? static_cast<Uint64>(uploadRectCount) : 1u);
|
||||
}
|
||||
switch (MapToBackendTextureTarget(MGB_TEXTURE_TARGET(stateTextureObject))) {
|
||||
case TextureTarget::Texture2D:
|
||||
|
||||
@@ -741,36 +741,6 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
return glslCode;
|
||||
}
|
||||
|
||||
String RequestMultiviewExtension(String glslCode, GLenum shaderType, Int numViews, Bool driverHasMultiview2) {
|
||||
const Bool declaresViews = shaderType == GL_VERTEX_SHADER && numViews > 0;
|
||||
if (!declaresViews && glslCode.find("gl_ViewID_OVR") == String::npos) return glslCode;
|
||||
const String directive = std::format("#extension {} : require\n",
|
||||
driverHasMultiview2 ? "GL_OVR_multiview2" : "GL_OVR_multiview");
|
||||
// The directive goes right after #version; num_views is a declaration, so it goes after
|
||||
// the LAST directive, where ESSL lets non-preprocessor tokens start.
|
||||
const SizeT versionPos = glslCode.find("#version");
|
||||
const SizeT versionEnd = versionPos == String::npos ? String::npos : glslCode.find('\n', versionPos);
|
||||
glslCode.insert(versionEnd == String::npos ? 0 : versionEnd + 1, directive);
|
||||
if (!declaresViews) return glslCode;
|
||||
SizeT insertAt = 0;
|
||||
for (SizeT lineStart = 0; lineStart < glslCode.size();) {
|
||||
const SizeT lineEnd = glslCode.find('\n', lineStart);
|
||||
const SizeT next = lineEnd == String::npos ? glslCode.size() : lineEnd + 1;
|
||||
const SizeT first = glslCode.find_first_not_of(" \t\r\n", lineStart);
|
||||
if (first == String::npos) break;
|
||||
if (first >= next) {
|
||||
lineStart = next; // a blank line
|
||||
continue;
|
||||
}
|
||||
if (glslCode[first] != '#') break;
|
||||
insertAt = next;
|
||||
lineStart = next;
|
||||
}
|
||||
if (insertAt > 0 && glslCode[insertAt - 1] != '\n') glslCode.insert(insertAt++, "\n");
|
||||
glslCode.insert(insertAt, std::format("layout(num_views = {}) in;\n", numViews));
|
||||
return glslCode;
|
||||
}
|
||||
|
||||
String RequestViewportArrayExtension(String glslCode, Bool needed) {
|
||||
#ifdef TRACY_ENABLE
|
||||
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
||||
|
||||
@@ -229,15 +229,6 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
// error, so this is never emitted speculatively. A no-op when not needed or already
|
||||
// present.
|
||||
String RequestViewportArrayExtension(String glslCode, Bool needed);
|
||||
// GL_OVR_multiview: adds `#extension GL_OVR_multiview2 : require` (GL_OVR_multiview where
|
||||
// the driver has only that one) to a stage that names gl_ViewID_OVR or, in the vertex
|
||||
// stage, declares `numViews`, and `layout(num_views = numViews) in;` to that vertex stage.
|
||||
// The SPIR-V reaching SPIRV-Cross carries neither (StripMultiviewCapabilityForEssl), so the
|
||||
// translation it memoizes stays independent of the view count. Frontend shaders that
|
||||
// declare only GL_OVR_multiview already keep gl_ViewID_OVR out of every output but
|
||||
// gl_Position, so asking for the smaller extension on such a driver is honest. A no-op
|
||||
// for every other stage.
|
||||
String RequestMultiviewExtension(String glslCode, GLenum shaderType, Int numViews, Bool driverHasMultiview2);
|
||||
// Adds `#extension <extensionName> : require` when a TESSELLATION or GEOMETRY stage's
|
||||
// emitted ESSL names gl_PointSize. Desktop GL has that built-in in gl_PerVertex for every
|
||||
// vertex-processing stage; ESSL does NOT have it in those two at any version - not even
|
||||
|
||||
@@ -921,15 +921,6 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
||||
if (features.CullDistance) {
|
||||
extensions.push_back(E_GL_ARB_cull_distance);
|
||||
}
|
||||
// Multiview render passes (VkRenderPassMultiviewCreateInfo) and the ViewIndex built-in.
|
||||
// Vulkan puts no restriction on what ViewIndex may feed, so the second string comes with
|
||||
// the first.
|
||||
if (features.Multiview) {
|
||||
extensions.push_back(E_GL_OVR_multiview);
|
||||
if (features.Multiview2) {
|
||||
extensions.push_back(E_GL_OVR_multiview2);
|
||||
}
|
||||
}
|
||||
// Vulkan's drawIndirectFirstInstance feature is optional. Direct base-instance calls work
|
||||
// without it, but ARB_base_instance also promises non-zero firstInstance in GPU indirect
|
||||
// commands; the renderer supplies true only when that word is legal and gl_InstanceID can
|
||||
@@ -1094,9 +1085,6 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
||||
}
|
||||
|
||||
void BackendObject_DirectVulkan::UpdateAdvertisedExtensions() {
|
||||
// GL_MAX_VIEWS_OVR beside the strings it decides, so the two cannot disagree.
|
||||
m_dynamicParameters.MaxViews =
|
||||
pVulkanRenderer != nullptr ? static_cast<Int>(pVulkanRenderer->GetMultiviewViewCount()) : 0;
|
||||
// GL_ARB_timer_query gates MC's F3 GPU% (LWJGL checks the extension
|
||||
// string). InitCapabilities runs after InitWindowSurface has created
|
||||
// and initialized the renderer, so the advertisement can be gated on
|
||||
@@ -1117,9 +1105,7 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
||||
m_vulkanCaps.SupportsImageCubeArray,
|
||||
AdvertisedFeatureSupport{.TessellationShader = m_vulkanCaps.SupportsTessellationShader,
|
||||
.CullDistance =
|
||||
m_vulkanCaps.SupportsShaderCullDistance && m_vulkanCaps.MaxCullDistances > 0,
|
||||
.Multiview = m_dynamicParameters.MaxViews > 0,
|
||||
.Multiview2 = m_dynamicParameters.MaxViews > 0});
|
||||
m_vulkanCaps.SupportsShaderCullDistance && m_vulkanCaps.MaxCullDistances > 0});
|
||||
// GL_EXT_fragment_shading_rate rides on VK_KHR_fragment_shading_rate's pipeline rate, and
|
||||
// its _primitive companion on the primitive rate; both only when the renderer enabled them.
|
||||
// _attachment is not advertised: no framebuffer carries a rate attachment to this backend.
|
||||
|
||||
@@ -45,9 +45,6 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
||||
IntVec2 extent = {0, 0};
|
||||
// VkFramebufferCreateInfo::layers of the entry's framebuffer (>1 for layered GL attachments).
|
||||
Uint32 layers = 1;
|
||||
// VkRenderPassMultiviewCreateInfo's view mask, zero when the pass is not multiview. Its
|
||||
// clear variants carry the same mask, which render-pass compatibility requires.
|
||||
Uint32 viewMask = 0;
|
||||
// Frame counter value of the last GetOrCreateRenderPass hit; drives cache eviction.
|
||||
Uint64 lastUsedFrame = 0;
|
||||
// P15 S0 (wire passes only): what the render pass was created from, and the render
|
||||
@@ -72,7 +69,6 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
||||
std::swap(sampleCount, that.sampleCount);
|
||||
std::swap(extent, that.extent);
|
||||
std::swap(layers, that.layers);
|
||||
std::swap(viewMask, that.viewMask);
|
||||
std::swap(lastUsedFrame, that.lastUsedFrame);
|
||||
std::swap(wireAttachments, that.wireAttachments);
|
||||
std::swap(wireColors, that.wireColors);
|
||||
@@ -109,7 +105,6 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
||||
std::swap(sampleCount, that.sampleCount);
|
||||
std::swap(extent, that.extent);
|
||||
std::swap(layers, that.layers);
|
||||
std::swap(viewMask, that.viewMask);
|
||||
std::swap(lastUsedFrame, that.lastUsedFrame);
|
||||
std::swap(wireAttachments, that.wireAttachments);
|
||||
std::swap(wireColors, that.wireColors);
|
||||
|
||||
@@ -407,9 +407,6 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
||||
// honored rather than accepted-and-ignored.
|
||||
Bool IsSamplerAnisotropySupported() const { return m_samplerAnisotropyFeatureEnabled; }
|
||||
const FragmentShadingRateSupport& GetFragmentShadingRateSupport() const { return m_fragmentShadingRate; }
|
||||
// GL_MAX_VIEWS_OVR: the multiview feature's maxMultiviewViewCount, capped at the 32 views
|
||||
// a render pass view mask can name; zero when the device was created without multiview.
|
||||
Uint32 GetMultiviewViewCount() const { return m_multiviewViewCount; }
|
||||
// ARB_base_instance extends indirect command records with a non-zero firstInstance and
|
||||
// requires gl_InstanceID to remain zero-based. Vulkan needs both features to honor that
|
||||
// complete contract: one legalizes the command word, the other enables the shader rebase.
|
||||
@@ -592,9 +589,6 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
||||
// Zero for the default framebuffer, which no arm that reads this ever reaches.
|
||||
VkImageUsageFlags usageFlags = 0;
|
||||
Uint32 level = 0, layer = 0, layers = 1, levels = 1;
|
||||
// GL_OVR_multiview: the surface's view count, zero when it is not multiview. A
|
||||
// multiview surface's layers are its views, from `layer` on.
|
||||
Uint32 views = 0;
|
||||
Bool isDefault = false;
|
||||
// Set when isDefault: the swapchain image index this role resolved to.
|
||||
Uint32 swapchainImageIndex = 0;
|
||||
@@ -883,9 +877,6 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
||||
Vector<Uint32> colorReferences;
|
||||
Uint32 depthReference = VK_ATTACHMENT_UNUSED;
|
||||
Uint32 width = 0, height = 0, layers = 1;
|
||||
// VkRenderPassMultiviewCreateInfo's view mask, zero for a pass that is not multiview
|
||||
// (whose framebuffer then has `layers` 1).
|
||||
Uint32 viewMask = 0;
|
||||
// The rasterization sample count of a pass with no attachments (0 otherwise), where
|
||||
// nothing else in the key would tell two such passes apart.
|
||||
Uint32 noAttachmentSamples = 0;
|
||||
@@ -1271,10 +1262,6 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
||||
// Null / all-false on a device without pipelineFragmentShadingRate.
|
||||
PFN_vkCmdSetFragmentShadingRateKHR s_vkCmdSetFragmentShadingRateKHR = nullptr;
|
||||
FragmentShadingRateSupport m_fragmentShadingRate{};
|
||||
// The multiview feature (Vulkan 1.1 core), which backs GL_OVR_multiview: chained into the
|
||||
// device create info, so it lives as long as the device creation that reads it.
|
||||
VkPhysicalDeviceMultiviewFeatures m_multiviewFeatures{};
|
||||
Uint32 m_multiviewViewCount = 0;
|
||||
|
||||
// VK_EXT_transform_feedback (GL transform feedback capture)
|
||||
Bool m_transformFeedbackFeatureEnabled = false;
|
||||
@@ -1765,9 +1752,6 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
||||
static Bool EnableOptionalDeviceExtension(const Vector<VkExtensionProperties>& availableExtensions,
|
||||
Vector<const char*>& inOutEnabledExtensions,
|
||||
const char* extensionName);
|
||||
void ChainMultiviewFeature(PFN_vkGetPhysicalDeviceFeatures2 getFeatures2,
|
||||
PFN_vkGetPhysicalDeviceProperties2 getProperties2,
|
||||
VkDeviceCreateInfo& deviceCreateInfo);
|
||||
void ResolveOptionalDeviceExtensions(const Vector<VkExtensionProperties>& availableExtensions,
|
||||
Vector<const char*>& inOutEnabledExtensions);
|
||||
static Bool IsNecessaryDeviceExtensionSupported(VkPhysicalDevice device);
|
||||
|
||||
@@ -912,7 +912,6 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
||||
if (!m_shaderDrawParametersFeatureEnabled) {
|
||||
MGLOG_W("shaderDrawParameters is unavailable; shaders using gl_DrawID/gl_BaseInstance will not work");
|
||||
}
|
||||
ChainMultiviewFeature(getPhysicalDeviceFeatures2, getPhysicalDeviceProperties2, deviceCreateInfo);
|
||||
|
||||
// primitiveTopologyListRestart lets primitive restart work on *list* topologies (strip/fan
|
||||
// restart needs no feature). Optional; enabled via VK_EXT_primitive_topology_list_restart.
|
||||
@@ -2336,39 +2335,6 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Multiview for GL_OVR_multiview, on a Vulkan 1.1 device that has it and at least the two views
|
||||
// GL requires. Only the base feature: GL refuses a multiview draw with a geometry or
|
||||
// tessellation stage, so their multiview features are never needed.
|
||||
void VulkanRenderer::ChainMultiviewFeature(PFN_vkGetPhysicalDeviceFeatures2 getFeatures2,
|
||||
PFN_vkGetPhysicalDeviceProperties2 getProperties2,
|
||||
VkDeviceCreateInfo& deviceCreateInfo) {
|
||||
m_multiviewViewCount = 0;
|
||||
m_multiviewFeatures = {};
|
||||
m_multiviewFeatures.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES;
|
||||
if (m_physicalDevice.properties.apiVersion < VK_API_VERSION_1_1 || getFeatures2 == nullptr ||
|
||||
getProperties2 == nullptr)
|
||||
return;
|
||||
VkPhysicalDeviceFeatures2 featureQuery{};
|
||||
featureQuery.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
|
||||
featureQuery.pNext = &m_multiviewFeatures;
|
||||
getFeatures2(m_physicalDevice.handle, &featureQuery);
|
||||
VkPhysicalDeviceMultiviewProperties multiviewProperties{};
|
||||
multiviewProperties.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_PROPERTIES;
|
||||
VkPhysicalDeviceProperties2 propertyQuery{};
|
||||
propertyQuery.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2;
|
||||
propertyQuery.pNext = &multiviewProperties;
|
||||
getProperties2(m_physicalDevice.handle, &propertyQuery);
|
||||
const Bool usable = m_multiviewFeatures.multiview == VK_TRUE && multiviewProperties.maxMultiviewViewCount >= 2;
|
||||
MGLOG_I("Multiview (GL_OVR_multiview): %s, maxMultiviewViewCount %u", usable ? "enabled" : "unavailable",
|
||||
multiviewProperties.maxMultiviewViewCount);
|
||||
if (!usable) return;
|
||||
m_multiviewFeatures.pNext = const_cast<void*>(deviceCreateInfo.pNext);
|
||||
m_multiviewFeatures.multiviewGeometryShader = VK_FALSE;
|
||||
m_multiviewFeatures.multiviewTessellationShader = VK_FALSE;
|
||||
deviceCreateInfo.pNext = &m_multiviewFeatures;
|
||||
m_multiviewViewCount = std::min<Uint32>(multiviewProperties.maxMultiviewViewCount, 32u);
|
||||
}
|
||||
|
||||
void VulkanRenderer::ResolveOptionalDeviceExtensions(const Vector<VkExtensionProperties>& availableExtensions,
|
||||
Vector<const char*>& inOutEnabledExtensions) {
|
||||
m_drawIndirectCountExtensionEnabled = EnableOptionalDeviceExtension(availableExtensions, inOutEnabledExtensions,
|
||||
|
||||
@@ -142,17 +142,6 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
||||
return layered(fbo.Depth) || layered(fbo.Stencil);
|
||||
}
|
||||
|
||||
// The multiview chain of a wire draw pass and of its clear variants: one subpass that renders
|
||||
// the views `viewMask` names. The mask is read through the pointer, so it has to outlive the
|
||||
// render pass creation, which is why it is taken by reference.
|
||||
static VkRenderPassMultiviewCreateInfo MakeWireMultiviewInfo(const Uint32& viewMask) {
|
||||
VkRenderPassMultiviewCreateInfo info{};
|
||||
info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_MULTIVIEW_CREATE_INFO;
|
||||
info.subpassCount = 1;
|
||||
info.pViewMasks = &viewMask;
|
||||
return info;
|
||||
}
|
||||
|
||||
[[noreturn]] static void WireBufferLegacyFatal() {
|
||||
MG_Pipe::MGPipeSessionFail(MG_Pipe::MGPipeFatalFamily::RoleViolation,
|
||||
"MGPipe: Fatal{RoleViolation, \"buffer-legacy-arm\"} (Magma P7 buffer consumer)");
|
||||
@@ -484,7 +473,6 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
||||
VkAttachmentReference depth{VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_GENERAL};
|
||||
VkExtent2D extent{~0u, ~0u};
|
||||
Uint32 layers = ~0u;
|
||||
Uint32 views = 0;
|
||||
VkSampleCountFlagBits samples = VK_SAMPLE_COUNT_1_BIT;
|
||||
Uint64 passHash = 0;
|
||||
auto& passKey = scratch.passKey;
|
||||
@@ -511,18 +499,6 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
||||
image = ResolveWireImage(fbo, surface, aspect, /*isWriteTarget=*/true);
|
||||
}
|
||||
if (!image.image) return VK_ATTACHMENT_UNUSED;
|
||||
// Only a pending clear of exactly this attachment's level and layers can become its
|
||||
// load op. One of other layers (another layer of a multiview or layered attachment)
|
||||
// would otherwise stay pending past this pass and land on top of its draws.
|
||||
if (image.resource != nullptr &&
|
||||
std::any_of(image.resource->pendingClears.begin(), image.resource->pendingClears.end(),
|
||||
[&](const VkTextureManager::WirePendingClear& entry) {
|
||||
return entry.level != image.level || entry.layer != image.layer ||
|
||||
entry.layers != image.layers;
|
||||
})) {
|
||||
MaterializeWirePendingClears(*image.resource);
|
||||
image.layout = image.resource->layout;
|
||||
}
|
||||
m_textureManager->FlushPendingUploads();
|
||||
m_wirePassMemo.attachments.push_back(
|
||||
{image.resource, image.storage, surface.Kind == MG_Pipe::kMGPipeSurfaceKindRenderbuffer});
|
||||
@@ -563,7 +539,6 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
||||
extent.width = std::min(extent.width, image.extent.width);
|
||||
extent.height = std::min(extent.height, image.extent.height);
|
||||
layers = std::min(layers, image.layers);
|
||||
views = std::max(views, image.views);
|
||||
samples = image.samples;
|
||||
passHash = XXH64(&description, sizeof(description), passHash);
|
||||
// Marked below, once the pass is known: a continued pass repeats the same marks.
|
||||
@@ -628,14 +603,6 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
||||
passKey.noAttachmentSamples = static_cast<Uint32>(samples);
|
||||
passHash = XXH64(&samples, sizeof(samples), passHash);
|
||||
}
|
||||
// GL_OVR_multiview: one view per attachment layer, rendered through a single framebuffer
|
||||
// layer, which is what a multiview render pass requires of its framebuffer.
|
||||
const Uint32 viewMask = views == 0 ? 0u : (views >= 32 ? ~0u : (1u << views) - 1u);
|
||||
if (viewMask != 0) {
|
||||
layers = 1;
|
||||
passHash = XXH64(&viewMask, sizeof(viewMask), passHash);
|
||||
}
|
||||
passKey.viewMask = viewMask;
|
||||
passKey.width = extent.width;
|
||||
passKey.height = extent.height;
|
||||
passKey.layers = layers;
|
||||
@@ -656,8 +623,6 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
||||
passInfo.pAttachments = attachments.data();
|
||||
passInfo.subpassCount = 1;
|
||||
passInfo.pSubpasses = &subpass;
|
||||
const VkRenderPassMultiviewCreateInfo multiview = MakeWireMultiviewInfo(passKey.viewMask);
|
||||
if (viewMask != 0) passInfo.pNext = &multiview;
|
||||
continuing = m_wireDrawPass && m_wireDrawPassKey == passKey;
|
||||
{
|
||||
const auto* active = VkRenderPassManager::GetActiveRenderPass();
|
||||
@@ -700,7 +665,6 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
||||
created.sampleCount = samples;
|
||||
created.extent = {static_cast<Int>(extent.width), static_cast<Int>(extent.height)};
|
||||
created.layers = layers;
|
||||
created.viewMask = viewMask;
|
||||
created.hash = created.compatibilityHash =
|
||||
XXH64(colors.data(), colors.size() * sizeof(colors[0]), passHash);
|
||||
created.wireAttachments.assign(attachments.begin(), attachments.end());
|
||||
@@ -745,7 +709,6 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
||||
for (const auto& color : colors)
|
||||
pipelinePassKey.colorReferences.push_back(color.attachment);
|
||||
pipelinePassKey.depthReference = depth.attachment;
|
||||
pipelinePassKey.viewMask = viewMask;
|
||||
m_wireDrawPassCompatibilityId = m_wireRenderPassCompatibility.Intern(pipelinePassKey);
|
||||
}
|
||||
} // !passContinues
|
||||
@@ -1438,8 +1401,6 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
||||
info.pAttachments = descriptions.data();
|
||||
info.subpassCount = 1;
|
||||
info.pSubpasses = &subpass;
|
||||
const VkRenderPassMultiviewCreateInfo multiview = MakeWireMultiviewInfo(begun.viewMask);
|
||||
if (begun.viewMask != 0) info.pNext = &multiview;
|
||||
VkRenderPass variant = VK_NULL_HANDLE;
|
||||
VK_VERIFY(vkCreateRenderPass(m_device, &info, nullptr, &variant));
|
||||
begun.clearVariants.push_back({variantKey, variant});
|
||||
|
||||
@@ -721,10 +721,6 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
||||
out.layer = layer;
|
||||
out.is3D = resource->depth > 1;
|
||||
out.layers = surface.Layered ? (out.is3D ? std::max(resource->depth >> level, 1u) : availableLayers) : 1;
|
||||
if (!renderbuffer && surface.NumViews != 0) {
|
||||
out.views = surface.NumViews;
|
||||
out.layers = surface.NumViews;
|
||||
}
|
||||
const Bool oneDimensional =
|
||||
resource->viewType == VK_IMAGE_VIEW_TYPE_1D || resource->viewType == VK_IMAGE_VIEW_TYPE_1D_ARRAY;
|
||||
out.viewType = oneDimensional ? (out.layers > 1 ? VK_IMAGE_VIEW_TYPE_1D_ARRAY : VK_IMAGE_VIEW_TYPE_1D)
|
||||
@@ -2302,7 +2298,7 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
||||
MG_Pipe::MGPSurface surface{};
|
||||
surface.Kind = MG_Pipe::kMGPipeSurfaceKindTexture;
|
||||
surface.Res = state.VerbCopyTexDst;
|
||||
surface.Level = static_cast<Uint8>(level);
|
||||
surface.Level = static_cast<Uint16>(level);
|
||||
WireImage source = ResolveWireImage(*read,
|
||||
aspect & VK_IMAGE_ASPECT_DEPTH_BIT ? read->Depth
|
||||
: aspect & VK_IMAGE_ASPECT_STENCIL_BIT ? read->Stencil
|
||||
|
||||
@@ -11,16 +11,14 @@
|
||||
#include "../VkIncludes.h"
|
||||
|
||||
namespace MobileGL::MG_Backend::DirectVulkan {
|
||||
// The wire draw pass has one graphics subpass, no input attachments and,
|
||||
// besides multiview, no extensions. Its Vulkan pipeline compatibility is
|
||||
// formats, sample counts, the ordered attachment references and the view
|
||||
// mask, not native handles, image identity, dimensions, load/store
|
||||
// operations or image layouts.
|
||||
// The wire draw pass has one graphics subpass, no input attachments,
|
||||
// multiview or extensions. Its Vulkan pipeline compatibility is formats,
|
||||
// sample counts and the ordered attachment references, not native handles,
|
||||
// image identity, dimensions, load/store operations or image layouts.
|
||||
struct WireRenderPassCompatibilityKey {
|
||||
Vector<Uint64> attachmentFormatsAndSamples;
|
||||
Vector<Uint32> colorReferences;
|
||||
Uint32 depthReference = VK_ATTACHMENT_UNUSED;
|
||||
Uint32 viewMask = 0;
|
||||
Bool operator==(const WireRenderPassCompatibilityKey&) const = default;
|
||||
};
|
||||
|
||||
@@ -37,7 +35,6 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
||||
for (const auto value : key.colorReferences)
|
||||
mix(value);
|
||||
mix(key.depthReference);
|
||||
mix(key.viewMask);
|
||||
return hash;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
// in FixupGsStripCaptureOrder - for the reason CONTRACT-P5B.md §6.5 gives.
|
||||
#include <MG_Remote/Client/SlotCaps.h>
|
||||
#include "../Getter/GL_Getter.h"
|
||||
#include "../Framebuffer/GL_Framebuffer.h"
|
||||
|
||||
namespace MobileGL::MG_Impl::GLImpl {
|
||||
static Bool ValidateProgramForExecution(const SharedPtr<MG_State::GLState::ProgramObject>& currentProgram,
|
||||
@@ -88,7 +87,7 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
return false;
|
||||
}
|
||||
|
||||
return ValidateMultiviewDraw(*currentProgram, functionName);
|
||||
return true;
|
||||
}
|
||||
|
||||
// gl_NumSamples has no SPIR-V built-in, so the source pipeline lowers it onto a reserved
|
||||
|
||||
@@ -2041,8 +2041,6 @@ DECLARE_GL_FUNCTION_STUB_HEAD(void, GetPixelTransformParameterivEXT, GLenum targ
|
||||
DECLARE_GL_FUNCTION_STUB_HEAD(void, GetPixelTransformParameterfvEXT, GLenum target, GLenum pname, GLfloat* params) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, GetPixelTransformParameterfvEXT, target, pname, params)
|
||||
DECLARE_GL_FUNCTION_STUB_HEAD(void, PointParameterfEXT, GLenum pname, GLfloat param) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, PointParameterfEXT, pname, param)
|
||||
DECLARE_GL_FUNCTION_STUB_HEAD(void, PointParameterfvEXT, GLenum pname, const GLfloat* params) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, PointParameterfvEXT, pname, params)
|
||||
DECLARE_GL_FUNCTION_HEAD(void, FramebufferTextureMultiviewOVR, GLenum target, GLenum attachment, GLuint texture, GLint level, GLint baseViewIndex, GLsizei numViews) DECLARE_GL_FUNCTION_END_NO_RETURN(void, FramebufferTextureMultiviewOVR, target, attachment, texture, level, baseViewIndex, numViews)
|
||||
DECLARE_GL_FUNCTION_HEAD(void, NamedFramebufferTextureMultiviewOVR, GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint baseViewIndex, GLsizei numViews) DECLARE_GL_FUNCTION_END_NO_RETURN(void, NamedFramebufferTextureMultiviewOVR, framebuffer, attachment, texture, level, baseViewIndex, numViews)
|
||||
DECLARE_GL_FUNCTION_HEAD(void, GetFragmentShadingRatesEXT, GLsizei samples, GLsizei maxCount, GLsizei* count, GLenum* shadingRates) DECLARE_GL_FUNCTION_END_NO_RETURN(void, GetFragmentShadingRatesEXT, samples, maxCount, count, shadingRates)
|
||||
DECLARE_GL_FUNCTION_HEAD(void, ShadingRateEXT, GLenum rate) DECLARE_GL_FUNCTION_END_NO_RETURN(void, ShadingRateEXT, rate)
|
||||
DECLARE_GL_FUNCTION_HEAD(void, ShadingRateCombinerOpsEXT, GLenum combinerOp0, GLenum combinerOp1) DECLARE_GL_FUNCTION_END_NO_RETURN(void, ShadingRateCombinerOpsEXT, combinerOp0, combinerOp1)
|
||||
@@ -2696,6 +2694,7 @@ DECLARE_GL_FUNCTION_STUB_HEAD(void, VideoCaptureStreamParameterivNV, GLuint vide
|
||||
DECLARE_GL_FUNCTION_STUB_HEAD(void, VideoCaptureStreamParameterfvNV, GLuint video_capture_slot, GLuint stream, GLenum pname, const GLfloat* params) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, VideoCaptureStreamParameterfvNV, video_capture_slot, stream, pname, params)
|
||||
DECLARE_GL_FUNCTION_STUB_HEAD(void, VideoCaptureStreamParameterdvNV, GLuint video_capture_slot, GLuint stream, GLenum pname, const GLdouble* params) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, VideoCaptureStreamParameterdvNV, video_capture_slot, stream, pname, params)
|
||||
DECLARE_GL_FUNCTION_STUB_HEAD(void, ViewportSwizzleNV, GLuint index, GLenum swizzlex, GLenum swizzley, GLenum swizzlez, GLenum swizzlew) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, ViewportSwizzleNV, index, swizzlex, swizzley, swizzlez, swizzlew)
|
||||
DECLARE_GL_FUNCTION_STUB_HEAD(void, FramebufferTextureMultiviewOVR, GLenum target, GLenum attachment, GLuint texture, GLint level, GLint baseViewIndex, GLsizei numViews) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, FramebufferTextureMultiviewOVR, target, attachment, texture, level, baseViewIndex, numViews)
|
||||
DECLARE_GL_FUNCTION_STUB_HEAD(void, HintPGI, GLenum target, GLint mode) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, HintPGI, target, mode)
|
||||
DECLARE_GL_FUNCTION_STUB_HEAD(void, DetailTexFuncSGIS, GLenum target, GLsizei n, const GLfloat* points) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, DetailTexFuncSGIS, target, n, points)
|
||||
DECLARE_GL_FUNCTION_STUB_HEAD(void, GetDetailTexFuncSGIS, GLenum target, GLfloat* points) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, GetDetailTexFuncSGIS, target, points)
|
||||
|
||||
@@ -111,7 +111,6 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
// property no single attachment's state explains.
|
||||
GLenum IncompleteFramebufferStatus(const MG_State::GLState::FramebufferObject& framebufferObject) {
|
||||
if (framebufferObject.HasLayerTargetMismatch()) return GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS;
|
||||
if (framebufferObject.HasViewTargetMismatch()) return GL_FRAMEBUFFER_INCOMPLETE_VIEW_TARGETS_OVR;
|
||||
return HasDefinedAttachment(framebufferObject) ? GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT
|
||||
: GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT;
|
||||
}
|
||||
@@ -364,9 +363,6 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
Bool TryAnswerAttachmentFormatQuery(const MG_State::GLState::FramebufferAttachmentObject* attachmentObject,
|
||||
FramebufferAttachmentType attachmentType, Bool depthStencilAlias,
|
||||
GLenum pname, GLint* params, const char* caller) {
|
||||
// The two GL_OVR_multiview pnames take the same fallback out of both query switches.
|
||||
if (FramebufferImpl::TryAnswerMultiviewAttachmentQuery(attachmentObject, pname, params, caller))
|
||||
return true;
|
||||
switch (pname) {
|
||||
case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE:
|
||||
case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE:
|
||||
@@ -493,8 +489,72 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
}
|
||||
}
|
||||
|
||||
using FramebufferImpl::ValidateFramebufferTextureAttachmentPoint;
|
||||
using FramebufferImpl::ValidateFramebufferTextureLevel;
|
||||
// GL 4.6 core 9.2.8 conditions that depend only on the framebuffer and the attachment
|
||||
// point. Shared, because glFramebufferTexture / 1D / 2D / 3D / TextureLayer are aliases of
|
||||
// one another in that section and a CTS case that walks the family must not get five
|
||||
// different answers - which is exactly what happened when these lived in one helper that
|
||||
// only two of the five went through.
|
||||
Bool ValidateFramebufferTextureAttachmentPoint(
|
||||
const char* functionName, const SharedPtr<MG_State::GLState::FramebufferObject>& framebufferObject,
|
||||
FramebufferAttachmentType attachmentType) {
|
||||
// "An INVALID_OPERATION error is generated if COLOR_ATTACHMENTm is used with m greater
|
||||
// than or equal to MAX_COLOR_ATTACHMENTS."
|
||||
if (!FramebufferImpl::ValidateColorAttachmentInRange(attachmentType, functionName)) return false;
|
||||
// "An INVALID_OPERATION error is generated if zero is bound to target." MobileGL keeps
|
||||
// a real FramebufferObject for framebuffer 0, so a null test can never see this - the
|
||||
// object is always there, and framebuffer 0 has to be recognized by identity instead,
|
||||
// the same comparison DrawBuffers_State makes. Without this an attach onto the default
|
||||
// framebuffer silently REPLACED its color attachment, permanently desynchronizing it
|
||||
// from what the swapchain keeps publishing.
|
||||
const auto& defaultFramebufferInfo = FramebufferImpl::pDefaultFramebufferInfo;
|
||||
if (!framebufferObject ||
|
||||
(defaultFramebufferInfo && framebufferObject == defaultFramebufferInfo->defaultFBO)) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeUnique<GenericErrorInfo>(
|
||||
"MG_Impl/GLImpl", functionName,
|
||||
"No framebuffer object is bound to the target; the default framebuffer's attachments "
|
||||
"cannot be named."));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// The other half of 9.2.8: "level must be greater than or equal to zero", and for a
|
||||
// texture with immutable storage it "must be smaller than the number of levels the texture
|
||||
// has". Split from the attachment-point half because the caller only has a texture object
|
||||
// once the detach (texture == 0) case is behind it.
|
||||
Bool ValidateFramebufferTextureLevel(const char* functionName,
|
||||
const SharedPtr<MG_State::GLState::ITextureObject>& textureObject,
|
||||
GLint level) {
|
||||
if (level < 0) {
|
||||
MG_State::pGLContext->RecordError(ErrorCode::InvalidValue,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", functionName,
|
||||
"Texture level must be non-negative."));
|
||||
return false;
|
||||
}
|
||||
if (!textureObject || !textureObject->IsImmutable()) {
|
||||
// A mutable texture has no level bound here: a level it has not specified yet is
|
||||
// not an error, it just leaves the framebuffer incomplete.
|
||||
return true;
|
||||
}
|
||||
// GetAddressableLevelCount(), NOT GetImmutableLevels(): for a VIEW the latter is
|
||||
// deliberately the ORIGINAL texture's count (GL 4.6 core 8.18 defines
|
||||
// TEXTURE_IMMUTABLE_LEVELS on a view that way), which is far too large a bound - a
|
||||
// two-level view onto a ten-level texture would accept level 5 and attach an image
|
||||
// nothing can draw into.
|
||||
const Uint levelBound = textureObject->GetAddressableLevelCount();
|
||||
if (static_cast<Uint>(level) >= levelBound) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue,
|
||||
MakeUnique<GenericErrorInfo>(
|
||||
"MG_Impl/GLImpl", functionName,
|
||||
std::format("Texture level {} is beyond the {} level(s) this texture has.", level,
|
||||
levelBound)));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void AttachFramebufferTextureWithUploadTarget(const char* functionName, GLenum target, GLenum attachment,
|
||||
GLuint texture, GLint level,
|
||||
@@ -2590,8 +2650,6 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
? FramebufferImpl::pDefaultFramebufferInfo->defaultFBO
|
||||
: GetNamedFramebufferObject_State(drawFramebuffer, "BlitNamedFramebuffer_State");
|
||||
if (!readObject || !drawObject) return;
|
||||
if (!FramebufferImpl::ValidateReadFramebufferIsSingleView(readObject.get(), "BlitNamedFramebuffer_State"))
|
||||
return;
|
||||
|
||||
BlitNamedFramebuffer_Backend(readObject, drawObject, srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1,
|
||||
mask, filter);
|
||||
@@ -2852,8 +2910,6 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", "ReadPixels_State", "Framebuffer is incomplete"));
|
||||
return false;
|
||||
}
|
||||
if (!FramebufferImpl::ValidateReadFramebufferIsSingleView(framebufferObject.get(), "ReadPixels_State"))
|
||||
return false;
|
||||
|
||||
// Check for required buffers
|
||||
if (textureInputFormat == TextureInputFormat::StencilIndex) {
|
||||
@@ -3308,7 +3364,6 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
void BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1,
|
||||
GLint dstY1, GLbitfield mask, GLenum filter) {
|
||||
if (!ValidateBlitMaskAndFilter(__func__, mask, filter)) return;
|
||||
if (!FramebufferImpl::ValidateBoundReadFramebufferIsSingleView(__func__)) return;
|
||||
BlitFramebuffer_Backend(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,10 +11,6 @@
|
||||
#include <Includes.h>
|
||||
#include <MG_State/GLState/Core.h>
|
||||
|
||||
namespace MobileGL::MG_State::GLState {
|
||||
class ProgramObject;
|
||||
} // namespace MobileGL::MG_State::GLState
|
||||
|
||||
namespace MobileGL::MG_Impl::GLImpl {
|
||||
/* @INSERTION_POINT:FUNCTION_DECLARATION@ */
|
||||
void ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels);
|
||||
@@ -59,25 +55,6 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
void NamedFramebufferTexture3D(GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level,
|
||||
GLint zoffset);
|
||||
void NamedFramebufferTextureLayer(GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer);
|
||||
// GL_OVR_multiview (GL_FramebufferMultiview.cpp).
|
||||
void FramebufferTextureMultiviewOVR(GLenum target, GLenum attachment, GLuint texture, GLint level,
|
||||
GLint baseViewIndex, GLsizei numViews);
|
||||
void NamedFramebufferTextureMultiviewOVR(GLuint framebuffer, GLenum attachment, GLuint texture, GLint level,
|
||||
GLint baseViewIndex, GLsizei numViews);
|
||||
void FramebufferTextureMultiviewOVR_State(GLenum target, GLenum attachment, GLuint texture, GLint level,
|
||||
GLint baseViewIndex, GLsizei numViews);
|
||||
void NamedFramebufferTextureMultiviewOVR_State(GLuint framebuffer, GLenum attachment, GLuint texture, GLint level,
|
||||
GLint baseViewIndex, GLsizei numViews);
|
||||
// GL_MAX_VIEWS_OVR as the active backend reports it; zero without a backend or without multiview,
|
||||
// which is exactly when GL_OVR_multiview is not advertised.
|
||||
Int GetMaxViews_State();
|
||||
Bool IsMultiviewSupported_State();
|
||||
// The draw-time rules of GL_OVR_multiview for `program` against the bound draw framebuffer.
|
||||
// Records INVALID_OPERATION and returns false when the draw must be dropped.
|
||||
Bool ValidateMultiviewDraw(const MG_State::GLState::ProgramObject& program, const char* functionName);
|
||||
// The framebuffer object a DSA entry point names, or null with INVALID_OPERATION recorded.
|
||||
SharedPtr<MG_State::GLState::FramebufferObject> GetNamedFramebufferObject_State(GLuint framebuffer,
|
||||
const char* caller);
|
||||
void NamedFramebufferDrawBuffer(GLuint framebuffer, GLenum buf);
|
||||
void NamedFramebufferDrawBuffers(GLuint framebuffer, GLsizei n, const GLenum* bufs);
|
||||
void NamedFramebufferReadBuffer(GLuint framebuffer, GLenum src);
|
||||
|
||||
@@ -1,223 +0,0 @@
|
||||
// MobileGL - MobileGL/MG_Impl/GLImpl/Framebuffer/GL_FramebufferMultiview.cpp
|
||||
// Copyright (c) 2025-2026 MobileGL-Dev
|
||||
// Licensed under the GNU Lesser General Public License v3.0:
|
||||
// https://www.gnu.org/licenses/gpl-3.0.txt
|
||||
// https://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
// SPDX-License-Identifier: LGPL-3.0-only
|
||||
// End of Source File Header
|
||||
|
||||
// GL_OVR_multiview: the two attaching entry points, the attachment queries and the draw-time rules.
|
||||
// A multiview attachment is a FramebufferAttachmentObject of a 2D array texture whose layer is the
|
||||
// base view index and whose view count is non-zero; the rest of the framebuffer code reads it
|
||||
// through FramebufferObject::GetViewCount() and HasViewTargetMismatch().
|
||||
#include "GL_Framebuffer.h"
|
||||
#include "Validators.h"
|
||||
#include <MG_Backend/BackendObjects.h>
|
||||
#include <MG_Impl/GLImpl/Texture/Validators.h>
|
||||
#include <MG_Impl/Pipe/FramebufferEmit.h>
|
||||
#include <MG_State/GLState/ErrorState/Error.h>
|
||||
#include <MG_State/GLState/ProgramState/ProgramObject.h>
|
||||
#include <MG_Util/Converters/GLToMG/FramebufferEnumConverter.h>
|
||||
|
||||
namespace MobileGL::MG_Impl::GLImpl {
|
||||
namespace {
|
||||
void RecordMultiviewError(ErrorCode code, const char* functionName, String detail) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
code, MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", functionName, Move(detail)));
|
||||
}
|
||||
|
||||
const MG_Backend::DynamicBackendParameters& ActiveBackendLimits() {
|
||||
static const MG_Backend::DynamicBackendParameters kNoBackend{};
|
||||
return MG_Backend::pActiveBackendObject ? MG_Backend::pActiveBackendObject->GetDynamicParameters()
|
||||
: kNoBackend;
|
||||
}
|
||||
|
||||
// The checks of the spec that do not depend on the framebuffer object, in its order:
|
||||
// FramebufferTextureLayer's own errors other than the layer ones, then numViews against
|
||||
// MAX_VIEWS_OVR, then the texture-dependent ones. Returns the texture to attach, or null
|
||||
// with `ok` telling a detach (texture 0) apart from a refusal.
|
||||
SharedPtr<MG_State::GLState::ITextureObject> ValidateMultiviewTexture(const char* functionName, GLuint texture,
|
||||
GLint level, GLint baseViewIndex,
|
||||
GLsizei numViews, Bool& ok) {
|
||||
ok = false;
|
||||
const Int maxViews = GetMaxViews_State();
|
||||
if (numViews < 1 || numViews > maxViews) {
|
||||
RecordMultiviewError(
|
||||
ErrorCode::InvalidValue, functionName,
|
||||
std::format("numViews {} is outside [1, GL_MAX_VIEWS_OVR = {}].", numViews, maxViews));
|
||||
return nullptr;
|
||||
}
|
||||
if (texture == 0) {
|
||||
ok = true;
|
||||
return nullptr;
|
||||
}
|
||||
const auto& textureObject = MG_State::pGLContext->GetTextureObject(texture);
|
||||
if (!textureObject) {
|
||||
RecordMultiviewError(ErrorCode::InvalidOperation, functionName,
|
||||
std::format("Texture object {} is not valid.", texture));
|
||||
return nullptr;
|
||||
}
|
||||
if (textureObject->GetTarget() != TextureTarget::Texture2DArray) {
|
||||
RecordMultiviewError(ErrorCode::InvalidOperation, functionName,
|
||||
"A multiview attachment must be a two-dimensional array texture.");
|
||||
return nullptr;
|
||||
}
|
||||
if (!FramebufferImpl::ValidateFramebufferTextureLevel(functionName, textureObject, level)) return nullptr;
|
||||
if (baseViewIndex < 0) {
|
||||
RecordMultiviewError(ErrorCode::InvalidValue, functionName, "baseViewIndex must be non-negative.");
|
||||
return nullptr;
|
||||
}
|
||||
const Int maxLayers = ActiveBackendLimits().MaxArrayTextureLayers;
|
||||
if (static_cast<Int64>(baseViewIndex) + numViews > maxLayers) {
|
||||
RecordMultiviewError(ErrorCode::InvalidValue, functionName,
|
||||
std::format("baseViewIndex {} + numViews {} exceeds GL_MAX_ARRAY_TEXTURE_LAYERS "
|
||||
"({}).",
|
||||
baseViewIndex, numViews, maxLayers));
|
||||
return nullptr;
|
||||
}
|
||||
ok = true;
|
||||
return textureObject;
|
||||
}
|
||||
|
||||
// Shared tail of both entry points once the framebuffer object is known. Returns whether
|
||||
// the framebuffer changed.
|
||||
Bool AttachMultiview(const char* functionName,
|
||||
const SharedPtr<MG_State::GLState::FramebufferObject>& framebufferObject,
|
||||
GLenum attachment, GLuint texture, GLint level, GLint baseViewIndex, GLsizei numViews) {
|
||||
if (!IsMultiviewSupported_State()) {
|
||||
RecordMultiviewError(ErrorCode::InvalidOperation, functionName,
|
||||
"GL_OVR_multiview is not supported by the active backend.");
|
||||
return false;
|
||||
}
|
||||
const Bool depthStencil = attachment == GL_DEPTH_STENCIL_ATTACHMENT;
|
||||
const FramebufferAttachmentType attachmentType =
|
||||
depthStencil ? FramebufferAttachmentType::Depth
|
||||
: MG_Util::ConvertGLEnumToFramebufferAttachmentType(attachment);
|
||||
if (!FramebufferImpl::ValidateFramebufferAttachmentType(attachmentType)) return false;
|
||||
if (!FramebufferImpl::ValidateFramebufferTextureAttachmentPoint(functionName, framebufferObject,
|
||||
attachmentType)) {
|
||||
return false;
|
||||
}
|
||||
Bool ok = false;
|
||||
const auto textureObject =
|
||||
ValidateMultiviewTexture(functionName, texture, level, baseViewIndex, numViews, ok);
|
||||
if (!ok) return false;
|
||||
|
||||
const FramebufferAttachmentType stencil = FramebufferAttachmentType::Stencil;
|
||||
if (!textureObject) {
|
||||
framebufferObject->Detach(attachmentType);
|
||||
if (depthStencil) framebufferObject->Detach(stencil);
|
||||
return true;
|
||||
}
|
||||
const auto attach = [&](FramebufferAttachmentType type) {
|
||||
framebufferObject->AttachTexture(type, textureObject, TextureUploadTarget::Texture2DArray, level,
|
||||
baseViewIndex, /*layered=*/false, numViews);
|
||||
};
|
||||
attach(attachmentType);
|
||||
if (depthStencil) attach(stencil);
|
||||
return true;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
Int GetMaxViews_State() {
|
||||
return std::max<Int>(ActiveBackendLimits().MaxViews, 0);
|
||||
}
|
||||
|
||||
Bool IsMultiviewSupported_State() {
|
||||
return MG_Backend::pActiveBackendObject != nullptr && GetMaxViews_State() > 0;
|
||||
}
|
||||
|
||||
void FramebufferTextureMultiviewOVR_State(GLenum target, GLenum attachment, GLuint texture, GLint level,
|
||||
GLint baseViewIndex, GLsizei numViews) {
|
||||
if (target == GL_FRAMEBUFFER) target = GL_DRAW_FRAMEBUFFER;
|
||||
const FramebufferTarget framebufferTarget = MG_Util::ConvertGLEnumToFramebufferTarget(target);
|
||||
if (!FramebufferImpl::ValidateFramebufferTarget(framebufferTarget)) return;
|
||||
if (!TextureImpl::ValidateTextureName(texture, true)) return;
|
||||
const auto& framebufferObject =
|
||||
MG_State::pGLContext->GetFramebufferBindingSlot(framebufferTarget).GetBoundObject();
|
||||
AttachMultiview(__func__, framebufferObject, attachment, texture, level, baseViewIndex, numViews);
|
||||
}
|
||||
|
||||
void NamedFramebufferTextureMultiviewOVR_State(GLuint framebuffer, GLenum attachment, GLuint texture, GLint level,
|
||||
GLint baseViewIndex, GLsizei numViews) {
|
||||
const auto framebufferObject = GetNamedFramebufferObject_State(framebuffer, __func__);
|
||||
if (!framebufferObject) return;
|
||||
if (AttachMultiview(__func__, framebufferObject, attachment, texture, level, baseViewIndex, numViews)) {
|
||||
// A DSA mutator has no validate point, so the record goes out now (see
|
||||
// PipePublishFramebufferByName in GL_Framebuffer.cpp).
|
||||
MG_Pipe::MGPipeFramebufferEmitterInstance().EmitFramebufferByName(*framebufferObject);
|
||||
}
|
||||
}
|
||||
|
||||
Bool ValidateMultiviewDraw(const MG_State::GLState::ProgramObject& program, const char* functionName) {
|
||||
// Without backend multiview no framebuffer can be multiview, so a single-view program
|
||||
// needs no framebuffer walk on every draw.
|
||||
if (program.GetMultiviewViewCount() == 1 && !IsMultiviewSupported_State()) return true;
|
||||
const auto& drawFramebuffer =
|
||||
MG_State::pGLContext->GetFramebufferBindingSlot(FramebufferTarget::Draw).GetBoundObject();
|
||||
const Int framebufferViews = drawFramebuffer ? drawFramebuffer->GetViewCount() : 1;
|
||||
const Int programViews = program.GetMultiviewViewCount();
|
||||
// GL_OVR_multiview 11.1.3.11 / 16.X: the program's num_views (1 without the qualifier)
|
||||
// must be the draw framebuffer's view count.
|
||||
if (framebufferViews != programViews) {
|
||||
RecordMultiviewError(ErrorCode::InvalidOperation, functionName,
|
||||
std::format("The program renders {} view(s) but the draw framebuffer has {}.",
|
||||
programViews, framebufferViews));
|
||||
return false;
|
||||
}
|
||||
if (!drawFramebuffer || !drawFramebuffer->IsMultiview()) return true;
|
||||
// A multiview draw framebuffer takes no geometry or tessellation stage and no active,
|
||||
// unpaused transform feedback.
|
||||
if (program.HasLinkedShaderStage(ShaderStage::Geometry) ||
|
||||
program.HasLinkedShaderStage(ShaderStage::TessControl) ||
|
||||
program.HasLinkedShaderStage(ShaderStage::TessEval)) {
|
||||
RecordMultiviewError(ErrorCode::InvalidOperation, functionName,
|
||||
"A multiview draw cannot run a geometry or tessellation stage.");
|
||||
return false;
|
||||
}
|
||||
if (MG_State::pGLContext->IsTransformFeedbackActive() && !MG_State::pGLContext->IsTransformFeedbackPaused()) {
|
||||
RecordMultiviewError(ErrorCode::InvalidOperation, functionName,
|
||||
"A multiview draw cannot capture transform feedback.");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
namespace FramebufferImpl {
|
||||
Bool TryAnswerMultiviewAttachmentQuery(const MG_State::GLState::FramebufferAttachmentObject* attachmentObject,
|
||||
GLenum pname, GLint* params, const char* caller) {
|
||||
if (pname != GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_NUM_VIEWS_OVR &&
|
||||
pname != GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_BASE_VIEW_INDEX_OVR) {
|
||||
return false;
|
||||
}
|
||||
if (!IsMultiviewSupported_State()) return false;
|
||||
const Bool nothingAttached =
|
||||
attachmentObject == nullptr || attachmentObject->IsEmpty() || !attachmentObject->IsValid();
|
||||
if (!nothingAttached && !attachmentObject->IsTexture()) {
|
||||
RecordMultiviewError(ErrorCode::InvalidEnum, caller,
|
||||
std::format("pname {:#x} is only defined for a texture attachment.", pname));
|
||||
return true;
|
||||
}
|
||||
// Zero for a texture attachment that is not multiview, as the spec answers for one
|
||||
// that is not a two-dimensional array texture; FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER
|
||||
// already reads the base view index.
|
||||
const Bool multiview = !nothingAttached && attachmentObject->IsMultiview();
|
||||
if (pname == GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_NUM_VIEWS_OVR) {
|
||||
*params = multiview ? static_cast<GLint>(attachmentObject->GetNumViews()) : 0;
|
||||
} else {
|
||||
*params = multiview ? static_cast<GLint>(attachmentObject->GetTextureLayer()) : 0;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} // namespace FramebufferImpl
|
||||
|
||||
void FramebufferTextureMultiviewOVR(GLenum target, GLenum attachment, GLuint texture, GLint level,
|
||||
GLint baseViewIndex, GLsizei numViews) {
|
||||
FramebufferTextureMultiviewOVR_State(target, attachment, texture, level, baseViewIndex, numViews);
|
||||
}
|
||||
|
||||
void NamedFramebufferTextureMultiviewOVR(GLuint framebuffer, GLenum attachment, GLuint texture, GLint level,
|
||||
GLint baseViewIndex, GLsizei numViews) {
|
||||
NamedFramebufferTextureMultiviewOVR_State(framebuffer, attachment, texture, level, baseViewIndex, numViews);
|
||||
}
|
||||
} // namespace MobileGL::MG_Impl::GLImpl
|
||||
@@ -7,7 +7,6 @@
|
||||
// End of Source File Header
|
||||
|
||||
#include "Validators.h"
|
||||
#include "GL_Framebuffer.h"
|
||||
#include <MG_Backend/BackendObjects.h>
|
||||
#include <MG_State/GLState/Core.h>
|
||||
#include <MG_State/GLState/ErrorState/Error.h>
|
||||
@@ -179,7 +178,6 @@ namespace MobileGL::MG_Impl::GLImpl::FramebufferImpl {
|
||||
"Read framebuffer is not framebuffer complete."));
|
||||
return false;
|
||||
}
|
||||
if (!ValidateReadFramebufferIsSingleView(framebufferObject.get(), caller)) return false;
|
||||
|
||||
const FramebufferAttachmentType readBuffer = framebufferObject->GetReadBuffer();
|
||||
if (readBuffer == FramebufferAttachmentType::None || !framebufferObject->GetAttachment(readBuffer).IsValid()) {
|
||||
@@ -212,87 +210,4 @@ namespace MobileGL::MG_Impl::GLImpl::FramebufferImpl {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Bool ValidateReadFramebufferIsSingleView(const MG_State::GLState::FramebufferObject* framebufferObject,
|
||||
const char* caller) {
|
||||
// GL_OVR_multiview 9.3 / 18.2 / 18.3: reading, copying or blitting out of a read
|
||||
// framebuffer with more than one view is INVALID_FRAMEBUFFER_OPERATION.
|
||||
if (!framebufferObject || framebufferObject->GetViewCount() <= 1) return true;
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidFramebufferOperation,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl/FramebufferImpl", caller,
|
||||
"The read framebuffer has more than one view (GL_OVR_multiview)."));
|
||||
return false;
|
||||
}
|
||||
|
||||
Bool ValidateBoundReadFramebufferIsSingleView(const char* caller) {
|
||||
const auto& framebufferObject =
|
||||
MG_State::pGLContext->GetFramebufferBindingSlot(FramebufferTarget::Read).GetBoundObject();
|
||||
return ValidateReadFramebufferIsSingleView(framebufferObject.get(), caller);
|
||||
}
|
||||
|
||||
// GL 4.6 core 9.2.8 conditions that depend only on the framebuffer and the attachment
|
||||
// point. Shared, because glFramebufferTexture / 1D / 2D / 3D / TextureLayer are aliases of
|
||||
// one another in that section and a CTS case that walks the family must not get five
|
||||
// different answers - which is exactly what happened when these lived in one helper that
|
||||
// only two of the five went through.
|
||||
Bool ValidateFramebufferTextureAttachmentPoint(
|
||||
const char* functionName, const SharedPtr<MG_State::GLState::FramebufferObject>& framebufferObject,
|
||||
FramebufferAttachmentType attachmentType) {
|
||||
// "An INVALID_OPERATION error is generated if COLOR_ATTACHMENTm is used with m greater
|
||||
// than or equal to MAX_COLOR_ATTACHMENTS."
|
||||
if (!FramebufferImpl::ValidateColorAttachmentInRange(attachmentType, functionName)) return false;
|
||||
// "An INVALID_OPERATION error is generated if zero is bound to target." MobileGL keeps
|
||||
// a real FramebufferObject for framebuffer 0, so a null test can never see this - the
|
||||
// object is always there, and framebuffer 0 has to be recognized by identity instead,
|
||||
// the same comparison DrawBuffers_State makes. Without this an attach onto the default
|
||||
// framebuffer silently REPLACED its color attachment, permanently desynchronizing it
|
||||
// from what the swapchain keeps publishing.
|
||||
const auto& defaultFramebufferInfo = FramebufferImpl::pDefaultFramebufferInfo;
|
||||
if (!framebufferObject || (defaultFramebufferInfo && framebufferObject == defaultFramebufferInfo->defaultFBO)) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeUnique<GenericErrorInfo>(
|
||||
"MG_Impl/GLImpl", functionName,
|
||||
"No framebuffer object is bound to the target; the default framebuffer's attachments "
|
||||
"cannot be named."));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// The other half of 9.2.8: "level must be greater than or equal to zero", and for a
|
||||
// texture with immutable storage it "must be smaller than the number of levels the texture
|
||||
// has". Split from the attachment-point half because the caller only has a texture object
|
||||
// once the detach (texture == 0) case is behind it.
|
||||
Bool ValidateFramebufferTextureLevel(const char* functionName,
|
||||
const SharedPtr<MG_State::GLState::ITextureObject>& textureObject,
|
||||
GLint level) {
|
||||
if (level < 0) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue,
|
||||
MakeUnique<GenericErrorInfo>("MG_Impl/GLImpl", functionName, "Texture level must be non-negative."));
|
||||
return false;
|
||||
}
|
||||
if (!textureObject || !textureObject->IsImmutable()) {
|
||||
// A mutable texture has no level bound here: a level it has not specified yet is
|
||||
// not an error, it just leaves the framebuffer incomplete.
|
||||
return true;
|
||||
}
|
||||
// GetAddressableLevelCount(), NOT GetImmutableLevels(): for a VIEW the latter is
|
||||
// deliberately the ORIGINAL texture's count (GL 4.6 core 8.18 defines
|
||||
// TEXTURE_IMMUTABLE_LEVELS on a view that way), which is far too large a bound - a
|
||||
// two-level view onto a ten-level texture would accept level 5 and attach an image
|
||||
// nothing can draw into.
|
||||
const Uint levelBound = textureObject->GetAddressableLevelCount();
|
||||
if (static_cast<Uint>(level) >= levelBound) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue,
|
||||
MakeUnique<GenericErrorInfo>(
|
||||
"MG_Impl/GLImpl", functionName,
|
||||
std::format("Texture level {} is beyond the {} level(s) this texture has.", level, levelBound)));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} // namespace MobileGL::MG_Impl::GLImpl::FramebufferImpl
|
||||
@@ -30,24 +30,4 @@ namespace MobileGL::MG_Impl::GLImpl::FramebufferImpl {
|
||||
// DEFAULT framebuffer does not answer INVALID_OPERATION. Testing the framebuffer kind first
|
||||
// would turn GL_FRAMEBUFFER_DEFAULT_WIDTH on framebuffer zero into the wrong error.
|
||||
Bool ValidateFramebufferParameterPname(GLenum pname, Bool isDefaultFramebuffer, Bool forSetter, const char* caller);
|
||||
// GL 4.6 core 9.2.8 conditions on the framebuffer and the attachment point that every
|
||||
// texture-attaching entry point shares: a color attachment beyond GL_MAX_COLOR_ATTACHMENTS, or
|
||||
// the default framebuffer bound to the target, is INVALID_OPERATION.
|
||||
Bool ValidateFramebufferTextureAttachmentPoint(
|
||||
const char* functionName, const SharedPtr<MG_State::GLState::FramebufferObject>& framebufferObject,
|
||||
FramebufferAttachmentType attachmentType);
|
||||
// The level half of 9.2.8: negative, or past an immutable texture's levels, is INVALID_VALUE.
|
||||
Bool ValidateFramebufferTextureLevel(const char* functionName,
|
||||
const SharedPtr<MG_State::GLState::ITextureObject>& textureObject,
|
||||
GLint level);
|
||||
// GL_OVR_multiview: a read framebuffer with more than one view cannot be read, copied or blitted
|
||||
// from (INVALID_FRAMEBUFFER_OPERATION). A null framebuffer passes; its caller reports that.
|
||||
Bool ValidateReadFramebufferIsSingleView(const MG_State::GLState::FramebufferObject* framebufferObject,
|
||||
const char* caller);
|
||||
Bool ValidateBoundReadFramebufferIsSingleView(const char* caller);
|
||||
// GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_NUM_VIEWS_OVR / _BASE_VIEW_INDEX_OVR. False when pname is
|
||||
// neither or GL_OVR_multiview is not supported, so the caller's INVALID_ENUM stands; true when
|
||||
// the query was answered or refused here. Defined in GL_FramebufferMultiview.cpp.
|
||||
Bool TryAnswerMultiviewAttachmentQuery(const MG_State::GLState::FramebufferAttachmentObject* attachmentObject,
|
||||
GLenum pname, GLint* params, const char* caller);
|
||||
} // namespace MobileGL::MG_Impl::GLImpl::FramebufferImpl
|
||||
@@ -50,9 +50,6 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
// a free function named BlendEquation, which would hide the ::MobileGL::BlendEquation enum
|
||||
// this file's blend-state queries name unqualified.
|
||||
GLboolean IsEnabledi(GLenum target, GLuint index);
|
||||
// GL_Framebuffer.h, declared here for the same reason.
|
||||
Int GetMaxViews_State();
|
||||
Bool IsMultiviewSupported_State();
|
||||
|
||||
namespace {
|
||||
enum class IndexedBufferQueryKind {
|
||||
@@ -1634,14 +1631,6 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
}
|
||||
}
|
||||
|
||||
// GL_MAX_VIEWS_OVR, answered only where GL_OVR_multiview is advertised; anywhere else it is an
|
||||
// unknown pname like any other extension's.
|
||||
static Bool TryGetMultiviewInteger(GLenum pname, GLint* params) {
|
||||
if (pname != GL_MAX_VIEWS_OVR || !IsMultiviewSupported_State()) return false;
|
||||
*params = GetMaxViews_State();
|
||||
return true;
|
||||
}
|
||||
|
||||
// GL_EXT_fragment_shading_rate's state and limits (tables 23.9 / 23.53 of the extension).
|
||||
// Returns false for any other pname. The tokens belong to the extension, so a context whose
|
||||
// backend cannot back it answers them like any unknown pname, and the attachment limits the
|
||||
@@ -1773,7 +1762,7 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
return;
|
||||
}
|
||||
|
||||
if (TryGetFragmentShadingRateInteger(pname, params) || TryGetMultiviewInteger(pname, params)) return;
|
||||
if (TryGetFragmentShadingRateInteger(pname, params)) return;
|
||||
|
||||
switch (pname) {
|
||||
case GL_ACTIVE_TEXTURE:
|
||||
|
||||
@@ -1547,7 +1547,7 @@ namespace MobileGL::MG_Impl {
|
||||
GETPROC(glGetIntegerui64i_vNV, name);
|
||||
GETPROC(glViewportSwizzleNV, name);
|
||||
GETPROC(glFramebufferTextureMultiviewOVR, name);
|
||||
GETPROC(glNamedFramebufferTextureMultiviewOVR, name);
|
||||
// GETPROC(glNamedFramebufferTextureMultiviewOVR, name);
|
||||
|
||||
MGLOG_D("GetProcAddress(%s) = nullptr!", name);
|
||||
return nullptr;
|
||||
|
||||
@@ -109,8 +109,7 @@ namespace MobileGL::MG_Pipe {
|
||||
surface.Kind = kMGPipeSurfaceKindTexture;
|
||||
surface.InternalFormat = static_cast<Uint32>(texture->GetFormat());
|
||||
surface.Layered = attachment.IsLayered() ? 1 : 0;
|
||||
surface.Level = static_cast<Uint8>(std::clamp<Int>(attachment.GetTextureLevel(), 0, 0xFF));
|
||||
surface.NumViews = static_cast<Uint8>(std::clamp<Int>(attachment.GetNumViews(), 0, 0xFF));
|
||||
surface.Level = static_cast<Uint16>(std::max<Int>(attachment.GetTextureLevel(), 0));
|
||||
surface.Layer = static_cast<Uint32>(std::max<Int>(attachment.GetTextureLayer(), 0));
|
||||
surface.UploadTarget = static_cast<Uint16>(MGPipeResolveAttachmentUploadTarget(attachment));
|
||||
// ID-12 DV-5: the field that WAS Pad0, and the size did not move. The four
|
||||
@@ -127,7 +126,6 @@ namespace MobileGL::MG_Pipe {
|
||||
surface.InternalFormat = static_cast<Uint32>(renderbuffer->GetInternalFormat());
|
||||
surface.Layered = 0;
|
||||
surface.Level = 0;
|
||||
surface.NumViews = 0;
|
||||
surface.Layer = 0;
|
||||
return surface;
|
||||
}
|
||||
@@ -181,7 +179,6 @@ namespace MobileGL::MG_Pipe {
|
||||
dst.Kind = src.Kind;
|
||||
dst.Layered = src.Layered;
|
||||
dst.Level = src.Level;
|
||||
dst.NumViews = src.NumViews;
|
||||
dst.Layer = src.Layer;
|
||||
dst.UploadTarget = src.UploadTarget;
|
||||
// MANDATORY, not optional: TextureTarget is a PipeFields.def row now, so a
|
||||
|
||||
@@ -487,18 +487,19 @@ namespace MobileGL::MG_Pipe {
|
||||
VaoMemo& MemoFor(const VertexArrayObject& vao) {
|
||||
const Uint64 lifetimeId = vao.GetLifetimeId();
|
||||
const Uint64 epoch = MGPipeSlots().ResetEpoch();
|
||||
// The three emitters of one validate ask for the same array: the last answer's index,
|
||||
// believed only while that entry still holds this id (a grow or an erase moves entries).
|
||||
if (m_lastMemoIndex < m_vaoMemo.size() && m_vaoMemo[m_lastMemoIndex].LifetimeId == lifetimeId &&
|
||||
m_vaoMemo[m_lastMemoIndex].SlotEpoch == epoch)
|
||||
return m_vaoMemo[m_lastMemoIndex];
|
||||
// A per-array hint survives switching arrays. Growth and erasure can move entries,
|
||||
// so the slot is only a candidate until both identity and the allocator epoch match.
|
||||
SizeT& hint = vao.PipeVertexInputMemoHint();
|
||||
if (hint < m_vaoMemo.size() && m_vaoMemo[hint].LifetimeId == lifetimeId &&
|
||||
m_vaoMemo[hint].SlotEpoch == epoch)
|
||||
return m_vaoMemo[hint];
|
||||
if (m_vaoMemo.empty() || (m_vaoMemoUsed + 1) * 2 > m_vaoMemo.size()) GrowVaoMemo();
|
||||
const SizeT mask = m_vaoMemo.size() - 1;
|
||||
SizeT i = VaoMemoHome(lifetimeId, mask);
|
||||
while (m_vaoMemo[i].LifetimeId != 0 && m_vaoMemo[i].LifetimeId != lifetimeId)
|
||||
i = (i + 1) & mask;
|
||||
VaoMemo& memo = m_vaoMemo[i];
|
||||
m_lastMemoIndex = i;
|
||||
hint = i;
|
||||
if (memo.LifetimeId == 0) ++m_vaoMemoUsed;
|
||||
if (memo.LifetimeId != lifetimeId || memo.SlotEpoch != epoch) {
|
||||
memo = VaoMemo{};
|
||||
@@ -527,7 +528,6 @@ namespace MobileGL::MG_Pipe {
|
||||
}
|
||||
Vector<VaoMemo> m_vaoMemo;
|
||||
SizeT m_vaoMemoUsed = 0;
|
||||
SizeT m_lastMemoIndex = ~SizeT{0};
|
||||
|
||||
public:
|
||||
// The VAO died (MGPipeEmitVertexElementsDestroyAndFree): its entry goes, by backward-shift
|
||||
|
||||
@@ -96,7 +96,6 @@ add_executable(MobileGLIntegrationTest
|
||||
Scenarios/PrimitiveRestartScenario.cpp
|
||||
Scenarios/FragCoordOriginScenario.cpp
|
||||
Scenarios/ClipControlScenario.cpp
|
||||
Scenarios/MultiviewScenario.cpp
|
||||
Scenarios/ClientVertexArrayScenario.cpp
|
||||
Scenarios/ClearThenReadPixelsScenario.cpp
|
||||
# P15 S0: a clear between draws into the same framebuffer (DirectVulkan records it in the pass).
|
||||
|
||||
@@ -201,8 +201,6 @@ DUALBLOCK_CAPABILITY_SKIPS = {
|
||||
"needs GL_KHR_shader_subgroup basic+arithmetic in compute",
|
||||
"DirectGLES.Split.IterationRPScratchFixScenario.WideFixtureShapedReductionSumsEveryInvocation":
|
||||
"needs GL_KHR_shader_subgroup basic+arithmetic in compute",
|
||||
"DirectGLES.Split.MultiviewScenario.AScissoredClearAfterADrawReachesEveryView":
|
||||
"ES driver crashes after a scissored clear of a multiview framebuffer",
|
||||
}
|
||||
|
||||
# Outstanding behavior, not a claim that another backend covers these semantics.
|
||||
|
||||
@@ -31,10 +31,6 @@ require subgroup width 16..256; local lavapipe exposes 8, so those two have no l
|
||||
execution coverage. Program203 and ScratchFix have passing Vulkan entries, which
|
||||
is not proof of the GLES path. The checker reports **capability gaps (not covered)**.
|
||||
|
||||
`MultiviewScenario.AScissoredClearAfterADrawReachesEveryView` skips on Espryt over
|
||||
llvmpipe: the driver corrupts its heap after a scissored clear of a multiview
|
||||
framebuffer, which surfaces at context destroy. The Vulkan entries of the case pass.
|
||||
|
||||
## Optional measurement
|
||||
|
||||
`FencePollScenario.PacedFrameFenceWaitsBench` is not part of generic split correctness
|
||||
|
||||
@@ -90,7 +90,6 @@ set(MGL_P8A_AMBIENT_CASES
|
||||
IterationRPScratchFixScenario.*
|
||||
LayeredAttachmentBarrierScenario.*
|
||||
LayeredAttachmentShapeScenario.*
|
||||
MultiviewScenario.*
|
||||
NarrowIntegerAttributeScenario.*
|
||||
NonCoreImageFormatScenario.*
|
||||
OrientationScenario.*
|
||||
|
||||
@@ -1,215 +0,0 @@
|
||||
// MobileGL - MobileGL/MG_IntegrationTest/Scenarios/MultiviewScenario.cpp
|
||||
// Copyright (c) 2026 MobileGL-Dev
|
||||
// Licensed under the GNU Lesser General Public License v3.0:
|
||||
// https://www.gnu.org/licenses/gpl-3.0.txt
|
||||
// https://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
// SPDX-License-Identifier: LGPL-3.0-only
|
||||
// End of Source File Header
|
||||
//
|
||||
// Scenario - GL_OVR_multiview RENDERS EACH VIEW INTO ITS OWN LAYER.
|
||||
//
|
||||
// A two-view attachment of layers 1 and 2 of a three-layer array texture, read back one layer at
|
||||
// a time through glFramebufferTextureLayer:
|
||||
//
|
||||
// - a draw reaches both views, with gl_ViewID_OVR telling them apart in the vertex stage (its
|
||||
// position and a varying) and in the fragment stage;
|
||||
// - a clear reaches both views, and layer 0, outside the views, is never written;
|
||||
// - a scissored clear issued after a draw, while that draw's pass is still open, reaches both
|
||||
// views too.
|
||||
//
|
||||
// Skipped where the backend does not advertise GL_OVR_multiview2.
|
||||
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
|
||||
#include "../Harness/HeadlessGL.h"
|
||||
#include "../Harness/ScenarioFixture.h"
|
||||
|
||||
#ifdef GLAPI
|
||||
#undef GLAPI
|
||||
#endif
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glcorearb.h>
|
||||
#undef GL_GLEXT_PROTOTYPES
|
||||
|
||||
namespace MGITest {
|
||||
namespace {
|
||||
constexpr int kSize = 32;
|
||||
|
||||
// View 0 covers the whole target in red; view 1 only its left half, in green.
|
||||
constexpr const char* kVaryingVS = R"(#version 330 core
|
||||
#extension GL_OVR_multiview2 : require
|
||||
layout(num_views = 2) in;
|
||||
layout(location = 0) in vec2 aPos;
|
||||
out vec4 vColor;
|
||||
void main() {
|
||||
bool second = gl_ViewID_OVR == 1u;
|
||||
vColor = second ? vec4(0.0, 1.0, 0.0, 1.0) : vec4(1.0, 0.0, 0.0, 1.0);
|
||||
float x = second ? aPos.x * 0.5 - 0.5 : aPos.x;
|
||||
gl_Position = vec4(x, aPos.y, 0.0, 1.0);
|
||||
}
|
||||
)";
|
||||
constexpr const char* kVaryingFS = R"(#version 330 core
|
||||
in vec4 vColor;
|
||||
out vec4 o_color;
|
||||
void main() { o_color = vColor; }
|
||||
)";
|
||||
|
||||
constexpr const char* kPlainVS = R"(#version 330 core
|
||||
#extension GL_OVR_multiview2 : require
|
||||
layout(num_views = 2) in;
|
||||
layout(location = 0) in vec2 aPos;
|
||||
void main() { gl_Position = vec4(aPos, 0.0, 1.0); }
|
||||
)";
|
||||
// The view seen from the fragment stage: red for view 0, green for view 1.
|
||||
constexpr const char* kViewFS = R"(#version 330 core
|
||||
#extension GL_OVR_multiview2 : require
|
||||
out vec4 o_color;
|
||||
void main() { o_color = gl_ViewID_OVR == 1u ? vec4(0.0, 1.0, 0.0, 1.0) : vec4(1.0, 0.0, 0.0, 1.0); }
|
||||
)";
|
||||
|
||||
bool ExtensionAdvertised(const char* name) {
|
||||
GLint count = 0;
|
||||
glGetIntegerv(GL_NUM_EXTENSIONS, &count);
|
||||
for (GLint i = 0; i < count; ++i) {
|
||||
const auto* extension = reinterpret_cast<const char*>(glGetStringi(GL_EXTENSIONS, i));
|
||||
if (extension && std::strcmp(extension, name) == 0) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// llvmpipe's OpenGL ES driver corrupts its heap when a multiview framebuffer is cleared
|
||||
// through a scissor: the context's teardown then crashes, with or without MobileGL in the
|
||||
// process (reproduced on llvmpipe 25.2 with nothing but the clear and eglDestroyContext).
|
||||
bool DriverBreaksScissoredMultiviewClears() {
|
||||
const auto* renderer = reinterpret_cast<const char*>(glGetString(GL_RENDERER));
|
||||
return renderer && std::strstr(renderer, "Espryt") && std::strstr(renderer, "llvmpipe");
|
||||
}
|
||||
|
||||
void DrawFullScreen(unsigned int program) {
|
||||
const float quad[] = {-1.0f, -1.0f, 1.0f, -1.0f, 1.0f, 1.0f, -1.0f, -1.0f, 1.0f, 1.0f, -1.0f, 1.0f};
|
||||
GLuint vao = 0, vbo = 0;
|
||||
glGenVertexArrays(1, &vao);
|
||||
glBindVertexArray(vao);
|
||||
glGenBuffers(1, &vbo);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, vbo);
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(quad), quad, GL_STATIC_DRAW);
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(float), nullptr);
|
||||
glUseProgram(program);
|
||||
glDrawArrays(GL_TRIANGLES, 0, 6);
|
||||
glUseProgram(0);
|
||||
glBindVertexArray(0);
|
||||
glDeleteBuffers(1, &vbo);
|
||||
glDeleteVertexArrays(1, &vao);
|
||||
}
|
||||
|
||||
class MultiviewScenario : public ScenarioTest {
|
||||
protected:
|
||||
void SetUp() override {
|
||||
ScenarioTest::SetUp();
|
||||
if (!Ready()) return;
|
||||
if (!ExtensionAdvertised("GL_OVR_multiview2")) {
|
||||
GTEST_SKIP() << "GL_OVR_multiview2 is not advertised by this backend/driver";
|
||||
}
|
||||
glGenTextures(1, &m_texture);
|
||||
glBindTexture(GL_TEXTURE_2D_ARRAY, m_texture);
|
||||
glTexStorage3D(GL_TEXTURE_2D_ARRAY, 1, GL_RGBA8, kSize, kSize, 3);
|
||||
glBindTexture(GL_TEXTURE_2D_ARRAY, 0);
|
||||
glGenFramebuffers(1, &m_readFbo);
|
||||
glGenFramebuffers(1, &m_multiviewFbo);
|
||||
// Every layer black first, one at a time, so layer 0 has a known value to keep.
|
||||
for (GLint layer = 0; layer < 3; ++layer) {
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, m_readFbo);
|
||||
glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, m_texture, 0, layer);
|
||||
ClearTo(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
}
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, m_multiviewFbo);
|
||||
glFramebufferTextureMultiviewOVR(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, m_texture, 0, 1, 2);
|
||||
ASSERT_EQ(glCheckFramebufferStatus(GL_FRAMEBUFFER), static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE));
|
||||
glViewport(0, 0, kSize, kSize);
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
if (m_texture == 0) return;
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
BindDefaultFramebuffer();
|
||||
glDeleteFramebuffers(1, &m_multiviewFbo);
|
||||
glDeleteFramebuffers(1, &m_readFbo);
|
||||
glDeleteTextures(1, &m_texture);
|
||||
}
|
||||
|
||||
Image ReadLayer(GLint layer) {
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, m_readFbo);
|
||||
glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, m_texture, 0, layer);
|
||||
Image image = ReadPixels(kSize, kSize);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, m_multiviewFbo);
|
||||
return image;
|
||||
}
|
||||
|
||||
::testing::AssertionResult HalvesAre(GLint layer, const char* left, const char* right,
|
||||
const std::string& when) {
|
||||
const Image image = ReadLayer(layer);
|
||||
const std::string where = when + ", layer " + std::to_string(layer);
|
||||
auto first = RegionIsMostly(image, 2, kSize / 2 - 3, 2, kSize - 3, left, 0.0, where + " (left half)");
|
||||
if (!first) return first;
|
||||
return RegionIsMostly(image, kSize / 2 + 2, kSize - 3, 2, kSize - 3, right, 0.0,
|
||||
where + " (right half)");
|
||||
}
|
||||
|
||||
GLuint m_texture = 0;
|
||||
GLuint m_readFbo = 0;
|
||||
GLuint m_multiviewFbo = 0;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
TEST_F(MultiviewScenario, ADrawReachesEveryViewAndTheVertexStageTellsThemApart) {
|
||||
if (!Ready() || IsSkipped()) return;
|
||||
std::string error;
|
||||
const unsigned int program = CompileProgram(kVaryingVS, kVaryingFS, &error);
|
||||
ASSERT_NE(program, 0u) << error;
|
||||
ClearTo(0.0f, 0.0f, 1.0f, 1.0f);
|
||||
DrawFullScreen(program);
|
||||
EXPECT_EQ(FirstGLError(), 0u);
|
||||
EXPECT_TRUE(HalvesAre(0, "black", "black", "outside the views"));
|
||||
EXPECT_TRUE(HalvesAre(1, "red", "red", "view 0"));
|
||||
EXPECT_TRUE(HalvesAre(2, "green", "blue", "view 1"));
|
||||
glDeleteProgram(program);
|
||||
EXPECT_EQ(FirstGLError(), 0u);
|
||||
}
|
||||
|
||||
TEST_F(MultiviewScenario, TheFragmentStageSeesItsView) {
|
||||
if (!Ready() || IsSkipped()) return;
|
||||
std::string error;
|
||||
const unsigned int program = CompileProgram(kPlainVS, kViewFS, &error);
|
||||
ASSERT_NE(program, 0u) << error;
|
||||
DrawFullScreen(program);
|
||||
EXPECT_EQ(FirstGLError(), 0u);
|
||||
EXPECT_TRUE(HalvesAre(1, "red", "red", "view 0"));
|
||||
EXPECT_TRUE(HalvesAre(2, "green", "green", "view 1"));
|
||||
glDeleteProgram(program);
|
||||
EXPECT_EQ(FirstGLError(), 0u);
|
||||
}
|
||||
|
||||
TEST_F(MultiviewScenario, AScissoredClearAfterADrawReachesEveryView) {
|
||||
if (!Ready() || IsSkipped()) return;
|
||||
if (DriverBreaksScissoredMultiviewClears()) {
|
||||
GTEST_SKIP() << "llvmpipe's ES driver crashes after a scissored clear of a multiview framebuffer";
|
||||
}
|
||||
std::string error;
|
||||
const unsigned int program = CompileProgram(kPlainVS, kViewFS, &error);
|
||||
ASSERT_NE(program, 0u) << error;
|
||||
DrawFullScreen(program);
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
glScissor(kSize / 2, 0, kSize / 2, kSize);
|
||||
ClearTo(0.0f, 0.0f, 1.0f, 1.0f);
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
EXPECT_EQ(FirstGLError(), 0u);
|
||||
EXPECT_TRUE(HalvesAre(1, "red", "blue", "view 0"));
|
||||
EXPECT_TRUE(HalvesAre(2, "green", "blue", "view 1"));
|
||||
EXPECT_TRUE(HalvesAre(0, "black", "black", "outside the views"));
|
||||
glDeleteProgram(program);
|
||||
EXPECT_EQ(FirstGLError(), 0u);
|
||||
}
|
||||
} // namespace MGITest
|
||||
@@ -677,11 +677,7 @@ namespace MobileGL::MG_Pipe {
|
||||
Uint32 InternalFormat;
|
||||
Uint8 Kind; // kMGPipeSurfaceKind{None,Texture,Renderbuffer}, above
|
||||
Uint8 Layered;
|
||||
// A mip level fits a byte: GL_MAX_TEXTURE_SIZE would have to pass 2^255 for it not to.
|
||||
Uint8 Level;
|
||||
// GL_OVR_multiview: non-zero on a multiview attachment, which renders views
|
||||
// [Layer, Layer + NumViews) of a 2D array texture. Layered is then 0.
|
||||
Uint8 NumViews;
|
||||
Uint16 Level;
|
||||
Uint32 Layer;
|
||||
Uint16 UploadTarget; // static_cast<Uint16>(MobileGL::TextureUploadTarget)
|
||||
// static_cast<Uint16>(MobileGL::TextureTarget), or kMGPipeSurfaceNoTextureTarget on a
|
||||
|
||||
@@ -100,7 +100,7 @@
|
||||
// Pad<n>, so the rename without this row is a pipe-gates failure, and the row without the
|
||||
// rename is one too. A meaning-carrying byte cannot enter this record silently.
|
||||
#define MGP_FIELDS_MGPSurface(F) \
|
||||
F(Res) F(InternalFormat) F(Kind) F(Layered) F(Level) F(NumViews) F(Layer) F(UploadTarget) F(TextureTarget)
|
||||
F(Res) F(InternalFormat) F(Kind) F(Layered) F(Level) F(Layer) F(UploadTarget) F(TextureTarget)
|
||||
|
||||
// P4a, D-C2: Pad0 became Uint8 Target, and gen_pipe.py's PADDING_MEMBER_RE only excludes a
|
||||
// member still NAMED Pad<n> - so the rename without this row is a pipe-gates failure, which
|
||||
@@ -399,7 +399,7 @@
|
||||
F(FragmentShadingRateAttachmentWithDefaultFramebuffer) F(FragmentShadingRateMasks) \
|
||||
F(MinFragmentShadingRateAttachmentTexelWidth) F(MinFragmentShadingRateAttachmentTexelHeight) \
|
||||
F(MaxFragmentShadingRateAttachmentTexelWidth) F(MaxFragmentShadingRateAttachmentTexelHeight) \
|
||||
F(MaxFragmentShadingRateAttachmentTexelAspectRatio) F(MaxFragmentShadingRateAttachmentLayers) F(MaxViews)
|
||||
F(MaxFragmentShadingRateAttachmentTexelAspectRatio) F(MaxFragmentShadingRateAttachmentLayers)
|
||||
|
||||
#define MGP_FIELDS_MGHostSpan(F) \
|
||||
F(Ptr) F(Seg) F(Size) F(Offset)
|
||||
|
||||
@@ -142,7 +142,6 @@ inline constexpr WireLayoutMember kMGPipeWireLayoutMembers[] = {
|
||||
{"MGPSurface.Kind", offsetof(MGPSurface, Kind), sizeof(((MGPSurface*)nullptr)->Kind)},
|
||||
{"MGPSurface.Layered", offsetof(MGPSurface, Layered), sizeof(((MGPSurface*)nullptr)->Layered)},
|
||||
{"MGPSurface.Level", offsetof(MGPSurface, Level), sizeof(((MGPSurface*)nullptr)->Level)},
|
||||
{"MGPSurface.NumViews", offsetof(MGPSurface, NumViews), sizeof(((MGPSurface*)nullptr)->NumViews)},
|
||||
{"MGPSurface.Layer", offsetof(MGPSurface, Layer), sizeof(((MGPSurface*)nullptr)->Layer)},
|
||||
{"MGPSurface.UploadTarget", offsetof(MGPSurface, UploadTarget), sizeof(((MGPSurface*)nullptr)->UploadTarget)},
|
||||
{"MGPSurface.TextureTarget", offsetof(MGPSurface, TextureTarget), sizeof(((MGPSurface*)nullptr)->TextureTarget)},
|
||||
@@ -686,7 +685,6 @@ inline constexpr WireLayoutMember kMGPipeWireLayoutMembers[] = {
|
||||
{"DynamicBackendParameters.MaxFragmentShadingRateAttachmentTexelHeight", offsetof(DynamicBackendParameters, MaxFragmentShadingRateAttachmentTexelHeight), sizeof(((DynamicBackendParameters*)nullptr)->MaxFragmentShadingRateAttachmentTexelHeight)},
|
||||
{"DynamicBackendParameters.MaxFragmentShadingRateAttachmentTexelAspectRatio", offsetof(DynamicBackendParameters, MaxFragmentShadingRateAttachmentTexelAspectRatio), sizeof(((DynamicBackendParameters*)nullptr)->MaxFragmentShadingRateAttachmentTexelAspectRatio)},
|
||||
{"DynamicBackendParameters.MaxFragmentShadingRateAttachmentLayers", offsetof(DynamicBackendParameters, MaxFragmentShadingRateAttachmentLayers), sizeof(((DynamicBackendParameters*)nullptr)->MaxFragmentShadingRateAttachmentLayers)},
|
||||
{"DynamicBackendParameters.MaxViews", offsetof(DynamicBackendParameters, MaxViews), sizeof(((DynamicBackendParameters*)nullptr)->MaxViews)},
|
||||
{"MGHostSpan", 0, sizeof(MGHostSpan)},
|
||||
{"MGHostSpan.Ptr", offsetof(MGHostSpan, Ptr), sizeof(((MGHostSpan*)nullptr)->Ptr)},
|
||||
{"MGHostSpan.Seg", offsetof(MGHostSpan, Seg), sizeof(((MGHostSpan*)nullptr)->Seg)},
|
||||
|
||||
@@ -45,9 +45,9 @@ namespace MobileGL::MG_State::GLState {
|
||||
// FramebufferAttachmentObject
|
||||
FramebufferAttachmentObject::FramebufferAttachmentObject(
|
||||
const SharedPtr<MG_State::GLState::ITextureObject>& texture, TextureUploadTarget textureUploadTarget, Int level,
|
||||
Int layer, Bool layered, Int numViews)
|
||||
Int layer, Bool layered)
|
||||
: m_texture(texture), m_textureUploadTarget(textureUploadTarget), m_textureLevel(level), m_textureLayer(layer),
|
||||
m_layered(layered), m_numViews(numViews) {}
|
||||
m_layered(layered) {}
|
||||
FramebufferAttachmentObject::FramebufferAttachmentObject(const SharedPtr<RenderbufferObject>& renderbuffer)
|
||||
: m_renderbuffer(renderbuffer) {}
|
||||
FramebufferAttachmentObject::FramebufferAttachmentObject(Bool IsValid)
|
||||
@@ -87,10 +87,6 @@ namespace MobileGL::MG_State::GLState {
|
||||
return m_layered;
|
||||
}
|
||||
|
||||
Int FramebufferAttachmentObject::GetNumViews() const {
|
||||
return m_numViews;
|
||||
}
|
||||
|
||||
TextureUploadTarget FramebufferAttachmentObject::GetTextureUploadTarget() const {
|
||||
return m_textureUploadTarget;
|
||||
}
|
||||
@@ -119,9 +115,7 @@ namespace MobileGL::MG_State::GLState {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
// GL_OVR_multiview 9.4.1: every view's layer, not only the base one.
|
||||
const Int lastLayer = m_textureLayer + std::max<Int>(m_numViews, 1) - 1;
|
||||
if (layerCount >= 0 && lastLayer >= layerCount) return false;
|
||||
if (layerCount >= 0 && m_textureLayer >= layerCount) return false;
|
||||
}
|
||||
return true;
|
||||
} else if (IsRenderbuffer()) {
|
||||
@@ -169,10 +163,9 @@ namespace MobileGL::MG_State::GLState {
|
||||
}
|
||||
|
||||
void FramebufferObject::AttachTexture(FramebufferAttachmentType type, const SharedPtr<ITextureObject>& texture,
|
||||
TextureUploadTarget textureUploadTarget, int level, int layer, Bool layered,
|
||||
int numViews) {
|
||||
TextureUploadTarget textureUploadTarget, int level, int layer, Bool layered) {
|
||||
m_attachmentObjects[static_cast<SizeT>(type)] =
|
||||
FramebufferAttachmentObject(texture, textureUploadTarget, level, layer, layered, numViews);
|
||||
FramebufferAttachmentObject(texture, textureUploadTarget, level, layer, layered);
|
||||
BumpAttachmentVersion(type);
|
||||
}
|
||||
|
||||
@@ -224,39 +217,7 @@ namespace MobileGL::MG_State::GLState {
|
||||
}
|
||||
|
||||
if (validAttachmentCount == 0) return false;
|
||||
return !HasLayerTargetMismatch() && !HasViewTargetMismatch();
|
||||
}
|
||||
|
||||
Bool FramebufferObject::HasViewTargetMismatch() const {
|
||||
Bool seen = false;
|
||||
Int numViews = 0;
|
||||
for (const auto& attachment : m_attachmentObjects) {
|
||||
if (!attachment.IsValid() || attachment.IsEmpty()) continue;
|
||||
const Int views = attachment.IsTexture() ? attachment.GetNumViews() : 0;
|
||||
if (seen && views != numViews) return true;
|
||||
seen = true;
|
||||
numViews = views;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Bool FramebufferObject::IsMultiview() const {
|
||||
for (const auto& attachment : m_attachmentObjects) {
|
||||
if (attachment.IsValid() && attachment.IsTexture() && attachment.IsMultiview()) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Int FramebufferObject::GetViewCount() const {
|
||||
Int numViews = 0;
|
||||
for (const auto& attachment : m_attachmentObjects) {
|
||||
if (!attachment.IsValid() || attachment.IsEmpty()) continue;
|
||||
const Int views = attachment.IsTexture() ? attachment.GetNumViews() : 0;
|
||||
if (views == 0) return 1;
|
||||
if (numViews != 0 && views != numViews) return 1;
|
||||
numViews = views;
|
||||
}
|
||||
return std::max<Int>(numViews, 1);
|
||||
return !HasLayerTargetMismatch();
|
||||
}
|
||||
|
||||
Bool FramebufferObject::HasLayerTargetMismatch() const {
|
||||
|
||||
@@ -75,7 +75,7 @@ namespace MobileGL {
|
||||
public:
|
||||
explicit FramebufferAttachmentObject(const SharedPtr<MG_State::GLState::ITextureObject>& texture,
|
||||
TextureUploadTarget textureUploadTarget, Int level = 0, Int layer = 0,
|
||||
Bool layered = false, Int numViews = 0);
|
||||
Bool layered = false);
|
||||
explicit FramebufferAttachmentObject(const SharedPtr<RenderbufferObject>& renderbuffer);
|
||||
explicit FramebufferAttachmentObject(Bool IsValid = true);
|
||||
|
||||
@@ -87,10 +87,6 @@ namespace MobileGL {
|
||||
Int GetTextureLevel() const;
|
||||
Int GetTextureLayer() const;
|
||||
Bool IsLayered() const;
|
||||
// GL_OVR_multiview: the attachment renders views [layer, layer + numViews) of a 2D
|
||||
// array texture, one per view. Zero for every attachment that is not multiview.
|
||||
Int GetNumViews() const;
|
||||
Bool IsMultiview() const { return m_numViews > 0; }
|
||||
TextureUploadTarget GetTextureUploadTarget() const;
|
||||
Bool IsComplete() const;
|
||||
IntVec3 GetSize() const;
|
||||
@@ -103,7 +99,6 @@ namespace MobileGL {
|
||||
Int m_textureLevel = 0;
|
||||
Int m_textureLayer = 0;
|
||||
Bool m_layered = false;
|
||||
Int m_numViews = 0;
|
||||
Bool m_isValid = true;
|
||||
};
|
||||
|
||||
@@ -127,7 +122,7 @@ namespace MobileGL {
|
||||
|
||||
void AttachTexture(FramebufferAttachmentType type, const SharedPtr<ITextureObject>& texture,
|
||||
TextureUploadTarget textureUploadTarget = TextureUploadTarget::Unknown, int level = 0,
|
||||
int layer = 0, Bool layered = false, int numViews = 0);
|
||||
int layer = 0, Bool layered = false);
|
||||
void AttachRenderbuffer(FramebufferAttachmentType type, const SharedPtr<RenderbufferObject>& renderbuffer);
|
||||
void Detach(FramebufferAttachmentType type);
|
||||
const FramebufferAttachmentObject& GetAttachment(FramebufferAttachmentType type) const;
|
||||
@@ -137,17 +132,6 @@ namespace MobileGL {
|
||||
// layered while another is not, or the layered color attachments come from textures of
|
||||
// different targets. CheckCompleteness() includes it; this tells the status apart.
|
||||
Bool HasLayerTargetMismatch() const;
|
||||
// GL_OVR_multiview's FRAMEBUFFER_INCOMPLETE_VIEW_TARGETS_OVR: the populated attachments
|
||||
// do not all have the same number of views. An attachment that is not multiview does
|
||||
// not match a multiview one, whatever its view count. CheckCompleteness() includes it.
|
||||
Bool HasViewTargetMismatch() const;
|
||||
// The number of views a draw into this framebuffer renders: the multiview attachments'
|
||||
// common count, or 1 when no attachment is multiview (or the counts disagree, which
|
||||
// leaves the framebuffer incomplete anyway).
|
||||
Int GetViewCount() const;
|
||||
// Whether any populated attachment is a multiview one. A multiview framebuffer with a
|
||||
// single view still takes the multiview draw rules.
|
||||
Bool IsMultiview() const;
|
||||
// aka. `buffer` as in glDrawBuffers/glReadBuffers
|
||||
void SetDrawBuffer(Uint index, FramebufferAttachmentType buffer);
|
||||
const FramebufferAttachmentArray& GetDrawBuffers() const;
|
||||
|
||||
@@ -383,9 +383,6 @@ namespace MobileGL::MG_State::GLState {
|
||||
GLenum gsOutputPrimitive = GL_NONE;
|
||||
Int gsMaxVertices = 0;
|
||||
Int gsInvocations = 0;
|
||||
// GL_OVR_multiview: the vertex stage's layout(num_views = N) in;, or 0 without one. The
|
||||
// backend that emits GLSL needs it back, because SPIR-V cannot say it.
|
||||
Int vsNumViews = 0;
|
||||
// The tessellation evaluation stage's layout: GL_QUADS / GL_TRIANGLES / GL_ISOLINES,
|
||||
// GL_EQUAL / GL_FRACTIONAL_EVEN / GL_FRACTIONAL_ODD, GL_CW / GL_CCW, and point mode.
|
||||
GLenum tessGenMode = GL_NONE;
|
||||
@@ -613,7 +610,6 @@ namespace MobileGL::MG_State::GLState {
|
||||
v("gsOutputPrimitive", a.gsOutputPrimitive);
|
||||
v("gsMaxVertices", a.gsMaxVertices);
|
||||
v("gsInvocations", a.gsInvocations);
|
||||
v("vsNumViews", a.vsNumViews);
|
||||
v("tessGenMode", a.tessGenMode);
|
||||
v("tessGenSpacing", a.tessGenSpacing);
|
||||
v("tessGenVertexOrder", a.tessGenVertexOrder);
|
||||
@@ -622,7 +618,7 @@ namespace MobileGL::MG_State::GLState {
|
||||
v("xfbVaryingNameMaxLength", a.xfbVaryingNameMaxLength);
|
||||
v("xfbNeedsScatteredCapture", a.xfbNeedsScatteredCapture);
|
||||
v("xfbPackedStride", a.xfbPackedStride);
|
||||
} // 58 fields (59 members minus `program`)
|
||||
} // 57 fields (58 members minus `program`)
|
||||
|
||||
template <class Self, class V>
|
||||
requires std::same_as<std::remove_const_t<Self>, SpirvArtifacts>
|
||||
@@ -654,7 +650,7 @@ namespace MobileGL::MG_State::GLState {
|
||||
#define MGL_XFBVARYING_SIZE 128
|
||||
// P7 OQ-8 added storageBlocks, one more Vector, in the disaggregated build ONLY. The pull
|
||||
// number below is the one G1 measures and it has not moved.
|
||||
#define MGL_LINKARTIFACTS_SIZE 1088
|
||||
#define MGL_LINKARTIFACTS_SIZE 1080
|
||||
#define MGL_SPIRVARTIFACTS_SIZE 96
|
||||
#elif defined(_LIBCPP_VERSION) && (SIZE_MAX == UINT64_MAX) && defined(MGL_ARTIFACT_SIZES_LIBCXX_PINNED)
|
||||
// The integrator pins these from the NDK build (brief C.4); until then this branch is inert.
|
||||
|
||||
@@ -67,8 +67,7 @@ namespace MobileGL::MG_State::GLState {
|
||||
// reader checks FIRST and what the refusal names, and CONTRACT-P7 §5.3 asks for the bump
|
||||
// explicitly. `wireFingerprint` moves with both, which is expected and is what makes a
|
||||
// mixed-version pair refuse at the handshake instead of at the first program.
|
||||
// 4: LinkArtifacts gained `vsNumViews` (GL_OVR_multiview), for the same reason.
|
||||
inline constexpr Uint32 kProgramArtifactsCodecVersion = 4;
|
||||
inline constexpr Uint32 kProgramArtifactsCodecVersion = 3;
|
||||
// Derived from the actual VisitFields order/names, container element schemas and scalar
|
||||
// representations. No native container size/offset is included. Also checked in Hello.
|
||||
Uint64 ProgramArtifactsSchemaFingerprint();
|
||||
|
||||
@@ -193,25 +193,6 @@ namespace {
|
||||
// The offsets themselves survive that lowering (reflection and the SPIR-V generator both
|
||||
// honor layoutOffset), so the check belongs here, over the same model the GL queries answer
|
||||
// from. Returns the info-log line for an illegal layout, empty for a legal one.
|
||||
// GL_OVR_multiview's layout(num_views = N) in; of the linked vertex stage into
|
||||
// artifacts.vsNumViews, 0 without one. glslang already refused a non-positive count and two
|
||||
// units that disagree; the upper bound is GL_MAX_VIEWS_OVR, which glslang does not know, so it
|
||||
// is held here. False, with the link failed and the TProgram dropped, when the count is over it.
|
||||
static MobileGL::Bool ResolveVertexNumViews(MobileGL::MG_State::GLState::ProgramObject::LinkArtifacts& artifacts,
|
||||
const MobileGL::MG_Util::ShaderTranspiler::CompileEnv& env) {
|
||||
artifacts.vsNumViews = 0;
|
||||
const glslang::TIntermediate* vs = artifacts.program->getIntermediate(EShLangVertex);
|
||||
if (vs == nullptr) return true;
|
||||
artifacts.vsNumViews = std::max(vs->getNumViews(), 0);
|
||||
if (!env.HasBackend() || artifacts.vsNumViews <= env.params.MaxViews) return true;
|
||||
artifacts.linkStatus = false;
|
||||
artifacts.program.reset();
|
||||
artifacts.infoLog =
|
||||
std::format("Vertex shader declares num_views = {}, more than the {} GL_MAX_VIEWS_OVR allows.",
|
||||
artifacts.vsNumViews, env.params.MaxViews);
|
||||
return false;
|
||||
}
|
||||
|
||||
static MobileGL::String ValidateAtomicCounterLayout(glslang::TProgram& reflection) {
|
||||
using MobileGL::Bool;
|
||||
using MobileGL::Int;
|
||||
@@ -1059,11 +1040,6 @@ namespace MobileGL::MG_State::GLState {
|
||||
}
|
||||
}
|
||||
|
||||
if (!ResolveVertexNumViews(artifacts, env)) {
|
||||
DeferLog(std::format("ProgramObject {}: Link failed - {}", in.externalIndex, artifacts.infoLog));
|
||||
return;
|
||||
}
|
||||
|
||||
// ---- everything below this line up to GenerateSpirv() is the GL query surface ----
|
||||
//
|
||||
// ORDERING NOTE (rewritten 2026-08-10; the constraint it records was RETESTED, not
|
||||
|
||||
@@ -1320,9 +1320,6 @@ namespace MobileGL::MG_State::GLState {
|
||||
GLenum GetGeometryOutputType() const { return Artifacts().gsOutputPrimitive; }
|
||||
Int GetGeometryVerticesOut() const { return Artifacts().gsMaxVertices; }
|
||||
Int GetGeometryShaderInvocations() const { return Artifacts().gsInvocations; }
|
||||
// GL_OVR_multiview: how many views a draw with this program renders - its vertex stage's
|
||||
// num_views, or 1 without the qualifier.
|
||||
Int GetMultiviewViewCount() const { return std::max<Int>(Artifacts().vsNumViews, 1); }
|
||||
// GL_TESS_CONTROL_OUTPUT_VERTICES of the linked tessellation control stage, or 0 when
|
||||
// the program has no such stage. Never greater than GL_MAX_PATCH_VERTICES: a program
|
||||
// that declared more does not link at all (GL 4.6 core 11.2.1.1).
|
||||
|
||||
@@ -69,6 +69,8 @@ namespace MobileGL {
|
||||
// DirectVulkan's VulkanRenderer).
|
||||
Uint64 GetLifetimeId() const { return m_lifetimeId; }
|
||||
|
||||
SizeT& PipeVertexInputMemoHint() const { return m_pipeVertexInputMemoHint; }
|
||||
|
||||
void SetAttributeDivisor(Uint index, Uint divisor);
|
||||
Uint GetAttributeDivisor(Uint index) const;
|
||||
|
||||
@@ -134,6 +136,7 @@ namespace MobileGL {
|
||||
|
||||
const Uint m_externalIndex = 0;
|
||||
const Uint64 m_lifetimeId = AllocateLifetimeId();
|
||||
mutable SizeT m_pipeVertexInputMemoHint = ~SizeT{0};
|
||||
Array<VertexAttribute, MAX_VERTEX_ATTRIBS> m_attributes;
|
||||
Array<VertexAttributeVersion, MAX_VERTEX_ATTRIBS> m_attributeVersions;
|
||||
BindingSlot<BufferObject> m_indexBufferBindingSlot;
|
||||
|
||||
@@ -67,6 +67,12 @@ target_include_directories(ContextEpochTest PRIVATE ${MGL_ROOT}/include ${MGL_RO
|
||||
target_link_libraries(ContextEpochTest PRIVATE MobileGLTestMain ${LINK_LIBRARIES})
|
||||
gtest_discover_tests(ContextEpochTest DISCOVERY_TIMEOUT 30 PROPERTIES LABELS unit)
|
||||
|
||||
# The record of texture storage sampled in the current offscreen draw batch.
|
||||
add_executable(DrawTextureReadsTest DrawTextureReadsTest.cpp)
|
||||
target_include_directories(DrawTextureReadsTest PRIVATE ${MGL_ROOT}/include ${MGL_ROOT}/MobileGL)
|
||||
target_link_libraries(DrawTextureReadsTest PRIVATE MobileGLTestMain ${LINK_LIBRARIES})
|
||||
gtest_discover_tests(DrawTextureReadsTest DISCOVERY_TIMEOUT 30 PROPERTIES LABELS unit)
|
||||
|
||||
# P3b/P4b R-5: D-K2's dependency rule had six statements and nothing compared them. This binary
|
||||
# is where the comparison can live, because it is the one that links BOTH the client check
|
||||
# (MG_Impl/Pipe, through MG_Pipe) and the server gate (MG_Backend/DirectGLES's resolvers).
|
||||
@@ -88,9 +94,3 @@ gtest_discover_tests(NarrowIntegerEsslTest DISCOVERY_TIMEOUT 30 PROPERTIES LABEL
|
||||
gtest_discover_tests(EsslShaderPassTest DISCOVERY_TIMEOUT 30 PROPERTIES LABELS unit)
|
||||
gtest_discover_tests(BaseInstanceInjectionTest DISCOVERY_TIMEOUT 30 PROPERTIES LABELS unit)
|
||||
gtest_discover_tests(ViewportIndexRoutingTest DISCOVERY_TIMEOUT 30 PROPERTIES LABELS unit)
|
||||
|
||||
# GL_OVR_multiview's ESSL: num_views through glslang, the capability strip and the text pass.
|
||||
add_executable(MultiviewEsslTest MultiviewEsslTest.cpp)
|
||||
target_include_directories(MultiviewEsslTest PRIVATE ${MGL_ROOT}/include ${MGL_ROOT}/MobileGL)
|
||||
target_link_libraries(MultiviewEsslTest PRIVATE MobileGLTestMain glslang-default-resource-limits ${LINK_LIBRARIES})
|
||||
gtest_discover_tests(MultiviewEsslTest DISCOVERY_TIMEOUT 30 PROPERTIES LABELS unit)
|
||||
@@ -0,0 +1,61 @@
|
||||
// MobileGL - MobileGL/MG_Test/Backend/DirectGLES/DrawTextureReadsTest.cpp
|
||||
// Copyright (c) 2025-2026 MobileGL-Dev
|
||||
// Licensed under the GNU Lesser General Public License v3.0:
|
||||
// https://www.gnu.org/licenses/gpl-3.0.txt
|
||||
// https://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
// SPDX-License-Identifier: LGPL-3.0-only
|
||||
// End of Source File Header
|
||||
|
||||
// The per-context record of texture storage sampled in the current offscreen draw batch.
|
||||
#include <gtest/gtest.h>
|
||||
#include <MG_Backend/DirectGLES/DrawTextureReads.h>
|
||||
|
||||
namespace {
|
||||
using MobileGL::MG_Backend::DirectGLES::TextureImpl::DrawTextureReads;
|
||||
|
||||
TEST(DrawTextureReads, RecordsOnlyOffscreenBatches) {
|
||||
DrawTextureReads reads;
|
||||
EXPECT_FALSE(reads.NeedsSamplerWalk(1, 1)) << "the window surface is not tracked";
|
||||
reads.NoteRead(3, 7);
|
||||
EXPECT_FALSE(reads.WasRead(3, 7));
|
||||
|
||||
reads.BindFramebuffer(5);
|
||||
EXPECT_TRUE(reads.NeedsSamplerWalk(1, 1));
|
||||
reads.NoteRead(3, 7);
|
||||
EXPECT_TRUE(reads.WasRead(3, 7));
|
||||
EXPECT_FALSE(reads.WasRead(3, 8)) << "a recycled slot has a new generation";
|
||||
EXPECT_FALSE(reads.WasRead(4, 7));
|
||||
}
|
||||
|
||||
TEST(DrawTextureReads, FramebufferChangesAndSwapsEndTheBatch) {
|
||||
DrawTextureReads reads;
|
||||
reads.BindFramebuffer(5);
|
||||
reads.NoteRead(2, 1);
|
||||
reads.BindFramebuffer(5);
|
||||
EXPECT_TRUE(reads.WasRead(2, 1)) << "rebinding the same framebuffer keeps the batch";
|
||||
|
||||
reads.BindFramebuffer(6);
|
||||
EXPECT_FALSE(reads.WasRead(2, 1));
|
||||
reads.NoteRead(2, 1);
|
||||
reads.EndBatch();
|
||||
EXPECT_FALSE(reads.WasRead(2, 1));
|
||||
|
||||
reads.NoteRead(9, 4);
|
||||
reads.DeleteFramebuffer(7);
|
||||
EXPECT_TRUE(reads.WasRead(9, 4)) << "deleting another framebuffer changes nothing";
|
||||
reads.DeleteFramebuffer(6);
|
||||
EXPECT_FALSE(reads.WasRead(9, 4));
|
||||
EXPECT_FALSE(reads.NeedsSamplerWalk(1, 1));
|
||||
}
|
||||
|
||||
TEST(DrawTextureReads, SamplerWalkRepeatsOnlyWhenTheViewsChange) {
|
||||
DrawTextureReads reads;
|
||||
reads.BindFramebuffer(5);
|
||||
reads.RecordSamplerWalk(1, 10);
|
||||
EXPECT_FALSE(reads.NeedsSamplerWalk(1, 10));
|
||||
EXPECT_TRUE(reads.NeedsSamplerWalk(1, 11));
|
||||
EXPECT_TRUE(reads.NeedsSamplerWalk(2, 10));
|
||||
reads.EndBatch();
|
||||
EXPECT_TRUE(reads.NeedsSamplerWalk(1, 10));
|
||||
}
|
||||
} // namespace
|
||||
@@ -1,197 +0,0 @@
|
||||
// MobileGL - MobileGL/MG_Test/Backend/DirectGLES/MultiviewEsslTest.cpp
|
||||
// Copyright (c) 2026 MobileGL-Dev
|
||||
// Licensed under the GNU Lesser General Public License v3.0:
|
||||
// https://www.gnu.org/licenses/gpl-3.0.txt
|
||||
// https://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
// SPDX-License-Identifier: LGPL-3.0-only
|
||||
// End of Source File Header
|
||||
//
|
||||
// GL_OVR_multiview through the steps DirectGLES takes: glslang keeps the vertex stage's num_views,
|
||||
// the SPIR-V loses its MultiView capability so SPIRV-Cross accepts both stages without a view
|
||||
// count, and the text pass puts the directive and num_views back. The result has to be ESSL 3.20
|
||||
// that a compiler accepts, in both stages.
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <MG_Backend/DirectGLES/DirectGLES.h>
|
||||
#include <MG_Backend/DirectGLES/Utils.h>
|
||||
#include <MG_Util/ShaderTranspiler/ShaderCompiler.h>
|
||||
#include <MG_Util/ShaderTranspiler/SpvcSession.h>
|
||||
#include <MG_Util/ShaderTranspiler/Types.h>
|
||||
|
||||
#include "Init.h"
|
||||
|
||||
#include <glslang/MachineIndependent/localintermediate.h>
|
||||
#include <glslang/Public/ResourceLimits.h>
|
||||
#include <glslang/Public/ShaderLang.h>
|
||||
|
||||
using namespace MobileGL;
|
||||
using MobileGL::MG_Backend::DirectGLES::PrgramImpl::RequestMultiviewExtension;
|
||||
using MobileGL::MG_Util::ShaderTranspiler::SessionUsageBit;
|
||||
using MobileGL::MG_Util::ShaderTranspiler::ShaderCompiler;
|
||||
using MobileGL::MG_Util::ShaderTranspiler::SpvcSession;
|
||||
|
||||
namespace {
|
||||
constexpr const char* kVertex = R"(#version 330 core
|
||||
#extension GL_OVR_multiview2 : require
|
||||
layout(num_views = 2) in;
|
||||
layout(location = 0) in vec2 pos;
|
||||
out float tint;
|
||||
void main() {
|
||||
tint = float(gl_ViewID_OVR);
|
||||
gl_Position = vec4(pos.x + float(gl_ViewID_OVR), pos.y, 0.0, 1.0);
|
||||
}
|
||||
)";
|
||||
constexpr const char* kFragment = R"(#version 330 core
|
||||
#extension GL_OVR_multiview2 : require
|
||||
in float tint;
|
||||
out vec4 color;
|
||||
void main() { color = vec4(tint, float(gl_ViewID_OVR), 0.0, 1.0); }
|
||||
)";
|
||||
|
||||
struct LinkedModules {
|
||||
Int numViews = -1;
|
||||
Vector<Vector<Uint32>> modules;
|
||||
};
|
||||
|
||||
LinkedModules CompileAndLink(const char* vertex, const char* fragment) {
|
||||
using namespace MG_Util::ShaderTranspiler;
|
||||
LinkedModules out;
|
||||
Vector<SharedPtr<glslang::TShader>> shaders;
|
||||
for (const auto& [stage, source] :
|
||||
Vector<Pair<GLenum, const char*>>{{GL_VERTEX_SHADER, vertex}, {GL_FRAGMENT_SHADER, fragment}}) {
|
||||
ShaderAttrib attrib{.shaderType = stage, .sourceStr = source};
|
||||
auto shader = ShaderCompiler::CompileShader(attrib);
|
||||
EXPECT_TRUE(shader) << (shader ? String{} : shader.error().log);
|
||||
if (!shader) return out;
|
||||
shaders.push_back(shader.value());
|
||||
}
|
||||
ProgramAttrib programAttrib{.shaders = shaders};
|
||||
auto program = ShaderCompiler::LinkProgram(programAttrib);
|
||||
EXPECT_TRUE(program) << (program ? String{} : program.error().log);
|
||||
if (!program) return out;
|
||||
out.numViews = program.value()->getIntermediate(EShLangVertex)->getNumViews();
|
||||
ProgramBinaryAttrib binaryAttrib{.shaderTypes = {GL_VERTEX_SHADER, GL_FRAGMENT_SHADER},
|
||||
.program = *program.value()};
|
||||
auto binary = ShaderCompiler::GetSpirvBinaryFromProgram(binaryAttrib);
|
||||
EXPECT_TRUE(binary) << (binary ? String{} : binary.error().log);
|
||||
if (!binary || binary->size() != 2) return out;
|
||||
for (auto module : binary.value()) {
|
||||
EXPECT_TRUE(ShaderCompiler::SanitizeAndOptimizeBinary(module, module, true, true));
|
||||
out.modules.push_back(Move(module));
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
String EmitEssl320(const Vector<Uint32>& spirv) {
|
||||
SpvcSession session(spirv, SessionUsageBit::Transpile);
|
||||
spvc_compiler_options options;
|
||||
session.CreateOptions(&options);
|
||||
spvc_compiler_options_set_uint(options, SPVC_COMPILER_OPTION_GLSL_VERSION, 320);
|
||||
spvc_compiler_options_set_bool(options, SPVC_COMPILER_OPTION_GLSL_ES, SPVC_TRUE);
|
||||
spvc_compiler_options_set_bool(options, SPVC_COMPILER_OPTION_GLSL_VULKAN_SEMANTICS, SPVC_FALSE);
|
||||
session.SetOptions(options);
|
||||
const char* result = nullptr;
|
||||
session.Compile(&result);
|
||||
EXPECT_NE(result, nullptr) << (session.GetLastErrorString() ? session.GetLastErrorString() : "");
|
||||
return result != nullptr ? String(result) : String{};
|
||||
}
|
||||
|
||||
String CompileErrorAsEssl320(const String& source, EShLanguage stage) {
|
||||
glslang::TShader shader(stage);
|
||||
const char* strings[] = {source.c_str()};
|
||||
shader.setStrings(strings, 1);
|
||||
if (shader.parse(GetDefaultResources(), 320, EEsProfile, false, false, EShMsgDefault)) return {};
|
||||
return shader.getInfoLog();
|
||||
}
|
||||
|
||||
Bool DeclaresMultiviewCapability(const Vector<Uint32>& module) {
|
||||
constexpr Uint32 kOpCapability = 17;
|
||||
constexpr Uint32 kCapabilityMultiView = 4439;
|
||||
for (SizeT at = 5; at < module.size();) {
|
||||
const Uint32 wordCount = module[at] >> 16;
|
||||
if (wordCount == 0) return false;
|
||||
if ((module[at] & 0xFFFFu) == kOpCapability && module[at + 1] == kCapabilityMultiView) return true;
|
||||
at += wordCount;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
TEST(MultiviewEssl, BothStagesComeOutAsMultiviewEsslACompilerAccepts) {
|
||||
MobileGL::Initialize();
|
||||
const LinkedModules linked = CompileAndLink(kVertex, kFragment);
|
||||
ASSERT_EQ(linked.modules.size(), 2u);
|
||||
EXPECT_EQ(linked.numViews, 2) << "glslang dropped the vertex stage's num_views";
|
||||
|
||||
const struct {
|
||||
GLenum glStage;
|
||||
EShLanguage stage;
|
||||
} stages[] = {{GL_VERTEX_SHADER, EShLangVertex}, {GL_FRAGMENT_SHADER, EShLangFragment}};
|
||||
for (SizeT i = 0; i < 2; ++i) {
|
||||
ASSERT_TRUE(DeclaresMultiviewCapability(linked.modules[i]));
|
||||
Vector<Uint32> stripped;
|
||||
ASSERT_TRUE(ShaderCompiler::StripMultiviewCapabilityForEssl(linked.modules[i], stripped));
|
||||
EXPECT_FALSE(DeclaresMultiviewCapability(stripped));
|
||||
|
||||
const String emitted = EmitEssl320(stripped);
|
||||
ASSERT_FALSE(emitted.empty());
|
||||
EXPECT_NE(emitted.find("gl_ViewID_OVR"), String::npos) << emitted;
|
||||
EXPECT_EQ(emitted.find("GL_OVR_multiview"), String::npos) << "the emission must not depend on the view count";
|
||||
|
||||
const String essl = RequestMultiviewExtension(emitted, stages[i].glStage, linked.numViews, true);
|
||||
EXPECT_NE(essl.find("#extension GL_OVR_multiview2 : require\n"), String::npos) << essl;
|
||||
const Bool vertex = stages[i].glStage == GL_VERTEX_SHADER;
|
||||
EXPECT_EQ(essl.find("layout(num_views = 2) in;") != String::npos, vertex) << essl;
|
||||
EXPECT_EQ(CompileErrorAsEssl320(essl, stages[i].stage), String{}) << essl;
|
||||
}
|
||||
}
|
||||
|
||||
TEST(MultiviewEssl, TheDirectiveFollowsTheDriversExtensionAndNumViewsFollowsTheDirectives) {
|
||||
const String source = "#version 320 es\n"
|
||||
"#extension GL_EXT_clip_cull_distance : require\n"
|
||||
"\n"
|
||||
"precision highp float;\n"
|
||||
"void main() { gl_Position = vec4(float(gl_ViewID_OVR)); }\n";
|
||||
const String essl = RequestMultiviewExtension(source, GL_VERTEX_SHADER, 3, false);
|
||||
EXPECT_EQ(essl, "#version 320 es\n"
|
||||
"#extension GL_OVR_multiview : require\n"
|
||||
"#extension GL_EXT_clip_cull_distance : require\n"
|
||||
"layout(num_views = 3) in;\n"
|
||||
"\n"
|
||||
"precision highp float;\n"
|
||||
"void main() { gl_Position = vec4(float(gl_ViewID_OVR)); }\n");
|
||||
|
||||
// Neither the built-in nor a view count: nothing to ask for.
|
||||
const String plain = "#version 320 es\nvoid main() {}\n";
|
||||
EXPECT_EQ(RequestMultiviewExtension(plain, GL_VERTEX_SHADER, 0, true), plain);
|
||||
EXPECT_EQ(RequestMultiviewExtension(plain, GL_FRAGMENT_SHADER, 2, true), plain);
|
||||
}
|
||||
|
||||
TEST(MultiviewEssl, AModuleWithoutMultiviewIsLeftAlone) {
|
||||
MobileGL::Initialize();
|
||||
const LinkedModules linked = CompileAndLink("#version 330 core\nvoid main() { gl_Position = vec4(0.0); }\n",
|
||||
"#version 330 core\nout vec4 c;\nvoid main() { c = vec4(1.0); }\n");
|
||||
ASSERT_EQ(linked.modules.size(), 2u);
|
||||
EXPECT_LT(linked.numViews, 0) << "no num_views qualifier was declared";
|
||||
Vector<Uint32> stripped;
|
||||
EXPECT_FALSE(ShaderCompiler::StripMultiviewCapabilityForEssl(linked.modules[0], stripped));
|
||||
EXPECT_TRUE(stripped.empty());
|
||||
}
|
||||
|
||||
TEST(MultiviewEssl, NumViewsIsAVertexStageQualifierAboveZero) {
|
||||
MobileGL::Initialize();
|
||||
using namespace MG_Util::ShaderTranspiler;
|
||||
for (const auto& [stage, source] : Vector<Pair<GLenum, const char*>>{
|
||||
{GL_VERTEX_SHADER, "#version 330 core\n#extension GL_OVR_multiview : require\n"
|
||||
"layout(num_views = 0) in;\nvoid main() { gl_Position = vec4(0.0); }\n"},
|
||||
{GL_FRAGMENT_SHADER, "#version 330 core\n#extension GL_OVR_multiview : require\n"
|
||||
"layout(num_views = 2) in;\nout vec4 c;\nvoid main() { c = vec4(1.0); }\n"},
|
||||
{GL_VERTEX_SHADER, "#version 330 core\n#extension GL_OVR_multiview : require\n"
|
||||
"layout(num_views = 2) in;\nlayout(num_views = 3) in;\n"
|
||||
"void main() { gl_Position = vec4(0.0); }\n"},
|
||||
}) {
|
||||
ShaderAttrib attrib{.shaderType = stage, .sourceStr = source};
|
||||
EXPECT_FALSE(ShaderCompiler::CompileShader(attrib)) << source;
|
||||
}
|
||||
}
|
||||
@@ -96,8 +96,6 @@ namespace {
|
||||
// baseInstance word and exposes it through gl_InstanceID.
|
||||
bool drawLeaksBaseInstanceWord = false;
|
||||
GLenum errorRaisedByDraw = GL_NO_ERROR;
|
||||
// GL_MAX_VIEWS_OVR, a GL_OVR_multiview pname.
|
||||
GLint maxViews = 4;
|
||||
|
||||
GLenum pendingError = GL_NO_ERROR;
|
||||
std::vector<std::string> extensions;
|
||||
@@ -272,9 +270,6 @@ namespace {
|
||||
case GL_NUM_EXTENSIONS:
|
||||
*data = static_cast<GLint>(g_fake.extensions.size());
|
||||
break;
|
||||
case GL_MAX_VIEWS_OVR:
|
||||
*data = g_fake.maxViews;
|
||||
break;
|
||||
default:
|
||||
// Leave the caller's defaults for every other capability query.
|
||||
break;
|
||||
@@ -1392,92 +1387,6 @@ TEST(CoreSurfaceAdvertisement, ClipControlFollowsTheBackendsRoute) {
|
||||
MobileGL::E_GL_ARB_clip_control));
|
||||
}
|
||||
|
||||
// GL_OVR_multiview needs the driver's string and glFramebufferTextureMultiviewOVR, and a
|
||||
// GL_MAX_VIEWS_OVR of at least the spec minimum; GL_OVR_multiview2 only counts on top of it.
|
||||
TEST(MultiviewCapabilities, NeedTheExtensionTheEntryPointAndTwoViews) {
|
||||
auto withEntryPoint = MakeFakeGLESFunctions();
|
||||
withEntryPoint.glFramebufferTextureMultiviewOVR = [](GLenum, GLenum, GLuint, GLint, GLint, GLsizei) {};
|
||||
|
||||
ResetFakeDriver();
|
||||
g_fake.maxVertexSsboBlocks = 0;
|
||||
g_fake.extensions.emplace_back("GL_OVR_multiview2");
|
||||
MobileGL::MG_External::GLESCapabilities onlyTheSecond;
|
||||
ASSERT_TRUE(MobileGL::MG_Util::BackendLoader::FillInGLESCapabilities(onlyTheSecond, withEntryPoint));
|
||||
EXPECT_FALSE(onlyTheSecond.SupportsMultiview);
|
||||
EXPECT_FALSE(onlyTheSecond.SupportsMultiview2);
|
||||
EXPECT_EQ(onlyTheSecond.MaxViews, 0);
|
||||
|
||||
ResetFakeDriver();
|
||||
g_fake.maxVertexSsboBlocks = 0;
|
||||
g_fake.extensions = {"GL_OVR_multiview", "GL_OVR_multiview2"};
|
||||
MobileGL::MG_External::GLESCapabilities noEntryPoint;
|
||||
ASSERT_TRUE(MobileGL::MG_Util::BackendLoader::FillInGLESCapabilities(noEntryPoint, MakeFakeGLESFunctions()));
|
||||
EXPECT_FALSE(noEntryPoint.SupportsMultiview);
|
||||
EXPECT_FALSE(noEntryPoint.SupportsMultiview2);
|
||||
|
||||
ResetFakeDriver();
|
||||
g_fake.maxVertexSsboBlocks = 0;
|
||||
g_fake.extensions = {"GL_OVR_multiview"};
|
||||
g_fake.maxViews = 1;
|
||||
MobileGL::MG_External::GLESCapabilities oneView;
|
||||
ASSERT_TRUE(MobileGL::MG_Util::BackendLoader::FillInGLESCapabilities(oneView, withEntryPoint));
|
||||
EXPECT_FALSE(oneView.SupportsMultiview);
|
||||
EXPECT_EQ(oneView.MaxViews, 0);
|
||||
|
||||
ResetFakeDriver();
|
||||
g_fake.maxVertexSsboBlocks = 0;
|
||||
g_fake.extensions = {"GL_OVR_multiview"};
|
||||
MobileGL::MG_External::GLESCapabilities firstOnly;
|
||||
ASSERT_TRUE(MobileGL::MG_Util::BackendLoader::FillInGLESCapabilities(firstOnly, withEntryPoint));
|
||||
EXPECT_TRUE(firstOnly.SupportsMultiview);
|
||||
EXPECT_FALSE(firstOnly.SupportsMultiview2);
|
||||
EXPECT_EQ(firstOnly.MaxViews, 4);
|
||||
|
||||
ResetFakeDriver();
|
||||
g_fake.maxVertexSsboBlocks = 0;
|
||||
g_fake.extensions = {"GL_OVR_multiview", "GL_OVR_multiview2"};
|
||||
MobileGL::MG_External::GLESCapabilities both;
|
||||
ASSERT_TRUE(MobileGL::MG_Util::BackendLoader::FillInGLESCapabilities(both, withEntryPoint));
|
||||
EXPECT_TRUE(both.SupportsMultiview);
|
||||
EXPECT_TRUE(both.SupportsMultiview2);
|
||||
}
|
||||
|
||||
// Each multiview string follows the DirectGLES driver's own; DirectVulkan advertises both where the
|
||||
// device has the multiview feature, and neither without it.
|
||||
TEST(CoreSurfaceAdvertisement, MultiviewFollowsTheDriver) {
|
||||
const auto contains = [](const MobileGL::Vector<MobileGL::GLExtension>& extensions, MobileGL::GLExtension wanted) {
|
||||
return std::find(extensions.begin(), extensions.end(), wanted) != extensions.end();
|
||||
};
|
||||
namespace DirectGLES = MobileGL::MG_Backend::DirectGLES;
|
||||
namespace DirectVulkan = MobileGL::MG_Backend::DirectVulkan;
|
||||
const auto none = DirectGLES::BuildAdvertisedExtensions(false, false, false, false, false, false);
|
||||
EXPECT_FALSE(contains(none, MobileGL::E_GL_OVR_multiview));
|
||||
EXPECT_FALSE(contains(none, MobileGL::E_GL_OVR_multiview2));
|
||||
|
||||
const auto first =
|
||||
DirectGLES::BuildAdvertisedExtensions(false, false, false, false, false, false, {.Multiview = true});
|
||||
EXPECT_TRUE(contains(first, MobileGL::E_GL_OVR_multiview));
|
||||
EXPECT_FALSE(contains(first, MobileGL::E_GL_OVR_multiview2));
|
||||
|
||||
const auto both = DirectGLES::BuildAdvertisedExtensions(false, false, false, false, false, false,
|
||||
{.Multiview = true, .Multiview2 = true});
|
||||
EXPECT_TRUE(contains(both, MobileGL::E_GL_OVR_multiview));
|
||||
EXPECT_TRUE(contains(both, MobileGL::E_GL_OVR_multiview2));
|
||||
|
||||
// The second string never stands without the first, whatever the flags say.
|
||||
const auto secondOnly =
|
||||
DirectGLES::BuildAdvertisedExtensions(false, false, false, false, false, false, {.Multiview2 = true});
|
||||
EXPECT_FALSE(contains(secondOnly, MobileGL::E_GL_OVR_multiview2));
|
||||
|
||||
const auto vulkanNone = DirectVulkan::BuildAdvertisedExtensions(false, false, false, false, false);
|
||||
EXPECT_FALSE(contains(vulkanNone, MobileGL::E_GL_OVR_multiview));
|
||||
EXPECT_FALSE(contains(vulkanNone, MobileGL::E_GL_OVR_multiview2));
|
||||
const auto vulkan = DirectVulkan::BuildAdvertisedExtensions(false, false, false, false, false,
|
||||
{.Multiview = true, .Multiview2 = true});
|
||||
EXPECT_TRUE(contains(vulkan, MobileGL::E_GL_OVR_multiview));
|
||||
EXPECT_TRUE(contains(vulkan, MobileGL::E_GL_OVR_multiview2));
|
||||
}
|
||||
|
||||
// Minecraft 26.3 checks ARB_draw_indirect before it considers the already-advertised
|
||||
// ARB_multi_draw_indirect, then separately requires ARB_base_instance before enabling its terrain
|
||||
// indirect path. Pin both strings and, just as importantly, the non-zero firstInstance gate.
|
||||
|
||||
@@ -11,7 +11,6 @@ cmake_minimum_required(VERSION 3.14)
|
||||
add_executable(
|
||||
FramebufferTest
|
||||
FramebufferTest.cpp
|
||||
FramebufferMultiviewTest.cpp
|
||||
)
|
||||
|
||||
target_include_directories(FramebufferTest PRIVATE
|
||||
|
||||
@@ -1,246 +0,0 @@
|
||||
// MobileGL - MobileGL/MG_Test/Framebuffer/FramebufferMultiviewTest.cpp
|
||||
// Copyright (c) 2025-2026 MobileGL-Dev
|
||||
// Licensed under the GNU Lesser General Public License v3.0:
|
||||
// https://www.gnu.org/licenses/gpl-3.0.txt
|
||||
// https://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
// SPDX-License-Identifier: LGPL-3.0-only
|
||||
// End of Source File Header
|
||||
|
||||
// GL_OVR_multiview on the frontend: the attach errors, both completeness rules, the attachment
|
||||
// queries, GL_MAX_VIEWS_OVR and the read-side refusal, against a backend whose GL_MAX_VIEWS_OVR the
|
||||
// test chooses. None of it reaches a driver.
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "Includes.h"
|
||||
#include "Init.h"
|
||||
#include <MG_Backend/BackendObjects.h>
|
||||
#include <MG_Impl/GLImpl/Framebuffer/GL_Framebuffer.h>
|
||||
#include <MG_Impl/GLImpl/Getter/GL_Getter.h>
|
||||
#include <MG_Impl/GLImpl/Texture/GL_Texture.h>
|
||||
#include <MG_State/GLState/Core.h>
|
||||
|
||||
using namespace MobileGL;
|
||||
|
||||
namespace {
|
||||
class MultiviewLimitsBackend final : public MG_Backend::BackendObject {
|
||||
public:
|
||||
explicit MultiviewLimitsBackend(Int maxViews) {
|
||||
m_params.MaxViews = maxViews;
|
||||
m_params.MaxArrayTextureLayers = 8;
|
||||
}
|
||||
|
||||
void Initialize() override {}
|
||||
Bool InitCapabilities() override { return true; }
|
||||
Bool InitWindowSurface() override { return true; }
|
||||
const RendererInfo& GetRendererInfo() const override {
|
||||
static RendererInfo info = {};
|
||||
return info;
|
||||
}
|
||||
String GetBackendAPIVersionString() const override { return {}; }
|
||||
const MG_Backend::GlobalBackendFunctionsTable& GetBackendFunctions() const override {
|
||||
static MG_Backend::GlobalBackendFunctionsTable table = {};
|
||||
return table;
|
||||
}
|
||||
const MG_Backend::DynamicBackendParameters& GetDynamicParameters() const override { return m_params; }
|
||||
BackendType GetBackendType() const override { return BackendType::Unknown; }
|
||||
|
||||
private:
|
||||
MG_Backend::DynamicBackendParameters m_params{};
|
||||
};
|
||||
|
||||
class ScopedMultiviewBackend {
|
||||
public:
|
||||
explicit ScopedMultiviewBackend(Int maxViews) : m_previous(Move(MG_Backend::pActiveBackendObject)) {
|
||||
MG_Backend::pActiveBackendObject = MakeUnique<MultiviewLimitsBackend>(maxViews);
|
||||
}
|
||||
~ScopedMultiviewBackend() { MG_Backend::pActiveBackendObject = Move(m_previous); }
|
||||
|
||||
private:
|
||||
UniquePtr<MG_Backend::BackendObject> m_previous;
|
||||
};
|
||||
|
||||
GLuint MakeArrayTexture(GLsizei layers) {
|
||||
GLuint texture = 0;
|
||||
MG_Impl::GLImpl::CreateTextures(GL_TEXTURE_2D_ARRAY, 1, &texture);
|
||||
MG_Impl::GLImpl::TextureStorage3D(texture, 1, GL_RGBA8, 4, 4, layers);
|
||||
return texture;
|
||||
}
|
||||
|
||||
GLint AttachmentParameter(GLuint framebuffer, GLenum attachment, GLenum pname) {
|
||||
GLint value = -1;
|
||||
MG_Impl::GLImpl::GetNamedFramebufferAttachmentParameteriv(framebuffer, attachment, pname, &value);
|
||||
return value;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
class FramebufferMultiviewTest : public ::testing::Test {
|
||||
protected:
|
||||
void SetUp() override {
|
||||
MobileGL::Initialize();
|
||||
for (Int drained = 0; drained < 16 && MG_Impl::GLImpl::GetError() != GL_NO_ERROR; ++drained) {}
|
||||
m_defaultFramebuffer = MG_State::pGLContext->GetFramebufferObject(0);
|
||||
ASSERT_NE(m_defaultFramebuffer, nullptr);
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
MG_State::pGLContext->GetFramebufferBindingSlot(FramebufferTarget::Read).Bind(m_defaultFramebuffer);
|
||||
MG_State::pGLContext->GetFramebufferBindingSlot(FramebufferTarget::Draw).Bind(m_defaultFramebuffer);
|
||||
EXPECT_EQ(MG_Impl::GLImpl::GetError(), GL_NO_ERROR) << "test left an unconsumed GL error behind";
|
||||
}
|
||||
|
||||
static void ExpectSingleGlError(GLenum expected) {
|
||||
EXPECT_EQ(MG_Impl::GLImpl::GetError(), expected);
|
||||
EXPECT_EQ(MG_Impl::GLImpl::GetError(), GL_NO_ERROR) << "the call recorded more than one error";
|
||||
}
|
||||
|
||||
SharedPtr<MG_State::GLState::FramebufferObject> m_defaultFramebuffer;
|
||||
};
|
||||
|
||||
TEST_F(FramebufferMultiviewTest, WithoutBackendMultiviewTheEntryPointsAndTokensAreRefused) {
|
||||
ScopedMultiviewBackend backend(0);
|
||||
GLuint framebuffer = 0;
|
||||
MG_Impl::GLImpl::CreateFramebuffers(1, &framebuffer);
|
||||
const GLuint texture = MakeArrayTexture(2);
|
||||
|
||||
MG_Impl::GLImpl::NamedFramebufferTextureMultiviewOVR(framebuffer, GL_COLOR_ATTACHMENT0, texture, 0, 0, 2);
|
||||
ExpectSingleGlError(GL_INVALID_OPERATION);
|
||||
EXPECT_FALSE(MG_State::pGLContext->GetFramebufferObject(framebuffer)
|
||||
->GetAttachment(FramebufferAttachmentType::Color0)
|
||||
.IsTexture());
|
||||
|
||||
GLint maxViews = -1;
|
||||
MG_Impl::GLImpl::GetIntegerv(GL_MAX_VIEWS_OVR, &maxViews);
|
||||
ExpectSingleGlError(GL_INVALID_ENUM);
|
||||
|
||||
MG_Impl::GLImpl::NamedFramebufferTextureLayer(framebuffer, GL_COLOR_ATTACHMENT0, texture, 0, 0);
|
||||
EXPECT_EQ(MG_Impl::GLImpl::GetError(), GL_NO_ERROR);
|
||||
AttachmentParameter(framebuffer, GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_NUM_VIEWS_OVR);
|
||||
ExpectSingleGlError(GL_INVALID_ENUM);
|
||||
}
|
||||
|
||||
TEST_F(FramebufferMultiviewTest, AttachesViewsOfAnArrayTextureAndAnswersTheQueries) {
|
||||
ScopedMultiviewBackend backend(4);
|
||||
GLint maxViews = -1;
|
||||
MG_Impl::GLImpl::GetIntegerv(GL_MAX_VIEWS_OVR, &maxViews);
|
||||
EXPECT_EQ(maxViews, 4);
|
||||
|
||||
GLuint framebuffer = 0;
|
||||
MG_Impl::GLImpl::CreateFramebuffers(1, &framebuffer);
|
||||
const GLuint texture = MakeArrayTexture(4);
|
||||
MG_Impl::GLImpl::NamedFramebufferTextureMultiviewOVR(framebuffer, GL_COLOR_ATTACHMENT0, texture, 0, 1, 2);
|
||||
ASSERT_EQ(MG_Impl::GLImpl::GetError(), GL_NO_ERROR);
|
||||
|
||||
const auto framebufferObject = MG_State::pGLContext->GetFramebufferObject(framebuffer);
|
||||
const auto& attachment = framebufferObject->GetAttachment(FramebufferAttachmentType::Color0);
|
||||
EXPECT_TRUE(attachment.IsMultiview());
|
||||
EXPECT_EQ(attachment.GetNumViews(), 2);
|
||||
EXPECT_FALSE(attachment.IsLayered());
|
||||
EXPECT_EQ(framebufferObject->GetViewCount(), 2);
|
||||
|
||||
EXPECT_EQ(AttachmentParameter(framebuffer, GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_NUM_VIEWS_OVR),
|
||||
2);
|
||||
EXPECT_EQ(
|
||||
AttachmentParameter(framebuffer, GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_BASE_VIEW_INDEX_OVR),
|
||||
1);
|
||||
EXPECT_EQ(AttachmentParameter(framebuffer, GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER), 1);
|
||||
EXPECT_EQ(MG_Impl::GLImpl::CheckNamedFramebufferStatus(framebuffer, GL_DRAW_FRAMEBUFFER),
|
||||
static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE));
|
||||
|
||||
// A plain layer attachment is not multiview, and says so. Layer 0, the one every backend backs.
|
||||
MG_Impl::GLImpl::NamedFramebufferTextureLayer(framebuffer, GL_COLOR_ATTACHMENT0, texture, 0, 0);
|
||||
ASSERT_EQ(MG_Impl::GLImpl::GetError(), GL_NO_ERROR);
|
||||
EXPECT_EQ(AttachmentParameter(framebuffer, GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_NUM_VIEWS_OVR),
|
||||
0);
|
||||
EXPECT_EQ(framebufferObject->GetViewCount(), 1);
|
||||
|
||||
// Texture 0 detaches.
|
||||
MG_Impl::GLImpl::NamedFramebufferTextureMultiviewOVR(framebuffer, GL_COLOR_ATTACHMENT0, 0, 0, 0, 2);
|
||||
EXPECT_EQ(MG_Impl::GLImpl::GetError(), GL_NO_ERROR);
|
||||
EXPECT_FALSE(framebufferObject->GetAttachment(FramebufferAttachmentType::Color0).IsTexture());
|
||||
}
|
||||
|
||||
TEST_F(FramebufferMultiviewTest, AttachRefusesWhatTheSpecRefuses) {
|
||||
ScopedMultiviewBackend backend(4);
|
||||
GLuint framebuffer = 0;
|
||||
MG_Impl::GLImpl::CreateFramebuffers(1, &framebuffer);
|
||||
const GLuint arrayTexture = MakeArrayTexture(8);
|
||||
GLuint texture2D = 0;
|
||||
MG_Impl::GLImpl::CreateTextures(GL_TEXTURE_2D, 1, &texture2D);
|
||||
MG_Impl::GLImpl::TextureStorage2D(texture2D, 1, GL_RGBA8, 4, 4);
|
||||
|
||||
MG_Impl::GLImpl::NamedFramebufferTextureMultiviewOVR(framebuffer, GL_COLOR_ATTACHMENT0, arrayTexture, 0, 0, 0);
|
||||
ExpectSingleGlError(GL_INVALID_VALUE);
|
||||
MG_Impl::GLImpl::NamedFramebufferTextureMultiviewOVR(framebuffer, GL_COLOR_ATTACHMENT0, arrayTexture, 0, 0, 5);
|
||||
ExpectSingleGlError(GL_INVALID_VALUE);
|
||||
// The view count is checked even when detaching.
|
||||
MG_Impl::GLImpl::NamedFramebufferTextureMultiviewOVR(framebuffer, GL_COLOR_ATTACHMENT0, 0, 0, 0, 0);
|
||||
ExpectSingleGlError(GL_INVALID_VALUE);
|
||||
MG_Impl::GLImpl::NamedFramebufferTextureMultiviewOVR(framebuffer, GL_COLOR_ATTACHMENT0, texture2D, 0, 0, 2);
|
||||
ExpectSingleGlError(GL_INVALID_OPERATION);
|
||||
MG_Impl::GLImpl::NamedFramebufferTextureMultiviewOVR(framebuffer, GL_COLOR_ATTACHMENT0, arrayTexture, 0, -1, 2);
|
||||
ExpectSingleGlError(GL_INVALID_VALUE);
|
||||
// GL_MAX_ARRAY_TEXTURE_LAYERS is 8: views 7 and 8 do not both exist.
|
||||
MG_Impl::GLImpl::NamedFramebufferTextureMultiviewOVR(framebuffer, GL_COLOR_ATTACHMENT0, arrayTexture, 0, 7, 2);
|
||||
ExpectSingleGlError(GL_INVALID_VALUE);
|
||||
MG_Impl::GLImpl::NamedFramebufferTextureMultiviewOVR(framebuffer, GL_COLOR_ATTACHMENT0, arrayTexture, 0, 6, 2);
|
||||
EXPECT_EQ(MG_Impl::GLImpl::GetError(), GL_NO_ERROR);
|
||||
|
||||
// The default framebuffer has no attachment points to name.
|
||||
MG_State::pGLContext->GetFramebufferBindingSlot(FramebufferTarget::Draw).Bind(m_defaultFramebuffer);
|
||||
MG_Impl::GLImpl::FramebufferTextureMultiviewOVR(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, arrayTexture, 0, 0, 2);
|
||||
ExpectSingleGlError(GL_INVALID_OPERATION);
|
||||
}
|
||||
|
||||
TEST_F(FramebufferMultiviewTest, CompletenessNeedsEveryViewAndOneViewCount) {
|
||||
ScopedMultiviewBackend backend(4);
|
||||
const GLuint fourLayers = MakeArrayTexture(4);
|
||||
const GLuint otherFourLayers = MakeArrayTexture(4);
|
||||
|
||||
GLuint pastTheEnd = 0;
|
||||
MG_Impl::GLImpl::CreateFramebuffers(1, &pastTheEnd);
|
||||
MG_Impl::GLImpl::NamedFramebufferTextureMultiviewOVR(pastTheEnd, GL_COLOR_ATTACHMENT0, fourLayers, 0, 3, 2);
|
||||
EXPECT_EQ(MG_Impl::GLImpl::GetError(), GL_NO_ERROR) << "the layer count is a completeness question";
|
||||
EXPECT_EQ(MG_Impl::GLImpl::CheckNamedFramebufferStatus(pastTheEnd, GL_DRAW_FRAMEBUFFER),
|
||||
static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT));
|
||||
|
||||
GLuint mixed = 0;
|
||||
MG_Impl::GLImpl::CreateFramebuffers(1, &mixed);
|
||||
MG_Impl::GLImpl::NamedFramebufferTextureMultiviewOVR(mixed, GL_COLOR_ATTACHMENT0, fourLayers, 0, 0, 2);
|
||||
MG_Impl::GLImpl::NamedFramebufferTextureLayer(mixed, GL_COLOR_ATTACHMENT1, otherFourLayers, 0, 0);
|
||||
EXPECT_EQ(MG_Impl::GLImpl::CheckNamedFramebufferStatus(mixed, GL_DRAW_FRAMEBUFFER),
|
||||
static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_VIEW_TARGETS_OVR));
|
||||
|
||||
GLuint differentCounts = 0;
|
||||
MG_Impl::GLImpl::CreateFramebuffers(1, &differentCounts);
|
||||
MG_Impl::GLImpl::NamedFramebufferTextureMultiviewOVR(differentCounts, GL_COLOR_ATTACHMENT0, fourLayers, 0, 0, 2);
|
||||
MG_Impl::GLImpl::NamedFramebufferTextureMultiviewOVR(differentCounts, GL_COLOR_ATTACHMENT1, otherFourLayers, 0, 0,
|
||||
3);
|
||||
EXPECT_EQ(MG_Impl::GLImpl::CheckNamedFramebufferStatus(differentCounts, GL_DRAW_FRAMEBUFFER),
|
||||
static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_VIEW_TARGETS_OVR));
|
||||
|
||||
// Matching counts with different base views are fine.
|
||||
GLuint matching = 0;
|
||||
MG_Impl::GLImpl::CreateFramebuffers(1, &matching);
|
||||
MG_Impl::GLImpl::NamedFramebufferTextureMultiviewOVR(matching, GL_COLOR_ATTACHMENT0, fourLayers, 0, 0, 2);
|
||||
MG_Impl::GLImpl::NamedFramebufferTextureMultiviewOVR(matching, GL_COLOR_ATTACHMENT1, otherFourLayers, 0, 2, 2);
|
||||
EXPECT_EQ(MG_Impl::GLImpl::CheckNamedFramebufferStatus(matching, GL_DRAW_FRAMEBUFFER),
|
||||
static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE));
|
||||
EXPECT_EQ(MG_Impl::GLImpl::GetError(), GL_NO_ERROR);
|
||||
}
|
||||
|
||||
TEST_F(FramebufferMultiviewTest, AReadFramebufferWithSeveralViewsCannotBeRead) {
|
||||
ScopedMultiviewBackend backend(4);
|
||||
GLuint framebuffer = 0;
|
||||
MG_Impl::GLImpl::CreateFramebuffers(1, &framebuffer);
|
||||
MG_Impl::GLImpl::NamedFramebufferTextureMultiviewOVR(framebuffer, GL_COLOR_ATTACHMENT0, MakeArrayTexture(2), 0, 0,
|
||||
2);
|
||||
ASSERT_EQ(MG_Impl::GLImpl::GetError(), GL_NO_ERROR);
|
||||
MG_State::pGLContext->GetFramebufferBindingSlot(FramebufferTarget::Read)
|
||||
.Bind(MG_State::pGLContext->GetFramebufferObject(framebuffer));
|
||||
|
||||
Uint8 pixels[4 * 4 * 4] = {};
|
||||
MG_Impl::GLImpl::ReadPixels(0, 0, 4, 4, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
|
||||
ExpectSingleGlError(GL_INVALID_FRAMEBUFFER_OPERATION);
|
||||
MG_Impl::GLImpl::BlitFramebuffer(0, 0, 4, 4, 0, 0, 4, 4, GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
||||
ExpectSingleGlError(GL_INVALID_FRAMEBUFFER_OPERATION);
|
||||
}
|
||||
@@ -45,7 +45,6 @@ endif()
|
||||
add_executable(
|
||||
ProgramTest
|
||||
ProgramTest.cpp
|
||||
ProgramMultiviewTest.cpp
|
||||
)
|
||||
|
||||
add_executable(
|
||||
|
||||
@@ -165,7 +165,6 @@ namespace {
|
||||
link.gsOutputPrimitive = GL_TRIANGLE_STRIP;
|
||||
link.gsMaxVertices = 12;
|
||||
link.gsInvocations = 2;
|
||||
link.vsNumViews = 2;
|
||||
link.tessGenMode = GL_QUADS;
|
||||
link.tessGenSpacing = GL_FRACTIONAL_ODD;
|
||||
link.tessGenVertexOrder = GL_CW;
|
||||
@@ -530,9 +529,9 @@ TEST(ProgramArtifactsCodec, AVersionMismatchIsRefused) {
|
||||
// no archive owns. A codec arm for it would be a use-after-free waiting for a cache hit.
|
||||
TEST(ProgramArtifactsCodec, TheTablesVisitEveryMemberExceptTheLiveProgram) {
|
||||
// P7 OQ-8: 59 members, 58 visited. The 59th is still the live TProgram; the 58th is
|
||||
// storageBlocks, which follows the record arm's guard (ProgramArtifacts.h). esOrigin and
|
||||
// vsNumViews then made it 61 visited.
|
||||
EXPECT_EQ(ProgramArtifactsVisitedFieldCount<LinkArtifacts>(), 61u);
|
||||
// storageBlocks, which follows the record arm's guard (ProgramArtifacts.h). esOrigin then
|
||||
// made it 60 and 59.
|
||||
EXPECT_EQ(ProgramArtifactsVisitedFieldCount<LinkArtifacts>(), 60u);
|
||||
EXPECT_EQ(ProgramArtifactsVisitedFieldCount<StorageBlockReflection>(), 3u);
|
||||
EXPECT_EQ(ProgramArtifactsVisitedFieldCount<SpirvArtifacts>(), 10u);
|
||||
EXPECT_EQ(ProgramArtifactsVisitedFieldCount<ResourceReflection>(), 14u);
|
||||
@@ -554,7 +553,7 @@ TEST(ProgramArtifactsCodec, PortableHeaderUsesWireSchemaRatherThanNativeContaine
|
||||
// too - it is derived from the VisitFields tables - and so did `wireFingerprint`, which is
|
||||
// what makes a mixed-version pair refuse at the handshake instead of at the first program.
|
||||
EXPECT_EQ(version, kProgramArtifactsCodecVersion);
|
||||
EXPECT_EQ(version, 4u);
|
||||
EXPECT_EQ(version, 3u);
|
||||
EXPECT_EQ(schema, ProgramArtifactsSchemaFingerprint());
|
||||
EXPECT_NE(schema, 0u);
|
||||
EXPECT_NE(schema, sizeof(LinkArtifacts));
|
||||
|
||||
@@ -84,7 +84,7 @@ namespace {
|
||||
// P7 OQ-8 added LinkArtifacts::storageBlocks and its own three-field table; since P13 W5
|
||||
// the member follows the record arm (ProgramArtifacts.h), which every library builds.
|
||||
EXPECT_EQ(CountFields<StorageBlockReflection>(), 3u);
|
||||
EXPECT_EQ(CountFields<LinkArtifacts>(), 61u);
|
||||
EXPECT_EQ(CountFields<LinkArtifacts>(), 60u);
|
||||
EXPECT_EQ(CountFields<SpirvArtifacts>(), 10u);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,210 +0,0 @@
|
||||
// MobileGL - MobileGL/MG_Test/Program/ProgramMultiviewTest.cpp
|
||||
// Copyright (c) 2026 MobileGL-Dev
|
||||
// Licensed under the GNU Lesser General Public License v3.0:
|
||||
// https://www.gnu.org/licenses/gpl-3.0.txt
|
||||
// https://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
// SPDX-License-Identifier: LGPL-3.0-only
|
||||
// End of Source File Header
|
||||
|
||||
// GL_OVR_multiview through the GL compile and link entry points: the vertex stage's num_views
|
||||
// reaches the program (and survives a link memo hit), GL_MAX_VIEWS_OVR bounds it, the shading
|
||||
// language extension and its macros exist only where the backend advertises the extension, and
|
||||
// the draw-time rule compares the program with the draw framebuffer.
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "Includes.h"
|
||||
#include "Init.h"
|
||||
#include "MG_Backend/BackendObjects.h"
|
||||
#include "MG_Impl/GLImpl/Framebuffer/GL_Framebuffer.h"
|
||||
#include "MG_Impl/GLImpl/Getter/GL_Getter.h"
|
||||
#include "MG_Impl/GLImpl/Program/GL_Program.h"
|
||||
#include "MG_Impl/GLImpl/Texture/GL_Texture.h"
|
||||
#include "MG_State/GLState/Core.h"
|
||||
|
||||
using namespace MobileGL;
|
||||
using namespace MobileGL::MG_Impl::GLImpl;
|
||||
|
||||
namespace {
|
||||
// A backend that claims a type, so the compile environment gates extensions against its list.
|
||||
class MultiviewProgramBackend final : public MG_Backend::BackendObject {
|
||||
public:
|
||||
MultiviewProgramBackend(Int maxViews, Vector<GLExtension> extensions) {
|
||||
m_params.MaxViews = maxViews;
|
||||
m_params.MaxArrayTextureLayers = 8;
|
||||
m_info.RendererGLInfo.Extensions = Move(extensions);
|
||||
}
|
||||
void Initialize() override {}
|
||||
Bool InitCapabilities() override { return true; }
|
||||
Bool InitWindowSurface() override { return true; }
|
||||
const RendererInfo& GetRendererInfo() const override { return m_info; }
|
||||
String GetBackendAPIVersionString() const override { return {}; }
|
||||
const MG_Backend::GlobalBackendFunctionsTable& GetBackendFunctions() const override {
|
||||
static MG_Backend::GlobalBackendFunctionsTable table = {};
|
||||
return table;
|
||||
}
|
||||
const MG_Backend::DynamicBackendParameters& GetDynamicParameters() const override { return m_params; }
|
||||
BackendType GetBackendType() const override { return BackendType::DirectGLES; }
|
||||
|
||||
private:
|
||||
MG_Backend::DynamicBackendParameters m_params{};
|
||||
RendererInfo m_info{};
|
||||
};
|
||||
|
||||
class ScopedProgramBackend {
|
||||
public:
|
||||
ScopedProgramBackend(Int maxViews, Vector<GLExtension> extensions)
|
||||
: m_previous(Move(MG_Backend::pActiveBackendObject)) {
|
||||
MG_Backend::pActiveBackendObject = MakeUnique<MultiviewProgramBackend>(maxViews, Move(extensions));
|
||||
// The context re-captures its compile environment when the backend's address changes,
|
||||
// and a freshly allocated mock can land on the address the previous one had.
|
||||
MG_State::pGLContext->InvalidateCompileEnv();
|
||||
}
|
||||
~ScopedProgramBackend() {
|
||||
MG_Backend::pActiveBackendObject = Move(m_previous);
|
||||
MG_State::pGLContext->InvalidateCompileEnv();
|
||||
}
|
||||
|
||||
private:
|
||||
UniquePtr<MG_Backend::BackendObject> m_previous;
|
||||
};
|
||||
|
||||
const Vector<GLExtension> kBothExtensions = {E_GL_OVR_multiview, E_GL_OVR_multiview2};
|
||||
|
||||
GLuint CompiledShader(GLenum type, const char* source, GLint& status) {
|
||||
const GLuint shader = CreateShader(type);
|
||||
ShaderSource(shader, 1, &source, nullptr);
|
||||
CompileShader(shader);
|
||||
GetShaderiv(shader, GL_COMPILE_STATUS, &status);
|
||||
return shader;
|
||||
}
|
||||
|
||||
Bool Compiles(GLenum type, const char* source) {
|
||||
GLint status = GL_FALSE;
|
||||
CompiledShader(type, source, status);
|
||||
return status == GL_TRUE;
|
||||
}
|
||||
|
||||
// The linked program, or 0 when it did not link.
|
||||
GLuint LinkedProgram(const char* vertex, const char* fragment) {
|
||||
GLint status = GL_FALSE;
|
||||
const GLuint vs = CompiledShader(GL_VERTEX_SHADER, vertex, status);
|
||||
EXPECT_EQ(status, GL_TRUE);
|
||||
const GLuint fs = CompiledShader(GL_FRAGMENT_SHADER, fragment, status);
|
||||
EXPECT_EQ(status, GL_TRUE);
|
||||
const GLuint program = CreateProgram();
|
||||
AttachShader(program, vs);
|
||||
AttachShader(program, fs);
|
||||
LinkProgram(program);
|
||||
GetProgramiv(program, GL_LINK_STATUS, &status);
|
||||
return status == GL_TRUE ? program : 0;
|
||||
}
|
||||
|
||||
String MultiviewVertex(Int numViews) {
|
||||
return std::format("#version 330 core\n"
|
||||
"#extension GL_OVR_multiview2 : require\n"
|
||||
"layout(num_views = {}) in;\n"
|
||||
"layout(location = 0) in vec2 pos;\n"
|
||||
"void main() {{ gl_Position = vec4(pos.x + float(gl_ViewID_OVR), pos.y, 0.0, 1.0); }}\n",
|
||||
numViews);
|
||||
}
|
||||
|
||||
constexpr const char* kFragment = "#version 330 core\n"
|
||||
"out vec4 color;\n"
|
||||
"void main() { color = vec4(1.0); }\n";
|
||||
} // namespace
|
||||
|
||||
class ProgramMultiviewTest : public ::testing::Test {
|
||||
protected:
|
||||
void SetUp() override {
|
||||
MobileGL::Initialize();
|
||||
for (Int drained = 0; drained < 16 && GetError() != GL_NO_ERROR; ++drained) {}
|
||||
}
|
||||
void TearDown() override { EXPECT_EQ(GetError(), GL_NO_ERROR) << "test left an unconsumed GL error behind"; }
|
||||
};
|
||||
|
||||
TEST_F(ProgramMultiviewTest, TheVertexStagesNumViewsReachesTheProgramAndSurvivesAMemoHit) {
|
||||
const ScopedProgramBackend backend(4, kBothExtensions);
|
||||
const String vertex = MultiviewVertex(3);
|
||||
for (Int link = 0; link < 2; ++link) {
|
||||
const GLuint program = LinkedProgram(vertex.c_str(), kFragment);
|
||||
ASSERT_NE(program, 0u) << "link " << link;
|
||||
const auto programObject = MG_State::pGLContext->GetProgramObject(program);
|
||||
ASSERT_NE(programObject, nullptr);
|
||||
EXPECT_EQ(programObject->GetMultiviewViewCount(), 3) << "link " << link;
|
||||
}
|
||||
|
||||
const GLuint plain = LinkedProgram("#version 330 core\nvoid main() { gl_Position = vec4(0.0); }\n", kFragment);
|
||||
ASSERT_NE(plain, 0u);
|
||||
EXPECT_EQ(MG_State::pGLContext->GetProgramObject(plain)->GetMultiviewViewCount(), 1);
|
||||
}
|
||||
|
||||
TEST_F(ProgramMultiviewTest, MoreViewsThanTheBackendHasFailsTheLink) {
|
||||
const ScopedProgramBackend backend(4, kBothExtensions);
|
||||
const String vertex = MultiviewVertex(5);
|
||||
EXPECT_EQ(LinkedProgram(vertex.c_str(), kFragment), 0u);
|
||||
}
|
||||
|
||||
TEST_F(ProgramMultiviewTest, TheShadingLanguageExtensionFollowsTheAdvertisement) {
|
||||
constexpr const char* kRequireFirst = "#version 330 core\n#extension GL_OVR_multiview : require\n"
|
||||
"void main() { gl_Position = vec4(float(gl_ViewID_OVR)); }\n";
|
||||
constexpr const char* kRequireSecond = "#version 330 core\n#extension GL_OVR_multiview2 : require\n"
|
||||
"void main() { gl_Position = vec4(float(gl_ViewID_OVR)); }\n";
|
||||
constexpr const char* kMacroAbsent = "#version 330 core\n#if defined(GL_OVR_multiview) || "
|
||||
"defined(GL_OVR_multiview2)\n#error the macro is defined\n#endif\n"
|
||||
"void main() { gl_Position = vec4(0.0); }\n";
|
||||
constexpr const char* kMacroPresent = "#version 330 core\n#ifndef GL_OVR_multiview\n#error the macro is "
|
||||
"missing\n#endif\nvoid main() { gl_Position = vec4(0.0); }\n";
|
||||
{
|
||||
const ScopedProgramBackend backend(0, {});
|
||||
EXPECT_FALSE(Compiles(GL_VERTEX_SHADER, kRequireFirst));
|
||||
EXPECT_FALSE(Compiles(GL_VERTEX_SHADER, kRequireSecond));
|
||||
EXPECT_TRUE(Compiles(GL_VERTEX_SHADER, kMacroAbsent));
|
||||
}
|
||||
{
|
||||
const ScopedProgramBackend backend(4, {E_GL_OVR_multiview});
|
||||
EXPECT_TRUE(Compiles(GL_VERTEX_SHADER, kRequireFirst));
|
||||
EXPECT_FALSE(Compiles(GL_VERTEX_SHADER, kRequireSecond));
|
||||
EXPECT_TRUE(Compiles(GL_VERTEX_SHADER, kMacroPresent));
|
||||
}
|
||||
{
|
||||
const ScopedProgramBackend backend(4, kBothExtensions);
|
||||
EXPECT_TRUE(Compiles(GL_VERTEX_SHADER, kRequireFirst));
|
||||
EXPECT_TRUE(Compiles(GL_VERTEX_SHADER, kRequireSecond));
|
||||
EXPECT_TRUE(Compiles(GL_VERTEX_SHADER, kMacroPresent));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(ProgramMultiviewTest, ADrawNeedsTheProgramsViewCountInTheDrawFramebuffer) {
|
||||
const ScopedProgramBackend backend(4, kBothExtensions);
|
||||
const String vertex = MultiviewVertex(2);
|
||||
const GLuint multiviewProgram = LinkedProgram(vertex.c_str(), kFragment);
|
||||
const GLuint plainProgram =
|
||||
LinkedProgram("#version 330 core\nvoid main() { gl_Position = vec4(0.0); }\n", kFragment);
|
||||
ASSERT_NE(multiviewProgram, 0u);
|
||||
ASSERT_NE(plainProgram, 0u);
|
||||
const auto& multiview = *MG_State::pGLContext->GetProgramObject(multiviewProgram);
|
||||
const auto& plain = *MG_State::pGLContext->GetProgramObject(plainProgram);
|
||||
|
||||
auto& drawSlot = MG_State::pGLContext->GetFramebufferBindingSlot(FramebufferTarget::Draw);
|
||||
const auto previous = drawSlot.GetBoundObject();
|
||||
|
||||
// The default framebuffer has one view.
|
||||
drawSlot.Bind(MG_State::pGLContext->GetFramebufferObject(0));
|
||||
EXPECT_TRUE(ValidateMultiviewDraw(plain, "test"));
|
||||
EXPECT_FALSE(ValidateMultiviewDraw(multiview, "test"));
|
||||
EXPECT_EQ(GetError(), static_cast<GLenum>(GL_INVALID_OPERATION));
|
||||
|
||||
GLuint texture = 0;
|
||||
CreateTextures(GL_TEXTURE_2D_ARRAY, 1, &texture);
|
||||
TextureStorage3D(texture, 1, GL_RGBA8, 4, 4, 2);
|
||||
GLuint framebuffer = 0;
|
||||
CreateFramebuffers(1, &framebuffer);
|
||||
NamedFramebufferTextureMultiviewOVR(framebuffer, GL_COLOR_ATTACHMENT0, texture, 0, 0, 2);
|
||||
ASSERT_EQ(GetError(), static_cast<GLenum>(GL_NO_ERROR));
|
||||
drawSlot.Bind(MG_State::pGLContext->GetFramebufferObject(framebuffer));
|
||||
EXPECT_TRUE(ValidateMultiviewDraw(multiview, "test"));
|
||||
EXPECT_FALSE(ValidateMultiviewDraw(plain, "test"));
|
||||
EXPECT_EQ(GetError(), static_cast<GLenum>(GL_INVALID_OPERATION));
|
||||
|
||||
drawSlot.Bind(previous);
|
||||
}
|
||||
@@ -142,3 +142,9 @@ gtest_discover_tests(LogLevelTest DISCOVERY_TIMEOUT 30 PROPERTIES LABELS unit)
|
||||
gtest_discover_tests(PipeStatsTest DISCOVERY_TIMEOUT 30 PROPERTIES LABELS unit)
|
||||
gtest_discover_tests(DamageTest DISCOVERY_TIMEOUT 30 PROPERTIES LABELS unit)
|
||||
gtest_discover_tests(ConfigFileTest DISCOVERY_TIMEOUT 30 PROPERTIES LABELS unit)
|
||||
|
||||
# Sparse texture uploads: the packed staging page and the two-box split.
|
||||
add_executable(TextureUploadPackingTest TextureUploadPackingTest.cpp)
|
||||
target_include_directories(TextureUploadPackingTest PRIVATE ${MGL_ROOT}/include ${MGL_ROOT}/MobileGL)
|
||||
target_link_libraries(TextureUploadPackingTest PRIVATE MobileGLTestMain ${LINK_LIBRARIES})
|
||||
gtest_discover_tests(TextureUploadPackingTest DISCOVERY_TIMEOUT 30 PROPERTIES LABELS unit)
|
||||
@@ -0,0 +1,201 @@
|
||||
// MobileGL - MobileGL/MG_Test/Util/TextureUploadPackingTest.cpp
|
||||
// Copyright (c) 2025-2026 MobileGL-Dev
|
||||
// Licensed under the GNU Lesser General Public License v3.0:
|
||||
// https://www.gnu.org/licenses/gpl-3.0.txt
|
||||
// https://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
// SPDX-License-Identifier: LGPL-3.0-only
|
||||
// End of Source File Header
|
||||
|
||||
// The sparse texture upload helpers: the packed staging page and the two-box split.
|
||||
#include <gtest/gtest.h>
|
||||
#include <MG_Util/Texture/PackedTextureUpload.h>
|
||||
#include <MG_Util/Texture/TextureUploadBoxes.h>
|
||||
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <initializer_list>
|
||||
#include <vector>
|
||||
|
||||
namespace {
|
||||
namespace Packed = MobileGL::MG_Util::PackedTextureUpload;
|
||||
namespace Boxes = MobileGL::MG_Util::TextureUploadBoxes;
|
||||
|
||||
// A level shadow whose every texel names its own coordinates, so a copied row shows where
|
||||
// it came from.
|
||||
struct Level {
|
||||
int width, height;
|
||||
std::vector<std::uint8_t> texels;
|
||||
|
||||
Level(int w, int h) : width(w), height(h), texels(static_cast<std::size_t>(w) * h * Packed::BytesPerTexel) {
|
||||
for (int y = 0; y < h; ++y) {
|
||||
for (int x = 0; x < w; ++x) {
|
||||
std::uint8_t* texel = Texel(x, y);
|
||||
texel[0] = static_cast<std::uint8_t>(x);
|
||||
texel[1] = static_cast<std::uint8_t>(y);
|
||||
texel[2] = static_cast<std::uint8_t>(x >> 8);
|
||||
texel[3] = static_cast<std::uint8_t>(y >> 8);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::uint8_t* Texel(int x, int y) {
|
||||
return texels.data() + (static_cast<std::size_t>(y) * width + x) * Packed::BytesPerTexel;
|
||||
}
|
||||
|
||||
Packed::Region Region(int level, int x, int y, int w, int h) {
|
||||
return {Texel(x, y), static_cast<std::size_t>(width) * Packed::BytesPerTexel, level, x, y, w, h};
|
||||
}
|
||||
};
|
||||
|
||||
void AddRegion(Packed::Batch& batch, const Packed::Region& region) {
|
||||
batch.regions[batch.count++] = region;
|
||||
}
|
||||
|
||||
bool Overlap(const Packed::Point& a, const Packed::Region& ra, const Packed::Point& b, const Packed::Region& rb) {
|
||||
return a.x < b.x + rb.width && b.x < a.x + ra.width && a.y < b.y + rb.height && b.y < a.y + ra.height;
|
||||
}
|
||||
|
||||
void ExpectValidLayout(const Packed::Batch& batch) {
|
||||
ASSERT_GT(batch.width, 0);
|
||||
ASSERT_GT(batch.height, 0);
|
||||
EXPECT_LE(batch.width, Packed::PageSide);
|
||||
EXPECT_LE(batch.height, Packed::PageSide);
|
||||
for (std::size_t i = 0; i < batch.count; ++i) {
|
||||
const auto& region = batch.regions[i];
|
||||
const auto& offset = batch.offsets[i];
|
||||
EXPECT_GE(offset.x, 0);
|
||||
EXPECT_GE(offset.y, 0);
|
||||
EXPECT_LE(offset.x + region.width, batch.width) << "region " << i;
|
||||
EXPECT_LE(offset.y + region.height, batch.height) << "region " << i;
|
||||
for (std::size_t j = i + 1; j < batch.count; ++j) {
|
||||
EXPECT_FALSE(Overlap(offset, region, batch.offsets[j], batch.regions[j]))
|
||||
<< "regions " << i << " and " << j;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST(PackedTextureUpload, PacksScatteredSpritesWithoutOverlap) {
|
||||
Level mip0(512, 512);
|
||||
Level mip1(256, 256);
|
||||
Packed::Batch batch;
|
||||
AddRegion(batch, mip0.Region(0, 0, 0, 16, 16));
|
||||
AddRegion(batch, mip0.Region(0, 480, 32, 32, 16));
|
||||
AddRegion(batch, mip0.Region(0, 200, 400, 16, 32));
|
||||
AddRegion(batch, mip0.Region(0, 300, 300, 64, 64));
|
||||
AddRegion(batch, mip1.Region(1, 8, 8, 8, 8));
|
||||
AddRegion(batch, mip1.Region(1, 240, 240, 16, 16));
|
||||
|
||||
ASSERT_TRUE(Packed::Pack(batch, 512ull * 512 + 256ull * 256));
|
||||
ExpectValidLayout(batch);
|
||||
// Largest first, so the 64x64 sprite takes the page origin.
|
||||
EXPECT_EQ(batch.regions[0].width * batch.regions[0].height, 64 * 64);
|
||||
EXPECT_EQ(batch.offsets[0].x, 0);
|
||||
EXPECT_EQ(batch.offsets[0].y, 0);
|
||||
}
|
||||
|
||||
TEST(PackedTextureUpload, WritePageCopiesEachRegionToItsOffset) {
|
||||
Level mip0(512, 512);
|
||||
Packed::Batch batch;
|
||||
AddRegion(batch, mip0.Region(0, 3, 5, 7, 9));
|
||||
AddRegion(batch, mip0.Region(0, 400, 300, 20, 11));
|
||||
AddRegion(batch, mip0.Region(0, 260, 17, 13, 13));
|
||||
ASSERT_TRUE(Packed::Pack(batch, 512ull * 512));
|
||||
ExpectValidLayout(batch);
|
||||
|
||||
std::vector<std::uint8_t> page(batch.ByteSize(), 0xCD);
|
||||
Packed::WritePage(batch, page.data());
|
||||
const std::size_t pitch = static_cast<std::size_t>(batch.width) * Packed::BytesPerTexel;
|
||||
for (std::size_t i = 0; i < batch.count; ++i) {
|
||||
const auto& region = batch.regions[i];
|
||||
const auto& offset = batch.offsets[i];
|
||||
for (int y = 0; y < region.height; ++y) {
|
||||
for (int x = 0; x < region.width; ++x) {
|
||||
const std::uint8_t* texel =
|
||||
page.data() + (offset.y + y) * pitch + (offset.x + x) * Packed::BytesPerTexel;
|
||||
ASSERT_EQ(texel[0], static_cast<std::uint8_t>(region.x + x)) << "region " << i;
|
||||
ASSERT_EQ(texel[1], static_cast<std::uint8_t>(region.y + y)) << "region " << i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST(PackedTextureUpload, DeclinesBatchesThatSaveTooLittle) {
|
||||
Level mip0(512, 512);
|
||||
Packed::Batch single;
|
||||
AddRegion(single, mip0.Region(0, 0, 0, 16, 16));
|
||||
EXPECT_FALSE(Packed::Pack(single, 512ull * 512)) << "one region already uploads exactly";
|
||||
|
||||
Packed::Batch dense;
|
||||
AddRegion(dense, mip0.Region(0, 0, 0, 16, 16));
|
||||
AddRegion(dense, mip0.Region(0, 16, 0, 16, 16));
|
||||
EXPECT_FALSE(Packed::Pack(dense, 32ull * 16)) << "the union box is already small";
|
||||
}
|
||||
|
||||
TEST(PackedTextureUpload, DeclinesRegionsThatCannotFitThePage) {
|
||||
Level mip0(512, 512);
|
||||
Packed::Batch wide;
|
||||
AddRegion(wide, mip0.Region(0, 0, 0, Packed::PageSide + 1, 4));
|
||||
AddRegion(wide, mip0.Region(0, 300, 300, 4, 4));
|
||||
EXPECT_FALSE(Packed::Pack(wide, 512ull * 512));
|
||||
|
||||
Packed::Batch full;
|
||||
AddRegion(full, mip0.Region(0, 0, 0, Packed::PageSide, Packed::PageSide));
|
||||
AddRegion(full, mip0.Region(0, 256, 256, Packed::PageSide, Packed::PageSide));
|
||||
EXPECT_FALSE(Packed::Pack(full, 512ull * 512)) << "more dirty texels than one page holds";
|
||||
}
|
||||
|
||||
TEST(PackedTextureUpload, PacksTheMaximumRegionCount) {
|
||||
Level mip0(512, 512);
|
||||
Packed::Batch batch;
|
||||
for (std::size_t i = 0; i < Packed::MaxRegions; ++i) {
|
||||
const int size = 8 + static_cast<int>(i % 4) * 4;
|
||||
AddRegion(batch, mip0.Region(0, static_cast<int>(i) * 15, static_cast<int>(i) * 15, size, size));
|
||||
}
|
||||
ASSERT_TRUE(Packed::Pack(batch, 512ull * 512));
|
||||
ExpectValidLayout(batch);
|
||||
}
|
||||
|
||||
std::array<Boxes::Box, Boxes::MaxRegions> Regions(std::initializer_list<Boxes::Box> boxes) {
|
||||
std::array<Boxes::Box, Boxes::MaxRegions> regions{};
|
||||
std::size_t i = 0;
|
||||
for (const auto& box : boxes)
|
||||
regions[i++] = box;
|
||||
return regions;
|
||||
}
|
||||
|
||||
bool Contains(const Boxes::Box& outer, const Boxes::Box& inner) {
|
||||
return outer.left <= inner.left && outer.top <= inner.top && outer.right >= inner.right &&
|
||||
outer.bottom >= inner.bottom;
|
||||
}
|
||||
|
||||
TEST(TextureUploadBoxes, SplitsTwoSeparatedClusters) {
|
||||
const Boxes::Box a{0, 0, 16, 16}, b{20, 4, 36, 20}, c{400, 300, 416, 316}, d{420, 330, 436, 346};
|
||||
auto regions = Regions({c, a, d, b});
|
||||
const Boxes::Box bounds{0, 0, 436, 346};
|
||||
const auto split = Boxes::Split(bounds, regions, 4);
|
||||
ASSERT_TRUE(split.has_value());
|
||||
const auto& first = (*split)[0];
|
||||
const auto& second = (*split)[1];
|
||||
const bool firstHoldsLeft = Contains(first, a);
|
||||
const auto& left = firstHoldsLeft ? first : second;
|
||||
const auto& right = firstHoldsLeft ? second : first;
|
||||
EXPECT_TRUE(Contains(left, a) && Contains(left, b));
|
||||
EXPECT_TRUE(Contains(right, c) && Contains(right, d));
|
||||
EXPECT_LE(first.Texels() + second.Texels(), bounds.Texels() / 2);
|
||||
const bool disjoint = left.right <= right.left || left.bottom <= right.top;
|
||||
EXPECT_TRUE(disjoint);
|
||||
}
|
||||
|
||||
TEST(TextureUploadBoxes, KeepsOneBoxWhenNoCutSeparatesTheRegions) {
|
||||
// Overlapping regions along the diagonal: no cut on either axis separates two groups.
|
||||
auto regions = Regions({{0, 0, 100, 100}, {90, 90, 190, 190}, {180, 180, 280, 280}});
|
||||
EXPECT_FALSE(Boxes::Split({0, 0, 280, 280}, regions, 3).has_value());
|
||||
}
|
||||
|
||||
TEST(TextureUploadBoxes, SkipsSmallOrSingleRegionLevels) {
|
||||
EXPECT_FALSE(Boxes::WorthSearching({0, 0, 32, 32}, 4)) << "a small level keeps one job";
|
||||
EXPECT_FALSE(Boxes::WorthSearching({0, 0, 512, 512}, 1));
|
||||
EXPECT_FALSE(Boxes::WorthSearching({0, 0, 512, 512}, Boxes::MaxRegions + 1));
|
||||
EXPECT_TRUE(Boxes::WorthSearching({0, 0, 512, 512}, 2));
|
||||
}
|
||||
} // namespace
|
||||
@@ -665,7 +665,6 @@ namespace MobileGL::MG_Util::BackendLoader {
|
||||
INIT_GLES_FUNC_OPTIONAL(glPolygonModeNV)
|
||||
INIT_GLES_FUNC_OPTIONAL(glPolygonModeANGLE)
|
||||
INIT_GLES_FUNC_OPTIONAL(glClipControlEXT)
|
||||
INIT_GLES_FUNC_OPTIONAL(glFramebufferTextureMultiviewOVR)
|
||||
INIT_GLES_FUNC_OPTIONAL(glColorMaskiEXT)
|
||||
INIT_GLES_FUNC_OPTIONAL(glColorMaskiOES)
|
||||
INIT_GLES_FUNC_OPTIONAL(glPolygonOffsetClampEXT)
|
||||
@@ -1001,39 +1000,6 @@ namespace MobileGL::MG_Util::BackendLoader {
|
||||
}
|
||||
}
|
||||
|
||||
// GL_OVR_multiview and GL_OVR_multiview2: the strings, the entry point and GL_MAX_VIEWS_OVR. The
|
||||
// second extension only counts on top of the first, which is the one with the entry point.
|
||||
static void FillInMultiviewCapabilities(MG_External::GLESCapabilities& caps,
|
||||
const MG_External::GLESFunctionsTable& glesFuncs, GLint extCount) {
|
||||
Bool hasMultiview = false;
|
||||
Bool hasMultiview2 = false;
|
||||
for (GLint i = 0; i < extCount; ++i) {
|
||||
const char* extension = reinterpret_cast<const char*>(glesFuncs.glGetStringi(GL_EXTENSIONS, i));
|
||||
if (!extension) continue;
|
||||
if (std::strcmp(extension, "GL_OVR_multiview") == 0) hasMultiview = true;
|
||||
if (std::strcmp(extension, "GL_OVR_multiview2") == 0) hasMultiview2 = true;
|
||||
}
|
||||
caps.SupportsMultiview = hasMultiview && glesFuncs.glFramebufferTextureMultiviewOVR != nullptr;
|
||||
caps.MaxViews = 0;
|
||||
if (caps.SupportsMultiview) {
|
||||
GLint maxViews = 0;
|
||||
while (glesFuncs.glGetError() != GL_NO_ERROR) {}
|
||||
glesFuncs.glGetIntegerv(GL_MAX_VIEWS_OVR, &maxViews);
|
||||
// The spec minimum is 2. A driver that rejects the query or answers less cannot back
|
||||
// the extension, so it is reported absent rather than clamped up.
|
||||
if (glesFuncs.glGetError() != GL_NO_ERROR || maxViews < 2) {
|
||||
MGLOG_W("GL_OVR_multiview is advertised but GL_MAX_VIEWS_OVR answered %d; reporting no multiview",
|
||||
maxViews);
|
||||
caps.SupportsMultiview = false;
|
||||
} else {
|
||||
caps.MaxViews = maxViews;
|
||||
}
|
||||
}
|
||||
caps.SupportsMultiview2 = caps.SupportsMultiview && hasMultiview2;
|
||||
MGLOG_I(" multiview (OVR_multiview / OVR_multiview2): %s / %s, GL_MAX_VIEWS_OVR %d",
|
||||
caps.SupportsMultiview ? "yes" : "no", caps.SupportsMultiview2 ? "yes" : "no", caps.MaxViews);
|
||||
}
|
||||
|
||||
// Reads what the driver answers for GL_EXT_fragment_shading_rate once the extension strings have
|
||||
// been matched. The per-sample-count rate lists are folded into masks of the packed encoding
|
||||
// ((log2 w << 2) | log2 h), which is what crosses to the frontend.
|
||||
@@ -1372,7 +1338,6 @@ namespace MobileGL::MG_Util::BackendLoader {
|
||||
// The string AND the pointer: eglGetProcAddress may hand back a stub for a name the
|
||||
// driver does not implement.
|
||||
caps.SupportsClipControl = hasClipControlExtension && glesFuncs.glClipControlEXT != nullptr;
|
||||
FillInMultiviewCapabilities(caps, glesFuncs, extCount);
|
||||
caps.SupportsComputeShader = esAtLeast31 && glesFuncs.glDispatchCompute != nullptr &&
|
||||
glesFuncs.glMemoryBarrier != nullptr && glesFuncs.glCreateShader != nullptr &&
|
||||
glesFuncs.glCreateProgram != nullptr;
|
||||
|
||||
@@ -650,9 +650,6 @@ namespace MobileGL {
|
||||
GL_FUNC_TYPEDEF(void, glPolygonModeANGLE, GLenum face, GLenum mode)
|
||||
// GL_EXT_clip_control (ES has no core glClipControl).
|
||||
GL_FUNC_TYPEDEF(void, glClipControlEXT, GLenum origin, GLenum depth)
|
||||
// GL_OVR_multiview.
|
||||
GL_FUNC_TYPEDEF(void, glFramebufferTextureMultiviewOVR, GLenum target, GLenum attachment, GLuint texture,
|
||||
GLint level, GLint baseViewIndex, GLsizei numViews)
|
||||
GL_FUNC_TYPEDEF(void, glColorMaskiEXT, GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a)
|
||||
GL_FUNC_TYPEDEF(void, glColorMaskiOES, GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a)
|
||||
// GL_EXT_polygon_offset_clamp. ES has no core spelling at any version.
|
||||
@@ -1072,7 +1069,6 @@ namespace MobileGL {
|
||||
GL_FUNC_DECL(glPolygonModeNV)
|
||||
GL_FUNC_DECL(glPolygonModeANGLE)
|
||||
GL_FUNC_DECL(glClipControlEXT)
|
||||
GL_FUNC_DECL(glFramebufferTextureMultiviewOVR)
|
||||
GL_FUNC_DECL(glColorMaskiEXT)
|
||||
GL_FUNC_DECL(glColorMaskiOES)
|
||||
GL_FUNC_DECL(glPolygonOffsetClampEXT)
|
||||
@@ -1128,11 +1124,6 @@ namespace MobileGL {
|
||||
// GL_EXT_clip_control advertised and glClipControlEXT resolved: the driver applies a
|
||||
// clip-space origin and depth mode, so the application's glClipControl is forwarded.
|
||||
Bool SupportsClipControl = false;
|
||||
// GL_OVR_multiview advertised and glFramebufferTextureMultiviewOVR resolved, with
|
||||
// GL_MAX_VIEWS_OVR in MaxViews. GL_OVR_multiview2 only counts on top of it.
|
||||
Bool SupportsMultiview = false;
|
||||
Bool SupportsMultiview2 = false;
|
||||
Int MaxViews = 0;
|
||||
// GL_EXT_texture_view / GL_OES_texture_view: two ES texture names sharing one
|
||||
// storage, i.e. the only way DirectGLES can answer glTextureView at all. ES never
|
||||
// made this core - not even in 3.2 - so unlike every other capability here there is
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
#include "ShaderCompiler.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
#include <format>
|
||||
|
||||
#include <cmath>
|
||||
@@ -1571,41 +1570,6 @@ namespace MobileGL {
|
||||
enableSpirvValidation);
|
||||
}
|
||||
|
||||
bool ShaderCompiler::StripMultiviewCapabilityForEssl(const Vector<Uint32>& inputBinary,
|
||||
Vector<uint32_t>& outputBinary) {
|
||||
outputBinary.clear();
|
||||
constexpr SizeT kHeaderWords = 5;
|
||||
if (inputBinary.size() <= kHeaderWords) return false;
|
||||
static constexpr char kExtension[] = "SPV_KHR_multiview";
|
||||
Vector<uint32_t> out(inputBinary.begin(), inputBinary.begin() + kHeaderWords);
|
||||
out.reserve(inputBinary.size());
|
||||
Bool stripped = false;
|
||||
SizeT at = kHeaderWords;
|
||||
// Capabilities and extensions all precede OpMemoryModel, so the walk stops there.
|
||||
while (at < inputBinary.size()) {
|
||||
const Uint32 wordCount = inputBinary[at] >> 16;
|
||||
const auto opcode = static_cast<spv::Op>(inputBinary[at] & 0xFFFFu);
|
||||
if (wordCount == 0 || at + wordCount > inputBinary.size()) return false;
|
||||
if (opcode == spv::Op::OpMemoryModel) break;
|
||||
Bool drop = false;
|
||||
if (opcode == spv::Op::OpCapability && wordCount == 2) {
|
||||
drop = inputBinary[at + 1] == static_cast<Uint32>(spv::Capability::MultiView);
|
||||
} else if (opcode == spv::Op::OpExtension && (wordCount - 1) * 4 > sizeof(kExtension) - 1) {
|
||||
drop = std::memcmp(&inputBinary[at + 1], kExtension, sizeof(kExtension)) == 0;
|
||||
}
|
||||
if (drop) {
|
||||
stripped = true;
|
||||
} else {
|
||||
out.insert(out.end(), inputBinary.begin() + at, inputBinary.begin() + at + wordCount);
|
||||
}
|
||||
at += wordCount;
|
||||
}
|
||||
if (!stripped) return false;
|
||||
out.insert(out.end(), inputBinary.begin() + at, inputBinary.end());
|
||||
outputBinary = Move(out);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ShaderCompiler::LowerViewportIndexForEssl(const Vector<Uint32>& inputBinary,
|
||||
Vector<uint32_t>& outputBinary,
|
||||
const bool enableSpirvValidation) {
|
||||
|
||||
@@ -56,15 +56,6 @@ namespace MobileGL {
|
||||
static bool LowerDrawParametersForEssl(const Vector<Uint32>& inputBinary,
|
||||
Vector<uint32_t>& outputBinary,
|
||||
bool enableSpirvValidation = false);
|
||||
// Drops OpCapability MultiView and OpExtension "SPV_KHR_multiview" and leaves the
|
||||
// ViewIndex built-in, which SPIRV-Cross then prints as gl_ViewID_OVR. Its own route
|
||||
// for the capability needs the view count, which the module does not carry, and
|
||||
// refuses every stage but the vertex one, where GL_OVR_multiview also has the
|
||||
// built-in in the fragment stage; DirectGLES spells the directive and num_views
|
||||
// itself (RequestMultiviewExtension). True, with `outputBinary` filled, only when
|
||||
// something was dropped.
|
||||
static bool StripMultiviewCapabilityForEssl(const Vector<Uint32>& inputBinary,
|
||||
Vector<uint32_t>& outputBinary);
|
||||
// Demotes the gl_ViewportIndex OUTPUT builtin to a plain Private global named
|
||||
// mg_ViewportIndex, so SPIRV-Cross emits an ordinary declaration instead of a bare
|
||||
// gl_ViewportIndex that ESSL has no core spelling for. Multi-viewport routing is
|
||||
|
||||
@@ -967,13 +967,10 @@ namespace {
|
||||
// this stage is not in GL_SUBGROUP_SUPPORTED_STAGES_KHR, or when that extension's
|
||||
// feature is not in GL_SUBGROUP_SUPPORTED_FEATURES_KHR - the KHR spec's own terms for
|
||||
// where each of the eight may be used. The stage and feature tests need a backend:
|
||||
// with none, every extension reads as available (CompileEnv::IsExtensionAdvertised);
|
||||
// * GL_OVR_multiview / GL_OVR_multiview2 when that extension is not advertised.
|
||||
// with none, every extension reads as available (CompileEnv::IsExtensionAdvertised).
|
||||
bool IsUnavailableShaderExtension(const MobileGL::MG_Util::ShaderTranspiler::CompileEnv& env,
|
||||
MobileGL::ShaderStage stage, const MobileGL::String& name) {
|
||||
if (name == "GL_ARB_gpu_shader_int64") return !env.IsExtensionAdvertised(MobileGL::E_GL_ARB_gpu_shader_int64);
|
||||
if (name == "GL_OVR_multiview") return !env.IsExtensionAdvertised(MobileGL::E_GL_OVR_multiview);
|
||||
if (name == "GL_OVR_multiview2") return !env.IsExtensionAdvertised(MobileGL::E_GL_OVR_multiview2);
|
||||
const GLbitfield feature = SubgroupFeatureBit(name);
|
||||
if (feature == 0) return false;
|
||||
if (!env.IsExtensionAdvertised(MobileGL::E_GL_KHR_shader_subgroup)) return true;
|
||||
@@ -1051,13 +1048,10 @@ namespace {
|
||||
source.replace(it->pos, it->len, it->replacement);
|
||||
}
|
||||
// The extension's own feature-test macro, so an `#ifdef` guard takes the fallback branch.
|
||||
// int64 keeps its historical treatment: hidden whether or not the source names it, and the
|
||||
// two multiview macros get the same, because glslang predefines them at every 300+ version.
|
||||
for (const char* alwaysHidden : {"GL_ARB_gpu_shader_int64", "GL_OVR_multiview", "GL_OVR_multiview2"}) {
|
||||
if (IsUnavailableShaderExtension(env, stage, alwaysHidden) &&
|
||||
std::find(hiddenNames.begin(), hiddenNames.end(), alwaysHidden) == hiddenNames.end()) {
|
||||
hiddenNames.push_back(alwaysHidden);
|
||||
}
|
||||
// int64 keeps its historical treatment: hidden whether or not the source names it.
|
||||
if (IsUnavailableShaderExtension(env, stage, "GL_ARB_gpu_shader_int64") &&
|
||||
std::find(hiddenNames.begin(), hiddenNames.end(), "GL_ARB_gpu_shader_int64") == hiddenNames.end()) {
|
||||
hiddenNames.push_back("GL_ARB_gpu_shader_int64");
|
||||
}
|
||||
for (const auto& name : hiddenNames) {
|
||||
ReplaceIdentifier(source, name, "MG_DISABLED_" + name);
|
||||
|
||||
@@ -0,0 +1,147 @@
|
||||
// MobileGL - MobileGL/MG_Util/Texture/PackedTextureUpload.h
|
||||
// Copyright (c) 2025-2026 MobileGL-Dev
|
||||
// Licensed under the GNU Lesser General Public License v3.0:
|
||||
// https://www.gnu.org/licenses/gpl-3.0.txt
|
||||
// https://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
// SPDX-License-Identifier: LGPL-3.0-only
|
||||
// End of Source File Header
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
|
||||
namespace MobileGL::MG_Util::PackedTextureUpload {
|
||||
// A small RGBA8 page bounds both temporary storage and the packing search.
|
||||
constexpr int PageSide = 128;
|
||||
constexpr std::size_t MaxRegions = 32;
|
||||
constexpr std::size_t BytesPerTexel = 4;
|
||||
|
||||
struct Region {
|
||||
const std::uint8_t* source;
|
||||
std::size_t sourcePitch;
|
||||
int level, x, y, width, height;
|
||||
};
|
||||
|
||||
struct Point {
|
||||
int x, y;
|
||||
};
|
||||
|
||||
struct Batch {
|
||||
std::array<Region, MaxRegions> regions;
|
||||
std::array<Point, MaxRegions> offsets;
|
||||
std::size_t count = 0;
|
||||
int width = 0;
|
||||
int height = 0;
|
||||
|
||||
std::size_t ByteSize() const { return BytesPerTexel * width * height; }
|
||||
};
|
||||
|
||||
namespace Detail {
|
||||
struct Rect {
|
||||
int x, y, width, height;
|
||||
int Area() const { return width * height; }
|
||||
};
|
||||
|
||||
// Best-area-fit guillotine packing. Splitting on the shorter remainder
|
||||
// leaves the larger free rectangle available for the next sprite.
|
||||
inline bool TryWidth(const Batch& batch, int width, Batch& result) {
|
||||
std::array<Rect, MaxRegions + 1> free;
|
||||
std::size_t freeCount = 1;
|
||||
free[0] = {0, 0, width, PageSide};
|
||||
int usedWidth = 0, usedHeight = 0;
|
||||
|
||||
for (std::size_t i = 0; i < batch.count; ++i) {
|
||||
const Region& region = batch.regions[i];
|
||||
std::size_t best = freeCount;
|
||||
for (std::size_t j = 0; j < freeCount; ++j) {
|
||||
const Rect& rect = free[j];
|
||||
if (region.width <= rect.width && region.height <= rect.height &&
|
||||
(best == freeCount || rect.Area() < free[best].Area())) {
|
||||
best = j;
|
||||
}
|
||||
}
|
||||
if (best == freeCount) return false;
|
||||
|
||||
const Rect rect = free[best];
|
||||
free[best] = free[--freeCount];
|
||||
result.offsets[i] = {rect.x, rect.y};
|
||||
usedWidth = std::max(usedWidth, rect.x + region.width);
|
||||
usedHeight = std::max(usedHeight, rect.y + region.height);
|
||||
|
||||
const int right = rect.width - region.width;
|
||||
const int below = rect.height - region.height;
|
||||
if (right > 0) {
|
||||
free[freeCount++] = {rect.x + region.width, rect.y, right,
|
||||
right <= below ? region.height : rect.height};
|
||||
}
|
||||
if (below > 0) {
|
||||
free[freeCount++] = {rect.x, rect.y + region.height, right <= below ? rect.width : region.width,
|
||||
below};
|
||||
}
|
||||
}
|
||||
|
||||
result.width = usedWidth;
|
||||
result.height = usedHeight;
|
||||
return true;
|
||||
}
|
||||
} // namespace Detail
|
||||
|
||||
inline bool Pack(Batch& batch, std::uint64_t unionTexels) {
|
||||
batch.width = 0;
|
||||
batch.height = 0;
|
||||
if (batch.count < 2 || batch.count > batch.regions.size()) return false;
|
||||
// Require a full page of traffic savings before taking on extra GPU copy
|
||||
// commands. Dense or single-region uploads already cost little.
|
||||
constexpr int PageTexels = PageSide * PageSide;
|
||||
if (unionTexels <= PageTexels) return false;
|
||||
|
||||
int widest = 1, dirtyTexels = 0;
|
||||
for (std::size_t i = 0; i < batch.count; ++i) {
|
||||
const Region& region = batch.regions[i];
|
||||
if (region.source == nullptr || region.width <= 0 || region.width > PageSide || region.height <= 0 ||
|
||||
region.height > PageSide) {
|
||||
return false;
|
||||
}
|
||||
widest = std::max(widest, region.width);
|
||||
dirtyTexels += region.width * region.height;
|
||||
}
|
||||
if (dirtyTexels > PageTexels) return false;
|
||||
|
||||
std::sort(batch.regions.begin(), batch.regions.begin() + batch.count, [](const Region& a, const Region& b) {
|
||||
const int aArea = a.width * a.height;
|
||||
const int bArea = b.width * b.height;
|
||||
if (aArea != bArea) return aArea > bArea;
|
||||
return std::max(a.width, a.height) > std::max(b.width, b.height);
|
||||
});
|
||||
|
||||
int width = 1;
|
||||
while (width < widest)
|
||||
width *= 2;
|
||||
Batch layout;
|
||||
for (; width <= PageSide; width *= 2) {
|
||||
if (!Detail::TryWidth(batch, width, layout)) continue;
|
||||
if (batch.width > 0 && layout.ByteSize() >= batch.ByteSize()) continue;
|
||||
std::copy_n(layout.offsets.begin(), batch.count, batch.offsets.begin());
|
||||
batch.width = layout.width;
|
||||
batch.height = layout.height;
|
||||
}
|
||||
return batch.width > 0 && unionTexels >= std::uint64_t(PageTexels + dirtyTexels + batch.width * batch.height);
|
||||
}
|
||||
|
||||
inline void WritePage(const Batch& batch, std::uint8_t* page) {
|
||||
std::memset(page, 0, batch.ByteSize());
|
||||
const std::size_t pitch = batch.width * BytesPerTexel;
|
||||
for (std::size_t i = 0; i < batch.count; ++i) {
|
||||
const Region& region = batch.regions[i];
|
||||
const Point offset = batch.offsets[i];
|
||||
auto* dest = page + offset.y * pitch + offset.x * BytesPerTexel;
|
||||
for (int y = 0; y < region.height; ++y) {
|
||||
std::memcpy(dest + y * pitch, region.source + y * region.sourcePitch, region.width * BytesPerTexel);
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace MobileGL::MG_Util::PackedTextureUpload
|
||||
@@ -0,0 +1,68 @@
|
||||
// MobileGL - MobileGL/MG_Util/Texture/TextureUploadBoxes.h
|
||||
// Copyright (c) 2025-2026 MobileGL-Dev
|
||||
// Licensed under the GNU Lesser General Public License v3.0:
|
||||
// https://www.gnu.org/licenses/gpl-3.0.txt
|
||||
// https://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
// SPDX-License-Identifier: LGPL-3.0-only
|
||||
// End of Source File Header
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <optional>
|
||||
|
||||
namespace MobileGL::MG_Util::TextureUploadBoxes {
|
||||
constexpr std::size_t MaxRegions = 64;
|
||||
constexpr std::uint64_t MinSavedTexels = 16 * 1024 / 4;
|
||||
|
||||
struct Box {
|
||||
int left, top, right, bottom;
|
||||
|
||||
std::uint64_t Texels() const { return static_cast<std::uint64_t>(right - left) * (bottom - top); }
|
||||
};
|
||||
|
||||
inline Box Union(Box a, Box b) {
|
||||
return {std::min(a.left, b.left), std::min(a.top, b.top), std::max(a.right, b.right),
|
||||
std::max(a.bottom, b.bottom)};
|
||||
}
|
||||
|
||||
// A second upload job is worth taking only for separated groups with a
|
||||
// substantial absolute and relative reduction. Small mip levels keep one job.
|
||||
inline bool WorthSearching(Box bounds, std::size_t count) {
|
||||
return count >= 2 && count <= MaxRegions && bounds.Texels() > MinSavedTexels;
|
||||
}
|
||||
|
||||
// Every input rectangle belongs to one group. Try cuts on both axes and
|
||||
// keep the least expensive pair of non-overlapping bounding boxes.
|
||||
inline std::optional<std::array<Box, 2>> Split(Box bounds, std::array<Box, MaxRegions>& regions,
|
||||
std::size_t count) {
|
||||
if (!WorthSearching(bounds, count)) return std::nullopt;
|
||||
const auto totalTexels = bounds.Texels();
|
||||
auto bestTexels = std::min(totalTexels / 2, totalTexels - MinSavedTexels);
|
||||
std::optional<std::array<Box, 2>> best;
|
||||
std::array<Box, MaxRegions> suffix;
|
||||
for (bool horizontal : {true, false}) {
|
||||
std::sort(regions.begin(), regions.begin() + count,
|
||||
[horizontal](Box a, Box b) { return horizontal ? a.left < b.left : a.top < b.top; });
|
||||
suffix[count - 1] = regions[count - 1];
|
||||
for (std::size_t i = count - 1; i > 1; --i) {
|
||||
suffix[i - 1] = Union(regions[i - 1], suffix[i]);
|
||||
}
|
||||
Box prefix = regions[0];
|
||||
for (std::size_t i = 1; i < count; ++i) {
|
||||
const Box rest = suffix[i];
|
||||
const bool separated = horizontal ? prefix.right < rest.left : prefix.bottom < rest.top;
|
||||
const auto texels = prefix.Texels() + rest.Texels();
|
||||
if (separated && texels <= bestTexels) {
|
||||
bestTexels = texels;
|
||||
best = std::array<Box, 2>{prefix, rest};
|
||||
}
|
||||
prefix = Union(prefix, regions[i]);
|
||||
}
|
||||
}
|
||||
return best;
|
||||
}
|
||||
} // namespace MobileGL::MG_Util::TextureUploadBoxes
|
||||
@@ -140,7 +140,7 @@ android {
|
||||
minSdk = androidApi
|
||||
targetSdk = 34
|
||||
versionCode = mobileGlVersionMajor * 1_000_000 + mobileGlVersionMinor * 10_000 + mobileGlMonthlyRevision
|
||||
versionName = "%d.%02d.%s".format(mobileGlVersionMajor, mobileGlVersionMinor, mobileGlGitShortHash)
|
||||
versionName = "%d.%02d-alpha.1".format(mobileGlVersionMajor, mobileGlVersionMinor)
|
||||
resValue("string", "config", pluginRendererConfig)
|
||||
|
||||
manifestPlaceholders.putAll(legacyManifest {
|
||||
|
||||
@@ -324,7 +324,6 @@ public:
|
||||
source(EShSourceNone),
|
||||
useVulkanMemoryModel(false),
|
||||
invocations(TQualifier::layoutNotSet), vertices(TQualifier::layoutNotSet),
|
||||
numViews(TQualifier::layoutNotSet),
|
||||
inputPrimitive(ElgNone), outputPrimitive(ElgNone),
|
||||
pixelCenterInteger(false), originUpperLeft(false),texCoordBuiltinRedeclared(false),
|
||||
vertexSpacing(EvsNone), vertexOrder(EvoNone), interlockOrdering(EioNone), pointMode(false), earlyFragmentTests(false),
|
||||
@@ -902,16 +901,6 @@ public:
|
||||
return true;
|
||||
}
|
||||
int getInvocations() const { return invocations; }
|
||||
// GL_OVR_multiview's layout(num_views = N) in; of a vertex shader. SPIR-V has no way to say
|
||||
// it, so a consumer that emits GLSL from the module reads it here.
|
||||
bool setNumViews(int n)
|
||||
{
|
||||
if (numViews != TQualifier::layoutNotSet)
|
||||
return numViews == n;
|
||||
numViews = n;
|
||||
return true;
|
||||
}
|
||||
int getNumViews() const { return numViews; }
|
||||
bool setVertices(int m)
|
||||
{
|
||||
if (vertices != TQualifier::layoutNotSet)
|
||||
@@ -1297,7 +1286,6 @@ protected:
|
||||
bool useVulkanMemoryModel;
|
||||
int invocations;
|
||||
int vertices;
|
||||
int numViews;
|
||||
TLayoutGeometry inputPrimitive;
|
||||
TLayoutGeometry outputPrimitive;
|
||||
bool pixelCenterInteger;
|
||||
|
||||
@@ -62,7 +62,6 @@
|
||||
"DirectGLES.MagmaWireReclaimScenario.ManySmallRespecifyAndDrawRoundsStayUnderTheStoreCountCeiling",
|
||||
"DirectGLES.MagmaWireReclaimScenario.RespecifiesWithNoDrawBetweenKeepTheLiveStoreCountBounded",
|
||||
"DirectGLES.MagmaWireReclaimScenario.RespecifyAndDrawEachStoreInOneFrameStaysWithinTheDeferredBudget",
|
||||
"DirectGLES.MultiviewScenario.AScissoredClearAfterADrawReachesEveryView",
|
||||
"DirectGLES.PersistentCoherentMapScenario.TheMapLandsInTheArmItsLaneDeclares",
|
||||
"DirectGLES.PointSizeDemotionScenario.ACaptureSurvivesAStageThatOnlyReadsThePointSize",
|
||||
"DirectGLES.PointSizeDemotionScenario.TheDemotionIsActuallyArmedWhenTheEnvironmentPinsItOn",
|
||||
@@ -1693,7 +1692,6 @@
|
||||
"DirectGLES.MagmaWireReclaimScenario.ManySmallRespecifyAndDrawRoundsStayUnderTheStoreCountCeiling",
|
||||
"DirectGLES.MagmaWireReclaimScenario.RespecifiesWithNoDrawBetweenKeepTheLiveStoreCountBounded",
|
||||
"DirectGLES.MagmaWireReclaimScenario.RespecifyAndDrawEachStoreInOneFrameStaysWithinTheDeferredBudget",
|
||||
"DirectGLES.MultiviewScenario.AScissoredClearAfterADrawReachesEveryView",
|
||||
"DirectGLES.ObjectSubsystemControlScenario.ASamplerBitWithoutTheTextureBitIsRefusedAndNamed",
|
||||
"DirectGLES.ObjectSubsystemControlScenario.ATextureBitWithoutTheSamplerBitIsRefusedAndNamed",
|
||||
"DirectGLES.ObjectSubsystemControlScenario.ClearingTheP4aBitsStopsTheEmissionsAndNotThePixels",
|
||||
@@ -1734,7 +1732,6 @@
|
||||
"DirectGLES.Spawn.IterationRPProgram203Scenario.FixedCompleteInputProducesFixedCompleteGoldenOutput",
|
||||
"DirectGLES.Spawn.IterationRPScratchFixScenario.FixtureShapedReductionSumsEveryInvocation",
|
||||
"DirectGLES.Spawn.IterationRPScratchFixScenario.WideFixtureShapedReductionSumsEveryInvocation",
|
||||
"DirectGLES.Spawn.MultiviewScenario.AScissoredClearAfterADrawReachesEveryView",
|
||||
"DirectGLES.Spawn.SsboDeclarationFormScenario.PackedBlockWithAnUnsizedArrayBeforeAnotherMember",
|
||||
"DirectGLES.Spawn.SsboDeclarationFormScenario.TwoUnsizedArraysInOneBlock",
|
||||
"DirectGLES.Spawn.Xfb.XfbRepeatedCaptureScenario.AVertexOnlyAdjacencyCaptureRecords",
|
||||
@@ -1753,7 +1750,6 @@
|
||||
"DirectGLES.Split.IterationRPProgram203Scenario.FixedCompleteInputProducesFixedCompleteGoldenOutput",
|
||||
"DirectGLES.Split.IterationRPScratchFixScenario.FixtureShapedReductionSumsEveryInvocation",
|
||||
"DirectGLES.Split.IterationRPScratchFixScenario.WideFixtureShapedReductionSumsEveryInvocation",
|
||||
"DirectGLES.Split.MultiviewScenario.AScissoredClearAfterADrawReachesEveryView",
|
||||
"DirectGLES.Split.SsboDeclarationFormScenario.PackedBlockWithAnUnsizedArrayBeforeAnotherMember",
|
||||
"DirectGLES.Split.SsboDeclarationFormScenario.TwoUnsizedArraysInOneBlock",
|
||||
"DirectGLES.Split.Xfb.XfbRepeatedCaptureScenario.AVertexOnlyAdjacencyCaptureRecords",
|
||||
@@ -1775,7 +1771,6 @@
|
||||
"DirectGLES.Tcp.IterationRPProgram203Scenario.FixedCompleteInputProducesFixedCompleteGoldenOutput",
|
||||
"DirectGLES.Tcp.IterationRPScratchFixScenario.FixtureShapedReductionSumsEveryInvocation",
|
||||
"DirectGLES.Tcp.IterationRPScratchFixScenario.WideFixtureShapedReductionSumsEveryInvocation",
|
||||
"DirectGLES.Tcp.MultiviewScenario.AScissoredClearAfterADrawReachesEveryView",
|
||||
"DirectGLES.Tcp.SsboDeclarationFormScenario.PackedBlockWithAnUnsizedArrayBeforeAnotherMember",
|
||||
"DirectGLES.Tcp.SsboDeclarationFormScenario.TwoUnsizedArraysInOneBlock",
|
||||
"DirectGLES.Tcp.Xfb.XfbRepeatedCaptureScenario.AVertexOnlyAdjacencyCaptureRecords",
|
||||
@@ -2477,7 +2472,6 @@
|
||||
"DirectGLES.MagmaWireReclaimScenario.ManySmallRespecifyAndDrawRoundsStayUnderTheStoreCountCeiling",
|
||||
"DirectGLES.MagmaWireReclaimScenario.RespecifiesWithNoDrawBetweenKeepTheLiveStoreCountBounded",
|
||||
"DirectGLES.MagmaWireReclaimScenario.RespecifyAndDrawEachStoreInOneFrameStaysWithinTheDeferredBudget",
|
||||
"DirectGLES.MultiviewScenario.AScissoredClearAfterADrawReachesEveryView",
|
||||
"DirectGLES.ObjectSubsystemControlScenario.ASamplerBitWithoutTheTextureBitIsRefusedAndNamed",
|
||||
"DirectGLES.ObjectSubsystemControlScenario.ATextureBitWithoutTheSamplerBitIsRefusedAndNamed",
|
||||
"DirectGLES.ObjectSubsystemControlScenario.ClearingTheP4aBitsStopsTheEmissionsAndNotThePixels",
|
||||
@@ -2519,7 +2513,6 @@
|
||||
"DirectGLES.Spawn.IterationRPProgram203Scenario.FixedCompleteInputProducesFixedCompleteGoldenOutput",
|
||||
"DirectGLES.Spawn.IterationRPScratchFixScenario.FixtureShapedReductionSumsEveryInvocation",
|
||||
"DirectGLES.Spawn.IterationRPScratchFixScenario.WideFixtureShapedReductionSumsEveryInvocation",
|
||||
"DirectGLES.Spawn.MultiviewScenario.AScissoredClearAfterADrawReachesEveryView",
|
||||
"DirectGLES.Spawn.SsboDeclarationFormScenario.PackedBlockWithAnUnsizedArrayBeforeAnotherMember",
|
||||
"DirectGLES.Spawn.SsboDeclarationFormScenario.TwoUnsizedArraysInOneBlock",
|
||||
"DirectGLES.Spawn.Xfb.XfbRepeatedCaptureScenario.AVertexOnlyAdjacencyCaptureRecords",
|
||||
@@ -2538,7 +2531,6 @@
|
||||
"DirectGLES.Split.IterationRPProgram203Scenario.FixedCompleteInputProducesFixedCompleteGoldenOutput",
|
||||
"DirectGLES.Split.IterationRPScratchFixScenario.FixtureShapedReductionSumsEveryInvocation",
|
||||
"DirectGLES.Split.IterationRPScratchFixScenario.WideFixtureShapedReductionSumsEveryInvocation",
|
||||
"DirectGLES.Split.MultiviewScenario.AScissoredClearAfterADrawReachesEveryView",
|
||||
"DirectGLES.Split.SsboDeclarationFormScenario.PackedBlockWithAnUnsizedArrayBeforeAnotherMember",
|
||||
"DirectGLES.Split.SsboDeclarationFormScenario.TwoUnsizedArraysInOneBlock",
|
||||
"DirectGLES.Split.Xfb.XfbRepeatedCaptureScenario.AVertexOnlyAdjacencyCaptureRecords",
|
||||
@@ -2561,7 +2553,6 @@
|
||||
"DirectGLES.Tcp.IterationRPProgram203Scenario.FixedCompleteInputProducesFixedCompleteGoldenOutput",
|
||||
"DirectGLES.Tcp.IterationRPScratchFixScenario.FixtureShapedReductionSumsEveryInvocation",
|
||||
"DirectGLES.Tcp.IterationRPScratchFixScenario.WideFixtureShapedReductionSumsEveryInvocation",
|
||||
"DirectGLES.Tcp.MultiviewScenario.AScissoredClearAfterADrawReachesEveryView",
|
||||
"DirectGLES.Tcp.SsboDeclarationFormScenario.PackedBlockWithAnUnsizedArrayBeforeAnotherMember",
|
||||
"DirectGLES.Tcp.SsboDeclarationFormScenario.TwoUnsizedArraysInOneBlock",
|
||||
"DirectGLES.Tcp.Xfb.XfbRepeatedCaptureScenario.AVertexOnlyAdjacencyCaptureRecords",
|
||||
@@ -7404,7 +7395,6 @@
|
||||
"DirectGLES.Split.IterationRPProgram203Scenario.FixedCompleteInputProducesFixedCompleteGoldenOutput",
|
||||
"DirectGLES.Split.IterationRPScratchFixScenario.FixtureShapedReductionSumsEveryInvocation",
|
||||
"DirectGLES.Split.IterationRPScratchFixScenario.WideFixtureShapedReductionSumsEveryInvocation",
|
||||
"DirectGLES.Split.MultiviewScenario.AScissoredClearAfterADrawReachesEveryView",
|
||||
"DirectGLES.Split.SsboDeclarationFormScenario.PackedBlockWithAnUnsizedArrayBeforeAnotherMember",
|
||||
"DirectGLES.Split.SsboDeclarationFormScenario.TwoUnsizedArraysInOneBlock",
|
||||
"DirectGLES.Split.Xfb.XfbRepeatedCaptureScenario.AVertexOnlyAdjacencyCaptureRecords",
|
||||
@@ -8631,7 +8621,6 @@
|
||||
"DirectGLES.Split.IterationRPProgram203Scenario.FixedCompleteInputProducesFixedCompleteGoldenOutput",
|
||||
"DirectGLES.Split.IterationRPScratchFixScenario.FixtureShapedReductionSumsEveryInvocation",
|
||||
"DirectGLES.Split.IterationRPScratchFixScenario.WideFixtureShapedReductionSumsEveryInvocation",
|
||||
"DirectGLES.Split.MultiviewScenario.AScissoredClearAfterADrawReachesEveryView",
|
||||
"DirectGLES.Split.SsboDeclarationFormScenario.PackedBlockWithAnUnsizedArrayBeforeAnotherMember",
|
||||
"DirectGLES.Split.SsboDeclarationFormScenario.TwoUnsizedArraysInOneBlock",
|
||||
"DirectGLES.Split.Xfb.XfbRepeatedCaptureScenario.AVertexOnlyAdjacencyCaptureRecords"
|
||||
@@ -12340,7 +12329,6 @@
|
||||
"DirectGLES.MagmaWireReclaimScenario.ManySmallRespecifyAndDrawRoundsStayUnderTheStoreCountCeiling",
|
||||
"DirectGLES.MagmaWireReclaimScenario.RespecifiesWithNoDrawBetweenKeepTheLiveStoreCountBounded",
|
||||
"DirectGLES.MagmaWireReclaimScenario.RespecifyAndDrawEachStoreInOneFrameStaysWithinTheDeferredBudget",
|
||||
"DirectGLES.MultiviewScenario.AScissoredClearAfterADrawReachesEveryView",
|
||||
"DirectGLES.ObjectSubsystemControlScenario.ASamplerBitWithoutTheTextureBitIsRefusedAndNamed",
|
||||
"DirectGLES.ObjectSubsystemControlScenario.ATextureBitWithoutTheSamplerBitIsRefusedAndNamed",
|
||||
"DirectGLES.ObjectSubsystemControlScenario.ClearingTheP4aBitsStopsTheEmissionsAndNotThePixels",
|
||||
@@ -12381,7 +12369,6 @@
|
||||
"DirectGLES.Spawn.IterationRPProgram203Scenario.FixedCompleteInputProducesFixedCompleteGoldenOutput",
|
||||
"DirectGLES.Spawn.IterationRPScratchFixScenario.FixtureShapedReductionSumsEveryInvocation",
|
||||
"DirectGLES.Spawn.IterationRPScratchFixScenario.WideFixtureShapedReductionSumsEveryInvocation",
|
||||
"DirectGLES.Spawn.MultiviewScenario.AScissoredClearAfterADrawReachesEveryView",
|
||||
"DirectGLES.Spawn.SsboDeclarationFormScenario.PackedBlockWithAnUnsizedArrayBeforeAnotherMember",
|
||||
"DirectGLES.Spawn.SsboDeclarationFormScenario.TwoUnsizedArraysInOneBlock",
|
||||
"DirectGLES.Spawn.Xfb.XfbRepeatedCaptureScenario.AVertexOnlyAdjacencyCaptureRecords",
|
||||
@@ -12400,7 +12387,6 @@
|
||||
"DirectGLES.Split.IterationRPProgram203Scenario.FixedCompleteInputProducesFixedCompleteGoldenOutput",
|
||||
"DirectGLES.Split.IterationRPScratchFixScenario.FixtureShapedReductionSumsEveryInvocation",
|
||||
"DirectGLES.Split.IterationRPScratchFixScenario.WideFixtureShapedReductionSumsEveryInvocation",
|
||||
"DirectGLES.Split.MultiviewScenario.AScissoredClearAfterADrawReachesEveryView",
|
||||
"DirectGLES.Split.SsboDeclarationFormScenario.PackedBlockWithAnUnsizedArrayBeforeAnotherMember",
|
||||
"DirectGLES.Split.SsboDeclarationFormScenario.TwoUnsizedArraysInOneBlock",
|
||||
"DirectGLES.Split.Xfb.XfbRepeatedCaptureScenario.AVertexOnlyAdjacencyCaptureRecords",
|
||||
@@ -12422,7 +12408,6 @@
|
||||
"DirectGLES.Tcp.IterationRPProgram203Scenario.FixedCompleteInputProducesFixedCompleteGoldenOutput",
|
||||
"DirectGLES.Tcp.IterationRPScratchFixScenario.FixtureShapedReductionSumsEveryInvocation",
|
||||
"DirectGLES.Tcp.IterationRPScratchFixScenario.WideFixtureShapedReductionSumsEveryInvocation",
|
||||
"DirectGLES.Tcp.MultiviewScenario.AScissoredClearAfterADrawReachesEveryView",
|
||||
"DirectGLES.Tcp.SsboDeclarationFormScenario.PackedBlockWithAnUnsizedArrayBeforeAnotherMember",
|
||||
"DirectGLES.Tcp.SsboDeclarationFormScenario.TwoUnsizedArraysInOneBlock",
|
||||
"DirectGLES.Tcp.Xfb.XfbRepeatedCaptureScenario.AVertexOnlyAdjacencyCaptureRecords",
|
||||
@@ -12692,7 +12677,6 @@
|
||||
"DirectGLES.MagmaWireReclaimScenario.ManySmallRespecifyAndDrawRoundsStayUnderTheStoreCountCeiling",
|
||||
"DirectGLES.MagmaWireReclaimScenario.RespecifiesWithNoDrawBetweenKeepTheLiveStoreCountBounded",
|
||||
"DirectGLES.MagmaWireReclaimScenario.RespecifyAndDrawEachStoreInOneFrameStaysWithinTheDeferredBudget",
|
||||
"DirectGLES.MultiviewScenario.AScissoredClearAfterADrawReachesEveryView",
|
||||
"DirectGLES.ObjectSubsystemControlScenario.ASamplerBitWithoutTheTextureBitIsRefusedAndNamed",
|
||||
"DirectGLES.ObjectSubsystemControlScenario.ATextureBitWithoutTheSamplerBitIsRefusedAndNamed",
|
||||
"DirectGLES.ObjectSubsystemControlScenario.ClearingTheP4aBitsStopsTheEmissionsAndNotThePixels",
|
||||
@@ -12734,7 +12718,6 @@
|
||||
"DirectGLES.Spawn.IterationRPProgram203Scenario.FixedCompleteInputProducesFixedCompleteGoldenOutput",
|
||||
"DirectGLES.Spawn.IterationRPScratchFixScenario.FixtureShapedReductionSumsEveryInvocation",
|
||||
"DirectGLES.Spawn.IterationRPScratchFixScenario.WideFixtureShapedReductionSumsEveryInvocation",
|
||||
"DirectGLES.Spawn.MultiviewScenario.AScissoredClearAfterADrawReachesEveryView",
|
||||
"DirectGLES.Spawn.SsboDeclarationFormScenario.PackedBlockWithAnUnsizedArrayBeforeAnotherMember",
|
||||
"DirectGLES.Spawn.SsboDeclarationFormScenario.TwoUnsizedArraysInOneBlock",
|
||||
"DirectGLES.Spawn.Xfb.XfbRepeatedCaptureScenario.AVertexOnlyAdjacencyCaptureRecords",
|
||||
@@ -12753,7 +12736,6 @@
|
||||
"DirectGLES.Split.IterationRPProgram203Scenario.FixedCompleteInputProducesFixedCompleteGoldenOutput",
|
||||
"DirectGLES.Split.IterationRPScratchFixScenario.FixtureShapedReductionSumsEveryInvocation",
|
||||
"DirectGLES.Split.IterationRPScratchFixScenario.WideFixtureShapedReductionSumsEveryInvocation",
|
||||
"DirectGLES.Split.MultiviewScenario.AScissoredClearAfterADrawReachesEveryView",
|
||||
"DirectGLES.Split.SsboDeclarationFormScenario.PackedBlockWithAnUnsizedArrayBeforeAnotherMember",
|
||||
"DirectGLES.Split.SsboDeclarationFormScenario.TwoUnsizedArraysInOneBlock",
|
||||
"DirectGLES.Split.Xfb.XfbRepeatedCaptureScenario.AVertexOnlyAdjacencyCaptureRecords",
|
||||
@@ -12776,7 +12758,6 @@
|
||||
"DirectGLES.Tcp.IterationRPProgram203Scenario.FixedCompleteInputProducesFixedCompleteGoldenOutput",
|
||||
"DirectGLES.Tcp.IterationRPScratchFixScenario.FixtureShapedReductionSumsEveryInvocation",
|
||||
"DirectGLES.Tcp.IterationRPScratchFixScenario.WideFixtureShapedReductionSumsEveryInvocation",
|
||||
"DirectGLES.Tcp.MultiviewScenario.AScissoredClearAfterADrawReachesEveryView",
|
||||
"DirectGLES.Tcp.SsboDeclarationFormScenario.PackedBlockWithAnUnsizedArrayBeforeAnotherMember",
|
||||
"DirectGLES.Tcp.SsboDeclarationFormScenario.TwoUnsizedArraysInOneBlock",
|
||||
"DirectGLES.Tcp.Xfb.XfbRepeatedCaptureScenario.AVertexOnlyAdjacencyCaptureRecords",
|
||||
@@ -13003,7 +12984,6 @@
|
||||
"DirectGLES.Spawn.IterationRPProgram203Scenario.FixedCompleteInputProducesFixedCompleteGoldenOutput",
|
||||
"DirectGLES.Spawn.IterationRPScratchFixScenario.FixtureShapedReductionSumsEveryInvocation",
|
||||
"DirectGLES.Spawn.IterationRPScratchFixScenario.WideFixtureShapedReductionSumsEveryInvocation",
|
||||
"DirectGLES.Spawn.MultiviewScenario.AScissoredClearAfterADrawReachesEveryView",
|
||||
"DirectGLES.Spawn.SsboDeclarationFormScenario.PackedBlockWithAnUnsizedArrayBeforeAnotherMember",
|
||||
"DirectGLES.Spawn.SsboDeclarationFormScenario.TwoUnsizedArraysInOneBlock",
|
||||
"DirectGLES.Spawn.Xfb.XfbRepeatedCaptureScenario.AVertexOnlyAdjacencyCaptureRecords"
|
||||
@@ -13678,7 +13658,6 @@
|
||||
"DirectGLES.Split.IterationRPProgram203Scenario.FixedCompleteInputProducesFixedCompleteGoldenOutput",
|
||||
"DirectGLES.Split.IterationRPScratchFixScenario.FixtureShapedReductionSumsEveryInvocation",
|
||||
"DirectGLES.Split.IterationRPScratchFixScenario.WideFixtureShapedReductionSumsEveryInvocation",
|
||||
"DirectGLES.Split.MultiviewScenario.AScissoredClearAfterADrawReachesEveryView",
|
||||
"DirectGLES.Split.SsboDeclarationFormScenario.PackedBlockWithAnUnsizedArrayBeforeAnotherMember",
|
||||
"DirectGLES.Split.SsboDeclarationFormScenario.TwoUnsizedArraysInOneBlock",
|
||||
"DirectGLES.Split.Xfb.XfbRepeatedCaptureScenario.AVertexOnlyAdjacencyCaptureRecords"
|
||||
@@ -13702,7 +13681,6 @@
|
||||
"DirectGLES.Tcp.IterationRPProgram203Scenario.FixedCompleteInputProducesFixedCompleteGoldenOutput",
|
||||
"DirectGLES.Tcp.IterationRPScratchFixScenario.FixtureShapedReductionSumsEveryInvocation",
|
||||
"DirectGLES.Tcp.IterationRPScratchFixScenario.WideFixtureShapedReductionSumsEveryInvocation",
|
||||
"DirectGLES.Tcp.MultiviewScenario.AScissoredClearAfterADrawReachesEveryView",
|
||||
"DirectGLES.Tcp.SsboDeclarationFormScenario.PackedBlockWithAnUnsizedArrayBeforeAnotherMember",
|
||||
"DirectGLES.Tcp.SsboDeclarationFormScenario.TwoUnsizedArraysInOneBlock",
|
||||
"DirectGLES.Tcp.Xfb.XfbRepeatedCaptureScenario.AVertexOnlyAdjacencyCaptureRecords"
|
||||
@@ -14446,7 +14424,6 @@
|
||||
"DirectGLES.VerifySplit.MagmaWireReclaimScenario.ManySmallRespecifyAndDrawRoundsStayUnderTheStoreCountCeiling",
|
||||
"DirectGLES.VerifySplit.MagmaWireReclaimScenario.RespecifiesWithNoDrawBetweenKeepTheLiveStoreCountBounded",
|
||||
"DirectGLES.VerifySplit.MagmaWireReclaimScenario.RespecifyAndDrawEachStoreInOneFrameStaysWithinTheDeferredBudget",
|
||||
"DirectGLES.VerifySplit.MultiviewScenario.AScissoredClearAfterADrawReachesEveryView",
|
||||
"DirectGLES.VerifySplit.PersistentCoherentMapScenario.TheMapLandsInTheArmItsLaneDeclares",
|
||||
"DirectGLES.VerifySplit.PointSizeDemotionScenario.ACaptureSurvivesAStageThatOnlyReadsThePointSize",
|
||||
"DirectGLES.VerifySplit.PointSizeDemotionScenario.TheDemotionIsActuallyArmedWhenTheEnvironmentPinsItOn",
|
||||
@@ -18029,7 +18006,6 @@
|
||||
"DirectGLES.Verify.LargeArenaAdoptionScenario.TheArenaLandsInTheTierItsLaneDeclares",
|
||||
"DirectGLES.Verify.MagmaVertexLayoutScenario.AnUnmappableVertexFormatDeclinesTheDrawInsteadOfEndingTheSession",
|
||||
"DirectGLES.Verify.MagmaVertexLayoutScenario.AnUnreadUnmappableArrayDoesNotStopTheRestOfTheDraw",
|
||||
"DirectGLES.Verify.MultiviewScenario.AScissoredClearAfterADrawReachesEveryView",
|
||||
"DirectGLES.Verify.ObjectSubsystemControlScenario.ASamplerBitWithoutTheTextureBitIsRefusedAndNamed",
|
||||
"DirectGLES.Verify.ObjectSubsystemControlScenario.ATextureBitWithoutTheSamplerBitIsRefusedAndNamed",
|
||||
"DirectGLES.Verify.ObjectSubsystemControlScenario.ClearingTheP4aBitsStopsTheEmissionsAndNotThePixels",
|
||||
|
||||
+1
-1
@@ -68,7 +68,7 @@ frame. It exists for sharing one GPU-owning server between processes, sandboxes
|
||||
|
||||
- `GL_RENDERER` starts with `Espryt (MobileGL Core)` or `Magma (MobileGL Core)`.
|
||||
- `GL_VENDOR` contains `MobileGL-Dev`.
|
||||
- `GL_VERSION` looks like `4.6.0 MobileGL 26.11-dev, Direct (GLES) Backend, GIT@<hash>` (or
|
||||
- `GL_VERSION` looks like `4.6.0 MobileGL 26.11-alpha.1, Direct (GLES) Backend, GIT@<hash>` (or
|
||||
`Direct (Vulkan)`).
|
||||
- In Minecraft, the F3 screen shows these strings.
|
||||
- The log says `Config: Active backend type set to DirectGLES` (or `DirectVulkan`). Logs go to
|
||||
|
||||
Reference in new issue
Block a user