mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-11-21 00:41:57 +09:00
[Fix] (Pipe, State): take the texture and framebuffer families through the contract own birth hooks, wire the texture subsystem bit, hand the applier the region tail it was promised and clear a level dirty flag only where the record was accepted
This commit is contained in:
@@ -9,13 +9,10 @@
|
||||
#include "RenderbufferObject.h"
|
||||
#include <MG_Util/Metrics/TextureMetrics.h>
|
||||
#include <MG_State/GLState/StateObjectDeathNotice.h>
|
||||
#if MOBILEGL_PIPE_PUSH
|
||||
// The second and last MG_State translation unit that sees the client's texture emitter. A
|
||||
// renderbuffer has no base class to hang protected helpers on and exactly one .cpp, so the
|
||||
// include is the whole coupling; see MG_Impl/Pipe/TextureEmit.h's header comment for why the
|
||||
// declaration cannot live in MG_Pipe/PipeMutation.h this phase.
|
||||
#include <MG_Impl/Pipe/TextureEmit.h>
|
||||
#endif
|
||||
// The contract's own door, exactly as the texture half takes it (c0b): the four renderbuffer
|
||||
// hooks this file calls are declared in MG_Pipe/PipeMutation.h and defined in
|
||||
// MG_Impl/Pipe/PipeFill.cpp, so no MG_State translation unit includes the client's emitter.
|
||||
#include <MG_Pipe/PipeMutation.h>
|
||||
|
||||
#include <atomic>
|
||||
|
||||
@@ -39,7 +36,12 @@ namespace MobileGL {
|
||||
// shape with textures and buffers and nothing else - and its handle is minted
|
||||
// whatever the subsystem bitmask says, because MGPSurface::Res names it out of the
|
||||
// framebuffer subsystem.
|
||||
MG_Pipe::MGPipeMintAndCreateRenderbuffer(*this);
|
||||
// TWO CALLS AND NOT ONE (c0b): the mint is unconditional in a push build
|
||||
// because a renderbuffer is named by handle out of the framebuffer subsystem
|
||||
// whether or not its own family is switched on; the create is what the gate in
|
||||
// PipeFill.cpp decides.
|
||||
MG_Pipe::MGPipeMintRenderbufferHandle(*this);
|
||||
MG_Pipe::MGPipeEmitRenderbufferResourceCreate(*this);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -51,7 +53,8 @@ namespace MobileGL {
|
||||
// still resolves - and the slot last. Steps 2 and 3 are the contract's helper;
|
||||
// step 1 is this package's, one statement earlier, because the helper's file
|
||||
// belongs to the contract package for the whole phase.
|
||||
MG_Pipe::MGPipeEmitRenderbufferResourceDestroy(m_lifetimeId);
|
||||
// All three steps are the contract's helper (c0b); v1's separate step-1 call
|
||||
// is deleted, not kept, for the reason ~TextureObjectBase states in full.
|
||||
MG_Pipe::MGPipeEmitRenderbufferDestroyAndFree(m_lifetimeId);
|
||||
}
|
||||
#endif
|
||||
@@ -145,7 +148,7 @@ namespace MobileGL {
|
||||
// The emitter dedupes on the built descriptor, so glRenderbufferStorage's three-setter
|
||||
// sequence publishes once rather than three times.
|
||||
void RenderbufferObject::PipePublishDescriptor() {
|
||||
MG_Pipe::MGPipeEmitRenderbufferRespecify(*this);
|
||||
MG_Pipe::MGPipeEmitRenderbufferResourceRespecify(*this);
|
||||
}
|
||||
#endif
|
||||
} // namespace GLState
|
||||
|
||||
@@ -12,15 +12,13 @@
|
||||
#include "MG_Util/Types.h"
|
||||
#include <MG_Util/Metrics/TextureMetrics.h>
|
||||
#include <MG_Pipe/PipeMutation.h>
|
||||
#if MOBILEGL_PIPE_PUSH
|
||||
// THE ONE MG_State TRANSLATION UNIT THAT SEES THE CLIENT'S TEXTURE EMITTER, on purpose: the
|
||||
// three PipePublish* helpers below are declared on TextureObjectBase and defined here, so the
|
||||
// cube's, the view's and the buffer texture's translation units call an inherited member and
|
||||
// still see only a declaration. That is the layering MG_Pipe/PipeMutation.h gives the buffer
|
||||
// family; P4a cannot use that header because it belongs to the contract package for the whole
|
||||
// phase and carries no texture row (TextureEmit.h's header comment has the full argument).
|
||||
#include <MG_Impl/Pipe/TextureEmit.h>
|
||||
#endif
|
||||
// NO MG_State TRANSLATION UNIT SEES THE CLIENT'S EMITTER ANY MORE (c0b, ID-13). v1 included
|
||||
// MG_Impl/Pipe/TextureEmit.h here and in RenderbufferObject.cpp because at the contract tag
|
||||
// MG_Pipe/PipeMutation.h carried no texture row; it now declares the four mints, the nine
|
||||
// emissions and the publication latch, so this file sees a DECLARATION exactly as
|
||||
// BufferObject.cpp does and the closure gate's mutation-header probe has nothing to find.
|
||||
// The three PipePublish* helpers stay on TextureObjectBase so the cube's, the view's and the
|
||||
// buffer texture's translation units keep calling an inherited member.
|
||||
|
||||
namespace MobileGL {
|
||||
namespace MG_State {
|
||||
@@ -53,29 +51,31 @@ namespace MobileGL {
|
||||
// name and leaves a still-bound object very much alive;
|
||||
// 3. the slot LAST, and a double free on a stale generation is a proven no-op.
|
||||
//
|
||||
// Steps 2 and 3 - plus the SamplerViewCso minted off this same lifetime id - are
|
||||
// the contract's helper. The BUILT-IN SAMPLER is deliberately not released from
|
||||
// here: it is a real SamplerObject with its own lifetime id and its own
|
||||
// destructor, which runs immediately after this body and takes the same helper
|
||||
// shape. Step 1 is the client package's, one statement earlier, because the
|
||||
// helper's file belongs to the contract package for the whole phase.
|
||||
MG_Pipe::MGPipeEmitTextureResourceDestroy(m_lifetimeId);
|
||||
// ALL THREE STEPS ARE THE CONTRACT'S HELPER (c0b): it reads the publication
|
||||
// latch, emits the resource_destroy itself, raises the notice while the handle
|
||||
// still resolves and frees the slot last. v1 emitted step 1 from a second
|
||||
// statement here because at the tag the helper hard-coded `published = false`;
|
||||
// that statement is deleted rather than kept, since a second delete for a
|
||||
// record the helper has already dropped is a refused call the applier asserts
|
||||
// on. The SamplerViewCso minted off this same lifetime id goes with it. The
|
||||
// BUILT-IN SAMPLER does not: it is a real SamplerObject with its own lifetime
|
||||
// id and its own destructor, which takes the same helper shape.
|
||||
MG_Pipe::MGPipeEmitTextureDestroyAndFree(m_lifetimeId);
|
||||
}
|
||||
|
||||
// ---- P4a's three client emission points (see TextureObject.h) ----
|
||||
|
||||
void TextureObjectBase::PipePublishDescriptor() {
|
||||
MG_Pipe::MGPipeEmitTextureRespecify(*this);
|
||||
MG_Pipe::MGPipeEmitTextureResourceRespecify(*this);
|
||||
}
|
||||
|
||||
void TextureObjectBase::PipePublishParams() {
|
||||
MG_Pipe::MGPipeEmitTextureParams(*this);
|
||||
}
|
||||
|
||||
void TextureObjectBase::PipeNoteLevelDirty(TextureUploadTarget uploadTarget, Uint mipmapLevel,
|
||||
Bool dirty) {
|
||||
MG_Pipe::MGPipeNoteTextureLevelDirty(*this, uploadTarget, mipmapLevel, dirty);
|
||||
void TextureObjectBase::PipeNoteLevelDirty(TextureUploadTarget uploadTarget, Uint mipmapLevel) {
|
||||
MG_Pipe::MGPipeNoteTextureLevelDirty(*this, static_cast<Uint32>(uploadTarget),
|
||||
static_cast<Uint32>(mipmapLevel));
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -115,15 +115,25 @@ namespace MobileGL {
|
||||
// because set_framebuffer_state and set_sampler_views name this texture by handle
|
||||
// out of two different subsystems.
|
||||
//
|
||||
// NOTHING VIRTUAL IS TOUCHED HERE and that is a correctness requirement rather
|
||||
// than a style: the derived object does not exist yet, and
|
||||
// ITextureObject::GetStorageType is PURE - calling it from a base constructor is
|
||||
// undefined behaviour. The target and the GL name are the two facts a create
|
||||
// carries and both are plain members by this point; the storage kind is derived
|
||||
// from the target, which is exact (TextureObjectBuffer is the only class that
|
||||
// reports Buffer and TextureBuffer is the only target it is constructed with).
|
||||
MG_Pipe::MGPipeMintAndCreateTexture(static_cast<ITextureObject*>(this), m_lifetimeId, target,
|
||||
externalIndex);
|
||||
// NOTHING THE DERIVED CLASS IMPLEMENTS IS TOUCHED HERE and that is a
|
||||
// correctness requirement rather than a style: the derived object does not exist
|
||||
// yet, so ITextureObject::GetStorageType and ::GetUploadTargets - PURE, with no
|
||||
// body on this base - would be undefined behaviour. The emitter reads GetTarget()
|
||||
// and GetExternalIndex(), which TextureObjectBase itself overrides and which
|
||||
// therefore dispatch to this class's own bodies over members the mem-init list
|
||||
// has already written; the storage kind is derived from the target, which is
|
||||
// exact (TextureObjectBuffer is the only class that reports Buffer and
|
||||
// TextureBuffer is the only target it is constructed with).
|
||||
//
|
||||
// TWO CALLS AND NOT ONE (c0b): the MINT is unconditional in a push build -
|
||||
// set_framebuffer_state and set_sampler_views name this texture by handle out of
|
||||
// two other subsystems, so gating it would make them emit null handles in exactly
|
||||
// the A/B arm that exists to isolate the families - and the CREATE is what the
|
||||
// subsystem gate in PipeFill.cpp decides.
|
||||
(void)target;
|
||||
(void)externalIndex;
|
||||
MG_Pipe::MGPipeMintTextureHandle(*this);
|
||||
MG_Pipe::MGPipeEmitTextureResourceCreate(*this);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -498,7 +508,9 @@ namespace MobileGL {
|
||||
}
|
||||
m_textureStorage.MarkDirty(GetIndexOfTextureUploadTarget(uploadTarget), mipmapLevel, dirty);
|
||||
#if MOBILEGL_PIPE_PUSH
|
||||
PipeNoteLevelDirty(uploadTarget, mipmapLevel, dirty);
|
||||
// THE DRAIN LIST HAS NO CLEAN ARM (see TextureEmit.h): a level that goes clean
|
||||
// is collected at the next drain, whose first test is IsStorageDirty.
|
||||
if (dirty) PipeNoteLevelDirty(uploadTarget, mipmapLevel);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -517,7 +529,7 @@ namespace MobileGL {
|
||||
// forwards this call to the OWNER's method after remapping the level and the
|
||||
// region, so an upload through a view and an upload through the owner arrive here
|
||||
// on the same object with the same owner-side coordinates.
|
||||
PipeNoteLevelDirty(uploadTarget, mipmapLevel, true);
|
||||
PipeNoteLevelDirty(uploadTarget, mipmapLevel);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -215,13 +215,11 @@ namespace MobileGL::MG_State::GLState {
|
||||
// that reaches the pull build is inside this guard, so the pull build's symbol set is
|
||||
// byte-for-byte the one it had before the phase.
|
||||
//
|
||||
// DECLARED HERE AND DEFINED IN TextureObject.cpp, which is the ONE MG_State
|
||||
// translation unit that includes the client's MG_Impl/Pipe/TextureEmit.h. Every other
|
||||
// texture .cpp - the cube's, the view's, the buffer texture's - calls the inherited
|
||||
// helper and still sees only a declaration, which is the same layering
|
||||
// MG_Pipe/PipeMutation.h gives the buffer family (that header is the contract
|
||||
// package's for the whole phase and carries no texture row, which is why the
|
||||
// declaration lives here instead; see TextureEmit.h's header comment).
|
||||
// DECLARED HERE AND DEFINED IN TextureObject.cpp, which calls the contract's own hooks
|
||||
// in MG_Pipe/PipeMutation.h - the same door BufferObject.cpp uses, and no MG_State
|
||||
// translation unit sees MG_Impl/Pipe/TextureEmit.h at all (c0b, ID-13). They stay
|
||||
// members rather than free calls so the cube's, the view's and the buffer texture's
|
||||
// translation units keep calling an inherited helper.
|
||||
//
|
||||
// resource_respecify. Called from BumpShapeVersion and from the three parameter
|
||||
// setters that move a DESCRIPTOR field without moving the shape (immutable levels,
|
||||
@@ -230,9 +228,11 @@ namespace MobileGL::MG_State::GLState {
|
||||
void PipePublishDescriptor();
|
||||
// set_texture_params, from every mutator that bumps m_textureParamsVersion.
|
||||
void PipePublishParams();
|
||||
// The sub-data DRAIN LIST. `dirty` false is a level going clean - a respecify, a
|
||||
// truncation, or the emitter's own clear after an accepted record.
|
||||
void PipeNoteLevelDirty(TextureUploadTarget uploadTarget, Uint mipmapLevel, Bool dirty);
|
||||
// The sub-data DRAIN LIST's append, on a level's first dirty mark. There is no clean
|
||||
// arm: the contract's hook (MG_Pipe/PipeMutation.h) carries no `dirty` flag, and a
|
||||
// level that goes clean is collected at the next drain, where !IsStorageDirty is the
|
||||
// first test EmitOneLevel makes.
|
||||
void PipeNoteLevelDirty(TextureUploadTarget uploadTarget, Uint mipmapLevel);
|
||||
#endif
|
||||
|
||||
const Uint m_externalIndex;
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace MobileGL {
|
||||
#if MOBILEGL_PIPE_PUSH
|
||||
// SIX FACES, SIX BLOBS, SIX DRAIN KEYS: the upload target is the face, and it is
|
||||
// what the sub-data record's Target byte carries beside the resource target.
|
||||
PipeNoteLevelDirty(uploadTarget, mipmapLevel, dirty);
|
||||
if (dirty) PipeNoteLevelDirty(uploadTarget, mipmapLevel);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ namespace MobileGL {
|
||||
m_textureStorage.MarkDirtyRegion(GetIndexOfTextureUploadTarget(uploadTarget), mipmapLevel, offset,
|
||||
size);
|
||||
#if MOBILEGL_PIPE_PUSH
|
||||
PipeNoteLevelDirty(uploadTarget, mipmapLevel, true);
|
||||
PipeNoteLevelDirty(uploadTarget, mipmapLevel);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user