X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Fgraphics-api%2Fgraphics-command-buffer.h;h=800583fd0c93691147fd84e34a0664db6d24b4fd;hb=c8885de47e3bd416d70b824f336b69ec05464fb7;hp=0b818706c5ce641b7f79d4e3982f026d723520bc;hpb=8ab23366e8533beb2dc21cd66177780e93c62b9f;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/graphics-api/graphics-command-buffer.h b/dali/graphics-api/graphics-command-buffer.h index 0b81870..800583f 100644 --- a/dali/graphics-api/graphics-command-buffer.h +++ b/dali/graphics-api/graphics-command-buffer.h @@ -2,7 +2,7 @@ #define DALI_GRAPHICS_COMMAND_BUFFER_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,16 +21,15 @@ // INTERNAL INCLUDES #include "graphics-types.h" -namespace Dali -{ -namespace Graphics +namespace Dali::Graphics { class Buffer; class Pipeline; -class Texture; -class Sampler; class RenderTarget; class RenderPass; +class Sampler; +class SyncObject; +class Texture; /** * @brief Uniform buffer bindings. @@ -83,12 +82,48 @@ struct ClearValue } color; struct { - float depth; - uint32_t stencil; + float depth; // glClearDepthf + uint32_t stencil; // glClearStencil } depthStencil; }; }; +// Native rendering (using native APIs) + +enum class DrawNativeAPI +{ + GLES, + UNDEFINED +}; + +struct DrawNativeInfo +{ + DrawNativeAPI api; ///< API used by the callback + Dali::CallbackBase* callback; ///< Callback pointer + + /** + * The call allows binding the resource so they can be passed into the callback + * Each resource will pass API specific data (for example GL texture and buffer ids) + */ + Graphics::Texture** textureList; ///< Textures to be used by the call + uint32_t textureCount; ///< Number of texture used by the callback + Graphics::Buffer** bufferList; ///< Buffers to be used by the call + uint32_t bufferCount; ///< Number of buffers used by the callback + + /** + * The GLES api specific structure that stores pointers to objects to be filled when requested + * by caller. The structure cointains void* to avoid creating any complex constructors and keep + * the class trivial. + */ + struct GLESNativeInfo + { + void* eglSharedContextStoragePointer; ///< Indicates the storage object to pass the shared context, must be null if not in use + } glesNativeInfo; + + void* userData; ///< Data passed into the callback (unspecified type, callback should decode it) + void* reserved; ///< Reserved for internal use +}; + /** * @brief CommandBuffer contains a stream of commands to be executed * by the controller. @@ -112,9 +147,9 @@ public: * @param[in] buffers List of buffers to bind * @param[in] offsets List of offsets for each buffer */ - virtual void BindVertexBuffers(uint32_t firstBinding, - std::vector buffers, - std::vector offsets) = 0; + virtual void BindVertexBuffers(uint32_t firstBinding, + const std::vector& buffers, + const std::vector& offsets) = 0; /** * @brief Binds uniform buffers @@ -135,14 +170,14 @@ public: * * @param[in] textureBindings List of texture bindings */ - virtual void BindTextures(std::vector& textureBindings) = 0; + virtual void BindTextures(const std::vector& textureBindings) = 0; /** * @brief Binds samplers * * @param[in] samplerBindings List of sampler bindings */ - virtual void BindSamplers(std::vector& samplerBindings) = 0; + virtual void BindSamplers(const std::vector& samplerBindings) = 0; /** * @brief Binds buffer containing push constants @@ -179,15 +214,15 @@ public: * Calling EndRenderPass() is necessary to finalize the render pass. * * @param[in] renderPass valid render pass object - * @param[in] renderTarget valid render target - * @param[in] renderArea area to draw + * @param[in] renderTarget valid render target, must not be used when framebuffer set + * @param[in] renderArea area to draw (clear operation is affected) * @param[in] clearValues clear values (compatible with renderpass spec) */ virtual void BeginRenderPass( - RenderPass& renderPass, - RenderTarget& renderTarget, - Extent2D renderArea, - std::vector clearValues) = 0; + RenderPass* renderPass, + RenderTarget* renderTarget, + Rect2D renderArea, + const std::vector& clearValues) = 0; /** * @brief Ends current render pass @@ -197,8 +232,25 @@ public: * the Controller may use end RP marker in order to resolve resource * dependencies (for example, to know when target texture is ready * before passing it to another render pass). + * + * The caller may query the sync object to determine when this render + * pass has actually finished on the GPU. + * + * @param[in] syncObject If non-null, this object will ensure an + * appropriate fence sync object is created after the render pass is + * executed. + */ + virtual void EndRenderPass(Graphics::SyncObject* syncObject) = 0; + + /** + * @brief Executes a list of secondary command buffers + * + * The secondary command buffers will be executed as a part of a primary + * command buffer that calls this function. + * + * @param[in] commandBuffers List of buffers to execute */ - virtual void EndRenderPass() = 0; + virtual void ExecuteCommandBuffers(std::vector&& commandBuffers) = 0; /** * @brief Draw primitives @@ -250,6 +302,21 @@ public: uint32_t stride) = 0; /** + * @brief Draws using native API (via callback) + * + * DrawNative should be use in order to acquire direct access to the + * graphics API like GL. Upon command execution, the backend will + * invoke given callback and pass API-specific arguments (for example, + * the GL callback will receive EGL context used for rendering). + * + * The client side must make sure the callback is valid for the + * time of execution. + * + * @param[in] drawInfo NativeDrawInfo structure + */ + virtual void DrawNative(const DrawNativeInfo* drawInfo) = 0; + + /** * @brief Resets CommandBuffer * * This function resets the command buffer and discards all previously @@ -292,11 +359,82 @@ public: */ virtual void SetViewportEnable(bool value) = 0; + /** + * @brief Sets the color mask for all channels. + */ + virtual void SetColorMask(bool enabled) = 0; + + /** + * @brief Clears the stencil buffer (outside of BeginRenderPass) to the current stencil mask + */ + virtual void ClearStencilBuffer() = 0; + + /** + * @brief Clears the depth buffer (outside of BeginRenderPass) to the current depth mask + */ + virtual void ClearDepthBuffer() = 0; + + /** + * @brief Enable or disable the stencil test + * + * @param[in] stencilEnable whether stencil test should be enabled + */ + virtual void SetStencilTestEnable(bool stencilEnable) = 0; + + /** + * @brief The mask used for writing to the stencil buffer. + * + * It should be as wide as necessary for the stencil texture format. + * @param[in] writeMask The mask for wriing to / clearing the stencil buffer + */ + virtual void SetStencilWriteMask(uint32_t writeMask) = 0; + + /** + * @brief Setup the stencil function + * + * @param[in] compareOp How the stencil buffer, reference and compareMask are combined to determine whether to draw a pixel or not. + * @param[in] reference A reference value that is ANDed with the mask in the compare op. + * @param[in] compareMask The bitplanes from the stencil buffer that are active. + */ + virtual void SetStencilFunc(Graphics::CompareOp compareOp, + uint32_t reference, + uint32_t compareMask) = 0; + + /** + * @brief Set how subsequent draws will affect the stencil buffer. + * @param[in] failOp What happens to stencil buffer if drawing a pixel fails the stencil test + * @param[in] passOp What happens to stencil buffer if drawing a pixel passes stencil & depth test + * @param[in] depthFailOp What happens to stencil buffer if drawing a pixel passes stencil but fails depth test. + */ + virtual void SetStencilOp(Graphics::StencilOp failOp, + Graphics::StencilOp passOp, + Graphics::StencilOp depthFailOp) = 0; + + /** + * @brief Defines the comparison operator for passing the depth test. + * + * @param[in] compareOp The comparison operator + */ + virtual void SetDepthCompareOp(Graphics::CompareOp compareOp) = 0; + + /** + * @brief Enables depth testing + * + * @param[in] depthTestEnable True if depth testing will be enabled. + */ + virtual void SetDepthTestEnable(bool depthTestEnable) = 0; + + /** + * @brief Enables depth writing / clearing + * + * @param[in] depthWriteEnabled True if the depth buffer can be updated or cleared. + */ + virtual void SetDepthWriteEnable(bool depthWriteEnable) = 0; + protected: CommandBuffer(CommandBuffer&&) = default; CommandBuffer& operator=(CommandBuffer&&) = default; }; -} // Namespace Graphics -} // Namespace Dali +} // namespace Dali::Graphics #endif