[2.2] Two texture issue and our fixes Topic is solved

Design / architecture / roadmap discussions related to future of Ogre3D (version 2.0 and above)
Post Reply
rujialiu
Gremlin
Posts: 180
Joined: Mon May 09, 2016 8:21 am
x 12

[2.2] Two texture issue and our fixes

Post by rujialiu » Thu Feb 07, 2019 4:16 am

Hi!

1. Today our app crashed due to a typo in DescriptorSetSampler:

Code: Select all

--- a/OgreMain/include/OgreDescriptorSetSampler.h
+++ b/OgreMain/include/OgreDescriptorSetSampler.h
@@ -67,7 +67,7 @@ namespace Ogre
         bool operator != ( const DescriptorSetSampler &other ) const
         {
-            const size_t thisNumSamplers = other.mSamplers.size();
+            const size_t thisNumSamplers = mSamplers.size();
             if( thisNumSamplers != other.mSamplers.size() )
                 return true;
2. And found another bug: when calling [MTLBlitCommandEncoder copyFromBuffer:],if toTexture's pixelFormat is MTLPixelFormatASTC_*,AND buffer already has PFG_R8_UINT and PFG_ASTC_RGBA_* format textures, we will get the following assertion:

Code: Select all

[MTLDebugBlitCommandEncoder validate CopyFromBuffer:sourceOffset:sourceBytesPerRow:sourceBytesPerImage:sourceSize:toTexture:destinationSlice:destinationLevel:destinationOrigin:options:]:502: failed assertion `sourceOffset (520) must be a multiple of 16 bytes.'
We don't know the correct way to solve this, but we had a temporary fix that works for us:

Code: Select all

bool StagingTextureBufferImpl::supportsFormat( uint32 width, uint32 height, uint32 depth,
                                                   uint32 slices, PixelFormatGpu pixelFormat ) const
    {
//////////// added by a teammate of mine
        if (pixelFormat >= PFG_ASTC_RGBA_UNORM_4X4_LDR && pixelFormat <= PFG_ASTC_RGBA_UNORM_12X12_sRGB) {
            if (mFormatFamily < PFG_ASTC_RGBA_UNORM_4X4_LDR || mFormatFamily > PFG_ASTC_RGBA_UNORM_12X12_sRGB)
                return false;
        } else {
            if (mFormatFamily >= PFG_ASTC_RGBA_UNORM_4X4_LDR && mFormatFamily <= PFG_ASTC_RGBA_UNORM_12X12_sRGB)
                return false;
        }
/////////////// added by a teammate of mine
        const uint32 rowAlignment = 4u;
        size_t requiredSize = PixelFormatGpuUtils::getSizeBytes( width, height, depth, slices,
                                                                 pixelFormat, rowAlignment );
        return requiredSize <= mSize;
    }
After the fix, we're able to use ASTC+KTX+mipmaps, mixed with other texture formats.

- Rujia
0 x

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 3947
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 172
Contact:

Re: [2.2] Two texture issue and our fixes

Post by dark_sylinc » Thu Feb 07, 2019 4:51 am

Your ASTC fix will work, but it's a bit extreme (it will waste memory).
I fixed it in a more conservative way.

Also thanks for the DescriptorSetSampler fix. Nice catch. I'd love if C++ would let us automate operator generation.
0 x

rujialiu
Gremlin
Posts: 180
Joined: Mon May 09, 2016 8:21 am
x 12

Re: [2.2] Two texture issue and our fixes

Post by rujialiu » Sun Feb 10, 2019 10:43 am

dark_sylinc wrote:
Thu Feb 07, 2019 4:51 am
Your ASTC fix will work, but it's a bit extreme (it will waste memory).
I fixed it in a more conservative way.

Also thanks for the DescriptorSetSampler fix. Nice catch. I'd love if C++ would let us automate operator generation.
Thanks!
0 x

Post Reply