mirror of https://github.com/AxioDL/boo.git
Add DXT3 texture format
This commit is contained in:
parent
66cf60ea55
commit
af50240143
|
@ -47,7 +47,7 @@ protected:
|
|||
enum class TextureType { Static, StaticArray, Dynamic, Render };
|
||||
|
||||
/** Supported texture formats */
|
||||
enum class TextureFormat { RGBA8, I8, I16, DXT1, PVRTC4 };
|
||||
enum class TextureFormat { RGBA8, I8, I16, DXT1, DXT3, PVRTC4 };
|
||||
|
||||
/** Supported texture clamp modes */
|
||||
enum class TextureClampMode { Invalid = -1, Repeat, ClampToWhite, ClampToBlack, ClampToEdge, ClampToEdgeNearest };
|
||||
|
|
|
@ -160,6 +160,12 @@ class D3D11TextureS : public GraphicsDataNode<ITextureS> {
|
|||
pxPitchNum = 1;
|
||||
pxPitchDenom = 2;
|
||||
break;
|
||||
case TextureFormat::DXT3:
|
||||
pfmt = DXGI_FORMAT_BC2_UNORM;
|
||||
compressed = true;
|
||||
pxPitchNum = 1;
|
||||
pxPitchDenom = 1;
|
||||
break;
|
||||
default:
|
||||
Log.report(logvisor::Fatal, "unsupported tex format");
|
||||
}
|
||||
|
|
|
@ -298,6 +298,12 @@ class GLTextureS : public GraphicsDataNode<ITextureS> {
|
|||
case TextureFormat::DXT1:
|
||||
intFormat = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
|
||||
compressed = true;
|
||||
pxPitch = 2;
|
||||
break;
|
||||
case TextureFormat::DXT3:
|
||||
intFormat = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT;
|
||||
compressed = true;
|
||||
pxPitch = 1;
|
||||
break;
|
||||
default:
|
||||
Log.report(logvisor::Fatal, "unsupported tex format");
|
||||
|
@ -305,7 +311,7 @@ class GLTextureS : public GraphicsDataNode<ITextureS> {
|
|||
|
||||
if (compressed) {
|
||||
for (size_t i = 0; i < mips; ++i) {
|
||||
size_t dataSz = width * height / 2;
|
||||
size_t dataSz = width * height / pxPitch;
|
||||
glCompressedTexImage2D(GL_TEXTURE_2D, i, intFormat, width, height, 0, dataSz, dataIt);
|
||||
dataIt += dataSz;
|
||||
if (width > 1)
|
||||
|
|
|
@ -256,6 +256,13 @@ class MetalTextureS : public GraphicsDataNode<ITextureS> {
|
|||
ppitchNum = 1;
|
||||
ppitchDenom = 2;
|
||||
bytesPerRow = width * 8 / 4; // Metal wants this in blocks, not bytes
|
||||
break;
|
||||
case TextureFormat::DXT3:
|
||||
pfmt = MTLPixelFormatBC2_RGBA;
|
||||
ppitchNum = 1;
|
||||
ppitchDenom = 1;
|
||||
bytesPerRow = width * 16 / 4; // Metal wants this in blocks, not bytes
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1315,6 +1315,11 @@ class VulkanTextureS : public GraphicsDataNode<ITextureS> {
|
|||
m_pixelPitchNum = 1;
|
||||
m_pixelPitchDenom = 2;
|
||||
break;
|
||||
case TextureFormat::DXT3:
|
||||
pfmt = VK_FORMAT_BC2_UNORM_BLOCK;
|
||||
m_pixelPitchNum = 1;
|
||||
m_pixelPitchDenom = 1;
|
||||
break;
|
||||
default:
|
||||
Log.report(logvisor::Fatal, "unsupported tex format");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue