| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238 |
- //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
- //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
- #pragma once
- #include "BsCorePrerequisites.h"
- #include "BsPixelUtil.h"
- #include "BsViewport.h"
- #include "BsCoreObject.h"
- #include "BsEvent.h"
- namespace BansheeEngine
- {
- /** @addtogroup RenderAPI
- * @{
- */
- /** Structure that contains information about what part of the texture represents the render surface. */
- struct BS_CORE_EXPORT RENDER_SURFACE_DESC
- {
- RENDER_SURFACE_DESC() { }
- HTexture texture;
- /** First face of the texture to bind (array index in texture arrays, or Z slice in 3D textures). */
- UINT32 face = 0;
- /**
- * Number of faces to bind (entries in a texture array, or Z slices in 3D textures). When zero the entire resource
- * will be bound.
- */
- UINT32 numFaces = 0;
- /** If the texture has multiple mips, which one to bind (only one can be bound for rendering). */
- UINT32 mipLevel = 0;
- };
- /**
- * @see RENDER_SURFACE_DESC
- *
- * @note References core textures instead of texture handles.
- */
- struct BS_CORE_EXPORT RENDER_SURFACE_CORE_DESC
- {
- RENDER_SURFACE_CORE_DESC() { }
- SPtr<TextureCore> texture;
- /** First face of the texture to bind (array index in texture arrays, or Z slice in 3D textures). */
- UINT32 face = 0;
- /**
- * Number of faces to bind (entries in a texture array, or Z slices in 3D textures). When zero the entire resource
- * will be bound.
- */
- UINT32 numFaces = 0;
- /** If the texture has multiple mips, which one to bind (only one can be bound for rendering). */
- UINT32 mipLevel = 0;
- };
- /** Contains various properties that describe a render target. */
- class BS_CORE_EXPORT RenderTargetProperties
- {
- public:
- RenderTargetProperties() { }
- virtual ~RenderTargetProperties() { }
- /**
- * Returns width of the render target, in pixels.
- *
- * @note Sim thread only.
- */
- UINT32 getWidth() const { return mWidth; }
- /**
- * Returns height of the render target, in pixels.
- *
- * @note Sim thread only.
- */
- UINT32 getHeight() const { return mHeight; }
- /** Gets the number of samples used for multisampling. (0 or 1 if multisampling is not used). */
- UINT32 getMultisampleCount() const { return mMultisampleCount; }
- /**
- * Returns true if the render target will wait for vertical sync before swapping buffers. This will eliminate
- * tearing but may increase input latency.
- */
- bool getVSync() const { return mVSync; }
- /**
- * Returns how often should the frame be presented in respect to display device refresh rate. Normal value is 1
- * where it will match the refresh rate. Higher values will decrease the frame rate (for example present interval of
- * 2 on 60Hz refresh rate will display at most 30 frames per second).
- */
- UINT32 getVSyncInterval() const { return mVSyncInterval; }
- /** Returns true if pixels written to the render target will be gamma corrected. */
- bool isHwGammaEnabled() const { return mHwGamma; }
- /**
- * Returns true if the render target can be used for rendering.
- *
- * @note Core thread only.
- */
- bool isActive() const { return mActive; }
- /**
- * Controls in what order is the render target rendered to compared to other render targets. Targets with higher
- * priority will be rendered before ones with lower priority.
- */
- INT32 getPriority() const { return mPriority; }
- /** Returns true if the render target is a render window. */
- bool isWindow() const { return mIsWindow; }
- /**
- * Does the texture need to be vertically flipped because of different screen space coordinate systems. (Determines
- * is origin top left or bottom left. Engine default is top left.)
- */
- bool requiresTextureFlipping() const { return mRequiresTextureFlipping; }
- protected:
- friend class RenderTargetCore;
- friend class RenderTarget;
- UINT32 mWidth = 0;
- UINT32 mHeight = 0;
- UINT32 mColorDepth = 32;
- INT32 mPriority = 0;
- UINT32 mVSyncInterval = 1;
- bool mActive = true;
- bool mHwGamma = false;
- bool mVSync = false;
- bool mRequiresTextureFlipping = false;
- bool mIsWindow = false;
- UINT32 mMultisampleCount = 0;
- };
- /**
- * Render target is a frame buffer or a texture that the render system renders the scene to.
- *
- * @note
- * Sim thread unless noted otherwise. Retrieve core implementation from getCore() for core thread only functionality.
- */
- class BS_CORE_EXPORT RenderTarget : public CoreObject
- {
- public:
- RenderTarget();
- virtual ~RenderTarget() { }
- /** Queries the render target for a custom attribute. This may be anything and is implementation specific. */
- virtual void getCustomAttribute(const String& name, void* pData) const;
- /**
- * @copydoc RenderTargetCore::setPriority
- *
- * @param[in] accessor Accessor on which will this command be queued for execution.
- */
- void setPriority(CoreAccessor& accessor, INT32 priority);
- /**
- * Returns properties that describe the render target.
- *
- * @note Sim thread only.
- */
- const RenderTargetProperties& getProperties() const;
- /** Retrieves a core implementation of a render target usable only from the core thread. */
- SPtr<RenderTargetCore> getCore() const;
- /**
- * Event that gets triggered whenever the render target is resized.
- *
- * @note Sim thread only.
- */
- mutable Event<void()> onResized;
- protected:
- friend class RenderTargetCore;
- /** Returns properties that describe the render target. */
- virtual const RenderTargetProperties& getPropertiesInternal() const = 0;
- };
- /** @} */
- /** @addtogroup RenderAPI-Internal
- * @{
- */
- /**
- * Provides access to internal render target implementation usable only from the core thread.
- *
- * @note Core thread only.
- */
- class BS_CORE_EXPORT RenderTargetCore : public CoreObjectCore
- {
- public:
- /** Frame buffer type when double-buffering is used. */
- enum FrameBuffer
- {
- FB_FRONT,
- FB_BACK,
- FB_AUTO
- };
- RenderTargetCore();
- virtual ~RenderTargetCore() { }
- /**
- * Sets a priority that determines in which orders the render targets the processed.
- *
- * @param[in] priority The priority. Higher value means the target will be rendered sooner.
- */
- void setPriority(INT32 priority);
- /** Swaps the frame buffers to display the next frame. */
- virtual void swapBuffers() {};
- /** Queries the render target for a custom attribute. This may be anything and is implementation specific. */
- virtual void getCustomAttribute(const String& name, void* pData) const;
- /** Returns properties that describe the render target. */
- const RenderTargetProperties& getProperties() const;
- protected:
- friend class RenderTarget;
- /** Returns properties that describe the render target. */
- virtual const RenderTargetProperties& getPropertiesInternal() const = 0;
- };
- /** @} */
- }
|