@@ -20,7 +20,7 @@ bool GSTexture::Save(const std::string& fn)
2020{
2121 // Depth textures need special treatment - we have a stencil component.
2222 // Just re-use the existing conversion shader instead.
23- if (m_format == Format::DepthStencil)
23+ if (m_format == Format::DepthStencil || m_format == Format::Float32 )
2424 {
2525 GSTexture* temp = g_gs_device->CreateRenderTarget (GetWidth (), GetHeight (), Format::Color, false );
2626 if (!temp)
@@ -63,23 +63,40 @@ bool GSTexture::Save(const std::string& fn)
6363
6464const char * GSTexture::GetFormatName (Format format)
6565{
66- static constexpr const char * format_names[] = {
67- " Invalid" ,
68- " Color" ,
69- " ColorHQ" ,
70- " ColorHDR" ,
71- " ColorClip" ,
72- " DepthStencil" ,
73- " UNorm8" ,
74- " UInt16" ,
75- " UInt32" ,
76- " PrimID" ,
77- " BC1" ,
78- " BC2" ,
79- " BC3" ,
80- " BC7" ,
81- };
82- return format_names[(static_cast <u32 >(format) < std::size (format_names)) ? static_cast <u32 >(format) : 0 ];
66+ switch (format)
67+ {
68+ default :
69+ pxFailRel (" Invalid texture format" );
70+ case Format::Invalid: return " Invalid" ;
71+ case Format::Color: return " Color" ;
72+ case Format::ColorHQ: return " ColorHQ" ;
73+ case Format::ColorHDR: return " ColorHDR" ;
74+ case Format::ColorClip: return " ColorClip" ;
75+ case Format::DepthStencil: return " DepthStencil" ;
76+ case Format::Float32: return " Float32" ;
77+ case Format::UNorm8: return " UNorm8" ;
78+ case Format::UInt16: return " UInt16" ;
79+ case Format::UInt32: return " UInt32" ;
80+ case Format::PrimID: return " PrimID" ;
81+ case Format::BC1: return " BC1" ;
82+ case Format::BC2: return " BC2" ;
83+ case Format::BC3: return " BC3" ;
84+ case Format::BC7: return " BC7" ;
85+ }
86+ }
87+
88+ bool GSTexture::IsBlockCompressedFormat (Format format)
89+ {
90+ switch (format)
91+ {
92+ case Format::BC1:
93+ case Format::BC2:
94+ case Format::BC3:
95+ case Format::BC7:
96+ return true ;
97+ default :
98+ return false ;
99+ }
83100}
84101
85102u32 GSTexture::GetCompressedBytesPerBlock () const
@@ -89,24 +106,26 @@ u32 GSTexture::GetCompressedBytesPerBlock() const
89106
90107u32 GSTexture::GetCompressedBytesPerBlock (Format format)
91108{
92- static constexpr u32 bytes_per_block[] = {
93- 1 , // Invalid
94- 4 , // Color/RGBA8
95- 4 , // ColorHQ/RGB10A2
96- 8 , // ColorHDR/RGBA16F
97- 8 , // ColorClip/RGBA16
98- 4 , // DepthStencil
99- 1 , // UNorm8/R8
100- 2 , // UInt16/R16UI
101- 4 , // UInt32/R32UI
102- 4 , // Int32/R32I
103- 8 , // BC1 - 16 pixels in 64 bits
104- 16 , // BC2 - 16 pixels in 128 bits
105- 16 , // BC3 - 16 pixels in 128 bits
106- 16 , // BC7 - 16 pixels in 128 bits
107- };
108-
109- return bytes_per_block[static_cast <u32 >(format)];
109+ switch (format)
110+ {
111+ default :
112+ pxFailRel (" Invalid texture format" );
113+ case Format::Invalid: return 1 ; // Invalid
114+ case Format::Color: return 4 ; // Color/RGBA8
115+ case Format::ColorHQ: return 4 ; // ColorHQ/RGB10A2
116+ case Format::ColorHDR: return 8 ; // ColorHDR/RGBA16F
117+ case Format::ColorClip: return 8 ; // ColorClip/RGBA16
118+ case Format::DepthStencil: return 4 ; // DepthStencil
119+ case Format::Float32: return 4 ; // Float32/R32
120+ case Format::UNorm8: return 1 ; // UNorm8/R8
121+ case Format::UInt16: return 2 ; // UInt16/R16UI
122+ case Format::UInt32: return 4 ; // UInt32/R32UI
123+ case Format::PrimID: return 4 ; // Int32/R32I
124+ case Format::BC1: return 8 ; // BC1 - 16 pixels in 64 bits
125+ case Format::BC2: return 16 ; // BC2 - 16 pixels in 128 bits
126+ case Format::BC3: return 16 ; // BC3 - 16 pixels in 128 bits
127+ case Format::BC7: return 16 ; // BC7 - 16 pixels in 128 bits
128+ }
110129}
111130
112131u32 GSTexture::GetCompressedBlockSize () const
@@ -116,10 +135,7 @@ u32 GSTexture::GetCompressedBlockSize() const
116135
117136u32 GSTexture::GetCompressedBlockSize (Format format)
118137{
119- if (format >= Format::BC1 && format <= Format::BC7)
120- return 4 ;
121- else
122- return 1 ;
138+ return IsBlockCompressedFormat (format) ? 4 : 1 ;
123139}
124140
125141u32 GSTexture::CalcUploadPitch (Format format, u32 width)
0 commit comments