Cannot create a Texture2D with a format of Bgra4444 [DirectX, Windows Store, Windows UWP]

I am trying to create a rendertarget with a format of Bgra4444

This results in a backing Texture2D being created with a directX format of B4G4R4A4_UNorm

Which crashes on the line “return new SharpDX.Direct3D11.Texture2D(GraphicsDevice._d3dDevice, desc);”
in the method “internal override SharpDX.Direct3D11.Resource CreateTexture()”
in the “Texture2D.DirectX.cs” file.

I am using a version of monogame from about 1 week ago from the main dev branch.

I am building for windows UWP, and running on a machine with a GeForce 960.

I have created a graphics device with all the featureLevels from Level_9_1 to Level_10_1 inclusive.

The error is:

Exception thrown: ‘SharpDX.SharpDXException’ in SharpDX.dll
An exception of type ‘SharpDX.SharpDXException’ occurred in SharpDX.dll but was not handled in user code
Additional information: HRESULT: [0x80070057], Module: [General], ApiCode: [E_INVALIDARG/Invalid Arguments], Message: The parameter is incorrect.

Any help in getting this fixed would be very appreciated, any suggestions of workarounds to get this working would be great. I would rather keep these textures in memory as the 4444 format as there is about 200mb of them which is significant and due to the nature of these textures there is almost zero quality loss with using 4444, and using a DXT format makes them look horrible due to the block compression.

I have made an issue on the monogame GitHub about it below.

I think Dev Branch questions need their own board really… quite irritating to come into one post and then find out it is a dev branch issue… :expressionless:

Or Tag the title with [DEV] ? Or [MG-Vx.y] ?

:cherries:

That could work too :slight_smile: but it still relies on the user doing one or the other…

Sure. But too bad for them, they loose time with the question about the build of MG right after, instead of a helping answer :wink:

Not really… it works both ways, I/We/Those whom currently do not use the dev branch waste less time reading a post about dev branch, and they get people who are familiar with the dev branch… and willing to help.

So is this only an issue in the dev branch?

I did try to add a tag to the GitHub issue but I didn’t have the privilege to set one.

I think it doesn’t work in the old release either, I’ve had troubles with non default formats before. Afaik it doesn’t work as a RT either

I didn’t think it was a new bug either. But I could be wrong.

Found the cause. DirectX 11 does not support the use of 16-bit formats Bgr565, Bgra5551 or Bgra4444 for render targets. DirectX 11.1 (or more correctly, DXGI 1.2) does support 16-bit formats for render targets.
https://msdn.microsoft.com/en-us/library/windows/desktop/ff471325(v=vs.85).aspx

I have submitted a PR (#5340) that implements the fallback to SurfaceFormat.Color for render targets if the preferredFormat is not supported, and similar for the preferredDepthFormat. This is what XNA did anyway if the requested format wasn’t supported, so we’re not losing functionality here.

1 Like