X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit%2Fdali-toolkit-test-utils%2Ftest-graphics-controller.h;h=cabc414740955c4532831101a6ae7649681235e0;hb=6a219d0bbcfd016e24b5466d5fb1a666c92feae5;hp=120f9844242895e9a1a246c3609ddd1e0fa0756c;hpb=c3d722a71a109cd8bd9820451ff999b5b327812e;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-controller.h b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-controller.h index 120f984..cabc414 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-controller.h +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-controller.h @@ -20,7 +20,10 @@ #include #include "test-gl-abstraction.h" #include "test-gl-context-helper-abstraction.h" -#include "test-gl-sync-abstraction.h" +#include "test-graphics-command-buffer.h" +#include "test-graphics-program.h" +#include "test-graphics-reflection.h" +#include "test-graphics-sync-impl.h" namespace Dali { @@ -34,28 +37,75 @@ std::ostream& operator<<(std::ostream& o, Graphics::SamplerFilter filterMode); std::ostream& operator<<(std::ostream& o, Graphics::SamplerMipmapMode mipmapMode); std::ostream& operator<<(std::ostream& o, const Graphics::SamplerCreateInfo& createInfo); +template +T* Uncast(const Graphics::CommandBuffer* object) +{ + return const_cast(static_cast(object)); +} + +template +T* Uncast(const Graphics::Texture* object) +{ + return const_cast(static_cast(object)); +} + +template +T* Uncast(const Graphics::Sampler* object) +{ + return const_cast(static_cast(object)); +} + +template +T* Uncast(const Graphics::Buffer* object) +{ + return const_cast(static_cast(object)); +} + +template +T* Uncast(const Graphics::Shader* object) +{ + return const_cast(static_cast(object)); +} + +template +T* Uncast(const Graphics::Framebuffer* object) +{ + return const_cast(static_cast(object)); +} + +template +T* Uncast(const Graphics::Pipeline* object) +{ + return const_cast(static_cast(object)); +} + +template +T* Uncast(const Graphics::RenderTarget* object) +{ + return const_cast(static_cast(object)); +} + +template +T* Uncast(const Graphics::SyncObject* object) +{ + return const_cast(static_cast(object)); +} + class TestGraphicsController : public Dali::Graphics::Controller { public: - TestGraphicsController() - { - } + TestGraphicsController(); virtual ~TestGraphicsController() = default; void Initialize() { - mGlAbstraction.Initialize(); + mGl.Initialize(); } Integration::GlAbstraction& GetGlAbstraction() override { - return mGlAbstraction; - } - - Integration::GlSyncAbstraction& GetGlSyncAbstraction() override - { - return mGlSyncAbstraction; + return mGl; } Integration::GlContextHelperAbstraction& GetGlContextHelperAbstraction() override @@ -63,38 +113,43 @@ public: return mGlContextHelperAbstraction; } - void SubmitCommandBuffers(const Graphics::SubmitInfo& submitInfo) override + TestGraphicsSyncImplementation& GetGraphicsSyncImpl() { + return mGraphicsSyncImpl; } + void SubmitCommandBuffers(const Graphics::SubmitInfo& submitInfo) override; + /** * @brief Presents render target * @param renderTarget render target to present */ - void PresentRenderTarget(Graphics::RenderTarget* renderTarget) override - { - } + void PresentRenderTarget(Graphics::RenderTarget* renderTarget) override; /** * @brief Waits until the GPU is idle */ - void WaitIdle() override - { - } + void WaitIdle() override; /** * @brief Lifecycle pause event */ - void Pause() override - { - } + void Pause() override; /** * @brief Lifecycle resume event */ - void Resume() override - { - } + void Resume() override; + + /** + * @brief Lifecycle shutdown event + */ + void Shutdown() override; + + /** + * @brief Lifecycle destroy event + */ + void Destroy() override; /** * @brief Executes batch update of textures @@ -110,40 +165,31 @@ public: * */ void UpdateTextures(const std::vector& updateInfoList, - const std::vector& sourceList) override - { - } + const std::vector& sourceList) override; + + /** + * Auto generates mipmaps for the texture + * @param[in] texture The texture + */ + void GenerateTextureMipmaps(const Graphics::Texture& texture) override; /** * TBD: do we need those functions in the new implementation? */ - bool EnableDepthStencilBuffer(bool enableDepth, bool enableStencil) override - { - return {}; - } + bool EnableDepthStencilBuffer(bool enableDepth, bool enableStencil) override; - void RunGarbageCollector(size_t numberOfDiscardedRenderers) override - { - } + void RunGarbageCollector(size_t numberOfDiscardedRenderers) override; - void DiscardUnusedResources() override - { - } + void DiscardUnusedResources() override; - bool IsDiscardQueueEmpty() override - { - return {}; - } + bool IsDiscardQueueEmpty() override; /** * @brief Test if the graphics subsystem has resumed & should force a draw * * @return true if the graphics subsystem requires a re-draw */ - bool IsDrawOnResumeRequired() override - { - return {}; - } + bool IsDrawOnResumeRequired() override; /** * @brief Creates new Buffer object @@ -159,10 +205,7 @@ public: * @param[in] bufferCreateInfo The valid BufferCreateInfo structure * @return pointer to the Buffer object */ - std::unique_ptr CreateBuffer(const Graphics::BufferCreateInfo& bufferCreateInfo, std::unique_ptr&& oldBuffer) override - { - return {}; - } + Graphics::UniquePtr CreateBuffer(const Graphics::BufferCreateInfo& bufferCreateInfo, Graphics::UniquePtr&& oldBuffer) override; /** * @brief Creates new CommandBuffer object @@ -170,10 +213,7 @@ public: * @param[in] bufferCreateInfo The valid BufferCreateInfo structure * @return pointer to the CommandBuffer object */ - std::unique_ptr CreateCommandBuffer(const Graphics::CommandBufferCreateInfo& commandBufferCreateInfo, std::unique_ptr&& oldCommandBuffer) override - { - return {}; - } + Graphics::UniquePtr CreateCommandBuffer(const Graphics::CommandBufferCreateInfo& commandBufferCreateInfo, Graphics::UniquePtr&& oldCommandBuffer) override; /** * @brief Creates new RenderPass object @@ -181,10 +221,7 @@ public: * @param[in] renderPassCreateInfo The valid RenderPassCreateInfo structure * @return pointer to the RenderPass object */ - std::unique_ptr CreateRenderPass(const Graphics::RenderPassCreateInfo& renderPassCreateInfo, std::unique_ptr&& oldRenderPass) override - { - return {}; - } + Graphics::UniquePtr CreateRenderPass(const Graphics::RenderPassCreateInfo& renderPassCreateInfo, Graphics::UniquePtr&& oldRenderPass) override; /** * @brief Creates new Texture object @@ -192,10 +229,7 @@ public: * @param[in] textureCreateInfo The valid TextureCreateInfo structure * @return pointer to the TextureCreateInfo object */ - std::unique_ptr CreateTexture(const Graphics::TextureCreateInfo& textureCreateInfo, std::unique_ptr&& oldTexture) override - { - return {}; - } + Graphics::UniquePtr CreateTexture(const Graphics::TextureCreateInfo& textureCreateInfo, Graphics::UniquePtr&& oldTexture) override; /** * @brief Creates new Framebuffer object @@ -203,10 +237,7 @@ public: * @param[in] framebufferCreateInfo The valid FramebufferCreateInfo structure * @return pointer to the Framebuffer object */ - std::unique_ptr CreateFramebuffer(const Graphics::FramebufferCreateInfo& framebufferCreateInfo, std::unique_ptr&& oldFramebuffer) override - { - return {}; - } + Graphics::UniquePtr CreateFramebuffer(const Graphics::FramebufferCreateInfo& framebufferCreateInfo, Graphics::UniquePtr&& oldFramebuffer) override; /** * @brief Creates new Pipeline object @@ -214,10 +245,15 @@ public: * @param[in] pipelineCreateInfo The valid PipelineCreateInfo structure * @return pointer to the Pipeline object */ - std::unique_ptr CreatePipeline(const Graphics::PipelineCreateInfo& pipelineCreateInfo, std::unique_ptr&& oldPipeline) override - { - return {}; - } + Graphics::UniquePtr CreatePipeline(const Graphics::PipelineCreateInfo& pipelineCreateInfo, Graphics::UniquePtr&& oldPipeline) override; + + /** + * @brief Creates new Program object + * + * @param[in] programCreateInfo The valid ProgramCreateInfo structure + * @return pointer to the Program object + */ + Graphics::UniquePtr CreateProgram(const Graphics::ProgramCreateInfo& programCreateInfo, Graphics::UniquePtr&& oldProgram) override; /** * @brief Creates new Shader object @@ -225,10 +261,7 @@ public: * @param[in] shaderCreateInfo The valid ShaderCreateInfo structure * @return pointer to the Shader object */ - std::unique_ptr CreateShader(const Graphics::ShaderCreateInfo& shaderCreateInfo, std::unique_ptr&& oldShader) override - { - return {}; - } + Graphics::UniquePtr CreateShader(const Graphics::ShaderCreateInfo& shaderCreateInfo, Graphics::UniquePtr&& oldShader) override; /** * @brief Creates new Sampler object @@ -236,10 +269,7 @@ public: * @param[in] samplerCreateInfo The valid SamplerCreateInfo structure * @return pointer to the Sampler object */ - std::unique_ptr CreateSampler(const Graphics::SamplerCreateInfo& samplerCreateInfo, std::unique_ptr&& oldSampler) override - { - return {}; - } + Graphics::UniquePtr CreateSampler(const Graphics::SamplerCreateInfo& samplerCreateInfo, Graphics::UniquePtr&& oldSampler) override; /** * @brief Creates new RenderTarget object @@ -247,22 +277,25 @@ public: * @param[in] renderTargetCreateInfo The valid RenderTargetCreateInfo structure * @return pointer to the RenderTarget object */ - std::unique_ptr CreateRenderTarget(const Graphics::RenderTargetCreateInfo& renderTargetCreateInfo, std::unique_ptr&& oldRenderTarget) override - { - return {}; - } + Graphics::UniquePtr CreateRenderTarget(const Graphics::RenderTargetCreateInfo& renderTargetCreateInfo, Graphics::UniquePtr&& oldRenderTarget) override; + + /** + * @brief Creates new sync object + * Could add timeout etc to createinfo... but nah. + * + * @return pointer to the SyncObject + */ + Graphics::UniquePtr CreateSyncObject(const Graphics::SyncObjectCreateInfo& syncObjectCreateInfo, + Graphics::UniquePtr&& oldSyncObject) override; /** * @brief Maps memory associated with Buffer object * * @param[in] mapInfo Filled details of mapped resource * - * @return Returns pointer to Memory object or Graphicsnullptr on error + * @return Returns pointer to Memory object or nullptr on error */ - std::unique_ptr MapBufferRange(const Graphics::MapBufferInfo& mapInfo) override - { - return {}; - } + Graphics::UniquePtr MapBufferRange(const Graphics::MapBufferInfo& mapInfo) override; /** * @brief Maps memory associated with the texture. @@ -278,10 +311,7 @@ public: * * @return Valid Memory object or nullptr on error */ - std::unique_ptr MapTextureRange(const Graphics::MapTextureInfo& mapInfo) override - { - return {}; - } + Graphics::UniquePtr MapTextureRange(const Graphics::MapTextureInfo& mapInfo) override; /** * @brief Unmaps memory and discards Memory object @@ -291,9 +321,7 @@ public: * * @param[in] memory Valid and previously mapped Memory object */ - void UnmapMemory(std::unique_ptr memory) override - { - } + void UnmapMemory(Graphics::UniquePtr memory) override; /** * @brief Returns memory requirements of the Texture object. @@ -304,10 +332,7 @@ public: * * @return Returns memory requirements of Texture */ - Graphics::MemoryRequirements GetTextureMemoryRequirements(Graphics::Texture& texture) const override - { - return {}; - } + Graphics::MemoryRequirements GetTextureMemoryRequirements(Graphics::Texture& texture) const override; /** * @brief Returns memory requirements of the Buffer object. @@ -318,10 +343,7 @@ public: * * @return Returns memory requirements of Buffer */ - Graphics::MemoryRequirements GetBufferMemoryRequirements(Graphics::Buffer& buffer) const override - { - return {}; - } + Graphics::MemoryRequirements GetBufferMemoryRequirements(Graphics::Buffer& buffer) const override; /** * @brief Returns specification of the Texture object @@ -332,11 +354,15 @@ public: * * @return Returns the TextureProperties object */ - const Graphics::TextureProperties& GetTextureProperties(const Graphics::Texture& texture) override - { - static Graphics::TextureProperties properties{}; - return properties; - } + const Graphics::TextureProperties& GetTextureProperties(const Graphics::Texture& texture) override; + + /** + * @brief Returns the reflection of the given program + * + * @param[in] program The program + * @return The reflection of the program + */ + const Graphics::Reflection& GetProgramReflection(const Graphics::Program& program) override; /** * @brief Tests whether two Pipelines are the same. @@ -345,19 +371,67 @@ public: * * @return true if pipeline objects match */ - bool PipelineEquals(const Graphics::Pipeline& pipeline0, const Graphics::Pipeline& pipeline1) const override + bool PipelineEquals(const Graphics::Pipeline& pipeline0, const Graphics::Pipeline& pipeline1) const override; + +public: // Test Functions + void SetVertexFormats(Property::Array& vfs) + { + mVertexFormats = vfs; + } + + void AddCustomUniforms(std::vector& customUniforms) + { + mCustomUniforms = customUniforms; + } + + void ClearSubmitStack() { - return {}; + mSubmitStack.clear(); } + /** + * @brief Retrieves program parameters + * + * This function can be used to retrieve data from internal implementation + * + * @param[in] program Valid program object + * @param[in] parameterId Integer parameter id + * @param[out] outData Pointer to output memory + * @return True on success + */ + bool GetProgramParameter(Graphics::Program& program, uint32_t parameterId, void* outData) override; + + void ProcessCommandBuffer(TestGraphicsCommandBuffer& commandBuffer); + + void BindPipeline(TestGraphicsPipeline* pipeline); + public: + mutable TraceCallStack mCallStack; + mutable TraceCallStack mCommandBufferCallStack; + mutable TraceCallStack mFrameBufferCallStack; + mutable std::vector mSubmitStack; - TestGlAbstraction mGlAbstraction; - TestGlSyncAbstraction mGlSyncAbstraction; + TestGlAbstraction mGl; + TestGraphicsSyncImplementation mGraphicsSyncImpl; TestGlContextHelperAbstraction mGlContextHelperAbstraction; bool isDiscardQueueEmptyResult{true}; bool isDrawOnResumeRequiredResult{true}; + + Property::Array mVertexFormats; + + struct ProgramCache + { + std::map> shaders; + TestGraphicsProgramImpl* programImpl; + }; + std::vector mProgramCache; + + struct PipelineCache + { + }; + + std::vector mCustomUniforms; }; } // namespace Dali