mirror of
https://github.com/blawar/GLideN64.git
synced 2024-07-04 10:03:36 +00:00
Keep track of FB attachments
This commit is contained in:
parent
822b098d6a
commit
b81dd6a673
|
@ -77,10 +77,16 @@ private:
|
|||
class AddFramebufferTexture2D : public AddFramebufferRenderTarget
|
||||
{
|
||||
public:
|
||||
AddFramebufferTexture2D(CachedBindFramebuffer * _bind) : m_bind(_bind) {}
|
||||
AddFramebufferTexture2D(CachedBindFramebuffer * _bind, FramebufferAttachments * _fbattachments) : m_bind(_bind), m_fbattachments(_fbattachments) {}
|
||||
|
||||
void addFrameBufferRenderTarget(const graphics::Context::FrameBufferRenderTarget & _params) override
|
||||
{
|
||||
FramebufferAttachments::const_iterator iter = m_fbattachments->find(u32(_params.bufferHandle));
|
||||
if (iter != m_fbattachments->end() && iter->second == u32(_params.textureHandle))
|
||||
return;
|
||||
|
||||
(*m_fbattachments)[u32(_params.bufferHandle)] = u32(_params.textureHandle);
|
||||
|
||||
m_bind->bind(_params.bufferTarget, _params.bufferHandle);
|
||||
if (_params.textureTarget == graphics::textureTarget::RENDERBUFFER) {
|
||||
glFramebufferRenderbuffer(GLenum(_params.bufferTarget),
|
||||
|
@ -98,6 +104,7 @@ public:
|
|||
|
||||
private:
|
||||
CachedBindFramebuffer * m_bind;
|
||||
FramebufferAttachments * m_fbattachments;
|
||||
};
|
||||
|
||||
class AddNamedFramebufferTexture : public AddFramebufferRenderTarget
|
||||
|
@ -602,7 +609,7 @@ AddFramebufferRenderTarget * BufferManipulationObjectFactory::getAddFramebufferR
|
|||
if (AddNamedFramebufferTexture::Check(m_glInfo))
|
||||
return new AddNamedFramebufferTexture;
|
||||
|
||||
return new AddFramebufferTexture2D(m_cachedFunctions.getCachedBindFramebuffer());
|
||||
return new AddFramebufferTexture2D(m_cachedFunctions.getCachedBindFramebuffer(), m_cachedFunctions.getFBAttachments());
|
||||
}
|
||||
|
||||
BlitFramebuffers * BufferManipulationObjectFactory::getBlitFramebuffers() const
|
||||
|
|
|
@ -157,6 +157,7 @@ void CachedFunctions::reset()
|
|||
for (auto it : m_enables)
|
||||
it.second.reset();
|
||||
|
||||
m_fbattachments.clear();
|
||||
m_bindTexture.reset();
|
||||
m_bindFramebuffer.reset();
|
||||
m_bindRenderbuffer.reset();
|
||||
|
@ -260,3 +261,8 @@ CachedTextureUnpackAlignment * CachedFunctions::getCachedTextureUnpackAlignment(
|
|||
{
|
||||
return &m_unpackAlignment;
|
||||
}
|
||||
|
||||
FramebufferAttachments * CachedFunctions::getFBAttachments()
|
||||
{
|
||||
return &m_fbattachments;
|
||||
}
|
||||
|
|
|
@ -205,6 +205,8 @@ namespace opengl {
|
|||
void setTextureUnpackAlignment(s32 _param);
|
||||
};
|
||||
|
||||
typedef std::unordered_map<u32, u32> FramebufferAttachments;
|
||||
|
||||
/*---------------CachedFunctions-------------*/
|
||||
|
||||
class CachedFunctions
|
||||
|
@ -247,9 +249,12 @@ namespace opengl {
|
|||
|
||||
CachedTextureUnpackAlignment * getCachedTextureUnpackAlignment();
|
||||
|
||||
FramebufferAttachments * getFBAttachments();
|
||||
|
||||
private:
|
||||
typedef std::unordered_map<u32, CachedEnable> EnableParameters;
|
||||
|
||||
FramebufferAttachments m_fbattachments;
|
||||
EnableParameters m_enables;
|
||||
CachedBindTexture m_bindTexture;
|
||||
CachedBindFramebuffer m_bindFramebuffer;
|
||||
|
|
|
@ -251,6 +251,7 @@ void ContextImpl::deleteFramebuffer(graphics::ObjectHandle _name)
|
|||
if (fbo != 0) {
|
||||
glDeleteFramebuffers(1, &fbo);
|
||||
m_cachedFunctions->getCachedBindFramebuffer()->reset();
|
||||
m_cachedFunctions->getFBAttachments()->erase(u32(_name));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user