Mipmap HW Generation Non-Power-Two Topic is solved

What it says on the tin: a place to discuss proposed new features.
Post Reply
cyberjunk
Halfling
Posts: 51
Joined: Tue Jun 05, 2012 4:33 pm

Mipmap HW Generation Non-Power-Two

Post by cyberjunk » Tue Jul 12, 2016 4:50 am

Hey,

the following line disables mipmap hardware generation for non power-of-two texture sizes in the 1.10 branch (d3d9):

Code: Select all

// Hacky override - many (all?) cards seem to not be able to autogen on 
// textures which are not a power of two
// Can we even mipmap on 3D textures? Well
if ((mWidth & mWidth-1) || (mHeight & mHeight-1) || (mDepth & mDepth-1))
  return false;
From: https://bitbucket.org/sinbad/ogre/src/f ... e.cpp-1677

However, the manual creation of mipmaps (which is caused by this line) seems to be the most expansive task for me when loading larger textures (e.g. 1364x638 and beyond). Note: I didn't chose non-power-of-two textures... I just have to deal with it... :D

I removed this check so mipmaps get hw created for non-power-of-two sizes and it seems to work perfectly for me.
System is: Win10 + Ogre 1.10 + Nvidia GTX 660

Is it possible this exclusion for non-power-of-two textures is rather obsolete by now?
Due to its great influence on loading time, I would like to suggest:

1) Consider enabling hw generation (=remove the exclusion). In case any target GPU past e.g. 2010 can do it just fine?
2) May be provide a config option to enable or disable hw mipmaps for non-power-of-two textures..

Thanks!
Last edited by cyberjunk on Wed Jul 13, 2016 5:05 am, edited 1 time in total.
0 x

cyberjunk
Halfling
Posts: 51
Joined: Tue Jun 05, 2012 4:33 pm

Re: Mipmap HW Generation Non-Power-Two

Post by cyberjunk » Wed Jul 13, 2016 2:52 am

This snippet from the OgreD3D9Texture.cpp:

Code: Select all

// use auto.gen. if available, and if desired
mMipmapsHardwareGenerated = _canAutoGenMipmaps(d3d9Device, usage, D3DRTYPE_TEXTURE, d3dPF);
if (mMipmapsHardwareGenerated)
{
  usage |= D3DUSAGE_AUTOGENMIPMAP;
  numMips = 0;
}
From: https://bitbucket.org/sinbad/ogre/src/f ... e.cpp-1078

The 'numMips' will actually be used in the call to 'D3DXCreateTexture()' later.
It seems that if hardware generation is enabled, it will always create mipmaps up to 1x1 and ignore any setting for it. Is that right?
If this value is zero or D3DX_DEFAULT, a complete mipmap chain is created.
From: https://msdn.microsoft.com/en-us/librar ... s.85).aspx

I've tried uncommenting the following statement from above and it seems mitmaps are still generated fine (and possibly faster due to less levels if set so)

Code: Select all

//numMips = 0;
Furthermore I'd like to add, that this snippet (which is executed at the end of texture creation) will always set 'mNumMipmaps' to 0 for hw-generated:

Code: Select all

// Make sure number of mips is right
mNumMipmaps = static_cast<uint8>(textureResources->pBaseTex->GetLevelCount() - 1);
From: https://bitbucket.org/sinbad/ogre/src/f ... e.cpp-1730
Warning If you create a texture with D3DUSAGE_AUTOGENMIPMAP to make that texture automatically generate sublevels, GetLevelCount always returns 1 for the number of levels.
From: https://msdn.microsoft.com/en-us/librar ... s.85).aspx

This will actually cause incorrect logs created (not mentioning the mipmaps at all), because this is checking for 'nNumMipmaps'

Code: Select all

if (!(mMipmapsHardwareGenerated && mNumMipmaps == 0))
{
  str << " with " << static_cast<int>(mNumMipmaps);
  if(mUsage & TU_AUTOMIPMAP)
  {
    if (mMipmapsHardwareGenerated)
      str << " hardware";
  
   str << " generated mipmaps";
...
From: https://bitbucket.org/sinbad/ogre/src/f ... re.cpp-254
0 x

cyberjunk
Halfling
Posts: 51
Joined: Tue Jun 05, 2012 4:33 pm

Re: Mipmap HW Generation Non-Power-Two

Post by cyberjunk » Tue Jul 19, 2016 5:38 am

Anyone reviewed this?

I've tested on a couple of other GPU hardware, back to "Nvidia 9650M GT" from ~2008, and they all seem to do hw mipmaps also for non-power-of-two just fine.
I've also rolled out this change with the latest patch for my game client and got no negative user feedback so far...

I guess a RenderSystem option might be the best solution?
To maintain backward compatibility, but enable hw mipmaps for non-power-of-two by default or optionally?
0 x

User avatar
Zonder
Gargoyle
Posts: 1097
Joined: Mon Aug 04, 2008 7:51 pm
Location: Manchester - England
x 8

Re: Mipmap HW Generation Non-Power-Two

Post by Zonder » Tue Jul 19, 2016 8:02 am

For compatibility it probably should be an option I think that can be enabled. I don't get why it doesn't attempt hardware then drop to software if that fails? maybe some drivers hard carsh? might be worth seeing if there was an issue logged with the commit for that change.
0 x
There are 10 types of people in the world: Those who understand binary, and those who don't...
My Blog - http://www.This post is suspected as SPAM! If you feel otherwise contact a moderator.

paroj
OGRE Team Member
OGRE Team Member
Posts: 570
Joined: Sun Mar 30, 2014 2:51 pm
x 81
Contact:

Re: Mipmap HW Generation Non-Power-Two

Post by paroj » Fri Mar 03, 2017 7:35 pm

fixed in 1.10. next time open an issue: https://ogre3d.atlassian.net/projects/OGRE/issues
0 x

cyberjunk
Halfling
Posts: 51
Joined: Tue Jun 05, 2012 4:33 pm

Re: Mipmap HW Generation Non-Power-Two

Post by cyberjunk » Sun May 07, 2017 2:29 am

@paroj

Thanks for having a look at this.
Yes, I should have opened a ticket in first place.

I did now:
https://ogre3d.atlassian.net/browse/OGRE-551

Because it seems to me that mentioned problems here about the user-defined mipmap count being ignored and the omitted log-info were not covered in your commit.
0 x

Post Reply