| 803 | } |
| 804 | |
| 805 | std::shared_ptr<IBlob> SaveStagingTextureAsDDS(nvrhi::IDevice* device, nvrhi::IStagingTexture* stagingTexture) |
| 806 | { |
| 807 | DDS_HEADER header = {}; |
| 808 | DDS_HEADER_DXT10 dx10header = {}; |
| 809 | const nvrhi::TextureDesc& textureDesc = stagingTexture->getDesc(); |
| 810 | |
| 811 | header.size = sizeof(DDS_HEADER); |
| 812 | header.flags = DDS_HEADER_FLAGS_TEXTURE; |
| 813 | header.width = textureDesc.width; |
| 814 | header.height = textureDesc.height; |
| 815 | header.depth = textureDesc.depth; |
| 816 | header.mipMapCount = textureDesc.mipLevels; |
| 817 | header.ddspf.size = sizeof(DDS_PIXELFORMAT); |
| 818 | header.ddspf.flags = DDS_FOURCC; |
| 819 | header.ddspf.fourCC = MAKEFOURCC('D', 'X', '1', '0'); |
| 820 | |
| 821 | switch (textureDesc.dimension) |
| 822 | { |
| 823 | case nvrhi::TextureDimension::Texture1D: |
| 824 | case nvrhi::TextureDimension::Texture1DArray: |
| 825 | dx10header.resourceDimension = DDS_DIMENSION_TEXTURE1D; |
| 826 | break; |
| 827 | |
| 828 | case nvrhi::TextureDimension::Texture2D: |
| 829 | case nvrhi::TextureDimension::Texture2DArray: |
| 830 | case nvrhi::TextureDimension::TextureCube: |
| 831 | case nvrhi::TextureDimension::TextureCubeArray: |
| 832 | dx10header.resourceDimension = DDS_DIMENSION_TEXTURE2D; |
| 833 | break; |
| 834 | |
| 835 | case nvrhi::TextureDimension::Texture3D: |
| 836 | // Unsupported |
| 837 | return nullptr; |
| 838 | /*header.flags |= DDS_HEADER_FLAGS_VOLUME; |
| 839 | dx10header.resourceDimension = DDS_DIMENSION_TEXTURE3D; |
| 840 | break;*/ |
| 841 | |
| 842 | case nvrhi::TextureDimension::Texture2DMS: |
| 843 | case nvrhi::TextureDimension::Texture2DMSArray: |
| 844 | case nvrhi::TextureDimension::Unknown: |
| 845 | // Unsupported |
| 846 | return nullptr; |
| 847 | } |
| 848 | |
| 849 | dx10header.arraySize = textureDesc.arraySize; |
| 850 | if (textureDesc.dimension == nvrhi::TextureDimension::TextureCube || textureDesc.dimension == nvrhi::TextureDimension::TextureCubeArray) |
| 851 | { |
| 852 | dx10header.arraySize /= 6; |
| 853 | dx10header.miscFlag |= D3D11_RESOURCE_MISC_TEXTURECUBE; |
| 854 | } |
| 855 | |
| 856 | for (const FormatMapping& mapping : g_FormatMappings) |
| 857 | { |
| 858 | if (mapping.nvrhiFormat == textureDesc.format) |
| 859 | { |
| 860 | dx10header.dxgiFormat = mapping.dxgiFormat; |
| 861 | break; |
| 862 | } |
nothing calls this directly
no test coverage detected