GFX: add support for cubemap texture arrays

Previously we only supported cube textures, this patch implements support for cube texture arrays.
This commit is contained in:
Kawe Mazidjatari 2025-01-15 14:00:56 +01:00
parent aa405dc4c3
commit 2083bc73fa

View File

@ -198,18 +198,35 @@ void CreateTextureResource(TextureAsset_s* textureHeader, INT_PTR imageData)
shaderResource.Format = dxgiFormat;
shaderResource.Texture2D.MipLevels = textureHeader->textureMipLevels;
if (textureHeader->arraySize > 1) // Do we have a texture array?
const u8 arraySize = textureHeader->arraySize;
if (arraySize > 1) // Do we have a texture array?
{
const bool isCubeMap = (textureHeader->layerCount & 2);
if (!isCubeMap)
{
shaderResource.Texture2DArray.FirstArraySlice = 0;
shaderResource.Texture2DArray.ArraySize = textureHeader->arraySize;
shaderResource.ViewDimension = D3D_SRV_DIMENSION_TEXTURE2DARRAY;
shaderResource.Texture2DArray.FirstArraySlice = 0;
shaderResource.Texture2DArray.ArraySize = arraySize;
}
else
shaderResource.ViewDimension = D3D_SRV_DIMENSION_TEXTURECUBE;
{
// Cube textures have 6 faces to form the cube; one texture per
// cube face. If we have more, we have a cube map array.
if (arraySize == 6)
shaderResource.ViewDimension = D3D_SRV_DIMENSION_TEXTURECUBE;
else
{
// Must have a multiple of 6 textures per cube in the array,
// else we have one or more cubes with missing faces.
Assert(arraySize % 6 == 0);
shaderResource.ViewDimension = D3D_SRV_DIMENSION_TEXTURECUBEARRAY;
shaderResource.Texture2DArray.FirstArraySlice = 0;
shaderResource.Texture2DArray.ArraySize = arraySize / 6;
}
}
}
else
{