Lacking true 8-bit pixel formats in D3D11 mappings [1.10 & 2.1]

Minor issues with the Ogre API that can be trivial to fix
Post Reply
Posts: 4
Joined: Mon Apr 09, 2018 1:35 pm

Lacking true 8-bit pixel formats in D3D11 mappings [1.10 & 2.1]

Post by garbage_collector »

With Direct3D 9 our application used PF_L8 for a manual 8-bit bayer texture, written from CPU. We read it in the shader by accessing the r-component of the texture lookup.

In Direct3D 11 (Ogre 1.10) there is some code in D3D11Texture::createInternalResourcesImpl that changes L8 to R8G8B8, which means our application can't use it anymore (we really need the 8-bit pixel size). The proposed solution by the inline comment is to use PF_R8... But, PF_R8 does not have any mapping in D3D11Mappings::_getPF.. I believe there should be a mapping to DXGI_FORMAT_R8_UNORM which is currently missing?!

Code: Select all

// PF_L8 maps to DXGI_FORMAT_R8_UNORM and grayscale textures became "redscale", without green and blue components.
// This can be fixed by shader modification, but here we can only convert PF_L8 to PF_R8G8B8 manually to fix the issue.
// Note, that you can use PF_R8 to explicitly request "redscale" behavior for grayscale textures, avoiding overhead.
if(mFormat == PF_L8)
    mFormat = PF_R8G8B8;
So, we ended up having to use PF_A8 (reading the a-component in the shader) because that seemed to be the only Ogre PF that mapped to a D3D11 8-bit PF...

(I haven't tried this in Ogre 2.1, but by looking at the code there seems to be similar lack of mappings in D3D11Mappings::_getPF)

How about adding a mapping from PF_R8 to DXGI_FORMAT_R8_UNORM in latest 1.10? (and preferably in 2.1 etc as well)

OGRE Team Member
OGRE Team Member
Posts: 1157
Joined: Sun Mar 30, 2014 2:51 pm
x 432

Re: Lacking true 8-bit pixel formats in D3D11 mappings [1.10 & 2.1]

Post by paroj »

yes, I agree that PF_R8 should be added to D3D11Mappings::_getPF.

can you create a pull-requests with your proposed changes at:

Post Reply