mirror of
https://github.com/blawar/GLideN64.git
synced 2024-06-25 22:09:35 +00:00
Cache SpecialFeatures check
This commit is contained in:
parent
b49ee1dd8b
commit
18e9a73eba
|
@ -320,7 +320,7 @@ ShaderProgram * CombinerInfo::getTexrectCopyProgram()
|
|||
|
||||
bool CombinerInfo::isShaderCacheSupported() const
|
||||
{
|
||||
return config.generalEmulation.enableShadersStorage != 0 && gfxContext.isSupported(SpecialFeatures::ShaderProgramBinary);
|
||||
return config.generalEmulation.enableShadersStorage != 0 && Context::ShaderProgramBinary;
|
||||
}
|
||||
|
||||
void CombinerInfo::setPolygonMode(DrawingState _drawingState)
|
||||
|
|
|
@ -191,7 +191,7 @@ void DepthBuffer::setDepthAttachment(ObjectHandle _fbo, BufferTargetParam _targe
|
|||
params.attachment = bufferAttachment::DEPTH_ATTACHMENT;
|
||||
params.bufferHandle = _fbo;
|
||||
params.bufferTarget = _target;
|
||||
if (gfxContext.isSupported(SpecialFeatures::DepthFramebufferTextures)) {
|
||||
if (Context::DepthFramebufferTextures) {
|
||||
params.textureHandle = m_pDepthBufferTexture->name;
|
||||
params.textureTarget = config.video.multisampling != 0 ? textureTarget::TEXTURE_2D_MULTISAMPLE : textureTarget::TEXTURE_2D;
|
||||
} else {
|
||||
|
@ -206,7 +206,7 @@ void DepthBuffer::setDepthAttachment(ObjectHandle _fbo, BufferTargetParam _targe
|
|||
|
||||
void DepthBuffer::initDepthBufferTexture(FrameBuffer * _pBuffer)
|
||||
{
|
||||
if (gfxContext.isSupported(SpecialFeatures::DepthFramebufferTextures)) {
|
||||
if (Context::DepthFramebufferTextures) {
|
||||
if (m_pDepthBufferTexture == nullptr) {
|
||||
m_pDepthBufferTexture = textureCache().addFrameBufferTexture(config.video.multisampling != 0);
|
||||
_initDepthBufferTexture(_pBuffer, m_pDepthBufferTexture, config.video.multisampling != 0);
|
||||
|
@ -318,7 +318,7 @@ void DepthBuffer::activateDepthBufferTexture(FrameBuffer * _pBuffer)
|
|||
|
||||
void DepthBuffer::bindDepthImageTexture()
|
||||
{
|
||||
if (!gfxContext.isSupported(graphics::SpecialFeatures::ImageTextures))
|
||||
if (!Context::ImageTextures)
|
||||
return;
|
||||
|
||||
Context::BindImageTextureParameters bindParams;
|
||||
|
|
|
@ -310,7 +310,7 @@ bool FrameBuffer::isValid(bool _forceCheck) const
|
|||
|
||||
void FrameBuffer::resolveMultisampledTexture(bool _bForce)
|
||||
{
|
||||
if (!gfxContext.isSupported(SpecialFeatures::Multisampling))
|
||||
if (!Context::Multisampling)
|
||||
return;
|
||||
|
||||
if (m_resolved && !_bForce)
|
||||
|
@ -373,7 +373,7 @@ bool FrameBuffer::_initSubTexture(u32 _t)
|
|||
|
||||
CachedTexture * FrameBuffer::_getSubTexture(u32 _t)
|
||||
{
|
||||
if (!gfxContext.isSupported(SpecialFeatures::BlitFramebuffer))
|
||||
if (!Context::BlitFramebuffer)
|
||||
return m_pTexture;
|
||||
|
||||
if (!_initSubTexture(_t))
|
||||
|
@ -389,7 +389,7 @@ CachedTexture * FrameBuffer::_getSubTexture(u32 _t)
|
|||
copyHeight = m_pTexture->realHeight - y0;
|
||||
|
||||
ObjectHandle readFBO = m_FBO;
|
||||
if (gfxContext.isSupported(SpecialFeatures::WeakBlitFramebuffer) &&
|
||||
if (Context::WeakBlitFramebuffer &&
|
||||
m_pTexture->frameBufferTexture == CachedTexture::fbMultiSample) {
|
||||
resolveMultisampledTexture(true);
|
||||
readFBO = m_resolveFBO;
|
||||
|
@ -795,8 +795,8 @@ void FrameBufferList::attachDepthBuffer()
|
|||
pDepthBuffer->initDepthBufferTexture(pCurrent);
|
||||
|
||||
bool goodDepthBufferTexture = false;
|
||||
if (gfxContext.isSupported(SpecialFeatures::DepthFramebufferTextures)) {
|
||||
goodDepthBufferTexture = gfxContext.isSupported(SpecialFeatures::WeakBlitFramebuffer) ?
|
||||
if (Context::DepthFramebufferTextures) {
|
||||
goodDepthBufferTexture = Context::WeakBlitFramebuffer ?
|
||||
pDepthBuffer->m_pDepthBufferTexture->realWidth == pCurrent->m_pTexture->realWidth :
|
||||
pDepthBuffer->m_pDepthBufferTexture->realWidth >= pCurrent->m_pTexture->realWidth;
|
||||
} else {
|
||||
|
|
|
@ -5,6 +5,15 @@ using namespace graphics;
|
|||
|
||||
Context gfxContext;
|
||||
|
||||
bool Context::Multisampling = false;
|
||||
bool Context::BlitFramebuffer = false;
|
||||
bool Context::WeakBlitFramebuffer = false;
|
||||
bool Context::DepthFramebufferTextures = false;
|
||||
bool Context::ShaderProgramBinary = false;
|
||||
bool Context::ImageTextures = false;
|
||||
bool Context::IntegerTextures = false;
|
||||
bool Context::ClipControl = false;
|
||||
|
||||
Context::Context() {}
|
||||
|
||||
Context::~Context() {
|
||||
|
@ -17,6 +26,14 @@ void Context::init()
|
|||
m_impl.reset(new opengl::ContextImpl);
|
||||
m_impl->init();
|
||||
m_fbTexFormats.reset(m_impl->getFramebufferTextureFormats());
|
||||
Multisampling = m_impl->isSupported(SpecialFeatures::Multisampling);
|
||||
BlitFramebuffer = m_impl->isSupported(SpecialFeatures::BlitFramebuffer);
|
||||
WeakBlitFramebuffer = m_impl->isSupported(SpecialFeatures::WeakBlitFramebuffer);
|
||||
DepthFramebufferTextures = m_impl->isSupported(SpecialFeatures::DepthFramebufferTextures);
|
||||
ShaderProgramBinary = m_impl->isSupported(SpecialFeatures::ShaderProgramBinary);
|
||||
ImageTextures = m_impl->isSupported(SpecialFeatures::ImageTextures);
|
||||
IntegerTextures = m_impl->isSupported(SpecialFeatures::IntegerTextures);
|
||||
ClipControl = m_impl->isSupported(SpecialFeatures::ClipControl);
|
||||
}
|
||||
|
||||
void Context::destroy()
|
||||
|
@ -290,11 +307,6 @@ f32 Context::getMaxLineWidth()
|
|||
return m_impl->getMaxLineWidth();
|
||||
}
|
||||
|
||||
bool Context::isSupported(SpecialFeatures _feature) const
|
||||
{
|
||||
return m_impl->isSupported(_feature);
|
||||
}
|
||||
|
||||
bool Context::isError() const
|
||||
{
|
||||
return m_impl->isError();
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace graphics {
|
|||
DepthFramebufferTextures,
|
||||
ShaderProgramBinary,
|
||||
ImageTextures,
|
||||
LUTTextures,
|
||||
IntegerTextures,
|
||||
ClipControl
|
||||
};
|
||||
|
||||
|
@ -269,12 +269,19 @@ namespace graphics {
|
|||
|
||||
/*---------------Misc-------------*/
|
||||
|
||||
bool isSupported(SpecialFeatures _feature) const;
|
||||
|
||||
bool isError() const;
|
||||
|
||||
bool isFramebufferError() const;
|
||||
|
||||
static bool Multisampling;
|
||||
static bool BlitFramebuffer;
|
||||
static bool WeakBlitFramebuffer;
|
||||
static bool DepthFramebufferTextures;
|
||||
static bool ShaderProgramBinary;
|
||||
static bool ImageTextures;
|
||||
static bool IntegerTextures;
|
||||
static bool ClipControl;
|
||||
|
||||
private:
|
||||
std::unique_ptr<ContextImpl> m_impl;
|
||||
std::unique_ptr<FramebufferTextureFormats> m_fbTexFormats;
|
||||
|
|
|
@ -109,7 +109,7 @@ bool ShaderStorage::saveShadersStorage(const graphics::Combiners & _combiners) c
|
|||
// Created shaders are obsolete due to changes in config, but we saved combiners keys.
|
||||
return true;
|
||||
|
||||
if (!gfxContext.isSupported(graphics::SpecialFeatures::ShaderProgramBinary))
|
||||
if (!graphics::Context::ShaderProgramBinary)
|
||||
// Shaders storage is not supported, but we saved combiners keys.
|
||||
return true;
|
||||
|
||||
|
@ -262,7 +262,7 @@ bool ShaderStorage::_loadFromCombinerKeys(graphics::Combiners & _combiners)
|
|||
if (opengl::Utils::isGLError())
|
||||
return false;
|
||||
|
||||
if (gfxContext.isSupported(graphics::SpecialFeatures::ShaderProgramBinary))
|
||||
if (graphics::Context::ShaderProgramBinary)
|
||||
// Restore shaders storage
|
||||
return saveShadersStorage(_combiners);
|
||||
|
||||
|
@ -272,7 +272,7 @@ bool ShaderStorage::_loadFromCombinerKeys(graphics::Combiners & _combiners)
|
|||
|
||||
bool ShaderStorage::loadShadersStorage(graphics::Combiners & _combiners)
|
||||
{
|
||||
if (!gfxContext.isSupported(graphics::SpecialFeatures::ShaderProgramBinary))
|
||||
if (!graphics::Context::ShaderProgramBinary)
|
||||
// Shaders storage is not supported, load from combiners keys.
|
||||
return _loadFromCombinerKeys(_combiners);
|
||||
|
||||
|
|
|
@ -467,7 +467,7 @@ bool ContextImpl::isSupported(graphics::SpecialFeatures _feature) const
|
|||
return m_glInfo.shaderStorage;
|
||||
case graphics::SpecialFeatures::DepthFramebufferTextures:
|
||||
return m_glInfo.depthTexture;
|
||||
case graphics::SpecialFeatures::LUTTextures:
|
||||
case graphics::SpecialFeatures::IntegerTextures:
|
||||
return !m_glInfo.isGLES2;
|
||||
case graphics::SpecialFeatures::ClipControl:
|
||||
return !m_glInfo.isGLESX;
|
||||
|
|
|
@ -87,7 +87,7 @@ void GraphicsDrawer::addTriangle(int _v0, int _v1, int _v2)
|
|||
}
|
||||
}
|
||||
|
||||
if (!gfxContext.isSupported(SpecialFeatures::ClipControl)) {
|
||||
if (!Context::ClipControl) {
|
||||
if (GBI.isNoN() && gDP.otherMode.depthCompare == 0 && gDP.otherMode.depthUpdate == 0) {
|
||||
for (u32 i = firstIndex; i < triangles.num; ++i) {
|
||||
SPVertex & vtx = triangles.vertices[triangles.elements[i]];
|
||||
|
@ -990,7 +990,7 @@ bool texturedRectShadowMap(const GraphicsDrawer::TexturedRectParams &)
|
|||
if (gDP.textureImage.size == 2 && gDP.textureImage.address >= gDP.depthImageAddress &&
|
||||
gDP.textureImage.address < (gDP.depthImageAddress + gDP.colorImage.width*gDP.colorImage.width * 6 / 4)) {
|
||||
|
||||
if (!gfxContext.isSupported(SpecialFeatures::LUTTextures))
|
||||
if (!Context::IntegerTextures)
|
||||
return true;
|
||||
|
||||
pCurrentBuffer->m_pDepthBuffer->activateDepthBufferTexture(pCurrentBuffer);
|
||||
|
|
|
@ -19,7 +19,7 @@ PaletteTexture::PaletteTexture()
|
|||
|
||||
void PaletteTexture::init()
|
||||
{
|
||||
if (!gfxContext.isSupported(SpecialFeatures::LUTTextures))
|
||||
if (!Context::IntegerTextures)
|
||||
return;
|
||||
|
||||
const FramebufferTextureFormats & fbTexFormats = gfxContext.getFramebufferTextureFormats();
|
||||
|
@ -63,7 +63,7 @@ void PaletteTexture::init()
|
|||
|
||||
void PaletteTexture::destroy()
|
||||
{
|
||||
if (!gfxContext.isSupported(SpecialFeatures::LUTTextures))
|
||||
if (!Context::IntegerTextures)
|
||||
return;
|
||||
|
||||
const FramebufferTextureFormats & fbTexFormats = gfxContext.getFramebufferTextureFormats();
|
||||
|
@ -75,7 +75,7 @@ void PaletteTexture::destroy()
|
|||
|
||||
void PaletteTexture::update()
|
||||
{
|
||||
if (!gfxContext.isSupported(SpecialFeatures::LUTTextures))
|
||||
if (!Context::IntegerTextures)
|
||||
return;
|
||||
|
||||
if (m_paletteCRC256 == gDP.paletteCRC256)
|
||||
|
|
|
@ -500,7 +500,7 @@ void TextureCache::init()
|
|||
|
||||
|
||||
m_pMSDummy = nullptr;
|
||||
if (config.video.multisampling != 0 && gfxContext.isSupported(SpecialFeatures::Multisampling)) {
|
||||
if (config.video.multisampling != 0 && Context::Multisampling) {
|
||||
m_pMSDummy = addFrameBufferTexture(true); // we don't want to remove dummy texture
|
||||
_initDummyTexture(m_pMSDummy);
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ ZlutTexture::ZlutTexture()
|
|||
|
||||
void ZlutTexture::init()
|
||||
{
|
||||
if (!gfxContext.isSupported(SpecialFeatures::LUTTextures))
|
||||
if (!Context::IntegerTextures)
|
||||
return;
|
||||
|
||||
const FramebufferTextureFormats & fbTexFormats = gfxContext.getFramebufferTextureFormats();
|
||||
|
@ -62,7 +62,7 @@ void ZlutTexture::init()
|
|||
|
||||
void ZlutTexture::destroy()
|
||||
{
|
||||
if (!gfxContext.isSupported(SpecialFeatures::LUTTextures))
|
||||
if (!Context::IntegerTextures)
|
||||
return;
|
||||
|
||||
const FramebufferTextureFormats & fbTexFormats = gfxContext.getFramebufferTextureFormats();
|
||||
|
|
|
@ -2232,7 +2232,7 @@ void _copyDepthBuffer()
|
|||
if (!config.frameBufferEmulation.enable)
|
||||
return;
|
||||
|
||||
if (!gfxContext.isSupported(SpecialFeatures::BlitFramebuffer))
|
||||
if (!Context::BlitFramebuffer)
|
||||
return;
|
||||
|
||||
// The game copies content of depth buffer into current color buffer
|
||||
|
|
Loading…
Reference in New Issue
Block a user