mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-11-28 12:12:16 +09:00
[Fix] (MG_Backend/DirectGLES): require raw RGBA8 for packed texture uploads
- Check the shadow format before copying bytes into the staging texture. - Document the draw-batch scope of sampled-storage tracking.
This commit is contained in:
1 parent
94d729c493
commit
6ad3d3f519
2 files changed
+13
-7
No files matched your search
@@ -14,6 +14,8 @@
|
|||||||
namespace MobileGL::MG_Backend::DirectGLES::TextureImpl {
|
namespace MobileGL::MG_Backend::DirectGLES::TextureImpl {
|
||||||
// One instance per native context. Slot generations distinguish reused texture names,
|
// One instance per native context. Slot generations distinguish reused texture names,
|
||||||
// and batch stamps let us discard a batch without walking its texture slots.
|
// and batch stamps let us discard a batch without walking its texture slots.
|
||||||
|
// This upload heuristic follows sampler reads from offscreen draws and the framebuffer
|
||||||
|
// changes observed by BindCurrentFBO. Compute dispatches do not record reads here.
|
||||||
class DrawTextureReads {
|
class DrawTextureReads {
|
||||||
public:
|
public:
|
||||||
void BindFramebuffer(std::uint32_t framebuffer) {
|
void BindFramebuffer(std::uint32_t framebuffer) {
|
||||||
|
|||||||
@@ -1640,9 +1640,10 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const auto mipmapCount = MGB_STORAGE_LEVELS(textureMipmapObject);
|
const auto mipmapCount = MGB_STORAGE_LEVELS(textureMipmapObject);
|
||||||
|
const auto storageFormat = MGB_STORAGE_FORMAT(textureMipmapObject);
|
||||||
GLenum glInternalFormat, glType, glFormat;
|
GLenum glInternalFormat, glType, glFormat;
|
||||||
TextureImpl::GenerateTextureFormatInfo(MGB_STORAGE_FORMAT(textureMipmapObject), &glInternalFormat,
|
TextureImpl::GenerateTextureFormatInfo(storageFormat, &glInternalFormat, &glFormat, &glType,
|
||||||
&glFormat, &glType, targetInternal);
|
targetInternal);
|
||||||
// The storage this level is being written into was widened when it was minted
|
// The storage this level is being written into was widened when it was minted
|
||||||
// (see above), so the transfer pair has to describe the carrier here too - ES
|
// (see above), so the transfer pair has to describe the carrier here too - ES
|
||||||
// requires glTexSubImage's `format` to match the storage's base internal
|
// requires glTexSubImage's `format` to match the storage's base internal
|
||||||
@@ -1652,15 +1653,18 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
ScopedDefaultUnpackState unpackState;
|
ScopedDefaultUnpackState unpackState;
|
||||||
// Update sampled storage directly to avoid stalling the current offscreen batch on a PBO.
|
// Update sampled storage directly to avoid stalling the current offscreen batch on a PBO.
|
||||||
const Bool useClientUnpack = stableStorage && WasTextureReadInDrawBatch(pushedRes);
|
const Bool useClientUnpack = stableStorage && WasTextureReadInDrawBatch(pushedRes);
|
||||||
|
// The staging page copies the shadow bytes as-is. Check the shadow and driver
|
||||||
|
// formats because a driver format can also be used for converted client data.
|
||||||
|
const Bool rawRgba8Copy = storageFormat == TextureInternalFormat::RGBA8 &&
|
||||||
|
glInternalFormat == GL_RGBA8 && glFormat == GL_RGBA &&
|
||||||
|
glType == GL_UNSIGNED_BYTE;
|
||||||
// Pack the small writes across all dirty mip levels before their
|
// Pack the small writes across all dirty mip levels before their
|
||||||
// per-level union boxes can pull in untouched atlas texels. The packed
|
// 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.
|
// copies write the destination on the GPU too, so sampled storage skips them.
|
||||||
if (stableStorage && !useClientUnpack && !m_driverMayHoldGpuWrites && !m_packedUploadRejected &&
|
if (stableStorage && !useClientUnpack && !m_driverMayHoldGpuWrites && !m_packedUploadRejected &&
|
||||||
!m_imageBindableStorageRequired && target == GL_TEXTURE_2D &&
|
!m_imageBindableStorageRequired && target == GL_TEXTURE_2D && rawRgba8Copy &&
|
||||||
(glInternalFormat == GL_RGBA8 || glInternalFormat == GL_RGBA) && glFormat == GL_RGBA &&
|
pushedStorage != nullptr && uploadTargets.size() == 1 && g_GLESFuncs.glCopyImageSubData &&
|
||||||
glType == GL_UNSIGNED_BYTE && pushedStorage != nullptr && uploadTargets.size() == 1 &&
|
g_GLESFuncs.glTexStorage2D && BufferImpl::UnpackRingAvailable()) {
|
||||||
g_GLESFuncs.glCopyImageSubData && g_GLESFuncs.glTexStorage2D &&
|
|
||||||
BufferImpl::UnpackRingAvailable()) {
|
|
||||||
const auto result = TryPackedMipUpload(textureMipmapObject, pushedStorage, pushedRes,
|
const auto result = TryPackedMipUpload(textureMipmapObject, pushedStorage, pushedRes,
|
||||||
uploadTargets.front(), mipmapCount, m_backendTextureId);
|
uploadTargets.front(), mipmapCount, m_backendTextureId);
|
||||||
if (result == PackedUploadResult::Rejected) {
|
if (result == PackedUploadResult::Rejected) {
|
||||||
|
|||||||
Reference in new issue
Block a user