mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-11-19 07:51:57 +09:00
[MG_Remote, Espryt] copy image regions through server-owned renderbuffer handles
This commit is contained in:
@@ -38,12 +38,19 @@ namespace MobileGL {
|
|||||||
SharedPtr<MG_State::GLState::RenderbufferObject> Renderbuffer;
|
SharedPtr<MG_State::GLState::RenderbufferObject> Renderbuffer;
|
||||||
#if MOBILEGL_BUILD_DISAGGREGATED
|
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||||
MG_Pipe::MGPipeHandle TextureHandle = MG_Pipe::kMGPipeNullHandle;
|
MG_Pipe::MGPipeHandle TextureHandle = MG_Pipe::kMGPipeNullHandle;
|
||||||
|
MG_Pipe::MGPipeHandle RenderbufferHandle = MG_Pipe::kMGPipeNullHandle;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Bool IsRenderbuffer() const { return Renderbuffer != nullptr; }
|
Bool IsRenderbuffer() const {
|
||||||
|
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||||
|
if (!MG_Pipe::MGPipeHandleIsNull(RenderbufferHandle)) return true;
|
||||||
|
#endif
|
||||||
|
return Renderbuffer != nullptr;
|
||||||
|
}
|
||||||
Bool Exists() const {
|
Bool Exists() const {
|
||||||
#if MOBILEGL_BUILD_DISAGGREGATED
|
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||||
if (!MG_Pipe::MGPipeHandleIsNull(TextureHandle)) return true;
|
if (!MG_Pipe::MGPipeHandleIsNull(TextureHandle)) return true;
|
||||||
|
if (!MG_Pipe::MGPipeHandleIsNull(RenderbufferHandle)) return true;
|
||||||
#endif
|
#endif
|
||||||
return Texture != nullptr || Renderbuffer != nullptr;
|
return Texture != nullptr || Renderbuffer != nullptr;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12508,6 +12508,16 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
static Bool MakeGLESCopyImageEndpoint(const CopyImageEndpoint& endpoint, GLenum appTarget, GLint x, GLint y,
|
static Bool MakeGLESCopyImageEndpoint(const CopyImageEndpoint& endpoint, GLenum appTarget, GLint x, GLint y,
|
||||||
GLint z, GLESCopyImageEndpoint& out) {
|
GLint z, GLESCopyImageEndpoint& out) {
|
||||||
if (endpoint.IsRenderbuffer()) {
|
if (endpoint.IsRenderbuffer()) {
|
||||||
|
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||||
|
if (MG_Config::Transport != MG_Config::TransportMode::Monolith) {
|
||||||
|
if (!PipeRenderbufferRecordForHandle(endpoint.RenderbufferHandle)) return false;
|
||||||
|
auto* slot = RenderbufferImpl::g_backendRenderbufferObjects.GetOrCreateByHandle(endpoint.RenderbufferHandle);
|
||||||
|
if (!slot) return false;
|
||||||
|
if (!*slot) *slot = MakeShared<RenderbufferImpl::BackendRenderbufferObject>();
|
||||||
|
out.renderbuffer = *slot;
|
||||||
|
out.renderbuffer->SyncToBackendByHandle(endpoint.RenderbufferHandle);
|
||||||
|
} else
|
||||||
|
#endif
|
||||||
out.renderbuffer = SyncRenderbufferObjectToBackend(endpoint.Renderbuffer);
|
out.renderbuffer = SyncRenderbufferObjectToBackend(endpoint.Renderbuffer);
|
||||||
if (!out.renderbuffer) return false;
|
if (!out.renderbuffer) return false;
|
||||||
out.target = GL_RENDERBUFFER;
|
out.target = GL_RENDERBUFFER;
|
||||||
@@ -12556,7 +12566,9 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
static TextureInternalFormat GetCopyImageEndpointFormat(const CopyImageEndpoint& endpoint) {
|
static TextureInternalFormat GetCopyImageEndpointFormat(const CopyImageEndpoint& endpoint) {
|
||||||
#if MOBILEGL_BUILD_DISAGGREGATED
|
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||||
if (MG_Config::Transport != MG_Config::TransportMode::Monolith) {
|
if (MG_Config::Transport != MG_Config::TransportMode::Monolith) {
|
||||||
const auto* record = PipeTextureRecordForHandle(endpoint.TextureHandle);
|
const auto* record = endpoint.IsRenderbuffer()
|
||||||
|
? PipeRenderbufferRecordForHandle(endpoint.RenderbufferHandle)
|
||||||
|
: PipeTextureRecordForHandle(endpoint.TextureHandle);
|
||||||
return record ? static_cast<TextureInternalFormat>(record->Desc.InternalFormat)
|
return record ? static_cast<TextureInternalFormat>(record->Desc.InternalFormat)
|
||||||
: TextureInternalFormat::Unknown;
|
: TextureInternalFormat::Unknown;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1274,19 +1274,21 @@ namespace MobileGL::MG_Remote::Client {
|
|||||||
// way to rebuild one from a name, and none was measured. P7 is where the backend
|
// way to rebuild one from a name, and none was measured. P7 is where the backend
|
||||||
// takes handles and this arm becomes ordinary. The sink refuses the same shape by
|
// takes handles and this arm becomes ordinary. The sink refuses the same shape by
|
||||||
// the same name if a record ever reaches it (defence on both sides of one wire).
|
// the same name if a record ever reaches it (defence on both sides of one wire).
|
||||||
if (src.IsRenderbuffer() || dst.IsRenderbuffer()) {
|
|
||||||
UnmigratedVerbFatal("CopyImageSubData+RENDERBUFFER");
|
|
||||||
}
|
|
||||||
|
|
||||||
MG_Pipe::MGPCopyRegion record{};
|
MG_Pipe::MGPCopyRegion record{};
|
||||||
record.Src = PublishedTextureHandle(src.Texture);
|
const auto handle = [](const MG_Backend::CopyImageEndpoint& endpoint) {
|
||||||
record.Dst = PublishedTextureHandle(dst.Texture);
|
return endpoint.IsRenderbuffer()
|
||||||
|
? MG_Pipe::MGPipeSlots().FindByLifetimeId(MG_Pipe::MGPipeKind::Renderbuffer,
|
||||||
|
endpoint.Renderbuffer->GetLifetimeId())
|
||||||
|
: PublishedTextureHandle(endpoint.Texture);
|
||||||
|
};
|
||||||
|
record.Src = handle(src);
|
||||||
|
record.Dst = handle(dst);
|
||||||
// The GL names beside the handles: the key MGB_CTX->GetTextureObject(name) takes on
|
// The GL names beside the handles: the key MGB_CTX->GetTextureObject(name) takes on
|
||||||
// the far side (a BARRIER-PULLED sticky forward, counted in `rsp`, retired by P7).
|
// the far side (a BARRIER-PULLED sticky forward, counted in `rsp`, retired by P7).
|
||||||
record.SrcGlName =
|
record.SrcGlName =
|
||||||
src.Texture ? static_cast<Uint32>(src.Texture->GetExternalIndex()) : 0u;
|
src.IsRenderbuffer() ? src.Renderbuffer->GetExternalIndex() : src.Texture->GetExternalIndex();
|
||||||
record.DstGlName =
|
record.DstGlName =
|
||||||
dst.Texture ? static_cast<Uint32>(dst.Texture->GetExternalIndex()) : 0u;
|
dst.IsRenderbuffer() ? dst.Renderbuffer->GetExternalIndex() : dst.Texture->GetExternalIndex();
|
||||||
// The GL targets verbatim, in a Uint16 - every GL texture target fits one. NOT
|
// The GL targets verbatim, in a Uint16 - every GL texture target fits one. NOT
|
||||||
// MGPipeResourceTarget: the sink only ever forwards these to a slot that takes GL
|
// MGPipeResourceTarget: the sink only ever forwards these to a slot that takes GL
|
||||||
// enums, and the tree has no resource-target -> GL-enum inverse to spend on them.
|
// enums, and the tree has no resource-target -> GL-enum inverse to spend on them.
|
||||||
|
|||||||
@@ -893,16 +893,15 @@ namespace MobileGL::MG_Remote::Server {
|
|||||||
// record that reached here anyway: no sticky forward hands out a RenderbufferObject, so
|
// record that reached here anyway: no sticky forward hands out a RenderbufferObject, so
|
||||||
// there is no honest way to build the endpoint, and guessing an empty one would copy
|
// there is no honest way to build the endpoint, and guessing an empty one would copy
|
||||||
// nothing and say it copied.
|
// nothing and say it copied.
|
||||||
if (copy.SrcTarget == GL_RENDERBUFFER || copy.DstTarget == GL_RENDERBUFFER) {
|
|
||||||
ServerUnmigratedVerbFatal("CopyImageSubData+RENDERBUFFER");
|
|
||||||
}
|
|
||||||
|
|
||||||
// P5f fe: both texture identities already travel in the record. Pass those handles
|
// P5f fe: both texture identities already travel in the record. Pass those handles
|
||||||
// to the backend's server-owned texture table; GL names are diagnostic data only.
|
// to the backend's server-owned texture table; GL names are diagnostic data only.
|
||||||
MG_Backend::CopyImageEndpoint src{};
|
MG_Backend::CopyImageEndpoint src{};
|
||||||
MG_Backend::CopyImageEndpoint dst{};
|
MG_Backend::CopyImageEndpoint dst{};
|
||||||
src.TextureHandle = copy.Src;
|
if (copy.SrcTarget == GL_RENDERBUFFER) src.RenderbufferHandle = copy.Src;
|
||||||
dst.TextureHandle = copy.Dst;
|
else src.TextureHandle = copy.Src;
|
||||||
|
if (copy.DstTarget == GL_RENDERBUFFER) dst.RenderbufferHandle = copy.Dst;
|
||||||
|
else dst.TextureHandle = copy.Dst;
|
||||||
if (MG_Pipe::MGPipeHandleIsNull(copy.Src) || MG_Pipe::MGPipeHandleIsNull(copy.Dst)) {
|
if (MG_Pipe::MGPipeHandleIsNull(copy.Src) || MG_Pipe::MGPipeHandleIsNull(copy.Dst)) {
|
||||||
// The monolith's own answer to this, in its own words (DirectGLES.cpp:9067
|
// The monolith's own answer to this, in its own words (DirectGLES.cpp:9067
|
||||||
// "source or destination image failed to sync; declining the copy"): the frontend
|
// "source or destination image failed to sync; declining the copy"): the frontend
|
||||||
|
|||||||
Reference in New Issue
Block a user