mirror of https://github.com/AxioDL/boo.git
Add DXT5/BPTC (BC3/BC7) texture formats
This commit is contained in:
parent
56a6b06210
commit
217031ebb9
|
@ -48,7 +48,7 @@ protected:
|
||||||
enum class TextureType { Static, StaticArray, Dynamic, Render, CubeRender };
|
enum class TextureType { Static, StaticArray, Dynamic, Render, CubeRender };
|
||||||
|
|
||||||
/** Supported texture formats */
|
/** Supported texture formats */
|
||||||
enum class TextureFormat { RGBA8, I8, I16, DXT1, DXT3, PVRTC4 };
|
enum class TextureFormat { RGBA8, I8, I16, DXT1, DXT3, DXT5, BPTC };
|
||||||
|
|
||||||
/** Supported texture clamp modes */
|
/** Supported texture clamp modes */
|
||||||
enum class TextureClampMode { Invalid = -1, Repeat, ClampToWhite, ClampToBlack, ClampToEdge, ClampToEdgeNearest };
|
enum class TextureClampMode { Invalid = -1, Repeat, ClampToWhite, ClampToBlack, ClampToEdge, ClampToEdgeNearest };
|
||||||
|
|
|
@ -179,6 +179,20 @@ class D3D11TextureS : public GraphicsDataNode<ITextureS> {
|
||||||
pxPitchDenom = 1;
|
pxPitchDenom = 1;
|
||||||
pxTilePitch = 4;
|
pxTilePitch = 4;
|
||||||
break;
|
break;
|
||||||
|
case TextureFormat::DXT5:
|
||||||
|
pfmt = DXGI_FORMAT_BC3_UNORM;
|
||||||
|
compressed = true;
|
||||||
|
pxPitchNum = 1;
|
||||||
|
pxPitchDenom = 1;
|
||||||
|
pxTilePitch = 4;
|
||||||
|
break;
|
||||||
|
case TextureFormat::BPTC:
|
||||||
|
pfmt = DXGI_FORMAT_BC7_UNORM;
|
||||||
|
compressed = true;
|
||||||
|
pxPitchNum = 1;
|
||||||
|
pxPitchDenom = 1;
|
||||||
|
pxTilePitch = 4;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
Log.report(logvisor::Fatal, fmt("unsupported tex format"));
|
Log.report(logvisor::Fatal, fmt("unsupported tex format"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -335,6 +335,16 @@ class GLTextureS : public GraphicsDataNode<ITextureS> {
|
||||||
compressed = true;
|
compressed = true;
|
||||||
pxPitch = 1;
|
pxPitch = 1;
|
||||||
break;
|
break;
|
||||||
|
case TextureFormat::DXT5:
|
||||||
|
intFormat = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
|
||||||
|
compressed = true;
|
||||||
|
pxPitch = 1;
|
||||||
|
break;
|
||||||
|
case TextureFormat::BPTC:
|
||||||
|
intFormat = GL_COMPRESSED_RGBA_BPTC_UNORM_ARB;
|
||||||
|
compressed = true;
|
||||||
|
pxPitch = 1;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
Log.report(logvisor::Fatal, fmt("unsupported tex format"));
|
Log.report(logvisor::Fatal, fmt("unsupported tex format"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,7 +85,7 @@ class MetalDataFactoryImpl : public MetalDataFactory, public GraphicsDataFactory
|
||||||
ObjToken<ITextureD> m_gammaLUT;
|
ObjToken<ITextureD> m_gammaLUT;
|
||||||
ObjToken<IGraphicsBufferS> m_gammaVBO;
|
ObjToken<IGraphicsBufferS> m_gammaVBO;
|
||||||
ObjToken<IShaderDataBinding> m_gammaBinding;
|
ObjToken<IShaderDataBinding> m_gammaBinding;
|
||||||
|
|
||||||
void SetupGammaResources();
|
void SetupGammaResources();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -232,6 +232,18 @@ class MetalTextureS : public GraphicsDataNode<ITextureS> {
|
||||||
ppitchDenom = 1;
|
ppitchDenom = 1;
|
||||||
bytesPerRow = width * 16 / 4; // Metal wants this in blocks, not bytes
|
bytesPerRow = width * 16 / 4; // Metal wants this in blocks, not bytes
|
||||||
break;
|
break;
|
||||||
|
case TextureFormat::DXT5:
|
||||||
|
pfmt = MTLPixelFormatBC3_RGBA;
|
||||||
|
ppitchNum = 1;
|
||||||
|
ppitchDenom = 1;
|
||||||
|
bytesPerRow = width * 16 / 4; // Metal wants this in blocks, not bytes
|
||||||
|
break;
|
||||||
|
case TextureFormat::BPTC:
|
||||||
|
pfmt = MTLPixelFormatBC7_RGBAUnorm;
|
||||||
|
ppitchNum = 1;
|
||||||
|
ppitchDenom = 1;
|
||||||
|
bytesPerRow = width * 16 / 4; // Metal wants this in blocks, not bytes
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1977,10 +1989,10 @@ std::vector<uint8_t> MetalDataFactory::CompileMetal(const char* source, Pipeline
|
||||||
memcpy(ret.data() + 1, source, strSz);
|
memcpy(ret.data() + 1, source, strSz);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MetalDataFactoryImpl::SetupGammaResources() {
|
void MetalDataFactoryImpl::SetupGammaResources() {
|
||||||
m_hasTessellation = [m_ctx->m_dev supportsFeatureSet:MTLFeatureSet_macOS_GPUFamily1_v2];
|
m_hasTessellation = [m_ctx->m_dev supportsFeatureSet:MTLFeatureSet_macOS_GPUFamily1_v2];
|
||||||
|
|
||||||
commitTransaction([this](IGraphicsDataFactory::Context& ctx) {
|
commitTransaction([this](IGraphicsDataFactory::Context& ctx) {
|
||||||
auto vertexMetal = MetalDataFactory::CompileMetal(GammaVS, PipelineStage::Vertex);
|
auto vertexMetal = MetalDataFactory::CompileMetal(GammaVS, PipelineStage::Vertex);
|
||||||
auto vertexShader = ctx.newShaderStage(vertexMetal, PipelineStage::Vertex);
|
auto vertexShader = ctx.newShaderStage(vertexMetal, PipelineStage::Vertex);
|
||||||
|
|
|
@ -1383,6 +1383,16 @@ class VulkanTextureS : public GraphicsDataNode<ITextureS> {
|
||||||
m_pixelPitchNum = 1;
|
m_pixelPitchNum = 1;
|
||||||
m_pixelPitchDenom = 1;
|
m_pixelPitchDenom = 1;
|
||||||
break;
|
break;
|
||||||
|
case TextureFormat::DXT5:
|
||||||
|
pfmt = VK_FORMAT_BC3_UNORM_BLOCK;
|
||||||
|
m_pixelPitchNum = 1;
|
||||||
|
m_pixelPitchDenom = 1;
|
||||||
|
break;
|
||||||
|
case TextureFormat::BPTC:
|
||||||
|
pfmt = VK_FORMAT_BC7_UNORM_BLOCK;
|
||||||
|
m_pixelPitchNum = 1;
|
||||||
|
m_pixelPitchDenom = 1;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
Log.report(logvisor::Fatal, fmt("unsupported tex format"));
|
Log.report(logvisor::Fatal, fmt("unsupported tex format"));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue