DirectXTex icon indicating copy to clipboard operation
DirectXTex copied to clipboard

UINT and SINT formats in texconv

Open Puxtril opened this issue 1 year ago • 6 comments

The help menu for texconv lists many DXGI formats of type UINT and SINT. Whenever I try to convert textures (from png/jpg) to these formats, texconv seems to output incorrect textures. Looking at the output in a hex editor, UINT and SINT only contain bytes of value 0 or 1. Is this intended behavior?

Textures.zip

Puxtril avatar Jun 18 '24 03:06 Puxtril

The values coming out of the PNG are expressed in float-point numbers which will be 0 to 1. When storing them as UINT or SINT, it's going to result in 0 or 1. If you want the values to range for all the supported integers, that is what UNORM and SNORM do.

walbourn avatar Jun 18 '24 21:06 walbourn

So in this case, it sounds like an issue with PNGs storing data as floats. Is there an input format that works better for this conversion?

Puxtril avatar Jun 19 '24 04:06 Puxtril

All image processing in DirectXTex is done with floating-point to take advantage of SIMD operations.

What is it you expect to happen converting a classic 8-bit UNORM image to a 32-bit UINT image?

walbourn avatar Jun 19 '24 19:06 walbourn

I just expected the end result to be similar to UNORM/SNORM conversions, considering the documentation on Microsoft states the underlying storage format for UNORM/UINT are identical (unsigned integer). And since texconv converted without throwing an error, I was confused why end results varied so much. It was a misunderstanding on my part.

I'm using texconv to generate test data for a project I'm working on using a random png I found online. Now I'm just wondering what would be a better source format to use for generating a valid UINT/SINT image.

Puxtril avatar Jun 19 '24 21:06 Puxtril

There are special conversion cases for doing to/from UNORM/SNORM formats which are not applied to UINT/SINT. This in large part because UINT/SINT doesn't have any specific meaning in textures: it's just a raw format used by compute shaders.

I'm open to adding some special conversion here, but it's not clear to me what is the logical behavior.

walbourn avatar Jun 21 '24 21:06 walbourn

I don't have any ideas for conversions, as I'm not familiar with UINT/SINT in standard use cases. But now I have a better understanding of how texconv sees those formats (doesn't do any conversion).

I'm fine with closing the issue as my questions have been answered.

Puxtril avatar Jun 23 '24 19:06 Puxtril