Optimized RenderTexture performance when using the FBO implementation by removing unnecessary context switches and flushing.

This commit is contained in:
binary1248 2018-02-28 19:54:02 +01:00 committed by Lukas Dürrenberger
parent c706f11f29
commit 0adde249ec
17 changed files with 755 additions and 247 deletions

View file

@ -296,7 +296,7 @@ public:
/// \return True if operation was successful, false otherwise
///
////////////////////////////////////////////////////////////
virtual bool setActive(bool active = true) = 0;
virtual bool setActive(bool active = true);
////////////////////////////////////////////////////////////
/// \brief Save the current OpenGL render states and matrices
@ -458,6 +458,7 @@ private:
{
enum {VertexCacheSize = 4};
bool enable; ///< Is the cache enabled?
bool glStatesSet; ///< Are our internal GL states set yet?
bool viewChanged; ///< Has the current view changed since last draw?
BlendMode lastBlendMode; ///< Cached blending mode
@ -473,6 +474,7 @@ private:
View m_defaultView; ///< Default view
View m_view; ///< Current view
StatesCache m_cache; ///< Render states cache
Uint64 m_id; ///< Unique number that identifies the RenderTarget
};
} // namespace sf

View file

@ -112,11 +112,26 @@ public:
////////////////////////////////////////////////////////////
/// \brief Get the currently active context
///
/// This function will only return sf::Context objects.
/// Contexts created e.g. by RenderTargets or for internal
/// use will not be returned by this function.
///
/// \return The currently active context or NULL if none is active
///
////////////////////////////////////////////////////////////
static const Context* getActiveContext();
////////////////////////////////////////////////////////////
/// \brief Get the currently active context's ID
///
/// The context ID is used to identify contexts when
/// managing unshareable OpenGL resources.
///
/// \return The active context's ID or 0 if no context is currently active
///
////////////////////////////////////////////////////////////
static Uint64 getActiveContextId();
////////////////////////////////////////////////////////////
/// \brief Construct a in-memory context
///

View file

@ -37,6 +37,8 @@ namespace sf
class Context;
typedef void(*ContextDestroyCallback)(void*);
////////////////////////////////////////////////////////////
/// \brief Base class for classes that require an OpenGL context
///
@ -57,6 +59,19 @@ protected:
////////////////////////////////////////////////////////////
~GlResource();
////////////////////////////////////////////////////////////
/// \brief Register a function to be called when a context is destroyed
///
/// This is used for internal purposes in order to properly
/// clean up OpenGL resources that cannot be shared between
/// contexts.
///
/// \param callback Function to be called when a context is destroyed
/// \param arg Argument to pass when calling the function
///
////////////////////////////////////////////////////////////
static void registerContextDestroyCallback(ContextDestroyCallback callback, void* arg);
////////////////////////////////////////////////////////////
/// \brief RAII helper class to temporarily lock an available context for use
///