I want to create a 1 bit per pixel monochrome texture 2D in DirectX 11 using dxgi format DXGI_FORMAT_R1_UNORM I have done trying the following but it's showing following errors:
D3D11 ERROR: ID3D11Device::CreateTexture2D: Device does not support the format R1_UNORM. [ STATE_CREATION ERROR #92: CREATETEXTURE2D_UNSUPPORTEDFORMAT] D3D11: BREAK enabled for the previous message, which was: [ ERROR STATE_CREATION #92: CREATETEXTURE2D_UNSUPPORTEDFORMAT ]
I have tried to create a texture for rendering but it's says as you seen above The "R1_UNORM" does not supported by device. So, which format should be used to create the texture 2D?
The bitmapPixels is a dynamic memory of 1 bit color array in BYTE, prepared from this algorithm which is under review Code Review: Bit Packing algorithm of 1-Bit monochrome image
D3D11_TEXTURE2D_DESC desc;
ZeroMemory(&desc, sizeof(desc));
desc.Width = 32;
desc.Height = 32;
desc.ArraySize = 1;
desc.Format = DXGI_FORMAT_R1_UNORM;
desc.Usage = D3D11_USAGE_DEFAULT;
desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
desc.MipLevels = 1;
desc.SampleDesc.Count = 1;
desc.MiscFlags = 0;
const D3D11_SUBRESOURCE_DATA subResourceData = {bitmapPixels, 4, 4 * desc.Height};
device->CreateTexture2D(&desc, &subResourceData, &texture2D);