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

Discussion area about developing with Ogre-Next (2.1, 2.2 and beyond)


Post Reply
rujialiu
Goblin
Posts: 296
Joined: Mon May 09, 2016 8:21 am
x 35

[2.2] Two texture issue and our fixes

Post by rujialiu »

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
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: [2.2] Two texture issue and our fixes

Post by dark_sylinc »

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.
rujialiu
Goblin
Posts: 296
Joined: Mon May 09, 2016 8:21 am
x 35

Re: [2.2] Two texture issue and our fixes

Post by rujialiu »

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!
Post Reply